Socket
Socket
Sign inDemoInstall

@sanity/presentation

Package Overview
Dependencies
Maintainers
44
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.11.1 to 1.11.2

24

dist/_chunks/PresentationTool.js

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

var e=Object.defineProperty,t=(t,n,i)=>(((t,n,i)=>{n in t?e(t,n,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[n]=i})(t,"symbol"!=typeof n?n+"":n,i),i);import{jsx as n,jsxs as i,Fragment as r}from"react/jsx-runtime";import{studioPath as o}from"@sanity/client/csm";import{Card as a,Flex as s,Container as l,Stack as c,Text as d,Inline as u,Box as p,Button as h,Code as f,Label as m,ErrorBoundary as v,TextInput as g,MenuItem as y,useToast as w,Switch as b,usePrefersReducedMotion as x,TooltipDelayGroupProvider as k,Tooltip as P,MenuButton as E,Menu as S,Spinner as I,BoundaryElementProvider as z}from"@sanity/ui";import{useContext as C,forwardRef as D,useCallback as O,useMemo as R,useState as $,useEffect as j,createContext as L,useLayoutEffect as T,useRef as U,memo as A,createElement as _,startTransition as W,useReducer as M,Suspense as N,lazy as F}from"react";import{useUnique as V,getPublishedId as B,useActiveWorkspace as K,useClient as q,useCurrentUser as G,Hotkeys as J,useProjectId as H,useDataset as X,useWorkspace as Z}from"sanity";import{StateLink as Q,useRouter as Y,decodeJsonParams as ee}from"sanity/router";import{PaneRouterContext as te,PaneLayout as ne,StructureToolProvider as ie,DocumentListPane as re,useStructureTool as oe,DocumentPane as ae,CommentsIntentProvider as se}from"sanity/structure";import le from"styled-components";import{P as ce,a as de,b as ue,A as pe,M as he,c as fe,C as me,E as ve,D as ge}from"./index.js";import{D as ye}from"./DisplayedDocumentBroadcaster.js";import{ResetIcon as we,LaunchIcon as be,CopyIcon as xe,PanelLeftIcon as ke,RefreshIcon as Pe,ShareIcon as Ee,ChevronDownIcon as Se,CheckmarkIcon as Ie,DesktopIcon as ze,MobileDeviceIcon as Ce,EditIcon as De,PublishIcon as Oe}from"@sanity/icons";import{hasSecretSearchParams as Re,setSecretSearchParams as $e,withoutSecretSearchParams as je}from"@sanity/preview-url-secret/without-secret-search-params";import{motion as Le,MotionConfig as Te,AnimatePresence as Ue}from"framer-motion";import{createPreviewSecret as Ae}from"@sanity/preview-url-secret/create-secret";import _e from"fast-deep-equal";import{definePreviewUrl as We}from"@sanity/preview-url-secret/define-preview-url";import{suspend as Me}from"suspend-react";let Ne;const Fe=new Uint8Array(16);function Ve(){if(!Ne&&(Ne=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!Ne))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return Ne(Fe)}const Be=[];for(let e=0;e<256;++e)Be.push((e+256).toString(16).slice(1));var Ke={randomUUID:typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function qe(e,t,n){if(Ke.randomUUID&&!t&&!e)return Ke.randomUUID();const i=(e=e||{}).random||(e.rng||Ve)();if(i[6]=15&i[6]|64,i[8]=63&i[8]|128,t){n=n||0;for(let e=0;e<16;++e)t[n+e]=i[e];return t}return function(e,t=0){return Be[e[t+0]]+Be[e[t+1]]+Be[e[t+2]]+Be[e[t+3]]+"-"+Be[e[t+4]]+Be[e[t+5]]+"-"+Be[e[t+6]]+Be[e[t+7]]+"-"+Be[e[t+8]]+Be[e[t+9]]+"-"+Be[e[t+10]]+Be[e[t+11]]+Be[e[t+12]]+Be[e[t+13]]+Be[e[t+14]]+Be[e[t+15]]}(i)}const Ge=1e3,Je=1e3,He=500,Xe=["handshake/syn","handshake/syn-ack","handshake/ack"],Ze=e=>Xe.some((t=>t===e)),Qe=({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 Ye(e){const t=e.target,n=e.connectTo.map((e=>({buffer:[],config:e,id:"",handler:r,status:"connecting",interval:void 0,heartbeat:void 0})));function i(e){window.clearInterval(e.interval)}function r(e){const{data:t}=e;if(Ze(t.type)){const e=n.find((e=>e.config.id===t.from));e&&"handshake/syn-ack"===t.type&&(l(e,"connected"),c(e,"handshake/ack",{id:e.id}))}}const o=t=>{var i,r,o;const{data:a}=t;if(!Ze(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==(r=(i=t.config).onEvent)||r.call(i,...n),null==(o=e.onEvent)||o.call(e,...n),d(t,"channel/response",{responseTo:a.id},!1)}}};function a(t){var i;if(Qe(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:i,origin:r}=t;return"sanity/channels"===i.domain&&i.to==e.id&&n.map((e=>e.config.id)).includes(i.from)&&"channel/response"!==i.type&&r===e.targetOrigin}(t)){const{data:e}=t;null==(i=n.find((t=>t.config.id===e.from)))||i.handler(t)}}function s(e){e.heartbeat&&window.clearInterval(e.heartbeat)}function l(t,n){var a,l,u;t.status=n,null==(l=(a=t.config).onStatusUpdate)||l.call(a,n,t.config.id),null==(u=e.onStatusUpdate)||u.call(e,n,t.config.id),"connecting"===n||"reconnecting"===n?(t.handler=r,s(t),function(e){e.id=qe(),e.interval=window.setInterval((()=>{c(e,"handshake/syn",{id:e.id})}),He)}(t)):"connected"===n?(t.handler=o,i(t),function(e){if(s(e),e.config.heartbeat){const t="number"==typeof e.config.heartbeat?e.config.heartbeat:Je;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=r,i(t),s(t))}function c(n,i,r){if(!n.id)throw new Error("No channel ID set");const o={connectionId:n.id,data:r,domain:"sanity/channels",from:e.id,id:qe(),to:n.config.id,type:i};try{null==t||t.postMessage(o,{targetOrigin:"*"})}catch{throw new Error(`Failed to postMessage '${o.id}' on '${e.id}'`)}}function d(n,i,r,o=!0){const a=qe();if("connecting"===n.status||"reconnecting"===n.status||"disconnected"===n.status)return void n.buffer.push({type:i,data:r});if(!n.id)throw new Error("No channel ID set");const s={connectionId:n.id,data:r,domain:"sanity/channels",from:e.id,id:a,to:n.config.id,type:i};if(o){const t=setTimeout((()=>{s.connectionId===n.id&&(window.removeEventListener("message",o,!1),"channel/heartbeat"!==i&&n.buffer.push({type:i,data:r}),l(n,"reconnecting"),console.warn(`Received no response to message '${s.type}' on client '${e.id}' (ID: '${s.id}').`))}),Ge),o=e=>{var n;const{data:i}=e;"channel/response"===i.type&&null!=(n=i.data)&&n.responseTo&&i.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=>{l(e,"connecting")})),{destroy:function(){n.forEach((e=>{["disconnected"].includes(e.status)||(d(e,"channel/disconnect",{id:e.id},!1),l(e,"disconnected"))})),window.removeEventListener("message",a,!1),n.forEach((e=>{s(e),i(e)}))},send:function(e,t,i){(e?Array.isArray(e)?[...e]:[e]:n).forEach((e=>{const r=n.find((t=>t.config.id===e));if(!r)throw new Error("Invalid channel ID");d(r,t,i)}))}}}const et=/^([A-Za-z]+):([0-9]+)$/,tt=/^([A-Za-z]+):([0-9]+),([0-9]+)$/,nt=/^([A-Za-z]+):([a-z0-9]+)$/;const it={alt:"altKey",ctrl:"ctrlKey",mod:typeof window<"u"&&/Mac|iPod|iPhone|iPad/.test(window.navigator.platform)?"metaKey":"ctrlKey",shift:"shiftKey"};function rt(e){return"Alt"===e.key}function ot(e){const{children:t,message:r,onRetry:o,onContinueAnyway:f,...m}=e,v=n(h,{fontSize:1,mode:"ghost",onClick:o,text:"Retry"}),g=n(h,{fontSize:1,mode:"ghost",tone:"critical",onClick:f,text:"Continue anyway"});return n(a,{height:"fill",...m,children:n(s,{align:"center",height:"fill",justify:"center",children:n(l,{padding:4,sizing:"border",width:0,children:i(c,{space:4,children:[i(c,{space:3,children:[n(d,{size:1,weight:"semibold",children:"An error occured"}),n(d,{muted:!0,size:1,children:r})]}),t,o&&f?i(u,{space:2,children:[v,g]}):o?n(p,{children:v}):f?n(p,{children:g}):null]})})})})}function at(){const e=C(ce);if(!e)throw new Error("Presentation context is missing");return e}function st(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 lt=D((function(e,t){const{deskParams:i,params:r}=at();return n(Q,{...e,ref:t,state:{type:void 0,_searchParams:Object.entries({...i,preview:r.preview})},title:void 0})})),ct=D((function(e,t){const{documentId:i,documentType:r,parentRefPath:o,template:a,...s}=e;return n(Q,{...s,ref:t,state:{id:i,type:r},title:void 0})}));function dt(e){const{children:t,params:i,onDeskParams:o,previewUrl:a,refs:s}=e,{state:l,resolvePathFromState:c}=Y(),d=V(Object.fromEntries(l._searchParams||[])),u=O((e=>`${c(l)}${st({...d,...e})}`),[c,d,l]),p=R((()=>({index:0,groupIndex:0,siblingIndex:0,payload:{},params:i,hasGroupSiblings:!1,groupLength:1,routerPanesState:[],ChildLink:e=>{const{childId:t,...i}=e,r=null==s?void 0:s.find((e=>e._id===t||B(e._id)===t));return r?n(Q,{...i,state:{id:t,type:r._type,_searchParams:Object.entries({preview:a})}}):n("div",{...i})},BackLink:lt,ReferenceChildLink:ct,ParameterizedLink:()=>n(r,{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;o({...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,o,i,a,s]);return n(te.Provider,{value:p,children:t})}const ut=le(ne)`
var e=Object.defineProperty,t=(t,n,i)=>(((t,n,i)=>{n in t?e(t,n,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[n]=i})(t,"symbol"!=typeof n?n+"":n,i),i);import{jsx as n,jsxs as i,Fragment as r}from"react/jsx-runtime";import{studioPath as o}from"@sanity/client/csm";import{Card as a,Flex as s,Container as c,Stack as l,Text as d,Inline as u,Box as p,Button as h,Code as f,Label as m,ErrorBoundary as v,TextInput as g,MenuItem as y,useToast as w,Switch as b,usePrefersReducedMotion as x,TooltipDelayGroupProvider as k,Tooltip as P,MenuButton as E,Menu as S,Spinner as I,BoundaryElementProvider as z}from"@sanity/ui";import{useContext as C,forwardRef as D,useCallback as O,useMemo as R,useState as $,useEffect as j,createContext as L,useLayoutEffect as T,useRef as U,memo as A,createElement as _,startTransition as W,useReducer as M,Suspense as N,lazy as F}from"react";import{useUnique as V,getPublishedId as B,useActiveWorkspace as K,useClient as q,useCurrentUser as G,Hotkeys as J,useProjectId as H,useDataset as X,useWorkspace as Z}from"sanity";import{StateLink as Q,useRouter as Y,decodeJsonParams as ee}from"sanity/router";import{PaneRouterContext as te,PaneLayout as ne,StructureToolProvider as ie,DocumentListPane as re,useStructureTool as oe,DocumentPane as ae,CommentsIntentProvider as se}from"sanity/structure";import ce from"styled-components";import{P as le,a as de,b as ue,A as pe,M as he,c as fe,C as me,E as ve,D as ge}from"./index.js";import{D as ye}from"./DisplayedDocumentBroadcaster.js";import{ResetIcon as we,LaunchIcon as be,CopyIcon as xe,PanelLeftIcon as ke,RefreshIcon as Pe,ShareIcon as Ee,ChevronDownIcon as Se,CheckmarkIcon as Ie,DesktopIcon as ze,MobileDeviceIcon as Ce,EditIcon as De,PublishIcon as Oe}from"@sanity/icons";import{hasSecretSearchParams as Re,setSecretSearchParams as $e,withoutSecretSearchParams as je}from"@sanity/preview-url-secret/without-secret-search-params";import{motion as Le,MotionConfig as Te,AnimatePresence as Ue}from"framer-motion";import{createPreviewSecret as Ae}from"@sanity/preview-url-secret/create-secret";import _e from"fast-deep-equal";import{definePreviewUrl as We}from"@sanity/preview-url-secret/define-preview-url";import{suspend as Me}from"suspend-react";let Ne;const Fe=new Uint8Array(16);function Ve(){if(!Ne&&(Ne=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!Ne))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return Ne(Fe)}const Be=[];for(let e=0;e<256;++e)Be.push((e+256).toString(16).slice(1));var Ke={randomUUID:typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function qe(e,t,n){if(Ke.randomUUID&&!t&&!e)return Ke.randomUUID();const i=(e=e||{}).random||(e.rng||Ve)();if(i[6]=15&i[6]|64,i[8]=63&i[8]|128,t){n=n||0;for(let e=0;e<16;++e)t[n+e]=i[e];return t}return function(e,t=0){return Be[e[t+0]]+Be[e[t+1]]+Be[e[t+2]]+Be[e[t+3]]+"-"+Be[e[t+4]]+Be[e[t+5]]+"-"+Be[e[t+6]]+Be[e[t+7]]+"-"+Be[e[t+8]]+Be[e[t+9]]+"-"+Be[e[t+10]]+Be[e[t+11]]+Be[e[t+12]]+Be[e[t+13]]+Be[e[t+14]]+Be[e[t+15]]}(i)}const Ge=1e3,Je=1e3,He=500,Xe=["handshake/syn","handshake/syn-ack","handshake/ack"],Ze=e=>Xe.some((t=>t===e)),Qe=({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 Ye(e){const t=e.target,n=e.connectTo.map((e=>({buffer:[],config:e,id:"",handler:r,status:"connecting",interval:void 0,heartbeat:void 0})));function i(e){window.clearInterval(e.interval)}function r(e){const{data:t}=e;if(Ze(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 i,r,o;const{data:a}=t;if(!Ze(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==(r=(i=t.config).onEvent)||r.call(i,...n),null==(o=e.onEvent)||o.call(e,...n),d(t,"channel/response",{responseTo:a.id},!1)}}};function a(t){var i;if(Qe(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:i,origin:r}=t;return"sanity/channels"===i.domain&&i.to==e.id&&n.map((e=>e.config.id)).includes(i.from)&&"channel/response"!==i.type&&r===e.targetOrigin}(t)){const{data:e}=t;null==(i=n.find((t=>t.config.id===e.from)))||i.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=r,s(t),function(e){e.id=qe(),e.interval=window.setInterval((()=>{l(e,"handshake/syn",{id:e.id})}),He)}(t)):"connected"===n?(t.handler=o,i(t),function(e){if(s(e),e.config.heartbeat){const t="number"==typeof e.config.heartbeat?e.config.heartbeat:Je;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=r,i(t),s(t))}function l(n,i,r){if(!n.id)throw new Error("No channel ID set");const o={connectionId:n.id,data:r,domain:"sanity/channels",from:e.id,id:qe(),to:n.config.id,type:i};try{null==t||t.postMessage(o,{targetOrigin:"*"})}catch{throw new Error(`Failed to postMessage '${o.id}' on '${e.id}'`)}}function d(n,i,r,o=!0){const a=qe();if("connecting"===n.status||"reconnecting"===n.status||"disconnected"===n.status)return void n.buffer.push({type:i,data:r});if(!n.id)throw new Error("No channel ID set");const s={connectionId:n.id,data:r,domain:"sanity/channels",from:e.id,id:a,to:n.config.id,type:i};if(o){const t=setTimeout((()=>{s.connectionId===n.id&&(window.removeEventListener("message",o,!1),"channel/heartbeat"!==i&&n.buffer.push({type:i,data:r}),c(n,"reconnecting"),console.warn(`Received no response to message '${s.type}' on client '${e.id}' (ID: '${s.id}').`))}),Ge),o=e=>{var n;const{data:i}=e;"channel/response"===i.type&&null!=(n=i.data)&&n.responseTo&&i.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),i(e)}))},send:function(e,t,i){(e?Array.isArray(e)?[...e]:[e]:n).forEach((e=>{const r=n.find((t=>t.config.id===e));if(!r)throw new Error("Invalid channel ID");d(r,t,i)}))}}}const et=/^([A-Za-z]+):([0-9]+)$/,tt=/^([A-Za-z]+):([0-9]+),([0-9]+)$/,nt=/^([A-Za-z]+):([a-z0-9]+)$/;const it={alt:"altKey",ctrl:"ctrlKey",mod:typeof window<"u"&&/Mac|iPod|iPhone|iPad/.test(window.navigator.platform)?"metaKey":"ctrlKey",shift:"shiftKey"};function rt(e){return"Alt"===e.key}function ot(e){const{children:t,message:r,onRetry:o,onContinueAnyway:f,...m}=e,v=n(h,{fontSize:1,mode:"ghost",onClick:o,text:"Retry"}),g=n(h,{fontSize:1,mode:"ghost",tone:"critical",onClick:f,text:"Continue anyway"});return n(a,{height:"fill",...m,children:n(s,{align:"center",height:"fill",justify:"center",children:n(c,{padding:4,sizing:"border",width:0,children:i(l,{space:4,children:[i(l,{space:3,children:[n(d,{size:1,weight:"semibold",children:"An error occured"}),n(d,{muted:!0,size:1,children:r})]}),t,o&&f?i(u,{space:2,children:[v,g]}):o?n(p,{children:v}):f?n(p,{children:g}):null]})})})})}function at(){const e=C(le);if(!e)throw new Error("Presentation context is missing");return e}function st(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 ct=D((function(e,t){const{deskParams:i,params:r}=at();return n(Q,{...e,ref:t,state:{type:void 0,_searchParams:Object.entries({...i,preview:r.preview})},title:void 0})})),lt=D((function(e,t){const{documentId:i,documentType:r,parentRefPath:o,template:a,...s}=e;return n(Q,{...s,ref:t,state:{id:i,type:r},title:void 0})}));function dt(e){const{children:t,params:i,onDeskParams:o,previewUrl:a,refs:s}=e,{state:c,resolvePathFromState:l}=Y(),d=V(Object.fromEntries(c._searchParams||[])),u=O((e=>`${l(c)}${st({...d,...e})}`),[l,d,c]),p=R((()=>({index:0,groupIndex:0,siblingIndex:0,payload:{},params:i,hasGroupSiblings:!1,groupLength:1,routerPanesState:[],ChildLink:e=>{const{childId:t,...i}=e,r=null==s?void 0:s.find((e=>e._id===t||B(e._id)===t));return r?n(Q,{...i,state:{id:t,type:r._type,_searchParams:Object.entries({preview:a})}}):n("div",{...i})},BackLink:ct,ReferenceChildLink:lt,ParameterizedLink:()=>n(r,{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;o({...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,o,i,a,s]);return n(te.Provider,{value:p,children:t})}const ut=ce(ne)`
height: 100%;
`,pt=le(s)`
`,pt=ce(s)`
& > div {

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

}
`,ht=le(f)`
`,ht=ce(f)`
white-space: pre-wrap;
`;function ft(e){const{onDeskParams:t,previewUrl:r,refs:o}=e,{devMode:s}=at(),l=R((()=>({id:"$root",options:{filter:"_id in $ids",params:{ids:o.map((e=>e._id))}},schemaTypeName:"",title:"Documents on this page",type:"documentList"})),[o]),[d,u]=$(null),p=O((()=>u(null)),[]),[h]=$((()=>({})));return j((()=>u(null)),[o]),d?n(ot,{flex:1,message:"Could not render the document list",onRetry:p,children:s&&n(a,{overflow:"auto",padding:3,radius:2,tone:"critical",children:i(c,{space:3,children:[n(m,{muted:!0,size:0,children:"Error message"}),n(ht,{size:1,children:d.error.message})]})})}):n(v,{onCatch:u,children:n(ut,{children:n(ie,{children:n(dt,{params:h,onDeskParams:t,previewUrl:r,refs:o,children:n(pt,{direction:"column",flex:1,children:n(re,{index:0,itemId:"$root",pane:l,paneKey:"$root"})})})})})})}const mt=le(f)`
`;function ft(e){const{onDeskParams:t,previewUrl:r,refs:o}=e,{devMode:s}=at(),c=R((()=>({id:"$root",options:{filter:"_id in $ids",params:{ids:o.map((e=>e._id))}},schemaTypeName:"",title:"Documents on this page",type:"documentList"})),[o]),[d,u]=$(null),p=O((()=>u(null)),[]),[h]=$((()=>({})));return j((()=>u(null)),[o]),d?n(ot,{flex:1,message:"Could not render the document list",onRetry:p,children:s&&n(a,{overflow:"auto",padding:3,radius:2,tone:"critical",children:i(l,{space:3,children:[n(m,{muted:!0,size:0,children:"Error message"}),n(ht,{size:1,children:d.error.message})]})})}):n(v,{onCatch:u,children:n(ut,{children:n(ie,{children:n(dt,{params:h,onDeskParams:t,previewUrl:r,refs:o,children:n(pt,{direction:"column",flex:1,children:n(re,{index:0,itemId:"$root",pane:c,paneKey:"$root"})})})})})})}const mt=ce(f)`
white-space: pre-wrap;
`;function vt(e){const{documentId:t,documentType:r,params:o,onDeskParams:s,onFocusPath:l}=e,{template:d,templateParams:u}=o,{devMode:p}=at(),h=R((()=>({id:t,options:{id:t,type:r,template:d,templateParameters:ee(u)},title:"",type:"document"})),[t,r,d,u]),[f,g]=$(null),y=O((()=>g(null)),[]);j((()=>{g(null)}),[t,r,o]);const{setLayoutCollapsed:w}=oe(),b=O((()=>w(!0)),[w]),x=O((()=>w(!1)),[w]);return f?n(ot,{flex:1,message:"Could not render the document editor",onRetry:y,children:p&&n(a,{overflow:"auto",padding:3,radius:2,tone:"critical",children:i(c,{space:3,children:[n(m,{muted:!0,size:0,children:"Error message"}),n(mt,{size:1,children:f.error.message})]})})}):n(v,{onCatch:g,children:n(ne,{style:{height:"100%"},onExpand:x,onCollapse:b,children:n(dt,{onDeskParams:s,params:o,children:n(ae,{paneKey:"document",index:1,itemId:"document",pane:h,onFocusPath:l})})})})}function gt(e){const{deskParams:t,documentId:i,documentType:r,onDeskParams:o,onFocusPath:a}=e;return n(ie,{children:n(vt,{documentId:i,documentType:r,params:t,onDeskParams:o,onFocusPath:a})})}function yt(e){const{deskParams:t,documentId:i,documentType:r,onDeskParams:o,onFocusPath:a,previewUrl:s,refs:l}=e;return i&&r?n(gt,{deskParams:t,documentId:i,documentType:r,onDeskParams:o,onFocusPath:a}):n(ft,{onDeskParams:o,previewUrl:s,refs:l})}const wt=L(null);wt.displayName="PanelsContext";const bt=le.div`
`;function vt(e){const{documentId:t,documentType:r,params:o,onDeskParams:s,onFocusPath:c}=e,{template:d,templateParams:u}=o,{devMode:p}=at(),h=R((()=>({id:t,options:{id:t,type:r,template:d,templateParameters:ee(u)},title:"",type:"document"})),[t,r,d,u]),[f,g]=$(null),y=O((()=>g(null)),[]);j((()=>{g(null)}),[t,r,o]);const{setLayoutCollapsed:w}=oe(),b=O((()=>w(!0)),[w]),x=O((()=>w(!1)),[w]);return f?n(ot,{flex:1,message:"Could not render the document editor",onRetry:y,children:p&&n(a,{overflow:"auto",padding:3,radius:2,tone:"critical",children:i(l,{space:3,children:[n(m,{muted:!0,size:0,children:"Error message"}),n(mt,{size:1,children:f.error.message})]})})}):n(v,{onCatch:g,children:n(ne,{style:{height:"100%"},onExpand:x,onCollapse:b,children:n(dt,{onDeskParams:s,params:o,children:n(ae,{paneKey:"document",index:1,itemId:"document",pane:h,onFocusPath:c})})})})}function gt(e){const{deskParams:t,documentId:i,documentType:r,onDeskParams:o,onFocusPath:a}=e;return n(ie,{children:n(vt,{documentId:i,documentType:r,params:t,onDeskParams:o,onFocusPath:a})})}function yt(e){const{deskParams:t,documentId:i,documentType:r,onDeskParams:o,onFocusPath:a,previewUrl:s,refs:c}=e;return i&&r?n(gt,{deskParams:t,documentId:i,documentType:r,onDeskParams:o,onFocusPath:a}):n(ft,{onDeskParams:o,previewUrl:s,refs:c})}const wt=L(null);wt.displayName="PanelsContext";const bt=ce.div`
overflow: hidden;
flex-basis: 0;
flex-shrink: 1;
`,xt=function({children:e,defaultSize:t=null,id:i,minWidth:r,maxWidth:o,order:a=0}){const s=C(wt);if(null===s)throw Error("Panel components must be rendered within a PanelGroup container");const{getPanelStyle:l,registerElement:c,unregisterElement:d}=s,u=l(i);return T((()=>(c(i,{id:i,type:"panel",defaultSize:t,maxWidth:null!=o?o:null,minWidth:null!=r?r:0,order:a}),()=>{d(i)})),[i,t,a,o,r,c,d]),n(bt,{style:u,children:e})};const kt=le.div`
`,xt=function({children:e,defaultSize:t=null,id:i,minWidth:r,maxWidth:o,order:a=0}){const s=C(wt);if(null===s)throw Error("Panel components must be rendered within a PanelGroup container");const{getPanelStyle:c,registerElement:l,unregisterElement:d}=s,u=c(i);return T((()=>(l(i,{id:i,type:"panel",defaultSize:t,maxWidth:null!=o?o:null,minWidth:null!=r?r:0,order:a}),()=>{d(i)})),[i,t,a,o,r,l,d]),n(bt,{style:u,children:e})};const kt=ce.div`
position: relative;
`,Pt=le.div`
`,Pt=ce.div`
position: absolute;

@@ -40,3 +40,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 "}
`,Et=function({id:e,order:t,disabled:r=!1}){const o=U(null),a=C(wt);if(null===a)throw Error("Panel components must be rendered within a PanelGroup container");const s=function(e){return U(e||qe()).current}(e),{activeResizer:l,drag:c,startDragging:d,stopDragging:u,registerElement:p,unregisterElement:h}=a,f=l===s;if(null===a)throw Error("Panel components must be rendered within a PanelGroup container");const m=O((e=>{d(s,e.nativeEvent)}),[s,d]),v=O((e=>{c(s,e)}),[s,c]),g=O((()=>{o.current.blur(),u()}),[u]);return j((()=>{if(f&&!r)return window.addEventListener("mousemove",v),window.addEventListener("mouseup",g),()=>{window.removeEventListener("mousemove",v),window.removeEventListener("mouseup",g)}}),[r,f,v,g]),T((()=>(p(s,{id:s,order:t,type:"resizer",el:o}),()=>{h(s)})),[s,t,p,h]),n(kt,{onMouseDown:m,ref:o,children:i(Pt,{$disabled:r,children:[n("span",{}),n("span",{})]})})};function St(e,t){let n;return(...i)=>{clearTimeout(n),n=setTimeout((()=>{e.apply(e,i)}),t)}}const It="presentation/panels",zt=()=>JSON.parse(localStorage.getItem(It)||"{}"),Ct=e=>e.map((e=>[e.id,e.order].join(":"))).join(",");function Dt(){return R((()=>{const e=(e,t)=>{(e=>{localStorage.setItem(It,JSON.stringify(e))})({...zt(),[Ct(e)]:t})};return{get:e=>zt()[Ct(e)],set:e,setDebounced:St(e,100)}}),[])}function Ot(e,t,n){const{maxWidth:i,minWidth:r}=e,o=null==i?100:i/n*100,a=r/n*100;return Math.min(o,Math.max(a,t))}function Rt(e,t,n){if(1===e.length)return"100";const i=n[e.findIndex((e=>e.id===t))];return null==i?"0":i.toPrecision(10)}function $t(e,t,n=0,i=null){return e.clientX-(i||t.getBoundingClientRect()).left-n}function jt(e){return"panel"===e.type}function Lt(e){return"resizer"===e.type}function Tt(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 Ut(e,t,n){const i=t.reduce(((e,t)=>e+t),0),r=[...t].map((e=>e/i*100));let o=0;for(let t=0;t<e.length;t++){const i=e[t],a=r[t],s=Ot(i,a,n);a!=s&&(o+=a-s,r[t]=s)}if("0.000"!==o.toFixed(3))for(let t=0;t<e.length;t++){const i=e[t];let{maxWidth:a,minWidth:s}=i;s=s/n*100,null!=a&&(a=a/n*100);const l=Math.min(null!=a?a:100,Math.max(s,r[t]+o));if(l!==r[t]&&(o-=l-r[t],r[t]=l,"0.000"===Math.abs(o).toFixed(3)))break}return r}const At=le.div`
`,Et=function({id:e,order:t,disabled:r=!1}){const o=U(null),a=C(wt);if(null===a)throw Error("Panel components must be rendered within a PanelGroup container");const s=function(e){return U(e||qe()).current}(e),{activeResizer:c,drag:l,startDragging:d,stopDragging:u,registerElement:p,unregisterElement:h}=a,f=c===s;if(null===a)throw Error("Panel components must be rendered within a PanelGroup container");const m=O((e=>{d(s,e.nativeEvent)}),[s,d]),v=O((e=>{l(s,e)}),[s,l]),g=O((()=>{o.current.blur(),u()}),[u]);return j((()=>{if(f&&!r)return window.addEventListener("mousemove",v),window.addEventListener("mouseup",g),()=>{window.removeEventListener("mousemove",v),window.removeEventListener("mouseup",g)}}),[r,f,v,g]),T((()=>(p(s,{id:s,order:t,type:"resizer",el:o}),()=>{h(s)})),[s,t,p,h]),n(kt,{onMouseDown:m,ref:o,children:i(Pt,{$disabled:r,children:[n("span",{}),n("span",{})]})})};function St(e,t){let n;return(...i)=>{clearTimeout(n),n=setTimeout((()=>{e.apply(e,i)}),t)}}const It="presentation/panels",zt=()=>JSON.parse(localStorage.getItem(It)||"{}"),Ct=e=>e.map((e=>[e.id,e.order].join(":"))).join(",");function Dt(){return R((()=>{const e=(e,t)=>{(e=>{localStorage.setItem(It,JSON.stringify(e))})({...zt(),[Ct(e)]:t})};return{get:e=>zt()[Ct(e)],set:e,setDebounced:St(e,100)}}),[])}function Ot(e,t,n){const{maxWidth:i,minWidth:r}=e,o=null==i?100:i/n*100,a=r/n*100;return Math.min(o,Math.max(a,t))}function Rt(e,t,n){if(1===e.length)return"100";const i=n[e.findIndex((e=>e.id===t))];return null==i?"0":i.toPrecision(10)}function $t(e,t,n=0,i=null){return e.clientX-(i||t.getBoundingClientRect()).left-n}function jt(e){return"panel"===e.type}function Lt(e){return"resizer"===e.type}function Tt(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 Ut(e,t,n){const i=t.reduce(((e,t)=>e+t),0),r=[...t].map((e=>e/i*100));let o=0;for(let t=0;t<e.length;t++){const i=e[t],a=r[t],s=Ot(i,a,n);a!=s&&(o+=a-s,r[t]=s)}if("0.000"!==o.toFixed(3))for(let t=0;t<e.length;t++){const i=e[t];let{maxWidth:a,minWidth:s}=i;s=s/n*100,null!=a&&(a=a/n*100);const c=Math.min(null!=a?a:100,Math.max(s,r[t]+o));if(c!==r[t]&&(o-=c-r[t],r[t]=c,"0.000"===Math.abs(o).toFixed(3)))break}return r}const At=ce.div`
display: flex;

@@ -47,3 +47,3 @@ flex-direction: row;

width: 100%;
`,_t=function({children:e}){const t=U(null),[i,r]=$(new Map),o=R((()=>Tt(i).filter(jt)),[i]),[a,s]=$([]),[l,c]=$(null),d=U({elements:i,panels:o,widths:a}),u=O((e=>({flexGrow:Rt(o,e,a),pointerEvents:null===l?void 0:"none"})),[l,o,a]),p=O(((e,t)=>{r((n=>{if(n.has(e))return n;const i=new Map(n);return i.set(e,t),i}))}),[]),h=O((e=>{r((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:[]}),m=O(((e,t)=>{const n=Tt(i),r=n.findIndex((t=>t.id===e)),o=i.get(e);if(!o||!Lt(o))return;const a=o.el.current;a&&(f.current={resizerIndex:r,panelBefore:n.reduce(((e,t,n)=>jt(t)&&n<r?t:e),null),panelAfter:n.reduce(((e,t,n)=>null===e&&jt(t)&&n>r?t:e),null),containerWidth:window.innerWidth,startX:t.pageX,dragOffset:$t(t,a),resizerRect:a.getBoundingClientRect(),widths:d.current.widths},c(e))}),[i]),v=O((()=>{c(null)}),[]),g=O(((e,n)=>{n.preventDefault(),n.stopPropagation();const{containerWidth:r,dragOffset:o,panelBefore:a,panelAfter:l,resizerRect:c}=f.current;if(null==a||null==l)return;const u=i.get(e);if(!u||!Lt(u))return;const p=u.el.current;if(!p)return;const h=$t(n,p,o,c);if(0===h)return;const{widths:m}=d.current,v=function(e,t,n,i,r,o){const{panels:a,widths:s}=r,{widths:l}=o,c=l||s,d=[...c];{const r=e<0?i:n,o=c[a.findIndex((e=>e.id===r.id))],s=Ot(r,o+Math.abs(e),t);if(o===s)return c;e=e<0?o-s:s-o}let u=0,p=e<0?n:i,h=a.findIndex((e=>e.id===p.id));for(;;){const n=a[h],i=c[h],r=Ot(n,i-(Math.abs(e)-Math.abs(u)),t);if(i!==r&&(u+=i-r,d[h]=r,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?c:(p=e<0?i:n,h=a.findIndex((e=>e.id===p.id)),d[h]=c[h]+u,d)}(h/t.current.getBoundingClientRect().width*100,r,a,l,d.current,f.current);m.some(((e,t)=>e!==v[t]))&&s(v)}),[i]);T((()=>{d.current.elements=i,d.current.panels=o,d.current.widths=a}),[i,o,a]);const y=Dt();T((()=>{const{widths:e}=d.current;if(e.length===o.length)return;const t=y.get(o);if(t){const e=Ut(o,t,window.innerWidth);return void s(e)}const n=function(e){let t=e.length,n=100;const i=e.map((e=>e.defaultSize?(n-=e.defaultSize,t-=1,e.defaultSize):null)),r=n/t;return i.map((e=>null===e?r:e))}(o);s(n)}),[y,o]),j((()=>{a.length&&y.setDebounced(o,a)}),[y,o,a]),T((()=>{const e=new ResizeObserver((()=>{const{panels:e,widths:t}=d.current,n=Ut(e,t,window.innerWidth);t.some(((e,t)=>e!==n[t]))&&s(n)}));return e.observe(t.current),()=>{e.disconnect()}}),[]);const w=R((()=>({activeResizer:l,drag:g,getPanelStyle:u,registerElement:p,startDragging:m,stopDragging:v,unregisterElement:h})),[l,g,u,p,m,v,h]);return n(wt.Provider,{value:w,children:n(At,{ref:t,children:e})})},Wt=function(e){const{children:t,navigate:i}=e,r=O(((e,t=void 0)=>{i(t||{},e?{preview:e}:{})}),[i]);return n(de.Provider,{value:r,children:t})};function Mt(e){const{unstable_navigator:t}=e,i=!(null==t||!t.component),[o,a]=function(e,t){const[n,i]=$((()=>{var n;return JSON.parse(null!=(n=localStorage.getItem(e))?n:JSON.stringify(t))}));return j((()=>{localStorage.setItem(e,JSON.stringify(n))}),[e,n]),[n,i]}("presentation/navigator",i),s=!!i&&o,l=R((()=>{if(i)return()=>a((e=>!e))}),[i,a]),c=O((function(){return n(r,{children:s&&n(Nt,{...t})})}),[s,t]);return[{navigatorEnabled:s,toggleNavigator:l},c]}const Nt=A((function(e){const{minWidth:t,maxWidth:o,component:a}=e,s=null!=t&&null!=o&&t===o;return i(r,{children:[n(xt,{id:"navigator",minWidth:t,maxWidth:o,order:1,children:n(a,{})}),n(Et,{order:2,disabled:s})]})})),Ft=function(e){const{children:t,params:i}=e,r=R((()=>i),[i]);return n(ue.Provider,{value:r,children:t})},Vt=function(e){const{children:t,deskParams:i,devMode:r,name:o,navigate:a,params:s}=e,l=R((()=>({deskParams:i,devMode:r,name:o,navigate:a,params:s})),[i,r,o,a,s]);return n(ce.Provider,{value:l,children:t})};var Bt,Kt,qt,Gt,Jt=class extends Error{constructor(e){super(e[0].message),t(this,"issues"),this.name="ValiError",this.issues=e}};function Ht(e,t){return Array.isArray(e)?[void 0,e]:[e,t]}function Xt(e,t,n,i,r){var o,a,s,l,c;const d=null!=(c=null!=(l=null!=(s=null!=(a=null!=(o=t.message)?o:function(e,t){var n;return null==(n=null==Gt?void 0:Gt.get(e))?void 0:n.get(t)}(n,r.lang))?a:e?(u=r.lang,null==qt?void 0:qt.get(u)):null)?s:null==i?void 0:i.message)?l:function(e){return null==Kt?void 0:Kt.get(e)}(r.lang))?c:r.message;var u;return"function"==typeof d?d(r):d}function Zt(e,t,n){return{typed:e,output:t,issues:n}}function Qt(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 i;const r=null!=(i=n.received)?i:Qt(n.input),o={reason:e.type,context:n.context.type,expected:n.context.expects,received:r,message:`Invalid ${n.label}: ${n.context.expects?`Expected ${n.context.expects} but r`:"R"}eceived ${r}`,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=Xt(!1,n.context,n.reference,t,o),o}function en(e,t,n,i){if(e.pipe&&(null==n||!n.skipPipe))for(const r of e.pipe){const o=r._parse(t);if(o.issues){for(const t of o.issues){const r=Yt(e,n,t);i?i.push(r):i=[r]}if(null!=n&&n.abortEarly||null!=n&&n.abortPipeEarly)break}else t=o.output}return Zt(!0,t,i)}function tn(e,t,n,i,r){var o,a;const s=Qt(n),l=null!=(o=null==r?void 0:r.expected)?o:e.expects,c={reason:null!=(a=null==r?void 0:r.reason)?a:"type",context:e.type,expected:l,received:s,message:`Invalid type: Expected ${l} but received ${s}`,input:n,path:null==r?void 0:r.path,issues:null==r?void 0:r.issues,lang:null==i?void 0:i.lang,abortEarly:null==i?void 0:i.abortEarly,abortPipeEarly:null==i?void 0:i.abortPipeEarly,skipPipe:null==i?void 0:i.skipPipe};return c.message=Xt(!0,e,t,i,c),{typed:!1,output:n,issues:[c]}}function nn(e,t){return{...e,fallback:t,_parse(t,n){const i=e._parse(t,n);return i.issues?Zt(!0,function(e,t){return"function"==typeof e.fallback?e.fallback(t):e.fallback}(this,{input:t,issues:i.issues})):i}}}function rn(e,t,n,i){const[r,o,a]=function(e,t,n){if(!e||"object"==typeof e&&!Array.isArray(e)){const[i,r]=Ht(t,n);return[e,i,r]}const[i,r]=Ht(e,t);return[void 0,i,r]}(t,n,i);let s;return{type:"object",expects:"Object",async:!1,entries:e,rest:r,message:o,pipe:a,_parse(e,t){if(e&&"object"==typeof e){s=null!=s?s:Object.entries(this.entries);let n,i=!0;const r={};for(const[o,a]of s){const s=e[o],l=a._parse(s,t);if(l.issues){const r={type:"object",origin:"value",input:e,key:o,value:s};for(const e of l.issues)e.path?e.path.unshift(r):e.path=[r],null==n||n.push(e);if(n||(n=l.issues),null!=t&&t.abortEarly){i=!1;break}}l.typed||(i=!1),(void 0!==l.output||o in e)&&(r[o]=l.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 r={type:"object",origin:"value",input:e,key:o,value:a};for(const e of s.issues)e.path?e.path.unshift(r):e.path=[r],null==n||n.push(e);if(n||(n=s.issues),null!=t&&t.abortEarly){i=!1;break}}s.typed||(i=!1),r[o]=s.output}return i?en(this,r,t,n):Zt(!1,r,n)}return tn(this,rn,e,t)}}}function on(e,t){return{type:"picklist",expects:e.map(Qt).join(" | "),async:!1,options:e,message:t,_parse(e,t){return this.options.includes(e)?Zt(!0,e):tn(this,on,e,t)}}}function an(e,t,n){const i=e._parse(t,function(e){var t,n,i,r;return{lang:null!=(t=null==e?void 0:e.lang)?t:null==Bt?void 0:Bt.lang,message:null==e?void 0:e.message,abortEarly:null!=(n=null==e?void 0:e.abortEarly)?n:null==Bt?void 0:Bt.abortEarly,abortPipeEarly:null!=(i=null==e?void 0:e.abortPipeEarly)?i:null==Bt?void 0:Bt.abortPipeEarly,skipPipe:null!=(r=null==e?void 0:e.skipPipe)?r:null==Bt?void 0:Bt.skipPipe}}(n));if(i.issues)throw new Jt(i.issues);return i.output}const sn="ACTION_IFRAME_LOADED",ln="ACTION_IFRAME_REFRESH",cn="ACTION_IFRAME_RELOAD",dn="ACTION_PERSPECTIVE",un="ACTION_VIEWPORT",pn="ACTION_VISUAL_EDITING_OVERLAYS_TOGGLE",hn=(e,t)=>{switch(t.type){case sn:return"loaded"===e.iframe.status?e:{...e,iframe:{...e.iframe,status:"loaded"}};case ln:return"refreshing"===e.iframe.status?e:{...e,iframe:{...e.iframe,status:"refreshing"}};case cn:return"reloading"===e.iframe.status?e:{...e,iframe:{...e.iframe,status:"reloading"}};case dn:return{...e,perspective:an(vn,t.perspective)};case un:return{...e,viewport:an(gn,t.viewport)};case pn:return fn(e,t);default:return e}},fn=(e,t)=>e.visualEditing.overlaysEnabled===t.enabled?e:{...e,visualEditing:{...e.visualEditing,overlaysEnabled:t.enabled}},mn=on(["loading","loaded","refreshing","reloading"]),vn=nn(on(["published","previewDrafts"]),"previewDrafts"),gn=nn(on(["desktop","mobile"]),"desktop"),yn=rn({iframe:rn({status:mn}),perspective:vn,viewport:gn,visualEditing:rn({overlaysEnabled:function e(t,n){const[i,r]=Ht(t,n);return{type:"boolean",expects:"boolean",async:!1,message:i,pipe:r,_parse(t,n){return"boolean"==typeof t?en(this,t,n):tn(this,e,t,n)}}}()})}),wn={iframe:{status:"loading"},perspective:"previewDrafts",viewport:"desktop",visualEditing:{overlaysEnabled:!1}};function bn(e){return an(yn,{...wn,...e})}const xn=Le(le.iframe`
`,_t=function({children:e}){const t=U(null),[i,r]=$(new Map),o=R((()=>Tt(i).filter(jt)),[i]),[a,s]=$([]),[c,l]=$(null),d=U({elements:i,panels:o,widths:a}),u=O((e=>({flexGrow:Rt(o,e,a),pointerEvents:null===c?void 0:"none"})),[c,o,a]),p=O(((e,t)=>{r((n=>{if(n.has(e))return n;const i=new Map(n);return i.set(e,t),i}))}),[]),h=O((e=>{r((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:[]}),m=O(((e,t)=>{const n=Tt(i),r=n.findIndex((t=>t.id===e)),o=i.get(e);if(!o||!Lt(o))return;const a=o.el.current;a&&(f.current={resizerIndex:r,panelBefore:n.reduce(((e,t,n)=>jt(t)&&n<r?t:e),null),panelAfter:n.reduce(((e,t,n)=>null===e&&jt(t)&&n>r?t:e),null),containerWidth:window.innerWidth,startX:t.pageX,dragOffset:$t(t,a),resizerRect:a.getBoundingClientRect(),widths:d.current.widths},l(e))}),[i]),v=O((()=>{l(null)}),[]),g=O(((e,n)=>{n.preventDefault(),n.stopPropagation();const{containerWidth:r,dragOffset:o,panelBefore:a,panelAfter:c,resizerRect:l}=f.current;if(null==a||null==c)return;const u=i.get(e);if(!u||!Lt(u))return;const p=u.el.current;if(!p)return;const h=$t(n,p,o,l);if(0===h)return;const{widths:m}=d.current,v=function(e,t,n,i,r,o){const{panels:a,widths:s}=r,{widths:c}=o,l=c||s,d=[...l];{const r=e<0?i:n,o=l[a.findIndex((e=>e.id===r.id))],s=Ot(r,o+Math.abs(e),t);if(o===s)return l;e=e<0?o-s:s-o}let u=0,p=e<0?n:i,h=a.findIndex((e=>e.id===p.id));for(;;){const n=a[h],i=l[h],r=Ot(n,i-(Math.abs(e)-Math.abs(u)),t);if(i!==r&&(u+=i-r,d[h]=r,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?i:n,h=a.findIndex((e=>e.id===p.id)),d[h]=l[h]+u,d)}(h/t.current.getBoundingClientRect().width*100,r,a,c,d.current,f.current);m.some(((e,t)=>e!==v[t]))&&s(v)}),[i]);T((()=>{d.current.elements=i,d.current.panels=o,d.current.widths=a}),[i,o,a]);const y=Dt();T((()=>{const{widths:e}=d.current;if(e.length===o.length)return;const t=y.get(o);if(t){const e=Ut(o,t,window.innerWidth);return void s(e)}const n=function(e){let t=e.length,n=100;const i=e.map((e=>e.defaultSize?(n-=e.defaultSize,t-=1,e.defaultSize):null)),r=n/t;return i.map((e=>null===e?r:e))}(o);s(n)}),[y,o]),j((()=>{a.length&&y.setDebounced(o,a)}),[y,o,a]),T((()=>{const e=new ResizeObserver((()=>{const{panels:e,widths:t}=d.current,n=Ut(e,t,window.innerWidth);t.some(((e,t)=>e!==n[t]))&&s(n)}));return e.observe(t.current),()=>{e.disconnect()}}),[]);const w=R((()=>({activeResizer:c,drag:g,getPanelStyle:u,registerElement:p,startDragging:m,stopDragging:v,unregisterElement:h})),[c,g,u,p,m,v,h]);return n(wt.Provider,{value:w,children:n(At,{ref:t,children:e})})},Wt=function(e){const{children:t,navigate:i}=e,r=O(((e,t=void 0)=>{i(t||{},e?{preview:e}:{})}),[i]);return n(de.Provider,{value:r,children:t})};function Mt(e){const{unstable_navigator:t}=e,i=!(null==t||!t.component),[o,a]=function(e,t){const[n,i]=$((()=>{var n;return JSON.parse(null!=(n=localStorage.getItem(e))?n:JSON.stringify(t))}));return j((()=>{localStorage.setItem(e,JSON.stringify(n))}),[e,n]),[n,i]}("presentation/navigator",i),s=!!i&&o,c=R((()=>{if(i)return()=>a((e=>!e))}),[i,a]),l=O((function(){return n(r,{children:s&&n(Nt,{...t})})}),[s,t]);return[{navigatorEnabled:s,toggleNavigator:c},l]}const Nt=A((function(e){const{minWidth:t,maxWidth:o,component:a}=e,s=null!=t&&null!=o&&t===o;return i(r,{children:[n(xt,{id:"navigator",minWidth:t,maxWidth:o,order:1,children:n(a,{})}),n(Et,{order:2,disabled:s})]})})),Ft=function(e){const{children:t,params:i}=e,r=R((()=>i),[i]);return n(ue.Provider,{value:r,children:t})},Vt=function(e){const{children:t,deskParams:i,devMode:r,name:o,navigate:a,params:s}=e,c=R((()=>({deskParams:i,devMode:r,name:o,navigate:a,params:s})),[i,r,o,a,s]);return n(le.Provider,{value:c,children:t})};var Bt,Kt,qt,Gt,Jt=class extends Error{constructor(e){super(e[0].message),t(this,"issues"),this.name="ValiError",this.issues=e}};function Ht(e,t){return Array.isArray(e)?[void 0,e]:[e,t]}function Xt(e,t,n,i,r){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==Gt?void 0:Gt.get(e))?void 0:n.get(t)}(n,r.lang))?a:e?(u=r.lang,null==qt?void 0:qt.get(u)):null)?s:null==i?void 0:i.message)?c:function(e){return null==Kt?void 0:Kt.get(e)}(r.lang))?l:r.message;var u;return"function"==typeof d?d(r):d}function Zt(e,t,n){return{typed:e,output:t,issues:n}}function Qt(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 i;const r=null!=(i=n.received)?i:Qt(n.input),o={reason:e.type,context:n.context.type,expected:n.context.expects,received:r,message:`Invalid ${n.label}: ${n.context.expects?`Expected ${n.context.expects} but r`:"R"}eceived ${r}`,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=Xt(!1,n.context,n.reference,t,o),o}function en(e,t,n,i){if(e.pipe&&(null==n||!n.skipPipe))for(const r of e.pipe){const o=r._parse(t);if(o.issues){for(const t of o.issues){const r=Yt(e,n,t);i?i.push(r):i=[r]}if(null!=n&&n.abortEarly||null!=n&&n.abortPipeEarly)break}else t=o.output}return Zt(!0,t,i)}function tn(e,t,n,i,r){var o,a;const s=Qt(n),c=null!=(o=null==r?void 0:r.expected)?o:e.expects,l={reason:null!=(a=null==r?void 0:r.reason)?a:"type",context:e.type,expected:c,received:s,message:`Invalid type: Expected ${c} but received ${s}`,input:n,path:null==r?void 0:r.path,issues:null==r?void 0:r.issues,lang:null==i?void 0:i.lang,abortEarly:null==i?void 0:i.abortEarly,abortPipeEarly:null==i?void 0:i.abortPipeEarly,skipPipe:null==i?void 0:i.skipPipe};return l.message=Xt(!0,e,t,i,l),{typed:!1,output:n,issues:[l]}}function nn(e,t){return{...e,fallback:t,_parse(t,n){const i=e._parse(t,n);return i.issues?Zt(!0,function(e,t){return"function"==typeof e.fallback?e.fallback(t):e.fallback}(this,{input:t,issues:i.issues})):i}}}function rn(e,t,n,i){const[r,o,a]=function(e,t,n){if(!e||"object"==typeof e&&!Array.isArray(e)){const[i,r]=Ht(t,n);return[e,i,r]}const[i,r]=Ht(e,t);return[void 0,i,r]}(t,n,i);let s;return{type:"object",expects:"Object",async:!1,entries:e,rest:r,message:o,pipe:a,_parse(e,t){if(e&&"object"==typeof e){s=null!=s?s:Object.entries(this.entries);let n,i=!0;const r={};for(const[o,a]of s){const s=e[o],c=a._parse(s,t);if(c.issues){const r={type:"object",origin:"value",input:e,key:o,value:s};for(const e of c.issues)e.path?e.path.unshift(r):e.path=[r],null==n||n.push(e);if(n||(n=c.issues),null!=t&&t.abortEarly){i=!1;break}}c.typed||(i=!1),(void 0!==c.output||o in e)&&(r[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 r={type:"object",origin:"value",input:e,key:o,value:a};for(const e of s.issues)e.path?e.path.unshift(r):e.path=[r],null==n||n.push(e);if(n||(n=s.issues),null!=t&&t.abortEarly){i=!1;break}}s.typed||(i=!1),r[o]=s.output}return i?en(this,r,t,n):Zt(!1,r,n)}return tn(this,rn,e,t)}}}function on(e,t){return{type:"picklist",expects:e.map(Qt).join(" | "),async:!1,options:e,message:t,_parse(e,t){return this.options.includes(e)?Zt(!0,e):tn(this,on,e,t)}}}function an(e,t,n){const i=e._parse(t,function(e){var t,n,i,r;return{lang:null!=(t=null==e?void 0:e.lang)?t:null==Bt?void 0:Bt.lang,message:null==e?void 0:e.message,abortEarly:null!=(n=null==e?void 0:e.abortEarly)?n:null==Bt?void 0:Bt.abortEarly,abortPipeEarly:null!=(i=null==e?void 0:e.abortPipeEarly)?i:null==Bt?void 0:Bt.abortPipeEarly,skipPipe:null!=(r=null==e?void 0:e.skipPipe)?r:null==Bt?void 0:Bt.skipPipe}}(n));if(i.issues)throw new Jt(i.issues);return i.output}const sn="ACTION_IFRAME_LOADED",cn="ACTION_IFRAME_REFRESH",ln="ACTION_IFRAME_RELOAD",dn="ACTION_PERSPECTIVE",un="ACTION_VIEWPORT",pn="ACTION_VISUAL_EDITING_OVERLAYS_TOGGLE",hn=(e,t)=>{switch(t.type){case sn:return"loaded"===e.iframe.status?e:{...e,iframe:{...e.iframe,status:"loaded"}};case cn:return"refreshing"===e.iframe.status?e:{...e,iframe:{...e.iframe,status:"refreshing"}};case ln:return"reloading"===e.iframe.status?e:{...e,iframe:{...e.iframe,status:"reloading"}};case dn:return{...e,perspective:an(vn,t.perspective)};case un:return{...e,viewport:an(gn,t.viewport)};case pn:return fn(e,t);default:return e}},fn=(e,t)=>e.visualEditing.overlaysEnabled===t.enabled?e:{...e,visualEditing:{...e.visualEditing,overlaysEnabled:t.enabled}},mn=on(["loading","loaded","refreshing","reloading"]),vn=nn(on(["published","previewDrafts"]),"previewDrafts"),gn=nn(on(["desktop","mobile"]),"desktop"),yn=rn({iframe:rn({status:mn}),perspective:vn,viewport:gn,visualEditing:rn({overlaysEnabled:function e(t,n){const[i,r]=Ht(t,n);return{type:"boolean",expects:"boolean",async:!1,message:i,pipe:r,_parse(t,n){return"boolean"==typeof t?en(this,t,n):tn(this,e,t,n)}}}()})}),wn={iframe:{status:"loading"},perspective:"previewDrafts",viewport:"desktop",visualEditing:{overlaysEnabled:!1}};function bn(e){return an(yn,{...wn,...e})}const xn=Le(ce.iframe`
border: 0;

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

display: block;
`),kn=function(e){var t;const{basePath:i="/"}=(null==(t=K())?void 0:t.activeWorkspace)||{},{fontSize:o=1,onChange:a,origin:s,padding:l=3,value:c}=e,d=U(null),[u,p]=$(void 0),[h,f]=$(void 0),m=O((e=>{p(e.currentTarget.value)}),[]),v=O((e=>{var t;if("Enter"===e.key){if(void 0===u)return;const e=u.startsWith("/")||""===u?`${s}${u}`:u;if(!e.startsWith(s+"/")&&e!==s)return void f(`URL must start with ${s}`);if(!s&&(e.startsWith(`${i}/`)||e===i))return void f(`URL can't have the same base path as the Studio ${i}`);const n=e===s?s+"/":e;f(void 0),p(void 0),a(n.slice(s.length)),null==(t=d.current)||t.blur()}"Escape"===e.key&&(f(void 0),p(void 0))}),[i,a,s,u]),y=O((()=>{f(void 0),p(void 0)}),[]);j((()=>{f(void 0),p(void 0)}),[s,c]);const w=R((()=>({icon:we})),[]);return n(r,{children:n(g,{clearButton:h?w:void 0,customValidity:h,fontSize:o,onBlur:y,onClear:()=>{f(void 0),p(s+c)},onChange:m,onKeyDownCapture:v,padding:l,style:{zIndex:1},radius:2,ref:d,space:l,value:void 0===u?`${s}${c}`:u})})};function Pn(e){const{initialUrl:t,openPopup:o,previewLocationOrigin:a,previewLocationRoute:s}=e,l=O((e=>{e.preventDefault(),o(e.currentTarget.href)}),[o]);return i(r,{children:[n(En,{initialUrl:t,previewLocationOrigin:a,previewLocationRoute:s}),n(y,{icon:be,text:"Open preview",as:"a",href:`${a}${s}`,onClick:l,rel:"opener",target:"_blank"})]})}function En(e){const{initialUrl:t,previewLocationOrigin:i,previewLocationRoute:r}=e,{push:o}=w(),a=q({apiVersion:pe}),s=G(),[l,c]=$(!1);return n(y,{disabled:l,onClick:()=>{if(null==navigator||!navigator.clipboard)return o({closable:!0,status:"error",title:"Clipboard not supported"}),!1;c(!0);let e,n=`${i}${r}`;const l=()=>{o({id:e,closable:!0,status:"success",title:"The URL is copied to the clipboard"}),c(!1)},d=e=>{o({closable:!0,status:"error",title:"Copy failed",description:e.message||e.toString()}),c(!1)};if(Re(t)&&typeof ClipboardItem<"u"){const i="text/plain",c=new ClipboardItem({[i]:(async()=>{e=o({closable:!0,title:"Copying URL to clipboard…"});const l=await Ae(a,"@sanity/presentation",typeof window>"u"?"":location.href,null==s?void 0:s.id);return n=$e(t,l.secret,r).toString(),new Blob([n],{type:i})})()});navigator.clipboard.write([c]).then(l).catch(d)}else navigator.clipboard.writeText(n).then(l).catch(d)},text:"Copy link",icon:xe})}const Sn=Le(s),In=le(b)`
`),kn=function(e){var t;const{basePath:i="/"}=(null==(t=K())?void 0:t.activeWorkspace)||{},{fontSize:o=1,onChange:a,origin:s,padding:c=3,value:l}=e,d=U(null),[u,p]=$(void 0),[h,f]=$(void 0),m=O((e=>{p(e.currentTarget.value)}),[]),v=O((e=>{var t;if("Enter"===e.key){if(void 0===u)return;const e=u.startsWith("/")||""===u?`${s}${u}`:u;if(!e.startsWith(s+"/")&&e!==s)return void f(`URL must start with ${s}`);if(!s&&(e.startsWith(`${i}/`)||e===i))return void f(`URL can't have the same base path as the Studio ${i}`);const n=e===s?s+"/":e;f(void 0),p(void 0),a(n.slice(s.length)),null==(t=d.current)||t.blur()}"Escape"===e.key&&(f(void 0),p(void 0))}),[i,a,s,u]),y=O((()=>{f(void 0),p(void 0)}),[]);j((()=>{f(void 0),p(void 0)}),[s,l]);const w=R((()=>({icon:we})),[]);return n(r,{children:n(g,{clearButton:h?w:void 0,customValidity:h,fontSize:o,onBlur:y,onClear:()=>{f(void 0),p(s+l)},onChange:m,onKeyDownCapture:v,padding:c,style:{zIndex:1},radius:2,ref:d,space:c,value:void 0===u?`${s}${l}`:u})})};function Pn(e){const{initialUrl:t,openPopup:o,previewLocationOrigin:a,previewLocationRoute:s}=e,c=O((e=>{e.preventDefault(),o(e.currentTarget.href)}),[o]);return i(r,{children:[n(En,{initialUrl:t,previewLocationOrigin:a,previewLocationRoute:s}),n(y,{icon:be,text:"Open preview",as:"a",href:`${a}${s}`,onClick:c,rel:"opener",target:"_blank"})]})}function En(e){const{initialUrl:t,previewLocationOrigin:i,previewLocationRoute:r}=e,{push:o}=w(),a=q({apiVersion:pe}),s=G(),[c,l]=$(!1);return n(y,{disabled:c,onClick:()=>{if(null==navigator||!navigator.clipboard)return o({closable:!0,status:"error",title:"Clipboard not supported"}),!1;l(!0);let e,n=`${i}${r}`;const c=()=>{o({id:e,closable:!0,status:"success",title:"The URL is copied to the clipboard"}),l(!1)},d=e=>{o({closable:!0,status:"error",title:"Copy failed",description:e.message||e.toString()}),l(!1)};if(Re(t)&&typeof ClipboardItem<"u"){const i="text/plain",l=new ClipboardItem({[i]:(async()=>{e=o({closable:!0,title:"Copying URL to clipboard…"});const c=await Ae(a,"@sanity/presentation",typeof window>"u"?"":location.href,null==s?void 0:s.id);return n=$e(t,c.secret,r).toString(),new Blob([n],{type:i})})()});navigator.clipboard.write([l]).then(c).catch(d)}else navigator.clipboard.writeText(n).then(c).catch(d)},text:"Copy link",icon:xe})}const Sn=Le(s),In=ce(b)`
& > span {

@@ -78,4 +78,4 @@ width: 21px;

}
`,zn={previewDrafts:"Drafts",published:"Published"},Cn="caution",Dn="positive",On={previewDrafts:De,published:Oe},Rn=D((function(e,t){const{dispatch:o,iframe:l,initialUrl:u,loadersConnection:v,navigatorEnabled:g,onPathChange:w,onRefresh:b,openPopup:z,overlaysConnection:C,params:D,perspective:L,targetOrigin:T,toggleNavigator:U,toggleOverlay:A,viewport:W,visualEditing:{overlaysEnabled:M}}=e,{devMode:N}=at(),F=x(),V=O((()=>o({type:un,viewport:"desktop"})),[o]),B=O((()=>o({type:un,viewport:"mobile"})),[o]),K="loading"===l.status||"reloading"===l.status,[q,G]=$(!1),H="refreshing"===l.status,[X,Z]=$(!1),Q=K||H||"connecting"===C,Y=R((()=>T===location.origin?"":T),[T]),ee=O((()=>{b((()=>{"function"==typeof t||null==t||!t.current||(o({type:cn}),t.current.src=`${T}${D.preview||"/"}`)}))}),[o,b,D.preview,T,t]),te=O((()=>{"function"==typeof t||null==t||!t.current||(t.current.src=u.toString(),o({type:cn}))}),[o,t,u]),ne=O((()=>{re(!0)}),[]),[ie,re]=$(!1),[oe,ae]=$(!1);j((()=>{if(!(K||H||"connecting"!==C&&"reconnecting"!==C)){const e=setTimeout((()=>{ae(!0)}),1e3);return()=>clearTimeout(e)}}),[C,K,H]),j((()=>{if(!K&&!H&&oe){if("connected"===C&&(Z(!1),ae(!1),G(!1),re(!1)),"connecting"===C){const e=setTimeout((()=>{G(!0),console.error("Unable to connect to visual editing. Make sure you've setup '@sanity/visual-editing' correctly")}),he);return()=>clearTimeout(e)}if("reconnecting"===C){const e=setTimeout((()=>{G(!0),Z(!0)}),he);return()=>clearTimeout(e)}"disconnected"===C&&Z(!0)}}),[K,C,H,oe]);const se=R((()=>{const e=new URL(D.preview||"/",T),{pathname:t,search:n}=je(e);return`${t}${n}`}),[D.preview,T]),le=O((()=>{o({type:sn})}),[o]);return n(Te,{transition:F?{duration:0}:void 0,children:i(k,{delay:1e3,children:[n(a,{flex:"none",padding:2,shadow:1,style:{position:"relative"},children:i(s,{align:"center",gap:2,style:{minHeight:0},children:[U&&n(P,{animate:!0,content:n(d,{size:1,children:"Toggle navigator"}),fallbackPlacements:["bottom-start"],padding:2,placement:"bottom",portal:!0,children:n(h,{"aria-label":"Toggle navigator",fontSize:1,icon:ke,mode:"bleed",onClick:U,padding:3,selected:g})}),n(P,{animate:!0,content:i(s,{align:"center",style:{whiteSpace:"nowrap"},children:[n(p,{padding:1,children:n(d,{size:1,children:M?"Disable edit overlay":"Enable edit overlay"})}),n(p,{paddingY:1,children:n(J,{keys:["Alt"],style:{marginTop:-4,marginBottom:-4}})})]}),fallbackPlacements:["bottom-start"],padding:1,placement:"bottom",portal:!0,children:n(a,{as:"label",flex:"none",padding:3,style:{lineHeight:0,borderRadius:999,userSelect:"none"},tone:M?"positive":void 0,children:i(s,{align:"center",gap:2,children:[n("div",{style:{margin:-2},children:n(In,{checked:M,onChange:A,disabled:"loading"===l.status||"connected"!==C})}),n(p,{children:n(d,{muted:!0,size:1,weight:"medium",children:"Edit"})})]})})}),n(P,{animate:!0,content:n(d,{size:1,children:"loading"===l.status?"Loading…":"reloading"===l.status||"refreshing"===l.status?"Refreshing…":"Refresh preview"}),fallbackPlacements:["bottom-start"],padding:2,placement:"bottom",portal:!0,children:n(h,{"aria-label":"Refresh preview",fontSize:1,icon:Pe,mode:"bleed",loading:"reloading"===l.status||"refreshing"===l.status,onClick:ee,padding:3})}),n(p,{flex:1,children:n(kn,{onChange:w,origin:Y,value:se})}),n(s,{align:"center",flex:"none",gap:1,children:n(E,{button:n(h,{fontSize:1,iconRight:Ee,mode:"bleed",padding:3,space:2}),id:"location-menu",menu:n(S,{children:n(Pn,{initialUrl:u,openPopup:z,previewLocationOrigin:Y,previewLocationRoute:se})}),popover:{animate:!0,constrainSize:!0,placement:"bottom",portal:!0}})}),n(s,{align:"center",flex:"none",gap:1,children:n(E,{button:n(h,{fontSize:1,iconRight:Se,mode:"bleed",padding:3,space:2,text:zn["connected"===v?L:"previewDrafts"],loading:"reconnecting"===v&&"loaded"!==l.status,disabled:"connected"!==v}),id:"perspective-menu",menu:i(S,{style:{maxWidth:240},children:[n(y,{fontSize:1,onClick:()=>o({type:dn,perspective:"previewDrafts"}),padding:3,pressed:"previewDrafts"===L,tone:Cn,children:i(s,{align:"flex-start",gap:3,children:[n(p,{flex:"none",children:n(d,{size:1,children:_(On.previewDrafts)})}),i(c,{flex:1,space:2,children:[n(d,{size:1,weight:"medium",children:zn.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"===L?1:0},children:n(Ie,{})})})]})}),n(y,{fontSize:1,onClick:()=>o({type:dn,perspective:"published"}),padding:3,pressed:"published"===L,tone:Dn,children:i(s,{align:"flex-start",gap:3,children:[n(p,{flex:"none",children:n(d,{size:1,children:_(On.published)})}),i(c,{flex:1,space:2,children:[n(d,{size:1,weight:"medium",children:zn.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"===L?1:0},children:n(Ie,{})})})]})})]}),popover:{animate:!0,constrainSize:!0,placement:"bottom",portal:!0}})}),i(s,{align:"center",flex:"none",gap:1,children:[n(P,{animate:!0,content:n(d,{size:1,children:"Full viewport"}),fallbackPlacements:["bottom-start"],padding:2,placement:"bottom",portal:!0,children:n(h,{"aria-label":"Full viewport",fontSize:1,icon:ze,mode:"bleed",onClick:V,padding:3,selected:"desktop"===W})}),n(P,{animate:!0,content:n(d,{size:1,children:"Narrow viewport"}),padding:2,placement:"bottom",portal:!0,children:n(h,{"aria-label":"Narrow viewport",fontSize:1,icon:Ce,mode:"bleed",onClick:B,padding:3,selected:"mobile"===W})})]})]})}),n(a,{flex:1,tone:"transparent",children:i(s,{align:"center",height:"fill",justify:"center",padding:"desktop"===W?0:2,sizing:"border",style:{position:"relative",cursor:Q?"wait":void 0},children:[n(Ue,{children:X||K||H||!oe||ie?(K||"connecting"===C&&"refreshing"!==l.status)&&!ie?n(Sn,{initial:"initial",animate:"animate",exit:"exit",variants:jn,justify:"center",align:"center",style:{inset:"0",position:"absolute"},children:i(s,{style:{...$n[W]},justify:"center",align:"center",direction:"column",gap:4,children:[n(I,{muted:!0}),n(d,{muted:!0,size:1,children:"Loading…"})]})}):X&&!ie?n(Sn,{initial:"initial",animate:"animate",exit:"exit",variants:Ln,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(ot,{flex:1,message:"Could not connect to the preview",onRetry:te,onContinueAnyway:ne,children:N&&i(r,{children:["connected"!==C&&n(a,{padding:3,radius:2,tone:"critical",children:i(c,{space:3,children:[n(m,{muted:!0,size:0,children:"Overlay connection status"}),n(f,{size:1,children:C})]})}),"connected"!==v&&n(a,{padding:3,radius:2,tone:"critical",children:i(c,{space:3,children:[n(m,{muted:!0,size:0,children:"Loader connection status"}),n(f,{size:1,children:v})]})})]})})}):null:n(Sn,{initial:"initial",animate:"animate",exit:"exit",variants:jn,justify:"center",align:"center",style:{inset:"0",position:"absolute",backdropFilter:q?"blur(16px) saturate(0.5) grayscale(0.5)":"blur(2px)",transition:"backdrop-filter 0.2s ease-in-out",WebkitBackdropFilter:q?"blur(16px) saturate(0.5) grayscale(0.5)":"blur(2px)",WebkitTransition:"-webkit-backdrop-filter 0.2s ease-in-out",zIndex:1},children:i(s,{style:{...$n[W]},justify:"center",align:"center",direction:"column",gap:4,children:[q&&n(h,{disabled:!0,fontSize:1,mode:"ghost",text:"Continue anyway",style:{opacity:0}}),n(a,{radius:2,tone:q?"caution":"inherit",padding:4,shadow:1,children:i(s,{justify:"center",align:"center",direction:"column",gap:4,children:[n(I,{muted:!0}),n(d,{muted:!0,size:1,children:q?n(r,{children:"Unable to connect, check the browser console for more information."}):"Connecting…"})]})}),q&&n(h,{fontSize:1,tone:"critical",onClick:ne,text:"Continue anyway"})]})})}),n(xn,{ref:t,style:{pointerEvents:(K||"connecting"===C&&"refreshing"!==l.status)&&!ie?"none":"auto",boxShadow:"0 0 0 1px var(--card-border-color)",borderTop:"1px solid transparent"},src:u.toString(),initial:["background"],variants:Tn,animate:[(K||"connecting"===C&&"refreshing"!==l.status)&&!ie?"background":"active",K?"reloading":"idle",W,oe&&!ie?"timedOut":""],onLoad:le})]})})]})})})),$n={desktop:{width:"100%",height:"100%"},mobile:{width:375,height:650}},jn={initial:{opacity:1},animate:{opacity:[0,0,1]},exit:{opacity:[1,0,0]}},Ln={initial:{opacity:1},animate:{opacity:[0,0,1]},exit:{opacity:[1,0,0]}},Tn={desktop:{...$n.desktop,boxShadow:"0 0 0 0px var(--card-border-color)"},mobile:{...$n.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 Un=!1;function An(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 _n(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 i=tt.exec(n);if(i){t.push(i[1],[Number(i[2]),Number(i[3])]);continue}const r=nt.exec(n);r?t.push(r[1],{_key:r[2]}):t.push(n)}return t}(decodeURIComponent(e)))}function Wn(e){return Object.fromEntries(Object.entries(e).filter((([,e])=>void 0!==e&&""!==e&&null!==e)))}function Mn({initialPreviewUrl:e,routerNavigate:t,routerState:n,routerSearchParams:i,frameStateRef:r}){const o=R((()=>{const{id:t,path:r,type:o}={id:An((a=n).id),path:_n(a.path),type:a.type};var a;return{id:t,type:o,path:r,preview:i.preview||`${e.pathname}${e.search}`,perspective:i.perspective,viewport:i.viewport,inspect:i.inspect,rev:i.rev,since:i.since,template:i.template,templateParams:i.templateParams,view:i.view,pathKey:i.pathKey,instruction:i.instruction,comment:i.comment}}),[n,i,e]),a=R((()=>Wn({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);j((()=>{s.current=n}),[n]);return{deskParams:a,navigate:R((()=>St(((e,n={},i)=>{const{_searchParams:o,...a}=s.current,l=(o||[]).reduce(((e,[t,n])=>(e[t]=n,e)),{}),c=Wn({...a,...e}),d=Wn({...l,...n});a.id!==c.id&&(delete d.template,delete d.templateParams),c._searchParams=Object.entries(d).reduce(((e,[t,n])=>[...e,[t,n]]),[]);const u=null!=i?i:d.preview===r.current.url;t(c,{replace:u})}),50)),[t,r]),params:o}}function Nn(e,t,n){var i,r;const o=q({apiVersion:pe}),a=K(),s=(null==(i=null==a?void 0:a.activeWorkspace)?void 0:i.basePath)||"/",l=(null==(r=null==a?void 0:a.activeWorkspace)?void 0:r.name)||"default",c=function(e,t,n){const i=G();return R((()=>["@sanity/presentation",t,n,e,null==i?void 0:i.id,Fn]),[t,null==i?void 0:i.id,e,n])}(t,s,l),d=function(e,t){const n=q({apiVersion:pe}),i=G(),[r,o]=$(""),a=e?Me((async()=>await Ae(n,"@sanity/presentation",typeof window>"u"?"":location.href,null==i?void 0:i.id)),[...t,r]):null;return j((()=>{if(!a)return;const e=setTimeout((()=>{W((()=>o(a.expiresAt.toString())))}),a.expiresAt.getTime()-Date.now());return()=>clearTimeout(e)}),[a]),(null==a?void 0:a.secret)||null}("object"==typeof e||"function"==typeof e,c);return Me((async()=>{if("string"==typeof e){const t=new URL(e,location.origin);let i=t;try{if(n){const e=new URL(n,t);e.origin===t.origin&&(i=e)}else if(document.referrer){const e=new URL(document.referrer);e.origin===t.origin&&(i=e)}}catch{}return location.origin!==i.origin||!i.pathname.startsWith(`${s}/`)&&i.pathname!==s?i:t}const t=await("object"==typeof e?We(e):e)({client:o,previewUrlSecret:d,previewSearchParam:n,referrer:typeof document>"u"?null:document.referrer,studioBasePath:s});return new URL(t,location.origin)}),[...c,d])}const Fn=Symbol();const Vn=F((()=>import("./LoaderQueries.js"))),Bn=F((()=>import("./PostMessageRefreshMutations.js"))),Kn=le(s)`
`,zn={previewDrafts:"Drafts",published:"Published"},Cn="caution",Dn="positive",On={previewDrafts:De,published:Oe},Rn=D((function(e,t){const{dispatch:o,iframe:c,initialUrl:u,loadersConnection:v,navigatorEnabled:g,onPathChange:w,onRefresh:b,openPopup:z,overlaysConnection:C,params:D,perspective:L,targetOrigin:T,toggleNavigator:U,toggleOverlay:A,viewport:W,visualEditing:{overlaysEnabled:M}}=e,{devMode:N}=at(),F=x(),V=O((()=>o({type:un,viewport:"desktop"})),[o]),B=O((()=>o({type:un,viewport:"mobile"})),[o]),K="loading"===c.status||"reloading"===c.status,[q,G]=$(!1),H="refreshing"===c.status,[X,Z]=$(!1),Q=K||H||"connecting"===C,Y=R((()=>T===location.origin?"":T),[T]),ee=O((()=>{b((()=>{"function"==typeof t||null==t||!t.current||(o({type:ln}),t.current.src=`${T}${D.preview||"/"}`)}))}),[o,b,D.preview,T,t]),te=O((()=>{"function"==typeof t||null==t||!t.current||(t.current.src=u.toString(),o({type:ln}))}),[o,t,u]),ne=O((()=>{re(!0)}),[]),[ie,re]=$(!1),[oe,ae]=$(!1);j((()=>{if(!(K||H||"connecting"!==C&&"reconnecting"!==C)){const e=setTimeout((()=>{ae(!0)}),1e3);return()=>clearTimeout(e)}}),[C,K,H]),j((()=>{if(!K&&!H&&oe){if("connected"===C&&(Z(!1),ae(!1),G(!1),re(!1)),"connecting"===C){const e=setTimeout((()=>{G(!0),console.error("Unable to connect to visual editing. Make sure you've setup '@sanity/visual-editing' correctly")}),he);return()=>clearTimeout(e)}if("reconnecting"===C){const e=setTimeout((()=>{G(!0),Z(!0)}),he);return()=>clearTimeout(e)}"disconnected"===C&&Z(!0)}}),[K,C,H,oe]);const se=R((()=>{const e=new URL(D.preview||"/",T),{pathname:t,search:n}=je(e);return`${t}${n}`}),[D.preview,T]),ce=O((()=>{o({type:sn})}),[o]);return n(Te,{transition:F?{duration:0}:void 0,children:i(k,{delay:1e3,children:[n(a,{flex:"none",padding:2,shadow:1,style:{position:"relative"},children:i(s,{align:"center",gap:2,style:{minHeight:0},children:[U&&n(P,{animate:!0,content:n(d,{size:1,children:"Toggle navigator"}),fallbackPlacements:["bottom-start"],padding:2,placement:"bottom",portal:!0,children:n(h,{"aria-label":"Toggle navigator",fontSize:1,icon:ke,mode:"bleed",onClick:U,padding:3,selected:g})}),n(P,{animate:!0,content:i(s,{align:"center",style:{whiteSpace:"nowrap"},children:[n(p,{padding:1,children:n(d,{size:1,children:M?"Disable edit overlay":"Enable edit overlay"})}),n(p,{paddingY:1,children:n(J,{keys:["Alt"],style:{marginTop:-4,marginBottom:-4}})})]}),fallbackPlacements:["bottom-start"],padding:1,placement:"bottom",portal:!0,children:n(a,{as:"label",flex:"none",padding:3,style:{lineHeight:0,borderRadius:999,userSelect:"none"},tone:M?"positive":void 0,children:i(s,{align:"center",gap:2,children:[n("div",{style:{margin:-2},children:n(In,{checked:M,onChange:A,disabled:"loading"===c.status||"connected"!==C})}),n(p,{children:n(d,{muted:!0,size:1,weight:"medium",children:"Edit"})})]})})}),n(P,{animate:!0,content:n(d,{size:1,children:"loading"===c.status?"Loading…":"reloading"===c.status||"refreshing"===c.status?"Refreshing…":"Refresh preview"}),fallbackPlacements:["bottom-start"],padding:2,placement:"bottom",portal:!0,children:n(h,{"aria-label":"Refresh preview",fontSize:1,icon:Pe,mode:"bleed",loading:"reloading"===c.status||"refreshing"===c.status,onClick:ee,padding:3})}),n(p,{flex:1,children:n(kn,{onChange:w,origin:Y,value:se})}),n(s,{align:"center",flex:"none",gap:1,children:n(E,{button:n(h,{fontSize:1,iconRight:Ee,mode:"bleed",padding:3,space:2}),id:"location-menu",menu:n(S,{children:n(Pn,{initialUrl:u,openPopup:z,previewLocationOrigin:Y,previewLocationRoute:se})}),popover:{animate:!0,constrainSize:!0,placement:"bottom",portal:!0}})}),n(s,{align:"center",flex:"none",gap:1,children:n(E,{button:n(h,{fontSize:1,iconRight:Se,mode:"bleed",padding:3,space:2,text:zn["connected"===v?L:"previewDrafts"],loading:"reconnecting"===v&&"loaded"!==c.status,disabled:"connected"!==v}),id:"perspective-menu",menu:i(S,{style:{maxWidth:240},children:[n(y,{fontSize:1,onClick:()=>o({type:dn,perspective:"previewDrafts"}),padding:3,pressed:"previewDrafts"===L,tone:Cn,children:i(s,{align:"flex-start",gap:3,children:[n(p,{flex:"none",children:n(d,{size:1,children:_(On.previewDrafts)})}),i(l,{flex:1,space:2,children:[n(d,{size:1,weight:"medium",children:zn.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"===L?1:0},children:n(Ie,{})})})]})}),n(y,{fontSize:1,onClick:()=>o({type:dn,perspective:"published"}),padding:3,pressed:"published"===L,tone:Dn,children:i(s,{align:"flex-start",gap:3,children:[n(p,{flex:"none",children:n(d,{size:1,children:_(On.published)})}),i(l,{flex:1,space:2,children:[n(d,{size:1,weight:"medium",children:zn.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"===L?1:0},children:n(Ie,{})})})]})})]}),popover:{animate:!0,constrainSize:!0,placement:"bottom",portal:!0}})}),i(s,{align:"center",flex:"none",gap:1,children:[n(P,{animate:!0,content:n(d,{size:1,children:"Full viewport"}),fallbackPlacements:["bottom-start"],padding:2,placement:"bottom",portal:!0,children:n(h,{"aria-label":"Full viewport",fontSize:1,icon:ze,mode:"bleed",onClick:V,padding:3,selected:"desktop"===W})}),n(P,{animate:!0,content:n(d,{size:1,children:"Narrow viewport"}),padding:2,placement:"bottom",portal:!0,children:n(h,{"aria-label":"Narrow viewport",fontSize:1,icon:Ce,mode:"bleed",onClick:B,padding:3,selected:"mobile"===W})})]})]})}),n(a,{flex:1,tone:"transparent",children:i(s,{align:"center",height:"fill",justify:"center",padding:"desktop"===W?0:2,sizing:"border",style:{position:"relative",cursor:Q?"wait":void 0},children:[n(Ue,{children:X||K||H||!oe||ie?(K||"connecting"===C&&"refreshing"!==c.status)&&!ie?n(Sn,{initial:"initial",animate:"animate",exit:"exit",variants:jn,justify:"center",align:"center",style:{inset:"0",position:"absolute"},children:i(s,{style:{...$n[W]},justify:"center",align:"center",direction:"column",gap:4,children:[n(I,{muted:!0}),n(d,{muted:!0,size:1,children:"Loading…"})]})}):X&&!ie?n(Sn,{initial:"initial",animate:"animate",exit:"exit",variants:Ln,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(ot,{flex:1,message:"Could not connect to the preview",onRetry:te,onContinueAnyway:ne,children:N&&i(r,{children:["connected"!==C&&n(a,{padding:3,radius:2,tone:"critical",children:i(l,{space:3,children:[n(m,{muted:!0,size:0,children:"Overlay connection status"}),n(f,{size:1,children:C})]})}),"connected"!==v&&n(a,{padding:3,radius:2,tone:"critical",children:i(l,{space:3,children:[n(m,{muted:!0,size:0,children:"Loader connection status"}),n(f,{size:1,children:v})]})})]})})}):null:n(Sn,{initial:"initial",animate:"animate",exit:"exit",variants:jn,justify:"center",align:"center",style:{inset:"0",position:"absolute",backdropFilter:q?"blur(16px) saturate(0.5) grayscale(0.5)":"blur(2px)",transition:"backdrop-filter 0.2s ease-in-out",WebkitBackdropFilter:q?"blur(16px) saturate(0.5) grayscale(0.5)":"blur(2px)",WebkitTransition:"-webkit-backdrop-filter 0.2s ease-in-out",zIndex:1},children:i(s,{style:{...$n[W]},justify:"center",align:"center",direction:"column",gap:4,children:[q&&n(h,{disabled:!0,fontSize:1,mode:"ghost",text:"Continue anyway",style:{opacity:0}}),n(a,{radius:2,tone:q?"caution":"inherit",padding:4,shadow:1,children:i(s,{justify:"center",align:"center",direction:"column",gap:4,children:[n(I,{muted:!0}),n(d,{muted:!0,size:1,children:q?n(r,{children:"Unable to connect, check the browser console for more information."}):"Connecting…"})]})}),q&&n(h,{fontSize:1,tone:"critical",onClick:ne,text:"Continue anyway"})]})})}),n(xn,{ref:t,style:{pointerEvents:(K||"connecting"===C&&"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:Tn,animate:[(K||"connecting"===C&&"refreshing"!==c.status)&&!ie?"background":"active",K?"reloading":"idle",W,oe&&!ie?"timedOut":""],onLoad:ce})]})})]})})})),$n={desktop:{width:"100%",height:"100%"},mobile:{width:375,height:650}},jn={initial:{opacity:1},animate:{opacity:[0,0,1]},exit:{opacity:[1,0,0]}},Ln={initial:{opacity:1},animate:{opacity:[0,0,1]},exit:{opacity:[1,0,0]}},Tn={desktop:{...$n.desktop,boxShadow:"0 0 0 0px var(--card-border-color)"},mobile:{...$n.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 Un=!1;function An(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 _n(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 i=tt.exec(n);if(i){t.push(i[1],[Number(i[2]),Number(i[3])]);continue}const r=nt.exec(n);r?t.push(r[1],{_key:r[2]}):t.push(n)}return t}(decodeURIComponent(e)))}function Wn(e){return Object.fromEntries(Object.entries(e).filter((([,e])=>void 0!==e&&""!==e&&null!==e)))}function Mn({initialPreviewUrl:e,routerNavigate:t,routerState:n,routerSearchParams:i,frameStateRef:r}){const o=R((()=>{const{id:t,path:r,type:o}={id:An((a=n).id),path:_n(a.path),type:a.type};var a;return{id:t,type:o,path:r,preview:i.preview||`${e.pathname}${e.search}`,perspective:i.perspective,viewport:i.viewport,inspect:i.inspect,rev:i.rev,since:i.since,template:i.template,templateParams:i.templateParams,view:i.view,pathKey:i.pathKey,instruction:i.instruction,comment:i.comment}}),[n,i,e]),a=R((()=>Wn({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);j((()=>{s.current=n}),[n]);return{deskParams:a,navigate:R((()=>St(((e,n={},i)=>{e.id&&(e.id=B(e.id));const{_searchParams:o,...a}=s.current,c=(o||[]).reduce(((e,[t,n])=>(e[t]=n,e)),{}),l=Wn({...a,...e}),d=Wn({...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!=i?i:d.preview===r.current.url;t(l,{replace:u})}),50)),[t,r]),params:o}}function Nn(e,t,n){var i,r;const o=q({apiVersion:pe}),a=K(),s=(null==(i=null==a?void 0:a.activeWorkspace)?void 0:i.basePath)||"/",c=(null==(r=null==a?void 0:a.activeWorkspace)?void 0:r.name)||"default",l=function(e,t,n){const i=G();return R((()=>["@sanity/presentation",t,n,e,null==i?void 0:i.id,Fn]),[t,null==i?void 0:i.id,e,n])}(t,s,c),d=function(e,t){const n=q({apiVersion:pe}),i=G(),[r,o]=$(""),a=e?Me((async()=>await Ae(n,"@sanity/presentation",typeof window>"u"?"":location.href,null==i?void 0:i.id)),[...t,r]):null;return j((()=>{if(!a)return;const e=setTimeout((()=>{W((()=>o(a.expiresAt.toString())))}),a.expiresAt.getTime()-Date.now());return()=>clearTimeout(e)}),[a]),(null==a?void 0:a.secret)||null}("object"==typeof e||"function"==typeof e,l);return Me((async()=>{if("string"==typeof e){const t=new URL(e,location.origin);let i=t;try{if(n){const e=new URL(n,t);e.origin===t.origin&&(i=e)}else if(document.referrer){const e=new URL(document.referrer);e.origin===t.origin&&(i=e)}}catch{}return location.origin!==i.origin||!i.pathname.startsWith(`${s}/`)&&i.pathname!==s?i:t}const t=await("object"==typeof e?We(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 Fn=Symbol();const Vn=F((()=>import("./LoaderQueries.js"))),Bn=F((()=>import("./PostMessageRefreshMutations.js"))),Kn=ce(s)`
overflow-x: auto;
`;function qn(e){var t;const{previewUrl:a,components:l}=null!=(t=e.tool.options)?t:{},c=e.tool.name||ge,{unstable_navigator:d}=l||{},{navigate:u,state:p}=Y(),h=V(Object.fromEntries(p._searchParams||[])),f=Nn(a||"/",c,h.preview||null),[m]=$((()=>{var t;const n=null==(t=e.tool.options)?void 0:t.devMode;return"function"==typeof n?n():"boolean"==typeof n?n:typeof window<"u"&&"localhost"===window.location.hostname})),v=R((()=>f.origin),[f.origin]),g=U(null),[y,w]=$(),[b,x]=$({}),k=U({title:void 0,url:void 0}),{params:P,deskParams:E,navigate:S}=Mn({initialPreviewUrl:f,routerNavigate:u,routerState:p,routerSearchParams:h,frameStateRef:k}),[I,C]=M(hn,{perspective:P.perspective,viewport:P.viewport},bn),[D,L]=function(e,t){if("published"!==e&&"previewDrafts"!==e)throw new Error(`Invalid perspective: ${e}`);const[n,i]=$({}),[r,o]=$({}),a=U(""),s=O(((e,n,r)=>{const s=r.filter((e=>"_projectId"in e&&e._projectId?(Un||(console.warn("Cross dataset references are not supported yet, ignoring source document",e),Un=!0),!1):e));("published"===n?i:o)((n=>{const i={};for(const e of s)i[e._id]=e;if(a.current!==t.current.url)return a.current=t.current.url,{[e]:i};const r=n[e];return _e(r,i)?n:{...n,[e]:i}}))}),[t]);return[R((()=>{const t=Object.values("published"===e?n:r).reduce(((e,t)=>(Object.values(t).forEach((t=>{e[t._id]=t})),e)),{});return Object.values(t)}),[e,r,n]),s]}(I.perspective,k),T=H(),A=X();j((()=>{(I.perspective!==P.perspective||I.viewport!==P.viewport)&&S({},{perspective:"previewDrafts"===I.perspective?void 0:I.perspective,viewport:"desktop"===I.viewport?void 0:I.viewport})}),[P.perspective,I.perspective,S,I.viewport,P.viewport]);const[_,F]=$("connecting"),[B,K]=$("connecting"),[q,G]=$("connecting"),[J]=$((()=>new Set)),Q=O((e=>{const t=window.open(e,"_blank");t&&J.add(t)}),[J]);j((()=>{if(J.size&&y)for(const e of J)e&&"closed"in e&&!e.closed&&y.addSource(e)}),[y,J,J.size]),j((()=>{var e;const t=null==(e=g.current)?void 0:e.contentWindow;if(!t)return;const n=function(e){const{destroy:t,send:n}=Ye(e),i=new Set,r=new WeakMap,o=new Set;return{destroy:()=>{t();for(const e of o)e()},send:(e,t,o)=>{n(e,t,o);for(const n of i)n&&"closed"in n&&!n.closed&&r.has(n)&&r.get(n)(e,t,o)},addSource(t){if(i.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}=Ye({...e,target:t,connectTo:e.connectTo.map((e=>{const{onStatusUpdate:t,onEvent:n,...i}=e;return{...i,onEvent:n?(e,t)=>{if("preview-kit/documents"!==e&&"overlay/navigate"!==e&&"loader/documents"!==e)return n(e,t)}:void 0}}))});o.add(a),r.set(t,n),i.add(t)}}}({id:"presentation",target:t,targetOrigin:v,connectTo:[{id:"overlays",heartbeat:!0,onStatusUpdate:F,onEvent(e,t){if("visual-editing/focus"!==e&&"overlay/focus"!==e||!("id"in t))if("visual-editing/navigate"===e||"overlay/navigate"===e){const{title:e,url:n}=t;k.current.url!==n&&S({},{preview:n}),k.current={title:e,url:n}}else"visual-editing/meta"===e?k.current.title=t.title:"visual-editing/toggle"===e||"overlay/toggle"===e?C({type:pn,enabled:t.enabled}):"visual-editing/documents"===e?L("visual-editing",t.perspective,t.documents):"visual-editing/refreshing"===e&&"manual"===t.source?clearTimeout(he.current):"visual-editing/refreshing"===e&&"mutation"===t.source?C({type:ln}):"visual-editing/refreshed"===e&&C({type:sn});else S({type:t.type,id:t.id,path:t.path})}},{id:"loaders",heartbeat:!0,onStatusUpdate:K,onEvent(e,t){if("loader/documents"===e&&t.projectId===T&&t.dataset===A)L("loaders",t.perspective,t.documents);else if("loader/query-listen"===e&&t.projectId===T&&t.dataset===A){if("number"==typeof t.heartbeat&&t.heartbeat<fe)throw new Error(`Loader query listen heartbeat interval must be at least ${fe}ms`);x((e=>{var n,i,r;return{...e,[(i=t.query,r=t.params,`${i}-${"string"==typeof r?r:JSON.stringify(r)}`)]:{perspective:t.perspective,query:t.query,params:t.params,receivedAt:Date.now(),heartbeat:null!=(n=t.heartbeat)&&n}}}))}}},{id:"preview-kit",heartbeat:!0,onStatusUpdate:G,onEvent(e,t){"preview-kit/documents"===e&&t.projectId===T&&t.dataset===A&&L("preview-kit",t.perspective,t.documents)}}]});return w(n),()=>{n.destroy(),w(void 0)}}),[A,T,L,S,v]),j((()=>{const e=setInterval((()=>W((()=>x((e=>{if(Object.keys(e).length<1)return e;const t=Date.now();if(!Object.values(e).some((e=>!1!==e.heartbeat&&t>e.receivedAt+e.heartbeat)))return e;const n={};for(const[i,r]of Object.entries(e))!1!==r.heartbeat&&t>r.receivedAt+r.heartbeat||(n[i]=r);return n}))))),fe);return()=>clearInterval(e)}),[]);const ee=O((e=>{S({path:o.toString(e)},{},!0)}),[S]),te=O((e=>{const t=new URL(e,f.origin),n=t.pathname+t.search;t.origin===f.origin&&n!==P.preview&&S({},{preview:n})}),[f,P,S]),ne=O((e=>{S({},e)}),[S]);j((()=>{P.id&&P.path?null==y||y.send("overlays","presentation/focus",{id:P.id,path:P.path}):null==y||y.send("overlays","presentation/blur",void 0)}),[y,P.id,P.path]),j((()=>{k.current.url&&P.preview&&k.current.url!==P.preview&&(k.current.url=P.preview,"connected"!==_&&g.current?g.current.src=`${v}${P.preview}`:null==y||y.send("overlays","presentation/navigate",{url:P.preview,type:"replace"}))}),[y,_,v,P.preview]);const ie=O((()=>null==y?void 0:y.send("overlays","presentation/toggleOverlay",void 0)),[y]),[re,oe]=$(null);j((()=>{const e=e=>{rt(e)&&ie()},t=e=>{var t;rt(e)&&ie(),t=e,["mod","\\"].every((e=>it[e]?t[it[e]]:t.key===e.toUpperCase()))&&ie()};return window.addEventListener("keydown",t),window.addEventListener("keyup",e),()=>{window.removeEventListener("keydown",t),window.removeEventListener("keyup",e)}}),[ie]);const[ae,le]=$(null),[{navigatorEnabled:ce,toggleNavigator:de},ue]=Mt({unstable_navigator:d}),pe=U(P.id);j((()=>{P.rev&&pe.current&&P.id!==pe.current&&S({},{rev:void 0}),pe.current=P.id}));const he=U(),we=O((e=>{if(C({type:ln}),y)return he.current=window.setTimeout(e,300),void y.send("overlays","presentation/refresh",{source:"manual",livePreviewEnabled:"connected"===q||"connected"===B});e()}),[y,B,q]),be=Z(),xe=O((({id:e,type:t,path:n})=>{if(k.current.url)return{title:k.current.title||k.current.url,name:"edit",params:{id:e,path:n,type:t,inspect:me,workspace:be.name,mode:ve,preview:P.preview}}}),[P.preview,be.name]);return i(r,{children:[n(Vt,{deskParams:E,devMode:m,name:c,params:P,navigate:S,children:n(Wt,{navigate:S,children:n(Ft,{params:P,children:n(Kn,{height:"fill",children:i(_t,{children:[n(ue,{}),n(xt,{id:"preview",minWidth:325,defaultSize:ce?50:75,order:3,children:n(s,{direction:"column",flex:1,height:"fill",ref:le,children:n(z,{element:ae,children:n(Rn,{dispatch:C,iframe:I.iframe,initialUrl:f,loadersConnection:B,navigatorEnabled:ce,onPathChange:te,onRefresh:we,openPopup:Q,overlaysConnection:_,params:P,perspective:I.perspective,ref:g,targetOrigin:v,toggleNavigator:de,toggleOverlay:ie,viewport:I.viewport,visualEditing:I.visualEditing})})})}),n(Et,{order:4}),n(xt,{id:"content",minWidth:325,order:5,children:n(ye,{documentId:P.id,setDisplayedDocument:oe,children:n(se,{getIntent:xe,children:n(yt,{refs:D,deskParams:E,documentId:P.id,documentType:P.type,onDeskParams:ne,onFocusPath:ee,previewUrl:P.preview})})})})]})})})})}),y&&n(N,{children:n(Vn,{channel:y,liveQueries:b,perspective:I.perspective,liveDocument:re,documentsOnPage:D})}),y&&P.id&&P.type&&n(N,{children:n(Bn,{channel:y,id:P.id,type:P.type,loadersConnection:B,previewKitConnection:q})})]})}export{qn as default};//# sourceMappingURL=PresentationTool.js.map
`;function qn(e){var t;const{previewUrl:a,components:c}=null!=(t=e.tool.options)?t:{},l=e.tool.name||ge,{unstable_navigator:d}=c||{},{navigate:u,state:p}=Y(),h=V(Object.fromEntries(p._searchParams||[])),f=Nn(a||"/",l,h.preview||null),[m]=$((()=>{var t;const n=null==(t=e.tool.options)?void 0:t.devMode;return"function"==typeof n?n():"boolean"==typeof n?n:typeof window<"u"&&"localhost"===window.location.hostname})),v=R((()=>f.origin),[f.origin]),g=U(null),[y,w]=$(),[b,x]=$({}),k=U({title:void 0,url:void 0}),{params:P,deskParams:E,navigate:S}=Mn({initialPreviewUrl:f,routerNavigate:u,routerState:p,routerSearchParams:h,frameStateRef:k}),[I,C]=M(hn,{perspective:P.perspective,viewport:P.viewport},bn),[D,L]=function(e,t){if("published"!==e&&"previewDrafts"!==e)throw new Error(`Invalid perspective: ${e}`);const[n,i]=$({}),[r,o]=$({}),a=U(""),s=O(((e,n,r=[])=>{const s=r.filter((e=>"_projectId"in e&&e._projectId?(Un||(console.warn("Cross dataset references are not supported yet, ignoring source document",e),Un=!0),!1):e));("published"===n?i:o)((n=>{const i={};for(const e of s)i[e._id]=e;if(a.current!==t.current.url)return a.current=t.current.url,{[e]:i};const r=n[e];return _e(r,i)?n:{...n,[e]:i}}))}),[t]);return[R((()=>{const t=Object.values("published"===e?n:r).reduce(((e,t)=>(Object.values(t).forEach((t=>{e[t._id]=t})),e)),{});return Object.values(t)}),[e,r,n]),s]}(I.perspective,k),T=H(),A=X();j((()=>{(I.perspective!==P.perspective||I.viewport!==P.viewport)&&S({},{perspective:"previewDrafts"===I.perspective?void 0:I.perspective,viewport:"desktop"===I.viewport?void 0:I.viewport})}),[P.perspective,I.perspective,S,I.viewport,P.viewport]);const[_,F]=$("connecting"),[B,K]=$("connecting"),[q,G]=$("connecting"),[J]=$((()=>new Set)),Q=O((e=>{const t=window.open(e,"_blank");t&&J.add(t)}),[J]);j((()=>{if(J.size&&y)for(const e of J)e&&"closed"in e&&!e.closed&&y.addSource(e)}),[y,J,J.size]),j((()=>{var e;const t=null==(e=g.current)?void 0:e.contentWindow;if(!t)return;const n=function(e){const{destroy:t,send:n}=Ye(e),i=new Set,r=new WeakMap,o=new Set;return{destroy:()=>{t();for(const e of o)e()},send:(e,t,o)=>{n(e,t,o);for(const n of i)n&&"closed"in n&&!n.closed&&r.has(n)&&r.get(n)(e,t,o)},addSource(t){if(i.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}=Ye({...e,target:t,connectTo:e.connectTo.map((e=>{const{onStatusUpdate:t,onEvent:n,...i}=e;return{...i,onEvent:n?(e,t)=>{if("preview-kit/documents"!==e&&"overlay/navigate"!==e&&"loader/documents"!==e)return n(e,t)}:void 0}}))});o.add(a),r.set(t,n),i.add(t)}}}({id:"presentation",target:t,targetOrigin:v,connectTo:[{id:"overlays",heartbeat:!0,onStatusUpdate:F,onEvent(e,t){if("visual-editing/focus"!==e&&"overlay/focus"!==e||!("id"in t))if("visual-editing/navigate"===e||"overlay/navigate"===e){const{title:e,url:n}=t;k.current.url!==n&&S({},{preview:n}),k.current={title:e,url:n}}else"visual-editing/meta"===e?k.current.title=t.title:"visual-editing/toggle"===e||"overlay/toggle"===e?C({type:pn,enabled:t.enabled}):"visual-editing/documents"===e?L("visual-editing",t.perspective,t.documents):"visual-editing/refreshing"===e&&"manual"===t.source?clearTimeout(he.current):"visual-editing/refreshing"===e&&"mutation"===t.source?C({type:cn}):"visual-editing/refreshed"===e&&C({type:sn});else S({type:t.type,id:t.id,path:t.path})}},{id:"loaders",heartbeat:!0,onStatusUpdate:K,onEvent(e,t){if("loader/documents"===e&&t.projectId===T&&t.dataset===A)L("loaders",t.perspective,t.documents);else if("loader/query-listen"===e&&t.projectId===T&&t.dataset===A){if("number"==typeof t.heartbeat&&t.heartbeat<fe)throw new Error(`Loader query listen heartbeat interval must be at least ${fe}ms`);x((e=>{var n,i,r;return{...e,[(i=t.query,r=t.params,`${i}-${"string"==typeof r?r:JSON.stringify(r)}`)]:{perspective:t.perspective,query:t.query,params:t.params,receivedAt:Date.now(),heartbeat:null!=(n=t.heartbeat)&&n}}}))}}},{id:"preview-kit",heartbeat:!0,onStatusUpdate:G,onEvent(e,t){"preview-kit/documents"===e&&t.projectId===T&&t.dataset===A&&L("preview-kit",t.perspective,t.documents)}}]});return w(n),()=>{n.destroy(),w(void 0)}}),[A,T,L,S,v]),j((()=>{const e=setInterval((()=>W((()=>x((e=>{if(Object.keys(e).length<1)return e;const t=Date.now();if(!Object.values(e).some((e=>!1!==e.heartbeat&&t>e.receivedAt+e.heartbeat)))return e;const n={};for(const[i,r]of Object.entries(e))!1!==r.heartbeat&&t>r.receivedAt+r.heartbeat||(n[i]=r);return n}))))),fe);return()=>clearInterval(e)}),[]);const ee=O((e=>{S({path:o.toString(e)},{},!0)}),[S]),te=O((e=>{const t=new URL(e,f.origin),n=t.pathname+t.search;t.origin===f.origin&&n!==P.preview&&S({},{preview:n})}),[f,P,S]),ne=O((e=>{S({},e)}),[S]);j((()=>{null==y||y.send("overlays","presentation/perspective",{perspective:I.perspective})}),[y,I.perspective]),j((()=>{P.id&&P.path?null==y||y.send("overlays","presentation/focus",{id:P.id,path:P.path}):null==y||y.send("overlays","presentation/blur",void 0)}),[y,P.id,P.path]),j((()=>{k.current.url&&P.preview&&k.current.url!==P.preview&&(k.current.url=P.preview,"connected"!==_&&g.current?g.current.src=`${v}${P.preview}`:null==y||y.send("overlays","presentation/navigate",{url:P.preview,type:"replace"}))}),[y,_,v,P.preview]);const ie=O((()=>null==y?void 0:y.send("overlays","presentation/toggleOverlay",void 0)),[y]),[re,oe]=$(null);j((()=>{const e=e=>{rt(e)&&ie()},t=e=>{var t;rt(e)&&ie(),t=e,["mod","\\"].every((e=>it[e]?t[it[e]]:t.key===e.toUpperCase()))&&ie()};return window.addEventListener("keydown",t),window.addEventListener("keyup",e),()=>{window.removeEventListener("keydown",t),window.removeEventListener("keyup",e)}}),[ie]);const[ae,ce]=$(null),[{navigatorEnabled:le,toggleNavigator:de},ue]=Mt({unstable_navigator:d}),pe=U(P.id);j((()=>{P.rev&&pe.current&&P.id!==pe.current&&S({},{rev:void 0}),pe.current=P.id}));const he=U(),we=O((e=>{if(C({type:cn}),y)return he.current=window.setTimeout(e,300),void y.send("overlays","presentation/refresh",{source:"manual",livePreviewEnabled:"connected"===q||"connected"===B});e()}),[y,B,q]),be=Z(),xe=O((({id:e,type:t,path:n})=>{if(k.current.url)return{title:k.current.title||k.current.url,name:"edit",params:{id:e,path:n,type:t,inspect:me,workspace:be.name,mode:ve,preview:P.preview}}}),[P.preview,be.name]);return i(r,{children:[n(Vt,{deskParams:E,devMode:m,name:l,params:P,navigate:S,children:n(Wt,{navigate:S,children:n(Ft,{params:P,children:n(Kn,{height:"fill",children:i(_t,{children:[n(ue,{}),n(xt,{id:"preview",minWidth:325,defaultSize:le?50:75,order:3,children:n(s,{direction:"column",flex:1,height:"fill",ref:ce,children:n(z,{element:ae,children:n(Rn,{dispatch:C,iframe:I.iframe,initialUrl:f,loadersConnection:B,navigatorEnabled:le,onPathChange:te,onRefresh:we,openPopup:Q,overlaysConnection:_,params:P,perspective:I.perspective,ref:g,targetOrigin:v,toggleNavigator:de,toggleOverlay:ie,viewport:I.viewport,visualEditing:I.visualEditing})})})}),n(Et,{order:4}),n(xt,{id:"content",minWidth:325,order:5,children:n(ye,{documentId:P.id,setDisplayedDocument:oe,children:n(se,{getIntent:xe,children:n(yt,{refs:D,deskParams:E,documentId:P.id,documentType:P.type,onDeskParams:ne,onFocusPath:ee,previewUrl:P.preview})})})})]})})})})}),y&&n(N,{children:n(Vn,{channel:y,liveQueries:b,perspective:I.perspective,liveDocument:re,documentsOnPage:D})}),y&&P.id&&P.type&&n(N,{children:n(Bn,{channel:y,id:P.id,type:P.type,loadersConnection:B,previewKitConnection:q})})]})}export{qn as default};//# sourceMappingURL=PresentationTool.js.map
{
"name": "@sanity/presentation",
"version": "1.11.1",
"version": "1.11.2",
"homepage": "https://github.com/sanity-io/visual-editing/tree/main/packages/presentation#readme",

@@ -120,5 +120,5 @@ "bugs": {

"@sanity/channels": "0.4.0",
"@sanity/client": "^6.14.4",
"@sanity/client": "^6.15.0",
"@sanity/pkg-utils": "^4.3.0",
"@sanity/visual-editing-helpers": "0.5.1",
"@sanity/visual-editing-helpers": "0.5.2",
"happy-dom": "^13.6.2",

@@ -133,3 +133,3 @@ "react": "^18.2.0",

"peerDependencies": {
"@sanity/client": "^6.14.4"
"@sanity/client": "^6.15.0"
},

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

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

perspective: ClientPerspective,
sourceDocuments: DocumentOnPage[],
sourceDocuments: DocumentOnPage[] = [],
) => {

@@ -47,0 +47,0 @@ const documents = sourceDocuments.filter((sourceDocument) => {

import { MutableRefObject, useEffect, useMemo, useRef } from 'react'
import { getPublishedId } from 'sanity'
import { RouterContextValue, RouterState, SearchParam } from 'sanity/router'

@@ -107,2 +108,5 @@

(nextState, nextSearchState = {}, forceReplace) => {
// Force navigation to use published IDs only
if (nextState.id) nextState.id = getPublishedId(nextState.id)
// Extract type, id and path as 'routerState'

@@ -109,0 +113,0 @@ const { _searchParams: routerSearchParams, ...routerState } =

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

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