1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[2073],{92073:(e,t,n)=>{let r;n.r(t),n.d(t,{default:()=>ot});var i,o,a,s,u,l,c,d,p=n(95155),f=n(48307),y=n(12115),m=n(47650);let h=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,g=/_key\s*==\s*['"](.*)['"]/,v=/^\d*:\d*$/;function b(e){return"number"==typeof e||"string"==typeof e&&/^\[\d+\]$/.test(e)}function w(e){return"string"==typeof e?g.test(e.trim()):"object"==typeof e&&"_key"in e}function x(e){if("string"==typeof e&&v.test(e))return!0;if(!Array.isArray(e)||2!==e.length)return!1;let[t,n]=e;return("number"==typeof t||""===t)&&("number"==typeof n||""===n)}function E(e){if(!Array.isArray(e))throw Error("Path is not an array");return e.reduce((e,t,n)=>{let r=typeof t;if("number"===r)return`${e}[${t}]`;if("string"===r)return`${e}${0===n?"":"."}${t}`;if(w(t)&&t._key)return`${e}[_key=="${t._key}"]`;if(Array.isArray(t)){let[n,r]=t;return`${e}[${n}:${r}]`}throw Error(`Unsupported path segment \`${JSON.stringify(t)}\``)},"")}function _(e){if("string"!=typeof e)throw Error("Path is not a string");let t=e.match(h);if(!t)throw Error("Invalid path string");return t.map(k)}function k(e){return b(e)?Number(e.replace(/[^\d]/g,"")):w(e)?{_key:e.match(g)[1]}:x(e)?function(e){let[t,n]=e.split(":").map(e=>""===e?e:Number(e));return[t,n]}(e):e}var j=Object.freeze({__proto__:null,fromString:_,get:function(e,t,n){let r="string"==typeof t?_(t):t;if(!Array.isArray(r))throw Error("Path must be an array or a string");let i=e;for(let e=0;e<r.length;e++){let t=r[e];if(b(t)){if(!Array.isArray(i))return n;i=i[t]}if(w(t)){if(!Array.isArray(i))return n;i=i.find(e=>e._key===t._key)}if("string"==typeof t&&(i="object"==typeof i&&null!==i?i[t]:void 0),typeof i>"u")return n}return i},isIndexSegment:b,isIndexTuple:x,isKeySegment:w,reKeySegment:g,toString:E});let I="drafts.";function M(e){return e.startsWith(I)}function S(e){return e.startsWith("versions.")}function $(e){return S(e)?I+O(e):M(e)?e:I+e}function O(e){return S(e)?e.split(".").slice(2).join("."):M(e)?e.slice(I.length):e}var A=n(17277);function P(e){return e.split(/[[.\]]/g).filter(Boolean).map(e=>e.includes("==")?function(e){let[t,n]=e.split("==");if("_key"!==t)throw Error(`Currently only "_key" is supported as path segment. Found ${t}`);if(typeof n>"u")throw Error('Invalid path segment, expected `key=="value"`');return{_key:n.replace(/^['"]/,"").replace(/['"]$/,"")}}(e):T.test(e)?Number(e):e)}let T=/^-?\d+$/,C=/^[a-z_$]+/;function R(e){return e.map((e,t)=>{var n;return n=0===t,Array.isArray(e)?`[${e[0]}:${e[1]||""}]`:"number"==typeof e?`[${e}]`:"object"==typeof e&&"_key"in e&&"string"==typeof e._key?`[_key==${JSON.stringify(e._key)}]`:"string"==typeof e&&C.test(e)?n?e:`.${e}`:`['${e}']`}).join("")}function D(e){if("createIfNotExists"in e)return{type:"createIfNotExists",document:e.createIfNotExists};if("createOrReplace"in e)return{type:"createOrReplace",document:e.createOrReplace};if("create"in e)return{type:"create",document:e.create};if("delete"in e)return{id:e.delete.id,type:"delete"};if("patch"in e){var t,n;return{type:"patch",id:e.patch.id,patches:[..."set"in(n=t=e.patch)?Object.keys(n.set).map(e=>({path:P(e),op:{type:"set",value:n.set[e]}})):[],..."setIfMissing"in t?Object.keys(t.setIfMissing).map(e=>({path:P(e),op:{type:"setIfMissing",value:t.setIfMissing[e]}})):[],..."unset"in t?t.unset.map(e=>({path:P(e),op:{type:"unset"}})):[],..."inc"in t?Object.keys(t.inc).map(e=>({path:P(e),op:{type:"inc",amount:t.inc[e]}})):[],..."inc"in t?Object.keys(t.dec).map(e=>({path:P(e),op:{type:"dec",amount:t.dec[e]}})):[],...function(e){if(!("insert"in e))return[];let t=function(e){let t=L.filter(t=>t in e);if(t.length>1)throw Error(`Insert patch is ambiguous. Should only contain one of: ${L.join(", ")}, instead found ${t.join(", ")}`);return t[0]}(e.insert);if(!t)throw Error("Insert patch missing position");let n=P(e.insert[t]),r=n.pop();return[{path:n,op:{type:"insert",position:t,referenceItem:r,items:e.insert.items}}]}(t)]}}throw Error(`Unknown mutation: ${JSON.stringify(e)}`)}let L=["before","replace","after"];function z(e){return U(e)}function N(e){return e.flatMap(z)}function U(e){if("create"===e.type||"createIfNotExists"===e.type||"createOrReplace"===e.type)return{[e.type]:e.document};if("delete"===e.type)return{delete:{id:e.id}};let t=e.options?.ifRevision;return e.patches.map(n=>({patch:{id:e.id,...t&&{ifRevisionID:t},...function(e){let{path:t,op:n}=e;if("unset"===n.type)return{unset:[R(t)]};if("insert"===n.type)return{insert:{[n.position]:R([...t,n.referenceItem]),items:n.items}};if("diffMatchPatch"===n.type)return{diffMatchPatch:{[R(t)]:n.value}};if("inc"===n.type)return{inc:{[R(t)]:n.amount}};if("dec"===n.type)return{dec:{[R(t)]:n.amount}};if("set"===n.type||"setIfMissing"===n.type)return{[n.type]:{[R(t)]:n.value}};if("truncate"===n.type){let e=[n.startIndex,"number"==typeof n.endIndex?n.endIndex:""].join(":");return{unset:[`${R(t)}[${e}]`]}}if("upsert"===n.type)return{unset:n.items.map(e=>
1R([...t,{_key:e._key}])),insert:{[n.position]:R([...t,n.referenceItem]),items:n.items}};if("assign"===n.type)return{set:Object.fromEntries(Object.keys(n.value).map(e=>[R(t.concat(e)),n.value[e]]))};if("unassign"===n.type)return{unset:n.keys.map(e=>R(t.concat(e)))};if("replace"===n.type)return{insert:{replace:R(t.concat(n.referenceItem)),items:n.items}};if("remove"===n.type)return{unset:[R(t.concat(n.referenceItem))]};throw Error(`Unknown operation type ${n.type}`)}(n)}}))}function F(e){return Array.isArray(e)?e:[e]}var V=Object.freeze({__proto__:null,decode:function(e){return D(e)},decodeAll:function(e){return e.map(D)},encode:z,encodeAll:N,encodeMutation:U,encodeTransaction:function(e){return{transactionId:e.id,mutations:N(e.mutations)}}});function W(e,t,n){return{type:"insert",referenceItem:n,position:t,items:F(e)}}function q(e,t){return{type:"truncate",startIndex:e,endIndex:t}}function G(e){return{type:"remove",referenceItem:e}}function B(e,t){return{path:"string"==typeof e?P(e):e,op:t}}var Y=n(8691),J=n(33720),H=n(47289),K=n(97752),X=n(24531),Z="object"==typeof global&&global&&global.Object===Object&&global,Q="object"==typeof self&&self&&self.Object===Object&&self,ee=Z||Q||Function("return this")(),et=ee.Symbol,en=Object.prototype,er=en.hasOwnProperty,ei=en.toString,eo=et?et.toStringTag:void 0;let ea=function(e){var t=er.call(e,eo),n=e[eo];try{e[eo]=void 0;var r=!0}catch(e){}var i=ei.call(e);return r&&(t?e[eo]=n:delete e[eo]),i};var es=Object.prototype.toString,eu=et?et.toStringTag:void 0;let el=function(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":eu&&eu in Object(e)?ea(e):es.call(e)},ec=function(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)},ed=function(e){if(!ec(e))return!1;var t=el(e);return"[object Function]"==t||"[object GeneratorFunction]"==t||"[object AsyncFunction]"==t||"[object Proxy]"==t};var ep=ee["__core-js_shared__"],ef=function(){var e=/[^.]+$/.exec(ep&&ep.keys&&ep.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""}(),ey=Function.prototype.toString;let em=function(e){if(null!=e){try{return ey.call(e)}catch(e){}try{return e+""}catch(e){}}return""};var eh=/^\[object .+?Constructor\]$/,eg=Object.prototype,ev=Function.prototype.toString,eb=eg.hasOwnProperty,ew=RegExp("^"+ev.call(eb).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");let ex=function(e,t){var n,r=null==e?void 0:e[t];return ec(n=r)&&(!ef||!(ef in n))&&(ed(n)?ew:eh).test(em(n))?r:void 0};var eE=function(){try{var e=ex(Object,"defineProperty");return e({},"",{}),e}catch(e){}}();let e_=function(e,t,n){"__proto__"==t&&eE?eE(e,t,{configurable:!0,enumerable:!0,value:n,writable:!0}):e[t]=n},ek=function(e,t,n,r){for(var i=-1,o=null==e?0:e.length;++i<o;){var a=e[i];t(r,a,n(a),e)}return r},ej=function(e,t,n){for(var r=-1,i=Object(e),o=n(e),a=o.length;a--;){var s=o[++r];if(!1===t(i[s],s,i))break}return e},eI=function(e,t){for(var n=-1,r=Array(e);++n<e;)r[n]=t(n);return r},eM=function(e){return null!=e&&"object"==typeof e},eS=function(e){return eM(e)&&"[object Arguments]"==el(e)};var e$=Object.prototype,eO=e$.hasOwnProperty,eA=e$.propertyIsEnumerable,eP=eS(function(){return arguments}())?eS:function(e){return eM(e)&&eO.call(e,"callee")&&!eA.call(e,"callee")},eT=Array.isArray,eC="object"==typeof exports&&exports&&!exports.nodeType&&exports,eR=eC&&"object"==typeof module&&module&&!module.nodeType&&module,eD=eR&&eR.exports===eC?ee.Buffer:void 0;let eL=(eD?eD.isBuffer:void 0)||function(){return!1};var ez=/^(?:0|[1-9]\d*)$/;let eN=function(e,t){var n=typeof e;return!!(t=null==t?0x1fffffffffffff:t)&&("number"==n||"symbol"!=n&&ez.test(e))&&e>-1&&e%1==0&&e<t},eU=function(e){return"number"==typeof e&&e>-1&&e%1==0&&e<=0x1fffffffffffff};var eF={};eF["[object Float32Array]"]=eF["[object Float64Array]"]=eF["[object Int8Array]"]=eF["[object Int16Array]"]=eF["[object Int32Array]"]=eF["[object Uint8Array]"]=eF["[object Uint8ClampedArray]"]=eF["[object Uint16Array]"]=eF["[object Uint32Array]"]=!0,eF["[object Arguments]"]=eF["[object Array]"]=eF["[object ArrayBuffer]"]=eF["[object Boolean]"]=eF["[object DataView]"]=eF["[object Date]"]=eF["[object Error]"]=eF["[object Function]"]=eF["[object Map]"]=eF["[object Number]"]=eF["[object Object]"]=eF["[object RegExp]"]=eF["[object Set]"]=eF["[object String]"]=eF["[object WeakMap]"]=!1;var eV="object"==typeof exports&&exports&&!exports.nodeType&&exports,eW=eV&&"object"==typeof module&&module&&!module.nodeType&&module,eq=eW&&eW.exp
1orts===eV&&Z.process,eG=function(){try{var e=eW&&eW.require&&eW.require("util").types;if(e)return e;return eq&&eq.binding&&eq.binding("util")}catch(e){}}(),eB=eG&&eG.isTypedArray,eY=eB?function(e){return eB(e)}:function(e){return eM(e)&&eU(e.length)&&!!eF[el(e)]},eJ=Object.prototype.hasOwnProperty;let eH=function(e,t){var n=eT(e),r=!n&&eP(e),i=!n&&!r&&eL(e),o=!n&&!r&&!i&&eY(e),a=n||r||i||o,s=a?eI(e.length,String):[],u=s.length;for(var l in e)(t||eJ.call(e,l))&&!(a&&("length"==l||i&&("offset"==l||"parent"==l)||o&&("buffer"==l||"byteLength"==l||"byteOffset"==l)||eN(l,u)))&&s.push(l);return s};var eK=Object.prototype;let eX=function(e){var t=e&&e.constructor;return e===("function"==typeof t&&t.prototype||eK)};var eZ=(a=Object.keys,s=Object,function(e){return a(s(e))}),eQ=Object.prototype.hasOwnProperty;let e0=function(e){if(!eX(e))return eZ(e);var t=[];for(var n in Object(e))eQ.call(e,n)&&"constructor"!=n&&t.push(n);return t},e1=function(e){return null!=e&&eU(e.length)&&!ed(e)},e2=function(e){return e1(e)?eH(e):e0(e)};var e9=(i=function(e,t){return e&&ej(e,t,e2)},function(e,t){if(null==e)return e;if(!e1(e))return i(e,t);for(var n=e.length,r=-1,o=Object(e);++r<n&&!1!==t(o[r],r,o););return e});let e5=function(e,t){return e===t||e!=e&&t!=t},e6=function(e,t){for(var n=e.length;n--;)if(e5(e[n][0],t))return n;return -1};var e3=Array.prototype.splice;function e8(e){var t=-1,n=null==e?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}e8.prototype.clear=function(){this.__data__=[],this.size=0},e8.prototype.delete=function(e){var t=this.__data__,n=e6(t,e);return!(n<0)&&(n==t.length-1?t.pop():e3.call(t,n,1),--this.size,!0)},e8.prototype.get=function(e){var t=this.__data__,n=e6(t,e);return n<0?void 0:t[n][1]},e8.prototype.has=function(e){return e6(this.__data__,e)>-1},e8.prototype.set=function(e,t){var n=this.__data__,r=e6(n,e);return r<0?(++this.size,n.push([e,t])):n[r][1]=t,this};var e4=ex(ee,"Map"),e7=ex(Object,"create"),te=Object.prototype.hasOwnProperty,tt=Object.prototype.hasOwnProperty;function tn(e){var t=-1,n=null==e?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}tn.prototype.clear=function(){this.__data__=e7?e7(null):{},this.size=0},tn.prototype.delete=function(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t},tn.prototype.get=function(e){var t=this.__data__;if(e7){var n=t[e];return"__lodash_hash_undefined__"===n?void 0:n}return te.call(t,e)?t[e]:void 0},tn.prototype.has=function(e){var t=this.__data__;return e7?void 0!==t[e]:tt.call(t,e)},tn.prototype.set=function(e,t){var n=this.__data__;return this.size+=this.has(e)?0:1,n[e]=e7&&void 0===t?"__lodash_hash_undefined__":t,this};let tr=function(e){var t=typeof e;return"string"==t||"number"==t||"symbol"==t||"boolean"==t?"__proto__"!==e:null===e},ti=function(e,t){var n=e.__data__;return tr(t)?n["string"==typeof t?"string":"hash"]:n.map};function to(e){var t=-1,n=null==e?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}function ta(e){var t=this.__data__=new e8(e);this.size=t.size}function ts(e){var t=-1,n=null==e?0:e.length;for(this.__data__=new to;++t<n;)this.add(e[t])}to.prototype.clear=function(){this.size=0,this.__data__={hash:new tn,map:new(e4||e8),string:new tn}},to.prototype.delete=function(e){var t=ti(this,e).delete(e);return this.size-=t?1:0,t},to.prototype.get=function(e){return ti(this,e).get(e)},to.prototype.has=function(e){return ti(this,e).has(e)},to.prototype.set=function(e,t){var n=ti(this,e),r=n.size;return n.set(e,t),this.size+=n.size==r?0:1,this},ta.prototype.clear=function(){this.__data__=new e8,this.size=0},ta.prototype.delete=function(e){var t=this.__data__,n=t.delete(e);return this.size=t.size,n},ta.prototype.get=function(e){return this.__data__.get(e)},ta.prototype.has=function(e){return this.__data__.has(e)},ta.prototype.set=function(e,t){var n=this.__data__;if(n instanceof e8){var r=n.__data__;if(!e4||r.length<199)return r.push([e,t]),this.size=++n.size,this;n=this.__data__=new to(r)}return n.set(e,t),this.size=n.size,this},ts.prototype.add=ts.prototype.push=function(e){return this.__data__.set(e,"__lodash_hash_undefined__"),this},ts.prototype.has=function(e){return this.__data__.has(e)};let tu=function(e,t){for(var n=-1,r=null==e?0:e.length;++n<r;)if(t(e[n],n,e))return!0;return!1}
1,tl=function(e,t,n,r,i,o){var a=1&n,s=e.length,u=t.length;if(s!=u&&!(a&&u>s))return!1;var l=o.get(e),c=o.get(t);if(l&&c)return l==t&&c==e;var d=-1,p=!0,f=2&n?new ts:void 0;for(o.set(e,t),o.set(t,e);++d<s;){var y=e[d],m=t[d];if(r)var h=a?r(m,y,d,t,e,o):r(y,m,d,e,t,o);if(void 0!==h){if(h)continue;p=!1;break}if(f){if(!tu(t,function(e,t){if(!f.has(t)&&(y===e||i(y,e,n,r,o)))return f.push(t)})){p=!1;break}}else if(!(y===m||i(y,m,n,r,o))){p=!1;break}}return o.delete(e),o.delete(t),p};var tc=ee.Uint8Array;let td=function(e){var t=-1,n=Array(e.size);return e.forEach(function(e,r){n[++t]=[r,e]}),n},tp=function(e){var t=-1,n=Array(e.size);return e.forEach(function(e){n[++t]=e}),n};var tf=et?et.prototype:void 0,ty=tf?tf.valueOf:void 0;let tm=function(e,t,n,r,i,o,a){switch(n){case"[object DataView]":if(e.byteLength!=t.byteLength||e.byteOffset!=t.byteOffset)break;e=e.buffer,t=t.buffer;case"[object ArrayBuffer]":if(e.byteLength!=t.byteLength||!o(new tc(e),new tc(t)))break;return!0;case"[object Boolean]":case"[object Date]":case"[object Number]":return e5(+e,+t);case"[object Error]":return e.name==t.name&&e.message==t.message;case"[object RegExp]":case"[object String]":return e==t+"";case"[object Map]":var s=td;case"[object Set]":var u=1&r;if(s||(s=tp),e.size!=t.size&&!u)break;var l=a.get(e);if(l)return l==t;r|=2,a.set(e,t);var c=tl(s(e),s(t),r,i,o,a);return a.delete(e),c;case"[object Symbol]":if(ty)return ty.call(e)==ty.call(t)}return!1},th=function(e,t){for(var n=-1,r=t.length,i=e.length;++n<r;)e[i+n]=t[n];return e},tg=function(e,t,n){var r=t(e);return eT(e)?r:th(r,n(e))},tv=function(e,t){for(var n=-1,r=null==e?0:e.length,i=0,o=[];++n<r;){var a=e[n];t(a,n,e)&&(o[i++]=a)}return o};var tb=Object.prototype.propertyIsEnumerable,tw=Object.getOwnPropertySymbols,tx=tw?function(e){return null==e?[]:tv(tw(e=Object(e)),function(t){return tb.call(e,t)})}:function(){return[]};let tE=function(e){return tg(e,e2,tx)};var t_=Object.prototype.hasOwnProperty;let tk=function(e,t,n,r,i,o){var a=1&n,s=tE(e),u=s.length;if(u!=tE(t).length&&!a)return!1;for(var l=u;l--;){var c=s[l];if(!(a?c in t:t_.call(t,c)))return!1}var d=o.get(e),p=o.get(t);if(d&&p)return d==t&&p==e;var f=!0;o.set(e,t),o.set(t,e);for(var y=a;++l<u;){var m=e[c=s[l]],h=t[c];if(r)var g=a?r(h,m,c,t,e,o):r(m,h,c,e,t,o);if(!(void 0===g?m===h||i(m,h,n,r,o):g)){f=!1;break}y||(y="constructor"==c)}if(f&&!y){var v=e.constructor,b=t.constructor;v!=b&&"constructor"in e&&"constructor"in t&&!("function"==typeof v&&v instanceof v&&"function"==typeof b&&b instanceof b)&&(f=!1)}return o.delete(e),o.delete(t),f};var tj=ex(ee,"DataView"),tI=ex(ee,"Promise"),tM=ex(ee,"Set"),tS=ex(ee,"WeakMap"),t$="[object Map]",tO="[object Promise]",tA="[object Set]",tP="[object WeakMap]",tT="[object DataView]",tC=em(tj),tR=em(e4),tD=em(tI),tL=em(tM),tz=em(tS),tN=el;(tj&&tN(new tj(new ArrayBuffer(1)))!=tT||e4&&tN(new e4)!=t$||tI&&tN(tI.resolve())!=tO||tM&&tN(new tM)!=tA||tS&&tN(new tS)!=tP)&&(tN=function(e){var t=el(e),n="[object Object]"==t?e.constructor:void 0,r=n?em(n):"";if(r)switch(r){case tC:return tT;case tR:return t$;case tD:return tO;case tL:return tA;case tz:return tP}return t});let tU=tN;var tF="[object Arguments]",tV="[object Array]",tW="[object Object]",tq=Object.prototype.hasOwnProperty;let tG=function(e,t,n,r,i,o){var a=eT(e),s=eT(t),u=a?tV:tU(e),l=s?tV:tU(t);u=u==tF?tW:u,l=l==tF?tW:l;var c=u==tW,d=l==tW,p=u==l;if(p&&eL(e)){if(!eL(t))return!1;a=!0,c=!1}if(p&&!c)return o||(o=new ta),a||eY(e)?tl(e,t,n,r,i,o):tm(e,t,u,n,r,i,o);if(!(1&n)){var f=c&&tq.call(e,"__wrapped__"),y=d&&tq.call(t,"__wrapped__");
1if(f||y){var m=f?e.value():e,h=y?t.value():t;return o||(o=new ta),i(m,h,n,r,o)}}return!!p&&(o||(o=new ta),tk(e,t,n,r,i,o))},tB=function e(t,n,r,i,o){return t===n||(null!=t&&null!=n&&(eM(t)||eM(n))?tG(t,n,r,i,e,o):t!=t&&n!=n)},tY=function(e,t,n,r){var i=n.length,o=i,a=!r;if(null==e)return!o;for(e=Object(e);i--;){var s=n[i];if(a&&s[2]?s[1]!==e[s[0]]:!(s[0]in e))return!1}for(;++i<o;){var u=(s=n[i])[0],l=e[u],c=s[1];if(a&&s[2]){if(void 0===l&&!(u in e))return!1}else{var d=new ta;if(r)var p=r(l,c,u,e,t,d);if(!(void 0===p?tB(c,l,3,r,d):p))return!1}}return!0},tJ=function(e){return e==e&&!ec(e)},tH=function(e){for(var t=e2(e),n=t.length;n--;){var r=t[n],i=e[r];t[n]=[r,i,tJ(i)]}return t},tK=function(e,t){return function(n){return null!=n&&n[e]===t&&(void 0!==t||e in Object(n))}},tX=function(e){var t=tH(e);return 1==t.length&&t[0][2]?tK(t[0][0],t[0][1]):function(n){return n===e||tY(n,e,t)}},tZ=function(e){return"symbol"==typeof e||eM(e)&&"[object Symbol]"==el(e)};var tQ=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,t0=/^\w*$/;let t1=function(e,t){if(eT(e))return!1;var n=typeof e;return!!("number"==n||"symbol"==n||"boolean"==n||null==e||tZ(e))||t0.test(e)||!tQ.test(e)||null!=t&&e in Object(t)};function t2(e,t){if("function"!=typeof e||null!=t&&"function"!=typeof t)throw TypeError("Expected a function");var n=function(){var r=arguments,i=t?t.apply(this,r):r[0],o=n.cache;if(o.has(i))return o.get(i);var a=e.apply(this,r);return n.cache=o.set(i,a)||o,a};return n.cache=new(t2.Cache||to),n}t2.Cache=to;var t9=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,t5=/\\(\\)?/g,t6=function(e){var t=t2(e,function(e){return 500===n.size&&n.clear(),e}),n=t.cache;return t}(function(e){var t=[];return 46===e.charCodeAt(0)&&t.push(""),e.replace(t9,function(e,n,r,i){t.push(r?i.replace(t5,"$1"):n||e)}),t});let t3=function(e,t){for(var n=-1,r=null==e?0:e.length,i=Array(r);++n<r;)i[n]=t(e[n],n,e);return i};var t8=1/0,t4=et?et.prototype:void 0,t7=t4?t4.toString:void 0;let ne=function e(t){if("string"==typeof t)return t;if(eT(t))return t3(t,e)+"";if(tZ(t))return t7?t7.call(t):"";var n=t+"";return"0"==n&&1/t==-t8?"-0":n},nt=function(e,t){return eT(e)?e:t1(e,t)?[e]:t6(null==e?"":ne(e))};var nn=1/0;let nr=function(e){if("string"==typeof e||tZ(e))return e;var t=e+"";return"0"==t&&1/e==-nn?"-0":t},ni=function(e,t){t=nt(t,e);for(var n=0,r=t.length;null!=e&&n<r;)e=e[nr(t[n++])];return n&&n==r?e:void 0},no=function(e,t,n){var r=null==e?void 0:ni(e,t);return void 0===r?n:r},na=function(e,t){return null!=e&&t in Object(e)},ns=function(e,t,n){t=nt(t,e);for(var r=-1,i=t.length,o=!1;++r<i;){var a=nr(t[r]);if(!(o=null!=e&&n(e,a)))break;e=e[a]}return o||++r!=i?o:!!(i=null==e?0:e.length)&&eU(i)&&eN(a,i)&&(eT(e)||eP(e))},nu=function(e){return e},nl=function(e){var t;return t1(e)?(t=nr(e),function(e){return null==e?void 0:e[t]}):function(t){return ni(t,e)}},nc=function(e){if("function"==typeof e)return e;if(null==e)return nu;if("object"==typeof e){var t,n;return eT(e)?(t=e[0],n=e[1],t1(t)&&tJ(n)?tK(nr(t),n):function(e){var r=no(e,t);return void 0===r&&r===n?null!=e&&ns(e,t,na):tB(n,r,3)}):tX(e)}return nl(e)};var nd=Object.prototype.hasOwnProperty,np=(o=function(e,t,n){nd.call(e,n)?e[n].push(t):e_(e,n,[t])},function(e,t){return(eT(e)?ek:function(e,t,n,r){return e9(e,function(e,i,o){t(r,e,n(e),o)}),r})(e,o,nc(t,2),{})}),nf=n(56918),ny=n(28983),nm=n(30070),nh=n(48179),ng=n(12260),nv=n(59176),nb=n(53825),nw=n(40223);function nx(e){if("patch"===e.type)return e.id;if("create"===e.type)return e.document._id;if("delete"===e.type)return e.id;if("createIfNotExists"===e.type||"createOrReplace"===e.type)return e.document._id;throw Error("Invalid mutation type")}let nE=(e=21)=>{let t="",n=crypto.getRandomValues(new Uint8Array(e));for(;e--;)t+="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict"[63&n[e]];return t};function n_(e){return"string"==typeof e?._key}function nk(e){return"object"==typeof e&&"_key"in e&&"string"==typeof e._key}function nj(e){return"number"==typeof e||nk(e)}function nI(e,t){if(0===e.length)return t;let n=t;for(let t of e){if(nj(t)){if(!Array.isArray(n))return;if(nk(t)){n=n.find(e=>e._key===t._key);continue}n=n[t];continue}n=n[t]}return n}let nM=/^[a-z_$]+/;function nS(e){return e.map((e,t)=>{var n;return n=0===t,Array.isArray(e)?`[${e[0]}:${e[1]||""}]`:"number"==typeof e?`[${e}
1]`:nk(e)?`[_key==${JSON.stringify(e._key)}]`:"string"==typeof e&&nM.test(e)?n?e:`.${e}`:`['${e}']`}).join("")}function n$(e){return null!==e&&"object"==typeof e&&!Array.isArray(e)}function nO(e,t){if("number"==typeof t)return function(e,t){if(0===e&&(-1===t||0===t))return 0;let n=t<0?e+t:t;return n>=e||n<0?null:n}(e.length,t);if(nk(t)){let n=e.findIndex(e=>(null!==e&&"object"==typeof e&&"string"==typeof e._key&&e._key||null)===t._key);return -1===n?null:n}throw Error(`Expected path segment to be addressing a single array item either by numeric index or by '_key'. Instead saw ${JSON.stringify(t)}`)}function nA(e,t,n,r){let i=e.slice();return i.splice(t,n,...r||[]),i}function nP(e,t){if(!Array.isArray(t))throw TypeError('Cannot apply "insert()" on non-array value');let n=nO(t,e.referenceItem);if(null===n)throw Error(`Found no matching array element to insert ${e.position}`);return 0===t.length?e.items:nA(t,"before"===e.position?n:n+1,0,e.items)}let nT=Object.prototype.hasOwnProperty.call.bind(Object.prototype.hasOwnProperty);var nC=Object.freeze({__proto__:null,assign:function(e,t){if(!n$(t))throw TypeError('Cannot apply "assign()" on non-object value');return!function(e){for(let t in e)if(nT(e,t))return!1;return!0}(e.value)?{...t,...e.value}:t},dec:function(e,t){if("number"!=typeof t)throw TypeError('Cannot apply "dec()" on non-numeric value');return t-e.amount},diffMatchPatch:function(e,t){if("string"!=typeof t)throw TypeError('Cannot apply "diffMatchPatch()" on non-string value');return(0,X.$i)((0,X.iz)(e.value),t)[0]},inc:function(e,t){if("number"!=typeof t)throw TypeError('Cannot apply "inc()" on non-numeric value');return t+e.amount},insert:nP,remove:function(e,t){if(!Array.isArray(t))throw TypeError('Cannot apply "remove()" on non-array value');let n=nO(t,e.referenceItem);if(null===n)throw Error("Found no matching array element to replace");return nA(t,n,1,[])},replace:function(e,t){if(!Array.isArray(t))throw TypeError('Cannot apply "replace()" on non-array value');let n=nO(t,e.referenceItem);if(null===n)throw Error("Found no matching array element to replace");return nA(t,n,e.items.length,e.items)},set:function(e,t){return e.value},setIfMissing:function(e,t){return t??e.value},truncate:function(e,t){if(!Array.isArray(t))throw TypeError('Cannot apply "truncate()" on non-array value');return"number"==typeof e.endIndex?t.slice(0,e.startIndex).concat(t.slice(e.endIndex)):t.slice(0,e.startIndex)},unassign:function(e,t){if(!n$(t))throw TypeError('Cannot apply "unassign()" on non-object value');return 0===e.keys.length?t:function(e,t){let n={...e};for(let e of t)delete n[e];return n}(t,e.keys)},unset:function(e){},upsert:function(e,t){if(!Array.isArray(t))throw TypeError('Cannot apply "upsert()" on non-array value');
1if(0===e.items.length)return t;let n=[],r=[];if(e.items.forEach((e,i)=>{let o=t.findIndex(t=>t?._key===e._key);o>=0?n[o]=i:r.push(e)}),0===n.length&&0==r.length)return t;let i=[...t];for(let t of n)i[t]=e.items[n[t]];return nP({type:"insert",items:r,referenceItem:e.referenceItem,position:e.position},i)}});function nR(e,t){return e.reduce((e,t)=>nD(t,e),t)}function nD(e,t){return function e(t,n,r){if(!(t.length>0))return function(e,t){if(!(e.type in nC))throw Error(`Invalid operation type: "${e.type}"`);return nC[e.type](e,t)}(n,r);let[i,...o]=t;if(nj(i)&&Array.isArray(r))return function(t,n,r,i){let o=nO(i,t);if(null===o||-1===o)return i;let a=i[o],s=e(n,r,a);return s===a?i:nA(i,o,1,[s])}(i,o,n,r);if("string"==typeof i&&n$(r))return function(t,n,r,i){let o=i[t];if(void 0===o&&n.length>0)return i;let a=e(n,r,o);return a===o?i:{...i,[t]:a}}(i,o,n,r);throw Error(`Cannot apply operation of type "${n.type}" to path ${nS(t)} on ${typeof r} value`)}(e.path,e.op,t)}function nL(e){return"_id"in e}function nz(e,t){return t.reduce((e,t)=>{let n=nN(e,t);if("error"===n.status)throw Error(n.message);return"noop"===n.status?e:n.after},e)}function nN(e,t){if("create"===t.type)return function(e,t){var n;if(e)return{status:"error",message:"Document already exist"};let r=nL(n=t.document)?n:{...n,_id:nE()};return{status:"created",id:r._id,after:r}}(e,t);if("createIfNotExists"===t.type)return nL(t.document)?e?{status:"noop"}:{status:"created",id:t.document._id,after:t.document}:{status:"error",message:"Cannot createIfNotExists on document without _id"};if("delete"===t.type)return e?t.id!==e._id?{status:"error",message:"Delete mutation targeted wrong document"}:{status:"deleted",id:t.id,before:e,after:void 0}:{status:"noop"};if("createOrReplace"===t.type)return nL(t.document)?e?{status:"updated",id:t.document._id,before:e,after:t.document}:{status:"created",id:t.document._id,after:t.document}:{status:"error",message:"Cannot createIfNotExists on document without _id"};if("patch"===t.type)return function(e,t){if(!e)return{status:"error",message:"Cannot apply patch on nonexistent document"};let n=function(e,t){if(e.options?.ifRevision&&t._rev!==e.options.ifRevision)throw Error("Revision mismatch");if(e.id!==t._id)throw Error(`Document id mismatch. Refusing to apply mutation for document with id="${e.id}" on the given document with id="${t._id}"`);return nR(e.patches,t)}(t,e);return e===n?{status:"noop"}:{status:"updated",id:t.id,before:e,after:n}}(e,t);throw Error(`Invalid mutation type: ${t.type}`)}function nU(e,t,n){let r=[];for(let n of e.slice().reverse()){if(t(n))return r;r.push(n)}return r.reverse()}function nF(e,t){return nS(e)===nS(t)}function nV(e,t){let n=e;return t.reduce((e,t)=>{let r=n;if(n=nD(t,n),"set"===t.op.type&&"string"==typeof t.op.value){let n=nI(t.path,r);if("string"==typeof n){let r={...t,op:{type:"diffMatchPatch",value:(0,X.w1)((0,X.jW)(n,t.op.value))}};return e.flatMap(e=>nF(e.path,t.path)&&"diffMatchPatch"===e.op.type?[]:e).concat(r)}}return e.push(t),e},[])}function nW(e,t,n,r){let i=t,o=r.map(t=>{let n=t.mutations.flatMap(t=>{if(nx(t)!==e)return[];let n=i;return i=nz(i,[t]),n&&"patch"===t.type?{type:"dmpified",mutation:{...t,dmpPatches:nV(n,t.patches),original:t.patches}}:t});return{...t,mutations:n}}),a=n;return o.map(t=>{let n=[];return t.mutations.forEach(t=>{if("dmpified"===t.type)try{a=nR(t.mutation.dmpPatches,a),n.push(t)}catch{console.warn("Failed to apply dmp patch, falling back to original");try{a=nR(t.mutation.original,a),n.push(t)}catch(t){throw Error(`Failed to apply patch for document "${e}": ${t.message}`)}}else a=nz(a,[t])})}),[r.map(t=>({...t,mutations:t.mutations.map(t=>"patch"!==t.type||nx(t)!==e?t:{...t,patches:t.patches.map(e=>"set"!==e.op.type?e:{...e,op:{...e.op,value:nI(e.path,a)}})})})),a]}function nq(e){return function(e){if("create"===e.type||"createIfNotExists"===e.type||"createOrReplace"===e.type)return{[e.type]:e.document};if("delete"===e.type)return{delete:{id:e.id}};let t=e.options?.ifRevision;return e.patches.map(n=>({patch:{id:e.id,...t&&{ifRevisionID:t},...function(e){let{path:t,op:n}=e;if("unset"===n.type)return{unset:[nS(t)]};if("insert"===n.type)return{insert:{[n.position]:nS([...t,n.referenceItem]),items:n.items}};if("diffMatchPatch"===n.type)return{diffMatchPatch:{[nS(t)]:n.value}};if("inc"===n.type)return{inc:{[nS(t)]:n.amount}};if("dec"===n.type)return{dec:{[nS(t)]:n.amount}};if("set"===n.type||"setIfMissing"===n.type)return{[n.type]:{[nS(t)]:n.value}};if("truncate"===n.type){let e=[n.startIndex,"number"==typeof n.endIndex?n.endIndex:""].join(":");return{unset:[`${nS(t)}[${e}]`]}}if("upsert"===n.type)return{unset:n.items.map(e=>
1nS([...t,{_key:e._key}])),insert:{[n.position]:nS([...t,n.referenceItem]),items:n.items}};if("assign"===n.type)return{set:Object.fromEntries(Object.keys(n.value).map(e=>[nS(t.concat(e)),n.value[e]]))};if("unassign"===n.type)return{unset:n.keys.map(e=>nS(t.concat(e)))};if("replace"===n.type)return{insert:{replace:nS(t.concat(n.referenceItem)),items:n.items}};if("remove"===n.type)return{unset:[nS(t.concat(n.referenceItem))]};throw Error(`Unknown operation type ${n.type}`)}(n)}}))}(e)}function nG(e){let t=e.listen('*[!(_id in path("_.**"))]',{},{events:["welcome","mutation","reconnect"],includeResult:!1,includePreviousRevision:!1,visibility:"transaction",effectFormat:"mendoza",includeMutations:!1}).pipe((0,ny.u)({resetOnRefCountZero:!0})),n=t.pipe((0,nm.p)(e=>"reconnect"===e.type)),r=t.pipe((0,nm.p)(e=>"welcome"===e.type)),i=t.pipe((0,nm.p)(e=>"mutation"===e.type)),o=(0,nh.h)(r,n).pipe((0,ng.t)({bufferSize:1,refCount:!0})).pipe((0,nm.p)(e=>"welcome"===e.type));return(0,nh.h)(o,i,n)}let nB=(0,H.mj)({types:{},actions:{"assign error to context":(0,J.a)({error:({event:e})=>e}),"clear error from context":(0,J.a)({error:void 0}),"connect to server-sent events":(0,K.O)({type:"connect"}),"listen to server-sent events":(0,K.P)("server-sent events",{id:"listener",input:({context:e})=>({listener:e.sharedListener||nG(e.client),id:e.id})}),"stop listening to server-sent events":(0,K.R)("listener"),"buffer remote mutation events":(0,J.a)({mutationEvents:({event:e,context:t})=>((0,H.DT)(e,"mutation"),[...t.mutationEvents,e])}),"restore stashed changes":(0,J.a)({stagedChanges:({event:e,context:t})=>((0,H.DT)(e,"xstate.done.actor.submitTransactions"),t.stashedChanges),stashedChanges:[]}),"rebase fetched remote snapshot":(0,J.b)(({enqueue:e})=>{e.assign(({event:e,context:t})=>{(0,H.DT)(e,"xstate.done.actor.getDocument");let n=t.remote,r=e.output,i=!1;for(let e of t.mutationEvents)e.effects?.apply&&(e.previousRev||"appear"===e.transition)&&(i||e.previousRev!==r?._rev||(i=!0),i&&(r=nY(r,e.effects.apply,e.resultRev)));t.cache&&(!t.cache.has(t.id)||t.cache.get(t.id)._rev!==r?._rev)&&t.cache.set(t.id,r);let[o,a]=nW(t.id,null===n?void 0:n,null===r?void 0:r,t.stagedChanges);return{remote:r,local:a,stagedChanges:o,mutationEvents:[]}}),e.sendParent(({context:e})=>({type:"rebased.remote",id:e.id,document:e.remote}))}),"apply mendoza patch":(0,J.a)(({event:e,context:t})=>{(0,H.DT)(e,"mutation");let n=t.remote;if(e.transactionId===n?._rev)return{};let r=nY(n,e.effects.apply,e.resultRev);t.cache&&(!t.cache.has(t.id)||t.cache.get(t.id)._rev!==r?._rev)&&t.cache.set(t.id,r);let[i,o]=nW(t.id,null===n?void 0:n,null===r?void 0:r,t.stagedChanges);return{remote:r,local:o,stagedChanges:i}}),"increment fetch attempts":(0,J.a)({fetchRemoteSnapshotAttempts:({context:e})=>e.fetchRemoteSnapshotAttempts+1}),"reset fetch attempts":(0,J.a)({fetchRemoteSnapshotAttempts:0}),"increment submit attempts":(0,J.a)({submitTransactionsAttempts:({context:e})=>e.submitTransactionsAttempts+1}),"reset submit attempts":(0,J.a)({submitTransactionsAttempts:0}),"stage mutation":(0,J.a)({stagedChanges:({event:e,context:t})=>((0,H.DT)(e,"mutate"),[...t.stagedChanges,{transaction:!1,mutations:e.mutations}])}),"stash mutation":(0,J.a)({stashedChanges:({event:e,context:t})=>((0,H.DT)(e,"mutate"),[...t.stashedChanges,{transaction:!1,mutations:e.mutations}])}),"rebase local snapshot":(0,J.b)(({enqueue:e})=>{e.assign({local:({event:e,context:t})=>{(0,H.DT)(e,"mutate");let n=new Map;return t.local&&n.set(t.id,t.local),function(e,t){e.forEach(e=>{("created"===e.status||"updated"===e.status)&&t.set(e.id,e.after),"deleted"===e.status&&t.delete(e.id)})}(function(e,t){let n=Object.create(null);for(let r of e){let e=nx(r);if(!e)throw Error("Unable to get document id from mutation");let i=n[e]?.after||t.get(e),o=nN(i,r);if("error"===o.status)throw Error(o.message);"noop"!==o.status&&("updated"===o.status||"created"===o.status||"deleted"===o.status)&&(e in n||(n[e]={before:i,after:void 0,muts:[]}),n[e].after=o.after)}return Object.entries(n).map(([e,{before:t,after:n,muts:r}])=>({id:e,status:n?t?"updated":"created":"deleted",mutations:r,before:t,after:n}))}(e.mutations,n),n),n.get(t.id)}}),e.sendParent(({context:e})=>({type:"rebased.local",id:e.id,document:e.local}))}),"send pristine event to parent":(0,J.s)(({context:e})=>({type:"pristine",id:e.id})),"send sync event to parent":(0,J.s)(({context:e})=>({type:"sync",id:e.id,document:e.remote})),"send mutation event to parent":(0,J.s)(({context:e,event:t})=>((0,H.DT)(t,"mutation"),{type:"mutation",id:e.id,previousRev:t.previousRev,resultRev:t.resultRev,effects:t.effects}))},actors:{"server-sent events":(0,Y.OX)(({input:e})=>{let{listener:t,id:n}=e;return(0,nv.v)(()=>t).pipe((0,nm.p)(e=>"welcome"===e.type||"reconnect"===e.type||"mutation"===e.type&&e.documentId===n),(0,nb.Q)(nw.$))}),"fetch remote snapshot":(0,Y.Sx)(async({input:e,signal:t})=>{let{client:n,id:r}=e;return await n.getDocument(r,{signal:t}).catch(e=>{if(!(e instanceof Error&&"AbortError"===e.name))throw e})}),"submit mutations as transactions":(0,Y.Sx)(async({input:e,signal:t})=>{let{client:n,transactions:r}=e;for(let e of r){if(t.aborted)return;await n.dataRequest("mutate",function(e){return{transactionId:e.id,mutations:e.mutations.flatMap(nq)}}(e),{visibility:"async",returnDocuments:!1,signal:t}).catch(e=>{if(!(e instanceof Error&&"AbortError"===e.name))throw e})}})},delays:{fetchRemoteSnapshotTimeout:({context:e})=>1e3*Math.pow(2,e.fetchRemoteSnapshotAttempts),submitTransactionsTimeout:({context:e})=>1e3*Math.pow(2,e.submitTransactionsAttempts)}}).createMachine({id:"document-mutator",context:({input:e})=>({client:e.client.withConfig({allowReconfigure:!1}),sharedListener:e.sharedListener,id:e.id,remote:void 0,local:void 0,mutationEvents:[],stagedChanges:[],stashedChanges:[],error:void 0,fetchRemoteSnapshotAttempts:0,submitTransactionsAttempts:0,cache:e.cache}),entry:["connect to server-sent events"],on:{mutate:{actions:["rebase local snapshot","stage mutation"]}},initial:"disconnected",states:{disconnected:{on:{connect:{target:"connecting",actions:["listen to server-sent events"]}}},connecting:{on:{welcome:"connected",reconnect:"reconnecting",error:"connectFailure"},tags:["busy"]},connectFailure:{on:{connect:{target:"connecting",actions:["listen to server-sent events"]}},entry:["stop listening to server-sent events","assign error to context"],exit:["clear error from context"],tags:["error"]},reconnecting:{on:{welcome:{target:"connected"},error:{target:"connectFailure"}},tags:["busy","error"]},connected:{on:{mutation:{actions:["buffer remote mutation events"]},reconnect:"reconnecting"},entry:["clear error from context"],initial:"loading",states:{loading:{invoke:{src:"fetch remote snapshot",id:"getDocument",input:({context:e})=>({client:e.client,id:e.id}),onError:{target:"loadFailure"},onDone:{target:"loaded",actions:["rebase fetched remote snapshot","reset fetch attempts"]}},tags:["busy"]},loaded:{entry:["send sync event to parent"],on:{mutation:{actions:["apply mendoza patch","send mutation event to parent"]}},initial:"pristine",states:{pristine:{on:{mutate:{actions:["rebase local snapshot","stage mutation"],target:"dirty"}},tags:["ready"]},dirty:{on:{submit:"submitting"},tags:["ready"]},submitting:{on:{mutate:{actions:["rebase local snapshot","stash mutation"]}},invoke:{src:"submit mutations as transactions",id:"submitTransactions",input:({context:e})=>{let t=new Map;return t.set(e.id,e.remote),{client:e.client,transactions:(function(e,t){let n=[],r=[];
1return e.forEach(e=>{t(e)?r.push(e):(r.length>0&&n.push(r),r=[],n.push([e]))}),r.length>0&&n.push(r),n})(e.stagedChanges,e=>!e.transaction).flatMap(e=>({...e[0],mutations:e.flatMap(e=>e.mutations)})).map(e=>({...e,mutations:Object.values(np(e.mutations,nx)).flatMap(e=>{var t;return(0===(t=0===e.length?e:e.reduce((e,t)=>"delete"===t.type?[t]:(e.push(t),e),[])).length?t:t.reduce((e,t)=>("createIfNotExists"!==t.type?e.push(t):nU(e,e=>"delete"===e.type).find(e=>"createIfNotExists"===e.type)||e.push(t),e),[])).flat().reduce((e,t)=>{let n=e[e.length-1];return n&&"patch"!==n.type||"patch"!==t.type?e.concat(t):e.slice(0,-1).concat({...t,patches:(n?.patches||[]).concat(t.patches)})},[])})})).map(e=>({...e,mutations:e.mutations.map(e=>"patch"!==e.type?e:{...e,patches:e.patches.reduce((e,t)=>{if("unset"!==t.op.type)return e.push(t),e;let n=e.filter(e=>{var n,r;return n=t.path,r=e.path,!(n.length<=r.length&&n.every((e,t)=>{var n;return n=function(e,t){if(t<0||t>=e.length)throw Error("Index out of bounds");return e[t]}(r,t),n_(e)&&n_(n)?e._key===n._key:"number"==typeof e?Number(e)===Number(n):e===n}))});return n.push(t),n},[]).reduceRight((e,t)=>(e.find(e=>{var n,r;return n=e.op,("set"===(r=t.op).type||"unset"===r.type)&&("set"===n.type||"unset"===n.type)&&nF(e.path,t.path)})||e.unshift(t),e),[]).reduce((e,t)=>("setIfMissing"!==t.op.type?e.push(t):nU(e,e=>"unset"===e.op.type).find(e=>"setIfMissing"===e.op.type&&nF(e.path,t.path))||e.push(t),e),[])})})).map(e=>({...e,mutations:e.mutations.map((e,n)=>{var r;return"patch"===e.type&&(r=t.get(e.id))?{...e,patches:nV(r,e.patches)}:e})})).map(e=>e.transaction&&void 0!==e.id?{id:e.id,mutations:e.mutations}:{mutations:e.mutations})}},onError:{target:"submitFailure"},onDone:{target:"pristine",actions:["restore stashed changes","reset submit attempts","send pristine event to parent"]}},tags:["busy","ready"]},submitFailure:{exit:["clear error from context"],after:{submitTransactionsTimeout:{actions:["increment submit attempts"],target:"submitting"}},on:{retry:"submitting"},tags:["error","ready"]}}},loadFailure:{exit:["clear error from context"],after:{fetchRemoteSnapshotTimeout:{actions:["increment fetch attempts"],target:"loading"}},on:{retry:"loading"},tags:["error"]}}}}});function nY(e,t,n){let r=(0,nf.X)(function(e){if(!e)return null;let{_rev:t,...n}=e;return n}(e),t);return r?Object.assign(r,{_rev:n}):null}let nJ=e=>{let t=(0,Y.Sx)(async({input:t,signal:n})=>{let{id:r}=t,{snapshot:i}=await e.fetch("visual-editing/fetch-snapshot",{documentId:r},{signal:n});return i}),n=(0,Y.Sx)(async({input:t})=>{let{transactions:n}=t;for(let t of n){let n=V.encodeTransaction(t);return e.post("visual-editing/mutate",n)}});return nB.provide({actions:{"send sync event to parent":(0,J.b)(({enqueue:e})=>{e.sendParent(({context:e})=>({type:"sync",id:e.id,document:e.remote})),e.emit(({context:e})=>({type:"ready",snapshot:e.local}))})},actors:{"fetch remote snapshot":t,"submit mutations as transactions":n}})},nH=(0,H.mj)({types:{},actions:{"emit sync event":(0,J.e)(({event:e})=>((0,H.DT)(e,"sync"),e)),"emit mutation event":(0,J.e)(({event:e})=>((0,H.DT)(e,"mutation"),e)),"emit rebased event":(0,J.e)(({event:e})=>((0,H.DT)(e,["rebased.local","rebased.remote"]),e)),"emit pristine event":(0,J.e)(({event:e})=>((0,H.DT)(e,["pristine"]),e)),"add document actor":(0,J.a)({documents:({context:e,event:t,spawn:n})=>{(0,H.DT)(t,"observe");let r=t.documentId;return e.documents[r]?e.documents:{...e.documents,[r]:n("documentMutatorMachine",{input
1:{id:r,client:e.client,sharedListener:e.sharedListener||nG(e.client)},id:r})}}}),"stop remote snapshot":(0,K.R)(({context:e,event:t})=>((0,H.DT)(t,"unobserve"),e.documents[t.documentId])),"remove remote snapshot from context":(0,J.a)({documents:({context:e,event:t})=>{if((0,H.DT)(t,"unobserve"),!e.documents[t.documentId])return e.documents;let{[t.documentId]:n,...r}=e.documents;return r}})},actors:{documentMutatorMachine:nB}}).createMachine({id:"dataset-mutator",context:({input:e})=>({documents:{},client:e.client,sharedListener:e.sharedListener}),on:{sync:{actions:["emit sync event"]},mutation:{actions:["emit mutation event"]},"rebased.*":{actions:["emit rebased event"]},pristine:{actions:["emit pristine event"]},observe:{actions:["add document actor"]},unobserve:{actions:["stop remote snapshot","remove remote snapshot from context"]}},initial:"pristine",states:{pristine:{}}}),nK=e=>nH.provide({actors:{documentMutatorMachine:nJ(e)}}),nX=(0,Y.H6)(),nZ=nX,nQ=new Set;var n0=n(49293);let n1=/_key\s*==\s*['"](.*)['"]/,n2=/^\d*:\d*$/;function n9(e){return"number"==typeof e||"string"==typeof e&&/^\[\d+\]$/.test(e)}function n5(e){return"string"==typeof e?n1.test(e.trim()):"object"==typeof e&&"_key"in e}let n6=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,n3=/_key\s*==\s*['"](.*)['"]/;function n8(e,t,n){let r="string"==typeof t?function(e){if("string"!=typeof e)throw Error("Path is not a string");let t=e.match(n6);if(!t)throw Error("Invalid path string");return t.map(n4)}(t):t;if(!Array.isArray(r))throw Error("Path must be an array or a string");let i=e;for(let e=0;e<r.length;e++){let t=r[e];if(n9(t)){if(!Array.isArray(i))return n;i=i[t]}if(n5(t)){if(!Array.isArray(i))return n;i=i.find(e=>e._key===t._key)}if("string"==typeof t&&(i="object"==typeof i&&null!==i?i[t]:void 0),typeof i>"u")return n}return i}function n4(e){return n9(e)?Number(e.replace(/[^\d]/g,"")):n5(e)?{_key:e.match(n3)[1]}:!function(e){if("string"==typeof e&&n2.test(e))return!0;if(!Array.isArray(e)||2!==e.length)return!1;let[t,n]=e;return!("number"!=typeof t&&""!==t||"number"!=typeof n&&""!==n)}(e)?e:function(e){let[t,n]=e.split(":").map(e=>""===e?e:Number(e));return[t,n]}(e)}function n7(){let e=(0,y.useCallback)(e=>(nQ.add(e),()=>nQ.delete(e)),[]);return(0,y.useSyncExternalStore)(e,()=>nZ,()=>nX)}function re(){let e=n7();return(0,y.useMemo)(()=>e!==nX,[e])}function rt(e,t){let n;return(...r)=>{clearTimeout(n),n=setTimeout(()=>{e.apply(e,r)},t)}}function rn(e,t){let n=(0,f.Fk)(),r=(0,f.v$)();if(t===nX||!n&&!r)throw Error("The `useDocuments` hook cannot be used in this context");let i=$(e),o=O(e),a=t.getSnapshot().context?.documents,s=a?.[i],u=a?.[o],l=s||u;if(!l)throw Error(`Document "${e}" not found`);let c=s.getSnapshot().context?.local||u.getSnapshot().context?.local,d=new Promise(e=>{if(c)e(c);else{let t=l.on("ready",n=>{let{snapshot:r}=n;e(r||null),t.unsubscribe()})}});return{draftDoc:s,draftId:i,getSnapshot:()=>d,publishedDoc:u,publishedId:o,get snapshot(){if(!c)throw Error(`Snapshot for document "${e}" not found`);return c}}}function rr(){let e=n7();return{getDocument:(0,y.useCallback)(t=>({id:t,commit:()=>{let{draftDoc:n}=rn(t,e);n.send({type:"submit"})},get:n=>{let{snapshot:r}=rn(t,e);return n?n8(r,n):r},getSnapshot:function(e,t){let{getSnapshot:n}=rn(e,t);return n}(t,e),patch:async(n,r)=>{let i=rn(t,e),{draftDoc:o,draftId:a,getSnapshot:s,publishedId:u}=i,{commit:l=!0}=r||{},c=await ("function"==typeof n?n({draftId:a,publishedId:u,get snapshot(){return i.snapshot},getSnapshot:s}):n),d=await s();if(!d)throw Error(`Snapshot for document "${t}" not found`);o.send({type:"mutate",mutations:[{type:"createIfNotExists",document:{...d,_id:a}},{type:"patch",id:a,patches:F(c)}]}),l&&("object"==typeof l&&"debounce"in l?rt(()=>o.send({type:"submit"}),l.debounce)():o.send({type:"submit"}))}}),[e]),mutateDocument:(0,y.useCallback)((t,n,r)=>{let{draftDoc:i}=rn(t,e),{commit:o=!0}=r||{};i.send({type:"mutate",mutations:n}),o&&("object"==typeof o&&"debounce"in o?rt(()=>i.send({type:"submit"}),o.debounce)():i.send({type:"submit"}))},[e])}}let ri=(()=>{let e;return()=>{if(e)return e;e=[];for(let t=0;t<256;++t)e[t]=(t+256).toString(16).slice(1);return e}})();function ro(e){let t=ri();return(function(e=16){let t=new Uint8Array(e);return(0,n0.A)(t),t})(e).reduce((e,n)=>e+t[n],"").slice(0,e)}function ra(e){let t,n;let r="string"==typeof e?e:e.path,i=r.lastIndexOf("."),o=r.substring(i+1,r.length);if(!o.indexOf("["))throw Error("Invalid path: not an array");let a=r.lastIndexOf("["),s=r.substring(0,a);if(o.includes("_key")){let e=o.indexOf('"')+1,r=o.indexOf('"',e);t=o.substring(e,r),n=!0}else{let e=o.indexOf("[")+1,r=o.indexOf("]",e);t=o.substring(e,r),n=!1}if(!s||!t)throw Error("Invalid path");return{path:s,key:t,hasExplicitKey:n}}async function rs(e,t,n){if(!e.type)throw Error("Node type is missing");let{path:r,key:i}=ra(e),o=await t.getSnapshot(),a=n8(o,r),s=n8(o,e.path),u=a.findIndex(e=>e._key===i),l=-1,c="before";if("first"===n){if(0===u)return[];l=0,c="before"}else if("last"===n){if(u===a.length-1)return[];l=-1,c="after"}else if("next"===n){if(u===a.length-1)return[];l=u,c="after"}else if("previous"===n){if(0===u)return[];l=u-1,c="before"}return[B(r,q(u,u+1)),B(r,W(s,c,l))]}function ru(e){return{lang:e?.lang??u?.lang,message:e?.message,abortEarly:e?.abortEarly??u?.abortEarly,abortPipeEarly:e?.abortPipeEarly??u?.abortPipeEarly,skipPipe:e?.skipPipe}}function rl(e,t,n,r,i){var o,a,s,u;let p;let f=i&&"input"in i?i.input:n.value,y=i?.expected??e.expects,m=i?.received??("object"==(p=typeof f)&&(p=(f&&Object.getPrototypeOf(f)?.constructor?.name)??"null"),"string"===p?`"${f}"`:"number"===p||"bigint"===p||"boolean"===p?`${f}`:p),h={kind:e.kind,type:e.type,input:f,expected:y,received:m,message:`Invalid ${t}: ${y?`Expected ${y} but r`:"R"}eceived ${m}`,requirement:e.requirement,path:i?.path,issues:i?.issues,lang:r.lang,abortEarly:r.abortEarly,abortPipeEarly:r.abortPipeEarly,skipPipe:r.skipPipe},g="schema"===e.kind,v=e.message??(o=e.reference,a=h.lang,d?.get(o)?.get(a))??(g?(s=h.lang,c?.get(s)):null)??r.message??(u=h.lang,l?.get(u));v&&(h.message="function"==typeof v?v(h):v),g&&(n.typed=!1),n.issues?n.issues.push(h):n.issues=[h]}
1var rc=class extends Error{issues;constructor(e){super(e[0].message),this.name="ValiError",this.issues=e}};function rd(e,t){return{kind:"validation",type:"min_length",reference:rd,async:!1,expects:`>=${e}`,requirement:e,message:t,_run(e,t){return e.typed&&e.value.length<this.requirement&&rl(this,"length",e,t,{received:`${e.value.length}`}),e}}}function rp(e,t,n){return"function"==typeof e.fallback?e.fallback(t,n):e.fallback}function rf(e,t,n){return"function"==typeof e.default?e.default(t,n):e.default}function ry(e){if("entries"in e){let t={};for(let n in e.entries)t[n]=ry(e.entries[n]);return t}return"items"in e?e.items.map(ry):rf(e)}async function rm(e){return"entries"in e?Object.fromEntries(await Promise.all(Object.entries(e.entries).map(async([e,t])=>[e,await rm(t)]))):"items"in e?Promise.all(e.items.map(rm)):rf(e)}function rh(e){if("entries"in e){let t={};for(let n in e.entries)t[n]=rh(e.entries[n]);return t}return"items"in e?e.items.map(rh):rp(e)}async function rg(e){return"entries"in e?Object.fromEntries(await Promise.all(Object.entries(e.entries).map(async([e,t])=>[e,await rg(t)]))):"items"in e?Promise.all(e.items.map(rg)):rp(e)}function rv(e,t){return{kind:"schema",type:"object",reference:rv,expects:"Object",async:!1,entries:e,message:t,_run(e,t){let n=e.value;if(n&&"object"==typeof n)for(let r in e.typed=!0,e.value={},this.entries){let i=n[r],o=this.entries[r]._run({typed:!1,value:i},t);if(o.issues){let a={type:"object",origin:"value",input:n,key:r,value:i};for(let t of o.issues)t.path?t.path.unshift(a):t.path=[a],e.issues?.push(t);if(e.issues||(e.issues=o.issues),t.abortEarly){e.typed=!1;break}}o.typed||(e.typed=!1),(void 0!==o.value||r in n)&&(e.value[r]=o.value)}else rl(this,"type",e,t);return e}}}function rb(e,...t){let n={kind:"schema",type:"optional",reference:rb,expects:`${e.expects} | undefined`,async:!1,wrapped:e,_run(e,t){return void 0===e.value&&("default"in this&&(e.value=rf(this,e,t)),void 0===e.value)?(e.typed=!0,e):this.wrapped._run(e,t)}};return 0 in t&&(n.default=t[0]),n}function rw(e){return{kind:"schema",type:"string",reference:rw,expects:"string",async:!1,message:e,_run(e,t){return"string"==typeof e.value?e.typed=!0:rl(this,"type",e,t),e}}}function rx(...e){return{...e[0],pipe:e,_run(t,n){for(let r=0;r<e.length;r++){t=e[r]._run(t,n);let i=e[r+1];if(n.skipPipe||t.issues&&(n.abortEarly||n.abortPipeEarly||i?.kind==="schema"||i?.kind==="transformation")){t.typed=!1;break}}return t}}}function rE(e,t,n){let r=e._run({typed:!1,value:t},ru(n));return{typed:r.typed,success:!r.issues,output:r.value,issues:r.issues}}let r_=rx(rw(),rd(1)),rk=rb(r_),rj=rv({baseUrl:r_,dataset:rk,id:r_,path:r_,projectId:rk,tool:rk,type:rk,workspace:rk}),rI=/^([\w-]+):(0|[1-9][0-9]*)$/,rM=/^([\w-]+):([0-9]+),([0-9]+)$/,rS=/^([\w-]+):([\w-]+)$/,r$=rx(rw(),rd(1)),rO=rv({origin:r$,href:r$,data:rb(function e(t,n,r){return{kind:"schema",type:"record",reference:e,expects:"Object",async:!1,key:t,value:n,message:r,_run(e,t){let n=e.value;if(n&&"object"==typeof n){for(let r in e.typed=!0,e.value={},n)if("__proto__"!==r&&"prototype"!==r&&"constructor"!==r){let i=n[r],o=this.key._run({typed:!1,value:r},t);if(o.issues){let a={type:"record",origin:"key",input:n,key:r,value:i};for(let t of o.issues)t.path=[a],e.issues?.push(t);if(e.issues||(e.issues=o.issues),t.abortEarly){e.typed=!1;break}}let a=this.value._run({typed:!1,value:i},t);if(a.issues){let o={type:"record",origin:"value",input:n,key:r,value:i};for(let t of a.issues)t.path?t.path.unshift(o):t.path=[o],e.issues?.push(t);if(e.issues||(e.issues=a.issues),t.abortEarly){e.typed=!1;break}}o.typed&&a.typed||(e.typed=!1),o.typed&&(e.value[o.value]=a.value)}}else rl(this,"type",e,t);return e}}}(rw(),function e(){return{kind:"schema",type:"unknown",reference:e,expects:"unknown",async:!1,_run:e=>(e.typed=!0,e)}}()))});function rA(e){let t=rE(rj,e);if(t.success)return t.output;let n=rE(rO,e);if(n.success)try{let e=new URL(n.output.href,typeof document>"u"?"https://example.com":location.origin);return e.searchParams.size>0?function(e,t,n){let r=e._run({typed:!1,value:t},ru(void 0));if(r.issues)throw new rc(r.issues);return r.value}
1(rj,Object.fromEntries(e.searchParams.entries())):n.output}catch(e){return console.error("Failed to parse sanity node",e),n.output}}var rP={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},rT={0:8203,1:8204,2:8205,3:65279},rC=[,,,,].fill(String.fromCodePoint(rT[0])).join(""),rR=Object.fromEntries(Object.entries(rT).map(e=>e.reverse())),rD=Object.fromEntries(Object.entries(rP).map(e=>e.reverse())),rL=`${Object.values(rP).map(e=>`\\u{${e.toString(16)}}`).join("")}`,rz=RegExp(`[${rL}]{4,}`,"gu");let rN=[];for(let e=0;e<256;++e)rN.push((e+256).toString(16).slice(1));let rU=new Uint8Array(16);var rF={randomUUID:"u">typeof crypto&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function rV(e){let t=e.getBoundingClientRect();return{x:t.x+scrollX,y:t.y+scrollY,w:t.width,h:t.height}}function rW(e,t,n){return"x"===n?{x:e.x+t,y:e.y,w:e.w-2*t,h:e.h}:{x:e.x,y:e.y+t,w:e.w,h:e.h-2*t}}function rq(e,t){return e.x===t.x&&e.y===t.y&&e.w===t.w&&e.h===t.h}function rG(e,t){let n=e.x-t.x,r=e.y-t.y;return Math.sqrt(n*n+r*r)}function rB(e,t,n){let r,i;let o={x:e.x1,y:e.y1};if(t.some(e=>(function(e,t){let n=e.x>=t.x&&e.x<=t.x+t.w,r=e.y>=t.y&&e.y<=t.y+t.h;return n&&r})(o,rW(e,Math.min(e.w,e.h)/10,"horizontal"===n?"x":"y"))))return null;for(let a of t){let t=function(e,t){let n=[{x1:t.x,y1:t.y,x2:t.x+t.w,y2:t.y},{x1:t.x+t.w,y1:t.y,x2:t.x+t.w,y2:t.y+t.h},{x1:t.x+t.w,y1:t.y+t.h,x2:t.x,y2:t.y+t.h},{x1:t.x,y1:t.y+t.h,x2:t.x,y2:t.y}],r=[];for(let t=0;t<n.length;t++){let i=function(e,t){let{x1:n,y1:r,x2:i,y2:o}=e,{x1:a,y1:s,x2:u,y2:l}=t;if(n===i&&r===o||a===u&&s===l)return!1;let c=(l-s)*(i-n)-(u-a)*(o-r);if(0===c)return!1;let d=((u-a)*(r-s)-(l-s)*(n-a))/c,p=((i-n)*(r-s)-(o-r)*(n-a))/c;return!(d<0||d>1||p<0||p>1)&&{x:n+d*(i-n),y:r+d*(o-r)}}(e,n[t]);if(i){let e=!1;for(let t=0;t<r.length;t++)r[t].x===i.x&&r[t].y===i.y&&(e=!0);e||r.push(i)}}return 0!==r.length&&r.sort((t,n)=>rG(t,{x:e.x1,y:e.y1})-rG(n,{x:e.x1,y:e.y1}))}(e,rW(a,Math.min(a.w,a.h)/10,"horizontal"===n?"x":"y"));if(t){let e=t[0];r?rG(o,e)<rG(o,r)&&(r=e,i=a):(r=e,i=a)}}return i||null}function rY(e,t,n){let{x:r,y:i,w:o,h:a}=e,{x:s,y:u}=n;return{x:s+(r-s)*t,y:u+(i-u)*t,w:o*t,h:a*t}}function rJ(e){let t=Math.max(0,Math.min(...e.map(e=>e.y))),n=Math.min(document.body.scrollHeight,Math.max(...e.map(e=>e.y+e.h)));return{min:t,max:n,height:n-t}}function rH(e,t){return t.find(t=>rq(rV(t.elements.element),e))?.sanity}function rK(e,t,n){return Object.values(t).every(e=>null===e)?null:"horizontal"===n?{left:t.left?{rect:t.left,sanity:rH(t.left,e)}:null,right:t.right?{rect:t.right,sanity:rH(t.right,e)}:null}:{top:t.top?{rect:t.top,sanity:rH(t.top,e)}:null,bottom:t.bottom?{rect:t.bottom,sanity:rH(t.bottom,e)}:null}}function rX(e){let t=document.body.getBoundingClientRect();return{x:Math.max(t.x,Math.min(e.clientX,t.x+t.width)),y:e.clientY+window.scrollY}}function rZ(e,t,n){let r=rV(t),i=[...t.querySelectorAll(":where(h1, h2, h3, h4, p, a, img, span, button):not(:has(*))")];e.x<=r.x&&(e.x=r.x),e.x>=r.x+r.w&&(e.x=r.x+r.w),e.y>=r.y+r.h&&(e.y=r.y+r.h),e.y<=r.y&&(e.y=r.y);let o=i.map(e=>{let t=rY(rV(e),n,{x:r.x,y:r.y});return{x:t.x-r.x,y:t.y-r.y,w:t.w,h:t.h,tagName:e.tagName}});return{offsetX:(r.x-e.x)*n,offsetY:(r.y-e.y)*n,w:r.w*n,h:r.h*n,maxWidth:r.w*n*.75,childRects:o}}function rQ(e){let t=function(e){let t=Math.max(0,Math.min(...e.map(e=>e.x))),n=Math.min(document.body.offsetWidth,Math.max(...e.map(e=>e.x+e.w)));return{min:t,max:n,width:n-t}}(e),n=rJ(e),r=t.min>8&&t.min+t.width<=window.innerWidth-8,i=n.min>8&&n.min+n.height<=document.body.scrollHeight-8,o=r&&i;return{x:o?t.min-8:t.min,y:o?n.min-8:n.min,w:o?t.width+16:t.width,h:o?n.height+16:n.height}}async function r0(e,t,n,r,i,o){return new Promise(a=>{if(1===new DOMMatrix(window.getComputedStyle(t).transform).a)return;let s=n-window.innerHeight,u=scrollY;(e-=window.innerHeight/2)<0&&(e=0),t.addEventListener("transitionend",()=>{t.style.transition="none",t.style.transform="none",scrollTo({top:e,behavior:"instant"}),setTimeout(()=>{r({type:"overlay/dragEndMinimapTransition"}),r({type:"overlay/dragToggleMinimap",display:!1})},2*i),a()},{once:!0}),r({type:"overlay/dragStartMinimapTransition"}),t.style.transform=`translateY(${Math.max(u-e,-s+u)}px) scale(1)`,o&&(document.body.style.overflow=o.body.overflow,document.body.style.height=o.body.height,document.documentElement.style.overflow=o.documentElement.overflow,document.documentElement.style.height=o.documentElement.height)})}let r1=!1,r2={x:0,y:0},r9={x:0,y:0},r5=typeof document>"u"?0:document.documentElement.scrollHeight,r6=null,r3=e=>e instanceof HTMLElement||e instanceof SVGElement,r8=e=>e&&r3(e)?e.dataset?.sanityOverlayElement?e:r8(e.parentElement):null;function r4(e,t=!1){return rz.lastIndex=0,rz.test(e)?function(e,t=!1){try{let n=function(e){let t=e.match(rz);
1if(t)return function(e,t=!1){let n=Array.from(e);if(n.length%2==0){if(n.length%4||!e.startsWith(rC))return function(e,t){var n;let r=[];for(let t=.5*e.length;t--;){let n=`${rD[e[2*t].codePointAt(0)]}${rD[e[2*t+1].codePointAt(0)]}`;r.unshift(String.fromCharCode(parseInt(n,16)))}let i=[],o=[r.join("")],a=10;for(;o.length;){let e=o.shift();try{if(i.push(JSON.parse(e)),t)break}catch(r){if(!a--)throw r;let t=+(null==(n=r.message.match(/\sposition\s(\d+)$/))?void 0:n[1]);if(!t)throw r;o.unshift(e.substring(0,t),e.substring(t))}}return i}(n,t)}else throw Error("Encoded data has invalid length");let r=[];for(let e=.25*n.length;e--;){let t=n.slice(4*e,4*e+4).map(e=>rR[e.codePointAt(0)]).join("");r.unshift(String.fromCharCode(parseInt(t,4)))}if(t){r.shift();let e=r.indexOf("\0");return -1===e&&(e=r.length),[JSON.parse(r.slice(0,e).join(""))]}return r.join("").split("\0").filter(Boolean).map(e=>JSON.parse(e))}(t[0],!0)[0]}(e);return n&&"sanity.io"===n.origin?(t&&(n.href=n.href?.replace(".alt","")),n):null}catch(t){return console.error("Failed to decode stega for string: ",e,"with the original error: ",t),null}}(e,t):null}let r7=e=>e.nodeType===Node.ELEMENT_NODE,ie=e=>"IMG"===e.tagName,it=e=>"TIME"===e.tagName,ir=e=>"SVG"===e.tagName.toUpperCase();function ii(e){return"path"in e}function io(e){let t=e.lastIndexOf(".");return e.substring(t,e.length).includes("[")}function ia(e){if(!io(e))return null;let t=e.split(".");return t[t.length-1]=t[t.length-1].replace(/\[.*?\]/g,"[]"),t.join(".")}function is(e,t){return!(!io(e.path)||!io(t.path))&&ia(e.path)===ia(t.path)}function iu(e,t,n,r){if(!e.getAttribute("data-sanity")||e.getAttribute("data-sanity-drag-disable")||!t||!ii(t)||!io(t.path))return null;let i=e.getAttribute("data-sanity-drag-group"),o=[...n].reduce((e,n)=>{let o=r.get(n),a=n.getAttribute("data-sanity-drag-disable"),s=n.getAttribute("data-sanity-drag-group"),u=null!==n.getAttribute("data-sanity");return o&&!a&&ii(o.sanity)&&is(t,o.sanity)&&(null===i||i===s)&&u&&e.push(o),e},[]);return o.length<=1?null:o}let il=(0,y.createContext)(null);var ic=n(93067),id=n(3620),ip=n(87659),iy=n(66677);let im=e=>{let{comlink:t,history:n}=e;return(0,y.useEffect)(()=>t?.on("presentation/navigate",e=>{n?.update(e)}),[t,n]),(0,y.useEffect)(()=>{if(n)return n.subscribe(e=>{e.title=e.title||document.title,t?.post("visual-editing/navigate",e)})},[t,n]),null},ih=e=>{let{comlink:t}=e;return(0,y.useEffect)(()=>{let e=()=>{t.post("visual-editing/meta",{title:document.title})},n=new MutationObserver(([t])=>{"TITLE"===t.target.nodeName&&e()});return n.observe(document.head,{subtree:!0,characterData:!0,childList:!0}),e(),()=>n.disconnect()},[t]),null},ig=(0,y.createContext)(null);function iv(){let e=(0,y.useContext)(ig);if(!e)throw Error("Schema context is missing");return e}function ib(e,t,n,r){if(!e.type)throw Error("Node type is missing");return()=>t.patch(()=>(function(e,t,n){let{path:r,key:i}=ra(e);return[B(r,W([{_type:t,_key:ro()}],n,{_key:i}))]})(e,n,r))}function iw(e){let{node:t,doc:n}=e;return n?[{type:"action",label:"Duplicate",icon:A.C,action:function(e,t){if(!e.type)throw Error("Node type is missing");return()=>t.patch(async({getSnapshot:t})=>(function(e,t,n="after"){let{path:r,key:i}=ra(e);return[B(r,W({...n8(t,e.path),_key:ro()},n,{_key:i}))]})(e,await t()))}(t,n),telemetryEvent:"Visual Editing Context Menu Item Duplicated"}]:[]}function ix(e){let{node:t,doc:n}=e;return n?[{type:"action",label:"Remove",icon:A.R,action:function(e,t){if(!e.type)throw Error("Node type is missing");return()=>t.patch(async({getSnapshot:t})=>(function(e,t){let{path:n,key:r}=ra(e),i=n8(t,n).findIndex(e=>e._key===r);return[B(n,q(i,i+1))]})(e,await t()))}(t,n),telemetryEvent:"Visual Editing Context Menu Item Removed"}]:[]}async function iE(e,t=!0){let{node:n,doc:r}=e;if(!r)return[];let i=[],o=[],[a,s,u,l]=await Promise.all([rs(n,r,"previous"),rs(n,r,"next"),rs(n,r,"first"),rs(n,r,"last")]);return u.length&&o.push({type:"action",label:"To top",icon:A.e,action:()=>r.patch(u),telemetryEvent:"Visual Editing Context Menu Item Moved"}),a.length&&o.push({type:"action",label:"Up",icon:A.f,action:()=>r.patch(a),telemetryEvent:"Visual Editing Context Menu Item Moved"}),s.length&&o.push({type:"action",label:"Down",icon:A.h,action:()=>r.patch(s),telemetryEvent:"Visual Editing Context Menu Item Moved"}),l.length&&o.push({type:"action",label:"To bottom",icon:A.U,action:()=>r.patch(l),telemetryEvent:"Visual Editing Context Menu Item Moved"}),o.length&&(i.push({type:"group",label:"Move",icon:A.S,items:o}),t&&i.push({type:"divider"})),i}let i_=e=>{let{label:t,parent:n,width:r,onSelect:i,boundaryElement:o}=e;return(0,p.jsx)(A.M,{fontSize:1,icon:A.b,padding:2,popover:{arrow:!1,constrainSize:!0,floatingBoundary:o,padding:0,placement:"right-start",fallbackPlacements:["left-start","right","left","right-end","left-end","bottom","top"],preventOverflow:!0,width:r,__unstable_margins:[4,4,4,4]},space:2,text:t,children:(0,p.jsx)(A.c,{node:n,onSelect:i})})},ik=[-4,4,-4,4];function ij(e){let{node:t,onDismiss:n,boundaryElement:r}=e,i=(0,A.u)(),o=(0,y.useCallback)(()=>{"action"===t.type&&(t.action?.(),n?.(),t.telemetryEvent&&i(t.telemetryEvent,null))},[t,n,i]);if("divider"===t.type)return(0,p.jsx)(A.o,{});if("action"===t.type)return(0,p.jsx)(A.p,{fontSize:1,hotkeys:t.hotkeys,icon:t.icon,padding:2,space:2,text:t.label,disabled:!t.action,onClick:o});if("group"===t.type)return(0,p.jsx)(A.M,{fontSize:1,icon:t.icon,padding:2,popover:{arrow:!1,constrainSize:!0,placement:"right-start",fallbackPlacements:["left-start","right","left","right-end","left-end","bottom","top"],preventOverflow:!0,__unstable_margins:ik},space:2,text:t.label,children:t.items.map((e,t)=>(0,p.jsx)(ij,{node:e,onDismiss:n,boundaryElement:r},t))});
1if("custom"===t.type){let{component:e}=t;return(0,p.jsx)(e,{boundaryElement:r,sendTelemetry:i})}return null}let iI=e=>{let{node:t,onDismiss:n,position:{x:r,y:i}}=e,[o,a]=(0,y.useState)(null),{getField:s}=iv(),{getDocument:u}=rr(),{field:l,parent:c}=s(t),d=(0,y.useMemo)(()=>l?.title||l?.name||"Unknown type",[l]),[f,m]=(0,y.useState)(void 0);(0,y.useEffect)(()=>{(async()=>{let e=u(t.id);e&&m(await function(e){let{node:t,field:n,parent:r,doc:i}=e;return"arrayItem"===n?.type?async function(e){let{node:t,field:n,doc:r}=e,i=[];return i.push(...iw(e)),i.push(...ix(e)),i.push(...await iE(e)),i.push({type:"action",label:"Insert before",icon:A.a,action:ib(t,r,n.name,"before"),telemetryEvent:"Visual Editing Context Menu Item Inserted"}),i.push({type:"action",label:"Insert after",icon:A.b,action:ib(t,r,n.name,"after"),telemetryEvent:"Visual Editing Context Menu Item Inserted"}),i}({node:t,field:n,doc:i}):"union"===r?.type?async function(e){let{doc:t,node:n,parent:r}=e,i=[];if(i.push(...iw(e)),i.push(...ix(e)),i.push(...await iE(e)),r.options?.insertMenu){let e=(r.options.insertMenu||{}).views?.some(e=>"grid"===e.name)?0:void 0;i.push({type:"custom",component:({boundaryElement:i,sendTelemetry:o})=>(0,p.jsx)(i_,{label:"Insert before",onSelect:e=>{ib(n,t,e.name,"before")(),o("Visual Editing Context Menu Item Inserted",null)},parent:r,width:e,boundaryElement:i})}),i.push({type:"custom",component:({boundaryElement:i,sendTelemetry:o})=>(0,p.jsx)(i_,{label:"Insert after",onSelect:e=>{ib(n,t,e.name,"after")(),o("Visual Editing Context Menu Item Inserted",null)},parent:r,width:e,boundaryElement:i})})}else i.push({type:"group",label:"Insert before",icon:A.a,items:r.of.filter(e=>"unionOption"===e.type).map(e=>({type:"action",icon:(0,A.g)(e),label:"block"===e.name?"Paragraph":e.title||e.name,action:ib(n,t,e.name,"before"),telemetryEvent:"Visual Editing Context Menu Item Inserted"}))}),i.push({type:"group",label:"Insert after",icon:A.b,items:r.of.filter(e=>"unionOption"===e.type).map(e=>({type:"action",label:"block"===e.name?"Paragraph":e.title||e.name,icon:(0,A.g)(e),action:ib(n,t,e.name,"after"),telemetryEvent:"Visual Editing Context Menu Item Inserted"}))});return i}({node:t,parent:r,doc:i}):Promise.resolve([])}({node:t,field:l,parent:c,doc:e}))})()},[l,t,c,u]);let h=(0,y.useMemo)(()=>({getBoundingClientRect:()=>({bottom:i,left:r,right:r,top:i,width:0,height:0})}),[r,i]),g=(0,y.useMemo)(()=>(0,A.g)(l),[l]);return(0,p.jsx)(A.i,{setBoundaryElement:a,onDismiss:n,children:(0,p.jsx)(A.j,{__unstable_margins:ik,arrow:!1,open:!0,placement:"right-start",referenceElement:h,content:(0,p.jsxs)(A.k,{style:{minWidth:120,maxWidth:160},children:[(0,p.jsxs)(A.F,{gap:2,padding:2,children:[(0,p.jsx)(A.l,{flex:"none",children:f?(0,p.jsx)(A.T,{size:1,children:g}):(0,p.jsx)(A.m,{size:1})}),(0,p.jsx)(A.n,{flex:1,space:2,children:(0,p.jsx)(A.T,{size:1,weight:"semibold",children:f?d:"Loading..."})})]}),f&&(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(A.o,{}),f.map((e,t)=>(0,p.jsx)(ij,{node:e,onDismiss:n,boundaryElement:o},t))]})]}),children:(0,p.jsx)("div",{style:{position:"absolute",left:r,top:i}},`${r}-${i}`)})})},iM=(0,y.createContext)(null),iS=(0,A.d)(A.q)` 2 background-color: var(--overlay-bg); 3 border-radius: 3px; 4 pointer-events: none; 5 position: absolute; 6 will-change: transform; 7 box-shadow: var(--overlay-box-shadow); 8 transition: none; 9 10 --overlay-bg: transparent; 11 --overlay-box-shadow: inset 0 0 0 1px transparent; 12 13 [data-overlays] & { 14 --overlay-bg: color-mix(in srgb, transparent 95%, var(--card-focus-ring-color)); 15 --overlay-box-shadow: inset 0 0 0 2px 16 color-mix(in srgb, transparent 50%, var(--card-focus-ring-color)); 17 } 18 19 [data-fading-out] & { 20 transition: 21 box-shadow 1550ms, 22 background-color 1550ms; 23 24 --overlay-bg: rgba(0, 0, 255, 0); 25 --overlay-box-shadow: inset 0 0 0 1px transparent; 26 } 27 28 &[data-focused] { 29 --overlay-box-shadow: inset 0 0 0 1px var(--card-focus-ring-color); 30 } 31 32 &[data-hovered]:not([data-focused]) { 33 transition: none; 34 --overlay-box-shadow: inset 0 0 0 2px var(--card-focus-ring-color); 35 } 36 37 /* [data-unmounted] & {
38 --overlay-box-shadow: inset 0 0 0 1px var(--card-focus-ring-color); 39 } */ 40 41 :link { 42 text-decoration: none; 43 } 44`,i$=(0,A.d)(A.F)` 45 bottom: 100%; 46 cursor: pointer; 47 pointer-events: none; 48 position: absolute; 49 right: 0; 50 51 [data-hovered] & { 52 pointer-events: all; 53 } 54 55 [data-flipped] & { 56 bottom: auto; 57 top: 100%; 58 } 59`,iO=(0,A.d)(A.F)` 60 bottom: 100%; 61 cursor: pointer; 62 pointer-events: none; 63 position: absolute; 64 left: 0; 65 66 [data-hovered] & { 67 pointer-events: all; 68 } 69 70 [data-flipped] & { 71 bottom: auto; 72 top: 100%; 73 } 74`,iA=(0,A.d)(A.q)` 75 cursor: pointer; 76 background-color: var(--card-focus-ring-color); 77 right: 0; 78 border-radius: 3px; 79 80 & [data-ui='Text'] { 81 color: #fff; 82 white-space: nowrap; 83 } 84`,iP=(0,A.d)(A.F)` 85 display: flex; 86 align-items: center; 87 background-color: var(--card-focus-ring-color); 88 right: 0; 89 border-radius: 3px; 90 & [data-ui='Text'], 91 & [data-sanity-icon] { 92 color: #fff; 93 white-space: nowrap; 94 } 95`,iT=e=>{let{element:t,focused:n,componentResolver:r,node:i,showActions:o,draggable:a}=e,{getField:s,getType:u}=iv(),l=u(i),{field:c,parent:d}=s(i),f="path"in i?function(e){let{id:t,type:n,path:r,baseUrl:i,tool:o,workspace:a}=e;return function(e){let{baseUrl:t,workspace:n="default",tool:r="default",id:i,type:o,path:a,projectId:s,dataset:u}=e;if(!t)throw Error("baseUrl is required");if(!a)throw Error("path is required");if(!i)throw Error("id is required");if("/"!==t&&t.endsWith("/"))throw Error("baseUrl must not end with a slash");let l="default"===n?void 0:n,c="default"===r?void 0:r,d=O(i),p=Array.isArray(a)?E(a.map(e=>{if("string"==typeof e||"number"==typeof e)return e;if(""!==e._key)return{_key:e._key};if(-1!==e._index)return e._index;throw Error(`invalid segment:${JSON.stringify(e)}`)})):a,f=new URLSearchParams({baseUrl:t,id:d,type:o,path:p});if(l&&f.set("workspace",l),c&&f.set("tool",c),s&&f.set("projectId",s),u&&f.set("dataset",u),M(i)||S(i)){if(S(i)){let e=function(e){if(!S(e))return;let[t,n,...r]=e.split(".");return n}(i);f.set("perspective",e)}}else f.set("perspective","published");let y=["/"===t?"":t];l&&y.push(l);let m=["mode=presentation",`id=${d}`,`type=${o}`,`path=${encodeURIComponent(p)}`];return c&&m.push(`tool=${c}`),y.push("intent","edit",`${m.join(";")}?${f}`),y.join("/")}({baseUrl:i,workspace:a,tool:o,type:n,id:t,path:function(e){let t="";for(let n of e){if("string"==typeof n){t&&(t+="."),t+=n;continue}if("number"==typeof n){t&&(t+=":"),t+=`${n}`;continue}if(null!==n&&Array.isArray(n)){t&&(t+=":"),t+=`${n.join(",")}}`;continue}if(n._key){t&&(t+=":"),t+=`${n._key}`;continue}}return t}(j.fromString(r))})}(i):i.href,m=function(){let e=(0,y.useContext)(iM);if(!e)throw Error("Preview Snapshots context is missing");return e}(),h=(0,y.useMemo)(()=>{if("path"in i)return m.find(e=>e._id===i.id)?.title},[i,m]),g=(0,y.useMemo)(()=>{if(!("path"in i)||!c||!l)return;let e=c.value.type;return{document:l,element:t,field:c,focused:!!n,node:i,parent:d,type:e}},[l,t,c,n,i,d]),v=function(e,t){return(0,y.useMemo)(()=>{if(!e)return;let n=t?.(e);return n?(0,y.isValidElement)(n)?n:(Array.isArray(n)?n:[n]).map(e=>"object"==typeof e&&"component"in e?e:{component:e,props:{}}):void 0},[t,e])}(g,r),b=l?.icon?(0,p.jsx)("div",{dangerouslySetInnerHTML:{__html:l.icon}}):(0,p.jsx)(A.r,{});return(0,p.jsxs)(p.Fragment,{children:[o?(0,p.jsx)(i$,{gap:1,paddingY:1,"data-sanity-overlay-element":!0,children:(0,p.jsx)(iR,{href:f})}):null,h&&(0,p.jsx)(iO,{gap:1,paddingY:1,children:(0,p.jsxs)(iP,{gap:2,padding:2,children:[a&&(0,p.jsx)(A.l,{marginRight:1,children:(0,p.jsx)(A.T,{className:"drag-handle",size:0,children:(0,p.jsx)(A.D,{})})}),(0,p.jsx)(A.T,{size:0,children:b}),(0,p.jsx)(A.T,{size:1,weight:"medium",children:h})]})}),Array.isArray(v)?v.map(({component:e,props:t},n)=>(0,p.jsx)(e,{PointerEvents:A.P,...g,...t},n)):v]})},iC=(0,y.memo)(function(e){let{draggable:t,focused:n,hovered:r,rect:i,wasMaybeCollapsed:o,enableScrollIntoView:a}=e,s=(0,y.useRef)(null),u=(0,y.useRef)(!1),l=(0,y.useMemo)(()=>({width:`${i.w}px`,height:`${i.h}px`,transform:`translate(${i.x}px, ${i.y}px)`}),[i]);(0,y.useEffect)(()=>
95{if(!u.current&&!o&&!0===n&&s.current&&a){let e=s.current;(0,ic.A)(s.current,{behavior:t=>{0!==t.length&&e.scrollIntoView({behavior:"smooth",block:"center",inline:"nearest"})},scrollMode:"if-needed",block:"center",inline:"nearest"})}u.current=!0===n},[n,o,a]);let[c,d]=(0,y.useState)(!1);return(0,y.useEffect)(()=>{if(!s.current||!r)return;let e=new IntersectionObserver(([e])=>{d(e.boundingClientRect.top<0)},{threshold:1});return e.observe(s.current),()=>e.disconnect()},[r,c]),(0,p.jsx)(iS,{"data-focused":n?"":void 0,"data-hovered":r?"":void 0,"data-flipped":c?"":void 0,"data-draggable":t?"":void 0,ref:s,style:l,children:r&&(0,p.jsx)(iT,{...e})})}),iR=(0,y.memo)(function(e){let t=(0,y.useSyncExternalStore)((0,y.useCallback)(e=>{let t=()=>e();return window.addEventListener("popstate",t),()=>window.removeEventListener("popstate",t)},[]),()=>window.location.href),n=(0,y.useMemo)(()=>(function e(t,n){try{let r=new URL(t,typeof location>"u"?void 0:location.origin);if(r.hash){let t=new URL(e(r.hash.slice(1),n));return`${r.origin}${r.pathname}${r.search}#${t.pathname}${t.search}`}return r.searchParams.set("preview",n),r.toString()}catch{return t}})(e.href,t),[e.href,t]);return(0,p.jsx)(A.l,{as:"a",href:n,target:"_blank",rel:"noopener noreferrer",children:(0,p.jsx)(iA,{padding:2,children:(0,p.jsx)(A.T,{size:1,weight:"medium",children:"Open in Studio"})})})}),iD=({dragGroupRect:e})=>(0,p.jsx)("div",{style:{position:"absolute",top:`${e.y}px`,left:`${e.x}px`,width:e.w-1+"px",height:e.h-1+"px",border:"1px dashed #f0709b",pointerEvents:"none"}}),iL=({dragInsertPosition:e})=>{if(null===e)return;let t=0,n=0,r=0,i=0;if("horizontal"==(e?.left||e?.right?"horizontal":"vertical")){let{left:o,right:a}=e;if(r=6,a&&o){let e=o.rect.x+o.rect.w,r=a.rect.x,s=.0125*Math.min(a.rect.h,o.rect.h);t=.5*e+.5*r-3,n=o.rect.y+s,i=Math.min(a.rect.h,o.rect.h)-2*s}else if(a&&!o){let e=.0125*a.rect.h;t=a.rect.x-3,n=a.rect.y+e,i=a.rect.h-2*e}else if(o&&!a){let e=.0125*o.rect.h;t=o.rect.x+o.rect.w-3,n=o.rect.y+e,i=o.rect.h-2*e}}else{let{bottom:o,top:a}=e;if(o&&a){let e=Math.min(a.rect.x,o.rect.x),s=a.rect.y+a.rect.h,u=o.rect.y,l=.0125*Math.min(o.rect.w,a.rect.w);i=6,t=e+l,n=.5*s+.5*u-3,r=Math.max(o.rect.w,a.rect.w)-2*l}else if(o&&!a){let e=.0125*o.rect.w;t=o.rect.x+e,n=o.rect.y-3,r=o.rect.w-2*e,i=6}else if(a&&!o){let e=.0125*a.rect.w;t=a.rect.x+e,n=a.rect.y+a.rect.h-3,r=a.rect.w-2*e,i=6}}return(0,p.jsx)("div",{style:{position:"absolute",width:`${r}px`,height:`${i}px`,transform:`translate(${t}px, ${n}px)`,background:"#556bfc",border:"2px solid white",borderRadius:"999px",zIndex:"999999"}})},iz=A.d.div` 96 --drag-preview-opacity: 0.98; 97 --drag-preview-skeleton-stroke: #ffffff; 98 99 @media (prefers-color-scheme: dark) { 100 --drag-preview-skeleton-stroke: #383d51; 101 } 102 103 position: fixed; 104 display: grid; 105 transform: ${({$scaleFactor:e,$width:t,$height:n})=>`translate(calc(var(--drag-preview-x) - ${t/2}px), calc(var(--drag-preview-y) - ${n/2}px)) scale(${e})`}; 106 width: ${({$width:e})=>`${e}px`}; 107 height: ${({$height:e})=>`${e}px`}; 108 z-index: 9999999; 109 opacity: var(--drag-preview-opacity); 110 cursor: move; 111 112 .drag-preview-content-wrapper { 113 position: relative; 114 width: 100%; 115 height: 100%; 116 container-type: inline-size; 117 } 118 119 [data-ui='card'] { 120 position: relative; 121 width: 100%; 122 height: 100%; 123 } 124 125 .drag-preview-skeleton { 126 position: absolute; 127 inset: 0; 128 129 rect { 130 stroke: var(--drag-preview-skeleton-stroke); 131 } 132 } 133 134 .drag-preview-handle { 135 position: absolute; 136 top: 4cqmin; 137 left: 4cqmin; 138 width: 6cqmin; 139 fill: var(--drag-preview-handle-fill); 140 } 141`,iN=({skeleton:e})=>{var t,n;let r=Math.min(e.maxWidth,window.innerWidth/2),i=e.w>r?r/e.w:1,o=e.offsetX*i,a=e.offsetY*i,s=(0,A.s)(),u=(0,A.t)(),l=u.radius[~~((n=(e.w-0)*((t=u.radius.length-2)-1)/1920+1)<1?1:n>t?t:n)],c=e.childRects.filter(e=>"IMG"===e.tagName),d=e.childRects.filter(e=>"IMG"!==e.tagName);return(0,p.jsx)(iz,{$width:e.w,$height:e.h,$offsetX:o,$offsetY:a,$scaleFactor:i,children:(0,p.jsx)(A.q,{radius:l,shadow:4,overflow:"hidden",tone:"transparent",scheme:s?"dark":"light",children:(0,p.jsx)("div",{className:"drag-preview-content-wrapper",children:(0,p.jsx)("svg",{className:"drag-preview-skeleton",viewBox:`0 0 ${e.w} ${e.h}`,children:[...c,...d].map((e,t)=>(0,p.jsx)("rect",{x:e.x,y:e.y,width:e.w,height:e.h,fill:u.color.skeleton.from},t))})})})})},iU=(0,A.d)(A.q)` 142 position: fixed; 143 bottom: 2rem; 144 left: 2rem; 145`,iF=()=>(0,p.jsx)(iU,{padding:2,shadow:2,radius:2,style:{zIndex:"999999"},children:(0,p.jsxs)(A.F,{align:"center",gap:2,children:[(0,p.jsx)(A.H,{keys:["Shift"]}),(0,p.jsx)(A.T,{size:1,children:"Zoom Out"}),(0,p.jsx)(A.E,{})]})}),iV=(e,t)=>{let{type:n}=t;switch(n){case"element/register":return e.find(e=>e.id===t.id)?e:[...e,{id:t.id,activated:!1,element:t.element,focused:!1,hovered:!1,rect:t.rect,sanity:t.sanity,dragDisabled:t.dragDisabled}];case"element/activate":return e.map(e=>e.id===t.id?{...e,activated:!0}:e);case"element/update":return e.map(e=>e.id===t.id?{...e,sanity:t.sanity,rect:t.rect}:e);case"element/unregister":return e.filter(e=>e.id!==t.id);case"element/deactivate":return e.map(e=>e.id===t.id?{...e,activated:!1,hovered:!1}:e);case"element/mouseenter":return e.map(e=>e.id===t.id?{...e,rect:t.rect,hovered:!0}:{...e,hovered:!1});case"element/mouseleave":return e.map(e=>e.id===t.id?{...e,hovered:!1}:e);case"element/updateRect":return e.map(e=>e.id===t.id?{...e,rect:t.rect}:e);case"element/click":return e.map(e=>({...e,focused:e.id===t.id&&"clicked"}));case"overlay/blur":case"presentation/blur":return e.map(e=>({...e,focused:!1}));case"presentation/focus":{let n=e.find(e=>"clicked"===e.focused);return e.map(e=>
145{let r="path"in e.sanity&&e.sanity.id===t.data.id&&e.sanity.path===t.data.path;return n&&e===n&&r?e:{...e,focused:r&&n?"duplicate":r}})}default:return e}};function iW(e,t){let{type:n}=t,{contextMenu:r,focusPath:i,perspective:o,isDragging:a,dragInsertPosition:s,dragShowMinimap:u,dragShowMinimapPrompt:l,dragSkeleton:c,dragMinimapTransition:d,dragGroupRect:p}=e,f=!1;if("presentation/focus"===n){let n=e.focusPath;n!==(i=t.data.path)&&(f=n.slice(i.length).startsWith("["))}return"presentation/perspective"===n&&(o=t.data.perspective),"element/contextmenu"===n&&(r="sanity"in t?{node:t.sanity,position:t.position}:null),("element/click"===n||"element/mouseleave"===n||"overlay/blur"===n||"presentation/blur"===n||"presentation/focus"===n)&&(r=null),"overlay/dragUpdateInsertPosition"===n&&(s=t.insertPosition),"overlay/dragStart"===n&&(a=!0),"overlay/dragUpdateSkeleton"===t.type&&(c=t.skeleton),"overlay/dragEnd"===n&&(a=!1),"overlay/dragToggleMinimapPrompt"===t.type&&(l=t.display),"overlay/dragStartMinimapTransition"===n&&(d=!0),"overlay/dragEndMinimapTransition"===n&&(d=!1),"overlay/dragUpdateGroupRect"===n&&(p=t.groupRect),"overlay/dragToggleMinimap"===n&&(u=t.display),{...e,contextMenu:r,elements:iV(e.elements,t),dragInsertPosition:s,dragSkeleton:c,dragGroupRect:p,isDragging:a,focusPath:i,perspective:o,wasMaybeCollapsed:f,dragShowMinimap:u,dragShowMinimapPrompt:l,dragMinimapTransition:d}}let iq=function(e){let{comlink:t,children:n}=e,[r,i]=(0,y.useState)([]),o=(0,y.useCallback)(async e=>{if(t)try{let n=await t.fetch("visual-editing/preview-snapshots",void 0,{signal:e,suppressWarnings:!0});i(n.snapshots)}catch{}},[t]);(0,y.useEffect)(()=>{if(!t)return;let e=new AbortController,n=t.onStatus(()=>{o(e.signal)},"connected");return()=>{e.abort(),n()}},[t,o]),(0,y.useEffect)(()=>t?.on("presentation/preview-snapshots",e=>{i(e.snapshots)}),[t]);let a=(0,y.useMemo)(()=>r,[r]);return(0,p.jsx)(iM.Provider,{value:a,children:n})};function iG(e){return"document"===e.type}function iB(e){return"type"===e.type}let iY=function(e){let{comlink:t,children:n,elements:r}=e,[i,o]=(0,y.useState)(new Map),[a,s]=(0,y.useState)(null),u=(0,y.useCallback)(async e=>{if(t)try{let n=await t.fetch("visual-editing/schema",void 0,{signal:e,suppressWarnings:!0});s(n.schema)}catch{}},[t]);(0,y.useEffect)(()=>{if(!t)return;let e=new AbortController,n=t.onStatus(()=>{u(e.signal)},"connected");return()=>{e.abort(),n()}},[t,u]);let l=(0,y.useRef)([]);(0,y.useEffect)(()=>{let e=new AbortController,n=r.reduce((e,t)=>{let{sanity:n}=t;if(!("id"in n)||!n.path.includes("[_key=="))return e;let r=n.path.split(".").toReversed().reduce((e,t)=>e.length?[t,...e]:t.includes("[_key==")?[t]:[],[]).join(".");return e.find(e=>e.id===n.id&&e.path===r)||e.push({id:n.id,path:r}),e},[]);return n.some(e=>!l.current.find(({id:t,path:n})=>t===e.id&&n===e.path))&&(async(e,n)=>{if(e.length&&t)try{let r=await t.fetch("visual-editing/schema-union-types",{paths:e},{signal:n,suppressWarnings:!0});o(r.types),l.current=e}catch{}})(n,e.signal),()=>e.abort()},[t,r]);let c=(0,y.useCallback)((e,t)=>{if(!a||"string"!=typeof e&&(!("path"in e)||!Array.isArray(a)))return;let n="string"==typeof e?e:e.type;return a.filter("document"===(t||"document")?iG:iB).find(e=>e.name===n)},[a]),d=(0,y.useCallback)(e=>{if(!("path"in e))return{field:void 0,parent:void 0};let t=c(e);if(!t)return{field:void 0,parent:void 0};let n=e.path.split(".").flatMap(e=>e.includes("[")?e.split(/(\[.+\])/,2):[e]);try{return function t(n,r,o,a=[]){if(!n)return{field:void 0,parent:void 0};let[s,...u]=r;if("fields"in n){let e=n.fields[s];if(!e&&"rest"in n)return t(n.rest,r,n,a);if(!u.length)return{field:e,parent:o};if(!e)throw Error(`[@sanity/visual-editing] No field could be resolved at path: "${[...a,...r].join(".")}"`);return t(e.value,u,n,[...a,s])}if("array"===n.type)return t(n.of,r,n,a);if("arrayItem"===n.type)return u.length?t(n.value,u,n,[...a,s]):{field:n,parent:o};if("union"===n.type){let r=s.startsWith("[_key==")?i?.get(e.id)?.get([a.join("."),s].filter(Boolean).join("")):s;return t(n.of.find(e=>"unionOption"===e.type?e.name===r:e),u,n,[...a,s])}if("unionOption"===n.type)return s?t(n.value,r,n,a):{field:n,parent:o};if("inline"===n.type)return t(c(n.name,"type").value,r,n,a);throw Error(`[@sanity/visual-editing] No field could be resolved at path: "${[...a,...r].join(".")}"`)}(t,n,void 0)}catch(e){return e instanceof Error&&console.warn(e.message),{field:void 0,parent:void 0}}},[c,i]),f=(0,y.useMemo)(()=>({getField:d,getType:c,resolvedTypes:i,schema:a||[]}),[d,c,i,a]);return(0,p.jsx)(ig.Provider,{value:f,children:n})},iJ=(()=>{let e={},t=new Set;return{getState:()=>e,setState:n=>
145{e=n(e),t.forEach(e=>e())},subscribe:e=>(t.add(e),()=>t.delete(e))}})(),iH=e=>{let{comlink:t,children:n}=e;(0,y.useEffect)(()=>t?.on("presentation/shared-state",e=>{"value"in e?iJ.setState(t=>({...t,[e.key]:e.value})):iJ.setState(t=>Object.fromEntries(Object.entries(t).filter(([t])=>t!==e.key)))}),[t]),(0,y.useEffect)(()=>{(async function(){let e=await t?.fetch("visual-editing/shared-state",void 0,{suppressWarnings:!0});e&&iJ.setState(()=>e.state)})().catch(e=>{console.debug(e),console.warn("[@sanity/visual-editing]: Failed to fetch shared state. Check your version of `sanity` is up-to-date")})},[t]);let r=(0,y.useMemo)(()=>({comlink:t,store:iJ}),[t]);return(0,p.jsx)(il.Provider,{value:r,children:n})},iK=({children:e,comlink:t})=>{let n=(0,y.useCallback)((e,n)=>{if(!t)return;let r=A.w[e];if(!r)throw Error(`Telemetry event: ${e} does not exist`);t.post("visual-editing/telemetry-log",{event:r,data:n})},[t]);return(0,p.jsx)(A.v.Provider,{value:n,children:e})},iX=A.d.div` 146 background-color: transparent; 147 direction: ltr; 148 inset: 0; 149 pointer-events: none; 150 position: absolute; 151 width: 100%; 152 height: 100%; 153 z-index: ${({$zIndex:e})=>e??"9999999"}; 154`;function iZ(e){let t,n;return t=requestAnimationFrame(()=>{n=requestAnimationFrame(e)}),()=>{void 0!==t&&cancelAnimationFrame(t),void 0!==n&&cancelAnimationFrame(n)}}let iQ=e=>{let{documentIds:t}=e,[n,r]=(0,y.useState)([]);(0,y.useEffect)(()=>{r(e=>{let n=Array.from(new Set(t));return e.length===n.length&&0===e.reduce((e,t)=>e.filter(e=>e!==t),n)?.length?e:n})},[t]);let i=n7();return(0,y.useEffect)(()=>{for(let e of n)i.send({type:"observe",documentId:$(e)}),i.send({type:"observe",documentId:O(e)});return()=>{for(let e of n)i.send({type:"unobserve",documentId:$(e)}),i.send({type:"unobserve",documentId:O(e)})}},[i,n]),null},i0=e=>{let{comlink:t,dispatch:n,inFrame:i,inPopUp:o,onDrag:a,overlayEnabled:s,rootElement:u}=e,{dispatchDragEndEvent:l}=function(){let{getDocument:e}=rr();return(0,y.useEffect)(()=>{let t=t=>{let{insertPosition:n,target:r,preventInsertDefault:i}=t.detail;if(i)return;let o=function(e){if(e){let{top:t,right:n,bottom:r,left:i}=e;if(i||t)return{node:(i??t).sanity,position:"after"};if(n||r)return{node:(n??r).sanity,position:"before"}}}(n);if(o){let t=e(r.id),{node:n,position:i}=o,{key:a,hasExplicitKey:s}=ra(r),{path:u,key:l}=ra(n);u&&l&&l!==a&&t.patch(async({getSnapshot:e})=>{let t=n8(await e(),r.path);return s?[B(u,G({_key:a})),B(u,W(t,i,{_key:l}))]:[B(u,G(~~a)),B(u,W(t,i,l>a?~~l-1:~~l))]})}};return window.addEventListener("sanity/dragEnd",t),()=>{window.removeEventListener("sanity/dragEnd",t)}},[e]),{dispatchDragEndEvent:(0,y.useCallback)(e=>{let t=new CustomEvent("sanity/dragEnd",{detail:e,cancelable:!0});window.dispatchEvent(t)},[])}}(),c=(0,A.u)(),d=function(e,t,n,i){let o=(0,y.useRef)(void 0),a=re();return(0,y.useEffect)(()=>{if(e)return o.current=function({handler:e,overlayElement:t,inFrame:n,inPopUp:i,optimisticActorReady:o}){let a=!1,s=new Map,u=new WeakMap,l=new Set,c=new WeakMap,d=new WeakMap,p,f,y,m=!1,h=[],g=()=>h[h.length-1];function v(e,t){e.removeEventListener("click",t.click,{capture:!0}),e.removeEventListener("contextmenu",t.contextmenu,{capture:!0}),e.removeEventListener("mousemove",t.mousemove,{capture:!0}),e.removeEventListener("mousedown",t.mousedown,{capture:!0}),e.removeEventListener("mouseenter",t.mouseenter),e.removeEventListener("mouseleave",t.mouseleave)}function b({id:t,elements:n,handlers:r}){let{element:i,measureElement:o}=n;i.addEventListener("click",r.click,{capture:!0}),i.addEventListener("contextmenu",r.contextmenu,{capture:!0}),i.addEventListener("mousemove",r.mousemove,{once:!0,capture:!0}),i.addEventListener("mousedown",r.mousedown,{capture:!0}),p.observe(o),e({type:"element/activate",id:t})}function w({id:t,elements:n,handlers:r}){let{element:i,measureElement:o}=n;v(i,r),p.unobserve(o),h=h.filter(e=>e!==i),e({type:"element/deactivate",id:t})}function x(t){if((n||i)&&o)for(let n of h){if(t===n){let n=u.get(t)?.sanity;if(!n||!ii(n))return;if(iu(t,n,l,u)){let n=t.style.cursor;n&&d.set(t,n),e({type:"overlay/setCursor",element:t,cursor:"move"});continue}}E(n)}}function E(t){let n=d.get(t);e({type:"overlay/setCursor",element:t,cursor:n})}function _(d){for(let p of function e(t){let n=[];function r(e,t){let r=function(e){if("object"==typeof e&&null!==e)return rA(e);try{let t=JSON.parse(e);return rA(t)}catch{return function(e){var t;let n=e.split(";").reduce((e,t)=>
154{let[n,r]=t.split("=");if(!n||t.includes("=")&&!r)return e;switch(n){case"id":e.id=r;break;case"type":e.type=r;break;case"path":e.path=j.toString(function(e){let t=[];for(let n of e.split(".")){let e=rI.exec(n);if(e){t.push(e[1],Number(e[2]));continue}let r=rM.exec(n);if(r){t.push(r[1],[Number(r[2]),Number(r[3])]);continue}let i=rS.exec(n);if(i){t.push(i[1],{_key:i[2]});continue}t.push(n)}return t}(r));break;case"base":e.baseUrl=decodeURIComponent(r);break;case"tool":e.tool=r;break;case"workspace":e.workspace=r;break;case"projectId":e.projectId=r;break;case"dataset":e.dataset=r}return e},{});if(t=n,!rj._run({typed:!1,value:t},{abortEarly:!0}).issues)return n}(e)}}(t);if(!r)return;let i=function e(t){let{display:n}=window.getComputedStyle(t);if("inline"!==n)return t;let r=t.parentElement;return r?e(r):null}(e);i&&n.push({elements:{element:e,measureElement:i},sanity:r})}if(t)for(let i of t.childNodes){let{nodeType:t,parentElement:o,textContent:a}=i;if(r7(i)&&void 0!==i.dataset?.sanityEditTarget){let t=e(i).map(({sanity:e})=>e);if(!t.map(e=>ii(e)).every((e,t,n)=>e===n[0]))continue;let r=function(e){if(!e.length||!e.map(e=>ii(e)).every((e,t,n)=>e===n[0]))return;if(!ii(e[0]))return e[0];let t=e.filter(ii),n=e[0],r=["projectId","dataset","id","baseUrl","workspace","tool"];for(let e=1;e<t.length;e++){let i=t[e];if(r.some(e=>i[e]!==n?.[e])){n=void 0;break}n.path=function(e,t){let n=e.split("."),r=t.split("."),i=Math.min(n.length,r.length);return n=n.slice(0,i).reverse(),r=r.slice(0,i).reverse(),n.reduce((e,t,n)=>t===r[n]?[...e,t]:[],[]).reverse().join(".")}(n.path,i.path)}return n}(t);r&&n.push({elements:{element:i,measureElement:i},sanity:r})}else if(t===Node.TEXT_NODE&&o&&a){let e=r4(a);if(!e)continue;r(o,e)}else if(r7(i)){if("SCRIPT"===i.tagName||"SANITY-VISUAL-EDITING"===i.tagName)continue;if(i.dataset?.sanity)r(i,i.dataset.sanity);else if(i.dataset?.sanityEditInfo)r(i,i.dataset.sanityEditInfo);else{if(ie(i)){let e=r4(i.alt,!0);if(!e)continue;r(i,e);continue}if(it(i)){let e=r4(i.dateTime,!0);if(!e)continue;r(i,e)}else if(ir(i)){if(!i.ariaLabel)continue;let e=r4(i.ariaLabel,!0);if(!e)continue;r(i,e)}}n.push(...e(i))}}return n}(d)){let{element:d}=p.elements;u.has(d)?function({elements:t,sanity:n}){let{element:r}=t,i=u.get(r);i&&(u.set(r,{...i,sanity:n}),e({type:"element/update",id:i.id,rect:rV(r),sanity:n}))}(p):function({elements:d,sanity:p}){let{element:y,measureElement:v}=d,w={click(t){let r=t.target;if(y===g()&&y.contains(r)){n&&(t.preventDefault(),t.stopPropagation());let r=u.get(y)?.sanity;r&&!m&&e({type:"element/click",id:_,sanity:r})}},contextmenu(t){if(!("path"in p)||!n&&!i||!o||!p.path.split(".").pop()?.includes("[_key=="))return;let r=t.target;y===g()&&y.contains(r)&&((n||i)&&(t.preventDefault(),t.stopPropagation()),e({type:"element/contextmenu",id:_,position:{x:t.clientX,y:t.clientY},sanity:p}))},mousedown(t){if(t.preventDefault(),t.currentTarget!==h.at(-1)||y.getAttribute("data-sanity-drag-disable")||!n&&!i||!o)return;let r=u.get(y)?.sanity;if(!r||!ii(r)||!io(r.path))return;let a=iu(y,p,l,u);a&&function(e){var t;let{mouseEvent:n,element:r,overlayGroup:i,handler:o,target:a,onSequenceStart:s,onSequenceEnd:u}=e;if(0!==n.button)return;window.focus();let l=i.map(e=>rV(e.elements.element)),c=r.getAttribute("data-sanity-drag-flow")||((t=l).some(e=>t.filter(t=>!rq(e,t)).some(t=>e.y===t.y))?"horizontal":"vertical"),d=r.getAttribute("data-sanity-drag-group"),p=!!r.getAttribute("data-sanity-drag-minimap-disable"),f=!!r.getAttribute("data-sanity-drag-prevent-default"),y=r.getAttribute("data-unstable_sanity-drag-document-height"),m=r.getAttribute("data-unstable_sanity-drag-group-height"),h=null,g=rX(n),v=document.body,{minYScaled:b,scaleFactor:w}=function(e,t){let n=t||rJ(e).height,r=(n+=200)>window.innerHeight?window.innerHeight/n:1,{min:i}=rJ(e.map(e=>rY(e,r,{x:window.innerWidth/2,y:0})));return{scaleFactor:r,minYScaled:i-100*r}}(l,m?~~m:null),x=!1,E=!1,_=!0;r1||(r6={body:{overflow:window.getComputedStyle(document.body).overflow,height:window.getComputedStyle(document.body).height},documentElement:{overflow:window.getComputedStyle(document.documentElement).overflow,height:window.getComputedStyle(document.documentElement).height}},r5=y?~~y:document.documentElement.scrollHeight);let k=setInterval(()=>{l=i.map(e=>rV(e.elements.element))},150),j=()=>{w>=1||(o({type:"overlay/dragUpdateSkeleton",skeleton:rZ(r9,r,w)}),o({type:"overlay/dragToggleMinimapPrompt",display:!1}),(async function(e,t,n,r){return new Promise(i=>{e.addEventListener("transitionend",()=>{setTimeout(()=>{r({type:"overlay/dragEndMinimapTransition"})},300),i()},{once:!0}),r({type:"overlay/dragStartMinimapTransition"}),r({type:"overlay/dragToggleMinimap",display:!0}),document.body.style.overflow="hidden",document.body.style.height="100%",document.documentElement.style.overflow="initial",document.documentElement.style.height="100%",setTimeout(()=>{e.style.transformOrigin="50% 0px",e.style.transition="transform 150ms ease",e.style.transform=`translate3d(0px, ${-n+scrollY}px, 0px) scale(${t})`},25)})})(v,w,b,o).then(()=>{setTimeout(()=>{o({type:"overlay/dragUpdateGroupRect",groupRect:rQ(l)})},300)}))},I=e=>{Math.abs(e.deltaY)>=10&&w<1&&!r1&&!E&&!p&&_&&(o({type:"overlay/dragToggleMinimapPrompt",display:!0}),E=!0),!e.shiftKey||r1||p||(window.dispatchEvent(new CustomEvent("unstable_sanity/dragApplyMinimap")),r1=!0,setTimeout(()=>{j()},50))},M=e=>{if(e.preventDefault(),r2=function(e){let t=document.body,n=window.getComputedStyle(t).transform;if("none"===n)return{x:e.x,y:e.y};let r=new DOMMatrix(n).inverse(),i=new DOMPoint(e.x,e.y).matrixTransform(r);return{x:i.x,y:i.y}}(r9=rX(e)),4>Math.abs(rG(r9,g)))return;if(!x){let e=rQ(l),t=rZ(r9,r,1);o({type:"overlay/dragStart",flow:c}),o({type:"overlay/dragUpdateSkeleton",skeleton:t}),o({type:"overlay/dragUpdateGroupRect",groupRect:e}),x=!0,s()}o({type:"overlay/dragUpdateCursorPosition",x:r9.x,y:r9.y}),!e.shiftKey||r1||p||(window.dispatchEvent(new CustomEvent("unstable_sanity/dragApplyMinimap")),r1=!0,setTimeout(()=>{j()},50));let t=function(e,t,n){if("horizontal"===n){let r={x1:e.x,y1:e.y,x2:e.x-1e8,y2:e.y},i={x1:e.x,y1:e.y,x2:e.x+1e8,y2:e.y};return{left:rB(r,t,n),right:rB(i,t,n)}}{let r={x1:e.x,y1:e.y,x2:e.x,y2:e.y-1e8},i={x1:e.x,y1:e.y,x2:e.x,y2:e.y+1e8};return{top:rB(r,t,n),bottom:rB(i,t,n)}}}(r9,l,c);JSON.stringify(h)!==JSON.stringify(t)&&o({type:"overlay/dragUpdateInsertPosition",insertPosition:rK(i,h=t,c)})},S=()=>{_=!1,o({type:"overlay/dragEnd",target:a,insertPosition:h?rK(i,h,c):null,dragGroup:d,flow:c,preventInsertDefault:f}),E&&o({type:"overlay/dragToggleMinimapPrompt",display:!1}),r1||(clearInterval(k),u(),T(),P()),A()},$=e=>{"Shift"===e.key&&r1&&(r1=!1,o({type:"overlay/dragUpdateSkeleton",skeleton:rZ(r9,r,1/w)}),window.dispatchEvent(new CustomEvent("unstable_sanity/dragResetMinimap")),setTimeout(()=>{r0(r2.y,v,r5,o,150,r6)},50),o({type:"overlay/dragUpdateGroupRect",groupRect:null}),_||(clearInterval(k),A(),T(),P(),u()))},O=()=>{o({type:"overlay/dragUpdateGroupRect",groupRect:null}),window.dispatchEvent(new CustomEvent("unstable_sanity/dragResetMinimap")),setTimeout(()=>{r0(r2.y,v,r5,o,150,r6).then(()=>{r1=!1})},50),clearInterval(k),A(),T(),P(),u()},A=()=>{window.removeEventListener("mousemove",M),window.removeEventListener("wheel",I),window.removeEventListener("mouseup",S)},P=()=>{window.removeEventListener("keyup",$)},T=()=>{window.removeEventListener("blur",O)};window.addEventListener("blur",O),window.addEventListener("keyup",$),window.addEventListener("wheel",I),window.addEventListener("mousemove",M),window.addEventListener("mouseup",S)}({element:y,handler:e,mouseEvent:t,overlayGroup:a,target:r,onSequenceStart:()=>{m=!0},onSequenceEnd:()=>{setTimeout(()=>{m=!1},250)}})},mousemove(e){w.mouseenter(e);let t=e.currentTarget;t&&(t.addEventListener("mouseenter",w.mouseenter),t.addEventListener("mouseleave",w.mouseleave))},mouseenter(){document.querySelector("vercel-live-feedback")&&y.closest("[data-vercel-edit-info]")||y.closest("[data-vercel-edit-target]")||(h.push(y),e({type:"element/mouseenter",id:_,rect:rV(y)}),x(y))},mouseleave(n){function r(){h.pop();let t=g();if(e({type:"element/mouseleave",id:_}),t){x(t);let n=u.get(t);n&&e({type:"element/mouseenter",id:n.id,rect:rV(t)})}E(y)}let{relatedTarget:i}=n,o=r8(i),a=t.contains(o);if(r3(o)&&a)return function e(t){let n=i=>{let{relatedTarget:o}=i;r8(o)?o&&r3(o)&&(t.removeEventListener("mouseleave",n),e(o)):(t.removeEventListener("mouseleave",n),r())};t.addEventListener("mouseleave",n)}(o);r()}},_=function(e){if(rF.randomUUID&&!e)return rF.randomUUID();let t=(e=e||{}).random??e.rng?.()??function(){if(!r){if(typeof crypto>"u"||!crypto.getRandomValues)throw Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");r=crypto.getRandomValues.bind(crypto)}return r(rU)}();if(t.length<16)throw Error("Random bytes length must be >= 16");return t[6]=15&t[6]|64,t[8]=63&t[8]|128,function(e,t=0){return(rN[e[t+0]]+rN[e[t+1
154]]+rN[e[t+2]]+rN[e[t+3]]+"-"+rN[e[t+4]]+rN[e[t+5]]+"-"+rN[e[t+6]]+rN[e[t+7]]+"-"+rN[e[t+8]]+rN[e[t+9]]+"-"+rN[e[t+10]]+rN[e[t+11]]+rN[e[t+12]]+rN[e[t+13]]+rN[e[t+14]]+rN[e[t+15]]).toLowerCase()}(t)}(),k={id:_,elements:d,sanity:p,handlers:w};l.add(y),c.set(v,y),s.set(_,y),u.set(y,k),f?.observe(y),e({type:"element/register",id:_,element:y,rect:rV(y),sanity:p,dragDisabled:!!y.getAttribute("data-sanity-drag-disable")}),a&&b(k)}(p)}}function k(t){let n=u.get(t);if(n){let{id:r,handlers:i}=n;v(t,i),p.unobserve(t),u.delete(t),l.delete(t),s.delete(r),e({type:"element/unregister",id:r})}}function I(t){let n=u.get(t);n&&e({type:"element/updateRect",id:n.id,rect:rV(t)})}function M(e){if(a)for(let t of e){let{target:e}=t,n=r3(e)&&u.get(e);n&&(t.isIntersecting?b(n):w(n))}}function S(t){let n=r8(t.target);n?"capture"===n.dataset.sanityOverlayElement&&(t.preventDefault(),t.stopPropagation()):(h=[],e({type:"overlay/blur"}))}function $(){for(let e of l)I(e)}function O(t){"Escape"===t.key&&(h=[],e({type:"overlay/blur"}))}function A(e){let{target:t}=e;if(t!==window.document&&r3(t))for(let e of l)t.contains(e)&&I(e)}function P(){a||(f=new IntersectionObserver(M,{threshold:.3}),l.forEach(e=>f.observe(e)),e({type:"overlay/activate"}),a=!0)}function T(){a&&(f?.disconnect(),l.forEach(e=>{let t=u.get(e);t&&w(t)}),e({type:"overlay/deactivate"}),a=!1)}return window.document.fonts.ready.then(()=>{for(let e of l)I(e)}),window.addEventListener("click",S),window.addEventListener("contextmenu",S),window.addEventListener("keydown",O),window.addEventListener("resize",$),window.addEventListener("scroll",A,{capture:!0,passive:!0}),p=new ResizeObserver(function(e){for(let t of e){let e=t.target;if(r3(e)){let t=c.get(e);if(!t)return;I(t)}}}),(y=new MutationObserver(function(e){let n=!1;for(let r of e){let{target:e,type:i}=r,o="characterData"===i?e.parentElement:e;o===t||t.contains(o)||(n=!0,r3(o)&&_({childNodes:[o]}))}if(n)for(let e of l)e.isConnected||k(e)})).observe(document.body,{attributes:!0,characterData:!0,childList:!0,subtree:!0}),_(document.body),P(),{activate:P,deactivate:T,destroy:function(){window.removeEventListener("click",S),window.removeEventListener("contextmenu",S),window.removeEventListener("keydown",O),window.removeEventListener("resize",$),window.removeEventListener("scroll",A),y.disconnect(),p.disconnect(),l.forEach(e=>{k(e)}),s.clear(),l.clear(),h=[],T()}}}({handler:t,overlayElement:e,inFrame:n,inPopUp:i,optimisticActorReady:a}),()=>{o.current?.destroy(),o.current=void 0}},[e,t,n,i,a]),o}(u,(0,y.useCallback)(e=>{if("element/click"===e.type){let{sanity:n}=e;t?.post("visual-editing/focus",n),c("Visual Editing Overlay Clicked",null)}else if("overlay/activate"===e.type)t?.post("visual-editing/toggle",{enabled:!0});else if("overlay/deactivate"===e.type)t?.post("visual-editing/toggle",{enabled:!1});else if("overlay/dragEnd"===e.type){let{insertPosition:t,target:n,dragGroup:r,flow:i,preventInsertDefault:o}=e;l({insertPosition:t,target:n,dragGroup:r,flow:i,preventInsertDefault:o}),t&&c("Visual Editing Drag Sequence Completed",null)}else{if("overlay/dragUpdateCursorPosition"===e.type)return void a(e.x,e.y);if("overlay/dragToggleMinimap"===e.type&&!0===e.display)c("Visual Editing Drag Minimap Enabled",null);else if("overlay/setCursor"===e.type){let{element:t,cursor:n}=e;n?t.style.cursor=n:t.style.removeProperty("cursor")}}n(e)},[t,n,l,a,c]),i,o);return(0,y.useEffect)(()=>{s?d.current?.activate():d.current?.deactivate()},[d,s]),null},i1=e=>{let{comlink:t,componentResolver:n,inFrame:r,inPopUp:i,zIndex:o}=e,[a,s]=(0,y.useState)(),u=(0,A.s)(),[{contextMenu:l,dragInsertPosition:c,dragShowMinimap:d,dragShowMinimapPrompt:f,dragSkeleton:m,elements:h,isDragging:g,perspective:v,wasMaybeCollapsed:b,dragMinimapTransition:w,dragGroupRect:x},E]=(0,y.useReducer)(iW,{contextMenu:null,dragInsertPosition:null,dragShowMinimap:!1,dragShowMinimapPrompt:!1,dragSkeleton:null,elements:[],focusPath:"",isDragging:!1,perspective:"published",wasMaybeCollapsed:!1,dragMinimapTransition:!1,dragGroupRect:null}),[_,k]=(0,y.useState)(null),[j,I]=(0,y.useState)(!0);(0,y.useEffect)(()=>{let e=[t?.on("presentation/focus",e=>{E({type:"presentation/focus",data:e})}),t?.on("presentation/blur",e=>{E({type:"presentation/blur",data:e})}),t?.on("presentation/toggle-overlay",()=>{I(e=>!e)}),t?.onStatus(e=>{s(e)}
154)].filter(Boolean);return()=>e.forEach(e=>e())},[t]),function(e,t){(0,y.useEffect)(()=>{let n=new AbortController;e?.fetch("visual-editing/fetch-perspective",void 0,{signal:n.signal,suppressWarnings:!0}).then(e=>{t({type:"presentation/perspective",data:e})}).catch(()=>{});let r=e?.on("presentation/perspective",e=>{t({type:"presentation/perspective",data:e})});return()=>{r?.(),n.abort()}},[e,t])}(t,E),function(e,t,n){let r=(0,y.useRef)(void 0),i=(0,y.useCallback)((t,n)=>{e?.post("visual-editing/documents",{documents:t,perspective:n})},[e]);(0,y.useEffect)(()=>{let e=t.map(e=>{let{sanity:t}=e;return"id"in t?t:null}).filter(e=>!!e),o=new Set(e.map(e=>e.id));if(!r.current||!function(e,t){if(e===t)return!0;if(e.size!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;return!0}(o,r.current.nodeIds)||n!==r.current.perspective){let t=Array.from(o).map(t=>{let{type:n,projectId:r,dataset:i}=e.find(e=>e.id===t);return r&&i?{_id:t,_type:n,_projectId:r,_dataset:i}:{_id:t,_type:n}});r.current={nodeIds:o,perspective:n},i(t,n)}},[t,n,i])}(t,h,v);let M=(0,y.useCallback)((e,t)=>{_&&(_.style.setProperty("--drag-preview-x",`${e}px`),_.style.setProperty("--drag-preview-y",t-window.scrollY+"px"))},[_]);(0,y.useEffect)(()=>{let e=e=>{let t=e.target;if(((0,A.G)(t)||(0,A.J)(t)&&t.closest("a"))&&e.altKey){e.preventDefault(),e.stopPropagation();let t=new MouseEvent(e.type,{...e,altKey:!1,bubbles:!0,cancelable:!0});e.target?.dispatchEvent(t)}},t=e=>{i9(e)&&I(e=>!e)},n=e=>{i9(e)&&I(e=>!e),["mod","\\"].every(t=>i2[t]?e[i2[t]]:e.key===t.toUpperCase())&&I(e=>!e)};return window.addEventListener("click",e),window.addEventListener("keydown",n),window.addEventListener("keyup",t),()=>{window.removeEventListener("click",e),window.removeEventListener("keydown",n),window.removeEventListener("keyup",t)}},[I]);let[S,$]=(0,y.useState)(!1),[O,P]=(0,y.useState)(!1),T=(0,y.useRef)(void 0);(0,y.useEffect)(()=>{if(j)return iZ(()=>{$(!0),iZ(()=>{P(!0),T.current=setTimeout(()=>{P(!1),$(!1)},1500)})});T.current&&(clearTimeout(T.current),$(!1),P(!1))},[j]);let C=(0,y.useMemo)(()=>h.flatMap(e=>"id"in e.sanity?[e.sanity.id]:[]),[h]),R=(0,y.useCallback)(()=>{E({type:"overlay/blur"})},[]),D=re(),L=(0,y.useMemo)(()=>D?n:void 0,[n,D]),z=(0,y.useMemo)(()=>(r||i)&&"connected"!==a||g?[]:h.filter(e=>e.activated||e.focused).map(({id:e,element:t,focused:n,hovered:i,rect:o,sanity:a,dragDisabled:s})=>{let u=!s&&!!t.getAttribute("data-sanity")&&D&&h.some(e=>"id"in e.sanity&&"id"in a&&is(e.sanity,a)&&e.sanity.path!==a.path);return(0,p.jsx)(iC,{componentResolver:L,element:t,enableScrollIntoView:!g&&!w&&!d,focused:n,hovered:i,node:a,rect:o,showActions:!r,draggable:u,isDragging:g||w,wasMaybeCollapsed:n&&b},e)}),[L,w,d,h,r,i,g,D,a,b]);return(0,p.jsx)(iK,{comlink:t,children:(0,p.jsx)(A.x,{scheme:u?"dark":"light",theme:A.y,tone:"transparent",children:(0,p.jsx)(A.L,{children:(0,p.jsx)(A.z,{element:_,children:(0,p.jsx)(iY,{comlink:t,elements:h,children:(0,p.jsx)(iq,{comlink:t,children:(0,p.jsx)(iH,{comlink:t,children:(0,p.jsxs)(iX,{"data-fading-out":O?"":void 0,"data-overlays":S?"":void 0,ref:k,$zIndex:o,children:[(0,p.jsx)(iQ,{documentIds:C,perspective:v}),(0,p.jsx)(i0,{comlink:t,dispatch:E,inFrame:r,inPopUp:i,onDrag:M,overlayEnabled:j,rootElement:_}),l&&(0,p.jsx)(iI,{...l,onDismiss:R}),z,g&&!w&&(0,p.jsxs)(p.Fragment,{children:[c&&(0,p.jsx)(iL,{dragInsertPosition:c}),f&&(0,p.jsx)(iF,{}),x&&(0,p.jsx)(iD,{dragGroupRect:x})]}),g&&m&&(0,p.jsx)(iN,{skeleton:m})]})})})})})})})})},i2={alt:"altKey",ctrl:"ctrlKey",mod:"u">typeof window&&/Mac|iPod|iPhone|iPad/.test(window.navigator.platform)?"metaKey":"ctrlKey",shift:"shiftKey"};function i9(e){return"Alt"===e.key}let i5=e=>{let{comlink:t,refresh:n}=e,r=(0,y.useRef)(0),i=(0,y.useRef)(0);return(0,y.useEffect)(()=>t.on("presentation/refresh",e=>{if("manual"===e.source){clearTimeout(r.current);let i=n(e);if(!1===i)return;t.post("visual-editing/refreshing",e);let o=!1;r.current=window.setTimeout(()=>{t.post("visual-editing/refreshed",e),o=!0},3e3),i?.finally?.(()=>{o||(clearTimeout(r.current),t.post("visual-editing/refreshed",e))})}else if("mutation"===e.source){clearTimeout(i.current);let r=n(e);if(!1===r)return;t.post("visual-editing/refreshing",e),i.current=window.setTimeout(()=>{let r=n(e);!1!==r&&(t.post("visual-editing/refreshing",e),r?.finally?.(()=>{t.post("visual-editing/refreshed",e)})||t.post("visual-editing/refreshed",e))},1e3),r?.finally?.(()=>{t.post("visual-editing/refreshed",e)})||t.post("visual-editing/refreshed",e)}}),[t,n]),null},i6=e=>{let{components:t,history:n,portal:r=!0,refresh:i,zIndex:o}=e,[a,s]=(0,y.useState)(null),[u,l]=(0,y.useState)(null);(0,y.useEffect)(()=>{s((0,f.Fk)()),l((0,f.v$)())},[]);let[c,d]=(0,y.useState)(null);(0,y.useEffect)(()=>
154{if(!1===r)return;let e=document.createElement("sanity-visual-editing");return document.documentElement.appendChild(e),d(e),()=>{d(null),document.documentElement.contains(e)&&document.documentElement.removeChild(e)}},[r]);let h=function(e=!0){let[t,n]=(0,y.useState)();return(0,y.useEffect)(()=>{if(!e)return;let t=(0,id.RM)({name:"visual-editing",connectTo:"presentation"},(0,id.Uc)().provide({actors:(0,f.jF)()}));n(t);let r=t.start();return()=>{r(),n(void 0)}},[e]),t}(!0===a||!0===u);!function(e){(0,y.useEffect)(()=>{if(!e)return;let t=function(e){let t=new ip.m(1),n=new iy.B;return e.fetch("visual-editing/snapshot-welcome",void 0,{suppressWarnings:!0}).then(e=>{t.next(e.event)}).catch(()=>{}),e.on("presentation/snapshot-event",e=>{"reconnect"===e.event.type&&t.next(e.event),"mutation"===e.event.type&&n.next(e.event)}),(0,nh.h)(t,n)}(e),n=nK(e),r=(0,K.A)(n,{input:{client:{withConfig:()=>{}},sharedListener:t}});r.start();let i=new AbortController,o=e.onStatus(()=>{e.fetch("visual-editing/features",void 0,{signal:i.signal,suppressWarnings:!0}).then(e=>{e.features.optimistic&&function(e){for(let t of(nZ=e,nQ))t()}(r)}).catch(()=>{console.warn("[@sanity/visual-editing] Package version mismatch detected: Please update your Sanity studio to prevent potential compatibility issues.")})},"connected");return()=>{r.stop(),i.abort(),o()}},[e])}(h);let g=(0,p.jsxs)(p.Fragment,{children:[null!==a&&null!==u&&(0,p.jsx)(i1,{comlink:h,componentResolver:t,inFrame:a,inPopUp:u,zIndex:o}),h&&(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(im,{comlink:h,history:n}),(0,p.jsx)(ih,{comlink:h}),i&&(0,p.jsx)(i5,{comlink:h,refresh:i})]})]});return!1!==r&&c?(0,m.createPortal)(g,c):g};i6.displayName="VisualEditing";var i3=n(76046),i8=n(20080);function i4(e){let t=e.indexOf("#"),n=e.indexOf("?"),r=n>-1&&(t<0||n<t);return r||t>-1?{pathname:e.substring(0,r?n:t),query:r?e.substring(n,t>-1?t:void 0):"",hash:t>-1?e.slice(t):""}:{pathname:e,query:"",hash:""}}function i7(e,t){if(!function(e,t){if("string"!=typeof e)return!1;let{pathname:n}=i4(e);return n===t||n.startsWith(`${t}/`)}(e,t))return e;let n=e.slice(t.length);return n.startsWith("/")?n:`/${n}`}let oe=(e,t)=>{let{pathname:n,query:r,hash:i}=i4(e);return t?n.endsWith("/")?`${n}${r}${i}`:`${n}/${r}${i}`:`${n.replace(/\/$/,"")||"/"}${r}${i}`};function ot(e){let{basePath:t="",components:n,refresh:r,trailingSlash:i=!1,zIndex:o}=e,a=(0,i3.useRouter)(),s=(0,y.useRef)(a),[u,l]=(0,y.useState)();(0,y.useEffect)(()=>{s.current=a},[a]);let c=(0,y.useMemo)(()=>({subscribe:e=>(l(()=>e),()=>l(void 0)),update:e=>{switch(e.type){case"push":return s.current.push(i7(e.url,t));case"pop":return s.current.back();case"replace":return s.current.replace(i7(e.url,t));default:throw Error(`Unknown update type: ${e.type}`)}}}),[t]),d=(0,i3.usePathname)(),f=(0,i3.useSearchParams)();(0,y.useEffect)(()=>{u&&u({type:"push",url:oe(function(e,t){if(!e.startsWith("/")||!t)return e;if("/"===e&&t)return t;let{pathname:n,query:r,hash:i}=i4(e);return`${t}${n}${r}${i}`}(`${d}${f?.size?`?${f}`:""}`,t),i)})},[t,u,d,f,i]);let m=(0,y.useCallback)(e=>{if(r)return r(e);switch(e.source){case"manual":return e.livePreviewEnabled?(console.debug("Live preview is setup, calling router.refresh() to refresh the server components without refetching cached data"),s.current.refresh(),Promise.resolve()):(console.debug("No loaders in live mode detected, or preview kit setup, revalidating root layout"),(0,i8.q)());case"mutation":return e.livePreviewEnabled?(console.debug("Live preview is setup, mutation is skipped assuming its handled by the live preview"),!1):(console.debug("No loaders in live mode detected, or preview kit setup, revalidating root layout"),(0,i8.q)());default:throw Error("Unknown refresh source",{cause:e})}},[r]);return(0,p.jsx)(i6,{components:n,history:c,portal:!0,refresh:m,zIndex:o})}}}]);
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.