1const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./JhxboH1M.js","./Cpj98o6Y.js"])))=>i.map(i=>d[i]); 2import{av as bn}from"./C7vKPjzM.js";import{S as Qs,E as Ks,m as Ys,_ as Xs,i as Zs,b as N,c as _n,O as X,d as z,o as Ye,e as Xe,f as it,h as er,j as En,n as tr,k as _t,l as T,s as nr,p as sr,P as Sn,x as rr,q as ir,r as or,A as ar,t as v,v as In,w as Ce,y as Et,z as P,B as J,D as $n,F as Tn,G as cr,H as xn,I as An,J as kn,K as Cn,L as ur,M as dr,N as hr,Q as lr,R as fr,T as pr,U as yr,V as ot,W as Wt}from"./l44pAUe5.js";function at(t,e){return new Promise(function(n,s){var r=new Qs({next:function(i){n(i),r.unsubscribe()},error:s,complete:function(){s(new Ks)}});t.subscribe(r)})}var gr=["addListener","removeListener"],mr=["addEventListener","removeEventListener"],vr=["on","off"];function xe(t,e,n,s){if(z(n)&&(s=n,n=void 0),s)return xe(t,e,n).pipe(Ys(s));var r=Xs(_r(t)?mr.map(function(a){return function(c){return t[a](e,c,n)}}):wr(t)?gr.map(Ht(t,e)):br(t)?vr.map(Ht(t,e)):[],2),i=r[0],o=r[1];if(!i&&Zs(t))return N(function(a){return xe(a,e,n)})(_n(t));if(!i)throw new TypeError("Invalid event target");return new X(function(a){var c=function(){for(var h=[],p=0;p<arguments.length;p++)h[p]=arguments[p];return a.next(1<h.length?h:h[0])};return i(c),function(){return o(c)}})}function Ht(t,e){return function(n){return function(s){return t[n](e,s)}}}function wr(t){return z(t.addListener)&&z(t.removeListener)}function br(t){return z(t.on)&&z(t.off)}function _r(t){return z(t.addEventListener)&&z(t.removeEventListener)}function Er(t,e){return e===void 0&&(e=null),e=e??t,Ye(function(n,s){var r=[],i=0;n.subscribe(Xe(s,function(o){var a,c,h,p,u=null;i++%e===0&&r.push([]);try{for(var d=it(r),l=d.next();!l.done;l=d.next()){var f=l.value;f.push(o),t<=f.length&&(u=u??[],u.push(f))}}catch(w){a={error:w}}finally{try{l&&!l.done&&(c=d.return)&&c.call(d)}finally{if(a)throw a.error}}if(u)try{for(var y=it(u),g=y.next();!g.done;g=y.next()){var f=g.value;er(r,f),s.next(f)}}catch(w){h={error:w}}finally{try{g&&!g.done&&(p=y.return)&&p.call(y)}finally{if(h)throw h.error}}},function(){var o,a;try{for(var c=it(r),h=c.next();!h.done;h=c.next()){var p=h.value;s.next(p)}}catch(u){o={error:u}}finally{try{h&&!h.done&&(a=c.return)&&a.call(c)}finally{if(o)throw o.error}}s.complete()},void 0,function(){r=null}))})}function Sr(t,e,n,s,r){return function(i,o){var a=n,c=e,h=0;i.subscribe(Xe(o,function(p){var u=h++;c=a?t(c,p,u):(a=!0,p)},(function(){a&&o.next(c),o.complete()})))}}function Ir(t,e){return Ye(Sr(t,e,arguments.length>=2,!1,!0))}function Rn(t,e){return z(e)?N(t,e,1):N(t,1)}function St(t){return t<=0?function(){return En}:Ye(function(e,n){var s=0;e.subscribe(Xe(n,function(r){++s<=t&&(n.next(r),t<=s&&n.complete())}))})}function $r(t){return Ye(function(e,n){_n(t).subscribe(Xe(n,function(){return n.complete()},tr)),!n.closed&&e.subscribe(n)})}function Le(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}var jn={0:8203,1:8204,2:8205,3:8290,4:8291,5:8288,6:65279,7:8289,8:119155,9:119156,a:119157,b:119158,c:119159,d:119160,e:119161,f:119162},be={0:8203,1:8204,2:8205,3:65279},_e={0:String.fromCodePoint(be[0]),1:String.fromCodePoint(be[1]),2:String.fromCodePoint(be[2]),3:String.fromCodePoint(be[3])},Tr=new Array(4).fill(String.fromCodePoint(be[0])).join("");function xr(t){let e=JSON.stringify(t),n=new TextEncoder().encode(e),s="";for(let r=0;r<n.length;r++){let i=n[r];s+=_e[i>>6&3]+_e[i>>4&3]+_e[i>>2&3]+_e[i&3]}return Tr+s}function Ar(t){return!Number.isNaN(Number(t))||/[a-z]/i.test(t)&&!/\d+(?:[-:\/]\d+){2}(?:T\d+(?:[-:\/]\d+){1,2}(\.\d+)?Z?)?/.test(t)?!1:!!Date.parse(t)}function kr(t){try{new URL(t,t.startsWith("/")?"https://acme.com":void 0)}catch{return!1}return!0}function Cr(t,e,n="auto"){return n===!0||n==="auto"&&(Ar(t)||kr(t))?t:`${t}${xr(e)}`}Object.fromEntries(Object.entries(_e).map(t=>[t[1],+t[0]]));Object.fromEntries(Object.entries(jn).map(t=>t.reverse()));var Rr=`${Object.values(jn).map(t=>`\\u{${t.toString(16)}}`).join("")}`,Nt=new RegExp(`[${Rr}]{4,}`,"gu");function jr(t){var e;return{cleaned:t.replace(Nt,""),encoded:((e=t.match(Nt))==null?void 0:e[0])||""}}function Mr(t){return t&&JSON.parse(jr(JSON.stringify(t)).cleaned)}function Or(t){return Mr(t)}let qr=t=>crypto.getRandomValues(new Uint8Array(t)),Dr=(t,e,n)=>{let s=(2<<Math.log(t.length-1)/Math.LN2)-1,r=-~(1.6*s*e/t.length);return(i=e)=>{let o="";for(;;){let a=n(r),c=r|0;for(;c--;)if(o+=t[a[c]&s]||"",o.length===i)return o}}},Pr=(t,e=21)=>Dr(t,e,qr);
2const zt=/\r\n|[\n\r\u2028\u2029]/;function Lr(t,e,n){const s=t.split(zt),r={start:Bt(e.start,s),end:e.end?Bt(e.end,s):void 0},{start:i,end:o,markerLines:a}=Ur(r,s),c=`${o}`.length;return t.split(zt,o).slice(i,o).map((h,p)=>{const u=i+1+p,d=` ${` ${u}`.slice(-c)} |`,l=a[u],f=!a[u+1];if(!l)return` ${d}${h.length>0?` ${h}`:""}`;let y="";if(Array.isArray(l)){const g=h.slice(0,Math.max(l[0]-1,0)).replace(/[^\t]/g," "),w=l[1]||1;y=[` 3 `,d.replace(/\d/g," ")," ",g,"^".repeat(w)].join(""),f&&n&&(y+=" "+n)}return[">",d,h.length>0?` ${h}`:"",y].join("")}).join(` 4`)}function Ur(t,e){const n={...t.start},s={...n,...t.end},r=2,i=3,o=n.line??-1,a=n.column??0,c=s.line,h=s.column;let p=Math.max(o-(r+1),0),u=Math.min(e.length,c+i);o===-1&&(p=0),c===-1&&(u=e.length);const d=c-o,l={};if(d)for(let f=0;f<=d;f++){const y=f+o;if(!a)l[y]=!0;else if(f===0){const g=e[y-1].length;l[y]=[a,g-a+1]}else if(f===d)l[y]=[0,h];else{const g=e[y-f].length;l[y]=[0,g]}}else a===h?a?l[o]=[a,0]:l[o]=!0:l[o]=[a,h-a];return{start:p,end:u,markerLines:l}}function Bt(t,e){let n=0;for(let s=0;s<e.length;s++){const r=e[s].length+1;if(n+r>t)return{line:s+1,column:t-n};n+=r}return{line:e.length,column:e[e.length-1]?.length??0}}const ct=5;class Vr extends Error{response;statusCode=400;responseBody;traceId;details;constructor(e,n){const s=Mn(e,n);super(s.message),Object.assign(this,s)}}class Wr extends Error{response;statusCode=500;responseBody;traceId;details;constructor(e){const n=Mn(e);super(n.message),Object.assign(this,n)}}function Mn(t,e){const n=t.body,s={response:t,statusCode:t.statusCode,responseBody:Br(n,t),traceId:zr(t),message:"",details:void 0};if(!Le(n))return s.message=`${ut(t,n)}${V(s.traceId)}`,s;const r=n.error;if(typeof r=="string"&&typeof n.message=="string")return s.message=`${r} - ${n.message}${V(s.traceId)}`,s;if(typeof r!="object"||r===null)return typeof r=="string"?s.message=`${r}${V(s.traceId)}`:typeof n.message=="string"?s.message=`${n.message}${V(s.traceId)}`:s.message=`${ut(t,n)}${V(s.traceId)}`,s;if(Hr(r)||Nr(r)){const i=r.items||[],o=i.slice(0,ct).map(c=>c.error?.description).filter(Boolean);let a=o.length?`: 5- ${o.join(` 6- `)}`:"";return i.length>ct&&(a+=` 7...and ${i.length-ct} more`),s.message=`${r.description}${V(s.traceId)}${a}`,s.details=n.error,s}if(On(r)){const i=e?.options?.query?.tag;return s.message=qn(r,i,s.traceId),s.details=n.error,s}return"description"in r&&typeof r.description=="string"?(s.message=`${r.description}${V(s.traceId)}`,s.details=r,s):(s.message=`${ut(t,n)}${V(s.traceId)}`,s)}function Hr(t){return"type"in t&&t.type==="mutationError"&&"description"in t&&typeof t.description=="string"}function Nr(t){return"type"in t&&t.type==="actionError"&&"description"in t&&typeof t.description=="string"}function On(t){return Le(t)&&t.type==="queryParseError"&&typeof t.query=="string"&&typeof t.start=="number"&&typeof t.end=="number"}function qn(t,e,n){const{query:s,start:r,end:i,description:o}=t,a=n?` 8(traceId: ${n})`:"";if(!s||typeof r>"u")return`GROQ query parse error: ${o}${a}`;const c=e?` 9 10Tag: ${e}`:"";return`GROQ query parse error: 11${Lr(s,{start:r,end:i},o)}${c}${a}`}function ut(t,e){const n=typeof e=="string"?` (${Fr(e,100)})`:"",s=t.statusMessage?` ${t.statusMessage}`:"";return`${t.method}-request to ${t.url} resulted in HTTP ${t.statusCode}${s}${n}`}function zr(t){const e=t?.headers?.traceparent;if(e)return e.split("-")[1]}function Br(t,e){return(e.headers["content-type"]||"").toLowerCase().indexOf("application/json")!==-1?JSON.stringify(t,null,2):t}function V(t){return t?` (traceId: ${t})`:""}function Fr(t,e){return t.length>e?`${t.slice(0,e)}â¦`:t}class yt extends Error{projectId;addOriginUrl;constructor({projectId:e,credentials:n}={}){if(super("CorsOriginError"),this.name="CorsOriginError",this.projectId=e,e&&typeof location<"u"){const s=new URL(`https://sanity.io/manage/project/${e}/api`),{origin:r}=location;s.searchParams.set("cors","add"),s.searchParams.set("origin",r),n&&s.searchParams.set("credentials",""),this.addOriginUrl=s,this.message=`The current origin is not allowed to connect to the Live Content API. Add it here: ${s}`}
11else e?this.message=`The current origin is not allowed to connect to the Live Content API. Change your configuration here: https://sanity.io/manage/project/${e}/api`:this.message="The current origin is not allowed to connect to the Live Content API."}}const Gr={onResponse:(t,e)=>{if(t.statusCode>=500)throw new Wr(t);if(t.statusCode>=400)throw new Vr(t,e);return t}};function Jr(t={}){const e={},n=s=>t.ignoreWarnings===void 0?!1:(Array.isArray(t.ignoreWarnings)?t.ignoreWarnings:[t.ignoreWarnings]).some(r=>typeof r=="string"?s.includes(r):r instanceof RegExp?r.test(s):!1);return{onResponse:s=>{const r=s.headers["x-sanity-warning"],i=Array.isArray(r)?r:[r];for(const o of i)!o||e[o]||n(o)||(e[o]=!0,console.warn(o));return s}}}function Ft(t,e={}){return sr([Sn({shouldRetry:Qr}),...t,Jr(e),rr(),ir(),or(),Gr,ar({implementation:X})])}function Qr(t,e,n){if(n.maxRetries===0)return!1;const s=n.method==="GET"||n.method==="HEAD",r=(n.uri||n.url).startsWith("/data/query"),i=t.response&&(t.response.statusCode===429||t.response.statusCode===502||t.response.statusCode===503);return(s||r)&&i?!0:Sn.shouldRetry(t,e,n)}const Kr="https://www.sanity.io/help/";function It(t){return Kr+t}const Gt=["image","file"],Jt=["before","after","replace"],le=t=>{if(!/^(~[a-z0-9]{1}[-\w]{0,63}|[a-z0-9]{1}[-\w]{0,63})$/.test(t))throw new Error("Datasets can only contain lowercase characters, numbers, underscores and dashes, and start with tilde, and be maximum 64 characters")},Yr=t=>{if(!/^[-a-z0-9]+$/i.test(t))throw new Error("`projectId` can only contain only a-z, 0-9 and dashes")},Xr=t=>{if(Gt.indexOf(t)===-1)throw new Error(`Invalid asset type: ${t}. Must be one of ${Gt.join(", ")}`)},Ee=(t,e)=>{if(e===null||typeof e!="object"||Array.isArray(e))throw new Error(`${t}() takes an object of properties`)},Ue=(t,e)=>{if(typeof e!="string"||!/^[a-z0-9_][a-z0-9_.-]{0,127}$/i.test(e)||e.includes(".."))throw new Error(`${t}(): "${e}" is not a valid document ID`)},fe=(t,e)=>{if(!e._id)throw new Error(`${t}() requires that the document contains an ID ("_id" property)`);Ue(t,e._id)},Zr=(t,e)=>{if(typeof e!="string")throw new Error(`\`${t}()\`: \`${e}\` is not a valid document type`)},Dn=(t,e)=>{if(!e._type)throw new Error(`\`${t}()\` requires that the document contains a type (\`_type\` property)`);Zr(t,e._type)},ei=(t,e)=>{if(e._id&&e._id!==t)throw new Error(`The provided document ID (\`${e._id}\`) does not match the generated version ID (\`${t}\`)`)},ti=(t,e,n)=>{const s="insert(at, selector, items)";if(Jt.indexOf(t)===-1){const r=Jt.map(i=>`"${i}"`).join(", ");throw new Error(`${s} takes an "at"-argument which is one of: ${r}`)}if(typeof e!="string")throw new Error(`${s} takes a "selector"-argument which must be a string`);if(!Array.isArray(n))throw new Error(`${s} takes an "items"-argument which must be an array`)},Z=t=>{if(t.dataset)return t.dataset;const e=t.resource;if(e&&e.type==="dataset"){const n=e.id.split(".");if(n.length!==2)throw new Error('Dataset resource ID must be in the format "project.dataset"');return n[1]}throw new Error("`dataset` must be provided to perform queries")},Pn=t=>{if(typeof t!="string"||!/^[a-z0-9._-]{1,75}$/i.test(t))throw new Error("Tag can only contain alphanumeric characters, underscores, dashes and dots, and be between one and 75 characters long.");return t},Ln=t=>{const e=t.resource;if(!e)throw new Error("`resource` must be provided to perform resource queries");const{type:n,id:s}=e;switch(n){case"dataset":{if(s.split(".").length!==2)throw new Error('Dataset resource ID must be in the format "project.dataset"');return}case"dashboard":case"media-library":case"canvas":return;default:throw new Error(`Unsupported resource type: ${n.toString()}`)}},O=(t,e)=>{if(e.resource)throw new Error(`\`${t}\` does not support resource-based operations`)};function ni(t){let e=!1,n;return(...s)=>(e||(n=t(...s),e=!0),n)}const L=t=>ni((...e)=>console.warn(t.join(" "),...e)),si=L(["Because you set `withCredentials` to true, we will override your `useCdn`","setting to be false since (cookie-based) credentials are never set on the CDN"]),ri=L(["Since you haven't set a value for `useCdn`, we will deliver content using our","global, edge-cached API-CDN. If you wish to have content delivered faster, set","`useCdn: false` to use the Live API. Note: You may incur higher costs using the live API."]),ii=L(["The Sanity client is configured with the `perspective` set to `drafts` or `previewDrafts`, which doesn't support the API-CDN.","The Live API will be used instead. Set `useCdn: false` in your configuration to hide this warning."]),oi=L(["The `previewDrafts` perspective has been renamed to `drafts` and will be removed in a future API version"]),ai=L(["You have configured Sanity client to use a token in the browser. This may cause unintentional security issues.",`See ${It("js-client-browser-token")} for more information and how to hide this warning.`]),ci=L(["You have configured Sanity client to use a token, but also provided `withCredentials: true`.","This is no longer supported - only token will be used - remove `withCredentials: true`."]),ui=L(["Using the Sanity client without specifying an API version is deprecated.",`See ${It("js-client-api-version")}`]),di=L(["You have called `createVersion()` with a defined `document`. The recommended approach is to provide a `baseId` and `releaseId` instead."]),hi=L(["The `~experimental_resource` configuration property has been renamed to `resource`.","Please update your client configuration to use `resource` instead. Support for `~experimental_resource` will be removed in a future version."]),li="apicdn.sanity.io",Se={apiHost:"https://api.sanity.io",apiVersion:"1",useProjectHostname:!0,stega:{enabled:!1}},fi=["localhost","127.0.0.1","0.0.0.0"],pi=t=>fi.indexOf(t)!==-1;function yi(t){if(t==="1"||t==="X")return;const e=new Date(t);if(!(/^\d{4}-\d{2}-\d{2}$/.test(t)&&e instanceof Date&&e.getTime()>0))throw new Error("Invalid API version string, expected `1` or date in format `YYYY-MM-DD`")}function $t(t){if(Array.isArray(t)&&t.length>1&&t.includes("raw"))throw new TypeError('Invalid API perspective value: "raw". The raw-perspective can not be combined with other perspectives')}const Un=(t,e)=>{const n={...e,...t,stega:{...typeof e.stega=="boolean"?{enabled:e.stega}:e.stega||Se.stega,...typeof t.stega=="boolean"?{enabled:t.stega}:t.stega||{}}};n.apiVersion||ui();const s={...Se,...n};s["~experimental_resource"]&&!s.resource&&(hi(),s.resource=s["~experimental_resource"]);const r=s.resource,i=s.useProjectHostname&&!r;if(typeof Promise>"u"){const l=It("js-client-promise-polyfill");throw new Error(`No native Promise-implementation found, polyfill needed - see ${l}`)}if(i&&!s.projectId)throw new Error("Configuration must contain `projectId`");if(r&&Ln(s),typeof s.perspective<"u"&&$t(s.perspective),"encodeSourceMap"in s)throw new Error("It looks like you're using options meant for '@sanity/preview-kit/client'. 'encodeSourceMap' is not supported in '@sanity/client'. Did you mean 'stega.enabled'?");if("encodeSourceMapAtPath"in s)throw new Error("It looks like you're using options meant for '@sanity/preview-kit/client'. 'encodeSourceMapAtPath' is not supported in '@sanity/client'. Did you mean 'stega.filter'?");
11if(typeof s.stega.enabled!="boolean")throw new Error(`stega.enabled must be a boolean, received ${s.stega.enabled}`);if(s.stega.enabled&&s.stega.studioUrl===void 0)throw new Error("stega.studioUrl must be defined when stega.enabled is true");if(s.stega.enabled&&typeof s.stega.studioUrl!="string"&&typeof s.stega.studioUrl!="function")throw new Error(`stega.studioUrl must be a string or a function, received ${s.stega.studioUrl}`);const o=typeof window<"u"&&window.location&&window.location.hostname,a=o&&pi(window.location.hostname),c=!!s.token;s.withCredentials&&c&&(ci(),s.withCredentials=!1),o&&a&&c&&s.ignoreBrowserTokenWarning!==!0?ai():typeof s.useCdn>"u"&&ri(),i&&Yr(s.projectId),s.dataset&&le(s.dataset),"requestTagPrefix"in s&&(s.requestTagPrefix=s.requestTagPrefix?Pn(s.requestTagPrefix).replace(/\.+$/,""):void 0),s.apiVersion=`${s.apiVersion}`.replace(/^v/,""),s.isDefaultApi=s.apiHost===Se.apiHost,s.useCdn===!0&&s.withCredentials&&si(),s.useCdn=s.useCdn!==!1&&!s.withCredentials,yi(s.apiVersion);const h=s.apiHost.split("://",2),p=h[0],u=h[1],d=s.isDefaultApi?li:u;return i?(s.url=`${p}://${s.projectId}.${u}/v${s.apiVersion}`,s.cdnUrl=`${p}://${s.projectId}.${d}/v${s.apiVersion}`):(s.url=`${s.apiHost}/v${s.apiVersion}`,s.cdnUrl=s.url),s};class Vn extends Error{name="ConnectionFailedError"}class gi extends Error{name="DisconnectError";reason;constructor(e,n,s={}){super(e,s),this.reason=n}}class mi extends Error{name="ChannelError";data;constructor(e,n){super(e),this.data=n}}class vi extends Error{name="MessageError";data;constructor(e,n,s={}){super(e,s),this.data=n}}class Qt extends Error{name="MessageParseError"}const wi=["channelError","disconnect"];function Wn(t,e){return _t(()=>{const n=t();return dr(n)?n:J(n)}).pipe(N(n=>bi(n,e)))}function bi(t,e){return new X(n=>{const s=e.includes("open"),r=e.includes("reconnect");function i(h){if("data"in h){const[p,u]=Kt(h);n.error(p?new Qt("Unable to parse EventSource error message",{cause:u}):new vi((u?.data).message,u));return}t.readyState===t.CLOSED?n.error(new Vn("EventSource connection failed")):r&&n.next({type:"reconnect"})}function o(){n.next({type:"open"})}function a(h){const[p,u]=Kt(h);if(p){n.error(new Qt("Unable to parse EventSource message",{cause:p}));return}if(h.type==="channelError"){const d=new URL(t.url).searchParams.get("tag");n.error(new mi(_i(u?.data,d),u.data));return}if(h.type==="disconnect"){n.error(new gi(`Server disconnected client: ${u.data?.reason||"unknown error"}`));return}n.next({type:h.type,id:h.lastEventId,...u.data?{data:u.data}:{}})}t.addEventListener("error",i),s&&t.addEventListener("open",o);const c=[...new Set([...wi,...e])].filter(h=>h!=="error"&&h!=="open"&&h!=="reconnect");return c.forEach(h=>t.addEventListener(h,a)),()=>{t.removeEventListener("error",i),s&&t.removeEventListener("open",o),c.forEach(h=>t.removeEventListener(h,a)),t.close()}})}function Kt(t){try{const e=typeof t.data=="string"&&JSON.parse(t.data);return[null,{type:t.type,id:t.lastEventId,...Ei(e)?{}:{data:e}}]}catch(e){return[e,null]}}function _i(t,e){const n=t.error;return n?On(n)?qn(n,e):n.description?n.description:typeof n=="string"?n:JSON.stringify(n,null,2):t.message||"Unknown listener error"}function Ei(t){for(const e in t)return!1;return!0}function Hn(t){if(typeof t=="string")return{id:t};if(Array.isArray(t))return{query:"*[_id in $ids]",params:{ids:t}};if(typeof t=="object"&&t!==null&&"query"in t&&typeof t.query=="string")return"params"in t&&typeof t.params=="object"&&t.params!==null?{query:t.query,params:t.params}:{query:t.query};const e=["* Document ID (<docId>)","* Array of document IDs","* Object containing `query`"].join(` 12`);throw new Error(`Unknown selection - must be one of: 13 14${e}`)}class Nn{selection;operations;constructor(e,n={}){this.selection=e,this.operations=n}set(e){return this._assign("set",e)}setIfMissing(e){return this._assign("setIfMissing",e)}diffMatchPatch(e){return Ee("diffMatchPatch",e),this._assign("diffMatchPatch",e)}unset(e){if(!Array.isArray(e))throw new Error("unset(attrs) takes an array of attributes to unset, non-array given");return this.operations=Object.assign({},this.operations,{unset:e}),this}inc(e){return this._assign("inc",e)}dec(e){return this._assign("dec",e)}insert(e,n,s){return ti(e,n,s),this._assign("insert",{[e]:n,items:s})}append(e,n){return this.insert("after",`${e}[-1]`,n)}prepend(e,n){return this.insert("before",`${e}[0]`,n)}splice(e,n,s,r){const i=typeof s>"u"||s===-1,o=n<0?n-1:n,a=i?-1:Math.max(0,n+s),c=o<0&&a>=0?"":a,h=`${e}[${o}:${c}]`;return this.insert("replace",h,r||[])}ifRevisionId(e){return this.operations.ifRevisionID=e,this}serialize(){return{...Hn(this.selection),...this.operations}}toJSON(){return this.serialize()}reset(){return this.operations={},this}_assign(e,n,s=!0){return Ee(e,n),this.operations=Object.assign({},this.operations,{[e]:Object.assign({},s&&this.operations[e]||{},n)}),this}_set(e,n){return this._assign(e,n,!1)}}class Q extends Nn{#e;constructor(e,n,s){super(e,n),this.#e=s}clone(){return new Q(this.selection,{...this.operations},this.#e)}commit(e){if(!this.#e)throw new Error("No `client` passed to patch, either provide one or pass the patch to a clients `mutate()` method");
14const n=typeof this.selection=="string",s=Object.assign({returnFirst:n,returnDocuments:!0},e);return this.#e.mutate({patch:this.serialize()},s)}}class H extends Nn{#e;constructor(e,n,s){super(e,n),this.#e=s}clone(){return new H(this.selection,{...this.operations},this.#e)}commit(e){if(!this.#e)throw new Error("No `client` passed to patch, either provide one or pass the patch to a clients `mutate()` method");const n=typeof this.selection=="string",s=Object.assign({returnFirst:n,returnDocuments:!0},e);return this.#e.mutate({patch:this.serialize()},s)}}const zn={returnDocuments:!1};class Bn{operations;trxId;constructor(e=[],n){this.operations=e,this.trxId=n}create(e){return Ee("create",e),this._add({create:e})}createIfNotExists(e){const n="createIfNotExists";return Ee(n,e),fe(n,e),this._add({[n]:e})}createOrReplace(e){const n="createOrReplace";return Ee(n,e),fe(n,e),this._add({[n]:e})}delete(e){return Ue("delete",e),this._add({delete:{id:e}})}transactionId(e){return e?(this.trxId=e,this):this.trxId}serialize(){return[...this.operations]}toJSON(){return this.serialize()}reset(){return this.operations=[],this}_add(e){return this.operations.push(e),this}}class Ze extends Bn{#e;constructor(e,n,s){super(e,s),this.#e=n}clone(){return new Ze([...this.operations],this.#e,this.trxId)}commit(e){if(!this.#e)throw new Error("No `client` passed to transaction, either provide one or pass the transaction to a clients `mutate()` method");return this.#e.mutate(this.serialize(),Object.assign({transactionId:this.trxId},zn,e||{}))}patch(e,n){const s=typeof n=="function",r=typeof e!="string"&&e instanceof H,i=typeof e=="object"&&("query"in e||"id"in e);if(r)return this._add({patch:e.serialize()});if(s){const o=n(new H(e,{},this.#e));if(!(o instanceof H))throw new Error("function passed to `patch()` must return the patch");return this._add({patch:o.serialize()})}if(i){const o=new H(e,n||{},this.#e);return this._add({patch:o.serialize()})}return this._add({patch:{id:e,...n}})}}class et extends Bn{#e;constructor(e,n,s){super(e,s),this.#e=n}clone(){return new et([...this.operations],this.#e,this.trxId)}commit(e){if(!this.#e)throw new Error("No `client` passed to transaction, either provide one or pass the transaction to a clients `mutate()` method");return this.#e.mutate(this.serialize(),Object.assign({transactionId:this.trxId},zn,e||{}))}patch(e,n){const s=typeof n=="function";if(typeof e!="string"&&e instanceof Q)return this._add({patch:e.serialize()});if(s){const r=n(new Q(e,{},this.#e));if(!(r instanceof Q))throw new Error("function passed to `patch()` must return the patch");return this._add({patch:r.serialize()})}return this._add({patch:{id:e,...n}})}}const Si="X-Sanity-Project-ID";function Ii(t,e={}){const n={};t.headers&&Object.assign(n,t.headers);const s=e.token||t.token;s&&(n.Authorization=`Bearer ${s}`),!e.useGlobalApi&&!t.useProjectHostname&&t.projectId&&(n[Si]=t.projectId);const r=!!(typeof e.withCredentials>"u"?t.withCredentials:e.withCredentials),i=typeof e.timeout>"u"?t.timeout:e.timeout;return Object.assign({},e,{headers:Object.assign({},n,e.headers||{}),timeout:typeof i>"u"?300*1e3:i,proxy:e.proxy||t.proxy,json:!0,withCredentials:r,fetch:typeof e.fetch=="object"&&typeof t.fetch=="object"?{...t.fetch,...e.fetch}:e.fetch||t.fetch})}const Fn=({query:t,params:e={},options:n={}})=>{const s=new URLSearchParams,{tag:r,includeMutations:i,returnQuery:o,...a}=n;r&&s.append("tag",r),s.append("query",t);for(const[c,h]of Object.entries(e))h!==void 0&&s.append(`$${c}`,JSON.stringify(h));for(const[c,h]of Object.entries(a))h&&s.append(c,`${h}`);return o===!1&&s.append("returnQuery","false"),i===!1&&s.append("includeMutations","false"),`?${s}`},$i=(t,e)=>t===!1?void 0:typeof t>"u"?e:t,Ti=(t={})=>({dryRun:t.dryRun,returnIds:!0,returnDocuments:$i(t.returnDocuments,!0),visibility:t.visibility||"sync",autoGenerateArrayKeys:t.autoGenerateArrayKeys,skipCrossDatasetReferenceValidation:t.skipCrossDatasetReferenceValidation}),tt=t=>t.type==="response",xi=t=>t.body,Ai=(t,e)=>t.reduce((n,s)=>(n[e(s)]=s,n),Object.create(null)),ki=11264;function Gn(t,e,n,s,r={},i={}){const o="stega"in i?{...n||{},...typeof i.stega=="boolean"?{enabled:i.stega}:i.stega||{}}:n,a=o.enabled?Or(r):r,c=i.filterResponse===!1?f=>f:f=>f.result,{cache:h,next:p,...u}={useAbortSignal:typeof i.signal<"u",resultSourceMap:o.enabled?"withKeyArraySelector":i.resultSourceMap,...i,returnQuery:i.filterResponse===!1&&i.returnQuery!==!1}
14,d=typeof h<"u"||typeof p<"u"?{...u,fetch:{cache:h,next:p}}:u,l=ee(t,e,"query",{query:s,params:a},d);return o.enabled?l.pipe(cr(xn(bn(()=>Promise.resolve().then(()=>Po),void 0,import.meta.url).then(function(f){return f.stegaEncodeSourceMap$1}).then(({stegaEncodeSourceMap:f})=>f))),T(([f,y])=>{const g=y(f.result,f.resultSourceMap,o);return c({...f,result:g})})):l.pipe(T(c))}function pe(t,e,n,s={}){const r=(()=>{if(!s.releaseId)return n;const o=An(n);if(!o){if(kn(n))throw new Error(`The document ID (\`${n}\`) is a draft, but \`options.releaseId\` is set as \`${s.releaseId}\``);return Ce(n,s.releaseId)}if(o!==s.releaseId)throw new Error(`The document ID (\`${n}\`) is already a version of \`${o}\` release, but this does not match the provided \`options.releaseId\` (\`${s.releaseId}\`)`);return n})(),i={uri:C(t,"doc",r),json:!0,tag:s.tag,signal:s.signal,query:s.includeAllVersions!==void 0?{includeAllVersions:s.includeAllVersions}:void 0};return ve(t,e,i).pipe(P(tt),T(o=>{const a=o.body.documents;return a?s.includeAllVersions?a:a[0]:s.includeAllVersions?[]:void 0}))}function Jn(t,e,n,s={}){const r={uri:C(t,"doc",n.join(",")),json:!0,tag:s.tag,signal:s.signal};return ve(t,e,r).pipe(P(tt),T(i=>{const o=Ai(i.body.documents||[],a=>a._id);return n.map(a=>o[a]||null)}))}const Yt=100;function Qn(t,e,n,s={}){if(n.length===0)return J(new Set);const r=[];for(let o=0;o<n.length;o+=Yt)r.push(n.slice(o,o+Yt));const i=o=>ve(t,e,{uri:C(t,"doc",o.map(encodeURIComponent).join(",")),tag:s.tag,signal:s.signal,query:{excludeContent:!0}}).pipe(P(tt),T(a=>{const c=new Set;for(const h of a.body.omitted||[])h.reason==="existence"&&c.add(h.id);return new Set(o.filter(h=>!c.has(h)))}));return xn(r).pipe(Rn(i),Ir((o,a)=>{for(const c of a)o.add(c);return o},new Set))}function Kn(t,e,n,s={}){return ee(t,e,"query",{query:"*[sanity::partOfRelease($releaseId)]",params:{releaseId:n}},s)}function Yn(t,e,n,s){return fe("createIfNotExists",n),nt(t,e,n,"createIfNotExists",s)}function Xn(t,e,n,s){return fe("createOrReplace",n),nt(t,e,n,"createOrReplace",s)}function Zn(t,e,n,s,r){return fe("createVersion",n),Dn("createVersion",n),di(),E(t,e,{actionType:"sanity.action.document.version.create",publishedId:s,document:n},r)}function es(t,e,n,s,r,i,o){if(!s)throw new Error("`createVersion()` requires `baseId` when no `document` is provided");if(!n)throw new Error("`createVersion()` requires `publishedId` when `baseId` is provided");Ue("createVersion",s),Ue("createVersion",n);const a={actionType:"sanity.action.document.version.create",publishedId:n,baseId:s,versionId:r?Ce(n,r):Cn(n),ifBaseRevisionId:i};return E(t,e,a,o)}function ts(t,e,n,s){return ee(t,e,"mutate",{mutations:[{delete:Hn(n)}]},s)}function ns(t,e,n,s=!1,r){return E(t,e,{actionType:"sanity.action.document.version.discard",versionId:n,purge:s},r)}function ss(t,e,n,s){return fe("replaceVersion",n),Dn("replaceVersion",n),E(t,e,{actionType:"sanity.action.document.version.replace",document:n},s)}function rs(t,e,n,s,r){return E(t,e,{actionType:"sanity.action.document.version.unpublish",versionId:n,publishedId:s},r)}function is(t,e,n,s){let r;n instanceof H||n instanceof Q?r={patch:n.serialize()}:n instanceof Ze||n instanceof et?r=n.serialize():r=n;const i=Array.isArray(r)?r:[r],o=s&&s.transactionId||void 0;return ee(t,e,"mutate",{mutations:i,transactionId:o},s)}function E(t,e,n,s){const r=Array.isArray(n)?n:[n],i=s&&s.transactionId||void 0,o=s&&s.skipCrossDatasetReferenceValidation||void 0,a=s&&s.dryRun||void 0;return ee(t,e,"actions",{actions:r,transactionId:i,skipCrossDatasetReferenceValidation:o,dryRun:a},s)}function ee(t,e,n,s,r={}){const i=n==="mutate",o=n==="actions",a=n==="query",c=i||o?"":Fn(s),h=!i&&!o&&c.length<ki,p=h?c:"",u=r.returnFirst,{timeout:d,token:l,tag:f,headers:y,returnQuery:g,lastLiveEventId:w,cacheMode:$}=r,U=C(t,n,p),m={method:h?"GET":"POST",uri:U,json:!0,body:h?void 0:s,query:i&&Ti(r),timeout:d,headers:y,token:l,tag:f,returnQuery:g,perspective:r.perspective,resultSourceMap:r.resultSourceMap,lastLiveEventId:Array.isArray(w)?w[0]:w,cacheMode:$,canUseCdn:a,signal:r.signal,fetch:r.fetch,useAbortSignal:r.useAbortSignal,useCdn:r.useCdn};return ve(t,e,m).pipe(P(tt),T(xi),T(b=>{if(!i)return b;const S=b.results||[];if(r.returnDocuments)return u?S[0]&&S[0].document:S.map(R=>R.document);const _=u?"documentId":"documentIds",A=u?S[0]&&S[0].id:S.map(R=>R.id);return{transactionId:b.transactionId,results:S,[_]:A}}))}function nt(t,e,n,s,r={}){const i={[s]:n},o=Object.assign({returnFirst:!0,returnDocuments:!0},r);return ee(t,e,"mutate",{mutations:[i]},o)}const Re=t=>{const e=t.config();return e.dataset!==void 0&&e.projectId!==void 0||e.resource!==void 0},os=(t,e)=>Re(t)&&e.startsWith(C(t,"query")),Ci=(t,e)=>Re(t)&&e.startsWith(C(t,"mutate")),Ri=(t,e)=>Re(t)&&e.startsWith(C(t,"doc","")),ji=(t,e)=>Re(t)&&e.startsWith(C(t,"listen")),Mi=(t,e)=>Re(t)&&e.startsWith(C(t,"history","")),Oi=(t,e)=>e.startsWith("/data/")||os(t,e)||Ci(t,e)||Ri(t,e)||ji(t,e)||Mi(t,e);function ve(t,e,n){const s=new Error,r=n.url||n.uri,i=t.config(),o=typeof n.canUseCdn>"u"?["GET","HEAD"].indexOf(n.method||"GET")>=0&&Oi(t,r):n.canUseCdn;let a=(n.useCdn??i.useCdn)&&o;const c=n.tag&&i.requestTagPrefix?[i.requestTagPrefix,n.tag].join("."):n.tag||i.requestTagPrefix;if(c&&n.tag!==null&&(n.query={tag:Pn(c),...n.query}),["GET","HEAD","POST"].indexOf(n.method||"GET")>=0&&os(t,r)){const u=n.resultSourceMap??i.resultSourceMap;u!==void 0&&u!==!1&&(n.query={resultSourceMap:u,...n.query});const d=n.perspective||i.perspective;typeof d<"u"&&(d==="previewDrafts"&&oi(),$t(d),n.query={perspective:Array.isArray(d)?d.join(","):d,...n.query},(Array.isArray(d)&&d.length>0||d==="previewDrafts"||d==="drafts")&&a&&(a=!1,ii())),n.lastLiveEventId&&(n.query={...n.query,lastLiveEventId:n.lastLiveEventId}),n.returnQuery===!1&&(n.query={returnQuery:"false",...n.query}),a&&n.cacheMode=="noStale"&&(n.query={cacheMode:"noStale",...n.query})}const h=Ii(i,Object.assign({},n,{url:Tt(t,r,a),callSiteStack:s})),p=new X(u=>e(h,i.requester).subscribe(u));
14return n.signal?p.pipe(qi(n.signal)):p}function I(t,e,n){return ve(t,e,n).pipe(P(s=>s.type==="response"),T(s=>s.body))}function C(t,e,n){const s=t.config();if(s.resource){Ln(s);const o=Li(s),a=n!==void 0?`${e}/${n}`:e;return`${o}/${a}`.replace(/\/($|\?)/,"$1")}const r=Z(s),i=`/${e}/${r}`;return`/data${n!==void 0?`${i}/${n}`:i}`.replace(/\/($|\?)/,"$1")}function Tt(t,e,n=!1){const{url:s,cdnUrl:r}=t.config();return`${n?r:s}/${e.replace(/^\//,"")}`}function qi(t){return e=>new X(n=>{const s=()=>n.error(Pi(t));if(t&&t.aborted){s();return}const r=e.subscribe(n);return t.addEventListener("abort",s),()=>{t.removeEventListener("abort",s),r.unsubscribe()}})}const Di=!!globalThis.DOMException;function Pi(t){if(Di)return new DOMException(t?.reason??"The operation was aborted.","AbortError");const e=new Error(t?.reason??"The operation was aborted.");return e.name="AbortError",e}const Li=t=>{const e=t.resource;if(!e)throw new Error("`resource` must be provided to perform resource queries");const{type:n,id:s}=e;switch(n){case"dataset":{const r=s.split(".");if(r.length!==2)throw new Error('Dataset ID must be in the format "project.dataset"');return`/projects/${r[0]}/datasets/${r[1]}`}case"canvas":return`/canvases/${s}`;case"media-library":return`/media-libraries/${s}`;case"dashboard":return`/dashboards/${s}`;default:throw new Error(`Unsupported resource type: ${n.toString()}`)}};function as(t,e,n){const s=Z(t.config());return I(t,e,{method:"POST",uri:`/agent/action/generate/${s}`,body:n})}function Ui(t,e,n){const s=Z(t.config());return I(t,e,{method:"POST",uri:`/agent/action/patch/${s}`,body:n})}function Vi(t,e,n){const s=Z(t.config());return I(t,e,{method:"POST",uri:`/agent/action/prompt/${s}`,body:n})}function cs(t,e,n){const s=Z(t.config());return I(t,e,{method:"POST",uri:`/agent/action/transform/${s}`,body:n})}function us(t,e,n){const s=Z(t.config());return I(t,e,{method:"POST",uri:`/agent/action/translate/${s}`,body:n})}class Wi{#e;#t;constructor(e,n){this.#e=e,this.#t=n}generate(e){return as(this.#e,this.#t,e)}transform(e){return cs(this.#e,this.#t,e)}translate(e){return us(this.#e,this.#t,e)}}class Hi{#e;#t;constructor(e,n){this.#e=e,this.#t=n}generate(e){return v(as(this.#e,this.#t,e))}transform(e){return v(cs(this.#e,this.#t,e))}translate(e){return v(us(this.#e,this.#t,e))}prompt(e){return v(Vi(this.#e,this.#t,e))}patch(e){return v(Ui(this.#e,this.#t,e))}}class Ni{#e;#t;constructor(e,n){this.#e=e,this.#t=n}upload(e,n,s){return ds(this.#e,this.#t,e,n,s)}}class zi{#e;#t;constructor(e,n){this.#e=e,this.#t=n}upload(e,n,s){const r=ds(this.#e,this.#t,e,n,s);return v(r.pipe(P(i=>i.type==="response"),T(i=>i.body.document)))}}function ds(t,e,n,s,r={}){Xr(n);let i=r.extract||void 0;i&&!i.length&&(i=["none"]);const o=t.config(),a=Fi(r,s),{tag:c,label:h,title:p,description:u,creditLine:d,filename:l,source:f}=a,y=o.resource?.type==="media-library",g=y?{title:p,filename:l}:{label:h,title:p,description:u,filename:l,meta:i,creditLine:d};return f&&!y&&(g.sourceId=f.id,g.sourceName=f.name,g.sourceUrl=f.url),ve(t,e,{tag:c,method:"POST",timeout:a.timeout||0,uri:Bi(o,n),headers:a.contentType?{"Content-Type":a.contentType}:{},query:g,body:s})}function Bi(t,e){const n=e==="image"?"images":"files",s=t.resource;if(s){const{type:i,id:o}=s;switch(i){case"dataset":throw new Error("Assets are not supported for dataset resources, yet. Configure the client with `{projectId: <projectId>, dataset: <datasetId>}` instead.");case"canvas":return`/canvases/${o}/assets/${n}`;case"media-library":return`/media-libraries/${o}/upload`;case"dashboard":return`/dashboards/${o}/assets/${n}`;default:throw new Error(`Unsupported resource type: ${i.toString()}`)}}const r=Z(t);return`assets/${n}/${r}`}function Fi(t,e){return typeof File>"u"||!(e instanceof File)?t:Object.assign({filename:t.preserveFilename===!1?void 0:e.name,contentType:e.type},t)}var Gi=(t,e)=>Object.keys(e).concat(Object.keys(t)).reduce((n,s)=>(n[s]=typeof t[s]>"u"?e[s]:t[s],n),{});const Ji=(t,e)=>e.reduce((n,s)=>(typeof t[s]>"u"||(n[s]=t[s]),n),{}),hs=_t(()=>bn(()=>import("./JhxboH1M.js").then(t=>t.b),__vite__mapDeps([0,1]),import.meta.url)).pipe(T(({default:t})=>t),nr(1));function ls(){return function(t){return t.pipe($n((e,n)=>e instanceof Vn?hr(J({type:"reconnect"}),lr(1e3).pipe(N(()=>n))):Et(()=>e)))}}const Qi=14800,Ki=["includePreviousRevision","includeResult","includeMutations","includeAllVersions","visibility","effectFormat","enableResume","tag"],Yi={includeResult:!0};function fs(t,e,n={}){const{url:s,token:r,withCredentials:i,requestTagPrefix:o,headers:a}=this.config(),c=n.tag&&o?[o,n.tag].join("."):n.tag,h={...Gi(n,Yi),tag:c},p=Ji(h,Ki),u=Fn({query:t,params:e,options:{tag:c,...p}}),d=`${s}${C(this,"listen",u)}`;if(d.length>Qi)return Et(()=>new Error("Query too large for listener"));const l=h.events?h.events:["mutation"],f={};return i&&(f.withCredentials=!0),(r||a)&&(f.headers={},r&&(f.headers.Authorization=`Bearer ${r}`),a&&Object.assign(f.headers,a)),Wn(()=>(typeof EventSource>"u"||f.headers?hs:J(EventSource)).pipe(T(y=>new y(d,f))),l).pipe(ls(),P(y=>l.includes(y.type)),T(y=>({type:y.type,..."data"in y?y.data:{}})))}function Xi(t,e){return Zi(typeof t=="function"?{predicate:t,...e}:t)}function Zi(t){return e=>{let n,s=!1;const{predicate:r,...i}=t,o=e.pipe(fr(c=>{t.predicate(c)&&(s=!0,n=c)}),Tn(()=>{s=!1,n=void 0}),pr(i)),a=new X(c=>{s&&c.next(n),c.complete()});return yr(o,a)}}const Xt="2021-03-25";class ps{#e;constructor(e){this.#e=e}events({includeDrafts:e=!1,tag:n,waitFor:s}={}
14){const{projectId:r,apiVersion:i,token:o,withCredentials:a,requestTagPrefix:c,headers:h}=this.#e.config(),p=i.replace(/^v/,"");if(p!=="X"&&p<Xt)throw new Error(`The live events API requires API version ${Xt} or later. The current API version is ${p}. Please update your API version to use this feature.`);if(e&&!o&&!a)throw new Error("The live events API requires a token or withCredentials when 'includeDrafts: true'. Please update your client configuration. The token should have the lowest possible access role.");const u=C(this.#e,"live/events"),d=new URL(this.#e.getUrl(u,!1)),l=n&&c?[c,n].join("."):n;l&&d.searchParams.set("tag",l),e&&d.searchParams.set("includeDrafts","true"),s&&d.searchParams.set("waitFor",s);const f={};e&&a&&(f.withCredentials=!0),(e&&o||h)&&(f.headers={},e&&o&&(f.headers.Authorization=`Bearer ${o}`),h&&Object.assign(f.headers,h));const y=`${d.href}::${JSON.stringify(f)}`,g=dt.get(y);if(g)return g;const w=Wn(()=>(typeof EventSource>"u"||f.headers?hs:J(EventSource)).pipe(T(m=>new m(d.href,f))),["message","restart","welcome","reconnect","goaway"]),$=eo(new URL(this.#e.getUrl("/check/cors",!1)),r,f.withCredentials===!0),U=w.pipe(ls(),N(m=>m.type==="reconnect"?$.pipe(N(()=>J(m))):J(m)),$n(m=>m instanceof yt?Et(()=>m):$.pipe(N(()=>{throw m}))),T(m=>{if(m.type==="message"){const{data:b,...S}=m;return{...S,tags:b.tags}}return m})).pipe(Tn(()=>dt.delete(y)),Xi({predicate:m=>m.type==="welcome"}));return dt.set(y,U),U}}function eo(t,e,n){return new X(s=>{const r=new AbortController,{signal:i}=r;return fetch(t,{method:"GET",mode:"cors",credentials:"omit",signal:i}).then(o=>{if(!(i.aborted||!o.ok))return o.json()}).then(o=>{if(!i.aborted){if(n&&o?.result?.withCredentials===!1){s.error(new yt({projectId:e,credentials:!0}));return}if(o?.result?.allowed===!1){s.error(new yt({projectId:e,credentials:n}));return}s.next(),s.complete()}}).catch(()=>{i.aborted||s.closed||(s.next(),s.complete())}),()=>r.abort()})}const dt=new Map;class to{#e;#t;constructor(e,n){this.#e=e,this.#t=n}create(e,n){return ae(this.#e,this.#t,"PUT",e,n)}edit(e,n){return ae(this.#e,this.#t,"PATCH",e,n)}delete(e){return ae(this.#e,this.#t,"DELETE",e)}list(){O("dataset",this.#e.config());const e=this.#e.config(),n=e.projectId;let s="/datasets";return e.useProjectHostname===!1&&(s=`/projects/${n}/datasets`),I(this.#e,this.#t,{uri:s,tag:null})}getEmbeddingsSettings(e){return O("dataset",this.#e.config()),le(e),I(this.#e,this.#t,{uri:Ve(this.#e,e),tag:null})}editEmbeddingsSettings(e,n){return O("dataset",this.#e.config()),le(e),I(this.#e,this.#t,{method:"PUT",uri:Ve(this.#e,e),body:n,tag:null})}}class no{#e;#t;constructor(e,n){this.#e=e,this.#t=n}create(e,n){return O("dataset",this.#e.config()),v(ae(this.#e,this.#t,"PUT",e,n))}edit(e,n){return O("dataset",this.#e.config()),v(ae(this.#e,this.#t,"PATCH",e,n))}delete(e){return O("dataset",this.#e.config()),v(ae(this.#e,this.#t,"DELETE",e))}list(){O("dataset",this.#e.config());const e=this.#e.config(),n=e.projectId;let s="/datasets";return e.useProjectHostname===!1&&(s=`/projects/${n}/datasets`),v(I(this.#e,this.#t,{uri:s,tag:null}))}getEmbeddingsSettings(e){return O("dataset",this.#e.config()),le(e),v(I(this.#e,this.#t,{uri:Ve(this.#e,e),tag:null}))}editEmbeddingsSettings(e,n){return O("dataset",this.#e.config()),le(e),v(I(this.#e,this.#t,{method:"PUT",uri:Ve(this.#e,e),body:n,tag:null}))}}function Ve(t,e){const n=t.config();return n.useProjectHostname===!1?`/projects/${n.projectId}/datasets/${e}/settings/embeddings`:`/datasets/${e}/settings/embeddings`}function ae(t,e,n,s,r){return O("dataset",t.config()),le(s),I(t,e,{method:n,uri:`/datasets/${s}`,body:r,tag:null})}class ys{#e;#t;constructor(e,n){this.#e=e,this.#t=n}getPlaybackInfo(e,n={}){const s=this.#e.config(),r=(s.resource||s["~experimental_resource"])?.id,{instanceId:i,libraryId:o}=oo(e),a=o||r;if(!a)throw new Error("Could not determine Media Library ID - you need to provide a valid Media Library ID in the client config or a Media Library GDR");const c=ao(i,a),h=co(n);return I(this.#e,this.#t,{method:"GET",uri:c,query:h})}}class so{#e;#t;constructor(e,n){this.#e=e,this.#t=n}
14getPlaybackInfo(e,n={}){return v(new ys(this.#e.observable,this.#t).getPlaybackInfo(e,n))}}const ro=/^media-library:(ml[^:]+):([^:]+)$/;function io(t){return typeof t=="object"&&"_ref"in t}function oo(t){const e=io(t)?t._ref:t,n=ro.exec(e);if(n){const[,s,r]=n;return{libraryId:s,instanceId:r}}if(typeof t=="string"&&t.startsWith("video-"))return{instanceId:t};throw new Error(`Invalid video asset instance identifier "${e}": must be a valid video instance id or a Global Dataset Reference (GDR) to the video asset in the Media Library`)}function ao(t,e){return`/media-libraries/${e}/video/${t}/playback-info`}function co(t){const e={};if(t.transformations){const{thumbnail:n,animated:s,storyboard:r}=t.transformations;n&&(n.width&&(e.thumbnailWidth=n.width),n.height&&(e.thumbnailHeight=n.height),n.time!==void 0&&(e.thumbnailTime=n.time),n.fit&&(e.thumbnailFit=n.fit),n.format&&(e.thumbnailFormat=n.format)),s&&(s.width&&(e.animatedWidth=s.width),s.height&&(e.animatedHeight=s.height),s.start!==void 0&&(e.animatedStart=s.start),s.end!==void 0&&(e.animatedEnd=s.end),s.fps&&(e.animatedFps=s.fps),s.format&&(e.animatedFormat=s.format)),r&&r.format&&(e.storyboardFormat=r.format)}return t.expiration&&(e.expiration=t.expiration),e}class uo{#e;#t;constructor(e,n){this.#e=e,this.#t=n}list(e){const n={},s="/projects";return e?.includeMembers===!1&&(n.includeMembers="false"),e?.includeFeatures===!1&&(n.includeFeatures="false"),e?.organizationId&&(n.organizationId=e.organizationId),e?.onlyExplicitMembership&&(n.onlyExplicitMembership="true"),I(this.#e,this.#t,{uri:s,query:n})}getById(e){return I(this.#e,this.#t,{uri:`/projects/${e}`})}}class ho{#e;#t;constructor(e,n){this.#e=e,this.#t=n}list(e){const n={},s="/projects";return e?.includeMembers===!1&&(n.includeMembers="false"),e?.includeFeatures===!1&&(n.includeFeatures="false"),e?.organizationId&&(n.organizationId=e.organizationId),e?.onlyExplicitMembership&&(n.onlyExplicitMembership="true"),v(I(this.#e,this.#t,{uri:s,query:n}))}getById(e){return v(I(this.#e,this.#t,{uri:`/projects/${e}`}))}}const Zt=Pr("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789",8),We=(t,e)=>e?Ce(t,e):Cn(t);function He(t,{releaseId:e,publishedId:n,document:s}){if(n&&s._id){const r=We(n,e);return ei(r,s),r}if(s._id){const r=kn(s._id),i=ur(s._id);if(!r&&!i)throw new Error(`\`${t}()\` requires a document with an \`_id\` that is a version or draft ID`);if(e){if(r)throw new Error(`\`${t}()\` was called with a document ID (\`${s._id}\`) that is a draft ID, but a release ID (\`${e}\`) was also provided.`);const o=An(s._id);if(o!==e)throw new Error(`\`${t}()\` was called with a document ID (\`${s._id}\`) that is a version ID, but the release ID (\`${e}\`) does not match the document's version ID (\`${o}\`).`)}return s._id}if(n)return We(n,e);throw new Error(`\`${t}()\` requires either a publishedId or a document with an \`_id\``)}const lo=(t,e)=>{if(typeof t=="object"&&t!==null&&("releaseId"in t||"metadata"in t)){const{releaseId:n=Zt(),metadata:s={}}=t;return[n,s,e]}return[Zt(),{},t]},gs=(t,e)=>{const[n,s,r]=lo(t,e),i={...s,releaseType:s.releaseType||"undecided"};return{action:{actionType:"sanity.action.release.create",releaseId:n,metadata:i},options:r}};class fo{#e;#t;constructor(e,n){this.#e=e,this.#t=n}get({releaseId:e},n){return pe(this.#e,this.#t,`_.releases.${e}`,n)}create(e,n){const{action:s,options:r}=gs(e,n),{releaseId:i,metadata:o}=s;return E(this.#e,this.#t,s,r).pipe(T(a=>({...a,releaseId:i,metadata:o})))}edit({releaseId:e,patch:n},s){const r={actionType:"sanity.action.release.edit",releaseId:e,patch:n};return E(this.#e,this.#t,r,s)}publish({releaseId:e},n){const s={actionType:"sanity.action.release.publish",releaseId:e};return E(this.#e,this.#t,s,n)}archive({releaseId:e},n){const s={actionType:"sanity.action.release.archive",releaseId:e};return E(this.#e,this.#t,s,n)}unarchive({releaseId:e},n){const s={actionType:"sanity.action.release.unarchive",releaseId:e};return E(this.#e,this.#t,s,n)}schedule({releaseId:e,publishAt:n},s){const r={actionType:"sanity.action.release.schedule",releaseId:e,publishAt:n};return E(this.#e,this.#t,r,s)}unschedule({releaseId:e},n){const s={actionType:"sanity.action.release.unschedule",releaseId:e};return E(this.#e,this.#t,s,n)}delete({releaseId:e},n){const s={actionType:"sanity.action.release.delete",releaseId:e};return E(this.#e,this.#t,s,n)}fetchDocuments({releaseId:e},n){return Kn(this.#e,this.#t,e,n)}}class po{#e;#t;constructor(e,n){this.#e=e,this.#t=n}
14get({releaseId:e},n){return v(pe(this.#e,this.#t,`_.releases.${e}`,n))}async create(e,n){const{action:s,options:r}=gs(e,n),{releaseId:i,metadata:o}=s;return{...await v(E(this.#e,this.#t,s,r)),releaseId:i,metadata:o}}edit({releaseId:e,patch:n},s){const r={actionType:"sanity.action.release.edit",releaseId:e,patch:n};return v(E(this.#e,this.#t,r,s))}publish({releaseId:e},n){const s={actionType:"sanity.action.release.publish",releaseId:e};return v(E(this.#e,this.#t,s,n))}archive({releaseId:e},n){const s={actionType:"sanity.action.release.archive",releaseId:e};return v(E(this.#e,this.#t,s,n))}unarchive({releaseId:e},n){const s={actionType:"sanity.action.release.unarchive",releaseId:e};return v(E(this.#e,this.#t,s,n))}schedule({releaseId:e,publishAt:n},s){const r={actionType:"sanity.action.release.schedule",releaseId:e,publishAt:n};return v(E(this.#e,this.#t,r,s))}unschedule({releaseId:e},n){const s={actionType:"sanity.action.release.unschedule",releaseId:e};return v(E(this.#e,this.#t,s,n))}delete({releaseId:e},n){const s={actionType:"sanity.action.release.delete",releaseId:e};return v(E(this.#e,this.#t,s,n))}fetchDocuments({releaseId:e},n){return v(Kn(this.#e,this.#t,e,n))}}class yo{#e;#t;constructor(e,n){this.#e=e,this.#t=n}getById(e){return I(this.#e,this.#t,{uri:`/users/${e}`})}}class go{#e;#t;constructor(e,n){this.#e=e,this.#t=n}getById(e){return v(I(this.#e,this.#t,{uri:`/users/${e}`}))}}class Ne{assets;datasets;live;mediaLibrary;projects;users;agent;releases;#e;#t;#n;listen=fs;constructor(e,n=Se){this.config(n),this.#t=e;const s=n._requestHandler;this.#n=s?(()=>{let r;return(i,o)=>{const a=i;return r||(r=new ce(e,{...n,_requestHandler:void 0})),s(a,c=>e(c,o),r)}})():e,this.assets=new Ni(this,this.#n),this.datasets=new to(this,this.#n),this.live=new ps(this),this.mediaLibrary={video:new ys(this,this.#n)},this.projects=new uo(this,this.#n),this.users=new yo(this,this.#n),this.agent={action:new Wi(this,this.#n)},this.releases=new fo(this,this.#n)}clone(){return new Ne(this.#t,this.config())}config(e){if(e===void 0)return{...this.#e};if(this.#e&&this.#e.allowReconfigure===!1)throw new Error("Existing client instance cannot be reconfigured - use `withConfig(newConfig)` to return a new client");return this.#e=Un(e,this.#e||{}),this}withConfig(e){const n=this.config();return new Ne(this.#t,{...n,...e,stega:{...n.stega||{},...typeof e?.stega=="boolean"?{enabled:e.stega}:e?.stega||{}}})}fetch(e,n,s){return Gn(this,this.#n,this.#e.stega,e,n,s)}getDocument(e,n){if(n?.includeAllVersions===!0)return pe(this,this.#n,e,{...n,includeAllVersions:!0});const s={signal:n?.signal,tag:n?.tag,releaseId:n?.releaseId,...n&&"includeAllVersions"in n?{includeAllVersions:!1}:{}};return pe(this,this.#n,e,s)}getDocuments(e,n){return Jn(this,this.#n,e,n)}documentsExists(e,n){return Qn(this,this.#n,e,n)}create(e,n){return nt(this,this.#n,e,"create",n)}createIfNotExists(e,n){return Yn(this,this.#n,e,n)}createOrReplace(e,n){return Xn(this,this.#n,e,n)}createVersion({document:e,publishedId:n,releaseId:s,baseId:r,ifBaseRevisionId:i},o){if(!e)return es(this,this.#n,n,r,s,i,o);const a=He("createVersion",{document:e,publishedId:n,releaseId:s}),c={...e,_id:a},h=n||In(e._id);return Zn(this,this.#n,c,h,o)}delete(e,n){return ts(this,this.#n,e,n)}discardVersion({releaseId:e,publishedId:n},s,r){const i=We(n,e);return ns(this,this.#n,i,s,r)}replaceVersion({document:e,publishedId:n,releaseId:s},r){const i=He("replaceVersion",{document:e,publishedId:n,releaseId:s}),o={...e,_id:i};return ss(this,this.#n,o,r)}unpublishVersion({releaseId:e,publishedId:n},s){const r=Ce(n,e);return rs(this,this.#n,r,n,s)}mutate(e,n){return is(this,this.#n,e,n)}patch(e,n){return new Q(e,n,this)}transaction(e){return new et(e,this)}action(e,n){return E(this,this.#n,e,n)}request(e){return I(this,this.#n,e)}getUrl(e,n){return Tt(this,e,n)}getDataUrl(e,n){return C(this,e,n)}}class ce{assets;datasets;live;mediaLibrary;projects;users;agent;releases;observable;#e;#t;#n;listen=fs;constructor(e,n=Se){this.config(n),this.#t=e;const s=n._requestHandler;this.#n=s?(()=>{let r;return(i,o)=>{const a=i;return r||(r=new ce(e,{...n,_requestHandler:void 0})),s(a,c=>e(c,o),r)}})():e,this.assets=new zi(this,this.#n),this.datasets=new no(this,this.#n),this.live=new ps(this),this.mediaLibrary={video:new so(this,this.#n)},this.projects=new ho(this,this.#n),this.users=new go(this,this.#n),this.agent={action:new Hi(this,this.#n)},this.releases=new po(this,this.#n),this.observable=new Ne(e,n)}clone(){return new ce(this.#t,this.config())}config(e){if(e===void 0)return{...this.#e};if(this.#e&&this.#e.allowReconfigure===!1)throw new Error("Existing client instance cannot be reconfigured - use `withConfig(newConfig)` to return a new client");return this.observable&&this.observable.config(e),this.#e=Un(e,this.#e||{}),this}withConfig(e){const n=this.config();return new ce(this.#t,{...n,...e,stega:{...n.stega||{},...typeof e?.stega=="boolean"?{enabled:e.stega}:e?.stega||{}}})}fetch(e,n,s){return v(Gn(this,this.#n,this.#e.stega,e,n,s))}getDocument(e,n){if(n?.includeAllVersions===!0)return v(pe(this,this.#n,e,{...n,includeAllVersions:!0}));const s={signal:n?.signal,tag:n?.tag,releaseId:n?.releaseId,...n&&"includeAllVersions"in n?{includeAllVersions:!1}:{}};return v(pe(this,this.#n,e,s))}getDocuments(e,n){return v(Jn(this,this.#n,e,n))}
14documentsExists(e,n){return v(Qn(this,this.#n,e,n))}create(e,n){return v(nt(this,this.#n,e,"create",n))}createIfNotExists(e,n){return v(Yn(this,this.#n,e,n))}createOrReplace(e,n){return v(Xn(this,this.#n,e,n))}createVersion({document:e,publishedId:n,releaseId:s,baseId:r,ifBaseRevisionId:i},o){if(!e)return at(es(this,this.#n,n,r,s,i,o));const a=He("createVersion",{document:e,publishedId:n,releaseId:s}),c={...e,_id:a},h=n||In(e._id);return at(Zn(this,this.#n,c,h,o))}delete(e,n){return v(ts(this,this.#n,e,n))}discardVersion({releaseId:e,publishedId:n},s,r){const i=We(n,e);return v(ns(this,this.#n,i,s,r))}replaceVersion({document:e,publishedId:n,releaseId:s},r){const i=He("replaceVersion",{document:e,publishedId:n,releaseId:s}),o={...e,_id:i};return at(ss(this,this.#n,o,r))}unpublishVersion({releaseId:e,publishedId:n},s){const r=Ce(n,e);return v(rs(this,this.#n,r,n,s))}mutate(e,n){return v(is(this,this.#n,e,n))}patch(e,n){return new H(e,n,this)}transaction(e){return new Ze(e,this)}action(e,n){return v(E(this,this.#n,e,n))}request(e){return v(I(this,this.#n,e))}dataRequest(e,n,s){return v(ee(this,this.#n,e,n,s))}getUrl(e,n){return Tt(this,e,n)}getDataUrl(e,n){return C(this,e,n)}}function mo(t,e){return{requester:Ft(t),createClient:n=>{const s=Ft(t,{ignoreWarnings:n.ignoreWarnings});return new e((r,i)=>(i||s)({maxRedirects:0,maxRetries:n.maxRetries,retryDelay:n.retryDelay,lineage:n.lineage,...r}),n)}}}var vo=[];mo(vo,ce);const ms=/_key\s*==\s*['"](.*)['"]/;function wo(t){return typeof t=="string"?ms.test(t.trim()):typeof t=="object"&&"_key"in t}function vs(t){if(!Array.isArray(t))throw new Error("Path is not an array");return t.reduce((e,n,s)=>{const r=typeof n;if(r==="number")return`${e}[${n}]`;if(r==="string")return`${e}${s===0?"":"."}${n}`;if(wo(n)&&n._key)return`${e}[_key=="${n._key}"]`;if(Array.isArray(n)){const[i,o]=n;return`${e}[${i}:${o}]`}throw new Error(`Unsupported path segment \`${JSON.stringify(n)}\``)},"")}const ze={"\f":"\\f","\n":"\\n","\r":"\\r"," ":"\\t","'":"\\'","\\":"\\\\"},en={"\\f":"\f","\\n":` 15`,"\\r":"\r","\\t":" ","\\'":"'","\\\\":"\\"};function bo(t){return`$${t.map(e=>typeof e=="string"?`['${e.replace(/[\f\n\r\t'\\]/g,n=>ze[n])}']`:typeof e=="number"?`[${e}]`:e._key!==""?`[?(@._key=='${e._key.replace(/['\\]/g,n=>ze[n])}')]`:`[${e._index}]`).join("")}`}function _o(t){return t.map(e=>typeof e=="string"?`['${e.replace(/[\f\n\r\t'\\]/g,n=>ze[n])}']`:typeof e=="number"?`[${e}]`:e._key!==""?`[?(@._key=='${e._key.replace(/['\\]/g,n=>ze[n])}')]`:`[${e._index}]`)}function tn(t){const e=[],n=/\['(.*?)'\]|\[(\d+)\]|\[\?\(@\._key=='(.*?)'\)\]/g;let s;for(;(s=n.exec(t))!==null;){if(s[1]!==void 0){const r=s[1].replace(/\\(\\|f|n|r|t|')/g,i=>en[i]);e.push(r);continue}if(s[2]!==void 0){e.push(parseInt(s[2],10));continue}if(s[3]!==void 0){const r=s[3].replace(/\\(\\')/g,i=>en[i]);e.push({_key:r,_index:-1});continue}}return e}function ws(t){return t.map(e=>{if(typeof e=="string"||typeof e=="number")return e;if(e._key!=="")return{_key:e._key};if(e._index!==-1)return e._index;throw new Error(`invalid segment:${JSON.stringify(e)}`)})}function nn(t){return t.map(e=>{if(typeof e=="string"||typeof e=="number")return e;if(e._index!==-1)return e._index;throw new Error(`invalid segment:${JSON.stringify(e)}`)})}function Eo(t,e){if(!e?.mappings)return;const n=bo(nn(t));if(e.mappings[n]!==void 0)return{mapping:e.mappings[n],matchedPath:n,pathSuffix:""};const s=_o(nn(t));for(let r=s.length-1;r>=0;r--){const i=`$${s.slice(0,r).join("")}`,o=e.mappings[i];if(o){const a=n.substring(i.length);return{mapping:o,matchedPath:i,pathSuffix:a}}}}function So(t){return t!==null&&Array.isArray(t)}function ne(t,e,n=[]){if(So(t))return t.map((s,r)=>{if(Le(s)){const i=s._key;if(typeof i=="string")return ne(s,e,n.concat({_key:i,_index:r}))}return ne(s,e,n.concat(r))});if(Le(t)){if(t._type==="block"||t._type==="span"){const s={...t};return t._type==="block"?s.children=ne(t.children,e,n.concat("children")):t._type==="span"&&(s.text=ne(t.text,e,n.concat("text"))),s}return Object.fromEntries(Object.entries(t).map(([s,r])=>[s,ne(r,e,n.concat(s))]))}return e(t,n)}function bs(t,e,n){return ne(t,(s,r)=>
15{if(typeof s!="string")return s;const i=Eo(r,e);if(!i)return s;const{mapping:o,matchedPath:a}=i;if(o.type!=="value"||o.source.type!=="documentValue")return s;const c=e.documents[o.source.document],h=e.paths[o.source.path],p=tn(a),u=tn(h).concat(r.slice(p.length));return n({sourcePath:u,sourceDocument:c,resultPath:r,value:s})})}const Io="drafts",$o="versions",Ae=".",_s=`${Io}${Ae}`,To=`${$o}${Ae}`;function Es(t){return t.startsWith(_s)}function st(t){return t.startsWith(To)}function xo(t){return!Es(t)&&!st(t)}function Ao(t){if(!st(t))return;const[e,n]=t.split(Ae);return n}function ko(t){return st(t)?t.split(Ae).slice(2).join(Ae):Es(t)?t.slice(_s.length):t}function Co(t){const{baseUrl:e,workspace:n="default",tool:s="default",id:r,type:i,path:o,projectId:a,dataset:c}=t;if(!e)throw new Error("baseUrl is required");if(!o)throw new Error("path is required");if(!r)throw new Error("id is required");if(e!=="/"&&e.endsWith("/"))throw new Error("baseUrl must not end with a slash");const h=n==="default"?void 0:n,p=s==="default"?void 0:s,u=ko(r),d=Array.isArray(o)?vs(ws(o)):o,l=new URLSearchParams({baseUrl:e,id:u,type:i,path:d});if(h&&l.set("workspace",h),p&&l.set("tool",p),a&&l.set("projectId",a),c&&l.set("dataset",c),xo(r))l.set("perspective","published");else if(st(r)){const g=Ao(r);l.set("perspective",g)}const f=[e==="/"?"":e];h&&f.push(h);const y=["mode=presentation",`id=${u}`,`type=${i}`,`path=${encodeURIComponent(d)}`];return p&&y.push(`tool=${p}`),f.push("intent","edit",`${y.join(";")}?${l}`),f.join("/")}function Ro(t){let e=typeof t=="string"?t:t.baseUrl;return e!=="/"&&(e=e.replace(/\/$/,"")),typeof t=="string"?{baseUrl:e}:{...t,baseUrl:e}}const sn=({sourcePath:t,resultPath:e,value:n})=>{if(Mo(n)||qo(n))return!1;const s=t.at(-1);return!(t.at(-2)==="slug"&&s==="current"||typeof s=="string"&&(s.startsWith("_")||s.endsWith("Id"))||t.some(r=>r==="meta"||r==="metadata"||r==="openGraph"||r==="seo")||rn(t)||rn(e)||typeof s=="string"&&jo.has(s))},jo=new Set(["color","colour","currency","email","format","gid","hex","href","hsl","hsla","icon","id","index","key","language","layout","link","linkAction","locale","lqip","page","path","ref","rgb","rgba","route","secret","slug","status","tag","template","theme","type","textTheme","unit","url","username","variant","website"]);function Mo(t){return/^\d{4}-\d{2}-\d{2}/.test(t)?!!Date.parse(t):!1}const Oo=new Set(["app:","data:","discord:","file:","ftp:","ftps:","geo:","http:","https:","imap:","javascript:","magnet:","mailto:","maps:","ms-excel:","ms-powerpoint:","ms-word:","slack:","sms:","spotify:","steam:","teams:","tel:","vscode:","zoom:"]);function qo(t){try{const{protocol:e}=new URL(t,t.startsWith("/")?"https://acme.com":void 0);return Oo.has(e)||e.startsWith("web+")}catch{return!1}}function rn(t){return t.some(e=>typeof e=="string"&&e.match(/type/i)!==null)}const qe=20;function xt(t,e,n){const{filter:s,logger:r,enabled:i}=n;if(!i){const c="config.enabled must be true, don't call this function otherwise";throw r?.error?.(`[@sanity/client]: ${c}`,{result:t,resultSourceMap:e,config:n}),new TypeError(c)}if(!e)return r?.error?.("[@sanity/client]: Missing Content Source Map from response body",{result:t,resultSourceMap:e,config:n}),t;if(!n.studioUrl){const c="config.studioUrl must be defined";throw r?.error?.(`[@sanity/client]: ${c}`,{result:t,resultSourceMap:e,config:n}),new TypeError(c)}const o={encoded:[],skipped:[]},a=bs(t,e,({sourcePath:c,sourceDocument:h,resultPath:p,value:u})=>{if((typeof s=="function"?s({sourcePath:c,resultPath:p,filterDefault:sn,sourceDocument:h,value:u}):sn({sourcePath:c,resultPath:p,value:u}))===!1)return r&&o.skipped.push({path:on(c),value:`${u.slice(0,qe)}${u.length>qe?"...":""}`,length:u.length}),u;r&&o.encoded.push({path:on(c),value:`${u.slice(0,qe)}${u.length>qe?"...":""}`,length:u.length});const{baseUrl:d,workspace:l,tool:f}=Ro(typeof n.studioUrl=="function"?n.studioUrl(h):n.studioUrl);if(!d)return u;const{_id:y,_type:g,_projectId:w,_dataset:$}=h;return Cr(u,{origin:"sanity.io",href:Co({baseUrl:d,workspace:l,tool:f,id:y,type:g,path:c,...!n.omitCrossDatasetReferenceData&&{dataset:$,projectId:w}})},!1)});if(r){const c=o.skipped.length,h=o.encoded.length;if((c||h)&&((r?.groupCollapsed||r.log)?.("[@sanity/client]: Encoding source map into result"),r.log?.(`[@sanity/client]: Paths encoded: ${o.encoded.length}, skipped: ${o.skipped.length}`)),o.encoded.length>0&&(r?.log?.("[@sanity/client]: Table of encoded paths"),(r?.table||r.log)?.(o.encoded)),o.skipped.length>0){const p=new Set;for(const{path:u}of o.skipped)p.add(u.replace(ms,"0").replace(/\[\d+\]/g,"[]"));r?.log?.("[@sanity/client]: List of skipped paths",[...p.values()])}(c||h)&&r?.groupEnd?.()}return a}function on(t){return vs(ws(t))}var Do=Object.freeze({__proto__:null,stegaEncodeSourceMap:xt});const Po=Object.freeze(Object.defineProperty({__proto__:null,encodeIntoResult:bs,stegaEncodeSourceMap:xt,stegaEncodeSourceMap$1:Do},Symbol.toStringTag,{value:"Module"})),x=[];for(let t=0;t<256;++t)x.push((t+256).toString(16).slice(1));function Lo(t,e=0){return(x[t[e+0]]+x[t[e+1]]+x[t[e+2]]+x[t[e+3]]+"-"+x[t[e+4]]+x[t[e+5]]+"-"+x[t[e+6]]+x[t[e+7]]+"-"+x[t[e+8]]+x[t[e+9]]+"-"+x[t[e+10]]+x[t[e+11]]+x[t[e+12]]+x[t[e+13]]+x[t[e+14]]+x[t[e+15]]).toLowerCase()}let ht;const Uo=new Uint8Array(16);
15function Vo(){if(!ht){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");ht=crypto.getRandomValues.bind(crypto)}return ht(Uo)}const Wo=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),an={randomUUID:Wo};function Ho(t,e,n){t=t||{};const s=t.random??t.rng?.()??Vo();if(s.length<16)throw new Error("Random bytes length must be >= 16");return s[6]=s[6]&15|64,s[8]=s[8]&63|128,Lo(s)}function Ss(t,e,n){return an.randomUUID&&!t?an.randomUUID():Ho(t)}function No(){if(typeof globalThis<"u")return globalThis;if(typeof self<"u")return self;if(typeof window<"u")return window;if(typeof global<"u")return global}function zo(){const t=No();if(t.__xstate__)return t.__xstate__}const Bo=t=>{if(typeof window>"u")return;const e=zo();e&&e.register(t)};class cn{constructor(e){this._process=e,this._active=!1,this._current=null,this._last=null}start(){this._active=!0,this.flush()}clear(){this._current&&(this._current.next=null,this._last=this._current)}enqueue(e){const n={value:e,next:null};if(this._current){this._last.next=n,this._last=n;return}this._current=n,this._last=n,this._active&&this.flush()}flush(){for(;this._current;){const e=this._current;this._process(e.value),this._current=e.next}this._last=null}}const Is=".",Fo="",$s="",Go="#",Jo="*",Ts="xstate.init",Qo="xstate.error",Be="xstate.stop";function Ko(t,e){return{type:`xstate.after.${t}.${e}`}}function gt(t,e){return{type:`xstate.done.state.${t}`,output:e}}function Yo(t,e){return{type:`xstate.done.actor.${t}`,output:e,actorId:t}}function xs(t,e){return{type:`xstate.error.actor.${t}`,error:e,actorId:t}}function As(t){return{type:Ts,input:t}}function M(t){setTimeout(()=>{throw t})}const Xo=typeof Symbol=="function"&&Symbol.observable||"@@observable";function ks(t,e){const n=un(t),s=un(e);return typeof s=="string"?typeof n=="string"?s===n:!1:typeof n=="string"?n in s:Object.keys(n).every(r=>r in s?ks(n[r],s[r]):!1)}function At(t){if(Rs(t))return t;const e=[];let n="";for(let s=0;s<t.length;s++){switch(t.charCodeAt(s)){case 92:n+=t[s+1],s++;continue;case 46:e.push(n),n="";continue}n+=t[s]}return e.push(n),e}function un(t){if(Oa(t))return t.value;if(typeof t!="string")return t;const e=At(t);return Zo(e)}function Zo(t){if(t.length===1)return t[0];const e={};let n=e;for(let s=0;s<t.length-1;s++)if(s===t.length-2)n[t[s]]=t[s+1];else{const r=n;n={},r[t[s]]=n}return e}function dn(t,e){const n={},s=Object.keys(t);for(let r=0;r<s.length;r++){const i=s[r];n[i]=e(t[i],i,t,r)}return n}function Cs(t){return Rs(t)?t:[t]}function D(t){return t===void 0?[]:Cs(t)}function mt(t,e,n,s){return typeof t=="function"?t({context:e,event:n,self:s}):t}function Rs(t){return Array.isArray(t)}function ea(t){return t.type.startsWith("xstate.error.actor")}function se(t){return Cs(t).map(e=>typeof e>"u"||typeof e=="string"?{target:e}:e)}function js(t){if(!(t===void 0||t===Fo))return D(t)}function De(t,e,n){const s=typeof t=="object",r=s?t:void 0;return{next:(s?t.next:t)?.bind(r),error:(s?t.error:e)?.bind(r),complete:(s?t.complete:n)?.bind(r)}}function hn(t,e){return`${e}.${t}`}function kt(t,e){const n=e.match(/^xstate\.invoke\.(\d+)\.(.*)/);if(!n)return t.implementations.actors[e];const[,s,r]=n,o=t.getStateNodeById(r).config.invoke;return(Array.isArray(o)?o[s]:o).src}function Ms(t,e){if(e===t||e===Jo)return!0;if(!e.endsWith(".*"))return!1;const n=e.split("."),s=t.split(".");for(let r=0;r<n.length;r++){const i=n[r],o=s[r];if(i==="*")return r===n.length-1;if(i!==o)return!1}return!0}function ln(t,e){return`${t.sessionId}.${e}`}let ta=0;function na(t,e){const n=new Map,s=new Map,r=new WeakMap,i=new Set,o={},{clock:a,logger:c}=e,h={schedule:(d,l,f,y,g=Math.random().toString(36).slice(2))=>{const w={source:d,target:l,event:f,delay:y,id:g,startedAt:Date.now()},$=ln(d,g);u._snapshot._scheduledEvents[$]=w;const U=a.setTimeout(()=>{delete o[$],delete u._snapshot._scheduledEvents[$],u._relay(d,l,f)},y);o[$]=U},cancel:(d,l)=>{const f=ln(d,l),y=o[f];delete o[f],delete u._snapshot._scheduledEvents[f],y!==void 0&&a.clearTimeout(y)}
15,cancelAll:d=>{for(const l in u._snapshot._scheduledEvents){const f=u._snapshot._scheduledEvents[l];f.source===d&&h.cancel(d,f.id)}}},p=d=>{if(!i.size)return;const l={...d,rootId:t.sessionId};i.forEach(f=>f.next?.(l))},u={_snapshot:{_scheduledEvents:(e?.snapshot&&e.snapshot.scheduler)??{}},_bookId:()=>`x:${ta++}`,_register:(d,l)=>(n.set(d,l),d),_unregister:d=>{n.delete(d.sessionId);const l=r.get(d);l!==void 0&&(s.delete(l),r.delete(d))},get:d=>s.get(d),getAll:()=>Object.fromEntries(s.entries()),_set:(d,l)=>{const f=s.get(d);if(f&&f!==l)throw new Error(`Actor with system ID '${d}' already exists.`);s.set(d,l),r.set(l,d)},inspect:d=>{const l=De(d);return i.add(l),{unsubscribe(){i.delete(l)}}},_sendInspectionEvent:p,_relay:(d,l,f)=>{u._sendInspectionEvent({type:"@xstate.event",sourceRef:d,actorRef:l,event:f}),l._send(f)},scheduler:h,getSnapshot:()=>({_scheduledEvents:{...u._snapshot._scheduledEvents}}),start:()=>{const d=u._snapshot._scheduledEvents;u._snapshot._scheduledEvents={};for(const l in d){const{source:f,target:y,event:g,delay:w,id:$}=d[l];h.schedule(f,y,g,w,$)}},_clock:a,_logger:c};return u}let lt=!1;const Ct=1;let k=(function(t){return t[t.NotStarted=0]="NotStarted",t[t.Running=1]="Running",t[t.Stopped=2]="Stopped",t})({});const sa={clock:{setTimeout:(t,e)=>setTimeout(t,e),clearTimeout:t=>clearTimeout(t)},logger:console.log.bind(console),devTools:!1};class ra{constructor(e,n){this.logic=e,this._snapshot=void 0,this.clock=void 0,this.options=void 0,this.id=void 0,this.mailbox=new cn(this._process.bind(this)),this.observers=new Set,this.eventListeners=new Map,this.logger=void 0,this._processingStatus=k.NotStarted,this._parent=void 0,this._syncSnapshot=void 0,this.ref=void 0,this._actorScope=void 0,this.systemId=void 0,this.sessionId=void 0,this.system=void 0,this._doneEvent=void 0,this.src=void 0,this._deferred=[];const s={...sa,...n},{clock:r,logger:i,parent:o,syncSnapshot:a,id:c,systemId:h,inspect:p}=s;this.system=o?o.system:na(this,{clock:r,logger:i}),p&&!o&&this.system.inspect(De(p)),this.sessionId=this.system._bookId(),this.id=c??this.sessionId,this.logger=n?.logger??this.system._logger,this.clock=n?.clock??this.system._clock,this._parent=o,this._syncSnapshot=a,this.options=s,this.src=s.src??e,this.ref=this,this._actorScope={self:this,id:this.id,sessionId:this.sessionId,logger:this.logger,defer:u=>{this._deferred.push(u)},system:this.system,stopChild:u=>{if(u._parent!==this)throw new Error(`Cannot stop child actor ${u.id} of ${this.id} because it is not a child`);u._stop()},emit:u=>{const d=this.eventListeners.get(u.type),l=this.eventListeners.get("*");if(!d&&!l)return;const f=[...d?d.values():[],...l?l.values():[]];for(const y of f)try{y(u)}catch(g){M(g)}},actionExecutor:u=>{const d=()=>{if(this._actorScope.system._sendInspectionEvent({type:"@xstate.action",actorRef:this,action:{type:u.type,params:u.params}}),!u.exec)return;const l=lt;try{lt=!0,u.exec(u.info,u.params)}finally{lt=l}};this._processingStatus===k.Running?d():this._deferred.push(d)}},this.send=this.send.bind(this),this.system._sendInspectionEvent({type:"@xstate.actor",actorRef:this}),h&&(this.systemId=h,this.system._set(h,this)),this._initState(n?.snapshot??n?.state),h&&this._snapshot.status!=="active"&&this.system._unregister(this)}_initState(e){try{this._snapshot=e?this.logic.restoreSnapshot?this.logic.restoreSnapshot(e,this._actorScope):e:this.logic.getInitialSnapshot(this._actorScope,this.options?.input)}catch(n){this._snapshot={status:"error",output:void 0,error:n}}}update(e,n){this._snapshot=e;let s;for(;s=this._deferred.shift();)try{s()}catch(r){this._deferred.length=0,this._snapshot={...e,status:"error",error:r}}switch(this._snapshot.status){case"active":for(const r of this.observers)try{r.next?.(e)}catch(i){M(i)}break;case"done":for(const r of this.observers)try{r.next?.(e)}catch(i){M(i)}this._stopProcedure(),this._complete(),this._doneEvent=Yo(this.id,this._snapshot.output),this._parent&&this.system._relay(this,this._parent,this._doneEvent);break;case"error":this._error(this._snapshot.error);break}this.system._sendInspectionEvent({type:"@xstate.snapshot",actorRef:this,event:n,snapshot:e})}subscribe(e,n,s){const r=De(e,n,s);if(this._processingStatus!==k.Stopped)this.observers.add(r);else switch(this._snapshot.status){case"done":try{r.complete?.()}catch(i){M(i)}break;case"error":{const i=this._snapshot.error;if(!r.error)M(i);else try{r.error(i)}catch(o){M(o)}break}}return{unsubscribe:()=>{this.observers.delete(r)}}}on(e,n){let s=this.eventListeners.get(e);s||(s=new Set,this.eventListeners.set(e,s));const r=n.bind(void 0);return s.add(r),{unsubscribe:()=>{s.delete(r)}}}select(e,n=Object.is){return{subscribe:s=>{const r=De(s),i=this.getSnapshot();let o=e(i);return this.subscribe(a=>{const c=e(a);n(o,c)||(o=c,r.next?.(c))})},get:()=>e(this.getSnapshot())}}
15start(){if(this._processingStatus===k.Running)return this;this._syncSnapshot&&this.subscribe({next:s=>{s.status==="active"&&this.system._relay(this,this._parent,{type:`xstate.snapshot.${this.id}`,snapshot:s})},error:()=>{}}),this.system._register(this.sessionId,this),this.systemId&&this.system._set(this.systemId,this),this._processingStatus=k.Running;const e=As(this.options.input);switch(this.system._sendInspectionEvent({type:"@xstate.event",sourceRef:this._parent,actorRef:this,event:e}),this._snapshot.status){case"done":return this.update(this._snapshot,e),this;case"error":return this._error(this._snapshot.error),this}if(this._parent||this.system.start(),this.logic.start)try{this.logic.start(this._snapshot,this._actorScope)}catch(s){return this._snapshot={...this._snapshot,status:"error",error:s},this._error(s),this}return this.update(this._snapshot,e),this.options.devTools&&this.attachDevTools(),this.mailbox.start(),this}_process(e){let n,s;try{n=this.logic.transition(this._snapshot,e,this._actorScope)}catch(r){s={err:r}}if(s){const{err:r}=s;this._snapshot={...this._snapshot,status:"error",error:r},this._error(r);return}this.update(n,e),e.type===Be&&(this._stopProcedure(),this._complete())}_stop(){return this._processingStatus===k.Stopped?this:(this.mailbox.clear(),this._processingStatus===k.NotStarted?(this._processingStatus=k.Stopped,this):(this.mailbox.enqueue({type:Be}),this))}stop(){if(this._parent)throw new Error("A non-root actor cannot be stopped directly.");return this._stop()}_complete(){for(const e of this.observers)try{e.complete?.()}catch(n){M(n)}this.observers.clear(),this.eventListeners.clear()}_reportError(e){if(!this.observers.size){this._parent||M(e),this.eventListeners.clear();return}let n=!1;for(const s of this.observers){const r=s.error;n||=!r;try{r?.(e)}catch(i){M(i)}}this.observers.clear(),this.eventListeners.clear(),n&&M(e)}_error(e){this._stopProcedure(),this._reportError(e),this._parent&&this.system._relay(this,this._parent,xs(this.id,e))}_stopProcedure(){return this._processingStatus!==k.Running?this:(this.system.scheduler.cancelAll(this),this.mailbox.clear(),this.mailbox=new cn(this._process.bind(this)),this._processingStatus=k.Stopped,this.system._unregister(this),this)}_send(e){this._processingStatus!==k.Stopped&&this.mailbox.enqueue(e)}send(e){this.system._relay(void 0,this,e)}attachDevTools(){const{devTools:e}=this.options;e&&(typeof e=="function"?e:Bo)(this)}toJSON(){return{xstate$$type:Ct,id:this.id}}getPersistedSnapshot(e){return this.logic.getPersistedSnapshot(this._snapshot,e)}[Xo](){return this}getSnapshot(){return this._snapshot}}function ke(t,...[e]){return new ra(t,e)}function ia(t,e,n,s,{sendId:r}){const i=typeof r=="function"?r(n,s):r;return[e,{sendId:i},void 0]}function oa(t,e){t.defer(()=>{t.system.scheduler.cancel(t.self,e.sendId)})}function Rt(t){function e(n,s){}return e.type="xstate.cancel",e.sendId=t,e.resolve=ia,e.execute=oa,e}function aa(t,e,n,s,{id:r,systemId:i,src:o,input:a,syncSnapshot:c}){const h=typeof o=="string"?kt(e.machine,o):o,p=typeof r=="function"?r(n):r;let u,d;return h&&(d=typeof a=="function"?a({context:e.context,event:n.event,self:t.self}):a,u=ke(h,{id:p,src:o,parent:t.self,syncSnapshot:c,systemId:i,input:d})),[Y(e,{children:{...e.children,[p]:u}}),{id:r,systemId:i,actorRef:u,src:o,input:d},void 0]}function ca(t,{actorRef:e}){e&&t.defer(()=>{e._processingStatus!==k.Stopped&&e.start()})}function jt(...[t,{id:e,systemId:n,input:s,syncSnapshot:r=!1}={}]){function i(o,a){}return i.type="xstate.spawnChild",i.id=e,i.systemId=n,i.src=t,i.input=s,i.syncSnapshot=r,i.resolve=aa,i.execute=ca,i}function ua(t,e,n,s,{actorRef:r}){const i=typeof r=="function"?r(n,s):r,o=typeof i=="string"?e.children[i]:i;let a=e.children;return o&&(a={...a},delete a[o.id]),[Y(e,{children:a}),o,void 0]}function Os(t,e){const n=e.getSnapshot();if(n&&"children"in n)for(const s of Object.values(n.children))Os(t,s);t.system._unregister(e)}function da(t,e){if(e){if(Os(t,e),e._processingStatus!==k.Running){t.stopChild(e);return}t.defer(()=>{t.stopChild(e)})}}function je(t){function e(n,s){}return e.type="xstate.stopChild",e.actorRef=t,e.resolve=ua,e.execute=da,e}function ha(t,{context:e,event:n},{guards:s}){return s.every(r=>Me(r,e,n,t))}function la(t){function e(n,s){return!1}return e.check=ha,e.guards=t,e}function Me(t,e,n,s){const{machine:r}=s,i=typeof t=="function",o=i?t:r.implementations.guards[typeof t=="string"?t:t.type];if(!i&&!o)throw new Error(`Guard '${typeof t=="string"?t:t.type}' is not implemented.'.`);if(typeof o!="function")return Me(o,e,n,s);const a={context:e,event:n},c=i||typeof t=="string"?void 0:"params"in t?typeof t.params=="function"?t.params({context:e,event:n}):t.params:void 0;return"check"in o?o.check(s,a,o):o(a,c)}function Mt(t){return t.type==="atomic"||t.type==="final"}function ye(t){return Object.values(t.states).filter(e=>e.type!=="history")}function Oe(t,e){const n=[];if(e===t)return n;let s=t.parent;for(;s&&s!==e;)n.push(s),s=s.parent;return n}function Fe(t){const e=new Set(t),n=Ds(e);for(const s of e)if(s.type==="compound"&&(!n.get(s)||!n.get(s).length))fn(s).forEac
15h(r=>e.add(r));else if(s.type==="parallel"){for(const r of ye(s))if(r.type!=="history"&&!e.has(r)){const i=fn(r);for(const o of i)e.add(o)}}for(const s of e){let r=s.parent;for(;r;)e.add(r),r=r.parent}return e}function qs(t,e){const n=e.get(t);if(!n)return{};if(t.type==="compound"){const r=n[0];if(r){if(Mt(r))return r.key}else return{}}const s={};for(const r of n)s[r.key]=qs(r,e);return s}function Ds(t){const e=new Map;for(const n of t)e.has(n)||e.set(n,[]),n.parent&&(e.has(n.parent)||e.set(n.parent,[]),e.get(n.parent).push(n));return e}function Ps(t,e){const n=Fe(e);return qs(t,Ds(n))}function Ot(t,e){return e.type==="compound"?ye(e).some(n=>n.type==="final"&&t.has(n)):e.type==="parallel"?ye(e).every(n=>Ot(t,n)):e.type==="final"}const rt=t=>t[0]===Go;function fa(t,e){const n=t.transitions.get(e),s=[...t.transitions.keys()].filter(r=>r!==e&&Ms(e,r)).sort((r,i)=>i.length-r.length).flatMap(r=>t.transitions.get(r));return n?[...n,...s]:s}function pa(t){const e=t.config.after;if(!e)return[];const n=r=>{const i=Ko(r,t.id),o=i.type;return t.entry.push(ue(i,{id:o,delay:r})),t.exit.push(Rt(o)),o};return Object.keys(e).flatMap(r=>{const i=e[r],o=typeof i=="string"?{target:i}:i,a=Number.isNaN(+r)?r:+r,c=n(a);return D(o).map(h=>({...h,event:c,delay:a}))}).map(r=>{const{delay:i}=r;return{...W(t,r.event,r),delay:i}})}function W(t,e,n){const s=js(n.target),r=n.reenter??!1,i=va(t,s),o={...n,actions:D(n.actions),guard:n.guard,target:i,source:t,reenter:r,eventType:e,toJSON:()=>({...o,source:`#${t.id}`,target:i?i.map(a=>`#${a.id}`):void 0})};return o}function ya(t){const e=new Map;if(t.config.on)for(const n of Object.keys(t.config.on)){if(n===$s)throw new Error('Null events ("") cannot be specified as a transition key. Use `always: { ... }` instead.');const s=t.config.on[n];e.set(n,se(s).map(r=>W(t,n,r)))}if(t.config.onDone){const n=`xstate.done.state.${t.id}`;e.set(n,se(t.config.onDone).map(s=>W(t,n,s)))}for(const n of t.invoke){if(n.onDone){const s=`xstate.done.actor.${n.id}`;e.set(s,se(n.onDone).map(r=>W(t,s,r)))}if(n.onError){const s=`xstate.error.actor.${n.id}`;e.set(s,se(n.onError).map(r=>W(t,s,r)))}if(n.onSnapshot){const s=`xstate.snapshot.${n.id}`;e.set(s,se(n.onSnapshot).map(r=>W(t,s,r)))}}for(const n of t.after){let s=e.get(n.eventType);s||(s=[],e.set(n.eventType,s)),s.push(n)}return e}function ga(t){const e=[],n=s=>{Object.values(s).forEach(r=>{if(r.config.route&&r.config.id){const i=r.config.id,o=r.config.route.guard,a=({event:h})=>h.to===`#${i}`,c={...r.config.route,guard:o?la([a,o]):a,target:`#${i}`};e.push(W(t,"xstate.route",c))}r.states&&n(r.states)})};n(t.states),e.length>0&&t.transitions.set("xstate.route",e)}function ma(t,e){const n=typeof e=="string"?t.states[e]:e?t.states[e.target]:void 0;if(!n&&e)throw new Error(`Initial state node "${e}" not found on parent state node #${t.id}`);const s={source:t,actions:!e||typeof e=="string"?[]:D(e.actions),eventType:null,reenter:!1,target:n?[n]:[],toJSON:()=>({...s,source:`#${t.id}`,target:n?[`#${n.id}`]:[]})};return s}function va(t,e){if(e!==void 0)return e.map(n=>{if(typeof n!="string")return n;if(rt(n))return t.machine.getStateNodeById(n);const s=n[0]===Is;if(s&&!t.parent)return Ge(t,n.slice(1));const r=s?t.key+n:n;if(t.parent)try{return Ge(t.parent,r)}catch(i){throw new Error(`Invalid transition definition for state node '${t.id}': 16${i.message}`)}else throw new Error(`Invalid target: "${n}" is not a valid target from the root node. Did you mean ".${n}"?`)})}function Ls(t){const e=js(t.config.target);return e?{target:e.map(n=>typeof n=="string"?Ge(t.parent,n):n)}:t.parent.initial}function G(t){return t.type==="history"}function fn(t){const e=Us(t);for(const n of e)for(const s of Oe(n,t))e.add(s);return e}function Us(t){const e=new Set;function n(s){if(!e.has(s)){if(e.add(s),s.type==="compound")n(s.initial.target[0]);else if(s.type==="parallel")for(const r of ye(s))n(r)}}return n(t),e}function ge(t,e){if(rt(e))return t.machine.getStateNodeById(e);if(!t.states)throw new Error(`Unable to retrieve child state '${e}' from '${t.id}'; no child states exist.`);const n=t.states[e];if(!n)throw new Error(`Child state '${e}' does not exist on '${t.id}'`);return n}function Ge(t,e){if(typeof e=="string"&&rt(e))try{return t.machine.getStateNodeById(e)}catch{}const n=At(e).slice();let s=t;for(;n.length;){const r=n.shift();if(!r.length)break;s=ge(s,r)}return s}function Je(t,e){if(typeof e=="string"){const r=t.states[e];if(!r)throw new Error(`State '${e}' does not exist on '${t.id}'`);return[t,r]}const n=Object.keys(e),s=n.map(r=>
16ge(t,r)).filter(Boolean);return[t.machine.root,t].concat(s,n.reduce((r,i)=>{const o=ge(t,i);if(!o)return r;const a=Je(o,e[i]);return r.concat(a)},[]))}function wa(t,e,n,s){const i=ge(t,e).next(n,s);return!i||!i.length?t.next(n,s):i}function ba(t,e,n,s){const r=Object.keys(e),i=ge(t,r[0]),o=qt(i,e[r[0]],n,s);return!o||!o.length?t.next(n,s):o}function _a(t,e,n,s){const r=[];for(const i of Object.keys(e)){const o=e[i];if(!o)continue;const a=ge(t,i),c=qt(a,o,n,s);c&&r.push(...c)}return r.length?r:t.next(n,s)}function qt(t,e,n,s){return typeof e=="string"?wa(t,e,n,s):Object.keys(e).length===1?ba(t,e,n,s):_a(t,e,n,s)}function Ea(t){return Object.keys(t.states).map(e=>t.states[e]).filter(e=>e.type==="history")}function B(t,e){let n=t;for(;n.parent&&n.parent!==e;)n=n.parent;return n.parent===e}function Sa(t,e){const n=new Set(t),s=new Set(e);for(const r of n)if(s.has(r))return!0;for(const r of s)if(n.has(r))return!0;return!1}function Vs(t,e,n){const s=new Set;for(const r of t){let i=!1;const o=new Set;for(const a of s)if(Sa(vt([r],e,n),vt([a],e,n)))if(B(r.source,a.source))o.add(a);else{i=!0;break}if(!i){for(const a of o)s.delete(a);s.add(r)}}return Array.from(s)}function Ia(t){const[e,...n]=t;for(const s of Oe(e,void 0))if(n.every(r=>B(r,s)))return s}function Dt(t,e){if(!t.target)return[];const n=new Set;for(const s of t.target)if(G(s))if(e[s.id])for(const r of e[s.id])n.add(r);else for(const r of Dt(Ls(s),e))n.add(r);else n.add(s);return[...n]}function Ws(t,e){const n=Dt(t,e);if(!n)return;if(!t.reenter&&n.every(r=>r===t.source||B(r,t.source)))return t.source;const s=Ia(n.concat(t.source));if(s)return s;if(!t.reenter)return t.source.machine.root}function vt(t,e,n){const s=new Set;for(const r of t)if(r.target?.length){const i=Ws(r,n);r.reenter&&r.source===i&&s.add(i);for(const o of e)B(o,i)&&s.add(o)}return[...s]}function $a(t,e){if(t.length!==e.size)return!1;for(const n of t)if(!e.has(n))return!1;return!0}function Ta(t,e,n,s,r){return wt([{target:[...Us(t)],source:t,reenter:!0,actions:[],eventType:null,toJSON:null}],e,n,s,!0,r)}function wt(t,e,n,s,r,i){const o=[];if(!t.length)return[e,o];const a=n.actionExecutor;n.actionExecutor=c=>{o.push(c),a(c)};try{const c=new Set(e._nodes);let h=e.historyValue;const p=Vs(t,c,h);let u=e;r||([u,h]=Ca(u,s,n,p,c,h,i,n.actionExecutor)),u=me(u,s,n,p.flatMap(l=>l.actions),i,void 0),u=Aa(u,s,n,p,c,i,h,r);const d=[...c];u.status==="done"&&(u=me(u,s,n,d.sort((l,f)=>f.order-l.order).flatMap(l=>l.exit),i,void 0));try{return h===e.historyValue&&$a(e._nodes,c)?[u,o]:[Y(u,{_nodes:d,historyValue:h}),o]}catch(l){throw l}}finally{n.actionExecutor=a}}function xa(t,e,n,s,r){if(s.output===void 0)return;const i=gt(r.id,r.output!==void 0&&r.parent?mt(r.output,t.context,e,n.self):void 0);return mt(s.output,t.context,i,n.self)}function Aa(t,e,n,s,r,i,o,a){let c=t;const h=new Set,p=new Set;ka(s,o,p,h),a&&p.add(t.machine.root);const u=new Set;for(const d of[...h].sort((l,f)=>l.order-f.order)){r.add(d);const l=[];l.push(...d.entry);for(const f of d.invoke)l.push(jt(f.src,{...f,syncSnapshot:!!f.onSnapshot}));if(p.has(d)){const f=d.initial.actions;l.push(...f)}if(c=me(c,e,n,l,i,d.invoke.map(f=>f.id)),d.type==="final"){const f=d.parent;let y=f?.type==="parallel"?f:f?.parent,g=y||d;for(f?.type==="compound"&&i.push(gt(f.id,d.output!==void 0?mt(d.output,c.context,e,n.self):void 0));y?.type==="parallel"&&!u.has(y)&&Ot(r,y);)u.add(y),i.push(gt(y.id)),g=y,y=y.parent;if(y)continue;c=Y(c,{status:"done",output:xa(c,e,n,c.machine.root,g)})}}return c}function ka(t,e,n,s){for(const r of t){const i=Ws(r,e);for(const a of r.target||[])!G(a)&&(r.source!==a||r.source!==i||r.reenter)&&(s.add(a),n.add(a)),ie(a,e,n,s);const o=Dt(r,e);for(const a of o){const c=Oe(a,i);i?.type==="parallel"&&c.push(i),Hs(s,e,n,c,!r.source.parent&&r.reenter?void 0:i)}}}function ie(t,e,n,s){if(G(t))if(e[t.id]){const r=e[t.id];for(const i of r)s.add(i),ie(i,e,n,s);for(const i of r)ft(i,t.parent,s,e,n)}else{const r=Ls(t);for(const i of r.target)s.add(i),r===t.parent?.initial&&n.add(t.parent),ie(i,e,n,s);for(const i of r.target)ft(i,t.parent,s,e,n)}else if(t.type==="compound"){const[r]=t.initial.target;G(r)||(s.add(r),n.add(r)),ie(r,e,n,s),ft(r,t,s,e,n)}else if(t.type==="parallel")for(const r of ye(t).filter(i=>!G(i)))[...s].some(i=>B(i,r))||(G(r)||(s.add(r),n.add(r)),ie(r,e,n,s))}function Hs(t,e,n,s,r){for(const i of s)if((!r||B(i,r))&&t.add(i),i.type==="parallel")for(const o of ye(i).filter(a=>!G(a)))[...t].some(a=>B(a,o))||(t.add(o),ie(o,e,n,t))}function ft(t,e,n,s,r){Hs(n,s,r,Oe(t,e))}function Ca(t,e,n,s,r,i,o,a){let c=t;const h=vt(s,r,i);h.sort((u,d)=>d.order-u.order);let p;for(const u of h)for(const d of Ea(u)){let l;d.history==="deep"?l=f=>Mt(f)&&B(f,u):l=f=>f.parent===u,p??={...i},p[d.id]=Array.from(r).filter(l)}for(const u of h)c=me(c,e,n,[...u.exit,...u.invoke.map(d=>je(d.id))],o,void 0),r.delete(u);return[c,p||i]}function Ra(t,e){return t.implementations.actions[e]}function Ns(t,e,n,s,r,i){const{machine:o}=t;let a=t;for(const c of s){const h=typeof c=="function",p=h?c:Ra(o,typeof c=="string"?c:c.type),u={context:a.context,event:e,self:n.self,system:n.system},d=h||typeof c=="string"?void 0:"params"in c?typeof c.params=="function"?c.params({context:a.context,event:e}):c.params:void 0;if(!p||!("resolve"in p)){n.actionExecutor({type:typeof c=="string"?c:typeof c=="object"?c.type:c.name||"(anonymous)",info:u,params:d,exec:p});continue}const l=p,[f,y,g]=l.resolve(n,a,u,d,p,r);a=f,"retryResolve"in l&&i?.push([l,y]),"execute"in l&&n.actionExecutor({type:l.type,info:u,params:y,exec:l.execute.bind(null,n,y)}),g&&(a=Ns(a,e,n,g,r,i))}return a}function me(t,e,n,s,r,i){const o=i?[]:void 0,a=Ns(t,e,n,s,{internalQueue:r,deferredActorIds:i},o);return o?.forEach(([c,h])=>{c.retryResolve(n,a,h)}),a}function pt(t,e,n,s){let r=t;const i=[];function o(u,d,l){n.system._sendInspectionEvent({type:"@xstate.microstep",actorRef:n.self,event:d,snapshot:u[0],_transitions:l}),i.push(u)}if(e.type===Be)return r=Y(pn(r,e,n),{status:"stopped"}),o([r,[]],e,[]),{snapshot:r,microsteps:i};let a=e;if(a.type!==Ts){const u=a,d=ea(u),l=yn(u,r);if(d&&!l.length)return r=Y(t,{status:"error",error:u.error}),o([r,[]],u,[]),{snapshot:r,microsteps:i};const f=wt(l,t,n,a,!1,s);r=f[0],o(f,u,l)}let c=!0;const h=t.machine.options?.maxIterations??1/0;let p=0;for(;r.status==="active";){if(p++,p>h)throw new Error(`Infinite loop detected: the machine has processed more than ${h} microsteps without reaching a stable state. This usually happens when there's a cycle of transitions (e.g., eventless transitions or raised events causing state A -> B -> C -> A).`);let u=c?ja(r,a):[];const d=u.length?r:void 0;if(!u.length){if(!s.length)break;a=s.shift(),u=yn(a,r)}const l=wt(u,r,n,a,!1,s);r=l[0],c=r!==d,o(l,a,u)}return r.status!=="active"&&pn(r,a,n),{snapshot:r,microsteps:i}}function pn(t,e,n){return me(t,e,n,Object.values(t.children).map(s=>je(s)),[],void 0)}function yn(t,e){return e.machine.getTransitionData(e,t)}function ja(t,e){const n=new Set,s=t._nodes.filter(Mt);for(const r of s)e:for(const i of[r].concat(Oe(r,void 0)))if(i.always){for(const o of i.always)if(o.guard===void 0||Me(o.guard,t.context,e,t)){n.add(o);break e}}return Vs(Array.from(n),new Set(t._nodes),t.historyValue)}function Ma(t,e){const n=Fe(Je(t,e));return Ps(t,[...n])}function Oa(t){return!!t&&typeof t=="object"&&"machine"in t&&"value"in t}const qa=function(e){return ks(e,this.value)},Da=function(e){return this.tags.has(e)},Pa=function(e){const n=this.machine.getTransitionData(this,e);return!!n?.length&&n.some(s=>s.target!==void 0||s.actions.length)},La=function(){const{_nodes:e,tags:n,machine:s,getMeta:r,toJSON:i,can:o,hasTag:a,matches:c,...h}=this;return{...h,tags:Array.from(n)}},Ua=function(){return this._nodes.reduce((e,n)=>(n.meta!==void 0&&(e[n.id]=n.meta),e),{})};function Pe(t,e){return{status:t.status,output:t.output,error:t.error,machine:e,context:t.context,_nodes:t._nodes,value:Ps(e.root,t._nodes),tags:new Set(t._nodes.flatMap(n=>n.tags)),children:t.children,historyValue:t.historyValue||{},matches:qa,hasTag:Da,can:Pa,getMeta:Ua,toJSON:La}}function Y(t,e={}){return Pe({...t,...e},t.machine)}function Va(t){if(typeof t!="object"||t===null)return{};const e={};for(const n in t){const s=t[n];Array.isArray(s)&&(e[n]=s.map(r=>({id:r.id})))}return e}function Wa(t,e){const{_nodes:n,tags:s,machine:r,children:i,context:o,can:a,hasTag:c,matches:h,getMeta:p,toJSON:u,...d}=t,l={};for(const y in i){const g=i[y];l[y]={snapshot:g.getPersistedSnapshot(e),src:g.src,systemId:g.systemId,syncSnapshot:g._syncSnapshot}}return{...d,context:zs(o),children:l,historyValue:Va(d.historyValue)}}function zs(t){let e;for(const n in t){const s=t[n];if(s&&typeof s=="object")if("sessionId"in s&&"send"in s&&"ref"in s)e??=Array.isArray(t)?t.slice():{...t},e[n]={xstate$$type:Ct,id:s.id};else{const r=zs(s);r!==s&&(e??=Array.isArray(t)?t.slice():{...t},e[n]=r)}}return e??t}function Ha(t,e,n,s,{event:r,id:i,delay:o},{internalQueue:a}){const c=e.machine.implementations.delays;if(typeof r=="string")throw new Error(`Only event objects may be used with raise; use raise({ type: "${r}" }) instead`);const h=typeof r=="function"?r(n,s):r;let p;
16if(typeof o=="string"){const u=c&&c[o];p=typeof u=="function"?u(n,s):u}else p=typeof o=="function"?o(n,s):o;return typeof p!="number"&&a.push(h),[e,{event:h,id:i,delay:p},void 0]}function Na(t,e){const{event:n,delay:s,id:r}=e;if(typeof s=="number"){t.defer(()=>{const i=t.self;t.system.scheduler.schedule(i,i,n,s,r)});return}}function ue(t,e){function n(s,r){}return n.type="xstate.raise",n.event=t,n.id=e?.id,n.delay=e?.delay,n.resolve=Ha,n.execute=Na,n}const gn="xstate.observable.error",mn="xstate.observable.complete";function Bs(t){return{config:t,transition:(n,s)=>{if(n.status!=="active")return n;switch(s.type){case gn:return{...n,status:"error",error:s.data,input:void 0,_subscription:void 0};case mn:return{...n,status:"done",input:void 0,_subscription:void 0};case Be:return n._subscription.unsubscribe(),{...n,status:"stopped",input:void 0,_subscription:void 0};default:return n}},getInitialSnapshot:(n,s)=>({status:"active",output:void 0,error:void 0,context:void 0,input:s,_subscription:void 0}),start:(n,{self:s,system:r,emit:i})=>{n.status!=="done"&&(n._subscription=t({input:n.input,system:r,self:s,emit:i}).subscribe({next:o=>{s._parent&&r._relay(s,s._parent,o)},error:o=>{r._relay(s,s,{type:gn,data:o})},complete:()=>{r._relay(s,s,{type:mn})}}))},getPersistedSnapshot:({_subscription:n,...s})=>s,restoreSnapshot:n=>({...n,_subscription:void 0})}}function za(t,{machine:e,context:n},s,r){const i=(o,a)=>{if(typeof o=="string"){const c=kt(e,o);if(!c)throw new Error(`Actor logic '${o}' not implemented in machine '${e.id}'`);const h=ke(c,{id:a?.id,parent:t.self,syncSnapshot:a?.syncSnapshot,input:typeof a?.input=="function"?a.input({context:n,event:s,self:t.self}):a?.input,src:o,systemId:a?.systemId});return r[h.id]=h,h}else return ke(o,{id:a?.id,parent:t.self,syncSnapshot:a?.syncSnapshot,input:a?.input,src:o,systemId:a?.systemId})};return(o,a)=>{const c=i(o,a);return r[c.id]=c,t.defer(()=>{c._processingStatus!==k.Stopped&&c.start()}),c}}function Ba(t,e,n,s,{assignment:r}){if(!e.context)throw new Error("Cannot assign to undefined `context`. Ensure that `context` is defined in the machine config.");const i={},o={context:e.context,event:n.event,spawn:za(t,e,n.event,i),self:t.self,system:t.system};let a={};if(typeof r=="function")a=r(o,s);else for(const h of Object.keys(r)){const p=r[h];a[h]=typeof p=="function"?p(o,s):p}const c=Object.assign({},e.context,a);return[Y(e,{context:c,children:Object.keys(i).length?{...e.children,...i}:e.children}),void 0,void 0]}function K(t){function e(n,s){}return e.type="xstate.assign",e.assignment=t,e.resolve=Ba,e}const vn=new WeakMap;function te(t,e,n){let s=vn.get(t);return s?e in s||(s[e]=n()):(s={[e]:n()},vn.set(t,s)),s[e]}const Fa={},we=t=>typeof t=="string"?{type:t}:typeof t=="function"?"resolve"in t?{type:t.type}:{type:t.name}:t;class Qe{constructor(e,n){if(this.config=e,this.key=void 0,this.id=void 0,this.type=void 0,this.path=void 0,this.states=void 0,this.history=void 0,this.entry=void 0,this.exit=void 0,this.parent=void 0,this.machine=void 0,this.meta=void 0,this.output=void 0,this.order=-1,this.description=void 0,this.tags=[],this.transitions=void 0,this.always=void 0,this.parent=n._parent,this.key=n._key,this.machine=n._machine,this.path=this.parent?this.parent.path.concat(this.key):[],this.id=this.config.id||[this.machine.id,...this.path].join(Is),this.type=this.config.type||(this.config.states&&Object.keys(this.config.states).length?"compound":this.config.history?"history":"atomic"),this.description=this.config.description,this.order=this.machine.idMap.size,this.machine.idMap.set(this.id,this),this.states=this.config.states?dn(this.config.states,(s,r)=>new Qe(s,{_parent:this,_key:r,_machine:this.machine})):Fa,this.type==="compound"&&!this.config.initial)throw new Error(`No initial state specified for compound state node "#${this.id}". Try adding { initial: "${Object.keys(this.states)[0]}" } to the state config.`);this.history=this.config.history===!0?"shallow":this.config.history||!1,this.entry=D(this.config.entry).slice(),this.exit=D(this.config.exit).slice(),this.meta=this.config.meta,this.output=this.t
16ype==="final"||!this.parent?this.config.output:void 0,this.tags=D(e.tags).slice()}_initialize(){this.transitions=ya(this),this.config.always&&(this.always=se(this.config.always).map(e=>W(this,$s,e))),Object.keys(this.states).forEach(e=>{this.states[e]._initialize()})}get definition(){return{id:this.id,key:this.key,version:this.machine.version,type:this.type,initial:this.initial?{target:this.initial.target,source:this,actions:this.initial.actions.map(we),eventType:null,reenter:!1,toJSON:()=>({target:this.initial.target.map(e=>`#${e.id}`),source:`#${this.id}`,actions:this.initial.actions.map(we),eventType:null})}:void 0,history:this.history,states:dn(this.states,e=>e.definition),on:this.on,transitions:[...this.transitions.values()].flat().map(e=>({...e,actions:e.actions.map(we)})),entry:this.entry.map(we),exit:this.exit.map(we),meta:this.meta,order:this.order||-1,output:this.output,invoke:this.invoke,description:this.description,tags:this.tags}}toJSON(){return this.definition}get invoke(){return te(this,"invoke",()=>D(this.config.invoke).map((e,n)=>{const{src:s,systemId:r}=e,i=e.id??hn(this.id,n),o=typeof s=="string"?s:`xstate.invoke.${hn(this.id,n)}`;return{...e,src:o,id:i,systemId:r,toJSON(){const{onDone:a,onError:c,...h}=e;return{...h,type:"xstate.invoke",src:o,id:i}}}}))}get on(){return te(this,"on",()=>[...this.transitions].flatMap(([n,s])=>s.map(r=>[n,r])).reduce((n,[s,r])=>(n[s]=n[s]||[],n[s].push(r),n),{}))}get after(){return te(this,"delayedTransitions",()=>pa(this))}get initial(){return te(this,"initial",()=>ma(this,this.config.initial))}next(e,n){const s=n.type,r=[];let i;const o=te(this,`candidates-${s}`,()=>fa(this,s));for(const a of o){const{guard:c}=a,h=e.context;let p=!1;try{p=!c||Me(c,h,n,e)}catch(u){const d=typeof c=="string"?c:typeof c=="object"?c.type:void 0;throw new Error(`Unable to evaluate guard ${d?`'${d}' `:""}in transition for event '${s}' in state node '${this.id}': 17${u.message}`)}if(p){r.push(...a.actions),i=a;break}}return i?[i]:void 0}get events(){return te(this,"events",()=>{const{states:e}=this,n=new Set(this.ownEvents);if(e)for(const s of Object.keys(e)){const r=e[s];if(r.states)for(const i of r.events)n.add(`${i}`)}return Array.from(n)})}get ownEvents(){const e=Object.keys(Object.fromEntries(this.transitions)),n=new Set(e.filter(s=>this.transitions.get(s).some(r=>!(!r.target&&!r.actions.length&&!r.reenter))));return Array.from(n)}}const Ga="#";class Pt{constructor(e,n){this.config=e,this.version=void 0,this.schemas=void 0,this.implementations=void 0,this.options=void 0,this.__xstatenode=!0,this.idMap=new Map,this.root=void 0,this.id=void 0,this.states=void 0,this.events=void 0,this.id=e.id||"(machine)",this.implementations={actors:n?.actors??{},actions:n?.actions??{},delays:n?.delays??{},guards:n?.guards??{}},this.version=this.config.version,this.schemas=this.config.schemas,this.options={maxIterations:1/0,...this.config.options},this.transition=this.transition.bind(this),this.getInitialSnapshot=this.getInitialSnapshot.bind(this),this.getPersistedSnapshot=this.getPersistedSnapshot.bind(this),this.restoreSnapshot=this.restoreSnapshot.bind(this),this.start=this.start.bind(this),this.root=new Qe(e,{_key:this.id,_machine:this}),this.root._initialize(),ga(this.root),this.states=this.root.states,this.events=this.root.events}provide(e){const{actions:n,guards:s,actors:r,delays:i}=this.implementations;return new Pt(this.config,{actions:{...n,...e.actions},guards:{...s,...e.guards},actors:{...r,...e.actors},delays:{...i,...e.delays}})}resolveState(e){const n=Ma(this.root,e.value),s=Fe(Je(this.root,n));return Pe({_nodes:[...s],context:e.context||{},children:{},status:Ot(s,this.root)?"done":e.status||"active",output:e.output,error:e.error,historyValue:e.historyValue},this)}transition(e,n,s){return pt(e,n,s,[]).snapshot}microstep(e,n,s){return pt(e,n,s,[]).microsteps.map(([r])=>r)}getTransitionData(e,n){return qt(this.root,e.value,e,n)||[]}_getPreInitialState(e,n,s){const{context:r}=this.config,i=Pe({context:typeof r!="function"&&r?r:{},_nodes:[this.root],children:{},status:"active"},this);return typeof r=="function"?me(i,n,e,[K(({spawn:a,event:c,self:h})=>r({spawn:a,input:c.input,self:h}))],s,void 0):i}getInitialSnapshot(e,n){const s=As(n),r=[],i=this._getPreInitialState(e,s,r),[o]=Ta(this.root,i,e,s,r),{snapshot:a}=pt(o,s,e,r);return a}
17start(e){Object.values(e.children).forEach(n=>{n.getSnapshot().status==="active"&&n.start()})}getStateNodeById(e){const n=At(e),s=n.slice(1),r=rt(n[0])?n[0].slice(Ga.length):n[0],i=this.idMap.get(r);if(!i)throw new Error(`Child state node '#${r}' does not exist on machine '${this.id}'`);return Ge(i,s)}get definition(){return this.root.definition}toJSON(){return this.definition}getPersistedSnapshot(e,n){return Wa(e,n)}restoreSnapshot(e,n){const s={},r=e.children;Object.keys(r).forEach(u=>{const d=r[u],l=d.snapshot,f=d.src,y=typeof f=="string"?kt(this,f):f;if(!y)return;const g=ke(y,{id:u,parent:n.self,syncSnapshot:d.syncSnapshot,snapshot:l,src:f,systemId:d.systemId});s[u]=g});function i(u,d){if(d instanceof Qe)return d;try{return u.machine.getStateNodeById(d.id)}catch{}}function o(u,d){if(!d||typeof d!="object")return{};const l={};for(const f in d){const y=d[f];for(const g of y){const w=i(u,g);w&&(l[f]??=[],l[f].push(w))}}return l}const a=o(this.root,e.historyValue),c=Pe({...e,children:s,_nodes:Array.from(Fe(Je(this.root,e.value))),historyValue:a},this),h=new Set;function p(u,d){if(!h.has(u)){h.add(u);for(const l in u){const f=u[l];if(f&&typeof f=="object"){if("xstate$$type"in f&&f.xstate$$type===Ct){u[l]=d[f.id];continue}p(f,d)}}}}return p(c.context,s),c}}function Ja(t,e,n,s,{event:r}){const i=typeof r=="function"?r(n,s):r;return[e,{event:i},void 0]}function Qa(t,{event:e}){t.defer(()=>t.emit(e))}function Ke(t){function e(n,s){}return e.type="xstate.emit",e.event=t,e.resolve=Ja,e.execute=Qa,e}let bt=(function(t){return t.Parent="#_parent",t.Internal="#_internal",t})({});function Ka(t,e,n,s,{to:r,event:i,id:o,delay:a},c){const h=e.machine.implementations.delays;if(typeof i=="string")throw new Error(`Only event objects may be used with sendTo; use sendTo({ type: "${i}" }) instead`);const p=typeof i=="function"?i(n,s):i;let u;if(typeof a=="string"){const f=h&&h[a];u=typeof f=="function"?f(n,s):f}else u=typeof a=="function"?a(n,s):a;const d=typeof r=="function"?r(n,s):r;let l;if(typeof d=="string"){if(d===bt.Parent?l=t.self._parent:d===bt.Internal?l=t.self:d.startsWith("#_")?l=e.children[d.slice(2)]:l=c.deferredActorIds?.includes(d)?d:e.children[d],!l)throw new Error(`Unable to send event to actor '${d}' from machine '${e.machine.id}'.`)}else l=d||t.self;return[e,{to:l,targetId:typeof d=="string"?d:void 0,event:p,id:o,delay:u},void 0]}function Ya(t,e,n){typeof n.to=="string"&&(n.to=e.children[n.to])}function Xa(t,e){t.defer(()=>{const{to:n,event:s,delay:r,id:i}=e;if(typeof r=="number"){t.system.scheduler.schedule(t.self,n,s,r,i);return}t.system._relay(t.self,n,s.type===Qo?xs(t.self.id,s.data):s)})}function de(t,e,n){function s(r,i){}return s.type="xstate.sendTo",s.to=t,s.event=e,s.id=n?.id,s.delay=n?.delay,s.resolve=Ka,s.retryResolve=Ya,s.execute=Xa,s}function Za(t,e){return de(bt.Parent,t,e)}function ec(t,e,n,s,{collect:r}){const i=[],o=function(c){i.push(c)};return o.assign=(...a)=>{i.push(K(...a))},o.cancel=(...a)=>{i.push(Rt(...a))},o.raise=(...a)=>{i.push(ue(...a))},o.sendTo=(...a)=>{i.push(de(...a))},o.sendParent=(...a)=>{i.push(Za(...a))},o.spawnChild=(...a)=>{i.push(jt(...a))},o.stopChild=(...a)=>{i.push(je(...a))},o.emit=(...a)=>{i.push(Ke(...a))},r({context:n.context,event:n.event,enqueue:o,check:a=>Me(a,e.context,n.event,e),self:t.self,system:t.system},s),[e,void 0,i]}function re(t){function e(n,s){}return e.type="xstate.enqueueActions",e.collect=t,e.resolve=ec,e}function tc(t,e,n,s,{value:r,label:i}){return[e,{value:typeof r=="function"?r(n,s):r,label:i},void 0]}function nc({logger:t},{value:e,label:n}){n?t(n,e):t(e)}function sc(t=({context:n,event:s})=>({context:n,event:s}),e){function n(s,r){}return n.type="xstate.log",n.value=t,n.label=e,n.resolve=tc,n.execute=nc,n}function j(t,e){const n=D(e);if(!n.some(r=>Ms(t.type,r))){const r=n.length===1?`type matching "${n[0]}"`:`one of types matching "${n.join('", "')}"`;throw new Error(`Expected event ${JSON.stringify(t)} to have ${r}`)}}function rc(t,e){return new Pt(t,e)}function Lt({schemas:t,actors:e,actions:n,guards:s,delays:r}){return{assign:K,sendTo:de,raise:ue,log:sc,cancel:Rt,stopChild:je,enqueueActions:re,emit:Ke,spawnChild:jt,createStateConfig:i=>i,createAction:i=>i,createMachine:i=>rc({...i,schemas:t},{actors:e,actions:n,guards:s,delays:r}),extend:i=>Lt({schemas:t,actors:e,actions:{...n,...i.actions},guards:{...s,...i.guards},delays:{...r,...i.delays}})}}const F=t=>({context:e})=>{const{count:n,include:s,exclude:r,responseType:i="message.received"}=t;return{count:n,domain:e.domain,from:e.connectTo,include:s?Array.isArray(s)?s:[s]:[],exclude:r?Array.isArray(r)?r:[r]:[],responseType:i,target:e.target,to:e.name}},ic=t=>e=>{const{data:n}=e;
17return(t.include.length?t.include.includes(n.type):!0)&&(t.exclude.length?!t.exclude.includes(n.type):!0)&&n.domain===t.domain&&n.from===t.from&&n.to===t.to&&(!t.target||e.source===t.target)},oc=t=>e=>({type:t,message:e}),ac=_t(()=>xe(window,"message")),Fs=t=>Bs(({input:e})=>ac.pipe(t?T(t):ot(),P(ic(e)),T(oc(e.responseType)),e.count?ot(Er(e.count),Rn(n=>n),St(e.count)):ot())),Ut="sanity/comlink",cc=3e3,uc=1e4,he="comlink/response",Ie="comlink/heartbeat",oe="comlink/disconnect",$e="comlink/handshake/syn",Vt="comlink/handshake/syn-ack",Te="comlink/handshake/ack",dc=t=>e=>e.pipe(St(1),T(()=>{throw new Error(t)})),Gs=()=>Lt({actors:{listen:Bs(({input:t})=>{const e=t.signal?xe(t.signal,"abort").pipe(dc(`Request ${t.requestId} aborted`)):En,n=s=>s.data?.type===he&&s.data?.responseTo===t.requestId&&!!s.source&&t.sources.has(s.source);return xe(window,"message").pipe(P(n),St(t.sources.size),$r(e))})},actions:{"send message":({context:t},e)=>{const{sources:n,targetOrigin:s}=t,{message:r}=e;n.forEach(i=>{i.postMessage(r,{targetOrigin:s})})},"on success":de(({context:t})=>t.parentRef,({context:t,self:e})=>(t.response&&t.resolvable?.resolve(t.response),{type:"request.success",requestId:e.id,response:t.response,responseTo:t.responseTo})),"on fail":de(({context:t})=>t.parentRef,({context:t,self:e})=>(t.suppressWarnings||console.warn(`[@sanity/comlink] Received no response to message '${t.type}' on client '${t.from}' (ID: '${t.id}').`),t.resolvable?.reject(new Error("No response received")),{type:"request.failed",requestId:e.id})),"on abort":de(({context:t})=>t.parentRef,({context:t,self:e})=>(t.resolvable?.reject(new Error("Request aborted")),{type:"request.aborted",requestId:e.id}))},guards:{expectsResponse:({context:t})=>t.expectResponse},delays:{initialTimeout:0,responseTimeout:({context:t})=>t.responseTimeout??cc}}).createMachine({context:({input:t})=>({channelId:t.channelId,data:t.data,domain:t.domain,expectResponse:t.expectResponse??!1,from:t.from,id:`msg-${Ss()}`,parentRef:t.parentRef,resolvable:t.resolvable,response:null,responseTimeout:t.responseTimeout,responseTo:t.responseTo,signal:t.signal,sources:t.sources instanceof Set?t.sources:new Set([t.sources]),suppressWarnings:t.suppressWarnings,targetOrigin:t.targetOrigin,to:t.to,type:t.type}),initial:"idle",on:{abort:".aborted"},states:{idle:{after:{initialTimeout:[{target:"sending"}]}},sending:{entry:{type:"send message",params:({context:t})=>{const{channelId:e,data:n,domain:s,from:r,id:i,responseTo:o,to:a,type:c}=t;return{message:{channelId:e,data:n,domain:s,from:r,id:i,to:a,type:c,responseTo:o}}}},always:[{guard:"expectsResponse",target:"awaiting"},"success"]},awaiting:{invoke:{id:"listen for response",src:"listen",input:({context:t})=>({requestId:t.id,sources:t.sources,signal:t.signal}),onError:"aborted"},after:{responseTimeout:"failed"},on:{message:{actions:K({response:({event:t})=>t.data.data,responseTo:({event:t})=>t.data.responseTo}),target:"success"}}},failed:{type:"final",entry:"on fail"},success:{type:"final",entry:"on success"},aborted:{type:"final",entry:"on abort"}},output:({context:t,self:e})=>({requestId:e.id,response:t.response,responseTo:t.responseTo})});function hc(){if(typeof Promise.withResolvers=="function")return Promise.withResolvers();let t,e;return{promise:new Promise((n,s)=>{t=n,e=s}),resolve:t,reject:e}}const Js=()=>Lt({actors:{requestMachine:Gs(),listen:Fs()},actions:{"buffer handshake":K({handshakeBuffer:({event:t,context:e})=>(j(t,"message.received"),[...e.handshakeBuffer,t])}),"buffer message":re(({enqueue:t})=>{t.assign({buffer:({event:e,context:n})=>(j(e,"post"),[...n.buffer,{data:e.data,resolvable:e.resolvable,options:e.options}])}),t.emit(({event:e})=>(j(e,"post"),{type:"buffer.added",message:e.data}))}),"create request":K({requests:({context:t,event:e,self:n,spawn:s})=>{j(e,"request");const r=(Array.isArray(e.data)?e.data:[e.data]).map(i=>{const o=`req-${Ss()}`;return s("requestMachine",{id:o,input:{channelId:t.channelId,data:i.data,domain:t.domain,expectResponse:i.expectResponse,from:t.name,parentRef:n,resolvable:i.resolvable,responseTimeout:i.options?.responseTimeout,responseTo:i.responseTo,signal:i.options?.signal,sources:t.target,suppressWarnings:i.options?.suppressWarnings,targetOrigin:t.targetOrigin,to:t.connectTo,type:i.type}})});return[...t.requests,...r]}}),"emit heartbeat":Ke(()=>({type:"heartbeat"})),"emit received message":re(({enqueue:t})=>{t.emit(({event:e})=>(j(e,"message.received"),{type:"message",message:e.message.data}))}),"emit status":Ke((t,e)=>({type:"status",status:e.status})),"post message":ue(({event:t})=>(j(t,"post"),{type:"request",data:{data:t.data.data,expectResponse:!!t.resolvable,type:t.data.type,resolvable:t.resolvable,options:t.options}})),"process pending handshakes":re(({context:t,enqueue:e})=>{t.handshakeBuffer.forEach(n=>e.raise(n)),e.assign({handshakeBuffer:[]})}),"remove request":re(({context:t,enqueue:e,event:n})=>{j(n,["request.success","request.failed","request.aborted"]),je(n.requestId),e.assign({requests:t.requests.filter(({id:s})=>s!==n.requestId)})}),"send response":ue(({event:t})=>(j(t,["message.received","heartbeat.received"]),{type:"request",data:{type:he,responseTo:t.message.data.id,data:void 0}})),"send handshake syn ack":ue({type:"request",data:{type:Vt}}),"send pending messages":re(({enqueue:t})=>{t.raise(({context:e})=>({type:"request",data:e.buffer.map(({data:n,resolvable:s,options:r})=>
17({data:n.data,type:n.type,expectResponse:!!s,resolvable:s,options:r}))})),t.emit(({context:e})=>({type:"buffer.flushed",messages:e.buffer.map(({data:n})=>n)})),t.assign({buffer:[]})}),"set connection config":K({channelId:({event:t})=>(j(t,"handshake.syn"),t.message.data.channelId),target:({event:t})=>(j(t,"handshake.syn"),t.message.source||void 0),targetOrigin:({event:t})=>(j(t,"handshake.syn"),t.message.origin)})},guards:{hasSource:({context:t})=>t.target!==null}}).createMachine({id:"node",context:({input:t})=>({buffer:[],channelId:null,connectTo:t.connectTo,domain:t.domain??Ut,handshakeBuffer:[],name:t.name,requests:[],target:void 0,targetOrigin:null}),invoke:{id:"listen for handshake syn",src:"listen",input:F({include:$e,responseType:"handshake.syn"})},on:{"request.success":{actions:"remove request"},"request.failed":{actions:"remove request"},"request.aborted":{actions:"remove request"},"handshake.syn":{actions:"set connection config",target:".handshaking"}},initial:"idle",states:{idle:{entry:[{type:"emit status",params:{status:"idle"}}],on:{post:{actions:"buffer message"}}},handshaking:{guard:"hasSource",entry:["send handshake syn ack",{type:"emit status",params:{status:"handshaking"}}],invoke:[{id:"listen for handshake ack",src:"listen",input:F({include:Te,count:1,responseType:"handshake.complete"}),onDone:"connected"},{id:"listen for disconnect",src:"listen",input:F({include:oe,count:1,responseType:"disconnect"})},{id:"listen for messages",src:"listen",input:F({exclude:[oe,$e,Te,Ie,he]})}],on:{request:{actions:"create request"},post:{actions:"buffer message"},"message.received":{actions:"buffer handshake"},disconnect:{target:"idle"}}},connected:{entry:["process pending handshakes","send pending messages",{type:"emit status",params:{status:"connected"}}],invoke:[{id:"listen for messages",src:"listen",input:F({exclude:[oe,$e,Te,Ie,he]})},{id:"listen for heartbeat",src:"listen",input:F({include:Ie,responseType:"heartbeat.received"})},{id:"listen for disconnect",src:"listen",input:F({include:oe,count:1,responseType:"disconnect"})}],on:{request:{actions:"create request"},post:{actions:"post message"},disconnect:{target:"idle"},"message.received":{actions:["send response","emit received message"]},"heartbeat.received":{actions:["send response","emit heartbeat"]}}}}}),lc=(t,e=Js())=>{const n=ke(e,{input:t}),s=new Map,r=new Map,i=(u,d,l)=>{const f=s.get(u)||new Set;s.has(u)||s.set(u,f),f.add(d);const y=r.get(u);if(y){const g=l?.replay??1;Array.from(y).slice(-g).forEach(({data:w})=>d(w)),r.delete(u)}return()=>{f.delete(d)}};let o;const a=(u,d)=>{const l=n.on("status",f=>{o=f.status,!(d&&f.status!==d)&&u(f.status)});return o&&u(o),()=>l.unsubscribe()},c=(u,d)=>{const l={type:u,data:d};n.send({type:"post",data:l})},h=(u,d,l)=>{const{responseTimeout:f=uc,signal:y,suppressWarnings:g}=l||{},w=hc(),$={type:u,data:d};return n.send({type:"post",data:$,resolvable:w,options:{responseTimeout:f,signal:y,suppressWarnings:g}}),w.promise};n.on("message",({message:u})=>{const d=s.get(u.type);if(d){d.forEach(f=>f(u.data));return}const l=r.get(u.type);l?l.add(u):r.set(u.type,new Set([u]))});const p=()=>{n.stop()};return{actor:n,fetch:h,machine:e,on:i,onStatus:a,post:c,start:()=>(n.start(),p),stop:p}},fc={"handshake/syn":$e,"handshake/syn-ack":Vt,"handshake/ack":Te,"channel/response":he,"channel/heartbeat":Ie,"channel/disconnect":oe,"overlay/focus":"visual-editing/focus","overlay/navigate":"visual-editing/navigate","overlay/toggle":"visual-editing/toggle","presentation/toggleOverlay":"presentation/toggle-overlay"},pc={[$e]:"handshake/syn",[Vt]:"handshake/syn-ack",[Te]:"handshake/ack",[he]:"channel/response",[Ie]:"channel/heartbeat",[oe]:"channel/disconnect","visual-editing/focus":"overlay/focus","visual-editing/navigate":"overlay/navigate","visual-editing/toggle":"overlay/toggle","presentation/toggle-overlay":"presentation/toggleOverlay"},yc=t=>{const{data:e}=t;return e&&typeof e=="object"&&"domain"in e&&"type"in e&&"from"in e&&"to"in e&&(e.domain==="sanity/channels"&&(e.domain=Ut),e.to==="overlays"&&(e.to="visual-editing"),e.from==="overlays"&&(e.from="visual-editing"),e.channelId=e.connectionId,delete e.connectionId,e.type=fc[e.type]??e.type),t},gc=t=>{const{channelId:e,...n}=t,s={...n,connectionId:e};return s.domain===Ut&&(s.domain="sanity/channels"),s.to==="visual-editing"&&(s.to="overlays"),s.from==="visual-editing"&&(s.from="overlays"),s.type=pc[s.type]??s.type,s.type==="channel/response"&&s.responseTo&&!s.data&&(s.data={responseTo:s.responseTo}),(s.type==="handshake/syn"||s.type==="handshake/syn-ack"||s.type==="handshake/ack")&&(s.data={id:s.connectionId}),s},mc=({context:t},e)=>{const{sources:n,targetOrigin:s}=t,r=gc(e.message);
17n.forEach(i=>{i.postMessage(r,{targetOrigin:s})})},vc=()=>({listen:Fs(yc),requestMachine:Gs().provide({actions:{"send message":mc}})}),wn=2e4;function _c(t){const{client:e,setFetcher:n,onConnect:s,onDisconnect:r,onPerspective:i}=t;if(!e)throw new Error(`Expected \`client\` to be an instance of SanityClient: ${JSON.stringify(e)}`);const{projectId:o,dataset:a,perspective:c}=e.config(),h=Wt(c&&c!=="raw"?c:"drafts"),p=Wt(!1),u=new Map,d=lc({name:"loaders",connectTo:"presentation"},Js().provide({actors:vc()}));d.onStatus(()=>{p.set(!0)},"connected"),d.on("loader/perspective",m=>{if(m.projectId===o&&m.dataset===a){$t(m.perspective);const b=m.perspective==="raw"?"drafts":m.perspective;h.set(b),i?.(b),$()}}),d.on("loader/query-change",m=>{if(m.projectId===o&&m.dataset===a){const{perspective:b,query:S,params:_}=m;m.result!==void 0&&m.resultSourceMap!==void 0&&e.config().stega.enabled?u.set(JSON.stringify({perspective:b,query:S,params:_}),{...m,result:xt(m.result,m.resultSourceMap,e.config().stega)}):u.set(JSON.stringify({perspective:b,query:S,params:_}),m),$()}});let l;const f=p.listen(m=>{m?(l=n({hydrate:(b,S,_)=>{const A=_?.perspective||h.get(),R=JSON.stringify({perspective:A,query:b,params:S}),q=u.get(R);return q?.result!==void 0&&q?.resultSourceMap!==void 0?{loading:!1,error:void 0,data:q.result,sourceMap:q.resultSourceMap,perspective:A}:{loading:p.value===!0&&_?.data===void 0||_?.sourceMap===void 0,error:void 0,data:_?.data,sourceMap:_?.sourceMap,perspective:_?.perspective||"published"}},fetch:(b,S,_,A)=>{try{const R=g(b,S,_);if(A.signal.addEventListener("abort",()=>{R(),$()},{once:!0}),$(),_.setKey("error",void 0),A.signal.aborted)return}catch(R){_.setKey("error",R),_.setKey("loading",!1)}}}),s?.()):(l?.(),r?.())}),y=new Set,g=(m,b,S)=>{const _={query:m,params:b,$fetch:S};y.add(_),w();const A=setInterval(()=>w(!0),wn);return()=>{clearInterval(A),y.delete(_),w()}},w=m=>{if(!d)throw new Error("No connection");const b=h.get();for(const{query:S,params:_,$fetch:A}of y)d.post("loader/query-listen",{projectId:o,dataset:a,perspective:b,query:S,params:_,heartbeat:wn}),!m&&p.value===!0&&A.setKey("loading",!0),A.setKey("perspective",b)};function $(){const m=h.get(),b=[];for(const{query:S,params:_,$fetch:A}of y){const R=JSON.stringify({perspective:m,query:S,params:_}),q=u.get(R);q&&(A.set({data:q.result,error:void 0,loading:!1,perspective:m,sourceMap:q.resultSourceMap}),b.push(...q.resultSourceMap?.documents??[]))}d.post("loader/documents",{projectId:o,dataset:a,perspective:m,documents:b})}const U=d.start();return()=>{l?.(),f(),U(),p.set(!1)}}export{_c as enableLiveMode}; 18//# sourceMappingURL=DCUHYe3S.js.map
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.