PageSourceSearch

https://www.jdph.de/_nuxt/PhnSexwT.js

js jdph.de collected 2026-10-02 07:26:43 UTC 114,065 bytes, 16 lines download raw bytes

1import{aG as Qs,aH as Ks,aI as Ys,aJ as z,aK as bn,aL as ee,aM as B,aN as Xe,aO as Ze,aP as at,aQ as Xs,aR as _n,aS as Zs,aT as $t,aU as x,aV as er,aW as tr,aX as En,aY as nr,aZ as sr,a_ as rr,a$ as ir,b0 as Sn,b1 as m,b2 as ct,b3 as It,b4 as V,b5 as Y,b6 as $n,b7 as In,b8 as or,b9 as Tn,ba as ar,bb as cr,bc as ur,bd as dr,be as lr,bf as hr,bg as fr,bh as ut,bi as dt}from"./rr0VrnFX.js";import{g as xn,b as Re,c as An,i as kn,d as Cn,e as pr}from"./BmtokrGV.js";var yr=["addListener","removeListener"],gr=["addEventListener","removeEventListener"],mr=["on","off"];function Ce(t,e,n,s){if(B(n)&&(s=n,n=void 0),s)return Ce(t,e,n).pipe(Qs(s));var r=Ks(br(t)?gr.map(function(a){return function(c){return t[a](e,c,n)}}):vr(t)?yr.map(Nt(t,e)):wr(t)?mr.map(Nt(t,e)):[],2),i=r[0],o=r[1];if(!i&&Ys(t))return z(function(a){return Ce(a,e,n)})(bn(t));if(!i)throw new TypeError("Invalid event target");return new ee(function(a){var c=function(){for(var l=[],p=0;p<arguments.length;p++)l[p]=arguments[p];return a.next(1<l.length?l:l[0])};return i(c),function(){return o(c)}})}function Nt(t,e){return function(n){return function(s){return t[n](e,s)}}}function vr(t){return B(t.addListener)&&B(t.removeListener)}function wr(t){return B(t.on)&&B(t.off)}function br(t){return B(t.addEventListener)&&B(t.removeEventListener)}function _r(t,e){return e===void 0&&(e=null),e=e??t,Xe(function(n,s){var r=[],i=0;n.subscribe(Ze(s,function(o){var a,c,l,p,d=null;i++%e===0&&r.push([]);try{for(var u=at(r),h=u.next();!h.done;h=u.next()){var f=h.value;f.push(o),t<=f.length&&(d=d??[],d.push(f))}}catch(w){a={error:w}}finally{try{h&&!h.done&&(c=u.return)&&c.call(u)}finally{if(a)throw a.error}}if(d)try{for(var y=at(d),g=y.next();!g.done;g=y.next()){var f=g.value;Xs(r,f),s.next(f)}}catch(w){l={error:w}}finally{try{g&&!g.done&&(p=y.return)&&p.call(y)}finally{if(l)throw l.error}}},function(){var o,a;try{for(var c=at(r),l=c.next();!l.done;l=c.next()){var p=l.value;s.next(p)}}catch(d){o={error:d}}finally{try{l&&!l.done&&(a=c.return)&&a.call(c)}finally{if(o)throw o.error}}s.complete()},void 0,function(){r=null}))})}function Er(t,e,n,s,r){return function(i,o){var a=n,c=e,l=0;i.subscribe(Ze(o,function(p){var d=l++;c=a?t(c,p,d):(a=!0,p)},(function(){a&&o.next(c),o.complete()})))}}function Sr(t,e){return Xe(Er(t,e,arguments.length>=2,!1,!0))}function jn(t,e){return B(e)?z(t,e,1):z(t,1)}function Tt(t){return t<=0?function(){return _n}:Xe(function(e,n){var s=0;e.subscribe(Ze(n,function(r){++s<=t&&(n.next(r),t<=s&&n.complete())}))})}function $r(t){return Xe(function(e,n){bn(t).subscribe(Ze(n,function(){return n.complete()},Zs)),!n.closed&&e.subscribe(n)})}function Ve(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}var Rn={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},_e={0:8203,1:8204,2:8205,3:65279},Ee={0:String.fromCodePoint(_e[0]),1:String.fromCodePoint(_e[1]),2:String.fromCodePoint(_e[2]),3:String.fromCodePoint(_e[3])},Ir=new Array(4).fill(String.fromCodePoint(_e[0])).join("");function Tr(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+=Ee[i>>6&3]+Ee[i>>4&3]+Ee[i>>2&3]+Ee[i&3]}return Ir+s}function xr(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 Ar(t){try{new URL(t,t.startsWith("/")?"https://acme.com":void 0)}catch{return!1}return!0}function kr(t,e,n="auto"){return n===!0||n==="auto"&&(xr(t)||Ar(t))?t:`${t}${Tr(e)}`}Object.fromEntries(Object.entries(Ee).map(t=>[t[1],+t[0]]));Object.fromEntries(Object.entries(Rn).map(t=>t.reverse()));var Cr=`${Object.values(Rn).map(t=>`\\u{${t.toString(16)}}`).join("")}`,zt=new RegExp(`[${Cr}]{4,}`,"gu");function jr(t){var e;return{cleaned:t.replace(zt,""),encoded:((e=t.match(zt))==null?void 0:e[0])||""}}function Rr(t){return t&&JSON.parse(jr(JSON.stringify(t)).cleaned)}function Mr(t){return Rr(t)}const Bt=/\r\n|[\n\r\u2028\u2029]/;function Or(t,e,n){const s=t.split(Bt),r={start:Ft(e.start,s),end:e.end?Ft(e.end,s):void 0},{start:i,end:o,markerLines:a}=qr(r,s),c=`${o}`.length;return t.split(Bt,o).slice(i,o).map((l,p)=>{const d=i+1+p,u=` ${` ${d}`.slice(-c)} |`,h=a[d],f=!a[d+1];if(!h)return` ${u}${l.length>0?` ${l}`:""}`;let y="";if(Array.isArray(h)){const g=l.slice(0,Math.max(h[0]-1,0)).replace(/[^\t]/g," "),w=h[1]||1;y=[`
2 `,u.replace(/\d/g," ")," ",g,"^".repeat(w)].join(""),f&&n&&(y+=" "+n)}return[">",u,l.length>0?` ${l}`:"",y].join("")}).join(`
3`)}function qr(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,l=s.column;let p=Math.max(o-(r+1),0),d=Math.min(e.length,c+i);o===-1&&(p=0),c===-1&&(d=e.length);const u=c-o,h={};if(u)for(let f=0;f<=u;f++){const y=f+o;if(!a)h[y]=!0;else if(f===0){const g=e[y-1].length;h[y]=[a,g-a+1]}else if(f===u)h[y]=[0,l];else{const g=e[y-f].length;h[y]=[0,g]}}else a===l?a?h[o]=[a,0]:h[o]=!0:h[o]=[a,l-a];return{start:p,end:d,markerLines:h}}function Ft(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 lt=5;
3class Dr extends Error{response;statusCode=400;responseBody;traceId;details;constructor(e,n){const s=Mn(e,n);super(s.message),Object.assign(this,s)}}class Pr 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:Wr(n,t),traceId:Ur(t),message:"",details:void 0};if(!Ve(n))return s.message=`${ht(t,n)}${W(s.traceId)}`,s;const r=n.error;if(typeof r=="string"&&typeof n.message=="string")return s.message=`${r} - ${n.message}${W(s.traceId)}`,s;if(typeof r!="object"||r===null)return typeof r=="string"?s.message=`${r}${W(s.traceId)}`:typeof n.message=="string"?s.message=`${n.message}${W(s.traceId)}`:s.message=`${ht(t,n)}${W(s.traceId)}`,s;if(Lr(r)||Vr(r)){const i=r.items||[],o=i.slice(0,lt).map(c=>c.error?.description).filter(Boolean);let a=o.length?`:
4- ${o.join(`
5- `)}`:"";return i.length>lt&&(a+=`
6...and ${i.length-lt} more`),s.message=`${r.description}${W(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}${W(s.traceId)}`,s.details=r,s):(s.message=`${ht(t,n)}${W(s.traceId)}`,s)}function Lr(t){return"type"in t&&t.type==="mutationError"&&"description"in t&&typeof t.description=="string"}function Vr(t){return"type"in t&&t.type==="actionError"&&"description"in t&&typeof t.description=="string"}function On(t){return Ve(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?`
7(traceId: ${n})`:"";if(!s||typeof r>"u")return`GROQ query parse error: ${o}${a}`;const c=e?`
8
9Tag: ${e}`:"";return`GROQ query parse error:
10${Or(s,{start:r,end:i},o)}${c}${a}`}function ht(t,e){const n=typeof e=="string"?` (${Hr(e,100)})`:"",s=t.statusMessage?` ${t.statusMessage}`:"";return`${t.method}-request to ${t.url} resulted in HTTP ${t.statusCode}${s}${n}`}function Ur(t){const e=t?.headers?.traceparent;if(e)return e.split("-")[1]}function Wr(t,e){return(e.headers["content-type"]||"").toLowerCase().indexOf("application/json")!==-1?JSON.stringify(t,null,2):t}function W(t){return t?` (traceId: ${t})`:""}function Hr(t,e){return t.length>e?`${t.slice(0,e)}…`:t}class mt 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}`}else 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 Nr={onResponse:(t,e)=>{if(t.statusCode>=500)throw new Pr(t);if(t.statusCode>=400)throw new Dr(t,e);return t}};function zr(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 Gt(t,e={}){return tr([En({shouldRetry:Br}),...t,zr(e),nr(),sr(),rr(),Nr,ir({implementation:ee})])}function Br(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:En.shouldRetry(t,e,n)}const Fr="https://www.sanity.io/help/";function xt(t){return Fr+t}const Jt=["image","file"],Qt=["before","after","replace"],fe=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")},Gr=t=>{if(!/^[-a-z0-9]+$/i.test(t))throw new Error("`projectId` can only contain only a-z, 0-9 and dashes")},Jr=t=>{if(Jt.indexOf(t)===-1)throw new Error(`Invalid asset type: ${t}. Must be one of ${Jt.join(", ")}`)},$e=(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`)},pe=(t,e)=>{if(!e._id)throw new Error(`${t}() requires that the document contains an ID ("_id" property)`);Ue(t,e._id)},Qr=(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)`);Qr(t,e._type)},Kr=(t,e)=>{if(e._id&&e._id!==t)throw new Error(`The provided document ID (\`${e._id}
10\`) does not match the generated version ID (\`${t}\`)`)},Yr=(t,e,n)=>{const s="insert(at, selector, items)";if(Qt.indexOf(t)===-1){const r=Qt.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`)},te=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()}`)}},D=(t,e)=>{if(e.resource)throw new Error(`\`${t}\` does not support resource-based operations`)};function Xr(t){let e=!1,n;return(...s)=>(e||(n=t(...s),e=!0),n)}const U=t=>Xr((...e)=>console.warn(t.join(" "),...e)),Zr=U(["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"]),ei=U(["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."]),ti=U(["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."]),ni=U(["The `previewDrafts` perspective has been renamed to  `drafts` and will be removed in a future API version"]),si=U(["You have configured Sanity client to use a token in the browser. This may cause unintentional security issues.",`See ${xt("js-client-browser-token")} for more information and how to hide this warning.`]),ri=U(["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`."]),ii=U(["Using the Sanity client without specifying an API version is deprecated.",`See ${xt("js-client-api-version")}`]),oi=U(["You have called `createVersion()` with a defined `document`. The recommended approach is to provide a `baseId` and `releaseId` instead."]),ai=U(["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."]),ci="apicdn.sanity.io",Ie={apiHost:"https://api.sanity.io",apiVersion:"1",useProjectHostname:!0,stega:{enabled:!1}},ui=["localhost","127.0.0.1","0.0.0.0"],di=t=>ui.indexOf(t)!==-1;function li(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 At(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 Vn=(t,e)=>{const n={...e,...t,stega:{...typeof e.stega=="boolean"?{enabled:e.stega}:e.stega||Ie.stega,...typeof t.stega=="boolean"?{enabled:t.stega}:t.stega||{}}};n.apiVersion||ii();const s={...Ie,...n};s["~experimental_resource"]&&!s.resource&&(ai(),s.resource=s["~experimental_resource"]);const r=s.resource,i=s.useProjectHostname&&!r;if(typeof Promise>"u"){const h=xt("js-client-promise-polyfill");throw new Error(`No native Promise-implementation found, polyfill needed - see ${h}`)}if(i&&!s.projectId)throw new Error("Configuration must contain `projectId`");if(r&&Ln(s),typeof s.perspective<"u"&&At(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'?");
10if(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&&di(window.location.hostname),c=!!s.token;s.withCredentials&&c&&(ri(),s.withCredentials=!1),o&&a&&c&&s.ignoreBrowserTokenWarning!==!0?si():typeof s.useCdn>"u"&&ei(),i&&Gr(s.projectId),s.dataset&&fe(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===Ie.apiHost,s.useCdn===!0&&s.withCredentials&&Zr(),s.useCdn=s.useCdn!==!1&&!s.withCredentials,li(s.apiVersion);const l=s.apiHost.split("://",2),p=l[0],d=l[1],u=s.isDefaultApi?ci:d;return i?(s.url=`${p}://${s.projectId}.${d}/v${s.apiVersion}`,s.cdnUrl=`${p}://${s.projectId}.${u}/v${s.apiVersion}`):(s.url=`${s.apiHost}/v${s.apiVersion}`,s.cdnUrl=s.url),s};class vt extends Error{name="ConnectionFailedError";status;constructor(e,n={}){const{status:s,...r}=n;super(e,r),this.status=s}}class hi extends Error{name="DisconnectError";reason;constructor(e,n,s={}){super(e,s),this.reason=n}}class fi extends Error{name="ChannelError";data;constructor(e,n){super(e),this.data=n}}class pi extends Error{name="MessageError";data;constructor(e,n,s={}){super(e,s),this.data=n}}class Kt extends Error{name="MessageParseError"}const yi=["channelError","disconnect"];function Un(t,e){return $t(()=>{const n=t();return ar(n)?n:Y(n)}).pipe(z(n=>gi(n,e)))}function gi(t,e){return new ee(n=>{const s=e.includes("open"),r=e.includes("reconnect");function i(l){if("data"in l){const[u,h]=Yt(l);n.error(u?new Kt("Unable to parse EventSource error message",{cause:h}):new pi((h?.data).message,h));return}const p=l.status,d=typeof p=="number"?p:void 0;if(d!==void 0){n.error(new vt("EventSource connection failed",{status:d}));return}t.readyState===t.CLOSED?n.error(new vt("EventSource connection failed")):r&&n.next({type:"reconnect"})}function o(){n.next({type:"open"})}function a(l){const[p,d]=Yt(l);if(p){n.error(new Kt("Unable to parse EventSource message",{cause:p}));return}if(l.type==="channelError"){const u=new URL(t.url).searchParams.get("tag");n.error(new fi(mi(d?.data,u),d.data));return}if(l.type==="disconnect"){n.error(new hi(`Server disconnected client: ${d.data?.reason||"unknown error"}`));return}n.next({type:l.type,id:l.lastEventId,...d.data?{data:d.data}:{}})}t.addEventListener("error",i),s&&t.addEventListener("open",o);const c=[...new Set([...yi,...e])].filter(l=>l!=="error"&&l!=="open"&&l!=="reconnect");return c.forEach(l=>t.addEventListener(l,a)),()=>{t.removeEventListener("error",i),s&&t.removeEventListener("open",o),c.forEach(l=>t.removeEventListener(l,a)),t.close()}})}function Yt(t){try{const e=typeof t.data=="string"&&JSON.parse(t.data);return[null,{type:t.type,id:t.lastEventId,...vi(e)?{}:{data:e}}]}catch(e){return[e,null]}}function mi(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 vi(t){for(const e in t)return!1;return!0}function Wn(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(`
11`);throw new Error(`Unknown selection - must be one of:
12
13${e}`)}class Hn{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 $e("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 Yr(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,l=`${e}[${o}:${c}]`;return this.insert("replace",l,r||[])}ifRevisionId(e){return this.operations.ifRevisionID=e,this}serialize(){return{...Wn(this.selection),...this.operations}}toJSON(){return this.serialize()}reset(){return this.operations={},this}_assign(e,n,s=!0){return $e(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 X extends Hn{#e;constructor(e,n,s){super(e,n),this.#e=s}clone(){return new X(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");
13const n=typeof this.selection=="string",s=Object.assign({returnFirst:n,returnDocuments:!0},e);return this.#e.mutate({patch:this.serialize()},s)}}class N extends Hn{#e;constructor(e,n,s){super(e,n),this.#e=s}clone(){return new N(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 Nn={returnDocuments:!1};class zn{operations;trxId;constructor(e=[],n){this.operations=e,this.trxId=n}create(e){return $e("create",e),this._add({create:e})}createIfNotExists(e){const n="createIfNotExists";return $e(n,e),pe(n,e),this._add({[n]:e})}createOrReplace(e){const n="createOrReplace";return $e(n,e),pe(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 et extends zn{#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},Nn,e||{}))}patch(e,n){const s=typeof n=="function",r=typeof e!="string"&&e instanceof N,i=typeof e=="object"&&("query"in e||"id"in e);if(r)return this._add({patch:e.serialize()});if(s){const o=n(new N(e,{},this.#e));if(!(o instanceof N))throw new Error("function passed to `patch()` must return the patch");return this._add({patch:o.serialize()})}if(i){const o=new N(e,n||{},this.#e);return this._add({patch:o.serialize()})}return this._add({patch:{id:e,...n}})}}class tt extends zn{#e;constructor(e,n,s){super(e,s),this.#e=n}clone(){return new tt([...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},Nn,e||{}))}patch(e,n){const s=typeof n=="function";if(typeof e!="string"&&e instanceof X)return this._add({patch:e.serialize()});if(s){const r=n(new X(e,{},this.#e));if(!(r instanceof X))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 wi="X-Sanity-Project-ID";function bi(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[wi]=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 Bn=({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,l]of Object.entries(e))l!==void 0&&s.append(`$${c}`,JSON.stringify(l));for(const[c,l]of Object.entries(a))l&&s.append(c,`${l}`);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,Ei=(t={})=>({dryRun:t.dryRun,returnIds:!0,returnDocuments:_i(t.returnDocuments,!0),visibility:t.visibility||"sync",autoGenerateArrayKeys:t.autoGenerateArrayKeys,skipCrossDatasetReferenceValidation:t.skipCrossDatasetReferenceValidation}),nt=t=>t.type==="response",Si=t=>t.body,$i=(t,e)=>t.reduce((n,s)=>(n[e(s)]=s,n),Object.create(null)),Ii=11264;function Fn(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?Mr(r):r,c=i.filterResponse===!1?f=>f:f=>f.result,{cache:l,next:p,...d}={useAbortSignal:typeof i.signal<"u",resultSourceMap:o.enabled?"withKeyArraySelector":i.resultSourceMap,...i,returnQuery:i.filterResponse===!1&&i.returnQuery!==!1}
13,u=typeof l<"u"||typeof p<"u"?{...d,fetch:{cache:l,next:p}}:d,h=ne(t,e,"query",{query:s,params:a},u);return o.enabled?h.pipe(or(Tn(Sn(()=>Promise.resolve().then(()=>qo),void 0,import.meta.url).then(function(f){return f.stegaEncodeSourceMap$1}).then(({stegaEncodeSourceMap:f})=>f))),x(([f,y])=>{const g=y(f.result,f.resultSourceMap,o);return c({...f,result:g})})):h.pipe(x(c))}function ye(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 Re(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:M(t,"doc",r),json:!0,tag:s.tag,signal:s.signal,query:s.includeAllVersions!==void 0?{includeAllVersions:s.includeAllVersions}:void 0};return we(t,e,i).pipe(V(nt),x(o=>{const a=o.body.documents;return a?s.includeAllVersions?a:a[0]:s.includeAllVersions?[]:void 0}))}function Gn(t,e,n,s={}){const r={uri:M(t,"doc",n.join(",")),json:!0,tag:s.tag,signal:s.signal};return we(t,e,r).pipe(V(nt),x(i=>{const o=$i(i.body.documents||[],a=>a._id);return n.map(a=>o[a]||null)}))}const Xt=100;function Jn(t,e,n,s={}){if(n.length===0)return Y(new Set);const r=[];for(let o=0;o<n.length;o+=Xt)r.push(n.slice(o,o+Xt));const i=o=>we(t,e,{uri:M(t,"doc",o.map(encodeURIComponent).join(",")),tag:s.tag,signal:s.signal,query:{excludeContent:!0}}).pipe(V(nt),x(a=>{const c=new Set;for(const l of a.body.omitted||[])l.reason==="existence"&&c.add(l.id);return new Set(o.filter(l=>!c.has(l)))}));return Tn(r).pipe(jn(i),Sr((o,a)=>{for(const c of a)o.add(c);return o},new Set))}function Qn(t,e,n,s={}){return ne(t,e,"query",{query:"*[sanity::partOfRelease($releaseId)]",params:{releaseId:n}},s)}function Kn(t,e,n,s){return pe("createIfNotExists",n),st(t,e,n,"createIfNotExists",s)}function Yn(t,e,n,s){return pe("createOrReplace",n),st(t,e,n,"createOrReplace",s)}function Xn(t,e,n,s,r){return pe("createVersion",n),Dn("createVersion",n),oi(),_(t,e,{actionType:"sanity.action.document.version.create",publishedId:s,document:n},r)}function Zn(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?Re(n,r):Cn(n),ifBaseRevisionId:i};return _(t,e,a,o)}function es(t,e,n,s){return ne(t,e,"mutate",{mutations:[{delete:Wn(n)}]},s)}function ts(t,e,n,s=!1,r){return _(t,e,{actionType:"sanity.action.document.version.discard",versionId:n,purge:s},r)}function ns(t,e,n,s){return pe("replaceVersion",n),Dn("replaceVersion",n),_(t,e,{actionType:"sanity.action.document.version.replace",document:n},s)}function ss(t,e,n,s,r){return _(t,e,{actionType:"sanity.action.document.version.unpublish",versionId:n,publishedId:s},r)}function rs(t,e,n,s){let r;n instanceof N||n instanceof X?r={patch:n.serialize()}:n instanceof et||n instanceof tt?r=n.serialize():r=n;const i=Array.isArray(r)?r:[r],o=s&&s.transactionId||void 0;return ne(t,e,"mutate",{mutations:i,transactionId:o},s)}function _(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 ne(t,e,"actions",{actions:r,transactionId:i,skipCrossDatasetReferenceValidation:o,dryRun:a},s)}function ne(t,e,n,s,r={}){const i=n==="mutate",o=n==="actions",a=n==="query",c=i||o?"":Bn(s),l=!i&&!o&&c.length<Ii,p=l?c:"",d=r.returnFirst,{timeout:u,token:h,tag:f,headers:y,returnQuery:g,lastLiveEventId:w,cacheMode:$}=r,j=M(t,n,p),E={method:l?"GET":"POST",uri:j,json:!0,body:l?void 0:s,query:i&&Ei(r),timeout:u,headers:y,token:h,tag:f,returnQuery:g,perspective:r.perspective,variant:r.variant,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 we(t,e,E).pipe(V(nt),x(Si),x(J=>{if(!i)return J;const v=J.results||[];if(r.returnDocuments)return d?v[0]&&v[0].document:v.map(b=>b.document);const I=d?"documentId":"documentIds",T=d?v[0]&&v[0].id:v.map(b=>b.id);return{transactionId:J.transactionId,results:v,[I]:T}}))}function st(t,e,n,s,r={}){const i={[s]:n},o=Object.assign({returnFirst:!0,returnDocuments:!0},r);return ne(t,e,"mutate",{mutations:[i]},o)}const Me=t=>{const e=t.config();return e.dataset!==void 0&&e.projectId!==void 0||e.resource!==void 0},is=(t,e)=>Me(t)&&e.startsWith(M(t,"query")),Ti=(t,e)=>Me(t)&&e.startsWith(M(t,"mutate")),xi=(t,e)=>Me(t)&&e.startsWith(M(t,"doc","")),Ai=(t,e)=>Me(t)&&e.startsWith(M(t,"listen")),ki=(t,e)=>Me(t)&&e.startsWith(M(t,"history","")),Ci=(t,e)=>e.startsWith("/data/")||is(t,e)||Ti(t,e)||xi(t,e)||Ai(t,e)||ki(t,e);function we(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&&Ci(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&&is(t,r)){const d=n.resultSourceMap??i.resultSourceMap;d!==void 0&&d!==!1&&(n.query={resultSourceMap:d,...n.query});const u=n.perspective||i.perspective;typeof u<"u"&&(u==="previewDrafts"&&ni(),At(u),n.query={perspective:Array.isArray(u)?u.join(","):u,...n.query},(Array.isArray(u)&&u.length>0||u==="previewDrafts"||u==="drafts")&&a&&(a=!1,ti()));const h=n.variant||i.variant;typeof h=="string"&&(n.query={variant:h,...n.query}),typeof h=="object"&&(n.query={variantCondition:qi(h),...n.query}),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 l=bi(i,Object.assign({},n,{url:kt(t,r,a),callSiteStack:s})),p=new ee(d=>e(l,i.requester).subscribe(d));
13return n.signal?p.pipe(ji(n.signal)):p}function S(t,e,n){return we(t,e,n).pipe(V(s=>s.type==="response"),x(s=>s.body))}function M(t,e,n){const s=t.config();if(s.resource){Ln(s);const o=Oi(s),a=n!==void 0?`${e}/${n}`:e;return`${o}/${a}`.replace(/\/($|\?)/,"$1")}const r=te(s),i=`/${e}/${r}`;return`/data${n!==void 0?`${i}/${n}`:i}`.replace(/\/($|\?)/,"$1")}function kt(t,e,n=!1){const{url:s,cdnUrl:r}=t.config();return`${n?r:s}/${e.replace(/^\//,"")}`}function ji(t){return e=>new ee(n=>{const s=()=>n.error(Mi(t));if(t&&t.aborted){s();return}const r=e.subscribe(n);return t.addEventListener("abort",s),()=>{t.removeEventListener("abort",s),r.unsubscribe()}})}const Ri=!!globalThis.DOMException;function Mi(t){if(Ri)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 Oi=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 qi(t){return Object.entries(t).map(([e,n])=>`${e}:${n}`).toSorted()}function os(t,e,n){const s=te(t.config());return S(t,e,{method:"POST",uri:`/agent/action/generate/${s}`,body:n})}function Di(t,e,n){const s=te(t.config());return S(t,e,{method:"POST",uri:`/agent/action/patch/${s}`,body:n})}function Pi(t,e,n){const s=te(t.config());return S(t,e,{method:"POST",uri:`/agent/action/prompt/${s}`,body:n})}function as(t,e,n){const s=te(t.config());return S(t,e,{method:"POST",uri:`/agent/action/transform/${s}`,body:n})}function cs(t,e,n){const s=te(t.config());return S(t,e,{method:"POST",uri:`/agent/action/translate/${s}`,body:n})}class Li{#e;#t;constructor(e,n){this.#e=e,this.#t=n}generate(e){return os(this.#e,this.#t,e)}transform(e){return as(this.#e,this.#t,e)}translate(e){return cs(this.#e,this.#t,e)}}class Vi{#e;#t;constructor(e,n){this.#e=e,this.#t=n}generate(e){return m(os(this.#e,this.#t,e))}transform(e){return m(as(this.#e,this.#t,e))}translate(e){return m(cs(this.#e,this.#t,e))}prompt(e){return m(Pi(this.#e,this.#t,e))}patch(e){return m(Di(this.#e,this.#t,e))}}class Ui{#e;#t;constructor(e,n){this.#e=e,this.#t=n}upload(e,n,s){return us(this.#e,this.#t,e,n,s)}}class Wi{#e;#t;constructor(e,n){this.#e=e,this.#t=n}upload(e,n,s){const r=us(this.#e,this.#t,e,n,s);return m(r.pipe(V(i=>i.type==="response"),x(i=>i.body.document)))}}function us(t,e,n,s,r={}){Jr(n);let i=r.extract||void 0;i&&!i.length&&(i=["none"]);const o=t.config(),a=Ni(r,s),{tag:c,label:l,title:p,description:d,creditLine:u,filename:h,source:f}=a,y=o.resource?.type==="media-library",g=y?{title:p,filename:h}:{label:l,title:p,description:d,filename:h,meta:i,creditLine:u};return f&&!y&&(g.sourceId=f.id,g.sourceName=f.name,g.sourceUrl=f.url),we(t,e,{tag:c,method:"POST",timeout:a.timeout||0,uri:Hi(o,n),headers:a.contentType?{"Content-Type":a.contentType}:{},query:g,body:s})}function Hi(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=te(t);return`assets/${n}/${r}`}function Ni(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 zi=(t,e)=>Object.keys(e).concat(Object.keys(t)).reduce((n,s)=>(n[s]=typeof t[s]>"u"?e[s]:t[s],n),{});const Bi=(t,e)=>e.reduce((n,s)=>(typeof t[s]>"u"||(n[s]=t[s]),n),{}),ds=$t(()=>Sn(()=>import("./oF805R1D.js"),[],import.meta.url)).pipe(x(({default:t})=>t),er(1)),Fi=new Set([408,429]);function ls(){return function(t){return t.pipe($n((e,n)=>e instanceof vt&&(typeof e.status!="number"||e.status<400||e.status>=500||Fi.has(e.status))?cr(Y({type:"reconnect"}),ur(1e3).pipe(z(()=>n))):It(()=>e)))}}const Gi=14800,Ji=["includePreviousRevision","includeResult","includeMutations","includeAllVersions","visibility","effectFormat","enableResume","tag"],Qi={includeResult:!0};function hs(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,l={...zi(n,Qi),tag:c},p=Bi(l,Ji),d=Bn({query:t,params:e,options:{tag:c,...p}}),u=`${s}${M(this,"listen",d)}`;if(u.length>Gi)return It(()=>new Error("Query too large for listener"));const h=l.events?l.events:["mutation"],f={};return i&&(f.withCredentials=!0),(r||a)&&(f.headers={},r&&(f.headers.Authorization=`Bearer ${r}`),a&&Object.assign(f.headers,a)),Un(()=>(typeof EventSource>"u"||f.headers?ds:Y(EventSource)).pipe(x(y=>new y(u,f))),h).pipe(ls(),V(y=>h.includes(y.type)),x(y=>({type:y.type,..."data"in y?y.data:{}})))}function Ki(t,e){return Yi(typeof t=="function"?{predicate:t,...e}:t)}function Yi(t){return e=>{let n,s=!1;const{predicate:r,...i}=t,o=e.pipe(dr(c=>{t.predicate(c)&&(s=!0,n=c)}),In(()=>{s=!1,n=void 0}),lr(i)),a=new ee(c=>{s&&c.next(n),c.complete()});return hr(o,a)}}const Zt="2021-03-25";class fs{#e;constructor(e){this.#e=e}events({includeDrafts:e=!1,tag:n,waitFor:s}={}
13){const{projectId:r,apiVersion:i,token:o,withCredentials:a,requestTagPrefix:c,headers:l}=this.#e.config(),p=i.replace(/^v/,"");if(p!=="X"&&p<Zt)throw new Error(`The live events API requires API version ${Zt} 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 d=M(this.#e,"live/events"),u=new URL(this.#e.getUrl(d,!1)),h=n&&c?[c,n].join("."):n;h&&u.searchParams.set("tag",h),e&&u.searchParams.set("includeDrafts","true"),s&&u.searchParams.set("waitFor",s);const f={};e&&a&&(f.withCredentials=!0),(e&&o||l)&&(f.headers={},e&&o&&(f.headers.Authorization=`Bearer ${o}`),l&&Object.assign(f.headers,l));const y=`${u.href}::${JSON.stringify(f)}`,g=ft.get(y);if(g)return g;const w=Un(()=>(typeof EventSource>"u"||f.headers?ds:Y(EventSource)).pipe(x(E=>new E(u.href,f))),["message","restart","welcome","reconnect","goaway"]),$=Xi(new URL(this.#e.getUrl("/check/cors",!1)),r,f.withCredentials===!0),j=w.pipe(ls(),z(E=>E.type==="reconnect"?$.pipe(z(()=>Y(E))):Y(E)),$n(E=>E instanceof mt?It(()=>E):$.pipe(z(()=>{throw E}))),x(E=>{if(E.type==="message"){const{data:J,...v}=E;return{...v,tags:J.tags}}return E})).pipe(In(()=>ft.delete(y)),Ki({predicate:E=>E.type==="welcome"}));return ft.set(y,j),j}}function Xi(t,e,n){return new ee(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 mt({projectId:e,credentials:!0}));return}if(o?.result?.allowed===!1){s.error(new mt({projectId:e,credentials:n}));return}s.next(),s.complete()}}).catch(()=>{i.aborted||s.closed||(s.next(),s.complete())}),()=>r.abort()})}const ft=new Map;class Zi{#e;#t;constructor(e,n){this.#e=e,this.#t=n}create(e,n){return ue(this.#e,this.#t,"PUT",e,n)}edit(e,n){return ue(this.#e,this.#t,"PATCH",e,n)}delete(e){return ue(this.#e,this.#t,"DELETE",e)}list(){D("dataset",this.#e.config());const e=this.#e.config(),n=e.projectId;let s="/datasets";return e.useProjectHostname===!1&&(s=`/projects/${n}/datasets`),S(this.#e,this.#t,{uri:s,tag:null})}getEmbeddingsSettings(e){return D("dataset",this.#e.config()),fe(e),S(this.#e,this.#t,{uri:We(this.#e,e),tag:null})}editEmbeddingsSettings(e,n){return D("dataset",this.#e.config()),fe(e),S(this.#e,this.#t,{method:"PUT",uri:We(this.#e,e),body:n,tag:null})}}class eo{#e;#t;constructor(e,n){this.#e=e,this.#t=n}create(e,n){return D("dataset",this.#e.config()),m(ue(this.#e,this.#t,"PUT",e,n))}edit(e,n){return D("dataset",this.#e.config()),m(ue(this.#e,this.#t,"PATCH",e,n))}delete(e){return D("dataset",this.#e.config()),m(ue(this.#e,this.#t,"DELETE",e))}list(){D("dataset",this.#e.config());const e=this.#e.config(),n=e.projectId;let s="/datasets";return e.useProjectHostname===!1&&(s=`/projects/${n}/datasets`),m(S(this.#e,this.#t,{uri:s,tag:null}))}getEmbeddingsSettings(e){return D("dataset",this.#e.config()),fe(e),m(S(this.#e,this.#t,{uri:We(this.#e,e),tag:null}))}editEmbeddingsSettings(e,n){return D("dataset",this.#e.config()),fe(e),m(S(this.#e,this.#t,{method:"PUT",uri:We(this.#e,e),body:n,tag:null}))}}function We(t,e){const n=t.config();return n.useProjectHostname===!1?`/projects/${n.projectId}/datasets/${e}/settings/embeddings`:`/datasets/${e}/settings/embeddings`}function ue(t,e,n,s,r){return D("dataset",t.config()),fe(s),S(t,e,{method:n,uri:`/datasets/${s}`,body:r,tag:null})}class ps{#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}=ro(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=io(i,a),l=oo(n);return S(this.#e,this.#t,{method:"GET",uri:c,query:l})}}class to{#e;#t;constructor(e,n){this.#e=e,this.#t=n}
13getPlaybackInfo(e,n={}){return m(new ps(this.#e.observable,this.#t).getPlaybackInfo(e,n))}}const no=/^media-library:(ml[^:]+):([^:]+)$/;function so(t){return typeof t=="object"&&"_ref"in t}function ro(t){const e=so(t)?t._ref:t,n=no.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 io(t,e){return`/media-libraries/${e}/video/${t}/playback-info`}function oo(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 ao{#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"),S(this.#e,this.#t,{uri:s,query:n})}getById(e){return S(this.#e,this.#t,{uri:`/projects/${e}`})}}class co{#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"),m(S(this.#e,this.#t,{uri:s,query:n}))}getById(e){return m(S(this.#e,this.#t,{uri:`/projects/${e}`}))}}const en=fr("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789",8),He=(t,e)=>e?Re(t,e):Cn(t);function Ne(t,{releaseId:e,publishedId:n,document:s}){if(n&&s._id){const r=He(n,e);return Kr(r,s),r}if(s._id){const r=kn(s._id),i=pr(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 He(n,e);throw new Error(`\`${t}()\` requires either a publishedId or a document with an \`_id\``)}const uo=(t,e)=>{if(typeof t=="object"&&t!==null&&("releaseId"in t||"metadata"in t)){const{releaseId:n=en(),metadata:s={}}=t;return[n,s,e]}return[en(),{},t]},ys=(t,e)=>{const[n,s,r]=uo(t,e),i={...s,releaseType:s.releaseType||"undecided"};return{action:{actionType:"sanity.action.release.create",releaseId:n,metadata:i},options:r}};class lo{#e;#t;constructor(e,n){this.#e=e,this.#t=n}get({releaseId:e},n){return ye(this.#e,this.#t,`_.releases.${e}`,n)}create(e,n){const{action:s,options:r}=ys(e,n),{releaseId:i,metadata:o}=s;return _(this.#e,this.#t,s,r).pipe(x(a=>({...a,releaseId:i,metadata:o})))}edit({releaseId:e,patch:n},s){const r={actionType:"sanity.action.release.edit",releaseId:e,patch:n};return _(this.#e,this.#t,r,s)}publish({releaseId:e},n){const s={actionType:"sanity.action.release.publish",releaseId:e};return _(this.#e,this.#t,s,n)}archive({releaseId:e},n){const s={actionType:"sanity.action.release.archive",releaseId:e};return _(this.#e,this.#t,s,n)}unarchive({releaseId:e},n){const s={actionType:"sanity.action.release.unarchive",releaseId:e};return _(this.#e,this.#t,s,n)}schedule({releaseId:e,publishAt:n},s){const r={actionType:"sanity.action.release.schedule",releaseId:e,publishAt:n};return _(this.#e,this.#t,r,s)}unschedule({releaseId:e},n){const s={actionType:"sanity.action.release.unschedule",releaseId:e};return _(this.#e,this.#t,s,n)}delete({releaseId:e},n){const s={actionType:"sanity.action.release.delete",releaseId:e};return _(this.#e,this.#t,s,n)}fetchDocuments({releaseId:e},n){return Qn(this.#e,this.#t,e,n)}}class ho{#e;#t;constructor(e,n){this.#e=e,this.#t=n}
13get({releaseId:e},n){return m(ye(this.#e,this.#t,`_.releases.${e}`,n))}async create(e,n){const{action:s,options:r}=ys(e,n),{releaseId:i,metadata:o}=s;return{...await m(_(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 m(_(this.#e,this.#t,r,s))}publish({releaseId:e},n){const s={actionType:"sanity.action.release.publish",releaseId:e};return m(_(this.#e,this.#t,s,n))}archive({releaseId:e},n){const s={actionType:"sanity.action.release.archive",releaseId:e};return m(_(this.#e,this.#t,s,n))}unarchive({releaseId:e},n){const s={actionType:"sanity.action.release.unarchive",releaseId:e};return m(_(this.#e,this.#t,s,n))}schedule({releaseId:e,publishAt:n},s){const r={actionType:"sanity.action.release.schedule",releaseId:e,publishAt:n};return m(_(this.#e,this.#t,r,s))}unschedule({releaseId:e},n){const s={actionType:"sanity.action.release.unschedule",releaseId:e};return m(_(this.#e,this.#t,s,n))}delete({releaseId:e},n){const s={actionType:"sanity.action.release.delete",releaseId:e};return m(_(this.#e,this.#t,s,n))}fetchDocuments({releaseId:e},n){return m(Qn(this.#e,this.#t,e,n))}}class fo{#e;#t;constructor(e,n){this.#e=e,this.#t=n}getById(e){return S(this.#e,this.#t,{uri:`/users/${e}`})}}class po{#e;#t;constructor(e,n){this.#e=e,this.#t=n}getById(e){return m(S(this.#e,this.#t,{uri:`/users/${e}`}))}}class ze{assets;datasets;live;mediaLibrary;projects;users;agent;releases;#e;#t;#n;listen=hs;constructor(e,n=Ie){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 de(e,{...n,_requestHandler:void 0})),s(a,c=>e(c,o),r)}})():e,this.assets=new Ui(this,this.#n),this.datasets=new Zi(this,this.#n),this.live=new fs(this),this.mediaLibrary={video:new ps(this,this.#n)},this.projects=new ao(this,this.#n),this.users=new fo(this,this.#n),this.agent={action:new Li(this,this.#n)},this.releases=new lo(this,this.#n)}clone(){return new ze(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=Vn(e,this.#e||{}),this}withConfig(e){const n=this.config();return new ze(this.#t,{...n,...e,stega:{...n.stega||{},...typeof e?.stega=="boolean"?{enabled:e.stega}:e?.stega||{}}})}fetch(e,n,s){return Fn(this,this.#n,this.#e.stega,e,n,s)}getDocument(e,n){if(n?.includeAllVersions===!0)return ye(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 ye(this,this.#n,e,s)}getDocuments(e,n){return Gn(this,this.#n,e,n)}documentsExists(e,n){return Jn(this,this.#n,e,n)}create(e,n){return st(this,this.#n,e,"create",n)}createIfNotExists(e,n){return Kn(this,this.#n,e,n)}createOrReplace(e,n){return Yn(this,this.#n,e,n)}createVersion({document:e,publishedId:n,releaseId:s,baseId:r,ifBaseRevisionId:i},o){if(!e)return Zn(this,this.#n,n,r,s,i,o);const a=Ne("createVersion",{document:e,publishedId:n,releaseId:s}),c={...e,_id:a},l=n||xn(e._id);return Xn(this,this.#n,c,l,o)}delete(e,n){return es(this,this.#n,e,n)}discardVersion({releaseId:e,publishedId:n},s,r){const i=He(n,e);return ts(this,this.#n,i,s,r)}replaceVersion({document:e,publishedId:n,releaseId:s},r){const i=Ne("replaceVersion",{document:e,publishedId:n,releaseId:s}),o={...e,_id:i};return ns(this,this.#n,o,r)}unpublishVersion({releaseId:e,publishedId:n},s){const r=Re(n,e);return ss(this,this.#n,r,n,s)}mutate(e,n){return rs(this,this.#n,e,n)}patch(e,n){return new X(e,n,this)}transaction(e){return new tt(e,this)}action(e,n){return _(this,this.#n,e,n)}request(e){return S(this,this.#n,e)}getUrl(e,n){return kt(this,e,n)}getDataUrl(e,n){return M(this,e,n)}}class de{assets;datasets;live;mediaLibrary;projects;users;agent;releases;observable;#e;#t;#n;listen=hs;constructor(e,n=Ie){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 de(e,{...n,_requestHandler:void 0})),s(a,c=>e(c,o),r)}})():e,this.assets=new Wi(this,this.#n),this.datasets=new eo(this,this.#n),this.live=new fs(this),this.mediaLibrary={video:new to(this,this.#n)},this.projects=new co(this,this.#n),this.users=new po(this,this.#n),this.agent={action:new Vi(this,this.#n)},this.releases=new ho(this,this.#n),this.observable=new ze(e,n)}clone(){return new de(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=Vn(e,this.#e||{}),this}withConfig(e){const n=this.config();return new de(this.#t,{...n,...e,stega:{...n.stega||{},...typeof e?.stega=="boolean"?{enabled:e.stega}:e?.stega||{}}})}fetch(e,n,s){return m(Fn(this,this.#n,this.#e.stega,e,n,s))}getDocument(e,n){if(n?.includeAllVersions===!0)return m(ye(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 m(ye(this,this.#n,e,s))}getDocuments(e,n){return m(Gn(this,this.#n,e,n))}
13documentsExists(e,n){return m(Jn(this,this.#n,e,n))}create(e,n){return m(st(this,this.#n,e,"create",n))}createIfNotExists(e,n){return m(Kn(this,this.#n,e,n))}createOrReplace(e,n){return m(Yn(this,this.#n,e,n))}createVersion({document:e,publishedId:n,releaseId:s,baseId:r,ifBaseRevisionId:i},o){if(!e)return ct(Zn(this,this.#n,n,r,s,i,o));const a=Ne("createVersion",{document:e,publishedId:n,releaseId:s}),c={...e,_id:a},l=n||xn(e._id);return ct(Xn(this,this.#n,c,l,o))}delete(e,n){return m(es(this,this.#n,e,n))}discardVersion({releaseId:e,publishedId:n},s,r){const i=He(n,e);return m(ts(this,this.#n,i,s,r))}replaceVersion({document:e,publishedId:n,releaseId:s},r){const i=Ne("replaceVersion",{document:e,publishedId:n,releaseId:s}),o={...e,_id:i};return ct(ns(this,this.#n,o,r))}unpublishVersion({releaseId:e,publishedId:n},s){const r=Re(n,e);return m(ss(this,this.#n,r,n,s))}mutate(e,n){return m(rs(this,this.#n,e,n))}patch(e,n){return new N(e,n,this)}transaction(e){return new et(e,this)}action(e,n){return m(_(this,this.#n,e,n))}request(e){return m(S(this,this.#n,e))}dataRequest(e,n,s){return m(ne(this,this.#n,e,n,s))}getUrl(e,n){return kt(this,e,n)}getDataUrl(e,n){return M(this,e,n)}}function yo(t,e){return{requester:Gt(t),createClient:n=>{const s=Gt(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 go=[];yo(go,de);const gs=/_key\s*==\s*['"](.*)['"]/;function mo(t){return typeof t=="string"?gs.test(t.trim()):typeof t=="object"&&"_key"in t}function ms(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(mo(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 Be={"\f":"\\f","\n":"\\n","\r":"\\r","	":"\\t","'":"\\'","\\":"\\\\"},tn={"\\f":"\f","\\n":`
14`,"\\r":"\r","\\t":"	","\\'":"'","\\\\":"\\"};function vo(t){return`$${t.map(e=>typeof e=="string"?`['${e.replace(/[\f\n\r\t'\\]/g,n=>Be[n])}']`:typeof e=="number"?`[${e}]`:e._key!==""?`[?(@._key=='${e._key.replace(/['\\]/g,n=>Be[n])}')]`:`[${e._index}]`).join("")}`}function wo(t){return t.map(e=>typeof e=="string"?`['${e.replace(/[\f\n\r\t'\\]/g,n=>Be[n])}']`:typeof e=="number"?`[${e}]`:e._key!==""?`[?(@._key=='${e._key.replace(/['\\]/g,n=>Be[n])}')]`:`[${e._index}]`)}function nn(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=>tn[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=>tn[i]);e.push({_key:r,_index:-1});continue}}return e}function vs(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 sn(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 bo(t,e){if(!e?.mappings)return;const n=vo(sn(t));if(e.mappings[n]!==void 0)return{mapping:e.mappings[n],matchedPath:n,pathSuffix:""};const s=wo(sn(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 _o(t){return t!==null&&Array.isArray(t)}function re(t,e,n=[]){if(_o(t))return t.map((s,r)=>{if(Ve(s)){const i=s._key;if(typeof i=="string")return re(s,e,n.concat({_key:i,_index:r}))}return re(s,e,n.concat(r))});if(Ve(t)){if(t._type==="block"||t._type==="span"){const s={...t};return t._type==="block"?s.children=re(t.children,e,n.concat("children")):t._type==="span"&&(s.text=re(t.text,e,n.concat("text"))),s}return Object.fromEntries(Object.entries(t).map(([s,r])=>[s,re(r,e,n.concat(s))]))}return e(t,n)}function ws(t,e,n){return re(t,(s,r)=>
14{if(typeof s!="string")return s;const i=bo(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],l=e.paths[o.source.path],p=nn(a),d=nn(l).concat(r.slice(p.length));return n({sourcePath:d,sourceDocument:c,resultPath:r,value:s})})}const Eo="drafts",So="versions",bs=`${Eo}.`,$o=`${So}.`;function _s(t){return t.startsWith(bs)}function rt(t){return t.startsWith($o)}function Io(t){return!_s(t)&&!rt(t)}function To(t){if(!rt(t))return;const[e,n]=t.split(".");return n}function xo(t){return rt(t)?t.split(".").slice(2).join("."):_s(t)?t.slice(bs.length):t}function Ao(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 l=n==="default"?void 0:n,p=s==="default"?void 0:s,d=xo(r),u=Array.isArray(o)?ms(vs(o)):o,h=new URLSearchParams({baseUrl:e,id:d,type:i,path:u});if(l&&h.set("workspace",l),p&&h.set("tool",p),a&&h.set("projectId",a),c&&h.set("dataset",c),Io(r))h.set("perspective","published");else if(rt(r)){const g=To(r);h.set("perspective",g)}const f=[e==="/"?"":e];l&&f.push(l);const y=["mode=presentation",`id=${d}`,`type=${i}`,`path=${encodeURIComponent(u)}`];return p&&y.push(`tool=${p}`),f.push("intent","edit",`${y.join(";")}?${h}`),f.join("/")}function ko(t){let e=typeof t=="string"?t:t.baseUrl;return e!=="/"&&(e=e.replace(/\/$/,"")),typeof t=="string"?{baseUrl:e}:{...t,baseUrl:e}}const rn=({sourcePath:t,resultPath:e,value:n})=>{if(jo(n)||Mo(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")||on(t)||on(e)||typeof s=="string"&&Co.has(s))},Co=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 jo(t){return/^\d{4}-\d{2}-\d{2}/.test(t)?!!Date.parse(t):!1}const Ro=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 Mo(t){try{const{protocol:e}=new URL(t,t.startsWith("/")?"https://acme.com":void 0);return Ro.has(e)||e.startsWith("web+")}catch{return!1}}function on(t){return t.some(e=>typeof e=="string"&&e.match(/type/i)!==null)}const Pe=20;function Ct(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=ws(t,e,({sourcePath:c,sourceDocument:l,resultPath:p,value:d})=>{if((typeof s=="function"?s({sourcePath:c,resultPath:p,filterDefault:rn,sourceDocument:l,value:d}):rn({sourcePath:c,resultPath:p,value:d}))===!1)return r&&o.skipped.push({path:an(c),value:`${d.slice(0,Pe)}${d.length>Pe?"...":""}`,length:d.length}),d;r&&o.encoded.push({path:an(c),value:`${d.slice(0,Pe)}${d.length>Pe?"...":""}`,length:d.length});const{baseUrl:u,workspace:h,tool:f}=ko(typeof n.studioUrl=="function"?n.studioUrl(l):n.studioUrl);if(!u)return d;const{_id:y,_type:g,_projectId:w,_dataset:$}=l;return kr(d,{origin:"sanity.io",href:Ao({baseUrl:u,workspace:h,tool:f,id:y,type:g,path:c,...!n.omitCrossDatasetReferenceData&&{dataset:$,projectId:w}})},!1)});if(r){const c=o.skipped.length,l=o.encoded.length;if((c||l)&&((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:d}of o.skipped)p.add(d.replace(gs,"0").replace(/\[\d+\]/g,"[]"));r?.log?.("[@sanity/client]: List of skipped paths",[...p.values()])}(c||l)&&r?.groupEnd?.()}return a}function an(t){return ms(vs(t))}var Oo=Object.freeze({__proto__:null,stegaEncodeSourceMap:Ct});const qo=Object.freeze(Object.defineProperty({__proto__:null,encodeIntoResult:ws,stegaEncodeSourceMap:Ct,stegaEncodeSourceMap$1:Oo}
14,Symbol.toStringTag,{value:"Module"})),A=[];for(let t=0;t<256;++t)A.push((t+256).toString(16).slice(1));function Do(t,e=0){return(A[t[e+0]]+A[t[e+1]]+A[t[e+2]]+A[t[e+3]]+"-"+A[t[e+4]]+A[t[e+5]]+"-"+A[t[e+6]]+A[t[e+7]]+"-"+A[t[e+8]]+A[t[e+9]]+"-"+A[t[e+10]]+A[t[e+11]]+A[t[e+12]]+A[t[e+13]]+A[t[e+14]]+A[t[e+15]]).toLowerCase()}const Po=new Uint8Array(16);function Lo(){return crypto.getRandomValues(Po)}function Es(t,e,n){return crypto.randomUUID?crypto.randomUUID():Vo(t)}function Vo(t,e,n){t=t||{};const s=t.random??t.rng?.()??Lo();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,Do(s)}function Uo(){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 Wo(){const t=Uo();if(t.__xstate__)return t.__xstate__}const Ho=t=>{if(typeof window>"u")return;const e=Wo();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 Ss=".",No="",$s="",zo="#",Bo="*",Is="xstate.init",Fo="xstate.error",Fe="xstate.stop";function Go(t,e){return{type:`xstate.after.${t}.${e}`}}function wt(t,e){return{type:`xstate.done.state.${t}`,output:e}}function Jo(t,e){return{type:`xstate.done.actor.${t}`,output:e,actorId:t}}function Ts(t,e){return{type:`xstate.error.actor.${t}`,error:e,actorId:t}}function xs(t){return{type:Is,input:t}}function q(t){setTimeout(()=>{throw t})}const Qo=typeof Symbol=="function"&&Symbol.observable||"@@observable";function As(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?As(n[r],s[r]):!1)}function jt(t){if(Cs(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(ja(t))return t.value;if(typeof t!="string")return t;const e=jt(t);return Ko(e)}function Ko(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 ks(t){return Cs(t)?t:[t]}function L(t){return t===void 0?[]:ks(t)}function bt(t,e,n,s){return typeof t=="function"?t({context:e,event:n,self:s}):t}function Cs(t){return Array.isArray(t)}function Yo(t){return t.type.startsWith("xstate.error.actor")}function ie(t){return ks(t).map(e=>typeof e>"u"||typeof e=="string"?{target:e}:e)}
14function js(t){if(!(t===void 0||t===No))return L(t)}function Le(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 ln(t,e){return`${e}.${t}`}function Rt(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 Rs(t,e){if(e===t||e===Bo)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 hn(t,e){return`${t.sessionId}.${e}`}let Xo=0;function Zo(t,e){const n=new Map,s=new Map,r=new WeakMap,i=new Set,o={},{clock:a,logger:c}=e,l={schedule:(u,h,f,y,g=Math.random().toString(36).slice(2))=>{const w={source:u,target:h,event:f,delay:y,id:g,startedAt:Date.now()},$=hn(u,g);d._snapshot._scheduledEvents[$]=w;const j=a.setTimeout(()=>{delete o[$],delete d._snapshot._scheduledEvents[$],d._relay(u,h,f)},y);o[$]=j},cancel:(u,h)=>{const f=hn(u,h),y=o[f];delete o[f],delete d._snapshot._scheduledEvents[f],y!==void 0&&a.clearTimeout(y)},cancelAll:u=>{for(const h in d._snapshot._scheduledEvents){const f=d._snapshot._scheduledEvents[h];f.source===u&&l.cancel(u,f.id)}}},p=u=>{if(!i.size)return;const h={...u,rootId:t.sessionId};i.forEach(f=>f.next?.(h))},d={_snapshot:{_scheduledEvents:(e?.snapshot&&e.snapshot.scheduler)??{}},_bookId:()=>`x:${Xo++}`,_register:(u,h)=>(n.set(u,h),u),_unregister:u=>{n.delete(u.sessionId);const h=r.get(u);h!==void 0&&(s.delete(h),r.delete(u))},get:u=>s.get(u),getAll:()=>Object.fromEntries(s.entries()),_set:(u,h)=>{const f=s.get(u);if(f&&f!==h)throw new Error(`Actor with system ID '${u}' already exists.`);s.set(u,h),r.set(h,u)},inspect:u=>{const h=Le(u);return i.add(h),{unsubscribe(){i.delete(h)}}},_sendInspectionEvent:p,_relay:(u,h,f)=>{d._sendInspectionEvent({type:"@xstate.event",sourceRef:u,actorRef:h,event:f}),h._send(f)},scheduler:l,getSnapshot:()=>({_scheduledEvents:{...d._snapshot._scheduledEvents}}),start:()=>{const u=d._snapshot._scheduledEvents;d._snapshot._scheduledEvents={};for(const h in u){const{source:f,target:y,event:g,delay:w,id:$}=u[h];l.schedule(f,y,g,w,$)}},_clock:a,_logger:c};return d}let pt=!1;const Mt=1;let C=(function(t){return t[t.NotStarted=0]="NotStarted",t[t.Running=1]="Running",t[t.Stopped=2]="Stopped",t})({});const ea={clock:{setTimeout:(t,e)=>setTimeout(t,e),clearTimeout:t=>clearTimeout(t)},logger:console.log.bind(console),devTools:!1};class ta{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=C.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={...ea,...n},{clock:r,logger:i,parent:o,syncSnapshot:a,id:c,systemId:l,inspect:p}=s;this.system=o?o.system:Zo(this,{clock:r,logger:i}),p&&!o&&this.system.inspect(Le(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:d=>{this._deferred.push(d)},system:this.system,stopChild:d=>{if(d._parent!==this)throw new Error(`Cannot stop child actor ${d.id} of ${this.id} because it is not a child`);d._stop()},emit:d=>{const u=this.eventListeners.get(d.type),h=this.eventListeners.get("*");if(!u&&!h)return;const f=[...u?u.values():[],...h?h.values():[]];for(const y of f)try{y(d)}catch(g){q(g)}},actionExecutor:d=>{const u=()=>{if(this._actorScope.system._sendInspectionEvent({type:"@xstate.action",actorRef:this,action:{type:d.type,params:d.params}}),!d.exec)return;const h=pt;try{pt=!0,d.exec(d.info,d.params)}finally{pt=h}};this._processingStatus===C.Running?u():this._deferred.push(u)}},this.send=this.send.bind(this),this.system._sendInspectionEvent({type:"@xstate.actor",actorRef:this}),l&&(this.systemId=l,this.system._set(l,this)),this._initState(n?.snapshot??n?.state),l&&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){q(i)}break;case"done":for(const r of this.observers)try{r.next?.(e)}catch(i){q(i)}this._stopProcedure(),this._complete(),this._doneEvent=Jo(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=Le(e,n,s);if(this._processingStatus!==C.Stopped)this.observers.add(r);else switch(this._snapshot.status){case"done":try{r.complete?.()}catch(i){q(i)}break;case"error":{const i=this._snapshot.error;if(!r.error)q(i);else try{r.error(i)}catch(o){q(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=Le(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())}}
14start(){if(this._processingStatus===C.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=C.Running;const e=xs(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===Fe&&(this._stopProcedure(),this._complete())}_stop(){return this._processingStatus===C.Stopped?this:(this.mailbox.clear(),this._processingStatus===C.NotStarted?(this._processingStatus=C.Stopped,this):(this.mailbox.enqueue({type:Fe}),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){q(n)}this.observers.clear(),this.eventListeners.clear()}_reportError(e){if(!this.observers.size){this._parent||q(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){q(i)}}this.observers.clear(),this.eventListeners.clear(),n&&q(e)}_error(e){this._stopProcedure(),this._reportError(e),this._parent&&this.system._relay(this,this._parent,Ts(this.id,e))}_stopProcedure(){return this._processingStatus!==C.Running?this:(this.system.scheduler.cancelAll(this),this.mailbox.clear(),this.mailbox=new cn(this._process.bind(this)),this._processingStatus=C.Stopped,this.system._unregister(this),this)}_send(e){this._processingStatus!==C.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:Ho)(this)}toJSON(){return{xstate$$type:Mt,id:this.id}}getPersistedSnapshot(e){return this.logic.getPersistedSnapshot(this._snapshot,e)}[Qo](){return this}getSnapshot(){return this._snapshot}}function je(t,...[e]){return new ta(t,e)}function na(t,e,n,s,{sendId:r}){const i=typeof r=="function"?r(n,s):r;return[e,{sendId:i},void 0]}function sa(t,e){t.defer(()=>{t.system.scheduler.cancel(t.self,e.sendId)})}function Ot(t){function e(n,s){}return e.type="xstate.cancel",e.sendId=t,e.resolve=na,e.execute=sa,e}function ra(t,e,n,s,{id:r,systemId:i,src:o,input:a,syncSnapshot:c}){const l=typeof o=="string"?Rt(e.machine,o):o,p=typeof r=="function"?r(n):r;let d,u;return l&&(u=typeof a=="function"?a({context:e.context,event:n.event,self:t.self}):a,d=je(l,{id:p,src:o,parent:t.self,syncSnapshot:c,systemId:i,input:u})),[G(e,{children:{...e.children,[p]:d}}),{id:r,systemId:i,actorRef:d,src:o,input:u},void 0]}function ia(t,{actorRef:e}){e&&t.defer(()=>{e._processingStatus!==C.Stopped&&e.start()})}function qt(...[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=ra,i.execute=ia,i}function oa(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]),[G(e,{children:a}),o,void 0]}function Ms(t,e){const n=e.getSnapshot();if(n&&"children"in n)for(const s of Object.values(n.children))Ms(t,s);t.system._unregister(e)}function aa(t,e){if(e){if(Ms(t,e),e._processingStatus!==C.Running){t.stopChild(e);return}t.defer(()=>{t.stopChild(e)})}}function Oe(t){function e(n,s){}return e.type="xstate.stopChild",e.actorRef=t,e.resolve=oa,e.execute=aa,e}function ca(t,{context:e,event:n},{guards:s}){return s.every(r=>qe(r,e,n,t))}function ua(t){function e(n,s){return!1}return e.check=ca,e.guards=t,e}function qe(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 qe(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 Dt(t){return t.type==="atomic"||t.type==="final"}function ge(t){return Object.values(t.states).filter(e=>e.type!=="history")}function De(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 Ge(t){const e=new Set(t),n=qs(e);for(const s of e)if(s.type==="compound"&&(!n.get(s)||!n.get(s).length))fn(s).forEac
14h(r=>e.add(r));else if(s.type==="parallel"){for(const r of ge(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 Os(t,e){const n=e.get(t);if(!n)return{};if(t.type==="compound"){const r=n[0];if(r){if(Dt(r))return r.key}else return{}}const s={};for(const r of n)s[r.key]=Os(r,e);return s}function qs(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 Ds(t,e){const n=Ge(e);return Os(t,qs(n))}function Pt(t,e){return e.type==="compound"?ge(e).some(n=>n.type==="final"&&t.has(n)):e.type==="parallel"?ge(e).every(n=>Pt(t,n)):e.type==="final"}const it=t=>t[0]===zo;function da(t,e){const n=t.transitions.get(e),s=[...t.transitions.keys()].filter(r=>r!==e&&Rs(e,r)).sort((r,i)=>i.length-r.length).flatMap(r=>t.transitions.get(r));return n?[...n,...s]:s}function la(t){const e=t.config.after;if(!e)return[];const n=r=>{const i=Go(r,t.id),o=i.type;return t.entry.push(le(i,{id:o,delay:r})),t.exit.push(Ot(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 L(o).map(l=>({...l,event:c,delay:a}))}).map(r=>{const{delay:i}=r;return{...H(t,r.event,r),delay:i}})}function H(t,e,n){const s=js(n.target),r=n.reenter??!1,i=ya(t,s),o={...n,actions:L(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 ha(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,ie(s).map(r=>H(t,n,r)))}if(t.config.onDone){const n=`xstate.done.state.${t.id}`;e.set(n,ie(t.config.onDone).map(s=>H(t,n,s)))}for(const n of t.invoke){if(n.onDone){const s=`xstate.done.actor.${n.id}`;e.set(s,ie(n.onDone).map(r=>H(t,s,r)))}if(n.onError){const s=`xstate.error.actor.${n.id}`;e.set(s,ie(n.onError).map(r=>H(t,s,r)))}if(n.onSnapshot){const s=`xstate.snapshot.${n.id}`;e.set(s,ie(n.onSnapshot).map(r=>H(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 fa(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:l})=>l.to===`#${i}`,c={...r.config.route,guard:o?ua([a,o]):a,target:`#${i}`};e.push(H(t,"xstate.route",c))}r.states&&n(r.states)})};n(t.states),e.length>0&&t.transitions.set("xstate.route",e)}function pa(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"?[]:L(e.actions),eventType:null,reenter:!1,target:n?[n]:[],toJSON:()=>({...s,source:`#${t.id}`,target:n?[`#${n.id}`]:[]})};return s}function ya(t,e){if(e!==void 0)return e.map(n=>{if(typeof n!="string")return n;if(it(n))return t.machine.getStateNodeById(n);const s=n[0]===Ss;if(s&&!t.parent)return Je(t,n.slice(1));const r=s?t.key+n:n;if(t.parent)try{return Je(t.parent,r)}catch(i){throw new Error(`Invalid transition definition for state node '${t.id}':
15${i.message}`)}else throw new Error(`Invalid target: "${n}" is not a valid target from the root node. Did you mean ".${n}"?`)})}function Ps(t){const e=js(t.config.target);return e?{target:e.map(n=>typeof n=="string"?Je(t.parent,n):n)}:t.parent.type==="parallel"?{target:[t.parent]}:t.parent.initial}function K(t){return t.type==="history"}function fn(t){const e=Ls(t);for(const n of e)for(const s of De(n,t))e.add(s);return e}function Ls(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 ge(s))n(r)}}return n(t),e}function me(t,e){if(it(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 Je(t,e){if(typeof e=="string"&&it(e))try{return t.machine.getStateNodeById(e)}catch{}const n=jt(e).slice();let s=t;for(;n.length;){const r=n.shift();if(!r.length)break;s=me(s,r)}return s}function Qe(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=>
15me(t,r)).filter(Boolean);return[t.machine.root,t].concat(s,n.reduce((r,i)=>{const o=me(t,i);if(!o)return r;const a=Qe(o,e[i]);return r.concat(a)},[]))}function ga(t,e,n,s){const i=me(t,e).next(n,s);return!i||!i.length?t.next(n,s):i}function ma(t,e,n,s){const r=Object.keys(e),i=me(t,r[0]),o=Lt(i,e[r[0]],n,s);return!o||!o.length?t.next(n,s):o}function va(t,e,n,s){const r=[];for(const i of Object.keys(e)){const o=e[i];if(!o)continue;const a=me(t,i),c=Lt(a,o,n,s);c&&r.push(...c)}return r.length?r:t.next(n,s)}function Lt(t,e,n,s){return typeof e=="string"?ga(t,e,n,s):Object.keys(e).length===1?ma(t,e,n,s):va(t,e,n,s)}function wa(t){return Object.keys(t.states).map(e=>t.states[e]).filter(e=>e.type==="history")}function F(t,e){let n=t;for(;n.parent&&n.parent!==e;)n=n.parent;return n.parent===e}function ba(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(ba(_t([r],e,n),_t([a],e,n)))if(F(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 _a(t){const[e,...n]=t;for(const s of De(e,void 0))if(n.every(r=>F(r,s)))return s}function Vt(t,e){if(!t.target)return[];const n=new Set;for(const s of t.target)if(K(s))if(e[s.id])for(const r of e[s.id])n.add(r);else for(const r of Vt(Ps(s),e))n.add(r);else n.add(s);return[...n]}function Us(t,e){const n=Vt(t,e);if(!n)return;if(!t.reenter&&n.every(r=>r===t.source||F(r,t.source)))return t.source;const s=_a(n.concat(t.source));if(s)return s;if(!t.reenter)return t.source.machine.root}function _t(t,e,n){const s=new Set;for(const r of t)if(r.target?.length){const i=Us(r,n);r.reenter&&r.source===i&&s.add(i);for(const o of e)F(o,i)&&s.add(o)}return[...s]}function Ea(t,e){if(t.length!==e.size)return!1;for(const n of t)if(!e.has(n))return!1;return!0}function Sa(t,e,n,s,r){return Et([{target:[...Ls(t)],source:t,reenter:!0,actions:[],eventType:null,toJSON:null}],e,n,s,!0,r)}function Et(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 l=e.historyValue;const p=Vs(t,c,l);let d=e;r||([d,l]=xa(d,s,n,p,c,l,i,n.actionExecutor)),d=ve(d,s,n,p.flatMap(h=>h.actions),i,void 0),d=Ia(d,s,n,p,c,i,l,r);const u=[...c];d.status==="done"&&(d=ve(d,s,n,u.sort((h,f)=>f.order-h.order).flatMap(h=>h.exit),i,void 0));try{return l===e.historyValue&&Ea(e._nodes,c)?[d,o]:[G(d,{_nodes:u,historyValue:l}),o]}catch(h){throw h}}finally{n.actionExecutor=a}}function $a(t,e,n,s,r){if(s.output===void 0)return;const i=wt(r.id,r.output!==void 0&&r.parent?bt(r.output,t.context,e,n.self):void 0);return bt(s.output,t.context,i,n.self)}function Ia(t,e,n,s,r,i,o,a){let c=t;const l=new Set,p=new Set;Ta(s,o,p,l),a&&p.add(t.machine.root);const d=new Set;for(const u of[...l].sort((h,f)=>h.order-f.order)){r.add(u);const h=[];h.push(...u.entry);for(const f of u.invoke)h.push(qt(f.src,{...f,syncSnapshot:!!f.onSnapshot}));if(p.has(u)){const f=u.initial.actions;h.push(...f)}if(c=ve(c,e,n,h,i,u.invoke.map(f=>f.id)),u.type==="final"){const f=u.parent;let y=f?.type==="parallel"?f:f?.parent,g=y||u;for(f?.type==="compound"&&i.push(wt(f.id,u.output!==void 0?bt(u.output,c.context,e,n.self):void 0));y?.type==="parallel"&&!d.has(y)&&Pt(r,y);)d.add(y),i.push(wt(y.id)),g=y,y=y.parent;if(y)continue;c=G(c,{status:"done",output:$a(c,e,n,c.machine.root,g)})}}return c}function Ta(t,e,n,s){for(const r of t){const i=Us(r,e);for(const a of r.target||[])!K(a)&&(r.source!==a||r.source!==i||r.reenter)&&(s.add(a),n.add(a)),ae(a,e,n,s);const o=Vt(r,e);for(const a of o){const c=De(a,i);i?.type==="parallel"&&c.push(i),Ws(s,e,n,c,!r.source.parent&&r.reenter?void 0:i)}}}function ae(t,e,n,s){if(K(t))if(e[t.id]){const r=e[t.id];for(const i of r)s.add(i),ae(i,e,n,s);for(const i of r)yt(i,t.parent,s,e,n)}else{const r=Ps(t);for(const i of r.target)s.add(i),r===t.parent?.initial&&n.add(t.parent),ae(i,e,n,s);for(const i of r.target)yt(i,t.parent,s,e,n)}else if(t.type==="compound"){const[r]=t.initial.target;K(r)||(s.add(r),n.add(r)),ae(r,e,n,s),yt(r,t,s,e,n)}else if(t.type==="parallel")for(const r of ge(t).filter(i=>!K(i)))[...s].some(i=>F(i,r))||(K(r)||(s.add(r),n.add(r)),ae(r,e,n,s))}function Ws(t,e,n,s,r){for(const i of s)if((!r||F(i,r))&&t.add(i),i.type==="parallel")for(const o of ge(i).filter(a=>!K(a)))[...t].some(a=>F(a,o))||(t.add(o),ae(o,e,n,t))}function yt(t,e,n,s,r){Ws(n,s,r,De(t,e))}function xa(t,e,n,s,r,i,o,a){let c=t;const l=_t(s,r,i);l.sort((d,u)=>u.order-d.order);let p;for(const d of l)for(const u of wa(d)){let h;u.history==="deep"?h=f=>Dt(f)&&F(f,d):h=f=>f.parent===d,p??={...i},p[u.id]=Array.from(r).filter(h)}for(const d of l)c=ve(c,e,n,[...d.exit,...d.invoke.map(u=>Oe(u.id))],o,void 0),r.delete(d);return[c,p||i]}function Aa(t,e){return t.implementations.actions[e]}function Hs(t,e,n,s,r,i){const{machine:o}=t;let a=t;for(const c of s){const l=typeof c=="function",p=l?c:Aa(o,typeof c=="string"?c:c.type),d={context:a.context,event:e,self:n.self,system:n.system},u=l||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:d,params:u,exec:p});continue}
15const h=p,[f,y,g]=h.resolve(n,a,d,u,p,r);a=f,"retryResolve"in h&&i?.push([h,y]),"execute"in h&&n.actionExecutor({type:h.type,info:d,params:y,exec:h.execute.bind(null,n,y)}),g&&(a=Hs(a,e,n,g,r,i))}return a}function ve(t,e,n,s,r,i){const o=i?[]:void 0,a=Hs(t,e,n,s,{internalQueue:r,deferredActorIds:i},o);return o?.forEach(([c,l])=>{c.retryResolve(n,a,l)}),a}function gt(t,e,n,s){let r=t;const i=[];function o(d,u,h){n.system._sendInspectionEvent({type:"@xstate.microstep",actorRef:n.self,event:u,snapshot:d[0],_transitions:h}),i.push(d)}if(e.type===Fe)return r=G(pn(r,e,n),{status:"stopped"}),o([r,[]],e,[]),{snapshot:r,microsteps:i};let a=e;if(a.type!==Is){const d=a,u=Yo(d),h=yn(d,r);if(u&&!h.length)return r=G(t,{status:"error",error:d.error}),o([r,[]],d,[]),{snapshot:r,microsteps:i};const f=Et(h,t,n,a,!1,s);r=f[0],o(f,d,h)}let c=!0;const l=t.machine.options?.maxIterations??1/0;let p=0;for(;r.status==="active";){if(p++,p>l)throw new Error(`Infinite loop detected: the machine has processed more than ${l} 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 d=c?ka(r,a):[];const u=d.length?r:void 0;if(!d.length){if(!s.length)break;a=s.shift(),d=yn(a,r)}const h=Et(d,r,n,a,!1,s);r=h[0],c=r!==u,o(h,a,d)}return r.status!=="active"&&pn(r,a,n),{snapshot:r,microsteps:i}}function pn(t,e,n){return ve(t,e,n,Object.values(t.children).map(s=>Oe(s)),[],void 0)}function yn(t,e){return e.machine.getTransitionData(e,t)}function ka(t,e){const n=new Set,s=t._nodes.filter(Dt);for(const r of s)e:for(const i of[r].concat(De(r,void 0)))if(i.always){for(const o of i.always)if(o.guard===void 0||qe(o.guard,t.context,e,t)){n.add(o);break e}}return Vs(Array.from(n),new Set(t._nodes),t.historyValue)}function Ca(t,e){const n=Ge(Qe(t,e));return Ds(t,[...n])}function ja(t){return!!t&&typeof t=="object"&&"machine"in t&&"value"in t}const Ra=function(e){return As(e,this.value)},Ma=function(e){return this.tags.has(e)},Oa=function(e){const n=this.machine.getTransitionData(this,e);return!!n?.length&&n.some(s=>s.target!==void 0||s.actions.length)},qa=function(){const{_nodes:e,tags:n,machine:s,getMeta:r,toJSON:i,can:o,hasTag:a,matches:c,...l}=this;return{...l,tags:Array.from(n)}},Da=function(){return this._nodes.reduce((e,n)=>(n.meta!==void 0&&(e[n.id]=n.meta),e),{})};function Se(t,e){return{status:t.status,output:t.output,error:t.error,machine:e,context:t.context,_nodes:t._nodes,value:Ds(e.root,t._nodes),tags:new Set(t._nodes.flatMap(n=>n.tags)),children:t.children,historyValue:t.historyValue||{},matches:Ra,hasTag:Ma,can:Oa,getMeta:Da,toJSON:qa}}function G(t,e={}){return Se({...t,...e},t.machine)}function Pa(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 La(t,e){const{_nodes:n,tags:s,machine:r,children:i,context:o,can:a,hasTag:c,matches:l,getMeta:p,toJSON:d,...u}=t,h={};for(const y in i){const g=i[y];h[y]={snapshot:g.getPersistedSnapshot(e),src:g.src,systemId:g.systemId,syncSnapshot:g._syncSnapshot}}return{...u,context:Ns(o),children:h,historyValue:Pa(u.historyValue)}}function Ns(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:Mt,id:s.id};else{const r=Ns(s);r!==s&&(e??=Array.isArray(t)?t.slice():{...t},e[n]=r)}}return e??t}function Va(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 l=typeof r=="function"?r(n,s):r;let p;if(typeof o=="string"){const d=c&&c[o];p=typeof d=="function"?d(n,s):d}else p=typeof o=="function"?o(n,s):o;return typeof p!="number"&&a.push(l),[e,{event:l,id:i,delay:p},void 0]}function Ua(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 le(t,e){function n(s,r){}return n.type="xstate.raise",n.event=t,n.id=e?.id,n.delay=e?.delay,n.resolve=Va,n.execute=Ua,n}const gn="xstate.observable.error",mn="xstate.observable.complete";function zs(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 Fe: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 Wa(t,{machine:e,context:n},s,r){const i=(o,a)=>
15{if(typeof o=="string"){const c=Rt(e,o);if(!c)throw new Error(`Actor logic '${o}' not implemented in machine '${e.id}'`);const l=je(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[l.id]=l,l}else return je(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!==C.Stopped&&c.start()}),c}}function Ha(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:Wa(t,e,n.event,i),self:t.self,system:t.system};let a={};if(typeof r=="function")a=r(o,s);else for(const l of Object.keys(r)){const p=r[l];a[l]=typeof p=="function"?p(o,s):p}const c=Object.assign({},e.context,a);return[G(e,{context:c,children:Object.keys(i).length?{...e.children,...i}:e.children}),void 0,void 0]}function Z(t){function e(n,s){}return e.type="xstate.assign",e.assignment=t,e.resolve=Ha,e}const vn=new WeakMap;function se(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 Na={},be=t=>typeof t=="string"?{type:t}:typeof t=="function"?"resolve"in t?{type:t.type}:{type:t.name}:t;class Ke{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(Ss),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 Ke(s,{_parent:this,_key:r,_machine:this.machine})):Na,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=L(this.config.entry).slice(),this.exit=L(this.config.exit).slice(),this.meta=this.config.meta,this.output=this.type==="final"||!this.parent?this.config.output:void 0,this.tags=L(e.tags).slice()}_initialize(){this.transitions=ha(this),this.config.always&&(this.always=ie(this.config.always).map(e=>H(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.t
15ype,initial:this.initial?{target:this.initial.target,source:this,actions:this.initial.actions.map(be),eventType:null,reenter:!1,toJSON:()=>({target:this.initial.target.map(e=>`#${e.id}`),source:`#${this.id}`,actions:this.initial.actions.map(be),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(be)})),entry:this.entry.map(be),exit:this.exit.map(be),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 se(this,"invoke",()=>L(this.config.invoke).map((e,n)=>{const{src:s,systemId:r}=e,i=e.id??ln(this.id,n),o=typeof s=="string"?s:`xstate.invoke.${ln(this.id,n)}`;return{...e,src:o,id:i,systemId:r,toJSON(){const{onDone:a,onError:c,...l}=e;return{...l,type:"xstate.invoke",src:o,id:i}}}}))}get on(){return se(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 se(this,"delayedTransitions",()=>la(this))}get initial(){return se(this,"initial",()=>pa(this,this.config.initial))}next(e,n){const s=n.type,r=[];let i;const o=se(this,`candidates-${s}`,()=>da(this,s));for(const a of o){const{guard:c}=a,l=e.context;let p=!1;try{p=!c||qe(c,l,n,e)}catch(d){const u=typeof c=="string"?c:typeof c=="object"?c.type:void 0;throw new Error(`Unable to evaluate guard ${u?`'${u}' `:""}in transition for event '${s}' in state node '${this.id}':
16${d.message}`)}if(p){r.push(...a.actions),i=a;break}}return i?[i]:void 0}get events(){return se(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 za="#";class Ut{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 Ke(e,{_key:this.id,_machine:this}),this.root._initialize(),fa(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 Ut(this.config,{actions:{...n,...e.actions},guards:{...s,...e.guards},actors:{...r,...e.actors},delays:{...i,...e.delays}})}resolveState(e){const n=Ca(this.root,e.value),s=Ge(Qe(this.root,n));return Se({_nodes:[...s],context:e.context||{},children:{},status:Pt(s,this.root)?"done":e.status||"active",output:e.output,error:e.error,historyValue:e.historyValue},this)}transition(e,n,s){return gt(e,n,s,[]).snapshot}microstep(e,n,s){return gt(e,n,s,[]).microsteps.map(([r])=>r)}getTransitionData(e,n){return Lt(this.root,e.value,e,n)||[]}_getPreInitialState(e,n,s){const{context:r}=this.config,i=Se({context:typeof r!="function"&&r?r:{},_nodes:[this.root],children:{},status:"active"},this);return typeof r=="function"?ve(i,n,e,[Z(({spawn:a,event:c,self:l})=>r({spawn:a,input:c.input,self:l}))],s,void 0):i}getInitialSnapshot(e,n){const s=xs(n),r=[];let i=Se({context:typeof this.config.context!="function"&&this.config.context?this.config.context:{},_nodes:[this.root],children:{},status:"active"},this);try{i=this._getPreInitialState(e,s,r);const[o]=Sa(this.root,i,e,s,r),{snapshot:a}=gt(o,s,e,r);return a}catch(o){return G(i,{status:"error",error:o})}}
16start(e){Object.values(e.children).forEach(n=>{n.getSnapshot().status==="active"&&n.start()})}getStateNodeById(e){const n=jt(e),s=n.slice(1),r=it(n[0])?n[0].slice(za.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 Je(i,s)}get definition(){return this.root.definition}toJSON(){return this.definition}getPersistedSnapshot(e,n){return La(e,n)}restoreSnapshot(e,n){const s={},r=e.children;Object.keys(r).forEach(d=>{const u=r[d],h=u.snapshot,f=u.src,y=typeof f=="string"?Rt(this,f):f;if(!y)return;const g=je(y,{id:d,parent:n.self,syncSnapshot:u.syncSnapshot,snapshot:h,src:f,systemId:u.systemId});s[d]=g});function i(d,u){if(u instanceof Ke)return u;try{return d.machine.getStateNodeById(u.id)}catch{}}function o(d,u){if(!u||typeof u!="object")return{};const h={};for(const f in u){const y=u[f];for(const g of y){const w=i(d,g);w&&(h[f]??=[],h[f].push(w))}}return h}const a=o(this.root,e.historyValue),c=Se({...e,children:s,_nodes:Array.from(Ge(Qe(this.root,e.value))),historyValue:a},this),l=new Set;function p(d,u){if(!l.has(d)){l.add(d);for(const h in d){const f=d[h];if(f&&typeof f=="object"){if("xstate$$type"in f&&f.xstate$$type===Mt){d[h]=u[f.id];continue}p(f,u)}}}}return p(c.context,s),c}}function Ba(t,e,n,s,{event:r}){const i=typeof r=="function"?r(n,s):r;return[e,{event:i},void 0]}function Fa(t,{event:e}){t.defer(()=>t.emit(e))}function Ye(t){function e(n,s){}return e.type="xstate.emit",e.event=t,e.resolve=Ba,e.execute=Fa,e}let St=(function(t){return t.Parent="#_parent",t.Internal="#_internal",t})({});function Ga(t,e,n,s,{to:r,event:i,id:o,delay:a},c){const l=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 d;if(typeof a=="string"){const f=l&&l[a];d=typeof f=="function"?f(n,s):f}else d=typeof a=="function"?a(n,s):a;const u=typeof r=="function"?r(n,s):r;let h;if(typeof u=="string"){if(u===St.Parent?h=t.self._parent:u===St.Internal?h=t.self:u.startsWith("#_")?h=e.children[u.slice(2)]:h=c.deferredActorIds?.includes(u)?u:e.children[u],!h)throw new Error(`Unable to send event to actor '${u}' from machine '${e.machine.id}'.`)}else h=u||t.self;return[e,{to:h,targetId:typeof u=="string"?u:void 0,event:p,id:o,delay:d},void 0]}function Ja(t,e,n){typeof n.to=="string"&&(n.to=e.children[n.to])}function Qa(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===Fo?Ts(t.self.id,s.data):s)})}function he(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=Ga,s.retryResolve=Ja,s.execute=Qa,s}function Ka(t,e){return he(St.Parent,t,e)}function Ya(t,e,n,s,{collect:r}){const i=[],o=function(c){i.push(c)};return o.assign=(...a)=>{i.push(Z(...a))},o.cancel=(...a)=>{i.push(Ot(...a))},o.raise=(...a)=>{i.push(le(...a))},o.sendTo=(...a)=>{i.push(he(...a))},o.sendParent=(...a)=>{i.push(Ka(...a))},o.spawnChild=(...a)=>{i.push(qt(...a))},o.stopChild=(...a)=>{i.push(Oe(...a))},o.emit=(...a)=>{i.push(Ye(...a))},r({context:n.context,event:n.event,enqueue:o,check:a=>qe(a,e.context,n.event,e),self:t.self,system:t.system},s),[e,void 0,i]}function oe(t){function e(n,s){}return e.type="xstate.enqueueActions",e.collect=t,e.resolve=Ya,e}function Xa(t,e,n,s,{value:r,label:i}){return[e,{value:typeof r=="function"?r(n,s):r,label:i},void 0]}function Za({logger:t},{value:e,label:n}){n?t(n,e):t(e)}function ec(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=Xa,n.execute=Za,n}function O(t,e){const n=L(e);if(!n.some(r=>Rs(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 tc(t,e){return new Ut(t,e)}function Wt({schemas:t,actors:e,actions:n,guards:s,delays:r}){return{assign:Z,sendTo:he,raise:le,log:ec,cancel:Ot,stopChild:Oe,enqueueActions:oe,emit:Ye,spawnChild:qt,createStateConfig:i=>i,createAction:i=>i,createMachine:i=>tc({...i,schemas:t},{actors:e,actions:n,guards:s,delays:r}),extend:i=>Wt({schemas:t,actors:e,actions:{...n,...i.actions},guards:{...s,...i.guards},delays:{...r,...i.delays}})}}const Q=t=>({context:e})=>{let{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}},nc=t=>e=>{let{data:n}=e;
16return(!t.include.length||t.include.includes(n.type))&&(!t.exclude.length||!t.exclude.includes(n.type))&&n.domain===t.domain&&n.from===t.from&&n.to===t.to&&(!t.target||e.source===t.target)},sc=t=>e=>({type:t,message:e}),rc=$t(()=>Ce(window,"message")),Bs=t=>zs(({input:e})=>rc.pipe(t?x(t):ut(),V(nc(e)),x(sc(e.responseType)),e.count?ut(_r(e.count),jn(n=>n),Tt(e.count)):ut())),Fs="sanity/comlink",ic=1e4,Te="comlink/response",xe="comlink/heartbeat",ce="comlink/disconnect",Ae="comlink/handshake/syn",Ht="comlink/handshake/syn-ack",ke="comlink/handshake/ack",oc=t=>e=>e.pipe(Tt(1),x(()=>{throw Error(t)})),Gs=()=>Wt({actors:{listen:zs(({input:t})=>{let e=t.signal?Ce(t.signal,"abort").pipe(oc(`Request ${t.requestId} aborted`)):_n,n=s=>s.data?.type==="comlink/response"&&s.data?.responseTo===t.requestId&&!!s.source&&t.sources.has(s.source);return Ce(window,"message").pipe(V(n),Tt(t.sources.size),$r(e))})},actions:{"send message":({context:t},e)=>{let{sources:n,targetOrigin:s}=t,{message:r}=e;n.forEach(i=>{i.postMessage(r,{targetOrigin:s})})},"on success":he(({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":he(({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(Error("No response received")),{type:"request.failed",requestId:e.id})),"on abort":he(({context:t})=>t.parentRef,({context:t,self:e})=>(t.resolvable?.reject(Error("Request aborted")),{type:"request.aborted",requestId:e.id}))},guards:{expectsResponse:({context:t})=>t.expectResponse},delays:{initialTimeout:0,responseTimeout:({context:t})=>t.responseTimeout??3e3}}).createMachine({context:({input:t})=>({channelId:t.channelId,data:t.data,domain:t.domain,expectResponse:t.expectResponse??!1,from:t.from,id:`msg-${Es()}`,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})=>{let{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:Z({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 ac(){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=()=>Wt({actors:{requestMachine:Gs(),listen:Bs()},actions:{"buffer handshake":Z({handshakeBuffer:({event:t,context:e})=>(O(t,"message.received"),[...e.handshakeBuffer,t])}),"buffer message":oe(({enqueue:t})=>{t.assign({buffer:({event:e,context:n})=>(O(e,"post"),[...n.buffer,{data:e.data,resolvable:e.resolvable,options:e.options}])}),t.emit(({event:e})=>(O(e,"post"),{type:"buffer.added",message:e.data}))}),"create request":Z({requests:({context:t,event:e,self:n,spawn:s})=>{O(e,"request");let r=(Array.isArray(e.data)?e.data:[e.data]).map(i=>s("requestMachine",{id:`req-${Es()}`,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":Ye(()=>({type:"heartbeat"})),"emit received message":oe(({enqueue:t})=>{t.emit(({event:e})=>(O(e,"message.received"),{type:"message",message:e.message.data}))}),"emit status":Ye((t,e)=>({type:"status",status:e.status})),"post message":le(({event:t})=>(O(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":oe(({context:t,enqueue:e})=>{t.handshakeBuffer.forEach(n=>e.raise(n)),e.assign({handshakeBuffer:[]})}),"remove request":oe(({context:t,enqueue:e,event:n})=>{O(n,["request.success","request.failed","request.aborted"]),Oe(n.requestId),e.assign({requests:t.requests.filter(({id:s})=>s!==n.requestId)})}),"send response":le(({event:t})=>(O(t,["message.received","heartbeat.received"]),{type:"request",data:{type:Te,responseTo:t.message.data.id,data:void 0}})),"send handshake syn ack":le({type:"request",data:{type:Ht}}),"send pending messages":oe(({enqueue:t})=>{t.raise(({context:e})=>({type:"request",data:e.buffer.map(({data:n,resolvable:s,options:r})=>
16({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":Z({channelId:({event:t})=>(O(t,"handshake.syn"),t.message.data.channelId),target:({event:t})=>(O(t,"handshake.syn"),t.message.source||void 0),targetOrigin:({event:t})=>(O(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??"sanity/comlink",handshakeBuffer:[],name:t.name,requests:[],target:void 0,targetOrigin:null}),invoke:{id:"listen for handshake syn",src:"listen",input:Q({include:Ae,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:Q({include:ke,count:1,responseType:"handshake.complete"}),onDone:"connected"},{id:"listen for disconnect",src:"listen",input:Q({include:ce,count:1,responseType:"disconnect"})},{id:"listen for messages",src:"listen",input:Q({exclude:[ce,Ae,ke,xe,Te]})}],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:Q({exclude:[ce,Ae,ke,xe,Te]})},{id:"listen for heartbeat",src:"listen",input:Q({include:xe,responseType:"heartbeat.received"})},{id:"listen for disconnect",src:"listen",input:Q({include:ce,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"]}}}}}),cc=(t,e=Js())=>{let n=je(e,{input:t}),s=new Map,r=new Map,i=(u,h,f)=>{let y=s.get(u)||new Set;s.has(u)||s.set(u,y),y.add(h);let g=r.get(u);if(g){let w=f?.replay??1;
16Array.from(g).slice(-w).forEach(({data:$})=>h($)),r.delete(u)}return()=>{y.delete(h)}},o,a=(u,h)=>{let f=n.on("status",y=>{o=y.status,!(h&&y.status!==h)&&u(y.status)});return o&&u(o),()=>f.unsubscribe()},c=(u,h)=>{let f={type:u,data:h};n.send({type:"post",data:f})},l=(u,h,f)=>{let{responseTimeout:y=ic,signal:g,suppressWarnings:w}=f||{},$=ac(),j={type:u,data:h};return n.send({type:"post",data:j,resolvable:$,options:{responseTimeout:y,signal:g,suppressWarnings:w}}),$.promise};n.on("message",({message:u})=>{let h=s.get(u.type);if(h){h.forEach(y=>y(u.data));return}let f=r.get(u.type);f?f.add(u):r.set(u.type,new Set([u]))});let p=()=>{n.stop()};return{actor:n,fetch:l,machine:e,on:i,onStatus:a,post:c,start:()=>(n.start(),p),stop:p}},uc={"handshake/syn":Ae,"handshake/syn-ack":Ht,"handshake/ack":ke,"channel/response":Te,"channel/heartbeat":xe,"channel/disconnect":ce,"overlay/focus":"visual-editing/focus","overlay/navigate":"visual-editing/navigate","overlay/toggle":"visual-editing/toggle","presentation/toggleOverlay":"presentation/toggle-overlay"},dc={[Ae]:"handshake/syn",[Ht]:"handshake/syn-ack",[ke]:"handshake/ack",[Te]:"channel/response",[xe]:"channel/heartbeat",[ce]:"channel/disconnect","visual-editing/focus":"overlay/focus","visual-editing/navigate":"overlay/navigate","visual-editing/toggle":"overlay/toggle","presentation/toggle-overlay":"presentation/toggleOverlay"},lc=t=>{let{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=Fs),e.to==="overlays"&&(e.to="visual-editing"),e.from==="overlays"&&(e.from="visual-editing"),e.channelId=e.connectionId,delete e.connectionId,e.type=uc[e.type]??e.type),t},hc=t=>{let{channelId:e,...n}=t,s={...n,connectionId:e};return s.domain===Fs&&(s.domain="sanity/channels"),s.to==="visual-editing"&&(s.to="overlays"),s.from==="visual-editing"&&(s.from="overlays"),s.type=dc[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},fc=({context:t},e)=>{let{sources:n,targetOrigin:s}=t,r=hc(e.message);n.forEach(i=>{i.postMessage(r,{targetOrigin:s})})},pc=()=>({listen:Bs(lc),requestMachine:Gs().provide({actions:{"send message":fc}})}),wn=2e4;function mc(t){let{client:e,setFetcher:n,onConnect:s,onDisconnect:r,onPerspective:i,onVariant:o}=t;if(!e)throw Error(`Expected \`client\` to be a Sanity client: ${JSON.stringify(e)}`);let{projectId:a,dataset:c,perspective:l}=e.config(),p=dt(l&&l!=="raw"?l:"drafts"),d=dt(void 0),u=dt(!1),h=new Map,f=cc({name:"loaders",connectTo:"presentation"},Js().provide({actors:pc()}));f.onStatus(()=>{u.set(!0)},"connected"),f.on("loader/perspective",v=>{if(v.projectId===a&&v.dataset===c){At(v.perspective);let I=v.perspective==="raw"?"drafts":v.perspective;p.set(I),i?.(I);let T=v.variant||void 0;d.set(T),o?.(T),j(),E()}}),f.on("loader/query-change",v=>{if(v.projectId===a&&v.dataset===c){let{perspective:I,query:T,params:b}=v,R=v.variant||void 0,k=JSON.stringify({perspective:I,variant:R,query:T,params:b});v.result!==void 0&&v.resultSourceMap!==void 0&&e.config().stega.enabled?h.set(k,{...v,result:Ct(v.result,v.resultSourceMap,e.config().stega)}):h.set(k,v),E()}});let y,g=u.listen(v=>{v?(y=n({hydrate:(I,T,b)=>{let R=b?.perspective||p.get(),k=b?.variant||d.get(),ot=JSON.stringify({perspective:R,variant:k,query:I,params:T}),P=h.get(ot);return P?.result!==void 0&&P?.resultSourceMap!==void 0?{loading:!1,error:void 0,data:P.result,sourceMap:P.resultSourceMap,perspective:R,variant:k}:{loading:u.value===!0&&b?.data===void 0||b?.sourceMap===void 0,error:void 0,data:b?.data,sourceMap:b?.sourceMap,perspective:b?.perspective||"published",variant:b?.variant}},fetch:(I,T,b,R)=>{try{let k=$(I,T,b);if(R.signal.addEventListener("abort",()=>{k(),E()},{once:!0}),E(),b.setKey("error",void 0),R.signal.aborted)return}catch(k){b.setKey("error",k),b.setKey("loading",!1)}}}),s?.()):(y?.(),r?.())}),w=new Set,$=(v,I,T)=>{let b={query:v,params:I,$fetch:T};w.add(b),j();let R=setInterval(()=>j(!0),wn);return()=>{clearInterval(R),w.delete(b),j()}},j=v=>{if(!f)throw Error("No connection");let I=p.get(),T=d.get();for(let{query:b,params:R,$fetch:k}of w)f.post("loader/query-listen",{projectId:a,dataset:c,perspective:I,variant:T,query:b,params:R,heartbeat:wn}),!v&&u.value===!0&&k.setKey("loading",!0),k.setKey("perspective",I),k.setKey("variant",T)};function E(){let v=p.get(),I=d.get(),T=[];for(let{query:b,params:R,$fetch:k}of w){let ot=JSON.stringify({perspective:v,variant:I,query:b,params:R}),P=h.get(ot);P&&(k.set({data:P.result,error:void 0,loading:!1,perspective:v,variant:I,sourceMap:P.resultSourceMap}),T.push(...P.resultSourceMap?.documents??[]))}f.post("loader/documents",{projectId:a,dataset:c,perspective:v,variant:I,documents:T})}let J=f.start();return()=>{y?.(),g(),J(),u.set(!1)}}export{mc as enableLiveMode};

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.