Socket
Socket
Sign inDemoInstall

@sanity/presentation

Package Overview
Dependencies
13
Maintainers
51
Versions
127
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.12.10 to 1.13.0

src/document/useCurrentPresentationToolName.ts

2

dist/_chunks-es/DisplayedDocumentBroadcaster.js

@@ -1,1 +0,1 @@

import{jsx as e}from"react/jsx-runtime";import r from"fast-deep-equal";import{createContext as t,useCallback as n,useEffect as o,useContext as u}from"react";const i=t(null);function c(t){const{children:u,setDisplayedDocument:c,documentId:m}=t,l=n((e=>c((t=>r(t,e)?t:e))),[c]);return o((()=>{if(m)return;const e=setTimeout((()=>c(null)));return()=>clearTimeout(e)}),[m,c]),e(i.Provider,{value:l,children:u})}function m(){return u(i)}export{c as D,m as u};//# sourceMappingURL=DisplayedDocumentBroadcaster.js.map
import{jsx as e}from"react/jsx-runtime";import r from"fast-deep-equal";import{createContext as t,useContext as n,useCallback as o,useEffect as u}from"react";const i=t(null);function c(t){const{children:n,setDisplayedDocument:c,documentId:m}=t,l=o((e=>c((t=>r(t,e)?t:e))),[c]);return u((()=>{if(m)return;const e=setTimeout((()=>c(null)));return()=>clearTimeout(e)}),[m,c]),e(i.Provider,{value:l,children:n})}function m(){return n(i)}export{c as D,m as u};//# sourceMappingURL=DisplayedDocumentBroadcaster.js.map

@@ -1,3 +0,3 @@

import{jsx as e,jsxs as t,Fragment as n}from"react/jsx-runtime";import{createContext as i,useState as o,useEffect as r,useContext as a,useCallback as s,createElement as c,useRef as l,useMemo as d,lazy as u,Suspense as p}from"react";import{useDocumentStore as m,defineDocumentFieldAction as h,useWorkspace as f,pathToString as v,isRecord as y,getPublishedId as g,definePlugin as w,isDocumentSchemaType as b}from"sanity";import{ComposeIcon as x,ChevronRightIcon as P,DesktopIcon as T,InfoOutlineIcon as I,WarningOutlineIcon as _,ErrorOutlineIcon as j,MasterDetailIcon as z}from"@sanity/icons";import{Card as S,Flex as A,Box as D,Text as B,Stack as O,rem as k}from"@sanity/ui";import{styled as C}from"styled-components";import{useIntentLink as E,useRouter as $,encodeJsonParams as H,route as L}from"sanity/router";import{isObservable as N,of as U}from"rxjs";import{uuid as M}from"@sanity/uuid";const R=x,q="presentation",F="Presentation",G="sanity/structure/comments",J="presentation",K=3e3,Q="2023-10-16",V=1e3,W=100,X=2048,Y=i(null),Z={locations:[]};const ee={1:"one",2:"two",3:"three",4:"four",5:"five",6:"six",7:"seven",8:"eight",9:"nine"},te={positive:I,caution:_,critical:j};function ne(i){const{documentId:l,options:d,schemaType:u,showPresentationTitle:p}=i,h=a(Y),{message:f,locations:v,tone:y}=function(e){const{id:t,locate:n,type:i}=e,a=m(),[s,c]=o(Z);return r((()=>{if(!n)return;const e=n({id:t,type:i},{documentStore:a}),o=(N(e)?e:U(e)).subscribe((e=>c(e||Z)));return()=>o.unsubscribe()}),[a,t,n,i]),s}({id:l,locate:d.locate,type:u.name}),g=(null==v?void 0:v.length)||0,[w,b]=o(!1),x=s((()=>b((e=>!e))),[]),T=f||(g?t(n,{children:["Used on ",ee[g]||g," ",e(n,1===g?{children:"page"}:{children:"pages"})]}):null);return 0!==g||T?e(S,{padding:1,radius:2,border:!0,tone:y,children:t("div",{style:{margin:-1},children:[!v&&t(A,{align:"flex-start",gap:3,padding:3,children:[y&&e(D,{flex:"none",children:e(B,{size:1,children:c(te[y])})}),e(D,{flex:1,children:t(B,{size:1,weight:"medium",children:[p&&t(n,{children:[d.title||F," · "]}),T]})})]}),v&&t(n,{children:[e(S,{as:"button",onClick:x,padding:3,radius:1,tone:"inherit",children:t(A,{gap:3,children:[e(D,{flex:"none",children:e(B,{size:1,children:e(P,{style:{transform:`rotate(${w?"90deg":0})`,transition:"transform 100ms ease-in-out"}})})}),e(D,{flex:1,children:t(B,{size:1,weight:"medium",children:[p&&t(n,{children:[d.title||F," · "]}),T]})})]})}),e(O,{hidden:!w,marginTop:1,space:1,children:v.map(((t,n)=>e(ie,{active:(d.name||q)===(null==h?void 0:h.name)&&t.href===(null==h?void 0:h.params.preview),documentId:l,documentType:u.name,node:t,toolName:d.name||q},n)))})]})]})}):null}function ie(n){const{documentId:i,documentType:o,node:r,active:l,toolName:d}=n,u=a(Y),p=null==u?void 0:u.navigate,m=E({intent:"edit",params:{id:i,type:o,mode:"presentation",presentation:d,...null==u?void 0:u.structureParams,preview:r.href}}),h=s((()=>{null==p||p({},{preview:r.href})}),[r.href,p]);return c(S,{...u?{}:m,as:u?"button":"a",key:r.href,onClick:h,padding:3,radius:1,pressed:l,tone:"inherit"},t(A,{gap:3,children:[e(D,{flex:"none",children:e(B,{size:1,children:e(T,{})})}),t(O,{flex:1,space:2,children:[e(B,{size:1,weight:"medium",children:r.title}),e(B,{muted:!0,size:1,textOverflow:"ellipsis",children:r.href})]})]}))}const oe=i(null),re=C(O)`
min-height: ${k(42)};
import{jsx as e,jsxs as t,Fragment as n}from"react/jsx-runtime";import{useState as i,useMemo as o,useEffect as r,createContext as s,useContext as a,useCallback as c,createElement as l,useRef as d,useLayoutEffect as u,lazy as p,Suspense as m}from"react";import{useDocumentStore as h,defineDocumentFieldAction as f,useWorkspace as v,pathToString as y,isRecord as g,getPublishedId as w,definePlugin as P,isDocumentSchemaType as x}from"sanity";import{ComposeIcon as b,InfoOutlineIcon as T,ChevronRightIcon as I,DesktopIcon as j,WarningOutlineIcon as $,ErrorOutlineIcon as _,MasterDetailIcon as z}from"@sanity/icons";import{Card as S,Flex as D,Box as A,Text as O,Spinner as k,Stack as C,rem as E}from"@sanity/ui";import{styled as R}from"styled-components";import{isObservable as B,of as N,map as U}from"rxjs";import{useIntentLink as H,useRouter as L,encodeJsonParams as M,route as Q}from"sanity/router";import{uuid as q}from"@sanity/uuid";const F=b,G="presentation",J="Presentation",K="sanity/structure/comments",V="presentation",W=3e3,X="2023-10-16",Y=1e3,Z=100,ee=2048,te={locations:[]};const ne=s(null);function ie(){const e=a(ne);if(!e)throw new Error("Presentation context is missing");return e}const oe={1:"one",2:"two",3:"three",4:"four",5:"five",6:"six",7:"seven",8:"eight",9:"nine"},re={positive:T,caution:$,critical:_};function se(o){const{documentId:r,isResolving:s,options:d,schemaType:u,showPresentationTitle:p}=o,{locations:m,message:h,tone:f}=o.state,v=(null==m?void 0:m.length)||0,y=a(ne),[g,w]=i(!1),P=c((()=>{v&&w((e=>!e))}),[v]),x=s?"Resolving locations...":h||(v?`Used on ${oe[v]||v} page${1===v?"":"s"}`:"Not used on any pages");return e(S,{padding:1,radius:2,border:!0,tone:f,children:t("div",{style:{margin:-1},children:[!m&&t(D,{align:"flex-start",gap:3,padding:3,children:[f&&e(A,{flex:"none",children:e(O,{size:1,children:l(re[f])})}),e(A,{flex:1,children:t(O,{size:1,weight:"medium",children:[p&&t(n,{children:[d.title||J," · "]}),x]})})]}),m&&t(n,{children:[e(S,{as:v?"button":void 0,onClick:P,padding:3,radius:1,tone:"inherit",children:t(D,{gap:3,children:[e(A,{flex:"none",children:s?e(k,{size:1}):e(O,{size:1,children:0===v?e(T,{}):e(I,{style:{transform:`rotate(${g?"90deg":0})`,transition:"transform 100ms ease-in-out"}})})}),e(A,{flex:1,children:t(O,{size:1,weight:"medium",children:[p&&t(n,{children:[d.title||J," · "]}),x]})})]})}),e(C,{hidden:!g,marginTop:1,space:1,children:m.map(((t,n)=>e(ae,{active:(d.name||G)===(null==y?void 0:y.name)&&t.href===(null==y?void 0:y.params.preview),documentId:r,documentType:u.name,node:t,toolName:d.name||G},n)))})]})]})})}function ae(n){const{documentId:i,documentType:o,node:r,active:s,toolName:d}=n,u=a(ne),p=d===function(){try{return ie().name}catch{return}}(),m=null==u?void 0:u.navigate,h=H({intent:"edit",params:{id:i,type:o,mode:"presentation",presentation:d,...null==u?void 0:u.structureParams,preview:r.href}}),f=c((()=>{null==m||m({},{preview:r.href})}),[r.href,m]);return l(S,{...p?{}:h,as:"a",key:r.href,onClick:p?f:h.onClick,padding:3,radius:1,pressed:s,tone:"inherit"},t(D,{gap:3,children:[e(A,{flex:"none",children:e(O,{size:1,children:e(j,{})})}),t(C,{flex:1,space:2,children:[e(O,{size:1,weight:"medium",children:r.title}),e(O,{muted:!0,size:1,textOverflow:"ellipsis",children:r.href})]})]}))}const ce=s(null),le=R(C)`
min-height: ${E(42)};

@@ -7,2 +7,2 @@ & + &:empty {

}
`;function ae(t){var n;const{documentId:i,options:o,schemaType:r}=t,s=a(oe);if(s&&s.options[0]!==o)return e(re,{marginBottom:5,space:5});const c=(null==(n=null==s?void 0:s.options)?void 0:n.length)||0;return e(re,{marginBottom:5,space:5,children:e(O,{space:2,children:null==s?void 0:s.options.map(((t,n)=>e(ne,{documentId:i,options:t,schemaType:r,showPresentationTitle:c>1},n)))})})}function se(t){const{children:n,options:i}=t,c=a(oe),u=null==c?void 0:c.register,[p,m]=o((()=>[])),h=s((e=>u?u(e):(m((t=>[e].concat(t))),()=>{m((t=>t.filter((t=>t!==e))))})),[u]),f=l(h);f.current=h;const v=d((()=>({options:(null==c?void 0:c.options)||p,register:h})),[p,c,h]);return r((()=>f.current(i)),[i]),e(oe.Provider,{value:v,children:n})}const ce=h({name:"presentation/openInStructure",useAction({documentId:e,documentType:t,path:n}){const i=f(),{navigateIntent:o}=$(),r=a(Y),s=d((()=>function(e,t,n){var i;const o=e.map((e=>{var i;return{tool:e,match:null==(i=e.canHandleIntent)?void 0:i.call(e,"edit",{id:t,type:n,mode:"structure"},{})}})),r=o.filter((e=>y(e.match)&&e.match.mode));return r.length>0?r[0].tool:null==(i=o.filter((e=>e.match))[0])?void 0:i.tool}(i.tools,e,t)),[e,t,i.tools]);return{type:"action",hidden:!r||n.length>0||!s,icon:(null==s?void 0:s.icon)||z,title:`Open in ${(null==s?void 0:s.title)||"Structure"}`,onAction(){o("edit",{id:e,type:t,mode:"structure",path:v(n)})},renderAsButton:!0}}});function le(e,t,n,i){const{id:o,mode:r,path:a,presentation:s,type:c,...l}=t;return"edit"===e&&o?{type:c||"*",id:g(o),path:a,_searchParams:Object.entries(l)}:"create"===e?(l.preview=l.preview||new URLSearchParams(window.location.search).get("preview")||"/",i&&"object"==typeof i&&(l.templateParams=H(i)),{type:c||"*",id:o||M(),_searchParams:Object.entries(l)}):{intent:e,params:t,payload:i}}const de=L.create("/",{__unsafe_disableScopedSearchParams:!0},[L.intents("/intent"),L.create(":type",[L.create(":id",[L.create(":path")])])]),ue=u((()=>import("./PresentationTool.js"))),pe=u((()=>import("./BroadcastDisplayedDocument.js"))),me=w((n=>{const i=n.name||q;return{document:{unstable_fieldActions:e=>[...e.filter((e=>e.name!==ce.name)),ce]},form:{components:{input:function(i){const o=i.value,r=null!=o&&o._id?g(null==o?void 0:o._id):void 0;return b(i.schemaType)?t(se,{options:n,children:[n.locate&&r&&e(ae,{documentId:r,options:n,schemaType:i.schemaType}),i.renderDefault(i),e(p,{children:e(pe,{value:o})},"broadcast-displayed-document")]}):i.renderDefault(i)}}},tools:[{icon:n.icon||R,name:i,title:n.title,component:ue,options:n,canHandleIntent:(e,t)=>"create"===e?function(e){return"type"in e&&(!("presentation"in e)||e.presentation===i)&&(!("template"in e)||{template:!0})}(t):"edit"===e&&function(e){return"type"in e&&"id"in e&&(!("presentation"in e)||e.presentation===i)&&(!("mode"in e)||{mode:e.mode===J})}(t),getIntentState:le,router:de}]}})),he=i(null);function fe(){const e=a(he);if(!e)throw new Error("Presentation navigate context is missing");return e}const ve=i(null);function ye(){const e=a(ve);if(!e)throw new Error("Presentation params context is missing");return e}export{Q as A,G as C,q as D,J as E,X as L,K as M,Y as P,he as a,ve as b,V as c,W as d,ye as e,me as p,fe as u};//# sourceMappingURL=index.js.map
`;function de(t){var n;const{documentId:s,options:c,schemaType:l}=t,d=a(ce),{state:u,status:p}=function(e){const{id:t,resolvers:n,type:s}=e,a=h(),[c,l]=i(te),d=n&&("function"==typeof n?n:n[s]),[u,p]=i(d?"resolving":"empty"),m=o((()=>{if(d){if("function"==typeof d){const e=d({id:t,type:s},{documentStore:a});return B(e)?e:N(e)}if("select"in d&&"resolve"in d){const e=`*[_id==$id][0]{${Object.entries(d.select).map((([e,t])=>`"${e}": ${t}`)).join(", ")}}`,n={id:t};return a.listenQuery(e,n,{perspective:"previewDrafts"}).pipe(U(d.resolve))}return N(d)}}),[a,t,d,s]);return r((()=>{const e=null==m?void 0:m.subscribe((e=>{l(e||te),p(e?"resolved":"empty")}));return()=>null==e?void 0:e.unsubscribe()}),[m]),{state:c,status:u}}({id:s,resolvers:(null==(n=c.resolve)?void 0:n.locations)||c.locate,type:l.name});if(d&&d.options[0]!==c||"empty"===p)return null;const m=(null==d?void 0:d.options)||[];return e(le,{marginBottom:5,space:5,children:e(C,{space:2,children:m.map(((t,n)=>e(se,{documentId:s,isResolving:"resolving"===p,options:t,schemaType:l,showPresentationTitle:m.length>1,state:u},n)))})})}function ue(t){const{children:n,options:r}=t,s=a(ce),l=null==s?void 0:s.register,[p,m]=i((()=>[])),h=c((e=>l?l(e):(m((t=>[e].concat(t))),()=>{m((t=>t.filter((t=>t!==e))))})),[l]),f=d(h);f.current=h;const v=o((()=>({options:(null==s?void 0:s.options)||p,register:h})),[p,s,h]);return u((()=>f.current(r)),[r]),e(ce.Provider,{value:v,children:n})}const pe=f({name:"presentation/openInStructure",useAction({documentId:e,documentType:t,path:n}){const i=v(),{navigateIntent:r}=L(),s=a(ne),c=o((()=>function(e,t,n){var i;const o=e.map((e=>{var i;return{tool:e,match:null==(i=e.canHandleIntent)?void 0:i.call(e,"edit",{id:t,type:n,mode:"structure"},{})}})),r=o.filter((e=>g(e.match)&&e.match.mode));return r.length>0?r[0].tool:null==(i=o.filter((e=>e.match))[0])?void 0:i.tool}(i.tools,e,t)),[e,t,i.tools]);return{type:"action",hidden:!s||n.length>0||!c,icon:(null==c?void 0:c.icon)||z,title:`Open in ${(null==c?void 0:c.title)||"Structure"}`,onAction(){r("edit",{id:e,type:t,mode:"structure",path:y(n)})},renderAsButton:!0}}});function me(e,t,n,i){const{id:o,mode:r,path:s,presentation:a,type:c,...l}=t;return"edit"===e&&o?{type:c||"*",id:w(o),path:s,_searchParams:Object.entries(l)}:"create"===e?(l.preview=l.preview||new URLSearchParams(window.location.search).get("preview")||"/",i&&"object"==typeof i&&(l.templateParams=M(i)),{type:c||"*",id:o||q(),_searchParams:Object.entries(l)}):{intent:e,params:t,payload:i}}const he=Q.create("/",{__unsafe_disableScopedSearchParams:!0},[Q.intents("/intent"),Q.create(":type",[Q.create(":id",[Q.create(":path")])])]),fe=p((()=>import("./PresentationTool.js"))),ve=p((()=>import("./BroadcastDisplayedDocument.js")));function ye(e){return e}function ge(e){return e}const we=P((n=>{var i;const o=n.name||G;"locate"in n&&console.warn("Presentation’s `locate` option is deprecated. Use `resolve.locations` instead.");const r=!!(null!=(i=n.resolve)&&i.locations||n.locate);return{document:{unstable_fieldActions:e=>[...e.filter((e=>e.name!==pe.name)),pe]},form:{components:{input:function(i){const o=i.value,s=null!=o&&o._id?w(null==o?void 0:o._id):void 0;return x(i.schemaType)?t(ue,{options:n,children:[r&&s&&e(de,{documentId:s,options:n,schemaType:i.schemaType}),i.renderDefault(i),e(m,{children:e(ve,{value:o})},"broadcast-displayed-document")]}):i.renderDefault(i)}}},tools:[{icon:n.icon||F,name:o,title:n.title,component:fe,options:n,canHandleIntent:(e,t)=>"create"===e?function(e){return"type"in e&&(!("presentation"in e)||e.presentation===o)&&(!("template"in e)||{template:!0})}(t):"edit"===e&&function(e){return"type"in e&&"id"in e&&(!("presentation"in e)||e.presentation===o)&&(!("mode"in e)||{mode:e.mode===V})}(t),getIntentState:me,router:he}]}})),Pe=s(null);function xe(){const e=a(Pe);if(!e)throw new Error("Presentation navigate context is missing");return e}const be=s(null);function Te(){const e=a(be);if(!e)throw new Error("Presentation params context is missing");return e}export{X as A,K as C,G as D,V as E,ee as L,W as M,Pe as P,be as a,ne as b,Y as c,Z as d,xe as e,Te as f,ye as g,ge as h,we as p,ie as u};//# sourceMappingURL=index.js.map

@@ -1,4 +0,14 @@

var e=Object.defineProperty,t=(t,n,r)=>(((t,n,r)=>{n in t?e(t,n,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[n]=r})(t,"symbol"!=typeof n?n+"":n,r),r);import{jsx as n,jsxs as r,Fragment as i}from"react/jsx-runtime";import{studioPath as o}from"@sanity/client/csm";import{Card as a,Flex as s,Container as c,Stack as l,Text as d,Inline as u,Box as p,Button as h,Code as f,Label as m,ErrorBoundary as v,TextInput as g,MenuItem as y,useToast as w,usePrefersReducedMotion as b,TooltipDelayGroupProvider as x,Tooltip as P,Switch as E,MenuButton as k,Menu as S,Spinner as I,BoundaryElementProvider as z}from"@sanity/ui";import{useContext as C,forwardRef as O,useCallback as R,useMemo as U,useState as $,useEffect as j,createContext as L,useLayoutEffect as T,useRef as D,memo as A,createElement as _,startTransition as W,useReducer as M,Suspense as N,lazy as F}from"react";import{useUnique as V,getPublishedId as B,useActiveWorkspace as K,useClient as q,useCurrentUser as G,Hotkeys as J,useProjectId as X,useDataset as H,useWorkspace as Z}from"sanity";import{StateLink as Q,useRouter as Y,decodeJsonParams as ee}from"sanity/router";import{PaneRouterContext as te,PaneLayout as ne,StructureToolProvider as re,DocumentListPane as ie,DocumentPane as oe,CommentsIntentProvider as ae}from"sanity/structure";import{styled as se}from"styled-components";import{P as ce,a as le,b as de,A as ue,M as pe,c as he,C as fe,E as me,D as ve}from"./index.js";import{D as ge}from"./DisplayedDocumentBroadcaster.js";import{ResetIcon as ye,LaunchIcon as we,CopyIcon as be,PanelLeftIcon as xe,RefreshIcon as Pe,ShareIcon as Ee,ChevronDownIcon as ke,CheckmarkIcon as Se,DesktopIcon as Ie,MobileDeviceIcon as ze,EditIcon as Ce,PublishIcon as Oe}from"@sanity/icons";import{hasSecretSearchParams as Re,setSecretSearchParams as Ue,withoutSecretSearchParams as $e}from"@sanity/preview-url-secret/without-secret-search-params";import{motion as je,MotionConfig as Le,AnimatePresence as Te}from"framer-motion";import{createPreviewSecret as De}from"@sanity/preview-url-secret/create-secret";import Ae from"fast-deep-equal";import{definePreviewUrl as _e}from"@sanity/preview-url-secret/define-preview-url";import{suspend as We}from"suspend-react";let Me;const Ne=new Uint8Array(16);function Fe(){if(!Me&&(Me=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!Me))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return Me(Ne)}const Ve=[];for(let e=0;e<256;++e)Ve.push((e+256).toString(16).slice(1));var Be={randomUUID:typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function Ke(e,t,n){if(Be.randomUUID&&!t&&!e)return Be.randomUUID();const r=(e=e||{}).random||(e.rng||Fe)();if(r[6]=15&r[6]|64,r[8]=63&r[8]|128,t){n=n||0;for(let e=0;e<16;++e)t[n+e]=r[e];return t}return function(e,t=0){return Ve[e[t+0]]+Ve[e[t+1]]+Ve[e[t+2]]+Ve[e[t+3]]+"-"+Ve[e[t+4]]+Ve[e[t+5]]+"-"+Ve[e[t+6]]+Ve[e[t+7]]+"-"+Ve[e[t+8]]+Ve[e[t+9]]+"-"+Ve[e[t+10]]+Ve[e[t+11]]+Ve[e[t+12]]+Ve[e[t+13]]+Ve[e[t+14]]+Ve[e[t+15]]}(r)}const qe=1e3,Ge=1e3,Je=500,Xe=["handshake/syn","handshake/syn-ack","handshake/ack"],He=e=>Xe.some((t=>t===e)),Ze=({data:e={}})=>"object"==typeof e&&null!==e&&!Array.isArray(e)&&!("domain"in e)&&["id","type","from","to"].every((t=>t in e))&&e.type.startsWith("handshake/");function Qe(e){const t=e.target,n=e.connectTo.map((e=>({buffer:[],config:e,id:"",handler:i,status:"connecting",interval:void 0,heartbeat:void 0})));function r(e){window.clearInterval(e.interval)}function i(e){const{data:t}=e;if(He(t.type)){const e=n.find((e=>e.config.id===t.from));e&&"handshake/syn-ack"===t.type&&(c(e,"connected"),l(e,"handshake/ack",{id:e.id}))}}const o=t=>{var r,i,o;const a=t.data;if(!He(a.type)&&n.find((e=>e.id===a.connectionId))){const t=n.find((e=>e.config.id===a.from));if(t){const n=[a.type,a.data];null==(i=(r=t.config).onEvent)||i.call(r,...n),null==(o=e.onEvent)||o.call(e,...n),d(t,"channel/response",{responseTo:a.id},!1)}}};function a(t){var r;if(Ze(t))console.error("Visual editing package mismatch detected! Please ensure you are using the latest version of Sanity Studio and any packages listed here:\nhttps://github.com/sanity-io/visual-editing");else if(function(t){const{data:r,origin:i}=t;return"sanity/channels"===r.domain&&r.to==e.id&&n.map((e=>e.config.id)).includes(r.from)&&"channel/response"!==r.type&&i===e.targetOrigin}(t)){const{data:e}=t;null==(r=n.find((t=>t.config.id===e.from)))||r.handler(t)}}function s(e){e.heartbeat&&window.clearInterval(e.heartbeat)}function c(t,n){var a,c,u;t.status=n,null==(c=(a=t.config).onStatusUpdate)||c.call(a,n,t.config.id),null==(u=e.onStatusUpdate)||u.call(e,n,t.config.id),"connecting"===n||"reconnecting"===n?(t.handler=i,s(t),function(e){e.id=Ke(),e.interval=window.setInterval((()=>{l(e,"handshake/syn",{id:e.id})}),Je)}(t)):"connected"===n?(t.handler=o,r(t),function(e){if(s(e),e.config.heartbeat){const t="number"==typeof e.config.heartbeat?e.config.heartbeat:Ge;e.heartbeat=window.setInterval((()=>{d(e,"channel/heartbeat")}),t)}}(t),function(e){const t=[...e.buffer];e.buffer.splice(0,e.buffer.length),t.forEach((({type:t,data:n})=>{d(e,t,n)}))}(t)):"disconnected"===n&&(t.id=null,t.handler=i,r(t),s(t))}function l(n,r,i){if(!n.id)throw new Error("No channel ID set");const o={connectionId:n.id,data:i,domain:"sanity/channels",from:e.id,id:Ke(),to:n.config.id,type:r};try{null==t||t.postMessage(o,{targetOrigin:"*"})}catch{throw new Error(`Failed to postMessage '${o.id}' on '${e.id}'`)}}function d(n,r,i,o=!0){const a=Ke();if("connecting"===n.status||"reconnecting"===n.status||"disconnected"===n.status)return void n.buffer.push({type:r,data:i});if(!n.id)throw new Error("No channel ID set");const s={connectionId:n.id,data:i,domain:"sanity/channels",from:e.id,id:a,to:n.config.id,type:r};if(o){const t=setTimeout((()=>{s.connectionId===n.id&&(window.removeEventListener("message",o,!1),"channel/heartbeat"!==r&&n.buffer.push({type:r,data:i}),c(n,"reconnecting"),console.warn(`Received no response to message '${s.type}' on client '${e.id}' (ID: '${s.id}').`))}),qe),o=e=>{var n;const{data:r}=e;"channel/response"===r.type&&null!=(n=r.data)&&n.responseTo&&r.data.responseTo===s.id&&(window.removeEventListener("message",o,!1),clearTimeout(t))};window.addEventListener("message",o,!1)}try{null==t||t.postMessage(s,{targetOrigin:e.targetOrigin})}catch{throw new Error(`Failed to postMessage '${s.id}' on client '${e.id}'`)}}return window.addEventListener("message",a,!1),n.forEach((e=>{c(e,"connecting")})),{destroy:function(){n.forEach((e=>{["disconnected"].includes(e.status)||(d(e,"channel/disconnect",{id:e.id},!1),c(e,"disconnected"))})),window.removeEventListener("message",a,!1),n.forEach((e=>{s(e),r(e)}))},send:function(e,t,r){(e?Array.isArray(e)?[...e]:[e]:n).forEach((e=>{const i=n.find((t=>t.config.id===e));if(!i)throw new Error("Invalid channel ID");d(i,t,r)}))}}}var Ye,et,tt,nt,rt=class extends Error{constructor(e){super(e[0].message),t(this,"issues"),this.name="ValiError",this.issues=e}};function it(e,t){return Array.isArray(e)?[void 0,e]:[e,t]}function ot(e,t,n,r,i){var o,a,s,c,l;const d=null!=(l=null!=(c=null!=(s=null!=(a=null!=(o=t.message)?o:function(e,t){var n;return null==(n=null==nt?void 0:nt.get(e))?void 0:n.get(t)}(n,i.lang))?a:e?(u=i.lang,null==tt?void 0:tt.get(u)):null)?s:null==r?void 0:r.message)?c:function(e){return null==et?void 0:et.get(e)}(i.lang))?l:i.message;var u;return"function"==typeof d?d(i):d}function at(e,t,n){return{typed:e,output:t,issues:n}}function st(e){let t=typeof e;return"object"===t&&(t=e?Object.getPrototypeOf(e).constructor.name:"null"),"string"===t?`"${e}"`:"number"===t||"bigint"===t||"boolean"===t?`${e}`:t}function ct(e,t,n){var r;const i=null!=(r=n.received)?r:st(n.input),o={reason:e.type,context:n.context.type,expected:n.context.expects,received:i,message:`Invalid ${n.label}: ${n.context.expects?`Expected ${n.context.expects} but r`:"R"}eceived ${i}`,input:n.input,requirement:n.context.requirement,path:n.path,lang:null==t?void 0:t.lang,abortEarly:null==t?void 0:t.abortEarly,abortPipeEarly:null==t?void 0:t.abortPipeEarly,skipPipe:null==t?void 0:t.skipPipe};return o.message=ot(!1,n.context,n.reference,t,o),o}function lt(e,t,n,r){if(e.pipe&&(null==n||!n.skipPipe))for(const i of e.pipe){const o=i._parse(t);if(o.issues){for(const t of o.issues){const i=ct(e,n,t);r?r.push(i):r=[i]}if(null!=n&&n.abortEarly||null!=n&&n.abortPipeEarly)break}else t=o.output}return at(!0,t,r)}function dt(e,t,n,r,i){var o,a;const s=st(n),c=null!=(o=null==i?void 0:i.expected)?o:e.expects,l={reason:null!=(a=null==i?void 0:i.reason)?a:"type",context:e.type,expected:c,received:s,message:`Invalid type: Expected ${c} but received ${s}`,input:n,path:null==i?void 0:i.path,issues:null==i?void 0:i.issues,lang:null==r?void 0:r.lang,abortEarly:null==r?void 0:r.abortEarly,abortPipeEarly:null==r?void 0:r.abortPipeEarly,skipPipe:null==r?void 0:r.skipPipe};return l.message=ot(!0,e,t,r,l),{typed:!1,output:n,issues:[l]}}function ut(e,t){return{...e,fallback:t,_parse(t,n){const r=e._parse(t,n);return r.issues?at(!0,function(e,t){return"function"==typeof e.fallback?e.fallback(t):e.fallback}(this,{input:t,issues:r.issues})):r}}}function pt(e,t,n,r){const[i,o,a]=function(e,t,n){if(!e||"object"==typeof e&&!Array.isArray(e)){const[r,i]=it(t,n);return[e,r,i]}const[r,i]=it(e,t);return[void 0,r,i]}(t,n,r);let s;return{type:"object",expects:"Object",async:!1,entries:e,rest:i,message:o,pipe:a,_parse(e,t){if(e&&"object"==typeof e){s=null!=s?s:Object.entries(this.entries);let n,r=!0;const i={};for(const[o,a]of s){const s=e[o],c=a._parse(s,t);if(c.issues){const i={type:"object",origin:"value",input:e,key:o,value:s};for(const e of c.issues)e.path?e.path.unshift(i):e.path=[i],null==n||n.push(e);if(n||(n=c.issues),null!=t&&t.abortEarly){r=!1;break}}c.typed||(r=!1),(void 0!==c.output||o in e)&&(i[o]=c.output)}if(this.rest&&(null==t||!t.abortEarly||!n))for(const o in e)if(!(o in this.entries)){const a=e[o],s=this.rest._parse(a,t);if(s.issues){const i={type:"object",origin:"value",input:e,key:o,value:a};for(const e of s.issues)e.path?e.path.unshift(i):e.path=[i],null==n||n.push(e);if(n||(n=s.issues),null!=t&&t.abortEarly){r=!1;break}}s.typed||(r=!1),i[o]=s.output}return r?lt(this,i,t,n):at(!1,i,n)}return dt(this,pt,e,t)}}}function ht(e,t){return{type:"picklist",expects:e.map(st).join(" | "),async:!1,options:e,message:t,_parse(e,t){return this.options.includes(e)?at(!0,e):dt(this,ht,e,t)}}}function ft(e,t,n){const r=e._parse(t,function(e){var t,n,r,i;return{lang:null!=(t=null==e?void 0:e.lang)?t:null==Ye?void 0:Ye.lang,message:null==e?void 0:e.message,abortEarly:null!=(n=null==e?void 0:e.abortEarly)?n:null==Ye?void 0:Ye.abortEarly,abortPipeEarly:null!=(r=null==e?void 0:e.abortPipeEarly)?r:null==Ye?void 0:Ye.abortPipeEarly,skipPipe:null!=(i=null==e?void 0:e.skipPipe)?i:null==Ye?void 0:Ye.skipPipe}}(n));if(r.issues)throw new rt(r.issues);return r.output}const mt=/^([A-Za-z]+):([0-9]+)$/,vt=/^([A-Za-z]+):([0-9]+),([0-9]+)$/,gt=/^([A-Za-z]+):([a-z0-9]+)$/;function yt(e,t){return`${e}-${"string"==typeof t?t:JSON.stringify(t)}`}const wt={alt:"altKey",ctrl:"ctrlKey",mod:typeof window<"u"&&/Mac|iPod|iPhone|iPad/.test(window.navigator.platform)?"metaKey":"ctrlKey",shift:"shiftKey"};function bt(e){return"Alt"===e.key}function xt(e){const{children:t,message:i,onRetry:o,onContinueAnyway:f,...m}=e,v=n(h,{fontSize:1,mode:"ghost",onClick:o,text:"Retry"}),g=n(h,{fontSize:1,mode:"ghost",tone:"critical",onClick:f,text:"Continue anyway"});return n(a,{height:"fill",...m,children:n(s,{align:"center",height:"fill",justify:"center",children:n(c,{padding:4,sizing:"border",width:0,children:r(l,{space:4,children:[r(l,{space:3,children:[n(d,{size:1,weight:"semibold",children:"An error occured"}),n(d,{muted:!0,size:1,children:i})]}),t,o&&f?r(u,{space:2,children:[v,g]}):o?n(p,{children:v}):f?n(p,{children:g}):null]})})})})}function Pt(){const e=C(ce);if(!e)throw new Error("Presentation context is missing");return e}function Et(e){const t=["comment","inspect","instruction","pathKey","rev","since","template","view"];return function(e={}){const t=Object.entries(e).map((([e,t])=>`${e}=${t}`)).join("&");return t.length?`?${t}`:""}(Object.entries(e).filter((([e])=>t.includes(e))).reduce(((e,[t,n])=>null==n?e:{...e,[t]:n}),{}))}const kt=O((function(e,t){const{params:r,structureParams:i}=Pt();return n(Q,{...e,ref:t,state:{type:void 0,_searchParams:Object.entries({...i,preview:r.preview})},title:void 0})})),St=O((function(e,t){const{documentId:r,documentType:i,parentRefPath:o,template:a,previewUrl:s,...c}=e;return n(Q,{...c,ref:t,state:{id:r,type:i,_searchParams:Object.entries({preview:s})},title:void 0})}));function It(e){const{children:t,onStructureParams:r,params:o,previewUrl:a,refs:s}=e,{state:c,resolvePathFromState:l}=Y(),d=V(Object.fromEntries(c._searchParams||[])),u=R((e=>`${l(c)}${Et({...d,...e})}`),[l,d,c]),p=U((()=>({index:0,groupIndex:0,siblingIndex:0,payload:{},params:o,hasGroupSiblings:!1,groupLength:1,routerPanesState:[],ChildLink:e=>{const{childId:t,...r}=e,i=null==s?void 0:s.find((e=>e._id===t||B(e._id)===t));return i?n(Q,{...r,state:{id:t,type:i._type,_searchParams:Object.entries({preview:a})}}):n("div",{...r})},BackLink:kt,ReferenceChildLink:e=>n(St,{...e,previewUrl:a}),ParameterizedLink:()=>n(i,{children:"ParameterizedLink"}),closeCurrentAndAfter:()=>{console.warn("closeCurrentAndAfter")},handleEditReference:e=>{console.warn("handleEditReference",e)},replaceCurrent:e=>{console.warn("replaceCurrent",e)},closeCurrent:()=>{console.warn("closeCurrent")},duplicateCurrent:e=>{console.warn("duplicateCurrent",e)},setView:e=>{console.warn("setView",e)},setParams:e=>{var t;r({...e,inspect:null!=(t=e.inspect)?t:void 0})},setPayload:e=>{console.warn("setPayload",e)},navigateIntent:(e,t,n)=>{console.warn("navigateIntent",e,t,n)},createPathWithParams:u})),[u,r,o,a,s]);return n(te.Provider,{value:p,children:t})}const zt=se(ne)`
var e=Object.defineProperty,t=(t,n,r)=>(((t,n,r)=>{n in t?e(t,n,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[n]=r})(t,"symbol"!=typeof n?n+"":n,r),r);import{jsx as n,jsxs as r,Fragment as i}from"react/jsx-runtime";import{studioPath as o}from"@sanity/client/csm";import{Card as a,Flex as s,Container as c,Stack as l,Text as d,Inline as u,Box as p,Button as h,Code as m,Label as f,ErrorBoundary as v,Badge as g,TextInput as y,MenuItem as w,useToast as b,usePrefersReducedMotion as x,TooltipDelayGroupProvider as P,Tooltip as E,Switch as k,MenuButton as S,Menu as I,Spinner as C,BoundaryElementProvider as z}from"@sanity/ui";import{createContext as D,useContext as O,useLayoutEffect as R,useMemo as U,useRef as _,useState as $,useCallback as j,useEffect as L,forwardRef as T,memo as A,createElement as M,startTransition as W,useReducer as N,Suspense as F,lazy as V}from"react";import{useUnique as B,getPublishedId as K,useSchema as q,Preview as G,useActiveWorkspace as J,useClient as X,useCurrentUser as H,Hotkeys as Z,useDocumentStore as Q,useProjectId as Y,useDataset as ee,useWorkspace as te}from"sanity";import{StateLink as ne,useRouter as re,decodeJsonParams as ie}from"sanity/router";import{styled as oe}from"styled-components";import{u as ae,P as se,a as ce,b as le,A as de,M as ue,c as pe,C as he,E as me,D as fe}from"./index.js";import{PaneRouterContext as ve,PaneLayout as ge,StructureToolProvider as ye,DocumentListPane as we,DocumentPane as be,CommentsIntentProvider as xe}from"sanity/structure";import{WarningOutlineIcon as Pe,ResetIcon as Ee,LaunchIcon as ke,CopyIcon as Se,PanelLeftIcon as Ie,RefreshIcon as Ce,ShareIcon as ze,ChevronDownIcon as De,CheckmarkIcon as Oe,DesktopIcon as Re,MobileDeviceIcon as Ue,EditIcon as _e,PublishIcon as $e}from"@sanity/icons";import{D as je}from"./DisplayedDocumentBroadcaster.js";import{hasSecretSearchParams as Le,setSecretSearchParams as Te,withoutSecretSearchParams as Ae}from"@sanity/preview-url-secret/without-secret-search-params";import{motion as Me,MotionConfig as We,AnimatePresence as Ne}from"framer-motion";import{createPreviewSecret as Fe}from"@sanity/preview-url-secret/create-secret";import Ve from"fast-deep-equal";import{match as Be}from"path-to-regexp";import{definePreviewUrl as Ke}from"@sanity/preview-url-secret/define-preview-url";import{suspend as qe}from"suspend-react";let Ge;const Je=new Uint8Array(16);function Xe(){if(!Ge&&(Ge=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!Ge))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return Ge(Je)}const He=[];for(let e=0;e<256;++e)He.push((e+256).toString(16).slice(1));var Ze={randomUUID:typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function Qe(e,t,n){if(Ze.randomUUID&&!t&&!e)return Ze.randomUUID();const r=(e=e||{}).random||(e.rng||Xe)();return r[6]=15&r[6]|64,r[8]=63&r[8]|128,function(e,t=0){return He[e[t+0]]+He[e[t+1]]+He[e[t+2]]+He[e[t+3]]+"-"+He[e[t+4]]+He[e[t+5]]+"-"+He[e[t+6]]+He[e[t+7]]+"-"+He[e[t+8]]+He[e[t+9]]+"-"+He[e[t+10]]+He[e[t+11]]+He[e[t+12]]+He[e[t+13]]+He[e[t+14]]+He[e[t+15]]}(r)}const Ye=1e3,et=1e3,tt=500,nt=["handshake/syn","handshake/syn-ack","handshake/ack"],rt=e=>nt.some((t=>t===e)),it=({data:e={}})=>"object"==typeof e&&null!==e&&!Array.isArray(e)&&!("domain"in e)&&["id","type","from","to"].every((t=>t in e))&&e.type.startsWith("handshake/");function ot(e){const t=e.target,n=e.connectTo.map((e=>({buffer:[],config:e,id:"",handler:i,status:"connecting",interval:void 0,heartbeat:void 0})));function r(e){window.clearInterval(e.interval)}function i(e){const{data:t}=e;if(rt(t.type)){const e=n.find((e=>e.config.id===t.from));e&&"handshake/syn-ack"===t.type&&(c(e,"connected"),l(e,"handshake/ack",{id:e.id}))}}const o=t=>{var r,i,o;const a=t.data;if(!rt(a.type)&&n.find((e=>e.id===a.connectionId))){const t=n.find((e=>e.config.id===a.from));if(t){const n=[a.type,a.data];null==(i=(r=t.config).onEvent)||i.call(r,...n),null==(o=e.onEvent)||o.call(e,...n),d(t,"channel/response",{responseTo:a.id},!1)}}};function a(t){var r;if(it(t))console.error("Visual editing package mismatch detected! Please ensure you are using the latest version of Sanity Studio and any packages listed here:\nhttps://github.com/sanity-io/visual-editing");else if(function(t){const{data:r,origin:i}=t;return"sanity/channels"===r.domain&&r.to==e.id&&n.map((e=>e.config.id)).includes(r.from)&&"channel/response"!==r.type&&i===e.targetOrigin}(t)){const{data:e}=t;null==(r=n.find((t=>t.config.id===e.from)))||r.handler(t)}}function s(e){e.heartbeat&&window.clearInterval(e.heartbeat)}function c(t,n){var a,c,u;t.status=n,null==(c=(a=t.config).onStatusUpdate)||c.call(a,n,t.config.id),null==(u=e.onStatusUpdate)||u.call(e,n,t.config.id),"connecting"===n||"reconnecting"===n?(t.handler=i,s(t),function(e){e.id=Qe(),e.interval=window.setInterval((()=>{l(e,"handshake/syn",{id:e.id})}),tt)}(t)):"connected"===n?(t.handler=o,r(t),function(e){if(s(e),e.config.heartbeat){const t="number"==typeof e.config.heartbeat?e.config.heartbeat:et;e.heartbeat=window.setInterval((()=>{d(e,"channel/heartbeat")}),t)}}(t),function(e){const t=[...e.buffer];e.buffer.splice(0,e.buffer.length),t.forEach((({type:t,data:n})=>{d(e,t,n)}))}(t)):"disconnected"===n&&(t.id=null,t.handler=i,r(t),s(t))}function l(n,r,i){if(!n.id)throw new Error("No channel ID set");const o={connectionId:n.id,data:i,domain:"sanity/channels",from:e.id,id:Qe(),to:n.config.id,type:r};try{null==t||t.postMessage(o,{targetOrigin:"*"})}catch{throw new Error(`Failed to postMessage '${o.id}' on '${e.id}'`)}}function d(n,r,i,o=!0){const a=Qe();if("connecting"===n.status||"reconnecting"===n.status||"disconnected"===n.status)return void n.buffer.push({type:r,data:i});if(!n.id)throw new Error("No channel ID set");const s={connectionId:n.id,data:i,domain:"sanity/channels",from:e.id,id:a,to:n.config.id,type:r};if(o){const t=setTimeout((()=>{s.connectionId===n.id&&(window.removeEventListener("message",o,!1),"channel/heartbeat"!==r&&n.buffer.push({type:r,data:i}),c(n,"reconnecting"),console.warn(`Received no response to message '${s.type}' on client '${e.id}' (ID: '${s.id}').`))}),Ye),o=e=>{var n;const{data:r}=e;"channel/response"===r.type&&null!=(n=r.data)&&n.responseTo&&r.data.responseTo===s.id&&(window.removeEventListener("message",o,!1),clearTimeout(t))};window.addEventListener("message",o,!1)}try{null==t||t.postMessage(s,{targetOrigin:e.targetOrigin})}catch{throw new Error(`Failed to postMessage '${s.id}' on client '${e.id}'`)}}return window.addEventListener("message",a,!1),n.forEach((e=>{c(e,"connecting")})),{destroy:function(){n.forEach((e=>{["disconnected"].includes(e.status)||(d(e,"channel/disconnect",{id:e.id},!1),c(e,"disconnected"))})),window.removeEventListener("message",a,!1),n.forEach((e=>{s(e),r(e)}))},send:function(e,t,r){(e?Array.isArray(e)?[...e]:[e]:n).forEach((e=>{const i=n.find((t=>t.config.id===e));if(!i)throw new Error("Invalid channel ID");d(i,t,r)}))}}}var at,st,ct,lt,dt=class extends Error{constructor(e){super(e[0].message),t(this,"issues"),this.name="ValiError",this.issues=e}};function ut(e,t){return Array.isArray(e)?[void 0,e]:[e,t]}function pt(e,t,n,r,i){var o,a,s,c,l;const d=null!=(l=null!=(c=null!=(s=null!=(a=null!=(o=t.message)?o:function(e,t){var n;return null==(n=null==lt?void 0:lt.get(e))?void 0:n.get(t)}(n,i.lang))?a:e?(u=i.lang,null==ct?void 0:ct.get(u)):null)?s:null==r?void 0:r.message)?c:function(e){return null==st?void 0:st.get(e)}(i.lang))?l:i.message;var u;return"function"==typeof d?d(i):d}function ht(e,t,n){return{typed:e,output:t,issues:n}}function mt(e){let t=typeof e;return"object"===t&&(t=e?Object.getPrototypeOf(e).constructor.name:"null"),"string"===t?`"${e}"`:"number"===t||"bigint"===t||"boolean"===t?`${e}`:t}function ft(e,t,n){var r;const i=null!=(r=n.received)?r:mt(n.input),o={reason:e.type,context:n.context.type,expected:n.context.expects,received:i,message:`Invalid ${n.label}: ${n.context.expects?`Expected ${n.context.expects} but r`:"R"}eceived ${i}`,input:n.input,requirement:n.context.requirement,path:n.path,lang:null==t?void 0:t.lang,abortEarly:null==t?void 0:t.abortEarly,abortPipeEarly:null==t?void 0:t.abortPipeEarly,skipPipe:null==t?void 0:t.skipPipe};return o.message=pt(!1,n.context,n.reference,t,o),o}function vt(e,t,n,r){if(e.pipe&&(null==n||!n.skipPipe))for(const i of e.pipe){const o=i._parse(t);if(o.issues){for(const t of o.issues){const i=ft(e,n,t);r?r.push(i):r=[i]}if(null!=n&&n.abortEarly||null!=n&&n.abortPipeEarly)break}else t=o.output}return ht(!0,t,r)}function gt(e,t,n,r,i){var o,a;const s=mt(n),c=null!=(o=null==i?void 0:i.expected)?o:e.expects,l={reason:null!=(a=null==i?void 0:i.reason)?a:"type",context:e.type,expected:c,received:s,message:`Invalid type: Expected ${c} but received ${s}`,input:n,path:null==i?void 0:i.path,issues:null==i?void 0:i.issues,lang:null==r?void 0:r.lang,abortEarly:null==r?void 0:r.abortEarly,abortPipeEarly:null==r?void 0:r.abortPipeEarly,skipPipe:null==r?void 0:r.skipPipe};return l.message=pt(!0,e,t,r,l),{typed:!1,output:n,issues:[l]}}function yt(e,t){return{...e,fallback:t,_parse(t,n){const r=e._parse(t,n);return r.issues?ht(!0,function(e,t){return"function"==typeof e.fallback?e.fallback(t):e.fallback}(this,{input:t,issues:r.issues})):r}}}function wt(e,t){const[n,r]=ut(e,t);return{type:"boolean",expects:"boolean",async:!1,message:n,pipe:r,_parse(e,t){return"boolean"==typeof e?vt(this,e,t):gt(this,wt,e,t)}}}function bt(e,t,n,r){const[i,o,a]=function(e,t,n){if(!e||"object"==typeof e&&!Array.isArray(e)){const[r,i]=ut(t,n);return[e,r,i]}const[r,i]=ut(e,t);return[void 0,r,i]}(t,n,r);let s;return{type:"object",expects:"Object",async:!1,entries:e,rest:i,message:o,pipe:a,_parse(e,t){if(e&&"object"==typeof e){s=null!=s?s:Object.entries(this.entries);let n,r=!0;const i={};for(const[o,a]of s){const s=e[o],c=a._parse(s,t);if(c.issues){const i={type:"object",origin:"value",input:e,key:o,value:s};for(const e of c.issues)e.path?e.path.unshift(i):e.path=[i],null==n||n.push(e);if(n||(n=c.issues),null!=t&&t.abortEarly){r=!1;break}}c.typed||(r=!1),(void 0!==c.output||o in e)&&(i[o]=c.output)}if(this.rest&&(null==t||!t.abortEarly||!n))for(const o in e)if(!(o in this.entries)){const a=e[o],s=this.rest._parse(a,t);if(s.issues){const i={type:"object",origin:"value",input:e,key:o,value:a};for(const e of s.issues)e.path?e.path.unshift(i):e.path=[i],null==n||n.push(e);if(n||(n=s.issues),null!=t&&t.abortEarly){r=!1;break}}s.typed||(r=!1),i[o]=s.output}return r?vt(this,i,t,n):ht(!1,i,n)}return gt(this,bt,e,t)}}}function xt(e,t){return{type:"picklist",expects:e.map(mt).join(" | "),async:!1,options:e,message:t,_parse(e,t){return this.options.includes(e)?ht(!0,e):gt(this,xt,e,t)}}}function Pt(e,t,n){const r=e._parse(t,function(e){var t,n,r,i;return{lang:null!=(t=null==e?void 0:e.lang)?t:null==at?void 0:at.lang,message:null==e?void 0:e.message,abortEarly:null!=(n=null==e?void 0:e.abortEarly)?n:null==at?void 0:at.abortEarly,abortPipeEarly:null!=(r=null==e?void 0:e.abortPipeEarly)?r:null==at?void 0:at.abortPipeEarly,skipPipe:null!=(i=null==e?void 0:e.skipPipe)?i:null==at?void 0:at.skipPipe}}(n));if(r.issues)throw new dt(r.issues);return r.output}const Et=/^([A-Za-z]+):([0-9]+)$/,kt=/^([A-Za-z]+):([0-9]+),([0-9]+)$/,St=/^([A-Za-z]+):([a-z0-9]+)$/;function It(e,t){return`${e}-${"string"==typeof t?t:JSON.stringify(t)}`}const Ct={alt:"altKey",ctrl:"ctrlKey",mod:typeof window<"u"&&/Mac|iPod|iPhone|iPad/.test(window.navigator.platform)?"metaKey":"ctrlKey",shift:"shiftKey"};function zt(e){return"Alt"===e.key}function Dt(e,t){let n;return(...r)=>{clearTimeout(n),n=setTimeout((()=>{e.apply(e,r)}),t)}}const Ot=D(null);Ot.displayName="PanelsContext";const Rt=oe.div`
overflow: hidden;
flex-basis: 0;
flex-shrink: 1;
`,Ut=function({children:e,defaultSize:t=null,id:r,minWidth:i,maxWidth:o,order:a=0}){const s=O(Ot);if(null===s)throw Error("Panel components must be rendered within a PanelGroup container");const{getPanelStyle:c,registerElement:l,unregisterElement:d}=s,u=c(r);return R((()=>(l(r,{id:r,type:"panel",defaultSize:t,maxWidth:null!=o?o:null,minWidth:null!=i?i:0,order:a}),()=>{d(r)})),[r,t,a,o,i,l,d]),n(Rt,{style:u,children:e})},_t="presentation/panels",$t=()=>JSON.parse(localStorage.getItem(_t)||"{}"),jt=e=>e.map((e=>[e.id,e.order].join(":"))).join(",");function Lt(){return U((()=>{const e=(e,t)=>{const n=$t(),r=jt(e);(e=>{localStorage.setItem(_t,JSON.stringify(e))})({...n,[r]:t})};return{get:e=>{const t=$t(),n=jt(e);return Array.isArray(t[n])&&t[n].some((e=>null===e))?void 0:t[n]},set:e,setDebounced:Dt(e,100)}}),[])}function Tt(e,t,n){const{maxWidth:r,minWidth:i}=e,o=null==r?100:r/n*100,a=i/n*100;return Math.min(o,Math.max(a,t))}function At(e,t,n){if(1===e.length)return"100";const r=n[e.findIndex((e=>e.id===t))];return null==r?"0":r.toPrecision(10)}function Mt(e,t,n=0,r=null){return e.clientX-(r||t.getBoundingClientRect()).left-n}function Wt(e){return"panel"===e.type}function Nt(e){return"resizer"===e.type}function Ft(e){return Array.from(e.values()).sort((({order:e},{order:t})=>null==e&&null==t?0:null==e?-1:null==t?1:e-t))}function Vt(e,t,n){const r=t.reduce(((e,t)=>e+t),0),i=[...t].map((e=>e/r*100));let o=0;for(let t=0;t<e.length;t++){const r=e[t],a=i[t],s=Tt(r,a,n);a!=s&&(o+=a-s,i[t]=s)}if("0.000"!==o.toFixed(3))for(let t=0;t<e.length;t++){const r=e[t];let{maxWidth:a,minWidth:s}=r;s=s/n*100,null!=a&&(a=a/n*100);const c=Math.min(null!=a?a:100,Math.max(s,i[t]+o));if(c!==i[t]&&(o-=c-i[t],i[t]=c,"0.000"===Math.abs(o).toFixed(3)))break}return i}const Bt=oe.div`
display: flex;
flex-direction: row;
height: 100%;
`,Ct=se(s)`
overflow: hidden;
width: 100%;
`,Kt=function({children:e}){const t=_(null),[r,i]=$(new Map),o=U((()=>Ft(r).filter(Wt)),[r]),[a,s]=$([]),[c,l]=$(null),d=_({elements:r,panels:o,widths:a}),u=j((e=>({flexGrow:At(o,e,a),pointerEvents:null===c?void 0:"none"})),[c,o,a]),p=j(((e,t)=>{i((n=>{if(n.has(e))return n;const r=new Map(n);return r.set(e,t),r}))}),[]),h=j((e=>{i((t=>{if(!t.has(e))return t;const n=new Map(t);return n.delete(e),n}))}),[]),m=_({containerWidth:window.innerWidth,dragOffset:0,panelAfter:null,panelBefore:null,resizerIndex:-1,resizerRect:null,startX:0,widths:[]}),f=j(((e,t)=>{const n=Ft(r),i=n.findIndex((t=>t.id===e)),o=r.get(e);if(!o||!Nt(o))return;const a=o.el.current;a&&(m.current={resizerIndex:i,panelBefore:n.reduce(((e,t,n)=>Wt(t)&&n<i?t:e),null),panelAfter:n.reduce(((e,t,n)=>null===e&&Wt(t)&&n>i?t:e),null),containerWidth:window.innerWidth,startX:t.pageX,dragOffset:Mt(t,a),resizerRect:a.getBoundingClientRect(),widths:d.current.widths},l(e))}),[r]),v=j((()=>{l(null)}),[]),g=j(((e,n)=>{n.preventDefault(),n.stopPropagation();const{containerWidth:i,dragOffset:o,panelBefore:a,panelAfter:c,resizerRect:l}=m.current;if(null==a||null==c)return;const u=r.get(e);if(!u||!Nt(u))return;const p=u.el.current;if(!p)return;const h=Mt(n,p,o,l);if(0===h)return;const{widths:f}=d.current,v=function(e,t,n,r,i,o){const{panels:a,widths:s}=i,{widths:c}=o,l=c||s,d=[...l];{const i=e<0?r:n,o=l[a.findIndex((e=>e.id===i.id))],s=Tt(i,o+Math.abs(e),t);if(o===s)return l;e=e<0?o-s:s-o}let u=0,p=e<0?n:r,h=a.findIndex((e=>e.id===p.id));for(;;){const n=a[h],r=l[h],i=Tt(n,r-(Math.abs(e)-Math.abs(u)),t);if(r!==i&&(u+=r-i,d[h]=i,u.toPrecision(10).localeCompare(Math.abs(e).toPrecision(10),void 0,{numeric:!0})>=0))break;if(e<0){if(--h<0)break}else if(++h>=a.length)break}return 0===u?l:(p=e<0?r:n,h=a.findIndex((e=>e.id===p.id)),d[h]=l[h]+u,d)}(h/t.current.getBoundingClientRect().width*100,i,a,c,d.current,m.current);f.some(((e,t)=>e!==v[t]))&&s(v)}),[r]);R((()=>{d.current.elements=r,d.current.panels=o,d.current.widths=a}),[r,o,a]);const y=Lt();R((()=>{const{widths:e}=d.current;if(e.length===o.length)return;const t=y.get(o);if(t){const e=Vt(o,t,window.innerWidth);return void s(e)}const n=function(e){let t=e.length,n=100;const r=e.map((e=>e.defaultSize?(n-=e.defaultSize,t-=1,e.defaultSize):null)),i=n/t;return r.map((e=>null===e?i:e))}(o);s(n)}),[y,o]),L((()=>{a.length&&y.setDebounced(o,a)}),[y,o,a]),R((()=>{const e=new ResizeObserver((()=>{const{panels:e,widths:t}=d.current,n=Vt(e,t,window.innerWidth);t.some(((e,t)=>e!==n[t]))&&s(n)}));return e.observe(t.current),()=>{e.disconnect()}}),[]);const w=U((()=>({activeResizer:c,drag:g,getPanelStyle:u,registerElement:p,startDragging:f,stopDragging:v,unregisterElement:h})),[c,g,u,p,f,v,h]);return n(Ot.Provider,{value:w,children:n(Bt,{ref:t,children:e})})};function qt(e){const{children:t,message:i,onRetry:o,onContinueAnyway:m,...f}=e,v=n(h,{fontSize:1,mode:"ghost",onClick:o,text:"Retry"}),g=n(h,{fontSize:1,mode:"ghost",tone:"critical",onClick:m,text:"Continue anyway"});return n(a,{height:"fill",...f,children:n(s,{align:"center",height:"fill",justify:"center",children:n(c,{padding:4,sizing:"border",width:0,children:r(l,{space:4,children:[r(l,{space:3,children:[n(d,{size:1,weight:"semibold",children:"An error occured"}),n(d,{muted:!0,size:1,children:i})]}),t,o&&m?r(u,{space:2,children:[v,g]}):o?n(p,{children:v}):m?n(p,{children:g}):null]})})})})}function Gt(e){const t=["comment","inspect","instruction","pathKey","rev","since","template","view"];return function(e={}){const t=Object.entries(e).map((([e,t])=>`${e}=${t}`)).join("&");return t.length?`?${t}`:""}(Object.entries(e).filter((([e])=>t.includes(e))).reduce(((e,[t,n])=>null==n?e:{...e,[t]:n}),{}))}const Jt=T((function(e,t){const{params:r,structureParams:i}=ae();return n(ne,{...e,ref:t,state:{type:void 0,_searchParams:Object.entries({...i,perspective:r.perspective,preview:r.preview})},title:void 0})})),Xt=T((function(e,t){const{documentId:r,documentType:i,parentRefPath:o,template:a,previewUrl:s,...c}=e;return n(ne,{...c,ref:t,state:{id:r,type:i,_searchParams:Object.entries({preview:s})},title:void 0})}));function Ht(e){const{children:t,onStructureParams:r,params:o,previewUrl:a,refs:s}=e,{state:c,resolvePathFromState:l}=re(),d=B(Object.fromEntries(c._searchParams||[])),u=j((e=>`${l(c)}${Gt({...d,...e})}`),[l,d,c]),p=U((()=>({index:0,groupIndex:0,siblingIndex:0,payload:{},params:o,hasGroupSiblings:!1,groupLength:1,routerPanesState:[],ChildLink:e=>{const{childId:t,...r}=e,i=null==s?void 0:s.find((e=>e._id===t||K(e._id)===t));return i?n(ne,{...r,state:{id:t,type:i._type,_searchParams:Object.entries({preview:a})}}):n("div",{...r})},BackLink:Jt,ReferenceChildLink:e=>n(Xt,{...e,previewUrl:a}),ParameterizedLink:()=>n(i,{children:"ParameterizedLink"}),closeCurrentAndAfter:()=>{console.warn("closeCurrentAndAfter")},handleEditReference:e=>{console.warn("handleEditReference",e)},replaceCurrent:e=>{console.warn("replaceCurrent",e)},closeCurrent:()=>{console.warn("closeCurrent")},duplicateCurrent:e=>{console.warn("duplicateCurrent",e)},setView:e=>{console.warn("setView",e)},setParams:e=>{var t;r({...e,inspect:null!=(t=e.inspect)?t:void 0})},setPayload:e=>{console.warn("setPayload",e)},navigateIntent:(e,t,n)=>{console.warn("navigateIntent",e,t,n)},createPathWithParams:u})),[u,r,o,a,s]);return n(ve.Provider,{value:p,children:t})}const Zt=oe(ge)`
height: 100%;
`,Qt=oe(s)`
& > div {

@@ -8,13 +18,9 @@ min-width: none !important;

}
`,Ot=se(f)`
`,Yt=oe(m)`
white-space: pre-wrap;
`;function Rt(e){const{onStructureParams:t,previewUrl:i,refs:o}=e,{devMode:s}=Pt(),c=U((()=>({id:"$root",options:{filter:"_id in $ids",params:{ids:o.map((e=>e._id))}},schemaTypeName:"",title:"Documents on this page",type:"documentList"})),[o]),[d,u]=$(null),p=R((()=>u(null)),[]),[h]=$((()=>({})));return j((()=>u(null)),[o]),d?n(xt,{flex:1,message:"Could not render the document list",onRetry:p,children:s&&n(a,{overflow:"auto",padding:3,radius:2,tone:"critical",children:r(l,{space:3,children:[n(m,{muted:!0,size:0,children:"Error message"}),n(Ot,{size:1,children:d.error.message})]})})}):n(v,{onCatch:u,children:n(zt,{children:n(re,{children:n(It,{onStructureParams:t,params:h,previewUrl:i,refs:o,children:n(Ct,{direction:"column",flex:1,children:n(ie,{index:0,itemId:"$root",pane:c,paneKey:"$root"})})})})})})}const Ut=se(f)`
`;function en(e){const{mainDocumentState:t,onStructureParams:i,previewUrl:o,refs:s}=e,{devMode:c}=ae(),d=U((()=>s.filter((e=>{var n;return K(e._id)!==(null==(n=null==t?void 0:t.document)?void 0:n._id)})).map((e=>e._id))),[t,s]),u=U((()=>({id:"$root",options:{filter:"_id in $ids",params:{ids:d}},schemaTypeName:"",title:"Documents on this page",type:"documentList"})),[d]),[p,h]=$(null),m=j((()=>h(null)),[]),[g]=$((()=>({})));return L((()=>h(null)),[s]),p?n(qt,{flex:1,message:"Could not render the document list",onRetry:m,children:c&&n(a,{overflow:"auto",padding:3,radius:2,tone:"critical",children:r(l,{space:3,children:[n(f,{muted:!0,size:0,children:"Error message"}),n(Yt,{size:1,children:p.error.message})]})})}):n(v,{onCatch:h,children:n(Zt,{children:n(ye,{children:n(Ht,{onStructureParams:i,params:g,previewUrl:o,refs:s,children:n(Qt,{direction:"column",flex:1,children:n(we,{index:0,itemId:"$root",pane:u,paneKey:"$root"})})})})})})}const tn=oe(m)`
white-space: pre-wrap;
`;function $t(e){const{documentId:t,documentType:i,onFocusPath:o,onStructureParams:s,params:c,previewUrl:d}=e,{template:u,templateParams:p}=c,{devMode:h}=Pt(),f=U((()=>({id:t,options:{id:t,type:i,template:u,templateParameters:ee(p)},title:"",type:"document"})),[t,i,u,p]),[g,y]=$(null),w=R((()=>y(null)),[]);return j((()=>{y(null)}),[t,i,c]),g?n(xt,{flex:1,message:"Could not render the document editor",onRetry:w,children:h&&n(a,{overflow:"auto",padding:3,radius:2,tone:"critical",children:r(l,{space:3,children:[n(m,{muted:!0,size:0,children:"Error message"}),n(Ut,{size:1,children:g.error.message})]})})}):n(v,{onCatch:y,children:n(ne,{style:{height:"100%"},children:n(It,{onStructureParams:s,params:c,previewUrl:d,children:n(oe,{paneKey:"document",index:1,itemId:"document",pane:f,onFocusPath:o})})})})}function jt(e){const{documentId:t,documentType:r,onFocusPath:i,onStructureParams:o,previewUrl:a,structureParams:s}=e;return n(re,{children:n($t,{documentId:t,documentType:r,onFocusPath:i,onStructureParams:o,params:s,previewUrl:a})})}function Lt(e){const{documentId:t,documentType:r,onFocusPath:i,onStructureParams:o,previewUrl:a,refs:s,structureParams:c}=e;return t&&r?n(jt,{documentId:t,documentType:r,onFocusPath:i,onStructureParams:o,previewUrl:a,structureParams:c}):n(Rt,{onStructureParams:o,previewUrl:a,refs:s})}const Tt=L(null);Tt.displayName="PanelsContext";const Dt=se.div`
overflow: hidden;
flex-basis: 0;
flex-shrink: 1;
`,At=function({children:e,defaultSize:t=null,id:r,minWidth:i,maxWidth:o,order:a=0}){const s=C(Tt);if(null===s)throw Error("Panel components must be rendered within a PanelGroup container");const{getPanelStyle:c,registerElement:l,unregisterElement:d}=s,u=c(r);return T((()=>(l(r,{id:r,type:"panel",defaultSize:t,maxWidth:null!=o?o:null,minWidth:null!=i?i:0,order:a}),()=>{d(r)})),[r,t,a,o,i,l,d]),n(Dt,{style:u,children:e})};const _t=se.div`
`;function nn(e){const{documentId:t,documentType:i,onFocusPath:o,onStructureParams:s,params:c,previewUrl:d}=e,{template:u,templateParams:p}=c,{devMode:h}=ae(),m=U((()=>({id:t,options:{id:t,type:i,template:u,templateParameters:ie(p)},title:"",type:"document"})),[t,i,u,p]),[g,y]=$(null),w=j((()=>y(null)),[]);return L((()=>{y(null)}),[t,i,c]),g?n(qt,{flex:1,message:"Could not render the document editor",onRetry:w,children:h&&n(a,{overflow:"auto",padding:3,radius:2,tone:"critical",children:r(l,{space:3,children:[n(f,{muted:!0,size:0,children:"Error message"}),n(tn,{size:1,children:g.error.message})]})})}):n(v,{onCatch:y,children:n(ge,{style:{height:"100%"},children:n(Ht,{onStructureParams:s,params:c,previewUrl:d,children:n(be,{paneKey:"document",index:1,itemId:"document",pane:m,onFocusPath:o})})})})}function rn(e){const{documentId:t,documentType:r,onFocusPath:i,onStructureParams:o,previewUrl:a,structureParams:s}=e;return n(ye,{children:n(nn,{documentId:t,documentType:r,onFocusPath:i,onStructureParams:o,params:s,previewUrl:a})})}function on(e){const{documentId:t,documentType:i,mainDocumentState:o,onFocusPath:c,onStructureParams:l,previewUrl:u,refs:h,structureParams:m}=e,f=q(),v=j((e=>n(ne,{...e,state:{id:o.document._id,type:o.document._type,_searchParams:Object.entries({preview:u})}})),[o,u]);return t&&i?n(rn,{documentId:t,documentType:i,onFocusPath:c,onStructureParams:l,previewUrl:u,structureParams:m}):r(s,{direction:"column",flex:1,height:"fill",children:[o&&n(a,{padding:3,tone:o.document?"inherit":"caution",children:o.document?n(a,{as:v,"data-as":"a",padding:0,radius:2,children:n(G,{schemaType:f.get(o.document._type),status:n(g,{children:"Main document"}),value:o.document})}):n(a,{padding:2,radius:2,tone:"inherit",children:r(s,{gap:3,children:[n(p,{flex:"none",children:n(d,{size:1,children:n(Pe,{})})}),n(p,{flex:1,children:r(d,{size:1,children:["Missing a main document for ",n("code",{children:o.path})]})})]})})}),n(en,{mainDocumentState:o,onStructureParams:l,previewUrl:u,refs:h})]})}const an=oe.div`
position: relative;
`,Wt=se.div`
`,sn=oe.div`
position: absolute;

@@ -40,9 +46,3 @@ top: 0;

${({$disabled:e})=>!e&&"\n /* Hover effect */\n & > span:nth-child(2) {\n display: block;\n position: absolute;\n top: 0;\n left: 0;\n width: 9px;\n bottom: 0;\n background-color: var(--card-border-color);\n opacity: 0;\n transition: opacity 150ms;\n }\n\n @media (hover: hover) {\n &:hover > span:nth-child(2) {\n opacity: 0.2;\n }\n }\n "}
`,Mt=function({id:e,order:t,disabled:i=!1}){const o=D(null),a=C(Tt);if(null===a)throw Error("Panel components must be rendered within a PanelGroup container");const s=function(e){return D(e||Ke()).current}(e),{activeResizer:c,drag:l,startDragging:d,stopDragging:u,registerElement:p,unregisterElement:h}=a,f=c===s;if(null===a)throw Error("Panel components must be rendered within a PanelGroup container");const m=R((e=>{d(s,e.nativeEvent)}),[s,d]),v=R((e=>{l(s,e)}),[s,l]),g=R((()=>{o.current.blur(),u()}),[u]);return j((()=>{if(f&&!i)return window.addEventListener("mousemove",v),window.addEventListener("mouseup",g),()=>{window.removeEventListener("mousemove",v),window.removeEventListener("mouseup",g)}}),[i,f,v,g]),T((()=>(p(s,{id:s,order:t,type:"resizer",el:o}),()=>{h(s)})),[s,t,p,h]),n(_t,{onMouseDown:m,ref:o,children:r(Wt,{$disabled:i,children:[n("span",{}),n("span",{})]})})};function Nt(e,t){let n;return(...r)=>{clearTimeout(n),n=setTimeout((()=>{e.apply(e,r)}),t)}}const Ft="presentation/panels",Vt=()=>JSON.parse(localStorage.getItem(Ft)||"{}"),Bt=e=>e.map((e=>[e.id,e.order].join(":"))).join(",");function Kt(){return U((()=>{const e=(e,t)=>{const n=Vt(),r=Bt(e);(e=>{localStorage.setItem(Ft,JSON.stringify(e))})({...n,[r]:t})};return{get:e=>{const t=Vt(),n=Bt(e);return Array.isArray(t[n])&&t[n].some((e=>null===e))?void 0:t[n]},set:e,setDebounced:Nt(e,100)}}),[])}function qt(e,t,n){const{maxWidth:r,minWidth:i}=e,o=null==r?100:r/n*100,a=i/n*100;return Math.min(o,Math.max(a,t))}function Gt(e,t,n){if(1===e.length)return"100";const r=n[e.findIndex((e=>e.id===t))];return null==r?"0":r.toPrecision(10)}function Jt(e,t,n=0,r=null){return e.clientX-(r||t.getBoundingClientRect()).left-n}function Xt(e){return"panel"===e.type}function Ht(e){return"resizer"===e.type}function Zt(e){return Array.from(e.values()).sort((({order:e},{order:t})=>null==e&&null==t?0:null==e?-1:null==t?1:e-t))}function Qt(e,t,n){const r=t.reduce(((e,t)=>e+t),0),i=[...t].map((e=>e/r*100));let o=0;for(let t=0;t<e.length;t++){const r=e[t],a=i[t],s=qt(r,a,n);a!=s&&(o+=a-s,i[t]=s)}if("0.000"!==o.toFixed(3))for(let t=0;t<e.length;t++){const r=e[t];let{maxWidth:a,minWidth:s}=r;s=s/n*100,null!=a&&(a=a/n*100);const c=Math.min(null!=a?a:100,Math.max(s,i[t]+o));if(c!==i[t]&&(o-=c-i[t],i[t]=c,"0.000"===Math.abs(o).toFixed(3)))break}return i}const Yt=se.div`
display: flex;
flex-direction: row;
height: 100%;
overflow: hidden;
width: 100%;
`,en=function({children:e}){const t=D(null),[r,i]=$(new Map),o=U((()=>Zt(r).filter(Xt)),[r]),[a,s]=$([]),[c,l]=$(null),d=D({elements:r,panels:o,widths:a}),u=R((e=>({flexGrow:Gt(o,e,a),pointerEvents:null===c?void 0:"none"})),[c,o,a]),p=R(((e,t)=>{i((n=>{if(n.has(e))return n;const r=new Map(n);return r.set(e,t),r}))}),[]),h=R((e=>{i((t=>{if(!t.has(e))return t;const n=new Map(t);return n.delete(e),n}))}),[]),f=D({containerWidth:window.innerWidth,dragOffset:0,panelAfter:null,panelBefore:null,resizerIndex:-1,resizerRect:null,startX:0,widths:[]}),m=R(((e,t)=>{const n=Zt(r),i=n.findIndex((t=>t.id===e)),o=r.get(e);if(!o||!Ht(o))return;const a=o.el.current;a&&(f.current={resizerIndex:i,panelBefore:n.reduce(((e,t,n)=>Xt(t)&&n<i?t:e),null),panelAfter:n.reduce(((e,t,n)=>null===e&&Xt(t)&&n>i?t:e),null),containerWidth:window.innerWidth,startX:t.pageX,dragOffset:Jt(t,a),resizerRect:a.getBoundingClientRect(),widths:d.current.widths},l(e))}),[r]),v=R((()=>{l(null)}),[]),g=R(((e,n)=>{n.preventDefault(),n.stopPropagation();const{containerWidth:i,dragOffset:o,panelBefore:a,panelAfter:c,resizerRect:l}=f.current;if(null==a||null==c)return;const u=r.get(e);if(!u||!Ht(u))return;const p=u.el.current;if(!p)return;const h=Jt(n,p,o,l);if(0===h)return;const{widths:m}=d.current,v=function(e,t,n,r,i,o){const{panels:a,widths:s}=i,{widths:c}=o,l=c||s,d=[...l];{const i=e<0?r:n,o=l[a.findIndex((e=>e.id===i.id))],s=qt(i,o+Math.abs(e),t);if(o===s)return l;e=e<0?o-s:s-o}let u=0,p=e<0?n:r,h=a.findIndex((e=>e.id===p.id));for(;;){const n=a[h],r=l[h],i=qt(n,r-(Math.abs(e)-Math.abs(u)),t);if(r!==i&&(u+=r-i,d[h]=i,u.toPrecision(10).localeCompare(Math.abs(e).toPrecision(10),void 0,{numeric:!0})>=0))break;if(e<0){if(--h<0)break}else if(++h>=a.length)break}return 0===u?l:(p=e<0?r:n,h=a.findIndex((e=>e.id===p.id)),d[h]=l[h]+u,d)}(h/t.current.getBoundingClientRect().width*100,i,a,c,d.current,f.current);m.some(((e,t)=>e!==v[t]))&&s(v)}),[r]);T((()=>{d.current.elements=r,d.current.panels=o,d.current.widths=a}),[r,o,a]);const y=Kt();T((()=>{const{widths:e}=d.current;if(e.length===o.length)return;const t=y.get(o);if(t){const e=Qt(o,t,window.innerWidth);return void s(e)}const n=function(e){let t=e.length,n=100;const r=e.map((e=>e.defaultSize?(n-=e.defaultSize,t-=1,e.defaultSize):null)),i=n/t;return r.map((e=>null===e?i:e))}(o);s(n)}),[y,o]),j((()=>{a.length&&y.setDebounced(o,a)}),[y,o,a]),T((()=>{const e=new ResizeObserver((()=>{const{panels:e,widths:t}=d.current,n=Qt(e,t,window.innerWidth);t.some(((e,t)=>e!==n[t]))&&s(n)}));return e.observe(t.current),()=>{e.disconnect()}}),[]);const w=U((()=>({activeResizer:c,drag:g,getPanelStyle:u,registerElement:p,startDragging:m,stopDragging:v,unregisterElement:h})),[c,g,u,p,m,v,h]);return n(Tt.Provider,{value:w,children:n(Yt,{ref:t,children:e})})},tn=function(e){const{children:t,navigate:r}=e,i=R(((e,t=void 0)=>{r(t||{},e?{preview:e}:{})}),[r]);return n(le.Provider,{value:i,children:t})};function nn(e){const{unstable_navigator:t}=e,r=!(null==t||!t.component),[o,a]=function(e,t){const[n,r]=$((()=>{var n;return JSON.parse(null!=(n=localStorage.getItem(e))?n:JSON.stringify(t))}));return j((()=>{localStorage.setItem(e,JSON.stringify(n))}),[e,n]),[n,r]}("presentation/navigator",r),s=!!r&&o,c=U((()=>{if(r)return()=>a((e=>!e))}),[r,a]),l=R((function(){return n(i,{children:s&&n(rn,{...t})})}),[s,t]);return[{navigatorEnabled:s,toggleNavigator:c},l]}const rn=A((function(e){const{minWidth:t,maxWidth:o,component:a}=e,s=null!=t&&null!=o&&t===o;return r(i,{children:[n(At,{id:"navigator",minWidth:t,maxWidth:o,order:1,children:n(a,{})}),n(Mt,{order:2,disabled:s})]})})),on=function(e){const{children:t,params:r}=e,i=U((()=>r),[r]);return n(de.Provider,{value:i,children:t})},an=function(e){const{children:t,devMode:r,name:i,navigate:o,params:a,structureParams:s}=e,c=U((()=>({devMode:r,name:i,navigate:o,params:a,structureParams:s})),[r,i,o,a,s]);return n(ce.Provider,{value:c,children:t})},sn="ACTION_IFRAME_LOADED",cn="ACTION_IFRAME_REFRESH",ln="ACTION_IFRAME_RELOAD",dn="ACTION_PERSPECTIVE",un="ACTION_VIEWPORT",pn="ACTION_VISUAL_EDITING_OVERLAYS_TOGGLE",hn=(e,t)=>{switch(t.type){case sn:return"loaded"===e.iframe.status?e:{...e,iframe:{...e.iframe,status:"loaded"}};case cn:return"refreshing"===e.iframe.status?e:{...e,iframe:{...e.iframe,status:"refreshing"}};case ln:return"reloading"===e.iframe.status?e:{...e,iframe:{...e.iframe,status:"reloading"}};case dn:return{...e,perspective:ft(vn,t.perspective)};case un:return{...e,viewport:ft(gn,t.viewport)};case pn:return fn(e,t);default:return e}},fn=(e,t)=>e.visualEditing.overlaysEnabled===t.enabled?e:{...e,visualEditing:{...e.visualEditing,overlaysEnabled:t.enabled}},mn=ht(["loading","loaded","refreshing","reloading"]),vn=ut(ht(["published","previewDrafts"]),"previewDrafts"),gn=ut(ht(["desktop","mobile"]),"desktop"),yn=pt({iframe:pt({status:mn}),perspective:vn,viewport:gn,visualEditing:pt({overlaysEnabled:function e(t,n){const[r,i]=it(t,n);return{type:"boolean",expects:"boolean",async:!1,message:r,pipe:i,_parse(t,n){return"boolean"==typeof t?lt(this,t,n):dt(this,e,t,n)}}}()})}),wn={iframe:{status:"loading"},perspective:"previewDrafts",viewport:"desktop",visualEditing:{overlaysEnabled:!1}};function bn(e){return ft(yn,{...wn,...e})}const xn=je(se.iframe`
`,cn=function({id:e,order:t,disabled:i=!1}){const o=_(null),a=O(Ot);if(null===a)throw Error("Panel components must be rendered within a PanelGroup container");const s=function(e){return _(e||Qe()).current}(e),{activeResizer:c,drag:l,startDragging:d,stopDragging:u,registerElement:p,unregisterElement:h}=a,m=c===s;if(null===a)throw Error("Panel components must be rendered within a PanelGroup container");const f=j((e=>{d(s,e.nativeEvent)}),[s,d]),v=j((e=>{l(s,e)}),[s,l]),g=j((()=>{o.current.blur(),u()}),[u]);return L((()=>{if(m&&!i)return window.addEventListener("mousemove",v),window.addEventListener("mouseup",g),()=>{window.removeEventListener("mousemove",v),window.removeEventListener("mouseup",g)}}),[i,m,v,g]),R((()=>(p(s,{id:s,order:t,type:"resizer",el:o}),()=>{h(s)})),[s,t,p,h]),n(an,{onMouseDown:f,ref:o,children:r(sn,{$disabled:i,children:[n("span",{}),n("span",{})]})})},ln=e=>{const{documentId:t,setDisplayedDocument:o,getCommentIntent:a}=e;return r(i,{children:[n(cn,{order:4}),n(Ut,{id:"content",minWidth:325,order:5,children:n(je,{documentId:t,setDisplayedDocument:o,children:n(xe,{getIntent:a,children:e.children})})})]})},dn=e=>{const{documentsOnPage:t,getCommentIntent:r,mainDocumentState:i,onFocusPath:o,onStructureParams:a,params:s,setDisplayedDocument:c,structureParams:l}=e;return n(ln,{documentId:s.id,getCommentIntent:r,setDisplayedDocument:c,children:n(on,{documentId:s.id,documentType:s.type,mainDocumentState:i,onFocusPath:o,onStructureParams:a,previewUrl:s.preview,refs:t,structureParams:l})})},un=function(e){const{children:t,navigate:r}=e,i=j(((e,t=void 0)=>{r(t||{},e?{preview:e}:{})}),[r]);return n(se.Provider,{value:i,children:t})};function pn(e){const{unstable_navigator:t}=e,r=!(null==t||!t.component),[o,a]=function(e,t){const[n,r]=$((()=>{var n;return JSON.parse(null!=(n=localStorage.getItem(e))?n:JSON.stringify(t))}));return L((()=>{localStorage.setItem(e,JSON.stringify(n))}),[e,n]),[n,r]}("presentation/navigator",r),s=!!r&&o,c=U((()=>{if(r)return()=>a((e=>!e))}),[r,a]),l=j((function(){return n(i,{children:s&&n(hn,{...t})})}),[s,t]);return[{navigatorEnabled:s,toggleNavigator:c},l]}const hn=A((function(e){const{minWidth:t,maxWidth:o,component:a}=e,s=null!=t&&null!=o&&t===o;return r(i,{children:[n(Ut,{id:"navigator",minWidth:t,maxWidth:o,order:1,children:n(a,{})}),n(cn,{order:2,disabled:s})]})})),mn=function(e){const{children:t,params:r}=e,i=U((()=>r),[r]);return n(ce.Provider,{value:i,children:t})},fn=function(e){const{children:t,devMode:r,name:i,navigate:o,params:a,structureParams:s}=e,c=U((()=>({devMode:r,name:i,navigate:o,params:a,structureParams:s})),[r,i,o,a,s]);return n(le.Provider,{value:c,children:t})},vn="ACTION_IFRAME_LOADED",gn="ACTION_IFRAME_REFRESH",yn="ACTION_IFRAME_RELOAD",wn="ACTION_PERSPECTIVE",bn="ACTION_VIEWPORT",xn="ACTION_VISUAL_EDITING_OVERLAYS_TOGGLE",Pn=(e,t)=>{switch(t.type){case vn:return"loaded"===e.iframe.status?e:{...e,iframe:{...e.iframe,status:"loaded"}};case gn:return"refreshing"===e.iframe.status?e:{...e,iframe:{...e.iframe,status:"refreshing"}};case yn:return"reloading"===e.iframe.status?e:{...e,iframe:{...e.iframe,status:"reloading"}};case wn:return{...e,perspective:Pt(In,t.perspective)};case bn:return{...e,viewport:Pt(Cn,t.viewport)};case xn:return En(e,t);default:return e}},En=(e,t)=>e.visualEditing.overlaysEnabled===t.enabled?e:{...e,visualEditing:{...e.visualEditing,overlaysEnabled:t.enabled}},kn=yt(wt(),!1),Sn=xt(["loading","loaded","refreshing","reloading"]),In=yt(xt(["published","previewDrafts"]),"previewDrafts"),Cn=yt(xt(["desktop","mobile"]),"desktop"),zn=bt({mainDocument:kn,iframe:bt({status:Sn}),perspective:In,viewport:Cn,visualEditing:bt({overlaysEnabled:wt()})}),Dn={mainDocument:!1,iframe:{status:"loading"},perspective:"previewDrafts",viewport:"desktop",visualEditing:{overlaysEnabled:!1}};function On(e){return Pt(zn,{...Dn,...e})}const Rn=Me(oe.iframe`
border: 0;

@@ -52,4 +52,4 @@ max-height: 100%;

display: block;
`),Pn=function(e){var t;const{basePath:r="/"}=(null==(t=K())?void 0:t.activeWorkspace)||{},{fontSize:o=1,onChange:a,origin:s,padding:c=3,prefix:l,suffix:d,value:u}=e,p=D(null),[h,f]=$(void 0),[m,v]=$(void 0),y=R((e=>{f(e.currentTarget.value)}),[]),w=R((e=>{var t;if("Enter"===e.key){if(void 0===h)return;const e=h.startsWith("/")||""===h?`${s}${h}`:h;if(!e.startsWith(s+"/")&&e!==s)return void v(`URL must start with ${s}`);if(!s&&(e.startsWith(`${r}/`)||e===r))return void v(`URL can't have the same base path as the Studio ${r}`);const n=e===s?s+"/":e;v(void 0),f(void 0),a(n.slice(s.length)),null==(t=p.current)||t.blur()}"Escape"===e.key&&(v(void 0),f(void 0))}),[r,a,s,h]),b=R((()=>{v(void 0),f(void 0)}),[]);j((()=>{v(void 0),f(void 0)}),[s,u]);const x=U((()=>({icon:ye})),[]);return n(i,{children:n(g,{clearButton:m?x:void 0,customValidity:m,fontSize:o,onBlur:b,onClear:()=>{v(void 0),f(s+u)},onChange:y,onKeyDownCapture:w,padding:c,prefix:l,style:{zIndex:1},radius:2,ref:p,space:c,suffix:d,value:void 0===h?`${s}${u}`:h})})};function En(e){const{initialUrl:t,openPopup:o,previewLocationOrigin:a,previewLocationRoute:s}=e,c=R((e=>{e.preventDefault(),o(e.currentTarget.href)}),[o]);return r(i,{children:[n(kn,{initialUrl:t,previewLocationOrigin:a,previewLocationRoute:s}),n(y,{icon:we,text:"Open preview",as:"a",href:`${a}${s}`,onClick:c,rel:"opener",target:"_blank"})]})}function kn(e){const{initialUrl:t,previewLocationOrigin:r,previewLocationRoute:i}=e,{push:o}=w(),a=q({apiVersion:ue}),s=G(),[c,l]=$(!1);return n(y,{disabled:c,onClick:()=>{if(null==navigator||!navigator.clipboard)return o({closable:!0,status:"error",title:"Clipboard not supported"}),!1;l(!0);let e,n=`${r}${i}`;const c=()=>{o({id:e,closable:!0,status:"success",title:"The URL is copied to the clipboard"}),l(!1)},d=e=>{o({closable:!0,status:"error",title:"Copy failed",description:e.message||e.toString()}),l(!1)};if(Re(t)&&typeof ClipboardItem<"u"){const r="text/plain",l=async()=>{e=o({closable:!0,title:"Copying URL to clipboard…"});const c=await De(a,"@sanity/presentation",typeof window>"u"?"":location.href,null==s?void 0:s.id);return n=Ue(t,c.secret,i).toString(),new Blob([n],{type:r})},u=new ClipboardItem({[r]:l()});navigator.clipboard.write([u]).then(c).catch(d)}else navigator.clipboard.writeText(n).then(c).catch(d)},text:"Copy link",icon:be})}const Sn=je(s),In={previewDrafts:"Drafts",published:"Published"},zn="caution",Cn="positive",On={previewDrafts:Ce,published:Oe},Rn=O((function(e,t){const{dispatch:o,iframe:c,initialUrl:u,loadersConnection:v,navigatorEnabled:g,onPathChange:w,onRefresh:z,openPopup:C,overlaysConnection:O,params:L,perspective:T,targetOrigin:D,toggleNavigator:A,toggleOverlay:W,viewport:M,visualEditing:{overlaysEnabled:N}}=e,{devMode:F}=Pt(),V=b(),B=R((()=>o({type:un,viewport:"desktop"})),[o]),K=R((()=>o({type:un,viewport:"mobile"})),[o]),q="loading"===c.status||"reloading"===c.status,[G,X]=$(!1),H="refreshing"===c.status,[Z,Q]=$(!1),Y=q||H||"connecting"===O,ee=U((()=>D===location.origin?"":D),[D]),te=R((()=>{z((()=>{"function"==typeof t||null==t||!t.current||(o({type:ln}),t.current.src=`${D}${L.preview||"/"}`)}))}),[o,z,L.preview,D,t]),ne=R((()=>{"function"==typeof t||null==t||!t.current||(t.current.src=u.toString(),o({type:ln}))}),[o,t,u]),re=R((()=>{oe(!0)}),[]),[ie,oe]=$(!1),[ae,se]=$(!1);j((()=>{if(!(q||H||"connecting"!==O&&"reconnecting"!==O)){const e=setTimeout((()=>{se(!0)}),1e3);return()=>clearTimeout(e)}}),[O,q,H]),j((()=>{if(!q&&!H&&ae){if("connected"===O&&(Q(!1),se(!1),X(!1),oe(!1)),"connecting"===O){const e=setTimeout((()=>{X(!0),console.error("Unable to connect to visual editing. Make sure you've setup '@sanity/visual-editing' correctly")}),pe);return()=>clearTimeout(e)}if("reconnecting"===O){const e=setTimeout((()=>{X(!0),Q(!0)}),pe);return()=>clearTimeout(e)}"disconnected"===O&&Q(!0)}}),[q,O,H,ae]);const ce=U((()=>{const e=new URL(L.preview||"/",D),{pathname:t,search:n}=$e(e);return`${t}${n}`}),[L.preview,D]),le=R((()=>{o({type:sn})}),[o]);return j((()=>{if("function"==typeof t||null==t||!t.current)return;const e=t.current;function n(){e===document.activeElement&&e.dispatchEvent(new MouseEvent("mousedown",{bubbles:!0,cancelable:!0}))}return window.addEventListener("blur",n),()=>{window.removeEventListener("blur",n)}}),[t]),n(Le,{transition:V?{duration:0}:void 0,children:r(x,{delay:1e3,children:[n(a,{flex:"none",padding:2,shadow:1,style:{position:"relative"},children:r(s,{align:"center",style:{minHeight:0},children:[A&&n(p,{flex:"none",marginRight:1,padding:1,children:n(P,{animate:!0,content:n(d,{size:1,children:"Toggle navigator"}),fallbackPlacements:["bottom-start"],padding:2,placement:"bottom",portal:!0,children:n(h,{"aria-label":"Toggle navigator",fontSize:1,icon:xe,mode:"bleed",onClick:A,padding:2,selected:g})})}),n(P,{animate:!0,content:r(s,{align:"center",style:{whiteSpace:"nowrap"},children:[n(p,{padding:1,children:n(d,{size:1,children:N?"Disable edit overlay":"Enable edit overlay"})}),n(p,{paddingY:1,children:n(J,{keys:["Alt"],style:{marginTop:-4,marginBottom:-4}})})]}),fallbackPlacements:["bottom-start"],padding:1,placement:"bottom",portal:!0,children:n(a,{as:"label",flex:"none",marginRight:1,padding:3,style:{lineHeight:0,borderRadius:999,userSelect:"none"},tone:N?"transparent":void 0,children:r(s,{align:"center",gap:3,children:[n("div",{style:{margin:-4},children:n(E,{checked:N,onChange:W,disabled:"loading"===c.status||"connected"!==O})}),n(p,{children:n(d,{muted:!N,size:1,weight:"medium",children:"Edit"})})]})})}),n(p,{flex:1,marginX:1,children:n(Pn,{prefix:n(p,{padding:1,children:n(P,{animate:!0,content:n(d,{size:1,children:"loading"===c.status?"Loading…":"reloading"===c.status||"refreshing"===c.status?"Refreshing…":"Refresh preview"}),fallbackPlacements:["bottom-start"],padding:2,placement:"bottom",portal:!0,children:n(h,{"aria-label":"Refresh preview",fontSize:1,icon:Pe,mode:"bleed",loading:"reloading"===c.status||"refreshing"===c.status,onClick:te,padding:2})})}),onChange:w,origin:ee,suffix:n(p,{padding:1,children:n(k,{button:n(h,{fontSize:1,iconRight:Ee,mode:"bleed",padding:2,space:2}),id:"location-menu",menu:n(S,{children:n(En,{initialUrl:u,openPopup:C,previewLocationOrigin:ee,previewLocationRoute:ce})}),popover:{animate:!0,constrainSize:!0,placement:"bottom",portal:!0}})}),value:ce})}),n(s,{align:"center",flex:"none",gap:1,padding:1,children:n(k,{button:n(h,{fontSize:1,iconRight:ke,mode:"bleed",padding:2,space:2,text:In["connected"===v?T:"previewDrafts"],loading:"reconnecting"===v&&"loaded"!==c.status,disabled:"connected"!==v}),id:"perspective-menu",menu:r(S,{style:{maxWidth:240},children:[n(y,{fontSize:1,onClick:()=>o({type:dn,perspective:"previewDrafts"}),padding:3,pressed:"previewDrafts"===T,tone:zn,children:r(s,{align:"flex-start",gap:3,children:[n(p,{flex:"none",children:n(d,{size:1,children:_(On.previewDrafts)})}),r(l,{flex:1,space:2,children:[n(d,{size:1,weight:"medium",children:In.previewDrafts}),n(d,{muted:!0,size:1,children:"View this page with latest draft content"})]}),n(p,{flex:"none",children:n(d,{muted:!0,size:1,style:{opacity:"previewDrafts"===T?1:0},children:n(Se,{})})})]})}),n(y,{fontSize:1,onClick:()=>o({type:dn,perspective:"published"}),padding:3,pressed:"published"===T,tone:Cn,children:r(s,{align:"flex-start",gap:3,children:[n(p,{flex:"none",children:n(d,{size:1,children:_(On.published)})}),r(l,{flex:1,space:2,children:[n(d,{size:1,weight:"medium",children:In.published}),n(d,{muted:!0,size:1,children:"View this page with published content"})]}),n(p,{flex:"none",children:n(d,{muted:!0,size:1,style:{opacity:"published"===T?1:0},children:n(Se,{})})})]})})]}),popover:{animate:!0,constrainSize:!0,placement:"bottom",portal:!0}})}),r(s,{align:"center",flex:"none",gap:1,padding:1,children:[n(P,{animate:!0,content:n(d,{size:1,children:"Full viewport"}),fallbackPlacements:["bottom-start"],padding:2,placement:"bottom",portal:!0,children:n(h,{"aria-label":"Full viewport",fontSize:1,icon:Ie,mode:"bleed",onClick:B,padding:2,selected:"desktop"===M})}),n(P,{animate:!0,content:n(d,{size:1,children:"Narrow viewport"}),padding:2,placement:"bottom",portal:!0,children:n(h,{"aria-label":"Narrow viewport",fontSize:1,icon:ze,mode:"bleed",onClick:K,padding:2,selected:"mobile"===M})})]})]})}),n(a,{flex:1,tone:"transparent",children:r(s,{align:"center",height:"fill",justify:"center",padding:"desktop"===M?0:2,sizing:"border",style:{position:"relative",cursor:Y?"wait":void 0},children:[n(Te,{children:Z||q||H||!ae||ie?(q||"connecting"===O&&"refreshing"!==c.status)&&!ie?n(Sn,{initial:"initial",animate:"animate",exit:"exit",variants:$n,justify:"center",align:"center",style:{inset:"0",position:"absolute"},children:r(s,{style:{...Un[M]},justify:"center",align:"center",direction:"column",gap:4,children:[n(I,{muted:!0}),n(d,{muted:!0,size:1,children:"Loading…"})]})}):Z&&!ie?n(Sn,{initial:"initial",animate:"animate",exit:"exit",variants:jn,justify:"center",align:"center",style:{background:"var(--card-bg-color)",inset:"0",position:"absolute",borderTop:"1px solid transparent",boxShadow:"0 0 0 1px var(--card-border-color)"},children:n(xt,{flex:1,message:"Could not connect to the preview",onRetry:ne,onContinueAnyway:re,children:F&&r(i,{children:["connected"!==O&&n(a,{padding:3,radius:2,tone:"critical",children:r(l,{space:3,children:[n(m,{muted:!0,size:0,children:"Overlay connection status"}),n(f,{size:1,children:O})]})}),"connected"!==v&&n(a,{padding:3,radius:2,tone:"critical",children:r(l,{space:3,children:[n(m,{muted:!0,size:0,children:"Loader connection status"}),n(f,{size:1,children:v})]})})]})})}):null:n(Sn,{initial:"initial",animate:"animate",exit:"exit",variants:$n,justify:"center",align:"center",style:{inset:"0",position:"absolute",backdropFilter:G?"blur(16px) saturate(0.5) grayscale(0.5)":"blur(2px)",transition:"backdrop-filter 0.2s ease-in-out",WebkitBackdropFilter:G?"blur(16px) saturate(0.5) grayscale(0.5)":"blur(2px)",WebkitTransition:"-webkit-backdrop-filter 0.2s ease-in-out",zIndex:1},children:r(s,{style:{...Un[M]},justify:"center",align:"center",direction:"column",gap:4,children:[G&&n(h,{disabled:!0,fontSize:1,mode:"ghost",text:"Continue anyway",style:{opacity:0}}),n(a,{radius:2,tone:G?"caution":"inherit",padding:4,shadow:1,children:r(s,{justify:"center",align:"center",direction:"column",gap:4,children:[n(I,{muted:!0}),n(d,{muted:!0,size:1,children:G?n(i,{children:"Unable to connect, check the browser console for more information."}):"Connecting…"})]})}),G&&n(h,{fontSize:1,tone:"critical",onClick:re,text:"Continue anyway"})]})})}),n(xn,{ref:t,style:{pointerEvents:(q||"connecting"===O&&"refreshing"!==c.status)&&!ie?"none":"auto",boxShadow:"0 0 0 1px var(--card-border-color)",borderTop:"1px solid transparent"},src:u.toString(),initial:["background"],variants:Ln,animate:[(q||"connecting"===O&&"refreshing"!==c.status)&&!ie?"background":"active",q?"reloading":"idle",M,ae&&!ie?"timedOut":""],onLoad:le})]})})]})})})),Un={desktop:{width:"100%",height:"100%"},mobile:{width:375,height:650}},$n={initial:{opacity:1},animate:{opacity:[0,0,1]},exit:{opacity:[1,0,0]}},jn={initial:{opacity:1},animate:{opacity:[0,0,1]},exit:{opacity:[1,0,0]}},Ln={desktop:{...Un.desktop,boxShadow:"0 0 0 0px var(--card-border-color)"},mobile:{...Un.mobile,boxShadow:"0 0 0 1px var(--card-border-color)"},background:{opacity:0,scale:1},idle:{scale:1},reloading:{scale:[1,1,1,.98]},active:{opacity:[0,0,1],scale:1},timedOut:{opacity:[0,0,1]}};let Tn=!1;function Dn(e){var t;if(void 0===e)return;const n=null==(t=decodeURIComponent(e))?void 0:t.split(".");return"drafts"===n[0]&&n.shift(),n.join(".")}function An(e){if(void 0!==e)return o.toString(function(e){const t=[];for(const n of e.split(".")){const e=mt.exec(n);if(e){t.push(e[1],Number(e[2]));continue}const r=vt.exec(n);if(r){t.push(r[1],[Number(r[2]),Number(r[3])]);continue}const i=gt.exec(n);i?t.push(i[1],{_key:i[2]}):t.push(n)}return t}(decodeURIComponent(e)))}function _n(e){return Object.fromEntries(Object.entries(e).filter((([,e])=>void 0!==e&&""!==e&&null!==e)))}function Wn({initialPreviewUrl:e,routerNavigate:t,routerState:n,routerSearchParams:r,frameStateRef:i}){const o=U((()=>{const{id:t,path:i,type:o}={id:Dn((a=n).id),path:An(a.path),type:a.type};var a;return{id:t,type:o,path:i,preview:r.preview||`${e.pathname}${e.search}`,perspective:r.perspective,viewport:r.viewport,inspect:r.inspect,rev:r.rev,since:r.since,template:r.template,templateParams:r.templateParams,view:r.view,pathKey:r.pathKey,instruction:r.instruction,comment:r.comment}}),[n,r,e]),a=U((()=>_n({inspect:o.inspect,path:o.path,rev:o.rev,since:o.since,template:o.template,templateParams:o.templateParams,view:o.view,pathKey:o.pathKey,instruction:o.instruction,comment:o.comment})),[o.comment,o.inspect,o.instruction,o.path,o.pathKey,o.rev,o.since,o.template,o.templateParams,o.view]),s=D(n);j((()=>{s.current=n}),[n]);return{structureParams:a,navigate:U((()=>Nt(((e,n={},r)=>{e.id&&(e.id=B(e.id));const{_searchParams:o,...a}=s.current,c=(o||[]).reduce(((e,[t,n])=>(e[t]=n,e)),{}),l=_n({...a,...e}),d=_n({...c,...n});a.id!==l.id&&(delete d.template,delete d.templateParams),l._searchParams=Object.entries(d).reduce(((e,[t,n])=>[...e,[t,n]]),[]);const u=null!=r?r:d.preview===i.current.url;t(l,{replace:u})}),50)),[t,i]),params:o}}function Mn(e,t,n){var r,i;const o=q({apiVersion:ue}),a=K(),s=(null==(r=null==a?void 0:a.activeWorkspace)?void 0:r.basePath)||"/",c=(null==(i=null==a?void 0:a.activeWorkspace)?void 0:i.name)||"default",l=function(e,t,n,r){const[i,o]=$((()=>r||"")),a=D(0);j((()=>{if(i&&r)return window.clearTimeout(a.current),()=>{a.current=window.setTimeout((()=>{o("")}),100)}}),[i,r]);const s=G();return U((()=>["@sanity/presentation",t,n,e,null==s?void 0:s.id,Nn,i]),[t,null==s?void 0:s.id,e,n,i])}(t,s,c,n),d=function(e,t){const n=q({apiVersion:ue}),r=G(),[i,o]=$(""),a=e?We((async()=>await De(n,"@sanity/presentation",typeof window>"u"?"":location.href,null==r?void 0:r.id)),[...t,i]):null;return j((()=>{if(!a)return;const e=setTimeout((()=>{W((()=>o(a.expiresAt.toString())))}),a.expiresAt.getTime()-Date.now());return()=>clearTimeout(e)}),[a]),(null==a?void 0:a.secret)||null}("object"==typeof e||"function"==typeof e,l);return We((async()=>{if("string"==typeof e){const t=new URL(e,location.origin);let r=t;try{if(n){const e=new URL(n,t);e.origin===t.origin&&(r=e)}else if(document.referrer){const e=new URL(document.referrer);e.origin===t.origin&&(r=e)}}catch{}return location.origin!==r.origin||!r.pathname.startsWith(`${s}/`)&&r.pathname!==s?r:t}const t=await("object"==typeof e?_e(e):e)({client:o,previewUrlSecret:d,previewSearchParam:n,referrer:typeof document>"u"?null:document.referrer,studioBasePath:s});return new URL(t,location.origin)}),[...l,d])}const Nn=Symbol();const Fn=F((()=>import("./LoaderQueries.js"))),Vn=F((()=>import("./PostMessageRefreshMutations.js"))),Bn=se(s)`
`),Un=function(e){var t;const{basePath:r="/"}=(null==(t=J())?void 0:t.activeWorkspace)||{},{fontSize:o=1,onChange:a,origin:s,padding:c=3,prefix:l,suffix:d,value:u}=e,p=_(null),[h,m]=$(void 0),[f,v]=$(void 0),g=j((e=>{m(e.currentTarget.value)}),[]),w=j((e=>{var t;if("Enter"===e.key){if(void 0===h)return;const e=h.startsWith("/")||""===h?`${s}${h}`:h;if(!e.startsWith(s+"/")&&e!==s)return void v(`URL must start with ${s}`);if(!s&&(e.startsWith(`${r}/`)||e===r))return void v(`URL can't have the same base path as the Studio ${r}`);const n=e===s?s+"/":e;v(void 0),m(void 0),a(n.slice(s.length)),null==(t=p.current)||t.blur()}"Escape"===e.key&&(v(void 0),m(void 0))}),[r,a,s,h]),b=j((()=>{v(void 0),m(void 0)}),[]);L((()=>{v(void 0),m(void 0)}),[s,u]);const x=U((()=>({icon:Ee})),[]);return n(i,{children:n(y,{clearButton:f?x:void 0,customValidity:f,fontSize:o,onBlur:b,onClear:()=>{v(void 0),m(s+u)},onChange:g,onKeyDownCapture:w,padding:c,prefix:l,style:{zIndex:1},radius:2,ref:p,space:c,suffix:d,value:void 0===h?`${s}${u}`:h})})};function _n(e){const{initialUrl:t,openPopup:o,previewLocationOrigin:a,previewLocationRoute:s}=e,c=j((e=>{e.preventDefault(),o(e.currentTarget.href)}),[o]);return r(i,{children:[n($n,{initialUrl:t,previewLocationOrigin:a,previewLocationRoute:s}),n(w,{icon:ke,text:"Open preview",as:"a",href:`${a}${s}`,onClick:c,rel:"opener",target:"_blank"})]})}function $n(e){const{initialUrl:t,previewLocationOrigin:r,previewLocationRoute:i}=e,{push:o}=b(),a=X({apiVersion:de}),s=H(),[c,l]=$(!1);return n(w,{disabled:c,onClick:()=>{if(null==navigator||!navigator.clipboard)return o({closable:!0,status:"error",title:"Clipboard not supported"}),!1;l(!0);let e,n=`${r}${i}`;const c=()=>{o({id:e,closable:!0,status:"success",title:"The URL is copied to the clipboard"}),l(!1)},d=e=>{o({closable:!0,status:"error",title:"Copy failed",description:e.message||e.toString()}),l(!1)};if(Le(t)&&typeof ClipboardItem<"u"){const r="text/plain",l=async()=>{e=o({closable:!0,title:"Copying URL to clipboard…"});const c=await Fe(a,"@sanity/presentation",typeof window>"u"?"":location.href,null==s?void 0:s.id);return n=Te(t,c.secret,i).toString(),new Blob([n],{type:r})},u=new ClipboardItem({[r]:l()});navigator.clipboard.write([u]).then(c).catch(d)}else navigator.clipboard.writeText(n).then(c).catch(d)},text:"Copy link",icon:Se})}const jn=Me(s),Ln={previewDrafts:"Drafts",published:"Published"},Tn="caution",An="positive",Mn={previewDrafts:_e,published:$e},Wn=T((function(e,t){const{dispatch:o,iframe:c,initialUrl:u,loadersConnection:v,navigatorEnabled:g,onPathChange:y,onRefresh:b,openPopup:z,overlaysConnection:D,params:O,perspective:R,targetOrigin:_,toggleNavigator:T,toggleOverlay:A,viewport:W,visualEditing:{overlaysEnabled:N}}=e,{devMode:F}=ae(),V=x(),B=j((()=>o({type:bn,viewport:"desktop"})),[o]),K=j((()=>o({type:bn,viewport:"mobile"})),[o]),q="loading"===c.status||"reloading"===c.status,[G,J]=$(!1),X="refreshing"===c.status,[H,Q]=$(!1),Y=q||X||"connecting"===D,ee=U((()=>_===location.origin?"":_),[_]),te=j((()=>{b((()=>{"function"==typeof t||null==t||!t.current||(o({type:yn}),t.current.src=`${_}${O.preview||"/"}`)}))}),[o,b,O.preview,_,t]),ne=j((()=>{"function"==typeof t||null==t||!t.current||(t.current.src=u.toString(),o({type:yn}))}),[o,t,u]),re=j((()=>{oe(!0)}),[]),[ie,oe]=$(!1),[se,ce]=$(!1);L((()=>{if(!(q||X||"connecting"!==D&&"reconnecting"!==D)){const e=setTimeout((()=>{ce(!0)}),1e3);return()=>clearTimeout(e)}}),[D,q,X]),L((()=>{if(!q&&!X&&se){if("connected"===D&&(Q(!1),ce(!1),J(!1),oe(!1)),"connecting"===D){const e=setTimeout((()=>{J(!0),console.error("Unable to connect to visual editing. Make sure you've setup '@sanity/visual-editing' correctly")}),ue);return()=>clearTimeout(e)}if("reconnecting"===D){const e=setTimeout((()=>{J(!0),Q(!0)}),ue);return()=>clearTimeout(e)}"disconnected"===D&&Q(!0)}}),[q,D,X,se]);const le=U((()=>{const e=new URL(O.preview||"/",_),{pathname:t,search:n}=Ae(e);return`${t}${n}`}),[O.preview,_]),de=j((()=>{o({type:vn})}),[o]);return L((()=>{if("function"==typeof t||null==t||!t.current)return;const e=t.current;function n(){e===document.activeElement&&e.dispatchEvent(new MouseEvent("mousedown",{bubbles:!0,cancelable:!0}))}return window.addEventListener("blur",n),()=>{window.removeEventListener("blur",n)}}),[t]),n(We,{transition:V?{duration:0}:void 0,children:r(P,{delay:1e3,children:[n(a,{flex:"none",padding:2,shadow:1,style:{position:"relative"},children:r(s,{align:"center",style:{minHeight:0},children:[T&&n(p,{flex:"none",marginRight:1,padding:1,children:n(E,{animate:!0,content:n(d,{size:1,children:"Toggle navigator"}),fallbackPlacements:["bottom-start"],padding:2,placement:"bottom",portal:!0,children:n(h,{"aria-label":"Toggle navigator",fontSize:1,icon:Ie,mode:"bleed",onClick:T,padding:2,selected:g})})}),n(E,{animate:!0,content:r(s,{align:"center",style:{whiteSpace:"nowrap"},children:[n(p,{padding:1,children:n(d,{size:1,children:N?"Disable edit overlay":"Enable edit overlay"})}),n(p,{paddingY:1,children:n(Z,{keys:["Alt"],style:{marginTop:-4,marginBottom:-4}})})]}),fallbackPlacements:["bottom-start"],padding:1,placement:"bottom",portal:!0,children:n(a,{as:"label",flex:"none",marginRight:1,padding:3,style:{lineHeight:0,borderRadius:999,userSelect:"none"},tone:N?"transparent":void 0,children:r(s,{align:"center",gap:3,children:[n("div",{style:{margin:-4},children:n(k,{checked:N,onChange:A,disabled:"loading"===c.status||"connected"!==D})}),n(p,{children:n(d,{muted:!N,size:1,weight:"medium",children:"Edit"})})]})})}),n(p,{flex:1,marginX:1,children:n(Un,{prefix:n(p,{padding:1,children:n(E,{animate:!0,content:n(d,{size:1,children:"loading"===c.status?"Loading…":"reloading"===c.status||"refreshing"===c.status?"Refreshing…":"Refresh preview"}),fallbackPlacements:["bottom-start"],padding:2,placement:"bottom",portal:!0,children:n(h,{"aria-label":"Refresh preview",fontSize:1,icon:Ce,mode:"bleed",loading:"reloading"===c.status||"refreshing"===c.status,onClick:te,padding:2})})}),onChange:y,origin:ee,suffix:n(p,{padding:1,children:n(S,{button:n(h,{fontSize:1,iconRight:ze,mode:"bleed",padding:2,space:2}),id:"location-menu",menu:n(I,{children:n(_n,{initialUrl:u,openPopup:z,previewLocationOrigin:ee,previewLocationRoute:le})}),popover:{animate:!0,constrainSize:!0,placement:"bottom",portal:!0}})}),value:le})}),n(s,{align:"center",flex:"none",gap:1,padding:1,children:n(S,{button:n(h,{fontSize:1,iconRight:De,mode:"bleed",padding:2,space:2,text:Ln["connected"===v?R:"previewDrafts"],loading:"reconnecting"===v&&"loaded"!==c.status,disabled:"connected"!==v}),id:"perspective-menu",menu:r(I,{style:{maxWidth:240},children:[n(w,{fontSize:1,onClick:()=>o({type:wn,perspective:"previewDrafts"}),padding:3,pressed:"previewDrafts"===R,tone:Tn,children:r(s,{align:"flex-start",gap:3,children:[n(p,{flex:"none",children:n(d,{size:1,children:M(Mn.previewDrafts)})}),r(l,{flex:1,space:2,children:[n(d,{size:1,weight:"medium",children:Ln.previewDrafts}),n(d,{muted:!0,size:1,children:"View this page with latest draft content"})]}),n(p,{flex:"none",children:n(d,{muted:!0,size:1,style:{opacity:"previewDrafts"===R?1:0},children:n(Oe,{})})})]})}),n(w,{fontSize:1,onClick:()=>o({type:wn,perspective:"published"}),padding:3,pressed:"published"===R,tone:An,children:r(s,{align:"flex-start",gap:3,children:[n(p,{flex:"none",children:n(d,{size:1,children:M(Mn.published)})}),r(l,{flex:1,space:2,children:[n(d,{size:1,weight:"medium",children:Ln.published}),n(d,{muted:!0,size:1,children:"View this page with published content"})]}),n(p,{flex:"none",children:n(d,{muted:!0,size:1,style:{opacity:"published"===R?1:0},children:n(Oe,{})})})]})})]}),popover:{animate:!0,constrainSize:!0,placement:"bottom",portal:!0}})}),r(s,{align:"center",flex:"none",gap:1,padding:1,children:[n(E,{animate:!0,content:n(d,{size:1,children:"Full viewport"}),fallbackPlacements:["bottom-start"],padding:2,placement:"bottom",portal:!0,children:n(h,{"aria-label":"Full viewport",fontSize:1,icon:Re,mode:"bleed",onClick:B,padding:2,selected:"desktop"===W})}),n(E,{animate:!0,content:n(d,{size:1,children:"Narrow viewport"}),padding:2,placement:"bottom",portal:!0,children:n(h,{"aria-label":"Narrow viewport",fontSize:1,icon:Ue,mode:"bleed",onClick:K,padding:2,selected:"mobile"===W})})]})]})}),n(a,{flex:1,tone:"transparent",children:r(s,{align:"center",height:"fill",justify:"center",padding:"desktop"===W?0:2,sizing:"border",style:{position:"relative",cursor:Y?"wait":void 0},children:[n(Ne,{children:H||q||X||!se||ie?(q||"connecting"===D&&"refreshing"!==c.status)&&!ie?n(jn,{initial:"initial",animate:"animate",exit:"exit",variants:Fn,justify:"center",align:"center",style:{inset:"0",position:"absolute"},children:r(s,{style:{...Nn[W]},justify:"center",align:"center",direction:"column",gap:4,children:[n(C,{muted:!0}),n(d,{muted:!0,size:1,children:"Loading…"})]})}):H&&!ie?n(jn,{initial:"initial",animate:"animate",exit:"exit",variants:Vn,justify:"center",align:"center",style:{background:"var(--card-bg-color)",inset:"0",position:"absolute",borderTop:"1px solid transparent",boxShadow:"0 0 0 1px var(--card-border-color)"},children:n(qt,{flex:1,message:"Could not connect to the preview",onRetry:ne,onContinueAnyway:re,children:F&&r(i,{children:["connected"!==D&&n(a,{padding:3,radius:2,tone:"critical",children:r(l,{space:3,children:[n(f,{muted:!0,size:0,children:"Overlay connection status"}),n(m,{size:1,children:D})]})}),"connected"!==v&&n(a,{padding:3,radius:2,tone:"critical",children:r(l,{space:3,children:[n(f,{muted:!0,size:0,children:"Loader connection status"}),n(m,{size:1,children:v})]})})]})})}):null:n(jn,{initial:"initial",animate:"animate",exit:"exit",variants:Fn,justify:"center",align:"center",style:{inset:"0",position:"absolute",backdropFilter:G?"blur(16px) saturate(0.5) grayscale(0.5)":"blur(2px)",transition:"backdrop-filter 0.2s ease-in-out",WebkitBackdropFilter:G?"blur(16px) saturate(0.5) grayscale(0.5)":"blur(2px)",WebkitTransition:"-webkit-backdrop-filter 0.2s ease-in-out",zIndex:1},children:r(s,{style:{...Nn[W]},justify:"center",align:"center",direction:"column",gap:4,children:[G&&n(h,{disabled:!0,fontSize:1,mode:"ghost",text:"Continue anyway",style:{opacity:0}}),n(a,{radius:2,tone:G?"caution":"inherit",padding:4,shadow:1,children:r(s,{justify:"center",align:"center",direction:"column",gap:4,children:[n(C,{muted:!0}),n(d,{muted:!0,size:1,children:G?n(i,{children:"Unable to connect, check the browser console for more information."}):"Connecting…"})]})}),G&&n(h,{fontSize:1,tone:"critical",onClick:re,text:"Continue anyway"})]})})}),n(Rn,{ref:t,style:{pointerEvents:(q||"connecting"===D&&"refreshing"!==c.status)&&!ie?"none":"auto",boxShadow:"0 0 0 1px var(--card-border-color)",borderTop:"1px solid transparent"},src:u.toString(),initial:["background"],variants:Bn,animate:[(q||"connecting"===D&&"refreshing"!==c.status)&&!ie?"background":"active",q?"reloading":"idle",W,se&&!ie?"timedOut":""],onLoad:de})]})})]})})})),Nn={desktop:{width:"100%",height:"100%"},mobile:{width:375,height:650}},Fn={initial:{opacity:1},animate:{opacity:[0,0,1]},exit:{opacity:[1,0,0]}},Vn={initial:{opacity:1},animate:{opacity:[0,0,1]},exit:{opacity:[1,0,0]}},Bn={desktop:{...Nn.desktop,boxShadow:"0 0 0 0px var(--card-border-color)"},mobile:{...Nn.mobile,boxShadow:"0 0 0 1px var(--card-border-color)"},background:{opacity:0,scale:1},idle:{scale:1},reloading:{scale:[1,1,1,.98]},active:{opacity:[0,0,1],scale:1},timedOut:{opacity:[0,0,1]}};let Kn=!1;function qn(e,t){return e instanceof Function?e(t):e}function Gn(e,t){const n=Array.isArray(e)?e:[e];for(e of n){let n,r=e;if("string"==typeof e)try{const t=new URL(e);n=t.origin,r=t.pathname}catch{}if(!n||t.origin===n)try{const e=Be(r,{decode:decodeURIComponent})(t.pathname);if(e){const{params:t,path:r}=e;return{origin:n,params:t,path:r}}}catch{throw new Error(`"${e}" is not a valid route pattern`)}}}function Jn(e){const{navigate:t,resolvers:n=[],path:r,previewUrl:i}=e,{state:o}=re(),a=Q(),s=X({apiVersion:de}),[c,l]=$(void 0),d=_(void 0),u=U((()=>{var e,t;const n=r||(null==(t=null==(e=o._searchParams)?void 0:e.find((([e])=>"preview"===e)))?void 0:t[1])||"",a="string"==typeof i?i:"object"==typeof i?null==i?void 0:i.origin:location.origin;return new URL(n,a)}),[r,i,o._searchParams]),p=j((()=>{l(void 0),d.current=void 0}),[]);return L((()=>{if(n.length&&u){let c;for(const e of n){const t=Gn(e.route,u);if(t){c={context:t,resolver:e};break}}if(c){const n=function(e,t){var n;if(e.resolve){const r=null==(n=e.resolve(t))?void 0:n.filter;return r?`*[${r}][0]{_id, _type}`:void 0}return"type"in e?`*[_type == "${e.type}"][0]{_id, _type}`:`*[${qn(e.filter,t)}][0]{_id, _type}`}(c.resolver,c.context),p=(e=c.resolver,r=c.context,e.resolve?null!=(o=null==(i=e.resolve(r))?void 0:i.params)?o:r.params:"type"in e?{}:null!=(a=qn(e.params,r))?a:r.params);if(n){const e=new AbortController,r={perspective:"previewDrafts",signal:e.signal};return s.fetch(n,p,r).then((e=>{(!e||d.current!==e._id)&&(l({document:e,path:u.pathname}),null==t||t({id:null==e?void 0:e._id,type:null==e?void 0:e._type}),d.current=null==e?void 0:e._id)})).catch((e=>{e instanceof Error&&"AbortError"===e.name||(l({document:void 0,path:u.pathname}),d.current=void 0)})),()=>{e.abort()}}}}var e,r,i,o,a;p()}),[s,p,a,t,n,u]),c}function Xn(e){var t;if(void 0===e)return;const n=null==(t=decodeURIComponent(e))?void 0:t.split(".");return"drafts"===n[0]&&n.shift(),n.join(".")}function Hn(e){if(void 0!==e)return o.toString(function(e){const t=[];for(const n of e.split(".")){const e=Et.exec(n);if(e){t.push(e[1],Number(e[2]));continue}const r=kt.exec(n);if(r){t.push(r[1],[Number(r[2]),Number(r[3])]);continue}const i=St.exec(n);i?t.push(i[1],{_key:i[2]}):t.push(n)}return t}(decodeURIComponent(e)))}function Zn(e){return Object.fromEntries(Object.entries(e).filter((([,e])=>void 0!==e&&""!==e&&null!==e)))}function Qn({initialPreviewUrl:e,routerNavigate:t,routerState:n,routerSearchParams:r,frameStateRef:i}){const o=U((()=>{const{id:t,path:i,type:o}={id:Xn((a=n).id),path:Hn(a.path),type:a.type};var a;return{id:t,type:o,path:i,preview:r.preview||`${e.pathname}${e.search}`,perspective:r.perspective,viewport:r.viewport,inspect:r.inspect,rev:r.rev,since:r.since,template:r.template,templateParams:r.templateParams,view:r.view,pathKey:r.pathKey,instruction:r.instruction,comment:r.comment}}),[n,r,e]),a=U((()=>Zn({inspect:o.inspect,path:o.path,rev:o.rev,since:o.since,template:o.template,templateParams:o.templateParams,view:o.view,pathKey:o.pathKey,instruction:o.instruction,comment:o.comment})),[o.comment,o.inspect,o.instruction,o.path,o.pathKey,o.rev,o.since,o.template,o.templateParams,o.view]),s=_(n);L((()=>{s.current=n}),[n]);return{structureParams:a,navigate:j(((e,n={},r)=>{e.id&&(e.id=K(e.id));const{_searchParams:o,...a}=s.current,c=(o||[]).reduce(((e,[t,n])=>(e[t]=n,e)),{}),l=Zn({...a,...e}),d=Zn({...c,...n});a.id!==l.id&&(delete d.template,delete d.templateParams),l._searchParams=Object.entries(d).reduce(((e,[t,n])=>[...e,[t,n]]),[]);const u=null!=r?r:d.preview===i.current.url;t(l,{replace:u})}),[t,i]),params:o}}function Yn(e,t,n){var r,i;const o=X({apiVersion:de}),a=J(),s=(null==(r=null==a?void 0:a.activeWorkspace)?void 0:r.basePath)||"/",c=(null==(i=null==a?void 0:a.activeWorkspace)?void 0:i.name)||"default",l=function(e,t,n,r){const[i,o]=$((()=>r||"")),a=_(0);L((()=>{if(i&&r)return window.clearTimeout(a.current),()=>{a.current=window.setTimeout((()=>{o("")}),100)}}),[i,r]);const s=H();return U((()=>["@sanity/presentation",t,n,e,null==s?void 0:s.id,er,i]),[t,null==s?void 0:s.id,e,n,i])}(t,s,c,n),d=function(e,t){const n=X({apiVersion:de}),r=H(),[i,o]=$(""),a=e?qe((async()=>await Fe(n,"@sanity/presentation",typeof window>"u"?"":location.href,null==r?void 0:r.id)),[...t,i]):null;return L((()=>{if(!a)return;const e=setTimeout((()=>{W((()=>o(a.expiresAt.toString())))}),a.expiresAt.getTime()-Date.now());return()=>clearTimeout(e)}),[a]),(null==a?void 0:a.secret)||null}("object"==typeof e||"function"==typeof e,l);return qe((async()=>{if("string"==typeof e){const t=new URL(e,location.origin);let r=t;try{if(n){const e=new URL(n,t);e.origin===t.origin&&(r=e)}else if(document.referrer){const e=new URL(document.referrer);e.origin===t.origin&&(r=e)}}catch{}return location.origin!==r.origin||!r.pathname.startsWith(`${s}/`)&&r.pathname!==s?r:t}const t=await("object"==typeof e?Ke(e):e)({client:o,previewUrlSecret:d,previewSearchParam:n,referrer:typeof document>"u"?null:document.referrer,studioBasePath:s});return new URL(t,location.origin)}),[...l,d])}const er=Symbol();const tr=V((()=>import("./LoaderQueries.js"))),nr=V((()=>import("./PostMessageRefreshMutations.js"))),rr=oe(s)`
overflow-x: auto;
`;function Kn(e){var t;const{previewUrl:a,components:c}=null!=(t=e.tool.options)?t:{},l=e.tool.name||ve,{unstable_navigator:d}=c||{},{navigate:u,state:p}=Y(),h=V(Object.fromEntries(p._searchParams||[])),f=Mn(a||"/",l,h.preview||null),[m]=$((()=>{var t;const n=null==(t=e.tool.options)?void 0:t.devMode;return"function"==typeof n?n():"boolean"==typeof n?n:typeof window<"u"&&"localhost"===window.location.hostname})),v=U((()=>f.origin),[f.origin]),g=D(null),[y,w]=$(),[b,x]=$({}),P=D({title:void 0,url:void 0}),{navigate:E,params:k,structureParams:S}=Wn({initialPreviewUrl:f,routerNavigate:u,routerState:p,routerSearchParams:h,frameStateRef:P}),[I,C]=M(hn,{perspective:k.perspective,viewport:k.viewport},bn),[O,L]=function(e,t){if("published"!==e&&"previewDrafts"!==e)throw new Error(`Invalid perspective: ${e}`);const[n,r]=$({}),[i,o]=$({}),a=D(""),s=R(((e,n,i=[])=>{const s=i.filter((e=>"_projectId"in e&&e._projectId?(Tn||(console.warn("Cross dataset references are not supported yet, ignoring source document",e),Tn=!0),!1):e));("published"===n?r:o)((n=>{const r={};for(const e of s)r[e._id]=e;if(a.current!==t.current.url)return a.current=t.current.url,{[e]:r};const i=n[e];return Ae(i,r)?n:{...n,[e]:r}}))}),[t]);return[U((()=>{const t=Object.values("published"===e?n:i).reduce(((e,t)=>(Object.values(t).forEach((t=>{e[t._id]=t})),e)),{});return Object.values(t)}),[e,i,n]),s]}(I.perspective,P),T=X(),A=H();j((()=>{(I.perspective!==k.perspective||I.viewport!==k.viewport)&&E({},{perspective:"previewDrafts"===I.perspective?void 0:I.perspective,viewport:"desktop"===I.viewport?void 0:I.viewport})}),[k.perspective,I.perspective,E,I.viewport,k.viewport]);const[_,F]=$("connecting"),[B,K]=$("connecting"),[q,G]=$("connecting"),[J]=$((()=>new Set)),Q=R((e=>{const t=window.open(e,"_blank");t&&J.add(t)}),[J]);j((()=>{if(J.size&&y)for(const e of J)e&&"closed"in e&&!e.closed&&y.addSource(e)}),[y,J,J.size]),j((()=>{var e;const t=null==(e=g.current)?void 0:e.contentWindow;if(!t)return;const n=function(e){const{destroy:t,send:n}=Qe(e),r=new Set,i=new WeakMap,o=new Set;return{destroy:()=>{t();for(const e of o)e()},send:(e,...t)=>{n(e,...t);for(const n of r)n&&"closed"in n&&!n.closed&&i.has(n)&&i.get(n)(e,...t)},addSource(t){if(r.has(t))return;if(!("closed"in t))throw console.warn("Source is unsupported",{source:t}),new Error("Source is unsupported");if(t.closed)throw new Error("Source is closed");const{send:n,destroy:a}=Qe({...e,target:t,connectTo:e.connectTo.map((e=>{const{onStatusUpdate:t,onEvent:n,...r}=e;return{...r,onEvent:n?(...e)=>{const[t]=e;if("preview-kit/documents"!==t&&"overlay/navigate"!==t&&"loader/documents"!==t)return n(...e)}:void 0}}))});o.add(a),i.set(t,n),r.add(t)}}}({id:"presentation",target:t,targetOrigin:v,connectTo:[{id:"overlays",heartbeat:!0,onStatusUpdate:F,onEvent(e,t){if("visual-editing/focus"!==e&&"overlay/focus"!==e||!("id"in t))if("visual-editing/navigate"===e||"overlay/navigate"===e){const{title:e,url:n}=t;P.current.url!==n&&E({},{preview:n}),P.current={title:e,url:n}}else"visual-editing/meta"===e?P.current.title=t.title:"visual-editing/toggle"===e||"overlay/toggle"===e?C({type:pn,enabled:t.enabled}):"visual-editing/documents"===e?L("visual-editing",t.perspective,t.documents):"visual-editing/refreshing"===e&&"manual"===t.source?clearTimeout(ye.current):"visual-editing/refreshing"===e&&"mutation"===t.source?C({type:cn}):"visual-editing/refreshed"===e&&C({type:sn});else E({type:t.type,id:t.id,path:t.path})}},{id:"loaders",heartbeat:!0,onStatusUpdate:K,onEvent(e,t){if("loader/documents"===e&&t.projectId===T&&t.dataset===A)L("loaders",t.perspective,t.documents);else if("loader/query-listen"===e&&t.projectId===T&&t.dataset===A){if("number"==typeof t.heartbeat&&t.heartbeat<he)throw new Error(`Loader query listen heartbeat interval must be at least ${he}ms`);x((e=>{var n;return{...e,[yt(t.query,t.params)]:{perspective:t.perspective,query:t.query,params:t.params,receivedAt:Date.now(),heartbeat:null!=(n=t.heartbeat)&&n}}}))}}},{id:"preview-kit",heartbeat:!0,onStatusUpdate:G,onEvent(e,t){"preview-kit/documents"===e&&t.projectId===T&&t.dataset===A&&L("preview-kit",t.perspective,t.documents)}}]});return w(n),()=>{n.destroy(),w(void 0)}}),[A,T,L,E,v]),j((()=>{const e=setInterval((()=>W((()=>x((e=>{if(Object.keys(e).length<1)return e;const t=Date.now();if(!Object.values(e).some((e=>!1!==e.heartbeat&&t>e.receivedAt+e.heartbeat)))return e;const n={};for(const[r,i]of Object.entries(e))!1!==i.heartbeat&&t>i.receivedAt+i.heartbeat||(n[r]=i);return n}))))),he);return()=>clearInterval(e)}),[]);const ee=R((e=>{E({path:o.toString(e)},{},!0)}),[E]),te=R((e=>{const t=new URL(e,f.origin),n=t.pathname+t.search;t.origin===f.origin&&n!==k.preview&&E({},{preview:n})}),[f,k,E]),ne=R((e=>{E({},e)}),[E]);j((()=>{null==y||y.send("overlays","presentation/perspective",{perspective:I.perspective})}),[y,I.perspective]),j((()=>{k.id&&k.path?null==y||y.send("overlays","presentation/focus",{id:k.id,path:k.path}):null==y||y.send("overlays","presentation/blur",void 0)}),[y,k.id,k.path]),j((()=>{P.current.url&&k.preview&&P.current.url!==k.preview&&(P.current.url=k.preview,"connected"!==_&&g.current?g.current.src=`${v}${k.preview}`:null==y||y.send("overlays","presentation/navigate",{url:k.preview,type:"replace"}))}),[y,_,v,k.preview]);const re=R((()=>null==y?void 0:y.send("overlays","presentation/toggleOverlay",void 0)),[y]),[ie,oe]=$(null);j((()=>{const e=e=>{bt(e)&&re()},t=e=>{var t;bt(e)&&re(),t=e,["mod","\\"].every((e=>wt[e]?t[wt[e]]:t.key===e.toUpperCase()))&&re()};return window.addEventListener("keydown",t),window.addEventListener("keyup",e),()=>{window.removeEventListener("keydown",t),window.removeEventListener("keyup",e)}}),[re]);const[se,ce]=$(null),[{navigatorEnabled:le,toggleNavigator:de},ue]=nn({unstable_navigator:d}),pe=D(k.id);j((()=>{k.rev&&pe.current&&k.id!==pe.current&&E({},{rev:void 0}),pe.current=k.id}));const ye=D(),we=R((e=>{if(C({type:cn}),y)return ye.current=window.setTimeout(e,300),void y.send("overlays","presentation/refresh",{source:"manual",livePreviewEnabled:"connected"===q||"connected"===B});e()}),[y,B,q]),be=Z(),xe=R((({id:e,type:t,path:n})=>{if(P.current.url)return{title:P.current.title||P.current.url,name:"edit",params:{id:e,path:n,type:t,inspect:fe,workspace:be.name,mode:me,preview:k.preview}}}),[k.preview,be.name]);return r(i,{children:[n(an,{devMode:m,name:l,navigate:E,params:k,structureParams:S,children:n(tn,{navigate:E,children:n(on,{params:k,children:n(Bn,{height:"fill",children:r(en,{children:[n(ue,{}),n(At,{id:"preview",minWidth:325,defaultSize:le?50:75,order:3,children:n(s,{direction:"column",flex:1,height:"fill",ref:ce,children:n(z,{element:se,children:n(Rn,{dispatch:C,iframe:I.iframe,initialUrl:f,loadersConnection:B,navigatorEnabled:le,onPathChange:te,onRefresh:we,openPopup:Q,overlaysConnection:_,params:k,perspective:I.perspective,ref:g,targetOrigin:v,toggleNavigator:de,toggleOverlay:re,viewport:I.viewport,visualEditing:I.visualEditing})})})}),n(Mt,{order:4}),n(At,{id:"content",minWidth:325,order:5,children:n(ge,{documentId:k.id,setDisplayedDocument:oe,children:n(ae,{getIntent:xe,children:n(Lt,{documentId:k.id,documentType:k.type,onFocusPath:ee,onStructureParams:ne,previewUrl:k.preview,refs:O,structureParams:S})})})})]})})})})}),y&&n(N,{children:n(Fn,{channel:y,liveQueries:b,perspective:I.perspective,liveDocument:ie,documentsOnPage:O})}),y&&k.id&&k.type&&n(N,{children:n(Vn,{channel:y,id:k.id,type:k.type,loadersConnection:B,previewKitConnection:q})})]})}export{Kn as default};//# sourceMappingURL=PresentationTool.js.map
`;function ir(e){var t,a,c,l;const{previewUrl:d,components:u}=null!=(t=e.tool.options)?t:{},p=e.tool.name||fe,{unstable_navigator:h}=u||{},{navigate:m,state:f}=re(),v=B(Object.fromEntries(f._searchParams||[])),g=Yn(d||"/",p,v.preview||null),[y]=$((()=>{var t;const n=null==(t=e.tool.options)?void 0:t.devMode;return"function"==typeof n?n():"boolean"==typeof n?n:typeof window<"u"&&"localhost"===window.location.hostname})),w=U((()=>g.origin),[g.origin]),b=_(null),[x,P]=$(),[E,k]=$({}),S=_({title:void 0,url:void 0}),{navigate:I,params:C,structureParams:D}=Qn({initialPreviewUrl:g,routerNavigate:m,routerState:f,routerSearchParams:v,frameStateRef:S}),O=U((()=>Dt(I,50)),[I]),[R,T]=N(Pn,{perspective:C.perspective,viewport:C.viewport},On),[A,M]=function(e,t){if("published"!==e&&"previewDrafts"!==e)throw new Error(`Invalid perspective: ${e}`);const[n,r]=$({}),[i,o]=$({}),a=_(""),s=j(((e,n,i=[])=>{const s=i.filter((e=>"_projectId"in e&&e._projectId?(Kn||(console.warn("Cross dataset references are not supported yet, ignoring source document",e),Kn=!0),!1):e));("published"===n?r:o)((n=>{const r={};for(const e of s)r[e._id]=e;if(a.current!==t.current.url)return a.current=t.current.url,{[e]:r};const i=n[e];return Ve(i,r)?n:{...n,[e]:r}}))}),[t]);return[U((()=>{const t=Object.values("published"===e?n:i).reduce(((e,t)=>(Object.values(t).forEach((t=>{e[t._id]=t})),e)),{});return Object.values(t)}),[e,i,n]),s]}(R.perspective,S),V=Y(),K=ee(),q=Jn({resolvers:null==(c=null==(a=e.tool.options)?void 0:a.resolve)?void 0:c.mainDocuments,previewUrl:null==(l=e.tool.options)?void 0:l.previewUrl,path:C.preview,navigate:I});L((()=>{(R.perspective!==C.perspective||R.viewport!==C.viewport)&&O({},{perspective:"previewDrafts"===R.perspective?void 0:R.perspective,viewport:"desktop"===R.viewport?void 0:R.viewport})}),[C.perspective,R.perspective,O,R.viewport,C.viewport]);const[G,J]=$("connecting"),[X,H]=$("connecting"),[Z,Q]=$("connecting"),[ne]=$((()=>new Set)),ie=j((e=>{const t=window.open(e,"_blank");t&&ne.add(t)}),[ne]);L((()=>{if(ne.size&&x)for(const e of ne)e&&"closed"in e&&!e.closed&&x.addSource(e)}),[x,ne,ne.size]),L((()=>{var e;const t=null==(e=b.current)?void 0:e.contentWindow;if(!t)return;const n=function(e){const{destroy:t,send:n}=ot(e),r=new Set,i=new WeakMap,o=new Set;return{destroy:()=>{t();for(const e of o)e()},send:(e,...t)=>{n(e,...t);for(const n of r)n&&"closed"in n&&!n.closed&&i.has(n)&&i.get(n)(e,...t)},addSource(t){if(r.has(t))return;if(!("closed"in t))throw console.warn("Source is unsupported",{source:t}),new Error("Source is unsupported");if(t.closed)throw new Error("Source is closed");const{send:n,destroy:a}=ot({...e,target:t,connectTo:e.connectTo.map((e=>{const{onStatusUpdate:t,onEvent:n,...r}=e;return{...r,onEvent:n?(...e)=>{const[t]=e;if("preview-kit/documents"!==t&&"overlay/navigate"!==t&&"loader/documents"!==t)return n(...e)}:void 0}}))});o.add(a),i.set(t,n),r.add(t)}}}({id:"presentation",target:t,targetOrigin:w,connectTo:[{id:"overlays",heartbeat:!0,onStatusUpdate:J,onEvent(e,t){if("visual-editing/focus"!==e&&"overlay/focus"!==e||!("id"in t))if("visual-editing/navigate"===e||"overlay/navigate"===e){const{title:e,url:n}=t;S.current.url!==n&&O({},{preview:n}),S.current={title:e,url:n}}else"visual-editing/meta"===e?S.current.title=t.title:"visual-editing/toggle"===e||"overlay/toggle"===e?T({type:xn,enabled:t.enabled}):"visual-editing/documents"===e?M("visual-editing",t.perspective,t.documents):"visual-editing/refreshing"===e&&"manual"===t.source?clearTimeout(xe.current):"visual-editing/refreshing"===e&&"mutation"===t.source?T({type:gn}):"visual-editing/refreshed"===e&&T({type:vn});else O({type:t.type,id:t.id,path:t.path})}},{id:"loaders",heartbeat:!0,onStatusUpdate:H,onEvent(e,t){if("loader/documents"===e&&t.projectId===V&&t.dataset===K)M("loaders",t.perspective,t.documents);else if("loader/query-listen"===e&&t.projectId===V&&t.dataset===K){if("number"==typeof t.heartbeat&&t.heartbeat<pe)throw new Error(`Loader query listen heartbeat interval must be at least ${pe}ms`);k((e=>{var n;return{...e,[It(t.query,t.params)]:{perspective:t.perspective,query:t.query,params:t.params,receivedAt:Date.now(),heartbeat:null!=(n=t.heartbeat)&&n}}}))}}},{id:"preview-kit",heartbeat:!0,onStatusUpdate:Q,onEvent(e,t){"preview-kit/documents"===e&&t.projectId===V&&t.dataset===K&&M("preview-kit",t.perspective,t.documents)}}]});return P(n),()=>{n.destroy(),P(void 0)}}),[K,V,M,O,w]),L((()=>{const e=setInterval((()=>W((()=>k((e=>{if(Object.keys(e).length<1)return e;const t=Date.now();if(!Object.values(e).some((e=>!1!==e.heartbeat&&t>e.receivedAt+e.heartbeat)))return e;const n={};for(const[r,i]of Object.entries(e))!1!==i.heartbeat&&t>i.receivedAt+i.heartbeat||(n[r]=i);return n}))))),pe);return()=>clearInterval(e)}),[]);const oe=j((e=>{O({path:o.toString(e)},{},!0)}),[O]),ae=j((e=>{const t=new URL(e,g.origin),n=t.pathname+t.search;t.origin===g.origin&&n!==C.preview&&O({},{preview:n})}),[g,C,O]),se=j((e=>{O({},e)}),[O]);L((()=>{null==x||x.send("overlays","presentation/perspective",{perspective:R.perspective})}),[x,R.perspective]),L((()=>{C.id&&C.path?null==x||x.send("overlays","presentation/focus",{id:C.id,path:C.path}):null==x||x.send("overlays","presentation/blur",void 0)}),[x,C.id,C.path]),L((()=>{S.current.url&&C.preview&&S.current.url!==C.preview&&(S.current.url=C.preview,"connected"!==G&&b.current?b.current.src=`${w}${C.preview}`:null==x||x.send("overlays","presentation/navigate",{url:C.preview,type:"replace"}))}),[x,G,w,C.preview]);const ce=j((()=>null==x?void 0:x.send("overlays","presentation/toggleOverlay",void 0)),[x]),[le,de]=$(null);L((()=>{const e=e=>{zt(e)&&ce()},t=e=>{var t;zt(e)&&ce(),t=e,["mod","\\"].every((e=>Ct[e]?t[Ct[e]]:t.key===e.toUpperCase()))&&ce()};return window.addEventListener("keydown",t),window.addEventListener("keyup",e),()=>{window.removeEventListener("keydown",t),window.removeEventListener("keyup",e)}}),[ce]);const[ue,ve]=$(null),[{navigatorEnabled:ge,toggleNavigator:ye},we]=pn({unstable_navigator:h}),be=_(C.id);L((()=>{C.rev&&be.current&&C.id!==be.current&&O({},{rev:void 0}),be.current=C.id}));const xe=_(),Pe=j((e=>{if(T({type:gn}),x)return xe.current=window.setTimeout(e,300),void x.send("overlays","presentation/refresh",{source:"manual",livePreviewEnabled:"connected"===Z||"connected"===X});e()}),[x,X,Z]),Ee=te(),ke=j((({id:e,type:t,path:n})=>{if(S.current.url)return{title:S.current.title||S.current.url,name:"edit",params:{id:e,path:n,type:t,inspect:he,workspace:Ee.name,mode:me,preview:C.preview}}}),[C.preview,Ee.name]);return r(i,{children:[n(fn,{devMode:y,name:p,navigate:O,params:C,structureParams:D,children:n(un,{navigate:O,children:n(mn,{params:C,children:n(rr,{height:"fill",children:r(Kt,{children:[n(we,{}),n(Ut,{id:"preview",minWidth:325,defaultSize:ge?50:75,order:3,children:n(s,{direction:"column",flex:1,height:"fill",ref:ve,children:n(z,{element:ue,children:n(Wn,{dispatch:T,iframe:R.iframe,initialUrl:g,loadersConnection:X,navigatorEnabled:ge,onPathChange:ae,onRefresh:Pe,openPopup:ie,overlaysConnection:G,params:C,perspective:R.perspective,ref:b,targetOrigin:w,toggleNavigator:ye,toggleOverlay:ce,viewport:R.viewport,visualEditing:R.visualEditing})})})}),n(dn,{mainDocumentState:q,params:C,documentsOnPage:A,getCommentIntent:ke,onFocusPath:oe,onStructureParams:se,setDisplayedDocument:de,structureParams:D})]})})})})}),x&&n(F,{children:n(tr,{channel:x,liveQueries:E,perspective:R.perspective,liveDocument:le,documentsOnPage:A})}),x&&C.id&&C.type&&n(F,{children:n(nr,{channel:x,id:C.id,type:C.type,loadersConnection:X,previewKitConnection:Z})})]})}export{ir as default};//# sourceMappingURL=PresentationTool.js.map

@@ -13,2 +13,31 @@ /// <reference types="react" />

/**
* @internal
*/
export declare type ContextFn<T> = (context: DocumentResolverContext) => T
/**
* Define documents for a given location.
* This function doesn't do anything itself, it is used to provide type information.
* @param resolvers - resolvers that return documents.
* @public
*/
export declare function defineDocuments(resolvers: DocumentResolver[]): typeof resolvers
/**
* Define locations for a given document type.
* This function doesn't do anything itself, it is used to provide type information.
* @param resolver - resolver that return locations for a document.
* @public
*/
export declare function defineLocations<K extends string>(
resolver: DocumentLocationResolverObject<K> | DocumentLocationsState,
): typeof resolver
/**
* Represents a document location
* @typeParam title - Title of the document
* @typeParam href - URL of the document location
* @public
*/
export declare interface DocumentLocation {

@@ -19,2 +48,9 @@ title: string

/**
* Function used for advanced document location resolution
* @param params - Object with document `id` and document `type` properties
* @param context - Object with `documentStore` property for creating listenQuery subscriptions
* @returns Document location state, optionally as an Observable, or null/undefined if no locations are available
* @public
*/
export declare type DocumentLocationResolver = (

@@ -34,2 +70,30 @@ params: {

/**
* Document location resolver object
* @typeParam select - object for selecting document fields
* @typeParam resolve - function that accepts a document with the selected fields and returns an optional document location state
* @public
*/
export declare type DocumentLocationResolverObject<K extends string = string> = {
select: Record<K, string>
resolve: (value: Record<K, any> | null) => DocumentLocationsState | null | undefined | void
}
/**
* Object of document location resolver definitions per document type
* @public
*/
export declare type DocumentLocationResolvers = Record<
string,
DocumentLocationResolverObject | DocumentLocationsState
>
/**
* State for describing document locations or providing a message if no document
* locations are unavailable
* @typeParam locations - Array of document locations
* @typeParam message - Message to display if locations are unavailable
* @typeParam tone - Tone of the message
* @public
*/
export declare interface DocumentLocationsState {

@@ -41,2 +105,49 @@ locations?: DocumentLocation[]

/**
* @internal
*/
export declare type DocumentLocationsStatus = 'empty' | 'resolving' | 'resolved'
/**
* Object for resolving a document for a given route pattern
* @public
*/
export declare type DocumentResolver =
| {
route: string | Array<string>
type: string
filter?: never
params?: never
resolve?: never
}
| {
route: string | Array<string>
type?: never
filter: ContextFn<string> | string
params?: ContextFn<Record<string, string>> | Record<string, string>
resolve?: never
}
| {
route: string | Array<string>
type?: never
filter?: never
params?: never
resolve: ContextFn<
| {
filter: string
params?: Record<string, string>
}
| undefined
>
}
/**
* @internal
*/
export declare interface DocumentResolverContext {
origin: string | undefined
params: Record<string, string>
path: string
}
/** @internal */

@@ -65,2 +176,18 @@ export declare interface FrameState {

/**
* @internal
*/
export declare interface MainDocument {
_id: string
_type: string
}
/**
* @internal
*/
export declare interface MainDocumentState {
path: string
document: MainDocument | undefined
}
export declare interface NavigatorOptions {

@@ -100,3 +227,10 @@ minWidth?: number

title?: string
/**
* @deprecated use `resolve.locations` instead
*/
locate?: DocumentLocationResolver
resolve?: {
mainDocuments?: DocumentResolver[]
locations?: DocumentLocationResolvers | DocumentLocationResolver
}
previewUrl: PreviewUrlOption

@@ -103,0 +237,0 @@ components?: {

@@ -1,1 +0,1 @@

import{p as e,u as s,e as a}from"./_chunks-es/index.js";export{e as presentationTool,s as usePresentationNavigate,a as usePresentationParams};//# sourceMappingURL=index.js.map
import{h as e,g as s,p as a,e as n,f as o}from"./_chunks-es/index.js";export{e as defineDocuments,s as defineLocations,a as presentationTool,n as usePresentationNavigate,o as usePresentationParams};//# sourceMappingURL=index.js.map
{
"name": "@sanity/presentation",
"version": "1.12.10",
"version": "1.13.0",
"homepage": "https://github.com/sanity-io/visual-editing/tree/main/packages/presentation#readme",

@@ -103,2 +103,3 @@ "bugs": {

"mnemonist": "0.39.8",
"path-to-regexp": "^6.2.2",
"rxjs": "^7.8.1",

@@ -111,7 +112,7 @@ "suspend-react": "0.1.3"

"@sanity/client": "^6.15.20",
"@sanity/pkg-utils": "6.8.7",
"@sanity/pkg-utils": "6.8.8",
"happy-dom": "^14.7.1",
"react": "^18.3.0",
"react-dom": "^18.3.0",
"sanity": "^3.39.0",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"sanity": "^3.39.1",
"styled-components": "6.1.8",

@@ -118,0 +119,0 @@ "typescript": "5.4.5",

@@ -6,2 +6,3 @@ import type {ClientPerspective} from '@sanity/client'

export interface PresentationState {
mainDocument: boolean
iframe: {

@@ -126,2 +127,4 @@ status: 'loading' | 'loaded' | 'refreshing' | 'reloading'

const mainDocumentSchema = fallback(boolean(), false)
const iframeStatusSchema = picklist(['loading', 'loaded', 'refreshing', 'reloading'])

@@ -137,2 +140,3 @@ const perspectiveSchema = fallback(

const initStateSchema = object({
mainDocument: mainDocumentSchema,
iframe: object({

@@ -147,2 +151,3 @@ status: iframeStatusSchema,

const INITIAL_PRESENTATION_STATE = {
mainDocument: false,
iframe: {

@@ -160,2 +165,3 @@ status: 'loading',

Partial<{
mainDocument: boolean
perspective: string

@@ -162,0 +168,0 @@ viewport: string

@@ -12,2 +12,8 @@ import type {ClientPerspective, QueryParams} from '@sanity/client'

/**
* Represents a document location
* @typeParam title - Title of the document
* @typeParam href - URL of the document location
* @public
*/
export interface DocumentLocation {

@@ -18,2 +24,10 @@ title: string

/**
* State for describing document locations or providing a message if no document
* locations are unavailable
* @typeParam locations - Array of document locations
* @typeParam message - Message to display if locations are unavailable
* @typeParam tone - Tone of the message
* @public
*/
export interface DocumentLocationsState {

@@ -25,2 +39,14 @@ locations?: DocumentLocation[]

/**
* @internal
*/
export type DocumentLocationsStatus = 'empty' | 'resolving' | 'resolved'
/**
* Function used for advanced document location resolution
* @param params - Object with document `id` and document `type` properties
* @param context - Object with `documentStore` property for creating listenQuery subscriptions
* @returns Document location state, optionally as an Observable, or null/undefined if no locations are available
* @public
*/
export type DocumentLocationResolver = (

@@ -43,2 +69,69 @@ params: {id: string; type: string},

/**
* Object of document location resolver definitions per document type
* @public
*/
export type DocumentLocationResolvers = Record<
string,
DocumentLocationResolverObject | DocumentLocationsState
>
/**
* Document location resolver object
* @typeParam select - object for selecting document fields
* @typeParam resolve - function that accepts a document with the selected fields and returns an optional document location state
* @public
*/
export type DocumentLocationResolverObject<K extends string = string> = {
select: Record<K, string>
resolve: (value: Record<K, any> | null) => DocumentLocationsState | null | undefined | void
}
/**
* @internal
*/
export interface DocumentResolverContext {
origin: string | undefined
params: Record<string, string>
path: string
}
/**
* @internal
*/
export type ContextFn<T> = (context: DocumentResolverContext) => T
/**
* Object for resolving a document for a given route pattern
* @public
*/
export type DocumentResolver =
| {
route: string | Array<string>
type: string
filter?: never
params?: never
resolve?: never
}
| {
route: string | Array<string>
type?: never
filter: ContextFn<string> | string
params?: ContextFn<Record<string, string>> | Record<string, string>
resolve?: never
}
| {
route: string | Array<string>
type?: never
filter?: never
params?: never
resolve: ContextFn<
| {
filter: string
params?: Record<string, string>
}
| undefined
>
}
export interface PresentationPluginOptions {

@@ -49,3 +142,10 @@ devMode?: boolean | (() => boolean)

title?: string
/**
* @deprecated use `resolve.locations` instead
*/
locate?: DocumentLocationResolver
resolve?: {
mainDocuments?: DocumentResolver[]
locations?: DocumentLocationResolvers | DocumentLocationResolver
}
previewUrl: PreviewUrlOption

@@ -125,1 +225,17 @@ components?: {

}
/**
* @internal
*/
export interface MainDocument {
_id: string
_type: string
}
/**
* @internal
*/
export interface MainDocumentState {
path: string
document: MainDocument | undefined
}

@@ -1,6 +0,11 @@

import {useEffect, useState} from 'react'
import {isObservable, of} from 'rxjs'
import {useDocumentStore} from 'sanity'
import {useEffect, useMemo, useState} from 'react'
import {isObservable, map, type Observable, of} from 'rxjs'
import {type SanityDocument, useDocumentStore} from 'sanity'
import type {DocumentLocationResolver, DocumentLocationsState} from './types'
import type {
DocumentLocationResolver,
DocumentLocationResolvers,
DocumentLocationsState,
DocumentLocationsStatus,
} from './types'

@@ -11,24 +16,59 @@ const INITIAL_STATE: DocumentLocationsState = {locations: []}

id: string
locate?: DocumentLocationResolver
resolvers?: DocumentLocationResolver | DocumentLocationResolvers
type: string
}): DocumentLocationsState {
const {id, locate, type} = props
}): {
state: DocumentLocationsState
status: DocumentLocationsStatus
} {
const {id, resolvers, type} = props
const documentStore = useDocumentStore()
const [state, setLocations] = useState<DocumentLocationsState>(INITIAL_STATE)
const [locationsState, setLocationsState] = useState<DocumentLocationsState>(INITIAL_STATE)
useEffect(() => {
if (!locate) return undefined
const resolver = resolvers && (typeof resolvers === 'function' ? resolvers : resolvers[type])
const params = {id, type}
const context = {documentStore}
const [locationsStatus, setLocationsStatus] = useState<DocumentLocationsStatus>(
resolver ? 'resolving' : 'empty',
)
const result = locate(params, context)
const locations$ = isObservable(result) ? result : of(result)
const result = useMemo(() => {
if (!resolver) return undefined
const sub = locations$.subscribe((d) => setLocations(d || INITIAL_STATE))
// Original/advanced resolver which requires explicit use of Observables
if (typeof resolver === 'function') {
const params = {id, type}
const context = {documentStore}
const _result = resolver(params, context)
return isObservable(_result) ? _result : of(_result)
}
return () => sub.unsubscribe()
}, [documentStore, id, locate, type])
// Simplified resolver pattern which abstracts away Observable logic
if ('select' in resolver && 'resolve' in resolver) {
const projection = Object.entries(resolver.select)
.map(([key, value]) => `"${key}": ${value}`)
.join(', ')
const query = `*[_id==$id][0]{${projection}}`
const params = {id}
const doc$ = documentStore.listenQuery(query, params, {
perspective: 'previewDrafts',
}) as Observable<SanityDocument | null>
return doc$.pipe(map(resolver.resolve))
}
return state
// Resolver is explicitly provided state
return of(resolver)
}, [documentStore, id, resolver, type])
useEffect(() => {
const sub = result?.subscribe((state) => {
setLocationsState(state || INITIAL_STATE)
setLocationsStatus(state ? 'resolved' : 'empty')
})
return () => sub?.unsubscribe()
}, [result])
return {
state: locationsState,
status: locationsStatus,
}
}

@@ -1,6 +0,5 @@

import {type MutableRefObject, useEffect, useMemo, useRef} from 'react'
import {type MutableRefObject, useCallback, useEffect, useMemo, useRef} from 'react'
import {getPublishedId} from 'sanity'
import type {RouterContextValue, RouterState, SearchParam} from 'sanity/router'
import {debounce} from './lib/debounce'
import {parseRouterState} from './lib/parse'

@@ -103,44 +102,43 @@ import type {

const navigate = useMemo(
() =>
debounce<PresentationNavigate>((nextState, nextSearchState = {}, forceReplace) => {
// Force navigation to use published IDs only
if (nextState.id) nextState.id = getPublishedId(nextState.id)
const navigate = useCallback<PresentationNavigate>(
(nextState, nextSearchState = {}, forceReplace) => {
// Force navigation to use published IDs only
if (nextState.id) nextState.id = getPublishedId(nextState.id)
// Extract type, id and path as 'routerState'
const {_searchParams: routerSearchParams, ...routerState} = routerStateRef.current
// Extract type, id and path as 'routerState'
const {_searchParams: routerSearchParams, ...routerState} = routerStateRef.current
// Convert array of search params to an object
const routerSearchState = (routerSearchParams || []).reduce(
(acc, [key, value]) => ((acc[key as keyof PresentationSearchParams] = value), acc),
{} as PresentationSearchParams,
)
// Convert array of search params to an object
const routerSearchState = (routerSearchParams || []).reduce(
(acc, [key, value]) => ((acc[key as keyof PresentationSearchParams] = value), acc),
{} as PresentationSearchParams,
)
// Merge routerState and incoming state
const state: RouterState = pruneObject({
...routerState,
...nextState,
})
// Merge routerState and incoming state
const state: RouterState = pruneObject({
...routerState,
...nextState,
})
// Merge routerSearchState and incoming searchState
const searchState = pruneObject({
...routerSearchState,
...nextSearchState,
})
// Merge routerSearchState and incoming searchState
const searchState = pruneObject({
...routerSearchState,
...nextSearchState,
})
// If the document has changed, clear the template and templateParams
if (routerState.id !== state['id']) {
delete searchState.template
delete searchState.templateParams
}
// If the document has changed, clear the template and templateParams
if (routerState.id !== state['id']) {
delete searchState.template
delete searchState.templateParams
}
state._searchParams = Object.entries(searchState).reduce(
(acc, [key, value]) => [...acc, [key, value]],
[] as SearchParam[],
)
state._searchParams = Object.entries(searchState).reduce(
(acc, [key, value]) => [...acc, [key, value]],
[] as SearchParam[],
)
const replace = forceReplace ?? searchState.preview === frameStateRef.current.url
const replace = forceReplace ?? searchState.preview === frameStateRef.current.url
routerNavigate(state, {replace})
}, 50),
routerNavigate(state, {replace})
},
[routerNavigate, frameStateRef],

@@ -147,0 +145,0 @@ )

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc