Socket
Socket
Sign inDemoInstall

@sanity/presentation

Package Overview
Dependencies
Maintainers
51
Versions
167
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@sanity/presentation - npm Package Compare versions

Comparing version 1.13.0 to 1.14.0

dist/_chunks-cjs/resources.cjs

6

dist/_chunks-es/index.js

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

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)};
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,defineLocaleResourceBundle as f,useTranslation as v,defineDocumentFieldAction as y,useWorkspace as g,pathToString as w,isRecord as b,getPublishedId as P,definePlugin as x,isDocumentSchemaType as T}from"sanity";import{ComposeIcon as I,InfoOutlineIcon as j,ChevronRightIcon as _,DesktopIcon as z,WarningOutlineIcon as S,ErrorOutlineIcon as $,MasterDetailIcon as D}from"@sanity/icons";import{Card as A,Flex as O,Box as k,Text as C,Spinner as E,Stack as B,rem as R}from"@sanity/ui";import{styled as U}from"styled-components";import{isObservable as H,of as L,map as N}from"rxjs";import{useIntentLink as M,useRouter as Q,encodeJsonParams as q,route as F}from"sanity/router";import{uuid as G}from"@sanity/uuid";const J=I,K="presentation",V="Presentation",W="sanity/structure/comments",X="presentation",Y=3e3,Z="2023-10-16",ee=1e3,te=100,ne=2048,ie={locations:[]};const oe="presentation",re=f({locale:"en-US",namespace:oe,resources:()=>import("./resources.js")}),se=s(null);function ae(){const e=a(se);if(!e)throw new Error("Presentation context is missing");return e}const ce={positive:j,caution:S,critical:$};function le(o){const{documentId:r,isResolving:s,options:d,schemaType:u,showPresentationTitle:p}=o,{locations:m,message:h,tone:f}=o.state,y=(null==m?void 0:m.length)||0,{t:g}=v(oe),w=a(se),[b,P]=i(!1),x=c((()=>{y&&P((e=>!e))}),[y]),T=s?g("locations-banner.resolving.text"):h||g("locations-banner.locations-count",{count:y});return e(A,{padding:1,radius:2,border:!0,tone:f,children:t("div",{style:{margin:-1},children:[!m&&t(O,{align:"flex-start",gap:3,padding:3,children:[f&&e(k,{flex:"none",children:e(C,{size:1,children:l(ce[f])})}),e(k,{flex:1,children:t(C,{size:1,weight:"medium",children:[p&&t(n,{children:[d.title||V," · "]}),T]})})]}),m&&t(n,{children:[e(A,{as:y?"button":void 0,onClick:x,padding:3,radius:1,tone:"inherit",children:t(O,{gap:3,children:[e(k,{flex:"none",children:s?e(E,{size:1}):e(C,{size:1,children:0===y?e(j,{}):e(_,{style:{transform:`rotate(${b?"90deg":0})`,transition:"transform 100ms ease-in-out"}})})}),e(k,{flex:1,children:t(C,{size:1,weight:"medium",children:[p&&t(n,{children:[d.title||V," · "]}),T]})})]})}),e(B,{hidden:!b,marginTop:1,space:1,children:m.map(((t,n)=>e(de,{active:(d.name||K)===(null==w?void 0:w.name)&&t.href===(null==w?void 0:w.params.preview),documentId:r,documentType:u.name,node:t,toolName:d.name||K},n)))})]})]})})}function de(n){const{documentId:i,documentType:o,node:r,active:s,toolName:d}=n,u=a(se),p=d===function(){try{return ae().name}catch{return}}(),m=null==u?void 0:u.navigate,h=M({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(A,{...p?{}:h,as:"a",key:r.href,onClick:p?f:h.onClick,padding:3,radius:1,pressed:s,tone:"inherit"},t(O,{gap:3,children:[e(k,{flex:"none",children:e(C,{size:1,children:e(z,{})})}),t(B,{flex:1,space:2,children:[e(C,{size:1,weight:"medium",children:r.title}),e(C,{muted:!0,size:1,textOverflow:"ellipsis",children:r.href})]})]}))}const ue=s(null),pe=U(B)`
min-height: ${R(42)};

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

}
`;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
`;function me(t){var n;const{documentId:s,options:c,schemaType:l}=t,d=a(ue),{state:u,status:p}=function(e){const{id:t,resolvers:n,type:s}=e,a=h(),[c,l]=i(ie),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 H(e)?e:L(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(N(d.resolve))}return L(d)}}),[a,t,d,s]);return r((()=>{const e=null==m?void 0:m.subscribe((e=>{l(e||ie),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(pe,{marginBottom:5,space:5,children:e(B,{space:2,children:m.map(((t,n)=>e(le,{documentId:s,isResolving:"resolving"===p,options:t,schemaType:l,showPresentationTitle:m.length>1,state:u},n)))})})}function he(t){const{children:n,options:r}=t,s=a(ue),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(ue.Provider,{value:v,children:n})}const fe=y({name:"presentation/openInStructure",useAction({documentId:e,documentType:t,path:n}){const i=g(),{navigateIntent:r}=Q(),s=a(se),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=>b(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)||D,title:`Open in ${(null==c?void 0:c.title)||"Structure"}`,onAction(){r("edit",{id:e,type:t,mode:"structure",path:w(n)})},renderAsButton:!0}}});function ve(e,t,n,i){const{id:o,mode:r,path:s,presentation:a,type:c,...l}=t;return"edit"===e&&o?{type:c||"*",id:P(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=q(i)),{type:c||"*",id:o||G(),_searchParams:Object.entries(l)}):{intent:e,params:t,payload:i}}const ye=F.create("/",{__unsafe_disableScopedSearchParams:!0},[F.intents("/intent"),F.create(":type",[F.create(":id",[F.create(":path")])])]),ge=p((()=>import("./PresentationTool.js"))),we=p((()=>import("./BroadcastDisplayedDocument.js")));function be(e){return e}function Pe(e){return e}const xe=x((n=>{var i;const o=n.name||K;"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{i18n:{bundles:[re]},document:{unstable_fieldActions:e=>[...e.filter((e=>e.name!==fe.name)),fe]},form:{components:{input:function(i){const o=i.value,s=null!=o&&o._id?P(null==o?void 0:o._id):void 0;return T(i.schemaType)?t(he,{options:n,children:[r&&s&&e(me,{documentId:s,options:n,schemaType:i.schemaType}),i.renderDefault(i),e(m,{children:e(we,{value:o})},"broadcast-displayed-document")]}):i.renderDefault(i)}}},tools:[{icon:n.icon||J,name:o,title:n.title,component:ge,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===X})}(t),getIntentState:ve,router:ye}]}})),Te=s(null);function Ie(){const e=a(Te);if(!e)throw new Error("Presentation navigate context is missing");return e}const je=s(null);function _e(){const e=a(je);if(!e)throw new Error("Presentation params context is missing");return e}export{Z as A,W as C,K as D,X as E,ne as L,Y as M,Te as P,je as a,se as b,ee as c,te as d,Ie as e,_e as f,be as g,Pe as h,xe as i,oe as p,ae as u};//# sourceMappingURL=index.js.map

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

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`
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{Button as a,Card as s,Flex as c,Container as l,Stack as d,Text as u,Inline as p,Box as m,Code as f,Label as v,ErrorBoundary as h,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 z,BoundaryElementProvider as D}from"@sanity/ui";import{createContext as C,useContext as O,useLayoutEffect as _,useMemo as $,useRef as U,useState as R,useCallback as j,useEffect as T,forwardRef as A,memo as L,createElement as W,startTransition as M,useReducer as N,Suspense as F,lazy as K}from"react";import{useTranslation as V,useUnique as B,getPublishedId as q,useSchema as G,Preview as J,Translate as X,useActiveWorkspace as H,useClient as Z,useCurrentUser as Q,Hotkeys as Y,useDocumentStore as ee,useProjectId as te,useDataset as ne,useWorkspace as re}from"sanity";import{StateLink as ie,useRouter as oe,decodeJsonParams as ae}from"sanity/router";import{styled as se}from"styled-components";import{p as ce,u as le,P as de,a as ue,b as pe,A as me,M as fe,c as ve,C as he,E as ge,D as ye}from"./index.js";import{PaneRouterContext as we,PaneLayout as be,StructureToolProvider as xe,DocumentListPane as Pe,DocumentPane as Ee,CommentsIntentProvider as ke}from"sanity/structure";import{WarningOutlineIcon as Se,ResetIcon as Ie,LaunchIcon as ze,CopyIcon as De,PanelLeftIcon as Ce,RefreshIcon as Oe,ShareIcon as _e,ChevronDownIcon as $e,CheckmarkIcon as Ue,DesktopIcon as Re,MobileDeviceIcon as je,EditIcon as Te,PublishIcon as Ae}from"@sanity/icons";import{D as Le}from"./DisplayedDocumentBroadcaster.js";import{hasSecretSearchParams as We,setSecretSearchParams as Me,withoutSecretSearchParams as Ne}from"@sanity/preview-url-secret/without-secret-search-params";import{motion as Fe,MotionConfig as Ke,AnimatePresence as Ve}from"framer-motion";import{createPreviewSecret as Be}from"@sanity/preview-url-secret/create-secret";import qe from"fast-deep-equal";import{match as Ge}from"path-to-regexp";import{definePreviewUrl as Je}from"@sanity/preview-url-secret/define-preview-url";import{suspend as Xe}from"suspend-react";let He;const Ze=new Uint8Array(16);function Qe(){if(!He&&(He=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!He))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return He(Ze)}const Ye=[];for(let e=0;e<256;++e)Ye.push((e+256).toString(16).slice(1));var et={randomUUID:typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function tt(e,t,n){if(et.randomUUID&&!t&&!e)return et.randomUUID();const r=(e=e||{}).random||(e.rng||Qe)();return r[6]=15&r[6]|64,r[8]=63&r[8]|128,function(e,t=0){return Ye[e[t+0]]+Ye[e[t+1]]+Ye[e[t+2]]+Ye[e[t+3]]+"-"+Ye[e[t+4]]+Ye[e[t+5]]+"-"+Ye[e[t+6]]+Ye[e[t+7]]+"-"+Ye[e[t+8]]+Ye[e[t+9]]+"-"+Ye[e[t+10]]+Ye[e[t+11]]+Ye[e[t+12]]+Ye[e[t+13]]+Ye[e[t+14]]+Ye[e[t+15]]}(r)}const nt=1e3,rt=1e3,it=500,ot=["handshake/syn","handshake/syn-ack","handshake/ack"],at=e=>ot.some((t=>t===e)),st=({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 ct(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(at(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(!at(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(st(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=tt(),e.interval=window.setInterval((()=>{l(e,"handshake/syn",{id:e.id})}),it)}(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:rt;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:tt(),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=tt();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}').`))}),nt),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 lt,dt,ut,pt,mt=class extends Error{constructor(e){super(e[0].message),t(this,"issues"),this.name="ValiError",this.issues=e}};function ft(e,t){return Array.isArray(e)?[void 0,e]:[e,t]}function vt(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==pt?void 0:pt.get(e))?void 0:n.get(t)}(n,i.lang))?a:e?(u=i.lang,null==ut?void 0:ut.get(u)):null)?s:null==r?void 0:r.message)?c:function(e){return null==dt?void 0:dt.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 gt(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 yt(e,t,n){var r;const i=null!=(r=n.received)?r:gt(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=vt(!1,n.context,n.reference,t,o),o}function wt(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=yt(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 bt(e,t,n,r,i){var o,a;const s=gt(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=vt(!0,e,t,r,l),{typed:!1,output:n,issues:[l]}}function xt(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 Pt(e,t){const[n,r]=ft(e,t);return{type:"boolean",expects:"boolean",async:!1,message:n,pipe:r,_parse(e,t){return"boolean"==typeof e?wt(this,e,t):bt(this,Pt,e,t)}}}function Et(e,t,n,r){const[i,o,a]=function(e,t,n){if(!e||"object"==typeof e&&!Array.isArray(e)){const[r,i]=ft(t,n);return[e,r,i]}const[r,i]=ft(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?wt(this,i,t,n):ht(!1,i,n)}return bt(this,Et,e,t)}}}function kt(e,t){return{type:"picklist",expects:e.map(gt).join(" | "),async:!1,options:e,message:t,_parse(e,t){return this.options.includes(e)?ht(!0,e):bt(this,kt,e,t)}}}function St(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==lt?void 0:lt.lang,message:null==e?void 0:e.message,abortEarly:null!=(n=null==e?void 0:e.abortEarly)?n:null==lt?void 0:lt.abortEarly,abortPipeEarly:null!=(r=null==e?void 0:e.abortPipeEarly)?r:null==lt?void 0:lt.abortPipeEarly,skipPipe:null!=(i=null==e?void 0:e.skipPipe)?i:null==lt?void 0:lt.skipPipe}}(n));if(r.issues)throw new mt(r.issues);return r.output}const It=/^([A-Za-z]+):([0-9]+)$/,zt=/^([A-Za-z]+):([0-9]+),([0-9]+)$/,Dt=/^([A-Za-z]+):([a-z0-9]+)$/;function Ct(e,t){return`${e}-${"string"==typeof t?t:JSON.stringify(t)}`}const Ot={alt:"altKey",ctrl:"ctrlKey",mod:typeof window<"u"&&/Mac|iPod|iPhone|iPad/.test(window.navigator.platform)?"metaKey":"ctrlKey",shift:"shiftKey"};function _t(e){return"Alt"===e.key}function $t(e,t){let n;return(...r)=>{clearTimeout(n),n=setTimeout((()=>{e.apply(e,r)}),t)}}const Ut=C(null);Ut.displayName="PanelsContext";const Rt=se.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`
`,jt=function({children:e,defaultSize:t=null,id:r,minWidth:i,maxWidth:o,order:a=0}){const s=O(Ut);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 _((()=>(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})},Tt="presentation/panels",At=()=>JSON.parse(localStorage.getItem(Tt)||"{}"),Lt=e=>e.map((e=>[e.id,e.order].join(":"))).join(",");function Wt(){return $((()=>{const e=(e,t)=>{const n=At(),r=Lt(e);(e=>{localStorage.setItem(Tt,JSON.stringify(e))})({...n,[r]:t})};return{get:e=>{const t=At(),n=Lt(e);return Array.isArray(t[n])&&t[n].some((e=>null===e))?void 0:t[n]},set:e,setDebounced:$t(e,100)}}),[])}function Mt(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 Nt(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 Ft(e,t,n=0,r=null){return e.clientX-(r||t.getBoundingClientRect()).left-n}function Kt(e){return"panel"===e.type}function Vt(e){return"resizer"===e.type}function Bt(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=Mt(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 Gt=se.div`
display: flex;

@@ -11,5 +11,5 @@ flex-direction: row;

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)`
`,Jt=function({children:e}){const t=U(null),[r,i]=R(new Map),o=$((()=>Bt(r).filter(Kt)),[r]),[a,s]=R([]),[c,l]=R(null),d=U({elements:r,panels:o,widths:a}),u=j((e=>({flexGrow:Nt(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}))}),[]),m=j((e=>{i((t=>{if(!t.has(e))return t;const n=new Map(t);return n.delete(e),n}))}),[]),f=U({containerWidth:window.innerWidth,dragOffset:0,panelAfter:null,panelBefore:null,resizerIndex:-1,resizerRect:null,startX:0,widths:[]}),v=j(((e,t)=>{const n=Bt(r),i=n.findIndex((t=>t.id===e)),o=r.get(e);if(!o||!Vt(o))return;const a=o.el.current;a&&(f.current={resizerIndex:i,panelBefore:n.reduce(((e,t,n)=>Kt(t)&&n<i?t:e),null),panelAfter:n.reduce(((e,t,n)=>null===e&&Kt(t)&&n>i?t:e),null),containerWidth:window.innerWidth,startX:t.pageX,dragOffset:Ft(t,a),resizerRect:a.getBoundingClientRect(),widths:d.current.widths},l(e))}),[r]),h=j((()=>{l(null)}),[]),g=j(((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||!Vt(u))return;const p=u.el.current;if(!p)return;const m=Ft(n,p,o,l);if(0===m)return;const{widths:v}=d.current,h=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=Mt(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,m=a.findIndex((e=>e.id===p.id));for(;;){const n=a[m],r=l[m],i=Mt(n,r-(Math.abs(e)-Math.abs(u)),t);if(r!==i&&(u+=r-i,d[m]=i,u.toPrecision(10).localeCompare(Math.abs(e).toPrecision(10),void 0,{numeric:!0})>=0))break;if(e<0){if(--m<0)break}else if(++m>=a.length)break}return 0===u?l:(p=e<0?r:n,m=a.findIndex((e=>e.id===p.id)),d[m]=l[m]+u,d)}(m/t.current.getBoundingClientRect().width*100,i,a,c,d.current,f.current);v.some(((e,t)=>e!==h[t]))&&s(h)}),[r]);_((()=>{d.current.elements=r,d.current.panels=o,d.current.widths=a}),[r,o,a]);const y=Wt();_((()=>{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]),T((()=>{a.length&&y.setDebounced(o,a)}),[y,o,a]),_((()=>{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=$((()=>({activeResizer:c,drag:g,getPanelStyle:u,registerElement:p,startDragging:v,stopDragging:h,unregisterElement:m})),[c,g,u,p,v,h,m]);return n(Ut.Provider,{value:w,children:n(Gt,{ref:t,children:e})})};function Xt(e){const{children:t,message:i,onRetry:o,onContinueAnyway:f,...v}=e,{t:h}=V(ce),g=n(a,{fontSize:1,mode:"ghost",onClick:o,text:h("error-card.retry-button.text")}),y=n(a,{fontSize:1,mode:"ghost",tone:"critical",onClick:f,text:h("error-card.continue-button.text")});return n(s,{height:"fill",...v,children:n(c,{align:"center",height:"fill",justify:"center",children:n(l,{padding:4,sizing:"border",width:0,children:r(d,{space:4,children:[r(d,{space:3,children:[n(u,{size:1,weight:"semibold",children:h("error-card.title")}),n(u,{muted:!0,size:1,children:i})]}),t,o&&f?r(p,{space:2,children:[g,y]}):o?n(m,{children:g}):f?n(m,{children:y}):null]})})})})}function Ht(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 Zt=A((function(e,t){const{params:r,structureParams:i}=le();return n(ie,{...e,ref:t,state:{type:void 0,_searchParams:Object.entries({...i,perspective:r.perspective,preview:r.preview})},title:void 0})})),Qt=A((function(e,t){const{documentId:r,documentType:i,parentRefPath:o,template:a,previewUrl:s,...c}=e;return n(ie,{...c,ref:t,state:{id:r,type:i,_searchParams:Object.entries({preview:s})},title:void 0})}));function Yt(e){const{children:t,onStructureParams:r,params:o,previewUrl:a,refs:s}=e,{state:c,resolvePathFromState:l}=oe(),d=B(Object.fromEntries(c._searchParams||[])),u=j((e=>`${l(c)}${Ht({...d,...e})}`),[l,d,c]),p=$((()=>({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||q(e._id)===t));return i?n(ie,{...r,state:{id:t,type:i._type,_searchParams:Object.entries({preview:a})}}):n("div",{...r})},BackLink:Zt,ReferenceChildLink:e=>n(Qt,{...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(we.Provider,{value:p,children:t})}const en=se(be)`
height: 100%;
`,Qt=oe(s)`
`,tn=se(c)`
& > div {

@@ -19,9 +19,9 @@ min-width: none !important;

}
`,Yt=oe(m)`
`,nn=se(f)`
white-space: pre-wrap;
`;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)`
`;function rn(e){const{mainDocumentState:t,onStructureParams:i,previewUrl:o,refs:a}=e,{t:c}=V(ce),{devMode:l}=le(),u=$((()=>a.filter((e=>{var n;return q(e._id)!==(null==(n=null==t?void 0:t.document)?void 0:n._id)})).map((e=>e._id))),[t,a]),p=$((()=>({id:"$root",options:{filter:"_id in $ids",params:{ids:u}},schemaTypeName:"",title:c("document-list-pane.document-list.title"),type:"documentList"})),[u,c]),[m,f]=R(null),g=j((()=>f(null)),[]),[y]=R((()=>({})));return T((()=>f(null)),[a]),m?n(Xt,{flex:1,message:c("document-list-pane.error.text"),onRetry:g,children:l&&n(s,{overflow:"auto",padding:3,radius:2,tone:"critical",children:r(d,{space:3,children:[n(v,{muted:!0,size:0,children:c("presentation-error.label")}),n(nn,{size:1,children:m.error.message})]})})}):n(h,{onCatch:f,children:n(en,{children:n(xe,{children:n(Yt,{onStructureParams:i,params:y,previewUrl:o,refs:a,children:n(tn,{direction:"column",flex:1,children:n(Pe,{index:0,itemId:"$root",pane:p,paneKey:"$root"})})})})})})}const on=se(f)`
white-space: pre-wrap;
`;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`
`;function an(e){const{documentId:t,documentType:i,onFocusPath:o,onStructureParams:a,params:c,previewUrl:l}=e,{template:u,templateParams:p}=c,{t:m}=V(ce),{devMode:f}=le(),g=$((()=>({id:t,options:{id:t,type:i,template:u,templateParameters:ae(p)},title:"",type:"document"})),[t,i,u,p]),[y,w]=R(null),b=j((()=>w(null)),[]);return T((()=>{w(null)}),[t,i,c]),y?n(Xt,{flex:1,message:m("document-pane.error.text"),onRetry:b,children:f&&n(s,{overflow:"auto",padding:3,radius:2,tone:"critical",children:r(d,{space:3,children:[n(v,{muted:!0,size:0,children:m("presentation-error.label")}),n(on,{size:1,children:y.error.message})]})})}):n(h,{onCatch:w,children:n(be,{style:{height:"100%"},children:n(Yt,{onStructureParams:a,params:c,previewUrl:l,children:n(Ee,{paneKey:"document",index:1,itemId:"document",pane:g,onFocusPath:o})})})})}function sn(e){const{documentId:t,documentType:r,onFocusPath:i,onStructureParams:o,previewUrl:a,structureParams:s}=e;return n(xe,{children:n(an,{documentId:t,documentType:r,onFocusPath:i,onStructureParams:o,params:s,previewUrl:a})})}function cn(e){const{documentId:t,documentType:i,mainDocumentState:o,onFocusPath:a,onStructureParams:l,previewUrl:d,refs:p,structureParams:f}=e,{t:v}=V(ce),h=G(),y=j((e=>n(ie,{...e,state:{id:o.document._id,type:o.document._type,_searchParams:Object.entries({preview:d})}})),[o,d]);return t&&i?n(sn,{documentId:t,documentType:i,onFocusPath:a,onStructureParams:l,previewUrl:d,structureParams:f}):r(c,{direction:"column",flex:1,height:"fill",children:[o&&n(s,{padding:3,tone:o.document?"inherit":"caution",children:o.document?n(s,{as:y,"data-as":"a",padding:0,radius:2,children:n(J,{schemaType:h.get(o.document._type),status:n(g,{children:v("main-document.label")}),value:o.document})}):n(s,{padding:2,radius:2,tone:"inherit",children:r(c,{gap:3,children:[n(m,{flex:"none",children:n(u,{size:1,children:n(Se,{})})}),n(m,{flex:1,children:n(u,{size:1,children:n(X,{t:v,i18nKey:"main-document.missing.text",components:{Code:"code"},values:{path:o.path}})})})]})})}),n(rn,{mainDocumentState:o,onStructureParams:l,previewUrl:d,refs:p})]})}const ln=se.div`
position: relative;
`,sn=oe.div`
`,dn=se.div`
position: absolute;

@@ -47,3 +47,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 "}
`,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`
`,un=function({id:e,order:t,disabled:i=!1}){const o=U(null),a=O(Ut);if(null===a)throw Error("Panel components must be rendered within a PanelGroup container");const s=function(e){return U(e||tt()).current}(e),{activeResizer:c,drag:l,startDragging:d,stopDragging:u,registerElement:p,unregisterElement:m}=a,f=c===s;if(null===a)throw Error("Panel components must be rendered within a PanelGroup container");const v=j((e=>{d(s,e.nativeEvent)}),[s,d]),h=j((e=>{l(s,e)}),[s,l]),g=j((()=>{o.current.blur(),u()}),[u]);return T((()=>{if(f&&!i)return window.addEventListener("mousemove",h),window.addEventListener("mouseup",g),()=>{window.removeEventListener("mousemove",h),window.removeEventListener("mouseup",g)}}),[i,f,h,g]),_((()=>(p(s,{id:s,order:t,type:"resizer",el:o}),()=>{m(s)})),[s,t,p,m]),n(ln,{onMouseDown:v,ref:o,children:r(dn,{$disabled:i,children:[n("span",{}),n("span",{})]})})},pn=e=>{const{documentId:t,setDisplayedDocument:o,getCommentIntent:a}=e;return r(i,{children:[n(un,{order:4}),n(jt,{id:"content",minWidth:325,order:5,children:n(Le,{documentId:t,setDisplayedDocument:o,children:n(ke,{getIntent:a,children:e.children})})})]})},mn=e=>{const{documentsOnPage:t,getCommentIntent:r,mainDocumentState:i,onFocusPath:o,onStructureParams:a,params:s,setDisplayedDocument:c,structureParams:l}=e;return n(pn,{documentId:s.id,getCommentIntent:r,setDisplayedDocument:c,children:n(cn,{documentId:s.id,documentType:s.type,mainDocumentState:i,onFocusPath:o,onStructureParams:a,previewUrl:s.preview,refs:t,structureParams:l})})},fn=function(e){const{children:t,navigate:r}=e,i=j(((e,t=void 0)=>{r(t||{},e?{preview:e}:{})}),[r]);return n(de.Provider,{value:i,children:t})};function vn(e){const{unstable_navigator:t}=e,r=!(null==t||!t.component),[o,a]=function(e,t){const[n,r]=R((()=>{var n;return JSON.parse(null!=(n=localStorage.getItem(e))?n:JSON.stringify(t))}));return T((()=>{localStorage.setItem(e,JSON.stringify(n))}),[e,n]),[n,r]}("presentation/navigator",r),s=!!r&&o,c=$((()=>{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=L((function(e){const{minWidth:t,maxWidth:o,component:a}=e,s=null!=t&&null!=o&&t===o;return r(i,{children:[n(jt,{id:"navigator",minWidth:t,maxWidth:o,order:1,children:n(a,{})}),n(un,{order:2,disabled:s})]})})),gn=function(e){const{children:t,params:r}=e,i=$((()=>r),[r]);return n(ue.Provider,{value:i,children:t})},yn=function(e){const{children:t,devMode:r,name:i,navigate:o,params:a,structureParams:s}=e,c=$((()=>({devMode:r,name:i,navigate:o,params:a,structureParams:s})),[r,i,o,a,s]);return n(pe.Provider,{value:c,children:t})},wn="ACTION_IFRAME_LOADED",bn="ACTION_IFRAME_REFRESH",xn="ACTION_IFRAME_RELOAD",Pn="ACTION_PERSPECTIVE",En="ACTION_VIEWPORT",kn="ACTION_VISUAL_EDITING_OVERLAYS_TOGGLE",Sn=(e,t)=>{switch(t.type){case wn:return"loaded"===e.iframe.status?e:{...e,iframe:{...e.iframe,status:"loaded"}};case bn:return"refreshing"===e.iframe.status?e:{...e,iframe:{...e.iframe,status:"refreshing"}};case xn:return"reloading"===e.iframe.status?e:{...e,iframe:{...e.iframe,status:"reloading"}};case Pn:return{...e,perspective:St(Cn,t.perspective)};case En:return{...e,viewport:St(On,t.viewport)};case kn:return In(e,t);default:return e}},In=(e,t)=>e.visualEditing.overlaysEnabled===t.enabled?e:{...e,visualEditing:{...e.visualEditing,overlaysEnabled:t.enabled}},zn=xt(Pt(),!1),Dn=kt(["loading","loaded","refreshing","reloading"]),Cn=xt(kt(["published","previewDrafts"]),"previewDrafts"),On=xt(kt(["desktop","mobile"]),"desktop"),_n=Et({mainDocument:zn,iframe:Et({status:Dn}),perspective:Cn,viewport:On,visualEditing:Et({overlaysEnabled:Pt()})}),$n={mainDocument:!1,iframe:{status:"loading"},perspective:"previewDrafts",viewport:"desktop",visualEditing:{overlaysEnabled:!1}};function Un(e){return St(_n,{...$n,...e})}const Rn=Fe(se.iframe`
border: 0;

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

display: block;
`),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)`
`),jn=function(e){var t;const{fontSize:r=1,onChange:o,origin:a,padding:s=3,prefix:c,suffix:l,value:d}=e,{t:u}=V(ce),{basePath:p="/"}=(null==(t=H())?void 0:t.activeWorkspace)||{},m=U(null),[f,v]=R(void 0),[h,g]=R(void 0),w=j((e=>{v(e.currentTarget.value)}),[]),b=j((e=>{var t;if("Enter"===e.key){if(void 0===f)return;const e=f.startsWith("/")||""===f?`${a}${f}`:f;if(!e.startsWith(a+"/")&&e!==a)return void g(u("preview-location-input.error",{origin:a,context:"missing-origin"}));if(!a&&(e.startsWith(`${p}/`)||e===p))return void g(u("preview-location-input.error",{basePath:p,context:"same-base-path"}));const n=e===a?a+"/":e;g(void 0),v(void 0),o(n.slice(a.length)),null==(t=m.current)||t.blur()}"Escape"===e.key&&(g(void 0),v(void 0))}),[p,o,a,f,u]),x=j((()=>{g(void 0),v(void 0)}),[]);T((()=>{g(void 0),v(void 0)}),[a,d]);const P=$((()=>({icon:Ie})),[]);return n(i,{children:n(y,{clearButton:h?P:void 0,customValidity:h,fontSize:r,onBlur:x,onClear:()=>{g(void 0),v(a+d)},onChange:w,onKeyDownCapture:b,padding:s,prefix:c,style:{zIndex:1},radius:2,ref:m,space:s,suffix:l,value:void 0===f?`${a}${d}`:f})})};function Tn(e){const{initialUrl:t,openPopup:o,previewLocationOrigin:a,previewLocationRoute:s}=e,{t:c}=V(ce),l=j((e=>{e.preventDefault(),o(e.currentTarget.href)}),[o]);return r(i,{children:[n(An,{initialUrl:t,previewLocationOrigin:a,previewLocationRoute:s}),n(w,{icon:ze,text:c("share-url.menu-item.open.text"),as:"a",href:`${a}${s}`,onClick:l,rel:"opener",target:"_blank"})]})}function An(e){const{initialUrl:t,previewLocationOrigin:r,previewLocationRoute:i}=e,{t:o}=V(ce),{push:a}=b(),s=Z({apiVersion:me}),c=Q(),[l,d]=R(!1);return n(w,{disabled:l,onClick:()=>{if(null==navigator||!navigator.clipboard)return a({closable:!0,status:"error",title:o("share-url.clipboard.status",{context:"unsupported"})}),!1;d(!0);let e,n=`${r}${i}`;const l=()=>{a({id:e,closable:!0,status:"success",title:o("share-url.clipboard.status",{context:"success"})}),d(!1)},u=e=>{a({closable:!0,status:"error",title:o("share-url.clipboard.status",{context:"failed"}),description:e.message||e.toString()}),d(!1)};if(We(t)&&typeof ClipboardItem<"u"){const r="text/plain",d=async()=>{e=a({closable:!0,title:o("share-url.clipboard.status",{context:"copying"})});const l=await Be(s,"@sanity/presentation",typeof window>"u"?"":location.href,null==c?void 0:c.id);return n=Me(t,l.secret,i).toString(),new Blob([n],{type:r})},p=new ClipboardItem({[r]:d()});navigator.clipboard.write([p]).then(l).catch(u)}else navigator.clipboard.writeText(n).then(l).catch(u)},text:o("share-url.menu-item.copy.text"),icon:De})}const Ln=Fe(c),Wn={previewDrafts:"preview-frame.perspective.previewDrafts.title",published:"preview-frame.perspective.published.title"},Mn="caution",Nn="positive",Fn={previewDrafts:Te,published:Ae},Kn=A((function(e,t){const{dispatch:o,iframe:l,initialUrl:p,loadersConnection:h,navigatorEnabled:g,onPathChange:y,onRefresh:b,openPopup:D,overlaysConnection:C,params:O,perspective:_,targetOrigin:U,toggleNavigator:A,toggleOverlay:L,viewport:M,visualEditing:{overlaysEnabled:N}}=e,{t:F}=V(ce),{devMode:K}=le(),B=x(),q=j((()=>o({type:En,viewport:"desktop"})),[o]),G=j((()=>o({type:En,viewport:"mobile"})),[o]),J="loading"===l.status||"reloading"===l.status,[X,H]=R(!1),Z="refreshing"===l.status,[Q,ee]=R(!1),te=J||Z||"connecting"===C,ne=$((()=>U===location.origin?"":U),[U]),re=j((()=>{b((()=>{"function"==typeof t||null==t||!t.current||(o({type:xn}),t.current.src=`${U}${O.preview||"/"}`)}))}),[o,b,O.preview,U,t]),ie=j((()=>{"function"==typeof t||null==t||!t.current||(t.current.src=p.toString(),o({type:xn}))}),[o,t,p]),oe=j((()=>{se(!0)}),[]),[ae,se]=R(!1),[de,ue]=R(!1);T((()=>{if(!(J||Z||"connecting"!==C&&"reconnecting"!==C)){const e=setTimeout((()=>{ue(!0)}),1e3);return()=>clearTimeout(e)}}),[C,J,Z]),T((()=>{if(!J&&!Z&&de){if("connected"===C&&(ee(!1),ue(!1),H(!1),se(!1)),"connecting"===C){const e=setTimeout((()=>{H(!0),console.error("Unable to connect to visual editing. Make sure you've setup '@sanity/visual-editing' correctly")}),fe);return()=>clearTimeout(e)}if("reconnecting"===C){const e=setTimeout((()=>{H(!0),ee(!0)}),fe);return()=>clearTimeout(e)}"disconnected"===C&&ee(!0)}}),[J,C,Z,de]);const pe=$((()=>{const e=new URL(O.preview||"/",U),{pathname:t,search:n}=Ne(e);return`${t}${n}`}),[O.preview,U]),me=j((()=>{o({type:wn})}),[o]);return T((()=>{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(Ke,{transition:B?{duration:0}:void 0,children:r(P,{delay:1e3,children:[n(s,{flex:"none",padding:2,shadow:1,style:{position:"relative"},children:r(c,{align:"center",style:{minHeight:0},children:[A&&n(m,{flex:"none",marginRight:1,padding:1,children:n(E,{animate:!0,content:n(u,{size:1,children:F("preview-frame.navigator.toggle-button.tooltip")}),fallbackPlacements:["bottom-start"],padding:2,placement:"bottom",portal:!0,children:n(a,{"aria-label":F("preview-frame.navigator.toggle-button.aria-label"),fontSize:1,icon:Ce,mode:"bleed",onClick:A,padding:2,selected:g})})}),n(E,{animate:!0,content:r(c,{align:"center",style:{whiteSpace:"nowrap"},children:[n(m,{padding:1,children:n(u,{size:1,children:F("preview-frame.overlay.toggle-button.tooltip",{context:N?"disable":"enable"})})}),n(m,{paddingY:1,children:n(Y,{keys:["Alt"],style:{marginTop:-4,marginBottom:-4}})})]}),fallbackPlacements:["bottom-start"],padding:1,placement:"bottom",portal:!0,children:n(s,{as:"label",flex:"none",marginRight:1,padding:3,style:{lineHeight:0,borderRadius:999,userSelect:"none"},tone:N?"transparent":void 0,children:r(c,{align:"center",gap:3,children:[n("div",{style:{margin:-4},children:n(k,{checked:N,onChange:L,disabled:"loading"===l.status||"connected"!==C})}),n(m,{children:n(u,{muted:!N,size:1,weight:"medium",children:F("preview-frame.overlay.toggle-button.text")})})]})})}),n(m,{flex:1,marginX:1,children:n(jn,{prefix:n(m,{padding:1,children:n(E,{animate:!0,content:n(u,{size:1,children:"loaded"===l.status?F("preview-frame.refresh-button.tooltip"):F("preview-frame.status",{context:l.status})}),fallbackPlacements:["bottom-start"],padding:2,placement:"bottom",portal:!0,children:n(a,{"aria-label":F("preview-frame.refresh-button.aria-label"),fontSize:1,icon:Oe,mode:"bleed",loading:"reloading"===l.status||"refreshing"===l.status,onClick:re,padding:2})})}),onChange:y,origin:ne,suffix:n(m,{padding:1,children:n(S,{button:n(a,{fontSize:1,iconRight:_e,mode:"bleed",padding:2,space:2}),id:"location-menu",menu:n(I,{children:n(Tn,{initialUrl:p,openPopup:D,previewLocationOrigin:ne,previewLocationRoute:pe})}),popover:{animate:!0,constrainSize:!0,placement:"bottom",portal:!0}})}),value:pe})}),n(c,{align:"center",flex:"none",gap:1,padding:1,children:n(S,{button:n(a,{fontSize:1,iconRight:$e,mode:"bleed",padding:2,space:2,text:F(Wn["connected"===h?_:"previewDrafts"]),loading:"reconnecting"===h&&"loaded"!==l.status,disabled:"connected"!==h}),id:"perspective-menu",menu:r(I,{style:{maxWidth:240},children:[n(w,{fontSize:1,onClick:()=>o({type:Pn,perspective:"previewDrafts"}),padding:3,pressed:"previewDrafts"===_,tone:Mn,children:r(c,{align:"flex-start",gap:3,children:[n(m,{flex:"none",children:n(u,{size:1,children:W(Fn.previewDrafts)})}),r(d,{flex:1,space:2,children:[n(u,{size:1,weight:"medium",children:F(Wn.previewDrafts)}),n(u,{muted:!0,size:1,children:F("preview-frame.perspective.previewDrafts.text")})]}),n(m,{flex:"none",children:n(u,{muted:!0,size:1,style:{opacity:"previewDrafts"===_?1:0},children:n(Ue,{})})})]})}),n(w,{fontSize:1,onClick:()=>o({type:Pn,perspective:"published"}),padding:3,pressed:"published"===_,tone:Nn,children:r(c,{align:"flex-start",gap:3,children:[n(m,{flex:"none",children:n(u,{size:1,children:W(Fn.published)})}),r(d,{flex:1,space:2,children:[n(u,{size:1,weight:"medium",children:F(Wn.published)}),n(u,{muted:!0,size:1,children:F("preview-frame.perspective.published.text")})]}),n(m,{flex:"none",children:n(u,{muted:!0,size:1,style:{opacity:"published"===_?1:0},children:n(Ue,{})})})]})})]}),popover:{animate:!0,constrainSize:!0,placement:"bottom",portal:!0}})}),r(c,{align:"center",flex:"none",gap:1,padding:1,children:[n(E,{animate:!0,content:n(u,{size:1,children:F("preview-frame.viewport-full-button.tooltip")}),fallbackPlacements:["bottom-start"],padding:2,placement:"bottom",portal:!0,children:n(a,{"aria-label":F("preview-frame.viewport-full-button.aria-label"),fontSize:1,icon:Re,mode:"bleed",onClick:q,padding:2,selected:"desktop"===M})}),n(E,{animate:!0,content:n(u,{size:1,children:F("preview-frame.viewport-narrow-button.tooltip")}),padding:2,placement:"bottom",portal:!0,children:n(a,{"aria-label":F("preview-frame.viewport-narrow-button.aria-label"),fontSize:1,icon:je,mode:"bleed",onClick:G,padding:2,selected:"mobile"===M})})]})]})}),n(s,{flex:1,tone:"transparent",children:r(c,{align:"center",height:"fill",justify:"center",padding:"desktop"===M?0:2,sizing:"border",style:{position:"relative",cursor:te?"wait":void 0},children:[n(Ve,{children:Q||J||Z||!de||ae?(J||"connecting"===C&&"refreshing"!==l.status)&&!ae?n(Ln,{initial:"initial",animate:"animate",exit:"exit",variants:Bn,justify:"center",align:"center",style:{inset:"0",position:"absolute"},children:r(c,{style:{...Vn[M]},justify:"center",align:"center",direction:"column",gap:4,children:[n(z,{muted:!0}),n(u,{muted:!0,size:1,children:F("preview-frame.status",{context:"loading"})})]})}):Q&&!ae?n(Ln,{initial:"initial",animate:"animate",exit:"exit",variants:qn,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:F("preview-frame.connection.error.text"),onRetry:ie,onContinueAnyway:oe,children:K&&r(i,{children:["connected"!==C&&n(s,{padding:3,radius:2,tone:"critical",children:r(d,{space:3,children:[n(v,{muted:!0,size:0,children:F("preview-frame.overlay.connection-status.label")}),n(f,{size:1,children:F("channel.status",{context:C})})]})}),"connected"!==h&&n(s,{padding:3,radius:2,tone:"critical",children:r(d,{space:3,children:[n(v,{muted:!0,size:0,children:F("preview-frame.loader.connection-status.label")}),n(f,{size:1,children:F("channel.status",{context:h})})]})})]})})}):null:n(Ln,{initial:"initial",animate:"animate",exit:"exit",variants:Bn,justify:"center",align:"center",style:{inset:"0",position:"absolute",backdropFilter:X?"blur(16px) saturate(0.5) grayscale(0.5)":"blur(2px)",transition:"backdrop-filter 0.2s ease-in-out",WebkitBackdropFilter:X?"blur(16px) saturate(0.5) grayscale(0.5)":"blur(2px)",WebkitTransition:"-webkit-backdrop-filter 0.2s ease-in-out",zIndex:1},children:r(c,{style:{...Vn[M]},justify:"center",align:"center",direction:"column",gap:4,children:[X&&n(a,{disabled:!0,fontSize:1,mode:"ghost",text:F("preview-frame.continue-button.text"),style:{opacity:0}}),n(s,{radius:2,tone:X?"caution":"inherit",padding:4,shadow:1,children:r(c,{justify:"center",align:"center",direction:"column",gap:4,children:[n(z,{muted:!0}),n(u,{muted:!0,size:1,children:F("preview-frame.status",X?{context:"timeout"}:{context:"connecting"})})]})}),X&&n(a,{fontSize:1,tone:"critical",onClick:oe,text:F("preview-frame.continue-button.text")})]})})}),n(Rn,{ref:t,style:{pointerEvents:(J||"connecting"===C&&"refreshing"!==l.status)&&!ae?"none":"auto",boxShadow:"0 0 0 1px var(--card-border-color)",borderTop:"1px solid transparent"},src:p.toString(),initial:["background"],variants:Gn,animate:[(J||"connecting"===C&&"refreshing"!==l.status)&&!ae?"background":"active",J?"reloading":"idle",M,de&&!ae?"timedOut":""],onLoad:me})]})})]})})})),Vn={desktop:{width:"100%",height:"100%"},mobile:{width:375,height:650}},Bn={initial:{opacity:1},animate:{opacity:[0,0,1]},exit:{opacity:[1,0,0]}},qn={initial:{opacity:1},animate:{opacity:[0,0,1]},exit:{opacity:[1,0,0]}},Gn={desktop:{...Vn.desktop,boxShadow:"0 0 0 0px var(--card-border-color)"},mobile:{...Vn.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 Jn=!1;function Xn(e,t){return e instanceof Function?e(t):e}function Hn(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=Ge(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 Zn(e){const{navigate:t,resolvers:n=[],path:r,previewUrl:i}=e,{state:o}=oe(),a=ee(),s=Z({apiVersion:me}),[c,l]=R(void 0),d=U(void 0),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 T((()=>{if(n.length&&u){let c;for(const e of n){const t=Hn(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}`:`*[${Xn(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=Xn(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 Qn(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 Yn(e){if(void 0!==e)return o.toString(function(e){const t=[];for(const n of e.split(".")){const e=It.exec(n);if(e){t.push(e[1],Number(e[2]));continue}const r=zt.exec(n);if(r){t.push(r[1],[Number(r[2]),Number(r[3])]);continue}const i=Dt.exec(n);i?t.push(i[1],{_key:i[2]}):t.push(n)}return t}(decodeURIComponent(e)))}function er(e){return Object.fromEntries(Object.entries(e).filter((([,e])=>void 0!==e&&""!==e&&null!==e)))}function tr({initialPreviewUrl:e,routerNavigate:t,routerState:n,routerSearchParams:r,frameStateRef:i}){const o=$((()=>{const{id:t,path:i,type:o}={id:Qn((a=n).id),path:Yn(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=$((()=>er({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=U(n);T((()=>{s.current=n}),[n]);return{structureParams:a,navigate:j(((e,n={},r)=>{e.id&&(e.id=q(e.id));const{_searchParams:o,...a}=s.current,c=(o||[]).reduce(((e,[t,n])=>(e[t]=n,e)),{}),l=er({...a,...e}),d=er({...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 nr(e,t,n){var r,i;const o=Z({apiVersion:me}),a=H(),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((()=>r||"")),a=U(0);T((()=>{if(i&&r)return window.clearTimeout(a.current),()=>{a.current=window.setTimeout((()=>{o("")}),100)}}),[i,r]);const s=Q();return $((()=>["@sanity/presentation",t,n,e,null==s?void 0:s.id,rr,i]),[t,null==s?void 0:s.id,e,n,i])}(t,s,c,n),d=function(e,t){const n=Z({apiVersion:me}),r=Q(),[i,o]=R(""),a=e?Xe((async()=>await Be(n,"@sanity/presentation",typeof window>"u"?"":location.href,null==r?void 0:r.id)),[...t,i]):null;return T((()=>{if(!a)return;const e=setTimeout((()=>{M((()=>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 Xe((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?Je(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 rr=Symbol();const ir=K((()=>import("./LoaderQueries.js"))),or=K((()=>import("./PostMessageRefreshMutations.js"))),ar=se(c)`
overflow-x: auto;
`;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
`;function sr(e){var t,a,s,l;const{previewUrl:d,components:u}=null!=(t=e.tool.options)?t:{},p=e.tool.name||ye,{unstable_navigator:m}=u||{},{navigate:f,state:v}=oe(),h=B(Object.fromEntries(v._searchParams||[])),g=nr(d||"/",p,h.preview||null),[y]=R((()=>{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=$((()=>g.origin),[g.origin]),b=U(null),[x,P]=R(),[E,k]=R({}),S=U({title:void 0,url:void 0}),{navigate:I,params:z,structureParams:C}=tr({initialPreviewUrl:g,routerNavigate:f,routerState:v,routerSearchParams:h,frameStateRef:S}),O=$((()=>$t(I,50)),[I]),[_,A]=N(Sn,{perspective:z.perspective,viewport:z.viewport},Un),[L,W]=function(e,t){if("published"!==e&&"previewDrafts"!==e)throw new Error(`Invalid perspective: ${e}`);const[n,r]=R({}),[i,o]=R({}),a=U(""),s=j(((e,n,i=[])=>{const s=i.filter((e=>"_projectId"in e&&e._projectId?(Jn||(console.warn("Cross dataset references are not supported yet, ignoring source document",e),Jn=!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 qe(i,r)?n:{...n,[e]:r}}))}),[t]);return[$((()=>{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]}(_.perspective,S),K=te(),V=ne(),q=Zn({resolvers:null==(s=null==(a=e.tool.options)?void 0:a.resolve)?void 0:s.mainDocuments,previewUrl:null==(l=e.tool.options)?void 0:l.previewUrl,path:z.preview,navigate:I});T((()=>{(_.perspective!==z.perspective||_.viewport!==z.viewport)&&O({},{perspective:"previewDrafts"===_.perspective?void 0:_.perspective,viewport:"desktop"===_.viewport?void 0:_.viewport})}),[z.perspective,_.perspective,O,_.viewport,z.viewport]);const[G,J]=R("connecting"),[X,H]=R("connecting"),[Z,Q]=R("connecting"),[Y]=R((()=>new Set)),ee=j((e=>{const t=window.open(e,"_blank");t&&Y.add(t)}),[Y]);T((()=>{if(Y.size&&x)for(const e of Y)e&&"closed"in e&&!e.closed&&x.addSource(e)}),[x,Y,Y.size]),T((()=>{var e;const t=null==(e=b.current)?void 0:e.contentWindow;if(!t)return;const n=function(e){const{destroy:t,send:n}=ct(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}=ct({...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?A({type:kn,enabled:t.enabled}):"visual-editing/documents"===e?W("visual-editing",t.perspective,t.documents):"visual-editing/refreshing"===e&&"manual"===t.source?clearTimeout(xe.current):"visual-editing/refreshing"===e&&"mutation"===t.source?A({type:bn}):"visual-editing/refreshed"===e&&A({type:wn});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===K&&t.dataset===V)W("loaders",t.perspective,t.documents);else if("loader/query-listen"===e&&t.projectId===K&&t.dataset===V){if("number"==typeof t.heartbeat&&t.heartbeat<ve)throw new Error(`Loader query listen heartbeat interval must be at least ${ve}ms`);k((e=>{var n;return{...e,[Ct(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===K&&t.dataset===V&&W("preview-kit",t.perspective,t.documents)}}]});return P(n),()=>{n.destroy(),P(void 0)}}),[V,K,W,O,w]),T((()=>{const e=setInterval((()=>M((()=>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}))))),ve);return()=>clearInterval(e)}),[]);const ie=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!==z.preview&&O({},{preview:n})}),[g,z,O]),se=j((e=>{O({},e)}),[O]);T((()=>{null==x||x.send("overlays","presentation/perspective",{perspective:_.perspective})}),[x,_.perspective]),T((()=>{z.id&&z.path?null==x||x.send("overlays","presentation/focus",{id:z.id,path:z.path}):null==x||x.send("overlays","presentation/blur",void 0)}),[x,z.id,z.path]),T((()=>{S.current.url&&z.preview&&S.current.url!==z.preview&&(S.current.url=z.preview,"connected"!==G&&b.current?b.current.src=`${w}${z.preview}`:null==x||x.send("overlays","presentation/navigate",{url:z.preview,type:"replace"}))}),[x,G,w,z.preview]);const ce=j((()=>null==x?void 0:x.send("overlays","presentation/toggleOverlay",void 0)),[x]),[le,de]=R(null);T((()=>{const e=e=>{_t(e)&&ce()},t=e=>{var t;_t(e)&&ce(),t=e,["mod","\\"].every((e=>Ot[e]?t[Ot[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,pe]=R(null),[{navigatorEnabled:me,toggleNavigator:fe},we]=vn({unstable_navigator:m}),be=U(z.id);T((()=>{z.rev&&be.current&&z.id!==be.current&&O({},{rev:void 0}),be.current=z.id}));const xe=U(),Pe=j((e=>{if(A({type:bn}),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=re(),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:ge,preview:z.preview}}}),[z.preview,Ee.name]);return r(i,{children:[n(yn,{devMode:y,name:p,navigate:O,params:z,structureParams:C,children:n(fn,{navigate:O,children:n(gn,{params:z,children:n(ar,{height:"fill",children:r(Jt,{children:[n(we,{}),n(jt,{id:"preview",minWidth:325,defaultSize:me?50:75,order:3,children:n(c,{direction:"column",flex:1,height:"fill",ref:pe,children:n(D,{element:ue,children:n(Kn,{dispatch:A,iframe:_.iframe,initialUrl:g,loadersConnection:X,navigatorEnabled:me,onPathChange:ae,onRefresh:Pe,openPopup:ee,overlaysConnection:G,params:z,perspective:_.perspective,ref:b,targetOrigin:w,toggleNavigator:fe,toggleOverlay:ce,viewport:_.viewport,visualEditing:_.visualEditing})})})}),n(mn,{mainDocumentState:q,params:z,documentsOnPage:L,getCommentIntent:ke,onFocusPath:ie,onStructureParams:se,setDisplayedDocument:de,structureParams:C})]})})})})}),x&&n(F,{children:n(ir,{channel:x,liveQueries:E,perspective:_.perspective,liveDocument:le,documentsOnPage:L})}),x&&z.id&&z.type&&n(F,{children:n(or,{channel:x,id:z.id,type:z.type,loadersConnection:X,previewKitConnection:Z})})]})}export{sr as default};//# sourceMappingURL=PresentationTool.js.map

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

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
import{h as e,g as s,i 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.13.0",
"version": "1.14.0",
"homepage": "https://github.com/sanity-io/visual-editing/tree/main/packages/presentation#readme",

@@ -94,4 +94,4 @@ "bugs": {

"@sanity/icons": "^2.11.8",
"@sanity/preview-url-secret": "^1.6.11",
"@sanity/ui": "^2.1.4",
"@sanity/preview-url-secret": "^1.6.12",
"@sanity/ui": "^2.1.6",
"@sanity/uuid": "3.0.2",

@@ -110,16 +110,16 @@ "@types/lodash.isequal": "^4.5.8",

"@repo/channels": "0.4.0",
"@repo/visual-editing-helpers": "0.6.9",
"@sanity/client": "^6.15.20",
"@sanity/pkg-utils": "6.8.8",
"@repo/visual-editing-helpers": "0.6.10",
"@sanity/client": "^6.17.2",
"@sanity/pkg-utils": "6.8.11",
"happy-dom": "^14.7.1",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"sanity": "^3.39.1",
"styled-components": "6.1.8",
"sanity": "^3.40.0",
"styled-components": "6.1.9",
"typescript": "5.4.5",
"vitest": "^1.5.2",
"vitest": "^1.6.0",
"@repo/package.config": "0.0.0"
},
"peerDependencies": {
"@sanity/client": "^6.15.20"
"@sanity/client": "^6.17.2"
},

@@ -126,0 +126,0 @@ "engines": {

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

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc