@noya-app/noya-multiplayer-react 0.1.86 → 0.1.87

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,26 +1,26 @@
1
- "use strict";var kk=Object.create;var yf=Object.defineProperty;var Dk=Object.getOwnPropertyDescriptor;var Uk=Object.getOwnPropertyNames;var _k=Object.getPrototypeOf,jk=Object.prototype.hasOwnProperty;var Lk=(e,t)=>()=>(e&&(t=e(e=0)),t);var ee=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),Ci=(e,t)=>{for(var n in t)yf(e,n,{get:t[n],enumerable:!0})},xI=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of Uk(t))!jk.call(e,i)&&i!==n&&yf(e,i,{get:()=>t[i],enumerable:!(r=Dk(t,i))||r.enumerable});return e};var Q=(e,t,n)=>(n=e!=null?kk(_k(e)):{},xI(t||!e||!e.__esModule?yf(n,"default",{value:e,enumerable:!0}):n,e)),Bk=e=>xI(yf({},"__esModule",{value:!0}),e);var u=Lk(()=>{"use strict"});var DE=ee((Xde,kE)=>{"use strict";u();var F$="Expected a function",wE="__lodash_hash_undefined__",ME=1/0,$$="[object Function]",K$="[object GeneratorFunction]",z$="[object Symbol]",H$=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,G$=/^\w*$/,q$=/^\./,V$=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,Q$=/[\\^$.*+?()[\]{}|]/g,Y$=/\\(\\)?/g,J$=/^\[object .+?Constructor\]$/,X$=typeof global=="object"&&global&&global.Object===Object&&global,Z$=typeof self=="object"&&self&&self.Object===Object&&self,kg=X$||Z$||Function("return this")();function W$(e,t){return e?.[t]}function eK(e){var t=!1;if(e!=null&&typeof e.toString!="function")try{t=!!(e+"")}catch{}return t}var tK=Array.prototype,nK=Function.prototype,OE=Object.prototype,Ng=kg["__core-js_shared__"],TE=function(){var e=/[^.]+$/.exec(Ng&&Ng.keys&&Ng.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""}(),AE=nK.toString,Dg=OE.hasOwnProperty,RE=OE.toString,rK=RegExp("^"+AE.call(Dg).replace(Q$,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),vE=kg.Symbol,iK=tK.splice,oK=PE(kg,"Map"),rl=PE(Object,"create"),IE=vE?vE.prototype:void 0,EE=IE?IE.toString:void 0;function Ds(e){var t=-1,n=e?e.length:0;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}function sK(){this.__data__=rl?rl(null):{}}function aK(e){return this.has(e)&&delete this.__data__[e]}function cK(e){var t=this.__data__;if(rl){var n=t[e];return n===wE?void 0:n}return Dg.call(t,e)?t[e]:void 0}function uK(e){var t=this.__data__;return rl?t[e]!==void 0:Dg.call(t,e)}function lK(e,t){var n=this.__data__;return n[e]=rl&&t===void 0?wE:t,this}Ds.prototype.clear=sK;Ds.prototype.delete=aK;Ds.prototype.get=cK;Ds.prototype.has=uK;Ds.prototype.set=lK;function ja(e){var t=-1,n=e?e.length:0;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}function pK(){this.__data__=[]}function fK(e){var t=this.__data__,n=Lf(t,e);if(n<0)return!1;var r=t.length-1;return n==r?t.pop():iK.call(t,n,1),!0}function dK(e){var t=this.__data__,n=Lf(t,e);return n<0?void 0:t[n][1]}function mK(e){return Lf(this.__data__,e)>-1}function hK(e,t){var n=this.__data__,r=Lf(n,e);return r<0?n.push([e,t]):n[r][1]=t,this}ja.prototype.clear=pK;ja.prototype.delete=fK;ja.prototype.get=dK;ja.prototype.has=mK;ja.prototype.set=hK;function Us(e){var t=-1,n=e?e.length:0;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}function yK(){this.__data__={hash:new Ds,map:new(oK||ja),string:new Ds}}function gK(e){return Bf(this,e).delete(e)}function bK(e){return Bf(this,e).get(e)}function SK(e){return Bf(this,e).has(e)}function xK(e,t){return Bf(this,e).set(e,t),this}Us.prototype.clear=yK;Us.prototype.delete=gK;Us.prototype.get=bK;Us.prototype.has=SK;Us.prototype.set=xK;function Lf(e,t){for(var n=e.length;n--;)if(CK(e[n][0],t))return n;return-1}function TK(e,t){t=wK(t,e)?[t]:EK(t);for(var n=0,r=t.length;e!=null&&n<r;)e=e[RK(t[n++])];return n&&n==r?e:void 0}function vK(e){if(!NE(e)||OK(e))return!1;var t=NK(e)||eK(e)?rK:J$;return t.test(PK(e))}function IK(e){if(typeof e=="string")return e;if(_g(e))return EE?EE.call(e):"";var t=e+"";return t=="0"&&1/e==-ME?"-0":t}function EK(e){return CE(e)?e:AK(e)}function Bf(e,t){var n=e.__data__;return MK(t)?n[typeof t=="string"?"string":"hash"]:n.map}function PE(e,t){var n=W$(e,t);return vK(n)?n:void 0}function wK(e,t){if(CE(e))return!1;var n=typeof e;return n=="number"||n=="symbol"||n=="boolean"||e==null||_g(e)?!0:G$.test(e)||!H$.test(e)||t!=null&&e in Object(t)}function MK(e){var t=typeof e;return t=="string"||t=="number"||t=="symbol"||t=="boolean"?e!=="__proto__":e===null}function OK(e){return!!TE&&TE in e}var AK=Ug(function(e){e=DK(e);var t=[];return q$.test(e)&&t.push(""),e.replace(V$,function(n,r,i,o){t.push(i?o.replace(Y$,"$1"):r||n)}),t});function RK(e){if(typeof e=="string"||_g(e))return e;var t=e+"";return t=="0"&&1/e==-ME?"-0":t}function PK(e){if(e!=null){try{return AE.call(e)}catch{}try{return e+""}catch{}}return""}function Ug(e,t){if(typeof e!="function"||t&&typeof t!="function")throw new TypeError(F$);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 s=e.apply(this,r);return n.cache=o.set(i,s),s};return n.cache=new(Ug.Cache||Us),n}Ug.Cache=Us;function CK(e,t){return e===t||e!==e&&t!==t}var CE=Array.isArray;function NK(e){var t=NE(e)?RE.call(e):"";return t==$$||t==K$}function NE(e){var t=typeof e;return!!e&&(t=="object"||t=="function")}function kK(e){return!!e&&typeof e=="object"}function _g(e){return typeof e=="symbol"||kK(e)&&RE.call(e)==z$}function DK(e){return e==null?"":IK(e)}function UK(e,t,n){var r=e==null?void 0:TK(e,t);return r===void 0?n:r}kE.exports=UK});var QE=ee((Wde,VE)=>{"use strict";u();var _K="Expected a function",BE="__lodash_hash_undefined__",FE=1/0,jK=9007199254740991,LK="[object Function]",BK="[object GeneratorFunction]",FK="[object Symbol]",$K=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,KK=/^\w*$/,zK=/^\./,HK=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,GK=/[\\^$.*+?()[\]{}|]/g,qK=/\\(\\)?/g,VK=/^\[object .+?Constructor\]$/,QK=/^(?:0|[1-9]\d*)$/,YK=typeof global=="object"&&global&&global.Object===Object&&global,JK=typeof self=="object"&&self&&self.Object===Object&&self,Lg=YK||JK||Function("return this")();function XK(e,t){return e?.[t]}function ZK(e){var t=!1;if(e!=null&&typeof e.toString!="function")try{t=!!(e+"")}catch{}return t}var WK=Array.prototype,ez=Function.prototype,$E=Object.prototype,jg=Lg["__core-js_shared__"],UE=function(){var e=/[^.]+$/.exec(jg&&jg.keys&&jg.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""}(),KE=ez.toString,$f=$E.hasOwnProperty,zE=$E.toString,tz=RegExp("^"+KE.call($f).replace(GK,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),_E=Lg.Symbol,nz=WK.splice,rz=HE(Lg,"Map"),il=HE(Object,"create"),jE=_E?_E.prototype:void 0,LE=jE?jE.toString:void 0;function _s(e){var t=-1,n=e?e.length:0;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}function iz(){this.__data__=il?il(null):{}}function oz(e){return this.has(e)&&delete this.__data__[e]}function sz(e){var t=this.__data__;if(il){var n=t[e];return n===BE?void 0:n}return $f.call(t,e)?t[e]:void 0}function az(e){var t=this.__data__;return il?t[e]!==void 0:$f.call(t,e)}function cz(e,t){var n=this.__data__;return n[e]=il&&t===void 0?BE:t,this}_s.prototype.clear=iz;_s.prototype.delete=oz;_s.prototype.get=sz;_s.prototype.has=az;_s.prototype.set=cz;function La(e){var t=-1,n=e?e.length:0;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}function uz(){this.__data__=[]}function lz(e){var t=this.__data__,n=Kf(t,e);if(n<0)return!1;var r=t.length-1;return n==r?t.pop():nz.call(t,n,1),!0}function pz(e){var t=this.__data__,n=Kf(t,e);return n<0?void 0:t[n][1]}function fz(e){return Kf(this.__data__,e)>-1}function dz(e,t){var n=this.__data__,r=Kf(n,e);return r<0?n.push([e,t]):n[r][1]=t,this}La.prototype.clear=uz;La.prototype.delete=lz;La.prototype.get=pz;La.prototype.has=fz;La.prototype.set=dz;function js(e){var t=-1,n=e?e.length:0;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}function mz(){this.__data__={hash:new _s,map:new(rz||La),string:new _s}}function hz(e){return zf(this,e).delete(e)}function yz(e){return zf(this,e).get(e)}function gz(e){return zf(this,e).has(e)}function bz(e,t){return zf(this,e).set(e,t),this}js.prototype.clear=mz;js.prototype.delete=hz;js.prototype.get=yz;js.prototype.has=gz;js.prototype.set=bz;function Sz(e,t,n){var r=e[t];(!($f.call(e,t)&&GE(r,n))||n===void 0&&!(t in e))&&(e[t]=n)}function Kf(e,t){for(var n=e.length;n--;)if(GE(e[n][0],t))return n;return-1}function xz(e){if(!Ff(e)||Oz(e))return!1;var t=Cz(e)||ZK(e)?tz:VK;return t.test(Pz(e))}function Tz(e,t,n,r){if(!Ff(e))return e;t=wz(t,e)?[t]:Iz(t);for(var i=-1,o=t.length,s=o-1,a=e;a!=null&&++i<o;){var c=Rz(t[i]),l=n;if(i!=s){var p=a[c];l=r?r(p,c,a):void 0,l===void 0&&(l=Ff(p)?p:Ez(t[i+1])?[]:{})}Sz(a,c,l),a=a[c]}return e}function vz(e){if(typeof e=="string")return e;if(Fg(e))return LE?LE.call(e):"";var t=e+"";return t=="0"&&1/e==-FE?"-0":t}function Iz(e){return qE(e)?e:Az(e)}function zf(e,t){var n=e.__data__;return Mz(t)?n[typeof t=="string"?"string":"hash"]:n.map}function HE(e,t){var n=XK(e,t);return xz(n)?n:void 0}function Ez(e,t){return t=t??jK,!!t&&(typeof e=="number"||QK.test(e))&&e>-1&&e%1==0&&e<t}function wz(e,t){if(qE(e))return!1;var n=typeof e;return n=="number"||n=="symbol"||n=="boolean"||e==null||Fg(e)?!0:KK.test(e)||!$K.test(e)||t!=null&&e in Object(t)}function Mz(e){var t=typeof e;return t=="string"||t=="number"||t=="symbol"||t=="boolean"?e!=="__proto__":e===null}function Oz(e){return!!UE&&UE in e}var Az=Bg(function(e){e=kz(e);var t=[];return zK.test(e)&&t.push(""),e.replace(HK,function(n,r,i,o){t.push(i?o.replace(qK,"$1"):r||n)}),t});function Rz(e){if(typeof e=="string"||Fg(e))return e;var t=e+"";return t=="0"&&1/e==-FE?"-0":t}function Pz(e){if(e!=null){try{return KE.call(e)}catch{}try{return e+""}catch{}}return""}function Bg(e,t){if(typeof e!="function"||t&&typeof t!="function")throw new TypeError(_K);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 s=e.apply(this,r);return n.cache=o.set(i,s),s};return n.cache=new(Bg.Cache||js),n}Bg.Cache=js;function GE(e,t){return e===t||e!==e&&t!==t}var qE=Array.isArray;function Cz(e){var t=Ff(e)?zE.call(e):"";return t==LK||t==BK}function Ff(e){var t=typeof e;return!!e&&(t=="object"||t=="function")}function Nz(e){return!!e&&typeof e=="object"}function Fg(e){return typeof e=="symbol"||Nz(e)&&zE.call(e)==FK}function kz(e){return e==null?"":vz(e)}function Dz(e,t,n){return e==null?e:Tz(e,t,n)}VE.exports=Dz});var qf=ee($a=>{"use strict";u();Object.defineProperty($a,"__esModule",{value:!0});$a.get=rH;$a.ancestors=iH;$a.access=oH;$a.accessPath=rw;function rH(e,t,n){if(n.includeTraversalContext){let i=nw(e,t,n);return i[i.length-1]}let r=t.slice();for(;r.length>0;){let i=r.shift(),s=n.getChildren(e,r)[i];if(!s)return;e=s}return e}function iH(e,t,n){return nw(e,t,n).slice(0,-1)}function nw(e,t,n){let r=t.slice(),i=[e];for(;r.length>0;){let o=r.shift(),s=n.includeTraversalContext?iw(i):void 0,c=n.getChildren(e,r,s)[o];if(!c)return i;e=c,i.push(e)}return i}function oH(e,t,n){if(n.includeTraversalContext){let i=rw(e,t,n);return i[i.length-1]}let r=t.slice();for(;r.length>0;){let i=r.shift();e=n.getChildren(e,r)[i]}return e}function rw(e,t,n){let r=t.slice(),i=[e];for(;r.length>0;){let o=r.shift(),s=n.includeTraversalContext?iw(i):void 0;e=n.getChildren(e,r,s)[o],i.push(e)}return i}function iw(e){return{getRoot:()=>e[0],getParent:()=>e[e.length-2],getAncestors:()=>e.slice(0,-1)}}});var Qf=ee(Vf=>{"use strict";u();Object.defineProperty(Vf,"__esModule",{value:!0});Vf.comparePathsByComponent=ow;Vf.sortPaths=sH;function ow(e,t){for(let n=0;n<Math.min(e.length,t.length);n++){if(e[n]<t[n])return-1;if(e[n]>t[n])return 1}return e.length-t.length}function sH(e){return[...e].sort(ow)}});var Yf=ee(Gg=>{"use strict";u();Object.defineProperty(Gg,"__esModule",{value:!0});Gg.ancestorPaths=cH;var aH=Qf();function cH(e,t){var n;let r=new Map,i=(n=t?.compare)!==null&&n!==void 0?n:aH.comparePathsByComponent,o=e.sort(i);for(let s of o)s.some((c,l)=>{let p=s.slice(0,l).join();return r.has(p)})||r.set(s.join(),s);return Array.from(r.values())}});var cw=ee(Vg=>{"use strict";u();Object.defineProperty(Vg,"__esModule",{value:!0});Vg.boxDiagram=fH;var Nt;(function(e){e.TopLeft="\u250C",e.TopRight="\u2510",e.BottomLeft="\u2514",e.BottomRight="\u2518",e.Horizontal="\u2500",e.Vertical="\u2502",e.BottomConnectorDown="\u252C",e.BottomConnectorUp="\u2534",e.TopConnectorUp="\u2534"})(Nt||(Nt={}));function uH(e){let t=e.split(`
2
- `),n=Math.max(...t.map(a=>a.length)),r=1,i=n+r*2+2,o=2+t.length,s=[[Nt.TopLeft,Nt.Horizontal.repeat(n+r*2),Nt.TopRight],...t.map(a=>[Nt.Vertical," ".repeat(r),a+(a.length<n?" ".repeat(n-a.length):"")," ".repeat(r),Nt.Vertical]),[Nt.BottomLeft,Nt.Horizontal.repeat(n+r*2),Nt.BottomRight]];return{width:i,height:o,contents:s.map(a=>a.join(""))}}function lH(e){if(e.length===0)throw new Error("Can't merge empty array of boxes");return e.slice(1).reduce((n,r)=>{let i=Math.max(n.height,r.height),o=n.width+1+r.width,s=[];for(let a=0;a<i;a++)s.push((n.contents[a]||" ".repeat(n.width))+" ".repeat(1)+(r.contents[a]||" ".repeat(r.width)));return{height:i,width:o,contents:aw(s,o)}},e[0])}function pH(e){if(e.length===0)throw new Error("Can't merge empty array of boxes");let n=Math.max(...e.map(r=>r.width));return e.slice(1).reduce((r,i)=>{let o=r.height+1+i.height,s=[];for(let a=0;a<o;a++)a<r.height?s.push(r.contents[a]):a===r.height?s.push(" ".repeat(n)):s.push(i.contents[a-r.height-1]);return{height:o,width:n,contents:aw(s,n)}},e[0])}function sw(e,t,n){let r=n.getLabel(e,t),i=uH(r),o=n.getChildren(e,t);if(o.length===0)return i;let s=o.map((m,y)=>{let S=sw(m,[...t,y],n);return S.contents[0]=qg(S.contents[0],Jf(S.contents[0].length),Nt.TopConnectorUp),S}),a=pH([i,lH(s)]),c=a.contents,l=Jf(a.width);c[i.height-1]=qg(c[i.height-1],l,Nt.BottomConnectorDown);let p=c[i.height+1].indexOf(Nt.TopConnectorUp),d=c[i.height+1].lastIndexOf(Nt.TopConnectorUp);for(let m=p;m<=d;m++){let y;m===l?y=s.length>1?Nt.BottomConnectorUp:Nt.Vertical:m===p?y=Nt.TopLeft:m===d?y=Nt.TopRight:y=Nt.Horizontal,a.contents[i.height]=qg(a.contents[i.height],m,y)}return a}function fH(e,t){return sw(e,[],t).contents.join(`
3
- `)}function Jf(e){return Math.floor(e/2)}function dH(e,t){let n=t-e.length;if(n<=0)return e;let r=Jf(n),i=Jf(n),o=" ".repeat(r)+e+" ".repeat(i);return r+i+o.length<t?o+" ":o}function aw(e,t){return e.map(n=>dH(n,t))}function qg(e,t,n){return t>e.length-1?e:e.substring(0,t)+n+e.substring(t+1)}});var lw=ee(al=>{"use strict";u();Object.defineProperty(al,"__esModule",{value:!0});al.directoryDiagram=mH;al.isMultiline=Yg;al.prefixBlock=uw;var ui;(function(e){e.Child="\u251C\u2500\u2500 ",e.LastChild="\u2514\u2500\u2500 ",e.NestedChild="\u2502 ",e.LastNestedChild=" "})(ui||(ui={}));function Qg(e,t,n){let r=n.getLabel(e,t),i=t.length,o={label:r,depth:i,prefix:"",multilinePrefix:""},s=n.getChildren(e,t);if(s.length===0)return[o];if(n.flattenSingleChildNodes&&s.length===1&&!Yg(r)){let[c]=Qg(s[0],[...t,0],n),l=t.length===0&&r==="";return o.label=l?`/ ${c.label}`:`${o.label} / ${c.label}`,[o]}let a=s.flatMap((c,l,p)=>{let d=l===p.length-1,m=Qg(c,[...t,l],n),y=d?ui.LastChild:ui.Child,S=d?ui.LastNestedChild:ui.NestedChild;return m.forEach(T=>{T.depth===i+1?(T.prefix=y+T.prefix,T.multilinePrefix=S+T.multilinePrefix):d?(T.prefix=ui.LastNestedChild+T.prefix,T.multilinePrefix=ui.LastNestedChild+T.multilinePrefix):(T.prefix=ui.NestedChild+T.prefix,T.multilinePrefix=ui.NestedChild+T.multilinePrefix)}),m});return[o,...a]}function mH(e,t){return Qg(e,[],t).map(i=>uw(i.label,i.prefix,i.multilinePrefix)).join(`
4
- `)}function Yg(e){return e.includes(`
5
- `)}function uw(e,t,n){return Yg(e)?e.split(`
1
+ "use strict";var kk=Object.create;var yf=Object.defineProperty;var Dk=Object.getOwnPropertyDescriptor;var Uk=Object.getOwnPropertyNames;var _k=Object.getPrototypeOf,jk=Object.prototype.hasOwnProperty;var Lk=(e,t)=>()=>(e&&(t=e(e=0)),t);var ee=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),Ci=(e,t)=>{for(var n in t)yf(e,n,{get:t[n],enumerable:!0})},xI=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of Uk(t))!jk.call(e,i)&&i!==n&&yf(e,i,{get:()=>t[i],enumerable:!(r=Dk(t,i))||r.enumerable});return e};var Q=(e,t,n)=>(n=e!=null?kk(_k(e)):{},xI(t||!e||!e.__esModule?yf(n,"default",{value:e,enumerable:!0}):n,e)),Bk=e=>xI(yf({},"__esModule",{value:!0}),e);var u=Lk(()=>{"use strict"});var DE=ee((Zde,kE)=>{"use strict";u();var F$="Expected a function",wE="__lodash_hash_undefined__",ME=1/0,$$="[object Function]",K$="[object GeneratorFunction]",z$="[object Symbol]",H$=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,G$=/^\w*$/,q$=/^\./,V$=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,Q$=/[\\^$.*+?()[\]{}|]/g,Y$=/\\(\\)?/g,J$=/^\[object .+?Constructor\]$/,X$=typeof global=="object"&&global&&global.Object===Object&&global,Z$=typeof self=="object"&&self&&self.Object===Object&&self,Dg=X$||Z$||Function("return this")();function W$(e,t){return e?.[t]}function eK(e){var t=!1;if(e!=null&&typeof e.toString!="function")try{t=!!(e+"")}catch{}return t}var tK=Array.prototype,nK=Function.prototype,OE=Object.prototype,kg=Dg["__core-js_shared__"],TE=function(){var e=/[^.]+$/.exec(kg&&kg.keys&&kg.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""}(),AE=nK.toString,Ug=OE.hasOwnProperty,RE=OE.toString,rK=RegExp("^"+AE.call(Ug).replace(Q$,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),vE=Dg.Symbol,iK=tK.splice,oK=PE(Dg,"Map"),rl=PE(Object,"create"),IE=vE?vE.prototype:void 0,EE=IE?IE.toString:void 0;function Ds(e){var t=-1,n=e?e.length:0;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}function sK(){this.__data__=rl?rl(null):{}}function aK(e){return this.has(e)&&delete this.__data__[e]}function cK(e){var t=this.__data__;if(rl){var n=t[e];return n===wE?void 0:n}return Ug.call(t,e)?t[e]:void 0}function uK(e){var t=this.__data__;return rl?t[e]!==void 0:Ug.call(t,e)}function lK(e,t){var n=this.__data__;return n[e]=rl&&t===void 0?wE:t,this}Ds.prototype.clear=sK;Ds.prototype.delete=aK;Ds.prototype.get=cK;Ds.prototype.has=uK;Ds.prototype.set=lK;function ja(e){var t=-1,n=e?e.length:0;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}function pK(){this.__data__=[]}function fK(e){var t=this.__data__,n=Lf(t,e);if(n<0)return!1;var r=t.length-1;return n==r?t.pop():iK.call(t,n,1),!0}function dK(e){var t=this.__data__,n=Lf(t,e);return n<0?void 0:t[n][1]}function mK(e){return Lf(this.__data__,e)>-1}function hK(e,t){var n=this.__data__,r=Lf(n,e);return r<0?n.push([e,t]):n[r][1]=t,this}ja.prototype.clear=pK;ja.prototype.delete=fK;ja.prototype.get=dK;ja.prototype.has=mK;ja.prototype.set=hK;function Us(e){var t=-1,n=e?e.length:0;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}function yK(){this.__data__={hash:new Ds,map:new(oK||ja),string:new Ds}}function gK(e){return Bf(this,e).delete(e)}function bK(e){return Bf(this,e).get(e)}function SK(e){return Bf(this,e).has(e)}function xK(e,t){return Bf(this,e).set(e,t),this}Us.prototype.clear=yK;Us.prototype.delete=gK;Us.prototype.get=bK;Us.prototype.has=SK;Us.prototype.set=xK;function Lf(e,t){for(var n=e.length;n--;)if(CK(e[n][0],t))return n;return-1}function TK(e,t){t=wK(t,e)?[t]:EK(t);for(var n=0,r=t.length;e!=null&&n<r;)e=e[RK(t[n++])];return n&&n==r?e:void 0}function vK(e){if(!NE(e)||OK(e))return!1;var t=NK(e)||eK(e)?rK:J$;return t.test(PK(e))}function IK(e){if(typeof e=="string")return e;if(jg(e))return EE?EE.call(e):"";var t=e+"";return t=="0"&&1/e==-ME?"-0":t}function EK(e){return CE(e)?e:AK(e)}function Bf(e,t){var n=e.__data__;return MK(t)?n[typeof t=="string"?"string":"hash"]:n.map}function PE(e,t){var n=W$(e,t);return vK(n)?n:void 0}function wK(e,t){if(CE(e))return!1;var n=typeof e;return n=="number"||n=="symbol"||n=="boolean"||e==null||jg(e)?!0:G$.test(e)||!H$.test(e)||t!=null&&e in Object(t)}function MK(e){var t=typeof e;return t=="string"||t=="number"||t=="symbol"||t=="boolean"?e!=="__proto__":e===null}function OK(e){return!!TE&&TE in e}var AK=_g(function(e){e=DK(e);var t=[];return q$.test(e)&&t.push(""),e.replace(V$,function(n,r,i,o){t.push(i?o.replace(Y$,"$1"):r||n)}),t});function RK(e){if(typeof e=="string"||jg(e))return e;var t=e+"";return t=="0"&&1/e==-ME?"-0":t}function PK(e){if(e!=null){try{return AE.call(e)}catch{}try{return e+""}catch{}}return""}function _g(e,t){if(typeof e!="function"||t&&typeof t!="function")throw new TypeError(F$);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 s=e.apply(this,r);return n.cache=o.set(i,s),s};return n.cache=new(_g.Cache||Us),n}_g.Cache=Us;function CK(e,t){return e===t||e!==e&&t!==t}var CE=Array.isArray;function NK(e){var t=NE(e)?RE.call(e):"";return t==$$||t==K$}function NE(e){var t=typeof e;return!!e&&(t=="object"||t=="function")}function kK(e){return!!e&&typeof e=="object"}function jg(e){return typeof e=="symbol"||kK(e)&&RE.call(e)==z$}function DK(e){return e==null?"":IK(e)}function UK(e,t,n){var r=e==null?void 0:TK(e,t);return r===void 0?n:r}kE.exports=UK});var QE=ee((eme,VE)=>{"use strict";u();var _K="Expected a function",BE="__lodash_hash_undefined__",FE=1/0,jK=9007199254740991,LK="[object Function]",BK="[object GeneratorFunction]",FK="[object Symbol]",$K=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,KK=/^\w*$/,zK=/^\./,HK=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,GK=/[\\^$.*+?()[\]{}|]/g,qK=/\\(\\)?/g,VK=/^\[object .+?Constructor\]$/,QK=/^(?:0|[1-9]\d*)$/,YK=typeof global=="object"&&global&&global.Object===Object&&global,JK=typeof self=="object"&&self&&self.Object===Object&&self,Bg=YK||JK||Function("return this")();function XK(e,t){return e?.[t]}function ZK(e){var t=!1;if(e!=null&&typeof e.toString!="function")try{t=!!(e+"")}catch{}return t}var WK=Array.prototype,ez=Function.prototype,$E=Object.prototype,Lg=Bg["__core-js_shared__"],UE=function(){var e=/[^.]+$/.exec(Lg&&Lg.keys&&Lg.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""}(),KE=ez.toString,$f=$E.hasOwnProperty,zE=$E.toString,tz=RegExp("^"+KE.call($f).replace(GK,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),_E=Bg.Symbol,nz=WK.splice,rz=HE(Bg,"Map"),il=HE(Object,"create"),jE=_E?_E.prototype:void 0,LE=jE?jE.toString:void 0;function _s(e){var t=-1,n=e?e.length:0;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}function iz(){this.__data__=il?il(null):{}}function oz(e){return this.has(e)&&delete this.__data__[e]}function sz(e){var t=this.__data__;if(il){var n=t[e];return n===BE?void 0:n}return $f.call(t,e)?t[e]:void 0}function az(e){var t=this.__data__;return il?t[e]!==void 0:$f.call(t,e)}function cz(e,t){var n=this.__data__;return n[e]=il&&t===void 0?BE:t,this}_s.prototype.clear=iz;_s.prototype.delete=oz;_s.prototype.get=sz;_s.prototype.has=az;_s.prototype.set=cz;function La(e){var t=-1,n=e?e.length:0;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}function uz(){this.__data__=[]}function lz(e){var t=this.__data__,n=Kf(t,e);if(n<0)return!1;var r=t.length-1;return n==r?t.pop():nz.call(t,n,1),!0}function pz(e){var t=this.__data__,n=Kf(t,e);return n<0?void 0:t[n][1]}function fz(e){return Kf(this.__data__,e)>-1}function dz(e,t){var n=this.__data__,r=Kf(n,e);return r<0?n.push([e,t]):n[r][1]=t,this}La.prototype.clear=uz;La.prototype.delete=lz;La.prototype.get=pz;La.prototype.has=fz;La.prototype.set=dz;function js(e){var t=-1,n=e?e.length:0;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}function mz(){this.__data__={hash:new _s,map:new(rz||La),string:new _s}}function hz(e){return zf(this,e).delete(e)}function yz(e){return zf(this,e).get(e)}function gz(e){return zf(this,e).has(e)}function bz(e,t){return zf(this,e).set(e,t),this}js.prototype.clear=mz;js.prototype.delete=hz;js.prototype.get=yz;js.prototype.has=gz;js.prototype.set=bz;function Sz(e,t,n){var r=e[t];(!($f.call(e,t)&&GE(r,n))||n===void 0&&!(t in e))&&(e[t]=n)}function Kf(e,t){for(var n=e.length;n--;)if(GE(e[n][0],t))return n;return-1}function xz(e){if(!Ff(e)||Oz(e))return!1;var t=Cz(e)||ZK(e)?tz:VK;return t.test(Pz(e))}function Tz(e,t,n,r){if(!Ff(e))return e;t=wz(t,e)?[t]:Iz(t);for(var i=-1,o=t.length,s=o-1,a=e;a!=null&&++i<o;){var c=Rz(t[i]),l=n;if(i!=s){var p=a[c];l=r?r(p,c,a):void 0,l===void 0&&(l=Ff(p)?p:Ez(t[i+1])?[]:{})}Sz(a,c,l),a=a[c]}return e}function vz(e){if(typeof e=="string")return e;if($g(e))return LE?LE.call(e):"";var t=e+"";return t=="0"&&1/e==-FE?"-0":t}function Iz(e){return qE(e)?e:Az(e)}function zf(e,t){var n=e.__data__;return Mz(t)?n[typeof t=="string"?"string":"hash"]:n.map}function HE(e,t){var n=XK(e,t);return xz(n)?n:void 0}function Ez(e,t){return t=t??jK,!!t&&(typeof e=="number"||QK.test(e))&&e>-1&&e%1==0&&e<t}function wz(e,t){if(qE(e))return!1;var n=typeof e;return n=="number"||n=="symbol"||n=="boolean"||e==null||$g(e)?!0:KK.test(e)||!$K.test(e)||t!=null&&e in Object(t)}function Mz(e){var t=typeof e;return t=="string"||t=="number"||t=="symbol"||t=="boolean"?e!=="__proto__":e===null}function Oz(e){return!!UE&&UE in e}var Az=Fg(function(e){e=kz(e);var t=[];return zK.test(e)&&t.push(""),e.replace(HK,function(n,r,i,o){t.push(i?o.replace(qK,"$1"):r||n)}),t});function Rz(e){if(typeof e=="string"||$g(e))return e;var t=e+"";return t=="0"&&1/e==-FE?"-0":t}function Pz(e){if(e!=null){try{return KE.call(e)}catch{}try{return e+""}catch{}}return""}function Fg(e,t){if(typeof e!="function"||t&&typeof t!="function")throw new TypeError(_K);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 s=e.apply(this,r);return n.cache=o.set(i,s),s};return n.cache=new(Fg.Cache||js),n}Fg.Cache=js;function GE(e,t){return e===t||e!==e&&t!==t}var qE=Array.isArray;function Cz(e){var t=Ff(e)?zE.call(e):"";return t==LK||t==BK}function Ff(e){var t=typeof e;return!!e&&(t=="object"||t=="function")}function Nz(e){return!!e&&typeof e=="object"}function $g(e){return typeof e=="symbol"||Nz(e)&&zE.call(e)==FK}function kz(e){return e==null?"":vz(e)}function Dz(e,t,n){return e==null?e:Tz(e,t,n)}VE.exports=Dz});var qf=ee($a=>{"use strict";u();Object.defineProperty($a,"__esModule",{value:!0});$a.get=rH;$a.ancestors=iH;$a.access=oH;$a.accessPath=rw;function rH(e,t,n){if(n.includeTraversalContext){let i=nw(e,t,n);return i[i.length-1]}let r=t.slice();for(;r.length>0;){let i=r.shift(),s=n.getChildren(e,r)[i];if(!s)return;e=s}return e}function iH(e,t,n){return nw(e,t,n).slice(0,-1)}function nw(e,t,n){let r=t.slice(),i=[e];for(;r.length>0;){let o=r.shift(),s=n.includeTraversalContext?iw(i):void 0,c=n.getChildren(e,r,s)[o];if(!c)return i;e=c,i.push(e)}return i}function oH(e,t,n){if(n.includeTraversalContext){let i=rw(e,t,n);return i[i.length-1]}let r=t.slice();for(;r.length>0;){let i=r.shift();e=n.getChildren(e,r)[i]}return e}function rw(e,t,n){let r=t.slice(),i=[e];for(;r.length>0;){let o=r.shift(),s=n.includeTraversalContext?iw(i):void 0;e=n.getChildren(e,r,s)[o],i.push(e)}return i}function iw(e){return{getRoot:()=>e[0],getParent:()=>e[e.length-2],getAncestors:()=>e.slice(0,-1)}}});var Qf=ee(Vf=>{"use strict";u();Object.defineProperty(Vf,"__esModule",{value:!0});Vf.comparePathsByComponent=ow;Vf.sortPaths=sH;function ow(e,t){for(let n=0;n<Math.min(e.length,t.length);n++){if(e[n]<t[n])return-1;if(e[n]>t[n])return 1}return e.length-t.length}function sH(e){return[...e].sort(ow)}});var Yf=ee(qg=>{"use strict";u();Object.defineProperty(qg,"__esModule",{value:!0});qg.ancestorPaths=cH;var aH=Qf();function cH(e,t){var n;let r=new Map,i=(n=t?.compare)!==null&&n!==void 0?n:aH.comparePathsByComponent,o=e.sort(i);for(let s of o)s.some((c,l)=>{let p=s.slice(0,l).join();return r.has(p)})||r.set(s.join(),s);return Array.from(r.values())}});var cw=ee(Qg=>{"use strict";u();Object.defineProperty(Qg,"__esModule",{value:!0});Qg.boxDiagram=fH;var Nt;(function(e){e.TopLeft="\u250C",e.TopRight="\u2510",e.BottomLeft="\u2514",e.BottomRight="\u2518",e.Horizontal="\u2500",e.Vertical="\u2502",e.BottomConnectorDown="\u252C",e.BottomConnectorUp="\u2534",e.TopConnectorUp="\u2534"})(Nt||(Nt={}));function uH(e){let t=e.split(`
2
+ `),n=Math.max(...t.map(a=>a.length)),r=1,i=n+r*2+2,o=2+t.length,s=[[Nt.TopLeft,Nt.Horizontal.repeat(n+r*2),Nt.TopRight],...t.map(a=>[Nt.Vertical," ".repeat(r),a+(a.length<n?" ".repeat(n-a.length):"")," ".repeat(r),Nt.Vertical]),[Nt.BottomLeft,Nt.Horizontal.repeat(n+r*2),Nt.BottomRight]];return{width:i,height:o,contents:s.map(a=>a.join(""))}}function lH(e){if(e.length===0)throw new Error("Can't merge empty array of boxes");return e.slice(1).reduce((n,r)=>{let i=Math.max(n.height,r.height),o=n.width+1+r.width,s=[];for(let a=0;a<i;a++)s.push((n.contents[a]||" ".repeat(n.width))+" ".repeat(1)+(r.contents[a]||" ".repeat(r.width)));return{height:i,width:o,contents:aw(s,o)}},e[0])}function pH(e){if(e.length===0)throw new Error("Can't merge empty array of boxes");let n=Math.max(...e.map(r=>r.width));return e.slice(1).reduce((r,i)=>{let o=r.height+1+i.height,s=[];for(let a=0;a<o;a++)a<r.height?s.push(r.contents[a]):a===r.height?s.push(" ".repeat(n)):s.push(i.contents[a-r.height-1]);return{height:o,width:n,contents:aw(s,n)}},e[0])}function sw(e,t,n){let r=n.getLabel(e,t),i=uH(r),o=n.getChildren(e,t);if(o.length===0)return i;let s=o.map((m,y)=>{let S=sw(m,[...t,y],n);return S.contents[0]=Vg(S.contents[0],Jf(S.contents[0].length),Nt.TopConnectorUp),S}),a=pH([i,lH(s)]),c=a.contents,l=Jf(a.width);c[i.height-1]=Vg(c[i.height-1],l,Nt.BottomConnectorDown);let p=c[i.height+1].indexOf(Nt.TopConnectorUp),d=c[i.height+1].lastIndexOf(Nt.TopConnectorUp);for(let m=p;m<=d;m++){let y;m===l?y=s.length>1?Nt.BottomConnectorUp:Nt.Vertical:m===p?y=Nt.TopLeft:m===d?y=Nt.TopRight:y=Nt.Horizontal,a.contents[i.height]=Vg(a.contents[i.height],m,y)}return a}function fH(e,t){return sw(e,[],t).contents.join(`
3
+ `)}function Jf(e){return Math.floor(e/2)}function dH(e,t){let n=t-e.length;if(n<=0)return e;let r=Jf(n),i=Jf(n),o=" ".repeat(r)+e+" ".repeat(i);return r+i+o.length<t?o+" ":o}function aw(e,t){return e.map(n=>dH(n,t))}function Vg(e,t,n){return t>e.length-1?e:e.substring(0,t)+n+e.substring(t+1)}});var lw=ee(al=>{"use strict";u();Object.defineProperty(al,"__esModule",{value:!0});al.directoryDiagram=mH;al.isMultiline=Jg;al.prefixBlock=uw;var ui;(function(e){e.Child="\u251C\u2500\u2500 ",e.LastChild="\u2514\u2500\u2500 ",e.NestedChild="\u2502 ",e.LastNestedChild=" "})(ui||(ui={}));function Yg(e,t,n){let r=n.getLabel(e,t),i=t.length,o={label:r,depth:i,prefix:"",multilinePrefix:""},s=n.getChildren(e,t);if(s.length===0)return[o];if(n.flattenSingleChildNodes&&s.length===1&&!Jg(r)){let[c]=Yg(s[0],[...t,0],n),l=t.length===0&&r==="";return o.label=l?`/ ${c.label}`:`${o.label} / ${c.label}`,[o]}let a=s.flatMap((c,l,p)=>{let d=l===p.length-1,m=Yg(c,[...t,l],n),y=d?ui.LastChild:ui.Child,S=d?ui.LastNestedChild:ui.NestedChild;return m.forEach(T=>{T.depth===i+1?(T.prefix=y+T.prefix,T.multilinePrefix=S+T.multilinePrefix):d?(T.prefix=ui.LastNestedChild+T.prefix,T.multilinePrefix=ui.LastNestedChild+T.multilinePrefix):(T.prefix=ui.NestedChild+T.prefix,T.multilinePrefix=ui.NestedChild+T.multilinePrefix)}),m});return[o,...a]}function mH(e,t){return Yg(e,[],t).map(i=>uw(i.label,i.prefix,i.multilinePrefix)).join(`
4
+ `)}function Jg(e){return e.includes(`
5
+ `)}function uw(e,t,n){return Jg(e)?e.split(`
6
6
  `).map((r,i)=>(i===0?t:n)+r).join(`
7
- `):t+e}});var Xg=ee(Jg=>{"use strict";u();Object.defineProperty(Jg,"__esModule",{value:!0});Jg.diagram=gH;var hH=cw(),yH=lw();function gH(e,t){return t.type==="box"?(0,hH.boxDiagram)(e,t):(0,yH.directoryDiagram)(e,t)}});var Bs=ee(li=>{"use strict";u();Object.defineProperty(li,"__esModule",{value:!0});li.STOP=li.SKIP=void 0;li.visit=bH;li.SKIP="skip";li.STOP="stop";function bH(e,t){let{onEnter:n,onLeave:r,getChildren:i,onDetectCycle:o,getIdentifier:s,direction:a="forward"}=t,c=(S,T,E)=>{let b=i(S,T,E);return a==="forward"?b:b.slice().reverse()},l=[],p=[{node:e}],d=o?new Set:void 0,m=t.includeTraversalContext?{getRoot(){return e},getParent(){var S;return(S=p[p.length-2])===null||S===void 0?void 0:S.node},getAncestors(){return p.slice(0,-1).map(S=>S.node)}}:void 0,y=t.reuseIndexPath?()=>l:()=>l.slice();for(;p.length>0;){let S=p[p.length-1];if(S.state===void 0){if(d){let b=s?s(S.node):S.node;if(d.has(b)){if((typeof o=="function"?o(S.node,y(),m):o)==="error")throw new Error("Cycle detected in tree");S.state=-1;continue}d.add(b)}let E=n?.(S.node,y());if(E===li.STOP)return;S.state=E===li.SKIP?-1:0}let T=S.children||c(S.node,y(),m);if(S.children||(S.children=T),S.state!==-1){if(S.state<T.length){let b=S.state;l.push(a==="forward"?b:T.length-b-1),p.push({node:T[b]}),S.state=b+1;continue}if(r?.(S.node,y())===li.STOP)return}if(d){let E=s?s(S.node):S.node;d.delete(E)}l.pop(),p.pop()}}});var Wg=ee(Zg=>{"use strict";u();Object.defineProperty(Zg,"__esModule",{value:!0});Zg.entries=xH;var SH=Bs();function xH(e,t){let n=[];return(0,SH.visit)(e,Object.assign(Object.assign({},t),{onEnter:(r,i)=>{n.push([i,r])}})),n}});var eb=ee(za=>{"use strict";u();Object.defineProperty(za,"__esModule",{value:!0});za.find=TH;za.findAll=vH;za.findPath=IH;za.findAllPaths=EH;var Ka=Bs();function TH(e,t){let n;return(0,Ka.visit)(e,Object.assign(Object.assign({},t),{onEnter:(r,i)=>{if(t.predicate(r,i))return n=r,Ka.STOP}})),n}function vH(e,t){let n=[];return(0,Ka.visit)(e,{onEnter:(r,i)=>{t.predicate(r,i)&&n.push(r)},getChildren:t.getChildren}),n}function IH(e,t){let n;return(0,Ka.visit)(e,{onEnter:(r,i)=>{if(t.predicate(r,i))return n=[...i],Ka.STOP},getChildren:t.getChildren}),n}function EH(e,t){let n=[];return(0,Ka.visit)(e,{onEnter:(r,i)=>{t.predicate(r,i)&&n.push([...i])},getChildren:t.getChildren}),n}});var Xf=ee(tb=>{"use strict";u();Object.defineProperty(tb,"__esModule",{value:!0});tb.reduce=MH;var wH=Bs();function MH(e,t){let n=t.initialResult;return(0,wH.visit)(e,Object.assign(Object.assign({},t),{onEnter:(r,i)=>{n=t.nextResult(n,r,i)}})),n}});var rb=ee(nb=>{"use strict";u();Object.defineProperty(nb,"__esModule",{value:!0});nb.flat=AH;var OH=Xf();function AH(e,t){return(0,OH.reduce)(e,Object.assign(Object.assign({},t),{initialResult:[],nextResult:(n,r)=>(n.push(r),n)}))}});var Wf=ee(Zf=>{"use strict";u();Object.defineProperty(Zf,"__esModule",{value:!0});Zf.map=PH;Zf.flatMap=pw;var RH=Bs();function PH(e,t){return pw(e,Object.assign(Object.assign({},t),{transform:(n,r,i)=>[t.transform(n,r,i)]}))}function pw(e,t){let n={};return(0,RH.visit)(e,Object.assign(Object.assign({},t),{onLeave:(r,i)=>{var o,s;let a=[0,...i],c=a.join(),l=t.transform(r,(o=n[c])!==null&&o!==void 0?o:[],i),p=a.slice(0,-1).join(),d=(s=n[p])!==null&&s!==void 0?s:[];d.push(...l),n[p]=d}})),n[""][0]}});var ob=ee(ib=>{"use strict";u();Object.defineProperty(ib,"__esModule",{value:!0});ib.transformPath=kH;var CH=Qf();function NH(e,t){let n=Math.min(e.length,t.length);for(let r=0;r<n;r++)if(e[r]!==t[r])return e.slice(0,r);return e.slice(0,n)}function kH(e,t,n,r=1){if(n.length>e.length||(0,CH.comparePathsByComponent)(n,e)>0)return e;if(n.length===0&&t==="remove")return;let i=NH(e,n),o=i.length===e.length||i.length===n.length?i.length-1:i.length,s=e[o],a=n[o];if(t==="insert"&&a<=s){let c=[...e];return c[o]+=r,c}else if(t==="remove"){if(a===s)return;if(a<s){let c=[...e];return c[o]-=r,c}}return e}});var Ha=ee(Gr=>{"use strict";u();Object.defineProperty(Gr,"__esModule",{value:!0});Gr.insertOperation=dw;Gr.removeOperation=mw;Gr.replaceOperation=ed;Gr.getInsertionOperations=_H;Gr.getRemovalOperations=jH;Gr.getReplaceOperations=LH;Gr.applyOperations=BH;Gr.arraySplice=sb;Gr.transformPathsByOperations=FH;var DH=Yf(),UH=Wf(),fw=ob();function dw(e,t){return{type:"insert",index:e,nodes:t}}function mw(e){return{type:"remove",indexes:e}}function ed(){return{type:"replace"}}function hw(e){return[e.slice(0,-1),e[e.length-1]]}function _H(e,t,n=new Map){var r;let[i,o]=hw(e);for(let a=i.length-1;a>=0;a--){let c=i.slice(0,a).join();switch((r=n.get(c))===null||r===void 0?void 0:r.type){case"remove":continue}n.set(c,ed())}let s=n.get(i.join());switch(s?.type){case"remove":n.set(i.join(),{type:"removeThenInsert",removeIndexes:s.indexes,insertIndex:o,insertNodes:t});break;default:n.set(i.join(),dw(o,t))}return n}function jH(e){var t,n;let r=(0,DH.ancestorPaths)(e),i=new Map;for(let s of r){let a=s.slice(0,-1).join(),c=(t=i.get(a))!==null&&t!==void 0?t:[];c.push(s[s.length-1]),i.set(a,c)}let o=new Map;for(let s of r)for(let a=s.length-1;a>=0;a--){let c=s.slice(0,a).join();o.set(c,ed())}for(let s of r){let a=s.slice(0,-1).join();o.set(a,mw((n=i.get(a))!==null&&n!==void 0?n:[]))}return o}function LH(e,t){let n=new Map,[r,i]=hw(e);for(let o=r.length-1;o>=0;o--){let s=r.slice(0,o).join();n.set(s,ed())}return n.set(r.join(),{type:"removeThenInsert",removeIndexes:[i],insertIndex:i,insertNodes:[t]}),n}function yw(e,t){return t.reduce((n,r)=>r<n?n-1:n,e)}function BH(e,t,n){return(0,UH.map)(e,Object.assign(Object.assign({},n),{getChildren:(r,i)=>{let o=i.join(),s=t.get(o);switch(s?.type){case"replace":case"remove":case"removeThenInsert":case"insert":return n.getChildren(r,i);default:return[]}},transform:(r,i,o)=>{let s=o.join(),a=t.get(s);switch(a?.type){case"remove":return n.create(r,i.filter((p,d)=>!a.indexes.includes(d)),o);case"removeThenInsert":let c=i.filter((p,d)=>!a.removeIndexes.includes(d)),l=yw(a.insertIndex,a.removeIndexes);return n.create(r,sb(c,l,0,...a.insertNodes),o);case"insert":return n.create(r,sb(i,a.index,0,...a.nodes),o);case"replace":return n.create(r,i,o);default:return r}}}))}function sb(e,t,n,...r){return[...e.slice(0,t),...r,...e.slice(t+n)]}function FH(e,t){let n=e;for(let[r,i]of t.entries()){let o=r?r.split(",").map(Number):[];n=ab(n,o,i)}return n}function ab(e,t,n){switch(n.type){case"insert":{let r=t.concat(n.index);return e.map(i=>i?(0,fw.transformPath)(i,"insert",r,n.nodes.length):void 0)}case"remove":{let r=[...n.indexes].reverse().map(i=>t.concat(i));return e.map(i=>{for(let o of r)i=i?(0,fw.transformPath)(i,"remove",o):void 0;return i})}case"removeThenInsert":{let r=ab(e,t,{type:"remove",indexes:n.removeIndexes}),i=yw(n.insertIndex,n.removeIndexes);return ab(r,t,{type:"insert",index:i,nodes:n.insertNodes})}case"replace":return e}}});var ub=ee(td=>{"use strict";u();Object.defineProperty(td,"__esModule",{value:!0});td.insert=$H;td.insertWithPathTracking=KH;var cb=Ha();function $H(e,t){return gw(e,t).node}function KH(e,t){return gw(e,t)}function gw(e,t){let{nodes:n,path:r,track:i}=t;if(r.length===0)throw new Error("Can't insert nodes at the root");let o=(0,cb.getInsertionOperations)(r,n),s=i?(0,cb.transformPathsByOperations)(i,o):[];return{node:(0,cb.applyOperations)(e,o,t),paths:s}}});var fb=ee(pb=>{"use strict";u();Object.defineProperty(pb,"__esModule",{value:!0});pb.move=GH;var zH=qf(),HH=Yf(),lb=Ha();function GH(e,t){if(t.paths.length===0)return e;for(let o of t.paths)if(o.length===0)throw new Error("Can't move the root node");if(t.to.length===0)throw new Error("Can't move nodes to the root");let n=(0,HH.ancestorPaths)(t.paths),r=n.map(o=>(0,zH.access)(e,o,t)),i=(0,lb.getInsertionOperations)(t.to,r,(0,lb.getRemovalOperations)(n));return(0,lb.applyOperations)(e,i,t)}});var mb=ee(nd=>{"use strict";u();Object.defineProperty(nd,"__esModule",{value:!0});nd.remove=qH;nd.removeWithPathTracking=VH;var db=Ha();function qH(e,t){return bw(e,t).node}function VH(e,t){return bw(e,t)}function bw(e,t){let{paths:n,track:r}=t,i=(0,db.getRemovalOperations)(n),o=r?(0,db.transformPathsByOperations)(r,i):[];return{node:(0,db.applyOperations)(e,i,t),paths:o}}});var yb=ee(hb=>{"use strict";u();Object.defineProperty(hb,"__esModule",{value:!0});hb.replace=QH;var Sw=Ha();function QH(e,t){if(t.path.length===0)return t.node;let n=(0,Sw.getReplaceOperations)(t.path,t.node);return(0,Sw.applyOperations)(e,n,t)}});var gb=ee(id=>{"use strict";u();Object.defineProperty(id,"__esModule",{value:!0});id.splice=YH;id.spliceWithPathTracking=JH;var rd=Ha();function YH(e,t){return xw(e,t).node}function JH(e,t){return xw(e,t)}function xw(e,t){let{path:n,deleteCount:r=0,nodes:i,track:o}=t;if(n.length===0)throw new Error("Can't splice at the root");let s=XH(n,r),a=(0,rd.getInsertionOperations)(n,i,(0,rd.getRemovalOperations)(s)),c=o?(0,rd.transformPathsByOperations)(o,a):[];return{node:(0,rd.applyOperations)(e,a,t),paths:c}}function XH(e,t){let n=[],r=e.slice(0,-1),i=e[e.length-1];for(let o=0;o<t;o++)n.push(r.concat(i+o));return n}});var xb=ee(Sb=>{"use strict";u();Object.defineProperty(Sb,"__esModule",{value:!0});Sb.defineTree=r3;var od=qf(),Tw=Xg(),ZH=Wg(),wo=eb(),WH=rb(),vw=ub(),Iw=Wf(),e3=fb(),t3=Xf(),Ew=mb(),n3=yb(),ww=gb(),Mw=Bs(),bb=class e{constructor(t,n){this.appliedOptions=n,this.getChildren=(r,i,o)=>this._getChildren(r,i,o),this.mergeOptions=r=>Object.assign(Object.assign(Object.assign({},this.baseOptions),this.appliedOptions),r),this.withOptions=r=>new e(this.baseOptions,Object.assign(Object.assign({},this.appliedOptions),r)),this.access=(r,i)=>(0,od.access)(r,i,this.mergeOptions({})),this.accessPath=(r,i)=>(0,od.accessPath)(r,i,this.mergeOptions({})),this.get=(r,i)=>(0,od.get)(r,i,this.mergeOptions({})),this.ancestors=(r,i)=>(0,od.ancestors)(r,i,this.mergeOptions({})),this.diagram=(r,i)=>typeof i=="function"?(0,Tw.diagram)(r,this.mergeOptions({getLabel:i})):(0,Tw.diagram)(r,this.mergeOptions(i)),this.find=(r,i)=>typeof i=="function"?(0,wo.find)(r,this.mergeOptions({predicate:i})):(0,wo.find)(r,this.mergeOptions(Object.assign({},i))),this.findAll=(r,i)=>typeof i=="function"?(0,wo.findAll)(r,this.mergeOptions({predicate:i})):(0,wo.findAll)(r,this.mergeOptions(Object.assign({},i))),this.findPath=(r,i)=>typeof i=="function"?(0,wo.findPath)(r,this.mergeOptions({predicate:i})):(0,wo.findPath)(r,this.mergeOptions(Object.assign({},i))),this.findAllPaths=(r,i)=>typeof i=="function"?(0,wo.findAllPaths)(r,this.mergeOptions({predicate:i})):(0,wo.findAllPaths)(r,this.mergeOptions(Object.assign({},i))),this.entries=r=>(0,ZH.entries)(r,this.mergeOptions({})),this.flat=r=>(0,WH.flat)(r,this.mergeOptions({})),this.reduce=(r,i,o)=>(0,t3.reduce)(r,this.mergeOptions({nextResult:i,initialResult:o})),this.map=(r,i)=>(0,Iw.map)(r,this.mergeOptions({transform:i})),this.flatMap=(r,i)=>(0,Iw.flatMap)(r,this.mergeOptions({transform:i})),this.visit=(r,i)=>typeof i=="function"?(0,Mw.visit)(r,this.mergeOptions({onEnter:i})):(0,Mw.visit)(r,this.mergeOptions(Object.assign({},i))),this.insert=(r,i)=>(0,vw.insert)(r,this.mergeOptions(i)),this.insertWithPathTracking=(r,i)=>(0,vw.insertWithPathTracking)(r,this.mergeOptions(i)),this.remove=(r,i)=>(0,Ew.remove)(r,this.mergeOptions(i)),this.removeWithPathTracking=(r,i)=>(0,Ew.removeWithPathTracking)(r,this.mergeOptions(i)),this.move=(r,i)=>(0,e3.move)(r,this.mergeOptions(i)),this.splice=(r,i)=>(0,ww.splice)(r,this.mergeOptions(i)),this.spliceWithPathTracking=(r,i)=>(0,ww.spliceWithPathTracking)(r,this.mergeOptions(i)),this.replace=(r,i)=>(0,n3.replace)(r,this.mergeOptions(i)),this.baseOptions=typeof t=="function"?{getChildren:t}:t,this._getChildren=this.baseOptions.getChildren}};function r3(e){return new bb(e,{})}});var Aw=ee(Ow=>{"use strict";u();Object.defineProperty(Ow,"__esModule",{value:!0})});var Pw=ee(Rw=>{"use strict";u();Object.defineProperty(Rw,"__esModule",{value:!0})});var Cw=ee(sd=>{"use strict";u();Object.defineProperty(sd,"__esModule",{value:!0});sd.withOptions=void 0;var i3=xb();sd.withOptions=i3.defineTree});var ad=ee(Ye=>{"use strict";u();var o3=Ye&&Ye.__createBinding||(Object.create?function(e,t,n,r){r===void 0&&(r=n);var i=Object.getOwnPropertyDescriptor(t,n);(!i||("get"in i?!t.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,i)}:function(e,t,n,r){r===void 0&&(r=n),e[r]=t[n]}),It=Ye&&Ye.__exportStar||function(e,t){for(var n in e)n!=="default"&&!Object.prototype.hasOwnProperty.call(t,n)&&o3(t,e,n)};Object.defineProperty(Ye,"__esModule",{value:!0});It(qf(),Ye);It(Yf(),Ye);It(xb(),Ye);It(Xg(),Ye);It(Wg(),Ye);It(eb(),Ye);It(rb(),Ye);It(Aw(),Ye);It(ub(),Ye);It(Wf(),Ye);It(fb(),Ye);It(Pw(),Ye);It(Xf(),Ye);It(mb(),Ye);It(yb(),Ye);It(Qf(),Ye);It(gb(),Ye);It(ob(),Ye);It(Bs(),Ye);It(Cw(),Ye)});var Bw=ee(Lw=>{"use strict";u();Object.defineProperty(Lw,"__esModule",{value:!0})});var cl=ee(cd=>{"use strict";u();Object.defineProperty(cd,"__esModule",{value:!0});cd.Nodes=void 0;function p3(e,t){return{type:"file",data:e,metadata:t}}function f3(e={},t){return{type:"directory",children:e,metadata:t}}function d3(e){return e.type==="file"}function m3(e){return e.type==="directory"}function h3(e){return e.metadata}function y3(e){return Object.keys(e.children)}function g3(e,t){return e.children[t]}function b3(e,t){return t in e.children}cd.Nodes={createDirectory:f3,createFile:p3,getChild:g3,getMetadata:h3,hasChild:b3,isDirectory:m3,isFile:d3,readDirectory:y3}});var ul=ee(Et=>{"use strict";u();Object.defineProperty(Et,"__esModule",{value:!0});Et.dirname=Et.basename=Et.extname=Et.join=Et.normalize=Et.sep=void 0;Et.sep="/";function S3(e,t){return e.startsWith("/")&&(t="/"+t),t[t.length-1]!=="/"&&e.endsWith("/")&&(t=t+"/"),t}function Fw(e){let t=e.split(Et.sep).filter(i=>!!i),n=0,r=t.length-1;for(;n<r;)t[n]==="."?(t.splice(n,1),r--):t[n]===".."&&n!==0?(t.splice(n-1,2),r-=2,n-=1):t[n]===""&&t[n+1]===""?(t.splice(n,1),r--):n++;return S3(e,t.join(Et.sep))}Et.normalize=Fw;function x3(...e){let t=Fw(e.join(Et.sep));return t===""&&(t="."),t}Et.join=x3;function T3(e){let t=e.lastIndexOf(".");return t!==-1?e.slice(t):e}Et.extname=T3;function Tb(e,t){t&&e.endsWith(t)&&(e=e.slice(0,-t.length));let n=e.lastIndexOf(Et.sep);return n===e.length-1?(e=e.slice(0,-1),e.length>1?Tb(e):e):e.slice(n+1)}Et.basename=Tb;function v3(e){let t=Tb(e),n=e.slice(0,-(t.length+1));return n===""&&(e.startsWith(Et.sep)?n=Et.sep:n="."),n}Et.dirname=v3});var $w=ee(ud=>{"use strict";u();Object.defineProperty(ud,"__esModule",{value:!0});ud.Entries=void 0;var I3=cl(),E3=ul();function w3(e){let[t,n]=e;return I3.Nodes.isDirectory(n)?Object.entries(n.children).map(([r,i])=>[(0,E3.join)(t,r),i]):[]}function M3(e,t){return[e,t]}ud.Entries={createEntry:M3,getEntries:w3}});var pd=ee(Mo=>{"use strict";u();Object.defineProperty(Mo,"__esModule",{value:!0});Mo.getNewAndParentName=Mo.normalizePathLikeInternal=Mo.getPathComponents=void 0;var ld=ul();function Kw(e){return t((0,ld.normalize)(e));function t(n){if(n.startsWith(".."))throw new Error(`Invalid path ${n}, can't go up past root.`);return n.startsWith(".")||n.startsWith("/")?t(n.slice(1)):n===""?[]:n.split(ld.sep).filter(r=>!!r)}}Mo.getPathComponents=Kw;function O3(e){return typeof e=="string"?Kw(e):e}Mo.normalizePathLikeInternal=O3;function A3(e){let t=typeof e=="string"?(0,ld.dirname)(e):e.slice(0,-1),n=typeof e=="string"?(0,ld.basename)(e):e[e.length-1];return{parentName:t,newName:n}}Mo.getNewAndParentName=A3});var vb=ee(wr=>{"use strict";u();Object.defineProperty(wr,"__esModule",{value:!0});wr.getMetadata=wr.readDirectory=wr.readFile=wr.getNode=wr.getNodeInternal=void 0;var qa=cl(),ll=ul(),fd=pd();function zw(e,t,n){let r=(0,fd.normalizePathLikeInternal)(t),i=0,o=e;for(;i<r.length;){let s=r[i];if(o.type!=="directory")throw new Error(`File ${(0,ll.join)(...r.slice(0,i))} is not a directory`);let a=qa.Nodes.getChild(o,s);if(!a)if(n.makeIntermediateDirectoryMetadata){let c=qa.Nodes.createDirectory({},n.makeIntermediateDirectoryMetadata((0,ll.join)(...r.slice(0,i+1))));o.children[s]=c,a=c}else if(n.makeIntermediateDirectories){let c=qa.Nodes.createDirectory();o.children[s]=c,a=c}else throw new Error(`File ${(0,ll.join)(...r.slice(0,i+1))} not found`);o=a,i++}return o}wr.getNodeInternal=zw;function dd(e,t){return zw(e,t,{})}wr.getNode=dd;function R3(e,t){let n=(0,fd.normalizePathLikeInternal)(t),r=dd(e,n);if(!qa.Nodes.isFile(r))throw new Error(`Can't read, ${(0,ll.join)(...n)} not a file`);return r.data}wr.readFile=R3;function P3(e,t){let n=(0,fd.normalizePathLikeInternal)(t),r=dd(e,n);if(!qa.Nodes.isDirectory(r))throw new Error(`Can't read, ${(0,ll.join)(...n)} not a directory`);return qa.Nodes.readDirectory(r)}wr.readDirectory=P3;function C3(e,t){let n=(0,fd.normalizePathLikeInternal)(t);return dd(e,n).metadata}wr.getMetadata=C3});var Gw=ee(Bn=>{"use strict";u();Object.defineProperty(Bn,"__esModule",{value:!0});Bn.create=Bn.setMetadata=Bn.removeFile=Bn.makeDirectory=Bn.writeFile=Bn.setNode=void 0;var Oo=cl(),Ib=pd(),md=vb();function Hw(e,t,n,r){let{parentName:i,newName:o}=(0,Ib.getNewAndParentName)(t),s=(0,md.getNodeInternal)(e,i,r??{});if(!Oo.Nodes.isDirectory(s))throw new Error(`Can't create ${o}, ${i} not a directory`);s.children[o]=n}Bn.setNode=Hw;function N3(e,t,n,r){var i;Hw(e,t,Oo.Nodes.createFile(n,(i=r)===null||i===void 0?void 0:i.metadata),r)}Bn.writeFile=N3;function k3(e,t,n){var r;let{parentName:i,newName:o}=(0,Ib.getNewAndParentName)(t),s=(0,md.getNodeInternal)(e,i,n??{});if(!Oo.Nodes.isDirectory(s))throw new Error(`Can't create ${o}, ${i} not a directory`);Oo.Nodes.getChild(s,o)&&Oo.Nodes.isDirectory(s.children[o])||(s.children[o]=Oo.Nodes.createDirectory({},(r=n)===null||r===void 0?void 0:r.metadata))}Bn.makeDirectory=k3;function D3(e,t){let{parentName:n,newName:r}=(0,Ib.getNewAndParentName)(t),i=(0,md.getNode)(e,n);if(!Oo.Nodes.isDirectory(i))throw new Error(`Can't remove file ${r}, ${n} not a directory`);delete i.children[r]}Bn.removeFile=D3;function U3(e,t,n){let r=(0,md.getNode)(e,t);r.metadata=n}Bn.setMetadata=U3;function _3(e){return Oo.Nodes.createDirectory({},e&&"metadata"in e?e.metadata:void 0)}Bn.create=_3});var qw=ee(yd=>{"use strict";u();Object.defineProperty(yd,"__esModule",{value:!0});yd.Volume=void 0;var j3=pd(),hd=vb(),Va=Gw();yd.Volume={getPathComponents:j3.getPathComponents,getMetadata:hd.getMetadata,getNode:hd.getNode,readDirectory:hd.readDirectory,readFile:hd.readFile,create:Va.create,makeDirectory:Va.makeDirectory,removeFile:Va.removeFile,setMetadata:Va.setMetadata,setNode:Va.setNode,writeFile:Va.writeFile}});var Qw=ee(fn=>{"use strict";u();var Vw=fn&&fn.__createBinding||(Object.create?function(e,t,n,r){r===void 0&&(r=n),Object.defineProperty(e,r,{enumerable:!0,get:function(){return t[n]}})}:function(e,t,n,r){r===void 0&&(r=n),e[r]=t[n]}),L3=fn&&fn.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),gd=fn&&fn.__exportStar||function(e,t){for(var n in e)n!=="default"&&!Object.prototype.hasOwnProperty.call(t,n)&&Vw(t,e,n)},B3=fn&&fn.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var n in e)n!=="default"&&Object.prototype.hasOwnProperty.call(e,n)&&Vw(t,e,n);return L3(t,e),t};Object.defineProperty(fn,"__esModule",{value:!0});fn.path=void 0;gd(Bw(),fn);gd(cl(),fn);gd($w(),fn);gd(qw(),fn);fn.path=B3(ul())});var FM=ee((sIe,BM)=>{"use strict";u();var rr=-1,wn=1,kt=0;function El(e,t,n,r,i){if(e===t)return e?[[kt,e]]:[];if(n!=null){var o=U4(e,t,n);if(o)return o}var s=Qb(e,t),a=e.substring(0,s);e=e.substring(s),t=t.substring(s),s=Nd(e,t);var c=e.substring(e.length-s);e=e.substring(0,e.length-s),t=t.substring(0,t.length-s);var l=O4(e,t);return a&&l.unshift([kt,a]),c&&l.push([kt,c]),Yb(l,i),r&&P4(l),l}function O4(e,t){var n;if(!e)return[[wn,t]];if(!t)return[[rr,e]];var r=e.length>t.length?e:t,i=e.length>t.length?t:e,o=r.indexOf(i);if(o!==-1)return n=[[wn,r.substring(0,o)],[kt,i],[wn,r.substring(o+i.length)]],e.length>t.length&&(n[0][0]=n[2][0]=rr),n;if(i.length===1)return[[rr,e],[wn,t]];var s=R4(e,t);if(s){var a=s[0],c=s[1],l=s[2],p=s[3],d=s[4],m=El(a,l),y=El(c,p);return m.concat([[kt,d]],y)}return A4(e,t)}function A4(e,t){for(var n=e.length,r=t.length,i=Math.ceil((n+r)/2),o=i,s=2*i,a=new Array(s),c=new Array(s),l=0;l<s;l++)a[l]=-1,c[l]=-1;a[o+1]=0,c[o+1]=0;for(var p=n-r,d=p%2!==0,m=0,y=0,S=0,T=0,E=0;E<i;E++){for(var b=-E+m;b<=E-y;b+=2){var f=o+b,g;b===-E||b!==E&&a[f-1]<a[f+1]?g=a[f+1]:g=a[f-1]+1;for(var v=g-b;g<n&&v<r&&e.charAt(g)===t.charAt(v);)g++,v++;if(a[f]=g,g>n)y+=2;else if(v>r)m+=2;else if(d){var I=o+p-b;if(I>=0&&I<s&&c[I]!==-1){var M=n-c[I];if(g>=M)return PM(e,t,g,v)}}}for(var O=-E+S;O<=E-T;O+=2){var I=o+O,M;O===-E||O!==E&&c[I-1]<c[I+1]?M=c[I+1]:M=c[I-1]+1;for(var C=M-O;M<n&&C<r&&e.charAt(n-M-1)===t.charAt(r-C-1);)M++,C++;if(c[I]=M,M>n)T+=2;else if(C>r)S+=2;else if(!d){var f=o+p-O;if(f>=0&&f<s&&a[f]!==-1){var g=a[f],v=o+g-f;if(M=n-M,g>=M)return PM(e,t,g,v)}}}}return[[rr,e],[wn,t]]}function PM(e,t,n,r){var i=e.substring(0,n),o=t.substring(0,r),s=e.substring(n),a=t.substring(r),c=El(i,o),l=El(s,a);return c.concat(l)}function Qb(e,t){if(!e||!t||e.charAt(0)!==t.charAt(0))return 0;for(var n=0,r=Math.min(e.length,t.length),i=r,o=0;n<i;)e.substring(o,i)==t.substring(o,i)?(n=i,o=n):r=i,i=Math.floor((r-n)/2+n);return UM(e.charCodeAt(i-1))&&i--,i}function CM(e,t){var n=e.length,r=t.length;if(n==0||r==0)return 0;n>r?e=e.substring(n-r):n<r&&(t=t.substring(0,n));var i=Math.min(n,r);if(e==t)return i;for(var o=0,s=1;;){var a=e.substring(i-s),c=t.indexOf(a);if(c==-1)return o;s+=c,(c==0||e.substring(i-s)==t.substring(0,s))&&(o=s,s++)}}function Nd(e,t){if(!e||!t||e.slice(-1)!==t.slice(-1))return 0;for(var n=0,r=Math.min(e.length,t.length),i=r,o=0;n<i;)e.substring(e.length-i,e.length-o)==t.substring(t.length-i,t.length-o)?(n=i,o=n):r=i,i=Math.floor((r-n)/2+n);return _M(e.charCodeAt(e.length-i))&&i--,i}function R4(e,t){var n=e.length>t.length?e:t,r=e.length>t.length?t:e;if(n.length<4||r.length*2<n.length)return null;function i(y,S,T){for(var E=y.substring(T,T+Math.floor(y.length/4)),b=-1,f="",g,v,I,M;(b=S.indexOf(E,b+1))!==-1;){var O=Qb(y.substring(T),S.substring(b)),C=Nd(y.substring(0,T),S.substring(0,b));f.length<C+O&&(f=S.substring(b-C,b)+S.substring(b,b+O),g=y.substring(0,T-C),v=y.substring(T+O),I=S.substring(0,b-C),M=S.substring(b+O))}return f.length*2>=y.length?[g,v,I,M,f]:null}var o=i(n,r,Math.ceil(n.length/4)),s=i(n,r,Math.ceil(n.length/2)),a;if(!o&&!s)return null;s?o?a=o[4].length>s[4].length?o:s:a=s:a=o;var c,l,p,d;e.length>t.length?(c=a[0],l=a[1],p=a[2],d=a[3]):(p=a[0],d=a[1],c=a[2],l=a[3]);var m=a[4];return[c,l,p,d,m]}function P4(e){for(var t=!1,n=[],r=0,i=null,o=0,s=0,a=0,c=0,l=0;o<e.length;)e[o][0]==kt?(n[r++]=o,s=c,a=l,c=0,l=0,i=e[o][1]):(e[o][0]==wn?c+=e[o][1].length:l+=e[o][1].length,i&&i.length<=Math.max(s,a)&&i.length<=Math.max(c,l)&&(e.splice(n[r-1],0,[rr,i]),e[n[r-1]+1][0]=wn,r--,r--,o=r>0?n[r-1]:-1,s=0,a=0,c=0,l=0,i=null,t=!0)),o++;for(t&&Yb(e),k4(e),o=1;o<e.length;){if(e[o-1][0]==rr&&e[o][0]==wn){var p=e[o-1][1],d=e[o][1],m=CM(p,d),y=CM(d,p);m>=y?(m>=p.length/2||m>=d.length/2)&&(e.splice(o,0,[kt,d.substring(0,m)]),e[o-1][1]=p.substring(0,p.length-m),e[o+1][1]=d.substring(m),o++):(y>=p.length/2||y>=d.length/2)&&(e.splice(o,0,[kt,p.substring(0,y)]),e[o-1][0]=wn,e[o-1][1]=d.substring(0,d.length-y),e[o+1][0]=rr,e[o+1][1]=p.substring(y),o++),o++}o++}}var NM=/[^a-zA-Z0-9]/,kM=/\s/,DM=/[\r\n]/,C4=/\n\r?\n$/,N4=/^\r?\n\r?\n/;function k4(e){function t(y,S){if(!y||!S)return 6;var T=y.charAt(y.length-1),E=S.charAt(0),b=T.match(NM),f=E.match(NM),g=b&&T.match(kM),v=f&&E.match(kM),I=g&&T.match(DM),M=v&&E.match(DM),O=I&&y.match(C4),C=M&&S.match(N4);return O||C?5:I||M?4:b&&!g&&v?3:g||v?2:b||f?1:0}for(var n=1;n<e.length-1;){if(e[n-1][0]==kt&&e[n+1][0]==kt){var r=e[n-1][1],i=e[n][1],o=e[n+1][1],s=Nd(r,i);if(s){var a=i.substring(i.length-s);r=r.substring(0,r.length-s),i=a+i.substring(0,i.length-s),o=a+o}for(var c=r,l=i,p=o,d=t(r,i)+t(i,o);i.charAt(0)===o.charAt(0);){r+=i.charAt(0),i=i.substring(1)+o.charAt(0),o=o.substring(1);var m=t(r,i)+t(i,o);m>=d&&(d=m,c=r,l=i,p=o)}e[n-1][1]!=c&&(c?e[n-1][1]=c:(e.splice(n-1,1),n--),e[n][1]=l,p?e[n+1][1]=p:(e.splice(n+1,1),n--))}n++}}function Yb(e,t){e.push([kt,""]);for(var n=0,r=0,i=0,o="",s="",a;n<e.length;){if(n<e.length-1&&!e[n][1]){e.splice(n,1);continue}switch(e[n][0]){case wn:i++,s+=e[n][1],n++;break;case rr:r++,o+=e[n][1],n++;break;case kt:var c=n-i-r-1;if(t){if(c>=0&&LM(e[c][1])){var l=e[c][1].slice(-1);if(e[c][1]=e[c][1].slice(0,-1),o=l+o,s=l+s,!e[c][1]){e.splice(c,1),n--;var p=c-1;e[p]&&e[p][0]===wn&&(i++,s=e[p][1]+s,p--),e[p]&&e[p][0]===rr&&(r++,o=e[p][1]+o,p--),c=p}}if(jM(e[n][1])){var l=e[n][1].charAt(0);e[n][1]=e[n][1].slice(1),o+=l,s+=l}}if(n<e.length-1&&!e[n][1]){e.splice(n,1);break}if(o.length>0||s.length>0){o.length>0&&s.length>0&&(a=Qb(s,o),a!==0&&(c>=0?e[c][1]+=s.substring(0,a):(e.splice(0,0,[kt,s.substring(0,a)]),n++),s=s.substring(a),o=o.substring(a)),a=Nd(s,o),a!==0&&(e[n][1]=s.substring(s.length-a)+e[n][1],s=s.substring(0,s.length-a),o=o.substring(0,o.length-a)));var d=i+r;o.length===0&&s.length===0?(e.splice(n-d,d),n=n-d):o.length===0?(e.splice(n-d,d,[wn,s]),n=n-d+1):s.length===0?(e.splice(n-d,d,[rr,o]),n=n-d+1):(e.splice(n-d,d,[rr,o],[wn,s]),n=n-d+2)}n!==0&&e[n-1][0]===kt?(e[n-1][1]+=e[n][1],e.splice(n,1)):n++,i=0,r=0,o="",s="";break}}e[e.length-1][1]===""&&e.pop();var m=!1;for(n=1;n<e.length-1;)e[n-1][0]===kt&&e[n+1][0]===kt&&(e[n][1].substring(e[n][1].length-e[n-1][1].length)===e[n-1][1]?(e[n][1]=e[n-1][1]+e[n][1].substring(0,e[n][1].length-e[n-1][1].length),e[n+1][1]=e[n-1][1]+e[n+1][1],e.splice(n-1,1),m=!0):e[n][1].substring(0,e[n+1][1].length)==e[n+1][1]&&(e[n-1][1]+=e[n+1][1],e[n][1]=e[n][1].substring(e[n+1][1].length)+e[n+1][1],e.splice(n+1,1),m=!0)),n++;m&&Yb(e,t)}function UM(e){return e>=55296&&e<=56319}function _M(e){return e>=56320&&e<=57343}function jM(e){return _M(e.charCodeAt(0))}function LM(e){return UM(e.charCodeAt(e.length-1))}function D4(e){for(var t=[],n=0;n<e.length;n++)e[n][1].length>0&&t.push(e[n]);return t}function Vb(e,t,n,r){return LM(e)||jM(r)?null:D4([[kt,e],[rr,t],[wn,n],[kt,r]])}function U4(e,t,n){var r=typeof n=="number"?{index:n,length:0}:n.oldRange,i=typeof n=="number"?null:n.newRange,o=e.length,s=t.length;if(r.length===0&&(i===null||i.length===0)){var a=r.index,c=e.slice(0,a),l=e.slice(a),p=i?i.index:null;e:{var d=a+s-o;if(p!==null&&p!==d||d<0||d>s)break e;var m=t.slice(0,d),y=t.slice(d);if(y!==l)break e;var S=Math.min(a,d),T=c.slice(0,S),E=m.slice(0,S);if(T!==E)break e;var b=c.slice(S),f=m.slice(S);return Vb(T,b,f,l)}e:{if(p!==null&&p!==a)break e;var g=a,m=t.slice(0,g),y=t.slice(g);if(m!==c)break e;var v=Math.min(o-g,s-g),I=l.slice(l.length-v),M=y.slice(y.length-v);if(I!==M)break e;var b=l.slice(0,l.length-v),f=y.slice(0,y.length-v);return Vb(c,b,f,I)}}if(r.length>0&&i&&i.length===0)e:{var T=e.slice(0,r.index),I=e.slice(r.index+r.length),S=T.length,v=I.length;if(s<S+v)break e;var E=t.slice(0,S),M=t.slice(s-v);if(T!==E||I!==M)break e;var b=e.slice(S,o-v),f=t.slice(S,s-v);return Vb(T,b,f,I)}return null}function kd(e,t,n,r){return El(e,t,n,r,!0)}kd.INSERT=wn;kd.DELETE=rr;kd.EQUAL=kt;BM.exports=kd});var _A=ee(tt=>{"use strict";u();function mx(e,t){var n=e.length;e.push(t);e:for(;0<n;){var r=n-1>>>1,i=e[r];if(0<dm(i,t))e[r]=t,e[n]=i,n=r;else break e}}function yi(e){return e.length===0?null:e[0]}function hm(e){if(e.length===0)return null;var t=e[0],n=e.pop();if(n!==t){e[0]=n;e:for(var r=0,i=e.length,o=i>>>1;r<o;){var s=2*(r+1)-1,a=e[s],c=s+1,l=e[c];if(0>dm(a,n))c<i&&0>dm(l,a)?(e[r]=l,e[c]=n,r=c):(e[r]=a,e[s]=n,r=s);else if(c<i&&0>dm(l,n))e[r]=l,e[c]=n,r=c;else break e}}return t}function dm(e,t){var n=e.sortIndex-t.sortIndex;return n!==0?n:e.id-t.id}tt.unstable_now=void 0;typeof performance=="object"&&typeof performance.now=="function"?(OA=performance,tt.unstable_now=function(){return OA.now()}):(px=Date,AA=px.now(),tt.unstable_now=function(){return px.now()-AA});var OA,px,AA,Yi=[],Fo=[],f8=1,Ar=null,dn=3,hx=!1,op=!1,sp=!1,yx=!1,CA=typeof setTimeout=="function"?setTimeout:null,NA=typeof clearTimeout=="function"?clearTimeout:null,RA=typeof setImmediate<"u"?setImmediate:null;function mm(e){for(var t=yi(Fo);t!==null;){if(t.callback===null)hm(Fo);else if(t.startTime<=e)hm(Fo),t.sortIndex=t.expirationTime,mx(Yi,t);else break;t=yi(Fo)}}function gx(e){if(sp=!1,mm(e),!op)if(yi(Yi)!==null)op=!0,dc||(dc=!0,fc());else{var t=yi(Fo);t!==null&&bx(gx,t.startTime-e)}}var dc=!1,ap=-1,kA=5,DA=-1;function UA(){return yx?!0:!(tt.unstable_now()-DA<kA)}function fx(){if(yx=!1,dc){var e=tt.unstable_now();DA=e;var t=!0;try{e:{op=!1,sp&&(sp=!1,NA(ap),ap=-1),hx=!0;var n=dn;try{t:{for(mm(e),Ar=yi(Yi);Ar!==null&&!(Ar.expirationTime>e&&UA());){var r=Ar.callback;if(typeof r=="function"){Ar.callback=null,dn=Ar.priorityLevel;var i=r(Ar.expirationTime<=e);if(e=tt.unstable_now(),typeof i=="function"){Ar.callback=i,mm(e),t=!0;break t}Ar===yi(Yi)&&hm(Yi),mm(e)}else hm(Yi);Ar=yi(Yi)}if(Ar!==null)t=!0;else{var o=yi(Fo);o!==null&&bx(gx,o.startTime-e),t=!1}}break e}finally{Ar=null,dn=n,hx=!1}t=void 0}}finally{t?fc():dc=!1}}}var fc;typeof RA=="function"?fc=function(){RA(fx)}:typeof MessageChannel<"u"?(dx=new MessageChannel,PA=dx.port2,dx.port1.onmessage=fx,fc=function(){PA.postMessage(null)}):fc=function(){CA(fx,0)};var dx,PA;function bx(e,t){ap=CA(function(){e(tt.unstable_now())},t)}tt.unstable_IdlePriority=5;tt.unstable_ImmediatePriority=1;tt.unstable_LowPriority=4;tt.unstable_NormalPriority=3;tt.unstable_Profiling=null;tt.unstable_UserBlockingPriority=2;tt.unstable_cancelCallback=function(e){e.callback=null};tt.unstable_forceFrameRate=function(e){0>e||125<e?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):kA=0<e?Math.floor(1e3/e):5};tt.unstable_getCurrentPriorityLevel=function(){return dn};tt.unstable_next=function(e){switch(dn){case 1:case 2:case 3:var t=3;break;default:t=dn}var n=dn;dn=t;try{return e()}finally{dn=n}};tt.unstable_requestPaint=function(){yx=!0};tt.unstable_runWithPriority=function(e,t){switch(e){case 1:case 2:case 3:case 4:case 5:break;default:e=3}var n=dn;dn=e;try{return t()}finally{dn=n}};tt.unstable_scheduleCallback=function(e,t,n){var r=tt.unstable_now();switch(typeof n=="object"&&n!==null?(n=n.delay,n=typeof n=="number"&&0<n?r+n:r):n=r,e){case 1:var i=-1;break;case 2:i=250;break;case 5:i=1073741823;break;case 4:i=1e4;break;default:i=5e3}return i=n+i,e={id:f8++,callback:t,priorityLevel:e,startTime:n,expirationTime:i,sortIndex:-1},n>r?(e.sortIndex=n,mx(Fo,e),yi(Yi)===null&&e===yi(Fo)&&(sp?(NA(ap),ap=-1):sp=!0,bx(gx,n-r))):(e.sortIndex=i,mx(Yi,e),op||hx||(op=!0,dc||(dc=!0,fc()))),e};tt.unstable_shouldYield=UA;tt.unstable_wrapCallback=function(e){var t=dn;return function(){var n=dn;dn=t;try{return e.apply(this,arguments)}finally{dn=n}}}});var LA=ee((gke,jA)=>{"use strict";u();jA.exports=_A()});var F1=ee(jh=>{"use strict";u();var Lt=LA(),sP=require("react"),d8=require("react-dom");function D(e){var t="https://react.dev/errors/"+e;if(1<arguments.length){t+="?args[]="+encodeURIComponent(arguments[1]);for(var n=2;n<arguments.length;n++)t+="&args[]="+encodeURIComponent(arguments[n])}return"Minified React error #"+e+"; visit "+t+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function aP(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function Qp(e){var t=e,n=e;if(e.alternate)for(;t.return;)t=t.return;else{e=t;do t=e,t.flags&4098&&(n=t.return),e=t.return;while(e)}return t.tag===3?n:null}function cP(e){if(e.tag===13){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function BA(e){if(Qp(e)!==e)throw Error(D(188))}function m8(e){var t=e.alternate;if(!t){if(t=Qp(e),t===null)throw Error(D(188));return t!==e?null:e}for(var n=e,r=t;;){var i=n.return;if(i===null)break;var o=i.alternate;if(o===null){if(r=i.return,r!==null){n=r;continue}break}if(i.child===o.child){for(o=i.child;o;){if(o===n)return BA(i),e;if(o===r)return BA(i),t;o=o.sibling}throw Error(D(188))}if(n.return!==r.return)n=i,r=o;else{for(var s=!1,a=i.child;a;){if(a===n){s=!0,n=i,r=o;break}if(a===r){s=!0,r=i,n=o;break}a=a.sibling}if(!s){for(a=o.child;a;){if(a===n){s=!0,n=o,r=i;break}if(a===r){s=!0,r=o,n=i;break}a=a.sibling}if(!s)throw Error(D(189))}}if(n.alternate!==r)throw Error(D(190))}if(n.tag!==3)throw Error(D(188));return n.stateNode.current===n?e:t}function uP(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e;for(e=e.child;e!==null;){if(t=uP(e),t!==null)return t;e=e.sibling}return null}var We=Object.assign,h8=Symbol.for("react.element"),ym=Symbol.for("react.transitional.element"),yp=Symbol.for("react.portal"),xc=Symbol.for("react.fragment"),lP=Symbol.for("react.strict_mode"),Jx=Symbol.for("react.profiler"),y8=Symbol.for("react.provider"),pP=Symbol.for("react.consumer"),eo=Symbol.for("react.context"),GT=Symbol.for("react.forward_ref"),Xx=Symbol.for("react.suspense"),Zx=Symbol.for("react.suspense_list"),qT=Symbol.for("react.memo"),zo=Symbol.for("react.lazy");Symbol.for("react.scope");var Wx=Symbol.for("react.activity");Symbol.for("react.legacy_hidden");Symbol.for("react.tracing_marker");var g8=Symbol.for("react.memo_cache_sentinel");Symbol.for("react.view_transition");var FA=Symbol.iterator;function cp(e){return e===null||typeof e!="object"?null:(e=FA&&e[FA]||e["@@iterator"],typeof e=="function"?e:null)}var b8=Symbol.for("react.client.reference");function eT(e){if(e==null)return null;if(typeof e=="function")return e.$$typeof===b8?null:e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case xc:return"Fragment";case Jx:return"Profiler";case lP:return"StrictMode";case Xx:return"Suspense";case Zx:return"SuspenseList";case Wx:return"Activity"}if(typeof e=="object")switch(e.$$typeof){case yp:return"Portal";case eo:return(e.displayName||"Context")+".Provider";case pP:return(e._context.displayName||"Context")+".Consumer";case GT:var t=e.render;return e=e.displayName,e||(e=t.displayName||t.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case qT:return t=e.displayName||null,t!==null?t:eT(e.type)||"Memo";case zo:t=e._payload,e=e._init;try{return eT(e(t))}catch{}}return null}var gp=Array.isArray,X=sP.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,Me=d8.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,oa={pending:!1,data:null,method:null,action:null},tT=[],Tc=-1;function Ii(e){return{current:e}}function Yt(e){0>Tc||(e.current=tT[Tc],tT[Tc]=null,Tc--)}function rt(e,t){Tc++,tT[Tc]=e.current,e.current=t}var xi=Ii(null),Dp=Ii(null),Wo=Ii(null),qm=Ii(null);function Vm(e,t){switch(rt(Wo,t),rt(Dp,e),rt(xi,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?qR(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)t=qR(t),e=A1(t,e);else switch(e){case"svg":e=1;break;case"math":e=2;break;default:e=0}}Yt(xi),rt(xi,e)}function Fc(){Yt(xi),Yt(Dp),Yt(Wo)}function nT(e){e.memoizedState!==null&&rt(qm,e);var t=xi.current,n=A1(t,e.type);t!==n&&(rt(Dp,e),rt(xi,n))}function Qm(e){Dp.current===e&&(Yt(xi),Yt(Dp)),qm.current===e&&(Yt(qm),Hp._currentValue=oa)}var rT=Object.prototype.hasOwnProperty,VT=Lt.unstable_scheduleCallback,Sx=Lt.unstable_cancelCallback,S8=Lt.unstable_shouldYield,x8=Lt.unstable_requestPaint,Ti=Lt.unstable_now,T8=Lt.unstable_getCurrentPriorityLevel,fP=Lt.unstable_ImmediatePriority,dP=Lt.unstable_UserBlockingPriority,Ym=Lt.unstable_NormalPriority,v8=Lt.unstable_LowPriority,mP=Lt.unstable_IdlePriority,I8=Lt.log,E8=Lt.unstable_setDisableYieldValue,Yp=null,ur=null;function Yo(e){if(typeof I8=="function"&&E8(e),ur&&typeof ur.setStrictMode=="function")try{ur.setStrictMode(Yp,e)}catch{}}var lr=Math.clz32?Math.clz32:O8,w8=Math.log,M8=Math.LN2;function O8(e){return e>>>=0,e===0?32:31-(w8(e)/M8|0)|0}var gm=256,bm=4194304;function na(e){var t=e&42;if(t!==0)return t;switch(e&-e){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return e&4194048;case 4194304:case 8388608:case 16777216:case 33554432:return e&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return e}}function vh(e,t,n){var r=e.pendingLanes;if(r===0)return 0;var i=0,o=e.suspendedLanes,s=e.pingedLanes;e=e.warmLanes;var a=r&134217727;return a!==0?(r=a&~o,r!==0?i=na(r):(s&=a,s!==0?i=na(s):n||(n=a&~e,n!==0&&(i=na(n))))):(a=r&~o,a!==0?i=na(a):s!==0?i=na(s):n||(n=r&~e,n!==0&&(i=na(n)))),i===0?0:t!==0&&t!==i&&!(t&o)&&(o=i&-i,n=t&-t,o>=n||o===32&&(n&4194048)!==0)?t:i}function Jp(e,t){return(e.pendingLanes&~(e.suspendedLanes&~e.pingedLanes)&t)===0}function A8(e,t){switch(e){case 1:case 2:case 4:case 8:case 64:return t+250;case 16:case 32:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return t+5e3;case 4194304:case 8388608:case 16777216:case 33554432:return-1;case 67108864:case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function hP(){var e=gm;return gm<<=1,!(gm&4194048)&&(gm=256),e}function yP(){var e=bm;return bm<<=1,!(bm&62914560)&&(bm=4194304),e}function xx(e){for(var t=[],n=0;31>n;n++)t.push(e);return t}function Xp(e,t){e.pendingLanes|=t,t!==268435456&&(e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0)}function R8(e,t,n,r,i,o){var s=e.pendingLanes;e.pendingLanes=n,e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0,e.expiredLanes&=n,e.entangledLanes&=n,e.errorRecoveryDisabledLanes&=n,e.shellSuspendCounter=0;var a=e.entanglements,c=e.expirationTimes,l=e.hiddenUpdates;for(n=s&~n;0<n;){var p=31-lr(n),d=1<<p;a[p]=0,c[p]=-1;var m=l[p];if(m!==null)for(l[p]=null,p=0;p<m.length;p++){var y=m[p];y!==null&&(y.lane&=-536870913)}n&=~d}r!==0&&gP(e,r,0),o!==0&&i===0&&e.tag!==0&&(e.suspendedLanes|=o&~(s&~t))}function gP(e,t,n){e.pendingLanes|=t,e.suspendedLanes&=~t;var r=31-lr(t);e.entangledLanes|=t,e.entanglements[r]=e.entanglements[r]|1073741824|n&4194090}function bP(e,t){var n=e.entangledLanes|=t;for(e=e.entanglements;n;){var r=31-lr(n),i=1<<r;i&t|e[r]&t&&(e[r]|=t),n&=~i}}function QT(e){switch(e){case 2:e=1;break;case 8:e=4;break;case 32:e=16;break;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:e=128;break;case 268435456:e=134217728;break;default:e=0}return e}function YT(e){return e&=-e,2<e?8<e?e&134217727?32:268435456:8:2}function SP(){var e=Me.p;return e!==0?e:(e=window.event,e===void 0?32:L1(e.type))}function P8(e,t){var n=Me.p;try{return Me.p=e,t()}finally{Me.p=n}}var ls=Math.random().toString(36).slice(2),mn="__reactFiber$"+ls,Hn="__reactProps$"+ls,Xc="__reactContainer$"+ls,iT="__reactEvents$"+ls,C8="__reactListeners$"+ls,N8="__reactHandles$"+ls,$A="__reactResources$"+ls,Zp="__reactMarker$"+ls;function JT(e){delete e[mn],delete e[Hn],delete e[iT],delete e[C8],delete e[N8]}function vc(e){var t=e[mn];if(t)return t;for(var n=e.parentNode;n;){if(t=n[Xc]||n[mn]){if(n=t.alternate,t.child!==null||n!==null&&n.child!==null)for(e=YR(e);e!==null;){if(n=e[mn])return n;e=YR(e)}return t}e=n,n=e.parentNode}return null}function Zc(e){if(e=e[mn]||e[Xc]){var t=e.tag;if(t===5||t===6||t===13||t===26||t===27||t===3)return e}return null}function bp(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e.stateNode;throw Error(D(33))}function Nc(e){var t=e[$A];return t||(t=e[$A]={hoistableStyles:new Map,hoistableScripts:new Map}),t}function Vt(e){e[Zp]=!0}var xP=new Set,TP={};function ya(e,t){$c(e,t),$c(e+"Capture",t)}function $c(e,t){for(TP[e]=t,e=0;e<t.length;e++)xP.add(t[e])}var k8=RegExp("^[:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD][:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD\\-.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*$"),KA={},zA={};function D8(e){return rT.call(zA,e)?!0:rT.call(KA,e)?!1:k8.test(e)?zA[e]=!0:(KA[e]=!0,!1)}function km(e,t,n){if(D8(t))if(n===null)e.removeAttribute(t);else{switch(typeof n){case"undefined":case"function":case"symbol":e.removeAttribute(t);return;case"boolean":var r=t.toLowerCase().slice(0,5);if(r!=="data-"&&r!=="aria-"){e.removeAttribute(t);return}}e.setAttribute(t,""+n)}}function Sm(e,t,n){if(n===null)e.removeAttribute(t);else{switch(typeof n){case"undefined":case"function":case"symbol":case"boolean":e.removeAttribute(t);return}e.setAttribute(t,""+n)}}function Ji(e,t,n,r){if(r===null)e.removeAttribute(n);else{switch(typeof r){case"undefined":case"function":case"symbol":case"boolean":e.removeAttribute(n);return}e.setAttributeNS(t,n,""+r)}}var Tx,HA;function gc(e){if(Tx===void 0)try{throw Error()}catch(n){var t=n.stack.trim().match(/\n( *(at )?)/);Tx=t&&t[1]||"",HA=-1<n.stack.indexOf(`
7
+ `):t+e}});var Zg=ee(Xg=>{"use strict";u();Object.defineProperty(Xg,"__esModule",{value:!0});Xg.diagram=gH;var hH=cw(),yH=lw();function gH(e,t){return t.type==="box"?(0,hH.boxDiagram)(e,t):(0,yH.directoryDiagram)(e,t)}});var Bs=ee(li=>{"use strict";u();Object.defineProperty(li,"__esModule",{value:!0});li.STOP=li.SKIP=void 0;li.visit=bH;li.SKIP="skip";li.STOP="stop";function bH(e,t){let{onEnter:n,onLeave:r,getChildren:i,onDetectCycle:o,getIdentifier:s,direction:a="forward"}=t,c=(S,T,E)=>{let b=i(S,T,E);return a==="forward"?b:b.slice().reverse()},l=[],p=[{node:e}],d=o?new Set:void 0,m=t.includeTraversalContext?{getRoot(){return e},getParent(){var S;return(S=p[p.length-2])===null||S===void 0?void 0:S.node},getAncestors(){return p.slice(0,-1).map(S=>S.node)}}:void 0,y=t.reuseIndexPath?()=>l:()=>l.slice();for(;p.length>0;){let S=p[p.length-1];if(S.state===void 0){if(d){let b=s?s(S.node):S.node;if(d.has(b)){if((typeof o=="function"?o(S.node,y(),m):o)==="error")throw new Error("Cycle detected in tree");S.state=-1;continue}d.add(b)}let E=n?.(S.node,y());if(E===li.STOP)return;S.state=E===li.SKIP?-1:0}let T=S.children||c(S.node,y(),m);if(S.children||(S.children=T),S.state!==-1){if(S.state<T.length){let b=S.state;l.push(a==="forward"?b:T.length-b-1),p.push({node:T[b]}),S.state=b+1;continue}if(r?.(S.node,y())===li.STOP)return}if(d){let E=s?s(S.node):S.node;d.delete(E)}l.pop(),p.pop()}}});var eb=ee(Wg=>{"use strict";u();Object.defineProperty(Wg,"__esModule",{value:!0});Wg.entries=xH;var SH=Bs();function xH(e,t){let n=[];return(0,SH.visit)(e,Object.assign(Object.assign({},t),{onEnter:(r,i)=>{n.push([i,r])}})),n}});var tb=ee(za=>{"use strict";u();Object.defineProperty(za,"__esModule",{value:!0});za.find=TH;za.findAll=vH;za.findPath=IH;za.findAllPaths=EH;var Ka=Bs();function TH(e,t){let n;return(0,Ka.visit)(e,Object.assign(Object.assign({},t),{onEnter:(r,i)=>{if(t.predicate(r,i))return n=r,Ka.STOP}})),n}function vH(e,t){let n=[];return(0,Ka.visit)(e,{onEnter:(r,i)=>{t.predicate(r,i)&&n.push(r)},getChildren:t.getChildren}),n}function IH(e,t){let n;return(0,Ka.visit)(e,{onEnter:(r,i)=>{if(t.predicate(r,i))return n=[...i],Ka.STOP},getChildren:t.getChildren}),n}function EH(e,t){let n=[];return(0,Ka.visit)(e,{onEnter:(r,i)=>{t.predicate(r,i)&&n.push([...i])},getChildren:t.getChildren}),n}});var Xf=ee(nb=>{"use strict";u();Object.defineProperty(nb,"__esModule",{value:!0});nb.reduce=MH;var wH=Bs();function MH(e,t){let n=t.initialResult;return(0,wH.visit)(e,Object.assign(Object.assign({},t),{onEnter:(r,i)=>{n=t.nextResult(n,r,i)}})),n}});var ib=ee(rb=>{"use strict";u();Object.defineProperty(rb,"__esModule",{value:!0});rb.flat=AH;var OH=Xf();function AH(e,t){return(0,OH.reduce)(e,Object.assign(Object.assign({},t),{initialResult:[],nextResult:(n,r)=>(n.push(r),n)}))}});var Wf=ee(Zf=>{"use strict";u();Object.defineProperty(Zf,"__esModule",{value:!0});Zf.map=PH;Zf.flatMap=pw;var RH=Bs();function PH(e,t){return pw(e,Object.assign(Object.assign({},t),{transform:(n,r,i)=>[t.transform(n,r,i)]}))}function pw(e,t){let n={};return(0,RH.visit)(e,Object.assign(Object.assign({},t),{onLeave:(r,i)=>{var o,s;let a=[0,...i],c=a.join(),l=t.transform(r,(o=n[c])!==null&&o!==void 0?o:[],i),p=a.slice(0,-1).join(),d=(s=n[p])!==null&&s!==void 0?s:[];d.push(...l),n[p]=d}})),n[""][0]}});var sb=ee(ob=>{"use strict";u();Object.defineProperty(ob,"__esModule",{value:!0});ob.transformPath=kH;var CH=Qf();function NH(e,t){let n=Math.min(e.length,t.length);for(let r=0;r<n;r++)if(e[r]!==t[r])return e.slice(0,r);return e.slice(0,n)}function kH(e,t,n,r=1){if(n.length>e.length||(0,CH.comparePathsByComponent)(n,e)>0)return e;if(n.length===0&&t==="remove")return;let i=NH(e,n),o=i.length===e.length||i.length===n.length?i.length-1:i.length,s=e[o],a=n[o];if(t==="insert"&&a<=s){let c=[...e];return c[o]+=r,c}else if(t==="remove"){if(a===s)return;if(a<s){let c=[...e];return c[o]-=r,c}}return e}});var Ha=ee(Gr=>{"use strict";u();Object.defineProperty(Gr,"__esModule",{value:!0});Gr.insertOperation=dw;Gr.removeOperation=mw;Gr.replaceOperation=ed;Gr.getInsertionOperations=_H;Gr.getRemovalOperations=jH;Gr.getReplaceOperations=LH;Gr.applyOperations=BH;Gr.arraySplice=ab;Gr.transformPathsByOperations=FH;var DH=Yf(),UH=Wf(),fw=sb();function dw(e,t){return{type:"insert",index:e,nodes:t}}function mw(e){return{type:"remove",indexes:e}}function ed(){return{type:"replace"}}function hw(e){return[e.slice(0,-1),e[e.length-1]]}function _H(e,t,n=new Map){var r;let[i,o]=hw(e);for(let a=i.length-1;a>=0;a--){let c=i.slice(0,a).join();switch((r=n.get(c))===null||r===void 0?void 0:r.type){case"remove":continue}n.set(c,ed())}let s=n.get(i.join());switch(s?.type){case"remove":n.set(i.join(),{type:"removeThenInsert",removeIndexes:s.indexes,insertIndex:o,insertNodes:t});break;default:n.set(i.join(),dw(o,t))}return n}function jH(e){var t,n;let r=(0,DH.ancestorPaths)(e),i=new Map;for(let s of r){let a=s.slice(0,-1).join(),c=(t=i.get(a))!==null&&t!==void 0?t:[];c.push(s[s.length-1]),i.set(a,c)}let o=new Map;for(let s of r)for(let a=s.length-1;a>=0;a--){let c=s.slice(0,a).join();o.set(c,ed())}for(let s of r){let a=s.slice(0,-1).join();o.set(a,mw((n=i.get(a))!==null&&n!==void 0?n:[]))}return o}function LH(e,t){let n=new Map,[r,i]=hw(e);for(let o=r.length-1;o>=0;o--){let s=r.slice(0,o).join();n.set(s,ed())}return n.set(r.join(),{type:"removeThenInsert",removeIndexes:[i],insertIndex:i,insertNodes:[t]}),n}function yw(e,t){return t.reduce((n,r)=>r<n?n-1:n,e)}function BH(e,t,n){return(0,UH.map)(e,Object.assign(Object.assign({},n),{getChildren:(r,i)=>{let o=i.join(),s=t.get(o);switch(s?.type){case"replace":case"remove":case"removeThenInsert":case"insert":return n.getChildren(r,i);default:return[]}},transform:(r,i,o)=>{let s=o.join(),a=t.get(s);switch(a?.type){case"remove":return n.create(r,i.filter((p,d)=>!a.indexes.includes(d)),o);case"removeThenInsert":let c=i.filter((p,d)=>!a.removeIndexes.includes(d)),l=yw(a.insertIndex,a.removeIndexes);return n.create(r,ab(c,l,0,...a.insertNodes),o);case"insert":return n.create(r,ab(i,a.index,0,...a.nodes),o);case"replace":return n.create(r,i,o);default:return r}}}))}function ab(e,t,n,...r){return[...e.slice(0,t),...r,...e.slice(t+n)]}function FH(e,t){let n=e;for(let[r,i]of t.entries()){let o=r?r.split(",").map(Number):[];n=cb(n,o,i)}return n}function cb(e,t,n){switch(n.type){case"insert":{let r=t.concat(n.index);return e.map(i=>i?(0,fw.transformPath)(i,"insert",r,n.nodes.length):void 0)}case"remove":{let r=[...n.indexes].reverse().map(i=>t.concat(i));return e.map(i=>{for(let o of r)i=i?(0,fw.transformPath)(i,"remove",o):void 0;return i})}case"removeThenInsert":{let r=cb(e,t,{type:"remove",indexes:n.removeIndexes}),i=yw(n.insertIndex,n.removeIndexes);return cb(r,t,{type:"insert",index:i,nodes:n.insertNodes})}case"replace":return e}}});var lb=ee(td=>{"use strict";u();Object.defineProperty(td,"__esModule",{value:!0});td.insert=$H;td.insertWithPathTracking=KH;var ub=Ha();function $H(e,t){return gw(e,t).node}function KH(e,t){return gw(e,t)}function gw(e,t){let{nodes:n,path:r,track:i}=t;if(r.length===0)throw new Error("Can't insert nodes at the root");let o=(0,ub.getInsertionOperations)(r,n),s=i?(0,ub.transformPathsByOperations)(i,o):[];return{node:(0,ub.applyOperations)(e,o,t),paths:s}}});var db=ee(fb=>{"use strict";u();Object.defineProperty(fb,"__esModule",{value:!0});fb.move=GH;var zH=qf(),HH=Yf(),pb=Ha();function GH(e,t){if(t.paths.length===0)return e;for(let o of t.paths)if(o.length===0)throw new Error("Can't move the root node");if(t.to.length===0)throw new Error("Can't move nodes to the root");let n=(0,HH.ancestorPaths)(t.paths),r=n.map(o=>(0,zH.access)(e,o,t)),i=(0,pb.getInsertionOperations)(t.to,r,(0,pb.getRemovalOperations)(n));return(0,pb.applyOperations)(e,i,t)}});var hb=ee(nd=>{"use strict";u();Object.defineProperty(nd,"__esModule",{value:!0});nd.remove=qH;nd.removeWithPathTracking=VH;var mb=Ha();function qH(e,t){return bw(e,t).node}function VH(e,t){return bw(e,t)}function bw(e,t){let{paths:n,track:r}=t,i=(0,mb.getRemovalOperations)(n),o=r?(0,mb.transformPathsByOperations)(r,i):[];return{node:(0,mb.applyOperations)(e,i,t),paths:o}}});var gb=ee(yb=>{"use strict";u();Object.defineProperty(yb,"__esModule",{value:!0});yb.replace=QH;var Sw=Ha();function QH(e,t){if(t.path.length===0)return t.node;let n=(0,Sw.getReplaceOperations)(t.path,t.node);return(0,Sw.applyOperations)(e,n,t)}});var bb=ee(id=>{"use strict";u();Object.defineProperty(id,"__esModule",{value:!0});id.splice=YH;id.spliceWithPathTracking=JH;var rd=Ha();function YH(e,t){return xw(e,t).node}function JH(e,t){return xw(e,t)}function xw(e,t){let{path:n,deleteCount:r=0,nodes:i,track:o}=t;if(n.length===0)throw new Error("Can't splice at the root");let s=XH(n,r),a=(0,rd.getInsertionOperations)(n,i,(0,rd.getRemovalOperations)(s)),c=o?(0,rd.transformPathsByOperations)(o,a):[];return{node:(0,rd.applyOperations)(e,a,t),paths:c}}function XH(e,t){let n=[],r=e.slice(0,-1),i=e[e.length-1];for(let o=0;o<t;o++)n.push(r.concat(i+o));return n}});var Tb=ee(xb=>{"use strict";u();Object.defineProperty(xb,"__esModule",{value:!0});xb.defineTree=r3;var od=qf(),Tw=Zg(),ZH=eb(),wo=tb(),WH=ib(),vw=lb(),Iw=Wf(),e3=db(),t3=Xf(),Ew=hb(),n3=gb(),ww=bb(),Mw=Bs(),Sb=class e{constructor(t,n){this.appliedOptions=n,this.getChildren=(r,i,o)=>this._getChildren(r,i,o),this.mergeOptions=r=>Object.assign(Object.assign(Object.assign({},this.baseOptions),this.appliedOptions),r),this.withOptions=r=>new e(this.baseOptions,Object.assign(Object.assign({},this.appliedOptions),r)),this.access=(r,i)=>(0,od.access)(r,i,this.mergeOptions({})),this.accessPath=(r,i)=>(0,od.accessPath)(r,i,this.mergeOptions({})),this.get=(r,i)=>(0,od.get)(r,i,this.mergeOptions({})),this.ancestors=(r,i)=>(0,od.ancestors)(r,i,this.mergeOptions({})),this.diagram=(r,i)=>typeof i=="function"?(0,Tw.diagram)(r,this.mergeOptions({getLabel:i})):(0,Tw.diagram)(r,this.mergeOptions(i)),this.find=(r,i)=>typeof i=="function"?(0,wo.find)(r,this.mergeOptions({predicate:i})):(0,wo.find)(r,this.mergeOptions(Object.assign({},i))),this.findAll=(r,i)=>typeof i=="function"?(0,wo.findAll)(r,this.mergeOptions({predicate:i})):(0,wo.findAll)(r,this.mergeOptions(Object.assign({},i))),this.findPath=(r,i)=>typeof i=="function"?(0,wo.findPath)(r,this.mergeOptions({predicate:i})):(0,wo.findPath)(r,this.mergeOptions(Object.assign({},i))),this.findAllPaths=(r,i)=>typeof i=="function"?(0,wo.findAllPaths)(r,this.mergeOptions({predicate:i})):(0,wo.findAllPaths)(r,this.mergeOptions(Object.assign({},i))),this.entries=r=>(0,ZH.entries)(r,this.mergeOptions({})),this.flat=r=>(0,WH.flat)(r,this.mergeOptions({})),this.reduce=(r,i,o)=>(0,t3.reduce)(r,this.mergeOptions({nextResult:i,initialResult:o})),this.map=(r,i)=>(0,Iw.map)(r,this.mergeOptions({transform:i})),this.flatMap=(r,i)=>(0,Iw.flatMap)(r,this.mergeOptions({transform:i})),this.visit=(r,i)=>typeof i=="function"?(0,Mw.visit)(r,this.mergeOptions({onEnter:i})):(0,Mw.visit)(r,this.mergeOptions(Object.assign({},i))),this.insert=(r,i)=>(0,vw.insert)(r,this.mergeOptions(i)),this.insertWithPathTracking=(r,i)=>(0,vw.insertWithPathTracking)(r,this.mergeOptions(i)),this.remove=(r,i)=>(0,Ew.remove)(r,this.mergeOptions(i)),this.removeWithPathTracking=(r,i)=>(0,Ew.removeWithPathTracking)(r,this.mergeOptions(i)),this.move=(r,i)=>(0,e3.move)(r,this.mergeOptions(i)),this.splice=(r,i)=>(0,ww.splice)(r,this.mergeOptions(i)),this.spliceWithPathTracking=(r,i)=>(0,ww.spliceWithPathTracking)(r,this.mergeOptions(i)),this.replace=(r,i)=>(0,n3.replace)(r,this.mergeOptions(i)),this.baseOptions=typeof t=="function"?{getChildren:t}:t,this._getChildren=this.baseOptions.getChildren}};function r3(e){return new Sb(e,{})}});var Aw=ee(Ow=>{"use strict";u();Object.defineProperty(Ow,"__esModule",{value:!0})});var Pw=ee(Rw=>{"use strict";u();Object.defineProperty(Rw,"__esModule",{value:!0})});var Cw=ee(sd=>{"use strict";u();Object.defineProperty(sd,"__esModule",{value:!0});sd.withOptions=void 0;var i3=Tb();sd.withOptions=i3.defineTree});var ad=ee(Ye=>{"use strict";u();var o3=Ye&&Ye.__createBinding||(Object.create?function(e,t,n,r){r===void 0&&(r=n);var i=Object.getOwnPropertyDescriptor(t,n);(!i||("get"in i?!t.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,i)}:function(e,t,n,r){r===void 0&&(r=n),e[r]=t[n]}),It=Ye&&Ye.__exportStar||function(e,t){for(var n in e)n!=="default"&&!Object.prototype.hasOwnProperty.call(t,n)&&o3(t,e,n)};Object.defineProperty(Ye,"__esModule",{value:!0});It(qf(),Ye);It(Yf(),Ye);It(Tb(),Ye);It(Zg(),Ye);It(eb(),Ye);It(tb(),Ye);It(ib(),Ye);It(Aw(),Ye);It(lb(),Ye);It(Wf(),Ye);It(db(),Ye);It(Pw(),Ye);It(Xf(),Ye);It(hb(),Ye);It(gb(),Ye);It(Qf(),Ye);It(bb(),Ye);It(sb(),Ye);It(Bs(),Ye);It(Cw(),Ye)});var Bw=ee(Lw=>{"use strict";u();Object.defineProperty(Lw,"__esModule",{value:!0})});var cl=ee(cd=>{"use strict";u();Object.defineProperty(cd,"__esModule",{value:!0});cd.Nodes=void 0;function p3(e,t){return{type:"file",data:e,metadata:t}}function f3(e={},t){return{type:"directory",children:e,metadata:t}}function d3(e){return e.type==="file"}function m3(e){return e.type==="directory"}function h3(e){return e.metadata}function y3(e){return Object.keys(e.children)}function g3(e,t){return e.children[t]}function b3(e,t){return t in e.children}cd.Nodes={createDirectory:f3,createFile:p3,getChild:g3,getMetadata:h3,hasChild:b3,isDirectory:m3,isFile:d3,readDirectory:y3}});var ul=ee(Et=>{"use strict";u();Object.defineProperty(Et,"__esModule",{value:!0});Et.dirname=Et.basename=Et.extname=Et.join=Et.normalize=Et.sep=void 0;Et.sep="/";function S3(e,t){return e.startsWith("/")&&(t="/"+t),t[t.length-1]!=="/"&&e.endsWith("/")&&(t=t+"/"),t}function Fw(e){let t=e.split(Et.sep).filter(i=>!!i),n=0,r=t.length-1;for(;n<r;)t[n]==="."?(t.splice(n,1),r--):t[n]===".."&&n!==0?(t.splice(n-1,2),r-=2,n-=1):t[n]===""&&t[n+1]===""?(t.splice(n,1),r--):n++;return S3(e,t.join(Et.sep))}Et.normalize=Fw;function x3(...e){let t=Fw(e.join(Et.sep));return t===""&&(t="."),t}Et.join=x3;function T3(e){let t=e.lastIndexOf(".");return t!==-1?e.slice(t):e}Et.extname=T3;function vb(e,t){t&&e.endsWith(t)&&(e=e.slice(0,-t.length));let n=e.lastIndexOf(Et.sep);return n===e.length-1?(e=e.slice(0,-1),e.length>1?vb(e):e):e.slice(n+1)}Et.basename=vb;function v3(e){let t=vb(e),n=e.slice(0,-(t.length+1));return n===""&&(e.startsWith(Et.sep)?n=Et.sep:n="."),n}Et.dirname=v3});var $w=ee(ud=>{"use strict";u();Object.defineProperty(ud,"__esModule",{value:!0});ud.Entries=void 0;var I3=cl(),E3=ul();function w3(e){let[t,n]=e;return I3.Nodes.isDirectory(n)?Object.entries(n.children).map(([r,i])=>[(0,E3.join)(t,r),i]):[]}function M3(e,t){return[e,t]}ud.Entries={createEntry:M3,getEntries:w3}});var pd=ee(Mo=>{"use strict";u();Object.defineProperty(Mo,"__esModule",{value:!0});Mo.getNewAndParentName=Mo.normalizePathLikeInternal=Mo.getPathComponents=void 0;var ld=ul();function Kw(e){return t((0,ld.normalize)(e));function t(n){if(n.startsWith(".."))throw new Error(`Invalid path ${n}, can't go up past root.`);return n.startsWith(".")||n.startsWith("/")?t(n.slice(1)):n===""?[]:n.split(ld.sep).filter(r=>!!r)}}Mo.getPathComponents=Kw;function O3(e){return typeof e=="string"?Kw(e):e}Mo.normalizePathLikeInternal=O3;function A3(e){let t=typeof e=="string"?(0,ld.dirname)(e):e.slice(0,-1),n=typeof e=="string"?(0,ld.basename)(e):e[e.length-1];return{parentName:t,newName:n}}Mo.getNewAndParentName=A3});var Ib=ee(wr=>{"use strict";u();Object.defineProperty(wr,"__esModule",{value:!0});wr.getMetadata=wr.readDirectory=wr.readFile=wr.getNode=wr.getNodeInternal=void 0;var qa=cl(),ll=ul(),fd=pd();function zw(e,t,n){let r=(0,fd.normalizePathLikeInternal)(t),i=0,o=e;for(;i<r.length;){let s=r[i];if(o.type!=="directory")throw new Error(`File ${(0,ll.join)(...r.slice(0,i))} is not a directory`);let a=qa.Nodes.getChild(o,s);if(!a)if(n.makeIntermediateDirectoryMetadata){let c=qa.Nodes.createDirectory({},n.makeIntermediateDirectoryMetadata((0,ll.join)(...r.slice(0,i+1))));o.children[s]=c,a=c}else if(n.makeIntermediateDirectories){let c=qa.Nodes.createDirectory();o.children[s]=c,a=c}else throw new Error(`File ${(0,ll.join)(...r.slice(0,i+1))} not found`);o=a,i++}return o}wr.getNodeInternal=zw;function dd(e,t){return zw(e,t,{})}wr.getNode=dd;function R3(e,t){let n=(0,fd.normalizePathLikeInternal)(t),r=dd(e,n);if(!qa.Nodes.isFile(r))throw new Error(`Can't read, ${(0,ll.join)(...n)} not a file`);return r.data}wr.readFile=R3;function P3(e,t){let n=(0,fd.normalizePathLikeInternal)(t),r=dd(e,n);if(!qa.Nodes.isDirectory(r))throw new Error(`Can't read, ${(0,ll.join)(...n)} not a directory`);return qa.Nodes.readDirectory(r)}wr.readDirectory=P3;function C3(e,t){let n=(0,fd.normalizePathLikeInternal)(t);return dd(e,n).metadata}wr.getMetadata=C3});var Gw=ee(Bn=>{"use strict";u();Object.defineProperty(Bn,"__esModule",{value:!0});Bn.create=Bn.setMetadata=Bn.removeFile=Bn.makeDirectory=Bn.writeFile=Bn.setNode=void 0;var Oo=cl(),Eb=pd(),md=Ib();function Hw(e,t,n,r){let{parentName:i,newName:o}=(0,Eb.getNewAndParentName)(t),s=(0,md.getNodeInternal)(e,i,r??{});if(!Oo.Nodes.isDirectory(s))throw new Error(`Can't create ${o}, ${i} not a directory`);s.children[o]=n}Bn.setNode=Hw;function N3(e,t,n,r){var i;Hw(e,t,Oo.Nodes.createFile(n,(i=r)===null||i===void 0?void 0:i.metadata),r)}Bn.writeFile=N3;function k3(e,t,n){var r;let{parentName:i,newName:o}=(0,Eb.getNewAndParentName)(t),s=(0,md.getNodeInternal)(e,i,n??{});if(!Oo.Nodes.isDirectory(s))throw new Error(`Can't create ${o}, ${i} not a directory`);Oo.Nodes.getChild(s,o)&&Oo.Nodes.isDirectory(s.children[o])||(s.children[o]=Oo.Nodes.createDirectory({},(r=n)===null||r===void 0?void 0:r.metadata))}Bn.makeDirectory=k3;function D3(e,t){let{parentName:n,newName:r}=(0,Eb.getNewAndParentName)(t),i=(0,md.getNode)(e,n);if(!Oo.Nodes.isDirectory(i))throw new Error(`Can't remove file ${r}, ${n} not a directory`);delete i.children[r]}Bn.removeFile=D3;function U3(e,t,n){let r=(0,md.getNode)(e,t);r.metadata=n}Bn.setMetadata=U3;function _3(e){return Oo.Nodes.createDirectory({},e&&"metadata"in e?e.metadata:void 0)}Bn.create=_3});var qw=ee(yd=>{"use strict";u();Object.defineProperty(yd,"__esModule",{value:!0});yd.Volume=void 0;var j3=pd(),hd=Ib(),Va=Gw();yd.Volume={getPathComponents:j3.getPathComponents,getMetadata:hd.getMetadata,getNode:hd.getNode,readDirectory:hd.readDirectory,readFile:hd.readFile,create:Va.create,makeDirectory:Va.makeDirectory,removeFile:Va.removeFile,setMetadata:Va.setMetadata,setNode:Va.setNode,writeFile:Va.writeFile}});var Qw=ee(fn=>{"use strict";u();var Vw=fn&&fn.__createBinding||(Object.create?function(e,t,n,r){r===void 0&&(r=n),Object.defineProperty(e,r,{enumerable:!0,get:function(){return t[n]}})}:function(e,t,n,r){r===void 0&&(r=n),e[r]=t[n]}),L3=fn&&fn.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),gd=fn&&fn.__exportStar||function(e,t){for(var n in e)n!=="default"&&!Object.prototype.hasOwnProperty.call(t,n)&&Vw(t,e,n)},B3=fn&&fn.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var n in e)n!=="default"&&Object.prototype.hasOwnProperty.call(e,n)&&Vw(t,e,n);return L3(t,e),t};Object.defineProperty(fn,"__esModule",{value:!0});fn.path=void 0;gd(Bw(),fn);gd(cl(),fn);gd($w(),fn);gd(qw(),fn);fn.path=B3(ul())});var FM=ee((aIe,BM)=>{"use strict";u();var rr=-1,wn=1,kt=0;function El(e,t,n,r,i){if(e===t)return e?[[kt,e]]:[];if(n!=null){var o=U4(e,t,n);if(o)return o}var s=Yb(e,t),a=e.substring(0,s);e=e.substring(s),t=t.substring(s),s=Nd(e,t);var c=e.substring(e.length-s);e=e.substring(0,e.length-s),t=t.substring(0,t.length-s);var l=O4(e,t);return a&&l.unshift([kt,a]),c&&l.push([kt,c]),Jb(l,i),r&&P4(l),l}function O4(e,t){var n;if(!e)return[[wn,t]];if(!t)return[[rr,e]];var r=e.length>t.length?e:t,i=e.length>t.length?t:e,o=r.indexOf(i);if(o!==-1)return n=[[wn,r.substring(0,o)],[kt,i],[wn,r.substring(o+i.length)]],e.length>t.length&&(n[0][0]=n[2][0]=rr),n;if(i.length===1)return[[rr,e],[wn,t]];var s=R4(e,t);if(s){var a=s[0],c=s[1],l=s[2],p=s[3],d=s[4],m=El(a,l),y=El(c,p);return m.concat([[kt,d]],y)}return A4(e,t)}function A4(e,t){for(var n=e.length,r=t.length,i=Math.ceil((n+r)/2),o=i,s=2*i,a=new Array(s),c=new Array(s),l=0;l<s;l++)a[l]=-1,c[l]=-1;a[o+1]=0,c[o+1]=0;for(var p=n-r,d=p%2!==0,m=0,y=0,S=0,T=0,E=0;E<i;E++){for(var b=-E+m;b<=E-y;b+=2){var f=o+b,g;b===-E||b!==E&&a[f-1]<a[f+1]?g=a[f+1]:g=a[f-1]+1;for(var v=g-b;g<n&&v<r&&e.charAt(g)===t.charAt(v);)g++,v++;if(a[f]=g,g>n)y+=2;else if(v>r)m+=2;else if(d){var I=o+p-b;if(I>=0&&I<s&&c[I]!==-1){var M=n-c[I];if(g>=M)return PM(e,t,g,v)}}}for(var O=-E+S;O<=E-T;O+=2){var I=o+O,M;O===-E||O!==E&&c[I-1]<c[I+1]?M=c[I+1]:M=c[I-1]+1;for(var C=M-O;M<n&&C<r&&e.charAt(n-M-1)===t.charAt(r-C-1);)M++,C++;if(c[I]=M,M>n)T+=2;else if(C>r)S+=2;else if(!d){var f=o+p-O;if(f>=0&&f<s&&a[f]!==-1){var g=a[f],v=o+g-f;if(M=n-M,g>=M)return PM(e,t,g,v)}}}}return[[rr,e],[wn,t]]}function PM(e,t,n,r){var i=e.substring(0,n),o=t.substring(0,r),s=e.substring(n),a=t.substring(r),c=El(i,o),l=El(s,a);return c.concat(l)}function Yb(e,t){if(!e||!t||e.charAt(0)!==t.charAt(0))return 0;for(var n=0,r=Math.min(e.length,t.length),i=r,o=0;n<i;)e.substring(o,i)==t.substring(o,i)?(n=i,o=n):r=i,i=Math.floor((r-n)/2+n);return UM(e.charCodeAt(i-1))&&i--,i}function CM(e,t){var n=e.length,r=t.length;if(n==0||r==0)return 0;n>r?e=e.substring(n-r):n<r&&(t=t.substring(0,n));var i=Math.min(n,r);if(e==t)return i;for(var o=0,s=1;;){var a=e.substring(i-s),c=t.indexOf(a);if(c==-1)return o;s+=c,(c==0||e.substring(i-s)==t.substring(0,s))&&(o=s,s++)}}function Nd(e,t){if(!e||!t||e.slice(-1)!==t.slice(-1))return 0;for(var n=0,r=Math.min(e.length,t.length),i=r,o=0;n<i;)e.substring(e.length-i,e.length-o)==t.substring(t.length-i,t.length-o)?(n=i,o=n):r=i,i=Math.floor((r-n)/2+n);return _M(e.charCodeAt(e.length-i))&&i--,i}function R4(e,t){var n=e.length>t.length?e:t,r=e.length>t.length?t:e;if(n.length<4||r.length*2<n.length)return null;function i(y,S,T){for(var E=y.substring(T,T+Math.floor(y.length/4)),b=-1,f="",g,v,I,M;(b=S.indexOf(E,b+1))!==-1;){var O=Yb(y.substring(T),S.substring(b)),C=Nd(y.substring(0,T),S.substring(0,b));f.length<C+O&&(f=S.substring(b-C,b)+S.substring(b,b+O),g=y.substring(0,T-C),v=y.substring(T+O),I=S.substring(0,b-C),M=S.substring(b+O))}return f.length*2>=y.length?[g,v,I,M,f]:null}var o=i(n,r,Math.ceil(n.length/4)),s=i(n,r,Math.ceil(n.length/2)),a;if(!o&&!s)return null;s?o?a=o[4].length>s[4].length?o:s:a=s:a=o;var c,l,p,d;e.length>t.length?(c=a[0],l=a[1],p=a[2],d=a[3]):(p=a[0],d=a[1],c=a[2],l=a[3]);var m=a[4];return[c,l,p,d,m]}function P4(e){for(var t=!1,n=[],r=0,i=null,o=0,s=0,a=0,c=0,l=0;o<e.length;)e[o][0]==kt?(n[r++]=o,s=c,a=l,c=0,l=0,i=e[o][1]):(e[o][0]==wn?c+=e[o][1].length:l+=e[o][1].length,i&&i.length<=Math.max(s,a)&&i.length<=Math.max(c,l)&&(e.splice(n[r-1],0,[rr,i]),e[n[r-1]+1][0]=wn,r--,r--,o=r>0?n[r-1]:-1,s=0,a=0,c=0,l=0,i=null,t=!0)),o++;for(t&&Jb(e),k4(e),o=1;o<e.length;){if(e[o-1][0]==rr&&e[o][0]==wn){var p=e[o-1][1],d=e[o][1],m=CM(p,d),y=CM(d,p);m>=y?(m>=p.length/2||m>=d.length/2)&&(e.splice(o,0,[kt,d.substring(0,m)]),e[o-1][1]=p.substring(0,p.length-m),e[o+1][1]=d.substring(m),o++):(y>=p.length/2||y>=d.length/2)&&(e.splice(o,0,[kt,p.substring(0,y)]),e[o-1][0]=wn,e[o-1][1]=d.substring(0,d.length-y),e[o+1][0]=rr,e[o+1][1]=p.substring(y),o++),o++}o++}}var NM=/[^a-zA-Z0-9]/,kM=/\s/,DM=/[\r\n]/,C4=/\n\r?\n$/,N4=/^\r?\n\r?\n/;function k4(e){function t(y,S){if(!y||!S)return 6;var T=y.charAt(y.length-1),E=S.charAt(0),b=T.match(NM),f=E.match(NM),g=b&&T.match(kM),v=f&&E.match(kM),I=g&&T.match(DM),M=v&&E.match(DM),O=I&&y.match(C4),C=M&&S.match(N4);return O||C?5:I||M?4:b&&!g&&v?3:g||v?2:b||f?1:0}for(var n=1;n<e.length-1;){if(e[n-1][0]==kt&&e[n+1][0]==kt){var r=e[n-1][1],i=e[n][1],o=e[n+1][1],s=Nd(r,i);if(s){var a=i.substring(i.length-s);r=r.substring(0,r.length-s),i=a+i.substring(0,i.length-s),o=a+o}for(var c=r,l=i,p=o,d=t(r,i)+t(i,o);i.charAt(0)===o.charAt(0);){r+=i.charAt(0),i=i.substring(1)+o.charAt(0),o=o.substring(1);var m=t(r,i)+t(i,o);m>=d&&(d=m,c=r,l=i,p=o)}e[n-1][1]!=c&&(c?e[n-1][1]=c:(e.splice(n-1,1),n--),e[n][1]=l,p?e[n+1][1]=p:(e.splice(n+1,1),n--))}n++}}function Jb(e,t){e.push([kt,""]);for(var n=0,r=0,i=0,o="",s="",a;n<e.length;){if(n<e.length-1&&!e[n][1]){e.splice(n,1);continue}switch(e[n][0]){case wn:i++,s+=e[n][1],n++;break;case rr:r++,o+=e[n][1],n++;break;case kt:var c=n-i-r-1;if(t){if(c>=0&&LM(e[c][1])){var l=e[c][1].slice(-1);if(e[c][1]=e[c][1].slice(0,-1),o=l+o,s=l+s,!e[c][1]){e.splice(c,1),n--;var p=c-1;e[p]&&e[p][0]===wn&&(i++,s=e[p][1]+s,p--),e[p]&&e[p][0]===rr&&(r++,o=e[p][1]+o,p--),c=p}}if(jM(e[n][1])){var l=e[n][1].charAt(0);e[n][1]=e[n][1].slice(1),o+=l,s+=l}}if(n<e.length-1&&!e[n][1]){e.splice(n,1);break}if(o.length>0||s.length>0){o.length>0&&s.length>0&&(a=Yb(s,o),a!==0&&(c>=0?e[c][1]+=s.substring(0,a):(e.splice(0,0,[kt,s.substring(0,a)]),n++),s=s.substring(a),o=o.substring(a)),a=Nd(s,o),a!==0&&(e[n][1]=s.substring(s.length-a)+e[n][1],s=s.substring(0,s.length-a),o=o.substring(0,o.length-a)));var d=i+r;o.length===0&&s.length===0?(e.splice(n-d,d),n=n-d):o.length===0?(e.splice(n-d,d,[wn,s]),n=n-d+1):s.length===0?(e.splice(n-d,d,[rr,o]),n=n-d+1):(e.splice(n-d,d,[rr,o],[wn,s]),n=n-d+2)}n!==0&&e[n-1][0]===kt?(e[n-1][1]+=e[n][1],e.splice(n,1)):n++,i=0,r=0,o="",s="";break}}e[e.length-1][1]===""&&e.pop();var m=!1;for(n=1;n<e.length-1;)e[n-1][0]===kt&&e[n+1][0]===kt&&(e[n][1].substring(e[n][1].length-e[n-1][1].length)===e[n-1][1]?(e[n][1]=e[n-1][1]+e[n][1].substring(0,e[n][1].length-e[n-1][1].length),e[n+1][1]=e[n-1][1]+e[n+1][1],e.splice(n-1,1),m=!0):e[n][1].substring(0,e[n+1][1].length)==e[n+1][1]&&(e[n-1][1]+=e[n+1][1],e[n][1]=e[n][1].substring(e[n+1][1].length)+e[n+1][1],e.splice(n+1,1),m=!0)),n++;m&&Jb(e,t)}function UM(e){return e>=55296&&e<=56319}function _M(e){return e>=56320&&e<=57343}function jM(e){return _M(e.charCodeAt(0))}function LM(e){return UM(e.charCodeAt(e.length-1))}function D4(e){for(var t=[],n=0;n<e.length;n++)e[n][1].length>0&&t.push(e[n]);return t}function Qb(e,t,n,r){return LM(e)||jM(r)?null:D4([[kt,e],[rr,t],[wn,n],[kt,r]])}function U4(e,t,n){var r=typeof n=="number"?{index:n,length:0}:n.oldRange,i=typeof n=="number"?null:n.newRange,o=e.length,s=t.length;if(r.length===0&&(i===null||i.length===0)){var a=r.index,c=e.slice(0,a),l=e.slice(a),p=i?i.index:null;e:{var d=a+s-o;if(p!==null&&p!==d||d<0||d>s)break e;var m=t.slice(0,d),y=t.slice(d);if(y!==l)break e;var S=Math.min(a,d),T=c.slice(0,S),E=m.slice(0,S);if(T!==E)break e;var b=c.slice(S),f=m.slice(S);return Qb(T,b,f,l)}e:{if(p!==null&&p!==a)break e;var g=a,m=t.slice(0,g),y=t.slice(g);if(m!==c)break e;var v=Math.min(o-g,s-g),I=l.slice(l.length-v),M=y.slice(y.length-v);if(I!==M)break e;var b=l.slice(0,l.length-v),f=y.slice(0,y.length-v);return Qb(c,b,f,I)}}if(r.length>0&&i&&i.length===0)e:{var T=e.slice(0,r.index),I=e.slice(r.index+r.length),S=T.length,v=I.length;if(s<S+v)break e;var E=t.slice(0,S),M=t.slice(s-v);if(T!==E||I!==M)break e;var b=e.slice(S,o-v),f=t.slice(S,s-v);return Qb(T,b,f,I)}return null}function kd(e,t,n,r){return El(e,t,n,r,!0)}kd.INSERT=wn;kd.DELETE=rr;kd.EQUAL=kt;BM.exports=kd});var _A=ee(tt=>{"use strict";u();function mx(e,t){var n=e.length;e.push(t);e:for(;0<n;){var r=n-1>>>1,i=e[r];if(0<mm(i,t))e[r]=t,e[n]=i,n=r;else break e}}function yi(e){return e.length===0?null:e[0]}function ym(e){if(e.length===0)return null;var t=e[0],n=e.pop();if(n!==t){e[0]=n;e:for(var r=0,i=e.length,o=i>>>1;r<o;){var s=2*(r+1)-1,a=e[s],c=s+1,l=e[c];if(0>mm(a,n))c<i&&0>mm(l,a)?(e[r]=l,e[c]=n,r=c):(e[r]=a,e[s]=n,r=s);else if(c<i&&0>mm(l,n))e[r]=l,e[c]=n,r=c;else break e}}return t}function mm(e,t){var n=e.sortIndex-t.sortIndex;return n!==0?n:e.id-t.id}tt.unstable_now=void 0;typeof performance=="object"&&typeof performance.now=="function"?(OA=performance,tt.unstable_now=function(){return OA.now()}):(px=Date,AA=px.now(),tt.unstable_now=function(){return px.now()-AA});var OA,px,AA,Yi=[],Fo=[],d8=1,Ar=null,dn=3,hx=!1,op=!1,sp=!1,yx=!1,CA=typeof setTimeout=="function"?setTimeout:null,NA=typeof clearTimeout=="function"?clearTimeout:null,RA=typeof setImmediate<"u"?setImmediate:null;function hm(e){for(var t=yi(Fo);t!==null;){if(t.callback===null)ym(Fo);else if(t.startTime<=e)ym(Fo),t.sortIndex=t.expirationTime,mx(Yi,t);else break;t=yi(Fo)}}function gx(e){if(sp=!1,hm(e),!op)if(yi(Yi)!==null)op=!0,dc||(dc=!0,fc());else{var t=yi(Fo);t!==null&&bx(gx,t.startTime-e)}}var dc=!1,ap=-1,kA=5,DA=-1;function UA(){return yx?!0:!(tt.unstable_now()-DA<kA)}function fx(){if(yx=!1,dc){var e=tt.unstable_now();DA=e;var t=!0;try{e:{op=!1,sp&&(sp=!1,NA(ap),ap=-1),hx=!0;var n=dn;try{t:{for(hm(e),Ar=yi(Yi);Ar!==null&&!(Ar.expirationTime>e&&UA());){var r=Ar.callback;if(typeof r=="function"){Ar.callback=null,dn=Ar.priorityLevel;var i=r(Ar.expirationTime<=e);if(e=tt.unstable_now(),typeof i=="function"){Ar.callback=i,hm(e),t=!0;break t}Ar===yi(Yi)&&ym(Yi),hm(e)}else ym(Yi);Ar=yi(Yi)}if(Ar!==null)t=!0;else{var o=yi(Fo);o!==null&&bx(gx,o.startTime-e),t=!1}}break e}finally{Ar=null,dn=n,hx=!1}t=void 0}}finally{t?fc():dc=!1}}}var fc;typeof RA=="function"?fc=function(){RA(fx)}:typeof MessageChannel<"u"?(dx=new MessageChannel,PA=dx.port2,dx.port1.onmessage=fx,fc=function(){PA.postMessage(null)}):fc=function(){CA(fx,0)};var dx,PA;function bx(e,t){ap=CA(function(){e(tt.unstable_now())},t)}tt.unstable_IdlePriority=5;tt.unstable_ImmediatePriority=1;tt.unstable_LowPriority=4;tt.unstable_NormalPriority=3;tt.unstable_Profiling=null;tt.unstable_UserBlockingPriority=2;tt.unstable_cancelCallback=function(e){e.callback=null};tt.unstable_forceFrameRate=function(e){0>e||125<e?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):kA=0<e?Math.floor(1e3/e):5};tt.unstable_getCurrentPriorityLevel=function(){return dn};tt.unstable_next=function(e){switch(dn){case 1:case 2:case 3:var t=3;break;default:t=dn}var n=dn;dn=t;try{return e()}finally{dn=n}};tt.unstable_requestPaint=function(){yx=!0};tt.unstable_runWithPriority=function(e,t){switch(e){case 1:case 2:case 3:case 4:case 5:break;default:e=3}var n=dn;dn=e;try{return t()}finally{dn=n}};tt.unstable_scheduleCallback=function(e,t,n){var r=tt.unstable_now();switch(typeof n=="object"&&n!==null?(n=n.delay,n=typeof n=="number"&&0<n?r+n:r):n=r,e){case 1:var i=-1;break;case 2:i=250;break;case 5:i=1073741823;break;case 4:i=1e4;break;default:i=5e3}return i=n+i,e={id:d8++,callback:t,priorityLevel:e,startTime:n,expirationTime:i,sortIndex:-1},n>r?(e.sortIndex=n,mx(Fo,e),yi(Yi)===null&&e===yi(Fo)&&(sp?(NA(ap),ap=-1):sp=!0,bx(gx,n-r))):(e.sortIndex=i,mx(Yi,e),op||hx||(op=!0,dc||(dc=!0,fc()))),e};tt.unstable_shouldYield=UA;tt.unstable_wrapCallback=function(e){var t=dn;return function(){var n=dn;dn=t;try{return e.apply(this,arguments)}finally{dn=n}}}});var LA=ee((bke,jA)=>{"use strict";u();jA.exports=_A()});var F1=ee(Lh=>{"use strict";u();var Lt=LA(),sP=require("react"),m8=require("react-dom");function D(e){var t="https://react.dev/errors/"+e;if(1<arguments.length){t+="?args[]="+encodeURIComponent(arguments[1]);for(var n=2;n<arguments.length;n++)t+="&args[]="+encodeURIComponent(arguments[n])}return"Minified React error #"+e+"; visit "+t+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function aP(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function Qp(e){var t=e,n=e;if(e.alternate)for(;t.return;)t=t.return;else{e=t;do t=e,t.flags&4098&&(n=t.return),e=t.return;while(e)}return t.tag===3?n:null}function cP(e){if(e.tag===13){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function BA(e){if(Qp(e)!==e)throw Error(D(188))}function h8(e){var t=e.alternate;if(!t){if(t=Qp(e),t===null)throw Error(D(188));return t!==e?null:e}for(var n=e,r=t;;){var i=n.return;if(i===null)break;var o=i.alternate;if(o===null){if(r=i.return,r!==null){n=r;continue}break}if(i.child===o.child){for(o=i.child;o;){if(o===n)return BA(i),e;if(o===r)return BA(i),t;o=o.sibling}throw Error(D(188))}if(n.return!==r.return)n=i,r=o;else{for(var s=!1,a=i.child;a;){if(a===n){s=!0,n=i,r=o;break}if(a===r){s=!0,r=i,n=o;break}a=a.sibling}if(!s){for(a=o.child;a;){if(a===n){s=!0,n=o,r=i;break}if(a===r){s=!0,r=o,n=i;break}a=a.sibling}if(!s)throw Error(D(189))}}if(n.alternate!==r)throw Error(D(190))}if(n.tag!==3)throw Error(D(188));return n.stateNode.current===n?e:t}function uP(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e;for(e=e.child;e!==null;){if(t=uP(e),t!==null)return t;e=e.sibling}return null}var We=Object.assign,y8=Symbol.for("react.element"),gm=Symbol.for("react.transitional.element"),yp=Symbol.for("react.portal"),xc=Symbol.for("react.fragment"),lP=Symbol.for("react.strict_mode"),Jx=Symbol.for("react.profiler"),g8=Symbol.for("react.provider"),pP=Symbol.for("react.consumer"),eo=Symbol.for("react.context"),GT=Symbol.for("react.forward_ref"),Xx=Symbol.for("react.suspense"),Zx=Symbol.for("react.suspense_list"),qT=Symbol.for("react.memo"),zo=Symbol.for("react.lazy");Symbol.for("react.scope");var Wx=Symbol.for("react.activity");Symbol.for("react.legacy_hidden");Symbol.for("react.tracing_marker");var b8=Symbol.for("react.memo_cache_sentinel");Symbol.for("react.view_transition");var FA=Symbol.iterator;function cp(e){return e===null||typeof e!="object"?null:(e=FA&&e[FA]||e["@@iterator"],typeof e=="function"?e:null)}var S8=Symbol.for("react.client.reference");function eT(e){if(e==null)return null;if(typeof e=="function")return e.$$typeof===S8?null:e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case xc:return"Fragment";case Jx:return"Profiler";case lP:return"StrictMode";case Xx:return"Suspense";case Zx:return"SuspenseList";case Wx:return"Activity"}if(typeof e=="object")switch(e.$$typeof){case yp:return"Portal";case eo:return(e.displayName||"Context")+".Provider";case pP:return(e._context.displayName||"Context")+".Consumer";case GT:var t=e.render;return e=e.displayName,e||(e=t.displayName||t.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case qT:return t=e.displayName||null,t!==null?t:eT(e.type)||"Memo";case zo:t=e._payload,e=e._init;try{return eT(e(t))}catch{}}return null}var gp=Array.isArray,X=sP.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,Me=m8.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,oa={pending:!1,data:null,method:null,action:null},tT=[],Tc=-1;function Ii(e){return{current:e}}function Yt(e){0>Tc||(e.current=tT[Tc],tT[Tc]=null,Tc--)}function rt(e,t){Tc++,tT[Tc]=e.current,e.current=t}var xi=Ii(null),Dp=Ii(null),Wo=Ii(null),Vm=Ii(null);function Qm(e,t){switch(rt(Wo,t),rt(Dp,e),rt(xi,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?qR(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)t=qR(t),e=A1(t,e);else switch(e){case"svg":e=1;break;case"math":e=2;break;default:e=0}}Yt(xi),rt(xi,e)}function Fc(){Yt(xi),Yt(Dp),Yt(Wo)}function nT(e){e.memoizedState!==null&&rt(Vm,e);var t=xi.current,n=A1(t,e.type);t!==n&&(rt(Dp,e),rt(xi,n))}function Ym(e){Dp.current===e&&(Yt(xi),Yt(Dp)),Vm.current===e&&(Yt(Vm),Hp._currentValue=oa)}var rT=Object.prototype.hasOwnProperty,VT=Lt.unstable_scheduleCallback,Sx=Lt.unstable_cancelCallback,x8=Lt.unstable_shouldYield,T8=Lt.unstable_requestPaint,Ti=Lt.unstable_now,v8=Lt.unstable_getCurrentPriorityLevel,fP=Lt.unstable_ImmediatePriority,dP=Lt.unstable_UserBlockingPriority,Jm=Lt.unstable_NormalPriority,I8=Lt.unstable_LowPriority,mP=Lt.unstable_IdlePriority,E8=Lt.log,w8=Lt.unstable_setDisableYieldValue,Yp=null,ur=null;function Yo(e){if(typeof E8=="function"&&w8(e),ur&&typeof ur.setStrictMode=="function")try{ur.setStrictMode(Yp,e)}catch{}}var lr=Math.clz32?Math.clz32:A8,M8=Math.log,O8=Math.LN2;function A8(e){return e>>>=0,e===0?32:31-(M8(e)/O8|0)|0}var bm=256,Sm=4194304;function na(e){var t=e&42;if(t!==0)return t;switch(e&-e){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return e&4194048;case 4194304:case 8388608:case 16777216:case 33554432:return e&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return e}}function Ih(e,t,n){var r=e.pendingLanes;if(r===0)return 0;var i=0,o=e.suspendedLanes,s=e.pingedLanes;e=e.warmLanes;var a=r&134217727;return a!==0?(r=a&~o,r!==0?i=na(r):(s&=a,s!==0?i=na(s):n||(n=a&~e,n!==0&&(i=na(n))))):(a=r&~o,a!==0?i=na(a):s!==0?i=na(s):n||(n=r&~e,n!==0&&(i=na(n)))),i===0?0:t!==0&&t!==i&&!(t&o)&&(o=i&-i,n=t&-t,o>=n||o===32&&(n&4194048)!==0)?t:i}function Jp(e,t){return(e.pendingLanes&~(e.suspendedLanes&~e.pingedLanes)&t)===0}function R8(e,t){switch(e){case 1:case 2:case 4:case 8:case 64:return t+250;case 16:case 32:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return t+5e3;case 4194304:case 8388608:case 16777216:case 33554432:return-1;case 67108864:case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function hP(){var e=bm;return bm<<=1,!(bm&4194048)&&(bm=256),e}function yP(){var e=Sm;return Sm<<=1,!(Sm&62914560)&&(Sm=4194304),e}function xx(e){for(var t=[],n=0;31>n;n++)t.push(e);return t}function Xp(e,t){e.pendingLanes|=t,t!==268435456&&(e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0)}function P8(e,t,n,r,i,o){var s=e.pendingLanes;e.pendingLanes=n,e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0,e.expiredLanes&=n,e.entangledLanes&=n,e.errorRecoveryDisabledLanes&=n,e.shellSuspendCounter=0;var a=e.entanglements,c=e.expirationTimes,l=e.hiddenUpdates;for(n=s&~n;0<n;){var p=31-lr(n),d=1<<p;a[p]=0,c[p]=-1;var m=l[p];if(m!==null)for(l[p]=null,p=0;p<m.length;p++){var y=m[p];y!==null&&(y.lane&=-536870913)}n&=~d}r!==0&&gP(e,r,0),o!==0&&i===0&&e.tag!==0&&(e.suspendedLanes|=o&~(s&~t))}function gP(e,t,n){e.pendingLanes|=t,e.suspendedLanes&=~t;var r=31-lr(t);e.entangledLanes|=t,e.entanglements[r]=e.entanglements[r]|1073741824|n&4194090}function bP(e,t){var n=e.entangledLanes|=t;for(e=e.entanglements;n;){var r=31-lr(n),i=1<<r;i&t|e[r]&t&&(e[r]|=t),n&=~i}}function QT(e){switch(e){case 2:e=1;break;case 8:e=4;break;case 32:e=16;break;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:e=128;break;case 268435456:e=134217728;break;default:e=0}return e}function YT(e){return e&=-e,2<e?8<e?e&134217727?32:268435456:8:2}function SP(){var e=Me.p;return e!==0?e:(e=window.event,e===void 0?32:L1(e.type))}function C8(e,t){var n=Me.p;try{return Me.p=e,t()}finally{Me.p=n}}var ls=Math.random().toString(36).slice(2),mn="__reactFiber$"+ls,Hn="__reactProps$"+ls,Xc="__reactContainer$"+ls,iT="__reactEvents$"+ls,N8="__reactListeners$"+ls,k8="__reactHandles$"+ls,$A="__reactResources$"+ls,Zp="__reactMarker$"+ls;function JT(e){delete e[mn],delete e[Hn],delete e[iT],delete e[N8],delete e[k8]}function vc(e){var t=e[mn];if(t)return t;for(var n=e.parentNode;n;){if(t=n[Xc]||n[mn]){if(n=t.alternate,t.child!==null||n!==null&&n.child!==null)for(e=YR(e);e!==null;){if(n=e[mn])return n;e=YR(e)}return t}e=n,n=e.parentNode}return null}function Zc(e){if(e=e[mn]||e[Xc]){var t=e.tag;if(t===5||t===6||t===13||t===26||t===27||t===3)return e}return null}function bp(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e.stateNode;throw Error(D(33))}function Nc(e){var t=e[$A];return t||(t=e[$A]={hoistableStyles:new Map,hoistableScripts:new Map}),t}function Vt(e){e[Zp]=!0}var xP=new Set,TP={};function ya(e,t){$c(e,t),$c(e+"Capture",t)}function $c(e,t){for(TP[e]=t,e=0;e<t.length;e++)xP.add(t[e])}var D8=RegExp("^[:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD][:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD\\-.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*$"),KA={},zA={};function U8(e){return rT.call(zA,e)?!0:rT.call(KA,e)?!1:D8.test(e)?zA[e]=!0:(KA[e]=!0,!1)}function Dm(e,t,n){if(U8(t))if(n===null)e.removeAttribute(t);else{switch(typeof n){case"undefined":case"function":case"symbol":e.removeAttribute(t);return;case"boolean":var r=t.toLowerCase().slice(0,5);if(r!=="data-"&&r!=="aria-"){e.removeAttribute(t);return}}e.setAttribute(t,""+n)}}function xm(e,t,n){if(n===null)e.removeAttribute(t);else{switch(typeof n){case"undefined":case"function":case"symbol":case"boolean":e.removeAttribute(t);return}e.setAttribute(t,""+n)}}function Ji(e,t,n,r){if(r===null)e.removeAttribute(n);else{switch(typeof r){case"undefined":case"function":case"symbol":case"boolean":e.removeAttribute(n);return}e.setAttributeNS(t,n,""+r)}}var Tx,HA;function gc(e){if(Tx===void 0)try{throw Error()}catch(n){var t=n.stack.trim().match(/\n( *(at )?)/);Tx=t&&t[1]||"",HA=-1<n.stack.indexOf(`
8
8
  at`)?" (<anonymous>)":-1<n.stack.indexOf("@")?"@unknown:0:0":""}return`
9
9
  `+Tx+e+HA}var vx=!1;function Ix(e,t){if(!e||vx)return"";vx=!0;var n=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var r={DetermineComponentFrameRoot:function(){try{if(t){var d=function(){throw Error()};if(Object.defineProperty(d.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(d,[])}catch(y){var m=y}Reflect.construct(e,[],d)}else{try{d.call()}catch(y){m=y}e.call(d.prototype)}}else{try{throw Error()}catch(y){m=y}(d=e())&&typeof d.catch=="function"&&d.catch(function(){})}}catch(y){if(y&&m&&typeof y.stack=="string")return[y.stack,m.stack]}return[null,null]}};r.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var i=Object.getOwnPropertyDescriptor(r.DetermineComponentFrameRoot,"name");i&&i.configurable&&Object.defineProperty(r.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var o=r.DetermineComponentFrameRoot(),s=o[0],a=o[1];if(s&&a){var c=s.split(`
10
10
  `),l=a.split(`
11
11
  `);for(i=r=0;r<c.length&&!c[r].includes("DetermineComponentFrameRoot");)r++;for(;i<l.length&&!l[i].includes("DetermineComponentFrameRoot");)i++;if(r===c.length||i===l.length)for(r=c.length-1,i=l.length-1;1<=r&&0<=i&&c[r]!==l[i];)i--;for(;1<=r&&0<=i;r--,i--)if(c[r]!==l[i]){if(r!==1||i!==1)do if(r--,i--,0>i||c[r]!==l[i]){var p=`
12
- `+c[r].replace(" at new "," at ");return e.displayName&&p.includes("<anonymous>")&&(p=p.replace("<anonymous>",e.displayName)),p}while(1<=r&&0<=i);break}}}finally{vx=!1,Error.prepareStackTrace=n}return(n=e?e.displayName||e.name:"")?gc(n):""}function U8(e){switch(e.tag){case 26:case 27:case 5:return gc(e.type);case 16:return gc("Lazy");case 13:return gc("Suspense");case 19:return gc("SuspenseList");case 0:case 15:return Ix(e.type,!1);case 11:return Ix(e.type.render,!1);case 1:return Ix(e.type,!0);case 31:return gc("Activity");default:return""}}function GA(e){try{var t="";do t+=U8(e),e=e.return;while(e);return t}catch(n){return`
12
+ `+c[r].replace(" at new "," at ");return e.displayName&&p.includes("<anonymous>")&&(p=p.replace("<anonymous>",e.displayName)),p}while(1<=r&&0<=i);break}}}finally{vx=!1,Error.prepareStackTrace=n}return(n=e?e.displayName||e.name:"")?gc(n):""}function _8(e){switch(e.tag){case 26:case 27:case 5:return gc(e.type);case 16:return gc("Lazy");case 13:return gc("Suspense");case 19:return gc("SuspenseList");case 0:case 15:return Ix(e.type,!1);case 11:return Ix(e.type.render,!1);case 1:return Ix(e.type,!0);case 31:return gc("Activity");default:return""}}function GA(e){try{var t="";do t+=_8(e),e=e.return;while(e);return t}catch(n){return`
13
13
  Error generating stack: `+n.message+`
14
- `+n.stack}}function Pr(e){switch(typeof e){case"bigint":case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function vP(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(t==="checkbox"||t==="radio")}function _8(e){var t=vP(e)?"checked":"value",n=Object.getOwnPropertyDescriptor(e.constructor.prototype,t),r=""+e[t];if(!e.hasOwnProperty(t)&&typeof n<"u"&&typeof n.get=="function"&&typeof n.set=="function"){var i=n.get,o=n.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return i.call(this)},set:function(s){r=""+s,o.call(this,s)}}),Object.defineProperty(e,t,{enumerable:n.enumerable}),{getValue:function(){return r},setValue:function(s){r=""+s},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}function Jm(e){e._valueTracker||(e._valueTracker=_8(e))}function IP(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var n=t.getValue(),r="";return e&&(r=vP(e)?e.checked?"true":"false":e.value),e=r,e!==n?(t.setValue(e),!0):!1}function Xm(e){if(e=e||(typeof document<"u"?document:void 0),typeof e>"u")return null;try{return e.activeElement||e.body}catch{return e.body}}var j8=/[\n"\\]/g;function kr(e){return e.replace(j8,function(t){return"\\"+t.charCodeAt(0).toString(16)+" "})}function oT(e,t,n,r,i,o,s,a){e.name="",s!=null&&typeof s!="function"&&typeof s!="symbol"&&typeof s!="boolean"?e.type=s:e.removeAttribute("type"),t!=null?s==="number"?(t===0&&e.value===""||e.value!=t)&&(e.value=""+Pr(t)):e.value!==""+Pr(t)&&(e.value=""+Pr(t)):s!=="submit"&&s!=="reset"||e.removeAttribute("value"),t!=null?sT(e,s,Pr(t)):n!=null?sT(e,s,Pr(n)):r!=null&&e.removeAttribute("value"),i==null&&o!=null&&(e.defaultChecked=!!o),i!=null&&(e.checked=i&&typeof i!="function"&&typeof i!="symbol"),a!=null&&typeof a!="function"&&typeof a!="symbol"&&typeof a!="boolean"?e.name=""+Pr(a):e.removeAttribute("name")}function EP(e,t,n,r,i,o,s,a){if(o!=null&&typeof o!="function"&&typeof o!="symbol"&&typeof o!="boolean"&&(e.type=o),t!=null||n!=null){if(!(o!=="submit"&&o!=="reset"||t!=null))return;n=n!=null?""+Pr(n):"",t=t!=null?""+Pr(t):n,a||t===e.value||(e.value=t),e.defaultValue=t}r=r??i,r=typeof r!="function"&&typeof r!="symbol"&&!!r,e.checked=a?e.checked:!!r,e.defaultChecked=!!r,s!=null&&typeof s!="function"&&typeof s!="symbol"&&typeof s!="boolean"&&(e.name=s)}function sT(e,t,n){t==="number"&&Xm(e.ownerDocument)===e||e.defaultValue===""+n||(e.defaultValue=""+n)}function kc(e,t,n,r){if(e=e.options,t){t={};for(var i=0;i<n.length;i++)t["$"+n[i]]=!0;for(n=0;n<e.length;n++)i=t.hasOwnProperty("$"+e[n].value),e[n].selected!==i&&(e[n].selected=i),i&&r&&(e[n].defaultSelected=!0)}else{for(n=""+Pr(n),t=null,i=0;i<e.length;i++){if(e[i].value===n){e[i].selected=!0,r&&(e[i].defaultSelected=!0);return}t!==null||e[i].disabled||(t=e[i])}t!==null&&(t.selected=!0)}}function wP(e,t,n){if(t!=null&&(t=""+Pr(t),t!==e.value&&(e.value=t),n==null)){e.defaultValue!==t&&(e.defaultValue=t);return}e.defaultValue=n!=null?""+Pr(n):""}function MP(e,t,n,r){if(t==null){if(r!=null){if(n!=null)throw Error(D(92));if(gp(r)){if(1<r.length)throw Error(D(93));r=r[0]}n=r}n==null&&(n=""),t=n}n=Pr(t),e.defaultValue=n,r=e.textContent,r===n&&r!==""&&r!==null&&(e.value=r)}function Kc(e,t){if(t){var n=e.firstChild;if(n&&n===e.lastChild&&n.nodeType===3){n.nodeValue=t;return}}e.textContent=t}var L8=new Set("animationIterationCount aspectRatio borderImageOutset borderImageSlice borderImageWidth boxFlex boxFlexGroup boxOrdinalGroup columnCount columns flex flexGrow flexPositive flexShrink flexNegative flexOrder gridArea gridRow gridRowEnd gridRowSpan gridRowStart gridColumn gridColumnEnd gridColumnSpan gridColumnStart fontWeight lineClamp lineHeight opacity order orphans scale tabSize widows zIndex zoom fillOpacity floodOpacity stopOpacity strokeDasharray strokeDashoffset strokeMiterlimit strokeOpacity strokeWidth MozAnimationIterationCount MozBoxFlex MozBoxFlexGroup MozLineClamp msAnimationIterationCount msFlex msZoom msFlexGrow msFlexNegative msFlexOrder msFlexPositive msFlexShrink msGridColumn msGridColumnSpan msGridRow msGridRowSpan WebkitAnimationIterationCount WebkitBoxFlex WebKitBoxFlexGroup WebkitBoxOrdinalGroup WebkitColumnCount WebkitColumns WebkitFlex WebkitFlexGrow WebkitFlexPositive WebkitFlexShrink WebkitLineClamp".split(" "));function qA(e,t,n){var r=t.indexOf("--")===0;n==null||typeof n=="boolean"||n===""?r?e.setProperty(t,""):t==="float"?e.cssFloat="":e[t]="":r?e.setProperty(t,n):typeof n!="number"||n===0||L8.has(t)?t==="float"?e.cssFloat=n:e[t]=(""+n).trim():e[t]=n+"px"}function OP(e,t,n){if(t!=null&&typeof t!="object")throw Error(D(62));if(e=e.style,n!=null){for(var r in n)!n.hasOwnProperty(r)||t!=null&&t.hasOwnProperty(r)||(r.indexOf("--")===0?e.setProperty(r,""):r==="float"?e.cssFloat="":e[r]="");for(var i in t)r=t[i],t.hasOwnProperty(i)&&n[i]!==r&&qA(e,i,r)}else for(var o in t)t.hasOwnProperty(o)&&qA(e,o,t[o])}function XT(e){if(e.indexOf("-")===-1)return!1;switch(e){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var B8=new Map([["acceptCharset","accept-charset"],["htmlFor","for"],["httpEquiv","http-equiv"],["crossOrigin","crossorigin"],["accentHeight","accent-height"],["alignmentBaseline","alignment-baseline"],["arabicForm","arabic-form"],["baselineShift","baseline-shift"],["capHeight","cap-height"],["clipPath","clip-path"],["clipRule","clip-rule"],["colorInterpolation","color-interpolation"],["colorInterpolationFilters","color-interpolation-filters"],["colorProfile","color-profile"],["colorRendering","color-rendering"],["dominantBaseline","dominant-baseline"],["enableBackground","enable-background"],["fillOpacity","fill-opacity"],["fillRule","fill-rule"],["floodColor","flood-color"],["floodOpacity","flood-opacity"],["fontFamily","font-family"],["fontSize","font-size"],["fontSizeAdjust","font-size-adjust"],["fontStretch","font-stretch"],["fontStyle","font-style"],["fontVariant","font-variant"],["fontWeight","font-weight"],["glyphName","glyph-name"],["glyphOrientationHorizontal","glyph-orientation-horizontal"],["glyphOrientationVertical","glyph-orientation-vertical"],["horizAdvX","horiz-adv-x"],["horizOriginX","horiz-origin-x"],["imageRendering","image-rendering"],["letterSpacing","letter-spacing"],["lightingColor","lighting-color"],["markerEnd","marker-end"],["markerMid","marker-mid"],["markerStart","marker-start"],["overlinePosition","overline-position"],["overlineThickness","overline-thickness"],["paintOrder","paint-order"],["panose-1","panose-1"],["pointerEvents","pointer-events"],["renderingIntent","rendering-intent"],["shapeRendering","shape-rendering"],["stopColor","stop-color"],["stopOpacity","stop-opacity"],["strikethroughPosition","strikethrough-position"],["strikethroughThickness","strikethrough-thickness"],["strokeDasharray","stroke-dasharray"],["strokeDashoffset","stroke-dashoffset"],["strokeLinecap","stroke-linecap"],["strokeLinejoin","stroke-linejoin"],["strokeMiterlimit","stroke-miterlimit"],["strokeOpacity","stroke-opacity"],["strokeWidth","stroke-width"],["textAnchor","text-anchor"],["textDecoration","text-decoration"],["textRendering","text-rendering"],["transformOrigin","transform-origin"],["underlinePosition","underline-position"],["underlineThickness","underline-thickness"],["unicodeBidi","unicode-bidi"],["unicodeRange","unicode-range"],["unitsPerEm","units-per-em"],["vAlphabetic","v-alphabetic"],["vHanging","v-hanging"],["vIdeographic","v-ideographic"],["vMathematical","v-mathematical"],["vectorEffect","vector-effect"],["vertAdvY","vert-adv-y"],["vertOriginX","vert-origin-x"],["vertOriginY","vert-origin-y"],["wordSpacing","word-spacing"],["writingMode","writing-mode"],["xmlnsXlink","xmlns:xlink"],["xHeight","x-height"]]),F8=/^[\u0000-\u001F ]*j[\r\n\t]*a[\r\n\t]*v[\r\n\t]*a[\r\n\t]*s[\r\n\t]*c[\r\n\t]*r[\r\n\t]*i[\r\n\t]*p[\r\n\t]*t[\r\n\t]*:/i;function Dm(e){return F8.test(""+e)?"javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')":e}var aT=null;function ZT(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var Ic=null,Dc=null;function VA(e){var t=Zc(e);if(t&&(e=t.stateNode)){var n=e[Hn]||null;e:switch(e=t.stateNode,t.type){case"input":if(oT(e,n.value,n.defaultValue,n.defaultValue,n.checked,n.defaultChecked,n.type,n.name),t=n.name,n.type==="radio"&&t!=null){for(n=e;n.parentNode;)n=n.parentNode;for(n=n.querySelectorAll('input[name="'+kr(""+t)+'"][type="radio"]'),t=0;t<n.length;t++){var r=n[t];if(r!==e&&r.form===e.form){var i=r[Hn]||null;if(!i)throw Error(D(90));oT(r,i.value,i.defaultValue,i.defaultValue,i.checked,i.defaultChecked,i.type,i.name)}}for(t=0;t<n.length;t++)r=n[t],r.form===e.form&&IP(r)}break e;case"textarea":wP(e,n.value,n.defaultValue);break e;case"select":t=n.value,t!=null&&kc(e,!!n.multiple,t,!1)}}}var Ex=!1;function AP(e,t,n){if(Ex)return e(t,n);Ex=!0;try{var r=e(t);return r}finally{if(Ex=!1,(Ic!==null||Dc!==null)&&(Nh(),Ic&&(t=Ic,e=Dc,Dc=Ic=null,VA(t),e)))for(t=0;t<e.length;t++)VA(e[t])}}function Up(e,t){var n=e.stateNode;if(n===null)return null;var r=n[Hn]||null;if(r===null)return null;n=r[t];e:switch(t){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(r=!r.disabled)||(e=e.type,r=!(e==="button"||e==="input"||e==="select"||e==="textarea")),e=!r;break e;default:e=!1}if(e)return null;if(n&&typeof n!="function")throw Error(D(231,t,typeof n));return n}var ao=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),cT=!1;if(ao)try{mc={},Object.defineProperty(mc,"passive",{get:function(){cT=!0}}),window.addEventListener("test",mc,mc),window.removeEventListener("test",mc,mc)}catch{cT=!1}var mc,Jo=null,WT=null,Um=null;function RP(){if(Um)return Um;var e,t=WT,n=t.length,r,i="value"in Jo?Jo.value:Jo.textContent,o=i.length;for(e=0;e<n&&t[e]===i[e];e++);var s=n-e;for(r=1;r<=s&&t[n-r]===i[o-r];r++);return Um=i.slice(e,1<r?1-r:void 0)}function _m(e){var t=e.keyCode;return"charCode"in e?(e=e.charCode,e===0&&t===13&&(e=13)):e=t,e===10&&(e=13),32<=e||e===13?e:0}function xm(){return!0}function QA(){return!1}function Gn(e){function t(n,r,i,o,s){this._reactName=n,this._targetInst=i,this.type=r,this.nativeEvent=o,this.target=s,this.currentTarget=null;for(var a in e)e.hasOwnProperty(a)&&(n=e[a],this[a]=n?n(o):o[a]);return this.isDefaultPrevented=(o.defaultPrevented!=null?o.defaultPrevented:o.returnValue===!1)?xm:QA,this.isPropagationStopped=QA,this}return We(t.prototype,{preventDefault:function(){this.defaultPrevented=!0;var n=this.nativeEvent;n&&(n.preventDefault?n.preventDefault():typeof n.returnValue!="unknown"&&(n.returnValue=!1),this.isDefaultPrevented=xm)},stopPropagation:function(){var n=this.nativeEvent;n&&(n.stopPropagation?n.stopPropagation():typeof n.cancelBubble!="unknown"&&(n.cancelBubble=!0),this.isPropagationStopped=xm)},persist:function(){},isPersistent:xm}),t}var ga={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(e){return e.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},Ih=Gn(ga),Wp=We({},ga,{view:0,detail:0}),$8=Gn(Wp),wx,Mx,up,Eh=We({},Wp,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:ev,button:0,buttons:0,relatedTarget:function(e){return e.relatedTarget===void 0?e.fromElement===e.srcElement?e.toElement:e.fromElement:e.relatedTarget},movementX:function(e){return"movementX"in e?e.movementX:(e!==up&&(up&&e.type==="mousemove"?(wx=e.screenX-up.screenX,Mx=e.screenY-up.screenY):Mx=wx=0,up=e),wx)},movementY:function(e){return"movementY"in e?e.movementY:Mx}}),YA=Gn(Eh),K8=We({},Eh,{dataTransfer:0}),z8=Gn(K8),H8=We({},Wp,{relatedTarget:0}),Ox=Gn(H8),G8=We({},ga,{animationName:0,elapsedTime:0,pseudoElement:0}),q8=Gn(G8),V8=We({},ga,{clipboardData:function(e){return"clipboardData"in e?e.clipboardData:window.clipboardData}}),Q8=Gn(V8),Y8=We({},ga,{data:0}),JA=Gn(Y8),J8={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},X8={8:"Backspace",9:"Tab",12:"Clear",13:"Enter",16:"Shift",17:"Control",18:"Alt",19:"Pause",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",45:"Insert",46:"Delete",112:"F1",113:"F2",114:"F3",115:"F4",116:"F5",117:"F6",118:"F7",119:"F8",120:"F9",121:"F10",122:"F11",123:"F12",144:"NumLock",145:"ScrollLock",224:"Meta"},Z8={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function W8(e){var t=this.nativeEvent;return t.getModifierState?t.getModifierState(e):(e=Z8[e])?!!t[e]:!1}function ev(){return W8}var eG=We({},Wp,{key:function(e){if(e.key){var t=J8[e.key]||e.key;if(t!=="Unidentified")return t}return e.type==="keypress"?(e=_m(e),e===13?"Enter":String.fromCharCode(e)):e.type==="keydown"||e.type==="keyup"?X8[e.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:ev,charCode:function(e){return e.type==="keypress"?_m(e):0},keyCode:function(e){return e.type==="keydown"||e.type==="keyup"?e.keyCode:0},which:function(e){return e.type==="keypress"?_m(e):e.type==="keydown"||e.type==="keyup"?e.keyCode:0}}),tG=Gn(eG),nG=We({},Eh,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),XA=Gn(nG),rG=We({},Wp,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:ev}),iG=Gn(rG),oG=We({},ga,{propertyName:0,elapsedTime:0,pseudoElement:0}),sG=Gn(oG),aG=We({},Eh,{deltaX:function(e){return"deltaX"in e?e.deltaX:"wheelDeltaX"in e?-e.wheelDeltaX:0},deltaY:function(e){return"deltaY"in e?e.deltaY:"wheelDeltaY"in e?-e.wheelDeltaY:"wheelDelta"in e?-e.wheelDelta:0},deltaZ:0,deltaMode:0}),cG=Gn(aG),uG=We({},ga,{newState:0,oldState:0}),lG=Gn(uG),pG=[9,13,27,32],tv=ao&&"CompositionEvent"in window,xp=null;ao&&"documentMode"in document&&(xp=document.documentMode);var fG=ao&&"TextEvent"in window&&!xp,PP=ao&&(!tv||xp&&8<xp&&11>=xp),ZA=" ",WA=!1;function CP(e,t){switch(e){case"keyup":return pG.indexOf(t.keyCode)!==-1;case"keydown":return t.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function NP(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var Ec=!1;function dG(e,t){switch(e){case"compositionend":return NP(t);case"keypress":return t.which!==32?null:(WA=!0,ZA);case"textInput":return e=t.data,e===ZA&&WA?null:e;default:return null}}function mG(e,t){if(Ec)return e==="compositionend"||!tv&&CP(e,t)?(e=RP(),Um=WT=Jo=null,Ec=!1,e):null;switch(e){case"paste":return null;case"keypress":if(!(t.ctrlKey||t.altKey||t.metaKey)||t.ctrlKey&&t.altKey){if(t.char&&1<t.char.length)return t.char;if(t.which)return String.fromCharCode(t.which)}return null;case"compositionend":return PP&&t.locale!=="ko"?null:t.data;default:return null}}var hG={color:!0,date:!0,datetime:!0,"datetime-local":!0,email:!0,month:!0,number:!0,password:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0};function eR(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t==="input"?!!hG[e.type]:t==="textarea"}function kP(e,t,n,r){Ic?Dc?Dc.push(r):Dc=[r]:Ic=r,t=hh(t,"onChange"),0<t.length&&(n=new Ih("onChange","change",null,n,r),e.push({event:n,listeners:t}))}var Tp=null,_p=null;function yG(e){w1(e,0)}function wh(e){var t=bp(e);if(IP(t))return e}function tR(e,t){if(e==="change")return t}var DP=!1;ao&&(ao?(vm="oninput"in document,vm||(Ax=document.createElement("div"),Ax.setAttribute("oninput","return;"),vm=typeof Ax.oninput=="function"),Tm=vm):Tm=!1,DP=Tm&&(!document.documentMode||9<document.documentMode));var Tm,vm,Ax;function nR(){Tp&&(Tp.detachEvent("onpropertychange",UP),_p=Tp=null)}function UP(e){if(e.propertyName==="value"&&wh(_p)){var t=[];kP(t,_p,e,ZT(e)),AP(yG,t)}}function gG(e,t,n){e==="focusin"?(nR(),Tp=t,_p=n,Tp.attachEvent("onpropertychange",UP)):e==="focusout"&&nR()}function bG(e){if(e==="selectionchange"||e==="keyup"||e==="keydown")return wh(_p)}function SG(e,t){if(e==="click")return wh(t)}function xG(e,t){if(e==="input"||e==="change")return wh(t)}function TG(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var dr=typeof Object.is=="function"?Object.is:TG;function jp(e,t){if(dr(e,t))return!0;if(typeof e!="object"||e===null||typeof t!="object"||t===null)return!1;var n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(r=0;r<n.length;r++){var i=n[r];if(!rT.call(t,i)||!dr(e[i],t[i]))return!1}return!0}function rR(e){for(;e&&e.firstChild;)e=e.firstChild;return e}function iR(e,t){var n=rR(e);e=0;for(var r;n;){if(n.nodeType===3){if(r=e+n.textContent.length,e<=t&&r>=t)return{node:n,offset:t-e};e=r}e:{for(;n;){if(n.nextSibling){n=n.nextSibling;break e}n=n.parentNode}n=void 0}n=rR(n)}}function _P(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?_P(e,t.parentNode):"contains"in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function jP(e){e=e!=null&&e.ownerDocument!=null&&e.ownerDocument.defaultView!=null?e.ownerDocument.defaultView:window;for(var t=Xm(e.document);t instanceof e.HTMLIFrameElement;){try{var n=typeof t.contentWindow.location.href=="string"}catch{n=!1}if(n)e=t.contentWindow;else break;t=Xm(e.document)}return t}function nv(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t&&(t==="input"&&(e.type==="text"||e.type==="search"||e.type==="tel"||e.type==="url"||e.type==="password")||t==="textarea"||e.contentEditable==="true")}var vG=ao&&"documentMode"in document&&11>=document.documentMode,wc=null,uT=null,vp=null,lT=!1;function oR(e,t,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;lT||wc==null||wc!==Xm(r)||(r=wc,"selectionStart"in r&&nv(r)?r={start:r.selectionStart,end:r.selectionEnd}:(r=(r.ownerDocument&&r.ownerDocument.defaultView||window).getSelection(),r={anchorNode:r.anchorNode,anchorOffset:r.anchorOffset,focusNode:r.focusNode,focusOffset:r.focusOffset}),vp&&jp(vp,r)||(vp=r,r=hh(uT,"onSelect"),0<r.length&&(t=new Ih("onSelect","select",null,t,n),e.push({event:t,listeners:r}),t.target=wc)))}function ta(e,t){var n={};return n[e.toLowerCase()]=t.toLowerCase(),n["Webkit"+e]="webkit"+t,n["Moz"+e]="moz"+t,n}var Mc={animationend:ta("Animation","AnimationEnd"),animationiteration:ta("Animation","AnimationIteration"),animationstart:ta("Animation","AnimationStart"),transitionrun:ta("Transition","TransitionRun"),transitionstart:ta("Transition","TransitionStart"),transitioncancel:ta("Transition","TransitionCancel"),transitionend:ta("Transition","TransitionEnd")},Rx={},LP={};ao&&(LP=document.createElement("div").style,"AnimationEvent"in window||(delete Mc.animationend.animation,delete Mc.animationiteration.animation,delete Mc.animationstart.animation),"TransitionEvent"in window||delete Mc.transitionend.transition);function ba(e){if(Rx[e])return Rx[e];if(!Mc[e])return e;var t=Mc[e],n;for(n in t)if(t.hasOwnProperty(n)&&n in LP)return Rx[e]=t[n];return e}var BP=ba("animationend"),FP=ba("animationiteration"),$P=ba("animationstart"),IG=ba("transitionrun"),EG=ba("transitionstart"),wG=ba("transitioncancel"),KP=ba("transitionend"),zP=new Map,pT="abort auxClick beforeToggle cancel canPlay canPlayThrough click close contextMenu copy cut drag dragEnd dragEnter dragExit dragLeave dragOver dragStart drop durationChange emptied encrypted ended error gotPointerCapture input invalid keyDown keyPress keyUp load loadedData loadedMetadata loadStart lostPointerCapture mouseDown mouseMove mouseOut mouseOver mouseUp paste pause play playing pointerCancel pointerDown pointerMove pointerOut pointerOver pointerUp progress rateChange reset resize seeked seeking stalled submit suspend timeUpdate touchCancel touchEnd touchStart volumeChange scroll toggle touchMove waiting wheel".split(" ");pT.push("scrollEnd");function ei(e,t){zP.set(e,t),ya(t,[e])}var sR=new WeakMap;function Dr(e,t){if(typeof e=="object"&&e!==null){var n=sR.get(e);return n!==void 0?n:(t={value:e,source:t,stack:GA(t)},sR.set(e,t),t)}return{value:e,source:t,stack:GA(t)}}var Rr=[],Oc=0,rv=0;function Mh(){for(var e=Oc,t=rv=Oc=0;t<e;){var n=Rr[t];Rr[t++]=null;var r=Rr[t];Rr[t++]=null;var i=Rr[t];Rr[t++]=null;var o=Rr[t];if(Rr[t++]=null,r!==null&&i!==null){var s=r.pending;s===null?i.next=i:(i.next=s.next,s.next=i),r.pending=i}o!==0&&HP(n,i,o)}}function Oh(e,t,n,r){Rr[Oc++]=e,Rr[Oc++]=t,Rr[Oc++]=n,Rr[Oc++]=r,rv|=r,e.lanes|=r,e=e.alternate,e!==null&&(e.lanes|=r)}function iv(e,t,n,r){return Oh(e,t,n,r),Zm(e)}function Wc(e,t){return Oh(e,null,null,t),Zm(e)}function HP(e,t,n){e.lanes|=n;var r=e.alternate;r!==null&&(r.lanes|=n);for(var i=!1,o=e.return;o!==null;)o.childLanes|=n,r=o.alternate,r!==null&&(r.childLanes|=n),o.tag===22&&(e=o.stateNode,e===null||e._visibility&1||(i=!0)),e=o,o=o.return;return e.tag===3?(o=e.stateNode,i&&t!==null&&(i=31-lr(n),e=o.hiddenUpdates,r=e[i],r===null?e[i]=[t]:r.push(t),t.lane=n|536870912),o):null}function Zm(e){if(50<Np)throw Np=0,NT=null,Error(D(185));for(var t=e.return;t!==null;)e=t,t=e.return;return e.tag===3?e.stateNode:null}var Ac={};function MG(e,t,n,r){this.tag=e,this.key=n,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.refCleanup=this.ref=null,this.pendingProps=t,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=r,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function cr(e,t,n,r){return new MG(e,t,n,r)}function ov(e){return e=e.prototype,!(!e||!e.isReactComponent)}function oo(e,t){var n=e.alternate;return n===null?(n=cr(e.tag,t,e.key,e.mode),n.elementType=e.elementType,n.type=e.type,n.stateNode=e.stateNode,n.alternate=e,e.alternate=n):(n.pendingProps=t,n.type=e.type,n.flags=0,n.subtreeFlags=0,n.deletions=null),n.flags=e.flags&65011712,n.childLanes=e.childLanes,n.lanes=e.lanes,n.child=e.child,n.memoizedProps=e.memoizedProps,n.memoizedState=e.memoizedState,n.updateQueue=e.updateQueue,t=e.dependencies,n.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext},n.sibling=e.sibling,n.index=e.index,n.ref=e.ref,n.refCleanup=e.refCleanup,n}function GP(e,t){e.flags&=65011714;var n=e.alternate;return n===null?(e.childLanes=0,e.lanes=t,e.child=null,e.subtreeFlags=0,e.memoizedProps=null,e.memoizedState=null,e.updateQueue=null,e.dependencies=null,e.stateNode=null):(e.childLanes=n.childLanes,e.lanes=n.lanes,e.child=n.child,e.subtreeFlags=0,e.deletions=null,e.memoizedProps=n.memoizedProps,e.memoizedState=n.memoizedState,e.updateQueue=n.updateQueue,e.type=n.type,t=n.dependencies,e.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext}),e}function jm(e,t,n,r,i,o){var s=0;if(r=e,typeof e=="function")ov(e)&&(s=1);else if(typeof e=="string")s=Mq(e,n,xi.current)?26:e==="html"||e==="head"||e==="body"?27:5;else e:switch(e){case Wx:return e=cr(31,n,t,i),e.elementType=Wx,e.lanes=o,e;case xc:return sa(n.children,i,o,t);case lP:s=8,i|=24;break;case Jx:return e=cr(12,n,t,i|2),e.elementType=Jx,e.lanes=o,e;case Xx:return e=cr(13,n,t,i),e.elementType=Xx,e.lanes=o,e;case Zx:return e=cr(19,n,t,i),e.elementType=Zx,e.lanes=o,e;default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case y8:case eo:s=10;break e;case pP:s=9;break e;case GT:s=11;break e;case qT:s=14;break e;case zo:s=16,r=null;break e}s=29,n=Error(D(130,e===null?"null":typeof e,"")),r=null}return t=cr(s,n,t,i),t.elementType=e,t.type=r,t.lanes=o,t}function sa(e,t,n,r){return e=cr(7,e,r,t),e.lanes=n,e}function Px(e,t,n){return e=cr(6,e,null,t),e.lanes=n,e}function Cx(e,t,n){return t=cr(4,e.children!==null?e.children:[],e.key,t),t.lanes=n,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}var Rc=[],Pc=0,Wm=null,eh=0,Cr=[],Nr=0,aa=null,to=1,no="";function ra(e,t){Rc[Pc++]=eh,Rc[Pc++]=Wm,Wm=e,eh=t}function qP(e,t,n){Cr[Nr++]=to,Cr[Nr++]=no,Cr[Nr++]=aa,aa=e;var r=to;e=no;var i=32-lr(r)-1;r&=~(1<<i),n+=1;var o=32-lr(t)+i;if(30<o){var s=i-i%5;o=(r&(1<<s)-1).toString(32),r>>=s,i-=s,to=1<<32-lr(t)+i|n<<i|r,no=o+e}else to=1<<o|n<<i|r,no=e}function sv(e){e.return!==null&&(ra(e,1),qP(e,1,0))}function av(e){for(;e===Wm;)Wm=Rc[--Pc],Rc[Pc]=null,eh=Rc[--Pc],Rc[Pc]=null;for(;e===aa;)aa=Cr[--Nr],Cr[Nr]=null,no=Cr[--Nr],Cr[Nr]=null,to=Cr[--Nr],Cr[Nr]=null}var Mn=null,pt=null,we=!1,ca=null,bi=!1,fT=Error(D(519));function fa(e){var t=Error(D(418,""));throw Lp(Dr(t,e)),fT}function aR(e){var t=e.stateNode,n=e.type,r=e.memoizedProps;switch(t[mn]=e,t[Hn]=r,n){case"dialog":le("cancel",t),le("close",t);break;case"iframe":case"object":case"embed":le("load",t);break;case"video":case"audio":for(n=0;n<$p.length;n++)le($p[n],t);break;case"source":le("error",t);break;case"img":case"image":case"link":le("error",t),le("load",t);break;case"details":le("toggle",t);break;case"input":le("invalid",t),EP(t,r.value,r.defaultValue,r.checked,r.defaultChecked,r.type,r.name,!0),Jm(t);break;case"select":le("invalid",t);break;case"textarea":le("invalid",t),MP(t,r.value,r.defaultValue,r.children),Jm(t)}n=r.children,typeof n!="string"&&typeof n!="number"&&typeof n!="bigint"||t.textContent===""+n||r.suppressHydrationWarning===!0||O1(t.textContent,n)?(r.popover!=null&&(le("beforetoggle",t),le("toggle",t)),r.onScroll!=null&&le("scroll",t),r.onScrollEnd!=null&&le("scrollend",t),r.onClick!=null&&(t.onclick=Uh),t=!0):t=!1,t||fa(e)}function cR(e){for(Mn=e.return;Mn;)switch(Mn.tag){case 5:case 13:bi=!1;return;case 27:case 3:bi=!0;return;default:Mn=Mn.return}}function lp(e){if(e!==Mn)return!1;if(!we)return cR(e),we=!0,!1;var t=e.tag,n;if((n=t!==3&&t!==27)&&((n=t===5)&&(n=e.type,n=!(n!=="form"&&n!=="button")||LT(e.type,e.memoizedProps)),n=!n),n&&pt&&fa(e),cR(e),t===13){if(e=e.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(D(317));e:{for(e=e.nextSibling,t=0;e;){if(e.nodeType===8)if(n=e.data,n==="/$"){if(t===0){pt=Wr(e.nextSibling);break e}t--}else n!=="$"&&n!=="$!"&&n!=="$?"||t++;e=e.nextSibling}pt=null}}else t===27?(t=pt,ps(e.type)?(e=$T,$T=null,pt=e):pt=t):pt=Mn?Wr(e.stateNode.nextSibling):null;return!0}function ef(){pt=Mn=null,we=!1}function uR(){var e=ca;return e!==null&&(zn===null?zn=e:zn.push.apply(zn,e),ca=null),e}function Lp(e){ca===null?ca=[e]:ca.push(e)}var dT=Ii(null),Sa=null,ro=null;function Go(e,t,n){rt(dT,t._currentValue),t._currentValue=n}function so(e){e._currentValue=dT.current,Yt(dT)}function mT(e,t,n){for(;e!==null;){var r=e.alternate;if((e.childLanes&t)!==t?(e.childLanes|=t,r!==null&&(r.childLanes|=t)):r!==null&&(r.childLanes&t)!==t&&(r.childLanes|=t),e===n)break;e=e.return}}function hT(e,t,n,r){var i=e.child;for(i!==null&&(i.return=e);i!==null;){var o=i.dependencies;if(o!==null){var s=i.child;o=o.firstContext;e:for(;o!==null;){var a=o;o=i;for(var c=0;c<t.length;c++)if(a.context===t[c]){o.lanes|=n,a=o.alternate,a!==null&&(a.lanes|=n),mT(o.return,n,e),r||(s=null);break e}o=a.next}}else if(i.tag===18){if(s=i.return,s===null)throw Error(D(341));s.lanes|=n,o=s.alternate,o!==null&&(o.lanes|=n),mT(s,n,e),s=null}else s=i.child;if(s!==null)s.return=i;else for(s=i;s!==null;){if(s===e){s=null;break}if(i=s.sibling,i!==null){i.return=s.return,s=i;break}s=s.return}i=s}}function tf(e,t,n,r){e=null;for(var i=t,o=!1;i!==null;){if(!o){if(i.flags&524288)o=!0;else if(i.flags&262144)break}if(i.tag===10){var s=i.alternate;if(s===null)throw Error(D(387));if(s=s.memoizedProps,s!==null){var a=i.type;dr(i.pendingProps.value,s.value)||(e!==null?e.push(a):e=[a])}}else if(i===qm.current){if(s=i.alternate,s===null)throw Error(D(387));s.memoizedState.memoizedState!==i.memoizedState.memoizedState&&(e!==null?e.push(Hp):e=[Hp])}i=i.return}e!==null&&hT(t,e,n,r),t.flags|=262144}function th(e){for(e=e.firstContext;e!==null;){if(!dr(e.context._currentValue,e.memoizedValue))return!0;e=e.next}return!1}function da(e){Sa=e,ro=null,e=e.dependencies,e!==null&&(e.firstContext=null)}function hn(e){return VP(Sa,e)}function Im(e,t){return Sa===null&&da(e),VP(e,t)}function VP(e,t){var n=t._currentValue;if(t={context:t,memoizedValue:n,next:null},ro===null){if(e===null)throw Error(D(308));ro=t,e.dependencies={lanes:0,firstContext:t},e.flags|=524288}else ro=ro.next=t;return n}var OG=typeof AbortController<"u"?AbortController:function(){var e=[],t=this.signal={aborted:!1,addEventListener:function(n,r){e.push(r)}};this.abort=function(){t.aborted=!0,e.forEach(function(n){return n()})}},AG=Lt.unstable_scheduleCallback,RG=Lt.unstable_NormalPriority,_t={$$typeof:eo,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function cv(){return{controller:new OG,data:new Map,refCount:0}}function nf(e){e.refCount--,e.refCount===0&&AG(RG,function(){e.controller.abort()})}var Ip=null,yT=0,zc=0,Uc=null;function PG(e,t){if(Ip===null){var n=Ip=[];yT=0,zc=Cv(),Uc={status:"pending",value:void 0,then:function(r){n.push(r)}}}return yT++,t.then(lR,lR),t}function lR(){if(--yT===0&&Ip!==null){Uc!==null&&(Uc.status="fulfilled");var e=Ip;Ip=null,zc=0,Uc=null;for(var t=0;t<e.length;t++)(0,e[t])()}}function CG(e,t){var n=[],r={status:"pending",value:null,reason:null,then:function(i){n.push(i)}};return e.then(function(){r.status="fulfilled",r.value=t;for(var i=0;i<n.length;i++)(0,n[i])(t)},function(i){for(r.status="rejected",r.reason=i,i=0;i<n.length;i++)(0,n[i])(void 0)}),r}var pR=X.S;X.S=function(e,t){typeof t=="object"&&t!==null&&typeof t.then=="function"&&PG(e,t),pR!==null&&pR(e,t)};var ua=Ii(null);function uv(){var e=ua.current;return e!==null?e:Xe.pooledCache}function Lm(e,t){t===null?rt(ua,ua.current):rt(ua,t.pool)}function QP(){var e=uv();return e===null?null:{parent:_t._currentValue,pool:e}}var rf=Error(D(460)),YP=Error(D(474)),Ah=Error(D(542)),gT={then:function(){}};function fR(e){return e=e.status,e==="fulfilled"||e==="rejected"}function Em(){}function JP(e,t,n){switch(n=e[n],n===void 0?e.push(t):n!==t&&(t.then(Em,Em),t=n),t.status){case"fulfilled":return t.value;case"rejected":throw e=t.reason,mR(e),e;default:if(typeof t.status=="string")t.then(Em,Em);else{if(e=Xe,e!==null&&100<e.shellSuspendCounter)throw Error(D(482));e=t,e.status="pending",e.then(function(r){if(t.status==="pending"){var i=t;i.status="fulfilled",i.value=r}},function(r){if(t.status==="pending"){var i=t;i.status="rejected",i.reason=r}})}switch(t.status){case"fulfilled":return t.value;case"rejected":throw e=t.reason,mR(e),e}throw Ep=t,rf}}var Ep=null;function dR(){if(Ep===null)throw Error(D(459));var e=Ep;return Ep=null,e}function mR(e){if(e===rf||e===Ah)throw Error(D(483))}var Ho=!1;function lv(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function bT(e,t){e=e.updateQueue,t.updateQueue===e&&(t.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,callbacks:null})}function es(e){return{lane:e,tag:0,payload:null,callback:null,next:null}}function ts(e,t,n){var r=e.updateQueue;if(r===null)return null;if(r=r.shared,_e&2){var i=r.pending;return i===null?t.next=t:(t.next=i.next,i.next=t),r.pending=t,t=Zm(e),HP(e,null,n),t}return Oh(e,r,t,n),Zm(e)}function wp(e,t,n){if(t=t.updateQueue,t!==null&&(t=t.shared,(n&4194048)!==0)){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,bP(e,n)}}function Nx(e,t){var n=e.updateQueue,r=e.alternate;if(r!==null&&(r=r.updateQueue,n===r)){var i=null,o=null;if(n=n.firstBaseUpdate,n!==null){do{var s={lane:n.lane,tag:n.tag,payload:n.payload,callback:null,next:null};o===null?i=o=s:o=o.next=s,n=n.next}while(n!==null);o===null?i=o=t:o=o.next=t}else i=o=t;n={baseState:r.baseState,firstBaseUpdate:i,lastBaseUpdate:o,shared:r.shared,callbacks:r.callbacks},e.updateQueue=n;return}e=n.lastBaseUpdate,e===null?n.firstBaseUpdate=t:e.next=t,n.lastBaseUpdate=t}var ST=!1;function Mp(){if(ST){var e=Uc;if(e!==null)throw e}}function Op(e,t,n,r){ST=!1;var i=e.updateQueue;Ho=!1;var o=i.firstBaseUpdate,s=i.lastBaseUpdate,a=i.shared.pending;if(a!==null){i.shared.pending=null;var c=a,l=c.next;c.next=null,s===null?o=l:s.next=l,s=c;var p=e.alternate;p!==null&&(p=p.updateQueue,a=p.lastBaseUpdate,a!==s&&(a===null?p.firstBaseUpdate=l:a.next=l,p.lastBaseUpdate=c))}if(o!==null){var d=i.baseState;s=0,p=l=c=null,a=o;do{var m=a.lane&-536870913,y=m!==a.lane;if(y?(Se&m)===m:(r&m)===m){m!==0&&m===zc&&(ST=!0),p!==null&&(p=p.next={lane:0,tag:a.tag,payload:a.payload,callback:null,next:null});e:{var S=e,T=a;m=t;var E=n;switch(T.tag){case 1:if(S=T.payload,typeof S=="function"){d=S.call(E,d,m);break e}d=S;break e;case 3:S.flags=S.flags&-65537|128;case 0:if(S=T.payload,m=typeof S=="function"?S.call(E,d,m):S,m==null)break e;d=We({},d,m);break e;case 2:Ho=!0}}m=a.callback,m!==null&&(e.flags|=64,y&&(e.flags|=8192),y=i.callbacks,y===null?i.callbacks=[m]:y.push(m))}else y={lane:m,tag:a.tag,payload:a.payload,callback:a.callback,next:null},p===null?(l=p=y,c=d):p=p.next=y,s|=m;if(a=a.next,a===null){if(a=i.shared.pending,a===null)break;y=a,a=y.next,y.next=null,i.lastBaseUpdate=y,i.shared.pending=null}}while(!0);p===null&&(c=d),i.baseState=c,i.firstBaseUpdate=l,i.lastBaseUpdate=p,o===null&&(i.shared.lanes=0),us|=s,e.lanes=s,e.memoizedState=d}}function XP(e,t){if(typeof e!="function")throw Error(D(191,e));e.call(t)}function ZP(e,t){var n=e.callbacks;if(n!==null)for(e.callbacks=null,e=0;e<n.length;e++)XP(n[e],t)}var Hc=Ii(null),nh=Ii(0);function hR(e,t){e=lo,rt(nh,e),rt(Hc,t),lo=e|t.baseLanes}function xT(){rt(nh,lo),rt(Hc,Hc.current)}function pv(){lo=nh.current,Yt(Hc),Yt(nh)}var as=0,re=null,Fe=null,Ot=null,rh=!1,_c=!1,ma=!1,ih=0,Bp=0,jc=null,NG=0;function yt(){throw Error(D(321))}function fv(e,t){if(t===null)return!1;for(var n=0;n<t.length&&n<e.length;n++)if(!dr(e[n],t[n]))return!1;return!0}function dv(e,t,n,r,i,o){return as=o,re=t,t.memoizedState=null,t.updateQueue=null,t.lanes=0,X.H=e===null||e.memoizedState===null?RC:PC,ma=!1,o=n(r,i),ma=!1,_c&&(o=eC(t,n,r,i)),WP(e),o}function WP(e){X.H=oh;var t=Fe!==null&&Fe.next!==null;if(as=0,Ot=Fe=re=null,rh=!1,Bp=0,jc=null,t)throw Error(D(300));e===null||Qt||(e=e.dependencies,e!==null&&th(e)&&(Qt=!0))}function eC(e,t,n,r){re=e;var i=0;do{if(_c&&(jc=null),Bp=0,_c=!1,25<=i)throw Error(D(301));if(i+=1,Ot=Fe=null,e.updateQueue!=null){var o=e.updateQueue;o.lastEffect=null,o.events=null,o.stores=null,o.memoCache!=null&&(o.memoCache.index=0)}X.H=BG,o=t(n,r)}while(_c);return o}function kG(){var e=X.H,t=e.useState()[0];return t=typeof t.then=="function"?of(t):t,e=e.useState()[0],(Fe!==null?Fe.memoizedState:null)!==e&&(re.flags|=1024),t}function mv(){var e=ih!==0;return ih=0,e}function hv(e,t,n){t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~n}function yv(e){if(rh){for(e=e.memoizedState;e!==null;){var t=e.queue;t!==null&&(t.pending=null),e=e.next}rh=!1}as=0,Ot=Fe=re=null,_c=!1,Bp=ih=0,jc=null}function $n(){var e={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return Ot===null?re.memoizedState=Ot=e:Ot=Ot.next=e,Ot}function At(){if(Fe===null){var e=re.alternate;e=e!==null?e.memoizedState:null}else e=Fe.next;var t=Ot===null?re.memoizedState:Ot.next;if(t!==null)Ot=t,Fe=e;else{if(e===null)throw re.alternate===null?Error(D(467)):Error(D(310));Fe=e,e={memoizedState:Fe.memoizedState,baseState:Fe.baseState,baseQueue:Fe.baseQueue,queue:Fe.queue,next:null},Ot===null?re.memoizedState=Ot=e:Ot=Ot.next=e}return Ot}function gv(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function of(e){var t=Bp;return Bp+=1,jc===null&&(jc=[]),e=JP(jc,e,t),t=re,(Ot===null?t.memoizedState:Ot.next)===null&&(t=t.alternate,X.H=t===null||t.memoizedState===null?RC:PC),e}function Rh(e){if(e!==null&&typeof e=="object"){if(typeof e.then=="function")return of(e);if(e.$$typeof===eo)return hn(e)}throw Error(D(438,String(e)))}function bv(e){var t=null,n=re.updateQueue;if(n!==null&&(t=n.memoCache),t==null){var r=re.alternate;r!==null&&(r=r.updateQueue,r!==null&&(r=r.memoCache,r!=null&&(t={data:r.data.map(function(i){return i.slice()}),index:0})))}if(t==null&&(t={data:[],index:0}),n===null&&(n=gv(),re.updateQueue=n),n.memoCache=t,n=t.data[t.index],n===void 0)for(n=t.data[t.index]=Array(e),r=0;r<e;r++)n[r]=g8;return t.index++,n}function co(e,t){return typeof t=="function"?t(e):t}function Bm(e){var t=At();return Sv(t,Fe,e)}function Sv(e,t,n){var r=e.queue;if(r===null)throw Error(D(311));r.lastRenderedReducer=n;var i=e.baseQueue,o=r.pending;if(o!==null){if(i!==null){var s=i.next;i.next=o.next,o.next=s}t.baseQueue=i=o,r.pending=null}if(o=e.baseState,i===null)e.memoizedState=o;else{t=i.next;var a=s=null,c=null,l=t,p=!1;do{var d=l.lane&-536870913;if(d!==l.lane?(Se&d)===d:(as&d)===d){var m=l.revertLane;if(m===0)c!==null&&(c=c.next={lane:0,revertLane:0,action:l.action,hasEagerState:l.hasEagerState,eagerState:l.eagerState,next:null}),d===zc&&(p=!0);else if((as&m)===m){l=l.next,m===zc&&(p=!0);continue}else d={lane:0,revertLane:l.revertLane,action:l.action,hasEagerState:l.hasEagerState,eagerState:l.eagerState,next:null},c===null?(a=c=d,s=o):c=c.next=d,re.lanes|=m,us|=m;d=l.action,ma&&n(o,d),o=l.hasEagerState?l.eagerState:n(o,d)}else m={lane:d,revertLane:l.revertLane,action:l.action,hasEagerState:l.hasEagerState,eagerState:l.eagerState,next:null},c===null?(a=c=m,s=o):c=c.next=m,re.lanes|=d,us|=d;l=l.next}while(l!==null&&l!==t);if(c===null?s=o:c.next=a,!dr(o,e.memoizedState)&&(Qt=!0,p&&(n=Uc,n!==null)))throw n;e.memoizedState=o,e.baseState=s,e.baseQueue=c,r.lastRenderedState=o}return i===null&&(r.lanes=0),[e.memoizedState,r.dispatch]}function kx(e){var t=At(),n=t.queue;if(n===null)throw Error(D(311));n.lastRenderedReducer=e;var r=n.dispatch,i=n.pending,o=t.memoizedState;if(i!==null){n.pending=null;var s=i=i.next;do o=e(o,s.action),s=s.next;while(s!==i);dr(o,t.memoizedState)||(Qt=!0),t.memoizedState=o,t.baseQueue===null&&(t.baseState=o),n.lastRenderedState=o}return[o,r]}function tC(e,t,n){var r=re,i=At(),o=we;if(o){if(n===void 0)throw Error(D(407));n=n()}else n=t();var s=!dr((Fe||i).memoizedState,n);s&&(i.memoizedState=n,Qt=!0),i=i.queue;var a=iC.bind(null,r,i,e);if(sf(2048,8,a,[e]),i.getSnapshot!==t||s||Ot!==null&&Ot.memoizedState.tag&1){if(r.flags|=2048,Gc(9,Ph(),rC.bind(null,r,i,n,t),null),Xe===null)throw Error(D(349));o||as&124||nC(r,t,n)}return n}function nC(e,t,n){e.flags|=16384,e={getSnapshot:t,value:n},t=re.updateQueue,t===null?(t=gv(),re.updateQueue=t,t.stores=[e]):(n=t.stores,n===null?t.stores=[e]:n.push(e))}function rC(e,t,n,r){t.value=n,t.getSnapshot=r,oC(t)&&sC(e)}function iC(e,t,n){return n(function(){oC(t)&&sC(e)})}function oC(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!dr(e,n)}catch{return!0}}function sC(e){var t=Wc(e,2);t!==null&&fr(t,e,2)}function TT(e){var t=$n();if(typeof e=="function"){var n=e;if(e=n(),ma){Yo(!0);try{n()}finally{Yo(!1)}}}return t.memoizedState=t.baseState=e,t.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:co,lastRenderedState:e},t}function aC(e,t,n,r){return e.baseState=n,Sv(e,Fe,typeof r=="function"?r:co)}function DG(e,t,n,r,i){if(Ch(e))throw Error(D(485));if(e=t.action,e!==null){var o={payload:i,action:e,next:null,isTransition:!0,status:"pending",value:null,reason:null,listeners:[],then:function(s){o.listeners.push(s)}};X.T!==null?n(!0):o.isTransition=!1,r(o),n=t.pending,n===null?(o.next=t.pending=o,cC(t,o)):(o.next=n.next,t.pending=n.next=o)}}function cC(e,t){var n=t.action,r=t.payload,i=e.state;if(t.isTransition){var o=X.T,s={};X.T=s;try{var a=n(i,r),c=X.S;c!==null&&c(s,a),yR(e,t,a)}catch(l){vT(e,t,l)}finally{X.T=o}}else try{o=n(i,r),yR(e,t,o)}catch(l){vT(e,t,l)}}function yR(e,t,n){n!==null&&typeof n=="object"&&typeof n.then=="function"?n.then(function(r){gR(e,t,r)},function(r){return vT(e,t,r)}):gR(e,t,n)}function gR(e,t,n){t.status="fulfilled",t.value=n,uC(t),e.state=n,t=e.pending,t!==null&&(n=t.next,n===t?e.pending=null:(n=n.next,t.next=n,cC(e,n)))}function vT(e,t,n){var r=e.pending;if(e.pending=null,r!==null){r=r.next;do t.status="rejected",t.reason=n,uC(t),t=t.next;while(t!==r)}e.action=null}function uC(e){e=e.listeners;for(var t=0;t<e.length;t++)(0,e[t])()}function lC(e,t){return t}function bR(e,t){if(we){var n=Xe.formState;if(n!==null){e:{var r=re;if(we){if(pt){t:{for(var i=pt,o=bi;i.nodeType!==8;){if(!o){i=null;break t}if(i=Wr(i.nextSibling),i===null){i=null;break t}}o=i.data,i=o==="F!"||o==="F"?i:null}if(i){pt=Wr(i.nextSibling),r=i.data==="F!";break e}}fa(r)}r=!1}r&&(t=n[0])}}return n=$n(),n.memoizedState=n.baseState=t,r={pending:null,lanes:0,dispatch:null,lastRenderedReducer:lC,lastRenderedState:t},n.queue=r,n=MC.bind(null,re,r),r.dispatch=n,r=TT(!1),o=Iv.bind(null,re,!1,r.queue),r=$n(),i={state:t,dispatch:null,action:e,pending:null},r.queue=i,n=DG.bind(null,re,i,o,n),i.dispatch=n,r.memoizedState=e,[t,n,!1]}function SR(e){var t=At();return pC(t,Fe,e)}function pC(e,t,n){if(t=Sv(e,t,lC)[0],e=Bm(co)[0],typeof t=="object"&&t!==null&&typeof t.then=="function")try{var r=of(t)}catch(s){throw s===rf?Ah:s}else r=t;t=At();var i=t.queue,o=i.dispatch;return n!==t.memoizedState&&(re.flags|=2048,Gc(9,Ph(),UG.bind(null,i,n),null)),[r,o,e]}function UG(e,t){e.action=t}function xR(e){var t=At(),n=Fe;if(n!==null)return pC(t,n,e);At(),t=t.memoizedState,n=At();var r=n.queue.dispatch;return n.memoizedState=e,[t,r,!1]}function Gc(e,t,n,r){return e={tag:e,create:n,deps:r,inst:t,next:null},t=re.updateQueue,t===null&&(t=gv(),re.updateQueue=t),n=t.lastEffect,n===null?t.lastEffect=e.next=e:(r=n.next,n.next=e,e.next=r,t.lastEffect=e),e}function Ph(){return{destroy:void 0,resource:void 0}}function fC(){return At().memoizedState}function Fm(e,t,n,r){var i=$n();r=r===void 0?null:r,re.flags|=e,i.memoizedState=Gc(1|t,Ph(),n,r)}function sf(e,t,n,r){var i=At();r=r===void 0?null:r;var o=i.memoizedState.inst;Fe!==null&&r!==null&&fv(r,Fe.memoizedState.deps)?i.memoizedState=Gc(t,o,n,r):(re.flags|=e,i.memoizedState=Gc(1|t,o,n,r))}function TR(e,t){Fm(8390656,8,e,t)}function dC(e,t){sf(2048,8,e,t)}function mC(e,t){return sf(4,2,e,t)}function hC(e,t){return sf(4,4,e,t)}function yC(e,t){if(typeof t=="function"){e=e();var n=t(e);return function(){typeof n=="function"?n():t(null)}}if(t!=null)return e=e(),t.current=e,function(){t.current=null}}function gC(e,t,n){n=n!=null?n.concat([e]):null,sf(4,4,yC.bind(null,t,e),n)}function xv(){}function bC(e,t){var n=At();t=t===void 0?null:t;var r=n.memoizedState;return t!==null&&fv(t,r[1])?r[0]:(n.memoizedState=[e,t],e)}function SC(e,t){var n=At();t=t===void 0?null:t;var r=n.memoizedState;if(t!==null&&fv(t,r[1]))return r[0];if(r=e(),ma){Yo(!0);try{e()}finally{Yo(!1)}}return n.memoizedState=[r,t],r}function Tv(e,t,n){return n===void 0||as&1073741824?e.memoizedState=t:(e.memoizedState=n,e=u1(),re.lanes|=e,us|=e,n)}function xC(e,t,n,r){return dr(n,t)?n:Hc.current!==null?(e=Tv(e,n,r),dr(e,t)||(Qt=!0),e):as&42?(e=u1(),re.lanes|=e,us|=e,t):(Qt=!0,e.memoizedState=n)}function TC(e,t,n,r,i){var o=Me.p;Me.p=o!==0&&8>o?o:8;var s=X.T,a={};X.T=a,Iv(e,!1,t,n);try{var c=i(),l=X.S;if(l!==null&&l(a,c),c!==null&&typeof c=="object"&&typeof c.then=="function"){var p=CG(c,r);Ap(e,t,p,pr(e))}else Ap(e,t,r,pr(e))}catch(d){Ap(e,t,{then:function(){},status:"rejected",reason:d},pr())}finally{Me.p=o,X.T=s}}function _G(){}function IT(e,t,n,r){if(e.tag!==5)throw Error(D(476));var i=vC(e).queue;TC(e,i,t,oa,n===null?_G:function(){return IC(e),n(r)})}function vC(e){var t=e.memoizedState;if(t!==null)return t;t={memoizedState:oa,baseState:oa,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:co,lastRenderedState:oa},next:null};var n={};return t.next={memoizedState:n,baseState:n,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:co,lastRenderedState:n},next:null},e.memoizedState=t,e=e.alternate,e!==null&&(e.memoizedState=t),t}function IC(e){var t=vC(e).next.queue;Ap(e,t,{},pr())}function vv(){return hn(Hp)}function EC(){return At().memoizedState}function wC(){return At().memoizedState}function jG(e){for(var t=e.return;t!==null;){switch(t.tag){case 24:case 3:var n=pr();e=es(n);var r=ts(t,e,n);r!==null&&(fr(r,t,n),wp(r,t,n)),t={cache:cv()},e.payload=t;return}t=t.return}}function LG(e,t,n){var r=pr();n={lane:r,revertLane:0,action:n,hasEagerState:!1,eagerState:null,next:null},Ch(e)?OC(t,n):(n=iv(e,t,n,r),n!==null&&(fr(n,e,r),AC(n,t,r)))}function MC(e,t,n){var r=pr();Ap(e,t,n,r)}function Ap(e,t,n,r){var i={lane:r,revertLane:0,action:n,hasEagerState:!1,eagerState:null,next:null};if(Ch(e))OC(t,i);else{var o=e.alternate;if(e.lanes===0&&(o===null||o.lanes===0)&&(o=t.lastRenderedReducer,o!==null))try{var s=t.lastRenderedState,a=o(s,n);if(i.hasEagerState=!0,i.eagerState=a,dr(a,s))return Oh(e,t,i,0),Xe===null&&Mh(),!1}catch{}finally{}if(n=iv(e,t,i,r),n!==null)return fr(n,e,r),AC(n,t,r),!0}return!1}function Iv(e,t,n,r){if(r={lane:2,revertLane:Cv(),action:r,hasEagerState:!1,eagerState:null,next:null},Ch(e)){if(t)throw Error(D(479))}else t=iv(e,n,r,2),t!==null&&fr(t,e,2)}function Ch(e){var t=e.alternate;return e===re||t!==null&&t===re}function OC(e,t){_c=rh=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function AC(e,t,n){if(n&4194048){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,bP(e,n)}}var oh={readContext:hn,use:Rh,useCallback:yt,useContext:yt,useEffect:yt,useImperativeHandle:yt,useLayoutEffect:yt,useInsertionEffect:yt,useMemo:yt,useReducer:yt,useRef:yt,useState:yt,useDebugValue:yt,useDeferredValue:yt,useTransition:yt,useSyncExternalStore:yt,useId:yt,useHostTransitionStatus:yt,useFormState:yt,useActionState:yt,useOptimistic:yt,useMemoCache:yt,useCacheRefresh:yt},RC={readContext:hn,use:Rh,useCallback:function(e,t){return $n().memoizedState=[e,t===void 0?null:t],e},useContext:hn,useEffect:TR,useImperativeHandle:function(e,t,n){n=n!=null?n.concat([e]):null,Fm(4194308,4,yC.bind(null,t,e),n)},useLayoutEffect:function(e,t){return Fm(4194308,4,e,t)},useInsertionEffect:function(e,t){Fm(4,2,e,t)},useMemo:function(e,t){var n=$n();t=t===void 0?null:t;var r=e();if(ma){Yo(!0);try{e()}finally{Yo(!1)}}return n.memoizedState=[r,t],r},useReducer:function(e,t,n){var r=$n();if(n!==void 0){var i=n(t);if(ma){Yo(!0);try{n(t)}finally{Yo(!1)}}}else i=t;return r.memoizedState=r.baseState=i,e={pending:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:i},r.queue=e,e=e.dispatch=LG.bind(null,re,e),[r.memoizedState,e]},useRef:function(e){var t=$n();return e={current:e},t.memoizedState=e},useState:function(e){e=TT(e);var t=e.queue,n=MC.bind(null,re,t);return t.dispatch=n,[e.memoizedState,n]},useDebugValue:xv,useDeferredValue:function(e,t){var n=$n();return Tv(n,e,t)},useTransition:function(){var e=TT(!1);return e=TC.bind(null,re,e.queue,!0,!1),$n().memoizedState=e,[!1,e]},useSyncExternalStore:function(e,t,n){var r=re,i=$n();if(we){if(n===void 0)throw Error(D(407));n=n()}else{if(n=t(),Xe===null)throw Error(D(349));Se&124||nC(r,t,n)}i.memoizedState=n;var o={value:n,getSnapshot:t};return i.queue=o,TR(iC.bind(null,r,o,e),[e]),r.flags|=2048,Gc(9,Ph(),rC.bind(null,r,o,n,t),null),n},useId:function(){var e=$n(),t=Xe.identifierPrefix;if(we){var n=no,r=to;n=(r&~(1<<32-lr(r)-1)).toString(32)+n,t="\xAB"+t+"R"+n,n=ih++,0<n&&(t+="H"+n.toString(32)),t+="\xBB"}else n=NG++,t="\xAB"+t+"r"+n.toString(32)+"\xBB";return e.memoizedState=t},useHostTransitionStatus:vv,useFormState:bR,useActionState:bR,useOptimistic:function(e){var t=$n();t.memoizedState=t.baseState=e;var n={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return t.queue=n,t=Iv.bind(null,re,!0,n),n.dispatch=t,[e,t]},useMemoCache:bv,useCacheRefresh:function(){return $n().memoizedState=jG.bind(null,re)}},PC={readContext:hn,use:Rh,useCallback:bC,useContext:hn,useEffect:dC,useImperativeHandle:gC,useInsertionEffect:mC,useLayoutEffect:hC,useMemo:SC,useReducer:Bm,useRef:fC,useState:function(){return Bm(co)},useDebugValue:xv,useDeferredValue:function(e,t){var n=At();return xC(n,Fe.memoizedState,e,t)},useTransition:function(){var e=Bm(co)[0],t=At().memoizedState;return[typeof e=="boolean"?e:of(e),t]},useSyncExternalStore:tC,useId:EC,useHostTransitionStatus:vv,useFormState:SR,useActionState:SR,useOptimistic:function(e,t){var n=At();return aC(n,Fe,e,t)},useMemoCache:bv,useCacheRefresh:wC},BG={readContext:hn,use:Rh,useCallback:bC,useContext:hn,useEffect:dC,useImperativeHandle:gC,useInsertionEffect:mC,useLayoutEffect:hC,useMemo:SC,useReducer:kx,useRef:fC,useState:function(){return kx(co)},useDebugValue:xv,useDeferredValue:function(e,t){var n=At();return Fe===null?Tv(n,e,t):xC(n,Fe.memoizedState,e,t)},useTransition:function(){var e=kx(co)[0],t=At().memoizedState;return[typeof e=="boolean"?e:of(e),t]},useSyncExternalStore:tC,useId:EC,useHostTransitionStatus:vv,useFormState:xR,useActionState:xR,useOptimistic:function(e,t){var n=At();return Fe!==null?aC(n,Fe,e,t):(n.baseState=e,[e,n.queue.dispatch])},useMemoCache:bv,useCacheRefresh:wC},Lc=null,Fp=0;function wm(e){var t=Fp;return Fp+=1,Lc===null&&(Lc=[]),JP(Lc,e,t)}function pp(e,t){t=t.props.ref,e.ref=t!==void 0?t:null}function Mm(e,t){throw t.$$typeof===h8?Error(D(525)):(e=Object.prototype.toString.call(t),Error(D(31,e==="[object Object]"?"object with keys {"+Object.keys(t).join(", ")+"}":e)))}function vR(e){var t=e._init;return t(e._payload)}function CC(e){function t(b,f){if(e){var g=b.deletions;g===null?(b.deletions=[f],b.flags|=16):g.push(f)}}function n(b,f){if(!e)return null;for(;f!==null;)t(b,f),f=f.sibling;return null}function r(b){for(var f=new Map;b!==null;)b.key!==null?f.set(b.key,b):f.set(b.index,b),b=b.sibling;return f}function i(b,f){return b=oo(b,f),b.index=0,b.sibling=null,b}function o(b,f,g){return b.index=g,e?(g=b.alternate,g!==null?(g=g.index,g<f?(b.flags|=67108866,f):g):(b.flags|=67108866,f)):(b.flags|=1048576,f)}function s(b){return e&&b.alternate===null&&(b.flags|=67108866),b}function a(b,f,g,v){return f===null||f.tag!==6?(f=Px(g,b.mode,v),f.return=b,f):(f=i(f,g),f.return=b,f)}function c(b,f,g,v){var I=g.type;return I===xc?p(b,f,g.props.children,v,g.key):f!==null&&(f.elementType===I||typeof I=="object"&&I!==null&&I.$$typeof===zo&&vR(I)===f.type)?(f=i(f,g.props),pp(f,g),f.return=b,f):(f=jm(g.type,g.key,g.props,null,b.mode,v),pp(f,g),f.return=b,f)}function l(b,f,g,v){return f===null||f.tag!==4||f.stateNode.containerInfo!==g.containerInfo||f.stateNode.implementation!==g.implementation?(f=Cx(g,b.mode,v),f.return=b,f):(f=i(f,g.children||[]),f.return=b,f)}function p(b,f,g,v,I){return f===null||f.tag!==7?(f=sa(g,b.mode,v,I),f.return=b,f):(f=i(f,g),f.return=b,f)}function d(b,f,g){if(typeof f=="string"&&f!==""||typeof f=="number"||typeof f=="bigint")return f=Px(""+f,b.mode,g),f.return=b,f;if(typeof f=="object"&&f!==null){switch(f.$$typeof){case ym:return g=jm(f.type,f.key,f.props,null,b.mode,g),pp(g,f),g.return=b,g;case yp:return f=Cx(f,b.mode,g),f.return=b,f;case zo:var v=f._init;return f=v(f._payload),d(b,f,g)}if(gp(f)||cp(f))return f=sa(f,b.mode,g,null),f.return=b,f;if(typeof f.then=="function")return d(b,wm(f),g);if(f.$$typeof===eo)return d(b,Im(b,f),g);Mm(b,f)}return null}function m(b,f,g,v){var I=f!==null?f.key:null;if(typeof g=="string"&&g!==""||typeof g=="number"||typeof g=="bigint")return I!==null?null:a(b,f,""+g,v);if(typeof g=="object"&&g!==null){switch(g.$$typeof){case ym:return g.key===I?c(b,f,g,v):null;case yp:return g.key===I?l(b,f,g,v):null;case zo:return I=g._init,g=I(g._payload),m(b,f,g,v)}if(gp(g)||cp(g))return I!==null?null:p(b,f,g,v,null);if(typeof g.then=="function")return m(b,f,wm(g),v);if(g.$$typeof===eo)return m(b,f,Im(b,g),v);Mm(b,g)}return null}function y(b,f,g,v,I){if(typeof v=="string"&&v!==""||typeof v=="number"||typeof v=="bigint")return b=b.get(g)||null,a(f,b,""+v,I);if(typeof v=="object"&&v!==null){switch(v.$$typeof){case ym:return b=b.get(v.key===null?g:v.key)||null,c(f,b,v,I);case yp:return b=b.get(v.key===null?g:v.key)||null,l(f,b,v,I);case zo:var M=v._init;return v=M(v._payload),y(b,f,g,v,I)}if(gp(v)||cp(v))return b=b.get(g)||null,p(f,b,v,I,null);if(typeof v.then=="function")return y(b,f,g,wm(v),I);if(v.$$typeof===eo)return y(b,f,g,Im(f,v),I);Mm(f,v)}return null}function S(b,f,g,v){for(var I=null,M=null,O=f,C=f=0,z=null;O!==null&&C<g.length;C++){O.index>C?(z=O,O=null):z=O.sibling;var F=m(b,O,g[C],v);if(F===null){O===null&&(O=z);break}e&&O&&F.alternate===null&&t(b,O),f=o(F,f,C),M===null?I=F:M.sibling=F,M=F,O=z}if(C===g.length)return n(b,O),we&&ra(b,C),I;if(O===null){for(;C<g.length;C++)O=d(b,g[C],v),O!==null&&(f=o(O,f,C),M===null?I=O:M.sibling=O,M=O);return we&&ra(b,C),I}for(O=r(O);C<g.length;C++)z=y(O,b,C,g[C],v),z!==null&&(e&&z.alternate!==null&&O.delete(z.key===null?C:z.key),f=o(z,f,C),M===null?I=z:M.sibling=z,M=z);return e&&O.forEach(function(N){return t(b,N)}),we&&ra(b,C),I}function T(b,f,g,v){if(g==null)throw Error(D(151));for(var I=null,M=null,O=f,C=f=0,z=null,F=g.next();O!==null&&!F.done;C++,F=g.next()){O.index>C?(z=O,O=null):z=O.sibling;var N=m(b,O,F.value,v);if(N===null){O===null&&(O=z);break}e&&O&&N.alternate===null&&t(b,O),f=o(N,f,C),M===null?I=N:M.sibling=N,M=N,O=z}if(F.done)return n(b,O),we&&ra(b,C),I;if(O===null){for(;!F.done;C++,F=g.next())F=d(b,F.value,v),F!==null&&(f=o(F,f,C),M===null?I=F:M.sibling=F,M=F);return we&&ra(b,C),I}for(O=r(O);!F.done;C++,F=g.next())F=y(O,b,C,F.value,v),F!==null&&(e&&F.alternate!==null&&O.delete(F.key===null?C:F.key),f=o(F,f,C),M===null?I=F:M.sibling=F,M=F);return e&&O.forEach(function(H){return t(b,H)}),we&&ra(b,C),I}function E(b,f,g,v){if(typeof g=="object"&&g!==null&&g.type===xc&&g.key===null&&(g=g.props.children),typeof g=="object"&&g!==null){switch(g.$$typeof){case ym:e:{for(var I=g.key;f!==null;){if(f.key===I){if(I=g.type,I===xc){if(f.tag===7){n(b,f.sibling),v=i(f,g.props.children),v.return=b,b=v;break e}}else if(f.elementType===I||typeof I=="object"&&I!==null&&I.$$typeof===zo&&vR(I)===f.type){n(b,f.sibling),v=i(f,g.props),pp(v,g),v.return=b,b=v;break e}n(b,f);break}else t(b,f);f=f.sibling}g.type===xc?(v=sa(g.props.children,b.mode,v,g.key),v.return=b,b=v):(v=jm(g.type,g.key,g.props,null,b.mode,v),pp(v,g),v.return=b,b=v)}return s(b);case yp:e:{for(I=g.key;f!==null;){if(f.key===I)if(f.tag===4&&f.stateNode.containerInfo===g.containerInfo&&f.stateNode.implementation===g.implementation){n(b,f.sibling),v=i(f,g.children||[]),v.return=b,b=v;break e}else{n(b,f);break}else t(b,f);f=f.sibling}v=Cx(g,b.mode,v),v.return=b,b=v}return s(b);case zo:return I=g._init,g=I(g._payload),E(b,f,g,v)}if(gp(g))return S(b,f,g,v);if(cp(g)){if(I=cp(g),typeof I!="function")throw Error(D(150));return g=I.call(g),T(b,f,g,v)}if(typeof g.then=="function")return E(b,f,wm(g),v);if(g.$$typeof===eo)return E(b,f,Im(b,g),v);Mm(b,g)}return typeof g=="string"&&g!==""||typeof g=="number"||typeof g=="bigint"?(g=""+g,f!==null&&f.tag===6?(n(b,f.sibling),v=i(f,g),v.return=b,b=v):(n(b,f),v=Px(g,b.mode,v),v.return=b,b=v),s(b)):n(b,f)}return function(b,f,g,v){try{Fp=0;var I=E(b,f,g,v);return Lc=null,I}catch(O){if(O===rf||O===Ah)throw O;var M=cr(29,O,null,b.mode);return M.lanes=v,M.return=b,M}finally{}}}var qc=CC(!0),NC=CC(!1),_r=Ii(null),vi=null;function qo(e){var t=e.alternate;rt(jt,jt.current&1),rt(_r,e),vi===null&&(t===null||Hc.current!==null||t.memoizedState!==null)&&(vi=e)}function kC(e){if(e.tag===22){if(rt(jt,jt.current),rt(_r,e),vi===null){var t=e.alternate;t!==null&&t.memoizedState!==null&&(vi=e)}}else Vo(e)}function Vo(){rt(jt,jt.current),rt(_r,_r.current)}function io(e){Yt(_r),vi===e&&(vi=null),Yt(jt)}var jt=Ii(0);function sh(e){for(var t=e;t!==null;){if(t.tag===13){var n=t.memoizedState;if(n!==null&&(n=n.dehydrated,n===null||n.data==="$?"||FT(n)))return t}else if(t.tag===19&&t.memoizedProps.revealOrder!==void 0){if(t.flags&128)return t}else if(t.child!==null){t.child.return=t,t=t.child;continue}if(t===e)break;for(;t.sibling===null;){if(t.return===null||t.return===e)return null;t=t.return}t.sibling.return=t.return,t=t.sibling}return null}function Dx(e,t,n,r){t=e.memoizedState,n=n(r,t),n=n==null?t:We({},t,n),e.memoizedState=n,e.lanes===0&&(e.updateQueue.baseState=n)}var ET={enqueueSetState:function(e,t,n){e=e._reactInternals;var r=pr(),i=es(r);i.payload=t,n!=null&&(i.callback=n),t=ts(e,i,r),t!==null&&(fr(t,e,r),wp(t,e,r))},enqueueReplaceState:function(e,t,n){e=e._reactInternals;var r=pr(),i=es(r);i.tag=1,i.payload=t,n!=null&&(i.callback=n),t=ts(e,i,r),t!==null&&(fr(t,e,r),wp(t,e,r))},enqueueForceUpdate:function(e,t){e=e._reactInternals;var n=pr(),r=es(n);r.tag=2,t!=null&&(r.callback=t),t=ts(e,r,n),t!==null&&(fr(t,e,n),wp(t,e,n))}};function IR(e,t,n,r,i,o,s){return e=e.stateNode,typeof e.shouldComponentUpdate=="function"?e.shouldComponentUpdate(r,o,s):t.prototype&&t.prototype.isPureReactComponent?!jp(n,r)||!jp(i,o):!0}function ER(e,t,n,r){e=t.state,typeof t.componentWillReceiveProps=="function"&&t.componentWillReceiveProps(n,r),typeof t.UNSAFE_componentWillReceiveProps=="function"&&t.UNSAFE_componentWillReceiveProps(n,r),t.state!==e&&ET.enqueueReplaceState(t,t.state,null)}function ha(e,t){var n=t;if("ref"in t){n={};for(var r in t)r!=="ref"&&(n[r]=t[r])}if(e=e.defaultProps){n===t&&(n=We({},n));for(var i in e)n[i]===void 0&&(n[i]=e[i])}return n}var ah=typeof reportError=="function"?reportError:function(e){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var t=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof e=="object"&&e!==null&&typeof e.message=="string"?String(e.message):String(e),error:e});if(!window.dispatchEvent(t))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",e);return}console.error(e)};function DC(e){ah(e)}function UC(e){console.error(e)}function _C(e){ah(e)}function ch(e,t){try{var n=e.onUncaughtError;n(t.value,{componentStack:t.stack})}catch(r){setTimeout(function(){throw r})}}function wR(e,t,n){try{var r=e.onCaughtError;r(n.value,{componentStack:n.stack,errorBoundary:t.tag===1?t.stateNode:null})}catch(i){setTimeout(function(){throw i})}}function wT(e,t,n){return n=es(n),n.tag=3,n.payload={element:null},n.callback=function(){ch(e,t)},n}function jC(e){return e=es(e),e.tag=3,e}function LC(e,t,n,r){var i=n.type.getDerivedStateFromError;if(typeof i=="function"){var o=r.value;e.payload=function(){return i(o)},e.callback=function(){wR(t,n,r)}}var s=n.stateNode;s!==null&&typeof s.componentDidCatch=="function"&&(e.callback=function(){wR(t,n,r),typeof i!="function"&&(ns===null?ns=new Set([this]):ns.add(this));var a=r.stack;this.componentDidCatch(r.value,{componentStack:a!==null?a:""})})}function FG(e,t,n,r,i){if(n.flags|=32768,r!==null&&typeof r=="object"&&typeof r.then=="function"){if(t=n.alternate,t!==null&&tf(t,n,i,!0),n=_r.current,n!==null){switch(n.tag){case 13:return vi===null?kT():n.alternate===null&&ft===0&&(ft=3),n.flags&=-257,n.flags|=65536,n.lanes=i,r===gT?n.flags|=16384:(t=n.updateQueue,t===null?n.updateQueue=new Set([r]):t.add(r),Gx(e,r,i)),!1;case 22:return n.flags|=65536,r===gT?n.flags|=16384:(t=n.updateQueue,t===null?(t={transitions:null,markerInstances:null,retryQueue:new Set([r])},n.updateQueue=t):(n=t.retryQueue,n===null?t.retryQueue=new Set([r]):n.add(r)),Gx(e,r,i)),!1}throw Error(D(435,n.tag))}return Gx(e,r,i),kT(),!1}if(we)return t=_r.current,t!==null?(!(t.flags&65536)&&(t.flags|=256),t.flags|=65536,t.lanes=i,r!==fT&&(e=Error(D(422),{cause:r}),Lp(Dr(e,n)))):(r!==fT&&(t=Error(D(423),{cause:r}),Lp(Dr(t,n))),e=e.current.alternate,e.flags|=65536,i&=-i,e.lanes|=i,r=Dr(r,n),i=wT(e.stateNode,r,i),Nx(e,i),ft!==4&&(ft=2)),!1;var o=Error(D(520),{cause:r});if(o=Dr(o,n),Cp===null?Cp=[o]:Cp.push(o),ft!==4&&(ft=2),t===null)return!0;r=Dr(r,n),n=t;do{switch(n.tag){case 3:return n.flags|=65536,e=i&-i,n.lanes|=e,e=wT(n.stateNode,r,e),Nx(n,e),!1;case 1:if(t=n.type,o=n.stateNode,(n.flags&128)===0&&(typeof t.getDerivedStateFromError=="function"||o!==null&&typeof o.componentDidCatch=="function"&&(ns===null||!ns.has(o))))return n.flags|=65536,i&=-i,n.lanes|=i,i=jC(i),LC(i,e,n,r),Nx(n,i),!1}n=n.return}while(n!==null);return!1}var BC=Error(D(461)),Qt=!1;function nn(e,t,n,r){t.child=e===null?NC(t,null,n,r):qc(t,e.child,n,r)}function MR(e,t,n,r,i){n=n.render;var o=t.ref;if("ref"in r){var s={};for(var a in r)a!=="ref"&&(s[a]=r[a])}else s=r;return da(t),r=dv(e,t,n,s,o,i),a=mv(),e!==null&&!Qt?(hv(e,t,i),uo(e,t,i)):(we&&a&&sv(t),t.flags|=1,nn(e,t,r,i),t.child)}function OR(e,t,n,r,i){if(e===null){var o=n.type;return typeof o=="function"&&!ov(o)&&o.defaultProps===void 0&&n.compare===null?(t.tag=15,t.type=o,FC(e,t,o,r,i)):(e=jm(n.type,null,r,t,t.mode,i),e.ref=t.ref,e.return=t,t.child=e)}if(o=e.child,!Ev(e,i)){var s=o.memoizedProps;if(n=n.compare,n=n!==null?n:jp,n(s,r)&&e.ref===t.ref)return uo(e,t,i)}return t.flags|=1,e=oo(o,r),e.ref=t.ref,e.return=t,t.child=e}function FC(e,t,n,r,i){if(e!==null){var o=e.memoizedProps;if(jp(o,r)&&e.ref===t.ref)if(Qt=!1,t.pendingProps=r=o,Ev(e,i))e.flags&131072&&(Qt=!0);else return t.lanes=e.lanes,uo(e,t,i)}return MT(e,t,n,r,i)}function $C(e,t,n){var r=t.pendingProps,i=r.children,o=e!==null?e.memoizedState:null;if(r.mode==="hidden"){if(t.flags&128){if(r=o!==null?o.baseLanes|n:n,e!==null){for(i=t.child=e.child,o=0;i!==null;)o=o|i.lanes|i.childLanes,i=i.sibling;t.childLanes=o&~r}else t.childLanes=0,t.child=null;return AR(e,t,r,n)}if(n&536870912)t.memoizedState={baseLanes:0,cachePool:null},e!==null&&Lm(t,o!==null?o.cachePool:null),o!==null?hR(t,o):xT(),kC(t);else return t.lanes=t.childLanes=536870912,AR(e,t,o!==null?o.baseLanes|n:n,n)}else o!==null?(Lm(t,o.cachePool),hR(t,o),Vo(t),t.memoizedState=null):(e!==null&&Lm(t,null),xT(),Vo(t));return nn(e,t,i,n),t.child}function AR(e,t,n,r){var i=uv();return i=i===null?null:{parent:_t._currentValue,pool:i},t.memoizedState={baseLanes:n,cachePool:i},e!==null&&Lm(t,null),xT(),kC(t),e!==null&&tf(e,t,r,!0),null}function $m(e,t){var n=t.ref;if(n===null)e!==null&&e.ref!==null&&(t.flags|=4194816);else{if(typeof n!="function"&&typeof n!="object")throw Error(D(284));(e===null||e.ref!==n)&&(t.flags|=4194816)}}function MT(e,t,n,r,i){return da(t),n=dv(e,t,n,r,void 0,i),r=mv(),e!==null&&!Qt?(hv(e,t,i),uo(e,t,i)):(we&&r&&sv(t),t.flags|=1,nn(e,t,n,i),t.child)}function RR(e,t,n,r,i,o){return da(t),t.updateQueue=null,n=eC(t,r,n,i),WP(e),r=mv(),e!==null&&!Qt?(hv(e,t,o),uo(e,t,o)):(we&&r&&sv(t),t.flags|=1,nn(e,t,n,o),t.child)}function PR(e,t,n,r,i){if(da(t),t.stateNode===null){var o=Ac,s=n.contextType;typeof s=="object"&&s!==null&&(o=hn(s)),o=new n(r,o),t.memoizedState=o.state!==null&&o.state!==void 0?o.state:null,o.updater=ET,t.stateNode=o,o._reactInternals=t,o=t.stateNode,o.props=r,o.state=t.memoizedState,o.refs={},lv(t),s=n.contextType,o.context=typeof s=="object"&&s!==null?hn(s):Ac,o.state=t.memoizedState,s=n.getDerivedStateFromProps,typeof s=="function"&&(Dx(t,n,s,r),o.state=t.memoizedState),typeof n.getDerivedStateFromProps=="function"||typeof o.getSnapshotBeforeUpdate=="function"||typeof o.UNSAFE_componentWillMount!="function"&&typeof o.componentWillMount!="function"||(s=o.state,typeof o.componentWillMount=="function"&&o.componentWillMount(),typeof o.UNSAFE_componentWillMount=="function"&&o.UNSAFE_componentWillMount(),s!==o.state&&ET.enqueueReplaceState(o,o.state,null),Op(t,r,o,i),Mp(),o.state=t.memoizedState),typeof o.componentDidMount=="function"&&(t.flags|=4194308),r=!0}else if(e===null){o=t.stateNode;var a=t.memoizedProps,c=ha(n,a);o.props=c;var l=o.context,p=n.contextType;s=Ac,typeof p=="object"&&p!==null&&(s=hn(p));var d=n.getDerivedStateFromProps;p=typeof d=="function"||typeof o.getSnapshotBeforeUpdate=="function",a=t.pendingProps!==a,p||typeof o.UNSAFE_componentWillReceiveProps!="function"&&typeof o.componentWillReceiveProps!="function"||(a||l!==s)&&ER(t,o,r,s),Ho=!1;var m=t.memoizedState;o.state=m,Op(t,r,o,i),Mp(),l=t.memoizedState,a||m!==l||Ho?(typeof d=="function"&&(Dx(t,n,d,r),l=t.memoizedState),(c=Ho||IR(t,n,c,r,m,l,s))?(p||typeof o.UNSAFE_componentWillMount!="function"&&typeof o.componentWillMount!="function"||(typeof o.componentWillMount=="function"&&o.componentWillMount(),typeof o.UNSAFE_componentWillMount=="function"&&o.UNSAFE_componentWillMount()),typeof o.componentDidMount=="function"&&(t.flags|=4194308)):(typeof o.componentDidMount=="function"&&(t.flags|=4194308),t.memoizedProps=r,t.memoizedState=l),o.props=r,o.state=l,o.context=s,r=c):(typeof o.componentDidMount=="function"&&(t.flags|=4194308),r=!1)}else{o=t.stateNode,bT(e,t),s=t.memoizedProps,p=ha(n,s),o.props=p,d=t.pendingProps,m=o.context,l=n.contextType,c=Ac,typeof l=="object"&&l!==null&&(c=hn(l)),a=n.getDerivedStateFromProps,(l=typeof a=="function"||typeof o.getSnapshotBeforeUpdate=="function")||typeof o.UNSAFE_componentWillReceiveProps!="function"&&typeof o.componentWillReceiveProps!="function"||(s!==d||m!==c)&&ER(t,o,r,c),Ho=!1,m=t.memoizedState,o.state=m,Op(t,r,o,i),Mp();var y=t.memoizedState;s!==d||m!==y||Ho||e!==null&&e.dependencies!==null&&th(e.dependencies)?(typeof a=="function"&&(Dx(t,n,a,r),y=t.memoizedState),(p=Ho||IR(t,n,p,r,m,y,c)||e!==null&&e.dependencies!==null&&th(e.dependencies))?(l||typeof o.UNSAFE_componentWillUpdate!="function"&&typeof o.componentWillUpdate!="function"||(typeof o.componentWillUpdate=="function"&&o.componentWillUpdate(r,y,c),typeof o.UNSAFE_componentWillUpdate=="function"&&o.UNSAFE_componentWillUpdate(r,y,c)),typeof o.componentDidUpdate=="function"&&(t.flags|=4),typeof o.getSnapshotBeforeUpdate=="function"&&(t.flags|=1024)):(typeof o.componentDidUpdate!="function"||s===e.memoizedProps&&m===e.memoizedState||(t.flags|=4),typeof o.getSnapshotBeforeUpdate!="function"||s===e.memoizedProps&&m===e.memoizedState||(t.flags|=1024),t.memoizedProps=r,t.memoizedState=y),o.props=r,o.state=y,o.context=c,r=p):(typeof o.componentDidUpdate!="function"||s===e.memoizedProps&&m===e.memoizedState||(t.flags|=4),typeof o.getSnapshotBeforeUpdate!="function"||s===e.memoizedProps&&m===e.memoizedState||(t.flags|=1024),r=!1)}return o=r,$m(e,t),r=(t.flags&128)!==0,o||r?(o=t.stateNode,n=r&&typeof n.getDerivedStateFromError!="function"?null:o.render(),t.flags|=1,e!==null&&r?(t.child=qc(t,e.child,null,i),t.child=qc(t,null,n,i)):nn(e,t,n,i),t.memoizedState=o.state,e=t.child):e=uo(e,t,i),e}function CR(e,t,n,r){return ef(),t.flags|=256,nn(e,t,n,r),t.child}var Ux={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function _x(e){return{baseLanes:e,cachePool:QP()}}function jx(e,t,n){return e=e!==null?e.childLanes&~n:0,t&&(e|=Ur),e}function KC(e,t,n){var r=t.pendingProps,i=!1,o=(t.flags&128)!==0,s;if((s=o)||(s=e!==null&&e.memoizedState===null?!1:(jt.current&2)!==0),s&&(i=!0,t.flags&=-129),s=(t.flags&32)!==0,t.flags&=-33,e===null){if(we){if(i?qo(t):Vo(t),we){var a=pt,c;if(c=a){e:{for(c=a,a=bi;c.nodeType!==8;){if(!a){a=null;break e}if(c=Wr(c.nextSibling),c===null){a=null;break e}}a=c}a!==null?(t.memoizedState={dehydrated:a,treeContext:aa!==null?{id:to,overflow:no}:null,retryLane:536870912,hydrationErrors:null},c=cr(18,null,null,0),c.stateNode=a,c.return=t,t.child=c,Mn=t,pt=null,c=!0):c=!1}c||fa(t)}if(a=t.memoizedState,a!==null&&(a=a.dehydrated,a!==null))return FT(a)?t.lanes=32:t.lanes=536870912,null;io(t)}return a=r.children,r=r.fallback,i?(Vo(t),i=t.mode,a=uh({mode:"hidden",children:a},i),r=sa(r,i,n,null),a.return=t,r.return=t,a.sibling=r,t.child=a,i=t.child,i.memoizedState=_x(n),i.childLanes=jx(e,s,n),t.memoizedState=Ux,r):(qo(t),OT(t,a))}if(c=e.memoizedState,c!==null&&(a=c.dehydrated,a!==null)){if(o)t.flags&256?(qo(t),t.flags&=-257,t=Lx(e,t,n)):t.memoizedState!==null?(Vo(t),t.child=e.child,t.flags|=128,t=null):(Vo(t),i=r.fallback,a=t.mode,r=uh({mode:"visible",children:r.children},a),i=sa(i,a,n,null),i.flags|=2,r.return=t,i.return=t,r.sibling=i,t.child=r,qc(t,e.child,null,n),r=t.child,r.memoizedState=_x(n),r.childLanes=jx(e,s,n),t.memoizedState=Ux,t=i);else if(qo(t),FT(a)){if(s=a.nextSibling&&a.nextSibling.dataset,s)var l=s.dgst;s=l,r=Error(D(419)),r.stack="",r.digest=s,Lp({value:r,source:null,stack:null}),t=Lx(e,t,n)}else if(Qt||tf(e,t,n,!1),s=(n&e.childLanes)!==0,Qt||s){if(s=Xe,s!==null&&(r=n&-n,r=r&42?1:QT(r),r=r&(s.suspendedLanes|n)?0:r,r!==0&&r!==c.retryLane))throw c.retryLane=r,Wc(e,r),fr(s,e,r),BC;a.data==="$?"||kT(),t=Lx(e,t,n)}else a.data==="$?"?(t.flags|=192,t.child=e.child,t=null):(e=c.treeContext,pt=Wr(a.nextSibling),Mn=t,we=!0,ca=null,bi=!1,e!==null&&(Cr[Nr++]=to,Cr[Nr++]=no,Cr[Nr++]=aa,to=e.id,no=e.overflow,aa=t),t=OT(t,r.children),t.flags|=4096);return t}return i?(Vo(t),i=r.fallback,a=t.mode,c=e.child,l=c.sibling,r=oo(c,{mode:"hidden",children:r.children}),r.subtreeFlags=c.subtreeFlags&65011712,l!==null?i=oo(l,i):(i=sa(i,a,n,null),i.flags|=2),i.return=t,r.return=t,r.sibling=i,t.child=r,r=i,i=t.child,a=e.child.memoizedState,a===null?a=_x(n):(c=a.cachePool,c!==null?(l=_t._currentValue,c=c.parent!==l?{parent:l,pool:l}:c):c=QP(),a={baseLanes:a.baseLanes|n,cachePool:c}),i.memoizedState=a,i.childLanes=jx(e,s,n),t.memoizedState=Ux,r):(qo(t),n=e.child,e=n.sibling,n=oo(n,{mode:"visible",children:r.children}),n.return=t,n.sibling=null,e!==null&&(s=t.deletions,s===null?(t.deletions=[e],t.flags|=16):s.push(e)),t.child=n,t.memoizedState=null,n)}function OT(e,t){return t=uh({mode:"visible",children:t},e.mode),t.return=e,e.child=t}function uh(e,t){return e=cr(22,e,null,t),e.lanes=0,e.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null},e}function Lx(e,t,n){return qc(t,e.child,null,n),e=OT(t,t.pendingProps.children),e.flags|=2,t.memoizedState=null,e}function NR(e,t,n){e.lanes|=t;var r=e.alternate;r!==null&&(r.lanes|=t),mT(e.return,t,n)}function Bx(e,t,n,r,i){var o=e.memoizedState;o===null?e.memoizedState={isBackwards:t,rendering:null,renderingStartTime:0,last:r,tail:n,tailMode:i}:(o.isBackwards=t,o.rendering=null,o.renderingStartTime=0,o.last=r,o.tail=n,o.tailMode=i)}function zC(e,t,n){var r=t.pendingProps,i=r.revealOrder,o=r.tail;if(nn(e,t,r.children,n),r=jt.current,r&2)r=r&1|2,t.flags|=128;else{if(e!==null&&e.flags&128)e:for(e=t.child;e!==null;){if(e.tag===13)e.memoizedState!==null&&NR(e,n,t);else if(e.tag===19)NR(e,n,t);else if(e.child!==null){e.child.return=e,e=e.child;continue}if(e===t)break e;for(;e.sibling===null;){if(e.return===null||e.return===t)break e;e=e.return}e.sibling.return=e.return,e=e.sibling}r&=1}switch(rt(jt,r),i){case"forwards":for(n=t.child,i=null;n!==null;)e=n.alternate,e!==null&&sh(e)===null&&(i=n),n=n.sibling;n=i,n===null?(i=t.child,t.child=null):(i=n.sibling,n.sibling=null),Bx(t,!1,i,n,o);break;case"backwards":for(n=null,i=t.child,t.child=null;i!==null;){if(e=i.alternate,e!==null&&sh(e)===null){t.child=i;break}e=i.sibling,i.sibling=n,n=i,i=e}Bx(t,!0,n,null,o);break;case"together":Bx(t,!1,null,null,void 0);break;default:t.memoizedState=null}return t.child}function uo(e,t,n){if(e!==null&&(t.dependencies=e.dependencies),us|=t.lanes,!(n&t.childLanes))if(e!==null){if(tf(e,t,n,!1),(n&t.childLanes)===0)return null}else return null;if(e!==null&&t.child!==e.child)throw Error(D(153));if(t.child!==null){for(e=t.child,n=oo(e,e.pendingProps),t.child=n,n.return=t;e.sibling!==null;)e=e.sibling,n=n.sibling=oo(e,e.pendingProps),n.return=t;n.sibling=null}return t.child}function Ev(e,t){return e.lanes&t?!0:(e=e.dependencies,!!(e!==null&&th(e)))}function $G(e,t,n){switch(t.tag){case 3:Vm(t,t.stateNode.containerInfo),Go(t,_t,e.memoizedState.cache),ef();break;case 27:case 5:nT(t);break;case 4:Vm(t,t.stateNode.containerInfo);break;case 10:Go(t,t.type,t.memoizedProps.value);break;case 13:var r=t.memoizedState;if(r!==null)return r.dehydrated!==null?(qo(t),t.flags|=128,null):n&t.child.childLanes?KC(e,t,n):(qo(t),e=uo(e,t,n),e!==null?e.sibling:null);qo(t);break;case 19:var i=(e.flags&128)!==0;if(r=(n&t.childLanes)!==0,r||(tf(e,t,n,!1),r=(n&t.childLanes)!==0),i){if(r)return zC(e,t,n);t.flags|=128}if(i=t.memoizedState,i!==null&&(i.rendering=null,i.tail=null,i.lastEffect=null),rt(jt,jt.current),r)break;return null;case 22:case 23:return t.lanes=0,$C(e,t,n);case 24:Go(t,_t,e.memoizedState.cache)}return uo(e,t,n)}function HC(e,t,n){if(e!==null)if(e.memoizedProps!==t.pendingProps)Qt=!0;else{if(!Ev(e,n)&&!(t.flags&128))return Qt=!1,$G(e,t,n);Qt=!!(e.flags&131072)}else Qt=!1,we&&t.flags&1048576&&qP(t,eh,t.index);switch(t.lanes=0,t.tag){case 16:e:{e=t.pendingProps;var r=t.elementType,i=r._init;if(r=i(r._payload),t.type=r,typeof r=="function")ov(r)?(e=ha(r,e),t.tag=1,t=PR(null,t,r,e,n)):(t.tag=0,t=MT(null,t,r,e,n));else{if(r!=null){if(i=r.$$typeof,i===GT){t.tag=11,t=MR(null,t,r,e,n);break e}else if(i===qT){t.tag=14,t=OR(null,t,r,e,n);break e}}throw t=eT(r)||r,Error(D(306,t,""))}}return t;case 0:return MT(e,t,t.type,t.pendingProps,n);case 1:return r=t.type,i=ha(r,t.pendingProps),PR(e,t,r,i,n);case 3:e:{if(Vm(t,t.stateNode.containerInfo),e===null)throw Error(D(387));r=t.pendingProps;var o=t.memoizedState;i=o.element,bT(e,t),Op(t,r,null,n);var s=t.memoizedState;if(r=s.cache,Go(t,_t,r),r!==o.cache&&hT(t,[_t],n,!0),Mp(),r=s.element,o.isDehydrated)if(o={element:r,isDehydrated:!1,cache:s.cache},t.updateQueue.baseState=o,t.memoizedState=o,t.flags&256){t=CR(e,t,r,n);break e}else if(r!==i){i=Dr(Error(D(424)),t),Lp(i),t=CR(e,t,r,n);break e}else{switch(e=t.stateNode.containerInfo,e.nodeType){case 9:e=e.body;break;default:e=e.nodeName==="HTML"?e.ownerDocument.body:e}for(pt=Wr(e.firstChild),Mn=t,we=!0,ca=null,bi=!0,n=NC(t,null,r,n),t.child=n;n;)n.flags=n.flags&-3|4096,n=n.sibling}else{if(ef(),r===i){t=uo(e,t,n);break e}nn(e,t,r,n)}t=t.child}return t;case 26:return $m(e,t),e===null?(n=XR(t.type,null,t.pendingProps,null))?t.memoizedState=n:we||(n=t.type,e=t.pendingProps,r=yh(Wo.current).createElement(n),r[mn]=t,r[Hn]=e,on(r,n,e),Vt(r),t.stateNode=r):t.memoizedState=XR(t.type,e.memoizedProps,t.pendingProps,e.memoizedState),null;case 27:return nT(t),e===null&&we&&(r=t.stateNode=P1(t.type,t.pendingProps,Wo.current),Mn=t,bi=!0,i=pt,ps(t.type)?($T=i,pt=Wr(r.firstChild)):pt=i),nn(e,t,t.pendingProps.children,n),$m(e,t),e===null&&(t.flags|=4194304),t.child;case 5:return e===null&&we&&((i=r=pt)&&(r=dq(r,t.type,t.pendingProps,bi),r!==null?(t.stateNode=r,Mn=t,pt=Wr(r.firstChild),bi=!1,i=!0):i=!1),i||fa(t)),nT(t),i=t.type,o=t.pendingProps,s=e!==null?e.memoizedProps:null,r=o.children,LT(i,o)?r=null:s!==null&&LT(i,s)&&(t.flags|=32),t.memoizedState!==null&&(i=dv(e,t,kG,null,null,n),Hp._currentValue=i),$m(e,t),nn(e,t,r,n),t.child;case 6:return e===null&&we&&((e=n=pt)&&(n=mq(n,t.pendingProps,bi),n!==null?(t.stateNode=n,Mn=t,pt=null,e=!0):e=!1),e||fa(t)),null;case 13:return KC(e,t,n);case 4:return Vm(t,t.stateNode.containerInfo),r=t.pendingProps,e===null?t.child=qc(t,null,r,n):nn(e,t,r,n),t.child;case 11:return MR(e,t,t.type,t.pendingProps,n);case 7:return nn(e,t,t.pendingProps,n),t.child;case 8:return nn(e,t,t.pendingProps.children,n),t.child;case 12:return nn(e,t,t.pendingProps.children,n),t.child;case 10:return r=t.pendingProps,Go(t,t.type,r.value),nn(e,t,r.children,n),t.child;case 9:return i=t.type._context,r=t.pendingProps.children,da(t),i=hn(i),r=r(i),t.flags|=1,nn(e,t,r,n),t.child;case 14:return OR(e,t,t.type,t.pendingProps,n);case 15:return FC(e,t,t.type,t.pendingProps,n);case 19:return zC(e,t,n);case 31:return r=t.pendingProps,n=t.mode,r={mode:r.mode,children:r.children},e===null?(n=uh(r,n),n.ref=t.ref,t.child=n,n.return=t,t=n):(n=oo(e.child,r),n.ref=t.ref,t.child=n,n.return=t,t=n),t;case 22:return $C(e,t,n);case 24:return da(t),r=hn(_t),e===null?(i=uv(),i===null&&(i=Xe,o=cv(),i.pooledCache=o,o.refCount++,o!==null&&(i.pooledCacheLanes|=n),i=o),t.memoizedState={parent:r,cache:i},lv(t),Go(t,_t,i)):(e.lanes&n&&(bT(e,t),Op(t,null,null,n),Mp()),i=e.memoizedState,o=t.memoizedState,i.parent!==r?(i={parent:r,cache:r},t.memoizedState=i,t.lanes===0&&(t.memoizedState=t.updateQueue.baseState=i),Go(t,_t,r)):(r=o.cache,Go(t,_t,r),r!==i.cache&&hT(t,[_t],n,!0))),nn(e,t,t.pendingProps.children,n),t.child;case 29:throw t.pendingProps}throw Error(D(156,t.tag))}function Xi(e){e.flags|=4}function kR(e,t){if(t.type!=="stylesheet"||t.state.loading&4)e.flags&=-16777217;else if(e.flags|=16777216,!k1(t)){if(t=_r.current,t!==null&&((Se&4194048)===Se?vi!==null:(Se&62914560)!==Se&&!(Se&536870912)||t!==vi))throw Ep=gT,YP;e.flags|=8192}}function Om(e,t){t!==null&&(e.flags|=4),e.flags&16384&&(t=e.tag!==22?yP():536870912,e.lanes|=t,Vc|=t)}function fp(e,t){if(!we)switch(e.tailMode){case"hidden":t=e.tail;for(var n=null;t!==null;)t.alternate!==null&&(n=t),t=t.sibling;n===null?e.tail=null:n.sibling=null;break;case"collapsed":n=e.tail;for(var r=null;n!==null;)n.alternate!==null&&(r=n),n=n.sibling;r===null?t||e.tail===null?e.tail=null:e.tail.sibling=null:r.sibling=null}}function at(e){var t=e.alternate!==null&&e.alternate.child===e.child,n=0,r=0;if(t)for(var i=e.child;i!==null;)n|=i.lanes|i.childLanes,r|=i.subtreeFlags&65011712,r|=i.flags&65011712,i.return=e,i=i.sibling;else for(i=e.child;i!==null;)n|=i.lanes|i.childLanes,r|=i.subtreeFlags,r|=i.flags,i.return=e,i=i.sibling;return e.subtreeFlags|=r,e.childLanes=n,t}function KG(e,t,n){var r=t.pendingProps;switch(av(t),t.tag){case 31:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return at(t),null;case 1:return at(t),null;case 3:return n=t.stateNode,r=null,e!==null&&(r=e.memoizedState.cache),t.memoizedState.cache!==r&&(t.flags|=2048),so(_t),Fc(),n.pendingContext&&(n.context=n.pendingContext,n.pendingContext=null),(e===null||e.child===null)&&(lp(t)?Xi(t):e===null||e.memoizedState.isDehydrated&&!(t.flags&256)||(t.flags|=1024,uR())),at(t),null;case 26:return n=t.memoizedState,e===null?(Xi(t),n!==null?(at(t),kR(t,n)):(at(t),t.flags&=-16777217)):n?n!==e.memoizedState?(Xi(t),at(t),kR(t,n)):(at(t),t.flags&=-16777217):(e.memoizedProps!==r&&Xi(t),at(t),t.flags&=-16777217),null;case 27:Qm(t),n=Wo.current;var i=t.type;if(e!==null&&t.stateNode!=null)e.memoizedProps!==r&&Xi(t);else{if(!r){if(t.stateNode===null)throw Error(D(166));return at(t),null}e=xi.current,lp(t)?aR(t,e):(e=P1(i,r,n),t.stateNode=e,Xi(t))}return at(t),null;case 5:if(Qm(t),n=t.type,e!==null&&t.stateNode!=null)e.memoizedProps!==r&&Xi(t);else{if(!r){if(t.stateNode===null)throw Error(D(166));return at(t),null}if(e=xi.current,lp(t))aR(t,e);else{switch(i=yh(Wo.current),e){case 1:e=i.createElementNS("http://www.w3.org/2000/svg",n);break;case 2:e=i.createElementNS("http://www.w3.org/1998/Math/MathML",n);break;default:switch(n){case"svg":e=i.createElementNS("http://www.w3.org/2000/svg",n);break;case"math":e=i.createElementNS("http://www.w3.org/1998/Math/MathML",n);break;case"script":e=i.createElement("div"),e.innerHTML="<script><\/script>",e=e.removeChild(e.firstChild);break;case"select":e=typeof r.is=="string"?i.createElement("select",{is:r.is}):i.createElement("select"),r.multiple?e.multiple=!0:r.size&&(e.size=r.size);break;default:e=typeof r.is=="string"?i.createElement(n,{is:r.is}):i.createElement(n)}}e[mn]=t,e[Hn]=r;e:for(i=t.child;i!==null;){if(i.tag===5||i.tag===6)e.appendChild(i.stateNode);else if(i.tag!==4&&i.tag!==27&&i.child!==null){i.child.return=i,i=i.child;continue}if(i===t)break e;for(;i.sibling===null;){if(i.return===null||i.return===t)break e;i=i.return}i.sibling.return=i.return,i=i.sibling}t.stateNode=e;e:switch(on(e,n,r),n){case"button":case"input":case"select":case"textarea":e=!!r.autoFocus;break e;case"img":e=!0;break e;default:e=!1}e&&Xi(t)}}return at(t),t.flags&=-16777217,null;case 6:if(e&&t.stateNode!=null)e.memoizedProps!==r&&Xi(t);else{if(typeof r!="string"&&t.stateNode===null)throw Error(D(166));if(e=Wo.current,lp(t)){if(e=t.stateNode,n=t.memoizedProps,r=null,i=Mn,i!==null)switch(i.tag){case 27:case 5:r=i.memoizedProps}e[mn]=t,e=!!(e.nodeValue===n||r!==null&&r.suppressHydrationWarning===!0||O1(e.nodeValue,n)),e||fa(t)}else e=yh(e).createTextNode(r),e[mn]=t,t.stateNode=e}return at(t),null;case 13:if(r=t.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(i=lp(t),r!==null&&r.dehydrated!==null){if(e===null){if(!i)throw Error(D(318));if(i=t.memoizedState,i=i!==null?i.dehydrated:null,!i)throw Error(D(317));i[mn]=t}else ef(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;at(t),i=!1}else i=uR(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=i),i=!0;if(!i)return t.flags&256?(io(t),t):(io(t),null)}if(io(t),t.flags&128)return t.lanes=n,t;if(n=r!==null,e=e!==null&&e.memoizedState!==null,n){r=t.child,i=null,r.alternate!==null&&r.alternate.memoizedState!==null&&r.alternate.memoizedState.cachePool!==null&&(i=r.alternate.memoizedState.cachePool.pool);var o=null;r.memoizedState!==null&&r.memoizedState.cachePool!==null&&(o=r.memoizedState.cachePool.pool),o!==i&&(r.flags|=2048)}return n!==e&&n&&(t.child.flags|=8192),Om(t,t.updateQueue),at(t),null;case 4:return Fc(),e===null&&Nv(t.stateNode.containerInfo),at(t),null;case 10:return so(t.type),at(t),null;case 19:if(Yt(jt),i=t.memoizedState,i===null)return at(t),null;if(r=(t.flags&128)!==0,o=i.rendering,o===null)if(r)fp(i,!1);else{if(ft!==0||e!==null&&e.flags&128)for(e=t.child;e!==null;){if(o=sh(e),o!==null){for(t.flags|=128,fp(i,!1),e=o.updateQueue,t.updateQueue=e,Om(t,e),t.subtreeFlags=0,e=n,n=t.child;n!==null;)GP(n,e),n=n.sibling;return rt(jt,jt.current&1|2),t.child}e=e.sibling}i.tail!==null&&Ti()>ph&&(t.flags|=128,r=!0,fp(i,!1),t.lanes=4194304)}else{if(!r)if(e=sh(o),e!==null){if(t.flags|=128,r=!0,e=e.updateQueue,t.updateQueue=e,Om(t,e),fp(i,!0),i.tail===null&&i.tailMode==="hidden"&&!o.alternate&&!we)return at(t),null}else 2*Ti()-i.renderingStartTime>ph&&n!==536870912&&(t.flags|=128,r=!0,fp(i,!1),t.lanes=4194304);i.isBackwards?(o.sibling=t.child,t.child=o):(e=i.last,e!==null?e.sibling=o:t.child=o,i.last=o)}return i.tail!==null?(t=i.tail,i.rendering=t,i.tail=t.sibling,i.renderingStartTime=Ti(),t.sibling=null,e=jt.current,rt(jt,r?e&1|2:e&1),t):(at(t),null);case 22:case 23:return io(t),pv(),r=t.memoizedState!==null,e!==null?e.memoizedState!==null!==r&&(t.flags|=8192):r&&(t.flags|=8192),r?n&536870912&&!(t.flags&128)&&(at(t),t.subtreeFlags&6&&(t.flags|=8192)):at(t),n=t.updateQueue,n!==null&&Om(t,n.retryQueue),n=null,e!==null&&e.memoizedState!==null&&e.memoizedState.cachePool!==null&&(n=e.memoizedState.cachePool.pool),r=null,t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(r=t.memoizedState.cachePool.pool),r!==n&&(t.flags|=2048),e!==null&&Yt(ua),null;case 24:return n=null,e!==null&&(n=e.memoizedState.cache),t.memoizedState.cache!==n&&(t.flags|=2048),so(_t),at(t),null;case 25:return null;case 30:return null}throw Error(D(156,t.tag))}function zG(e,t){switch(av(t),t.tag){case 1:return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return so(_t),Fc(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 26:case 27:case 5:return Qm(t),null;case 13:if(io(t),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(D(340));ef()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return Yt(jt),null;case 4:return Fc(),null;case 10:return so(t.type),null;case 22:case 23:return io(t),pv(),e!==null&&Yt(ua),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 24:return so(_t),null;case 25:return null;default:return null}}function GC(e,t){switch(av(t),t.tag){case 3:so(_t),Fc();break;case 26:case 27:case 5:Qm(t);break;case 4:Fc();break;case 13:io(t);break;case 19:Yt(jt);break;case 10:so(t.type);break;case 22:case 23:io(t),pv(),e!==null&&Yt(ua);break;case 24:so(_t)}}function af(e,t){try{var n=t.updateQueue,r=n!==null?n.lastEffect:null;if(r!==null){var i=r.next;n=i;do{if((n.tag&e)===e){r=void 0;var o=n.create,s=n.inst;r=o(),s.destroy=r}n=n.next}while(n!==i)}}catch(a){He(t,t.return,a)}}function cs(e,t,n){try{var r=t.updateQueue,i=r!==null?r.lastEffect:null;if(i!==null){var o=i.next;r=o;do{if((r.tag&e)===e){var s=r.inst,a=s.destroy;if(a!==void 0){s.destroy=void 0,i=t;var c=n,l=a;try{l()}catch(p){He(i,c,p)}}}r=r.next}while(r!==o)}}catch(p){He(t,t.return,p)}}function qC(e){var t=e.updateQueue;if(t!==null){var n=e.stateNode;try{ZP(t,n)}catch(r){He(e,e.return,r)}}}function VC(e,t,n){n.props=ha(e.type,e.memoizedProps),n.state=e.memoizedState;try{n.componentWillUnmount()}catch(r){He(e,t,r)}}function Rp(e,t){try{var n=e.ref;if(n!==null){switch(e.tag){case 26:case 27:case 5:var r=e.stateNode;break;case 30:r=e.stateNode;break;default:r=e.stateNode}typeof n=="function"?e.refCleanup=n(r):n.current=r}}catch(i){He(e,t,i)}}function Si(e,t){var n=e.ref,r=e.refCleanup;if(n!==null)if(typeof r=="function")try{r()}catch(i){He(e,t,i)}finally{e.refCleanup=null,e=e.alternate,e!=null&&(e.refCleanup=null)}else if(typeof n=="function")try{n(null)}catch(i){He(e,t,i)}else n.current=null}function QC(e){var t=e.type,n=e.memoizedProps,r=e.stateNode;try{e:switch(t){case"button":case"input":case"select":case"textarea":n.autoFocus&&r.focus();break e;case"img":n.src?r.src=n.src:n.srcSet&&(r.srcset=n.srcSet)}}catch(i){He(e,e.return,i)}}function Fx(e,t,n){try{var r=e.stateNode;cq(r,e.type,n,t),r[Hn]=t}catch(i){He(e,e.return,i)}}function YC(e){return e.tag===5||e.tag===3||e.tag===26||e.tag===27&&ps(e.type)||e.tag===4}function $x(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||YC(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;e.tag!==5&&e.tag!==6&&e.tag!==18;){if(e.tag===27&&ps(e.type)||e.flags&2||e.child===null||e.tag===4)continue e;e.child.return=e,e=e.child}if(!(e.flags&2))return e.stateNode}}function AT(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?(n.nodeType===9?n.body:n.nodeName==="HTML"?n.ownerDocument.body:n).insertBefore(e,t):(t=n.nodeType===9?n.body:n.nodeName==="HTML"?n.ownerDocument.body:n,t.appendChild(e),n=n._reactRootContainer,n!=null||t.onclick!==null||(t.onclick=Uh));else if(r!==4&&(r===27&&ps(e.type)&&(n=e.stateNode,t=null),e=e.child,e!==null))for(AT(e,t,n),e=e.sibling;e!==null;)AT(e,t,n),e=e.sibling}function lh(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?n.insertBefore(e,t):n.appendChild(e);else if(r!==4&&(r===27&&ps(e.type)&&(n=e.stateNode),e=e.child,e!==null))for(lh(e,t,n),e=e.sibling;e!==null;)lh(e,t,n),e=e.sibling}function JC(e){var t=e.stateNode,n=e.memoizedProps;try{for(var r=e.type,i=t.attributes;i.length;)t.removeAttributeNode(i[0]);on(t,r,n),t[mn]=e,t[Hn]=n}catch(o){He(e,e.return,o)}}var Wi=!1,gt=!1,Kx=!1,DR=typeof WeakSet=="function"?WeakSet:Set,qt=null;function HG(e,t){if(e=e.containerInfo,_T=xh,e=jP(e),nv(e)){if("selectionStart"in e)var n={start:e.selectionStart,end:e.selectionEnd};else e:{n=(n=e.ownerDocument)&&n.defaultView||window;var r=n.getSelection&&n.getSelection();if(r&&r.rangeCount!==0){n=r.anchorNode;var i=r.anchorOffset,o=r.focusNode;r=r.focusOffset;try{n.nodeType,o.nodeType}catch{n=null;break e}var s=0,a=-1,c=-1,l=0,p=0,d=e,m=null;t:for(;;){for(var y;d!==n||i!==0&&d.nodeType!==3||(a=s+i),d!==o||r!==0&&d.nodeType!==3||(c=s+r),d.nodeType===3&&(s+=d.nodeValue.length),(y=d.firstChild)!==null;)m=d,d=y;for(;;){if(d===e)break t;if(m===n&&++l===i&&(a=s),m===o&&++p===r&&(c=s),(y=d.nextSibling)!==null)break;d=m,m=d.parentNode}d=y}n=a===-1||c===-1?null:{start:a,end:c}}else n=null}n=n||{start:0,end:0}}else n=null;for(jT={focusedElem:e,selectionRange:n},xh=!1,qt=t;qt!==null;)if(t=qt,e=t.child,(t.subtreeFlags&1024)!==0&&e!==null)e.return=t,qt=e;else for(;qt!==null;){switch(t=qt,o=t.alternate,e=t.flags,t.tag){case 0:break;case 11:case 15:break;case 1:if(e&1024&&o!==null){e=void 0,n=t,i=o.memoizedProps,o=o.memoizedState,r=n.stateNode;try{var S=ha(n.type,i,n.elementType===n.type);e=r.getSnapshotBeforeUpdate(S,o),r.__reactInternalSnapshotBeforeUpdate=e}catch(T){He(n,n.return,T)}}break;case 3:if(e&1024){if(e=t.stateNode.containerInfo,n=e.nodeType,n===9)BT(e);else if(n===1)switch(e.nodeName){case"HEAD":case"HTML":case"BODY":BT(e);break;default:e.textContent=""}}break;case 5:case 26:case 27:case 6:case 4:case 17:break;default:if(e&1024)throw Error(D(163))}if(e=t.sibling,e!==null){e.return=t.return,qt=e;break}qt=t.return}}function XC(e,t,n){var r=n.flags;switch(n.tag){case 0:case 11:case 15:$o(e,n),r&4&&af(5,n);break;case 1:if($o(e,n),r&4)if(e=n.stateNode,t===null)try{e.componentDidMount()}catch(s){He(n,n.return,s)}else{var i=ha(n.type,t.memoizedProps);t=t.memoizedState;try{e.componentDidUpdate(i,t,e.__reactInternalSnapshotBeforeUpdate)}catch(s){He(n,n.return,s)}}r&64&&qC(n),r&512&&Rp(n,n.return);break;case 3:if($o(e,n),r&64&&(e=n.updateQueue,e!==null)){if(t=null,n.child!==null)switch(n.child.tag){case 27:case 5:t=n.child.stateNode;break;case 1:t=n.child.stateNode}try{ZP(e,t)}catch(s){He(n,n.return,s)}}break;case 27:t===null&&r&4&&JC(n);case 26:case 5:$o(e,n),t===null&&r&4&&QC(n),r&512&&Rp(n,n.return);break;case 12:$o(e,n);break;case 13:$o(e,n),r&4&&e1(e,n),r&64&&(e=n.memoizedState,e!==null&&(e=e.dehydrated,e!==null&&(n=WG.bind(null,n),hq(e,n))));break;case 22:if(r=n.memoizedState!==null||Wi,!r){t=t!==null&&t.memoizedState!==null||gt,i=Wi;var o=gt;Wi=r,(gt=t)&&!o?Ko(e,n,(n.subtreeFlags&8772)!==0):$o(e,n),Wi=i,gt=o}break;case 30:break;default:$o(e,n)}}function ZC(e){var t=e.alternate;t!==null&&(e.alternate=null,ZC(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&JT(t)),e.stateNode=null,e.return=null,e.dependencies=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.stateNode=null,e.updateQueue=null}var nt=null,Kn=!1;function Zi(e,t,n){for(n=n.child;n!==null;)WC(e,t,n),n=n.sibling}function WC(e,t,n){if(ur&&typeof ur.onCommitFiberUnmount=="function")try{ur.onCommitFiberUnmount(Yp,n)}catch{}switch(n.tag){case 26:gt||Si(n,t),Zi(e,t,n),n.memoizedState?n.memoizedState.count--:n.stateNode&&(n=n.stateNode,n.parentNode.removeChild(n));break;case 27:gt||Si(n,t);var r=nt,i=Kn;ps(n.type)&&(nt=n.stateNode,Kn=!1),Zi(e,t,n),kp(n.stateNode),nt=r,Kn=i;break;case 5:gt||Si(n,t);case 6:if(r=nt,i=Kn,nt=null,Zi(e,t,n),nt=r,Kn=i,nt!==null)if(Kn)try{(nt.nodeType===9?nt.body:nt.nodeName==="HTML"?nt.ownerDocument.body:nt).removeChild(n.stateNode)}catch(o){He(n,t,o)}else try{nt.removeChild(n.stateNode)}catch(o){He(n,t,o)}break;case 18:nt!==null&&(Kn?(e=nt,QR(e.nodeType===9?e.body:e.nodeName==="HTML"?e.ownerDocument.body:e,n.stateNode),Vp(e)):QR(nt,n.stateNode));break;case 4:r=nt,i=Kn,nt=n.stateNode.containerInfo,Kn=!0,Zi(e,t,n),nt=r,Kn=i;break;case 0:case 11:case 14:case 15:gt||cs(2,n,t),gt||cs(4,n,t),Zi(e,t,n);break;case 1:gt||(Si(n,t),r=n.stateNode,typeof r.componentWillUnmount=="function"&&VC(n,t,r)),Zi(e,t,n);break;case 21:Zi(e,t,n);break;case 22:gt=(r=gt)||n.memoizedState!==null,Zi(e,t,n),gt=r;break;default:Zi(e,t,n)}}function e1(e,t){if(t.memoizedState===null&&(e=t.alternate,e!==null&&(e=e.memoizedState,e!==null&&(e=e.dehydrated,e!==null))))try{Vp(e)}catch(n){He(t,t.return,n)}}function GG(e){switch(e.tag){case 13:case 19:var t=e.stateNode;return t===null&&(t=e.stateNode=new DR),t;case 22:return e=e.stateNode,t=e._retryCache,t===null&&(t=e._retryCache=new DR),t;default:throw Error(D(435,e.tag))}}function zx(e,t){var n=GG(e);t.forEach(function(r){var i=eq.bind(null,e,r);n.has(r)||(n.add(r),r.then(i,i))})}function or(e,t){var n=t.deletions;if(n!==null)for(var r=0;r<n.length;r++){var i=n[r],o=e,s=t,a=s;e:for(;a!==null;){switch(a.tag){case 27:if(ps(a.type)){nt=a.stateNode,Kn=!1;break e}break;case 5:nt=a.stateNode,Kn=!1;break e;case 3:case 4:nt=a.stateNode.containerInfo,Kn=!0;break e}a=a.return}if(nt===null)throw Error(D(160));WC(o,s,i),nt=null,Kn=!1,o=i.alternate,o!==null&&(o.return=null),i.return=null}if(t.subtreeFlags&13878)for(t=t.child;t!==null;)t1(t,e),t=t.sibling}var Zr=null;function t1(e,t){var n=e.alternate,r=e.flags;switch(e.tag){case 0:case 11:case 14:case 15:or(t,e),sr(e),r&4&&(cs(3,e,e.return),af(3,e),cs(5,e,e.return));break;case 1:or(t,e),sr(e),r&512&&(gt||n===null||Si(n,n.return)),r&64&&Wi&&(e=e.updateQueue,e!==null&&(r=e.callbacks,r!==null&&(n=e.shared.hiddenCallbacks,e.shared.hiddenCallbacks=n===null?r:n.concat(r))));break;case 26:var i=Zr;if(or(t,e),sr(e),r&512&&(gt||n===null||Si(n,n.return)),r&4){var o=n!==null?n.memoizedState:null;if(r=e.memoizedState,n===null)if(r===null)if(e.stateNode===null){e:{r=e.type,n=e.memoizedProps,i=i.ownerDocument||i;t:switch(r){case"title":o=i.getElementsByTagName("title")[0],(!o||o[Zp]||o[mn]||o.namespaceURI==="http://www.w3.org/2000/svg"||o.hasAttribute("itemprop"))&&(o=i.createElement(r),i.head.insertBefore(o,i.querySelector("head > title"))),on(o,r,n),o[mn]=e,Vt(o),r=o;break e;case"link":var s=WR("link","href",i).get(r+(n.href||""));if(s){for(var a=0;a<s.length;a++)if(o=s[a],o.getAttribute("href")===(n.href==null||n.href===""?null:n.href)&&o.getAttribute("rel")===(n.rel==null?null:n.rel)&&o.getAttribute("title")===(n.title==null?null:n.title)&&o.getAttribute("crossorigin")===(n.crossOrigin==null?null:n.crossOrigin)){s.splice(a,1);break t}}o=i.createElement(r),on(o,r,n),i.head.appendChild(o);break;case"meta":if(s=WR("meta","content",i).get(r+(n.content||""))){for(a=0;a<s.length;a++)if(o=s[a],o.getAttribute("content")===(n.content==null?null:""+n.content)&&o.getAttribute("name")===(n.name==null?null:n.name)&&o.getAttribute("property")===(n.property==null?null:n.property)&&o.getAttribute("http-equiv")===(n.httpEquiv==null?null:n.httpEquiv)&&o.getAttribute("charset")===(n.charSet==null?null:n.charSet)){s.splice(a,1);break t}}o=i.createElement(r),on(o,r,n),i.head.appendChild(o);break;default:throw Error(D(468,r))}o[mn]=e,Vt(o),r=o}e.stateNode=r}else eP(i,e.type,e.stateNode);else e.stateNode=ZR(i,r,e.memoizedProps);else o!==r?(o===null?n.stateNode!==null&&(n=n.stateNode,n.parentNode.removeChild(n)):o.count--,r===null?eP(i,e.type,e.stateNode):ZR(i,r,e.memoizedProps)):r===null&&e.stateNode!==null&&Fx(e,e.memoizedProps,n.memoizedProps)}break;case 27:or(t,e),sr(e),r&512&&(gt||n===null||Si(n,n.return)),n!==null&&r&4&&Fx(e,e.memoizedProps,n.memoizedProps);break;case 5:if(or(t,e),sr(e),r&512&&(gt||n===null||Si(n,n.return)),e.flags&32){i=e.stateNode;try{Kc(i,"")}catch(y){He(e,e.return,y)}}r&4&&e.stateNode!=null&&(i=e.memoizedProps,Fx(e,i,n!==null?n.memoizedProps:i)),r&1024&&(Kx=!0);break;case 6:if(or(t,e),sr(e),r&4){if(e.stateNode===null)throw Error(D(162));r=e.memoizedProps,n=e.stateNode;try{n.nodeValue=r}catch(y){He(e,e.return,y)}}break;case 3:if(Hm=null,i=Zr,Zr=gh(t.containerInfo),or(t,e),Zr=i,sr(e),r&4&&n!==null&&n.memoizedState.isDehydrated)try{Vp(t.containerInfo)}catch(y){He(e,e.return,y)}Kx&&(Kx=!1,n1(e));break;case 4:r=Zr,Zr=gh(e.stateNode.containerInfo),or(t,e),sr(e),Zr=r;break;case 12:or(t,e),sr(e);break;case 13:or(t,e),sr(e),e.child.flags&8192&&e.memoizedState!==null!=(n!==null&&n.memoizedState!==null)&&(Rv=Ti()),r&4&&(r=e.updateQueue,r!==null&&(e.updateQueue=null,zx(e,r)));break;case 22:i=e.memoizedState!==null;var c=n!==null&&n.memoizedState!==null,l=Wi,p=gt;if(Wi=l||i,gt=p||c,or(t,e),gt=p,Wi=l,sr(e),r&8192)e:for(t=e.stateNode,t._visibility=i?t._visibility&-2:t._visibility|1,i&&(n===null||c||Wi||gt||ia(e)),n=null,t=e;;){if(t.tag===5||t.tag===26){if(n===null){c=n=t;try{if(o=c.stateNode,i)s=o.style,typeof s.setProperty=="function"?s.setProperty("display","none","important"):s.display="none";else{a=c.stateNode;var d=c.memoizedProps.style,m=d!=null&&d.hasOwnProperty("display")?d.display:null;a.style.display=m==null||typeof m=="boolean"?"":(""+m).trim()}}catch(y){He(c,c.return,y)}}}else if(t.tag===6){if(n===null){c=t;try{c.stateNode.nodeValue=i?"":c.memoizedProps}catch(y){He(c,c.return,y)}}}else if((t.tag!==22&&t.tag!==23||t.memoizedState===null||t===e)&&t.child!==null){t.child.return=t,t=t.child;continue}if(t===e)break e;for(;t.sibling===null;){if(t.return===null||t.return===e)break e;n===t&&(n=null),t=t.return}n===t&&(n=null),t.sibling.return=t.return,t=t.sibling}r&4&&(r=e.updateQueue,r!==null&&(n=r.retryQueue,n!==null&&(r.retryQueue=null,zx(e,n))));break;case 19:or(t,e),sr(e),r&4&&(r=e.updateQueue,r!==null&&(e.updateQueue=null,zx(e,r)));break;case 30:break;case 21:break;default:or(t,e),sr(e)}}function sr(e){var t=e.flags;if(t&2){try{for(var n,r=e.return;r!==null;){if(YC(r)){n=r;break}r=r.return}if(n==null)throw Error(D(160));switch(n.tag){case 27:var i=n.stateNode,o=$x(e);lh(e,o,i);break;case 5:var s=n.stateNode;n.flags&32&&(Kc(s,""),n.flags&=-33);var a=$x(e);lh(e,a,s);break;case 3:case 4:var c=n.stateNode.containerInfo,l=$x(e);AT(e,l,c);break;default:throw Error(D(161))}}catch(p){He(e,e.return,p)}e.flags&=-3}t&4096&&(e.flags&=-4097)}function n1(e){if(e.subtreeFlags&1024)for(e=e.child;e!==null;){var t=e;n1(t),t.tag===5&&t.flags&1024&&t.stateNode.reset(),e=e.sibling}}function $o(e,t){if(t.subtreeFlags&8772)for(t=t.child;t!==null;)XC(e,t.alternate,t),t=t.sibling}function ia(e){for(e=e.child;e!==null;){var t=e;switch(t.tag){case 0:case 11:case 14:case 15:cs(4,t,t.return),ia(t);break;case 1:Si(t,t.return);var n=t.stateNode;typeof n.componentWillUnmount=="function"&&VC(t,t.return,n),ia(t);break;case 27:kp(t.stateNode);case 26:case 5:Si(t,t.return),ia(t);break;case 22:t.memoizedState===null&&ia(t);break;case 30:ia(t);break;default:ia(t)}e=e.sibling}}function Ko(e,t,n){for(n=n&&(t.subtreeFlags&8772)!==0,t=t.child;t!==null;){var r=t.alternate,i=e,o=t,s=o.flags;switch(o.tag){case 0:case 11:case 15:Ko(i,o,n),af(4,o);break;case 1:if(Ko(i,o,n),r=o,i=r.stateNode,typeof i.componentDidMount=="function")try{i.componentDidMount()}catch(l){He(r,r.return,l)}if(r=o,i=r.updateQueue,i!==null){var a=r.stateNode;try{var c=i.shared.hiddenCallbacks;if(c!==null)for(i.shared.hiddenCallbacks=null,i=0;i<c.length;i++)XP(c[i],a)}catch(l){He(r,r.return,l)}}n&&s&64&&qC(o),Rp(o,o.return);break;case 27:JC(o);case 26:case 5:Ko(i,o,n),n&&r===null&&s&4&&QC(o),Rp(o,o.return);break;case 12:Ko(i,o,n);break;case 13:Ko(i,o,n),n&&s&4&&e1(i,o);break;case 22:o.memoizedState===null&&Ko(i,o,n),Rp(o,o.return);break;case 30:break;default:Ko(i,o,n)}t=t.sibling}}function wv(e,t){var n=null;e!==null&&e.memoizedState!==null&&e.memoizedState.cachePool!==null&&(n=e.memoizedState.cachePool.pool),e=null,t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(e=t.memoizedState.cachePool.pool),e!==n&&(e!=null&&e.refCount++,n!=null&&nf(n))}function Mv(e,t){e=null,t.alternate!==null&&(e=t.alternate.memoizedState.cache),t=t.memoizedState.cache,t!==e&&(t.refCount++,e!=null&&nf(e))}function gi(e,t,n,r){if(t.subtreeFlags&10256)for(t=t.child;t!==null;)r1(e,t,n,r),t=t.sibling}function r1(e,t,n,r){var i=t.flags;switch(t.tag){case 0:case 11:case 15:gi(e,t,n,r),i&2048&&af(9,t);break;case 1:gi(e,t,n,r);break;case 3:gi(e,t,n,r),i&2048&&(e=null,t.alternate!==null&&(e=t.alternate.memoizedState.cache),t=t.memoizedState.cache,t!==e&&(t.refCount++,e!=null&&nf(e)));break;case 12:if(i&2048){gi(e,t,n,r),e=t.stateNode;try{var o=t.memoizedProps,s=o.id,a=o.onPostCommit;typeof a=="function"&&a(s,t.alternate===null?"mount":"update",e.passiveEffectDuration,-0)}catch(c){He(t,t.return,c)}}else gi(e,t,n,r);break;case 13:gi(e,t,n,r);break;case 23:break;case 22:o=t.stateNode,s=t.alternate,t.memoizedState!==null?o._visibility&2?gi(e,t,n,r):Pp(e,t):o._visibility&2?gi(e,t,n,r):(o._visibility|=2,bc(e,t,n,r,(t.subtreeFlags&10256)!==0)),i&2048&&wv(s,t);break;case 24:gi(e,t,n,r),i&2048&&Mv(t.alternate,t);break;default:gi(e,t,n,r)}}function bc(e,t,n,r,i){for(i=i&&(t.subtreeFlags&10256)!==0,t=t.child;t!==null;){var o=e,s=t,a=n,c=r,l=s.flags;switch(s.tag){case 0:case 11:case 15:bc(o,s,a,c,i),af(8,s);break;case 23:break;case 22:var p=s.stateNode;s.memoizedState!==null?p._visibility&2?bc(o,s,a,c,i):Pp(o,s):(p._visibility|=2,bc(o,s,a,c,i)),i&&l&2048&&wv(s.alternate,s);break;case 24:bc(o,s,a,c,i),i&&l&2048&&Mv(s.alternate,s);break;default:bc(o,s,a,c,i)}t=t.sibling}}function Pp(e,t){if(t.subtreeFlags&10256)for(t=t.child;t!==null;){var n=e,r=t,i=r.flags;switch(r.tag){case 22:Pp(n,r),i&2048&&wv(r.alternate,r);break;case 24:Pp(n,r),i&2048&&Mv(r.alternate,r);break;default:Pp(n,r)}t=t.sibling}}var Sp=8192;function hc(e){if(e.subtreeFlags&Sp)for(e=e.child;e!==null;)i1(e),e=e.sibling}function i1(e){switch(e.tag){case 26:hc(e),e.flags&Sp&&e.memoizedState!==null&&Aq(Zr,e.memoizedState,e.memoizedProps);break;case 5:hc(e);break;case 3:case 4:var t=Zr;Zr=gh(e.stateNode.containerInfo),hc(e),Zr=t;break;case 22:e.memoizedState===null&&(t=e.alternate,t!==null&&t.memoizedState!==null?(t=Sp,Sp=16777216,hc(e),Sp=t):hc(e));break;default:hc(e)}}function o1(e){var t=e.alternate;if(t!==null&&(e=t.child,e!==null)){t.child=null;do t=e.sibling,e.sibling=null,e=t;while(e!==null)}}function dp(e){var t=e.deletions;if(e.flags&16){if(t!==null)for(var n=0;n<t.length;n++){var r=t[n];qt=r,a1(r,e)}o1(e)}if(e.subtreeFlags&10256)for(e=e.child;e!==null;)s1(e),e=e.sibling}function s1(e){switch(e.tag){case 0:case 11:case 15:dp(e),e.flags&2048&&cs(9,e,e.return);break;case 3:dp(e);break;case 12:dp(e);break;case 22:var t=e.stateNode;e.memoizedState!==null&&t._visibility&2&&(e.return===null||e.return.tag!==13)?(t._visibility&=-3,Km(e)):dp(e);break;default:dp(e)}}function Km(e){var t=e.deletions;if(e.flags&16){if(t!==null)for(var n=0;n<t.length;n++){var r=t[n];qt=r,a1(r,e)}o1(e)}for(e=e.child;e!==null;){switch(t=e,t.tag){case 0:case 11:case 15:cs(8,t,t.return),Km(t);break;case 22:n=t.stateNode,n._visibility&2&&(n._visibility&=-3,Km(t));break;default:Km(t)}e=e.sibling}}function a1(e,t){for(;qt!==null;){var n=qt;switch(n.tag){case 0:case 11:case 15:cs(8,n,t);break;case 23:case 22:if(n.memoizedState!==null&&n.memoizedState.cachePool!==null){var r=n.memoizedState.cachePool.pool;r!=null&&r.refCount++}break;case 24:nf(n.memoizedState.cache)}if(r=n.child,r!==null)r.return=n,qt=r;else e:for(n=e;qt!==null;){r=qt;var i=r.sibling,o=r.return;if(ZC(r),r===n){qt=null;break e}if(i!==null){i.return=o,qt=i;break e}qt=o}}}var qG={getCacheForType:function(e){var t=hn(_t),n=t.data.get(e);return n===void 0&&(n=e(),t.data.set(e,n)),n}},VG=typeof WeakMap=="function"?WeakMap:Map,_e=0,Xe=null,pe=null,Se=0,Ue=0,ar=null,Xo=!1,eu=!1,Ov=!1,lo=0,ft=0,us=0,la=0,Av=0,Ur=0,Vc=0,Cp=null,zn=null,RT=!1,Rv=0,ph=1/0,fh=null,ns=null,rn=0,rs=null,Qc=null,Bc=0,PT=0,CT=null,c1=null,Np=0,NT=null;function pr(){if(_e&2&&Se!==0)return Se&-Se;if(X.T!==null){var e=zc;return e!==0?e:Cv()}return SP()}function u1(){Ur===0&&(Ur=!(Se&536870912)||we?hP():536870912);var e=_r.current;return e!==null&&(e.flags|=32),Ur}function fr(e,t,n){(e===Xe&&(Ue===2||Ue===9)||e.cancelPendingCommit!==null)&&(Yc(e,0),Zo(e,Se,Ur,!1)),Xp(e,n),(!(_e&2)||e!==Xe)&&(e===Xe&&(!(_e&2)&&(la|=n),ft===4&&Zo(e,Se,Ur,!1)),Ei(e))}function l1(e,t,n){if(_e&6)throw Error(D(327));var r=!n&&(t&124)===0&&(t&e.expiredLanes)===0||Jp(e,t),i=r?JG(e,t):Hx(e,t,!0),o=r;do{if(i===0){eu&&!r&&Zo(e,t,0,!1);break}else{if(n=e.current.alternate,o&&!QG(n)){i=Hx(e,t,!1),o=!1;continue}if(i===2){if(o=t,e.errorRecoveryDisabledLanes&o)var s=0;else s=e.pendingLanes&-536870913,s=s!==0?s:s&536870912?536870912:0;if(s!==0){t=s;e:{var a=e;i=Cp;var c=a.current.memoizedState.isDehydrated;if(c&&(Yc(a,s).flags|=256),s=Hx(a,s,!1),s!==2){if(Ov&&!c){a.errorRecoveryDisabledLanes|=o,la|=o,i=4;break e}o=zn,zn=i,o!==null&&(zn===null?zn=o:zn.push.apply(zn,o))}i=s}if(o=!1,i!==2)continue}}if(i===1){Yc(e,0),Zo(e,t,0,!0);break}e:{switch(r=e,o=i,o){case 0:case 1:throw Error(D(345));case 4:if((t&4194048)!==t)break;case 6:Zo(r,t,Ur,!Xo);break e;case 2:zn=null;break;case 3:case 5:break;default:throw Error(D(329))}if((t&62914560)===t&&(i=Rv+300-Ti(),10<i)){if(Zo(r,t,Ur,!Xo),vh(r,0,!0)!==0)break e;r.timeoutHandle=R1(UR.bind(null,r,n,zn,fh,RT,t,Ur,la,Vc,Xo,o,2,-0,0),i);break e}UR(r,n,zn,fh,RT,t,Ur,la,Vc,Xo,o,0,-0,0)}}break}while(!0);Ei(e)}function UR(e,t,n,r,i,o,s,a,c,l,p,d,m,y){if(e.timeoutHandle=-1,d=t.subtreeFlags,(d&8192||(d&16785408)===16785408)&&(zp={stylesheets:null,count:0,unsuspend:Oq},i1(t),d=Rq(),d!==null)){e.cancelPendingCommit=d(jR.bind(null,e,t,o,n,r,i,s,a,c,p,1,m,y)),Zo(e,o,s,!l);return}jR(e,t,o,n,r,i,s,a,c)}function QG(e){for(var t=e;;){var n=t.tag;if((n===0||n===11||n===15)&&t.flags&16384&&(n=t.updateQueue,n!==null&&(n=n.stores,n!==null)))for(var r=0;r<n.length;r++){var i=n[r],o=i.getSnapshot;i=i.value;try{if(!dr(o(),i))return!1}catch{return!1}}if(n=t.child,t.subtreeFlags&16384&&n!==null)n.return=t,t=n;else{if(t===e)break;for(;t.sibling===null;){if(t.return===null||t.return===e)return!0;t=t.return}t.sibling.return=t.return,t=t.sibling}}return!0}function Zo(e,t,n,r){t&=~Av,t&=~la,e.suspendedLanes|=t,e.pingedLanes&=~t,r&&(e.warmLanes|=t),r=e.expirationTimes;for(var i=t;0<i;){var o=31-lr(i),s=1<<o;r[o]=-1,i&=~s}n!==0&&gP(e,n,t)}function Nh(){return _e&6?!0:(cf(0,!1),!1)}function Pv(){if(pe!==null){if(Ue===0)var e=pe.return;else e=pe,ro=Sa=null,yv(e),Lc=null,Fp=0,e=pe;for(;e!==null;)GC(e.alternate,e),e=e.return;pe=null}}function Yc(e,t){var n=e.timeoutHandle;n!==-1&&(e.timeoutHandle=-1,lq(n)),n=e.cancelPendingCommit,n!==null&&(e.cancelPendingCommit=null,n()),Pv(),Xe=e,pe=n=oo(e.current,null),Se=t,Ue=0,ar=null,Xo=!1,eu=Jp(e,t),Ov=!1,Vc=Ur=Av=la=us=ft=0,zn=Cp=null,RT=!1,t&8&&(t|=t&32);var r=e.entangledLanes;if(r!==0)for(e=e.entanglements,r&=t;0<r;){var i=31-lr(r),o=1<<i;t|=e[i],r&=~o}return lo=t,Mh(),n}function p1(e,t){re=null,X.H=oh,t===rf||t===Ah?(t=dR(),Ue=3):t===YP?(t=dR(),Ue=4):Ue=t===BC?8:t!==null&&typeof t=="object"&&typeof t.then=="function"?6:1,ar=t,pe===null&&(ft=1,ch(e,Dr(t,e.current)))}function f1(){var e=X.H;return X.H=oh,e===null?oh:e}function d1(){var e=X.A;return X.A=qG,e}function kT(){ft=4,Xo||(Se&4194048)!==Se&&_r.current!==null||(eu=!0),!(us&134217727)&&!(la&134217727)||Xe===null||Zo(Xe,Se,Ur,!1)}function Hx(e,t,n){var r=_e;_e|=2;var i=f1(),o=d1();(Xe!==e||Se!==t)&&(fh=null,Yc(e,t)),t=!1;var s=ft;e:do try{if(Ue!==0&&pe!==null){var a=pe,c=ar;switch(Ue){case 8:Pv(),s=6;break e;case 3:case 2:case 9:case 6:_r.current===null&&(t=!0);var l=Ue;if(Ue=0,ar=null,Cc(e,a,c,l),n&&eu){s=0;break e}break;default:l=Ue,Ue=0,ar=null,Cc(e,a,c,l)}}YG(),s=ft;break}catch(p){p1(e,p)}while(!0);return t&&e.shellSuspendCounter++,ro=Sa=null,_e=r,X.H=i,X.A=o,pe===null&&(Xe=null,Se=0,Mh()),s}function YG(){for(;pe!==null;)m1(pe)}function JG(e,t){var n=_e;_e|=2;var r=f1(),i=d1();Xe!==e||Se!==t?(fh=null,ph=Ti()+500,Yc(e,t)):eu=Jp(e,t);e:do try{if(Ue!==0&&pe!==null){t=pe;var o=ar;t:switch(Ue){case 1:Ue=0,ar=null,Cc(e,t,o,1);break;case 2:case 9:if(fR(o)){Ue=0,ar=null,_R(t);break}t=function(){Ue!==2&&Ue!==9||Xe!==e||(Ue=7),Ei(e)},o.then(t,t);break e;case 3:Ue=7;break e;case 4:Ue=5;break e;case 7:fR(o)?(Ue=0,ar=null,_R(t)):(Ue=0,ar=null,Cc(e,t,o,7));break;case 5:var s=null;switch(pe.tag){case 26:s=pe.memoizedState;case 5:case 27:var a=pe;if(!s||k1(s)){Ue=0,ar=null;var c=a.sibling;if(c!==null)pe=c;else{var l=a.return;l!==null?(pe=l,kh(l)):pe=null}break t}}Ue=0,ar=null,Cc(e,t,o,5);break;case 6:Ue=0,ar=null,Cc(e,t,o,6);break;case 8:Pv(),ft=6;break e;default:throw Error(D(462))}}XG();break}catch(p){p1(e,p)}while(!0);return ro=Sa=null,X.H=r,X.A=i,_e=n,pe!==null?0:(Xe=null,Se=0,Mh(),ft)}function XG(){for(;pe!==null&&!S8();)m1(pe)}function m1(e){var t=HC(e.alternate,e,lo);e.memoizedProps=e.pendingProps,t===null?kh(e):pe=t}function _R(e){var t=e,n=t.alternate;switch(t.tag){case 15:case 0:t=RR(n,t,t.pendingProps,t.type,void 0,Se);break;case 11:t=RR(n,t,t.pendingProps,t.type.render,t.ref,Se);break;case 5:yv(t);default:GC(n,t),t=pe=GP(t,lo),t=HC(n,t,lo)}e.memoizedProps=e.pendingProps,t===null?kh(e):pe=t}function Cc(e,t,n,r){ro=Sa=null,yv(t),Lc=null,Fp=0;var i=t.return;try{if(FG(e,i,t,n,Se)){ft=1,ch(e,Dr(n,e.current)),pe=null;return}}catch(o){if(i!==null)throw pe=i,o;ft=1,ch(e,Dr(n,e.current)),pe=null;return}t.flags&32768?(we||r===1?e=!0:eu||Se&536870912?e=!1:(Xo=e=!0,(r===2||r===9||r===3||r===6)&&(r=_r.current,r!==null&&r.tag===13&&(r.flags|=16384))),h1(t,e)):kh(t)}function kh(e){var t=e;do{if(t.flags&32768){h1(t,Xo);return}e=t.return;var n=KG(t.alternate,t,lo);if(n!==null){pe=n;return}if(t=t.sibling,t!==null){pe=t;return}pe=t=e}while(t!==null);ft===0&&(ft=5)}function h1(e,t){do{var n=zG(e.alternate,e);if(n!==null){n.flags&=32767,pe=n;return}if(n=e.return,n!==null&&(n.flags|=32768,n.subtreeFlags=0,n.deletions=null),!t&&(e=e.sibling,e!==null)){pe=e;return}pe=e=n}while(e!==null);ft=6,pe=null}function jR(e,t,n,r,i,o,s,a,c){e.cancelPendingCommit=null;do Dh();while(rn!==0);if(_e&6)throw Error(D(327));if(t!==null){if(t===e.current)throw Error(D(177));if(o=t.lanes|t.childLanes,o|=rv,R8(e,n,o,s,a,c),e===Xe&&(pe=Xe=null,Se=0),Qc=t,rs=e,Bc=n,PT=o,CT=i,c1=r,t.subtreeFlags&10256||t.flags&10256?(e.callbackNode=null,e.callbackPriority=0,tq(Ym,function(){return x1(!0),null})):(e.callbackNode=null,e.callbackPriority=0),r=(t.flags&13878)!==0,t.subtreeFlags&13878||r){r=X.T,X.T=null,i=Me.p,Me.p=2,s=_e,_e|=4;try{HG(e,t,n)}finally{_e=s,Me.p=i,X.T=r}}rn=1,y1(),g1(),b1()}}function y1(){if(rn===1){rn=0;var e=rs,t=Qc,n=(t.flags&13878)!==0;if(t.subtreeFlags&13878||n){n=X.T,X.T=null;var r=Me.p;Me.p=2;var i=_e;_e|=4;try{t1(t,e);var o=jT,s=jP(e.containerInfo),a=o.focusedElem,c=o.selectionRange;if(s!==a&&a&&a.ownerDocument&&_P(a.ownerDocument.documentElement,a)){if(c!==null&&nv(a)){var l=c.start,p=c.end;if(p===void 0&&(p=l),"selectionStart"in a)a.selectionStart=l,a.selectionEnd=Math.min(p,a.value.length);else{var d=a.ownerDocument||document,m=d&&d.defaultView||window;if(m.getSelection){var y=m.getSelection(),S=a.textContent.length,T=Math.min(c.start,S),E=c.end===void 0?T:Math.min(c.end,S);!y.extend&&T>E&&(s=E,E=T,T=s);var b=iR(a,T),f=iR(a,E);if(b&&f&&(y.rangeCount!==1||y.anchorNode!==b.node||y.anchorOffset!==b.offset||y.focusNode!==f.node||y.focusOffset!==f.offset)){var g=d.createRange();g.setStart(b.node,b.offset),y.removeAllRanges(),T>E?(y.addRange(g),y.extend(f.node,f.offset)):(g.setEnd(f.node,f.offset),y.addRange(g))}}}}for(d=[],y=a;y=y.parentNode;)y.nodeType===1&&d.push({element:y,left:y.scrollLeft,top:y.scrollTop});for(typeof a.focus=="function"&&a.focus(),a=0;a<d.length;a++){var v=d[a];v.element.scrollLeft=v.left,v.element.scrollTop=v.top}}xh=!!_T,jT=_T=null}finally{_e=i,Me.p=r,X.T=n}}e.current=t,rn=2}}function g1(){if(rn===2){rn=0;var e=rs,t=Qc,n=(t.flags&8772)!==0;if(t.subtreeFlags&8772||n){n=X.T,X.T=null;var r=Me.p;Me.p=2;var i=_e;_e|=4;try{XC(e,t.alternate,t)}finally{_e=i,Me.p=r,X.T=n}}rn=3}}function b1(){if(rn===4||rn===3){rn=0,x8();var e=rs,t=Qc,n=Bc,r=c1;t.subtreeFlags&10256||t.flags&10256?rn=5:(rn=0,Qc=rs=null,S1(e,e.pendingLanes));var i=e.pendingLanes;if(i===0&&(ns=null),YT(n),t=t.stateNode,ur&&typeof ur.onCommitFiberRoot=="function")try{ur.onCommitFiberRoot(Yp,t,void 0,(t.current.flags&128)===128)}catch{}if(r!==null){t=X.T,i=Me.p,Me.p=2,X.T=null;try{for(var o=e.onRecoverableError,s=0;s<r.length;s++){var a=r[s];o(a.value,{componentStack:a.stack})}}finally{X.T=t,Me.p=i}}Bc&3&&Dh(),Ei(e),i=e.pendingLanes,n&4194090&&i&42?e===NT?Np++:(Np=0,NT=e):Np=0,cf(0,!1)}}function S1(e,t){(e.pooledCacheLanes&=t)===0&&(t=e.pooledCache,t!=null&&(e.pooledCache=null,nf(t)))}function Dh(e){return y1(),g1(),b1(),x1(e)}function x1(){if(rn!==5)return!1;var e=rs,t=PT;PT=0;var n=YT(Bc),r=X.T,i=Me.p;try{Me.p=32>n?32:n,X.T=null,n=CT,CT=null;var o=rs,s=Bc;if(rn=0,Qc=rs=null,Bc=0,_e&6)throw Error(D(331));var a=_e;if(_e|=4,s1(o.current),r1(o,o.current,s,n),_e=a,cf(0,!1),ur&&typeof ur.onPostCommitFiberRoot=="function")try{ur.onPostCommitFiberRoot(Yp,o)}catch{}return!0}finally{Me.p=i,X.T=r,S1(e,t)}}function LR(e,t,n){t=Dr(n,t),t=wT(e.stateNode,t,2),e=ts(e,t,2),e!==null&&(Xp(e,2),Ei(e))}function He(e,t,n){if(e.tag===3)LR(e,e,n);else for(;t!==null;){if(t.tag===3){LR(t,e,n);break}else if(t.tag===1){var r=t.stateNode;if(typeof t.type.getDerivedStateFromError=="function"||typeof r.componentDidCatch=="function"&&(ns===null||!ns.has(r))){e=Dr(n,e),n=jC(2),r=ts(t,n,2),r!==null&&(LC(n,r,t,e),Xp(r,2),Ei(r));break}}t=t.return}}function Gx(e,t,n){var r=e.pingCache;if(r===null){r=e.pingCache=new VG;var i=new Set;r.set(t,i)}else i=r.get(t),i===void 0&&(i=new Set,r.set(t,i));i.has(n)||(Ov=!0,i.add(n),e=ZG.bind(null,e,t,n),t.then(e,e))}function ZG(e,t,n){var r=e.pingCache;r!==null&&r.delete(t),e.pingedLanes|=e.suspendedLanes&n,e.warmLanes&=~n,Xe===e&&(Se&n)===n&&(ft===4||ft===3&&(Se&62914560)===Se&&300>Ti()-Rv?!(_e&2)&&Yc(e,0):Av|=n,Vc===Se&&(Vc=0)),Ei(e)}function T1(e,t){t===0&&(t=yP()),e=Wc(e,t),e!==null&&(Xp(e,t),Ei(e))}function WG(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),T1(e,n)}function eq(e,t){var n=0;switch(e.tag){case 13:var r=e.stateNode,i=e.memoizedState;i!==null&&(n=i.retryLane);break;case 19:r=e.stateNode;break;case 22:r=e.stateNode._retryCache;break;default:throw Error(D(314))}r!==null&&r.delete(t),T1(e,n)}function tq(e,t){return VT(e,t)}var dh=null,Sc=null,DT=!1,mh=!1,qx=!1,pa=0;function Ei(e){e!==Sc&&e.next===null&&(Sc===null?dh=Sc=e:Sc=Sc.next=e),mh=!0,DT||(DT=!0,rq())}function cf(e,t){if(!qx&&mh){qx=!0;do for(var n=!1,r=dh;r!==null;){if(!t)if(e!==0){var i=r.pendingLanes;if(i===0)var o=0;else{var s=r.suspendedLanes,a=r.pingedLanes;o=(1<<31-lr(42|e)+1)-1,o&=i&~(s&~a),o=o&201326741?o&201326741|1:o?o|2:0}o!==0&&(n=!0,BR(r,o))}else o=Se,o=vh(r,r===Xe?o:0,r.cancelPendingCommit!==null||r.timeoutHandle!==-1),!(o&3)||Jp(r,o)||(n=!0,BR(r,o));r=r.next}while(n);qx=!1}}function nq(){v1()}function v1(){mh=DT=!1;var e=0;pa!==0&&(uq()&&(e=pa),pa=0);for(var t=Ti(),n=null,r=dh;r!==null;){var i=r.next,o=I1(r,t);o===0?(r.next=null,n===null?dh=i:n.next=i,i===null&&(Sc=n)):(n=r,(e!==0||o&3)&&(mh=!0)),r=i}cf(e,!1)}function I1(e,t){for(var n=e.suspendedLanes,r=e.pingedLanes,i=e.expirationTimes,o=e.pendingLanes&-62914561;0<o;){var s=31-lr(o),a=1<<s,c=i[s];c===-1?(!(a&n)||a&r)&&(i[s]=A8(a,t)):c<=t&&(e.expiredLanes|=a),o&=~a}if(t=Xe,n=Se,n=vh(e,e===t?n:0,e.cancelPendingCommit!==null||e.timeoutHandle!==-1),r=e.callbackNode,n===0||e===t&&(Ue===2||Ue===9)||e.cancelPendingCommit!==null)return r!==null&&r!==null&&Sx(r),e.callbackNode=null,e.callbackPriority=0;if(!(n&3)||Jp(e,n)){if(t=n&-n,t===e.callbackPriority)return t;switch(r!==null&&Sx(r),YT(n)){case 2:case 8:n=dP;break;case 32:n=Ym;break;case 268435456:n=mP;break;default:n=Ym}return r=E1.bind(null,e),n=VT(n,r),e.callbackPriority=t,e.callbackNode=n,t}return r!==null&&r!==null&&Sx(r),e.callbackPriority=2,e.callbackNode=null,2}function E1(e,t){if(rn!==0&&rn!==5)return e.callbackNode=null,e.callbackPriority=0,null;var n=e.callbackNode;if(Dh(!0)&&e.callbackNode!==n)return null;var r=Se;return r=vh(e,e===Xe?r:0,e.cancelPendingCommit!==null||e.timeoutHandle!==-1),r===0?null:(l1(e,r,t),I1(e,Ti()),e.callbackNode!=null&&e.callbackNode===n?E1.bind(null,e):null)}function BR(e,t){if(Dh())return null;l1(e,t,!0)}function rq(){pq(function(){_e&6?VT(fP,nq):v1()})}function Cv(){return pa===0&&(pa=hP()),pa}function FR(e){return e==null||typeof e=="symbol"||typeof e=="boolean"?null:typeof e=="function"?e:Dm(""+e)}function $R(e,t){var n=t.ownerDocument.createElement("input");return n.name=t.name,n.value=t.value,e.id&&n.setAttribute("form",e.id),t.parentNode.insertBefore(n,t),e=new FormData(e),n.parentNode.removeChild(n),e}function iq(e,t,n,r,i){if(t==="submit"&&n&&n.stateNode===i){var o=FR((i[Hn]||null).action),s=r.submitter;s&&(t=(t=s[Hn]||null)?FR(t.formAction):s.getAttribute("formAction"),t!==null&&(o=t,s=null));var a=new Ih("action","action",null,r,i);e.push({event:a,listeners:[{instance:null,listener:function(){if(r.defaultPrevented){if(pa!==0){var c=s?$R(i,s):new FormData(i);IT(n,{pending:!0,data:c,method:i.method,action:o},null,c)}}else typeof o=="function"&&(a.preventDefault(),c=s?$R(i,s):new FormData(i),IT(n,{pending:!0,data:c,method:i.method,action:o},o,c))},currentTarget:i}]})}}for(Am=0;Am<pT.length;Am++)Rm=pT[Am],KR=Rm.toLowerCase(),zR=Rm[0].toUpperCase()+Rm.slice(1),ei(KR,"on"+zR);var Rm,KR,zR,Am;ei(BP,"onAnimationEnd");ei(FP,"onAnimationIteration");ei($P,"onAnimationStart");ei("dblclick","onDoubleClick");ei("focusin","onFocus");ei("focusout","onBlur");ei(IG,"onTransitionRun");ei(EG,"onTransitionStart");ei(wG,"onTransitionCancel");ei(KP,"onTransitionEnd");$c("onMouseEnter",["mouseout","mouseover"]);$c("onMouseLeave",["mouseout","mouseover"]);$c("onPointerEnter",["pointerout","pointerover"]);$c("onPointerLeave",["pointerout","pointerover"]);ya("onChange","change click focusin focusout input keydown keyup selectionchange".split(" "));ya("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" "));ya("onBeforeInput",["compositionend","keypress","textInput","paste"]);ya("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" "));ya("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" "));ya("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var $p="abort canplay canplaythrough durationchange emptied encrypted ended error loadeddata loadedmetadata loadstart pause play playing progress ratechange resize seeked seeking stalled suspend timeupdate volumechange waiting".split(" "),oq=new Set("beforetoggle cancel close invalid load scroll scrollend toggle".split(" ").concat($p));function w1(e,t){t=(t&4)!==0;for(var n=0;n<e.length;n++){var r=e[n],i=r.event;r=r.listeners;e:{var o=void 0;if(t)for(var s=r.length-1;0<=s;s--){var a=r[s],c=a.instance,l=a.currentTarget;if(a=a.listener,c!==o&&i.isPropagationStopped())break e;o=a,i.currentTarget=l;try{o(i)}catch(p){ah(p)}i.currentTarget=null,o=c}else for(s=0;s<r.length;s++){if(a=r[s],c=a.instance,l=a.currentTarget,a=a.listener,c!==o&&i.isPropagationStopped())break e;o=a,i.currentTarget=l;try{o(i)}catch(p){ah(p)}i.currentTarget=null,o=c}}}}function le(e,t){var n=t[iT];n===void 0&&(n=t[iT]=new Set);var r=e+"__bubble";n.has(r)||(M1(t,e,2,!1),n.add(r))}function Vx(e,t,n){var r=0;t&&(r|=4),M1(n,e,r,t)}var Pm="_reactListening"+Math.random().toString(36).slice(2);function Nv(e){if(!e[Pm]){e[Pm]=!0,xP.forEach(function(n){n!=="selectionchange"&&(oq.has(n)||Vx(n,!1,e),Vx(n,!0,e))});var t=e.nodeType===9?e:e.ownerDocument;t===null||t[Pm]||(t[Pm]=!0,Vx("selectionchange",!1,t))}}function M1(e,t,n,r){switch(L1(t)){case 2:var i=Nq;break;case 8:i=kq;break;default:i=_v}n=i.bind(null,t,n,e),i=void 0,!cT||t!=="touchstart"&&t!=="touchmove"&&t!=="wheel"||(i=!0),r?i!==void 0?e.addEventListener(t,n,{capture:!0,passive:i}):e.addEventListener(t,n,!0):i!==void 0?e.addEventListener(t,n,{passive:i}):e.addEventListener(t,n,!1)}function Qx(e,t,n,r,i){var o=r;if(!(t&1)&&!(t&2)&&r!==null)e:for(;;){if(r===null)return;var s=r.tag;if(s===3||s===4){var a=r.stateNode.containerInfo;if(a===i)break;if(s===4)for(s=r.return;s!==null;){var c=s.tag;if((c===3||c===4)&&s.stateNode.containerInfo===i)return;s=s.return}for(;a!==null;){if(s=vc(a),s===null)return;if(c=s.tag,c===5||c===6||c===26||c===27){r=o=s;continue e}a=a.parentNode}}r=r.return}AP(function(){var l=o,p=ZT(n),d=[];e:{var m=zP.get(e);if(m!==void 0){var y=Ih,S=e;switch(e){case"keypress":if(_m(n)===0)break e;case"keydown":case"keyup":y=tG;break;case"focusin":S="focus",y=Ox;break;case"focusout":S="blur",y=Ox;break;case"beforeblur":case"afterblur":y=Ox;break;case"click":if(n.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":y=YA;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":y=z8;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":y=iG;break;case BP:case FP:case $P:y=q8;break;case KP:y=sG;break;case"scroll":case"scrollend":y=$8;break;case"wheel":y=cG;break;case"copy":case"cut":case"paste":y=Q8;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":y=XA;break;case"toggle":case"beforetoggle":y=lG}var T=(t&4)!==0,E=!T&&(e==="scroll"||e==="scrollend"),b=T?m!==null?m+"Capture":null:m;T=[];for(var f=l,g;f!==null;){var v=f;if(g=v.stateNode,v=v.tag,v!==5&&v!==26&&v!==27||g===null||b===null||(v=Up(f,b),v!=null&&T.push(Kp(f,v,g))),E)break;f=f.return}0<T.length&&(m=new y(m,S,null,n,p),d.push({event:m,listeners:T}))}}if(!(t&7)){e:{if(m=e==="mouseover"||e==="pointerover",y=e==="mouseout"||e==="pointerout",m&&n!==aT&&(S=n.relatedTarget||n.fromElement)&&(vc(S)||S[Xc]))break e;if((y||m)&&(m=p.window===p?p:(m=p.ownerDocument)?m.defaultView||m.parentWindow:window,y?(S=n.relatedTarget||n.toElement,y=l,S=S?vc(S):null,S!==null&&(E=Qp(S),T=S.tag,S!==E||T!==5&&T!==27&&T!==6)&&(S=null)):(y=null,S=l),y!==S)){if(T=YA,v="onMouseLeave",b="onMouseEnter",f="mouse",(e==="pointerout"||e==="pointerover")&&(T=XA,v="onPointerLeave",b="onPointerEnter",f="pointer"),E=y==null?m:bp(y),g=S==null?m:bp(S),m=new T(v,f+"leave",y,n,p),m.target=E,m.relatedTarget=g,v=null,vc(p)===l&&(T=new T(b,f+"enter",S,n,p),T.target=g,T.relatedTarget=E,v=T),E=v,y&&S)t:{for(T=y,b=S,f=0,g=T;g;g=yc(g))f++;for(g=0,v=b;v;v=yc(v))g++;for(;0<f-g;)T=yc(T),f--;for(;0<g-f;)b=yc(b),g--;for(;f--;){if(T===b||b!==null&&T===b.alternate)break t;T=yc(T),b=yc(b)}T=null}else T=null;y!==null&&HR(d,m,y,T,!1),S!==null&&E!==null&&HR(d,E,S,T,!0)}}e:{if(m=l?bp(l):window,y=m.nodeName&&m.nodeName.toLowerCase(),y==="select"||y==="input"&&m.type==="file")var I=tR;else if(eR(m))if(DP)I=xG;else{I=bG;var M=gG}else y=m.nodeName,!y||y.toLowerCase()!=="input"||m.type!=="checkbox"&&m.type!=="radio"?l&&XT(l.elementType)&&(I=tR):I=SG;if(I&&(I=I(e,l))){kP(d,I,n,p);break e}M&&M(e,m,l),e==="focusout"&&l&&m.type==="number"&&l.memoizedProps.value!=null&&sT(m,"number",m.value)}switch(M=l?bp(l):window,e){case"focusin":(eR(M)||M.contentEditable==="true")&&(wc=M,uT=l,vp=null);break;case"focusout":vp=uT=wc=null;break;case"mousedown":lT=!0;break;case"contextmenu":case"mouseup":case"dragend":lT=!1,oR(d,n,p);break;case"selectionchange":if(vG)break;case"keydown":case"keyup":oR(d,n,p)}var O;if(tv)e:{switch(e){case"compositionstart":var C="onCompositionStart";break e;case"compositionend":C="onCompositionEnd";break e;case"compositionupdate":C="onCompositionUpdate";break e}C=void 0}else Ec?CP(e,n)&&(C="onCompositionEnd"):e==="keydown"&&n.keyCode===229&&(C="onCompositionStart");C&&(PP&&n.locale!=="ko"&&(Ec||C!=="onCompositionStart"?C==="onCompositionEnd"&&Ec&&(O=RP()):(Jo=p,WT="value"in Jo?Jo.value:Jo.textContent,Ec=!0)),M=hh(l,C),0<M.length&&(C=new JA(C,e,null,n,p),d.push({event:C,listeners:M}),O?C.data=O:(O=NP(n),O!==null&&(C.data=O)))),(O=fG?dG(e,n):mG(e,n))&&(C=hh(l,"onBeforeInput"),0<C.length&&(M=new JA("onBeforeInput","beforeinput",null,n,p),d.push({event:M,listeners:C}),M.data=O)),iq(d,e,l,n,p)}w1(d,t)})}function Kp(e,t,n){return{instance:e,listener:t,currentTarget:n}}function hh(e,t){for(var n=t+"Capture",r=[];e!==null;){var i=e,o=i.stateNode;if(i=i.tag,i!==5&&i!==26&&i!==27||o===null||(i=Up(e,n),i!=null&&r.unshift(Kp(e,i,o)),i=Up(e,t),i!=null&&r.push(Kp(e,i,o))),e.tag===3)return r;e=e.return}return[]}function yc(e){if(e===null)return null;do e=e.return;while(e&&e.tag!==5&&e.tag!==27);return e||null}function HR(e,t,n,r,i){for(var o=t._reactName,s=[];n!==null&&n!==r;){var a=n,c=a.alternate,l=a.stateNode;if(a=a.tag,c!==null&&c===r)break;a!==5&&a!==26&&a!==27||l===null||(c=l,i?(l=Up(n,o),l!=null&&s.unshift(Kp(n,l,c))):i||(l=Up(n,o),l!=null&&s.push(Kp(n,l,c)))),n=n.return}s.length!==0&&e.push({event:t,listeners:s})}var sq=/\r\n?/g,aq=/\u0000|\uFFFD/g;function GR(e){return(typeof e=="string"?e:""+e).replace(sq,`
15
- `).replace(aq,"")}function O1(e,t){return t=GR(t),GR(e)===t}function Uh(){}function Be(e,t,n,r,i,o){switch(n){case"children":typeof r=="string"?t==="body"||t==="textarea"&&r===""||Kc(e,r):(typeof r=="number"||typeof r=="bigint")&&t!=="body"&&Kc(e,""+r);break;case"className":Sm(e,"class",r);break;case"tabIndex":Sm(e,"tabindex",r);break;case"dir":case"role":case"viewBox":case"width":case"height":Sm(e,n,r);break;case"style":OP(e,r,o);break;case"data":if(t!=="object"){Sm(e,"data",r);break}case"src":case"href":if(r===""&&(t!=="a"||n!=="href")){e.removeAttribute(n);break}if(r==null||typeof r=="function"||typeof r=="symbol"||typeof r=="boolean"){e.removeAttribute(n);break}r=Dm(""+r),e.setAttribute(n,r);break;case"action":case"formAction":if(typeof r=="function"){e.setAttribute(n,"javascript:throw new Error('A React form was unexpectedly submitted. If you called form.submit() manually, consider using form.requestSubmit() instead. If you\\'re trying to use event.stopPropagation() in a submit event handler, consider also calling event.preventDefault().')");break}else typeof o=="function"&&(n==="formAction"?(t!=="input"&&Be(e,t,"name",i.name,i,null),Be(e,t,"formEncType",i.formEncType,i,null),Be(e,t,"formMethod",i.formMethod,i,null),Be(e,t,"formTarget",i.formTarget,i,null)):(Be(e,t,"encType",i.encType,i,null),Be(e,t,"method",i.method,i,null),Be(e,t,"target",i.target,i,null)));if(r==null||typeof r=="symbol"||typeof r=="boolean"){e.removeAttribute(n);break}r=Dm(""+r),e.setAttribute(n,r);break;case"onClick":r!=null&&(e.onclick=Uh);break;case"onScroll":r!=null&&le("scroll",e);break;case"onScrollEnd":r!=null&&le("scrollend",e);break;case"dangerouslySetInnerHTML":if(r!=null){if(typeof r!="object"||!("__html"in r))throw Error(D(61));if(n=r.__html,n!=null){if(i.children!=null)throw Error(D(60));e.innerHTML=n}}break;case"multiple":e.multiple=r&&typeof r!="function"&&typeof r!="symbol";break;case"muted":e.muted=r&&typeof r!="function"&&typeof r!="symbol";break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"defaultValue":case"defaultChecked":case"innerHTML":case"ref":break;case"autoFocus":break;case"xlinkHref":if(r==null||typeof r=="function"||typeof r=="boolean"||typeof r=="symbol"){e.removeAttribute("xlink:href");break}n=Dm(""+r),e.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",n);break;case"contentEditable":case"spellCheck":case"draggable":case"value":case"autoReverse":case"externalResourcesRequired":case"focusable":case"preserveAlpha":r!=null&&typeof r!="function"&&typeof r!="symbol"?e.setAttribute(n,""+r):e.removeAttribute(n);break;case"inert":case"allowFullScreen":case"async":case"autoPlay":case"controls":case"default":case"defer":case"disabled":case"disablePictureInPicture":case"disableRemotePlayback":case"formNoValidate":case"hidden":case"loop":case"noModule":case"noValidate":case"open":case"playsInline":case"readOnly":case"required":case"reversed":case"scoped":case"seamless":case"itemScope":r&&typeof r!="function"&&typeof r!="symbol"?e.setAttribute(n,""):e.removeAttribute(n);break;case"capture":case"download":r===!0?e.setAttribute(n,""):r!==!1&&r!=null&&typeof r!="function"&&typeof r!="symbol"?e.setAttribute(n,r):e.removeAttribute(n);break;case"cols":case"rows":case"size":case"span":r!=null&&typeof r!="function"&&typeof r!="symbol"&&!isNaN(r)&&1<=r?e.setAttribute(n,r):e.removeAttribute(n);break;case"rowSpan":case"start":r==null||typeof r=="function"||typeof r=="symbol"||isNaN(r)?e.removeAttribute(n):e.setAttribute(n,r);break;case"popover":le("beforetoggle",e),le("toggle",e),km(e,"popover",r);break;case"xlinkActuate":Ji(e,"http://www.w3.org/1999/xlink","xlink:actuate",r);break;case"xlinkArcrole":Ji(e,"http://www.w3.org/1999/xlink","xlink:arcrole",r);break;case"xlinkRole":Ji(e,"http://www.w3.org/1999/xlink","xlink:role",r);break;case"xlinkShow":Ji(e,"http://www.w3.org/1999/xlink","xlink:show",r);break;case"xlinkTitle":Ji(e,"http://www.w3.org/1999/xlink","xlink:title",r);break;case"xlinkType":Ji(e,"http://www.w3.org/1999/xlink","xlink:type",r);break;case"xmlBase":Ji(e,"http://www.w3.org/XML/1998/namespace","xml:base",r);break;case"xmlLang":Ji(e,"http://www.w3.org/XML/1998/namespace","xml:lang",r);break;case"xmlSpace":Ji(e,"http://www.w3.org/XML/1998/namespace","xml:space",r);break;case"is":km(e,"is",r);break;case"innerText":case"textContent":break;default:(!(2<n.length)||n[0]!=="o"&&n[0]!=="O"||n[1]!=="n"&&n[1]!=="N")&&(n=B8.get(n)||n,km(e,n,r))}}function UT(e,t,n,r,i,o){switch(n){case"style":OP(e,r,o);break;case"dangerouslySetInnerHTML":if(r!=null){if(typeof r!="object"||!("__html"in r))throw Error(D(61));if(n=r.__html,n!=null){if(i.children!=null)throw Error(D(60));e.innerHTML=n}}break;case"children":typeof r=="string"?Kc(e,r):(typeof r=="number"||typeof r=="bigint")&&Kc(e,""+r);break;case"onScroll":r!=null&&le("scroll",e);break;case"onScrollEnd":r!=null&&le("scrollend",e);break;case"onClick":r!=null&&(e.onclick=Uh);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"innerHTML":case"ref":break;case"innerText":case"textContent":break;default:if(!TP.hasOwnProperty(n))e:{if(n[0]==="o"&&n[1]==="n"&&(i=n.endsWith("Capture"),t=n.slice(2,i?n.length-7:void 0),o=e[Hn]||null,o=o!=null?o[n]:null,typeof o=="function"&&e.removeEventListener(t,o,i),typeof r=="function")){typeof o!="function"&&o!==null&&(n in e?e[n]=null:e.hasAttribute(n)&&e.removeAttribute(n)),e.addEventListener(t,r,i);break e}n in e?e[n]=r:r===!0?e.setAttribute(n,""):km(e,n,r)}}}function on(e,t,n){switch(t){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"img":le("error",e),le("load",e);var r=!1,i=!1,o;for(o in n)if(n.hasOwnProperty(o)){var s=n[o];if(s!=null)switch(o){case"src":r=!0;break;case"srcSet":i=!0;break;case"children":case"dangerouslySetInnerHTML":throw Error(D(137,t));default:Be(e,t,o,s,n,null)}}i&&Be(e,t,"srcSet",n.srcSet,n,null),r&&Be(e,t,"src",n.src,n,null);return;case"input":le("invalid",e);var a=o=s=i=null,c=null,l=null;for(r in n)if(n.hasOwnProperty(r)){var p=n[r];if(p!=null)switch(r){case"name":i=p;break;case"type":s=p;break;case"checked":c=p;break;case"defaultChecked":l=p;break;case"value":o=p;break;case"defaultValue":a=p;break;case"children":case"dangerouslySetInnerHTML":if(p!=null)throw Error(D(137,t));break;default:Be(e,t,r,p,n,null)}}EP(e,o,a,c,l,s,i,!1),Jm(e);return;case"select":le("invalid",e),r=s=o=null;for(i in n)if(n.hasOwnProperty(i)&&(a=n[i],a!=null))switch(i){case"value":o=a;break;case"defaultValue":s=a;break;case"multiple":r=a;default:Be(e,t,i,a,n,null)}t=o,n=s,e.multiple=!!r,t!=null?kc(e,!!r,t,!1):n!=null&&kc(e,!!r,n,!0);return;case"textarea":le("invalid",e),o=i=r=null;for(s in n)if(n.hasOwnProperty(s)&&(a=n[s],a!=null))switch(s){case"value":r=a;break;case"defaultValue":i=a;break;case"children":o=a;break;case"dangerouslySetInnerHTML":if(a!=null)throw Error(D(91));break;default:Be(e,t,s,a,n,null)}MP(e,r,i,o),Jm(e);return;case"option":for(c in n)if(n.hasOwnProperty(c)&&(r=n[c],r!=null))switch(c){case"selected":e.selected=r&&typeof r!="function"&&typeof r!="symbol";break;default:Be(e,t,c,r,n,null)}return;case"dialog":le("beforetoggle",e),le("toggle",e),le("cancel",e),le("close",e);break;case"iframe":case"object":le("load",e);break;case"video":case"audio":for(r=0;r<$p.length;r++)le($p[r],e);break;case"image":le("error",e),le("load",e);break;case"details":le("toggle",e);break;case"embed":case"source":case"link":le("error",e),le("load",e);case"area":case"base":case"br":case"col":case"hr":case"keygen":case"meta":case"param":case"track":case"wbr":case"menuitem":for(l in n)if(n.hasOwnProperty(l)&&(r=n[l],r!=null))switch(l){case"children":case"dangerouslySetInnerHTML":throw Error(D(137,t));default:Be(e,t,l,r,n,null)}return;default:if(XT(t)){for(p in n)n.hasOwnProperty(p)&&(r=n[p],r!==void 0&&UT(e,t,p,r,n,void 0));return}}for(a in n)n.hasOwnProperty(a)&&(r=n[a],r!=null&&Be(e,t,a,r,n,null))}function cq(e,t,n,r){switch(t){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"input":var i=null,o=null,s=null,a=null,c=null,l=null,p=null;for(y in n){var d=n[y];if(n.hasOwnProperty(y)&&d!=null)switch(y){case"checked":break;case"value":break;case"defaultValue":c=d;default:r.hasOwnProperty(y)||Be(e,t,y,null,r,d)}}for(var m in r){var y=r[m];if(d=n[m],r.hasOwnProperty(m)&&(y!=null||d!=null))switch(m){case"type":o=y;break;case"name":i=y;break;case"checked":l=y;break;case"defaultChecked":p=y;break;case"value":s=y;break;case"defaultValue":a=y;break;case"children":case"dangerouslySetInnerHTML":if(y!=null)throw Error(D(137,t));break;default:y!==d&&Be(e,t,m,y,r,d)}}oT(e,s,a,c,l,p,o,i);return;case"select":y=s=a=m=null;for(o in n)if(c=n[o],n.hasOwnProperty(o)&&c!=null)switch(o){case"value":break;case"multiple":y=c;default:r.hasOwnProperty(o)||Be(e,t,o,null,r,c)}for(i in r)if(o=r[i],c=n[i],r.hasOwnProperty(i)&&(o!=null||c!=null))switch(i){case"value":m=o;break;case"defaultValue":a=o;break;case"multiple":s=o;default:o!==c&&Be(e,t,i,o,r,c)}t=a,n=s,r=y,m!=null?kc(e,!!n,m,!1):!!r!=!!n&&(t!=null?kc(e,!!n,t,!0):kc(e,!!n,n?[]:"",!1));return;case"textarea":y=m=null;for(a in n)if(i=n[a],n.hasOwnProperty(a)&&i!=null&&!r.hasOwnProperty(a))switch(a){case"value":break;case"children":break;default:Be(e,t,a,null,r,i)}for(s in r)if(i=r[s],o=n[s],r.hasOwnProperty(s)&&(i!=null||o!=null))switch(s){case"value":m=i;break;case"defaultValue":y=i;break;case"children":break;case"dangerouslySetInnerHTML":if(i!=null)throw Error(D(91));break;default:i!==o&&Be(e,t,s,i,r,o)}wP(e,m,y);return;case"option":for(var S in n)if(m=n[S],n.hasOwnProperty(S)&&m!=null&&!r.hasOwnProperty(S))switch(S){case"selected":e.selected=!1;break;default:Be(e,t,S,null,r,m)}for(c in r)if(m=r[c],y=n[c],r.hasOwnProperty(c)&&m!==y&&(m!=null||y!=null))switch(c){case"selected":e.selected=m&&typeof m!="function"&&typeof m!="symbol";break;default:Be(e,t,c,m,r,y)}return;case"img":case"link":case"area":case"base":case"br":case"col":case"embed":case"hr":case"keygen":case"meta":case"param":case"source":case"track":case"wbr":case"menuitem":for(var T in n)m=n[T],n.hasOwnProperty(T)&&m!=null&&!r.hasOwnProperty(T)&&Be(e,t,T,null,r,m);for(l in r)if(m=r[l],y=n[l],r.hasOwnProperty(l)&&m!==y&&(m!=null||y!=null))switch(l){case"children":case"dangerouslySetInnerHTML":if(m!=null)throw Error(D(137,t));break;default:Be(e,t,l,m,r,y)}return;default:if(XT(t)){for(var E in n)m=n[E],n.hasOwnProperty(E)&&m!==void 0&&!r.hasOwnProperty(E)&&UT(e,t,E,void 0,r,m);for(p in r)m=r[p],y=n[p],!r.hasOwnProperty(p)||m===y||m===void 0&&y===void 0||UT(e,t,p,m,r,y);return}}for(var b in n)m=n[b],n.hasOwnProperty(b)&&m!=null&&!r.hasOwnProperty(b)&&Be(e,t,b,null,r,m);for(d in r)m=r[d],y=n[d],!r.hasOwnProperty(d)||m===y||m==null&&y==null||Be(e,t,d,m,r,y)}var _T=null,jT=null;function yh(e){return e.nodeType===9?e:e.ownerDocument}function qR(e){switch(e){case"http://www.w3.org/2000/svg":return 1;case"http://www.w3.org/1998/Math/MathML":return 2;default:return 0}}function A1(e,t){if(e===0)switch(t){case"svg":return 1;case"math":return 2;default:return 0}return e===1&&t==="foreignObject"?0:e}function LT(e,t){return e==="textarea"||e==="noscript"||typeof t.children=="string"||typeof t.children=="number"||typeof t.children=="bigint"||typeof t.dangerouslySetInnerHTML=="object"&&t.dangerouslySetInnerHTML!==null&&t.dangerouslySetInnerHTML.__html!=null}var Yx=null;function uq(){var e=window.event;return e&&e.type==="popstate"?e===Yx?!1:(Yx=e,!0):(Yx=null,!1)}var R1=typeof setTimeout=="function"?setTimeout:void 0,lq=typeof clearTimeout=="function"?clearTimeout:void 0,VR=typeof Promise=="function"?Promise:void 0,pq=typeof queueMicrotask=="function"?queueMicrotask:typeof VR<"u"?function(e){return VR.resolve(null).then(e).catch(fq)}:R1;function fq(e){setTimeout(function(){throw e})}function ps(e){return e==="head"}function QR(e,t){var n=t,r=0,i=0;do{var o=n.nextSibling;if(e.removeChild(n),o&&o.nodeType===8)if(n=o.data,n==="/$"){if(0<r&&8>r){n=r;var s=e.ownerDocument;if(n&1&&kp(s.documentElement),n&2&&kp(s.body),n&4)for(n=s.head,kp(n),s=n.firstChild;s;){var a=s.nextSibling,c=s.nodeName;s[Zp]||c==="SCRIPT"||c==="STYLE"||c==="LINK"&&s.rel.toLowerCase()==="stylesheet"||n.removeChild(s),s=a}}if(i===0){e.removeChild(o),Vp(t);return}i--}else n==="$"||n==="$?"||n==="$!"?i++:r=n.charCodeAt(0)-48;else r=0;n=o}while(n);Vp(t)}function BT(e){var t=e.firstChild;for(t&&t.nodeType===10&&(t=t.nextSibling);t;){var n=t;switch(t=t.nextSibling,n.nodeName){case"HTML":case"HEAD":case"BODY":BT(n),JT(n);continue;case"SCRIPT":case"STYLE":continue;case"LINK":if(n.rel.toLowerCase()==="stylesheet")continue}e.removeChild(n)}}function dq(e,t,n,r){for(;e.nodeType===1;){var i=n;if(e.nodeName.toLowerCase()!==t.toLowerCase()){if(!r&&(e.nodeName!=="INPUT"||e.type!=="hidden"))break}else if(r){if(!e[Zp])switch(t){case"meta":if(!e.hasAttribute("itemprop"))break;return e;case"link":if(o=e.getAttribute("rel"),o==="stylesheet"&&e.hasAttribute("data-precedence"))break;if(o!==i.rel||e.getAttribute("href")!==(i.href==null||i.href===""?null:i.href)||e.getAttribute("crossorigin")!==(i.crossOrigin==null?null:i.crossOrigin)||e.getAttribute("title")!==(i.title==null?null:i.title))break;return e;case"style":if(e.hasAttribute("data-precedence"))break;return e;case"script":if(o=e.getAttribute("src"),(o!==(i.src==null?null:i.src)||e.getAttribute("type")!==(i.type==null?null:i.type)||e.getAttribute("crossorigin")!==(i.crossOrigin==null?null:i.crossOrigin))&&o&&e.hasAttribute("async")&&!e.hasAttribute("itemprop"))break;return e;default:return e}}else if(t==="input"&&e.type==="hidden"){var o=i.name==null?null:""+i.name;if(i.type==="hidden"&&e.getAttribute("name")===o)return e}else return e;if(e=Wr(e.nextSibling),e===null)break}return null}function mq(e,t,n){if(t==="")return null;for(;e.nodeType!==3;)if((e.nodeType!==1||e.nodeName!=="INPUT"||e.type!=="hidden")&&!n||(e=Wr(e.nextSibling),e===null))return null;return e}function FT(e){return e.data==="$!"||e.data==="$?"&&e.ownerDocument.readyState==="complete"}function hq(e,t){var n=e.ownerDocument;if(e.data!=="$?"||n.readyState==="complete")t();else{var r=function(){t(),n.removeEventListener("DOMContentLoaded",r)};n.addEventListener("DOMContentLoaded",r),e._reactRetry=r}}function Wr(e){for(;e!=null;e=e.nextSibling){var t=e.nodeType;if(t===1||t===3)break;if(t===8){if(t=e.data,t==="$"||t==="$!"||t==="$?"||t==="F!"||t==="F")break;if(t==="/$")return null}}return e}var $T=null;function YR(e){e=e.previousSibling;for(var t=0;e;){if(e.nodeType===8){var n=e.data;if(n==="$"||n==="$!"||n==="$?"){if(t===0)return e;t--}else n==="/$"&&t++}e=e.previousSibling}return null}function P1(e,t,n){switch(t=yh(n),e){case"html":if(e=t.documentElement,!e)throw Error(D(452));return e;case"head":if(e=t.head,!e)throw Error(D(453));return e;case"body":if(e=t.body,!e)throw Error(D(454));return e;default:throw Error(D(451))}}function kp(e){for(var t=e.attributes;t.length;)e.removeAttributeNode(t[0]);JT(e)}var jr=new Map,JR=new Set;function gh(e){return typeof e.getRootNode=="function"?e.getRootNode():e.nodeType===9?e:e.ownerDocument}var po=Me.d;Me.d={f:yq,r:gq,D:bq,C:Sq,L:xq,m:Tq,X:Iq,S:vq,M:Eq};function yq(){var e=po.f(),t=Nh();return e||t}function gq(e){var t=Zc(e);t!==null&&t.tag===5&&t.type==="form"?IC(t):po.r(e)}var tu=typeof document>"u"?null:document;function C1(e,t,n){var r=tu;if(r&&typeof t=="string"&&t){var i=kr(t);i='link[rel="'+e+'"][href="'+i+'"]',typeof n=="string"&&(i+='[crossorigin="'+n+'"]'),JR.has(i)||(JR.add(i),e={rel:e,crossOrigin:n,href:t},r.querySelector(i)===null&&(t=r.createElement("link"),on(t,"link",e),Vt(t),r.head.appendChild(t)))}}function bq(e){po.D(e),C1("dns-prefetch",e,null)}function Sq(e,t){po.C(e,t),C1("preconnect",e,t)}function xq(e,t,n){po.L(e,t,n);var r=tu;if(r&&e&&t){var i='link[rel="preload"][as="'+kr(t)+'"]';t==="image"&&n&&n.imageSrcSet?(i+='[imagesrcset="'+kr(n.imageSrcSet)+'"]',typeof n.imageSizes=="string"&&(i+='[imagesizes="'+kr(n.imageSizes)+'"]')):i+='[href="'+kr(e)+'"]';var o=i;switch(t){case"style":o=Jc(e);break;case"script":o=nu(e)}jr.has(o)||(e=We({rel:"preload",href:t==="image"&&n&&n.imageSrcSet?void 0:e,as:t},n),jr.set(o,e),r.querySelector(i)!==null||t==="style"&&r.querySelector(uf(o))||t==="script"&&r.querySelector(lf(o))||(t=r.createElement("link"),on(t,"link",e),Vt(t),r.head.appendChild(t)))}}function Tq(e,t){po.m(e,t);var n=tu;if(n&&e){var r=t&&typeof t.as=="string"?t.as:"script",i='link[rel="modulepreload"][as="'+kr(r)+'"][href="'+kr(e)+'"]',o=i;switch(r){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":o=nu(e)}if(!jr.has(o)&&(e=We({rel:"modulepreload",href:e},t),jr.set(o,e),n.querySelector(i)===null)){switch(r){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(n.querySelector(lf(o)))return}r=n.createElement("link"),on(r,"link",e),Vt(r),n.head.appendChild(r)}}}function vq(e,t,n){po.S(e,t,n);var r=tu;if(r&&e){var i=Nc(r).hoistableStyles,o=Jc(e);t=t||"default";var s=i.get(o);if(!s){var a={loading:0,preload:null};if(s=r.querySelector(uf(o)))a.loading=5;else{e=We({rel:"stylesheet",href:e,"data-precedence":t},n),(n=jr.get(o))&&kv(e,n);var c=s=r.createElement("link");Vt(c),on(c,"link",e),c._p=new Promise(function(l,p){c.onload=l,c.onerror=p}),c.addEventListener("load",function(){a.loading|=1}),c.addEventListener("error",function(){a.loading|=2}),a.loading|=4,zm(s,t,r)}s={type:"stylesheet",instance:s,count:1,state:a},i.set(o,s)}}}function Iq(e,t){po.X(e,t);var n=tu;if(n&&e){var r=Nc(n).hoistableScripts,i=nu(e),o=r.get(i);o||(o=n.querySelector(lf(i)),o||(e=We({src:e,async:!0},t),(t=jr.get(i))&&Dv(e,t),o=n.createElement("script"),Vt(o),on(o,"link",e),n.head.appendChild(o)),o={type:"script",instance:o,count:1,state:null},r.set(i,o))}}function Eq(e,t){po.M(e,t);var n=tu;if(n&&e){var r=Nc(n).hoistableScripts,i=nu(e),o=r.get(i);o||(o=n.querySelector(lf(i)),o||(e=We({src:e,async:!0,type:"module"},t),(t=jr.get(i))&&Dv(e,t),o=n.createElement("script"),Vt(o),on(o,"link",e),n.head.appendChild(o)),o={type:"script",instance:o,count:1,state:null},r.set(i,o))}}function XR(e,t,n,r){var i=(i=Wo.current)?gh(i):null;if(!i)throw Error(D(446));switch(e){case"meta":case"title":return null;case"style":return typeof n.precedence=="string"&&typeof n.href=="string"?(t=Jc(n.href),n=Nc(i).hoistableStyles,r=n.get(t),r||(r={type:"style",instance:null,count:0,state:null},n.set(t,r)),r):{type:"void",instance:null,count:0,state:null};case"link":if(n.rel==="stylesheet"&&typeof n.href=="string"&&typeof n.precedence=="string"){e=Jc(n.href);var o=Nc(i).hoistableStyles,s=o.get(e);if(s||(i=i.ownerDocument||i,s={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},o.set(e,s),(o=i.querySelector(uf(e)))&&!o._p&&(s.instance=o,s.state.loading=5),jr.has(e)||(n={rel:"preload",as:"style",href:n.href,crossOrigin:n.crossOrigin,integrity:n.integrity,media:n.media,hrefLang:n.hrefLang,referrerPolicy:n.referrerPolicy},jr.set(e,n),o||wq(i,e,n,s.state))),t&&r===null)throw Error(D(528,""));return s}if(t&&r!==null)throw Error(D(529,""));return null;case"script":return t=n.async,n=n.src,typeof n=="string"&&t&&typeof t!="function"&&typeof t!="symbol"?(t=nu(n),n=Nc(i).hoistableScripts,r=n.get(t),r||(r={type:"script",instance:null,count:0,state:null},n.set(t,r)),r):{type:"void",instance:null,count:0,state:null};default:throw Error(D(444,e))}}function Jc(e){return'href="'+kr(e)+'"'}function uf(e){return'link[rel="stylesheet"]['+e+"]"}function N1(e){return We({},e,{"data-precedence":e.precedence,precedence:null})}function wq(e,t,n,r){e.querySelector('link[rel="preload"][as="style"]['+t+"]")?r.loading=1:(t=e.createElement("link"),r.preload=t,t.addEventListener("load",function(){return r.loading|=1}),t.addEventListener("error",function(){return r.loading|=2}),on(t,"link",n),Vt(t),e.head.appendChild(t))}function nu(e){return'[src="'+kr(e)+'"]'}function lf(e){return"script[async]"+e}function ZR(e,t,n){if(t.count++,t.instance===null)switch(t.type){case"style":var r=e.querySelector('style[data-href~="'+kr(n.href)+'"]');if(r)return t.instance=r,Vt(r),r;var i=We({},n,{"data-href":n.href,"data-precedence":n.precedence,href:null,precedence:null});return r=(e.ownerDocument||e).createElement("style"),Vt(r),on(r,"style",i),zm(r,n.precedence,e),t.instance=r;case"stylesheet":i=Jc(n.href);var o=e.querySelector(uf(i));if(o)return t.state.loading|=4,t.instance=o,Vt(o),o;r=N1(n),(i=jr.get(i))&&kv(r,i),o=(e.ownerDocument||e).createElement("link"),Vt(o);var s=o;return s._p=new Promise(function(a,c){s.onload=a,s.onerror=c}),on(o,"link",r),t.state.loading|=4,zm(o,n.precedence,e),t.instance=o;case"script":return o=nu(n.src),(i=e.querySelector(lf(o)))?(t.instance=i,Vt(i),i):(r=n,(i=jr.get(o))&&(r=We({},n),Dv(r,i)),e=e.ownerDocument||e,i=e.createElement("script"),Vt(i),on(i,"link",r),e.head.appendChild(i),t.instance=i);case"void":return null;default:throw Error(D(443,t.type))}else t.type==="stylesheet"&&!(t.state.loading&4)&&(r=t.instance,t.state.loading|=4,zm(r,n.precedence,e));return t.instance}function zm(e,t,n){for(var r=n.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),i=r.length?r[r.length-1]:null,o=i,s=0;s<r.length;s++){var a=r[s];if(a.dataset.precedence===t)o=a;else if(o!==i)break}o?o.parentNode.insertBefore(e,o.nextSibling):(t=n.nodeType===9?n.head:n,t.insertBefore(e,t.firstChild))}function kv(e,t){e.crossOrigin==null&&(e.crossOrigin=t.crossOrigin),e.referrerPolicy==null&&(e.referrerPolicy=t.referrerPolicy),e.title==null&&(e.title=t.title)}function Dv(e,t){e.crossOrigin==null&&(e.crossOrigin=t.crossOrigin),e.referrerPolicy==null&&(e.referrerPolicy=t.referrerPolicy),e.integrity==null&&(e.integrity=t.integrity)}var Hm=null;function WR(e,t,n){if(Hm===null){var r=new Map,i=Hm=new Map;i.set(n,r)}else i=Hm,r=i.get(n),r||(r=new Map,i.set(n,r));if(r.has(e))return r;for(r.set(e,null),n=n.getElementsByTagName(e),i=0;i<n.length;i++){var o=n[i];if(!(o[Zp]||o[mn]||e==="link"&&o.getAttribute("rel")==="stylesheet")&&o.namespaceURI!=="http://www.w3.org/2000/svg"){var s=o.getAttribute(t)||"";s=e+s;var a=r.get(s);a?a.push(o):r.set(s,[o])}}return r}function eP(e,t,n){e=e.ownerDocument||e,e.head.insertBefore(n,t==="title"?e.querySelector("head > title"):null)}function Mq(e,t,n){if(n===1||t.itemProp!=null)return!1;switch(e){case"meta":case"title":return!0;case"style":if(typeof t.precedence!="string"||typeof t.href!="string"||t.href==="")break;return!0;case"link":if(typeof t.rel!="string"||typeof t.href!="string"||t.href===""||t.onLoad||t.onError)break;switch(t.rel){case"stylesheet":return e=t.disabled,typeof t.precedence=="string"&&e==null;default:return!0}case"script":if(t.async&&typeof t.async!="function"&&typeof t.async!="symbol"&&!t.onLoad&&!t.onError&&t.src&&typeof t.src=="string")return!0}return!1}function k1(e){return!(e.type==="stylesheet"&&!(e.state.loading&3))}var zp=null;function Oq(){}function Aq(e,t,n){if(zp===null)throw Error(D(475));var r=zp;if(t.type==="stylesheet"&&(typeof n.media!="string"||matchMedia(n.media).matches!==!1)&&!(t.state.loading&4)){if(t.instance===null){var i=Jc(n.href),o=e.querySelector(uf(i));if(o){e=o._p,e!==null&&typeof e=="object"&&typeof e.then=="function"&&(r.count++,r=bh.bind(r),e.then(r,r)),t.state.loading|=4,t.instance=o,Vt(o);return}o=e.ownerDocument||e,n=N1(n),(i=jr.get(i))&&kv(n,i),o=o.createElement("link"),Vt(o);var s=o;s._p=new Promise(function(a,c){s.onload=a,s.onerror=c}),on(o,"link",n),t.instance=o}r.stylesheets===null&&(r.stylesheets=new Map),r.stylesheets.set(t,e),(e=t.state.preload)&&!(t.state.loading&3)&&(r.count++,t=bh.bind(r),e.addEventListener("load",t),e.addEventListener("error",t))}}function Rq(){if(zp===null)throw Error(D(475));var e=zp;return e.stylesheets&&e.count===0&&KT(e,e.stylesheets),0<e.count?function(t){var n=setTimeout(function(){if(e.stylesheets&&KT(e,e.stylesheets),e.unsuspend){var r=e.unsuspend;e.unsuspend=null,r()}},6e4);return e.unsuspend=t,function(){e.unsuspend=null,clearTimeout(n)}}:null}function bh(){if(this.count--,this.count===0){if(this.stylesheets)KT(this,this.stylesheets);else if(this.unsuspend){var e=this.unsuspend;this.unsuspend=null,e()}}}var Sh=null;function KT(e,t){e.stylesheets=null,e.unsuspend!==null&&(e.count++,Sh=new Map,t.forEach(Pq,e),Sh=null,bh.call(e))}function Pq(e,t){if(!(t.state.loading&4)){var n=Sh.get(e);if(n)var r=n.get(null);else{n=new Map,Sh.set(e,n);for(var i=e.querySelectorAll("link[data-precedence],style[data-precedence]"),o=0;o<i.length;o++){var s=i[o];(s.nodeName==="LINK"||s.getAttribute("media")!=="not all")&&(n.set(s.dataset.precedence,s),r=s)}r&&n.set(null,r)}i=t.instance,s=i.getAttribute("data-precedence"),o=n.get(s)||r,o===r&&n.set(null,i),n.set(s,i),this.count++,r=bh.bind(this),i.addEventListener("load",r),i.addEventListener("error",r),o?o.parentNode.insertBefore(i,o.nextSibling):(e=e.nodeType===9?e.head:e,e.insertBefore(i,e.firstChild)),t.state.loading|=4}}var Hp={$$typeof:eo,Provider:null,Consumer:null,_currentValue:oa,_currentValue2:oa,_threadCount:0};function Cq(e,t,n,r,i,o,s,a){this.tag=1,this.containerInfo=e,this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.next=this.pendingContext=this.context=this.cancelPendingCommit=null,this.callbackPriority=0,this.expirationTimes=xx(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=xx(0),this.hiddenUpdates=xx(null),this.identifierPrefix=r,this.onUncaughtError=i,this.onCaughtError=o,this.onRecoverableError=s,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=a,this.incompleteTransitions=new Map}function D1(e,t,n,r,i,o,s,a,c,l,p,d){return e=new Cq(e,t,n,s,a,c,l,d),t=1,o===!0&&(t|=24),o=cr(3,null,null,t),e.current=o,o.stateNode=e,t=cv(),t.refCount++,e.pooledCache=t,t.refCount++,o.memoizedState={element:r,isDehydrated:n,cache:t},lv(o),e}function U1(e){return e?(e=Ac,e):Ac}function _1(e,t,n,r,i,o){i=U1(i),r.context===null?r.context=i:r.pendingContext=i,r=es(t),r.payload={element:n},o=o===void 0?null:o,o!==null&&(r.callback=o),n=ts(e,r,t),n!==null&&(fr(n,e,t),wp(n,e,t))}function tP(e,t){if(e=e.memoizedState,e!==null&&e.dehydrated!==null){var n=e.retryLane;e.retryLane=n!==0&&n<t?n:t}}function Uv(e,t){tP(e,t),(e=e.alternate)&&tP(e,t)}function j1(e){if(e.tag===13){var t=Wc(e,67108864);t!==null&&fr(t,e,67108864),Uv(e,67108864)}}var xh=!0;function Nq(e,t,n,r){var i=X.T;X.T=null;var o=Me.p;try{Me.p=2,_v(e,t,n,r)}finally{Me.p=o,X.T=i}}function kq(e,t,n,r){var i=X.T;X.T=null;var o=Me.p;try{Me.p=8,_v(e,t,n,r)}finally{Me.p=o,X.T=i}}function _v(e,t,n,r){if(xh){var i=zT(r);if(i===null)Qx(e,t,r,Th,n),nP(e,r);else if(Uq(i,e,t,n,r))r.stopPropagation();else if(nP(e,r),t&4&&-1<Dq.indexOf(e)){for(;i!==null;){var o=Zc(i);if(o!==null)switch(o.tag){case 3:if(o=o.stateNode,o.current.memoizedState.isDehydrated){var s=na(o.pendingLanes);if(s!==0){var a=o;for(a.pendingLanes|=2,a.entangledLanes|=2;s;){var c=1<<31-lr(s);a.entanglements[1]|=c,s&=~c}Ei(o),!(_e&6)&&(ph=Ti()+500,cf(0,!1))}}break;case 13:a=Wc(o,2),a!==null&&fr(a,o,2),Nh(),Uv(o,2)}if(o=zT(r),o===null&&Qx(e,t,r,Th,n),o===i)break;i=o}i!==null&&r.stopPropagation()}else Qx(e,t,r,null,n)}}function zT(e){return e=ZT(e),jv(e)}var Th=null;function jv(e){if(Th=null,e=vc(e),e!==null){var t=Qp(e);if(t===null)e=null;else{var n=t.tag;if(n===13){if(e=cP(t),e!==null)return e;e=null}else if(n===3){if(t.stateNode.current.memoizedState.isDehydrated)return t.tag===3?t.stateNode.containerInfo:null;e=null}else t!==e&&(e=null)}}return Th=e,null}function L1(e){switch(e){case"beforetoggle":case"cancel":case"click":case"close":case"contextmenu":case"copy":case"cut":case"auxclick":case"dblclick":case"dragend":case"dragstart":case"drop":case"focusin":case"focusout":case"input":case"invalid":case"keydown":case"keypress":case"keyup":case"mousedown":case"mouseup":case"paste":case"pause":case"play":case"pointercancel":case"pointerdown":case"pointerup":case"ratechange":case"reset":case"resize":case"seeked":case"submit":case"toggle":case"touchcancel":case"touchend":case"touchstart":case"volumechange":case"change":case"selectionchange":case"textInput":case"compositionstart":case"compositionend":case"compositionupdate":case"beforeblur":case"afterblur":case"beforeinput":case"blur":case"fullscreenchange":case"focus":case"hashchange":case"popstate":case"select":case"selectstart":return 2;case"drag":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"mousemove":case"mouseout":case"mouseover":case"pointermove":case"pointerout":case"pointerover":case"scroll":case"touchmove":case"wheel":case"mouseenter":case"mouseleave":case"pointerenter":case"pointerleave":return 8;case"message":switch(T8()){case fP:return 2;case dP:return 8;case Ym:case v8:return 32;case mP:return 268435456;default:return 32}default:return 32}}var HT=!1,is=null,os=null,ss=null,Gp=new Map,qp=new Map,Qo=[],Dq="mousedown mouseup touchcancel touchend touchstart auxclick dblclick pointercancel pointerdown pointerup dragend dragstart drop compositionend compositionstart keydown keypress keyup input textInput copy cut paste click change contextmenu reset".split(" ");function nP(e,t){switch(e){case"focusin":case"focusout":is=null;break;case"dragenter":case"dragleave":os=null;break;case"mouseover":case"mouseout":ss=null;break;case"pointerover":case"pointerout":Gp.delete(t.pointerId);break;case"gotpointercapture":case"lostpointercapture":qp.delete(t.pointerId)}}function mp(e,t,n,r,i,o){return e===null||e.nativeEvent!==o?(e={blockedOn:t,domEventName:n,eventSystemFlags:r,nativeEvent:o,targetContainers:[i]},t!==null&&(t=Zc(t),t!==null&&j1(t)),e):(e.eventSystemFlags|=r,t=e.targetContainers,i!==null&&t.indexOf(i)===-1&&t.push(i),e)}function Uq(e,t,n,r,i){switch(t){case"focusin":return is=mp(is,e,t,n,r,i),!0;case"dragenter":return os=mp(os,e,t,n,r,i),!0;case"mouseover":return ss=mp(ss,e,t,n,r,i),!0;case"pointerover":var o=i.pointerId;return Gp.set(o,mp(Gp.get(o)||null,e,t,n,r,i)),!0;case"gotpointercapture":return o=i.pointerId,qp.set(o,mp(qp.get(o)||null,e,t,n,r,i)),!0}return!1}function B1(e){var t=vc(e.target);if(t!==null){var n=Qp(t);if(n!==null){if(t=n.tag,t===13){if(t=cP(n),t!==null){e.blockedOn=t,P8(e.priority,function(){if(n.tag===13){var r=pr();r=QT(r);var i=Wc(n,r);i!==null&&fr(i,n,r),Uv(n,r)}});return}}else if(t===3&&n.stateNode.current.memoizedState.isDehydrated){e.blockedOn=n.tag===3?n.stateNode.containerInfo:null;return}}}e.blockedOn=null}function Gm(e){if(e.blockedOn!==null)return!1;for(var t=e.targetContainers;0<t.length;){var n=zT(e.nativeEvent);if(n===null){n=e.nativeEvent;var r=new n.constructor(n.type,n);aT=r,n.target.dispatchEvent(r),aT=null}else return t=Zc(n),t!==null&&j1(t),e.blockedOn=n,!1;t.shift()}return!0}function rP(e,t,n){Gm(e)&&n.delete(t)}function _q(){HT=!1,is!==null&&Gm(is)&&(is=null),os!==null&&Gm(os)&&(os=null),ss!==null&&Gm(ss)&&(ss=null),Gp.forEach(rP),qp.forEach(rP)}function Cm(e,t){e.blockedOn===t&&(e.blockedOn=null,HT||(HT=!0,Lt.unstable_scheduleCallback(Lt.unstable_NormalPriority,_q)))}var Nm=null;function iP(e){Nm!==e&&(Nm=e,Lt.unstable_scheduleCallback(Lt.unstable_NormalPriority,function(){Nm===e&&(Nm=null);for(var t=0;t<e.length;t+=3){var n=e[t],r=e[t+1],i=e[t+2];if(typeof r!="function"){if(jv(r||n)===null)continue;break}var o=Zc(n);o!==null&&(e.splice(t,3),t-=3,IT(o,{pending:!0,data:i,method:n.method,action:r},r,i))}}))}function Vp(e){function t(c){return Cm(c,e)}is!==null&&Cm(is,e),os!==null&&Cm(os,e),ss!==null&&Cm(ss,e),Gp.forEach(t),qp.forEach(t);for(var n=0;n<Qo.length;n++){var r=Qo[n];r.blockedOn===e&&(r.blockedOn=null)}for(;0<Qo.length&&(n=Qo[0],n.blockedOn===null);)B1(n),n.blockedOn===null&&Qo.shift();if(n=(e.ownerDocument||e).$$reactFormReplay,n!=null)for(r=0;r<n.length;r+=3){var i=n[r],o=n[r+1],s=i[Hn]||null;if(typeof o=="function")s||iP(n);else if(s){var a=null;if(o&&o.hasAttribute("formAction")){if(i=o,s=o[Hn]||null)a=s.formAction;else if(jv(i)!==null)continue}else a=s.action;typeof a=="function"?n[r+1]=a:(n.splice(r,3),r-=3),iP(n)}}}function Lv(e){this._internalRoot=e}_h.prototype.render=Lv.prototype.render=function(e){var t=this._internalRoot;if(t===null)throw Error(D(409));var n=t.current,r=pr();_1(n,r,e,t,null,null)};_h.prototype.unmount=Lv.prototype.unmount=function(){var e=this._internalRoot;if(e!==null){this._internalRoot=null;var t=e.containerInfo;_1(e.current,2,null,e,null,null),Nh(),t[Xc]=null}};function _h(e){this._internalRoot=e}_h.prototype.unstable_scheduleHydration=function(e){if(e){var t=SP();e={blockedOn:null,target:e,priority:t};for(var n=0;n<Qo.length&&t!==0&&t<Qo[n].priority;n++);Qo.splice(n,0,e),n===0&&B1(e)}};var oP=sP.version;if(oP!=="19.1.2")throw Error(D(527,oP,"19.1.2"));Me.findDOMNode=function(e){var t=e._reactInternals;if(t===void 0)throw typeof e.render=="function"?Error(D(188)):(e=Object.keys(e).join(","),Error(D(268,e)));return e=m8(t),e=e!==null?uP(e):null,e=e===null?null:e.stateNode,e};var jq={bundleType:0,version:"19.1.2",rendererPackageName:"react-dom",currentDispatcherRef:X,reconcilerVersion:"19.1.2"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&(hp=__REACT_DEVTOOLS_GLOBAL_HOOK__,!hp.isDisabled&&hp.supportsFiber))try{Yp=hp.inject(jq),ur=hp}catch{}var hp;jh.createRoot=function(e,t){if(!aP(e))throw Error(D(299));var n=!1,r="",i=DC,o=UC,s=_C,a=null;return t!=null&&(t.unstable_strictMode===!0&&(n=!0),t.identifierPrefix!==void 0&&(r=t.identifierPrefix),t.onUncaughtError!==void 0&&(i=t.onUncaughtError),t.onCaughtError!==void 0&&(o=t.onCaughtError),t.onRecoverableError!==void 0&&(s=t.onRecoverableError),t.unstable_transitionCallbacks!==void 0&&(a=t.unstable_transitionCallbacks)),t=D1(e,1,!1,null,null,n,r,i,o,s,a,null),e[Xc]=t.current,Nv(e),new Lv(t)};jh.hydrateRoot=function(e,t,n){if(!aP(e))throw Error(D(299));var r=!1,i="",o=DC,s=UC,a=_C,c=null,l=null;return n!=null&&(n.unstable_strictMode===!0&&(r=!0),n.identifierPrefix!==void 0&&(i=n.identifierPrefix),n.onUncaughtError!==void 0&&(o=n.onUncaughtError),n.onCaughtError!==void 0&&(s=n.onCaughtError),n.onRecoverableError!==void 0&&(a=n.onRecoverableError),n.unstable_transitionCallbacks!==void 0&&(c=n.unstable_transitionCallbacks),n.formState!==void 0&&(l=n.formState)),t=D1(e,1,!0,t,n??null,r,i,o,s,a,c,l),t.context=U1(null),n=t.current,r=pr(),r=QT(r),i=es(r),i.callback=null,ts(n,i,r),n=r,t.current.lanes=n,Xp(t,n),Ei(t),e[Xc]=t.current,Nv(e),new _h(t)};jh.version="19.1.2"});var Bv=ee((Tke,K1)=>{"use strict";u();function $1(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE($1)}catch(e){console.error(e)}}$1(),K1.exports=F1()});var f5={};Ci(f5,{AIManager:()=>fl,AccessPolicy:()=>Q4,ActivityEventsManager:()=>sl,AnyNoyaStateContext:()=>ty,AssetManager:()=>dl,AssetStoreIndexedDB:()=>Ya,AssetStoreMemory:()=>Ja,AssetStoreRemote:()=>$i,ConnectionEventManager:()=>yl,EvalManager:()=>Ol,FallbackUntilInitialized:()=>LN,FilePropertyManager:()=>Al,GIT_BUNDLE_CONTENT_TYPE:()=>Ki,GitFileEditSession:()=>kl,GitManager:()=>Dl,HistoryEntries:()=>Mr,IOManager:()=>_l,ImagePickerManager:()=>Ul,Kind:()=>R,LocalAssetStorageAdapter:()=>jl,LocalGitFileEditor:()=>ep,LogManager:()=>zs,MAX_INPUT_QUEUE_LENGTH:()=>d6,MULTIPLAYER_POLICY_METADATA_KEY:()=>qs,MenuItemTree:()=>cA,MenuManager:()=>Ll,MultiplayerStateManager:()=>Gi,MultiplayerStateManagerError:()=>Ys,NoyaManager:()=>Vi,OperationManager:()=>Co,PipelineManager:()=>$l,PublishingManager:()=>Kl,RPCManager:()=>ql,ReconnectingWebSocket:()=>lc,ResourceEditSession:()=>zl,ResourceManager:()=>Hl,SERVER_COMPUTED_METADATA_KEY:()=>zd,SERVER_SCRIPTS_METADATA_KEY:()=>hS,SandboxManager:()=>Gl,ScriptEvaluationError:()=>Vd,ScriptEvaluatorManager:()=>Vl,SecretManager:()=>Ql,ServerComputed:()=>V4,ServerScriptManager:()=>Qs,ServerScripts:()=>Y4,SharedConnectionDataManager:()=>Cl,StateInspector:()=>hf,StateInterpolator:()=>ix,StateManager:()=>$s,TaskManager:()=>Yl,TranscriptionManager:()=>Jl,Type:()=>x,TypeGuard:()=>w,UserActivityDetector:()=>uc,UserManager:()=>rp,UserPointersOverlay:()=>l5,Value:()=>Cg,WebSocketConnection:()=>Bo,addPathPrefixToEditOptions:()=>B4,apply:()=>qb,applyDocumentOperationsParametersSchema:()=>Wb,applyExtendedPatch:()=>De,applyPatchToString:()=>AM,applyServerComputedMetadata:()=>bS,applyServerMessage:()=>Lo,bridgeRpcRequestToLocalAssets:()=>QS,bridgeRpcRequestToNetwork:()=>JS,buildResourcePatchPayload:()=>PN,castValue:()=>ml,checkType:()=>Ao,checkTypeSafe:()=>uM,clearConnectionQueue:()=>m6,clientId$:()=>hi,clientImage$:()=>Xs,clientName$:()=>Js,createDefaultAppData:()=>wN,createDefaultMessageHandler:()=>sm,createEditHistoryEntry:()=>Dd,createEmbeddedHost:()=>H6,createExtended:()=>Cd,createHash:()=>Nl,createInitialSandboxState:()=>$O,createNoyaContext:()=>o5,createOrCastValue:()=>hl,createPatchHistoryEntry:()=>No,createPipelineRunRequest:()=>e8,createSecretRequest:()=>t8,createStateInspectorRoot:()=>Jh,createValue:()=>Ab,decodeAll:()=>xN,defaultMergeHistoryEntries:()=>fA,deleteNoyaSingleton:()=>PV,deleteSecretRequest:()=>n8,diff:()=>Qr,diffString:()=>Jb,drainInputQueue:()=>OS,encodeAll:()=>SN,enforceMultiplayerPolicies:()=>gS,enforceSchema:()=>MN,enqueueInput:()=>MS,ensureLocalAssetStore:()=>ac,ensureLocalResourceStore:()=>Zs,exportAll:()=>iI,extractItemId:()=>ec,fetchAssetMap:()=>bN,fetchRPC:()=>jo,fetchRPCStream:()=>_o,filterStateForReadAccess:()=>t6,findNoyaUser:()=>am,forwardConnectionEventsToChild:()=>qS,getAppData:()=>Zh,getNoyaManagerSingleton:()=>pI,getNoyaSingletonBindings:()=>fI,getOfflineStorageKey:()=>q6,getResourceTransformUrl:()=>FO,getResourceUrl:()=>wS,getSelectableMenuItems:()=>uA,getServerScriptDefinitions:()=>yS,getShortcutMenuItems:()=>tx,getSyncAdapter:()=>Wh,handleAdapterMessage:()=>Xl,importAll:()=>oI,initializeNoyaSingleton:()=>RV,isEmbeddedApp:()=>AS,isEmbeddedToParentMessage:()=>pA,isParentToEmbeddedMessage:()=>lA,jwt:()=>Hd,localStorageSync:()=>XS,parentFrameSync:()=>nx,parseAppDataParameter:()=>ON,populateLocalStorageSync:()=>G6,processLocalStorageMessage:()=>Wl,readDocumentParametersSchema:()=>Zb,registerDocumentAITools:()=>Ml,replaceDeep:()=>rI,requestTranscription:()=>jS,resourceToCreateParameters:()=>RN,resourceToMediaItem:()=>t5,routeEmbeddedMultiplayerMessage:()=>YS,runDocumentScriptParametersSchema:()=>eS,sendLocalInitializationMessages:()=>tm,serializeServerScriptLogValue:()=>Vs,setClientId:()=>KS,setClientImage:()=>zS,setClientName:()=>$S,stubSync:()=>np,toExtendedPatch:()=>Vr,toExtendedPatches:()=>Wa,toExtendedPathKey:()=>Gb,toSimplePatch:()=>RM,toSimplePath:()=>Il,useAIManager:()=>ny,useActivityEvents:()=>i5,useActivityEventsForManager:()=>Gh,useAnyNoyaManager:()=>CV,useAnyNoyaStateContext:()=>xe,useAnySharedConnectionData:()=>JV,useAsset:()=>UV,useAssetManager:()=>NN,useAssets:()=>DV,useBindNoyaManager:()=>Xh,useCallableAITools:()=>a5,useColorScheme:()=>NV,useEnqueueInput:()=>XV,useFileName:()=>DN,useFilePropertyManager:()=>UN,useIOManager:()=>$V,useInputs:()=>BV,useIsInitialized:()=>kN,useIsProcessing:()=>ZV,useManagedHistory:()=>aI,useManagedState:()=>wV,useMultiplayerState:()=>MV,useNoyaActiveUsers:()=>VV,useNoyaAssetTranscription:()=>e5,useNoyaCurrentUser:()=>QV,useNoyaCurrentUserId:()=>YV,useNoyaStateInternal:()=>lI,useNoyaTranscriptionManager:()=>jN,useNoyaUser:()=>qV,useNoyaUserManager:()=>cu,useNoyaUsers:()=>GV,useObservable:()=>q,useOptionalAnyNoyaStateContext:()=>CN,useOutputTransforms:()=>FV,usePipelineManager:()=>zV,usePublish:()=>KV,useRegisterAITool:()=>s5,useResourceManager:()=>_N,useResourceUrl:()=>p5,useResources:()=>n5,useScriptEvaluator:()=>HV,useSecret:()=>LV,useSecretManager:()=>_V,useSecrets:()=>jV,useSetFileNameState:()=>WV,useStateInspector:()=>uI,useViewType:()=>kV,webSocketSync:()=>rx});module.exports=Bk(f5);u();u();u();u();u();u();var Rn={};Ci(Rn,{IsArray:()=>An,IsAsyncIterator:()=>uy,IsBigInt:()=>lu,IsBoolean:()=>go,IsDate:()=>pu,IsFunction:()=>ly,IsIterator:()=>py,IsNull:()=>fy,IsNumber:()=>Fr,IsObject:()=>Ge,IsRegExp:()=>dy,IsString:()=>qe,IsSymbol:()=>my,IsUint8Array:()=>ms,IsUndefined:()=>ot});u();function uy(e){return Ge(e)&&!An(e)&&!ms(e)&&Symbol.asyncIterator in e}function An(e){return Array.isArray(e)}function lu(e){return typeof e=="bigint"}function go(e){return typeof e=="boolean"}function pu(e){return e instanceof globalThis.Date}function ly(e){return typeof e=="function"}function py(e){return Ge(e)&&!An(e)&&!ms(e)&&Symbol.iterator in e}function fy(e){return e===null}function Fr(e){return typeof e=="number"}function Ge(e){return typeof e=="object"&&e!==null}function dy(e){return e instanceof globalThis.RegExp}function qe(e){return typeof e=="string"}function my(e){return typeof e=="symbol"}function ms(e){return e instanceof globalThis.Uint8Array}function ot(e){return e===void 0}function Fk(e){return e.map(t=>gf(t))}function $k(e){return new Date(e.getTime())}function Kk(e){return new Uint8Array(e)}function zk(e){return new RegExp(e.source,e.flags)}function Hk(e){let t={};for(let n of Object.getOwnPropertyNames(e))t[n]=gf(e[n]);for(let n of Object.getOwnPropertySymbols(e))t[n]=gf(e[n]);return t}function gf(e){return An(e)?Fk(e):pu(e)?$k(e):ms(e)?Kk(e):dy(e)?zk(e):Ge(e)?Hk(e):e}function TI(e){return gf(e)}function ct(e){return e.map(t=>B(t))}function B(e,t={}){return{...TI(e),...t}}u();u();var Z=class extends Error{constructor(t){super(t)}};u();u();u();u();var mt=Symbol.for("TypeBox.Transform"),Ni=Symbol.for("TypeBox.Readonly"),Sn=Symbol.for("TypeBox.Optional"),Pn=Symbol.for("TypeBox.Hint"),R=Symbol.for("TypeBox.Kind");function vI(e){return Ge(e)&&e[Ni]==="Readonly"}function ni(e){return Ge(e)&&e[Sn]==="Optional"}function Gk(e){return ye(e,"Any")}function ki(e){return ye(e,"Array")}function fu(e){return ye(e,"AsyncIterator")}function hy(e){return ye(e,"BigInt")}function yy(e){return ye(e,"Boolean")}function du(e){return ye(e,"Constructor")}function qk(e){return ye(e,"Date")}function mu(e){return ye(e,"Function")}function hs(e){return ye(e,"Integer")}function ht(e){return ye(e,"Intersect")}function hu(e){return ye(e,"Iterator")}function ye(e,t){return Ge(e)&&R in e&&e[R]===t}function Di(e){return ye(e,"Literal")}function qn(e){return ye(e,"MappedKey")}function Ze(e){return ye(e,"MappedResult")}function Ea(e){return ye(e,"Never")}function Vk(e){return ye(e,"Not")}function Qk(e){return ye(e,"Null")}function ys(e){return ye(e,"Number")}function Pt(e){return ye(e,"Object")}function gs(e){return ye(e,"Promise")}function gy(e){return ye(e,"Record")}function by(e){return ye(e,"Ref")}function Sy(e){return ye(e,"RegExp")}function yu(e){return ye(e,"String")}function Yk(e){return ye(e,"Symbol")}function Vn(e){return ye(e,"TemplateLiteral")}function Jk(e){return ye(e,"This")}function wa(e){return Ge(e)&&mt in e}function $r(e){return ye(e,"Tuple")}function Xk(e){return ye(e,"Undefined")}function Te(e){return ye(e,"Union")}function Zk(e){return ye(e,"Uint8Array")}function Wk(e){return ye(e,"Unknown")}function eD(e){return ye(e,"Unsafe")}function tD(e){return ye(e,"Void")}function nD(e){return Ge(e)&&R in e&&qe(e[R])}function Qn(e){return Gk(e)||ki(e)||yy(e)||hy(e)||fu(e)||du(e)||qk(e)||mu(e)||hs(e)||ht(e)||hu(e)||Di(e)||qn(e)||Ze(e)||Ea(e)||Vk(e)||Qk(e)||ys(e)||Pt(e)||gs(e)||gy(e)||by(e)||Sy(e)||yu(e)||Yk(e)||Vn(e)||Jk(e)||$r(e)||Xk(e)||Te(e)||Zk(e)||Wk(e)||eD(e)||tD(e)||nD(e)}var w={};Ci(w,{IsAny:()=>MI,IsArray:()=>OI,IsAsyncIterator:()=>AI,IsBigInt:()=>RI,IsBoolean:()=>PI,IsConstructor:()=>CI,IsDate:()=>NI,IsFunction:()=>kI,IsInteger:()=>DI,IsIntersect:()=>UI,IsIterator:()=>_I,IsKind:()=>a0,IsKindOf:()=>he,IsLiteral:()=>bu,IsLiteralBoolean:()=>uD,IsLiteralNumber:()=>LI,IsLiteralString:()=>jI,IsLiteralValue:()=>BI,IsMappedKey:()=>FI,IsMappedResult:()=>$I,IsNever:()=>KI,IsNot:()=>zI,IsNull:()=>HI,IsNumber:()=>GI,IsObject:()=>qI,IsOptional:()=>cD,IsPromise:()=>VI,IsProperties:()=>Iy,IsReadonly:()=>aD,IsRecord:()=>QI,IsRecursive:()=>lD,IsRef:()=>YI,IsRegExp:()=>JI,IsSchema:()=>fe,IsString:()=>XI,IsSymbol:()=>ZI,IsTemplateLiteral:()=>WI,IsThis:()=>e0,IsTransform:()=>Ve,IsTuple:()=>t0,IsUint8Array:()=>r0,IsUndefined:()=>n0,IsUnion:()=>Ey,IsUnionLiteral:()=>pD,IsUnknown:()=>i0,IsUnsafe:()=>o0,IsVoid:()=>s0,TypeGuardUnknownTypeError:()=>xy});u();var xy=class extends Z{},iD=["Any","Array","AsyncIterator","BigInt","Boolean","Constructor","Date","Enum","Function","Integer","Intersect","Iterator","Literal","MappedKey","MappedResult","Not","Null","Number","Object","Promise","Record","Ref","RegExp","String","Symbol","TemplateLiteral","This","Tuple","Undefined","Union","Uint8Array","Unknown","Void"];function II(e){try{return new RegExp(e),!0}catch{return!1}}function Ty(e){if(!qe(e))return!1;for(let t=0;t<e.length;t++){let n=e.charCodeAt(t);if(n>=7&&n<=13||n===27||n===127)return!1}return!0}function EI(e){return vy(e)||fe(e)}function gu(e){return ot(e)||lu(e)}function $e(e){return ot(e)||Fr(e)}function vy(e){return ot(e)||go(e)}function Ce(e){return ot(e)||qe(e)}function oD(e){return ot(e)||qe(e)&&Ty(e)&&II(e)}function sD(e){return ot(e)||qe(e)&&Ty(e)}function wI(e){return ot(e)||fe(e)}function aD(e){return Ge(e)&&e[Ni]==="Readonly"}function cD(e){return Ge(e)&&e[Sn]==="Optional"}function MI(e){return he(e,"Any")&&Ce(e.$id)}function OI(e){return he(e,"Array")&&e.type==="array"&&Ce(e.$id)&&fe(e.items)&&$e(e.minItems)&&$e(e.maxItems)&&vy(e.uniqueItems)&&wI(e.contains)&&$e(e.minContains)&&$e(e.maxContains)}function AI(e){return he(e,"AsyncIterator")&&e.type==="AsyncIterator"&&Ce(e.$id)&&fe(e.items)}function RI(e){return he(e,"BigInt")&&e.type==="bigint"&&Ce(e.$id)&&gu(e.exclusiveMaximum)&&gu(e.exclusiveMinimum)&&gu(e.maximum)&&gu(e.minimum)&&gu(e.multipleOf)}function PI(e){return he(e,"Boolean")&&e.type==="boolean"&&Ce(e.$id)}function CI(e){return he(e,"Constructor")&&e.type==="Constructor"&&Ce(e.$id)&&An(e.parameters)&&e.parameters.every(t=>fe(t))&&fe(e.returns)}function NI(e){return he(e,"Date")&&e.type==="Date"&&Ce(e.$id)&&$e(e.exclusiveMaximumTimestamp)&&$e(e.exclusiveMinimumTimestamp)&&$e(e.maximumTimestamp)&&$e(e.minimumTimestamp)&&$e(e.multipleOfTimestamp)}function kI(e){return he(e,"Function")&&e.type==="Function"&&Ce(e.$id)&&An(e.parameters)&&e.parameters.every(t=>fe(t))&&fe(e.returns)}function DI(e){return he(e,"Integer")&&e.type==="integer"&&Ce(e.$id)&&$e(e.exclusiveMaximum)&&$e(e.exclusiveMinimum)&&$e(e.maximum)&&$e(e.minimum)&&$e(e.multipleOf)}function Iy(e){return Ge(e)&&Object.entries(e).every(([t,n])=>Ty(t)&&fe(n))}function UI(e){return he(e,"Intersect")&&!(qe(e.type)&&e.type!=="object")&&An(e.allOf)&&e.allOf.every(t=>fe(t)&&!Ve(t))&&Ce(e.type)&&(vy(e.unevaluatedProperties)||wI(e.unevaluatedProperties))&&Ce(e.$id)}function _I(e){return he(e,"Iterator")&&e.type==="Iterator"&&Ce(e.$id)&&fe(e.items)}function he(e,t){return Ge(e)&&R in e&&e[R]===t}function jI(e){return bu(e)&&qe(e.const)}function LI(e){return bu(e)&&Fr(e.const)}function uD(e){return bu(e)&&go(e.const)}function bu(e){return he(e,"Literal")&&Ce(e.$id)&&BI(e.const)}function BI(e){return go(e)||Fr(e)||qe(e)}function FI(e){return he(e,"MappedKey")&&An(e.keys)&&e.keys.every(t=>Fr(t)||qe(t))}function $I(e){return he(e,"MappedResult")&&Iy(e.properties)}function KI(e){return he(e,"Never")&&Ge(e.not)&&Object.getOwnPropertyNames(e.not).length===0}function zI(e){return he(e,"Not")&&fe(e.not)}function HI(e){return he(e,"Null")&&e.type==="null"&&Ce(e.$id)}function GI(e){return he(e,"Number")&&e.type==="number"&&Ce(e.$id)&&$e(e.exclusiveMaximum)&&$e(e.exclusiveMinimum)&&$e(e.maximum)&&$e(e.minimum)&&$e(e.multipleOf)}function qI(e){return he(e,"Object")&&e.type==="object"&&Ce(e.$id)&&Iy(e.properties)&&EI(e.additionalProperties)&&$e(e.minProperties)&&$e(e.maxProperties)}function VI(e){return he(e,"Promise")&&e.type==="Promise"&&Ce(e.$id)&&fe(e.item)}function QI(e){return he(e,"Record")&&e.type==="object"&&Ce(e.$id)&&EI(e.additionalProperties)&&Ge(e.patternProperties)&&(t=>{let n=Object.getOwnPropertyNames(t.patternProperties);return n.length===1&&II(n[0])&&Ge(t.patternProperties)&&fe(t.patternProperties[n[0]])})(e)}function lD(e){return Ge(e)&&Pn in e&&e[Pn]==="Recursive"}function YI(e){return he(e,"Ref")&&Ce(e.$id)&&qe(e.$ref)}function JI(e){return he(e,"RegExp")&&Ce(e.$id)&&qe(e.source)&&qe(e.flags)&&$e(e.maxLength)&&$e(e.minLength)}function XI(e){return he(e,"String")&&e.type==="string"&&Ce(e.$id)&&$e(e.minLength)&&$e(e.maxLength)&&oD(e.pattern)&&sD(e.format)}function ZI(e){return he(e,"Symbol")&&e.type==="symbol"&&Ce(e.$id)}function WI(e){return he(e,"TemplateLiteral")&&e.type==="string"&&qe(e.pattern)&&e.pattern[0]==="^"&&e.pattern[e.pattern.length-1]==="$"}function e0(e){return he(e,"This")&&Ce(e.$id)&&qe(e.$ref)}function Ve(e){return Ge(e)&&mt in e}function t0(e){return he(e,"Tuple")&&e.type==="array"&&Ce(e.$id)&&Fr(e.minItems)&&Fr(e.maxItems)&&e.minItems===e.maxItems&&(ot(e.items)&&ot(e.additionalItems)&&e.minItems===0||An(e.items)&&e.items.every(t=>fe(t)))}function n0(e){return he(e,"Undefined")&&e.type==="undefined"&&Ce(e.$id)}function pD(e){return Ey(e)&&e.anyOf.every(t=>jI(t)||LI(t))}function Ey(e){return he(e,"Union")&&Ce(e.$id)&&Ge(e)&&An(e.anyOf)&&e.anyOf.every(t=>fe(t))}function r0(e){return he(e,"Uint8Array")&&e.type==="Uint8Array"&&Ce(e.$id)&&$e(e.minByteLength)&&$e(e.maxByteLength)}function i0(e){return he(e,"Unknown")&&Ce(e.$id)}function o0(e){return he(e,"Unsafe")}function s0(e){return he(e,"Void")&&e.type==="void"&&Ce(e.$id)}function a0(e){return Ge(e)&&R in e&&qe(e[R])&&!iD.includes(e[R])}function fe(e){return Ge(e)&&(MI(e)||OI(e)||PI(e)||RI(e)||AI(e)||CI(e)||NI(e)||kI(e)||DI(e)||UI(e)||_I(e)||bu(e)||FI(e)||$I(e)||KI(e)||zI(e)||HI(e)||GI(e)||qI(e)||VI(e)||QI(e)||YI(e)||JI(e)||XI(e)||ZI(e)||WI(e)||e0(e)||t0(e)||n0(e)||Ey(e)||r0(e)||i0(e)||o0(e)||s0(e)||a0(e))}u();u();u();u();var wy="(true|false)",Su="(0|[1-9][0-9]*)",My="(.*)",V5=`^${wy}$`,Ui=`^${Su}$`,bo=`^${My}$`;u();var Cn={};Ci(Cn,{Clear:()=>dD,Delete:()=>mD,Entries:()=>fD,Get:()=>gD,Has:()=>hD,Set:()=>yD});u();var Ma=new Map;function fD(){return new Map(Ma)}function dD(){return Ma.clear()}function mD(e){return Ma.delete(e)}function hD(e){return Ma.has(e)}function yD(e,t){Ma.set(e,t)}function gD(e){return Ma.get(e)}var Nn={};Ci(Nn,{Clear:()=>SD,Delete:()=>xD,Entries:()=>bD,Get:()=>ID,Has:()=>TD,Set:()=>vD});u();var Oa=new Map;function bD(){return new Map(Oa)}function SD(){return Oa.clear()}function xD(e){return Oa.delete(e)}function TD(e){return Oa.has(e)}function vD(e,t){Oa.set(e,t)}function ID(e){return Oa.get(e)}u();u();function c0(e,t){return e.includes(t)}function u0(e){return[...new Set(e)]}function ED(e,t){return e.filter(n=>t.includes(n))}function wD(e,t){return e.reduce((n,r)=>ED(n,r),t)}function l0(e){return e.length===1?e[0]:e.length>1?wD(e.slice(1),e[0]):[]}function p0(e){let t=[];for(let n of e)t.push(...n);return t}u();u();function _i(e={}){return{...e,[R]:"Any"}}u();u();function bs(e,t={}){return{...t,[R]:"Array",type:"array",items:B(e)}}u();u();function xu(e,t={}){return{...t,[R]:"AsyncIterator",type:"AsyncIterator",items:B(e)}}u();u();u();u();u();u();function MD(e,t){let{[t]:n,...r}=e;return r}function ut(e,t){return t.reduce((n,r)=>MD(n,r),e)}u();u();function je(e={}){return{...e,[R]:"Never",not:{}}}u();u();u();u();u();function ge(e){return{[R]:"MappedResult",properties:e}}u();u();u();function Tu(e,t,n){return{...n,[R]:"Constructor",type:"Constructor",parameters:ct(e),returns:B(t)}}u();u();function ji(e,t,n){return{...n,[R]:"Function",type:"Function",parameters:ct(e),returns:B(t)}}u();u();u();u();u();u();function vu(e,t){return{...t,[R]:"Union",anyOf:ct(e)}}function OD(e){return e.some(t=>ni(t))}function f0(e){return e.map(t=>ni(t)?AD(t):t)}function AD(e){return ut(e,[Sn])}function RD(e,t){return OD(e)?xn(vu(f0(e),t)):vu(f0(e),t)}function ri(e,t={}){return e.length===0?je(t):e.length===1?B(e[0],t):RD(e,t)}u();u();function ve(e,t={}){return e.length===0?je(t):e.length===1?B(e[0],t):vu(e,t)}u();u();u();u();var bf=class extends Z{};function PD(e){return e.replace(/\\\$/g,"$").replace(/\\\*/g,"*").replace(/\\\^/g,"^").replace(/\\\|/g,"|").replace(/\\\(/g,"(").replace(/\\\)/g,")")}function Oy(e,t,n){return e[t]===n&&e.charCodeAt(t-1)!==92}function Li(e,t){return Oy(e,t,"(")}function Iu(e,t){return Oy(e,t,")")}function d0(e,t){return Oy(e,t,"|")}function CD(e){if(!(Li(e,0)&&Iu(e,e.length-1)))return!1;let t=0;for(let n=0;n<e.length;n++)if(Li(e,n)&&(t+=1),Iu(e,n)&&(t-=1),t===0&&n!==e.length-1)return!1;return!0}function ND(e){return e.slice(1,e.length-1)}function kD(e){let t=0;for(let n=0;n<e.length;n++)if(Li(e,n)&&(t+=1),Iu(e,n)&&(t-=1),d0(e,n)&&t===0)return!0;return!1}function DD(e){for(let t=0;t<e.length;t++)if(Li(e,t))return!0;return!1}function UD(e){let[t,n]=[0,0],r=[];for(let o=0;o<e.length;o++)if(Li(e,o)&&(t+=1),Iu(e,o)&&(t-=1),d0(e,o)&&t===0){let s=e.slice(n,o);s.length>0&&r.push(Aa(s)),n=o+1}let i=e.slice(n);return i.length>0&&r.push(Aa(i)),r.length===0?{type:"const",const:""}:r.length===1?r[0]:{type:"or",expr:r}}function _D(e){function t(i,o){if(!Li(i,o))throw new bf("TemplateLiteralParser: Index must point to open parens");let s=0;for(let a=o;a<i.length;a++)if(Li(i,a)&&(s+=1),Iu(i,a)&&(s-=1),s===0)return[o,a];throw new bf("TemplateLiteralParser: Unclosed group parens in expression")}function n(i,o){for(let s=o;s<i.length;s++)if(Li(i,s))return[o,s];return[o,i.length]}let r=[];for(let i=0;i<e.length;i++)if(Li(e,i)){let[o,s]=t(e,i),a=e.slice(o,s+1);r.push(Aa(a)),i=s}else{let[o,s]=n(e,i),a=e.slice(o,s);a.length>0&&r.push(Aa(a)),i=s-1}return r.length===0?{type:"const",const:""}:r.length===1?r[0]:{type:"and",expr:r}}function Aa(e){return CD(e)?Aa(ND(e)):kD(e)?UD(e):DD(e)?_D(e):{type:"const",const:PD(e)}}function Ra(e){return Aa(e.slice(1,e.length-1))}var Ay=class extends Z{};function jD(e){return e.type==="or"&&e.expr.length===2&&e.expr[0].type==="const"&&e.expr[0].const==="0"&&e.expr[1].type==="const"&&e.expr[1].const==="[1-9][0-9]*"}function LD(e){return e.type==="or"&&e.expr.length===2&&e.expr[0].type==="const"&&e.expr[0].const==="true"&&e.expr[1].type==="const"&&e.expr[1].const==="false"}function BD(e){return e.type==="const"&&e.const===".*"}function Ss(e){return jD(e)||BD(e)?!1:LD(e)?!0:e.type==="and"?e.expr.every(t=>Ss(t)):e.type==="or"?e.expr.every(t=>Ss(t)):e.type==="const"?!0:(()=>{throw new Ay("Unknown expression type")})()}function Sf(e){let t=Ra(e.pattern);return Ss(t)}u();var Ry=class extends Z{};function*m0(e){if(e.length===1)return yield*e[0];for(let t of e[0])for(let n of m0(e.slice(1)))yield`${t}${n}`}function*FD(e){return yield*m0(e.expr.map(t=>[...Eu(t)]))}function*$D(e){for(let t of e.expr)yield*Eu(t)}function*KD(e){return yield e.const}function*Eu(e){return e.type==="and"?yield*FD(e):e.type==="or"?yield*$D(e):e.type==="const"?yield*KD(e):(()=>{throw new Ry("Unknown expression")})()}function Pa(e){let t=Ra(e.pattern);return Ss(t)?[...Eu(t)]:[]}u();u();u();function oe(e,t={}){return{...t,[R]:"Literal",const:e,type:typeof e}}u();u();function wu(e={}){return{...e,[R]:"Boolean",type:"boolean"}}u();u();function xs(e={}){return{...e,[R]:"BigInt",type:"bigint"}}u();u();function Yn(e={}){return{...e,[R]:"Number",type:"number"}}u();u();function Tn(e={}){return{...e,[R]:"String",type:"string"}}function*zD(e){let t=e.trim().replace(/"|'/g,"");return t==="boolean"?yield wu():t==="number"?yield Yn():t==="bigint"?yield xs():t==="string"?yield Tn():yield(()=>{let n=t.split("|").map(r=>oe(r.trim()));return n.length===0?je():n.length===1?n[0]:ri(n)})()}function*HD(e){if(e[1]!=="{"){let t=oe("$"),n=Py(e.slice(1));return yield*[t,...n]}for(let t=2;t<e.length;t++)if(e[t]==="}"){let n=zD(e.slice(2,t)),r=Py(e.slice(t+1));return yield*[...n,...r]}yield oe(e)}function*Py(e){for(let t=0;t<e.length;t++)if(e[t]==="$"){let n=oe(e.slice(0,t)),r=HD(e.slice(t));return yield*[n,...r]}yield oe(e)}function h0(e){return[...Py(e)]}u();var Cy=class extends Z{};function GD(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function y0(e,t){return Vn(e)?e.pattern.slice(1,e.pattern.length-1):Te(e)?`(${e.anyOf.map(n=>y0(n,t)).join("|")})`:ys(e)?`${t}${Su}`:hs(e)?`${t}${Su}`:hy(e)?`${t}${Su}`:yu(e)?`${t}${My}`:Di(e)?`${t}${GD(e.const.toString())}`:yy(e)?`${t}${wy}`:(()=>{throw new Cy(`Unexpected Kind '${e[R]}'`)})()}function Ny(e){return`^${e.map(t=>y0(t,"")).join("")}$`}u();function Ts(e){let n=Pa(e).map(r=>oe(r));return ri(n)}u();function Mu(e,t={}){let n=qe(e)?Ny(h0(e)):Ny(e);return{...t,[R]:"TemplateLiteral",type:"string",pattern:n}}function qD(e){return Pa(e).map(n=>n.toString())}function VD(e){let t=[];for(let n of e)t.push(...kn(n));return t}function QD(e){return[e.toString()]}function kn(e){return[...new Set(Vn(e)?qD(e):Te(e)?VD(e.anyOf):Di(e)?QD(e.const):ys(e)?["[number]"]:hs(e)?["[number]"]:[])]}u();function YD(e,t,n){let r={};for(let i of Object.getOwnPropertyNames(t))r[i]=vs(e,kn(t[i]),n);return r}function JD(e,t,n){return YD(e,t.properties,n)}function g0(e,t,n){let r=JD(e,t,n);return ge(r)}function S0(e,t){return e.map(n=>x0(n,t))}function XD(e){return e.filter(t=>!Ea(t))}function ZD(e,t){return xf(XD(S0(e,t)))}function WD(e){return e.some(t=>Ea(t))?[]:e}function eU(e,t){return ri(WD(S0(e,t)))}function tU(e,t){return t in e?e[t]:t==="[number]"?ri(e):je()}function nU(e,t){return t==="[number]"?e:je()}function rU(e,t){return t in e?e[t]:je()}function x0(e,t){return ht(e)?ZD(e.allOf,t):Te(e)?eU(e.anyOf,t):$r(e)?tU(e.items??[],t):ki(e)?nU(e.items,t):Pt(e)?rU(e.properties,t):je()}function Ou(e,t){return t.map(n=>x0(e,n))}function b0(e,t){return ri(Ou(e,t))}function vs(e,t,n={}){return Ze(t)?B(g0(e,t,n)):qn(t)?B(T0(e,t,n)):Qn(t)?B(b0(e,kn(t)),n):B(b0(e,t),n)}function iU(e,t,n){return{[t]:vs(e,[t],n)}}function oU(e,t,n){return t.reduce((r,i)=>({...r,...iU(e,i,n)}),{})}function sU(e,t,n){return oU(e,t.keys,n)}function T0(e,t,n){let r=sU(e,t,n);return ge(r)}u();u();function Au(e,t={}){return{...t,[R]:"Iterator",type:"Iterator",items:B(e)}}u();u();function aU(e,t={}){let n=globalThis.Object.getOwnPropertyNames(e),r=n.filter(a=>ni(e[a])),i=n.filter(a=>!r.includes(a)),o=Qn(t.additionalProperties)?{additionalProperties:B(t.additionalProperties)}:{},s={};for(let a of n)s[a]=B(e[a]);return i.length>0?{...t,...o,[R]:"Object",type:"object",properties:s,required:i}:{...t,...o,[R]:"Object",type:"object",properties:s}}var Ne=aU;u();u();function Ru(e,t={}){return{...t,[R]:"Promise",type:"Promise",item:B(e)}}u();u();u();function cU(e){return ut(B(e),[Ni])}function uU(e){return{...B(e),[Ni]:"Readonly"}}function lU(e,t){return t===!1?cU(e):uU(e)}function Jn(e,t){let n=t??!0;return Ze(e)?v0(e,n):lU(e,n)}function pU(e,t){let n={};for(let r of globalThis.Object.getOwnPropertyNames(e))n[r]=Jn(e[r],t);return n}function fU(e,t){return pU(e.properties,t)}function v0(e,t){let n=fU(e,t);return ge(n)}u();u();function Kr(e,t={}){let[n,r,i]=[!1,e.length,e.length];return e.length>0?{...t,[R]:"Tuple",type:"array",items:ct(e),additionalItems:n,minItems:r,maxItems:i}:{...t,[R]:"Tuple",type:"array",minItems:r,maxItems:i}}function I0(e,t){return e in t?gr(e,t[e]):ge(t)}function dU(e){return{[e]:oe(e)}}function mU(e){let t={};for(let n of e)t[n]=oe(n);return t}function hU(e,t){return c0(t,e)?dU(e):mU(t)}function yU(e,t){let n=hU(e,t);return I0(e,n)}function Pu(e,t){return t.map(n=>gr(e,n))}function gU(e,t){let n={};for(let r of globalThis.Object.getOwnPropertyNames(t))n[r]=gr(e,t[r]);return n}function gr(e,t){return ni(t)?xn(gr(e,ut(t,[Sn]))):vI(t)?Jn(gr(e,ut(t,[Ni]))):Ze(t)?I0(e,t.properties):qn(t)?yU(e,t.keys):du(t)?Tu(Pu(e,t.parameters),gr(e,t.returns)):mu(t)?ji(Pu(e,t.parameters),gr(e,t.returns)):fu(t)?xu(gr(e,t.items)):hu(t)?Au(gr(e,t.items)):ht(t)?vn(Pu(e,t.allOf)):Te(t)?ve(Pu(e,t.anyOf)):$r(t)?Kr(Pu(e,t.items??[])):Pt(t)?Ne(gU(e,t.properties)):ki(t)?bs(gr(e,t.items)):gs(t)?Ru(gr(e,t.item)):t}function bU(e,t){let n={};for(let r of e)n[r]=gr(r,t);return n}function ky(e,t,n={}){let r=Qn(e)?kn(e):e,i=t({[R]:"MappedKey",keys:r}),o=bU(r,i);return B(Ne(o),n)}u();function SU(e){return ut(B(e),[Sn])}function xU(e){return{...B(e),[Sn]:"Optional"}}function TU(e,t){return t===!1?SU(e):xU(e)}function xn(e,t){let n=t??!0;return Ze(e)?E0(e,n):TU(e,n)}function vU(e,t){let n={};for(let r of globalThis.Object.getOwnPropertyNames(e))n[r]=xn(e[r],t);return n}function IU(e,t){return vU(e.properties,t)}function E0(e,t){let n=IU(e,t);return ge(n)}u();function Cu(e,t){let n=e.every(i=>Pt(i)),r=Qn(t.unevaluatedProperties)?{unevaluatedProperties:B(t.unevaluatedProperties)}:{};return t.unevaluatedProperties===!1||Qn(t.unevaluatedProperties)||n?{...t,...r,[R]:"Intersect",type:"object",allOf:ct(e)}:{...t,...r,[R]:"Intersect",allOf:ct(e)}}function EU(e){return e.every(t=>ni(t))}function wU(e){return ut(e,[Sn])}function w0(e){return e.map(t=>ni(t)?wU(t):t)}function MU(e,t){return EU(e)?xn(Cu(w0(e),t)):Cu(w0(e),t)}function xf(e,t={}){if(e.length===0)return je(t);if(e.length===1)return B(e[0],t);if(e.some(n=>wa(n)))throw new Error("Cannot intersect transform types");return MU(e,t)}u();u();function vn(e,t={}){if(e.length===0)return je(t);if(e.length===1)return B(e[0],t);if(e.some(n=>wa(n)))throw new Error("Cannot intersect transform types");return Cu(e,t)}function M0(e){return e.map(t=>Dy(t))}function OU(e){return vn(M0(e))}function AU(e){return ve(M0(e))}function RU(e){return Dy(e)}function Dy(e){return ht(e)?OU(e.allOf):Te(e)?AU(e.anyOf):gs(e)?RU(e.item):e}function Uy(e,t={}){return B(Dy(e),t)}u();u();u();u();u();u();function O0(e){let t=[];for(let n of e)t.push(Dn(n));return t}function PU(e){let t=O0(e);return p0(t)}function CU(e){let t=O0(e);return l0(t)}function NU(e){return e.map((t,n)=>n.toString())}function kU(e){return["[number]"]}function DU(e){return globalThis.Object.getOwnPropertyNames(e)}function UU(e){return _y?globalThis.Object.getOwnPropertyNames(e).map(n=>n[0]==="^"&&n[n.length-1]==="$"?n.slice(1,n.length-1):n):[]}function Dn(e){return ht(e)?PU(e.allOf):Te(e)?CU(e.anyOf):$r(e)?NU(e.items??[]):ki(e)?kU(e.items):Pt(e)?DU(e.properties):gy(e)?UU(e.patternProperties):[]}var _y=!1;function Ca(e){_y=!0;let t=Dn(e);return _y=!1,`^(${t.map(r=>`(${r})`).join("|")})$`}function _U(e){return e.map(t=>t==="[number]"?Yn():oe(t))}function Nu(e,t={}){if(Ze(e))return A0(e,t);{let n=Dn(e),r=_U(n),i=ri(r);return B(i,t)}}function jU(e,t){let n={};for(let r of globalThis.Object.getOwnPropertyNames(e))n[r]=Nu(e[r],t);return n}function LU(e,t){return jU(e.properties,t)}function A0(e,t){let n=LU(e,t);return ge(n)}u();function Tf(e){let t=Dn(e),n=Ou(e,t);return t.map((r,i)=>[t[i],n[i]])}function BU(e){let t=[];for(let n of e)t.push(...Dn(n));return u0(t)}function FU(e){return e.filter(t=>!Ea(t))}function $U(e,t){let n=[];for(let r of e)n.push(...Ou(r,[t]));return FU(n)}function KU(e,t){let n={};for(let r of t)n[r]=xf($U(e,r));return n}function jy(e,t={}){let n=BU(e),r=KU(e,n);return Ne(r,t)}u();u();u();u();function ku(e={}){return{...e,[R]:"Date",type:"Date"}}u();u();function Du(e={}){return{...e,[R]:"Null",type:"null"}}u();u();function Uu(e){return{...e,[R]:"Symbol",type:"symbol"}}u();u();function _u(e={}){return{...e,[R]:"Undefined",type:"undefined"}}u();u();function ju(e={}){return{...e,[R]:"Uint8Array",type:"Uint8Array"}}u();u();function Xn(e={}){return{...e,[R]:"Unknown"}}function zU(e){return e.map(t=>Ly(t,!1))}function HU(e){let t={};for(let n of globalThis.Object.getOwnPropertyNames(e))t[n]=Jn(Ly(e[n],!1));return t}function vf(e,t){return t===!0?e:Jn(e)}function Ly(e,t){return uy(e)?vf(_i(),t):py(e)?vf(_i(),t):An(e)?Jn(Kr(zU(e))):ms(e)?ju():pu(e)?ku():Ge(e)?vf(Ne(HU(e)),t):ly(e)?vf(ji([],Xn()),t):ot(e)?_u():fy(e)?Du():my(e)?Uu():lu(e)?xs():Fr(e)?oe(e):go(e)?oe(e):qe(e)?oe(e):Ne({})}function By(e,t={}){return B(Ly(e,!0),t)}u();u();function Fy(e,t={}){return Kr(ct(e.parameters),{...t})}u();u();function Lu(e,t){return e.map(n=>br(n,t))}function GU(e,t){let n={};for(let r of globalThis.Object.getOwnPropertyNames(e))n[r]=br(e[r],t);return n}function qU(e,t){return e.parameters=Lu(e.parameters,t),e.returns=br(e.returns,t),e}function VU(e,t){return e.parameters=Lu(e.parameters,t),e.returns=br(e.returns,t),e}function QU(e,t){return e.allOf=Lu(e.allOf,t),e}function YU(e,t){return e.anyOf=Lu(e.anyOf,t),e}function JU(e,t){return ot(e.items)||(e.items=Lu(e.items,t)),e}function XU(e,t){return e.items=br(e.items,t),e}function ZU(e,t){return e.properties=GU(e.properties,t),e}function WU(e,t){return e.item=br(e.item,t),e}function e_(e,t){return e.items=br(e.items,t),e}function t_(e,t){return e.items=br(e.items,t),e}function n_(e,t){let n=t.find(i=>i.$id===e.$ref);if(n===void 0)throw Error(`Unable to dereference schema with $id ${e.$ref}`);let r=ut(n,["$id"]);return br(r,t)}function r_(e,t){return du(e)?qU(e,t):mu(e)?VU(e,t):ht(e)?QU(e,t):Te(e)?YU(e,t):$r(e)?JU(e,t):ki(e)?XU(e,t):Pt(e)?ZU(e,t):gs(e)?WU(e,t):fu(e)?e_(e,t):hu(e)?t_(e,t):by(e)?n_(e,t):e}function br(e,t){return r_(B(e),ct(t))}u();u();function $y(e,t={}){if(ot(e))throw new Error("Enum undefined or empty");let n=globalThis.Object.getOwnPropertyNames(e).filter(o=>isNaN(o)).map(o=>e[o]),i=[...new Set(n)].map(o=>oe(o));return ve(i,{...t,[Pn]:"Enum"})}u();u();u();u();u();var zy=class extends Z{},P;(function(e){e[e.Union=0]="Union",e[e.True=1]="True",e[e.False=2]="False"})(P||(P={}));function Sr(e){return e===P.False?e:P.True}function Na(e){throw new zy(e)}function Tt(e){return w.IsNever(e)||w.IsIntersect(e)||w.IsUnion(e)||w.IsUnknown(e)||w.IsAny(e)}function vt(e,t){return w.IsNever(t)?U0(e,t):w.IsIntersect(t)?If(e,t):w.IsUnion(t)?Vy(e,t):w.IsUnknown(t)?B0(e,t):w.IsAny(t)?qy(e,t):Na("StructuralRight")}function qy(e,t){return P.True}function i_(e,t){return w.IsIntersect(t)?If(e,t):w.IsUnion(t)&&t.anyOf.some(n=>w.IsAny(n)||w.IsUnknown(n))?P.True:w.IsUnion(t)?P.Union:w.IsUnknown(t)||w.IsAny(t)?P.True:P.Union}function o_(e,t){return w.IsUnknown(e)?P.False:w.IsAny(e)?P.Union:w.IsNever(e)?P.True:P.False}function s_(e,t){return w.IsObject(t)&&Ef(t)?P.True:Tt(t)?vt(e,t):w.IsArray(t)?Sr(ke(e.items,t.items)):P.False}function a_(e,t){return Tt(t)?vt(e,t):w.IsAsyncIterator(t)?Sr(ke(e.items,t.items)):P.False}function c_(e,t){return Tt(t)?vt(e,t):w.IsObject(t)?an(e,t):w.IsRecord(t)?xr(e,t):w.IsBigInt(t)?P.True:P.False}function k0(e,t){return w.IsLiteralBoolean(e)||w.IsBoolean(e)?P.True:P.False}function u_(e,t){return Tt(t)?vt(e,t):w.IsObject(t)?an(e,t):w.IsRecord(t)?xr(e,t):w.IsBoolean(t)?P.True:P.False}function l_(e,t){return Tt(t)?vt(e,t):w.IsObject(t)?an(e,t):w.IsConstructor(t)?e.parameters.length>t.parameters.length?P.False:e.parameters.every((n,r)=>Sr(ke(t.parameters[r],n))===P.True)?Sr(ke(e.returns,t.returns)):P.False:P.False}function p_(e,t){return Tt(t)?vt(e,t):w.IsObject(t)?an(e,t):w.IsRecord(t)?xr(e,t):w.IsDate(t)?P.True:P.False}function f_(e,t){return Tt(t)?vt(e,t):w.IsObject(t)?an(e,t):w.IsFunction(t)?e.parameters.length>t.parameters.length?P.False:e.parameters.every((n,r)=>Sr(ke(t.parameters[r],n))===P.True)?Sr(ke(e.returns,t.returns)):P.False:P.False}function D0(e,t){return w.IsLiteral(e)&&Rn.IsNumber(e.const)||w.IsNumber(e)||w.IsInteger(e)?P.True:P.False}function d_(e,t){return w.IsInteger(t)||w.IsNumber(t)?P.True:Tt(t)?vt(e,t):w.IsObject(t)?an(e,t):w.IsRecord(t)?xr(e,t):P.False}function If(e,t){return t.allOf.every(n=>ke(e,n)===P.True)?P.True:P.False}function m_(e,t){return e.allOf.some(n=>ke(n,t)===P.True)?P.True:P.False}function h_(e,t){return Tt(t)?vt(e,t):w.IsIterator(t)?Sr(ke(e.items,t.items)):P.False}function y_(e,t){return w.IsLiteral(t)&&t.const===e.const?P.True:Tt(t)?vt(e,t):w.IsObject(t)?an(e,t):w.IsRecord(t)?xr(e,t):w.IsString(t)?L0(e,t):w.IsNumber(t)?_0(e,t):w.IsInteger(t)?D0(e,t):w.IsBoolean(t)?k0(e,t):P.False}function U0(e,t){return P.False}function g_(e,t){return P.True}function R0(e){let[t,n]=[e,0];for(;w.IsNot(t);)t=t.not,n+=1;return n%2===0?t:Xn()}function b_(e,t){return w.IsNot(e)?ke(R0(e),t):w.IsNot(t)?ke(e,R0(t)):Na("Invalid fallthrough for Not")}function S_(e,t){return Tt(t)?vt(e,t):w.IsObject(t)?an(e,t):w.IsRecord(t)?xr(e,t):w.IsNull(t)?P.True:P.False}function _0(e,t){return w.IsLiteralNumber(e)||w.IsNumber(e)||w.IsInteger(e)?P.True:P.False}function x_(e,t){return Tt(t)?vt(e,t):w.IsObject(t)?an(e,t):w.IsRecord(t)?xr(e,t):w.IsInteger(t)||w.IsNumber(t)?P.True:P.False}function Un(e,t){return Object.getOwnPropertyNames(e.properties).length===t}function P0(e){return Ef(e)}function C0(e){return Un(e,0)||Un(e,1)&&"description"in e.properties&&w.IsUnion(e.properties.description)&&e.properties.description.anyOf.length===2&&(w.IsString(e.properties.description.anyOf[0])&&w.IsUndefined(e.properties.description.anyOf[1])||w.IsString(e.properties.description.anyOf[1])&&w.IsUndefined(e.properties.description.anyOf[0]))}function Ky(e){return Un(e,0)}function N0(e){return Un(e,0)}function T_(e){return Un(e,0)}function v_(e){return Un(e,0)}function I_(e){return Ef(e)}function E_(e){let t=Yn();return Un(e,0)||Un(e,1)&&"length"in e.properties&&Sr(ke(e.properties.length,t))===P.True}function w_(e){return Un(e,0)}function Ef(e){let t=Yn();return Un(e,0)||Un(e,1)&&"length"in e.properties&&Sr(ke(e.properties.length,t))===P.True}function M_(e){let t=ji([_i()],_i());return Un(e,0)||Un(e,1)&&"then"in e.properties&&Sr(ke(e.properties.then,t))===P.True}function j0(e,t){return ke(e,t)===P.False||w.IsOptional(e)&&!w.IsOptional(t)?P.False:P.True}function an(e,t){return w.IsUnknown(e)?P.False:w.IsAny(e)?P.Union:w.IsNever(e)||w.IsLiteralString(e)&&P0(t)||w.IsLiteralNumber(e)&&Ky(t)||w.IsLiteralBoolean(e)&&N0(t)||w.IsSymbol(e)&&C0(t)||w.IsBigInt(e)&&T_(t)||w.IsString(e)&&P0(t)||w.IsSymbol(e)&&C0(t)||w.IsNumber(e)&&Ky(t)||w.IsInteger(e)&&Ky(t)||w.IsBoolean(e)&&N0(t)||w.IsUint8Array(e)&&I_(t)||w.IsDate(e)&&v_(t)||w.IsConstructor(e)&&w_(t)||w.IsFunction(e)&&E_(t)?P.True:w.IsRecord(e)&&w.IsString(Hy(e))?t[Pn]==="Record"?P.True:P.False:w.IsRecord(e)&&w.IsNumber(Hy(e))?Un(t,0)?P.True:P.False:P.False}function O_(e,t){return Tt(t)?vt(e,t):w.IsRecord(t)?xr(e,t):w.IsObject(t)?(()=>{for(let n of Object.getOwnPropertyNames(t.properties)){if(!(n in e.properties)&&!w.IsOptional(t.properties[n]))return P.False;if(w.IsOptional(t.properties[n]))return P.True;if(j0(e.properties[n],t.properties[n])===P.False)return P.False}return P.True})():P.False}function A_(e,t){return Tt(t)?vt(e,t):w.IsObject(t)&&M_(t)?P.True:w.IsPromise(t)?Sr(ke(e.item,t.item)):P.False}function Hy(e){return Ui in e.patternProperties?Yn():bo in e.patternProperties?Tn():Na("Unknown record key pattern")}function Gy(e){return Ui in e.patternProperties?e.patternProperties[Ui]:bo in e.patternProperties?e.patternProperties[bo]:Na("Unable to get record value schema")}function xr(e,t){let[n,r]=[Hy(t),Gy(t)];return w.IsLiteralString(e)&&w.IsNumber(n)&&Sr(ke(e,r))===P.True?P.True:w.IsUint8Array(e)&&w.IsNumber(n)||w.IsString(e)&&w.IsNumber(n)||w.IsArray(e)&&w.IsNumber(n)?ke(e,r):w.IsObject(e)?(()=>{for(let i of Object.getOwnPropertyNames(e.properties))if(j0(r,e.properties[i])===P.False)return P.False;return P.True})():P.False}function R_(e,t){return Tt(t)?vt(e,t):w.IsObject(t)?an(e,t):w.IsRecord(t)?ke(Gy(e),Gy(t)):P.False}function P_(e,t){let n=w.IsRegExp(e)?Tn():e,r=w.IsRegExp(t)?Tn():t;return ke(n,r)}function L0(e,t){return w.IsLiteral(e)&&Rn.IsString(e.const)||w.IsString(e)?P.True:P.False}function C_(e,t){return Tt(t)?vt(e,t):w.IsObject(t)?an(e,t):w.IsRecord(t)?xr(e,t):w.IsString(t)?P.True:P.False}function N_(e,t){return Tt(t)?vt(e,t):w.IsObject(t)?an(e,t):w.IsRecord(t)?xr(e,t):w.IsSymbol(t)?P.True:P.False}function k_(e,t){return w.IsTemplateLiteral(e)?ke(Ts(e),t):w.IsTemplateLiteral(t)?ke(e,Ts(t)):Na("Invalid fallthrough for TemplateLiteral")}function D_(e,t){return w.IsArray(t)&&e.items!==void 0&&e.items.every(n=>ke(n,t.items)===P.True)}function U_(e,t){return w.IsNever(e)?P.True:w.IsUnknown(e)?P.False:w.IsAny(e)?P.Union:P.False}function __(e,t){return Tt(t)?vt(e,t):w.IsObject(t)&&Ef(t)||w.IsArray(t)&&D_(e,t)?P.True:w.IsTuple(t)?Rn.IsUndefined(e.items)&&!Rn.IsUndefined(t.items)||!Rn.IsUndefined(e.items)&&Rn.IsUndefined(t.items)?P.False:Rn.IsUndefined(e.items)&&!Rn.IsUndefined(t.items)||e.items.every((n,r)=>ke(n,t.items[r])===P.True)?P.True:P.False:P.False}function j_(e,t){return Tt(t)?vt(e,t):w.IsObject(t)?an(e,t):w.IsRecord(t)?xr(e,t):w.IsUint8Array(t)?P.True:P.False}function L_(e,t){return Tt(t)?vt(e,t):w.IsObject(t)?an(e,t):w.IsRecord(t)?xr(e,t):w.IsVoid(t)?$_(e,t):w.IsUndefined(t)?P.True:P.False}function Vy(e,t){return t.anyOf.some(n=>ke(e,n)===P.True)?P.True:P.False}function B_(e,t){return e.anyOf.every(n=>ke(n,t)===P.True)?P.True:P.False}function B0(e,t){return P.True}function F_(e,t){return w.IsNever(t)?U0(e,t):w.IsIntersect(t)?If(e,t):w.IsUnion(t)?Vy(e,t):w.IsAny(t)?qy(e,t):w.IsString(t)?L0(e,t):w.IsNumber(t)?_0(e,t):w.IsInteger(t)?D0(e,t):w.IsBoolean(t)?k0(e,t):w.IsArray(t)?o_(e,t):w.IsTuple(t)?U_(e,t):w.IsObject(t)?an(e,t):w.IsUnknown(t)?P.True:P.False}function $_(e,t){return w.IsUndefined(e)||w.IsUndefined(e)?P.True:P.False}function K_(e,t){return w.IsIntersect(t)?If(e,t):w.IsUnion(t)?Vy(e,t):w.IsUnknown(t)?B0(e,t):w.IsAny(t)?qy(e,t):w.IsObject(t)?an(e,t):w.IsVoid(t)?P.True:P.False}function ke(e,t){return w.IsTemplateLiteral(e)||w.IsTemplateLiteral(t)?k_(e,t):w.IsRegExp(e)||w.IsRegExp(t)?P_(e,t):w.IsNot(e)||w.IsNot(t)?b_(e,t):w.IsAny(e)?i_(e,t):w.IsArray(e)?s_(e,t):w.IsBigInt(e)?c_(e,t):w.IsBoolean(e)?u_(e,t):w.IsAsyncIterator(e)?a_(e,t):w.IsConstructor(e)?l_(e,t):w.IsDate(e)?p_(e,t):w.IsFunction(e)?f_(e,t):w.IsInteger(e)?d_(e,t):w.IsIntersect(e)?m_(e,t):w.IsIterator(e)?h_(e,t):w.IsLiteral(e)?y_(e,t):w.IsNever(e)?g_(e,t):w.IsNull(e)?S_(e,t):w.IsNumber(e)?x_(e,t):w.IsObject(e)?O_(e,t):w.IsRecord(e)?R_(e,t):w.IsString(e)?C_(e,t):w.IsSymbol(e)?N_(e,t):w.IsTuple(e)?__(e,t):w.IsPromise(e)?A_(e,t):w.IsUint8Array(e)?j_(e,t):w.IsUndefined(e)?L_(e,t):w.IsUnion(e)?B_(e,t):w.IsUnknown(e)?F_(e,t):w.IsVoid(e)?K_(e,t):Na(`Unknown left type operand '${e[R]}'`)}function So(e,t){return ke(e,t)}u();u();u();function z_(e,t,n,r,i){let o={};for(let s of globalThis.Object.getOwnPropertyNames(e))o[s]=Is(e[s],t,n,r,i);return o}function H_(e,t,n,r,i){return z_(e.properties,t,n,r,i)}function F0(e,t,n,r,i){let o=H_(e,t,n,r,i);return ge(o)}function G_(e,t,n,r){let i=So(e,t);return i===P.Union?ve([n,r]):i===P.True?n:r}function Is(e,t,n,r,i={}){return Ze(e)?F0(e,t,n,r,i):qn(e)?B($0(e,t,n,r,i)):B(G_(e,t,n,r),i)}function q_(e,t,n,r,i){return{[e]:Is(oe(e),t,n,r,i)}}function V_(e,t,n,r,i){return e.reduce((o,s)=>({...o,...q_(s,t,n,r,i)}),{})}function Q_(e,t,n,r,i){return V_(e.keys,t,n,r,i)}function $0(e,t,n,r,i){let o=Q_(e,t,n,r,i);return ge(o)}u();function Y_(e){return e.allOf.every(t=>Es(t))}function J_(e){return e.anyOf.some(t=>Es(t))}function X_(e){return!Es(e.not)}function Es(e){return e[R]==="Intersect"?Y_(e):e[R]==="Union"?J_(e):e[R]==="Not"?X_(e):e[R]==="Undefined"}u();function K0(e,t){return ws(Ts(e),t)}function Z_(e,t){let n=e.filter(r=>So(r,t)===P.False);return n.length===1?n[0]:ve(n)}function ws(e,t,n={}){return Vn(e)?B(K0(e,t),n):Ze(e)?B(z0(e,t),n):B(Te(e)?Z_(e.anyOf,t):So(e,t)!==P.False?je():e,n)}function W_(e,t){let n={};for(let r of globalThis.Object.getOwnPropertyNames(e))n[r]=ws(e[r],t);return n}function ej(e,t){return W_(e.properties,t)}function z0(e,t){let n=ej(e,t);return ge(n)}u();u();u();u();function H0(e,t){return Ms(Ts(e),t)}function tj(e,t){let n=e.filter(r=>So(r,t)!==P.False);return n.length===1?n[0]:ve(n)}function Ms(e,t,n={}){return Vn(e)?B(H0(e,t),n):Ze(e)?B(G0(e,t),n):B(Te(e)?tj(e.anyOf,t):So(e,t)!==P.False?e:je(),n)}function nj(e,t){let n={};for(let r of globalThis.Object.getOwnPropertyNames(e))n[r]=Ms(e[r],t);return n}function rj(e,t){return nj(e.properties,t)}function G0(e,t){let n=rj(e,t);return ge(n)}u();u();function Qy(e,t={}){return B(e.returns,t)}u();u();function Yy(e={}){return{...e,[R]:"Integer",type:"integer"}}u();u();u();u();function ij(e,t,n){return{[e]:zr(oe(e),t,n)}}function oj(e,t,n){return e.reduce((r,i)=>({...r,...ij(i,t,n)}),{})}function sj(e,t,n){return oj(e.keys,t,n)}function q0(e,t,n){let r=sj(e,t,n);return ge(r)}function aj(e){let[t,n]=[e.slice(0,1),e.slice(1)];return[t.toLowerCase(),n].join("")}function cj(e){let[t,n]=[e.slice(0,1),e.slice(1)];return[t.toUpperCase(),n].join("")}function uj(e){return e.toUpperCase()}function lj(e){return e.toLowerCase()}function pj(e,t,n){let r=Ra(e.pattern);if(!Ss(r))return{...e,pattern:V0(e.pattern,t)};let s=[...Eu(r)].map(l=>oe(l)),a=Q0(s,t),c=ve(a);return Mu([c],n)}function V0(e,t){return typeof e=="string"?t==="Uncapitalize"?aj(e):t==="Capitalize"?cj(e):t==="Uppercase"?uj(e):t==="Lowercase"?lj(e):e:e.toString()}function Q0(e,t){return e.map(n=>zr(n,t))}function zr(e,t,n={}){return qn(e)?q0(e,t,n):Vn(e)?pj(e,t,e):Te(e)?ve(Q0(e.anyOf,t),n):Di(e)?oe(V0(e.const,t),n):e}function Jy(e,t={}){return zr(e,"Capitalize",t)}u();function Xy(e,t={}){return zr(e,"Lowercase",t)}u();function Zy(e,t={}){return zr(e,"Uncapitalize",t)}u();function Wy(e,t={}){return zr(e,"Uppercase",t)}u();u();function eg(e,t){return{...t,[R]:"Not",not:B(e)}}u();u();u();u();function fj(e,t,n){let r={};for(let i of globalThis.Object.getOwnPropertyNames(e))r[i]=Os(e[i],t,n);return r}function dj(e,t,n){return fj(e.properties,t,n)}function Y0(e,t,n){let r=dj(e,t,n);return ge(r)}function mj(e,t){return e.map(n=>tg(n,t))}function hj(e,t){return e.map(n=>tg(n,t))}function yj(e,t){let{[t]:n,...r}=e;return r}function gj(e,t){return t.reduce((n,r)=>yj(n,r),e)}function tg(e,t){return ht(e)?vn(mj(e.allOf,t)):Te(e)?ve(hj(e.anyOf,t)):Pt(e)?Ne(gj(e.properties,t)):Ne({})}function Os(e,t,n={}){if(qn(t))return J0(e,t,n);if(Ze(e))return Y0(e,t,n);let r=Qn(t)?kn(t):t,i=ut(e,[mt,"$id","required"]),o=B(tg(e,r),n);return{...i,...o}}function bj(e,t,n){return{[t]:Os(e,[t],n)}}function Sj(e,t,n){return t.reduce((r,i)=>({...r,...bj(e,i,n)}),{})}function xj(e,t,n){return Sj(e,t.keys,n)}function J0(e,t,n){let r=xj(e,t,n);return ge(r)}u();u();function ng(e,t={}){return Kr(ct(e.parameters),{...t})}u();u();u();function X0(e){return e.map(t=>Z0(t))}function Tj(e){let t={};for(let n of globalThis.Object.getOwnPropertyNames(e))t[n]=xn(e[n]);return t}function Z0(e){return ht(e)?vn(X0(e.allOf)):Te(e)?ve(X0(e.anyOf)):Pt(e)?Ne(Tj(e.properties)):Ne({})}function Bu(e,t={}){if(Ze(e))return W0(e,t);let n=ut(e,[mt,"$id","required"]),r=B(Z0(e),t);return{...n,...r}}function vj(e,t){let n={};for(let r of globalThis.Object.getOwnPropertyNames(e))n[r]=Bu(e[r],t);return n}function Ij(e,t){return vj(e.properties,t)}function W0(e,t){let n=Ij(e,t);return ge(n)}u();u();u();u();function Ej(e,t,n){let r={};for(let i of globalThis.Object.getOwnPropertyNames(e))r[i]=As(e[i],t,n);return r}function wj(e,t,n){return Ej(e.properties,t,n)}function eE(e,t,n){let r=wj(e,t,n);return ge(r)}function Mj(e,t){return e.map(n=>rg(n,t))}function Oj(e,t){return e.map(n=>rg(n,t))}function Aj(e,t){let n={};for(let r of t)r in e&&(n[r]=e[r]);return n}function rg(e,t){return ht(e)?vn(Mj(e.allOf,t)):Te(e)?ve(Oj(e.anyOf,t)):Pt(e)?Ne(Aj(e.properties,t)):Ne({})}function As(e,t,n={}){if(qn(t))return tE(e,t,n);if(Ze(e))return eE(e,t,n);let r=Qn(t)?kn(t):t,i=ut(e,[mt,"$id","required"]),o=B(rg(e,r),n);return{...i,...o}}function Rj(e,t,n){return{[t]:As(e,[t],n)}}function Pj(e,t,n){return t.reduce((r,i)=>({...r,...Rj(e,i,n)}),{})}function Cj(e,t,n){return Pj(e,t.keys,n)}function tE(e,t,n){let r=Cj(e,t,n);return ge(r)}u();u();function ig(e){return Jn(xn(e))}u();u();function Fu(e,t,n){return{...n,[R]:"Record",type:"object",patternProperties:{[e]:B(t)}}}function og(e,t,n){let r={};for(let i of e)r[i]=B(t);return Ne(r,{...n,[Pn]:"Record"})}function Nj(e,t,n){return Sf(e)?og(kn(e),t,n):Fu(e.pattern,t,n)}function kj(e,t,n){return og(kn(ve(e)),t,n)}function Dj(e,t,n){return og([e.toString()],t,n)}function Uj(e,t,n){return Fu(e.source,t,n)}function _j(e,t,n){let r=ot(e.pattern)?bo:e.pattern;return Fu(r,t,n)}function jj(e,t,n){return Fu(Ui,t,n)}function Lj(e,t,n){return Fu(Ui,t,n)}function sg(e,t,n={}){return Te(e)?kj(e.anyOf,t,n):Vn(e)?Nj(e,t,n):Di(e)?Dj(e.const,t,n):hs(e)?jj(e,t,n):ys(e)?Lj(e,t,n):Sy(e)?Uj(e,t,n):yu(e)?_j(e,t,n):je(n)}u();u();var Bj=0;function ag(e,t={}){ot(t.$id)&&(t.$id=`T${Bj++}`);let n=e({[R]:"This",$ref:`${t.$id}`});return n.$id=t.$id,B({...t,[Pn]:"Recursive",...n})}u();u();function cg(e,t={}){if(qe(e))return{...t,[R]:"Ref",$ref:e};if(ot(e.$id))throw new Error("Reference target type must specify an $id");return{...t,[R]:"Ref",$ref:e.$id}}u();u();function ug(e,t={}){let n=qe(e)?new globalThis.RegExp(e):e;return{...t,[R]:"RegExp",type:"RegExp",source:n.source,flags:n.flags}}u();u();u();function nE(e){return e.map(t=>rE(t))}function Fj(e){let t={};for(let n of globalThis.Object.getOwnPropertyNames(e))t[n]=ut(e[n],[Sn]);return t}function rE(e){return ht(e)?vn(nE(e.allOf)):Te(e)?ve(nE(e.anyOf)):Pt(e)?Ne(Fj(e.properties)):Ne({})}function $u(e,t={}){if(Ze(e))return iE(e,t);{let n=ut(e,[mt,"$id","required"]),r=B(rE(e),t);return{...n,...r}}}function $j(e,t){let n={};for(let r of globalThis.Object.getOwnPropertyNames(e))n[r]=$u(e[r],t);return n}function Kj(e,t){return $j(e.properties,t)}function iE(e,t){let n=Kj(e,t);return ge(n)}u();u();function zj(e){return ht(e)?ct(e.allOf):Te(e)?ct(e.anyOf):$r(e)?ct(e.items??[]):[]}function lg(e){return ct(zj(e))}u();u();function pg(e,t={}){return B(e.returns,t)}u();u();u();u();u();u();u();function fg(e){return JSON.parse(JSON.stringify(e))}u();u();var dg=class{schema;constructor(t){this.schema=t}Decode(t){return new mg(this.schema,t)}},mg=class{schema;decode;constructor(t,n){this.schema=t,this.decode=n}EncodeTransform(t,n){let o={Encode:s=>n[mt].Encode(t(s)),Decode:s=>this.decode(n[mt].Decode(s))};return{...n,[mt]:o}}EncodeSchema(t,n){let r={Decode:this.decode,Encode:t};return{...n,[mt]:r}}Encode(t){let n=B(this.schema);return wa(n)?this.EncodeTransform(t,n):this.EncodeSchema(t,n)}};function hg(e){return new dg(e)}u();u();function Ku(e={}){return{...e,[R]:e[R]??"Unsafe"}}u();u();function yg(e={}){return{...e,[R]:"Void",type:"void"}}u();u();var gg={};Ci(gg,{Any:()=>_i,Array:()=>bs,AsyncIterator:()=>xu,Awaited:()=>Uy,BigInt:()=>xs,Boolean:()=>wu,Capitalize:()=>Jy,Composite:()=>jy,Const:()=>By,Constructor:()=>Tu,ConstructorParameters:()=>Fy,Date:()=>ku,Deref:()=>br,Enum:()=>$y,Exclude:()=>ws,Extends:()=>Is,Extract:()=>Ms,Function:()=>ji,Index:()=>vs,InstanceType:()=>Qy,Integer:()=>Yy,Intersect:()=>vn,Iterator:()=>Au,KeyOf:()=>Nu,Literal:()=>oe,Lowercase:()=>Xy,Mapped:()=>ky,Never:()=>je,Not:()=>eg,Null:()=>Du,Number:()=>Yn,Object:()=>Ne,Omit:()=>Os,Optional:()=>xn,Parameters:()=>ng,Partial:()=>Bu,Pick:()=>As,Promise:()=>Ru,Readonly:()=>Jn,ReadonlyOptional:()=>ig,Record:()=>sg,Recursive:()=>ag,Ref:()=>cg,RegExp:()=>ug,Required:()=>$u,Rest:()=>lg,ReturnType:()=>pg,Strict:()=>fg,String:()=>Tn,Symbol:()=>Uu,TemplateLiteral:()=>Mu,Transform:()=>hg,Tuple:()=>Kr,Uint8Array:()=>ju,Uncapitalize:()=>Zy,Undefined:()=>_u,Union:()=>ve,Unknown:()=>Xn,Unsafe:()=>Ku,Uppercase:()=>Wy,Void:()=>yg});u();u();var x=gg;var Cg={};Ci(Cg,{Cast:()=>Cs,Check:()=>ue,Clean:()=>Of,Clone:()=>Pe,Convert:()=>Rf,Create:()=>pn,Default:()=>Cf,Delete:()=>gE,Diff:()=>vg,Edit:()=>N2,Equal:()=>To,HasPropertyKey:()=>W,HasTransform:()=>jf,Hash:()=>Ps,Insert:()=>hE,IsArray:()=>J,IsAsyncIterator:()=>zu,IsBigInt:()=>Tr,IsBigInt64Array:()=>rL,IsBigUint64Array:()=>iL,IsBoolean:()=>Hr,IsDate:()=>_n,IsFloat32Array:()=>tL,IsFloat64Array:()=>nL,IsFunction:()=>ka,IsInstanceObject:()=>Gj,IsInt16Array:()=>Xj,IsInt32Array:()=>Wj,IsInt8Array:()=>Yj,IsInteger:()=>qu,IsIterator:()=>Hu,IsMap:()=>qj,IsNull:()=>ii,IsNumber:()=>Qe,IsObject:()=>Ct,IsPromise:()=>Gu,IsRegExp:()=>Qj,IsSet:()=>Vj,IsStandardObject:()=>Ae,IsString:()=>se,IsSymbol:()=>In,IsTypedArray:()=>cn,IsUint16Array:()=>Zj,IsUint32Array:()=>eL,IsUint8Array:()=>Rs,IsUint8ClampedArray:()=>Jj,IsUndefined:()=>et,IsValueType:()=>un,Mutate:()=>wg,Patch:()=>Ig,TransformDecode:()=>Mg,TransformDecodeCheckError:()=>tl,TransformDecodeError:()=>Uf,TransformEncode:()=>Og,TransformEncodeCheckError:()=>nl,TransformEncodeError:()=>_f,Update:()=>yE,Value:()=>ks,ValueCastError:()=>Qu,ValueCheckUnknownTypeError:()=>Mf,ValueCreateError:()=>Ln,ValueDeltaError:()=>Zu,ValueDeltaSymbolError:()=>Ns,ValueErrorIterator:()=>Vu,ValueErrorType:()=>A,ValueHashError:()=>wf,ValueMutateError:()=>el,ValuePointer:()=>Ir});u();u();u();u();u();u();u();function zu(e){return Ct(e)&&Symbol.asyncIterator in e}function Hu(e){return Ct(e)&&Symbol.iterator in e}function Ae(e){return Ct(e)&&(Object.getPrototypeOf(e)===Object.prototype||Object.getPrototypeOf(e)===null)}function Gj(e){return Ct(e)&&!J(e)&&ka(e.constructor)&&e.constructor.name!=="Object"}function Gu(e){return e instanceof Promise}function _n(e){return e instanceof Date&&Number.isFinite(e.getTime())}function qj(e){return e instanceof globalThis.Map}function Vj(e){return e instanceof globalThis.Set}function Qj(e){return e instanceof globalThis.RegExp}function cn(e){return ArrayBuffer.isView(e)}function Yj(e){return e instanceof globalThis.Int8Array}function Rs(e){return e instanceof globalThis.Uint8Array}function Jj(e){return e instanceof globalThis.Uint8ClampedArray}function Xj(e){return e instanceof globalThis.Int16Array}function Zj(e){return e instanceof globalThis.Uint16Array}function Wj(e){return e instanceof globalThis.Int32Array}function eL(e){return e instanceof globalThis.Uint32Array}function tL(e){return e instanceof globalThis.Float32Array}function nL(e){return e instanceof globalThis.Float64Array}function rL(e){return e instanceof globalThis.BigInt64Array}function iL(e){return e instanceof globalThis.BigUint64Array}function W(e,t){return t in e}function Ct(e){return e!==null&&typeof e=="object"}function J(e){return Array.isArray(e)&&!ArrayBuffer.isView(e)}function et(e){return e===void 0}function ii(e){return e===null}function Hr(e){return typeof e=="boolean"}function Qe(e){return typeof e=="number"}function qu(e){return Number.isInteger(e)}function Tr(e){return typeof e=="bigint"}function se(e){return typeof e=="string"}function ka(e){return typeof e=="function"}function In(e){return typeof e=="symbol"}function un(e){return Tr(e)||Hr(e)||ii(e)||Qe(e)||se(e)||In(e)||et(e)}var jn;(function(e){e.ExactOptionalPropertyTypes=!1,e.AllowArrayObject=!1,e.AllowNaN=!1,e.AllowNullVoid=!1;function t(s,a){return e.ExactOptionalPropertyTypes?a in s:s[a]!==void 0}e.IsExactOptionalProperty=t;function n(s){let a=Ct(s);return e.AllowArrayObject?a:a&&!J(s)}e.IsObjectLike=n;function r(s){return n(s)&&!(s instanceof Date)&&!(s instanceof Uint8Array)}e.IsRecordLike=r;function i(s){return e.AllowNaN?Qe(s):Number.isFinite(s)}e.IsNumberLike=i;function o(s){let a=et(s);return e.AllowNullVoid?a||s===null:a}e.IsVoidLike=o})(jn||(jn={}));u();var bg=class extends Z{constructor(t){super(`Duplicate type kind '${t}' detected`)}},Sg=class extends Z{constructor(t){super(`Duplicate string format '${t}' detected`)}},oE;(function(e){function t(r,i){if(Nn.Has(r))throw new bg(r);return Nn.Set(r,i),(o={})=>Ku({...o,[R]:r})}e.Type=t;function n(r,i){if(Cn.Has(r))throw new Sg(r);return Cn.Set(r,i),r}e.Format=n})(oE||(oE={}));u();function oL(e){switch(e.errorType){case A.ArrayContains:return"Expected array to contain at least one matching value";case A.ArrayMaxContains:return`Expected array to contain no more than ${e.schema.maxContains} matching values`;case A.ArrayMinContains:return`Expected array to contain at least ${e.schema.minContains} matching values`;case A.ArrayMaxItems:return`Expected array length to be less or equal to ${e.schema.maxItems}`;case A.ArrayMinItems:return`Expected array length to be greater or equal to ${e.schema.minItems}`;case A.ArrayUniqueItems:return"Expected array elements to be unique";case A.Array:return"Expected array";case A.AsyncIterator:return"Expected AsyncIterator";case A.BigIntExclusiveMaximum:return`Expected bigint to be less than ${e.schema.exclusiveMaximum}`;case A.BigIntExclusiveMinimum:return`Expected bigint to be greater than ${e.schema.exclusiveMinimum}`;case A.BigIntMaximum:return`Expected bigint to be less or equal to ${e.schema.maximum}`;case A.BigIntMinimum:return`Expected bigint to be greater or equal to ${e.schema.minimum}`;case A.BigIntMultipleOf:return`Expected bigint to be a multiple of ${e.schema.multipleOf}`;case A.BigInt:return"Expected bigint";case A.Boolean:return"Expected boolean";case A.DateExclusiveMinimumTimestamp:return`Expected Date timestamp to be greater than ${e.schema.exclusiveMinimumTimestamp}`;case A.DateExclusiveMaximumTimestamp:return`Expected Date timestamp to be less than ${e.schema.exclusiveMaximumTimestamp}`;case A.DateMinimumTimestamp:return`Expected Date timestamp to be greater or equal to ${e.schema.minimumTimestamp}`;case A.DateMaximumTimestamp:return`Expected Date timestamp to be less or equal to ${e.schema.maximumTimestamp}`;case A.DateMultipleOfTimestamp:return`Expected Date timestamp to be a multiple of ${e.schema.multipleOfTimestamp}`;case A.Date:return"Expected Date";case A.Function:return"Expected function";case A.IntegerExclusiveMaximum:return`Expected integer to be less than ${e.schema.exclusiveMaximum}`;case A.IntegerExclusiveMinimum:return`Expected integer to be greater than ${e.schema.exclusiveMinimum}`;case A.IntegerMaximum:return`Expected integer to be less or equal to ${e.schema.maximum}`;case A.IntegerMinimum:return`Expected integer to be greater or equal to ${e.schema.minimum}`;case A.IntegerMultipleOf:return`Expected integer to be a multiple of ${e.schema.multipleOf}`;case A.Integer:return"Expected integer";case A.IntersectUnevaluatedProperties:return"Unexpected property";case A.Intersect:return"Expected all values to match";case A.Iterator:return"Expected Iterator";case A.Literal:return`Expected ${typeof e.schema.const=="string"?`'${e.schema.const}'`:e.schema.const}`;case A.Never:return"Never";case A.Not:return"Value should not match";case A.Null:return"Expected null";case A.NumberExclusiveMaximum:return`Expected number to be less than ${e.schema.exclusiveMaximum}`;case A.NumberExclusiveMinimum:return`Expected number to be greater than ${e.schema.exclusiveMinimum}`;case A.NumberMaximum:return`Expected number to be less or equal to ${e.schema.maximum}`;case A.NumberMinimum:return`Expected number to be greater or equal to ${e.schema.minimum}`;case A.NumberMultipleOf:return`Expected number to be a multiple of ${e.schema.multipleOf}`;case A.Number:return"Expected number";case A.Object:return"Expected object";case A.ObjectAdditionalProperties:return"Unexpected property";case A.ObjectMaxProperties:return`Expected object to have no more than ${e.schema.maxProperties} properties`;case A.ObjectMinProperties:return`Expected object to have at least ${e.schema.minProperties} properties`;case A.ObjectRequiredProperty:return"Required property";case A.Promise:return"Expected Promise";case A.RegExp:return"Expected string to match regular expression";case A.StringFormatUnknown:return`Unknown format '${e.schema.format}'`;case A.StringFormat:return`Expected string to match '${e.schema.format}' format`;case A.StringMaxLength:return`Expected string length less or equal to ${e.schema.maxLength}`;case A.StringMinLength:return`Expected string length greater or equal to ${e.schema.minLength}`;case A.StringPattern:return`Expected string to match '${e.schema.pattern}'`;case A.String:return"Expected string";case A.Symbol:return"Expected symbol";case A.TupleLength:return`Expected tuple to have ${e.schema.maxItems||0} elements`;case A.Tuple:return"Expected tuple";case A.Uint8ArrayMaxByteLength:return`Expected byte length less or equal to ${e.schema.maxByteLength}`;case A.Uint8ArrayMinByteLength:return`Expected byte length greater or equal to ${e.schema.minByteLength}`;case A.Uint8Array:return"Expected Uint8Array";case A.Undefined:return"Expected undefined";case A.Union:return"Expected union value";case A.Void:return"Expected void";case A.Kind:return`Expected kind '${e.schema[R]}'`;default:return"Unknown error type"}}var sL=oL;function sE(){return sL}u();u();var xg=class extends Z{schema;constructor(t){super(`Unable to dereference schema with $id '${t.$id}'`),this.schema=t}};function Re(e,t){let n=t.findIndex(r=>r.$id===e.$ref);if(n===-1)throw new xg(e);return t[n]}u();u();var wf=class extends Z{value;constructor(t){super("Unable to hash value"),this.value=t}},Zn;(function(e){e[e.Undefined=0]="Undefined",e[e.Null=1]="Null",e[e.Boolean=2]="Boolean",e[e.Number=3]="Number",e[e.String=4]="String",e[e.Object=5]="Object",e[e.Array=6]="Array",e[e.Date=7]="Date",e[e.Uint8Array=8]="Uint8Array",e[e.Symbol=9]="Symbol",e[e.BigInt=10]="BigInt"})(Zn||(Zn={}));var Da=BigInt("14695981039346656037"),[aL,cL]=[BigInt("1099511628211"),BigInt("2")**BigInt("64")],uL=Array.from({length:256}).map((e,t)=>BigInt(t)),aE=new Float64Array(1),cE=new DataView(aE.buffer),uE=new Uint8Array(aE.buffer);function*lL(e){let t=e===0?1:Math.ceil(Math.floor(Math.log2(e)+1)/8);for(let n=0;n<t;n++)yield e>>8*(t-1-n)&255}function pL(e){ln(Zn.Array);for(let t of e)Ua(t)}function fL(e){ln(Zn.Boolean),ln(e?1:0)}function dL(e){ln(Zn.BigInt),cE.setBigInt64(0,e);for(let t of uE)ln(t)}function mL(e){ln(Zn.Date),Ua(e.getTime())}function hL(e){ln(Zn.Null)}function yL(e){ln(Zn.Number),cE.setFloat64(0,e);for(let t of uE)ln(t)}function gL(e){ln(Zn.Object);for(let t of globalThis.Object.getOwnPropertyNames(e).sort())Ua(t),Ua(e[t])}function bL(e){ln(Zn.String);for(let t=0;t<e.length;t++)for(let n of lL(e.charCodeAt(t)))ln(n)}function SL(e){ln(Zn.Symbol),Ua(e.description)}function xL(e){ln(Zn.Uint8Array);for(let t=0;t<e.length;t++)ln(e[t])}function TL(e){return ln(Zn.Undefined)}function Ua(e){if(J(e))return pL(e);if(Hr(e))return fL(e);if(Tr(e))return dL(e);if(_n(e))return mL(e);if(ii(e))return hL(e);if(Qe(e))return yL(e);if(Ae(e))return gL(e);if(se(e))return bL(e);if(In(e))return SL(e);if(Rs(e))return xL(e);if(et(e))return TL(e);throw new wf(e)}function ln(e){Da=Da^uL[e],Da=Da*aL%cL}function Ps(e){return Da=BigInt("14695981039346656037"),Ua(e),Da}var A;(function(e){e[e.ArrayContains=0]="ArrayContains",e[e.ArrayMaxContains=1]="ArrayMaxContains",e[e.ArrayMaxItems=2]="ArrayMaxItems",e[e.ArrayMinContains=3]="ArrayMinContains",e[e.ArrayMinItems=4]="ArrayMinItems",e[e.ArrayUniqueItems=5]="ArrayUniqueItems",e[e.Array=6]="Array",e[e.AsyncIterator=7]="AsyncIterator",e[e.BigIntExclusiveMaximum=8]="BigIntExclusiveMaximum",e[e.BigIntExclusiveMinimum=9]="BigIntExclusiveMinimum",e[e.BigIntMaximum=10]="BigIntMaximum",e[e.BigIntMinimum=11]="BigIntMinimum",e[e.BigIntMultipleOf=12]="BigIntMultipleOf",e[e.BigInt=13]="BigInt",e[e.Boolean=14]="Boolean",e[e.DateExclusiveMaximumTimestamp=15]="DateExclusiveMaximumTimestamp",e[e.DateExclusiveMinimumTimestamp=16]="DateExclusiveMinimumTimestamp",e[e.DateMaximumTimestamp=17]="DateMaximumTimestamp",e[e.DateMinimumTimestamp=18]="DateMinimumTimestamp",e[e.DateMultipleOfTimestamp=19]="DateMultipleOfTimestamp",e[e.Date=20]="Date",e[e.Function=21]="Function",e[e.IntegerExclusiveMaximum=22]="IntegerExclusiveMaximum",e[e.IntegerExclusiveMinimum=23]="IntegerExclusiveMinimum",e[e.IntegerMaximum=24]="IntegerMaximum",e[e.IntegerMinimum=25]="IntegerMinimum",e[e.IntegerMultipleOf=26]="IntegerMultipleOf",e[e.Integer=27]="Integer",e[e.IntersectUnevaluatedProperties=28]="IntersectUnevaluatedProperties",e[e.Intersect=29]="Intersect",e[e.Iterator=30]="Iterator",e[e.Kind=31]="Kind",e[e.Literal=32]="Literal",e[e.Never=33]="Never",e[e.Not=34]="Not",e[e.Null=35]="Null",e[e.NumberExclusiveMaximum=36]="NumberExclusiveMaximum",e[e.NumberExclusiveMinimum=37]="NumberExclusiveMinimum",e[e.NumberMaximum=38]="NumberMaximum",e[e.NumberMinimum=39]="NumberMinimum",e[e.NumberMultipleOf=40]="NumberMultipleOf",e[e.Number=41]="Number",e[e.ObjectAdditionalProperties=42]="ObjectAdditionalProperties",e[e.ObjectMaxProperties=43]="ObjectMaxProperties",e[e.ObjectMinProperties=44]="ObjectMinProperties",e[e.ObjectRequiredProperty=45]="ObjectRequiredProperty",e[e.Object=46]="Object",e[e.Promise=47]="Promise",e[e.RegExp=48]="RegExp",e[e.StringFormatUnknown=49]="StringFormatUnknown",e[e.StringFormat=50]="StringFormat",e[e.StringMaxLength=51]="StringMaxLength",e[e.StringMinLength=52]="StringMinLength",e[e.StringPattern=53]="StringPattern",e[e.String=54]="String",e[e.Symbol=55]="Symbol",e[e.TupleLength=56]="TupleLength",e[e.Tuple=57]="Tuple",e[e.Uint8ArrayMaxByteLength=58]="Uint8ArrayMaxByteLength",e[e.Uint8ArrayMinByteLength=59]="Uint8ArrayMinByteLength",e[e.Uint8Array=60]="Uint8Array",e[e.Undefined=61]="Undefined",e[e.Union=62]="Union",e[e.Void=63]="Void"})(A||(A={}));var Tg=class extends Z{schema;constructor(t){super("Unknown type"),this.schema=t}};function Bi(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}function ae(e){return e!==void 0}var Vu=class{iterator;constructor(t){this.iterator=t}[Symbol.iterator](){return this.iterator}First(){let t=this.iterator.next();return t.done?void 0:t.value}};function $(e,t,n,r){return{type:e,schema:t,path:n,value:r,message:sE()({errorType:e,path:n,schema:t,value:r})}}function*vL(e,t,n,r){}function*IL(e,t,n,r){if(!J(r))return yield $(A.Array,e,n,r);ae(e.minItems)&&!(r.length>=e.minItems)&&(yield $(A.ArrayMinItems,e,n,r)),ae(e.maxItems)&&!(r.length<=e.maxItems)&&(yield $(A.ArrayMaxItems,e,n,r));for(let s=0;s<r.length;s++)yield*Zt(e.items,t,`${n}/${s}`,r[s]);if(e.uniqueItems===!0&&!function(){let s=new Set;for(let a of r){let c=Ps(a);if(s.has(c))return!1;s.add(c)}return!0}()&&(yield $(A.ArrayUniqueItems,e,n,r)),!(ae(e.contains)||ae(e.minContains)||ae(e.maxContains)))return;let i=ae(e.contains)?e.contains:je(),o=r.reduce((s,a,c)=>Zt(i,t,`${n}${c}`,a).next().done===!0?s+1:s,0);o===0&&(yield $(A.ArrayContains,e,n,r)),Qe(e.minContains)&&o<e.minContains&&(yield $(A.ArrayMinContains,e,n,r)),Qe(e.maxContains)&&o>e.maxContains&&(yield $(A.ArrayMaxContains,e,n,r))}function*EL(e,t,n,r){zu(r)||(yield $(A.AsyncIterator,e,n,r))}function*wL(e,t,n,r){if(!Tr(r))return yield $(A.BigInt,e,n,r);ae(e.exclusiveMaximum)&&!(r<e.exclusiveMaximum)&&(yield $(A.BigIntExclusiveMaximum,e,n,r)),ae(e.exclusiveMinimum)&&!(r>e.exclusiveMinimum)&&(yield $(A.BigIntExclusiveMinimum,e,n,r)),ae(e.maximum)&&!(r<=e.maximum)&&(yield $(A.BigIntMaximum,e,n,r)),ae(e.minimum)&&!(r>=e.minimum)&&(yield $(A.BigIntMinimum,e,n,r)),ae(e.multipleOf)&&r%e.multipleOf!==BigInt(0)&&(yield $(A.BigIntMultipleOf,e,n,r))}function*ML(e,t,n,r){Hr(r)||(yield $(A.Boolean,e,n,r))}function*OL(e,t,n,r){yield*Zt(e.returns,t,n,r.prototype)}function*AL(e,t,n,r){if(!_n(r))return yield $(A.Date,e,n,r);ae(e.exclusiveMaximumTimestamp)&&!(r.getTime()<e.exclusiveMaximumTimestamp)&&(yield $(A.DateExclusiveMaximumTimestamp,e,n,r)),ae(e.exclusiveMinimumTimestamp)&&!(r.getTime()>e.exclusiveMinimumTimestamp)&&(yield $(A.DateExclusiveMinimumTimestamp,e,n,r)),ae(e.maximumTimestamp)&&!(r.getTime()<=e.maximumTimestamp)&&(yield $(A.DateMaximumTimestamp,e,n,r)),ae(e.minimumTimestamp)&&!(r.getTime()>=e.minimumTimestamp)&&(yield $(A.DateMinimumTimestamp,e,n,r)),ae(e.multipleOfTimestamp)&&r.getTime()%e.multipleOfTimestamp!==0&&(yield $(A.DateMultipleOfTimestamp,e,n,r))}function*RL(e,t,n,r){ka(r)||(yield $(A.Function,e,n,r))}function*PL(e,t,n,r){if(!qu(r))return yield $(A.Integer,e,n,r);ae(e.exclusiveMaximum)&&!(r<e.exclusiveMaximum)&&(yield $(A.IntegerExclusiveMaximum,e,n,r)),ae(e.exclusiveMinimum)&&!(r>e.exclusiveMinimum)&&(yield $(A.IntegerExclusiveMinimum,e,n,r)),ae(e.maximum)&&!(r<=e.maximum)&&(yield $(A.IntegerMaximum,e,n,r)),ae(e.minimum)&&!(r>=e.minimum)&&(yield $(A.IntegerMinimum,e,n,r)),ae(e.multipleOf)&&r%e.multipleOf!==0&&(yield $(A.IntegerMultipleOf,e,n,r))}function*CL(e,t,n,r){for(let i of e.allOf){let o=Zt(i,t,n,r).next();o.done||(yield $(A.Intersect,e,n,r),yield o.value)}if(e.unevaluatedProperties===!1){let i=new RegExp(Ca(e));for(let o of Object.getOwnPropertyNames(r))i.test(o)||(yield $(A.IntersectUnevaluatedProperties,e,`${n}/${o}`,r))}if(typeof e.unevaluatedProperties=="object"){let i=new RegExp(Ca(e));for(let o of Object.getOwnPropertyNames(r))if(!i.test(o)){let s=Zt(e.unevaluatedProperties,t,`${n}/${o}`,r[o]).next();s.done||(yield s.value)}}}function*NL(e,t,n,r){Hu(r)||(yield $(A.Iterator,e,n,r))}function*kL(e,t,n,r){r!==e.const&&(yield $(A.Literal,e,n,r))}function*DL(e,t,n,r){yield $(A.Never,e,n,r)}function*UL(e,t,n,r){Zt(e.not,t,n,r).next().done===!0&&(yield $(A.Not,e,n,r))}function*_L(e,t,n,r){ii(r)||(yield $(A.Null,e,n,r))}function*jL(e,t,n,r){if(!jn.IsNumberLike(r))return yield $(A.Number,e,n,r);ae(e.exclusiveMaximum)&&!(r<e.exclusiveMaximum)&&(yield $(A.NumberExclusiveMaximum,e,n,r)),ae(e.exclusiveMinimum)&&!(r>e.exclusiveMinimum)&&(yield $(A.NumberExclusiveMinimum,e,n,r)),ae(e.maximum)&&!(r<=e.maximum)&&(yield $(A.NumberMaximum,e,n,r)),ae(e.minimum)&&!(r>=e.minimum)&&(yield $(A.NumberMinimum,e,n,r)),ae(e.multipleOf)&&r%e.multipleOf!==0&&(yield $(A.NumberMultipleOf,e,n,r))}function*LL(e,t,n,r){if(!jn.IsObjectLike(r))return yield $(A.Object,e,n,r);ae(e.minProperties)&&!(Object.getOwnPropertyNames(r).length>=e.minProperties)&&(yield $(A.ObjectMinProperties,e,n,r)),ae(e.maxProperties)&&!(Object.getOwnPropertyNames(r).length<=e.maxProperties)&&(yield $(A.ObjectMaxProperties,e,n,r));let i=Array.isArray(e.required)?e.required:[],o=Object.getOwnPropertyNames(e.properties),s=Object.getOwnPropertyNames(r);for(let a of i)s.includes(a)||(yield $(A.ObjectRequiredProperty,e.properties[a],`${n}/${Bi(a)}`,void 0));if(e.additionalProperties===!1)for(let a of s)o.includes(a)||(yield $(A.ObjectAdditionalProperties,e,`${n}/${Bi(a)}`,r[a]));if(typeof e.additionalProperties=="object")for(let a of s)o.includes(a)||(yield*Zt(e.additionalProperties,t,`${n}/${Bi(a)}`,r[a]));for(let a of o){let c=e.properties[a];e.required&&e.required.includes(a)?(yield*Zt(c,t,`${n}/${Bi(a)}`,r[a]),Es(e)&&!(a in r)&&(yield $(A.ObjectRequiredProperty,c,`${n}/${Bi(a)}`,void 0))):jn.IsExactOptionalProperty(r,a)&&(yield*Zt(c,t,`${n}/${Bi(a)}`,r[a]))}}function*BL(e,t,n,r){Gu(r)||(yield $(A.Promise,e,n,r))}function*FL(e,t,n,r){if(!jn.IsRecordLike(r))return yield $(A.Object,e,n,r);ae(e.minProperties)&&!(Object.getOwnPropertyNames(r).length>=e.minProperties)&&(yield $(A.ObjectMinProperties,e,n,r)),ae(e.maxProperties)&&!(Object.getOwnPropertyNames(r).length<=e.maxProperties)&&(yield $(A.ObjectMaxProperties,e,n,r));let[i,o]=Object.entries(e.patternProperties)[0],s=new RegExp(i);for(let[a,c]of Object.entries(r))s.test(a)&&(yield*Zt(o,t,`${n}/${Bi(a)}`,c));if(typeof e.additionalProperties=="object")for(let[a,c]of Object.entries(r))s.test(a)||(yield*Zt(e.additionalProperties,t,`${n}/${Bi(a)}`,c));if(e.additionalProperties===!1){for(let[a,c]of Object.entries(r))if(!s.test(a))return yield $(A.ObjectAdditionalProperties,e,`${n}/${Bi(a)}`,c)}}function*$L(e,t,n,r){yield*Zt(Re(e,t),t,n,r)}function*KL(e,t,n,r){if(!se(r))return yield $(A.String,e,n,r);if(ae(e.minLength)&&!(r.length>=e.minLength)&&(yield $(A.StringMinLength,e,n,r)),ae(e.maxLength)&&!(r.length<=e.maxLength)&&(yield $(A.StringMaxLength,e,n,r)),!new RegExp(e.source,e.flags).test(r))return yield $(A.RegExp,e,n,r)}function*zL(e,t,n,r){if(!se(r))return yield $(A.String,e,n,r);ae(e.minLength)&&!(r.length>=e.minLength)&&(yield $(A.StringMinLength,e,n,r)),ae(e.maxLength)&&!(r.length<=e.maxLength)&&(yield $(A.StringMaxLength,e,n,r)),se(e.pattern)&&(new RegExp(e.pattern).test(r)||(yield $(A.StringPattern,e,n,r))),se(e.format)&&(Cn.Has(e.format)?Cn.Get(e.format)(r)||(yield $(A.StringFormat,e,n,r)):yield $(A.StringFormatUnknown,e,n,r))}function*HL(e,t,n,r){In(r)||(yield $(A.Symbol,e,n,r))}function*GL(e,t,n,r){if(!se(r))return yield $(A.String,e,n,r);new RegExp(e.pattern).test(r)||(yield $(A.StringPattern,e,n,r))}function*qL(e,t,n,r){yield*Zt(Re(e,t),t,n,r)}function*VL(e,t,n,r){if(!J(r))return yield $(A.Tuple,e,n,r);if(e.items===void 0&&r.length!==0)return yield $(A.TupleLength,e,n,r);if(r.length!==e.maxItems)return yield $(A.TupleLength,e,n,r);if(e.items)for(let i=0;i<e.items.length;i++)yield*Zt(e.items[i],t,`${n}/${i}`,r[i])}function*QL(e,t,n,r){et(r)||(yield $(A.Undefined,e,n,r))}function*YL(e,t,n,r){let i=0;for(let o of e.anyOf){let s=[...Zt(o,t,n,r)];if(s.length===0)return;i+=s.length}i>0&&(yield $(A.Union,e,n,r))}function*JL(e,t,n,r){if(!Rs(r))return yield $(A.Uint8Array,e,n,r);ae(e.maxByteLength)&&!(r.length<=e.maxByteLength)&&(yield $(A.Uint8ArrayMaxByteLength,e,n,r)),ae(e.minByteLength)&&!(r.length>=e.minByteLength)&&(yield $(A.Uint8ArrayMinByteLength,e,n,r))}function*XL(e,t,n,r){}function*ZL(e,t,n,r){jn.IsVoidLike(r)||(yield $(A.Void,e,n,r))}function*WL(e,t,n,r){Nn.Get(e[R])(e,r)||(yield $(A.Kind,e,n,r))}function*Zt(e,t,n,r){let i=ae(e.$id)?[...t,e]:t,o=e;switch(o[R]){case"Any":return yield*vL(o,i,n,r);case"Array":return yield*IL(o,i,n,r);case"AsyncIterator":return yield*EL(o,i,n,r);case"BigInt":return yield*wL(o,i,n,r);case"Boolean":return yield*ML(o,i,n,r);case"Constructor":return yield*OL(o,i,n,r);case"Date":return yield*AL(o,i,n,r);case"Function":return yield*RL(o,i,n,r);case"Integer":return yield*PL(o,i,n,r);case"Intersect":return yield*CL(o,i,n,r);case"Iterator":return yield*NL(o,i,n,r);case"Literal":return yield*kL(o,i,n,r);case"Never":return yield*DL(o,i,n,r);case"Not":return yield*UL(o,i,n,r);case"Null":return yield*_L(o,i,n,r);case"Number":return yield*jL(o,i,n,r);case"Object":return yield*LL(o,i,n,r);case"Promise":return yield*BL(o,i,n,r);case"Record":return yield*FL(o,i,n,r);case"Ref":return yield*$L(o,i,n,r);case"RegExp":return yield*KL(o,i,n,r);case"String":return yield*zL(o,i,n,r);case"Symbol":return yield*HL(o,i,n,r);case"TemplateLiteral":return yield*GL(o,i,n,r);case"This":return yield*qL(o,i,n,r);case"Tuple":return yield*VL(o,i,n,r);case"Undefined":return yield*QL(o,i,n,r);case"Union":return yield*YL(o,i,n,r);case"Uint8Array":return yield*JL(o,i,n,r);case"Unknown":return yield*XL(o,i,n,r);case"Void":return yield*ZL(o,i,n,r);default:if(!Nn.Has(o[R]))throw new Tg(e);return yield*WL(o,i,n,r)}}function _a(...e){let t=e.length===3?Zt(e[0],e[1],"",e[2]):Zt(e[0],[],"",e[1]);return new Vu(t)}u();u();u();u();u();u();var Mf=class extends Z{schema;constructor(t){super("Unknown type"),this.schema=t}};function eB(e){return e[R]==="Any"||e[R]==="Unknown"}function ce(e){return e!==void 0}function tB(e,t,n){return!0}function nB(e,t,n){if(!J(n)||ce(e.minItems)&&!(n.length>=e.minItems)||ce(e.maxItems)&&!(n.length<=e.maxItems)||!n.every(o=>Wt(e.items,t,o))||e.uniqueItems===!0&&!function(){let o=new Set;for(let s of n){let a=Ps(s);if(o.has(a))return!1;o.add(a)}return!0}())return!1;if(!(ce(e.contains)||Qe(e.minContains)||Qe(e.maxContains)))return!0;let r=ce(e.contains)?e.contains:je(),i=n.reduce((o,s)=>Wt(r,t,s)?o+1:o,0);return!(i===0||Qe(e.minContains)&&i<e.minContains||Qe(e.maxContains)&&i>e.maxContains)}function rB(e,t,n){return zu(n)}function iB(e,t,n){return!(!Tr(n)||ce(e.exclusiveMaximum)&&!(n<e.exclusiveMaximum)||ce(e.exclusiveMinimum)&&!(n>e.exclusiveMinimum)||ce(e.maximum)&&!(n<=e.maximum)||ce(e.minimum)&&!(n>=e.minimum)||ce(e.multipleOf)&&n%e.multipleOf!==BigInt(0))}function oB(e,t,n){return Hr(n)}function sB(e,t,n){return Wt(e.returns,t,n.prototype)}function aB(e,t,n){return!(!_n(n)||ce(e.exclusiveMaximumTimestamp)&&!(n.getTime()<e.exclusiveMaximumTimestamp)||ce(e.exclusiveMinimumTimestamp)&&!(n.getTime()>e.exclusiveMinimumTimestamp)||ce(e.maximumTimestamp)&&!(n.getTime()<=e.maximumTimestamp)||ce(e.minimumTimestamp)&&!(n.getTime()>=e.minimumTimestamp)||ce(e.multipleOfTimestamp)&&n.getTime()%e.multipleOfTimestamp!==0)}function cB(e,t,n){return ka(n)}function uB(e,t,n){return!(!qu(n)||ce(e.exclusiveMaximum)&&!(n<e.exclusiveMaximum)||ce(e.exclusiveMinimum)&&!(n>e.exclusiveMinimum)||ce(e.maximum)&&!(n<=e.maximum)||ce(e.minimum)&&!(n>=e.minimum)||ce(e.multipleOf)&&n%e.multipleOf!==0)}function lB(e,t,n){let r=e.allOf.every(i=>Wt(i,t,n));if(e.unevaluatedProperties===!1){let i=new RegExp(Ca(e)),o=Object.getOwnPropertyNames(n).every(s=>i.test(s));return r&&o}else if(fe(e.unevaluatedProperties)){let i=new RegExp(Ca(e)),o=Object.getOwnPropertyNames(n).every(s=>i.test(s)||Wt(e.unevaluatedProperties,t,n[s]));return r&&o}else return r}function pB(e,t,n){return Hu(n)}function fB(e,t,n){return n===e.const}function dB(e,t,n){return!1}function mB(e,t,n){return!Wt(e.not,t,n)}function hB(e,t,n){return ii(n)}function yB(e,t,n){return!(!jn.IsNumberLike(n)||ce(e.exclusiveMaximum)&&!(n<e.exclusiveMaximum)||ce(e.exclusiveMinimum)&&!(n>e.exclusiveMinimum)||ce(e.minimum)&&!(n>=e.minimum)||ce(e.maximum)&&!(n<=e.maximum)||ce(e.multipleOf)&&n%e.multipleOf!==0)}function gB(e,t,n){if(!jn.IsObjectLike(n)||ce(e.minProperties)&&!(Object.getOwnPropertyNames(n).length>=e.minProperties)||ce(e.maxProperties)&&!(Object.getOwnPropertyNames(n).length<=e.maxProperties))return!1;let r=Object.getOwnPropertyNames(e.properties);for(let i of r){let o=e.properties[i];if(e.required&&e.required.includes(i)){if(!Wt(o,t,n[i])||(Es(o)||eB(o))&&!(i in n))return!1}else if(jn.IsExactOptionalProperty(n,i)&&!Wt(o,t,n[i]))return!1}if(e.additionalProperties===!1){let i=Object.getOwnPropertyNames(n);return e.required&&e.required.length===r.length&&i.length===r.length?!0:i.every(o=>r.includes(o))}else return typeof e.additionalProperties=="object"?Object.getOwnPropertyNames(n).every(o=>r.includes(o)||Wt(e.additionalProperties,t,n[o])):!0}function bB(e,t,n){return Gu(n)}function SB(e,t,n){if(!jn.IsRecordLike(n)||ce(e.minProperties)&&!(Object.getOwnPropertyNames(n).length>=e.minProperties)||ce(e.maxProperties)&&!(Object.getOwnPropertyNames(n).length<=e.maxProperties))return!1;let[r,i]=Object.entries(e.patternProperties)[0],o=new RegExp(r),s=Object.entries(n).every(([l,p])=>o.test(l)?Wt(i,t,p):!0),a=typeof e.additionalProperties=="object"?Object.entries(n).every(([l,p])=>o.test(l)?!0:Wt(e.additionalProperties,t,p)):!0,c=e.additionalProperties===!1?Object.getOwnPropertyNames(n).every(l=>o.test(l)):!0;return s&&a&&c}function xB(e,t,n){return Wt(Re(e,t),t,n)}function TB(e,t,n){let r=new RegExp(e.source,e.flags);return ce(e.minLength)&&!(n.length>=e.minLength)||ce(e.maxLength)&&!(n.length<=e.maxLength)?!1:r.test(n)}function vB(e,t,n){return!se(n)||ce(e.minLength)&&!(n.length>=e.minLength)||ce(e.maxLength)&&!(n.length<=e.maxLength)||ce(e.pattern)&&!new RegExp(e.pattern).test(n)?!1:ce(e.format)?Cn.Has(e.format)?Cn.Get(e.format)(n):!1:!0}function IB(e,t,n){return In(n)}function EB(e,t,n){return se(n)&&new RegExp(e.pattern).test(n)}function wB(e,t,n){return Wt(Re(e,t),t,n)}function MB(e,t,n){if(!J(n)||e.items===void 0&&n.length!==0||n.length!==e.maxItems)return!1;if(!e.items)return!0;for(let r=0;r<e.items.length;r++)if(!Wt(e.items[r],t,n[r]))return!1;return!0}function OB(e,t,n){return et(n)}function AB(e,t,n){return e.anyOf.some(r=>Wt(r,t,n))}function RB(e,t,n){return!(!Rs(n)||ce(e.maxByteLength)&&!(n.length<=e.maxByteLength)||ce(e.minByteLength)&&!(n.length>=e.minByteLength))}function PB(e,t,n){return!0}function CB(e,t,n){return jn.IsVoidLike(n)}function NB(e,t,n){return Nn.Has(e[R])?Nn.Get(e[R])(e,n):!1}function Wt(e,t,n){let r=ce(e.$id)?[...t,e]:t,i=e;switch(i[R]){case"Any":return tB(i,r,n);case"Array":return nB(i,r,n);case"AsyncIterator":return rB(i,r,n);case"BigInt":return iB(i,r,n);case"Boolean":return oB(i,r,n);case"Constructor":return sB(i,r,n);case"Date":return aB(i,r,n);case"Function":return cB(i,r,n);case"Integer":return uB(i,r,n);case"Intersect":return lB(i,r,n);case"Iterator":return pB(i,r,n);case"Literal":return fB(i,r,n);case"Never":return dB(i,r,n);case"Not":return mB(i,r,n);case"Null":return hB(i,r,n);case"Number":return yB(i,r,n);case"Object":return gB(i,r,n);case"Promise":return bB(i,r,n);case"Record":return SB(i,r,n);case"Ref":return xB(i,r,n);case"RegExp":return TB(i,r,n);case"String":return vB(i,r,n);case"Symbol":return IB(i,r,n);case"TemplateLiteral":return EB(i,r,n);case"This":return wB(i,r,n);case"Tuple":return MB(i,r,n);case"Undefined":return OB(i,r,n);case"Union":return AB(i,r,n);case"Uint8Array":return RB(i,r,n);case"Unknown":return PB(i,r,n);case"Void":return CB(i,r,n);default:if(!Nn.Has(i[R]))throw new Mf(i);return NB(i,r,n)}}function ue(...e){return e.length===3?Wt(e[0],e[1],e[2]):Wt(e[0],[],e[1])}u();u();function kB(e){let t={};for(let n of Object.getOwnPropertyNames(e))t[n]=Pe(e[n]);for(let n of Object.getOwnPropertySymbols(e))t[n]=Pe(e[n]);return t}function DB(e){return e.map(t=>Pe(t))}function UB(e){return e.slice()}function _B(e){return new Date(e.toISOString())}function Pe(e){if(J(e))return DB(e);if(_n(e))return _B(e);if(Ae(e))return kB(e);if(cn(e))return UB(e);if(un(e))return e;throw new Error("ValueClone: Unable to clone value")}var Ln=class extends Z{schema;constructor(t,n){super(n),this.schema=t}};function be(e){return typeof e=="function"?e:Pe(e)}function jB(e,t){return W(e,"default")?be(e.default):{}}function LB(e,t){if(e.uniqueItems===!0&&!W(e,"default"))throw new Ln(e,"Array with the uniqueItems constraint requires a default value");if("contains"in e&&!W(e,"default"))throw new Ln(e,"Array with the contains constraint requires a default value");return"default"in e?be(e.default):e.minItems!==void 0?Array.from({length:e.minItems}).map(n=>Wn(e.items,t)):[]}function BB(e,t){return W(e,"default")?be(e.default):async function*(){}()}function FB(e,t){return W(e,"default")?be(e.default):BigInt(0)}function $B(e,t){return W(e,"default")?be(e.default):!1}function KB(e,t){if(W(e,"default"))return be(e.default);{let n=Wn(e.returns,t);return typeof n=="object"&&!Array.isArray(n)?class{constructor(){for(let[r,i]of Object.entries(n)){let o=this;o[r]=i}}}:class{}}}function zB(e,t){return W(e,"default")?be(e.default):e.minimumTimestamp!==void 0?new Date(e.minimumTimestamp):new Date}function HB(e,t){return W(e,"default")?be(e.default):()=>Wn(e.returns,t)}function GB(e,t){return W(e,"default")?be(e.default):e.minimum!==void 0?e.minimum:0}function qB(e,t){if(W(e,"default"))return be(e.default);{let n=e.allOf.reduce((r,i)=>{let o=Wn(i,t);return typeof o=="object"?{...r,...o}:o},{});if(!ue(e,t,n))throw new Ln(e,"Intersect produced invalid value. Consider using a default value.");return n}}function VB(e,t){return W(e,"default")?be(e.default):function*(){}()}function QB(e,t){return W(e,"default")?be(e.default):e.const}function YB(e,t){if(W(e,"default"))return be(e.default);throw new Ln(e,"Never types cannot be created. Consider using a default value.")}function JB(e,t){if(W(e,"default"))return be(e.default);throw new Ln(e,"Not types must have a default value")}function XB(e,t){return W(e,"default")?be(e.default):null}function ZB(e,t){return W(e,"default")?be(e.default):e.minimum!==void 0?e.minimum:0}function WB(e,t){if(W(e,"default"))return be(e.default);{let n=new Set(e.required),r={};for(let[i,o]of Object.entries(e.properties))n.has(i)&&(r[i]=Wn(o,t));return r}}function eF(e,t){return W(e,"default")?be(e.default):Promise.resolve(Wn(e.item,t))}function tF(e,t){let[n,r]=Object.entries(e.patternProperties)[0];if(W(e,"default"))return be(e.default);if(n===bo||n===Ui)return{};{let i=n.slice(1,n.length-1).split("|"),o={};for(let s of i)o[s]=Wn(r,t);return o}}function nF(e,t){return W(e,"default")?be(e.default):Wn(Re(e,t),t)}function rF(e,t){if(W(e,"default"))return be(e.default);throw new Ln(e,"RegExp types cannot be created. Consider using a default value.")}function iF(e,t){if(e.pattern!==void 0){if(W(e,"default"))return be(e.default);throw new Ln(e,"String types with patterns must specify a default value")}else if(e.format!==void 0){if(W(e,"default"))return be(e.default);throw new Ln(e,"String types with formats must specify a default value")}else return W(e,"default")?be(e.default):e.minLength!==void 0?Array.from({length:e.minLength}).map(()=>" ").join(""):""}function oF(e,t){return W(e,"default")?be(e.default):"value"in e?Symbol.for(e.value):Symbol()}function sF(e,t){if(W(e,"default"))return be(e.default);if(!Sf(e))throw new Ln(e,"Can only create template literals that produce a finite variants. Consider using a default value.");return Pa(e)[0]}function aF(e,t){if(lE++>hF)throw new Ln(e,"Cannot create recursive type as it appears possibly infinite. Consider using a default.");return W(e,"default")?be(e.default):Wn(Re(e,t),t)}function cF(e,t){return W(e,"default")?be(e.default):e.items===void 0?[]:Array.from({length:e.minItems}).map((n,r)=>Wn(e.items[r],t))}function uF(e,t){if(W(e,"default"))return be(e.default)}function lF(e,t){if(W(e,"default"))return be(e.default);if(e.anyOf.length===0)throw new Error("ValueCreate.Union: Cannot create Union with zero variants");return Wn(e.anyOf[0],t)}function pF(e,t){return W(e,"default")?be(e.default):e.minByteLength!==void 0?new Uint8Array(e.minByteLength):new Uint8Array(0)}function fF(e,t){return W(e,"default")?be(e.default):{}}function dF(e,t){if(W(e,"default"))return be(e.default)}function mF(e,t){if(W(e,"default"))return be(e.default);throw new Error("User defined types must specify a default value")}function Wn(e,t){let n=se(e.$id)?[...t,e]:t,r=e;switch(r[R]){case"Any":return jB(r,n);case"Array":return LB(r,n);case"AsyncIterator":return BB(r,n);case"BigInt":return FB(r,n);case"Boolean":return $B(r,n);case"Constructor":return KB(r,n);case"Date":return zB(r,n);case"Function":return HB(r,n);case"Integer":return GB(r,n);case"Intersect":return qB(r,n);case"Iterator":return VB(r,n);case"Literal":return QB(r,n);case"Never":return YB(r,n);case"Not":return JB(r,n);case"Null":return XB(r,n);case"Number":return ZB(r,n);case"Object":return WB(r,n);case"Promise":return eF(r,n);case"Record":return tF(r,n);case"Ref":return nF(r,n);case"RegExp":return rF(r,n);case"String":return iF(r,n);case"Symbol":return oF(r,n);case"TemplateLiteral":return sF(r,n);case"This":return aF(r,n);case"Tuple":return cF(r,n);case"Undefined":return uF(r,n);case"Union":return lF(r,n);case"Uint8Array":return pF(r,n);case"Unknown":return fF(r,n);case"Void":return dF(r,n);default:if(!Nn.Has(r[R]))throw new Ln(r,"Unknown type");return mF(r,n)}}var hF=512,lE=0;function pn(...e){return lE=0,e.length===2?Wn(e[0],e[1]):Wn(e[0],[])}var Qu=class extends Z{schema;constructor(t,n){super(n),this.schema=t}};function yF(e,t,n){if(e[R]==="Object"&&typeof n=="object"&&!ii(n)){let r=e,i=Object.getOwnPropertyNames(n),o=Object.entries(r.properties),[s,a]=[1/o.length,o.length];return o.reduce((c,[l,p])=>{let d=p[R]==="Literal"&&p.const===n[l]?a:0,m=ue(p,t,n[l])?s:0,y=i.includes(l)?s:0;return c+(d+m+y)},0)}else return ue(e,t,n)?1:0}function gF(e,t,n){let[r,i]=[e.anyOf[0],0];for(let o of e.anyOf){let s=yF(o,t,n);s>i&&(r=o,i=s)}return r}function bF(e,t,n){if("default"in e)return typeof n=="function"?e.default:Pe(e.default);{let r=gF(e,t,n);return Cs(r,t,n)}}function SF(e,t,n){return ue(e,t,n)?Pe(n):pn(e,t)}function xF(e,t,n){return ue(e,t,n)?n:pn(e,t)}function TF(e,t,n){if(ue(e,t,n))return Pe(n);let r=J(n)?Pe(n):pn(e,t),i=Qe(e.minItems)&&r.length<e.minItems?[...r,...Array.from({length:e.minItems-r.length},()=>null)]:r,s=(Qe(e.maxItems)&&i.length>e.maxItems?i.slice(0,e.maxItems):i).map(c=>oi(e.items,t,c));if(e.uniqueItems!==!0)return s;let a=[...new Set(s)];if(!ue(e,t,a))throw new Qu(e,"Array cast produced invalid data due to uniqueItems constraint");return a}function vF(e,t,n){if(ue(e,t,n))return pn(e,t);let r=new Set(e.returns.required||[]),i=function(){};for(let[o,s]of Object.entries(e.returns.properties))!r.has(o)&&n.prototype[o]===void 0||(i.prototype[o]=oi(s,t,n.prototype[o]));return i}function IF(e,t,n){let r=pn(e,t),i=Ae(r)&&Ae(n)?{...r,...n}:n;return ue(e,t,i)?i:pn(e,t)}function EF(e,t,n){throw new Qu(e,"Never types cannot be cast")}function wF(e,t,n){if(ue(e,t,n))return n;if(n===null||typeof n!="object")return pn(e,t);let r=new Set(e.required||[]),i={};for(let[o,s]of Object.entries(e.properties))!r.has(o)&&n[o]===void 0||(i[o]=oi(s,t,n[o]));if(typeof e.additionalProperties=="object"){let o=Object.getOwnPropertyNames(e.properties);for(let s of Object.getOwnPropertyNames(n))o.includes(s)||(i[s]=oi(e.additionalProperties,t,n[s]))}return i}function MF(e,t,n){if(ue(e,t,n))return Pe(n);if(n===null||typeof n!="object"||Array.isArray(n)||n instanceof Date)return pn(e,t);let r=Object.getOwnPropertyNames(e.patternProperties)[0],i=e.patternProperties[r],o={};for(let[s,a]of Object.entries(n))o[s]=oi(i,t,a);return o}function OF(e,t,n){return oi(Re(e,t),t,n)}function AF(e,t,n){return oi(Re(e,t),t,n)}function RF(e,t,n){return ue(e,t,n)?Pe(n):J(n)?e.items===void 0?[]:e.items.map((r,i)=>oi(r,t,n[i])):pn(e,t)}function PF(e,t,n){return ue(e,t,n)?Pe(n):bF(e,t,n)}function oi(e,t,n){let r=se(e.$id)?[...t,e]:t,i=e;switch(e[R]){case"Array":return TF(i,r,n);case"Constructor":return vF(i,r,n);case"Intersect":return IF(i,r,n);case"Never":return EF(i,r,n);case"Object":return wF(i,r,n);case"Record":return MF(i,r,n);case"Ref":return OF(i,r,n);case"This":return AF(i,r,n);case"Tuple":return RF(i,r,n);case"Union":return PF(i,r,n);case"Date":case"Symbol":case"Uint8Array":return SF(e,t,n);default:return xF(i,r,n)}}function Cs(...e){return e.length===3?oi(e[0],e[1],e[2]):oi(e[0],[],e[1])}u();u();function CF(e){return fe(e)&&e[R]!=="Unsafe"}function NF(e,t,n){return J(n)?n.map(r=>er(e.items,t,r)):n}function kF(e,t,n){let r=e.unevaluatedProperties,o=e.allOf.map(a=>er(a,t,Pe(n))).reduce((a,c)=>Ct(c)?{...a,...c}:c,{});if(!Ct(n)||!Ct(o)||!fe(r))return o;let s=Dn(e);for(let a of Object.getOwnPropertyNames(n))s.includes(a)||ue(r,t,n[a])&&(o[a]=er(r,t,n[a]));return o}function DF(e,t,n){if(!Ct(n)||J(n))return n;let r=e.additionalProperties;for(let i of Object.getOwnPropertyNames(n)){if(i in e.properties){n[i]=er(e.properties[i],t,n[i]);continue}if(fe(r)&&ue(r,t,n[i])){n[i]=er(r,t,n[i]);continue}delete n[i]}return n}function UF(e,t,n){if(!Ct(n))return n;let r=e.additionalProperties,i=Object.getOwnPropertyNames(n),[o,s]=Object.entries(e.patternProperties)[0],a=new RegExp(o);for(let c of i){if(a.test(c)){n[c]=er(s,t,n[c]);continue}if(fe(r)&&ue(r,t,n[c])){n[c]=er(r,t,n[c]);continue}delete n[c]}return n}function _F(e,t,n){return er(Re(e,t),t,n)}function jF(e,t,n){return er(Re(e,t),t,n)}function LF(e,t,n){if(!J(n))return n;if(et(e.items))return[];let r=Math.min(n.length,e.items.length);for(let i=0;i<r;i++)n[i]=er(e.items[i],t,n[i]);return n.length>r?n.slice(0,r):n}function BF(e,t,n){for(let r of e.anyOf)if(CF(r)&&ue(r,t,n))return er(r,t,n);return n}function er(e,t,n){let r=se(e.$id)?[...t,e]:t,i=e;switch(i[R]){case"Array":return NF(i,r,n);case"Intersect":return kF(i,r,n);case"Object":return DF(i,r,n);case"Record":return UF(i,r,n);case"Ref":return _F(i,r,n);case"This":return jF(i,r,n);case"Tuple":return LF(i,r,n);case"Union":return BF(i,r,n);default:return n}}function Of(...e){return e.length===3?er(e[0],e[1],e[2]):er(e[0],[],e[1])}u();u();function Af(e){return se(e)&&!isNaN(e)&&!isNaN(parseFloat(e))}function FF(e){return Tr(e)||Hr(e)||Qe(e)}function Yu(e){return e===!0||Qe(e)&&e===1||Tr(e)&&e===BigInt("1")||se(e)&&(e.toLowerCase()==="true"||e==="1")}function Ju(e){return e===!1||Qe(e)&&(e===0||Object.is(e,-0))||Tr(e)&&e===BigInt("0")||se(e)&&(e.toLowerCase()==="false"||e==="0"||e==="-0")}function $F(e){return se(e)&&/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)$/i.test(e)}function KF(e){return se(e)&&/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)?$/i.test(e)}function zF(e){return se(e)&&/^\d\d\d\d-[0-1]\d-[0-3]\dt(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)$/i.test(e)}function HF(e){return se(e)&&/^\d\d\d\d-[0-1]\d-[0-3]\dt(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)?$/i.test(e)}function GF(e){return se(e)&&/^\d\d\d\d-[0-1]\d-[0-3]\d$/i.test(e)}function qF(e,t){let n=fE(e);return n===t?n:e}function VF(e,t){let n=dE(e);return n===t?n:e}function QF(e,t){let n=pE(e);return n===t?n:e}function YF(e,t){return se(e.const)?qF(t,e.const):Qe(e.const)?VF(t,e.const):Hr(e.const)?QF(t,e.const):Pe(t)}function pE(e){return Yu(e)?!0:Ju(e)?!1:e}function JF(e){return Af(e)?BigInt(parseInt(e)):Qe(e)?BigInt(e|0):Ju(e)?BigInt(0):Yu(e)?BigInt(1):e}function fE(e){return FF(e)?e.toString():In(e)&&e.description!==void 0?e.description.toString():e}function dE(e){return Af(e)?parseFloat(e):Yu(e)?1:Ju(e)?0:e}function XF(e){return Af(e)?parseInt(e):Qe(e)?e|0:Yu(e)?1:Ju(e)?0:e}function ZF(e){return se(e)&&e.toLowerCase()==="null"?null:e}function WF(e){return se(e)&&e==="undefined"?void 0:e}function e2(e){return _n(e)?e:Qe(e)?new Date(e):Yu(e)?new Date(1):Ju(e)?new Date(0):Af(e)?new Date(parseInt(e)):KF(e)?new Date(`1970-01-01T${e}.000Z`):$F(e)?new Date(`1970-01-01T${e}`):HF(e)?new Date(`${e}.000Z`):zF(e)?new Date(e):GF(e)?new Date(`${e}T00:00:00.000Z`):e}function t2(e,t,n){return(J(n)?n:[n]).map(i=>si(e.items,t,i))}function n2(e,t,n){return JF(n)}function r2(e,t,n){return pE(n)}function i2(e,t,n){return e2(n)}function o2(e,t,n){return XF(n)}function s2(e,t,n){return e.allOf.reduce((r,i)=>si(i,t,r),n)}function a2(e,t,n){return YF(e,n)}function c2(e,t,n){return ZF(n)}function u2(e,t,n){return dE(n)}function l2(e,t,n){if(!Ct(n))return n;let i={};for(let o of Object.keys(n))i[o]=W(e.properties,o)?si(e.properties[o],t,n[o]):n[o];return i}function p2(e,t,n){let r=Object.getOwnPropertyNames(e.patternProperties)[0],i=e.patternProperties[r],o={};for(let[s,a]of Object.entries(n))o[s]=si(i,t,a);return o}function f2(e,t,n){return si(Re(e,t),t,n)}function d2(e,t,n){return fE(n)}function m2(e,t,n){return se(n)||Qe(n)?Symbol(n):n}function h2(e,t,n){return si(Re(e,t),t,n)}function y2(e,t,n){return J(n)&&!et(e.items)?n.map((i,o)=>o<e.items.length?si(e.items[o],t,i):i):n}function g2(e,t,n){return WF(n)}function b2(e,t,n){for(let r of e.anyOf){let i=si(r,t,n);if(ue(r,t,i))return i}return n}function si(e,t,n){let r=se(e.$id)?[...t,e]:t,i=e;switch(e[R]){case"Array":return t2(i,r,n);case"BigInt":return n2(i,r,n);case"Boolean":return r2(i,r,n);case"Date":return i2(i,r,n);case"Integer":return o2(i,r,n);case"Intersect":return s2(i,r,n);case"Literal":return a2(i,r,n);case"Null":return c2(i,r,n);case"Number":return u2(i,r,n);case"Object":return l2(i,r,n);case"Record":return p2(i,r,n);case"Ref":return f2(i,r,n);case"String":return d2(i,r,n);case"Symbol":return m2(i,r,n);case"This":return h2(i,r,n);case"Tuple":return y2(i,r,n);case"Undefined":return g2(i,r,n);case"Union":return b2(i,r,n);default:return n}}function Rf(...e){return e.length===3?si(e[0],e[1],e[2]):si(e[0],[],e[1])}u();u();function xo(e,t){return t===void 0&&"default"in e?Pe(e.default):t}function S2(e){return fe(e)&&e[R]!=="Unsafe"}function Pf(e){return fe(e)&&"default"in e}function x2(e,t,n){let r=xo(e,n);if(!J(r))return r;for(let i=0;i<r.length;i++)r[i]=vr(e.items,t,r[i]);return r}function T2(e,t,n){let r=xo(e,n);return e.allOf.reduce((i,o)=>{let s=vr(o,t,r);return Ct(s)?{...i,...s}:s},{})}function v2(e,t,n){let r=xo(e,n);if(!Ct(r))return r;let i=e.additionalProperties,o=Object.getOwnPropertyNames(e.properties);for(let s of o)Pf(e.properties[s])&&(r[s]=vr(e.properties[s],t,r[s]));if(!Pf(i))return r;for(let s of Object.getOwnPropertyNames(r))o.includes(s)||(r[s]=vr(i,t,r[s]));return r}function I2(e,t,n){let r=xo(e,n);if(!Ct(r))return r;let i=e.additionalProperties,[o,s]=Object.entries(e.patternProperties)[0],a=new RegExp(o);for(let c of Object.getOwnPropertyNames(r))a.test(c)&&Pf(s)&&(r[c]=vr(s,t,r[c]));if(!Pf(i))return r;for(let c of Object.getOwnPropertyNames(r))a.test(c)||(r[c]=vr(i,t,r[c]));return r}function E2(e,t,n){return vr(Re(e,t),t,xo(e,n))}function w2(e,t,n){return vr(Re(e,t),t,n)}function M2(e,t,n){let r=xo(e,n);if(!J(r)||et(e.items))return r;let[i,o]=[e.items,Math.max(e.items.length,r.length)];for(let s=0;s<o;s++)s<i.length&&(r[s]=vr(i[s],t,r[s]));return r}function O2(e,t,n){let r=xo(e,n);for(let i of e.anyOf){let o=vr(i,t,r);if(S2(i)&&ue(i,o))return o}return r}function vr(e,t,n){let r=se(e.$id)?[...t,e]:t,i=e;switch(i[R]){case"Array":return x2(i,r,n);case"Intersect":return T2(i,r,n);case"Object":return v2(i,r,n);case"Record":return I2(i,r,n);case"Ref":return E2(i,r,n);case"This":return w2(i,r,n);case"Tuple":return M2(i,r,n);case"Union":return O2(i,r,n);default:return xo(i,n)}}function Cf(...e){return e.length===3?vr(e[0],e[1],e[2]):vr(e[0],[],e[1])}u();u();u();var Ir={};Ci(Ir,{Delete:()=>R2,Format:()=>Xu,Get:()=>C2,Has:()=>P2,Set:()=>A2,ValuePointerRootDeleteError:()=>kf,ValuePointerRootSetError:()=>Nf});u();var Nf=class extends Z{value;path;update;constructor(t,n,r){super("Cannot set root value"),this.value=t,this.path=n,this.update=r}},kf=class extends Z{value;path;constructor(t,n){super("Cannot delete root value"),this.value=t,this.path=n}};function mE(e){return e.indexOf("~")===-1?e:e.replace(/~1/g,"/").replace(/~0/g,"~")}function*Xu(e){if(e==="")return;let[t,n]=[0,0];for(let r=0;r<e.length;r++)e.charAt(r)==="/"?(r===0||(n=r,yield mE(e.slice(t,n))),t=r+1):n=r;yield mE(e.slice(t))}function A2(e,t,n){if(t==="")throw new Nf(e,t,n);let[r,i,o]=[null,e,""];for(let s of Xu(t))i[s]===void 0&&(i[s]={}),r=i,i=i[s],o=s;r[o]=n}function R2(e,t){if(t==="")throw new kf(e,t);let[n,r,i]=[null,e,""];for(let o of Xu(t)){if(r[o]===void 0||r[o]===null)return;n=r,r=r[o],i=o}if(Array.isArray(n)){let o=parseInt(i);n.splice(o,1)}else delete n[i]}function P2(e,t){if(t==="")return!0;let[n,r,i]=[null,e,""];for(let o of Xu(t)){if(r[o]===void 0)return!1;n=r,r=r[o],i=o}return Object.getOwnPropertyNames(n).includes(i)}function C2(e,t){if(t==="")return e;let n=e;for(let r of Xu(t)){if(n[r]===void 0)return;n=n[r]}return n}var hE=Ne({type:oe("insert"),path:Tn(),value:Xn()}),yE=Ne({type:oe("update"),path:Tn(),value:Xn()}),gE=Ne({type:oe("delete"),path:Tn()}),N2=ve([hE,yE,gE]),Zu=class extends Z{value;constructor(t,n){super(n),this.value=t}},Ns=class extends Zu{value;constructor(t){super(t,"Cannot diff objects with symbol keys"),this.value=t}};function Wu(e,t){return{type:"update",path:e,value:t}}function bE(e,t){return{type:"insert",path:e,value:t}}function SE(e){return{type:"delete",path:e}}function*k2(e,t,n){if(!Ae(n))return yield Wu(e,n);let r=[...globalThis.Object.keys(t),...globalThis.Object.getOwnPropertySymbols(t)],i=[...globalThis.Object.keys(n),...globalThis.Object.getOwnPropertySymbols(n)];for(let o of r){if(In(o))throw new Ns(o);et(n[o])&&i.includes(o)&&(yield Wu(`${e}/${globalThis.String(o)}`,void 0))}for(let o of i)if(!(et(t[o])||et(n[o]))){if(In(o))throw new Ns(o);yield*Df(`${e}/${globalThis.String(o)}`,t[o],n[o])}for(let o of i){if(In(o))throw new Ns(o);et(t[o])&&(yield bE(`${e}/${globalThis.String(o)}`,n[o]))}for(let o of r.reverse()){if(In(o))throw new Ns(o);et(n[o])&&!i.includes(o)&&(yield SE(`${e}/${globalThis.String(o)}`))}}function*D2(e,t,n){if(!J(n))return yield Wu(e,n);for(let r=0;r<Math.min(t.length,n.length);r++)yield*Df(`${e}/${r}`,t[r],n[r]);for(let r=0;r<n.length;r++)r<t.length||(yield bE(`${e}/${r}`,n[r]));for(let r=t.length-1;r>=0;r--)r<n.length||(yield SE(`${e}/${r}`))}function*U2(e,t,n){if(!cn(n)||t.length!==n.length||globalThis.Object.getPrototypeOf(t).constructor.name!==globalThis.Object.getPrototypeOf(n).constructor.name)return yield Wu(e,n);for(let r=0;r<Math.min(t.length,n.length);r++)yield*Df(`${e}/${r}`,t[r],n[r])}function*_2(e,t,n){t!==n&&(yield Wu(e,n))}function*Df(e,t,n){if(Ae(t))return yield*k2(e,t,n);if(J(t))return yield*D2(e,t,n);if(cn(t))return yield*U2(e,t,n);if(un(t))return yield*_2(e,t,n);throw new Zu(t,"Unable to create diff edits for unknown value")}function vg(e,t){return[...Df("",e,t)]}function j2(e){return e.length>0&&e[0].path===""&&e[0].type==="update"}function L2(e){return e.length===0}function Ig(e,t){if(j2(t))return Pe(t[0].value);if(L2(t))return Pe(e);let n=Pe(e);for(let r of t)switch(r.type){case"insert":{Ir.Set(n,r.path,r.value);break}case"update":{Ir.Set(n,r.path,r.value);break}case"delete":{Ir.Delete(n,r.path);break}}return n}u();u();function B2(e,t){if(!Ae(t))return!1;let n=[...Object.keys(e),...Object.getOwnPropertySymbols(e)],r=[...Object.keys(t),...Object.getOwnPropertySymbols(t)];return n.length!==r.length?!1:n.every(i=>To(e[i],t[i]))}function F2(e,t){return _n(t)&&e.getTime()===t.getTime()}function $2(e,t){return!J(t)||e.length!==t.length?!1:e.every((n,r)=>To(n,t[r]))}function K2(e,t){return!cn(t)||e.length!==t.length||Object.getPrototypeOf(e).constructor.name!==Object.getPrototypeOf(t).constructor.name?!1:e.every((n,r)=>To(n,t[r]))}function z2(e,t){return e===t}function To(e,t){if(Ae(e))return B2(e,t);if(_n(e))return F2(e,t);if(cn(e))return K2(e,t);if(J(e))return $2(e,t);if(un(e))return z2(e,t);throw new Error("ValueEquals: Unable to compare value")}u();u();var el=class extends Z{constructor(t){super(t)}};function H2(e,t,n,r){if(!Ae(n))Ir.Set(e,t,Pe(r));else{let i=Object.getOwnPropertyNames(n),o=Object.getOwnPropertyNames(r);for(let s of i)o.includes(s)||delete n[s];for(let s of o)i.includes(s)||(n[s]=null);for(let s of o)Eg(e,`${t}/${s}`,n[s],r[s])}}function G2(e,t,n,r){if(!J(n))Ir.Set(e,t,Pe(r));else{for(let i=0;i<r.length;i++)Eg(e,`${t}/${i}`,n[i],r[i]);n.splice(r.length)}}function q2(e,t,n,r){if(cn(n)&&n.length===r.length)for(let i=0;i<n.length;i++)n[i]=r[i];else Ir.Set(e,t,Pe(r))}function V2(e,t,n,r){n!==r&&Ir.Set(e,t,r)}function Eg(e,t,n,r){if(J(r))return G2(e,t,n,r);if(cn(r))return q2(e,t,n,r);if(Ae(r))return H2(e,t,n,r);if(un(r))return V2(e,t,n,r)}function xE(e){return cn(e)||un(e)}function Q2(e,t){return Ae(e)&&J(t)||J(e)&&Ae(t)}function wg(e,t){if(xE(e)||xE(t))throw new el("Only object and array types can be mutated at the root level");if(Q2(e,t))throw new el("Cannot assign due type mismatch of assignable values");Eg(e,"",e,t)}u();u();var tl=class extends Z{schema;value;error;constructor(t,n,r){super("Unable to decode value as it does not match the expected schema"),this.schema=t,this.value=n,this.error=r}},Uf=class extends Z{schema;path;value;error;constructor(t,n,r,i){super(i instanceof Error?i.message:"Unknown error"),this.schema=t,this.path=n,this.value=r,this.error=i}};function st(e,t,n){try{return Ve(e)?e[mt].Decode(n):n}catch(r){throw new Uf(e,t,n,r)}}function Y2(e,t,n,r){return J(r)?st(e,n,r.map((i,o)=>ai(e.items,t,`${n}/${o}`,i))):st(e,n,r)}function J2(e,t,n,r){if(!Ae(r)||un(r))return st(e,n,r);let i=Tf(e),o=i.map(p=>p[0]),s={...r};for(let[p,d]of i)p in s&&(s[p]=ai(d,t,`${n}/${p}`,s[p]));if(!Ve(e.unevaluatedProperties))return st(e,n,s);let a=Object.getOwnPropertyNames(s),c=e.unevaluatedProperties,l={...s};for(let p of a)o.includes(p)||(l[p]=st(c,`${n}/${p}`,l[p]));return st(e,n,l)}function X2(e,t,n,r){return st(e,n,ai(e.not,t,n,r))}function Z2(e,t,n,r){if(!Ae(r))return st(e,n,r);let i=Dn(e),o={...r};for(let l of i)l in o&&(o[l]=ai(e.properties[l],t,`${n}/${l}`,o[l]));if(!fe(e.additionalProperties))return st(e,n,o);let s=Object.getOwnPropertyNames(o),a=e.additionalProperties,c={...o};for(let l of s)i.includes(l)||(c[l]=st(a,`${n}/${l}`,c[l]));return st(e,n,c)}function W2(e,t,n,r){if(!Ae(r))return st(e,n,r);let i=Object.getOwnPropertyNames(e.patternProperties)[0],o=new RegExp(i),s={...r};for(let p of Object.getOwnPropertyNames(r))o.test(p)&&(s[p]=ai(e.patternProperties[i],t,`${n}/${p}`,s[p]));if(!fe(e.additionalProperties))return st(e,n,s);let a=Object.getOwnPropertyNames(s),c=e.additionalProperties,l={...s};for(let p of a)o.test(p)||(l[p]=st(c,`${n}/${p}`,l[p]));return st(e,n,l)}function e$(e,t,n,r){let i=Re(e,t);return st(e,n,ai(i,t,n,r))}function t$(e,t,n,r){let i=Re(e,t);return st(e,n,ai(i,t,n,r))}function n$(e,t,n,r){return J(r)&&J(e.items)?st(e,n,e.items.map((i,o)=>ai(i,t,`${n}/${o}`,r[o]))):st(e,n,r)}function r$(e,t,n,r){for(let i of e.anyOf){if(!ue(i,t,r))continue;let o=ai(i,t,n,r);return st(e,n,o)}return st(e,n,r)}function ai(e,t,n,r){let i=typeof e.$id=="string"?[...t,e]:t,o=e;switch(e[R]){case"Array":return Y2(o,i,n,r);case"Intersect":return J2(o,i,n,r);case"Not":return X2(o,i,n,r);case"Object":return Z2(o,i,n,r);case"Record":return W2(o,i,n,r);case"Ref":return e$(o,i,n,r);case"Symbol":return st(o,n,r);case"This":return t$(o,i,n,r);case"Tuple":return n$(o,i,n,r);case"Union":return r$(o,i,n,r);default:return st(o,n,r)}}function Mg(e,t,n){return ai(e,t,"",n)}u();var nl=class extends Z{schema;value;error;constructor(t,n,r){super("The encoded value does not match the expected schema"),this.schema=t,this.value=n,this.error=r}},_f=class extends Z{schema;path;value;error;constructor(t,n,r,i){super(`${i instanceof Error?i.message:"Unknown error"}`),this.schema=t,this.path=n,this.value=r,this.error=i}};function Kt(e,t,n){try{return Ve(e)?e[mt].Encode(n):n}catch(r){throw new _f(e,t,n,r)}}function i$(e,t,n,r){let i=Kt(e,n,r);return J(i)?i.map((o,s)=>ci(e.items,t,`${n}/${s}`,o)):i}function o$(e,t,n,r){let i=Kt(e,n,r);if(!Ae(r)||un(r))return i;let o=Tf(e),s=o.map(d=>d[0]),a={...i};for(let[d,m]of o)d in a&&(a[d]=ci(m,t,`${n}/${d}`,a[d]));if(!Ve(e.unevaluatedProperties))return Kt(e,n,a);let c=Object.getOwnPropertyNames(a),l=e.unevaluatedProperties,p={...a};for(let d of c)s.includes(d)||(p[d]=Kt(l,`${n}/${d}`,p[d]));return p}function s$(e,t,n,r){return Kt(e.not,n,Kt(e,n,r))}function a$(e,t,n,r){let i=Kt(e,n,r);if(!Ae(i))return i;let o=Dn(e),s={...i};for(let p of o)p in s&&(s[p]=ci(e.properties[p],t,`${n}/${p}`,s[p]));if(!fe(e.additionalProperties))return s;let a=Object.getOwnPropertyNames(s),c=e.additionalProperties,l={...s};for(let p of a)o.includes(p)||(l[p]=Kt(c,`${n}/${p}`,l[p]));return l}function c$(e,t,n,r){let i=Kt(e,n,r);if(!Ae(r))return i;let o=Object.getOwnPropertyNames(e.patternProperties)[0],s=new RegExp(o),a={...i};for(let d of Object.getOwnPropertyNames(r))s.test(d)&&(a[d]=ci(e.patternProperties[o],t,`${n}/${d}`,a[d]));if(!fe(e.additionalProperties))return Kt(e,n,a);let c=Object.getOwnPropertyNames(a),l=e.additionalProperties,p={...a};for(let d of c)s.test(d)||(p[d]=Kt(l,`${n}/${d}`,p[d]));return p}function u$(e,t,n,r){let i=Re(e,t),o=ci(i,t,n,r);return Kt(e,n,o)}function l$(e,t,n,r){let i=Re(e,t),o=ci(i,t,n,r);return Kt(e,n,o)}function p$(e,t,n,r){let i=Kt(e,n,r);return J(e.items)?e.items.map((o,s)=>ci(o,t,`${n}/${s}`,i[s])):[]}function f$(e,t,n,r){for(let i of e.anyOf){if(!ue(i,t,r))continue;let o=ci(i,t,n,r);return Kt(e,n,o)}for(let i of e.anyOf){let o=ci(i,t,n,r);if(ue(e,t,o))return Kt(e,n,o)}return Kt(e,n,r)}function ci(e,t,n,r){let i=typeof e.$id=="string"?[...t,e]:t,o=e;switch(e[R]){case"Array":return i$(o,i,n,r);case"Intersect":return o$(o,i,n,r);case"Not":return s$(o,i,n,r);case"Object":return a$(o,i,n,r);case"Record":return c$(o,i,n,r);case"Ref":return u$(o,i,n,r);case"This":return l$(o,i,n,r);case"Tuple":return p$(o,i,n,r);case"Union":return f$(o,i,n,r);default:return Kt(o,n,r)}}function Og(e,t,n){return ci(e,t,"",n)}u();function d$(e,t){return Ve(e)||zt(e.items,t)}function m$(e,t){return Ve(e)||zt(e.items,t)}function h$(e,t){return Ve(e)||zt(e.returns,t)||e.parameters.some(n=>zt(n,t))}function y$(e,t){return Ve(e)||zt(e.returns,t)||e.parameters.some(n=>zt(n,t))}function g$(e,t){return Ve(e)||Ve(e.unevaluatedProperties)||e.allOf.some(n=>zt(n,t))}function b$(e,t){return Ve(e)||zt(e.items,t)}function S$(e,t){return Ve(e)||zt(e.not,t)}function x$(e,t){return Ve(e)||Object.values(e.properties).some(n=>zt(n,t))||fe(e.additionalProperties)&&zt(e.additionalProperties,t)}function T$(e,t){return Ve(e)||zt(e.item,t)}function v$(e,t){let n=Object.getOwnPropertyNames(e.patternProperties)[0],r=e.patternProperties[n];return Ve(e)||zt(r,t)||fe(e.additionalProperties)&&Ve(e.additionalProperties)}function I$(e,t){return Ve(e)?!0:zt(Re(e,t),t)}function E$(e,t){return Ve(e)?!0:zt(Re(e,t),t)}function w$(e,t){return Ve(e)||!et(e.items)&&e.items.some(n=>zt(n,t))}function M$(e,t){return Ve(e)||e.anyOf.some(n=>zt(n,t))}function zt(e,t){let n=se(e.$id)?[...t,e]:t,r=e;if(e.$id&&Ag.has(e.$id))return!1;switch(e.$id&&Ag.add(e.$id),e[R]){case"Array":return d$(r,n);case"AsyncIterator":return m$(r,n);case"Constructor":return h$(r,n);case"Function":return y$(r,n);case"Intersect":return g$(r,n);case"Iterator":return b$(r,n);case"Not":return S$(r,n);case"Object":return x$(r,n);case"Promise":return T$(r,n);case"Record":return v$(r,n);case"Ref":return I$(r,n);case"This":return E$(r,n);case"Tuple":return w$(r,n);case"Union":return M$(r,n);default:return Ve(e)}}var Ag=new Set;function jf(e,t){return Ag.clear(),zt(e,t)}u();var ks={};Ci(ks,{Cast:()=>O$,Check:()=>Rg,Clean:()=>R$,Clone:()=>C$,Convert:()=>P$,Create:()=>A$,Decode:()=>N$,Default:()=>k$,Diff:()=>_$,Encode:()=>D$,Equal:()=>U$,Errors:()=>Pg,Hash:()=>j$,Mutate:()=>B$,Patch:()=>L$});u();function O$(...e){return Cs.apply(Cs,e)}function A$(...e){return pn.apply(pn,e)}function Rg(...e){return ue.apply(ue,e)}function R$(...e){return Of.apply(Of,e)}function P$(...e){return Rf.apply(Rf,e)}function C$(e){return Pe(e)}function N$(...e){let[t,n,r]=e.length===3?[e[0],e[1],e[2]]:[e[0],[],e[1]];if(!Rg(t,n,r))throw new tl(t,r,Pg(t,n,r).First());return jf(t,n)?Mg(t,n,r):r}function k$(...e){return Cf.apply(Cf,e)}function D$(...e){let[t,n,r]=e.length===3?[e[0],e[1],e[2]]:[e[0],[],e[1]],i=jf(t,n)?Og(t,n,r):r;if(!Rg(t,n,i))throw new nl(t,i,Pg(t,n,i).First());return i}function Pg(...e){return _a.apply(_a,e)}function U$(e,t){return To(e,t)}function _$(e,t){return vg(e,t)}function j$(e){return Ps(e)}function L$(e,t){return Ig(e,t)}function B$(e,t){wg(e,t)}u();u();u();var YE=Q(DE()),Uz=Q(QE()),Ba=["/","."],_z=new RegExp(`[${Ba.join("")}]`);function vo(e,t=Ba){if(!e||e.length===0)return[];if(Array.isArray(e))return e;if(t.some(r=>e===r))return[];t.some(r=>e.startsWith(r))&&(e=e.slice(1));let n=t===Ba?_z:new RegExp(`[${t.join("")}]`);return e.split(n).filter(Boolean)}function JE(e){return!e||e.length===0?"":typeof e=="string"?vo(e).join("/"):e.join("/")}function Ht(e,t,n=Ba){let r=vo(t,n);return r.length===0?e:(0,YE.default)(e,r)}u();var ol=class e{root={hasValue:!1,children:new Map};set(t,n){let r=this.root;for(let i of t){if(typeof i!="string"&&typeof i!="number")throw new Error("Key must be a string or number");r.children.has(i)||r.children.set(i,{hasValue:!1,children:new Map}),r=r.children.get(i)}r.hasValue=!0,r.value=n}get(t){let n=this.root;for(let r of t){if(!n.children.has(r))return;n=n.children.get(r)}return n.hasValue?n.value:void 0}has(t){let n=this.root;for(let r of t){if(!n.children.has(r))return!1;n=n.children.get(r)}return n.hasValue}delete(t){if(t.length===0)return this.root.hasValue?(this.root.hasValue=!1,delete this.root.value,!0):!1;let n=[],r=this.root;for(let i=0;i<t.length;i++){let o=t[i];if(!r.children.has(o))return!1;n.push({parent:r,key:o}),r=r.children.get(o)}if(!r.hasValue)return!1;if(r.hasValue=!1,delete r.value,r.children.size===0)for(let i=n.length-1;i>=0;i--){let{parent:o,key:s}=n[i],a=o.children.get(s);if(!a.hasValue&&a.children.size===0)o.children.delete(s);else break}return!0}clear(){this.root={hasValue:!1,children:new Map}}getAllPaths(){let t=[],n=(r,i)=>{r.hasValue&&t.push([...i]);for(let[o,s]of r.children)n(s,[...i,o])};return n(this.root,[]),t}entries(){let t=[],n=(r,i)=>{r.hasValue&&r.value!==void 0&&t.push([[...i],r.value]);for(let[o,s]of r.children)n(s,[...i,o])};return n(this.root,[]),t}sortedEntries(){return this.entries().sort((t,n)=>{let r=t[0].join("/"),i=n[0].join("/");return r.localeCompare(i)})}get size(){let t=0,n=r=>{r.hasValue&&t++;for(let i of r.children.values())n(i)};return n(this.root),t}equals(t,n){if(this.size!==t.size)return!1;for(let[r,i]of this.entries()){let o=t.get(r);if(o===void 0||!n(i,o,{path:r}))return!1}return!0}clone(){let t=new e;for(let[n,r]of this.entries())t.set(n,r);return t}hasSamePaths(t){let n=this.getAllPaths(),r=t.getAllPaths();if(n.length!==r.length)return!1;let i=new Set(n.map(s=>s.join("/"))),o=new Set(r.map(s=>s.join("/")));for(let s of i)if(!o.has(s))return!1;return!0}};u();u();var Ee=class{constructor(t={}){this.bufferEventsIfNoListeners=t.bufferEventsIfNoListeners??!1}bufferEventsIfNoListeners;listeners=[];addListener=(t,n={})=>{if(n.once){let r=(...i)=>(this.removeListener(r),t(...i));this.listeners.push(r)}else this.listeners.push(t);if(this.bufferedEvents.length>0){let r=this.bufferedEvents;this.bufferedEvents=[],r.forEach(i=>{this.emit(...i)})}return()=>this.removeListener(t)};removeListener=t=>{let n=this.listeners.indexOf(t);n!==-1&&this.listeners.splice(n,1)};emit=(...t)=>{if(this.bufferEventsIfNoListeners&&this.listeners.length===0){this.bufferedEvents.push(t);return}this.listeners.forEach(n=>n(...t))};bufferedEvents=[]};u();function XE(e,{delay:t,setTimeout:n=globalThis.setTimeout,clearTimeout:r=globalThis.clearTimeout}){let i=null,o,s=()=>!!i,a=()=>{i&&(r(i),i=null)},c=()=>{i&&(a(),e(...o))};function l(...d){i&&r(i),o=d,i=n(()=>{e(...o),i=null},t)}return Object.assign(l,{cancel:a,flush:c,isPending:s})}u();function Fa(e,t){if(!e||typeof e!="object")return e;if(Array.isArray(e))return e.map(r=>typeof r=="object"&&r!==null?Fa(r,t):r);let n={};for(let r in t){let i=t[r];if(i===!0)n[r]=e[r];else if(typeof i=="object"&&i!==null&&"$select"in i){let o=e[r];o&&typeof o=="object"&&(Array.isArray(o)?n[r]=o.map(s=>typeof s=="object"&&s!==null?Fa(s,i.$select):s):n[r]=Fa(o,i.$select))}}return n}u();function Ls(e,t,n,r=Ba){let i=vo(t,r);return i.length===0?n:jz(e,i,n)}function jz(e,t,n){if(!t.length)return n;if(!e||typeof e!="object")return e;let[r,...i]=t;if(Array.isArray(e)){let a=typeof r=="number"?r:parseInt(r,10);if(!Number.isInteger(a))return e;let c=e[a],l=i.length?Ls(c,i,n):n;if(c===l)return e;let p=[...e];return p[a]=l,p}let o=e[r],s=i.length?Ls(o,i,n):n;return o===s?e:{...e,[r]:s}}u();function $g(e,t){if(!e||typeof e!="object"||Array.isArray(e))return e;let n=!1,r={...e};for(let i in t){let o=t[i],s=e[i];if(o!==void 0)if(typeof o=="object"&&o!==null&&"$set"in o&&typeof o.$set=="object"&&o.$set!==null){let a=$g(s,o.$set);a!==s&&(r[i]=a,n=!0)}else s!==o&&(r[i]=o,n=!0)}return n?r:e}u();function ZE(e,{delay:t,setTimeout:n=globalThis.setTimeout,now:r=Date.now}){let i=null,o=0;return function(...a){let c=r(),l=c-o;i||(l>=t?(o=c,e(...a)):i=n(()=>{o=r(),e(...a),i=null},t-l))}}function WE(e,t){return e===t}var _=class e{emitter=new Ee;value;isEqual;get listeners(){return this.emitter.listeners}version=0;constructor(t,n={}){this.value=t,this.isEqual=n.isEqual??WE}listenKeys={};get=t=>Ht(this.value,t);setFn=(...t)=>{if(t.length===2){let[n,r]=t,i=vo(n),o=Ls(this.value,i,r(this.get(n)));this.set(o)}else{let[n]=t;this.set(n(this.get()))}};set=(...t)=>{if(t.length===2){let[n,r]=t,i=vo(n);if(this.isEqual(this.value,r,{path:i}))return;let o=Ls(this.value,i,r);return this.set(o)}else{let[n]=t;if(this.isEqual(this.value,n,{path:[]}))return;this.value=n,this.version++,this.emitter.emit(n)}};setProperties=t=>{this.set($g(this.value,t))};next=this.set;subscriptionEmitter=new Ee;subscribe=(...t)=>{if(t.length===1){let[c]=t;c(this.value);let l=this.emitter.addListener(c);return this.subscriptionEmitter.emit("add"),()=>{l(),this.subscriptionEmitter.emit("remove")}}let[n,r]=t,i=vo(n);if(i.length===0){r(this.value);let c=this.emitter.addListener(r);return this.subscriptionEmitter.emit("add"),()=>{c(),this.subscriptionEmitter.emit("remove")}}let o=JE(i),s=this.get(n);r(s),this.listenKeys[o]=this.listenKeys[o]??{prev:s,version:this.version,callbacks:[]},this.listenKeys[o].callbacks.push(r);let a=this.emitter.addListener(()=>{let c=this.listenKeys[o].prev,l=this.get(n);this.listenKeys[o].version!==this.version&&!this.isEqual(l,c,{path:i})&&(this.listenKeys[o].callbacks.forEach(p=>{p(l)}),this.listenKeys[o].prev=l)});return this.subscriptionEmitter.emit("add"),()=>{a(),this.subscriptionEmitter.emit("remove"),this.listenKeys[o].callbacks=this.listenKeys[o].callbacks.filter(c=>c!==r),this.listenKeys[o].callbacks.length===0&&delete this.listenKeys[o]}};static from(t,n){let r=new e(t.get(),n);return t.subscribe(()=>{r.set(t.get())}),r}map(t,n){return e.from({get:()=>t(this.get()),subscribe:this.subscribe},n)}select(t,n){let r=new e(Fa(this.get(),t),n),i=n?.isEqual??WE,o=(p,d=[],m)=>{let y=[],S=m??this.get(d);if(d.length===0&&Array.isArray(S)){for(let T=0;T<S.length;T++){let E=o(p,[T],S[T]);y.push(...E)}return y}for(let T in p){let E=p[T],b=[...d,T],f=S?.[T];if(E===!0)y.push(b);else if(typeof E=="object"&&E!==null&&"$select"in E)if(Array.isArray(f))for(let g=0;g<f.length;g++){let v=o(E.$select,[...b,g],f[g]);y.push(...v)}else{let g=o(E.$select,b,f);y.push(...g)}}return y},s=null,a=new ol,c=()=>{let p=new ol,d=o(t);for(let m of d){let y=this.get(m);p.set(m,y)}return p};return(()=>{s||(a=c(),s=this.subscribe(()=>{let p=c();if(!p.equals(a,i)){a=p;let d=Fa(this.get(),t);r.set(d)}}))})(),r}observePath(t,n){let r=new e(this.get(t),n);return this.subscribe(t,i=>{r.set(i)}),r}readOnly(){return e.from({get:()=>this.get(),subscribe:this.subscribe},{isEqual:this.isEqual})}waitFor(t){return this.isEqual(this.value,t,{path:[]})?Promise.resolve():new Promise(n=>{this.emitter.addListener(r=>{this.isEqual(r,t,{path:[]})&&n()})})}throttle(t,n){let r=new e(this.get(),n),o=ZE(()=>{r.set(this.get())},typeof t=="number"?{delay:t}:t);return this.subscribe(()=>{o()}),r}debounce(t,n){let r=new Kg(this.get(),n),o=XE(()=>{r.set(this.get())},typeof t=="number"?{delay:t}:t);r.cancel=o.cancel,r.flush=o.flush,r.isPending=o.isPending;let s=!1;return this.subscribe(()=>{s?o():(s=!0,r.set(this.get()))}),r}static combine(t,n,r){return e.from({get:()=>n(t.map(i=>i?.get())),subscribe:i=>{t.forEach(o=>o?.subscribe(i))}},r)}},Kg=class extends _{cancel=()=>{};flush=()=>{};isPending=()=>!1};var sl=class{constructor(t){this.sendMessage=t}activityEventStreams={};subscribe(t){let n=t==="all"?"all":`resource-${t.resourceId}`;if(!this.activityEventStreams[n]){this.activityEventStreams[n]={activityEvents:new _([]),isInitialized:new _(!1)};let r=void 0;this.sendMessage?.({type:"activityEvents.subscribe",streamId:n,...r&&{cursor:r}})}return n}getStream(t){return this.activityEventStreams[t]?.activityEvents}unsubscribe(t){this.sendMessage?.({type:"activityEvents.unsubscribe",streamId:t}),delete this.activityEventStreams[t]}setStreamEvents(t,n){this.activityEventStreams[t]||(this.activityEventStreams[t]={activityEvents:new _([]),isInitialized:new _(!1)});let r=this.activityEventStreams[t].activityEvents.get(),i=Lz(r,n);this.activityEventStreams[t].activityEvents.set(i),this.activityEventStreams[t].isInitialized.set(!0)}};function Lz(e,t){let n=new Map,r=i=>i&&typeof i=="object"?i.id:void 0;for(let i of[...t||[],...e||[]]){let o=r(i);typeof o=="string"&&n.set(o,i)}return Array.from(n.values())}u();u();u();u();u();var lt=e=>x.Union([x.Null(),e]);var Bz=x.Object({id:x.String(),name:lt(x.String()),email:lt(x.String()),image:lt(x.String())}),Fz=x.Object({id:x.String(),name:x.String()}),$z=x.Object({id:x.String(),name:lt(x.String())}),Kz=x.Object({id:x.String(),path:x.String(),type:x.Union([x.Literal("asset"),x.Literal("file"),x.Literal("fileVersion"),x.Literal("directory"),x.Literal("resource")])}),zz=x.Object({id:x.String(),subdomain:lt(x.String())}),xye=x.Object({id:x.String(),createdAt:x.String(),actorId:lt(x.String()),actor:x.Optional(Bz),type:x.Union([x.Literal("file"),x.Literal("resource"),x.Literal("site"),x.Literal("snapshot"),x.Literal("restore")]),workspaceId:lt(x.String()),workspace:x.Optional(Fz),fileId:lt(x.String()),file:x.Optional($z),fileVersionId:lt(x.String()),resourceId:lt(x.String()),resource:x.Optional(Kz),siteId:lt(x.String()),site:x.Optional(zz),previousData:lt(x.Any()),currentData:lt(x.Any()),metadata:lt(x.Any()),userAgent:lt(x.String())});u();var Hz=x.Union([x.Literal("immutable"),x.Literal("mutable")]),wye=x.Object({id:x.String(),stableId:x.String(),url:x.String(),createdAt:x.String(),size:x.Number(),contentType:x.Optional(x.String()),width:x.Union([x.Null(),x.Number()]),height:x.Union([x.Null(),x.Number()]),userId:x.Union([x.Null(),x.String()]),mode:x.Optional(Hz),version:x.Optional(x.Number())});u();var ew=new Map([[R,"_kind"],[Pn,"_hint"]]),Gz=new Map(Array.from(ew.entries()).map(([e,t])=>[t,e]));function Io(e,t=ew){function n(r){if(Array.isArray(r))return r.map(n);if(typeof r=="object"&&r!==null){let i={};for(let o in r)if(Object.prototype.hasOwnProperty.call(r,o)){let s=r[o];i[o]=n(s)}for(let o of Object.getOwnPropertySymbols(r)){let s=t.get(o);s&&(i[s]=n(r[o]))}return i}return r}return n(e)}function Eo(e,t=Gz){function n(r){if(Array.isArray(r))return r.map(n);if(typeof r=="object"&&r!==null){let i={};for(let o in r)if(Object.prototype.hasOwnProperty.call(r,o)){let s=r[o],a=t.get(o);a?i[a]=n(s):i[o]=n(s)}return i}return r}return n(e)}u();var qz=x.Union([x.Literal("utf-8"),x.Literal("base64")]),Vz=x.Object({id:x.String({format:"uuid",default:""}),kind:x.Literal("folder")}),Qz=x.Object({id:x.String({format:"uuid",default:""}),kind:x.Literal("asset"),assetId:x.String()}),Yz=x.Object({id:x.String({format:"uuid",default:""}),kind:x.Literal("file"),content:x.String(),encoding:qz}),Jz=x.Object({id:x.String({format:"uuid",default:""}),kind:x.Literal("noyaFile"),fileId:x.String()}),Xz=x.Union([Vz,Qz,Yz,Jz],{discriminator:"kind"}),Dye=x.Record(x.String(),Xz);u();var Bye=x.Object({owner:x.Optional(x.String()),name:x.Optional(x.String()),ref:x.Optional(x.String()),path:x.Optional(x.String())}),Fye=x.Object({id:x.Optional(x.String())});u();u();u();var Hf=x.Recursive(e=>x.Union([x.Object({type:x.Literal("string"),default:x.Optional(x.String()),_kind:x.Literal("String")}),x.Object({type:x.Literal("number"),default:x.Optional(x.Number()),minimum:x.Optional(x.Number()),maximum:x.Optional(x.Number()),_kind:x.Literal("Number")}),x.Object({type:x.Literal("boolean"),default:x.Optional(x.Boolean()),_kind:x.Literal("Boolean")}),x.Object({type:x.Literal("null"),_kind:x.Literal("Null")}),x.Object({type:x.Literal("array"),items:e,_kind:x.Literal("Array")}),x.Object({type:x.Literal("object"),properties:x.Record(x.String(),e),required:x.Optional(x.Array(x.String())),_kind:x.Literal("Object")})],{discriminator:"type"}),{$id:"jsonSchema"});function Gf(e){return x.Union([e,x.Null()],{default:null})}var zg={id:x.String({format:"uuid",default:""}),stableId:x.String({format:"uuid",default:""}),name:x.String(),description:Gf(x.String()),required:x.Boolean({default:!1})},Zz=x.Object({...zg,kind:x.Literal("file"),toolId:Gf(x.String())}),Wz=x.Object({...zg,kind:x.Literal("data"),schema:Gf(Hf)}),eH=x.Object({...zg,kind:x.Literal("secret"),authProvider:x.Optional(x.Union([x.Null(),x.Literal("github"),x.Literal("figma")],{default:null})),authScope:x.Optional(Gf(x.String()))}),Hg=x.Union([Zz,Wz,eH],{discriminator:"kind"}),tw={id:x.String({format:"uuid",default:""}),stableId:x.String({format:"uuid",default:""}),order:x.Number()},tH=x.Object({...tw,kind:x.Literal("script"),location:x.Union([x.Literal("state"),x.Literal("url")]),value:x.String()}),nH=x.Object({...tw,kind:x.Literal("jsonPointer"),value:x.String()}),tge=x.Union([tH,nH],{discriminator:"kind"});u();u();var Nw=Q(ad()),s3=(0,Nw.defineTree)(e=>w.IsUnion(e)?e.anyOf:w.IsObject(e)?Object.values(e.properties):w.IsArray(e)?[e.items]:[]).withOptions({getLabel(e){return e[R]??"<UnknownKind>"}});function Er(e){return e?s3.flat(e).flatMap(t=>t.$id?[t]:[]):[]}function Fs(e){return Array.isArray(e)?e:Object.values(e)}u();var Ga={id:x.String(),stableId:x.String(),path:x.String(),createdAt:x.String(),updatedAt:x.String(),accessibleByFileId:lt(x.String()),accessibleByFile:x.Optional(x.Object({id:x.String(),name:x.String(),toolId:x.String()})),accessibleByFileVersionId:lt(x.String()),url:x.Optional(x.String())},a3=x.Object({content:x.String(),contentType:x.String(),encoding:x.Union([x.Literal("utf-8"),x.Literal("base64")])}),c3=x.Object({...Ga,type:x.Literal("asset"),assetId:x.String()}),u3=x.Object({...Ga,type:x.Literal("asset"),assetId:x.Optional(x.String()),asset:x.Optional(a3)}),Dw=x.Object({...Ga,type:x.Literal("file"),fileId:x.String()}),Uw=x.Object({...Ga,type:x.Literal("directory")}),_w=x.Object({...Ga,type:x.Literal("resource"),fileId:x.String(),resourceId:x.String()}),mbe=x.Union([c3,Dw,Uw,_w],{discriminator:"type"}),hbe=x.Union([u3,Dw,Uw,_w],{discriminator:"type"});var ybe=x.Object({...Ga,type:x.Union([x.Literal("asset"),x.Literal("file"),x.Literal("directory"),x.Literal("resource")]),assetId:lt(x.String()),fileId:lt(x.String()),resourceId:lt(x.String())});function kw({oldResource:e,newResource:t,oldPath:n,newPath:r}){let i={};r!==void 0&&(n??e.path)!==r&&(i.path=r);let o=e.type==="asset"?e.assetId:void 0,s=t.type==="asset"?t.assetId:void 0;return o!==s&&(i.assetId=s),t.type==="asset"&&t.asset!==void 0&&(i.asset=t.asset),i}function l3(e,t){return new Set([...e].filter(n=>t.has(n)))}function jw(e,t,n){let r=new Map(Object.entries(e).map(([E,b])=>[b[n],E])),i=new Map(Object.entries(t).map(([E,b])=>[b[n],E])),o=new Set(Object.values(e).map(E=>E[n])),s=new Set(Object.values(t).map(E=>E[n])),a=l3(o,s),c=Object.values(t).filter(E=>!o.has(E[n])),l=Object.values(e).filter(E=>!s.has(E[n])),p=[...a].flatMap(E=>{let b=Object.values(e).find(M=>M[n]===E),f=Object.values(t).find(M=>M[n]===E);if(!b||!f)return[];let g=r.get(E),v=i.get(E),I=kw({oldResource:b,newResource:f,oldPath:g,newPath:v});return Object.keys(I).length===0?[]:[{id:E,stableId:f.stableId,...I}]}),d=new Map(l.map(E=>[E.path,E])),m=new Set,y=[];for(let E of c){let b=d.get(E.path);if(!b||b.type!==E.type||b[n]===E[n])continue;m.add(E.path);let f=kw({oldResource:b,newResource:E,oldPath:b.path,newPath:E.path});if(Object.keys(f).length===0)continue;let g=b[n];y.push({id:g,stableId:b.stableId,...f})}let S=c.filter(E=>!m.has(E.path)),T=l.filter(E=>!m.has(E.path));return{addedResources:S,removedResources:T,modifiedResources:[...p,...y]}}u();var F3=Q(Qw()),$3=Q(ad());function K3(e){return/^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$/.test(e)}Cn.Set("color",()=>!0);Cn.Set("uuid",K3);u();u();function z3(e){let t=atob(e),n=t.length,r=new Uint8Array(n);for(let i=0;i<n;i++)r[i]=t.charCodeAt(i);return r}function H3(e){let t=new Uint8Array(e),n="",r=t.byteLength;for(let i=0;i<r;i++)n+=String.fromCharCode(t[i]);return globalThis.btoa(n)}var en={encode:H3,decode:z3};u();var Qa=class{capacity;map;constructor(t){let{capacity:n}=t;if(!Number.isFinite(n)||n<=0)throw new Error("LRUCache capacity must be a positive finite number");this.capacity=Math.floor(n),this.map=new Map}get size(){return this.map.size}has(t){return this.map.has(t)}get(t){if(!this.map.has(t))return;let n=this.map.get(t);return this.map.delete(t),this.map.set(t,n),n}set(t,n){if(this.map.has(t)&&this.map.delete(t),this.map.set(t,n),this.map.size>this.capacity){let[r]=this.map.keys();r!==void 0&&this.map.delete(r)}}delete(t){return this.map.delete(t)}clear(){this.map.clear()}peek(t){return this.map.get(t)}wrap(t,n){let r=n?.key??(i=>i);return i=>{let o=r(i),s=this.get(o);if(s!==void 0||this.has(o))return s;let a=t(i);return this.set(o,a),a}}};u();u();u();u();u();u();u();u();u();function Yw(e,t,n){let r=e.get(t);return!!r&&r.has(n)}function Jw(e,t,n){let r=e.get(t);r||(r=new WeakSet,e.set(t,r)),r.add(n)}function q3(e,t,n,r,i){if(e===t)return!0;if(e.length!==t.length)return!1;if(Yw(i,e,t))return!0;Jw(i,e,t);for(let o=0;o<e.length;o++)if(!(n?Eb(e[o],t[o],n,r,i):e[o]===t[o]))return!1;return!0}function V3(e,t,n,r,i){if(e===t)return!0;if(!e||!t)return!1;if(Yw(i,e,t))return!0;Jw(i,e,t);let o=Object.keys(e),s=Object.keys(t);if(r){let a=r.shouldIgnoreKey;a&&(o=o.filter(c=>!a(c,e,t)),s=s.filter(c=>!a(c,e,t)))}if(o.length!==s.length)return!1;for(let a=0;a<o.length;a++){let c=o[a];if(!Object.prototype.hasOwnProperty.call(t,c)||!(n?Eb(e[c],t[c],n,r,i):e[c]===t[c]))return!1}return!0}function Eb(e,t,n,r,i){let o=typeof e;if(o!==typeof t)return!1;if(o!=="object"||!e||!t)return e===t;let a=Array.isArray(e),c=Array.isArray(t);return a!==c?!1:a&&c?q3(e,t,n,r,i):V3(e,t,n,r,i)}function bd(e,t,n,r){return Eb(e,t,n,r,new WeakMap)}u();function Xw(e){return Object.fromEntries(Object.entries(e).map(([t,n])=>[n,t]))}var Q3={"image/png":"png","image/jpeg":"jpg","image/webp":"webp","image/svg+xml":"svg","application/pdf":"pdf","application/zip":"zip","application/x-7z-compressed":"7z"},ASe=Xw(Q3);u();u();u();u();u();u();function Zw(e,t){let n=t?.cache,r=t?.ignoreUndefinedProperties??!1,i=new WeakSet;function o(a){return s(a).toString(16).padStart(8,"0")}function s(a){if(a===null)return wt(2166136261,110);switch(typeof a){case"boolean":{let l=wt(2166136261,98);return l=wt(l,a?49:48),l}case"number":{let l=a;if(Number.isNaN(l))return Fi(2166136261,"nNaN");if(!Number.isFinite(l))return Fi(2166136261,l>0?"nInfinity":"n-Infinity");if(Object.is(l,-0))return Fi(2166136261,"n-0");let p=wt(2166136261,110);return p=Fi(p,String(l)),p}case"string":{let l=wt(2166136261,115);return l=Fi(l,JSON.stringify(a)),l}case"undefined":return wt(2166136261,117);case"bigint":{let l=wt(2166136261,105);return l=Fi(l,a.toString()),l}case"symbol":case"function":throw new TypeError("Unsupported type for hashing");case"object":{let l=a;if(Array.isArray(l)){if(i.has(l))throw new TypeError("Cannot hash circular structure");if(n?.has(l)){let d=n.peek(l);if(d!==void 0)return parseInt(d,16)>>>0}i.add(l);try{let d=wt(2166136261,91);for(let y=0;y<l.length;y+=1){y>0&&(d=wt(d,44));let S=l[y];if(S===void 0)d=wt(d,117);else{let T=o(S);d=wt(d,104),d=Fi(d,T)}}d=wt(d,93);let m=d.toString(16).padStart(8,"0");return n?.set(l,m),d}finally{i.delete(l)}}let p=l.toJSON;if(typeof p=="function"){let d=p.call(l);if(d!==void 0)return s(d)}if(i.has(l))throw new TypeError("Cannot hash circular structure");if(n?.has(l)){let d=n.peek(l);if(d!==void 0)return parseInt(d,16)>>>0}i.add(l);try{let d=l,m=Object.keys(d).map(T=>[T,d[T]]).filter(T=>r?T[1]!==void 0:!0).sort((T,E)=>T[0]<E[0]?-1:T[0]>E[0]?1:0),y=wt(2166136261,123);for(let T=0;T<m.length;T+=1){T>0&&(y=wt(y,44));let[E,b]=m[T];if(y=wt(y,107),y=Fi(y,JSON.stringify(E)),y=wt(y,58),b===void 0)y=wt(y,117);else{let f=o(b);y=wt(y,104),y=Fi(y,f)}}y=wt(y,125);let S=y.toString(16).padStart(8,"0");return n?.set(l,S),y}finally{i.delete(l)}}default:return wt(2166136261,117)}}return o(e)}function Fi(e,t){for(let n=0;n<t.length;n+=1)e^=t.charCodeAt(n),e=Math.imul(e,16777619),e>>>=0;return e}function wt(e,t){return e^=t,e=Math.imul(e,16777619),e>>>=0,e}u();u();u();u();function Gt(e,t,n){return bd(e,t,!0,n)}u();u();u();u();u();function Ww(e){let t=new Map,n=new Map,r=0;return(...i)=>{let o="";for(let s of i)t.has(s)||t.set(s,`${r++}`),o+=t.get(s)+":";return n.has(o)||n.set(o,e(...i)),n.get(o)}}u();var hxe=Symbol("object"),yxe=Symbol("array"),gxe=Symbol("key"),bxe=Symbol("end"),Sxe=Symbol("primitive"),xxe=Symbol("argsep");u();u();u();u();u();u();u();u();u();u();u();function wb(e){return e.slice(0,1).toUpperCase()+e.slice(1)}u();u();u();u();var Sd,Y3=new Uint8Array(16);function Mb(){if(!Sd&&(Sd=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||typeof msCrypto<"u"&&typeof msCrypto.getRandomValues=="function"&&msCrypto.getRandomValues.bind(msCrypto),!Sd))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return Sd(Y3)}u();u();u();var eM=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;function J3(e){return typeof e=="string"&&eM.test(e)}var tM=J3;var tn=[];for(xd=0;xd<256;++xd)tn.push((xd+256).toString(16).substr(1));var xd;function X3(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,n=(tn[e[t+0]]+tn[e[t+1]]+tn[e[t+2]]+tn[e[t+3]]+"-"+tn[e[t+4]]+tn[e[t+5]]+"-"+tn[e[t+6]]+tn[e[t+7]]+"-"+tn[e[t+8]]+tn[e[t+9]]+"-"+tn[e[t+10]]+tn[e[t+11]]+tn[e[t+12]]+tn[e[t+13]]+tn[e[t+14]]+tn[e[t+15]]).toLowerCase();if(!tM(n))throw TypeError("Stringified UUID is invalid");return n}var nM=X3;u();function Z3(e,t,n){e=e||{};var r=e.random||(e.rng||Mb)();if(r[6]=r[6]&15|64,r[8]=r[8]&63|128,t){n=n||0;for(var i=0;i<16;++i)t[n+i]=r[i];return t}return nM(r)}var Ob=Z3;function te(){return Ob()}u();var fl=class{constructor(t){this.rpcManager=t;this.fetch=this.createFetch()}invocationEmitter=new Ee;responseEmitter=new Ee;tools$=new _([]);systemMessage$=new _(void 0);documentState$=new _(void 0);documentSchema$=new _(void 0);callableTools$=this.tools$.map(t=>Object.fromEntries(t.map(({functionName:n,description:r,parameters:i})=>[n,{description:r,parameters:i}])));configuration$=_.combine([this.callableTools$,this.systemMessage$],([t,n])=>({tools:t,systemMessage:n}),{isEqual:Gt});get callableTools(){return this.callableTools$.get()}createFetch(){return async(t,n)=>{let{readable:r,writable:i}=new TransformStream,o=i.getWriter();return this.rpcManager.requestStreamingRoute("POST /api/ai",{body:n?.body?.toString(),headers:n?.headers?Object.fromEntries(new Headers(n.headers).entries()):void 0,onStreamChunk:async a=>{await o.write(new TextEncoder().encode(a))},onStreamEnd:async()=>{await o.close()}}).then(async()=>{},async a=>{await o.abort(a)}),new Response(r,{status:200,statusText:"OK",headers:new Headers({"content-type":"text/plain; charset=utf-8"})})}}fetch;registerTool(t){return this.tools$.set([...this.tools$.get(),t]),()=>this.unregisterTool(t.functionName)}unregisterTool(t){this.tools$.set(this.tools$.get().filter(n=>n.functionName!==t))}callTool(t){let n=this.tools$.get().find(r=>r.functionName===t.name);if(!n){console.error(`Tool ${t.name} not found`);return}return n.onCall(t.parameters)}async requestGenerationStream(t,n,r){let i="",o,s,a=l=>{if(!l.trim())return;let p=JSON.parse(l);if(p.type==="error")o=p.error;else if(p.type==="text-delta"||p.type==="partial-object"||p.type==="object"||p.type==="text")r(p);else throw new Error("AI returned an unexpected stream event")},c=(l=!1)=>{let p=i.split(`
16
- `);i=p.pop()??"",l&&i.trim()&&(p.push(i),i="");for(let d of p)a(d)};if(await this.rpcManager.requestStreamingRoute(t,{body:JSON.stringify(n),headers:{"Content-Type":"application/json"},onStreamChunk:l=>{if(!s)try{i+=l,c()}catch(p){s=p instanceof Error?p:new Error("AI returned invalid stream data")}},onStreamEnd:async()=>{if(!s)try{c(!0)}catch(l){s=l instanceof Error?l:new Error("AI returned invalid stream data")}}}),s)throw s;if(o)throw new Error(o)}async generateObject(t){let{prompt:n,schema:r,system:i,images:o=[],model:s}=t;pl(n,s);let a=Td(t),c={prompt:n,schema:r,encodedSchema:Io(r),...a,...i?{system:i}:{},...s?{model:s}:{},...o.length?{images:await Promise.all(o.map(Id))}:{}},l=await this.rpcManager.requestRoute("POST /api/ai/generate",{body:JSON.stringify(c),headers:{"Content-Type":"application/json"}}),p=this.rpcManager.getResponseBody(l);if(!p||!("object"in p))throw new Error("AI returned an unexpected response");return rM(r,p.object)}streamObject(t){let{prompt:n,schema:r,system:i,images:o=[],model:s}=t;pl(n,s);let a=Td(t),c=iM(),l=Promise.withResolvers();return(async()=>{try{let p={prompt:n,schema:r,encodedSchema:Io(r),stream:!0,...a,...i?{system:i}:{},...s?{model:s}:{},...o.length?{images:await Promise.all(o.map(Id))}:{}},d,m=!1;if(await this.requestGenerationStream("POST /api/ai/generate",p,S=>{if(S.type==="partial-object")c.push(S.object);else if(S.type==="object")d=S.object,m=!0;else throw new Error("AI returned an unexpected object stream event")}),!m)throw new Error("AI returned no result in its object stream");let y=rM(r,d);c.end(),l.resolve(y)}catch(p){let d=oM(p);c.fail(d),l.reject(d)}})(),{partialObjectStream:c.iterable,object:l.promise}}async generateText(t){let{prompt:n,system:r,images:i=[],model:o}=t;pl(n,o);let s=Td(t),a={prompt:n,...s,...r?{system:r}:{},...o?{model:o}:{},...i.length?{images:await Promise.all(i.map(Id))}:{}},c=await this.rpcManager.requestRoute("POST /api/ai/generate/text",{body:JSON.stringify(a),headers:{"Content-Type":"application/json"}}),l=this.rpcManager.getResponseBody(c);if(!l||typeof l.text!="string")throw new Error("AI returned an unexpected text response");return l.text}streamText(t){let{prompt:n,system:r,images:i=[],model:o}=t;pl(n,o);let s=Td(t),a=iM(),c=Promise.withResolvers();return(async()=>{try{let l={prompt:n,stream:!0,...s,...r?{system:r}:{},...o?{model:o}:{},...i.length?{images:await Promise.all(i.map(Id))}:{}},p;if(await this.requestGenerationStream("POST /api/ai/generate/text",l,d=>{if(d.type==="text-delta")a.push(d.textDelta);else if(d.type==="text")p=d.text;else throw new Error("AI returned an unexpected text stream event")}),p===void 0)throw new Error("AI returned no result in its text stream");a.end(),c.resolve(p)}catch(l){let p=oM(l);a.fail(p),c.reject(p)}})(),{textStream:a.iterable,text:c.promise}}async generateImage({prompt:t,model:n}){pl(t,n);let r={prompt:t,...n?{model:n}:{}},i=await this.rpcManager.requestRoute("POST /api/ai/generate/image",{body:JSON.stringify(r),headers:{"Content-Type":"application/json"}}),o=this.rpcManager.getResponseBody(i);if(!o||typeof o.base64!="string"||typeof o.mediaType!="string")throw new Error("AI returned an unexpected image response");return{data:en.decode(o.base64),mediaType:o.mediaType}}};function rM(e,t){if(!ks.Check(e,t)){let n=[...ks.Errors(e,t)].map(({path:r,message:i})=>`${r||"/"}: ${i}`).join(", ");throw new Error(`AI response does not match the requested schema: ${n}`)}return t}function iM(){let e=[],t=!1,n,r,i=()=>{r?.(),r=void 0},o=async()=>{if(e.length>0)return{done:!1,value:e.shift()};if(n)throw n;return t?{done:!0,value:void 0}:(await new Promise(a=>{r=a}),o())};return{iterable:{[Symbol.asyncIterator](){return{next:o}}},push(a){t||n||(e.push(a),i())},end(){t=!0,i()},fail(a){n=a,i()}}}function oM(e){return e instanceof Error?e:new Error(String(e))}function Td(e){if(vd(e.temperature,"temperature",0,1),vd(e.topP,"topP",0,1),vd(e.presencePenalty,"presencePenalty",-1,1),vd(e.frequencyPenalty,"frequencyPenalty",-1,1),e.topK!==void 0&&(!Number.isSafeInteger(e.topK)||e.topK<=0))throw new Error("AI topK must be a positive integer");if(e.seed!==void 0&&!Number.isSafeInteger(e.seed))throw new Error("AI seed must be an integer");return{temperature:e.temperature,topP:e.topP,topK:e.topK,presencePenalty:e.presencePenalty,frequencyPenalty:e.frequencyPenalty,seed:e.seed}}function vd(e,t,n,r){if(e!==void 0&&(!Number.isFinite(e)||e<n||e>r))throw new Error(`AI ${t} must be between ${n} and ${r}`)}function pl(e,t){if(!e.trim())throw new Error("AI prompt must not be empty");if(t!==void 0&&!t.trim())throw new Error("AI model must not be empty")}async function Id(e){if(e instanceof Blob)return sM(e.type),{type:"data",data:en.encode(await e.arrayBuffer()),mediaType:e.type};if("url"in e){let t=new URL(e.url).toString();if(!["http:","https:"].includes(new URL(t).protocol))throw new Error("AI image URLs must use http or https");return{type:"url",url:t}}return sM(e.mediaType),{type:"data",data:en.encode(e.data),mediaType:e.mediaType}}function sM(e){if(!e.toLowerCase().startsWith("image/"))throw new Error(`Invalid AI image media type: ${e||"(missing)"}`)}u();var dl=class{isInitialized$=new _(!1);assets$=new _([]);uploads$=new _({});_assetStore;get assetStore(){return this._assetStore}set assetStore(t){this._assetStore=t,this.fetch()}constructor(t={}){this._assetStore=t.assetStore??new Ja,t.initialAssets&&this.set(t.initialAssets)}_toNoyaAsset=t=>W3(t);set=t=>{let n=this.assets$.get(),r=Object.fromEntries(n.filter(o=>{try{return new URL(o.url).searchParams.get("token")!==null}catch{return!1}}).map(o=>[o.id,o.url])),i=t.map(o=>({...o,url:r[o.id]??o.url}));this.assets$.set(i),this.isInitialized$.set(!0)};fetch=async()=>{try{let t=await this.assetStore.list();this.set(t)}catch(t){console.warn("Failed to fetch assets. This is probably okay, they will be pushed to us later.",t)}};_withUploadProgress=async(t,n)=>{let r=te();try{return await n(i=>{this.uploads$.set({...this.uploads$.get(),[r]:{...i,name:t,id:r}})})}finally{let{[r]:i,...o}=this.uploads$.get();this.uploads$.set(o)}};create=async t=>{let n=await aM(t),{stableId:r,mode:i}=!(t instanceof Uint8Array)&&!(t instanceof File)&&!(t instanceof Blob)?{stableId:t.stableId,mode:t.mode}:{},o=await this._withUploadProgress(n.name,a=>this.assetStore.create({data:n.data,contentType:n.contentType,...r?{stableId:r}:{},...i?{mode:i}:{},onUploadProgress:a}));await this.fetch();let s=this.assets$.get().find(a=>a.id===o.id)??o;return this._toNoyaAsset(s)};delete=async t=>{let r=this.assets$.get().find(s=>s.id===t||s.stableId===t),i=r?.id??t,o=r?this._toNoyaAsset(r):void 0;return await this.assetStore.delete(i),await this.fetch(),o};update=async(t,n)=>{if(!this.assetStore.update)throw new Error("Asset store does not support updates");let o=this.assets$.get().find(l=>l.id===t||l.stableId===t)?.id??t,s=await aM(n),a=await this._withUploadProgress(s.name,l=>this.assetStore.update(o,{data:s.data,contentType:s.contentType,onUploadProgress:l}));await this.fetch();let c=this.assets$.get().find(l=>l.id===a.id)??a;return this._toNoyaAsset(c)};read=t=>{let n=this.assets$.get(),r=n.find(i=>i.stableId===t)||n.find(i=>i.id===t);return r?this._toNoyaAsset(r):void 0};getAsset=t=>this.read(t);_getServerAssetId=t=>{let n=this.assets$.get();return(n.find(i=>i.stableId===t)||n.find(i=>i.id===t))?.id};getRealAssetId=t=>this._getServerAssetId(t)};async function aM(e){return e instanceof Uint8Array?{data:e}:e instanceof File?{data:new Uint8Array(await e.arrayBuffer()),contentType:e.type,name:e.name}:e instanceof Blob?{data:new Uint8Array(await e.arrayBuffer()),contentType:e.type}:{data:e.data,contentType:e.contentType}}var cM=new WeakMap,W3=e=>{let t=cM.get(e);return t||(t={id:e.stableId,url:e.url,createdAt:e.createdAt,size:e.size,contentType:e.contentType,width:e.width??null,height:e.height??null,userId:e.userId??null,mode:e.mode,version:e.version},cM.set(e,t)),t},Ya=class{databaseName;randomId;db;constructor(t={}){this.databaseName=t.databaseName??"noya-assets",this.randomId=t.randomId??te,this.db=this._initialize(t)}async _initialize({indexedDB:t=globalThis.indexedDB}={}){let n=await new Promise((r,i)=>{let o=t.open(this.databaseName,1);o.onerror=()=>i(o.error),o.onsuccess=()=>r(o.result),o.onupgradeneeded=s=>{let a=s.target.result;a.objectStoreNames.contains("assets")||a.createObjectStore("assets",{keyPath:"id"})}});return await this._populateUrlCache(n),n}read=async t=>{let n=await this._readWithBytes(t);if(!n)return null;let{data:r,...i}=n;return{...i,url:this._getUrl(t)}};_readWithBytes=async t=>{let n=await this.db;return new Promise((r,i)=>{let a=n.transaction("assets","readonly").objectStore("assets").get(t);a.onerror=()=>i(a.error),a.onsuccess=()=>r(a.result)})};list=async()=>{let t=await this.db;return new Promise((n,r)=>{let s=t.transaction("assets","readonly").objectStore("assets").getAll();s.onerror=()=>r(s.error),s.onsuccess=()=>n(s.result.map(({data:a,...c})=>({...c,url:this._getUrl(c.id)})))})};_listWithBytes=async()=>{let t=await this.db;return this._list(t)};create=async t=>{let n=this.randomId(),r={id:n,stableId:t.stableId??te(),data:t.data,size:t.data.length,createdAt:new Date().toISOString(),contentType:t.contentType,width:null,height:null,userId:null,mode:void 0,version:void 0};return await(await this.db).transaction("assets","readwrite").objectStore("assets").put(r),this._createAssetUrl(r),{id:n,stableId:r.stableId,url:this._getUrl(n),createdAt:r.createdAt,size:r.size,contentType:r.contentType,width:r.width,height:r.height,userId:r.userId,mode:r.mode,version:r.version}};update=async(t,n)=>{let r=await this.db,i=await this._readWithBytes(t);if(!i)throw new Error(`Asset ${t} not found`);let o={...i,data:n.data,size:n.data.length,contentType:n.contentType??i.contentType,version:(i.version??0)+1};await r.transaction("assets","readwrite").objectStore("assets").put(o);let s=this._urlCache.get(t);return s&&URL.revokeObjectURL(s),this._createAssetUrl(o),{id:t,stableId:o.stableId,url:this._getUrl(t),createdAt:o.createdAt,size:o.size,contentType:o.contentType,width:o.width,height:o.height,userId:o.userId,mode:o.mode,version:o.version}};delete=async t=>{await(await this.db).transaction("assets","readwrite").objectStore("assets").delete(t)};_list=async t=>new Promise((n,r)=>{let s=t.transaction("assets","readonly").objectStore("assets").getAll();s.onerror=()=>r(s.error),s.onsuccess=()=>n(s.result)});_urlCache=new Map;_getUrl=t=>{let n=this._urlCache.get(t);if(!n)throw new Error(`URL for asset ${t} not found`);return n};_createAssetUrl(t){let n=new Blob([t.data],{...t.contentType?{type:t.contentType}:{}}),r=URL.createObjectURL(n);this._urlCache.set(t.id,r)}async _populateUrlCache(t){let n=await this._list(t);for(let r of n)this._createAssetUrl(r)}},Ja=class{assets=[];randomId;constructor(t={}){this.randomId=t.randomId??te,this.assets=t.initialAssets??[],this.assets.forEach(n=>{this._createAssetUrl(n)})}read=async t=>{let n=this.assets.find(r=>r.id===t);return n?{...n,url:this._getUrl(t)}:null};list=async()=>this.assets.map(({data:t,...n})=>({...n,url:this._getUrl(n.id)}));_listWithBytes=async()=>this.assets;create=async t=>{let n=this.randomId(),r={id:n,stableId:t.stableId??te(),data:t.data,size:t.data.length,createdAt:new Date().toISOString(),contentType:t.contentType,width:null,height:null,userId:null,mode:void 0,version:void 0};return this.assets.push(r),this._createAssetUrl(r),{id:n,stableId:r.stableId,url:this._getUrl(n),createdAt:r.createdAt,size:r.size,contentType:r.contentType,width:r.width,height:r.height,userId:r.userId,mode:r.mode,version:r.version}};update=async(t,n)=>{let r=this.assets.findIndex(a=>a.id===t);if(r===-1)throw new Error(`Asset ${t} not found`);let i=this.assets[r],o={...i,data:n.data,size:n.data.length,contentType:n.contentType??i.contentType,version:(i.version??0)+1};this.assets[r]=o;let s=this._urlCache.get(t);return s&&URL.revokeObjectURL(s),this._createAssetUrl(o),{id:t,stableId:o.stableId,url:this._getUrl(t),createdAt:o.createdAt,size:o.size,contentType:o.contentType,width:o.width,height:o.height,userId:o.userId,mode:o.mode,version:o.version}};delete=async t=>{this.assets=this.assets.filter(n=>n.id!==t)};_urlCache=new Map;_getUrl=t=>{let n=this._urlCache.get(t);if(!n)throw new Error(`URL for asset ${t} not found`);return n};_createAssetUrl(t){let n=t.contentType?new Blob([t.data],{type:t.contentType}):new Blob([t.data]),r=URL.createObjectURL(n);this._urlCache.set(t.id,r)}},$i=class{constructor(t){this.rpcManager=t}read=async t=>{let n=await this.list();return n.find(r=>r.id===t)||n.find(r=>r.stableId===t)||null};list=async()=>{let t=await this.rpcManager.requestRoute("GET /api/assets");return JSON.parse(t.body)};create=async t=>{let n=await this.rpcManager.requestRoute("POST /api/assets",{body:en.encode(t.data),headers:{...t.contentType?{"Content-Type":t.contentType}:{}},searchParams:{...t.mode?{mode:t.mode}:{}},onUploadProgress:t.onUploadProgress});return JSON.parse(n.body)};update=async(t,n)=>{let r=await this.rpcManager.requestRoute(`PUT /api/assets/${t}`,{body:en.encode(n.data),headers:{...n.contentType?{"Content-Type":n.contentType}:{}},onUploadProgress:n.onUploadProgress});return JSON.parse(r.body)};delete=async t=>{await this.rpcManager.requestRoute(`DELETE /api/assets/${t}`)}};u();u();function Ab(e,t){return t||(t=Er(e)),pn(e,Fs(t))}function ml(e,t,n){return t||(t=Er(e)),Cs(e,Fs(t),n)}function Ao(e,t,n,{debug:r=!1}={}){if(!t)return e;if(!ue(t,Fs(n),e)){let s=[..._a(t,e)].map(a=>{let{schema:c,type:l,...p}=a;return{...p}});throw r&&console.error("Schema typecheck failed",t,e),new Error(`State does not match schema:
14
+ `+n.stack}}function Pr(e){switch(typeof e){case"bigint":case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function vP(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(t==="checkbox"||t==="radio")}function j8(e){var t=vP(e)?"checked":"value",n=Object.getOwnPropertyDescriptor(e.constructor.prototype,t),r=""+e[t];if(!e.hasOwnProperty(t)&&typeof n<"u"&&typeof n.get=="function"&&typeof n.set=="function"){var i=n.get,o=n.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return i.call(this)},set:function(s){r=""+s,o.call(this,s)}}),Object.defineProperty(e,t,{enumerable:n.enumerable}),{getValue:function(){return r},setValue:function(s){r=""+s},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}function Xm(e){e._valueTracker||(e._valueTracker=j8(e))}function IP(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var n=t.getValue(),r="";return e&&(r=vP(e)?e.checked?"true":"false":e.value),e=r,e!==n?(t.setValue(e),!0):!1}function Zm(e){if(e=e||(typeof document<"u"?document:void 0),typeof e>"u")return null;try{return e.activeElement||e.body}catch{return e.body}}var L8=/[\n"\\]/g;function kr(e){return e.replace(L8,function(t){return"\\"+t.charCodeAt(0).toString(16)+" "})}function oT(e,t,n,r,i,o,s,a){e.name="",s!=null&&typeof s!="function"&&typeof s!="symbol"&&typeof s!="boolean"?e.type=s:e.removeAttribute("type"),t!=null?s==="number"?(t===0&&e.value===""||e.value!=t)&&(e.value=""+Pr(t)):e.value!==""+Pr(t)&&(e.value=""+Pr(t)):s!=="submit"&&s!=="reset"||e.removeAttribute("value"),t!=null?sT(e,s,Pr(t)):n!=null?sT(e,s,Pr(n)):r!=null&&e.removeAttribute("value"),i==null&&o!=null&&(e.defaultChecked=!!o),i!=null&&(e.checked=i&&typeof i!="function"&&typeof i!="symbol"),a!=null&&typeof a!="function"&&typeof a!="symbol"&&typeof a!="boolean"?e.name=""+Pr(a):e.removeAttribute("name")}function EP(e,t,n,r,i,o,s,a){if(o!=null&&typeof o!="function"&&typeof o!="symbol"&&typeof o!="boolean"&&(e.type=o),t!=null||n!=null){if(!(o!=="submit"&&o!=="reset"||t!=null))return;n=n!=null?""+Pr(n):"",t=t!=null?""+Pr(t):n,a||t===e.value||(e.value=t),e.defaultValue=t}r=r??i,r=typeof r!="function"&&typeof r!="symbol"&&!!r,e.checked=a?e.checked:!!r,e.defaultChecked=!!r,s!=null&&typeof s!="function"&&typeof s!="symbol"&&typeof s!="boolean"&&(e.name=s)}function sT(e,t,n){t==="number"&&Zm(e.ownerDocument)===e||e.defaultValue===""+n||(e.defaultValue=""+n)}function kc(e,t,n,r){if(e=e.options,t){t={};for(var i=0;i<n.length;i++)t["$"+n[i]]=!0;for(n=0;n<e.length;n++)i=t.hasOwnProperty("$"+e[n].value),e[n].selected!==i&&(e[n].selected=i),i&&r&&(e[n].defaultSelected=!0)}else{for(n=""+Pr(n),t=null,i=0;i<e.length;i++){if(e[i].value===n){e[i].selected=!0,r&&(e[i].defaultSelected=!0);return}t!==null||e[i].disabled||(t=e[i])}t!==null&&(t.selected=!0)}}function wP(e,t,n){if(t!=null&&(t=""+Pr(t),t!==e.value&&(e.value=t),n==null)){e.defaultValue!==t&&(e.defaultValue=t);return}e.defaultValue=n!=null?""+Pr(n):""}function MP(e,t,n,r){if(t==null){if(r!=null){if(n!=null)throw Error(D(92));if(gp(r)){if(1<r.length)throw Error(D(93));r=r[0]}n=r}n==null&&(n=""),t=n}n=Pr(t),e.defaultValue=n,r=e.textContent,r===n&&r!==""&&r!==null&&(e.value=r)}function Kc(e,t){if(t){var n=e.firstChild;if(n&&n===e.lastChild&&n.nodeType===3){n.nodeValue=t;return}}e.textContent=t}var B8=new Set("animationIterationCount aspectRatio borderImageOutset borderImageSlice borderImageWidth boxFlex boxFlexGroup boxOrdinalGroup columnCount columns flex flexGrow flexPositive flexShrink flexNegative flexOrder gridArea gridRow gridRowEnd gridRowSpan gridRowStart gridColumn gridColumnEnd gridColumnSpan gridColumnStart fontWeight lineClamp lineHeight opacity order orphans scale tabSize widows zIndex zoom fillOpacity floodOpacity stopOpacity strokeDasharray strokeDashoffset strokeMiterlimit strokeOpacity strokeWidth MozAnimationIterationCount MozBoxFlex MozBoxFlexGroup MozLineClamp msAnimationIterationCount msFlex msZoom msFlexGrow msFlexNegative msFlexOrder msFlexPositive msFlexShrink msGridColumn msGridColumnSpan msGridRow msGridRowSpan WebkitAnimationIterationCount WebkitBoxFlex WebKitBoxFlexGroup WebkitBoxOrdinalGroup WebkitColumnCount WebkitColumns WebkitFlex WebkitFlexGrow WebkitFlexPositive WebkitFlexShrink WebkitLineClamp".split(" "));function qA(e,t,n){var r=t.indexOf("--")===0;n==null||typeof n=="boolean"||n===""?r?e.setProperty(t,""):t==="float"?e.cssFloat="":e[t]="":r?e.setProperty(t,n):typeof n!="number"||n===0||B8.has(t)?t==="float"?e.cssFloat=n:e[t]=(""+n).trim():e[t]=n+"px"}function OP(e,t,n){if(t!=null&&typeof t!="object")throw Error(D(62));if(e=e.style,n!=null){for(var r in n)!n.hasOwnProperty(r)||t!=null&&t.hasOwnProperty(r)||(r.indexOf("--")===0?e.setProperty(r,""):r==="float"?e.cssFloat="":e[r]="");for(var i in t)r=t[i],t.hasOwnProperty(i)&&n[i]!==r&&qA(e,i,r)}else for(var o in t)t.hasOwnProperty(o)&&qA(e,o,t[o])}function XT(e){if(e.indexOf("-")===-1)return!1;switch(e){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var F8=new Map([["acceptCharset","accept-charset"],["htmlFor","for"],["httpEquiv","http-equiv"],["crossOrigin","crossorigin"],["accentHeight","accent-height"],["alignmentBaseline","alignment-baseline"],["arabicForm","arabic-form"],["baselineShift","baseline-shift"],["capHeight","cap-height"],["clipPath","clip-path"],["clipRule","clip-rule"],["colorInterpolation","color-interpolation"],["colorInterpolationFilters","color-interpolation-filters"],["colorProfile","color-profile"],["colorRendering","color-rendering"],["dominantBaseline","dominant-baseline"],["enableBackground","enable-background"],["fillOpacity","fill-opacity"],["fillRule","fill-rule"],["floodColor","flood-color"],["floodOpacity","flood-opacity"],["fontFamily","font-family"],["fontSize","font-size"],["fontSizeAdjust","font-size-adjust"],["fontStretch","font-stretch"],["fontStyle","font-style"],["fontVariant","font-variant"],["fontWeight","font-weight"],["glyphName","glyph-name"],["glyphOrientationHorizontal","glyph-orientation-horizontal"],["glyphOrientationVertical","glyph-orientation-vertical"],["horizAdvX","horiz-adv-x"],["horizOriginX","horiz-origin-x"],["imageRendering","image-rendering"],["letterSpacing","letter-spacing"],["lightingColor","lighting-color"],["markerEnd","marker-end"],["markerMid","marker-mid"],["markerStart","marker-start"],["overlinePosition","overline-position"],["overlineThickness","overline-thickness"],["paintOrder","paint-order"],["panose-1","panose-1"],["pointerEvents","pointer-events"],["renderingIntent","rendering-intent"],["shapeRendering","shape-rendering"],["stopColor","stop-color"],["stopOpacity","stop-opacity"],["strikethroughPosition","strikethrough-position"],["strikethroughThickness","strikethrough-thickness"],["strokeDasharray","stroke-dasharray"],["strokeDashoffset","stroke-dashoffset"],["strokeLinecap","stroke-linecap"],["strokeLinejoin","stroke-linejoin"],["strokeMiterlimit","stroke-miterlimit"],["strokeOpacity","stroke-opacity"],["strokeWidth","stroke-width"],["textAnchor","text-anchor"],["textDecoration","text-decoration"],["textRendering","text-rendering"],["transformOrigin","transform-origin"],["underlinePosition","underline-position"],["underlineThickness","underline-thickness"],["unicodeBidi","unicode-bidi"],["unicodeRange","unicode-range"],["unitsPerEm","units-per-em"],["vAlphabetic","v-alphabetic"],["vHanging","v-hanging"],["vIdeographic","v-ideographic"],["vMathematical","v-mathematical"],["vectorEffect","vector-effect"],["vertAdvY","vert-adv-y"],["vertOriginX","vert-origin-x"],["vertOriginY","vert-origin-y"],["wordSpacing","word-spacing"],["writingMode","writing-mode"],["xmlnsXlink","xmlns:xlink"],["xHeight","x-height"]]),$8=/^[\u0000-\u001F ]*j[\r\n\t]*a[\r\n\t]*v[\r\n\t]*a[\r\n\t]*s[\r\n\t]*c[\r\n\t]*r[\r\n\t]*i[\r\n\t]*p[\r\n\t]*t[\r\n\t]*:/i;function Um(e){return $8.test(""+e)?"javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')":e}var aT=null;function ZT(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var Ic=null,Dc=null;function VA(e){var t=Zc(e);if(t&&(e=t.stateNode)){var n=e[Hn]||null;e:switch(e=t.stateNode,t.type){case"input":if(oT(e,n.value,n.defaultValue,n.defaultValue,n.checked,n.defaultChecked,n.type,n.name),t=n.name,n.type==="radio"&&t!=null){for(n=e;n.parentNode;)n=n.parentNode;for(n=n.querySelectorAll('input[name="'+kr(""+t)+'"][type="radio"]'),t=0;t<n.length;t++){var r=n[t];if(r!==e&&r.form===e.form){var i=r[Hn]||null;if(!i)throw Error(D(90));oT(r,i.value,i.defaultValue,i.defaultValue,i.checked,i.defaultChecked,i.type,i.name)}}for(t=0;t<n.length;t++)r=n[t],r.form===e.form&&IP(r)}break e;case"textarea":wP(e,n.value,n.defaultValue);break e;case"select":t=n.value,t!=null&&kc(e,!!n.multiple,t,!1)}}}var Ex=!1;function AP(e,t,n){if(Ex)return e(t,n);Ex=!0;try{var r=e(t);return r}finally{if(Ex=!1,(Ic!==null||Dc!==null)&&(kh(),Ic&&(t=Ic,e=Dc,Dc=Ic=null,VA(t),e)))for(t=0;t<e.length;t++)VA(e[t])}}function Up(e,t){var n=e.stateNode;if(n===null)return null;var r=n[Hn]||null;if(r===null)return null;n=r[t];e:switch(t){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(r=!r.disabled)||(e=e.type,r=!(e==="button"||e==="input"||e==="select"||e==="textarea")),e=!r;break e;default:e=!1}if(e)return null;if(n&&typeof n!="function")throw Error(D(231,t,typeof n));return n}var ao=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),cT=!1;if(ao)try{mc={},Object.defineProperty(mc,"passive",{get:function(){cT=!0}}),window.addEventListener("test",mc,mc),window.removeEventListener("test",mc,mc)}catch{cT=!1}var mc,Jo=null,WT=null,_m=null;function RP(){if(_m)return _m;var e,t=WT,n=t.length,r,i="value"in Jo?Jo.value:Jo.textContent,o=i.length;for(e=0;e<n&&t[e]===i[e];e++);var s=n-e;for(r=1;r<=s&&t[n-r]===i[o-r];r++);return _m=i.slice(e,1<r?1-r:void 0)}function jm(e){var t=e.keyCode;return"charCode"in e?(e=e.charCode,e===0&&t===13&&(e=13)):e=t,e===10&&(e=13),32<=e||e===13?e:0}function Tm(){return!0}function QA(){return!1}function Gn(e){function t(n,r,i,o,s){this._reactName=n,this._targetInst=i,this.type=r,this.nativeEvent=o,this.target=s,this.currentTarget=null;for(var a in e)e.hasOwnProperty(a)&&(n=e[a],this[a]=n?n(o):o[a]);return this.isDefaultPrevented=(o.defaultPrevented!=null?o.defaultPrevented:o.returnValue===!1)?Tm:QA,this.isPropagationStopped=QA,this}return We(t.prototype,{preventDefault:function(){this.defaultPrevented=!0;var n=this.nativeEvent;n&&(n.preventDefault?n.preventDefault():typeof n.returnValue!="unknown"&&(n.returnValue=!1),this.isDefaultPrevented=Tm)},stopPropagation:function(){var n=this.nativeEvent;n&&(n.stopPropagation?n.stopPropagation():typeof n.cancelBubble!="unknown"&&(n.cancelBubble=!0),this.isPropagationStopped=Tm)},persist:function(){},isPersistent:Tm}),t}var ga={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(e){return e.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},Eh=Gn(ga),Wp=We({},ga,{view:0,detail:0}),K8=Gn(Wp),wx,Mx,up,wh=We({},Wp,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:ev,button:0,buttons:0,relatedTarget:function(e){return e.relatedTarget===void 0?e.fromElement===e.srcElement?e.toElement:e.fromElement:e.relatedTarget},movementX:function(e){return"movementX"in e?e.movementX:(e!==up&&(up&&e.type==="mousemove"?(wx=e.screenX-up.screenX,Mx=e.screenY-up.screenY):Mx=wx=0,up=e),wx)},movementY:function(e){return"movementY"in e?e.movementY:Mx}}),YA=Gn(wh),z8=We({},wh,{dataTransfer:0}),H8=Gn(z8),G8=We({},Wp,{relatedTarget:0}),Ox=Gn(G8),q8=We({},ga,{animationName:0,elapsedTime:0,pseudoElement:0}),V8=Gn(q8),Q8=We({},ga,{clipboardData:function(e){return"clipboardData"in e?e.clipboardData:window.clipboardData}}),Y8=Gn(Q8),J8=We({},ga,{data:0}),JA=Gn(J8),X8={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},Z8={8:"Backspace",9:"Tab",12:"Clear",13:"Enter",16:"Shift",17:"Control",18:"Alt",19:"Pause",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",45:"Insert",46:"Delete",112:"F1",113:"F2",114:"F3",115:"F4",116:"F5",117:"F6",118:"F7",119:"F8",120:"F9",121:"F10",122:"F11",123:"F12",144:"NumLock",145:"ScrollLock",224:"Meta"},W8={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function eG(e){var t=this.nativeEvent;return t.getModifierState?t.getModifierState(e):(e=W8[e])?!!t[e]:!1}function ev(){return eG}var tG=We({},Wp,{key:function(e){if(e.key){var t=X8[e.key]||e.key;if(t!=="Unidentified")return t}return e.type==="keypress"?(e=jm(e),e===13?"Enter":String.fromCharCode(e)):e.type==="keydown"||e.type==="keyup"?Z8[e.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:ev,charCode:function(e){return e.type==="keypress"?jm(e):0},keyCode:function(e){return e.type==="keydown"||e.type==="keyup"?e.keyCode:0},which:function(e){return e.type==="keypress"?jm(e):e.type==="keydown"||e.type==="keyup"?e.keyCode:0}}),nG=Gn(tG),rG=We({},wh,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),XA=Gn(rG),iG=We({},Wp,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:ev}),oG=Gn(iG),sG=We({},ga,{propertyName:0,elapsedTime:0,pseudoElement:0}),aG=Gn(sG),cG=We({},wh,{deltaX:function(e){return"deltaX"in e?e.deltaX:"wheelDeltaX"in e?-e.wheelDeltaX:0},deltaY:function(e){return"deltaY"in e?e.deltaY:"wheelDeltaY"in e?-e.wheelDeltaY:"wheelDelta"in e?-e.wheelDelta:0},deltaZ:0,deltaMode:0}),uG=Gn(cG),lG=We({},ga,{newState:0,oldState:0}),pG=Gn(lG),fG=[9,13,27,32],tv=ao&&"CompositionEvent"in window,xp=null;ao&&"documentMode"in document&&(xp=document.documentMode);var dG=ao&&"TextEvent"in window&&!xp,PP=ao&&(!tv||xp&&8<xp&&11>=xp),ZA=" ",WA=!1;function CP(e,t){switch(e){case"keyup":return fG.indexOf(t.keyCode)!==-1;case"keydown":return t.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function NP(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var Ec=!1;function mG(e,t){switch(e){case"compositionend":return NP(t);case"keypress":return t.which!==32?null:(WA=!0,ZA);case"textInput":return e=t.data,e===ZA&&WA?null:e;default:return null}}function hG(e,t){if(Ec)return e==="compositionend"||!tv&&CP(e,t)?(e=RP(),_m=WT=Jo=null,Ec=!1,e):null;switch(e){case"paste":return null;case"keypress":if(!(t.ctrlKey||t.altKey||t.metaKey)||t.ctrlKey&&t.altKey){if(t.char&&1<t.char.length)return t.char;if(t.which)return String.fromCharCode(t.which)}return null;case"compositionend":return PP&&t.locale!=="ko"?null:t.data;default:return null}}var yG={color:!0,date:!0,datetime:!0,"datetime-local":!0,email:!0,month:!0,number:!0,password:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0};function eR(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t==="input"?!!yG[e.type]:t==="textarea"}function kP(e,t,n,r){Ic?Dc?Dc.push(r):Dc=[r]:Ic=r,t=yh(t,"onChange"),0<t.length&&(n=new Eh("onChange","change",null,n,r),e.push({event:n,listeners:t}))}var Tp=null,_p=null;function gG(e){w1(e,0)}function Mh(e){var t=bp(e);if(IP(t))return e}function tR(e,t){if(e==="change")return t}var DP=!1;ao&&(ao?(Im="oninput"in document,Im||(Ax=document.createElement("div"),Ax.setAttribute("oninput","return;"),Im=typeof Ax.oninput=="function"),vm=Im):vm=!1,DP=vm&&(!document.documentMode||9<document.documentMode));var vm,Im,Ax;function nR(){Tp&&(Tp.detachEvent("onpropertychange",UP),_p=Tp=null)}function UP(e){if(e.propertyName==="value"&&Mh(_p)){var t=[];kP(t,_p,e,ZT(e)),AP(gG,t)}}function bG(e,t,n){e==="focusin"?(nR(),Tp=t,_p=n,Tp.attachEvent("onpropertychange",UP)):e==="focusout"&&nR()}function SG(e){if(e==="selectionchange"||e==="keyup"||e==="keydown")return Mh(_p)}function xG(e,t){if(e==="click")return Mh(t)}function TG(e,t){if(e==="input"||e==="change")return Mh(t)}function vG(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var dr=typeof Object.is=="function"?Object.is:vG;function jp(e,t){if(dr(e,t))return!0;if(typeof e!="object"||e===null||typeof t!="object"||t===null)return!1;var n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(r=0;r<n.length;r++){var i=n[r];if(!rT.call(t,i)||!dr(e[i],t[i]))return!1}return!0}function rR(e){for(;e&&e.firstChild;)e=e.firstChild;return e}function iR(e,t){var n=rR(e);e=0;for(var r;n;){if(n.nodeType===3){if(r=e+n.textContent.length,e<=t&&r>=t)return{node:n,offset:t-e};e=r}e:{for(;n;){if(n.nextSibling){n=n.nextSibling;break e}n=n.parentNode}n=void 0}n=rR(n)}}function _P(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?_P(e,t.parentNode):"contains"in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function jP(e){e=e!=null&&e.ownerDocument!=null&&e.ownerDocument.defaultView!=null?e.ownerDocument.defaultView:window;for(var t=Zm(e.document);t instanceof e.HTMLIFrameElement;){try{var n=typeof t.contentWindow.location.href=="string"}catch{n=!1}if(n)e=t.contentWindow;else break;t=Zm(e.document)}return t}function nv(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t&&(t==="input"&&(e.type==="text"||e.type==="search"||e.type==="tel"||e.type==="url"||e.type==="password")||t==="textarea"||e.contentEditable==="true")}var IG=ao&&"documentMode"in document&&11>=document.documentMode,wc=null,uT=null,vp=null,lT=!1;function oR(e,t,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;lT||wc==null||wc!==Zm(r)||(r=wc,"selectionStart"in r&&nv(r)?r={start:r.selectionStart,end:r.selectionEnd}:(r=(r.ownerDocument&&r.ownerDocument.defaultView||window).getSelection(),r={anchorNode:r.anchorNode,anchorOffset:r.anchorOffset,focusNode:r.focusNode,focusOffset:r.focusOffset}),vp&&jp(vp,r)||(vp=r,r=yh(uT,"onSelect"),0<r.length&&(t=new Eh("onSelect","select",null,t,n),e.push({event:t,listeners:r}),t.target=wc)))}function ta(e,t){var n={};return n[e.toLowerCase()]=t.toLowerCase(),n["Webkit"+e]="webkit"+t,n["Moz"+e]="moz"+t,n}var Mc={animationend:ta("Animation","AnimationEnd"),animationiteration:ta("Animation","AnimationIteration"),animationstart:ta("Animation","AnimationStart"),transitionrun:ta("Transition","TransitionRun"),transitionstart:ta("Transition","TransitionStart"),transitioncancel:ta("Transition","TransitionCancel"),transitionend:ta("Transition","TransitionEnd")},Rx={},LP={};ao&&(LP=document.createElement("div").style,"AnimationEvent"in window||(delete Mc.animationend.animation,delete Mc.animationiteration.animation,delete Mc.animationstart.animation),"TransitionEvent"in window||delete Mc.transitionend.transition);function ba(e){if(Rx[e])return Rx[e];if(!Mc[e])return e;var t=Mc[e],n;for(n in t)if(t.hasOwnProperty(n)&&n in LP)return Rx[e]=t[n];return e}var BP=ba("animationend"),FP=ba("animationiteration"),$P=ba("animationstart"),EG=ba("transitionrun"),wG=ba("transitionstart"),MG=ba("transitioncancel"),KP=ba("transitionend"),zP=new Map,pT="abort auxClick beforeToggle cancel canPlay canPlayThrough click close contextMenu copy cut drag dragEnd dragEnter dragExit dragLeave dragOver dragStart drop durationChange emptied encrypted ended error gotPointerCapture input invalid keyDown keyPress keyUp load loadedData loadedMetadata loadStart lostPointerCapture mouseDown mouseMove mouseOut mouseOver mouseUp paste pause play playing pointerCancel pointerDown pointerMove pointerOut pointerOver pointerUp progress rateChange reset resize seeked seeking stalled submit suspend timeUpdate touchCancel touchEnd touchStart volumeChange scroll toggle touchMove waiting wheel".split(" ");pT.push("scrollEnd");function ei(e,t){zP.set(e,t),ya(t,[e])}var sR=new WeakMap;function Dr(e,t){if(typeof e=="object"&&e!==null){var n=sR.get(e);return n!==void 0?n:(t={value:e,source:t,stack:GA(t)},sR.set(e,t),t)}return{value:e,source:t,stack:GA(t)}}var Rr=[],Oc=0,rv=0;function Oh(){for(var e=Oc,t=rv=Oc=0;t<e;){var n=Rr[t];Rr[t++]=null;var r=Rr[t];Rr[t++]=null;var i=Rr[t];Rr[t++]=null;var o=Rr[t];if(Rr[t++]=null,r!==null&&i!==null){var s=r.pending;s===null?i.next=i:(i.next=s.next,s.next=i),r.pending=i}o!==0&&HP(n,i,o)}}function Ah(e,t,n,r){Rr[Oc++]=e,Rr[Oc++]=t,Rr[Oc++]=n,Rr[Oc++]=r,rv|=r,e.lanes|=r,e=e.alternate,e!==null&&(e.lanes|=r)}function iv(e,t,n,r){return Ah(e,t,n,r),Wm(e)}function Wc(e,t){return Ah(e,null,null,t),Wm(e)}function HP(e,t,n){e.lanes|=n;var r=e.alternate;r!==null&&(r.lanes|=n);for(var i=!1,o=e.return;o!==null;)o.childLanes|=n,r=o.alternate,r!==null&&(r.childLanes|=n),o.tag===22&&(e=o.stateNode,e===null||e._visibility&1||(i=!0)),e=o,o=o.return;return e.tag===3?(o=e.stateNode,i&&t!==null&&(i=31-lr(n),e=o.hiddenUpdates,r=e[i],r===null?e[i]=[t]:r.push(t),t.lane=n|536870912),o):null}function Wm(e){if(50<Np)throw Np=0,NT=null,Error(D(185));for(var t=e.return;t!==null;)e=t,t=e.return;return e.tag===3?e.stateNode:null}var Ac={};function OG(e,t,n,r){this.tag=e,this.key=n,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.refCleanup=this.ref=null,this.pendingProps=t,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=r,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function cr(e,t,n,r){return new OG(e,t,n,r)}function ov(e){return e=e.prototype,!(!e||!e.isReactComponent)}function oo(e,t){var n=e.alternate;return n===null?(n=cr(e.tag,t,e.key,e.mode),n.elementType=e.elementType,n.type=e.type,n.stateNode=e.stateNode,n.alternate=e,e.alternate=n):(n.pendingProps=t,n.type=e.type,n.flags=0,n.subtreeFlags=0,n.deletions=null),n.flags=e.flags&65011712,n.childLanes=e.childLanes,n.lanes=e.lanes,n.child=e.child,n.memoizedProps=e.memoizedProps,n.memoizedState=e.memoizedState,n.updateQueue=e.updateQueue,t=e.dependencies,n.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext},n.sibling=e.sibling,n.index=e.index,n.ref=e.ref,n.refCleanup=e.refCleanup,n}function GP(e,t){e.flags&=65011714;var n=e.alternate;return n===null?(e.childLanes=0,e.lanes=t,e.child=null,e.subtreeFlags=0,e.memoizedProps=null,e.memoizedState=null,e.updateQueue=null,e.dependencies=null,e.stateNode=null):(e.childLanes=n.childLanes,e.lanes=n.lanes,e.child=n.child,e.subtreeFlags=0,e.deletions=null,e.memoizedProps=n.memoizedProps,e.memoizedState=n.memoizedState,e.updateQueue=n.updateQueue,e.type=n.type,t=n.dependencies,e.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext}),e}function Lm(e,t,n,r,i,o){var s=0;if(r=e,typeof e=="function")ov(e)&&(s=1);else if(typeof e=="string")s=Oq(e,n,xi.current)?26:e==="html"||e==="head"||e==="body"?27:5;else e:switch(e){case Wx:return e=cr(31,n,t,i),e.elementType=Wx,e.lanes=o,e;case xc:return sa(n.children,i,o,t);case lP:s=8,i|=24;break;case Jx:return e=cr(12,n,t,i|2),e.elementType=Jx,e.lanes=o,e;case Xx:return e=cr(13,n,t,i),e.elementType=Xx,e.lanes=o,e;case Zx:return e=cr(19,n,t,i),e.elementType=Zx,e.lanes=o,e;default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case g8:case eo:s=10;break e;case pP:s=9;break e;case GT:s=11;break e;case qT:s=14;break e;case zo:s=16,r=null;break e}s=29,n=Error(D(130,e===null?"null":typeof e,"")),r=null}return t=cr(s,n,t,i),t.elementType=e,t.type=r,t.lanes=o,t}function sa(e,t,n,r){return e=cr(7,e,r,t),e.lanes=n,e}function Px(e,t,n){return e=cr(6,e,null,t),e.lanes=n,e}function Cx(e,t,n){return t=cr(4,e.children!==null?e.children:[],e.key,t),t.lanes=n,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}var Rc=[],Pc=0,eh=null,th=0,Cr=[],Nr=0,aa=null,to=1,no="";function ra(e,t){Rc[Pc++]=th,Rc[Pc++]=eh,eh=e,th=t}function qP(e,t,n){Cr[Nr++]=to,Cr[Nr++]=no,Cr[Nr++]=aa,aa=e;var r=to;e=no;var i=32-lr(r)-1;r&=~(1<<i),n+=1;var o=32-lr(t)+i;if(30<o){var s=i-i%5;o=(r&(1<<s)-1).toString(32),r>>=s,i-=s,to=1<<32-lr(t)+i|n<<i|r,no=o+e}else to=1<<o|n<<i|r,no=e}function sv(e){e.return!==null&&(ra(e,1),qP(e,1,0))}function av(e){for(;e===eh;)eh=Rc[--Pc],Rc[Pc]=null,th=Rc[--Pc],Rc[Pc]=null;for(;e===aa;)aa=Cr[--Nr],Cr[Nr]=null,no=Cr[--Nr],Cr[Nr]=null,to=Cr[--Nr],Cr[Nr]=null}var Mn=null,pt=null,we=!1,ca=null,bi=!1,fT=Error(D(519));function fa(e){var t=Error(D(418,""));throw Lp(Dr(t,e)),fT}function aR(e){var t=e.stateNode,n=e.type,r=e.memoizedProps;switch(t[mn]=e,t[Hn]=r,n){case"dialog":le("cancel",t),le("close",t);break;case"iframe":case"object":case"embed":le("load",t);break;case"video":case"audio":for(n=0;n<$p.length;n++)le($p[n],t);break;case"source":le("error",t);break;case"img":case"image":case"link":le("error",t),le("load",t);break;case"details":le("toggle",t);break;case"input":le("invalid",t),EP(t,r.value,r.defaultValue,r.checked,r.defaultChecked,r.type,r.name,!0),Xm(t);break;case"select":le("invalid",t);break;case"textarea":le("invalid",t),MP(t,r.value,r.defaultValue,r.children),Xm(t)}n=r.children,typeof n!="string"&&typeof n!="number"&&typeof n!="bigint"||t.textContent===""+n||r.suppressHydrationWarning===!0||O1(t.textContent,n)?(r.popover!=null&&(le("beforetoggle",t),le("toggle",t)),r.onScroll!=null&&le("scroll",t),r.onScrollEnd!=null&&le("scrollend",t),r.onClick!=null&&(t.onclick=_h),t=!0):t=!1,t||fa(e)}function cR(e){for(Mn=e.return;Mn;)switch(Mn.tag){case 5:case 13:bi=!1;return;case 27:case 3:bi=!0;return;default:Mn=Mn.return}}function lp(e){if(e!==Mn)return!1;if(!we)return cR(e),we=!0,!1;var t=e.tag,n;if((n=t!==3&&t!==27)&&((n=t===5)&&(n=e.type,n=!(n!=="form"&&n!=="button")||LT(e.type,e.memoizedProps)),n=!n),n&&pt&&fa(e),cR(e),t===13){if(e=e.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(D(317));e:{for(e=e.nextSibling,t=0;e;){if(e.nodeType===8)if(n=e.data,n==="/$"){if(t===0){pt=Wr(e.nextSibling);break e}t--}else n!=="$"&&n!=="$!"&&n!=="$?"||t++;e=e.nextSibling}pt=null}}else t===27?(t=pt,ps(e.type)?(e=$T,$T=null,pt=e):pt=t):pt=Mn?Wr(e.stateNode.nextSibling):null;return!0}function ef(){pt=Mn=null,we=!1}function uR(){var e=ca;return e!==null&&(zn===null?zn=e:zn.push.apply(zn,e),ca=null),e}function Lp(e){ca===null?ca=[e]:ca.push(e)}var dT=Ii(null),Sa=null,ro=null;function Go(e,t,n){rt(dT,t._currentValue),t._currentValue=n}function so(e){e._currentValue=dT.current,Yt(dT)}function mT(e,t,n){for(;e!==null;){var r=e.alternate;if((e.childLanes&t)!==t?(e.childLanes|=t,r!==null&&(r.childLanes|=t)):r!==null&&(r.childLanes&t)!==t&&(r.childLanes|=t),e===n)break;e=e.return}}function hT(e,t,n,r){var i=e.child;for(i!==null&&(i.return=e);i!==null;){var o=i.dependencies;if(o!==null){var s=i.child;o=o.firstContext;e:for(;o!==null;){var a=o;o=i;for(var c=0;c<t.length;c++)if(a.context===t[c]){o.lanes|=n,a=o.alternate,a!==null&&(a.lanes|=n),mT(o.return,n,e),r||(s=null);break e}o=a.next}}else if(i.tag===18){if(s=i.return,s===null)throw Error(D(341));s.lanes|=n,o=s.alternate,o!==null&&(o.lanes|=n),mT(s,n,e),s=null}else s=i.child;if(s!==null)s.return=i;else for(s=i;s!==null;){if(s===e){s=null;break}if(i=s.sibling,i!==null){i.return=s.return,s=i;break}s=s.return}i=s}}function tf(e,t,n,r){e=null;for(var i=t,o=!1;i!==null;){if(!o){if(i.flags&524288)o=!0;else if(i.flags&262144)break}if(i.tag===10){var s=i.alternate;if(s===null)throw Error(D(387));if(s=s.memoizedProps,s!==null){var a=i.type;dr(i.pendingProps.value,s.value)||(e!==null?e.push(a):e=[a])}}else if(i===Vm.current){if(s=i.alternate,s===null)throw Error(D(387));s.memoizedState.memoizedState!==i.memoizedState.memoizedState&&(e!==null?e.push(Hp):e=[Hp])}i=i.return}e!==null&&hT(t,e,n,r),t.flags|=262144}function nh(e){for(e=e.firstContext;e!==null;){if(!dr(e.context._currentValue,e.memoizedValue))return!0;e=e.next}return!1}function da(e){Sa=e,ro=null,e=e.dependencies,e!==null&&(e.firstContext=null)}function hn(e){return VP(Sa,e)}function Em(e,t){return Sa===null&&da(e),VP(e,t)}function VP(e,t){var n=t._currentValue;if(t={context:t,memoizedValue:n,next:null},ro===null){if(e===null)throw Error(D(308));ro=t,e.dependencies={lanes:0,firstContext:t},e.flags|=524288}else ro=ro.next=t;return n}var AG=typeof AbortController<"u"?AbortController:function(){var e=[],t=this.signal={aborted:!1,addEventListener:function(n,r){e.push(r)}};this.abort=function(){t.aborted=!0,e.forEach(function(n){return n()})}},RG=Lt.unstable_scheduleCallback,PG=Lt.unstable_NormalPriority,_t={$$typeof:eo,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function cv(){return{controller:new AG,data:new Map,refCount:0}}function nf(e){e.refCount--,e.refCount===0&&RG(PG,function(){e.controller.abort()})}var Ip=null,yT=0,zc=0,Uc=null;function CG(e,t){if(Ip===null){var n=Ip=[];yT=0,zc=Cv(),Uc={status:"pending",value:void 0,then:function(r){n.push(r)}}}return yT++,t.then(lR,lR),t}function lR(){if(--yT===0&&Ip!==null){Uc!==null&&(Uc.status="fulfilled");var e=Ip;Ip=null,zc=0,Uc=null;for(var t=0;t<e.length;t++)(0,e[t])()}}function NG(e,t){var n=[],r={status:"pending",value:null,reason:null,then:function(i){n.push(i)}};return e.then(function(){r.status="fulfilled",r.value=t;for(var i=0;i<n.length;i++)(0,n[i])(t)},function(i){for(r.status="rejected",r.reason=i,i=0;i<n.length;i++)(0,n[i])(void 0)}),r}var pR=X.S;X.S=function(e,t){typeof t=="object"&&t!==null&&typeof t.then=="function"&&CG(e,t),pR!==null&&pR(e,t)};var ua=Ii(null);function uv(){var e=ua.current;return e!==null?e:Xe.pooledCache}function Bm(e,t){t===null?rt(ua,ua.current):rt(ua,t.pool)}function QP(){var e=uv();return e===null?null:{parent:_t._currentValue,pool:e}}var rf=Error(D(460)),YP=Error(D(474)),Rh=Error(D(542)),gT={then:function(){}};function fR(e){return e=e.status,e==="fulfilled"||e==="rejected"}function wm(){}function JP(e,t,n){switch(n=e[n],n===void 0?e.push(t):n!==t&&(t.then(wm,wm),t=n),t.status){case"fulfilled":return t.value;case"rejected":throw e=t.reason,mR(e),e;default:if(typeof t.status=="string")t.then(wm,wm);else{if(e=Xe,e!==null&&100<e.shellSuspendCounter)throw Error(D(482));e=t,e.status="pending",e.then(function(r){if(t.status==="pending"){var i=t;i.status="fulfilled",i.value=r}},function(r){if(t.status==="pending"){var i=t;i.status="rejected",i.reason=r}})}switch(t.status){case"fulfilled":return t.value;case"rejected":throw e=t.reason,mR(e),e}throw Ep=t,rf}}var Ep=null;function dR(){if(Ep===null)throw Error(D(459));var e=Ep;return Ep=null,e}function mR(e){if(e===rf||e===Rh)throw Error(D(483))}var Ho=!1;function lv(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function bT(e,t){e=e.updateQueue,t.updateQueue===e&&(t.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,callbacks:null})}function es(e){return{lane:e,tag:0,payload:null,callback:null,next:null}}function ts(e,t,n){var r=e.updateQueue;if(r===null)return null;if(r=r.shared,_e&2){var i=r.pending;return i===null?t.next=t:(t.next=i.next,i.next=t),r.pending=t,t=Wm(e),HP(e,null,n),t}return Ah(e,r,t,n),Wm(e)}function wp(e,t,n){if(t=t.updateQueue,t!==null&&(t=t.shared,(n&4194048)!==0)){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,bP(e,n)}}function Nx(e,t){var n=e.updateQueue,r=e.alternate;if(r!==null&&(r=r.updateQueue,n===r)){var i=null,o=null;if(n=n.firstBaseUpdate,n!==null){do{var s={lane:n.lane,tag:n.tag,payload:n.payload,callback:null,next:null};o===null?i=o=s:o=o.next=s,n=n.next}while(n!==null);o===null?i=o=t:o=o.next=t}else i=o=t;n={baseState:r.baseState,firstBaseUpdate:i,lastBaseUpdate:o,shared:r.shared,callbacks:r.callbacks},e.updateQueue=n;return}e=n.lastBaseUpdate,e===null?n.firstBaseUpdate=t:e.next=t,n.lastBaseUpdate=t}var ST=!1;function Mp(){if(ST){var e=Uc;if(e!==null)throw e}}function Op(e,t,n,r){ST=!1;var i=e.updateQueue;Ho=!1;var o=i.firstBaseUpdate,s=i.lastBaseUpdate,a=i.shared.pending;if(a!==null){i.shared.pending=null;var c=a,l=c.next;c.next=null,s===null?o=l:s.next=l,s=c;var p=e.alternate;p!==null&&(p=p.updateQueue,a=p.lastBaseUpdate,a!==s&&(a===null?p.firstBaseUpdate=l:a.next=l,p.lastBaseUpdate=c))}if(o!==null){var d=i.baseState;s=0,p=l=c=null,a=o;do{var m=a.lane&-536870913,y=m!==a.lane;if(y?(Se&m)===m:(r&m)===m){m!==0&&m===zc&&(ST=!0),p!==null&&(p=p.next={lane:0,tag:a.tag,payload:a.payload,callback:null,next:null});e:{var S=e,T=a;m=t;var E=n;switch(T.tag){case 1:if(S=T.payload,typeof S=="function"){d=S.call(E,d,m);break e}d=S;break e;case 3:S.flags=S.flags&-65537|128;case 0:if(S=T.payload,m=typeof S=="function"?S.call(E,d,m):S,m==null)break e;d=We({},d,m);break e;case 2:Ho=!0}}m=a.callback,m!==null&&(e.flags|=64,y&&(e.flags|=8192),y=i.callbacks,y===null?i.callbacks=[m]:y.push(m))}else y={lane:m,tag:a.tag,payload:a.payload,callback:a.callback,next:null},p===null?(l=p=y,c=d):p=p.next=y,s|=m;if(a=a.next,a===null){if(a=i.shared.pending,a===null)break;y=a,a=y.next,y.next=null,i.lastBaseUpdate=y,i.shared.pending=null}}while(!0);p===null&&(c=d),i.baseState=c,i.firstBaseUpdate=l,i.lastBaseUpdate=p,o===null&&(i.shared.lanes=0),us|=s,e.lanes=s,e.memoizedState=d}}function XP(e,t){if(typeof e!="function")throw Error(D(191,e));e.call(t)}function ZP(e,t){var n=e.callbacks;if(n!==null)for(e.callbacks=null,e=0;e<n.length;e++)XP(n[e],t)}var Hc=Ii(null),rh=Ii(0);function hR(e,t){e=lo,rt(rh,e),rt(Hc,t),lo=e|t.baseLanes}function xT(){rt(rh,lo),rt(Hc,Hc.current)}function pv(){lo=rh.current,Yt(Hc),Yt(rh)}var as=0,re=null,Fe=null,Ot=null,ih=!1,_c=!1,ma=!1,oh=0,Bp=0,jc=null,kG=0;function yt(){throw Error(D(321))}function fv(e,t){if(t===null)return!1;for(var n=0;n<t.length&&n<e.length;n++)if(!dr(e[n],t[n]))return!1;return!0}function dv(e,t,n,r,i,o){return as=o,re=t,t.memoizedState=null,t.updateQueue=null,t.lanes=0,X.H=e===null||e.memoizedState===null?RC:PC,ma=!1,o=n(r,i),ma=!1,_c&&(o=eC(t,n,r,i)),WP(e),o}function WP(e){X.H=sh;var t=Fe!==null&&Fe.next!==null;if(as=0,Ot=Fe=re=null,ih=!1,Bp=0,jc=null,t)throw Error(D(300));e===null||Qt||(e=e.dependencies,e!==null&&nh(e)&&(Qt=!0))}function eC(e,t,n,r){re=e;var i=0;do{if(_c&&(jc=null),Bp=0,_c=!1,25<=i)throw Error(D(301));if(i+=1,Ot=Fe=null,e.updateQueue!=null){var o=e.updateQueue;o.lastEffect=null,o.events=null,o.stores=null,o.memoCache!=null&&(o.memoCache.index=0)}X.H=FG,o=t(n,r)}while(_c);return o}function DG(){var e=X.H,t=e.useState()[0];return t=typeof t.then=="function"?of(t):t,e=e.useState()[0],(Fe!==null?Fe.memoizedState:null)!==e&&(re.flags|=1024),t}function mv(){var e=oh!==0;return oh=0,e}function hv(e,t,n){t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~n}function yv(e){if(ih){for(e=e.memoizedState;e!==null;){var t=e.queue;t!==null&&(t.pending=null),e=e.next}ih=!1}as=0,Ot=Fe=re=null,_c=!1,Bp=oh=0,jc=null}function $n(){var e={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return Ot===null?re.memoizedState=Ot=e:Ot=Ot.next=e,Ot}function At(){if(Fe===null){var e=re.alternate;e=e!==null?e.memoizedState:null}else e=Fe.next;var t=Ot===null?re.memoizedState:Ot.next;if(t!==null)Ot=t,Fe=e;else{if(e===null)throw re.alternate===null?Error(D(467)):Error(D(310));Fe=e,e={memoizedState:Fe.memoizedState,baseState:Fe.baseState,baseQueue:Fe.baseQueue,queue:Fe.queue,next:null},Ot===null?re.memoizedState=Ot=e:Ot=Ot.next=e}return Ot}function gv(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function of(e){var t=Bp;return Bp+=1,jc===null&&(jc=[]),e=JP(jc,e,t),t=re,(Ot===null?t.memoizedState:Ot.next)===null&&(t=t.alternate,X.H=t===null||t.memoizedState===null?RC:PC),e}function Ph(e){if(e!==null&&typeof e=="object"){if(typeof e.then=="function")return of(e);if(e.$$typeof===eo)return hn(e)}throw Error(D(438,String(e)))}function bv(e){var t=null,n=re.updateQueue;if(n!==null&&(t=n.memoCache),t==null){var r=re.alternate;r!==null&&(r=r.updateQueue,r!==null&&(r=r.memoCache,r!=null&&(t={data:r.data.map(function(i){return i.slice()}),index:0})))}if(t==null&&(t={data:[],index:0}),n===null&&(n=gv(),re.updateQueue=n),n.memoCache=t,n=t.data[t.index],n===void 0)for(n=t.data[t.index]=Array(e),r=0;r<e;r++)n[r]=b8;return t.index++,n}function co(e,t){return typeof t=="function"?t(e):t}function Fm(e){var t=At();return Sv(t,Fe,e)}function Sv(e,t,n){var r=e.queue;if(r===null)throw Error(D(311));r.lastRenderedReducer=n;var i=e.baseQueue,o=r.pending;if(o!==null){if(i!==null){var s=i.next;i.next=o.next,o.next=s}t.baseQueue=i=o,r.pending=null}if(o=e.baseState,i===null)e.memoizedState=o;else{t=i.next;var a=s=null,c=null,l=t,p=!1;do{var d=l.lane&-536870913;if(d!==l.lane?(Se&d)===d:(as&d)===d){var m=l.revertLane;if(m===0)c!==null&&(c=c.next={lane:0,revertLane:0,action:l.action,hasEagerState:l.hasEagerState,eagerState:l.eagerState,next:null}),d===zc&&(p=!0);else if((as&m)===m){l=l.next,m===zc&&(p=!0);continue}else d={lane:0,revertLane:l.revertLane,action:l.action,hasEagerState:l.hasEagerState,eagerState:l.eagerState,next:null},c===null?(a=c=d,s=o):c=c.next=d,re.lanes|=m,us|=m;d=l.action,ma&&n(o,d),o=l.hasEagerState?l.eagerState:n(o,d)}else m={lane:d,revertLane:l.revertLane,action:l.action,hasEagerState:l.hasEagerState,eagerState:l.eagerState,next:null},c===null?(a=c=m,s=o):c=c.next=m,re.lanes|=d,us|=d;l=l.next}while(l!==null&&l!==t);if(c===null?s=o:c.next=a,!dr(o,e.memoizedState)&&(Qt=!0,p&&(n=Uc,n!==null)))throw n;e.memoizedState=o,e.baseState=s,e.baseQueue=c,r.lastRenderedState=o}return i===null&&(r.lanes=0),[e.memoizedState,r.dispatch]}function kx(e){var t=At(),n=t.queue;if(n===null)throw Error(D(311));n.lastRenderedReducer=e;var r=n.dispatch,i=n.pending,o=t.memoizedState;if(i!==null){n.pending=null;var s=i=i.next;do o=e(o,s.action),s=s.next;while(s!==i);dr(o,t.memoizedState)||(Qt=!0),t.memoizedState=o,t.baseQueue===null&&(t.baseState=o),n.lastRenderedState=o}return[o,r]}function tC(e,t,n){var r=re,i=At(),o=we;if(o){if(n===void 0)throw Error(D(407));n=n()}else n=t();var s=!dr((Fe||i).memoizedState,n);s&&(i.memoizedState=n,Qt=!0),i=i.queue;var a=iC.bind(null,r,i,e);if(sf(2048,8,a,[e]),i.getSnapshot!==t||s||Ot!==null&&Ot.memoizedState.tag&1){if(r.flags|=2048,Gc(9,Ch(),rC.bind(null,r,i,n,t),null),Xe===null)throw Error(D(349));o||as&124||nC(r,t,n)}return n}function nC(e,t,n){e.flags|=16384,e={getSnapshot:t,value:n},t=re.updateQueue,t===null?(t=gv(),re.updateQueue=t,t.stores=[e]):(n=t.stores,n===null?t.stores=[e]:n.push(e))}function rC(e,t,n,r){t.value=n,t.getSnapshot=r,oC(t)&&sC(e)}function iC(e,t,n){return n(function(){oC(t)&&sC(e)})}function oC(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!dr(e,n)}catch{return!0}}function sC(e){var t=Wc(e,2);t!==null&&fr(t,e,2)}function TT(e){var t=$n();if(typeof e=="function"){var n=e;if(e=n(),ma){Yo(!0);try{n()}finally{Yo(!1)}}}return t.memoizedState=t.baseState=e,t.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:co,lastRenderedState:e},t}function aC(e,t,n,r){return e.baseState=n,Sv(e,Fe,typeof r=="function"?r:co)}function UG(e,t,n,r,i){if(Nh(e))throw Error(D(485));if(e=t.action,e!==null){var o={payload:i,action:e,next:null,isTransition:!0,status:"pending",value:null,reason:null,listeners:[],then:function(s){o.listeners.push(s)}};X.T!==null?n(!0):o.isTransition=!1,r(o),n=t.pending,n===null?(o.next=t.pending=o,cC(t,o)):(o.next=n.next,t.pending=n.next=o)}}function cC(e,t){var n=t.action,r=t.payload,i=e.state;if(t.isTransition){var o=X.T,s={};X.T=s;try{var a=n(i,r),c=X.S;c!==null&&c(s,a),yR(e,t,a)}catch(l){vT(e,t,l)}finally{X.T=o}}else try{o=n(i,r),yR(e,t,o)}catch(l){vT(e,t,l)}}function yR(e,t,n){n!==null&&typeof n=="object"&&typeof n.then=="function"?n.then(function(r){gR(e,t,r)},function(r){return vT(e,t,r)}):gR(e,t,n)}function gR(e,t,n){t.status="fulfilled",t.value=n,uC(t),e.state=n,t=e.pending,t!==null&&(n=t.next,n===t?e.pending=null:(n=n.next,t.next=n,cC(e,n)))}function vT(e,t,n){var r=e.pending;if(e.pending=null,r!==null){r=r.next;do t.status="rejected",t.reason=n,uC(t),t=t.next;while(t!==r)}e.action=null}function uC(e){e=e.listeners;for(var t=0;t<e.length;t++)(0,e[t])()}function lC(e,t){return t}function bR(e,t){if(we){var n=Xe.formState;if(n!==null){e:{var r=re;if(we){if(pt){t:{for(var i=pt,o=bi;i.nodeType!==8;){if(!o){i=null;break t}if(i=Wr(i.nextSibling),i===null){i=null;break t}}o=i.data,i=o==="F!"||o==="F"?i:null}if(i){pt=Wr(i.nextSibling),r=i.data==="F!";break e}}fa(r)}r=!1}r&&(t=n[0])}}return n=$n(),n.memoizedState=n.baseState=t,r={pending:null,lanes:0,dispatch:null,lastRenderedReducer:lC,lastRenderedState:t},n.queue=r,n=MC.bind(null,re,r),r.dispatch=n,r=TT(!1),o=Iv.bind(null,re,!1,r.queue),r=$n(),i={state:t,dispatch:null,action:e,pending:null},r.queue=i,n=UG.bind(null,re,i,o,n),i.dispatch=n,r.memoizedState=e,[t,n,!1]}function SR(e){var t=At();return pC(t,Fe,e)}function pC(e,t,n){if(t=Sv(e,t,lC)[0],e=Fm(co)[0],typeof t=="object"&&t!==null&&typeof t.then=="function")try{var r=of(t)}catch(s){throw s===rf?Rh:s}else r=t;t=At();var i=t.queue,o=i.dispatch;return n!==t.memoizedState&&(re.flags|=2048,Gc(9,Ch(),_G.bind(null,i,n),null)),[r,o,e]}function _G(e,t){e.action=t}function xR(e){var t=At(),n=Fe;if(n!==null)return pC(t,n,e);At(),t=t.memoizedState,n=At();var r=n.queue.dispatch;return n.memoizedState=e,[t,r,!1]}function Gc(e,t,n,r){return e={tag:e,create:n,deps:r,inst:t,next:null},t=re.updateQueue,t===null&&(t=gv(),re.updateQueue=t),n=t.lastEffect,n===null?t.lastEffect=e.next=e:(r=n.next,n.next=e,e.next=r,t.lastEffect=e),e}function Ch(){return{destroy:void 0,resource:void 0}}function fC(){return At().memoizedState}function $m(e,t,n,r){var i=$n();r=r===void 0?null:r,re.flags|=e,i.memoizedState=Gc(1|t,Ch(),n,r)}function sf(e,t,n,r){var i=At();r=r===void 0?null:r;var o=i.memoizedState.inst;Fe!==null&&r!==null&&fv(r,Fe.memoizedState.deps)?i.memoizedState=Gc(t,o,n,r):(re.flags|=e,i.memoizedState=Gc(1|t,o,n,r))}function TR(e,t){$m(8390656,8,e,t)}function dC(e,t){sf(2048,8,e,t)}function mC(e,t){return sf(4,2,e,t)}function hC(e,t){return sf(4,4,e,t)}function yC(e,t){if(typeof t=="function"){e=e();var n=t(e);return function(){typeof n=="function"?n():t(null)}}if(t!=null)return e=e(),t.current=e,function(){t.current=null}}function gC(e,t,n){n=n!=null?n.concat([e]):null,sf(4,4,yC.bind(null,t,e),n)}function xv(){}function bC(e,t){var n=At();t=t===void 0?null:t;var r=n.memoizedState;return t!==null&&fv(t,r[1])?r[0]:(n.memoizedState=[e,t],e)}function SC(e,t){var n=At();t=t===void 0?null:t;var r=n.memoizedState;if(t!==null&&fv(t,r[1]))return r[0];if(r=e(),ma){Yo(!0);try{e()}finally{Yo(!1)}}return n.memoizedState=[r,t],r}function Tv(e,t,n){return n===void 0||as&1073741824?e.memoizedState=t:(e.memoizedState=n,e=u1(),re.lanes|=e,us|=e,n)}function xC(e,t,n,r){return dr(n,t)?n:Hc.current!==null?(e=Tv(e,n,r),dr(e,t)||(Qt=!0),e):as&42?(e=u1(),re.lanes|=e,us|=e,t):(Qt=!0,e.memoizedState=n)}function TC(e,t,n,r,i){var o=Me.p;Me.p=o!==0&&8>o?o:8;var s=X.T,a={};X.T=a,Iv(e,!1,t,n);try{var c=i(),l=X.S;if(l!==null&&l(a,c),c!==null&&typeof c=="object"&&typeof c.then=="function"){var p=NG(c,r);Ap(e,t,p,pr(e))}else Ap(e,t,r,pr(e))}catch(d){Ap(e,t,{then:function(){},status:"rejected",reason:d},pr())}finally{Me.p=o,X.T=s}}function jG(){}function IT(e,t,n,r){if(e.tag!==5)throw Error(D(476));var i=vC(e).queue;TC(e,i,t,oa,n===null?jG:function(){return IC(e),n(r)})}function vC(e){var t=e.memoizedState;if(t!==null)return t;t={memoizedState:oa,baseState:oa,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:co,lastRenderedState:oa},next:null};var n={};return t.next={memoizedState:n,baseState:n,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:co,lastRenderedState:n},next:null},e.memoizedState=t,e=e.alternate,e!==null&&(e.memoizedState=t),t}function IC(e){var t=vC(e).next.queue;Ap(e,t,{},pr())}function vv(){return hn(Hp)}function EC(){return At().memoizedState}function wC(){return At().memoizedState}function LG(e){for(var t=e.return;t!==null;){switch(t.tag){case 24:case 3:var n=pr();e=es(n);var r=ts(t,e,n);r!==null&&(fr(r,t,n),wp(r,t,n)),t={cache:cv()},e.payload=t;return}t=t.return}}function BG(e,t,n){var r=pr();n={lane:r,revertLane:0,action:n,hasEagerState:!1,eagerState:null,next:null},Nh(e)?OC(t,n):(n=iv(e,t,n,r),n!==null&&(fr(n,e,r),AC(n,t,r)))}function MC(e,t,n){var r=pr();Ap(e,t,n,r)}function Ap(e,t,n,r){var i={lane:r,revertLane:0,action:n,hasEagerState:!1,eagerState:null,next:null};if(Nh(e))OC(t,i);else{var o=e.alternate;if(e.lanes===0&&(o===null||o.lanes===0)&&(o=t.lastRenderedReducer,o!==null))try{var s=t.lastRenderedState,a=o(s,n);if(i.hasEagerState=!0,i.eagerState=a,dr(a,s))return Ah(e,t,i,0),Xe===null&&Oh(),!1}catch{}finally{}if(n=iv(e,t,i,r),n!==null)return fr(n,e,r),AC(n,t,r),!0}return!1}function Iv(e,t,n,r){if(r={lane:2,revertLane:Cv(),action:r,hasEagerState:!1,eagerState:null,next:null},Nh(e)){if(t)throw Error(D(479))}else t=iv(e,n,r,2),t!==null&&fr(t,e,2)}function Nh(e){var t=e.alternate;return e===re||t!==null&&t===re}function OC(e,t){_c=ih=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function AC(e,t,n){if(n&4194048){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,bP(e,n)}}var sh={readContext:hn,use:Ph,useCallback:yt,useContext:yt,useEffect:yt,useImperativeHandle:yt,useLayoutEffect:yt,useInsertionEffect:yt,useMemo:yt,useReducer:yt,useRef:yt,useState:yt,useDebugValue:yt,useDeferredValue:yt,useTransition:yt,useSyncExternalStore:yt,useId:yt,useHostTransitionStatus:yt,useFormState:yt,useActionState:yt,useOptimistic:yt,useMemoCache:yt,useCacheRefresh:yt},RC={readContext:hn,use:Ph,useCallback:function(e,t){return $n().memoizedState=[e,t===void 0?null:t],e},useContext:hn,useEffect:TR,useImperativeHandle:function(e,t,n){n=n!=null?n.concat([e]):null,$m(4194308,4,yC.bind(null,t,e),n)},useLayoutEffect:function(e,t){return $m(4194308,4,e,t)},useInsertionEffect:function(e,t){$m(4,2,e,t)},useMemo:function(e,t){var n=$n();t=t===void 0?null:t;var r=e();if(ma){Yo(!0);try{e()}finally{Yo(!1)}}return n.memoizedState=[r,t],r},useReducer:function(e,t,n){var r=$n();if(n!==void 0){var i=n(t);if(ma){Yo(!0);try{n(t)}finally{Yo(!1)}}}else i=t;return r.memoizedState=r.baseState=i,e={pending:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:i},r.queue=e,e=e.dispatch=BG.bind(null,re,e),[r.memoizedState,e]},useRef:function(e){var t=$n();return e={current:e},t.memoizedState=e},useState:function(e){e=TT(e);var t=e.queue,n=MC.bind(null,re,t);return t.dispatch=n,[e.memoizedState,n]},useDebugValue:xv,useDeferredValue:function(e,t){var n=$n();return Tv(n,e,t)},useTransition:function(){var e=TT(!1);return e=TC.bind(null,re,e.queue,!0,!1),$n().memoizedState=e,[!1,e]},useSyncExternalStore:function(e,t,n){var r=re,i=$n();if(we){if(n===void 0)throw Error(D(407));n=n()}else{if(n=t(),Xe===null)throw Error(D(349));Se&124||nC(r,t,n)}i.memoizedState=n;var o={value:n,getSnapshot:t};return i.queue=o,TR(iC.bind(null,r,o,e),[e]),r.flags|=2048,Gc(9,Ch(),rC.bind(null,r,o,n,t),null),n},useId:function(){var e=$n(),t=Xe.identifierPrefix;if(we){var n=no,r=to;n=(r&~(1<<32-lr(r)-1)).toString(32)+n,t="\xAB"+t+"R"+n,n=oh++,0<n&&(t+="H"+n.toString(32)),t+="\xBB"}else n=kG++,t="\xAB"+t+"r"+n.toString(32)+"\xBB";return e.memoizedState=t},useHostTransitionStatus:vv,useFormState:bR,useActionState:bR,useOptimistic:function(e){var t=$n();t.memoizedState=t.baseState=e;var n={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return t.queue=n,t=Iv.bind(null,re,!0,n),n.dispatch=t,[e,t]},useMemoCache:bv,useCacheRefresh:function(){return $n().memoizedState=LG.bind(null,re)}},PC={readContext:hn,use:Ph,useCallback:bC,useContext:hn,useEffect:dC,useImperativeHandle:gC,useInsertionEffect:mC,useLayoutEffect:hC,useMemo:SC,useReducer:Fm,useRef:fC,useState:function(){return Fm(co)},useDebugValue:xv,useDeferredValue:function(e,t){var n=At();return xC(n,Fe.memoizedState,e,t)},useTransition:function(){var e=Fm(co)[0],t=At().memoizedState;return[typeof e=="boolean"?e:of(e),t]},useSyncExternalStore:tC,useId:EC,useHostTransitionStatus:vv,useFormState:SR,useActionState:SR,useOptimistic:function(e,t){var n=At();return aC(n,Fe,e,t)},useMemoCache:bv,useCacheRefresh:wC},FG={readContext:hn,use:Ph,useCallback:bC,useContext:hn,useEffect:dC,useImperativeHandle:gC,useInsertionEffect:mC,useLayoutEffect:hC,useMemo:SC,useReducer:kx,useRef:fC,useState:function(){return kx(co)},useDebugValue:xv,useDeferredValue:function(e,t){var n=At();return Fe===null?Tv(n,e,t):xC(n,Fe.memoizedState,e,t)},useTransition:function(){var e=kx(co)[0],t=At().memoizedState;return[typeof e=="boolean"?e:of(e),t]},useSyncExternalStore:tC,useId:EC,useHostTransitionStatus:vv,useFormState:xR,useActionState:xR,useOptimistic:function(e,t){var n=At();return Fe!==null?aC(n,Fe,e,t):(n.baseState=e,[e,n.queue.dispatch])},useMemoCache:bv,useCacheRefresh:wC},Lc=null,Fp=0;function Mm(e){var t=Fp;return Fp+=1,Lc===null&&(Lc=[]),JP(Lc,e,t)}function pp(e,t){t=t.props.ref,e.ref=t!==void 0?t:null}function Om(e,t){throw t.$$typeof===y8?Error(D(525)):(e=Object.prototype.toString.call(t),Error(D(31,e==="[object Object]"?"object with keys {"+Object.keys(t).join(", ")+"}":e)))}function vR(e){var t=e._init;return t(e._payload)}function CC(e){function t(b,f){if(e){var g=b.deletions;g===null?(b.deletions=[f],b.flags|=16):g.push(f)}}function n(b,f){if(!e)return null;for(;f!==null;)t(b,f),f=f.sibling;return null}function r(b){for(var f=new Map;b!==null;)b.key!==null?f.set(b.key,b):f.set(b.index,b),b=b.sibling;return f}function i(b,f){return b=oo(b,f),b.index=0,b.sibling=null,b}function o(b,f,g){return b.index=g,e?(g=b.alternate,g!==null?(g=g.index,g<f?(b.flags|=67108866,f):g):(b.flags|=67108866,f)):(b.flags|=1048576,f)}function s(b){return e&&b.alternate===null&&(b.flags|=67108866),b}function a(b,f,g,v){return f===null||f.tag!==6?(f=Px(g,b.mode,v),f.return=b,f):(f=i(f,g),f.return=b,f)}function c(b,f,g,v){var I=g.type;return I===xc?p(b,f,g.props.children,v,g.key):f!==null&&(f.elementType===I||typeof I=="object"&&I!==null&&I.$$typeof===zo&&vR(I)===f.type)?(f=i(f,g.props),pp(f,g),f.return=b,f):(f=Lm(g.type,g.key,g.props,null,b.mode,v),pp(f,g),f.return=b,f)}function l(b,f,g,v){return f===null||f.tag!==4||f.stateNode.containerInfo!==g.containerInfo||f.stateNode.implementation!==g.implementation?(f=Cx(g,b.mode,v),f.return=b,f):(f=i(f,g.children||[]),f.return=b,f)}function p(b,f,g,v,I){return f===null||f.tag!==7?(f=sa(g,b.mode,v,I),f.return=b,f):(f=i(f,g),f.return=b,f)}function d(b,f,g){if(typeof f=="string"&&f!==""||typeof f=="number"||typeof f=="bigint")return f=Px(""+f,b.mode,g),f.return=b,f;if(typeof f=="object"&&f!==null){switch(f.$$typeof){case gm:return g=Lm(f.type,f.key,f.props,null,b.mode,g),pp(g,f),g.return=b,g;case yp:return f=Cx(f,b.mode,g),f.return=b,f;case zo:var v=f._init;return f=v(f._payload),d(b,f,g)}if(gp(f)||cp(f))return f=sa(f,b.mode,g,null),f.return=b,f;if(typeof f.then=="function")return d(b,Mm(f),g);if(f.$$typeof===eo)return d(b,Em(b,f),g);Om(b,f)}return null}function m(b,f,g,v){var I=f!==null?f.key:null;if(typeof g=="string"&&g!==""||typeof g=="number"||typeof g=="bigint")return I!==null?null:a(b,f,""+g,v);if(typeof g=="object"&&g!==null){switch(g.$$typeof){case gm:return g.key===I?c(b,f,g,v):null;case yp:return g.key===I?l(b,f,g,v):null;case zo:return I=g._init,g=I(g._payload),m(b,f,g,v)}if(gp(g)||cp(g))return I!==null?null:p(b,f,g,v,null);if(typeof g.then=="function")return m(b,f,Mm(g),v);if(g.$$typeof===eo)return m(b,f,Em(b,g),v);Om(b,g)}return null}function y(b,f,g,v,I){if(typeof v=="string"&&v!==""||typeof v=="number"||typeof v=="bigint")return b=b.get(g)||null,a(f,b,""+v,I);if(typeof v=="object"&&v!==null){switch(v.$$typeof){case gm:return b=b.get(v.key===null?g:v.key)||null,c(f,b,v,I);case yp:return b=b.get(v.key===null?g:v.key)||null,l(f,b,v,I);case zo:var M=v._init;return v=M(v._payload),y(b,f,g,v,I)}if(gp(v)||cp(v))return b=b.get(g)||null,p(f,b,v,I,null);if(typeof v.then=="function")return y(b,f,g,Mm(v),I);if(v.$$typeof===eo)return y(b,f,g,Em(f,v),I);Om(f,v)}return null}function S(b,f,g,v){for(var I=null,M=null,O=f,C=f=0,z=null;O!==null&&C<g.length;C++){O.index>C?(z=O,O=null):z=O.sibling;var F=m(b,O,g[C],v);if(F===null){O===null&&(O=z);break}e&&O&&F.alternate===null&&t(b,O),f=o(F,f,C),M===null?I=F:M.sibling=F,M=F,O=z}if(C===g.length)return n(b,O),we&&ra(b,C),I;if(O===null){for(;C<g.length;C++)O=d(b,g[C],v),O!==null&&(f=o(O,f,C),M===null?I=O:M.sibling=O,M=O);return we&&ra(b,C),I}for(O=r(O);C<g.length;C++)z=y(O,b,C,g[C],v),z!==null&&(e&&z.alternate!==null&&O.delete(z.key===null?C:z.key),f=o(z,f,C),M===null?I=z:M.sibling=z,M=z);return e&&O.forEach(function(N){return t(b,N)}),we&&ra(b,C),I}function T(b,f,g,v){if(g==null)throw Error(D(151));for(var I=null,M=null,O=f,C=f=0,z=null,F=g.next();O!==null&&!F.done;C++,F=g.next()){O.index>C?(z=O,O=null):z=O.sibling;var N=m(b,O,F.value,v);if(N===null){O===null&&(O=z);break}e&&O&&N.alternate===null&&t(b,O),f=o(N,f,C),M===null?I=N:M.sibling=N,M=N,O=z}if(F.done)return n(b,O),we&&ra(b,C),I;if(O===null){for(;!F.done;C++,F=g.next())F=d(b,F.value,v),F!==null&&(f=o(F,f,C),M===null?I=F:M.sibling=F,M=F);return we&&ra(b,C),I}for(O=r(O);!F.done;C++,F=g.next())F=y(O,b,C,F.value,v),F!==null&&(e&&F.alternate!==null&&O.delete(F.key===null?C:F.key),f=o(F,f,C),M===null?I=F:M.sibling=F,M=F);return e&&O.forEach(function(H){return t(b,H)}),we&&ra(b,C),I}function E(b,f,g,v){if(typeof g=="object"&&g!==null&&g.type===xc&&g.key===null&&(g=g.props.children),typeof g=="object"&&g!==null){switch(g.$$typeof){case gm:e:{for(var I=g.key;f!==null;){if(f.key===I){if(I=g.type,I===xc){if(f.tag===7){n(b,f.sibling),v=i(f,g.props.children),v.return=b,b=v;break e}}else if(f.elementType===I||typeof I=="object"&&I!==null&&I.$$typeof===zo&&vR(I)===f.type){n(b,f.sibling),v=i(f,g.props),pp(v,g),v.return=b,b=v;break e}n(b,f);break}else t(b,f);f=f.sibling}g.type===xc?(v=sa(g.props.children,b.mode,v,g.key),v.return=b,b=v):(v=Lm(g.type,g.key,g.props,null,b.mode,v),pp(v,g),v.return=b,b=v)}return s(b);case yp:e:{for(I=g.key;f!==null;){if(f.key===I)if(f.tag===4&&f.stateNode.containerInfo===g.containerInfo&&f.stateNode.implementation===g.implementation){n(b,f.sibling),v=i(f,g.children||[]),v.return=b,b=v;break e}else{n(b,f);break}else t(b,f);f=f.sibling}v=Cx(g,b.mode,v),v.return=b,b=v}return s(b);case zo:return I=g._init,g=I(g._payload),E(b,f,g,v)}if(gp(g))return S(b,f,g,v);if(cp(g)){if(I=cp(g),typeof I!="function")throw Error(D(150));return g=I.call(g),T(b,f,g,v)}if(typeof g.then=="function")return E(b,f,Mm(g),v);if(g.$$typeof===eo)return E(b,f,Em(b,g),v);Om(b,g)}return typeof g=="string"&&g!==""||typeof g=="number"||typeof g=="bigint"?(g=""+g,f!==null&&f.tag===6?(n(b,f.sibling),v=i(f,g),v.return=b,b=v):(n(b,f),v=Px(g,b.mode,v),v.return=b,b=v),s(b)):n(b,f)}return function(b,f,g,v){try{Fp=0;var I=E(b,f,g,v);return Lc=null,I}catch(O){if(O===rf||O===Rh)throw O;var M=cr(29,O,null,b.mode);return M.lanes=v,M.return=b,M}finally{}}}var qc=CC(!0),NC=CC(!1),_r=Ii(null),vi=null;function qo(e){var t=e.alternate;rt(jt,jt.current&1),rt(_r,e),vi===null&&(t===null||Hc.current!==null||t.memoizedState!==null)&&(vi=e)}function kC(e){if(e.tag===22){if(rt(jt,jt.current),rt(_r,e),vi===null){var t=e.alternate;t!==null&&t.memoizedState!==null&&(vi=e)}}else Vo(e)}function Vo(){rt(jt,jt.current),rt(_r,_r.current)}function io(e){Yt(_r),vi===e&&(vi=null),Yt(jt)}var jt=Ii(0);function ah(e){for(var t=e;t!==null;){if(t.tag===13){var n=t.memoizedState;if(n!==null&&(n=n.dehydrated,n===null||n.data==="$?"||FT(n)))return t}else if(t.tag===19&&t.memoizedProps.revealOrder!==void 0){if(t.flags&128)return t}else if(t.child!==null){t.child.return=t,t=t.child;continue}if(t===e)break;for(;t.sibling===null;){if(t.return===null||t.return===e)return null;t=t.return}t.sibling.return=t.return,t=t.sibling}return null}function Dx(e,t,n,r){t=e.memoizedState,n=n(r,t),n=n==null?t:We({},t,n),e.memoizedState=n,e.lanes===0&&(e.updateQueue.baseState=n)}var ET={enqueueSetState:function(e,t,n){e=e._reactInternals;var r=pr(),i=es(r);i.payload=t,n!=null&&(i.callback=n),t=ts(e,i,r),t!==null&&(fr(t,e,r),wp(t,e,r))},enqueueReplaceState:function(e,t,n){e=e._reactInternals;var r=pr(),i=es(r);i.tag=1,i.payload=t,n!=null&&(i.callback=n),t=ts(e,i,r),t!==null&&(fr(t,e,r),wp(t,e,r))},enqueueForceUpdate:function(e,t){e=e._reactInternals;var n=pr(),r=es(n);r.tag=2,t!=null&&(r.callback=t),t=ts(e,r,n),t!==null&&(fr(t,e,n),wp(t,e,n))}};function IR(e,t,n,r,i,o,s){return e=e.stateNode,typeof e.shouldComponentUpdate=="function"?e.shouldComponentUpdate(r,o,s):t.prototype&&t.prototype.isPureReactComponent?!jp(n,r)||!jp(i,o):!0}function ER(e,t,n,r){e=t.state,typeof t.componentWillReceiveProps=="function"&&t.componentWillReceiveProps(n,r),typeof t.UNSAFE_componentWillReceiveProps=="function"&&t.UNSAFE_componentWillReceiveProps(n,r),t.state!==e&&ET.enqueueReplaceState(t,t.state,null)}function ha(e,t){var n=t;if("ref"in t){n={};for(var r in t)r!=="ref"&&(n[r]=t[r])}if(e=e.defaultProps){n===t&&(n=We({},n));for(var i in e)n[i]===void 0&&(n[i]=e[i])}return n}var ch=typeof reportError=="function"?reportError:function(e){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var t=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof e=="object"&&e!==null&&typeof e.message=="string"?String(e.message):String(e),error:e});if(!window.dispatchEvent(t))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",e);return}console.error(e)};function DC(e){ch(e)}function UC(e){console.error(e)}function _C(e){ch(e)}function uh(e,t){try{var n=e.onUncaughtError;n(t.value,{componentStack:t.stack})}catch(r){setTimeout(function(){throw r})}}function wR(e,t,n){try{var r=e.onCaughtError;r(n.value,{componentStack:n.stack,errorBoundary:t.tag===1?t.stateNode:null})}catch(i){setTimeout(function(){throw i})}}function wT(e,t,n){return n=es(n),n.tag=3,n.payload={element:null},n.callback=function(){uh(e,t)},n}function jC(e){return e=es(e),e.tag=3,e}function LC(e,t,n,r){var i=n.type.getDerivedStateFromError;if(typeof i=="function"){var o=r.value;e.payload=function(){return i(o)},e.callback=function(){wR(t,n,r)}}var s=n.stateNode;s!==null&&typeof s.componentDidCatch=="function"&&(e.callback=function(){wR(t,n,r),typeof i!="function"&&(ns===null?ns=new Set([this]):ns.add(this));var a=r.stack;this.componentDidCatch(r.value,{componentStack:a!==null?a:""})})}function $G(e,t,n,r,i){if(n.flags|=32768,r!==null&&typeof r=="object"&&typeof r.then=="function"){if(t=n.alternate,t!==null&&tf(t,n,i,!0),n=_r.current,n!==null){switch(n.tag){case 13:return vi===null?kT():n.alternate===null&&ft===0&&(ft=3),n.flags&=-257,n.flags|=65536,n.lanes=i,r===gT?n.flags|=16384:(t=n.updateQueue,t===null?n.updateQueue=new Set([r]):t.add(r),Gx(e,r,i)),!1;case 22:return n.flags|=65536,r===gT?n.flags|=16384:(t=n.updateQueue,t===null?(t={transitions:null,markerInstances:null,retryQueue:new Set([r])},n.updateQueue=t):(n=t.retryQueue,n===null?t.retryQueue=new Set([r]):n.add(r)),Gx(e,r,i)),!1}throw Error(D(435,n.tag))}return Gx(e,r,i),kT(),!1}if(we)return t=_r.current,t!==null?(!(t.flags&65536)&&(t.flags|=256),t.flags|=65536,t.lanes=i,r!==fT&&(e=Error(D(422),{cause:r}),Lp(Dr(e,n)))):(r!==fT&&(t=Error(D(423),{cause:r}),Lp(Dr(t,n))),e=e.current.alternate,e.flags|=65536,i&=-i,e.lanes|=i,r=Dr(r,n),i=wT(e.stateNode,r,i),Nx(e,i),ft!==4&&(ft=2)),!1;var o=Error(D(520),{cause:r});if(o=Dr(o,n),Cp===null?Cp=[o]:Cp.push(o),ft!==4&&(ft=2),t===null)return!0;r=Dr(r,n),n=t;do{switch(n.tag){case 3:return n.flags|=65536,e=i&-i,n.lanes|=e,e=wT(n.stateNode,r,e),Nx(n,e),!1;case 1:if(t=n.type,o=n.stateNode,(n.flags&128)===0&&(typeof t.getDerivedStateFromError=="function"||o!==null&&typeof o.componentDidCatch=="function"&&(ns===null||!ns.has(o))))return n.flags|=65536,i&=-i,n.lanes|=i,i=jC(i),LC(i,e,n,r),Nx(n,i),!1}n=n.return}while(n!==null);return!1}var BC=Error(D(461)),Qt=!1;function nn(e,t,n,r){t.child=e===null?NC(t,null,n,r):qc(t,e.child,n,r)}function MR(e,t,n,r,i){n=n.render;var o=t.ref;if("ref"in r){var s={};for(var a in r)a!=="ref"&&(s[a]=r[a])}else s=r;return da(t),r=dv(e,t,n,s,o,i),a=mv(),e!==null&&!Qt?(hv(e,t,i),uo(e,t,i)):(we&&a&&sv(t),t.flags|=1,nn(e,t,r,i),t.child)}function OR(e,t,n,r,i){if(e===null){var o=n.type;return typeof o=="function"&&!ov(o)&&o.defaultProps===void 0&&n.compare===null?(t.tag=15,t.type=o,FC(e,t,o,r,i)):(e=Lm(n.type,null,r,t,t.mode,i),e.ref=t.ref,e.return=t,t.child=e)}if(o=e.child,!Ev(e,i)){var s=o.memoizedProps;if(n=n.compare,n=n!==null?n:jp,n(s,r)&&e.ref===t.ref)return uo(e,t,i)}return t.flags|=1,e=oo(o,r),e.ref=t.ref,e.return=t,t.child=e}function FC(e,t,n,r,i){if(e!==null){var o=e.memoizedProps;if(jp(o,r)&&e.ref===t.ref)if(Qt=!1,t.pendingProps=r=o,Ev(e,i))e.flags&131072&&(Qt=!0);else return t.lanes=e.lanes,uo(e,t,i)}return MT(e,t,n,r,i)}function $C(e,t,n){var r=t.pendingProps,i=r.children,o=e!==null?e.memoizedState:null;if(r.mode==="hidden"){if(t.flags&128){if(r=o!==null?o.baseLanes|n:n,e!==null){for(i=t.child=e.child,o=0;i!==null;)o=o|i.lanes|i.childLanes,i=i.sibling;t.childLanes=o&~r}else t.childLanes=0,t.child=null;return AR(e,t,r,n)}if(n&536870912)t.memoizedState={baseLanes:0,cachePool:null},e!==null&&Bm(t,o!==null?o.cachePool:null),o!==null?hR(t,o):xT(),kC(t);else return t.lanes=t.childLanes=536870912,AR(e,t,o!==null?o.baseLanes|n:n,n)}else o!==null?(Bm(t,o.cachePool),hR(t,o),Vo(t),t.memoizedState=null):(e!==null&&Bm(t,null),xT(),Vo(t));return nn(e,t,i,n),t.child}function AR(e,t,n,r){var i=uv();return i=i===null?null:{parent:_t._currentValue,pool:i},t.memoizedState={baseLanes:n,cachePool:i},e!==null&&Bm(t,null),xT(),kC(t),e!==null&&tf(e,t,r,!0),null}function Km(e,t){var n=t.ref;if(n===null)e!==null&&e.ref!==null&&(t.flags|=4194816);else{if(typeof n!="function"&&typeof n!="object")throw Error(D(284));(e===null||e.ref!==n)&&(t.flags|=4194816)}}function MT(e,t,n,r,i){return da(t),n=dv(e,t,n,r,void 0,i),r=mv(),e!==null&&!Qt?(hv(e,t,i),uo(e,t,i)):(we&&r&&sv(t),t.flags|=1,nn(e,t,n,i),t.child)}function RR(e,t,n,r,i,o){return da(t),t.updateQueue=null,n=eC(t,r,n,i),WP(e),r=mv(),e!==null&&!Qt?(hv(e,t,o),uo(e,t,o)):(we&&r&&sv(t),t.flags|=1,nn(e,t,n,o),t.child)}function PR(e,t,n,r,i){if(da(t),t.stateNode===null){var o=Ac,s=n.contextType;typeof s=="object"&&s!==null&&(o=hn(s)),o=new n(r,o),t.memoizedState=o.state!==null&&o.state!==void 0?o.state:null,o.updater=ET,t.stateNode=o,o._reactInternals=t,o=t.stateNode,o.props=r,o.state=t.memoizedState,o.refs={},lv(t),s=n.contextType,o.context=typeof s=="object"&&s!==null?hn(s):Ac,o.state=t.memoizedState,s=n.getDerivedStateFromProps,typeof s=="function"&&(Dx(t,n,s,r),o.state=t.memoizedState),typeof n.getDerivedStateFromProps=="function"||typeof o.getSnapshotBeforeUpdate=="function"||typeof o.UNSAFE_componentWillMount!="function"&&typeof o.componentWillMount!="function"||(s=o.state,typeof o.componentWillMount=="function"&&o.componentWillMount(),typeof o.UNSAFE_componentWillMount=="function"&&o.UNSAFE_componentWillMount(),s!==o.state&&ET.enqueueReplaceState(o,o.state,null),Op(t,r,o,i),Mp(),o.state=t.memoizedState),typeof o.componentDidMount=="function"&&(t.flags|=4194308),r=!0}else if(e===null){o=t.stateNode;var a=t.memoizedProps,c=ha(n,a);o.props=c;var l=o.context,p=n.contextType;s=Ac,typeof p=="object"&&p!==null&&(s=hn(p));var d=n.getDerivedStateFromProps;p=typeof d=="function"||typeof o.getSnapshotBeforeUpdate=="function",a=t.pendingProps!==a,p||typeof o.UNSAFE_componentWillReceiveProps!="function"&&typeof o.componentWillReceiveProps!="function"||(a||l!==s)&&ER(t,o,r,s),Ho=!1;var m=t.memoizedState;o.state=m,Op(t,r,o,i),Mp(),l=t.memoizedState,a||m!==l||Ho?(typeof d=="function"&&(Dx(t,n,d,r),l=t.memoizedState),(c=Ho||IR(t,n,c,r,m,l,s))?(p||typeof o.UNSAFE_componentWillMount!="function"&&typeof o.componentWillMount!="function"||(typeof o.componentWillMount=="function"&&o.componentWillMount(),typeof o.UNSAFE_componentWillMount=="function"&&o.UNSAFE_componentWillMount()),typeof o.componentDidMount=="function"&&(t.flags|=4194308)):(typeof o.componentDidMount=="function"&&(t.flags|=4194308),t.memoizedProps=r,t.memoizedState=l),o.props=r,o.state=l,o.context=s,r=c):(typeof o.componentDidMount=="function"&&(t.flags|=4194308),r=!1)}else{o=t.stateNode,bT(e,t),s=t.memoizedProps,p=ha(n,s),o.props=p,d=t.pendingProps,m=o.context,l=n.contextType,c=Ac,typeof l=="object"&&l!==null&&(c=hn(l)),a=n.getDerivedStateFromProps,(l=typeof a=="function"||typeof o.getSnapshotBeforeUpdate=="function")||typeof o.UNSAFE_componentWillReceiveProps!="function"&&typeof o.componentWillReceiveProps!="function"||(s!==d||m!==c)&&ER(t,o,r,c),Ho=!1,m=t.memoizedState,o.state=m,Op(t,r,o,i),Mp();var y=t.memoizedState;s!==d||m!==y||Ho||e!==null&&e.dependencies!==null&&nh(e.dependencies)?(typeof a=="function"&&(Dx(t,n,a,r),y=t.memoizedState),(p=Ho||IR(t,n,p,r,m,y,c)||e!==null&&e.dependencies!==null&&nh(e.dependencies))?(l||typeof o.UNSAFE_componentWillUpdate!="function"&&typeof o.componentWillUpdate!="function"||(typeof o.componentWillUpdate=="function"&&o.componentWillUpdate(r,y,c),typeof o.UNSAFE_componentWillUpdate=="function"&&o.UNSAFE_componentWillUpdate(r,y,c)),typeof o.componentDidUpdate=="function"&&(t.flags|=4),typeof o.getSnapshotBeforeUpdate=="function"&&(t.flags|=1024)):(typeof o.componentDidUpdate!="function"||s===e.memoizedProps&&m===e.memoizedState||(t.flags|=4),typeof o.getSnapshotBeforeUpdate!="function"||s===e.memoizedProps&&m===e.memoizedState||(t.flags|=1024),t.memoizedProps=r,t.memoizedState=y),o.props=r,o.state=y,o.context=c,r=p):(typeof o.componentDidUpdate!="function"||s===e.memoizedProps&&m===e.memoizedState||(t.flags|=4),typeof o.getSnapshotBeforeUpdate!="function"||s===e.memoizedProps&&m===e.memoizedState||(t.flags|=1024),r=!1)}return o=r,Km(e,t),r=(t.flags&128)!==0,o||r?(o=t.stateNode,n=r&&typeof n.getDerivedStateFromError!="function"?null:o.render(),t.flags|=1,e!==null&&r?(t.child=qc(t,e.child,null,i),t.child=qc(t,null,n,i)):nn(e,t,n,i),t.memoizedState=o.state,e=t.child):e=uo(e,t,i),e}function CR(e,t,n,r){return ef(),t.flags|=256,nn(e,t,n,r),t.child}var Ux={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function _x(e){return{baseLanes:e,cachePool:QP()}}function jx(e,t,n){return e=e!==null?e.childLanes&~n:0,t&&(e|=Ur),e}function KC(e,t,n){var r=t.pendingProps,i=!1,o=(t.flags&128)!==0,s;if((s=o)||(s=e!==null&&e.memoizedState===null?!1:(jt.current&2)!==0),s&&(i=!0,t.flags&=-129),s=(t.flags&32)!==0,t.flags&=-33,e===null){if(we){if(i?qo(t):Vo(t),we){var a=pt,c;if(c=a){e:{for(c=a,a=bi;c.nodeType!==8;){if(!a){a=null;break e}if(c=Wr(c.nextSibling),c===null){a=null;break e}}a=c}a!==null?(t.memoizedState={dehydrated:a,treeContext:aa!==null?{id:to,overflow:no}:null,retryLane:536870912,hydrationErrors:null},c=cr(18,null,null,0),c.stateNode=a,c.return=t,t.child=c,Mn=t,pt=null,c=!0):c=!1}c||fa(t)}if(a=t.memoizedState,a!==null&&(a=a.dehydrated,a!==null))return FT(a)?t.lanes=32:t.lanes=536870912,null;io(t)}return a=r.children,r=r.fallback,i?(Vo(t),i=t.mode,a=lh({mode:"hidden",children:a},i),r=sa(r,i,n,null),a.return=t,r.return=t,a.sibling=r,t.child=a,i=t.child,i.memoizedState=_x(n),i.childLanes=jx(e,s,n),t.memoizedState=Ux,r):(qo(t),OT(t,a))}if(c=e.memoizedState,c!==null&&(a=c.dehydrated,a!==null)){if(o)t.flags&256?(qo(t),t.flags&=-257,t=Lx(e,t,n)):t.memoizedState!==null?(Vo(t),t.child=e.child,t.flags|=128,t=null):(Vo(t),i=r.fallback,a=t.mode,r=lh({mode:"visible",children:r.children},a),i=sa(i,a,n,null),i.flags|=2,r.return=t,i.return=t,r.sibling=i,t.child=r,qc(t,e.child,null,n),r=t.child,r.memoizedState=_x(n),r.childLanes=jx(e,s,n),t.memoizedState=Ux,t=i);else if(qo(t),FT(a)){if(s=a.nextSibling&&a.nextSibling.dataset,s)var l=s.dgst;s=l,r=Error(D(419)),r.stack="",r.digest=s,Lp({value:r,source:null,stack:null}),t=Lx(e,t,n)}else if(Qt||tf(e,t,n,!1),s=(n&e.childLanes)!==0,Qt||s){if(s=Xe,s!==null&&(r=n&-n,r=r&42?1:QT(r),r=r&(s.suspendedLanes|n)?0:r,r!==0&&r!==c.retryLane))throw c.retryLane=r,Wc(e,r),fr(s,e,r),BC;a.data==="$?"||kT(),t=Lx(e,t,n)}else a.data==="$?"?(t.flags|=192,t.child=e.child,t=null):(e=c.treeContext,pt=Wr(a.nextSibling),Mn=t,we=!0,ca=null,bi=!1,e!==null&&(Cr[Nr++]=to,Cr[Nr++]=no,Cr[Nr++]=aa,to=e.id,no=e.overflow,aa=t),t=OT(t,r.children),t.flags|=4096);return t}return i?(Vo(t),i=r.fallback,a=t.mode,c=e.child,l=c.sibling,r=oo(c,{mode:"hidden",children:r.children}),r.subtreeFlags=c.subtreeFlags&65011712,l!==null?i=oo(l,i):(i=sa(i,a,n,null),i.flags|=2),i.return=t,r.return=t,r.sibling=i,t.child=r,r=i,i=t.child,a=e.child.memoizedState,a===null?a=_x(n):(c=a.cachePool,c!==null?(l=_t._currentValue,c=c.parent!==l?{parent:l,pool:l}:c):c=QP(),a={baseLanes:a.baseLanes|n,cachePool:c}),i.memoizedState=a,i.childLanes=jx(e,s,n),t.memoizedState=Ux,r):(qo(t),n=e.child,e=n.sibling,n=oo(n,{mode:"visible",children:r.children}),n.return=t,n.sibling=null,e!==null&&(s=t.deletions,s===null?(t.deletions=[e],t.flags|=16):s.push(e)),t.child=n,t.memoizedState=null,n)}function OT(e,t){return t=lh({mode:"visible",children:t},e.mode),t.return=e,e.child=t}function lh(e,t){return e=cr(22,e,null,t),e.lanes=0,e.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null},e}function Lx(e,t,n){return qc(t,e.child,null,n),e=OT(t,t.pendingProps.children),e.flags|=2,t.memoizedState=null,e}function NR(e,t,n){e.lanes|=t;var r=e.alternate;r!==null&&(r.lanes|=t),mT(e.return,t,n)}function Bx(e,t,n,r,i){var o=e.memoizedState;o===null?e.memoizedState={isBackwards:t,rendering:null,renderingStartTime:0,last:r,tail:n,tailMode:i}:(o.isBackwards=t,o.rendering=null,o.renderingStartTime=0,o.last=r,o.tail=n,o.tailMode=i)}function zC(e,t,n){var r=t.pendingProps,i=r.revealOrder,o=r.tail;if(nn(e,t,r.children,n),r=jt.current,r&2)r=r&1|2,t.flags|=128;else{if(e!==null&&e.flags&128)e:for(e=t.child;e!==null;){if(e.tag===13)e.memoizedState!==null&&NR(e,n,t);else if(e.tag===19)NR(e,n,t);else if(e.child!==null){e.child.return=e,e=e.child;continue}if(e===t)break e;for(;e.sibling===null;){if(e.return===null||e.return===t)break e;e=e.return}e.sibling.return=e.return,e=e.sibling}r&=1}switch(rt(jt,r),i){case"forwards":for(n=t.child,i=null;n!==null;)e=n.alternate,e!==null&&ah(e)===null&&(i=n),n=n.sibling;n=i,n===null?(i=t.child,t.child=null):(i=n.sibling,n.sibling=null),Bx(t,!1,i,n,o);break;case"backwards":for(n=null,i=t.child,t.child=null;i!==null;){if(e=i.alternate,e!==null&&ah(e)===null){t.child=i;break}e=i.sibling,i.sibling=n,n=i,i=e}Bx(t,!0,n,null,o);break;case"together":Bx(t,!1,null,null,void 0);break;default:t.memoizedState=null}return t.child}function uo(e,t,n){if(e!==null&&(t.dependencies=e.dependencies),us|=t.lanes,!(n&t.childLanes))if(e!==null){if(tf(e,t,n,!1),(n&t.childLanes)===0)return null}else return null;if(e!==null&&t.child!==e.child)throw Error(D(153));if(t.child!==null){for(e=t.child,n=oo(e,e.pendingProps),t.child=n,n.return=t;e.sibling!==null;)e=e.sibling,n=n.sibling=oo(e,e.pendingProps),n.return=t;n.sibling=null}return t.child}function Ev(e,t){return e.lanes&t?!0:(e=e.dependencies,!!(e!==null&&nh(e)))}function KG(e,t,n){switch(t.tag){case 3:Qm(t,t.stateNode.containerInfo),Go(t,_t,e.memoizedState.cache),ef();break;case 27:case 5:nT(t);break;case 4:Qm(t,t.stateNode.containerInfo);break;case 10:Go(t,t.type,t.memoizedProps.value);break;case 13:var r=t.memoizedState;if(r!==null)return r.dehydrated!==null?(qo(t),t.flags|=128,null):n&t.child.childLanes?KC(e,t,n):(qo(t),e=uo(e,t,n),e!==null?e.sibling:null);qo(t);break;case 19:var i=(e.flags&128)!==0;if(r=(n&t.childLanes)!==0,r||(tf(e,t,n,!1),r=(n&t.childLanes)!==0),i){if(r)return zC(e,t,n);t.flags|=128}if(i=t.memoizedState,i!==null&&(i.rendering=null,i.tail=null,i.lastEffect=null),rt(jt,jt.current),r)break;return null;case 22:case 23:return t.lanes=0,$C(e,t,n);case 24:Go(t,_t,e.memoizedState.cache)}return uo(e,t,n)}function HC(e,t,n){if(e!==null)if(e.memoizedProps!==t.pendingProps)Qt=!0;else{if(!Ev(e,n)&&!(t.flags&128))return Qt=!1,KG(e,t,n);Qt=!!(e.flags&131072)}else Qt=!1,we&&t.flags&1048576&&qP(t,th,t.index);switch(t.lanes=0,t.tag){case 16:e:{e=t.pendingProps;var r=t.elementType,i=r._init;if(r=i(r._payload),t.type=r,typeof r=="function")ov(r)?(e=ha(r,e),t.tag=1,t=PR(null,t,r,e,n)):(t.tag=0,t=MT(null,t,r,e,n));else{if(r!=null){if(i=r.$$typeof,i===GT){t.tag=11,t=MR(null,t,r,e,n);break e}else if(i===qT){t.tag=14,t=OR(null,t,r,e,n);break e}}throw t=eT(r)||r,Error(D(306,t,""))}}return t;case 0:return MT(e,t,t.type,t.pendingProps,n);case 1:return r=t.type,i=ha(r,t.pendingProps),PR(e,t,r,i,n);case 3:e:{if(Qm(t,t.stateNode.containerInfo),e===null)throw Error(D(387));r=t.pendingProps;var o=t.memoizedState;i=o.element,bT(e,t),Op(t,r,null,n);var s=t.memoizedState;if(r=s.cache,Go(t,_t,r),r!==o.cache&&hT(t,[_t],n,!0),Mp(),r=s.element,o.isDehydrated)if(o={element:r,isDehydrated:!1,cache:s.cache},t.updateQueue.baseState=o,t.memoizedState=o,t.flags&256){t=CR(e,t,r,n);break e}else if(r!==i){i=Dr(Error(D(424)),t),Lp(i),t=CR(e,t,r,n);break e}else{switch(e=t.stateNode.containerInfo,e.nodeType){case 9:e=e.body;break;default:e=e.nodeName==="HTML"?e.ownerDocument.body:e}for(pt=Wr(e.firstChild),Mn=t,we=!0,ca=null,bi=!0,n=NC(t,null,r,n),t.child=n;n;)n.flags=n.flags&-3|4096,n=n.sibling}else{if(ef(),r===i){t=uo(e,t,n);break e}nn(e,t,r,n)}t=t.child}return t;case 26:return Km(e,t),e===null?(n=XR(t.type,null,t.pendingProps,null))?t.memoizedState=n:we||(n=t.type,e=t.pendingProps,r=gh(Wo.current).createElement(n),r[mn]=t,r[Hn]=e,on(r,n,e),Vt(r),t.stateNode=r):t.memoizedState=XR(t.type,e.memoizedProps,t.pendingProps,e.memoizedState),null;case 27:return nT(t),e===null&&we&&(r=t.stateNode=P1(t.type,t.pendingProps,Wo.current),Mn=t,bi=!0,i=pt,ps(t.type)?($T=i,pt=Wr(r.firstChild)):pt=i),nn(e,t,t.pendingProps.children,n),Km(e,t),e===null&&(t.flags|=4194304),t.child;case 5:return e===null&&we&&((i=r=pt)&&(r=mq(r,t.type,t.pendingProps,bi),r!==null?(t.stateNode=r,Mn=t,pt=Wr(r.firstChild),bi=!1,i=!0):i=!1),i||fa(t)),nT(t),i=t.type,o=t.pendingProps,s=e!==null?e.memoizedProps:null,r=o.children,LT(i,o)?r=null:s!==null&&LT(i,s)&&(t.flags|=32),t.memoizedState!==null&&(i=dv(e,t,DG,null,null,n),Hp._currentValue=i),Km(e,t),nn(e,t,r,n),t.child;case 6:return e===null&&we&&((e=n=pt)&&(n=hq(n,t.pendingProps,bi),n!==null?(t.stateNode=n,Mn=t,pt=null,e=!0):e=!1),e||fa(t)),null;case 13:return KC(e,t,n);case 4:return Qm(t,t.stateNode.containerInfo),r=t.pendingProps,e===null?t.child=qc(t,null,r,n):nn(e,t,r,n),t.child;case 11:return MR(e,t,t.type,t.pendingProps,n);case 7:return nn(e,t,t.pendingProps,n),t.child;case 8:return nn(e,t,t.pendingProps.children,n),t.child;case 12:return nn(e,t,t.pendingProps.children,n),t.child;case 10:return r=t.pendingProps,Go(t,t.type,r.value),nn(e,t,r.children,n),t.child;case 9:return i=t.type._context,r=t.pendingProps.children,da(t),i=hn(i),r=r(i),t.flags|=1,nn(e,t,r,n),t.child;case 14:return OR(e,t,t.type,t.pendingProps,n);case 15:return FC(e,t,t.type,t.pendingProps,n);case 19:return zC(e,t,n);case 31:return r=t.pendingProps,n=t.mode,r={mode:r.mode,children:r.children},e===null?(n=lh(r,n),n.ref=t.ref,t.child=n,n.return=t,t=n):(n=oo(e.child,r),n.ref=t.ref,t.child=n,n.return=t,t=n),t;case 22:return $C(e,t,n);case 24:return da(t),r=hn(_t),e===null?(i=uv(),i===null&&(i=Xe,o=cv(),i.pooledCache=o,o.refCount++,o!==null&&(i.pooledCacheLanes|=n),i=o),t.memoizedState={parent:r,cache:i},lv(t),Go(t,_t,i)):(e.lanes&n&&(bT(e,t),Op(t,null,null,n),Mp()),i=e.memoizedState,o=t.memoizedState,i.parent!==r?(i={parent:r,cache:r},t.memoizedState=i,t.lanes===0&&(t.memoizedState=t.updateQueue.baseState=i),Go(t,_t,r)):(r=o.cache,Go(t,_t,r),r!==i.cache&&hT(t,[_t],n,!0))),nn(e,t,t.pendingProps.children,n),t.child;case 29:throw t.pendingProps}throw Error(D(156,t.tag))}function Xi(e){e.flags|=4}function kR(e,t){if(t.type!=="stylesheet"||t.state.loading&4)e.flags&=-16777217;else if(e.flags|=16777216,!k1(t)){if(t=_r.current,t!==null&&((Se&4194048)===Se?vi!==null:(Se&62914560)!==Se&&!(Se&536870912)||t!==vi))throw Ep=gT,YP;e.flags|=8192}}function Am(e,t){t!==null&&(e.flags|=4),e.flags&16384&&(t=e.tag!==22?yP():536870912,e.lanes|=t,Vc|=t)}function fp(e,t){if(!we)switch(e.tailMode){case"hidden":t=e.tail;for(var n=null;t!==null;)t.alternate!==null&&(n=t),t=t.sibling;n===null?e.tail=null:n.sibling=null;break;case"collapsed":n=e.tail;for(var r=null;n!==null;)n.alternate!==null&&(r=n),n=n.sibling;r===null?t||e.tail===null?e.tail=null:e.tail.sibling=null:r.sibling=null}}function at(e){var t=e.alternate!==null&&e.alternate.child===e.child,n=0,r=0;if(t)for(var i=e.child;i!==null;)n|=i.lanes|i.childLanes,r|=i.subtreeFlags&65011712,r|=i.flags&65011712,i.return=e,i=i.sibling;else for(i=e.child;i!==null;)n|=i.lanes|i.childLanes,r|=i.subtreeFlags,r|=i.flags,i.return=e,i=i.sibling;return e.subtreeFlags|=r,e.childLanes=n,t}function zG(e,t,n){var r=t.pendingProps;switch(av(t),t.tag){case 31:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return at(t),null;case 1:return at(t),null;case 3:return n=t.stateNode,r=null,e!==null&&(r=e.memoizedState.cache),t.memoizedState.cache!==r&&(t.flags|=2048),so(_t),Fc(),n.pendingContext&&(n.context=n.pendingContext,n.pendingContext=null),(e===null||e.child===null)&&(lp(t)?Xi(t):e===null||e.memoizedState.isDehydrated&&!(t.flags&256)||(t.flags|=1024,uR())),at(t),null;case 26:return n=t.memoizedState,e===null?(Xi(t),n!==null?(at(t),kR(t,n)):(at(t),t.flags&=-16777217)):n?n!==e.memoizedState?(Xi(t),at(t),kR(t,n)):(at(t),t.flags&=-16777217):(e.memoizedProps!==r&&Xi(t),at(t),t.flags&=-16777217),null;case 27:Ym(t),n=Wo.current;var i=t.type;if(e!==null&&t.stateNode!=null)e.memoizedProps!==r&&Xi(t);else{if(!r){if(t.stateNode===null)throw Error(D(166));return at(t),null}e=xi.current,lp(t)?aR(t,e):(e=P1(i,r,n),t.stateNode=e,Xi(t))}return at(t),null;case 5:if(Ym(t),n=t.type,e!==null&&t.stateNode!=null)e.memoizedProps!==r&&Xi(t);else{if(!r){if(t.stateNode===null)throw Error(D(166));return at(t),null}if(e=xi.current,lp(t))aR(t,e);else{switch(i=gh(Wo.current),e){case 1:e=i.createElementNS("http://www.w3.org/2000/svg",n);break;case 2:e=i.createElementNS("http://www.w3.org/1998/Math/MathML",n);break;default:switch(n){case"svg":e=i.createElementNS("http://www.w3.org/2000/svg",n);break;case"math":e=i.createElementNS("http://www.w3.org/1998/Math/MathML",n);break;case"script":e=i.createElement("div"),e.innerHTML="<script><\/script>",e=e.removeChild(e.firstChild);break;case"select":e=typeof r.is=="string"?i.createElement("select",{is:r.is}):i.createElement("select"),r.multiple?e.multiple=!0:r.size&&(e.size=r.size);break;default:e=typeof r.is=="string"?i.createElement(n,{is:r.is}):i.createElement(n)}}e[mn]=t,e[Hn]=r;e:for(i=t.child;i!==null;){if(i.tag===5||i.tag===6)e.appendChild(i.stateNode);else if(i.tag!==4&&i.tag!==27&&i.child!==null){i.child.return=i,i=i.child;continue}if(i===t)break e;for(;i.sibling===null;){if(i.return===null||i.return===t)break e;i=i.return}i.sibling.return=i.return,i=i.sibling}t.stateNode=e;e:switch(on(e,n,r),n){case"button":case"input":case"select":case"textarea":e=!!r.autoFocus;break e;case"img":e=!0;break e;default:e=!1}e&&Xi(t)}}return at(t),t.flags&=-16777217,null;case 6:if(e&&t.stateNode!=null)e.memoizedProps!==r&&Xi(t);else{if(typeof r!="string"&&t.stateNode===null)throw Error(D(166));if(e=Wo.current,lp(t)){if(e=t.stateNode,n=t.memoizedProps,r=null,i=Mn,i!==null)switch(i.tag){case 27:case 5:r=i.memoizedProps}e[mn]=t,e=!!(e.nodeValue===n||r!==null&&r.suppressHydrationWarning===!0||O1(e.nodeValue,n)),e||fa(t)}else e=gh(e).createTextNode(r),e[mn]=t,t.stateNode=e}return at(t),null;case 13:if(r=t.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(i=lp(t),r!==null&&r.dehydrated!==null){if(e===null){if(!i)throw Error(D(318));if(i=t.memoizedState,i=i!==null?i.dehydrated:null,!i)throw Error(D(317));i[mn]=t}else ef(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;at(t),i=!1}else i=uR(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=i),i=!0;if(!i)return t.flags&256?(io(t),t):(io(t),null)}if(io(t),t.flags&128)return t.lanes=n,t;if(n=r!==null,e=e!==null&&e.memoizedState!==null,n){r=t.child,i=null,r.alternate!==null&&r.alternate.memoizedState!==null&&r.alternate.memoizedState.cachePool!==null&&(i=r.alternate.memoizedState.cachePool.pool);var o=null;r.memoizedState!==null&&r.memoizedState.cachePool!==null&&(o=r.memoizedState.cachePool.pool),o!==i&&(r.flags|=2048)}return n!==e&&n&&(t.child.flags|=8192),Am(t,t.updateQueue),at(t),null;case 4:return Fc(),e===null&&Nv(t.stateNode.containerInfo),at(t),null;case 10:return so(t.type),at(t),null;case 19:if(Yt(jt),i=t.memoizedState,i===null)return at(t),null;if(r=(t.flags&128)!==0,o=i.rendering,o===null)if(r)fp(i,!1);else{if(ft!==0||e!==null&&e.flags&128)for(e=t.child;e!==null;){if(o=ah(e),o!==null){for(t.flags|=128,fp(i,!1),e=o.updateQueue,t.updateQueue=e,Am(t,e),t.subtreeFlags=0,e=n,n=t.child;n!==null;)GP(n,e),n=n.sibling;return rt(jt,jt.current&1|2),t.child}e=e.sibling}i.tail!==null&&Ti()>fh&&(t.flags|=128,r=!0,fp(i,!1),t.lanes=4194304)}else{if(!r)if(e=ah(o),e!==null){if(t.flags|=128,r=!0,e=e.updateQueue,t.updateQueue=e,Am(t,e),fp(i,!0),i.tail===null&&i.tailMode==="hidden"&&!o.alternate&&!we)return at(t),null}else 2*Ti()-i.renderingStartTime>fh&&n!==536870912&&(t.flags|=128,r=!0,fp(i,!1),t.lanes=4194304);i.isBackwards?(o.sibling=t.child,t.child=o):(e=i.last,e!==null?e.sibling=o:t.child=o,i.last=o)}return i.tail!==null?(t=i.tail,i.rendering=t,i.tail=t.sibling,i.renderingStartTime=Ti(),t.sibling=null,e=jt.current,rt(jt,r?e&1|2:e&1),t):(at(t),null);case 22:case 23:return io(t),pv(),r=t.memoizedState!==null,e!==null?e.memoizedState!==null!==r&&(t.flags|=8192):r&&(t.flags|=8192),r?n&536870912&&!(t.flags&128)&&(at(t),t.subtreeFlags&6&&(t.flags|=8192)):at(t),n=t.updateQueue,n!==null&&Am(t,n.retryQueue),n=null,e!==null&&e.memoizedState!==null&&e.memoizedState.cachePool!==null&&(n=e.memoizedState.cachePool.pool),r=null,t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(r=t.memoizedState.cachePool.pool),r!==n&&(t.flags|=2048),e!==null&&Yt(ua),null;case 24:return n=null,e!==null&&(n=e.memoizedState.cache),t.memoizedState.cache!==n&&(t.flags|=2048),so(_t),at(t),null;case 25:return null;case 30:return null}throw Error(D(156,t.tag))}function HG(e,t){switch(av(t),t.tag){case 1:return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return so(_t),Fc(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 26:case 27:case 5:return Ym(t),null;case 13:if(io(t),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(D(340));ef()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return Yt(jt),null;case 4:return Fc(),null;case 10:return so(t.type),null;case 22:case 23:return io(t),pv(),e!==null&&Yt(ua),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 24:return so(_t),null;case 25:return null;default:return null}}function GC(e,t){switch(av(t),t.tag){case 3:so(_t),Fc();break;case 26:case 27:case 5:Ym(t);break;case 4:Fc();break;case 13:io(t);break;case 19:Yt(jt);break;case 10:so(t.type);break;case 22:case 23:io(t),pv(),e!==null&&Yt(ua);break;case 24:so(_t)}}function af(e,t){try{var n=t.updateQueue,r=n!==null?n.lastEffect:null;if(r!==null){var i=r.next;n=i;do{if((n.tag&e)===e){r=void 0;var o=n.create,s=n.inst;r=o(),s.destroy=r}n=n.next}while(n!==i)}}catch(a){He(t,t.return,a)}}function cs(e,t,n){try{var r=t.updateQueue,i=r!==null?r.lastEffect:null;if(i!==null){var o=i.next;r=o;do{if((r.tag&e)===e){var s=r.inst,a=s.destroy;if(a!==void 0){s.destroy=void 0,i=t;var c=n,l=a;try{l()}catch(p){He(i,c,p)}}}r=r.next}while(r!==o)}}catch(p){He(t,t.return,p)}}function qC(e){var t=e.updateQueue;if(t!==null){var n=e.stateNode;try{ZP(t,n)}catch(r){He(e,e.return,r)}}}function VC(e,t,n){n.props=ha(e.type,e.memoizedProps),n.state=e.memoizedState;try{n.componentWillUnmount()}catch(r){He(e,t,r)}}function Rp(e,t){try{var n=e.ref;if(n!==null){switch(e.tag){case 26:case 27:case 5:var r=e.stateNode;break;case 30:r=e.stateNode;break;default:r=e.stateNode}typeof n=="function"?e.refCleanup=n(r):n.current=r}}catch(i){He(e,t,i)}}function Si(e,t){var n=e.ref,r=e.refCleanup;if(n!==null)if(typeof r=="function")try{r()}catch(i){He(e,t,i)}finally{e.refCleanup=null,e=e.alternate,e!=null&&(e.refCleanup=null)}else if(typeof n=="function")try{n(null)}catch(i){He(e,t,i)}else n.current=null}function QC(e){var t=e.type,n=e.memoizedProps,r=e.stateNode;try{e:switch(t){case"button":case"input":case"select":case"textarea":n.autoFocus&&r.focus();break e;case"img":n.src?r.src=n.src:n.srcSet&&(r.srcset=n.srcSet)}}catch(i){He(e,e.return,i)}}function Fx(e,t,n){try{var r=e.stateNode;uq(r,e.type,n,t),r[Hn]=t}catch(i){He(e,e.return,i)}}function YC(e){return e.tag===5||e.tag===3||e.tag===26||e.tag===27&&ps(e.type)||e.tag===4}function $x(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||YC(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;e.tag!==5&&e.tag!==6&&e.tag!==18;){if(e.tag===27&&ps(e.type)||e.flags&2||e.child===null||e.tag===4)continue e;e.child.return=e,e=e.child}if(!(e.flags&2))return e.stateNode}}function AT(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?(n.nodeType===9?n.body:n.nodeName==="HTML"?n.ownerDocument.body:n).insertBefore(e,t):(t=n.nodeType===9?n.body:n.nodeName==="HTML"?n.ownerDocument.body:n,t.appendChild(e),n=n._reactRootContainer,n!=null||t.onclick!==null||(t.onclick=_h));else if(r!==4&&(r===27&&ps(e.type)&&(n=e.stateNode,t=null),e=e.child,e!==null))for(AT(e,t,n),e=e.sibling;e!==null;)AT(e,t,n),e=e.sibling}function ph(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?n.insertBefore(e,t):n.appendChild(e);else if(r!==4&&(r===27&&ps(e.type)&&(n=e.stateNode),e=e.child,e!==null))for(ph(e,t,n),e=e.sibling;e!==null;)ph(e,t,n),e=e.sibling}function JC(e){var t=e.stateNode,n=e.memoizedProps;try{for(var r=e.type,i=t.attributes;i.length;)t.removeAttributeNode(i[0]);on(t,r,n),t[mn]=e,t[Hn]=n}catch(o){He(e,e.return,o)}}var Wi=!1,gt=!1,Kx=!1,DR=typeof WeakSet=="function"?WeakSet:Set,qt=null;function GG(e,t){if(e=e.containerInfo,_T=Th,e=jP(e),nv(e)){if("selectionStart"in e)var n={start:e.selectionStart,end:e.selectionEnd};else e:{n=(n=e.ownerDocument)&&n.defaultView||window;var r=n.getSelection&&n.getSelection();if(r&&r.rangeCount!==0){n=r.anchorNode;var i=r.anchorOffset,o=r.focusNode;r=r.focusOffset;try{n.nodeType,o.nodeType}catch{n=null;break e}var s=0,a=-1,c=-1,l=0,p=0,d=e,m=null;t:for(;;){for(var y;d!==n||i!==0&&d.nodeType!==3||(a=s+i),d!==o||r!==0&&d.nodeType!==3||(c=s+r),d.nodeType===3&&(s+=d.nodeValue.length),(y=d.firstChild)!==null;)m=d,d=y;for(;;){if(d===e)break t;if(m===n&&++l===i&&(a=s),m===o&&++p===r&&(c=s),(y=d.nextSibling)!==null)break;d=m,m=d.parentNode}d=y}n=a===-1||c===-1?null:{start:a,end:c}}else n=null}n=n||{start:0,end:0}}else n=null;for(jT={focusedElem:e,selectionRange:n},Th=!1,qt=t;qt!==null;)if(t=qt,e=t.child,(t.subtreeFlags&1024)!==0&&e!==null)e.return=t,qt=e;else for(;qt!==null;){switch(t=qt,o=t.alternate,e=t.flags,t.tag){case 0:break;case 11:case 15:break;case 1:if(e&1024&&o!==null){e=void 0,n=t,i=o.memoizedProps,o=o.memoizedState,r=n.stateNode;try{var S=ha(n.type,i,n.elementType===n.type);e=r.getSnapshotBeforeUpdate(S,o),r.__reactInternalSnapshotBeforeUpdate=e}catch(T){He(n,n.return,T)}}break;case 3:if(e&1024){if(e=t.stateNode.containerInfo,n=e.nodeType,n===9)BT(e);else if(n===1)switch(e.nodeName){case"HEAD":case"HTML":case"BODY":BT(e);break;default:e.textContent=""}}break;case 5:case 26:case 27:case 6:case 4:case 17:break;default:if(e&1024)throw Error(D(163))}if(e=t.sibling,e!==null){e.return=t.return,qt=e;break}qt=t.return}}function XC(e,t,n){var r=n.flags;switch(n.tag){case 0:case 11:case 15:$o(e,n),r&4&&af(5,n);break;case 1:if($o(e,n),r&4)if(e=n.stateNode,t===null)try{e.componentDidMount()}catch(s){He(n,n.return,s)}else{var i=ha(n.type,t.memoizedProps);t=t.memoizedState;try{e.componentDidUpdate(i,t,e.__reactInternalSnapshotBeforeUpdate)}catch(s){He(n,n.return,s)}}r&64&&qC(n),r&512&&Rp(n,n.return);break;case 3:if($o(e,n),r&64&&(e=n.updateQueue,e!==null)){if(t=null,n.child!==null)switch(n.child.tag){case 27:case 5:t=n.child.stateNode;break;case 1:t=n.child.stateNode}try{ZP(e,t)}catch(s){He(n,n.return,s)}}break;case 27:t===null&&r&4&&JC(n);case 26:case 5:$o(e,n),t===null&&r&4&&QC(n),r&512&&Rp(n,n.return);break;case 12:$o(e,n);break;case 13:$o(e,n),r&4&&e1(e,n),r&64&&(e=n.memoizedState,e!==null&&(e=e.dehydrated,e!==null&&(n=eq.bind(null,n),yq(e,n))));break;case 22:if(r=n.memoizedState!==null||Wi,!r){t=t!==null&&t.memoizedState!==null||gt,i=Wi;var o=gt;Wi=r,(gt=t)&&!o?Ko(e,n,(n.subtreeFlags&8772)!==0):$o(e,n),Wi=i,gt=o}break;case 30:break;default:$o(e,n)}}function ZC(e){var t=e.alternate;t!==null&&(e.alternate=null,ZC(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&JT(t)),e.stateNode=null,e.return=null,e.dependencies=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.stateNode=null,e.updateQueue=null}var nt=null,Kn=!1;function Zi(e,t,n){for(n=n.child;n!==null;)WC(e,t,n),n=n.sibling}function WC(e,t,n){if(ur&&typeof ur.onCommitFiberUnmount=="function")try{ur.onCommitFiberUnmount(Yp,n)}catch{}switch(n.tag){case 26:gt||Si(n,t),Zi(e,t,n),n.memoizedState?n.memoizedState.count--:n.stateNode&&(n=n.stateNode,n.parentNode.removeChild(n));break;case 27:gt||Si(n,t);var r=nt,i=Kn;ps(n.type)&&(nt=n.stateNode,Kn=!1),Zi(e,t,n),kp(n.stateNode),nt=r,Kn=i;break;case 5:gt||Si(n,t);case 6:if(r=nt,i=Kn,nt=null,Zi(e,t,n),nt=r,Kn=i,nt!==null)if(Kn)try{(nt.nodeType===9?nt.body:nt.nodeName==="HTML"?nt.ownerDocument.body:nt).removeChild(n.stateNode)}catch(o){He(n,t,o)}else try{nt.removeChild(n.stateNode)}catch(o){He(n,t,o)}break;case 18:nt!==null&&(Kn?(e=nt,QR(e.nodeType===9?e.body:e.nodeName==="HTML"?e.ownerDocument.body:e,n.stateNode),Vp(e)):QR(nt,n.stateNode));break;case 4:r=nt,i=Kn,nt=n.stateNode.containerInfo,Kn=!0,Zi(e,t,n),nt=r,Kn=i;break;case 0:case 11:case 14:case 15:gt||cs(2,n,t),gt||cs(4,n,t),Zi(e,t,n);break;case 1:gt||(Si(n,t),r=n.stateNode,typeof r.componentWillUnmount=="function"&&VC(n,t,r)),Zi(e,t,n);break;case 21:Zi(e,t,n);break;case 22:gt=(r=gt)||n.memoizedState!==null,Zi(e,t,n),gt=r;break;default:Zi(e,t,n)}}function e1(e,t){if(t.memoizedState===null&&(e=t.alternate,e!==null&&(e=e.memoizedState,e!==null&&(e=e.dehydrated,e!==null))))try{Vp(e)}catch(n){He(t,t.return,n)}}function qG(e){switch(e.tag){case 13:case 19:var t=e.stateNode;return t===null&&(t=e.stateNode=new DR),t;case 22:return e=e.stateNode,t=e._retryCache,t===null&&(t=e._retryCache=new DR),t;default:throw Error(D(435,e.tag))}}function zx(e,t){var n=qG(e);t.forEach(function(r){var i=tq.bind(null,e,r);n.has(r)||(n.add(r),r.then(i,i))})}function or(e,t){var n=t.deletions;if(n!==null)for(var r=0;r<n.length;r++){var i=n[r],o=e,s=t,a=s;e:for(;a!==null;){switch(a.tag){case 27:if(ps(a.type)){nt=a.stateNode,Kn=!1;break e}break;case 5:nt=a.stateNode,Kn=!1;break e;case 3:case 4:nt=a.stateNode.containerInfo,Kn=!0;break e}a=a.return}if(nt===null)throw Error(D(160));WC(o,s,i),nt=null,Kn=!1,o=i.alternate,o!==null&&(o.return=null),i.return=null}if(t.subtreeFlags&13878)for(t=t.child;t!==null;)t1(t,e),t=t.sibling}var Zr=null;function t1(e,t){var n=e.alternate,r=e.flags;switch(e.tag){case 0:case 11:case 14:case 15:or(t,e),sr(e),r&4&&(cs(3,e,e.return),af(3,e),cs(5,e,e.return));break;case 1:or(t,e),sr(e),r&512&&(gt||n===null||Si(n,n.return)),r&64&&Wi&&(e=e.updateQueue,e!==null&&(r=e.callbacks,r!==null&&(n=e.shared.hiddenCallbacks,e.shared.hiddenCallbacks=n===null?r:n.concat(r))));break;case 26:var i=Zr;if(or(t,e),sr(e),r&512&&(gt||n===null||Si(n,n.return)),r&4){var o=n!==null?n.memoizedState:null;if(r=e.memoizedState,n===null)if(r===null)if(e.stateNode===null){e:{r=e.type,n=e.memoizedProps,i=i.ownerDocument||i;t:switch(r){case"title":o=i.getElementsByTagName("title")[0],(!o||o[Zp]||o[mn]||o.namespaceURI==="http://www.w3.org/2000/svg"||o.hasAttribute("itemprop"))&&(o=i.createElement(r),i.head.insertBefore(o,i.querySelector("head > title"))),on(o,r,n),o[mn]=e,Vt(o),r=o;break e;case"link":var s=WR("link","href",i).get(r+(n.href||""));if(s){for(var a=0;a<s.length;a++)if(o=s[a],o.getAttribute("href")===(n.href==null||n.href===""?null:n.href)&&o.getAttribute("rel")===(n.rel==null?null:n.rel)&&o.getAttribute("title")===(n.title==null?null:n.title)&&o.getAttribute("crossorigin")===(n.crossOrigin==null?null:n.crossOrigin)){s.splice(a,1);break t}}o=i.createElement(r),on(o,r,n),i.head.appendChild(o);break;case"meta":if(s=WR("meta","content",i).get(r+(n.content||""))){for(a=0;a<s.length;a++)if(o=s[a],o.getAttribute("content")===(n.content==null?null:""+n.content)&&o.getAttribute("name")===(n.name==null?null:n.name)&&o.getAttribute("property")===(n.property==null?null:n.property)&&o.getAttribute("http-equiv")===(n.httpEquiv==null?null:n.httpEquiv)&&o.getAttribute("charset")===(n.charSet==null?null:n.charSet)){s.splice(a,1);break t}}o=i.createElement(r),on(o,r,n),i.head.appendChild(o);break;default:throw Error(D(468,r))}o[mn]=e,Vt(o),r=o}e.stateNode=r}else eP(i,e.type,e.stateNode);else e.stateNode=ZR(i,r,e.memoizedProps);else o!==r?(o===null?n.stateNode!==null&&(n=n.stateNode,n.parentNode.removeChild(n)):o.count--,r===null?eP(i,e.type,e.stateNode):ZR(i,r,e.memoizedProps)):r===null&&e.stateNode!==null&&Fx(e,e.memoizedProps,n.memoizedProps)}break;case 27:or(t,e),sr(e),r&512&&(gt||n===null||Si(n,n.return)),n!==null&&r&4&&Fx(e,e.memoizedProps,n.memoizedProps);break;case 5:if(or(t,e),sr(e),r&512&&(gt||n===null||Si(n,n.return)),e.flags&32){i=e.stateNode;try{Kc(i,"")}catch(y){He(e,e.return,y)}}r&4&&e.stateNode!=null&&(i=e.memoizedProps,Fx(e,i,n!==null?n.memoizedProps:i)),r&1024&&(Kx=!0);break;case 6:if(or(t,e),sr(e),r&4){if(e.stateNode===null)throw Error(D(162));r=e.memoizedProps,n=e.stateNode;try{n.nodeValue=r}catch(y){He(e,e.return,y)}}break;case 3:if(Gm=null,i=Zr,Zr=bh(t.containerInfo),or(t,e),Zr=i,sr(e),r&4&&n!==null&&n.memoizedState.isDehydrated)try{Vp(t.containerInfo)}catch(y){He(e,e.return,y)}Kx&&(Kx=!1,n1(e));break;case 4:r=Zr,Zr=bh(e.stateNode.containerInfo),or(t,e),sr(e),Zr=r;break;case 12:or(t,e),sr(e);break;case 13:or(t,e),sr(e),e.child.flags&8192&&e.memoizedState!==null!=(n!==null&&n.memoizedState!==null)&&(Rv=Ti()),r&4&&(r=e.updateQueue,r!==null&&(e.updateQueue=null,zx(e,r)));break;case 22:i=e.memoizedState!==null;var c=n!==null&&n.memoizedState!==null,l=Wi,p=gt;if(Wi=l||i,gt=p||c,or(t,e),gt=p,Wi=l,sr(e),r&8192)e:for(t=e.stateNode,t._visibility=i?t._visibility&-2:t._visibility|1,i&&(n===null||c||Wi||gt||ia(e)),n=null,t=e;;){if(t.tag===5||t.tag===26){if(n===null){c=n=t;try{if(o=c.stateNode,i)s=o.style,typeof s.setProperty=="function"?s.setProperty("display","none","important"):s.display="none";else{a=c.stateNode;var d=c.memoizedProps.style,m=d!=null&&d.hasOwnProperty("display")?d.display:null;a.style.display=m==null||typeof m=="boolean"?"":(""+m).trim()}}catch(y){He(c,c.return,y)}}}else if(t.tag===6){if(n===null){c=t;try{c.stateNode.nodeValue=i?"":c.memoizedProps}catch(y){He(c,c.return,y)}}}else if((t.tag!==22&&t.tag!==23||t.memoizedState===null||t===e)&&t.child!==null){t.child.return=t,t=t.child;continue}if(t===e)break e;for(;t.sibling===null;){if(t.return===null||t.return===e)break e;n===t&&(n=null),t=t.return}n===t&&(n=null),t.sibling.return=t.return,t=t.sibling}r&4&&(r=e.updateQueue,r!==null&&(n=r.retryQueue,n!==null&&(r.retryQueue=null,zx(e,n))));break;case 19:or(t,e),sr(e),r&4&&(r=e.updateQueue,r!==null&&(e.updateQueue=null,zx(e,r)));break;case 30:break;case 21:break;default:or(t,e),sr(e)}}function sr(e){var t=e.flags;if(t&2){try{for(var n,r=e.return;r!==null;){if(YC(r)){n=r;break}r=r.return}if(n==null)throw Error(D(160));switch(n.tag){case 27:var i=n.stateNode,o=$x(e);ph(e,o,i);break;case 5:var s=n.stateNode;n.flags&32&&(Kc(s,""),n.flags&=-33);var a=$x(e);ph(e,a,s);break;case 3:case 4:var c=n.stateNode.containerInfo,l=$x(e);AT(e,l,c);break;default:throw Error(D(161))}}catch(p){He(e,e.return,p)}e.flags&=-3}t&4096&&(e.flags&=-4097)}function n1(e){if(e.subtreeFlags&1024)for(e=e.child;e!==null;){var t=e;n1(t),t.tag===5&&t.flags&1024&&t.stateNode.reset(),e=e.sibling}}function $o(e,t){if(t.subtreeFlags&8772)for(t=t.child;t!==null;)XC(e,t.alternate,t),t=t.sibling}function ia(e){for(e=e.child;e!==null;){var t=e;switch(t.tag){case 0:case 11:case 14:case 15:cs(4,t,t.return),ia(t);break;case 1:Si(t,t.return);var n=t.stateNode;typeof n.componentWillUnmount=="function"&&VC(t,t.return,n),ia(t);break;case 27:kp(t.stateNode);case 26:case 5:Si(t,t.return),ia(t);break;case 22:t.memoizedState===null&&ia(t);break;case 30:ia(t);break;default:ia(t)}e=e.sibling}}function Ko(e,t,n){for(n=n&&(t.subtreeFlags&8772)!==0,t=t.child;t!==null;){var r=t.alternate,i=e,o=t,s=o.flags;switch(o.tag){case 0:case 11:case 15:Ko(i,o,n),af(4,o);break;case 1:if(Ko(i,o,n),r=o,i=r.stateNode,typeof i.componentDidMount=="function")try{i.componentDidMount()}catch(l){He(r,r.return,l)}if(r=o,i=r.updateQueue,i!==null){var a=r.stateNode;try{var c=i.shared.hiddenCallbacks;if(c!==null)for(i.shared.hiddenCallbacks=null,i=0;i<c.length;i++)XP(c[i],a)}catch(l){He(r,r.return,l)}}n&&s&64&&qC(o),Rp(o,o.return);break;case 27:JC(o);case 26:case 5:Ko(i,o,n),n&&r===null&&s&4&&QC(o),Rp(o,o.return);break;case 12:Ko(i,o,n);break;case 13:Ko(i,o,n),n&&s&4&&e1(i,o);break;case 22:o.memoizedState===null&&Ko(i,o,n),Rp(o,o.return);break;case 30:break;default:Ko(i,o,n)}t=t.sibling}}function wv(e,t){var n=null;e!==null&&e.memoizedState!==null&&e.memoizedState.cachePool!==null&&(n=e.memoizedState.cachePool.pool),e=null,t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(e=t.memoizedState.cachePool.pool),e!==n&&(e!=null&&e.refCount++,n!=null&&nf(n))}function Mv(e,t){e=null,t.alternate!==null&&(e=t.alternate.memoizedState.cache),t=t.memoizedState.cache,t!==e&&(t.refCount++,e!=null&&nf(e))}function gi(e,t,n,r){if(t.subtreeFlags&10256)for(t=t.child;t!==null;)r1(e,t,n,r),t=t.sibling}function r1(e,t,n,r){var i=t.flags;switch(t.tag){case 0:case 11:case 15:gi(e,t,n,r),i&2048&&af(9,t);break;case 1:gi(e,t,n,r);break;case 3:gi(e,t,n,r),i&2048&&(e=null,t.alternate!==null&&(e=t.alternate.memoizedState.cache),t=t.memoizedState.cache,t!==e&&(t.refCount++,e!=null&&nf(e)));break;case 12:if(i&2048){gi(e,t,n,r),e=t.stateNode;try{var o=t.memoizedProps,s=o.id,a=o.onPostCommit;typeof a=="function"&&a(s,t.alternate===null?"mount":"update",e.passiveEffectDuration,-0)}catch(c){He(t,t.return,c)}}else gi(e,t,n,r);break;case 13:gi(e,t,n,r);break;case 23:break;case 22:o=t.stateNode,s=t.alternate,t.memoizedState!==null?o._visibility&2?gi(e,t,n,r):Pp(e,t):o._visibility&2?gi(e,t,n,r):(o._visibility|=2,bc(e,t,n,r,(t.subtreeFlags&10256)!==0)),i&2048&&wv(s,t);break;case 24:gi(e,t,n,r),i&2048&&Mv(t.alternate,t);break;default:gi(e,t,n,r)}}function bc(e,t,n,r,i){for(i=i&&(t.subtreeFlags&10256)!==0,t=t.child;t!==null;){var o=e,s=t,a=n,c=r,l=s.flags;switch(s.tag){case 0:case 11:case 15:bc(o,s,a,c,i),af(8,s);break;case 23:break;case 22:var p=s.stateNode;s.memoizedState!==null?p._visibility&2?bc(o,s,a,c,i):Pp(o,s):(p._visibility|=2,bc(o,s,a,c,i)),i&&l&2048&&wv(s.alternate,s);break;case 24:bc(o,s,a,c,i),i&&l&2048&&Mv(s.alternate,s);break;default:bc(o,s,a,c,i)}t=t.sibling}}function Pp(e,t){if(t.subtreeFlags&10256)for(t=t.child;t!==null;){var n=e,r=t,i=r.flags;switch(r.tag){case 22:Pp(n,r),i&2048&&wv(r.alternate,r);break;case 24:Pp(n,r),i&2048&&Mv(r.alternate,r);break;default:Pp(n,r)}t=t.sibling}}var Sp=8192;function hc(e){if(e.subtreeFlags&Sp)for(e=e.child;e!==null;)i1(e),e=e.sibling}function i1(e){switch(e.tag){case 26:hc(e),e.flags&Sp&&e.memoizedState!==null&&Rq(Zr,e.memoizedState,e.memoizedProps);break;case 5:hc(e);break;case 3:case 4:var t=Zr;Zr=bh(e.stateNode.containerInfo),hc(e),Zr=t;break;case 22:e.memoizedState===null&&(t=e.alternate,t!==null&&t.memoizedState!==null?(t=Sp,Sp=16777216,hc(e),Sp=t):hc(e));break;default:hc(e)}}function o1(e){var t=e.alternate;if(t!==null&&(e=t.child,e!==null)){t.child=null;do t=e.sibling,e.sibling=null,e=t;while(e!==null)}}function dp(e){var t=e.deletions;if(e.flags&16){if(t!==null)for(var n=0;n<t.length;n++){var r=t[n];qt=r,a1(r,e)}o1(e)}if(e.subtreeFlags&10256)for(e=e.child;e!==null;)s1(e),e=e.sibling}function s1(e){switch(e.tag){case 0:case 11:case 15:dp(e),e.flags&2048&&cs(9,e,e.return);break;case 3:dp(e);break;case 12:dp(e);break;case 22:var t=e.stateNode;e.memoizedState!==null&&t._visibility&2&&(e.return===null||e.return.tag!==13)?(t._visibility&=-3,zm(e)):dp(e);break;default:dp(e)}}function zm(e){var t=e.deletions;if(e.flags&16){if(t!==null)for(var n=0;n<t.length;n++){var r=t[n];qt=r,a1(r,e)}o1(e)}for(e=e.child;e!==null;){switch(t=e,t.tag){case 0:case 11:case 15:cs(8,t,t.return),zm(t);break;case 22:n=t.stateNode,n._visibility&2&&(n._visibility&=-3,zm(t));break;default:zm(t)}e=e.sibling}}function a1(e,t){for(;qt!==null;){var n=qt;switch(n.tag){case 0:case 11:case 15:cs(8,n,t);break;case 23:case 22:if(n.memoizedState!==null&&n.memoizedState.cachePool!==null){var r=n.memoizedState.cachePool.pool;r!=null&&r.refCount++}break;case 24:nf(n.memoizedState.cache)}if(r=n.child,r!==null)r.return=n,qt=r;else e:for(n=e;qt!==null;){r=qt;var i=r.sibling,o=r.return;if(ZC(r),r===n){qt=null;break e}if(i!==null){i.return=o,qt=i;break e}qt=o}}}var VG={getCacheForType:function(e){var t=hn(_t),n=t.data.get(e);return n===void 0&&(n=e(),t.data.set(e,n)),n}},QG=typeof WeakMap=="function"?WeakMap:Map,_e=0,Xe=null,pe=null,Se=0,Ue=0,ar=null,Xo=!1,eu=!1,Ov=!1,lo=0,ft=0,us=0,la=0,Av=0,Ur=0,Vc=0,Cp=null,zn=null,RT=!1,Rv=0,fh=1/0,dh=null,ns=null,rn=0,rs=null,Qc=null,Bc=0,PT=0,CT=null,c1=null,Np=0,NT=null;function pr(){if(_e&2&&Se!==0)return Se&-Se;if(X.T!==null){var e=zc;return e!==0?e:Cv()}return SP()}function u1(){Ur===0&&(Ur=!(Se&536870912)||we?hP():536870912);var e=_r.current;return e!==null&&(e.flags|=32),Ur}function fr(e,t,n){(e===Xe&&(Ue===2||Ue===9)||e.cancelPendingCommit!==null)&&(Yc(e,0),Zo(e,Se,Ur,!1)),Xp(e,n),(!(_e&2)||e!==Xe)&&(e===Xe&&(!(_e&2)&&(la|=n),ft===4&&Zo(e,Se,Ur,!1)),Ei(e))}function l1(e,t,n){if(_e&6)throw Error(D(327));var r=!n&&(t&124)===0&&(t&e.expiredLanes)===0||Jp(e,t),i=r?XG(e,t):Hx(e,t,!0),o=r;do{if(i===0){eu&&!r&&Zo(e,t,0,!1);break}else{if(n=e.current.alternate,o&&!YG(n)){i=Hx(e,t,!1),o=!1;continue}if(i===2){if(o=t,e.errorRecoveryDisabledLanes&o)var s=0;else s=e.pendingLanes&-536870913,s=s!==0?s:s&536870912?536870912:0;if(s!==0){t=s;e:{var a=e;i=Cp;var c=a.current.memoizedState.isDehydrated;if(c&&(Yc(a,s).flags|=256),s=Hx(a,s,!1),s!==2){if(Ov&&!c){a.errorRecoveryDisabledLanes|=o,la|=o,i=4;break e}o=zn,zn=i,o!==null&&(zn===null?zn=o:zn.push.apply(zn,o))}i=s}if(o=!1,i!==2)continue}}if(i===1){Yc(e,0),Zo(e,t,0,!0);break}e:{switch(r=e,o=i,o){case 0:case 1:throw Error(D(345));case 4:if((t&4194048)!==t)break;case 6:Zo(r,t,Ur,!Xo);break e;case 2:zn=null;break;case 3:case 5:break;default:throw Error(D(329))}if((t&62914560)===t&&(i=Rv+300-Ti(),10<i)){if(Zo(r,t,Ur,!Xo),Ih(r,0,!0)!==0)break e;r.timeoutHandle=R1(UR.bind(null,r,n,zn,dh,RT,t,Ur,la,Vc,Xo,o,2,-0,0),i);break e}UR(r,n,zn,dh,RT,t,Ur,la,Vc,Xo,o,0,-0,0)}}break}while(!0);Ei(e)}function UR(e,t,n,r,i,o,s,a,c,l,p,d,m,y){if(e.timeoutHandle=-1,d=t.subtreeFlags,(d&8192||(d&16785408)===16785408)&&(zp={stylesheets:null,count:0,unsuspend:Aq},i1(t),d=Pq(),d!==null)){e.cancelPendingCommit=d(jR.bind(null,e,t,o,n,r,i,s,a,c,p,1,m,y)),Zo(e,o,s,!l);return}jR(e,t,o,n,r,i,s,a,c)}function YG(e){for(var t=e;;){var n=t.tag;if((n===0||n===11||n===15)&&t.flags&16384&&(n=t.updateQueue,n!==null&&(n=n.stores,n!==null)))for(var r=0;r<n.length;r++){var i=n[r],o=i.getSnapshot;i=i.value;try{if(!dr(o(),i))return!1}catch{return!1}}if(n=t.child,t.subtreeFlags&16384&&n!==null)n.return=t,t=n;else{if(t===e)break;for(;t.sibling===null;){if(t.return===null||t.return===e)return!0;t=t.return}t.sibling.return=t.return,t=t.sibling}}return!0}function Zo(e,t,n,r){t&=~Av,t&=~la,e.suspendedLanes|=t,e.pingedLanes&=~t,r&&(e.warmLanes|=t),r=e.expirationTimes;for(var i=t;0<i;){var o=31-lr(i),s=1<<o;r[o]=-1,i&=~s}n!==0&&gP(e,n,t)}function kh(){return _e&6?!0:(cf(0,!1),!1)}function Pv(){if(pe!==null){if(Ue===0)var e=pe.return;else e=pe,ro=Sa=null,yv(e),Lc=null,Fp=0,e=pe;for(;e!==null;)GC(e.alternate,e),e=e.return;pe=null}}function Yc(e,t){var n=e.timeoutHandle;n!==-1&&(e.timeoutHandle=-1,pq(n)),n=e.cancelPendingCommit,n!==null&&(e.cancelPendingCommit=null,n()),Pv(),Xe=e,pe=n=oo(e.current,null),Se=t,Ue=0,ar=null,Xo=!1,eu=Jp(e,t),Ov=!1,Vc=Ur=Av=la=us=ft=0,zn=Cp=null,RT=!1,t&8&&(t|=t&32);var r=e.entangledLanes;if(r!==0)for(e=e.entanglements,r&=t;0<r;){var i=31-lr(r),o=1<<i;t|=e[i],r&=~o}return lo=t,Oh(),n}function p1(e,t){re=null,X.H=sh,t===rf||t===Rh?(t=dR(),Ue=3):t===YP?(t=dR(),Ue=4):Ue=t===BC?8:t!==null&&typeof t=="object"&&typeof t.then=="function"?6:1,ar=t,pe===null&&(ft=1,uh(e,Dr(t,e.current)))}function f1(){var e=X.H;return X.H=sh,e===null?sh:e}function d1(){var e=X.A;return X.A=VG,e}function kT(){ft=4,Xo||(Se&4194048)!==Se&&_r.current!==null||(eu=!0),!(us&134217727)&&!(la&134217727)||Xe===null||Zo(Xe,Se,Ur,!1)}function Hx(e,t,n){var r=_e;_e|=2;var i=f1(),o=d1();(Xe!==e||Se!==t)&&(dh=null,Yc(e,t)),t=!1;var s=ft;e:do try{if(Ue!==0&&pe!==null){var a=pe,c=ar;switch(Ue){case 8:Pv(),s=6;break e;case 3:case 2:case 9:case 6:_r.current===null&&(t=!0);var l=Ue;if(Ue=0,ar=null,Cc(e,a,c,l),n&&eu){s=0;break e}break;default:l=Ue,Ue=0,ar=null,Cc(e,a,c,l)}}JG(),s=ft;break}catch(p){p1(e,p)}while(!0);return t&&e.shellSuspendCounter++,ro=Sa=null,_e=r,X.H=i,X.A=o,pe===null&&(Xe=null,Se=0,Oh()),s}function JG(){for(;pe!==null;)m1(pe)}function XG(e,t){var n=_e;_e|=2;var r=f1(),i=d1();Xe!==e||Se!==t?(dh=null,fh=Ti()+500,Yc(e,t)):eu=Jp(e,t);e:do try{if(Ue!==0&&pe!==null){t=pe;var o=ar;t:switch(Ue){case 1:Ue=0,ar=null,Cc(e,t,o,1);break;case 2:case 9:if(fR(o)){Ue=0,ar=null,_R(t);break}t=function(){Ue!==2&&Ue!==9||Xe!==e||(Ue=7),Ei(e)},o.then(t,t);break e;case 3:Ue=7;break e;case 4:Ue=5;break e;case 7:fR(o)?(Ue=0,ar=null,_R(t)):(Ue=0,ar=null,Cc(e,t,o,7));break;case 5:var s=null;switch(pe.tag){case 26:s=pe.memoizedState;case 5:case 27:var a=pe;if(!s||k1(s)){Ue=0,ar=null;var c=a.sibling;if(c!==null)pe=c;else{var l=a.return;l!==null?(pe=l,Dh(l)):pe=null}break t}}Ue=0,ar=null,Cc(e,t,o,5);break;case 6:Ue=0,ar=null,Cc(e,t,o,6);break;case 8:Pv(),ft=6;break e;default:throw Error(D(462))}}ZG();break}catch(p){p1(e,p)}while(!0);return ro=Sa=null,X.H=r,X.A=i,_e=n,pe!==null?0:(Xe=null,Se=0,Oh(),ft)}function ZG(){for(;pe!==null&&!x8();)m1(pe)}function m1(e){var t=HC(e.alternate,e,lo);e.memoizedProps=e.pendingProps,t===null?Dh(e):pe=t}function _R(e){var t=e,n=t.alternate;switch(t.tag){case 15:case 0:t=RR(n,t,t.pendingProps,t.type,void 0,Se);break;case 11:t=RR(n,t,t.pendingProps,t.type.render,t.ref,Se);break;case 5:yv(t);default:GC(n,t),t=pe=GP(t,lo),t=HC(n,t,lo)}e.memoizedProps=e.pendingProps,t===null?Dh(e):pe=t}function Cc(e,t,n,r){ro=Sa=null,yv(t),Lc=null,Fp=0;var i=t.return;try{if($G(e,i,t,n,Se)){ft=1,uh(e,Dr(n,e.current)),pe=null;return}}catch(o){if(i!==null)throw pe=i,o;ft=1,uh(e,Dr(n,e.current)),pe=null;return}t.flags&32768?(we||r===1?e=!0:eu||Se&536870912?e=!1:(Xo=e=!0,(r===2||r===9||r===3||r===6)&&(r=_r.current,r!==null&&r.tag===13&&(r.flags|=16384))),h1(t,e)):Dh(t)}function Dh(e){var t=e;do{if(t.flags&32768){h1(t,Xo);return}e=t.return;var n=zG(t.alternate,t,lo);if(n!==null){pe=n;return}if(t=t.sibling,t!==null){pe=t;return}pe=t=e}while(t!==null);ft===0&&(ft=5)}function h1(e,t){do{var n=HG(e.alternate,e);if(n!==null){n.flags&=32767,pe=n;return}if(n=e.return,n!==null&&(n.flags|=32768,n.subtreeFlags=0,n.deletions=null),!t&&(e=e.sibling,e!==null)){pe=e;return}pe=e=n}while(e!==null);ft=6,pe=null}function jR(e,t,n,r,i,o,s,a,c){e.cancelPendingCommit=null;do Uh();while(rn!==0);if(_e&6)throw Error(D(327));if(t!==null){if(t===e.current)throw Error(D(177));if(o=t.lanes|t.childLanes,o|=rv,P8(e,n,o,s,a,c),e===Xe&&(pe=Xe=null,Se=0),Qc=t,rs=e,Bc=n,PT=o,CT=i,c1=r,t.subtreeFlags&10256||t.flags&10256?(e.callbackNode=null,e.callbackPriority=0,nq(Jm,function(){return x1(!0),null})):(e.callbackNode=null,e.callbackPriority=0),r=(t.flags&13878)!==0,t.subtreeFlags&13878||r){r=X.T,X.T=null,i=Me.p,Me.p=2,s=_e,_e|=4;try{GG(e,t,n)}finally{_e=s,Me.p=i,X.T=r}}rn=1,y1(),g1(),b1()}}function y1(){if(rn===1){rn=0;var e=rs,t=Qc,n=(t.flags&13878)!==0;if(t.subtreeFlags&13878||n){n=X.T,X.T=null;var r=Me.p;Me.p=2;var i=_e;_e|=4;try{t1(t,e);var o=jT,s=jP(e.containerInfo),a=o.focusedElem,c=o.selectionRange;if(s!==a&&a&&a.ownerDocument&&_P(a.ownerDocument.documentElement,a)){if(c!==null&&nv(a)){var l=c.start,p=c.end;if(p===void 0&&(p=l),"selectionStart"in a)a.selectionStart=l,a.selectionEnd=Math.min(p,a.value.length);else{var d=a.ownerDocument||document,m=d&&d.defaultView||window;if(m.getSelection){var y=m.getSelection(),S=a.textContent.length,T=Math.min(c.start,S),E=c.end===void 0?T:Math.min(c.end,S);!y.extend&&T>E&&(s=E,E=T,T=s);var b=iR(a,T),f=iR(a,E);if(b&&f&&(y.rangeCount!==1||y.anchorNode!==b.node||y.anchorOffset!==b.offset||y.focusNode!==f.node||y.focusOffset!==f.offset)){var g=d.createRange();g.setStart(b.node,b.offset),y.removeAllRanges(),T>E?(y.addRange(g),y.extend(f.node,f.offset)):(g.setEnd(f.node,f.offset),y.addRange(g))}}}}for(d=[],y=a;y=y.parentNode;)y.nodeType===1&&d.push({element:y,left:y.scrollLeft,top:y.scrollTop});for(typeof a.focus=="function"&&a.focus(),a=0;a<d.length;a++){var v=d[a];v.element.scrollLeft=v.left,v.element.scrollTop=v.top}}Th=!!_T,jT=_T=null}finally{_e=i,Me.p=r,X.T=n}}e.current=t,rn=2}}function g1(){if(rn===2){rn=0;var e=rs,t=Qc,n=(t.flags&8772)!==0;if(t.subtreeFlags&8772||n){n=X.T,X.T=null;var r=Me.p;Me.p=2;var i=_e;_e|=4;try{XC(e,t.alternate,t)}finally{_e=i,Me.p=r,X.T=n}}rn=3}}function b1(){if(rn===4||rn===3){rn=0,T8();var e=rs,t=Qc,n=Bc,r=c1;t.subtreeFlags&10256||t.flags&10256?rn=5:(rn=0,Qc=rs=null,S1(e,e.pendingLanes));var i=e.pendingLanes;if(i===0&&(ns=null),YT(n),t=t.stateNode,ur&&typeof ur.onCommitFiberRoot=="function")try{ur.onCommitFiberRoot(Yp,t,void 0,(t.current.flags&128)===128)}catch{}if(r!==null){t=X.T,i=Me.p,Me.p=2,X.T=null;try{for(var o=e.onRecoverableError,s=0;s<r.length;s++){var a=r[s];o(a.value,{componentStack:a.stack})}}finally{X.T=t,Me.p=i}}Bc&3&&Uh(),Ei(e),i=e.pendingLanes,n&4194090&&i&42?e===NT?Np++:(Np=0,NT=e):Np=0,cf(0,!1)}}function S1(e,t){(e.pooledCacheLanes&=t)===0&&(t=e.pooledCache,t!=null&&(e.pooledCache=null,nf(t)))}function Uh(e){return y1(),g1(),b1(),x1(e)}function x1(){if(rn!==5)return!1;var e=rs,t=PT;PT=0;var n=YT(Bc),r=X.T,i=Me.p;try{Me.p=32>n?32:n,X.T=null,n=CT,CT=null;var o=rs,s=Bc;if(rn=0,Qc=rs=null,Bc=0,_e&6)throw Error(D(331));var a=_e;if(_e|=4,s1(o.current),r1(o,o.current,s,n),_e=a,cf(0,!1),ur&&typeof ur.onPostCommitFiberRoot=="function")try{ur.onPostCommitFiberRoot(Yp,o)}catch{}return!0}finally{Me.p=i,X.T=r,S1(e,t)}}function LR(e,t,n){t=Dr(n,t),t=wT(e.stateNode,t,2),e=ts(e,t,2),e!==null&&(Xp(e,2),Ei(e))}function He(e,t,n){if(e.tag===3)LR(e,e,n);else for(;t!==null;){if(t.tag===3){LR(t,e,n);break}else if(t.tag===1){var r=t.stateNode;if(typeof t.type.getDerivedStateFromError=="function"||typeof r.componentDidCatch=="function"&&(ns===null||!ns.has(r))){e=Dr(n,e),n=jC(2),r=ts(t,n,2),r!==null&&(LC(n,r,t,e),Xp(r,2),Ei(r));break}}t=t.return}}function Gx(e,t,n){var r=e.pingCache;if(r===null){r=e.pingCache=new QG;var i=new Set;r.set(t,i)}else i=r.get(t),i===void 0&&(i=new Set,r.set(t,i));i.has(n)||(Ov=!0,i.add(n),e=WG.bind(null,e,t,n),t.then(e,e))}function WG(e,t,n){var r=e.pingCache;r!==null&&r.delete(t),e.pingedLanes|=e.suspendedLanes&n,e.warmLanes&=~n,Xe===e&&(Se&n)===n&&(ft===4||ft===3&&(Se&62914560)===Se&&300>Ti()-Rv?!(_e&2)&&Yc(e,0):Av|=n,Vc===Se&&(Vc=0)),Ei(e)}function T1(e,t){t===0&&(t=yP()),e=Wc(e,t),e!==null&&(Xp(e,t),Ei(e))}function eq(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),T1(e,n)}function tq(e,t){var n=0;switch(e.tag){case 13:var r=e.stateNode,i=e.memoizedState;i!==null&&(n=i.retryLane);break;case 19:r=e.stateNode;break;case 22:r=e.stateNode._retryCache;break;default:throw Error(D(314))}r!==null&&r.delete(t),T1(e,n)}function nq(e,t){return VT(e,t)}var mh=null,Sc=null,DT=!1,hh=!1,qx=!1,pa=0;function Ei(e){e!==Sc&&e.next===null&&(Sc===null?mh=Sc=e:Sc=Sc.next=e),hh=!0,DT||(DT=!0,iq())}function cf(e,t){if(!qx&&hh){qx=!0;do for(var n=!1,r=mh;r!==null;){if(!t)if(e!==0){var i=r.pendingLanes;if(i===0)var o=0;else{var s=r.suspendedLanes,a=r.pingedLanes;o=(1<<31-lr(42|e)+1)-1,o&=i&~(s&~a),o=o&201326741?o&201326741|1:o?o|2:0}o!==0&&(n=!0,BR(r,o))}else o=Se,o=Ih(r,r===Xe?o:0,r.cancelPendingCommit!==null||r.timeoutHandle!==-1),!(o&3)||Jp(r,o)||(n=!0,BR(r,o));r=r.next}while(n);qx=!1}}function rq(){v1()}function v1(){hh=DT=!1;var e=0;pa!==0&&(lq()&&(e=pa),pa=0);for(var t=Ti(),n=null,r=mh;r!==null;){var i=r.next,o=I1(r,t);o===0?(r.next=null,n===null?mh=i:n.next=i,i===null&&(Sc=n)):(n=r,(e!==0||o&3)&&(hh=!0)),r=i}cf(e,!1)}function I1(e,t){for(var n=e.suspendedLanes,r=e.pingedLanes,i=e.expirationTimes,o=e.pendingLanes&-62914561;0<o;){var s=31-lr(o),a=1<<s,c=i[s];c===-1?(!(a&n)||a&r)&&(i[s]=R8(a,t)):c<=t&&(e.expiredLanes|=a),o&=~a}if(t=Xe,n=Se,n=Ih(e,e===t?n:0,e.cancelPendingCommit!==null||e.timeoutHandle!==-1),r=e.callbackNode,n===0||e===t&&(Ue===2||Ue===9)||e.cancelPendingCommit!==null)return r!==null&&r!==null&&Sx(r),e.callbackNode=null,e.callbackPriority=0;if(!(n&3)||Jp(e,n)){if(t=n&-n,t===e.callbackPriority)return t;switch(r!==null&&Sx(r),YT(n)){case 2:case 8:n=dP;break;case 32:n=Jm;break;case 268435456:n=mP;break;default:n=Jm}return r=E1.bind(null,e),n=VT(n,r),e.callbackPriority=t,e.callbackNode=n,t}return r!==null&&r!==null&&Sx(r),e.callbackPriority=2,e.callbackNode=null,2}function E1(e,t){if(rn!==0&&rn!==5)return e.callbackNode=null,e.callbackPriority=0,null;var n=e.callbackNode;if(Uh(!0)&&e.callbackNode!==n)return null;var r=Se;return r=Ih(e,e===Xe?r:0,e.cancelPendingCommit!==null||e.timeoutHandle!==-1),r===0?null:(l1(e,r,t),I1(e,Ti()),e.callbackNode!=null&&e.callbackNode===n?E1.bind(null,e):null)}function BR(e,t){if(Uh())return null;l1(e,t,!0)}function iq(){fq(function(){_e&6?VT(fP,rq):v1()})}function Cv(){return pa===0&&(pa=hP()),pa}function FR(e){return e==null||typeof e=="symbol"||typeof e=="boolean"?null:typeof e=="function"?e:Um(""+e)}function $R(e,t){var n=t.ownerDocument.createElement("input");return n.name=t.name,n.value=t.value,e.id&&n.setAttribute("form",e.id),t.parentNode.insertBefore(n,t),e=new FormData(e),n.parentNode.removeChild(n),e}function oq(e,t,n,r,i){if(t==="submit"&&n&&n.stateNode===i){var o=FR((i[Hn]||null).action),s=r.submitter;s&&(t=(t=s[Hn]||null)?FR(t.formAction):s.getAttribute("formAction"),t!==null&&(o=t,s=null));var a=new Eh("action","action",null,r,i);e.push({event:a,listeners:[{instance:null,listener:function(){if(r.defaultPrevented){if(pa!==0){var c=s?$R(i,s):new FormData(i);IT(n,{pending:!0,data:c,method:i.method,action:o},null,c)}}else typeof o=="function"&&(a.preventDefault(),c=s?$R(i,s):new FormData(i),IT(n,{pending:!0,data:c,method:i.method,action:o},o,c))},currentTarget:i}]})}}for(Rm=0;Rm<pT.length;Rm++)Pm=pT[Rm],KR=Pm.toLowerCase(),zR=Pm[0].toUpperCase()+Pm.slice(1),ei(KR,"on"+zR);var Pm,KR,zR,Rm;ei(BP,"onAnimationEnd");ei(FP,"onAnimationIteration");ei($P,"onAnimationStart");ei("dblclick","onDoubleClick");ei("focusin","onFocus");ei("focusout","onBlur");ei(EG,"onTransitionRun");ei(wG,"onTransitionStart");ei(MG,"onTransitionCancel");ei(KP,"onTransitionEnd");$c("onMouseEnter",["mouseout","mouseover"]);$c("onMouseLeave",["mouseout","mouseover"]);$c("onPointerEnter",["pointerout","pointerover"]);$c("onPointerLeave",["pointerout","pointerover"]);ya("onChange","change click focusin focusout input keydown keyup selectionchange".split(" "));ya("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" "));ya("onBeforeInput",["compositionend","keypress","textInput","paste"]);ya("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" "));ya("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" "));ya("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var $p="abort canplay canplaythrough durationchange emptied encrypted ended error loadeddata loadedmetadata loadstart pause play playing progress ratechange resize seeked seeking stalled suspend timeupdate volumechange waiting".split(" "),sq=new Set("beforetoggle cancel close invalid load scroll scrollend toggle".split(" ").concat($p));function w1(e,t){t=(t&4)!==0;for(var n=0;n<e.length;n++){var r=e[n],i=r.event;r=r.listeners;e:{var o=void 0;if(t)for(var s=r.length-1;0<=s;s--){var a=r[s],c=a.instance,l=a.currentTarget;if(a=a.listener,c!==o&&i.isPropagationStopped())break e;o=a,i.currentTarget=l;try{o(i)}catch(p){ch(p)}i.currentTarget=null,o=c}else for(s=0;s<r.length;s++){if(a=r[s],c=a.instance,l=a.currentTarget,a=a.listener,c!==o&&i.isPropagationStopped())break e;o=a,i.currentTarget=l;try{o(i)}catch(p){ch(p)}i.currentTarget=null,o=c}}}}function le(e,t){var n=t[iT];n===void 0&&(n=t[iT]=new Set);var r=e+"__bubble";n.has(r)||(M1(t,e,2,!1),n.add(r))}function Vx(e,t,n){var r=0;t&&(r|=4),M1(n,e,r,t)}var Cm="_reactListening"+Math.random().toString(36).slice(2);function Nv(e){if(!e[Cm]){e[Cm]=!0,xP.forEach(function(n){n!=="selectionchange"&&(sq.has(n)||Vx(n,!1,e),Vx(n,!0,e))});var t=e.nodeType===9?e:e.ownerDocument;t===null||t[Cm]||(t[Cm]=!0,Vx("selectionchange",!1,t))}}function M1(e,t,n,r){switch(L1(t)){case 2:var i=kq;break;case 8:i=Dq;break;default:i=_v}n=i.bind(null,t,n,e),i=void 0,!cT||t!=="touchstart"&&t!=="touchmove"&&t!=="wheel"||(i=!0),r?i!==void 0?e.addEventListener(t,n,{capture:!0,passive:i}):e.addEventListener(t,n,!0):i!==void 0?e.addEventListener(t,n,{passive:i}):e.addEventListener(t,n,!1)}function Qx(e,t,n,r,i){var o=r;if(!(t&1)&&!(t&2)&&r!==null)e:for(;;){if(r===null)return;var s=r.tag;if(s===3||s===4){var a=r.stateNode.containerInfo;if(a===i)break;if(s===4)for(s=r.return;s!==null;){var c=s.tag;if((c===3||c===4)&&s.stateNode.containerInfo===i)return;s=s.return}for(;a!==null;){if(s=vc(a),s===null)return;if(c=s.tag,c===5||c===6||c===26||c===27){r=o=s;continue e}a=a.parentNode}}r=r.return}AP(function(){var l=o,p=ZT(n),d=[];e:{var m=zP.get(e);if(m!==void 0){var y=Eh,S=e;switch(e){case"keypress":if(jm(n)===0)break e;case"keydown":case"keyup":y=nG;break;case"focusin":S="focus",y=Ox;break;case"focusout":S="blur",y=Ox;break;case"beforeblur":case"afterblur":y=Ox;break;case"click":if(n.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":y=YA;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":y=H8;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":y=oG;break;case BP:case FP:case $P:y=V8;break;case KP:y=aG;break;case"scroll":case"scrollend":y=K8;break;case"wheel":y=uG;break;case"copy":case"cut":case"paste":y=Y8;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":y=XA;break;case"toggle":case"beforetoggle":y=pG}var T=(t&4)!==0,E=!T&&(e==="scroll"||e==="scrollend"),b=T?m!==null?m+"Capture":null:m;T=[];for(var f=l,g;f!==null;){var v=f;if(g=v.stateNode,v=v.tag,v!==5&&v!==26&&v!==27||g===null||b===null||(v=Up(f,b),v!=null&&T.push(Kp(f,v,g))),E)break;f=f.return}0<T.length&&(m=new y(m,S,null,n,p),d.push({event:m,listeners:T}))}}if(!(t&7)){e:{if(m=e==="mouseover"||e==="pointerover",y=e==="mouseout"||e==="pointerout",m&&n!==aT&&(S=n.relatedTarget||n.fromElement)&&(vc(S)||S[Xc]))break e;if((y||m)&&(m=p.window===p?p:(m=p.ownerDocument)?m.defaultView||m.parentWindow:window,y?(S=n.relatedTarget||n.toElement,y=l,S=S?vc(S):null,S!==null&&(E=Qp(S),T=S.tag,S!==E||T!==5&&T!==27&&T!==6)&&(S=null)):(y=null,S=l),y!==S)){if(T=YA,v="onMouseLeave",b="onMouseEnter",f="mouse",(e==="pointerout"||e==="pointerover")&&(T=XA,v="onPointerLeave",b="onPointerEnter",f="pointer"),E=y==null?m:bp(y),g=S==null?m:bp(S),m=new T(v,f+"leave",y,n,p),m.target=E,m.relatedTarget=g,v=null,vc(p)===l&&(T=new T(b,f+"enter",S,n,p),T.target=g,T.relatedTarget=E,v=T),E=v,y&&S)t:{for(T=y,b=S,f=0,g=T;g;g=yc(g))f++;for(g=0,v=b;v;v=yc(v))g++;for(;0<f-g;)T=yc(T),f--;for(;0<g-f;)b=yc(b),g--;for(;f--;){if(T===b||b!==null&&T===b.alternate)break t;T=yc(T),b=yc(b)}T=null}else T=null;y!==null&&HR(d,m,y,T,!1),S!==null&&E!==null&&HR(d,E,S,T,!0)}}e:{if(m=l?bp(l):window,y=m.nodeName&&m.nodeName.toLowerCase(),y==="select"||y==="input"&&m.type==="file")var I=tR;else if(eR(m))if(DP)I=TG;else{I=SG;var M=bG}else y=m.nodeName,!y||y.toLowerCase()!=="input"||m.type!=="checkbox"&&m.type!=="radio"?l&&XT(l.elementType)&&(I=tR):I=xG;if(I&&(I=I(e,l))){kP(d,I,n,p);break e}M&&M(e,m,l),e==="focusout"&&l&&m.type==="number"&&l.memoizedProps.value!=null&&sT(m,"number",m.value)}switch(M=l?bp(l):window,e){case"focusin":(eR(M)||M.contentEditable==="true")&&(wc=M,uT=l,vp=null);break;case"focusout":vp=uT=wc=null;break;case"mousedown":lT=!0;break;case"contextmenu":case"mouseup":case"dragend":lT=!1,oR(d,n,p);break;case"selectionchange":if(IG)break;case"keydown":case"keyup":oR(d,n,p)}var O;if(tv)e:{switch(e){case"compositionstart":var C="onCompositionStart";break e;case"compositionend":C="onCompositionEnd";break e;case"compositionupdate":C="onCompositionUpdate";break e}C=void 0}else Ec?CP(e,n)&&(C="onCompositionEnd"):e==="keydown"&&n.keyCode===229&&(C="onCompositionStart");C&&(PP&&n.locale!=="ko"&&(Ec||C!=="onCompositionStart"?C==="onCompositionEnd"&&Ec&&(O=RP()):(Jo=p,WT="value"in Jo?Jo.value:Jo.textContent,Ec=!0)),M=yh(l,C),0<M.length&&(C=new JA(C,e,null,n,p),d.push({event:C,listeners:M}),O?C.data=O:(O=NP(n),O!==null&&(C.data=O)))),(O=dG?mG(e,n):hG(e,n))&&(C=yh(l,"onBeforeInput"),0<C.length&&(M=new JA("onBeforeInput","beforeinput",null,n,p),d.push({event:M,listeners:C}),M.data=O)),oq(d,e,l,n,p)}w1(d,t)})}function Kp(e,t,n){return{instance:e,listener:t,currentTarget:n}}function yh(e,t){for(var n=t+"Capture",r=[];e!==null;){var i=e,o=i.stateNode;if(i=i.tag,i!==5&&i!==26&&i!==27||o===null||(i=Up(e,n),i!=null&&r.unshift(Kp(e,i,o)),i=Up(e,t),i!=null&&r.push(Kp(e,i,o))),e.tag===3)return r;e=e.return}return[]}function yc(e){if(e===null)return null;do e=e.return;while(e&&e.tag!==5&&e.tag!==27);return e||null}function HR(e,t,n,r,i){for(var o=t._reactName,s=[];n!==null&&n!==r;){var a=n,c=a.alternate,l=a.stateNode;if(a=a.tag,c!==null&&c===r)break;a!==5&&a!==26&&a!==27||l===null||(c=l,i?(l=Up(n,o),l!=null&&s.unshift(Kp(n,l,c))):i||(l=Up(n,o),l!=null&&s.push(Kp(n,l,c)))),n=n.return}s.length!==0&&e.push({event:t,listeners:s})}var aq=/\r\n?/g,cq=/\u0000|\uFFFD/g;function GR(e){return(typeof e=="string"?e:""+e).replace(aq,`
15
+ `).replace(cq,"")}function O1(e,t){return t=GR(t),GR(e)===t}function _h(){}function Be(e,t,n,r,i,o){switch(n){case"children":typeof r=="string"?t==="body"||t==="textarea"&&r===""||Kc(e,r):(typeof r=="number"||typeof r=="bigint")&&t!=="body"&&Kc(e,""+r);break;case"className":xm(e,"class",r);break;case"tabIndex":xm(e,"tabindex",r);break;case"dir":case"role":case"viewBox":case"width":case"height":xm(e,n,r);break;case"style":OP(e,r,o);break;case"data":if(t!=="object"){xm(e,"data",r);break}case"src":case"href":if(r===""&&(t!=="a"||n!=="href")){e.removeAttribute(n);break}if(r==null||typeof r=="function"||typeof r=="symbol"||typeof r=="boolean"){e.removeAttribute(n);break}r=Um(""+r),e.setAttribute(n,r);break;case"action":case"formAction":if(typeof r=="function"){e.setAttribute(n,"javascript:throw new Error('A React form was unexpectedly submitted. If you called form.submit() manually, consider using form.requestSubmit() instead. If you\\'re trying to use event.stopPropagation() in a submit event handler, consider also calling event.preventDefault().')");break}else typeof o=="function"&&(n==="formAction"?(t!=="input"&&Be(e,t,"name",i.name,i,null),Be(e,t,"formEncType",i.formEncType,i,null),Be(e,t,"formMethod",i.formMethod,i,null),Be(e,t,"formTarget",i.formTarget,i,null)):(Be(e,t,"encType",i.encType,i,null),Be(e,t,"method",i.method,i,null),Be(e,t,"target",i.target,i,null)));if(r==null||typeof r=="symbol"||typeof r=="boolean"){e.removeAttribute(n);break}r=Um(""+r),e.setAttribute(n,r);break;case"onClick":r!=null&&(e.onclick=_h);break;case"onScroll":r!=null&&le("scroll",e);break;case"onScrollEnd":r!=null&&le("scrollend",e);break;case"dangerouslySetInnerHTML":if(r!=null){if(typeof r!="object"||!("__html"in r))throw Error(D(61));if(n=r.__html,n!=null){if(i.children!=null)throw Error(D(60));e.innerHTML=n}}break;case"multiple":e.multiple=r&&typeof r!="function"&&typeof r!="symbol";break;case"muted":e.muted=r&&typeof r!="function"&&typeof r!="symbol";break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"defaultValue":case"defaultChecked":case"innerHTML":case"ref":break;case"autoFocus":break;case"xlinkHref":if(r==null||typeof r=="function"||typeof r=="boolean"||typeof r=="symbol"){e.removeAttribute("xlink:href");break}n=Um(""+r),e.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",n);break;case"contentEditable":case"spellCheck":case"draggable":case"value":case"autoReverse":case"externalResourcesRequired":case"focusable":case"preserveAlpha":r!=null&&typeof r!="function"&&typeof r!="symbol"?e.setAttribute(n,""+r):e.removeAttribute(n);break;case"inert":case"allowFullScreen":case"async":case"autoPlay":case"controls":case"default":case"defer":case"disabled":case"disablePictureInPicture":case"disableRemotePlayback":case"formNoValidate":case"hidden":case"loop":case"noModule":case"noValidate":case"open":case"playsInline":case"readOnly":case"required":case"reversed":case"scoped":case"seamless":case"itemScope":r&&typeof r!="function"&&typeof r!="symbol"?e.setAttribute(n,""):e.removeAttribute(n);break;case"capture":case"download":r===!0?e.setAttribute(n,""):r!==!1&&r!=null&&typeof r!="function"&&typeof r!="symbol"?e.setAttribute(n,r):e.removeAttribute(n);break;case"cols":case"rows":case"size":case"span":r!=null&&typeof r!="function"&&typeof r!="symbol"&&!isNaN(r)&&1<=r?e.setAttribute(n,r):e.removeAttribute(n);break;case"rowSpan":case"start":r==null||typeof r=="function"||typeof r=="symbol"||isNaN(r)?e.removeAttribute(n):e.setAttribute(n,r);break;case"popover":le("beforetoggle",e),le("toggle",e),Dm(e,"popover",r);break;case"xlinkActuate":Ji(e,"http://www.w3.org/1999/xlink","xlink:actuate",r);break;case"xlinkArcrole":Ji(e,"http://www.w3.org/1999/xlink","xlink:arcrole",r);break;case"xlinkRole":Ji(e,"http://www.w3.org/1999/xlink","xlink:role",r);break;case"xlinkShow":Ji(e,"http://www.w3.org/1999/xlink","xlink:show",r);break;case"xlinkTitle":Ji(e,"http://www.w3.org/1999/xlink","xlink:title",r);break;case"xlinkType":Ji(e,"http://www.w3.org/1999/xlink","xlink:type",r);break;case"xmlBase":Ji(e,"http://www.w3.org/XML/1998/namespace","xml:base",r);break;case"xmlLang":Ji(e,"http://www.w3.org/XML/1998/namespace","xml:lang",r);break;case"xmlSpace":Ji(e,"http://www.w3.org/XML/1998/namespace","xml:space",r);break;case"is":Dm(e,"is",r);break;case"innerText":case"textContent":break;default:(!(2<n.length)||n[0]!=="o"&&n[0]!=="O"||n[1]!=="n"&&n[1]!=="N")&&(n=F8.get(n)||n,Dm(e,n,r))}}function UT(e,t,n,r,i,o){switch(n){case"style":OP(e,r,o);break;case"dangerouslySetInnerHTML":if(r!=null){if(typeof r!="object"||!("__html"in r))throw Error(D(61));if(n=r.__html,n!=null){if(i.children!=null)throw Error(D(60));e.innerHTML=n}}break;case"children":typeof r=="string"?Kc(e,r):(typeof r=="number"||typeof r=="bigint")&&Kc(e,""+r);break;case"onScroll":r!=null&&le("scroll",e);break;case"onScrollEnd":r!=null&&le("scrollend",e);break;case"onClick":r!=null&&(e.onclick=_h);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"innerHTML":case"ref":break;case"innerText":case"textContent":break;default:if(!TP.hasOwnProperty(n))e:{if(n[0]==="o"&&n[1]==="n"&&(i=n.endsWith("Capture"),t=n.slice(2,i?n.length-7:void 0),o=e[Hn]||null,o=o!=null?o[n]:null,typeof o=="function"&&e.removeEventListener(t,o,i),typeof r=="function")){typeof o!="function"&&o!==null&&(n in e?e[n]=null:e.hasAttribute(n)&&e.removeAttribute(n)),e.addEventListener(t,r,i);break e}n in e?e[n]=r:r===!0?e.setAttribute(n,""):Dm(e,n,r)}}}function on(e,t,n){switch(t){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"img":le("error",e),le("load",e);var r=!1,i=!1,o;for(o in n)if(n.hasOwnProperty(o)){var s=n[o];if(s!=null)switch(o){case"src":r=!0;break;case"srcSet":i=!0;break;case"children":case"dangerouslySetInnerHTML":throw Error(D(137,t));default:Be(e,t,o,s,n,null)}}i&&Be(e,t,"srcSet",n.srcSet,n,null),r&&Be(e,t,"src",n.src,n,null);return;case"input":le("invalid",e);var a=o=s=i=null,c=null,l=null;for(r in n)if(n.hasOwnProperty(r)){var p=n[r];if(p!=null)switch(r){case"name":i=p;break;case"type":s=p;break;case"checked":c=p;break;case"defaultChecked":l=p;break;case"value":o=p;break;case"defaultValue":a=p;break;case"children":case"dangerouslySetInnerHTML":if(p!=null)throw Error(D(137,t));break;default:Be(e,t,r,p,n,null)}}EP(e,o,a,c,l,s,i,!1),Xm(e);return;case"select":le("invalid",e),r=s=o=null;for(i in n)if(n.hasOwnProperty(i)&&(a=n[i],a!=null))switch(i){case"value":o=a;break;case"defaultValue":s=a;break;case"multiple":r=a;default:Be(e,t,i,a,n,null)}t=o,n=s,e.multiple=!!r,t!=null?kc(e,!!r,t,!1):n!=null&&kc(e,!!r,n,!0);return;case"textarea":le("invalid",e),o=i=r=null;for(s in n)if(n.hasOwnProperty(s)&&(a=n[s],a!=null))switch(s){case"value":r=a;break;case"defaultValue":i=a;break;case"children":o=a;break;case"dangerouslySetInnerHTML":if(a!=null)throw Error(D(91));break;default:Be(e,t,s,a,n,null)}MP(e,r,i,o),Xm(e);return;case"option":for(c in n)if(n.hasOwnProperty(c)&&(r=n[c],r!=null))switch(c){case"selected":e.selected=r&&typeof r!="function"&&typeof r!="symbol";break;default:Be(e,t,c,r,n,null)}return;case"dialog":le("beforetoggle",e),le("toggle",e),le("cancel",e),le("close",e);break;case"iframe":case"object":le("load",e);break;case"video":case"audio":for(r=0;r<$p.length;r++)le($p[r],e);break;case"image":le("error",e),le("load",e);break;case"details":le("toggle",e);break;case"embed":case"source":case"link":le("error",e),le("load",e);case"area":case"base":case"br":case"col":case"hr":case"keygen":case"meta":case"param":case"track":case"wbr":case"menuitem":for(l in n)if(n.hasOwnProperty(l)&&(r=n[l],r!=null))switch(l){case"children":case"dangerouslySetInnerHTML":throw Error(D(137,t));default:Be(e,t,l,r,n,null)}return;default:if(XT(t)){for(p in n)n.hasOwnProperty(p)&&(r=n[p],r!==void 0&&UT(e,t,p,r,n,void 0));return}}for(a in n)n.hasOwnProperty(a)&&(r=n[a],r!=null&&Be(e,t,a,r,n,null))}function uq(e,t,n,r){switch(t){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"input":var i=null,o=null,s=null,a=null,c=null,l=null,p=null;for(y in n){var d=n[y];if(n.hasOwnProperty(y)&&d!=null)switch(y){case"checked":break;case"value":break;case"defaultValue":c=d;default:r.hasOwnProperty(y)||Be(e,t,y,null,r,d)}}for(var m in r){var y=r[m];if(d=n[m],r.hasOwnProperty(m)&&(y!=null||d!=null))switch(m){case"type":o=y;break;case"name":i=y;break;case"checked":l=y;break;case"defaultChecked":p=y;break;case"value":s=y;break;case"defaultValue":a=y;break;case"children":case"dangerouslySetInnerHTML":if(y!=null)throw Error(D(137,t));break;default:y!==d&&Be(e,t,m,y,r,d)}}oT(e,s,a,c,l,p,o,i);return;case"select":y=s=a=m=null;for(o in n)if(c=n[o],n.hasOwnProperty(o)&&c!=null)switch(o){case"value":break;case"multiple":y=c;default:r.hasOwnProperty(o)||Be(e,t,o,null,r,c)}for(i in r)if(o=r[i],c=n[i],r.hasOwnProperty(i)&&(o!=null||c!=null))switch(i){case"value":m=o;break;case"defaultValue":a=o;break;case"multiple":s=o;default:o!==c&&Be(e,t,i,o,r,c)}t=a,n=s,r=y,m!=null?kc(e,!!n,m,!1):!!r!=!!n&&(t!=null?kc(e,!!n,t,!0):kc(e,!!n,n?[]:"",!1));return;case"textarea":y=m=null;for(a in n)if(i=n[a],n.hasOwnProperty(a)&&i!=null&&!r.hasOwnProperty(a))switch(a){case"value":break;case"children":break;default:Be(e,t,a,null,r,i)}for(s in r)if(i=r[s],o=n[s],r.hasOwnProperty(s)&&(i!=null||o!=null))switch(s){case"value":m=i;break;case"defaultValue":y=i;break;case"children":break;case"dangerouslySetInnerHTML":if(i!=null)throw Error(D(91));break;default:i!==o&&Be(e,t,s,i,r,o)}wP(e,m,y);return;case"option":for(var S in n)if(m=n[S],n.hasOwnProperty(S)&&m!=null&&!r.hasOwnProperty(S))switch(S){case"selected":e.selected=!1;break;default:Be(e,t,S,null,r,m)}for(c in r)if(m=r[c],y=n[c],r.hasOwnProperty(c)&&m!==y&&(m!=null||y!=null))switch(c){case"selected":e.selected=m&&typeof m!="function"&&typeof m!="symbol";break;default:Be(e,t,c,m,r,y)}return;case"img":case"link":case"area":case"base":case"br":case"col":case"embed":case"hr":case"keygen":case"meta":case"param":case"source":case"track":case"wbr":case"menuitem":for(var T in n)m=n[T],n.hasOwnProperty(T)&&m!=null&&!r.hasOwnProperty(T)&&Be(e,t,T,null,r,m);for(l in r)if(m=r[l],y=n[l],r.hasOwnProperty(l)&&m!==y&&(m!=null||y!=null))switch(l){case"children":case"dangerouslySetInnerHTML":if(m!=null)throw Error(D(137,t));break;default:Be(e,t,l,m,r,y)}return;default:if(XT(t)){for(var E in n)m=n[E],n.hasOwnProperty(E)&&m!==void 0&&!r.hasOwnProperty(E)&&UT(e,t,E,void 0,r,m);for(p in r)m=r[p],y=n[p],!r.hasOwnProperty(p)||m===y||m===void 0&&y===void 0||UT(e,t,p,m,r,y);return}}for(var b in n)m=n[b],n.hasOwnProperty(b)&&m!=null&&!r.hasOwnProperty(b)&&Be(e,t,b,null,r,m);for(d in r)m=r[d],y=n[d],!r.hasOwnProperty(d)||m===y||m==null&&y==null||Be(e,t,d,m,r,y)}var _T=null,jT=null;function gh(e){return e.nodeType===9?e:e.ownerDocument}function qR(e){switch(e){case"http://www.w3.org/2000/svg":return 1;case"http://www.w3.org/1998/Math/MathML":return 2;default:return 0}}function A1(e,t){if(e===0)switch(t){case"svg":return 1;case"math":return 2;default:return 0}return e===1&&t==="foreignObject"?0:e}function LT(e,t){return e==="textarea"||e==="noscript"||typeof t.children=="string"||typeof t.children=="number"||typeof t.children=="bigint"||typeof t.dangerouslySetInnerHTML=="object"&&t.dangerouslySetInnerHTML!==null&&t.dangerouslySetInnerHTML.__html!=null}var Yx=null;function lq(){var e=window.event;return e&&e.type==="popstate"?e===Yx?!1:(Yx=e,!0):(Yx=null,!1)}var R1=typeof setTimeout=="function"?setTimeout:void 0,pq=typeof clearTimeout=="function"?clearTimeout:void 0,VR=typeof Promise=="function"?Promise:void 0,fq=typeof queueMicrotask=="function"?queueMicrotask:typeof VR<"u"?function(e){return VR.resolve(null).then(e).catch(dq)}:R1;function dq(e){setTimeout(function(){throw e})}function ps(e){return e==="head"}function QR(e,t){var n=t,r=0,i=0;do{var o=n.nextSibling;if(e.removeChild(n),o&&o.nodeType===8)if(n=o.data,n==="/$"){if(0<r&&8>r){n=r;var s=e.ownerDocument;if(n&1&&kp(s.documentElement),n&2&&kp(s.body),n&4)for(n=s.head,kp(n),s=n.firstChild;s;){var a=s.nextSibling,c=s.nodeName;s[Zp]||c==="SCRIPT"||c==="STYLE"||c==="LINK"&&s.rel.toLowerCase()==="stylesheet"||n.removeChild(s),s=a}}if(i===0){e.removeChild(o),Vp(t);return}i--}else n==="$"||n==="$?"||n==="$!"?i++:r=n.charCodeAt(0)-48;else r=0;n=o}while(n);Vp(t)}function BT(e){var t=e.firstChild;for(t&&t.nodeType===10&&(t=t.nextSibling);t;){var n=t;switch(t=t.nextSibling,n.nodeName){case"HTML":case"HEAD":case"BODY":BT(n),JT(n);continue;case"SCRIPT":case"STYLE":continue;case"LINK":if(n.rel.toLowerCase()==="stylesheet")continue}e.removeChild(n)}}function mq(e,t,n,r){for(;e.nodeType===1;){var i=n;if(e.nodeName.toLowerCase()!==t.toLowerCase()){if(!r&&(e.nodeName!=="INPUT"||e.type!=="hidden"))break}else if(r){if(!e[Zp])switch(t){case"meta":if(!e.hasAttribute("itemprop"))break;return e;case"link":if(o=e.getAttribute("rel"),o==="stylesheet"&&e.hasAttribute("data-precedence"))break;if(o!==i.rel||e.getAttribute("href")!==(i.href==null||i.href===""?null:i.href)||e.getAttribute("crossorigin")!==(i.crossOrigin==null?null:i.crossOrigin)||e.getAttribute("title")!==(i.title==null?null:i.title))break;return e;case"style":if(e.hasAttribute("data-precedence"))break;return e;case"script":if(o=e.getAttribute("src"),(o!==(i.src==null?null:i.src)||e.getAttribute("type")!==(i.type==null?null:i.type)||e.getAttribute("crossorigin")!==(i.crossOrigin==null?null:i.crossOrigin))&&o&&e.hasAttribute("async")&&!e.hasAttribute("itemprop"))break;return e;default:return e}}else if(t==="input"&&e.type==="hidden"){var o=i.name==null?null:""+i.name;if(i.type==="hidden"&&e.getAttribute("name")===o)return e}else return e;if(e=Wr(e.nextSibling),e===null)break}return null}function hq(e,t,n){if(t==="")return null;for(;e.nodeType!==3;)if((e.nodeType!==1||e.nodeName!=="INPUT"||e.type!=="hidden")&&!n||(e=Wr(e.nextSibling),e===null))return null;return e}function FT(e){return e.data==="$!"||e.data==="$?"&&e.ownerDocument.readyState==="complete"}function yq(e,t){var n=e.ownerDocument;if(e.data!=="$?"||n.readyState==="complete")t();else{var r=function(){t(),n.removeEventListener("DOMContentLoaded",r)};n.addEventListener("DOMContentLoaded",r),e._reactRetry=r}}function Wr(e){for(;e!=null;e=e.nextSibling){var t=e.nodeType;if(t===1||t===3)break;if(t===8){if(t=e.data,t==="$"||t==="$!"||t==="$?"||t==="F!"||t==="F")break;if(t==="/$")return null}}return e}var $T=null;function YR(e){e=e.previousSibling;for(var t=0;e;){if(e.nodeType===8){var n=e.data;if(n==="$"||n==="$!"||n==="$?"){if(t===0)return e;t--}else n==="/$"&&t++}e=e.previousSibling}return null}function P1(e,t,n){switch(t=gh(n),e){case"html":if(e=t.documentElement,!e)throw Error(D(452));return e;case"head":if(e=t.head,!e)throw Error(D(453));return e;case"body":if(e=t.body,!e)throw Error(D(454));return e;default:throw Error(D(451))}}function kp(e){for(var t=e.attributes;t.length;)e.removeAttributeNode(t[0]);JT(e)}var jr=new Map,JR=new Set;function bh(e){return typeof e.getRootNode=="function"?e.getRootNode():e.nodeType===9?e:e.ownerDocument}var po=Me.d;Me.d={f:gq,r:bq,D:Sq,C:xq,L:Tq,m:vq,X:Eq,S:Iq,M:wq};function gq(){var e=po.f(),t=kh();return e||t}function bq(e){var t=Zc(e);t!==null&&t.tag===5&&t.type==="form"?IC(t):po.r(e)}var tu=typeof document>"u"?null:document;function C1(e,t,n){var r=tu;if(r&&typeof t=="string"&&t){var i=kr(t);i='link[rel="'+e+'"][href="'+i+'"]',typeof n=="string"&&(i+='[crossorigin="'+n+'"]'),JR.has(i)||(JR.add(i),e={rel:e,crossOrigin:n,href:t},r.querySelector(i)===null&&(t=r.createElement("link"),on(t,"link",e),Vt(t),r.head.appendChild(t)))}}function Sq(e){po.D(e),C1("dns-prefetch",e,null)}function xq(e,t){po.C(e,t),C1("preconnect",e,t)}function Tq(e,t,n){po.L(e,t,n);var r=tu;if(r&&e&&t){var i='link[rel="preload"][as="'+kr(t)+'"]';t==="image"&&n&&n.imageSrcSet?(i+='[imagesrcset="'+kr(n.imageSrcSet)+'"]',typeof n.imageSizes=="string"&&(i+='[imagesizes="'+kr(n.imageSizes)+'"]')):i+='[href="'+kr(e)+'"]';var o=i;switch(t){case"style":o=Jc(e);break;case"script":o=nu(e)}jr.has(o)||(e=We({rel:"preload",href:t==="image"&&n&&n.imageSrcSet?void 0:e,as:t},n),jr.set(o,e),r.querySelector(i)!==null||t==="style"&&r.querySelector(uf(o))||t==="script"&&r.querySelector(lf(o))||(t=r.createElement("link"),on(t,"link",e),Vt(t),r.head.appendChild(t)))}}function vq(e,t){po.m(e,t);var n=tu;if(n&&e){var r=t&&typeof t.as=="string"?t.as:"script",i='link[rel="modulepreload"][as="'+kr(r)+'"][href="'+kr(e)+'"]',o=i;switch(r){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":o=nu(e)}if(!jr.has(o)&&(e=We({rel:"modulepreload",href:e},t),jr.set(o,e),n.querySelector(i)===null)){switch(r){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(n.querySelector(lf(o)))return}r=n.createElement("link"),on(r,"link",e),Vt(r),n.head.appendChild(r)}}}function Iq(e,t,n){po.S(e,t,n);var r=tu;if(r&&e){var i=Nc(r).hoistableStyles,o=Jc(e);t=t||"default";var s=i.get(o);if(!s){var a={loading:0,preload:null};if(s=r.querySelector(uf(o)))a.loading=5;else{e=We({rel:"stylesheet",href:e,"data-precedence":t},n),(n=jr.get(o))&&kv(e,n);var c=s=r.createElement("link");Vt(c),on(c,"link",e),c._p=new Promise(function(l,p){c.onload=l,c.onerror=p}),c.addEventListener("load",function(){a.loading|=1}),c.addEventListener("error",function(){a.loading|=2}),a.loading|=4,Hm(s,t,r)}s={type:"stylesheet",instance:s,count:1,state:a},i.set(o,s)}}}function Eq(e,t){po.X(e,t);var n=tu;if(n&&e){var r=Nc(n).hoistableScripts,i=nu(e),o=r.get(i);o||(o=n.querySelector(lf(i)),o||(e=We({src:e,async:!0},t),(t=jr.get(i))&&Dv(e,t),o=n.createElement("script"),Vt(o),on(o,"link",e),n.head.appendChild(o)),o={type:"script",instance:o,count:1,state:null},r.set(i,o))}}function wq(e,t){po.M(e,t);var n=tu;if(n&&e){var r=Nc(n).hoistableScripts,i=nu(e),o=r.get(i);o||(o=n.querySelector(lf(i)),o||(e=We({src:e,async:!0,type:"module"},t),(t=jr.get(i))&&Dv(e,t),o=n.createElement("script"),Vt(o),on(o,"link",e),n.head.appendChild(o)),o={type:"script",instance:o,count:1,state:null},r.set(i,o))}}function XR(e,t,n,r){var i=(i=Wo.current)?bh(i):null;if(!i)throw Error(D(446));switch(e){case"meta":case"title":return null;case"style":return typeof n.precedence=="string"&&typeof n.href=="string"?(t=Jc(n.href),n=Nc(i).hoistableStyles,r=n.get(t),r||(r={type:"style",instance:null,count:0,state:null},n.set(t,r)),r):{type:"void",instance:null,count:0,state:null};case"link":if(n.rel==="stylesheet"&&typeof n.href=="string"&&typeof n.precedence=="string"){e=Jc(n.href);var o=Nc(i).hoistableStyles,s=o.get(e);if(s||(i=i.ownerDocument||i,s={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},o.set(e,s),(o=i.querySelector(uf(e)))&&!o._p&&(s.instance=o,s.state.loading=5),jr.has(e)||(n={rel:"preload",as:"style",href:n.href,crossOrigin:n.crossOrigin,integrity:n.integrity,media:n.media,hrefLang:n.hrefLang,referrerPolicy:n.referrerPolicy},jr.set(e,n),o||Mq(i,e,n,s.state))),t&&r===null)throw Error(D(528,""));return s}if(t&&r!==null)throw Error(D(529,""));return null;case"script":return t=n.async,n=n.src,typeof n=="string"&&t&&typeof t!="function"&&typeof t!="symbol"?(t=nu(n),n=Nc(i).hoistableScripts,r=n.get(t),r||(r={type:"script",instance:null,count:0,state:null},n.set(t,r)),r):{type:"void",instance:null,count:0,state:null};default:throw Error(D(444,e))}}function Jc(e){return'href="'+kr(e)+'"'}function uf(e){return'link[rel="stylesheet"]['+e+"]"}function N1(e){return We({},e,{"data-precedence":e.precedence,precedence:null})}function Mq(e,t,n,r){e.querySelector('link[rel="preload"][as="style"]['+t+"]")?r.loading=1:(t=e.createElement("link"),r.preload=t,t.addEventListener("load",function(){return r.loading|=1}),t.addEventListener("error",function(){return r.loading|=2}),on(t,"link",n),Vt(t),e.head.appendChild(t))}function nu(e){return'[src="'+kr(e)+'"]'}function lf(e){return"script[async]"+e}function ZR(e,t,n){if(t.count++,t.instance===null)switch(t.type){case"style":var r=e.querySelector('style[data-href~="'+kr(n.href)+'"]');if(r)return t.instance=r,Vt(r),r;var i=We({},n,{"data-href":n.href,"data-precedence":n.precedence,href:null,precedence:null});return r=(e.ownerDocument||e).createElement("style"),Vt(r),on(r,"style",i),Hm(r,n.precedence,e),t.instance=r;case"stylesheet":i=Jc(n.href);var o=e.querySelector(uf(i));if(o)return t.state.loading|=4,t.instance=o,Vt(o),o;r=N1(n),(i=jr.get(i))&&kv(r,i),o=(e.ownerDocument||e).createElement("link"),Vt(o);var s=o;return s._p=new Promise(function(a,c){s.onload=a,s.onerror=c}),on(o,"link",r),t.state.loading|=4,Hm(o,n.precedence,e),t.instance=o;case"script":return o=nu(n.src),(i=e.querySelector(lf(o)))?(t.instance=i,Vt(i),i):(r=n,(i=jr.get(o))&&(r=We({},n),Dv(r,i)),e=e.ownerDocument||e,i=e.createElement("script"),Vt(i),on(i,"link",r),e.head.appendChild(i),t.instance=i);case"void":return null;default:throw Error(D(443,t.type))}else t.type==="stylesheet"&&!(t.state.loading&4)&&(r=t.instance,t.state.loading|=4,Hm(r,n.precedence,e));return t.instance}function Hm(e,t,n){for(var r=n.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),i=r.length?r[r.length-1]:null,o=i,s=0;s<r.length;s++){var a=r[s];if(a.dataset.precedence===t)o=a;else if(o!==i)break}o?o.parentNode.insertBefore(e,o.nextSibling):(t=n.nodeType===9?n.head:n,t.insertBefore(e,t.firstChild))}function kv(e,t){e.crossOrigin==null&&(e.crossOrigin=t.crossOrigin),e.referrerPolicy==null&&(e.referrerPolicy=t.referrerPolicy),e.title==null&&(e.title=t.title)}function Dv(e,t){e.crossOrigin==null&&(e.crossOrigin=t.crossOrigin),e.referrerPolicy==null&&(e.referrerPolicy=t.referrerPolicy),e.integrity==null&&(e.integrity=t.integrity)}var Gm=null;function WR(e,t,n){if(Gm===null){var r=new Map,i=Gm=new Map;i.set(n,r)}else i=Gm,r=i.get(n),r||(r=new Map,i.set(n,r));if(r.has(e))return r;for(r.set(e,null),n=n.getElementsByTagName(e),i=0;i<n.length;i++){var o=n[i];if(!(o[Zp]||o[mn]||e==="link"&&o.getAttribute("rel")==="stylesheet")&&o.namespaceURI!=="http://www.w3.org/2000/svg"){var s=o.getAttribute(t)||"";s=e+s;var a=r.get(s);a?a.push(o):r.set(s,[o])}}return r}function eP(e,t,n){e=e.ownerDocument||e,e.head.insertBefore(n,t==="title"?e.querySelector("head > title"):null)}function Oq(e,t,n){if(n===1||t.itemProp!=null)return!1;switch(e){case"meta":case"title":return!0;case"style":if(typeof t.precedence!="string"||typeof t.href!="string"||t.href==="")break;return!0;case"link":if(typeof t.rel!="string"||typeof t.href!="string"||t.href===""||t.onLoad||t.onError)break;switch(t.rel){case"stylesheet":return e=t.disabled,typeof t.precedence=="string"&&e==null;default:return!0}case"script":if(t.async&&typeof t.async!="function"&&typeof t.async!="symbol"&&!t.onLoad&&!t.onError&&t.src&&typeof t.src=="string")return!0}return!1}function k1(e){return!(e.type==="stylesheet"&&!(e.state.loading&3))}var zp=null;function Aq(){}function Rq(e,t,n){if(zp===null)throw Error(D(475));var r=zp;if(t.type==="stylesheet"&&(typeof n.media!="string"||matchMedia(n.media).matches!==!1)&&!(t.state.loading&4)){if(t.instance===null){var i=Jc(n.href),o=e.querySelector(uf(i));if(o){e=o._p,e!==null&&typeof e=="object"&&typeof e.then=="function"&&(r.count++,r=Sh.bind(r),e.then(r,r)),t.state.loading|=4,t.instance=o,Vt(o);return}o=e.ownerDocument||e,n=N1(n),(i=jr.get(i))&&kv(n,i),o=o.createElement("link"),Vt(o);var s=o;s._p=new Promise(function(a,c){s.onload=a,s.onerror=c}),on(o,"link",n),t.instance=o}r.stylesheets===null&&(r.stylesheets=new Map),r.stylesheets.set(t,e),(e=t.state.preload)&&!(t.state.loading&3)&&(r.count++,t=Sh.bind(r),e.addEventListener("load",t),e.addEventListener("error",t))}}function Pq(){if(zp===null)throw Error(D(475));var e=zp;return e.stylesheets&&e.count===0&&KT(e,e.stylesheets),0<e.count?function(t){var n=setTimeout(function(){if(e.stylesheets&&KT(e,e.stylesheets),e.unsuspend){var r=e.unsuspend;e.unsuspend=null,r()}},6e4);return e.unsuspend=t,function(){e.unsuspend=null,clearTimeout(n)}}:null}function Sh(){if(this.count--,this.count===0){if(this.stylesheets)KT(this,this.stylesheets);else if(this.unsuspend){var e=this.unsuspend;this.unsuspend=null,e()}}}var xh=null;function KT(e,t){e.stylesheets=null,e.unsuspend!==null&&(e.count++,xh=new Map,t.forEach(Cq,e),xh=null,Sh.call(e))}function Cq(e,t){if(!(t.state.loading&4)){var n=xh.get(e);if(n)var r=n.get(null);else{n=new Map,xh.set(e,n);for(var i=e.querySelectorAll("link[data-precedence],style[data-precedence]"),o=0;o<i.length;o++){var s=i[o];(s.nodeName==="LINK"||s.getAttribute("media")!=="not all")&&(n.set(s.dataset.precedence,s),r=s)}r&&n.set(null,r)}i=t.instance,s=i.getAttribute("data-precedence"),o=n.get(s)||r,o===r&&n.set(null,i),n.set(s,i),this.count++,r=Sh.bind(this),i.addEventListener("load",r),i.addEventListener("error",r),o?o.parentNode.insertBefore(i,o.nextSibling):(e=e.nodeType===9?e.head:e,e.insertBefore(i,e.firstChild)),t.state.loading|=4}}var Hp={$$typeof:eo,Provider:null,Consumer:null,_currentValue:oa,_currentValue2:oa,_threadCount:0};function Nq(e,t,n,r,i,o,s,a){this.tag=1,this.containerInfo=e,this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.next=this.pendingContext=this.context=this.cancelPendingCommit=null,this.callbackPriority=0,this.expirationTimes=xx(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=xx(0),this.hiddenUpdates=xx(null),this.identifierPrefix=r,this.onUncaughtError=i,this.onCaughtError=o,this.onRecoverableError=s,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=a,this.incompleteTransitions=new Map}function D1(e,t,n,r,i,o,s,a,c,l,p,d){return e=new Nq(e,t,n,s,a,c,l,d),t=1,o===!0&&(t|=24),o=cr(3,null,null,t),e.current=o,o.stateNode=e,t=cv(),t.refCount++,e.pooledCache=t,t.refCount++,o.memoizedState={element:r,isDehydrated:n,cache:t},lv(o),e}function U1(e){return e?(e=Ac,e):Ac}function _1(e,t,n,r,i,o){i=U1(i),r.context===null?r.context=i:r.pendingContext=i,r=es(t),r.payload={element:n},o=o===void 0?null:o,o!==null&&(r.callback=o),n=ts(e,r,t),n!==null&&(fr(n,e,t),wp(n,e,t))}function tP(e,t){if(e=e.memoizedState,e!==null&&e.dehydrated!==null){var n=e.retryLane;e.retryLane=n!==0&&n<t?n:t}}function Uv(e,t){tP(e,t),(e=e.alternate)&&tP(e,t)}function j1(e){if(e.tag===13){var t=Wc(e,67108864);t!==null&&fr(t,e,67108864),Uv(e,67108864)}}var Th=!0;function kq(e,t,n,r){var i=X.T;X.T=null;var o=Me.p;try{Me.p=2,_v(e,t,n,r)}finally{Me.p=o,X.T=i}}function Dq(e,t,n,r){var i=X.T;X.T=null;var o=Me.p;try{Me.p=8,_v(e,t,n,r)}finally{Me.p=o,X.T=i}}function _v(e,t,n,r){if(Th){var i=zT(r);if(i===null)Qx(e,t,r,vh,n),nP(e,r);else if(_q(i,e,t,n,r))r.stopPropagation();else if(nP(e,r),t&4&&-1<Uq.indexOf(e)){for(;i!==null;){var o=Zc(i);if(o!==null)switch(o.tag){case 3:if(o=o.stateNode,o.current.memoizedState.isDehydrated){var s=na(o.pendingLanes);if(s!==0){var a=o;for(a.pendingLanes|=2,a.entangledLanes|=2;s;){var c=1<<31-lr(s);a.entanglements[1]|=c,s&=~c}Ei(o),!(_e&6)&&(fh=Ti()+500,cf(0,!1))}}break;case 13:a=Wc(o,2),a!==null&&fr(a,o,2),kh(),Uv(o,2)}if(o=zT(r),o===null&&Qx(e,t,r,vh,n),o===i)break;i=o}i!==null&&r.stopPropagation()}else Qx(e,t,r,null,n)}}function zT(e){return e=ZT(e),jv(e)}var vh=null;function jv(e){if(vh=null,e=vc(e),e!==null){var t=Qp(e);if(t===null)e=null;else{var n=t.tag;if(n===13){if(e=cP(t),e!==null)return e;e=null}else if(n===3){if(t.stateNode.current.memoizedState.isDehydrated)return t.tag===3?t.stateNode.containerInfo:null;e=null}else t!==e&&(e=null)}}return vh=e,null}function L1(e){switch(e){case"beforetoggle":case"cancel":case"click":case"close":case"contextmenu":case"copy":case"cut":case"auxclick":case"dblclick":case"dragend":case"dragstart":case"drop":case"focusin":case"focusout":case"input":case"invalid":case"keydown":case"keypress":case"keyup":case"mousedown":case"mouseup":case"paste":case"pause":case"play":case"pointercancel":case"pointerdown":case"pointerup":case"ratechange":case"reset":case"resize":case"seeked":case"submit":case"toggle":case"touchcancel":case"touchend":case"touchstart":case"volumechange":case"change":case"selectionchange":case"textInput":case"compositionstart":case"compositionend":case"compositionupdate":case"beforeblur":case"afterblur":case"beforeinput":case"blur":case"fullscreenchange":case"focus":case"hashchange":case"popstate":case"select":case"selectstart":return 2;case"drag":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"mousemove":case"mouseout":case"mouseover":case"pointermove":case"pointerout":case"pointerover":case"scroll":case"touchmove":case"wheel":case"mouseenter":case"mouseleave":case"pointerenter":case"pointerleave":return 8;case"message":switch(v8()){case fP:return 2;case dP:return 8;case Jm:case I8:return 32;case mP:return 268435456;default:return 32}default:return 32}}var HT=!1,is=null,os=null,ss=null,Gp=new Map,qp=new Map,Qo=[],Uq="mousedown mouseup touchcancel touchend touchstart auxclick dblclick pointercancel pointerdown pointerup dragend dragstart drop compositionend compositionstart keydown keypress keyup input textInput copy cut paste click change contextmenu reset".split(" ");function nP(e,t){switch(e){case"focusin":case"focusout":is=null;break;case"dragenter":case"dragleave":os=null;break;case"mouseover":case"mouseout":ss=null;break;case"pointerover":case"pointerout":Gp.delete(t.pointerId);break;case"gotpointercapture":case"lostpointercapture":qp.delete(t.pointerId)}}function mp(e,t,n,r,i,o){return e===null||e.nativeEvent!==o?(e={blockedOn:t,domEventName:n,eventSystemFlags:r,nativeEvent:o,targetContainers:[i]},t!==null&&(t=Zc(t),t!==null&&j1(t)),e):(e.eventSystemFlags|=r,t=e.targetContainers,i!==null&&t.indexOf(i)===-1&&t.push(i),e)}function _q(e,t,n,r,i){switch(t){case"focusin":return is=mp(is,e,t,n,r,i),!0;case"dragenter":return os=mp(os,e,t,n,r,i),!0;case"mouseover":return ss=mp(ss,e,t,n,r,i),!0;case"pointerover":var o=i.pointerId;return Gp.set(o,mp(Gp.get(o)||null,e,t,n,r,i)),!0;case"gotpointercapture":return o=i.pointerId,qp.set(o,mp(qp.get(o)||null,e,t,n,r,i)),!0}return!1}function B1(e){var t=vc(e.target);if(t!==null){var n=Qp(t);if(n!==null){if(t=n.tag,t===13){if(t=cP(n),t!==null){e.blockedOn=t,C8(e.priority,function(){if(n.tag===13){var r=pr();r=QT(r);var i=Wc(n,r);i!==null&&fr(i,n,r),Uv(n,r)}});return}}else if(t===3&&n.stateNode.current.memoizedState.isDehydrated){e.blockedOn=n.tag===3?n.stateNode.containerInfo:null;return}}}e.blockedOn=null}function qm(e){if(e.blockedOn!==null)return!1;for(var t=e.targetContainers;0<t.length;){var n=zT(e.nativeEvent);if(n===null){n=e.nativeEvent;var r=new n.constructor(n.type,n);aT=r,n.target.dispatchEvent(r),aT=null}else return t=Zc(n),t!==null&&j1(t),e.blockedOn=n,!1;t.shift()}return!0}function rP(e,t,n){qm(e)&&n.delete(t)}function jq(){HT=!1,is!==null&&qm(is)&&(is=null),os!==null&&qm(os)&&(os=null),ss!==null&&qm(ss)&&(ss=null),Gp.forEach(rP),qp.forEach(rP)}function Nm(e,t){e.blockedOn===t&&(e.blockedOn=null,HT||(HT=!0,Lt.unstable_scheduleCallback(Lt.unstable_NormalPriority,jq)))}var km=null;function iP(e){km!==e&&(km=e,Lt.unstable_scheduleCallback(Lt.unstable_NormalPriority,function(){km===e&&(km=null);for(var t=0;t<e.length;t+=3){var n=e[t],r=e[t+1],i=e[t+2];if(typeof r!="function"){if(jv(r||n)===null)continue;break}var o=Zc(n);o!==null&&(e.splice(t,3),t-=3,IT(o,{pending:!0,data:i,method:n.method,action:r},r,i))}}))}function Vp(e){function t(c){return Nm(c,e)}is!==null&&Nm(is,e),os!==null&&Nm(os,e),ss!==null&&Nm(ss,e),Gp.forEach(t),qp.forEach(t);for(var n=0;n<Qo.length;n++){var r=Qo[n];r.blockedOn===e&&(r.blockedOn=null)}for(;0<Qo.length&&(n=Qo[0],n.blockedOn===null);)B1(n),n.blockedOn===null&&Qo.shift();if(n=(e.ownerDocument||e).$$reactFormReplay,n!=null)for(r=0;r<n.length;r+=3){var i=n[r],o=n[r+1],s=i[Hn]||null;if(typeof o=="function")s||iP(n);else if(s){var a=null;if(o&&o.hasAttribute("formAction")){if(i=o,s=o[Hn]||null)a=s.formAction;else if(jv(i)!==null)continue}else a=s.action;typeof a=="function"?n[r+1]=a:(n.splice(r,3),r-=3),iP(n)}}}function Lv(e){this._internalRoot=e}jh.prototype.render=Lv.prototype.render=function(e){var t=this._internalRoot;if(t===null)throw Error(D(409));var n=t.current,r=pr();_1(n,r,e,t,null,null)};jh.prototype.unmount=Lv.prototype.unmount=function(){var e=this._internalRoot;if(e!==null){this._internalRoot=null;var t=e.containerInfo;_1(e.current,2,null,e,null,null),kh(),t[Xc]=null}};function jh(e){this._internalRoot=e}jh.prototype.unstable_scheduleHydration=function(e){if(e){var t=SP();e={blockedOn:null,target:e,priority:t};for(var n=0;n<Qo.length&&t!==0&&t<Qo[n].priority;n++);Qo.splice(n,0,e),n===0&&B1(e)}};var oP=sP.version;if(oP!=="19.1.2")throw Error(D(527,oP,"19.1.2"));Me.findDOMNode=function(e){var t=e._reactInternals;if(t===void 0)throw typeof e.render=="function"?Error(D(188)):(e=Object.keys(e).join(","),Error(D(268,e)));return e=h8(t),e=e!==null?uP(e):null,e=e===null?null:e.stateNode,e};var Lq={bundleType:0,version:"19.1.2",rendererPackageName:"react-dom",currentDispatcherRef:X,reconcilerVersion:"19.1.2"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&(hp=__REACT_DEVTOOLS_GLOBAL_HOOK__,!hp.isDisabled&&hp.supportsFiber))try{Yp=hp.inject(Lq),ur=hp}catch{}var hp;Lh.createRoot=function(e,t){if(!aP(e))throw Error(D(299));var n=!1,r="",i=DC,o=UC,s=_C,a=null;return t!=null&&(t.unstable_strictMode===!0&&(n=!0),t.identifierPrefix!==void 0&&(r=t.identifierPrefix),t.onUncaughtError!==void 0&&(i=t.onUncaughtError),t.onCaughtError!==void 0&&(o=t.onCaughtError),t.onRecoverableError!==void 0&&(s=t.onRecoverableError),t.unstable_transitionCallbacks!==void 0&&(a=t.unstable_transitionCallbacks)),t=D1(e,1,!1,null,null,n,r,i,o,s,a,null),e[Xc]=t.current,Nv(e),new Lv(t)};Lh.hydrateRoot=function(e,t,n){if(!aP(e))throw Error(D(299));var r=!1,i="",o=DC,s=UC,a=_C,c=null,l=null;return n!=null&&(n.unstable_strictMode===!0&&(r=!0),n.identifierPrefix!==void 0&&(i=n.identifierPrefix),n.onUncaughtError!==void 0&&(o=n.onUncaughtError),n.onCaughtError!==void 0&&(s=n.onCaughtError),n.onRecoverableError!==void 0&&(a=n.onRecoverableError),n.unstable_transitionCallbacks!==void 0&&(c=n.unstable_transitionCallbacks),n.formState!==void 0&&(l=n.formState)),t=D1(e,1,!0,t,n??null,r,i,o,s,a,c,l),t.context=U1(null),n=t.current,r=pr(),r=QT(r),i=es(r),i.callback=null,ts(n,i,r),n=r,t.current.lanes=n,Xp(t,n),Ei(t),e[Xc]=t.current,Nv(e),new jh(t)};Lh.version="19.1.2"});var Bv=ee((vke,K1)=>{"use strict";u();function $1(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE($1)}catch(e){console.error(e)}}$1(),K1.exports=F1()});var d5={};Ci(d5,{AIManager:()=>fl,AccessPolicy:()=>Q4,ActivityEventsManager:()=>sl,AnyNoyaStateContext:()=>ny,AssetManager:()=>dl,AssetStoreIndexedDB:()=>Ya,AssetStoreMemory:()=>Ja,AssetStoreRemote:()=>$i,ConnectionEventManager:()=>yl,EvalManager:()=>Ol,FallbackUntilInitialized:()=>LN,FilePropertyManager:()=>Al,GIT_BUNDLE_CONTENT_TYPE:()=>Ki,GitFileEditSession:()=>kl,GitManager:()=>Dl,HistoryEntries:()=>Mr,IOManager:()=>_l,ImagePickerManager:()=>Ul,Kind:()=>R,LocalAssetStorageAdapter:()=>jl,LocalGitFileEditor:()=>ep,LogManager:()=>zs,MAX_INPUT_QUEUE_LENGTH:()=>m6,MULTIPLAYER_POLICY_METADATA_KEY:()=>qs,MenuItemTree:()=>cA,MenuManager:()=>Ll,MultiplayerStateManager:()=>Gi,MultiplayerStateManagerError:()=>Ys,NoyaManager:()=>Vi,OperationManager:()=>Co,PipelineManager:()=>$l,PublishingManager:()=>Kl,RPCManager:()=>ql,ReconnectingWebSocket:()=>lc,ResourceEditSession:()=>zl,ResourceManager:()=>Hl,SERVER_COMPUTED_METADATA_KEY:()=>zd,SERVER_SCRIPTS_METADATA_KEY:()=>yS,SandboxManager:()=>Gl,ScriptEvaluationError:()=>Qd,ScriptEvaluatorManager:()=>Vl,SecretManager:()=>Ql,ServerComputed:()=>V4,ServerScriptManager:()=>Qs,ServerScripts:()=>Y4,SharedConnectionDataManager:()=>Cl,StateInspector:()=>hf,StateInterpolator:()=>ix,StateManager:()=>$s,TaskManager:()=>Yl,TranscriptionManager:()=>Jl,Type:()=>x,TypeGuard:()=>w,UserActivityDetector:()=>uc,UserManager:()=>rp,UserPointersOverlay:()=>p5,Value:()=>Ng,WebSocketConnection:()=>Bo,addPathPrefixToEditOptions:()=>B4,apply:()=>Vb,applyDocumentOperationsParametersSchema:()=>eS,applyExtendedPatch:()=>De,applyPatchToString:()=>AM,applyServerComputedMetadata:()=>SS,applyServerMessage:()=>Lo,bridgeRpcRequestToLocalAssets:()=>QS,bridgeRpcRequestToNetwork:()=>JS,buildResourcePatchPayload:()=>PN,castValue:()=>ml,checkType:()=>Ao,checkTypeSafe:()=>uM,clearConnectionQueue:()=>h6,clientId$:()=>hi,clientImage$:()=>Xs,clientName$:()=>Js,createDefaultAppData:()=>wN,createDefaultMessageHandler:()=>am,createEditHistoryEntry:()=>Dd,createEmbeddedHost:()=>G6,createExtended:()=>Cd,createHash:()=>Nl,createInitialSandboxState:()=>$O,createNoyaContext:()=>s5,createOrCastValue:()=>hl,createPatchHistoryEntry:()=>No,createPipelineRunRequest:()=>t8,createSecretRequest:()=>n8,createStateInspectorRoot:()=>Xh,createValue:()=>Rb,decodeAll:()=>xN,defaultMergeHistoryEntries:()=>fA,deleteNoyaSingleton:()=>CV,deleteSecretRequest:()=>r8,diff:()=>Qr,diffString:()=>Xb,drainInputQueue:()=>OS,encodeAll:()=>SN,enforceMultiplayerPolicies:()=>bS,enforceSchema:()=>MN,enqueueInput:()=>MS,ensureLocalAssetStore:()=>ac,ensureLocalResourceStore:()=>Zs,exportAll:()=>iI,extractItemId:()=>ec,fetchAssetMap:()=>bN,fetchRPC:()=>jo,fetchRPCStream:()=>_o,filterStateForReadAccess:()=>t6,findNoyaUser:()=>cm,forwardConnectionEventsToChild:()=>qS,getAppData:()=>Wh,getNoyaManagerSingleton:()=>pI,getNoyaSingletonBindings:()=>fI,getOfflineStorageKey:()=>V6,getResourceTransformUrl:()=>FO,getResourceUrl:()=>Hd,getSelectableMenuItems:()=>uA,getServerScriptDefinitions:()=>gS,getShortcutMenuItems:()=>tx,getSyncAdapter:()=>ey,handleAdapterMessage:()=>Xl,importAll:()=>oI,initializeNoyaSingleton:()=>PV,isEmbeddedApp:()=>AS,isEmbeddedToParentMessage:()=>pA,isParentToEmbeddedMessage:()=>lA,jwt:()=>Gd,localStorageSync:()=>XS,parentFrameSync:()=>nx,parseAppDataParameter:()=>ON,populateLocalStorageSync:()=>q6,processLocalStorageMessage:()=>Wl,readDocumentParametersSchema:()=>Wb,registerDocumentAITools:()=>Ml,replaceDeep:()=>rI,requestTranscription:()=>jS,resolveResource:()=>d6,resourceToCreateParameters:()=>RN,resourceToMediaItem:()=>n5,routeEmbeddedMultiplayerMessage:()=>YS,runDocumentScriptParametersSchema:()=>tS,sendLocalInitializationMessages:()=>nm,serializeServerScriptLogValue:()=>Vs,setClientId:()=>KS,setClientImage:()=>zS,setClientName:()=>$S,stubSync:()=>np,toExtendedPatch:()=>Vr,toExtendedPatches:()=>Wa,toExtendedPathKey:()=>qb,toSimplePatch:()=>RM,toSimplePath:()=>Il,useAIManager:()=>ry,useActivityEvents:()=>o5,useActivityEventsForManager:()=>qh,useAnyNoyaManager:()=>NV,useAnyNoyaStateContext:()=>xe,useAnySharedConnectionData:()=>XV,useAsset:()=>_V,useAssetManager:()=>NN,useAssets:()=>UV,useBindNoyaManager:()=>Zh,useCallableAITools:()=>c5,useColorScheme:()=>kV,useEnqueueInput:()=>ZV,useFileName:()=>DN,useFilePropertyManager:()=>UN,useIOManager:()=>KV,useInputs:()=>FV,useIsInitialized:()=>kN,useIsProcessing:()=>WV,useManagedHistory:()=>aI,useManagedState:()=>MV,useMultiplayerState:()=>OV,useNoyaActiveUsers:()=>QV,useNoyaAssetTranscription:()=>t5,useNoyaCurrentUser:()=>YV,useNoyaCurrentUserId:()=>JV,useNoyaStateInternal:()=>lI,useNoyaTranscriptionManager:()=>jN,useNoyaUser:()=>VV,useNoyaUserManager:()=>cu,useNoyaUsers:()=>qV,useObservable:()=>q,useOptionalAnyNoyaStateContext:()=>CN,useOutputTransforms:()=>$V,usePipelineManager:()=>HV,usePublish:()=>zV,useRegisterAITool:()=>a5,useResourceManager:()=>_N,useResourceUrl:()=>f5,useResources:()=>r5,useScriptEvaluator:()=>GV,useSecret:()=>BV,useSecretManager:()=>jV,useSecrets:()=>LV,useSetFileNameState:()=>e5,useStateInspector:()=>uI,useViewType:()=>DV,webSocketSync:()=>rx});module.exports=Bk(d5);u();u();u();u();u();u();var Rn={};Ci(Rn,{IsArray:()=>An,IsAsyncIterator:()=>ly,IsBigInt:()=>lu,IsBoolean:()=>go,IsDate:()=>pu,IsFunction:()=>py,IsIterator:()=>fy,IsNull:()=>dy,IsNumber:()=>Fr,IsObject:()=>Ge,IsRegExp:()=>my,IsString:()=>qe,IsSymbol:()=>hy,IsUint8Array:()=>ms,IsUndefined:()=>ot});u();function ly(e){return Ge(e)&&!An(e)&&!ms(e)&&Symbol.asyncIterator in e}function An(e){return Array.isArray(e)}function lu(e){return typeof e=="bigint"}function go(e){return typeof e=="boolean"}function pu(e){return e instanceof globalThis.Date}function py(e){return typeof e=="function"}function fy(e){return Ge(e)&&!An(e)&&!ms(e)&&Symbol.iterator in e}function dy(e){return e===null}function Fr(e){return typeof e=="number"}function Ge(e){return typeof e=="object"&&e!==null}function my(e){return e instanceof globalThis.RegExp}function qe(e){return typeof e=="string"}function hy(e){return typeof e=="symbol"}function ms(e){return e instanceof globalThis.Uint8Array}function ot(e){return e===void 0}function Fk(e){return e.map(t=>gf(t))}function $k(e){return new Date(e.getTime())}function Kk(e){return new Uint8Array(e)}function zk(e){return new RegExp(e.source,e.flags)}function Hk(e){let t={};for(let n of Object.getOwnPropertyNames(e))t[n]=gf(e[n]);for(let n of Object.getOwnPropertySymbols(e))t[n]=gf(e[n]);return t}function gf(e){return An(e)?Fk(e):pu(e)?$k(e):ms(e)?Kk(e):my(e)?zk(e):Ge(e)?Hk(e):e}function TI(e){return gf(e)}function ct(e){return e.map(t=>B(t))}function B(e,t={}){return{...TI(e),...t}}u();u();var Z=class extends Error{constructor(t){super(t)}};u();u();u();u();var mt=Symbol.for("TypeBox.Transform"),Ni=Symbol.for("TypeBox.Readonly"),Sn=Symbol.for("TypeBox.Optional"),Pn=Symbol.for("TypeBox.Hint"),R=Symbol.for("TypeBox.Kind");function vI(e){return Ge(e)&&e[Ni]==="Readonly"}function ni(e){return Ge(e)&&e[Sn]==="Optional"}function Gk(e){return ye(e,"Any")}function ki(e){return ye(e,"Array")}function fu(e){return ye(e,"AsyncIterator")}function yy(e){return ye(e,"BigInt")}function gy(e){return ye(e,"Boolean")}function du(e){return ye(e,"Constructor")}function qk(e){return ye(e,"Date")}function mu(e){return ye(e,"Function")}function hs(e){return ye(e,"Integer")}function ht(e){return ye(e,"Intersect")}function hu(e){return ye(e,"Iterator")}function ye(e,t){return Ge(e)&&R in e&&e[R]===t}function Di(e){return ye(e,"Literal")}function qn(e){return ye(e,"MappedKey")}function Ze(e){return ye(e,"MappedResult")}function Ea(e){return ye(e,"Never")}function Vk(e){return ye(e,"Not")}function Qk(e){return ye(e,"Null")}function ys(e){return ye(e,"Number")}function Pt(e){return ye(e,"Object")}function gs(e){return ye(e,"Promise")}function by(e){return ye(e,"Record")}function Sy(e){return ye(e,"Ref")}function xy(e){return ye(e,"RegExp")}function yu(e){return ye(e,"String")}function Yk(e){return ye(e,"Symbol")}function Vn(e){return ye(e,"TemplateLiteral")}function Jk(e){return ye(e,"This")}function wa(e){return Ge(e)&&mt in e}function $r(e){return ye(e,"Tuple")}function Xk(e){return ye(e,"Undefined")}function Te(e){return ye(e,"Union")}function Zk(e){return ye(e,"Uint8Array")}function Wk(e){return ye(e,"Unknown")}function eD(e){return ye(e,"Unsafe")}function tD(e){return ye(e,"Void")}function nD(e){return Ge(e)&&R in e&&qe(e[R])}function Qn(e){return Gk(e)||ki(e)||gy(e)||yy(e)||fu(e)||du(e)||qk(e)||mu(e)||hs(e)||ht(e)||hu(e)||Di(e)||qn(e)||Ze(e)||Ea(e)||Vk(e)||Qk(e)||ys(e)||Pt(e)||gs(e)||by(e)||Sy(e)||xy(e)||yu(e)||Yk(e)||Vn(e)||Jk(e)||$r(e)||Xk(e)||Te(e)||Zk(e)||Wk(e)||eD(e)||tD(e)||nD(e)}var w={};Ci(w,{IsAny:()=>MI,IsArray:()=>OI,IsAsyncIterator:()=>AI,IsBigInt:()=>RI,IsBoolean:()=>PI,IsConstructor:()=>CI,IsDate:()=>NI,IsFunction:()=>kI,IsInteger:()=>DI,IsIntersect:()=>UI,IsIterator:()=>_I,IsKind:()=>a0,IsKindOf:()=>he,IsLiteral:()=>bu,IsLiteralBoolean:()=>uD,IsLiteralNumber:()=>LI,IsLiteralString:()=>jI,IsLiteralValue:()=>BI,IsMappedKey:()=>FI,IsMappedResult:()=>$I,IsNever:()=>KI,IsNot:()=>zI,IsNull:()=>HI,IsNumber:()=>GI,IsObject:()=>qI,IsOptional:()=>cD,IsPromise:()=>VI,IsProperties:()=>Ey,IsReadonly:()=>aD,IsRecord:()=>QI,IsRecursive:()=>lD,IsRef:()=>YI,IsRegExp:()=>JI,IsSchema:()=>fe,IsString:()=>XI,IsSymbol:()=>ZI,IsTemplateLiteral:()=>WI,IsThis:()=>e0,IsTransform:()=>Ve,IsTuple:()=>t0,IsUint8Array:()=>r0,IsUndefined:()=>n0,IsUnion:()=>wy,IsUnionLiteral:()=>pD,IsUnknown:()=>i0,IsUnsafe:()=>o0,IsVoid:()=>s0,TypeGuardUnknownTypeError:()=>Ty});u();var Ty=class extends Z{},iD=["Any","Array","AsyncIterator","BigInt","Boolean","Constructor","Date","Enum","Function","Integer","Intersect","Iterator","Literal","MappedKey","MappedResult","Not","Null","Number","Object","Promise","Record","Ref","RegExp","String","Symbol","TemplateLiteral","This","Tuple","Undefined","Union","Uint8Array","Unknown","Void"];function II(e){try{return new RegExp(e),!0}catch{return!1}}function vy(e){if(!qe(e))return!1;for(let t=0;t<e.length;t++){let n=e.charCodeAt(t);if(n>=7&&n<=13||n===27||n===127)return!1}return!0}function EI(e){return Iy(e)||fe(e)}function gu(e){return ot(e)||lu(e)}function $e(e){return ot(e)||Fr(e)}function Iy(e){return ot(e)||go(e)}function Ce(e){return ot(e)||qe(e)}function oD(e){return ot(e)||qe(e)&&vy(e)&&II(e)}function sD(e){return ot(e)||qe(e)&&vy(e)}function wI(e){return ot(e)||fe(e)}function aD(e){return Ge(e)&&e[Ni]==="Readonly"}function cD(e){return Ge(e)&&e[Sn]==="Optional"}function MI(e){return he(e,"Any")&&Ce(e.$id)}function OI(e){return he(e,"Array")&&e.type==="array"&&Ce(e.$id)&&fe(e.items)&&$e(e.minItems)&&$e(e.maxItems)&&Iy(e.uniqueItems)&&wI(e.contains)&&$e(e.minContains)&&$e(e.maxContains)}function AI(e){return he(e,"AsyncIterator")&&e.type==="AsyncIterator"&&Ce(e.$id)&&fe(e.items)}function RI(e){return he(e,"BigInt")&&e.type==="bigint"&&Ce(e.$id)&&gu(e.exclusiveMaximum)&&gu(e.exclusiveMinimum)&&gu(e.maximum)&&gu(e.minimum)&&gu(e.multipleOf)}function PI(e){return he(e,"Boolean")&&e.type==="boolean"&&Ce(e.$id)}function CI(e){return he(e,"Constructor")&&e.type==="Constructor"&&Ce(e.$id)&&An(e.parameters)&&e.parameters.every(t=>fe(t))&&fe(e.returns)}function NI(e){return he(e,"Date")&&e.type==="Date"&&Ce(e.$id)&&$e(e.exclusiveMaximumTimestamp)&&$e(e.exclusiveMinimumTimestamp)&&$e(e.maximumTimestamp)&&$e(e.minimumTimestamp)&&$e(e.multipleOfTimestamp)}function kI(e){return he(e,"Function")&&e.type==="Function"&&Ce(e.$id)&&An(e.parameters)&&e.parameters.every(t=>fe(t))&&fe(e.returns)}function DI(e){return he(e,"Integer")&&e.type==="integer"&&Ce(e.$id)&&$e(e.exclusiveMaximum)&&$e(e.exclusiveMinimum)&&$e(e.maximum)&&$e(e.minimum)&&$e(e.multipleOf)}function Ey(e){return Ge(e)&&Object.entries(e).every(([t,n])=>vy(t)&&fe(n))}function UI(e){return he(e,"Intersect")&&!(qe(e.type)&&e.type!=="object")&&An(e.allOf)&&e.allOf.every(t=>fe(t)&&!Ve(t))&&Ce(e.type)&&(Iy(e.unevaluatedProperties)||wI(e.unevaluatedProperties))&&Ce(e.$id)}function _I(e){return he(e,"Iterator")&&e.type==="Iterator"&&Ce(e.$id)&&fe(e.items)}function he(e,t){return Ge(e)&&R in e&&e[R]===t}function jI(e){return bu(e)&&qe(e.const)}function LI(e){return bu(e)&&Fr(e.const)}function uD(e){return bu(e)&&go(e.const)}function bu(e){return he(e,"Literal")&&Ce(e.$id)&&BI(e.const)}function BI(e){return go(e)||Fr(e)||qe(e)}function FI(e){return he(e,"MappedKey")&&An(e.keys)&&e.keys.every(t=>Fr(t)||qe(t))}function $I(e){return he(e,"MappedResult")&&Ey(e.properties)}function KI(e){return he(e,"Never")&&Ge(e.not)&&Object.getOwnPropertyNames(e.not).length===0}function zI(e){return he(e,"Not")&&fe(e.not)}function HI(e){return he(e,"Null")&&e.type==="null"&&Ce(e.$id)}function GI(e){return he(e,"Number")&&e.type==="number"&&Ce(e.$id)&&$e(e.exclusiveMaximum)&&$e(e.exclusiveMinimum)&&$e(e.maximum)&&$e(e.minimum)&&$e(e.multipleOf)}function qI(e){return he(e,"Object")&&e.type==="object"&&Ce(e.$id)&&Ey(e.properties)&&EI(e.additionalProperties)&&$e(e.minProperties)&&$e(e.maxProperties)}function VI(e){return he(e,"Promise")&&e.type==="Promise"&&Ce(e.$id)&&fe(e.item)}function QI(e){return he(e,"Record")&&e.type==="object"&&Ce(e.$id)&&EI(e.additionalProperties)&&Ge(e.patternProperties)&&(t=>{let n=Object.getOwnPropertyNames(t.patternProperties);return n.length===1&&II(n[0])&&Ge(t.patternProperties)&&fe(t.patternProperties[n[0]])})(e)}function lD(e){return Ge(e)&&Pn in e&&e[Pn]==="Recursive"}function YI(e){return he(e,"Ref")&&Ce(e.$id)&&qe(e.$ref)}function JI(e){return he(e,"RegExp")&&Ce(e.$id)&&qe(e.source)&&qe(e.flags)&&$e(e.maxLength)&&$e(e.minLength)}function XI(e){return he(e,"String")&&e.type==="string"&&Ce(e.$id)&&$e(e.minLength)&&$e(e.maxLength)&&oD(e.pattern)&&sD(e.format)}function ZI(e){return he(e,"Symbol")&&e.type==="symbol"&&Ce(e.$id)}function WI(e){return he(e,"TemplateLiteral")&&e.type==="string"&&qe(e.pattern)&&e.pattern[0]==="^"&&e.pattern[e.pattern.length-1]==="$"}function e0(e){return he(e,"This")&&Ce(e.$id)&&qe(e.$ref)}function Ve(e){return Ge(e)&&mt in e}function t0(e){return he(e,"Tuple")&&e.type==="array"&&Ce(e.$id)&&Fr(e.minItems)&&Fr(e.maxItems)&&e.minItems===e.maxItems&&(ot(e.items)&&ot(e.additionalItems)&&e.minItems===0||An(e.items)&&e.items.every(t=>fe(t)))}function n0(e){return he(e,"Undefined")&&e.type==="undefined"&&Ce(e.$id)}function pD(e){return wy(e)&&e.anyOf.every(t=>jI(t)||LI(t))}function wy(e){return he(e,"Union")&&Ce(e.$id)&&Ge(e)&&An(e.anyOf)&&e.anyOf.every(t=>fe(t))}function r0(e){return he(e,"Uint8Array")&&e.type==="Uint8Array"&&Ce(e.$id)&&$e(e.minByteLength)&&$e(e.maxByteLength)}function i0(e){return he(e,"Unknown")&&Ce(e.$id)}function o0(e){return he(e,"Unsafe")}function s0(e){return he(e,"Void")&&e.type==="void"&&Ce(e.$id)}function a0(e){return Ge(e)&&R in e&&qe(e[R])&&!iD.includes(e[R])}function fe(e){return Ge(e)&&(MI(e)||OI(e)||PI(e)||RI(e)||AI(e)||CI(e)||NI(e)||kI(e)||DI(e)||UI(e)||_I(e)||bu(e)||FI(e)||$I(e)||KI(e)||zI(e)||HI(e)||GI(e)||qI(e)||VI(e)||QI(e)||YI(e)||JI(e)||XI(e)||ZI(e)||WI(e)||e0(e)||t0(e)||n0(e)||wy(e)||r0(e)||i0(e)||o0(e)||s0(e)||a0(e))}u();u();u();u();var My="(true|false)",Su="(0|[1-9][0-9]*)",Oy="(.*)",Q5=`^${My}$`,Ui=`^${Su}$`,bo=`^${Oy}$`;u();var Cn={};Ci(Cn,{Clear:()=>dD,Delete:()=>mD,Entries:()=>fD,Get:()=>gD,Has:()=>hD,Set:()=>yD});u();var Ma=new Map;function fD(){return new Map(Ma)}function dD(){return Ma.clear()}function mD(e){return Ma.delete(e)}function hD(e){return Ma.has(e)}function yD(e,t){Ma.set(e,t)}function gD(e){return Ma.get(e)}var Nn={};Ci(Nn,{Clear:()=>SD,Delete:()=>xD,Entries:()=>bD,Get:()=>ID,Has:()=>TD,Set:()=>vD});u();var Oa=new Map;function bD(){return new Map(Oa)}function SD(){return Oa.clear()}function xD(e){return Oa.delete(e)}function TD(e){return Oa.has(e)}function vD(e,t){Oa.set(e,t)}function ID(e){return Oa.get(e)}u();u();function c0(e,t){return e.includes(t)}function u0(e){return[...new Set(e)]}function ED(e,t){return e.filter(n=>t.includes(n))}function wD(e,t){return e.reduce((n,r)=>ED(n,r),t)}function l0(e){return e.length===1?e[0]:e.length>1?wD(e.slice(1),e[0]):[]}function p0(e){let t=[];for(let n of e)t.push(...n);return t}u();u();function _i(e={}){return{...e,[R]:"Any"}}u();u();function bs(e,t={}){return{...t,[R]:"Array",type:"array",items:B(e)}}u();u();function xu(e,t={}){return{...t,[R]:"AsyncIterator",type:"AsyncIterator",items:B(e)}}u();u();u();u();u();u();function MD(e,t){let{[t]:n,...r}=e;return r}function ut(e,t){return t.reduce((n,r)=>MD(n,r),e)}u();u();function je(e={}){return{...e,[R]:"Never",not:{}}}u();u();u();u();u();function ge(e){return{[R]:"MappedResult",properties:e}}u();u();u();function Tu(e,t,n){return{...n,[R]:"Constructor",type:"Constructor",parameters:ct(e),returns:B(t)}}u();u();function ji(e,t,n){return{...n,[R]:"Function",type:"Function",parameters:ct(e),returns:B(t)}}u();u();u();u();u();u();function vu(e,t){return{...t,[R]:"Union",anyOf:ct(e)}}function OD(e){return e.some(t=>ni(t))}function f0(e){return e.map(t=>ni(t)?AD(t):t)}function AD(e){return ut(e,[Sn])}function RD(e,t){return OD(e)?xn(vu(f0(e),t)):vu(f0(e),t)}function ri(e,t={}){return e.length===0?je(t):e.length===1?B(e[0],t):RD(e,t)}u();u();function ve(e,t={}){return e.length===0?je(t):e.length===1?B(e[0],t):vu(e,t)}u();u();u();u();var bf=class extends Z{};function PD(e){return e.replace(/\\\$/g,"$").replace(/\\\*/g,"*").replace(/\\\^/g,"^").replace(/\\\|/g,"|").replace(/\\\(/g,"(").replace(/\\\)/g,")")}function Ay(e,t,n){return e[t]===n&&e.charCodeAt(t-1)!==92}function Li(e,t){return Ay(e,t,"(")}function Iu(e,t){return Ay(e,t,")")}function d0(e,t){return Ay(e,t,"|")}function CD(e){if(!(Li(e,0)&&Iu(e,e.length-1)))return!1;let t=0;for(let n=0;n<e.length;n++)if(Li(e,n)&&(t+=1),Iu(e,n)&&(t-=1),t===0&&n!==e.length-1)return!1;return!0}function ND(e){return e.slice(1,e.length-1)}function kD(e){let t=0;for(let n=0;n<e.length;n++)if(Li(e,n)&&(t+=1),Iu(e,n)&&(t-=1),d0(e,n)&&t===0)return!0;return!1}function DD(e){for(let t=0;t<e.length;t++)if(Li(e,t))return!0;return!1}function UD(e){let[t,n]=[0,0],r=[];for(let o=0;o<e.length;o++)if(Li(e,o)&&(t+=1),Iu(e,o)&&(t-=1),d0(e,o)&&t===0){let s=e.slice(n,o);s.length>0&&r.push(Aa(s)),n=o+1}let i=e.slice(n);return i.length>0&&r.push(Aa(i)),r.length===0?{type:"const",const:""}:r.length===1?r[0]:{type:"or",expr:r}}function _D(e){function t(i,o){if(!Li(i,o))throw new bf("TemplateLiteralParser: Index must point to open parens");let s=0;for(let a=o;a<i.length;a++)if(Li(i,a)&&(s+=1),Iu(i,a)&&(s-=1),s===0)return[o,a];throw new bf("TemplateLiteralParser: Unclosed group parens in expression")}function n(i,o){for(let s=o;s<i.length;s++)if(Li(i,s))return[o,s];return[o,i.length]}let r=[];for(let i=0;i<e.length;i++)if(Li(e,i)){let[o,s]=t(e,i),a=e.slice(o,s+1);r.push(Aa(a)),i=s}else{let[o,s]=n(e,i),a=e.slice(o,s);a.length>0&&r.push(Aa(a)),i=s-1}return r.length===0?{type:"const",const:""}:r.length===1?r[0]:{type:"and",expr:r}}function Aa(e){return CD(e)?Aa(ND(e)):kD(e)?UD(e):DD(e)?_D(e):{type:"const",const:PD(e)}}function Ra(e){return Aa(e.slice(1,e.length-1))}var Ry=class extends Z{};function jD(e){return e.type==="or"&&e.expr.length===2&&e.expr[0].type==="const"&&e.expr[0].const==="0"&&e.expr[1].type==="const"&&e.expr[1].const==="[1-9][0-9]*"}function LD(e){return e.type==="or"&&e.expr.length===2&&e.expr[0].type==="const"&&e.expr[0].const==="true"&&e.expr[1].type==="const"&&e.expr[1].const==="false"}function BD(e){return e.type==="const"&&e.const===".*"}function Ss(e){return jD(e)||BD(e)?!1:LD(e)?!0:e.type==="and"?e.expr.every(t=>Ss(t)):e.type==="or"?e.expr.every(t=>Ss(t)):e.type==="const"?!0:(()=>{throw new Ry("Unknown expression type")})()}function Sf(e){let t=Ra(e.pattern);return Ss(t)}u();var Py=class extends Z{};function*m0(e){if(e.length===1)return yield*e[0];for(let t of e[0])for(let n of m0(e.slice(1)))yield`${t}${n}`}function*FD(e){return yield*m0(e.expr.map(t=>[...Eu(t)]))}function*$D(e){for(let t of e.expr)yield*Eu(t)}function*KD(e){return yield e.const}function*Eu(e){return e.type==="and"?yield*FD(e):e.type==="or"?yield*$D(e):e.type==="const"?yield*KD(e):(()=>{throw new Py("Unknown expression")})()}function Pa(e){let t=Ra(e.pattern);return Ss(t)?[...Eu(t)]:[]}u();u();u();function oe(e,t={}){return{...t,[R]:"Literal",const:e,type:typeof e}}u();u();function wu(e={}){return{...e,[R]:"Boolean",type:"boolean"}}u();u();function xs(e={}){return{...e,[R]:"BigInt",type:"bigint"}}u();u();function Yn(e={}){return{...e,[R]:"Number",type:"number"}}u();u();function Tn(e={}){return{...e,[R]:"String",type:"string"}}function*zD(e){let t=e.trim().replace(/"|'/g,"");return t==="boolean"?yield wu():t==="number"?yield Yn():t==="bigint"?yield xs():t==="string"?yield Tn():yield(()=>{let n=t.split("|").map(r=>oe(r.trim()));return n.length===0?je():n.length===1?n[0]:ri(n)})()}function*HD(e){if(e[1]!=="{"){let t=oe("$"),n=Cy(e.slice(1));return yield*[t,...n]}for(let t=2;t<e.length;t++)if(e[t]==="}"){let n=zD(e.slice(2,t)),r=Cy(e.slice(t+1));return yield*[...n,...r]}yield oe(e)}function*Cy(e){for(let t=0;t<e.length;t++)if(e[t]==="$"){let n=oe(e.slice(0,t)),r=HD(e.slice(t));return yield*[n,...r]}yield oe(e)}function h0(e){return[...Cy(e)]}u();var Ny=class extends Z{};function GD(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function y0(e,t){return Vn(e)?e.pattern.slice(1,e.pattern.length-1):Te(e)?`(${e.anyOf.map(n=>y0(n,t)).join("|")})`:ys(e)?`${t}${Su}`:hs(e)?`${t}${Su}`:yy(e)?`${t}${Su}`:yu(e)?`${t}${Oy}`:Di(e)?`${t}${GD(e.const.toString())}`:gy(e)?`${t}${My}`:(()=>{throw new Ny(`Unexpected Kind '${e[R]}'`)})()}function ky(e){return`^${e.map(t=>y0(t,"")).join("")}$`}u();function Ts(e){let n=Pa(e).map(r=>oe(r));return ri(n)}u();function Mu(e,t={}){let n=qe(e)?ky(h0(e)):ky(e);return{...t,[R]:"TemplateLiteral",type:"string",pattern:n}}function qD(e){return Pa(e).map(n=>n.toString())}function VD(e){let t=[];for(let n of e)t.push(...kn(n));return t}function QD(e){return[e.toString()]}function kn(e){return[...new Set(Vn(e)?qD(e):Te(e)?VD(e.anyOf):Di(e)?QD(e.const):ys(e)?["[number]"]:hs(e)?["[number]"]:[])]}u();function YD(e,t,n){let r={};for(let i of Object.getOwnPropertyNames(t))r[i]=vs(e,kn(t[i]),n);return r}function JD(e,t,n){return YD(e,t.properties,n)}function g0(e,t,n){let r=JD(e,t,n);return ge(r)}function S0(e,t){return e.map(n=>x0(n,t))}function XD(e){return e.filter(t=>!Ea(t))}function ZD(e,t){return xf(XD(S0(e,t)))}function WD(e){return e.some(t=>Ea(t))?[]:e}function eU(e,t){return ri(WD(S0(e,t)))}function tU(e,t){return t in e?e[t]:t==="[number]"?ri(e):je()}function nU(e,t){return t==="[number]"?e:je()}function rU(e,t){return t in e?e[t]:je()}function x0(e,t){return ht(e)?ZD(e.allOf,t):Te(e)?eU(e.anyOf,t):$r(e)?tU(e.items??[],t):ki(e)?nU(e.items,t):Pt(e)?rU(e.properties,t):je()}function Ou(e,t){return t.map(n=>x0(e,n))}function b0(e,t){return ri(Ou(e,t))}function vs(e,t,n={}){return Ze(t)?B(g0(e,t,n)):qn(t)?B(T0(e,t,n)):Qn(t)?B(b0(e,kn(t)),n):B(b0(e,t),n)}function iU(e,t,n){return{[t]:vs(e,[t],n)}}function oU(e,t,n){return t.reduce((r,i)=>({...r,...iU(e,i,n)}),{})}function sU(e,t,n){return oU(e,t.keys,n)}function T0(e,t,n){let r=sU(e,t,n);return ge(r)}u();u();function Au(e,t={}){return{...t,[R]:"Iterator",type:"Iterator",items:B(e)}}u();u();function aU(e,t={}){let n=globalThis.Object.getOwnPropertyNames(e),r=n.filter(a=>ni(e[a])),i=n.filter(a=>!r.includes(a)),o=Qn(t.additionalProperties)?{additionalProperties:B(t.additionalProperties)}:{},s={};for(let a of n)s[a]=B(e[a]);return i.length>0?{...t,...o,[R]:"Object",type:"object",properties:s,required:i}:{...t,...o,[R]:"Object",type:"object",properties:s}}var Ne=aU;u();u();function Ru(e,t={}){return{...t,[R]:"Promise",type:"Promise",item:B(e)}}u();u();u();function cU(e){return ut(B(e),[Ni])}function uU(e){return{...B(e),[Ni]:"Readonly"}}function lU(e,t){return t===!1?cU(e):uU(e)}function Jn(e,t){let n=t??!0;return Ze(e)?v0(e,n):lU(e,n)}function pU(e,t){let n={};for(let r of globalThis.Object.getOwnPropertyNames(e))n[r]=Jn(e[r],t);return n}function fU(e,t){return pU(e.properties,t)}function v0(e,t){let n=fU(e,t);return ge(n)}u();u();function Kr(e,t={}){let[n,r,i]=[!1,e.length,e.length];return e.length>0?{...t,[R]:"Tuple",type:"array",items:ct(e),additionalItems:n,minItems:r,maxItems:i}:{...t,[R]:"Tuple",type:"array",minItems:r,maxItems:i}}function I0(e,t){return e in t?gr(e,t[e]):ge(t)}function dU(e){return{[e]:oe(e)}}function mU(e){let t={};for(let n of e)t[n]=oe(n);return t}function hU(e,t){return c0(t,e)?dU(e):mU(t)}function yU(e,t){let n=hU(e,t);return I0(e,n)}function Pu(e,t){return t.map(n=>gr(e,n))}function gU(e,t){let n={};for(let r of globalThis.Object.getOwnPropertyNames(t))n[r]=gr(e,t[r]);return n}function gr(e,t){return ni(t)?xn(gr(e,ut(t,[Sn]))):vI(t)?Jn(gr(e,ut(t,[Ni]))):Ze(t)?I0(e,t.properties):qn(t)?yU(e,t.keys):du(t)?Tu(Pu(e,t.parameters),gr(e,t.returns)):mu(t)?ji(Pu(e,t.parameters),gr(e,t.returns)):fu(t)?xu(gr(e,t.items)):hu(t)?Au(gr(e,t.items)):ht(t)?vn(Pu(e,t.allOf)):Te(t)?ve(Pu(e,t.anyOf)):$r(t)?Kr(Pu(e,t.items??[])):Pt(t)?Ne(gU(e,t.properties)):ki(t)?bs(gr(e,t.items)):gs(t)?Ru(gr(e,t.item)):t}function bU(e,t){let n={};for(let r of e)n[r]=gr(r,t);return n}function Dy(e,t,n={}){let r=Qn(e)?kn(e):e,i=t({[R]:"MappedKey",keys:r}),o=bU(r,i);return B(Ne(o),n)}u();function SU(e){return ut(B(e),[Sn])}function xU(e){return{...B(e),[Sn]:"Optional"}}function TU(e,t){return t===!1?SU(e):xU(e)}function xn(e,t){let n=t??!0;return Ze(e)?E0(e,n):TU(e,n)}function vU(e,t){let n={};for(let r of globalThis.Object.getOwnPropertyNames(e))n[r]=xn(e[r],t);return n}function IU(e,t){return vU(e.properties,t)}function E0(e,t){let n=IU(e,t);return ge(n)}u();function Cu(e,t){let n=e.every(i=>Pt(i)),r=Qn(t.unevaluatedProperties)?{unevaluatedProperties:B(t.unevaluatedProperties)}:{};return t.unevaluatedProperties===!1||Qn(t.unevaluatedProperties)||n?{...t,...r,[R]:"Intersect",type:"object",allOf:ct(e)}:{...t,...r,[R]:"Intersect",allOf:ct(e)}}function EU(e){return e.every(t=>ni(t))}function wU(e){return ut(e,[Sn])}function w0(e){return e.map(t=>ni(t)?wU(t):t)}function MU(e,t){return EU(e)?xn(Cu(w0(e),t)):Cu(w0(e),t)}function xf(e,t={}){if(e.length===0)return je(t);if(e.length===1)return B(e[0],t);if(e.some(n=>wa(n)))throw new Error("Cannot intersect transform types");return MU(e,t)}u();u();function vn(e,t={}){if(e.length===0)return je(t);if(e.length===1)return B(e[0],t);if(e.some(n=>wa(n)))throw new Error("Cannot intersect transform types");return Cu(e,t)}function M0(e){return e.map(t=>Uy(t))}function OU(e){return vn(M0(e))}function AU(e){return ve(M0(e))}function RU(e){return Uy(e)}function Uy(e){return ht(e)?OU(e.allOf):Te(e)?AU(e.anyOf):gs(e)?RU(e.item):e}function _y(e,t={}){return B(Uy(e),t)}u();u();u();u();u();u();function O0(e){let t=[];for(let n of e)t.push(Dn(n));return t}function PU(e){let t=O0(e);return p0(t)}function CU(e){let t=O0(e);return l0(t)}function NU(e){return e.map((t,n)=>n.toString())}function kU(e){return["[number]"]}function DU(e){return globalThis.Object.getOwnPropertyNames(e)}function UU(e){return jy?globalThis.Object.getOwnPropertyNames(e).map(n=>n[0]==="^"&&n[n.length-1]==="$"?n.slice(1,n.length-1):n):[]}function Dn(e){return ht(e)?PU(e.allOf):Te(e)?CU(e.anyOf):$r(e)?NU(e.items??[]):ki(e)?kU(e.items):Pt(e)?DU(e.properties):by(e)?UU(e.patternProperties):[]}var jy=!1;function Ca(e){jy=!0;let t=Dn(e);return jy=!1,`^(${t.map(r=>`(${r})`).join("|")})$`}function _U(e){return e.map(t=>t==="[number]"?Yn():oe(t))}function Nu(e,t={}){if(Ze(e))return A0(e,t);{let n=Dn(e),r=_U(n),i=ri(r);return B(i,t)}}function jU(e,t){let n={};for(let r of globalThis.Object.getOwnPropertyNames(e))n[r]=Nu(e[r],t);return n}function LU(e,t){return jU(e.properties,t)}function A0(e,t){let n=LU(e,t);return ge(n)}u();function Tf(e){let t=Dn(e),n=Ou(e,t);return t.map((r,i)=>[t[i],n[i]])}function BU(e){let t=[];for(let n of e)t.push(...Dn(n));return u0(t)}function FU(e){return e.filter(t=>!Ea(t))}function $U(e,t){let n=[];for(let r of e)n.push(...Ou(r,[t]));return FU(n)}function KU(e,t){let n={};for(let r of t)n[r]=xf($U(e,r));return n}function Ly(e,t={}){let n=BU(e),r=KU(e,n);return Ne(r,t)}u();u();u();u();function ku(e={}){return{...e,[R]:"Date",type:"Date"}}u();u();function Du(e={}){return{...e,[R]:"Null",type:"null"}}u();u();function Uu(e){return{...e,[R]:"Symbol",type:"symbol"}}u();u();function _u(e={}){return{...e,[R]:"Undefined",type:"undefined"}}u();u();function ju(e={}){return{...e,[R]:"Uint8Array",type:"Uint8Array"}}u();u();function Xn(e={}){return{...e,[R]:"Unknown"}}function zU(e){return e.map(t=>By(t,!1))}function HU(e){let t={};for(let n of globalThis.Object.getOwnPropertyNames(e))t[n]=Jn(By(e[n],!1));return t}function vf(e,t){return t===!0?e:Jn(e)}function By(e,t){return ly(e)?vf(_i(),t):fy(e)?vf(_i(),t):An(e)?Jn(Kr(zU(e))):ms(e)?ju():pu(e)?ku():Ge(e)?vf(Ne(HU(e)),t):py(e)?vf(ji([],Xn()),t):ot(e)?_u():dy(e)?Du():hy(e)?Uu():lu(e)?xs():Fr(e)?oe(e):go(e)?oe(e):qe(e)?oe(e):Ne({})}function Fy(e,t={}){return B(By(e,!0),t)}u();u();function $y(e,t={}){return Kr(ct(e.parameters),{...t})}u();u();function Lu(e,t){return e.map(n=>br(n,t))}function GU(e,t){let n={};for(let r of globalThis.Object.getOwnPropertyNames(e))n[r]=br(e[r],t);return n}function qU(e,t){return e.parameters=Lu(e.parameters,t),e.returns=br(e.returns,t),e}function VU(e,t){return e.parameters=Lu(e.parameters,t),e.returns=br(e.returns,t),e}function QU(e,t){return e.allOf=Lu(e.allOf,t),e}function YU(e,t){return e.anyOf=Lu(e.anyOf,t),e}function JU(e,t){return ot(e.items)||(e.items=Lu(e.items,t)),e}function XU(e,t){return e.items=br(e.items,t),e}function ZU(e,t){return e.properties=GU(e.properties,t),e}function WU(e,t){return e.item=br(e.item,t),e}function e_(e,t){return e.items=br(e.items,t),e}function t_(e,t){return e.items=br(e.items,t),e}function n_(e,t){let n=t.find(i=>i.$id===e.$ref);if(n===void 0)throw Error(`Unable to dereference schema with $id ${e.$ref}`);let r=ut(n,["$id"]);return br(r,t)}function r_(e,t){return du(e)?qU(e,t):mu(e)?VU(e,t):ht(e)?QU(e,t):Te(e)?YU(e,t):$r(e)?JU(e,t):ki(e)?XU(e,t):Pt(e)?ZU(e,t):gs(e)?WU(e,t):fu(e)?e_(e,t):hu(e)?t_(e,t):Sy(e)?n_(e,t):e}function br(e,t){return r_(B(e),ct(t))}u();u();function Ky(e,t={}){if(ot(e))throw new Error("Enum undefined or empty");let n=globalThis.Object.getOwnPropertyNames(e).filter(o=>isNaN(o)).map(o=>e[o]),i=[...new Set(n)].map(o=>oe(o));return ve(i,{...t,[Pn]:"Enum"})}u();u();u();u();u();var Hy=class extends Z{},P;(function(e){e[e.Union=0]="Union",e[e.True=1]="True",e[e.False=2]="False"})(P||(P={}));function Sr(e){return e===P.False?e:P.True}function Na(e){throw new Hy(e)}function Tt(e){return w.IsNever(e)||w.IsIntersect(e)||w.IsUnion(e)||w.IsUnknown(e)||w.IsAny(e)}function vt(e,t){return w.IsNever(t)?U0(e,t):w.IsIntersect(t)?If(e,t):w.IsUnion(t)?Qy(e,t):w.IsUnknown(t)?B0(e,t):w.IsAny(t)?Vy(e,t):Na("StructuralRight")}function Vy(e,t){return P.True}function i_(e,t){return w.IsIntersect(t)?If(e,t):w.IsUnion(t)&&t.anyOf.some(n=>w.IsAny(n)||w.IsUnknown(n))?P.True:w.IsUnion(t)?P.Union:w.IsUnknown(t)||w.IsAny(t)?P.True:P.Union}function o_(e,t){return w.IsUnknown(e)?P.False:w.IsAny(e)?P.Union:w.IsNever(e)?P.True:P.False}function s_(e,t){return w.IsObject(t)&&Ef(t)?P.True:Tt(t)?vt(e,t):w.IsArray(t)?Sr(ke(e.items,t.items)):P.False}function a_(e,t){return Tt(t)?vt(e,t):w.IsAsyncIterator(t)?Sr(ke(e.items,t.items)):P.False}function c_(e,t){return Tt(t)?vt(e,t):w.IsObject(t)?an(e,t):w.IsRecord(t)?xr(e,t):w.IsBigInt(t)?P.True:P.False}function k0(e,t){return w.IsLiteralBoolean(e)||w.IsBoolean(e)?P.True:P.False}function u_(e,t){return Tt(t)?vt(e,t):w.IsObject(t)?an(e,t):w.IsRecord(t)?xr(e,t):w.IsBoolean(t)?P.True:P.False}function l_(e,t){return Tt(t)?vt(e,t):w.IsObject(t)?an(e,t):w.IsConstructor(t)?e.parameters.length>t.parameters.length?P.False:e.parameters.every((n,r)=>Sr(ke(t.parameters[r],n))===P.True)?Sr(ke(e.returns,t.returns)):P.False:P.False}function p_(e,t){return Tt(t)?vt(e,t):w.IsObject(t)?an(e,t):w.IsRecord(t)?xr(e,t):w.IsDate(t)?P.True:P.False}function f_(e,t){return Tt(t)?vt(e,t):w.IsObject(t)?an(e,t):w.IsFunction(t)?e.parameters.length>t.parameters.length?P.False:e.parameters.every((n,r)=>Sr(ke(t.parameters[r],n))===P.True)?Sr(ke(e.returns,t.returns)):P.False:P.False}function D0(e,t){return w.IsLiteral(e)&&Rn.IsNumber(e.const)||w.IsNumber(e)||w.IsInteger(e)?P.True:P.False}function d_(e,t){return w.IsInteger(t)||w.IsNumber(t)?P.True:Tt(t)?vt(e,t):w.IsObject(t)?an(e,t):w.IsRecord(t)?xr(e,t):P.False}function If(e,t){return t.allOf.every(n=>ke(e,n)===P.True)?P.True:P.False}function m_(e,t){return e.allOf.some(n=>ke(n,t)===P.True)?P.True:P.False}function h_(e,t){return Tt(t)?vt(e,t):w.IsIterator(t)?Sr(ke(e.items,t.items)):P.False}function y_(e,t){return w.IsLiteral(t)&&t.const===e.const?P.True:Tt(t)?vt(e,t):w.IsObject(t)?an(e,t):w.IsRecord(t)?xr(e,t):w.IsString(t)?L0(e,t):w.IsNumber(t)?_0(e,t):w.IsInteger(t)?D0(e,t):w.IsBoolean(t)?k0(e,t):P.False}function U0(e,t){return P.False}function g_(e,t){return P.True}function R0(e){let[t,n]=[e,0];for(;w.IsNot(t);)t=t.not,n+=1;return n%2===0?t:Xn()}function b_(e,t){return w.IsNot(e)?ke(R0(e),t):w.IsNot(t)?ke(e,R0(t)):Na("Invalid fallthrough for Not")}function S_(e,t){return Tt(t)?vt(e,t):w.IsObject(t)?an(e,t):w.IsRecord(t)?xr(e,t):w.IsNull(t)?P.True:P.False}function _0(e,t){return w.IsLiteralNumber(e)||w.IsNumber(e)||w.IsInteger(e)?P.True:P.False}function x_(e,t){return Tt(t)?vt(e,t):w.IsObject(t)?an(e,t):w.IsRecord(t)?xr(e,t):w.IsInteger(t)||w.IsNumber(t)?P.True:P.False}function Un(e,t){return Object.getOwnPropertyNames(e.properties).length===t}function P0(e){return Ef(e)}function C0(e){return Un(e,0)||Un(e,1)&&"description"in e.properties&&w.IsUnion(e.properties.description)&&e.properties.description.anyOf.length===2&&(w.IsString(e.properties.description.anyOf[0])&&w.IsUndefined(e.properties.description.anyOf[1])||w.IsString(e.properties.description.anyOf[1])&&w.IsUndefined(e.properties.description.anyOf[0]))}function zy(e){return Un(e,0)}function N0(e){return Un(e,0)}function T_(e){return Un(e,0)}function v_(e){return Un(e,0)}function I_(e){return Ef(e)}function E_(e){let t=Yn();return Un(e,0)||Un(e,1)&&"length"in e.properties&&Sr(ke(e.properties.length,t))===P.True}function w_(e){return Un(e,0)}function Ef(e){let t=Yn();return Un(e,0)||Un(e,1)&&"length"in e.properties&&Sr(ke(e.properties.length,t))===P.True}function M_(e){let t=ji([_i()],_i());return Un(e,0)||Un(e,1)&&"then"in e.properties&&Sr(ke(e.properties.then,t))===P.True}function j0(e,t){return ke(e,t)===P.False||w.IsOptional(e)&&!w.IsOptional(t)?P.False:P.True}function an(e,t){return w.IsUnknown(e)?P.False:w.IsAny(e)?P.Union:w.IsNever(e)||w.IsLiteralString(e)&&P0(t)||w.IsLiteralNumber(e)&&zy(t)||w.IsLiteralBoolean(e)&&N0(t)||w.IsSymbol(e)&&C0(t)||w.IsBigInt(e)&&T_(t)||w.IsString(e)&&P0(t)||w.IsSymbol(e)&&C0(t)||w.IsNumber(e)&&zy(t)||w.IsInteger(e)&&zy(t)||w.IsBoolean(e)&&N0(t)||w.IsUint8Array(e)&&I_(t)||w.IsDate(e)&&v_(t)||w.IsConstructor(e)&&w_(t)||w.IsFunction(e)&&E_(t)?P.True:w.IsRecord(e)&&w.IsString(Gy(e))?t[Pn]==="Record"?P.True:P.False:w.IsRecord(e)&&w.IsNumber(Gy(e))?Un(t,0)?P.True:P.False:P.False}function O_(e,t){return Tt(t)?vt(e,t):w.IsRecord(t)?xr(e,t):w.IsObject(t)?(()=>{for(let n of Object.getOwnPropertyNames(t.properties)){if(!(n in e.properties)&&!w.IsOptional(t.properties[n]))return P.False;if(w.IsOptional(t.properties[n]))return P.True;if(j0(e.properties[n],t.properties[n])===P.False)return P.False}return P.True})():P.False}function A_(e,t){return Tt(t)?vt(e,t):w.IsObject(t)&&M_(t)?P.True:w.IsPromise(t)?Sr(ke(e.item,t.item)):P.False}function Gy(e){return Ui in e.patternProperties?Yn():bo in e.patternProperties?Tn():Na("Unknown record key pattern")}function qy(e){return Ui in e.patternProperties?e.patternProperties[Ui]:bo in e.patternProperties?e.patternProperties[bo]:Na("Unable to get record value schema")}function xr(e,t){let[n,r]=[Gy(t),qy(t)];return w.IsLiteralString(e)&&w.IsNumber(n)&&Sr(ke(e,r))===P.True?P.True:w.IsUint8Array(e)&&w.IsNumber(n)||w.IsString(e)&&w.IsNumber(n)||w.IsArray(e)&&w.IsNumber(n)?ke(e,r):w.IsObject(e)?(()=>{for(let i of Object.getOwnPropertyNames(e.properties))if(j0(r,e.properties[i])===P.False)return P.False;return P.True})():P.False}function R_(e,t){return Tt(t)?vt(e,t):w.IsObject(t)?an(e,t):w.IsRecord(t)?ke(qy(e),qy(t)):P.False}function P_(e,t){let n=w.IsRegExp(e)?Tn():e,r=w.IsRegExp(t)?Tn():t;return ke(n,r)}function L0(e,t){return w.IsLiteral(e)&&Rn.IsString(e.const)||w.IsString(e)?P.True:P.False}function C_(e,t){return Tt(t)?vt(e,t):w.IsObject(t)?an(e,t):w.IsRecord(t)?xr(e,t):w.IsString(t)?P.True:P.False}function N_(e,t){return Tt(t)?vt(e,t):w.IsObject(t)?an(e,t):w.IsRecord(t)?xr(e,t):w.IsSymbol(t)?P.True:P.False}function k_(e,t){return w.IsTemplateLiteral(e)?ke(Ts(e),t):w.IsTemplateLiteral(t)?ke(e,Ts(t)):Na("Invalid fallthrough for TemplateLiteral")}function D_(e,t){return w.IsArray(t)&&e.items!==void 0&&e.items.every(n=>ke(n,t.items)===P.True)}function U_(e,t){return w.IsNever(e)?P.True:w.IsUnknown(e)?P.False:w.IsAny(e)?P.Union:P.False}function __(e,t){return Tt(t)?vt(e,t):w.IsObject(t)&&Ef(t)||w.IsArray(t)&&D_(e,t)?P.True:w.IsTuple(t)?Rn.IsUndefined(e.items)&&!Rn.IsUndefined(t.items)||!Rn.IsUndefined(e.items)&&Rn.IsUndefined(t.items)?P.False:Rn.IsUndefined(e.items)&&!Rn.IsUndefined(t.items)||e.items.every((n,r)=>ke(n,t.items[r])===P.True)?P.True:P.False:P.False}function j_(e,t){return Tt(t)?vt(e,t):w.IsObject(t)?an(e,t):w.IsRecord(t)?xr(e,t):w.IsUint8Array(t)?P.True:P.False}function L_(e,t){return Tt(t)?vt(e,t):w.IsObject(t)?an(e,t):w.IsRecord(t)?xr(e,t):w.IsVoid(t)?$_(e,t):w.IsUndefined(t)?P.True:P.False}function Qy(e,t){return t.anyOf.some(n=>ke(e,n)===P.True)?P.True:P.False}function B_(e,t){return e.anyOf.every(n=>ke(n,t)===P.True)?P.True:P.False}function B0(e,t){return P.True}function F_(e,t){return w.IsNever(t)?U0(e,t):w.IsIntersect(t)?If(e,t):w.IsUnion(t)?Qy(e,t):w.IsAny(t)?Vy(e,t):w.IsString(t)?L0(e,t):w.IsNumber(t)?_0(e,t):w.IsInteger(t)?D0(e,t):w.IsBoolean(t)?k0(e,t):w.IsArray(t)?o_(e,t):w.IsTuple(t)?U_(e,t):w.IsObject(t)?an(e,t):w.IsUnknown(t)?P.True:P.False}function $_(e,t){return w.IsUndefined(e)||w.IsUndefined(e)?P.True:P.False}function K_(e,t){return w.IsIntersect(t)?If(e,t):w.IsUnion(t)?Qy(e,t):w.IsUnknown(t)?B0(e,t):w.IsAny(t)?Vy(e,t):w.IsObject(t)?an(e,t):w.IsVoid(t)?P.True:P.False}function ke(e,t){return w.IsTemplateLiteral(e)||w.IsTemplateLiteral(t)?k_(e,t):w.IsRegExp(e)||w.IsRegExp(t)?P_(e,t):w.IsNot(e)||w.IsNot(t)?b_(e,t):w.IsAny(e)?i_(e,t):w.IsArray(e)?s_(e,t):w.IsBigInt(e)?c_(e,t):w.IsBoolean(e)?u_(e,t):w.IsAsyncIterator(e)?a_(e,t):w.IsConstructor(e)?l_(e,t):w.IsDate(e)?p_(e,t):w.IsFunction(e)?f_(e,t):w.IsInteger(e)?d_(e,t):w.IsIntersect(e)?m_(e,t):w.IsIterator(e)?h_(e,t):w.IsLiteral(e)?y_(e,t):w.IsNever(e)?g_(e,t):w.IsNull(e)?S_(e,t):w.IsNumber(e)?x_(e,t):w.IsObject(e)?O_(e,t):w.IsRecord(e)?R_(e,t):w.IsString(e)?C_(e,t):w.IsSymbol(e)?N_(e,t):w.IsTuple(e)?__(e,t):w.IsPromise(e)?A_(e,t):w.IsUint8Array(e)?j_(e,t):w.IsUndefined(e)?L_(e,t):w.IsUnion(e)?B_(e,t):w.IsUnknown(e)?F_(e,t):w.IsVoid(e)?K_(e,t):Na(`Unknown left type operand '${e[R]}'`)}function So(e,t){return ke(e,t)}u();u();u();function z_(e,t,n,r,i){let o={};for(let s of globalThis.Object.getOwnPropertyNames(e))o[s]=Is(e[s],t,n,r,i);return o}function H_(e,t,n,r,i){return z_(e.properties,t,n,r,i)}function F0(e,t,n,r,i){let o=H_(e,t,n,r,i);return ge(o)}function G_(e,t,n,r){let i=So(e,t);return i===P.Union?ve([n,r]):i===P.True?n:r}function Is(e,t,n,r,i={}){return Ze(e)?F0(e,t,n,r,i):qn(e)?B($0(e,t,n,r,i)):B(G_(e,t,n,r),i)}function q_(e,t,n,r,i){return{[e]:Is(oe(e),t,n,r,i)}}function V_(e,t,n,r,i){return e.reduce((o,s)=>({...o,...q_(s,t,n,r,i)}),{})}function Q_(e,t,n,r,i){return V_(e.keys,t,n,r,i)}function $0(e,t,n,r,i){let o=Q_(e,t,n,r,i);return ge(o)}u();function Y_(e){return e.allOf.every(t=>Es(t))}function J_(e){return e.anyOf.some(t=>Es(t))}function X_(e){return!Es(e.not)}function Es(e){return e[R]==="Intersect"?Y_(e):e[R]==="Union"?J_(e):e[R]==="Not"?X_(e):e[R]==="Undefined"}u();function K0(e,t){return ws(Ts(e),t)}function Z_(e,t){let n=e.filter(r=>So(r,t)===P.False);return n.length===1?n[0]:ve(n)}function ws(e,t,n={}){return Vn(e)?B(K0(e,t),n):Ze(e)?B(z0(e,t),n):B(Te(e)?Z_(e.anyOf,t):So(e,t)!==P.False?je():e,n)}function W_(e,t){let n={};for(let r of globalThis.Object.getOwnPropertyNames(e))n[r]=ws(e[r],t);return n}function ej(e,t){return W_(e.properties,t)}function z0(e,t){let n=ej(e,t);return ge(n)}u();u();u();u();function H0(e,t){return Ms(Ts(e),t)}function tj(e,t){let n=e.filter(r=>So(r,t)!==P.False);return n.length===1?n[0]:ve(n)}function Ms(e,t,n={}){return Vn(e)?B(H0(e,t),n):Ze(e)?B(G0(e,t),n):B(Te(e)?tj(e.anyOf,t):So(e,t)!==P.False?e:je(),n)}function nj(e,t){let n={};for(let r of globalThis.Object.getOwnPropertyNames(e))n[r]=Ms(e[r],t);return n}function rj(e,t){return nj(e.properties,t)}function G0(e,t){let n=rj(e,t);return ge(n)}u();u();function Yy(e,t={}){return B(e.returns,t)}u();u();function Jy(e={}){return{...e,[R]:"Integer",type:"integer"}}u();u();u();u();function ij(e,t,n){return{[e]:zr(oe(e),t,n)}}function oj(e,t,n){return e.reduce((r,i)=>({...r,...ij(i,t,n)}),{})}function sj(e,t,n){return oj(e.keys,t,n)}function q0(e,t,n){let r=sj(e,t,n);return ge(r)}function aj(e){let[t,n]=[e.slice(0,1),e.slice(1)];return[t.toLowerCase(),n].join("")}function cj(e){let[t,n]=[e.slice(0,1),e.slice(1)];return[t.toUpperCase(),n].join("")}function uj(e){return e.toUpperCase()}function lj(e){return e.toLowerCase()}function pj(e,t,n){let r=Ra(e.pattern);if(!Ss(r))return{...e,pattern:V0(e.pattern,t)};let s=[...Eu(r)].map(l=>oe(l)),a=Q0(s,t),c=ve(a);return Mu([c],n)}function V0(e,t){return typeof e=="string"?t==="Uncapitalize"?aj(e):t==="Capitalize"?cj(e):t==="Uppercase"?uj(e):t==="Lowercase"?lj(e):e:e.toString()}function Q0(e,t){return e.map(n=>zr(n,t))}function zr(e,t,n={}){return qn(e)?q0(e,t,n):Vn(e)?pj(e,t,e):Te(e)?ve(Q0(e.anyOf,t),n):Di(e)?oe(V0(e.const,t),n):e}function Xy(e,t={}){return zr(e,"Capitalize",t)}u();function Zy(e,t={}){return zr(e,"Lowercase",t)}u();function Wy(e,t={}){return zr(e,"Uncapitalize",t)}u();function eg(e,t={}){return zr(e,"Uppercase",t)}u();u();function tg(e,t){return{...t,[R]:"Not",not:B(e)}}u();u();u();u();function fj(e,t,n){let r={};for(let i of globalThis.Object.getOwnPropertyNames(e))r[i]=Os(e[i],t,n);return r}function dj(e,t,n){return fj(e.properties,t,n)}function Y0(e,t,n){let r=dj(e,t,n);return ge(r)}function mj(e,t){return e.map(n=>ng(n,t))}function hj(e,t){return e.map(n=>ng(n,t))}function yj(e,t){let{[t]:n,...r}=e;return r}function gj(e,t){return t.reduce((n,r)=>yj(n,r),e)}function ng(e,t){return ht(e)?vn(mj(e.allOf,t)):Te(e)?ve(hj(e.anyOf,t)):Pt(e)?Ne(gj(e.properties,t)):Ne({})}function Os(e,t,n={}){if(qn(t))return J0(e,t,n);if(Ze(e))return Y0(e,t,n);let r=Qn(t)?kn(t):t,i=ut(e,[mt,"$id","required"]),o=B(ng(e,r),n);return{...i,...o}}function bj(e,t,n){return{[t]:Os(e,[t],n)}}function Sj(e,t,n){return t.reduce((r,i)=>({...r,...bj(e,i,n)}),{})}function xj(e,t,n){return Sj(e,t.keys,n)}function J0(e,t,n){let r=xj(e,t,n);return ge(r)}u();u();function rg(e,t={}){return Kr(ct(e.parameters),{...t})}u();u();u();function X0(e){return e.map(t=>Z0(t))}function Tj(e){let t={};for(let n of globalThis.Object.getOwnPropertyNames(e))t[n]=xn(e[n]);return t}function Z0(e){return ht(e)?vn(X0(e.allOf)):Te(e)?ve(X0(e.anyOf)):Pt(e)?Ne(Tj(e.properties)):Ne({})}function Bu(e,t={}){if(Ze(e))return W0(e,t);let n=ut(e,[mt,"$id","required"]),r=B(Z0(e),t);return{...n,...r}}function vj(e,t){let n={};for(let r of globalThis.Object.getOwnPropertyNames(e))n[r]=Bu(e[r],t);return n}function Ij(e,t){return vj(e.properties,t)}function W0(e,t){let n=Ij(e,t);return ge(n)}u();u();u();u();function Ej(e,t,n){let r={};for(let i of globalThis.Object.getOwnPropertyNames(e))r[i]=As(e[i],t,n);return r}function wj(e,t,n){return Ej(e.properties,t,n)}function eE(e,t,n){let r=wj(e,t,n);return ge(r)}function Mj(e,t){return e.map(n=>ig(n,t))}function Oj(e,t){return e.map(n=>ig(n,t))}function Aj(e,t){let n={};for(let r of t)r in e&&(n[r]=e[r]);return n}function ig(e,t){return ht(e)?vn(Mj(e.allOf,t)):Te(e)?ve(Oj(e.anyOf,t)):Pt(e)?Ne(Aj(e.properties,t)):Ne({})}function As(e,t,n={}){if(qn(t))return tE(e,t,n);if(Ze(e))return eE(e,t,n);let r=Qn(t)?kn(t):t,i=ut(e,[mt,"$id","required"]),o=B(ig(e,r),n);return{...i,...o}}function Rj(e,t,n){return{[t]:As(e,[t],n)}}function Pj(e,t,n){return t.reduce((r,i)=>({...r,...Rj(e,i,n)}),{})}function Cj(e,t,n){return Pj(e,t.keys,n)}function tE(e,t,n){let r=Cj(e,t,n);return ge(r)}u();u();function og(e){return Jn(xn(e))}u();u();function Fu(e,t,n){return{...n,[R]:"Record",type:"object",patternProperties:{[e]:B(t)}}}function sg(e,t,n){let r={};for(let i of e)r[i]=B(t);return Ne(r,{...n,[Pn]:"Record"})}function Nj(e,t,n){return Sf(e)?sg(kn(e),t,n):Fu(e.pattern,t,n)}function kj(e,t,n){return sg(kn(ve(e)),t,n)}function Dj(e,t,n){return sg([e.toString()],t,n)}function Uj(e,t,n){return Fu(e.source,t,n)}function _j(e,t,n){let r=ot(e.pattern)?bo:e.pattern;return Fu(r,t,n)}function jj(e,t,n){return Fu(Ui,t,n)}function Lj(e,t,n){return Fu(Ui,t,n)}function ag(e,t,n={}){return Te(e)?kj(e.anyOf,t,n):Vn(e)?Nj(e,t,n):Di(e)?Dj(e.const,t,n):hs(e)?jj(e,t,n):ys(e)?Lj(e,t,n):xy(e)?Uj(e,t,n):yu(e)?_j(e,t,n):je(n)}u();u();var Bj=0;function cg(e,t={}){ot(t.$id)&&(t.$id=`T${Bj++}`);let n=e({[R]:"This",$ref:`${t.$id}`});return n.$id=t.$id,B({...t,[Pn]:"Recursive",...n})}u();u();function ug(e,t={}){if(qe(e))return{...t,[R]:"Ref",$ref:e};if(ot(e.$id))throw new Error("Reference target type must specify an $id");return{...t,[R]:"Ref",$ref:e.$id}}u();u();function lg(e,t={}){let n=qe(e)?new globalThis.RegExp(e):e;return{...t,[R]:"RegExp",type:"RegExp",source:n.source,flags:n.flags}}u();u();u();function nE(e){return e.map(t=>rE(t))}function Fj(e){let t={};for(let n of globalThis.Object.getOwnPropertyNames(e))t[n]=ut(e[n],[Sn]);return t}function rE(e){return ht(e)?vn(nE(e.allOf)):Te(e)?ve(nE(e.anyOf)):Pt(e)?Ne(Fj(e.properties)):Ne({})}function $u(e,t={}){if(Ze(e))return iE(e,t);{let n=ut(e,[mt,"$id","required"]),r=B(rE(e),t);return{...n,...r}}}function $j(e,t){let n={};for(let r of globalThis.Object.getOwnPropertyNames(e))n[r]=$u(e[r],t);return n}function Kj(e,t){return $j(e.properties,t)}function iE(e,t){let n=Kj(e,t);return ge(n)}u();u();function zj(e){return ht(e)?ct(e.allOf):Te(e)?ct(e.anyOf):$r(e)?ct(e.items??[]):[]}function pg(e){return ct(zj(e))}u();u();function fg(e,t={}){return B(e.returns,t)}u();u();u();u();u();u();u();function dg(e){return JSON.parse(JSON.stringify(e))}u();u();var mg=class{schema;constructor(t){this.schema=t}Decode(t){return new hg(this.schema,t)}},hg=class{schema;decode;constructor(t,n){this.schema=t,this.decode=n}EncodeTransform(t,n){let o={Encode:s=>n[mt].Encode(t(s)),Decode:s=>this.decode(n[mt].Decode(s))};return{...n,[mt]:o}}EncodeSchema(t,n){let r={Decode:this.decode,Encode:t};return{...n,[mt]:r}}Encode(t){let n=B(this.schema);return wa(n)?this.EncodeTransform(t,n):this.EncodeSchema(t,n)}};function yg(e){return new mg(e)}u();u();function Ku(e={}){return{...e,[R]:e[R]??"Unsafe"}}u();u();function gg(e={}){return{...e,[R]:"Void",type:"void"}}u();u();var bg={};Ci(bg,{Any:()=>_i,Array:()=>bs,AsyncIterator:()=>xu,Awaited:()=>_y,BigInt:()=>xs,Boolean:()=>wu,Capitalize:()=>Xy,Composite:()=>Ly,Const:()=>Fy,Constructor:()=>Tu,ConstructorParameters:()=>$y,Date:()=>ku,Deref:()=>br,Enum:()=>Ky,Exclude:()=>ws,Extends:()=>Is,Extract:()=>Ms,Function:()=>ji,Index:()=>vs,InstanceType:()=>Yy,Integer:()=>Jy,Intersect:()=>vn,Iterator:()=>Au,KeyOf:()=>Nu,Literal:()=>oe,Lowercase:()=>Zy,Mapped:()=>Dy,Never:()=>je,Not:()=>tg,Null:()=>Du,Number:()=>Yn,Object:()=>Ne,Omit:()=>Os,Optional:()=>xn,Parameters:()=>rg,Partial:()=>Bu,Pick:()=>As,Promise:()=>Ru,Readonly:()=>Jn,ReadonlyOptional:()=>og,Record:()=>ag,Recursive:()=>cg,Ref:()=>ug,RegExp:()=>lg,Required:()=>$u,Rest:()=>pg,ReturnType:()=>fg,Strict:()=>dg,String:()=>Tn,Symbol:()=>Uu,TemplateLiteral:()=>Mu,Transform:()=>yg,Tuple:()=>Kr,Uint8Array:()=>ju,Uncapitalize:()=>Wy,Undefined:()=>_u,Union:()=>ve,Unknown:()=>Xn,Unsafe:()=>Ku,Uppercase:()=>eg,Void:()=>gg});u();u();var x=bg;var Ng={};Ci(Ng,{Cast:()=>Cs,Check:()=>ue,Clean:()=>Of,Clone:()=>Pe,Convert:()=>Rf,Create:()=>pn,Default:()=>Cf,Delete:()=>gE,Diff:()=>Ig,Edit:()=>N2,Equal:()=>To,HasPropertyKey:()=>W,HasTransform:()=>jf,Hash:()=>Ps,Insert:()=>hE,IsArray:()=>J,IsAsyncIterator:()=>zu,IsBigInt:()=>Tr,IsBigInt64Array:()=>rL,IsBigUint64Array:()=>iL,IsBoolean:()=>Hr,IsDate:()=>_n,IsFloat32Array:()=>tL,IsFloat64Array:()=>nL,IsFunction:()=>ka,IsInstanceObject:()=>Gj,IsInt16Array:()=>Xj,IsInt32Array:()=>Wj,IsInt8Array:()=>Yj,IsInteger:()=>qu,IsIterator:()=>Hu,IsMap:()=>qj,IsNull:()=>ii,IsNumber:()=>Qe,IsObject:()=>Ct,IsPromise:()=>Gu,IsRegExp:()=>Qj,IsSet:()=>Vj,IsStandardObject:()=>Ae,IsString:()=>se,IsSymbol:()=>In,IsTypedArray:()=>cn,IsUint16Array:()=>Zj,IsUint32Array:()=>eL,IsUint8Array:()=>Rs,IsUint8ClampedArray:()=>Jj,IsUndefined:()=>et,IsValueType:()=>un,Mutate:()=>Mg,Patch:()=>Eg,TransformDecode:()=>Og,TransformDecodeCheckError:()=>tl,TransformDecodeError:()=>Uf,TransformEncode:()=>Ag,TransformEncodeCheckError:()=>nl,TransformEncodeError:()=>_f,Update:()=>yE,Value:()=>ks,ValueCastError:()=>Qu,ValueCheckUnknownTypeError:()=>Mf,ValueCreateError:()=>Ln,ValueDeltaError:()=>Zu,ValueDeltaSymbolError:()=>Ns,ValueErrorIterator:()=>Vu,ValueErrorType:()=>A,ValueHashError:()=>wf,ValueMutateError:()=>el,ValuePointer:()=>Ir});u();u();u();u();u();u();u();function zu(e){return Ct(e)&&Symbol.asyncIterator in e}function Hu(e){return Ct(e)&&Symbol.iterator in e}function Ae(e){return Ct(e)&&(Object.getPrototypeOf(e)===Object.prototype||Object.getPrototypeOf(e)===null)}function Gj(e){return Ct(e)&&!J(e)&&ka(e.constructor)&&e.constructor.name!=="Object"}function Gu(e){return e instanceof Promise}function _n(e){return e instanceof Date&&Number.isFinite(e.getTime())}function qj(e){return e instanceof globalThis.Map}function Vj(e){return e instanceof globalThis.Set}function Qj(e){return e instanceof globalThis.RegExp}function cn(e){return ArrayBuffer.isView(e)}function Yj(e){return e instanceof globalThis.Int8Array}function Rs(e){return e instanceof globalThis.Uint8Array}function Jj(e){return e instanceof globalThis.Uint8ClampedArray}function Xj(e){return e instanceof globalThis.Int16Array}function Zj(e){return e instanceof globalThis.Uint16Array}function Wj(e){return e instanceof globalThis.Int32Array}function eL(e){return e instanceof globalThis.Uint32Array}function tL(e){return e instanceof globalThis.Float32Array}function nL(e){return e instanceof globalThis.Float64Array}function rL(e){return e instanceof globalThis.BigInt64Array}function iL(e){return e instanceof globalThis.BigUint64Array}function W(e,t){return t in e}function Ct(e){return e!==null&&typeof e=="object"}function J(e){return Array.isArray(e)&&!ArrayBuffer.isView(e)}function et(e){return e===void 0}function ii(e){return e===null}function Hr(e){return typeof e=="boolean"}function Qe(e){return typeof e=="number"}function qu(e){return Number.isInteger(e)}function Tr(e){return typeof e=="bigint"}function se(e){return typeof e=="string"}function ka(e){return typeof e=="function"}function In(e){return typeof e=="symbol"}function un(e){return Tr(e)||Hr(e)||ii(e)||Qe(e)||se(e)||In(e)||et(e)}var jn;(function(e){e.ExactOptionalPropertyTypes=!1,e.AllowArrayObject=!1,e.AllowNaN=!1,e.AllowNullVoid=!1;function t(s,a){return e.ExactOptionalPropertyTypes?a in s:s[a]!==void 0}e.IsExactOptionalProperty=t;function n(s){let a=Ct(s);return e.AllowArrayObject?a:a&&!J(s)}e.IsObjectLike=n;function r(s){return n(s)&&!(s instanceof Date)&&!(s instanceof Uint8Array)}e.IsRecordLike=r;function i(s){return e.AllowNaN?Qe(s):Number.isFinite(s)}e.IsNumberLike=i;function o(s){let a=et(s);return e.AllowNullVoid?a||s===null:a}e.IsVoidLike=o})(jn||(jn={}));u();var Sg=class extends Z{constructor(t){super(`Duplicate type kind '${t}' detected`)}},xg=class extends Z{constructor(t){super(`Duplicate string format '${t}' detected`)}},oE;(function(e){function t(r,i){if(Nn.Has(r))throw new Sg(r);return Nn.Set(r,i),(o={})=>Ku({...o,[R]:r})}e.Type=t;function n(r,i){if(Cn.Has(r))throw new xg(r);return Cn.Set(r,i),r}e.Format=n})(oE||(oE={}));u();function oL(e){switch(e.errorType){case A.ArrayContains:return"Expected array to contain at least one matching value";case A.ArrayMaxContains:return`Expected array to contain no more than ${e.schema.maxContains} matching values`;case A.ArrayMinContains:return`Expected array to contain at least ${e.schema.minContains} matching values`;case A.ArrayMaxItems:return`Expected array length to be less or equal to ${e.schema.maxItems}`;case A.ArrayMinItems:return`Expected array length to be greater or equal to ${e.schema.minItems}`;case A.ArrayUniqueItems:return"Expected array elements to be unique";case A.Array:return"Expected array";case A.AsyncIterator:return"Expected AsyncIterator";case A.BigIntExclusiveMaximum:return`Expected bigint to be less than ${e.schema.exclusiveMaximum}`;case A.BigIntExclusiveMinimum:return`Expected bigint to be greater than ${e.schema.exclusiveMinimum}`;case A.BigIntMaximum:return`Expected bigint to be less or equal to ${e.schema.maximum}`;case A.BigIntMinimum:return`Expected bigint to be greater or equal to ${e.schema.minimum}`;case A.BigIntMultipleOf:return`Expected bigint to be a multiple of ${e.schema.multipleOf}`;case A.BigInt:return"Expected bigint";case A.Boolean:return"Expected boolean";case A.DateExclusiveMinimumTimestamp:return`Expected Date timestamp to be greater than ${e.schema.exclusiveMinimumTimestamp}`;case A.DateExclusiveMaximumTimestamp:return`Expected Date timestamp to be less than ${e.schema.exclusiveMaximumTimestamp}`;case A.DateMinimumTimestamp:return`Expected Date timestamp to be greater or equal to ${e.schema.minimumTimestamp}`;case A.DateMaximumTimestamp:return`Expected Date timestamp to be less or equal to ${e.schema.maximumTimestamp}`;case A.DateMultipleOfTimestamp:return`Expected Date timestamp to be a multiple of ${e.schema.multipleOfTimestamp}`;case A.Date:return"Expected Date";case A.Function:return"Expected function";case A.IntegerExclusiveMaximum:return`Expected integer to be less than ${e.schema.exclusiveMaximum}`;case A.IntegerExclusiveMinimum:return`Expected integer to be greater than ${e.schema.exclusiveMinimum}`;case A.IntegerMaximum:return`Expected integer to be less or equal to ${e.schema.maximum}`;case A.IntegerMinimum:return`Expected integer to be greater or equal to ${e.schema.minimum}`;case A.IntegerMultipleOf:return`Expected integer to be a multiple of ${e.schema.multipleOf}`;case A.Integer:return"Expected integer";case A.IntersectUnevaluatedProperties:return"Unexpected property";case A.Intersect:return"Expected all values to match";case A.Iterator:return"Expected Iterator";case A.Literal:return`Expected ${typeof e.schema.const=="string"?`'${e.schema.const}'`:e.schema.const}`;case A.Never:return"Never";case A.Not:return"Value should not match";case A.Null:return"Expected null";case A.NumberExclusiveMaximum:return`Expected number to be less than ${e.schema.exclusiveMaximum}`;case A.NumberExclusiveMinimum:return`Expected number to be greater than ${e.schema.exclusiveMinimum}`;case A.NumberMaximum:return`Expected number to be less or equal to ${e.schema.maximum}`;case A.NumberMinimum:return`Expected number to be greater or equal to ${e.schema.minimum}`;case A.NumberMultipleOf:return`Expected number to be a multiple of ${e.schema.multipleOf}`;case A.Number:return"Expected number";case A.Object:return"Expected object";case A.ObjectAdditionalProperties:return"Unexpected property";case A.ObjectMaxProperties:return`Expected object to have no more than ${e.schema.maxProperties} properties`;case A.ObjectMinProperties:return`Expected object to have at least ${e.schema.minProperties} properties`;case A.ObjectRequiredProperty:return"Required property";case A.Promise:return"Expected Promise";case A.RegExp:return"Expected string to match regular expression";case A.StringFormatUnknown:return`Unknown format '${e.schema.format}'`;case A.StringFormat:return`Expected string to match '${e.schema.format}' format`;case A.StringMaxLength:return`Expected string length less or equal to ${e.schema.maxLength}`;case A.StringMinLength:return`Expected string length greater or equal to ${e.schema.minLength}`;case A.StringPattern:return`Expected string to match '${e.schema.pattern}'`;case A.String:return"Expected string";case A.Symbol:return"Expected symbol";case A.TupleLength:return`Expected tuple to have ${e.schema.maxItems||0} elements`;case A.Tuple:return"Expected tuple";case A.Uint8ArrayMaxByteLength:return`Expected byte length less or equal to ${e.schema.maxByteLength}`;case A.Uint8ArrayMinByteLength:return`Expected byte length greater or equal to ${e.schema.minByteLength}`;case A.Uint8Array:return"Expected Uint8Array";case A.Undefined:return"Expected undefined";case A.Union:return"Expected union value";case A.Void:return"Expected void";case A.Kind:return`Expected kind '${e.schema[R]}'`;default:return"Unknown error type"}}var sL=oL;function sE(){return sL}u();u();var Tg=class extends Z{schema;constructor(t){super(`Unable to dereference schema with $id '${t.$id}'`),this.schema=t}};function Re(e,t){let n=t.findIndex(r=>r.$id===e.$ref);if(n===-1)throw new Tg(e);return t[n]}u();u();var wf=class extends Z{value;constructor(t){super("Unable to hash value"),this.value=t}},Zn;(function(e){e[e.Undefined=0]="Undefined",e[e.Null=1]="Null",e[e.Boolean=2]="Boolean",e[e.Number=3]="Number",e[e.String=4]="String",e[e.Object=5]="Object",e[e.Array=6]="Array",e[e.Date=7]="Date",e[e.Uint8Array=8]="Uint8Array",e[e.Symbol=9]="Symbol",e[e.BigInt=10]="BigInt"})(Zn||(Zn={}));var Da=BigInt("14695981039346656037"),[aL,cL]=[BigInt("1099511628211"),BigInt("2")**BigInt("64")],uL=Array.from({length:256}).map((e,t)=>BigInt(t)),aE=new Float64Array(1),cE=new DataView(aE.buffer),uE=new Uint8Array(aE.buffer);function*lL(e){let t=e===0?1:Math.ceil(Math.floor(Math.log2(e)+1)/8);for(let n=0;n<t;n++)yield e>>8*(t-1-n)&255}function pL(e){ln(Zn.Array);for(let t of e)Ua(t)}function fL(e){ln(Zn.Boolean),ln(e?1:0)}function dL(e){ln(Zn.BigInt),cE.setBigInt64(0,e);for(let t of uE)ln(t)}function mL(e){ln(Zn.Date),Ua(e.getTime())}function hL(e){ln(Zn.Null)}function yL(e){ln(Zn.Number),cE.setFloat64(0,e);for(let t of uE)ln(t)}function gL(e){ln(Zn.Object);for(let t of globalThis.Object.getOwnPropertyNames(e).sort())Ua(t),Ua(e[t])}function bL(e){ln(Zn.String);for(let t=0;t<e.length;t++)for(let n of lL(e.charCodeAt(t)))ln(n)}function SL(e){ln(Zn.Symbol),Ua(e.description)}function xL(e){ln(Zn.Uint8Array);for(let t=0;t<e.length;t++)ln(e[t])}function TL(e){return ln(Zn.Undefined)}function Ua(e){if(J(e))return pL(e);if(Hr(e))return fL(e);if(Tr(e))return dL(e);if(_n(e))return mL(e);if(ii(e))return hL(e);if(Qe(e))return yL(e);if(Ae(e))return gL(e);if(se(e))return bL(e);if(In(e))return SL(e);if(Rs(e))return xL(e);if(et(e))return TL(e);throw new wf(e)}function ln(e){Da=Da^uL[e],Da=Da*aL%cL}function Ps(e){return Da=BigInt("14695981039346656037"),Ua(e),Da}var A;(function(e){e[e.ArrayContains=0]="ArrayContains",e[e.ArrayMaxContains=1]="ArrayMaxContains",e[e.ArrayMaxItems=2]="ArrayMaxItems",e[e.ArrayMinContains=3]="ArrayMinContains",e[e.ArrayMinItems=4]="ArrayMinItems",e[e.ArrayUniqueItems=5]="ArrayUniqueItems",e[e.Array=6]="Array",e[e.AsyncIterator=7]="AsyncIterator",e[e.BigIntExclusiveMaximum=8]="BigIntExclusiveMaximum",e[e.BigIntExclusiveMinimum=9]="BigIntExclusiveMinimum",e[e.BigIntMaximum=10]="BigIntMaximum",e[e.BigIntMinimum=11]="BigIntMinimum",e[e.BigIntMultipleOf=12]="BigIntMultipleOf",e[e.BigInt=13]="BigInt",e[e.Boolean=14]="Boolean",e[e.DateExclusiveMaximumTimestamp=15]="DateExclusiveMaximumTimestamp",e[e.DateExclusiveMinimumTimestamp=16]="DateExclusiveMinimumTimestamp",e[e.DateMaximumTimestamp=17]="DateMaximumTimestamp",e[e.DateMinimumTimestamp=18]="DateMinimumTimestamp",e[e.DateMultipleOfTimestamp=19]="DateMultipleOfTimestamp",e[e.Date=20]="Date",e[e.Function=21]="Function",e[e.IntegerExclusiveMaximum=22]="IntegerExclusiveMaximum",e[e.IntegerExclusiveMinimum=23]="IntegerExclusiveMinimum",e[e.IntegerMaximum=24]="IntegerMaximum",e[e.IntegerMinimum=25]="IntegerMinimum",e[e.IntegerMultipleOf=26]="IntegerMultipleOf",e[e.Integer=27]="Integer",e[e.IntersectUnevaluatedProperties=28]="IntersectUnevaluatedProperties",e[e.Intersect=29]="Intersect",e[e.Iterator=30]="Iterator",e[e.Kind=31]="Kind",e[e.Literal=32]="Literal",e[e.Never=33]="Never",e[e.Not=34]="Not",e[e.Null=35]="Null",e[e.NumberExclusiveMaximum=36]="NumberExclusiveMaximum",e[e.NumberExclusiveMinimum=37]="NumberExclusiveMinimum",e[e.NumberMaximum=38]="NumberMaximum",e[e.NumberMinimum=39]="NumberMinimum",e[e.NumberMultipleOf=40]="NumberMultipleOf",e[e.Number=41]="Number",e[e.ObjectAdditionalProperties=42]="ObjectAdditionalProperties",e[e.ObjectMaxProperties=43]="ObjectMaxProperties",e[e.ObjectMinProperties=44]="ObjectMinProperties",e[e.ObjectRequiredProperty=45]="ObjectRequiredProperty",e[e.Object=46]="Object",e[e.Promise=47]="Promise",e[e.RegExp=48]="RegExp",e[e.StringFormatUnknown=49]="StringFormatUnknown",e[e.StringFormat=50]="StringFormat",e[e.StringMaxLength=51]="StringMaxLength",e[e.StringMinLength=52]="StringMinLength",e[e.StringPattern=53]="StringPattern",e[e.String=54]="String",e[e.Symbol=55]="Symbol",e[e.TupleLength=56]="TupleLength",e[e.Tuple=57]="Tuple",e[e.Uint8ArrayMaxByteLength=58]="Uint8ArrayMaxByteLength",e[e.Uint8ArrayMinByteLength=59]="Uint8ArrayMinByteLength",e[e.Uint8Array=60]="Uint8Array",e[e.Undefined=61]="Undefined",e[e.Union=62]="Union",e[e.Void=63]="Void"})(A||(A={}));var vg=class extends Z{schema;constructor(t){super("Unknown type"),this.schema=t}};function Bi(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}function ae(e){return e!==void 0}var Vu=class{iterator;constructor(t){this.iterator=t}[Symbol.iterator](){return this.iterator}First(){let t=this.iterator.next();return t.done?void 0:t.value}};function $(e,t,n,r){return{type:e,schema:t,path:n,value:r,message:sE()({errorType:e,path:n,schema:t,value:r})}}function*vL(e,t,n,r){}function*IL(e,t,n,r){if(!J(r))return yield $(A.Array,e,n,r);ae(e.minItems)&&!(r.length>=e.minItems)&&(yield $(A.ArrayMinItems,e,n,r)),ae(e.maxItems)&&!(r.length<=e.maxItems)&&(yield $(A.ArrayMaxItems,e,n,r));for(let s=0;s<r.length;s++)yield*Zt(e.items,t,`${n}/${s}`,r[s]);if(e.uniqueItems===!0&&!function(){let s=new Set;for(let a of r){let c=Ps(a);if(s.has(c))return!1;s.add(c)}return!0}()&&(yield $(A.ArrayUniqueItems,e,n,r)),!(ae(e.contains)||ae(e.minContains)||ae(e.maxContains)))return;let i=ae(e.contains)?e.contains:je(),o=r.reduce((s,a,c)=>Zt(i,t,`${n}${c}`,a).next().done===!0?s+1:s,0);o===0&&(yield $(A.ArrayContains,e,n,r)),Qe(e.minContains)&&o<e.minContains&&(yield $(A.ArrayMinContains,e,n,r)),Qe(e.maxContains)&&o>e.maxContains&&(yield $(A.ArrayMaxContains,e,n,r))}function*EL(e,t,n,r){zu(r)||(yield $(A.AsyncIterator,e,n,r))}function*wL(e,t,n,r){if(!Tr(r))return yield $(A.BigInt,e,n,r);ae(e.exclusiveMaximum)&&!(r<e.exclusiveMaximum)&&(yield $(A.BigIntExclusiveMaximum,e,n,r)),ae(e.exclusiveMinimum)&&!(r>e.exclusiveMinimum)&&(yield $(A.BigIntExclusiveMinimum,e,n,r)),ae(e.maximum)&&!(r<=e.maximum)&&(yield $(A.BigIntMaximum,e,n,r)),ae(e.minimum)&&!(r>=e.minimum)&&(yield $(A.BigIntMinimum,e,n,r)),ae(e.multipleOf)&&r%e.multipleOf!==BigInt(0)&&(yield $(A.BigIntMultipleOf,e,n,r))}function*ML(e,t,n,r){Hr(r)||(yield $(A.Boolean,e,n,r))}function*OL(e,t,n,r){yield*Zt(e.returns,t,n,r.prototype)}function*AL(e,t,n,r){if(!_n(r))return yield $(A.Date,e,n,r);ae(e.exclusiveMaximumTimestamp)&&!(r.getTime()<e.exclusiveMaximumTimestamp)&&(yield $(A.DateExclusiveMaximumTimestamp,e,n,r)),ae(e.exclusiveMinimumTimestamp)&&!(r.getTime()>e.exclusiveMinimumTimestamp)&&(yield $(A.DateExclusiveMinimumTimestamp,e,n,r)),ae(e.maximumTimestamp)&&!(r.getTime()<=e.maximumTimestamp)&&(yield $(A.DateMaximumTimestamp,e,n,r)),ae(e.minimumTimestamp)&&!(r.getTime()>=e.minimumTimestamp)&&(yield $(A.DateMinimumTimestamp,e,n,r)),ae(e.multipleOfTimestamp)&&r.getTime()%e.multipleOfTimestamp!==0&&(yield $(A.DateMultipleOfTimestamp,e,n,r))}function*RL(e,t,n,r){ka(r)||(yield $(A.Function,e,n,r))}function*PL(e,t,n,r){if(!qu(r))return yield $(A.Integer,e,n,r);ae(e.exclusiveMaximum)&&!(r<e.exclusiveMaximum)&&(yield $(A.IntegerExclusiveMaximum,e,n,r)),ae(e.exclusiveMinimum)&&!(r>e.exclusiveMinimum)&&(yield $(A.IntegerExclusiveMinimum,e,n,r)),ae(e.maximum)&&!(r<=e.maximum)&&(yield $(A.IntegerMaximum,e,n,r)),ae(e.minimum)&&!(r>=e.minimum)&&(yield $(A.IntegerMinimum,e,n,r)),ae(e.multipleOf)&&r%e.multipleOf!==0&&(yield $(A.IntegerMultipleOf,e,n,r))}function*CL(e,t,n,r){for(let i of e.allOf){let o=Zt(i,t,n,r).next();o.done||(yield $(A.Intersect,e,n,r),yield o.value)}if(e.unevaluatedProperties===!1){let i=new RegExp(Ca(e));for(let o of Object.getOwnPropertyNames(r))i.test(o)||(yield $(A.IntersectUnevaluatedProperties,e,`${n}/${o}`,r))}if(typeof e.unevaluatedProperties=="object"){let i=new RegExp(Ca(e));for(let o of Object.getOwnPropertyNames(r))if(!i.test(o)){let s=Zt(e.unevaluatedProperties,t,`${n}/${o}`,r[o]).next();s.done||(yield s.value)}}}function*NL(e,t,n,r){Hu(r)||(yield $(A.Iterator,e,n,r))}function*kL(e,t,n,r){r!==e.const&&(yield $(A.Literal,e,n,r))}function*DL(e,t,n,r){yield $(A.Never,e,n,r)}function*UL(e,t,n,r){Zt(e.not,t,n,r).next().done===!0&&(yield $(A.Not,e,n,r))}function*_L(e,t,n,r){ii(r)||(yield $(A.Null,e,n,r))}function*jL(e,t,n,r){if(!jn.IsNumberLike(r))return yield $(A.Number,e,n,r);ae(e.exclusiveMaximum)&&!(r<e.exclusiveMaximum)&&(yield $(A.NumberExclusiveMaximum,e,n,r)),ae(e.exclusiveMinimum)&&!(r>e.exclusiveMinimum)&&(yield $(A.NumberExclusiveMinimum,e,n,r)),ae(e.maximum)&&!(r<=e.maximum)&&(yield $(A.NumberMaximum,e,n,r)),ae(e.minimum)&&!(r>=e.minimum)&&(yield $(A.NumberMinimum,e,n,r)),ae(e.multipleOf)&&r%e.multipleOf!==0&&(yield $(A.NumberMultipleOf,e,n,r))}function*LL(e,t,n,r){if(!jn.IsObjectLike(r))return yield $(A.Object,e,n,r);ae(e.minProperties)&&!(Object.getOwnPropertyNames(r).length>=e.minProperties)&&(yield $(A.ObjectMinProperties,e,n,r)),ae(e.maxProperties)&&!(Object.getOwnPropertyNames(r).length<=e.maxProperties)&&(yield $(A.ObjectMaxProperties,e,n,r));let i=Array.isArray(e.required)?e.required:[],o=Object.getOwnPropertyNames(e.properties),s=Object.getOwnPropertyNames(r);for(let a of i)s.includes(a)||(yield $(A.ObjectRequiredProperty,e.properties[a],`${n}/${Bi(a)}`,void 0));if(e.additionalProperties===!1)for(let a of s)o.includes(a)||(yield $(A.ObjectAdditionalProperties,e,`${n}/${Bi(a)}`,r[a]));if(typeof e.additionalProperties=="object")for(let a of s)o.includes(a)||(yield*Zt(e.additionalProperties,t,`${n}/${Bi(a)}`,r[a]));for(let a of o){let c=e.properties[a];e.required&&e.required.includes(a)?(yield*Zt(c,t,`${n}/${Bi(a)}`,r[a]),Es(e)&&!(a in r)&&(yield $(A.ObjectRequiredProperty,c,`${n}/${Bi(a)}`,void 0))):jn.IsExactOptionalProperty(r,a)&&(yield*Zt(c,t,`${n}/${Bi(a)}`,r[a]))}}function*BL(e,t,n,r){Gu(r)||(yield $(A.Promise,e,n,r))}function*FL(e,t,n,r){if(!jn.IsRecordLike(r))return yield $(A.Object,e,n,r);ae(e.minProperties)&&!(Object.getOwnPropertyNames(r).length>=e.minProperties)&&(yield $(A.ObjectMinProperties,e,n,r)),ae(e.maxProperties)&&!(Object.getOwnPropertyNames(r).length<=e.maxProperties)&&(yield $(A.ObjectMaxProperties,e,n,r));let[i,o]=Object.entries(e.patternProperties)[0],s=new RegExp(i);for(let[a,c]of Object.entries(r))s.test(a)&&(yield*Zt(o,t,`${n}/${Bi(a)}`,c));if(typeof e.additionalProperties=="object")for(let[a,c]of Object.entries(r))s.test(a)||(yield*Zt(e.additionalProperties,t,`${n}/${Bi(a)}`,c));if(e.additionalProperties===!1){for(let[a,c]of Object.entries(r))if(!s.test(a))return yield $(A.ObjectAdditionalProperties,e,`${n}/${Bi(a)}`,c)}}function*$L(e,t,n,r){yield*Zt(Re(e,t),t,n,r)}function*KL(e,t,n,r){if(!se(r))return yield $(A.String,e,n,r);if(ae(e.minLength)&&!(r.length>=e.minLength)&&(yield $(A.StringMinLength,e,n,r)),ae(e.maxLength)&&!(r.length<=e.maxLength)&&(yield $(A.StringMaxLength,e,n,r)),!new RegExp(e.source,e.flags).test(r))return yield $(A.RegExp,e,n,r)}function*zL(e,t,n,r){if(!se(r))return yield $(A.String,e,n,r);ae(e.minLength)&&!(r.length>=e.minLength)&&(yield $(A.StringMinLength,e,n,r)),ae(e.maxLength)&&!(r.length<=e.maxLength)&&(yield $(A.StringMaxLength,e,n,r)),se(e.pattern)&&(new RegExp(e.pattern).test(r)||(yield $(A.StringPattern,e,n,r))),se(e.format)&&(Cn.Has(e.format)?Cn.Get(e.format)(r)||(yield $(A.StringFormat,e,n,r)):yield $(A.StringFormatUnknown,e,n,r))}function*HL(e,t,n,r){In(r)||(yield $(A.Symbol,e,n,r))}function*GL(e,t,n,r){if(!se(r))return yield $(A.String,e,n,r);new RegExp(e.pattern).test(r)||(yield $(A.StringPattern,e,n,r))}function*qL(e,t,n,r){yield*Zt(Re(e,t),t,n,r)}function*VL(e,t,n,r){if(!J(r))return yield $(A.Tuple,e,n,r);if(e.items===void 0&&r.length!==0)return yield $(A.TupleLength,e,n,r);if(r.length!==e.maxItems)return yield $(A.TupleLength,e,n,r);if(e.items)for(let i=0;i<e.items.length;i++)yield*Zt(e.items[i],t,`${n}/${i}`,r[i])}function*QL(e,t,n,r){et(r)||(yield $(A.Undefined,e,n,r))}function*YL(e,t,n,r){let i=0;for(let o of e.anyOf){let s=[...Zt(o,t,n,r)];if(s.length===0)return;i+=s.length}i>0&&(yield $(A.Union,e,n,r))}function*JL(e,t,n,r){if(!Rs(r))return yield $(A.Uint8Array,e,n,r);ae(e.maxByteLength)&&!(r.length<=e.maxByteLength)&&(yield $(A.Uint8ArrayMaxByteLength,e,n,r)),ae(e.minByteLength)&&!(r.length>=e.minByteLength)&&(yield $(A.Uint8ArrayMinByteLength,e,n,r))}function*XL(e,t,n,r){}function*ZL(e,t,n,r){jn.IsVoidLike(r)||(yield $(A.Void,e,n,r))}function*WL(e,t,n,r){Nn.Get(e[R])(e,r)||(yield $(A.Kind,e,n,r))}function*Zt(e,t,n,r){let i=ae(e.$id)?[...t,e]:t,o=e;switch(o[R]){case"Any":return yield*vL(o,i,n,r);case"Array":return yield*IL(o,i,n,r);case"AsyncIterator":return yield*EL(o,i,n,r);case"BigInt":return yield*wL(o,i,n,r);case"Boolean":return yield*ML(o,i,n,r);case"Constructor":return yield*OL(o,i,n,r);case"Date":return yield*AL(o,i,n,r);case"Function":return yield*RL(o,i,n,r);case"Integer":return yield*PL(o,i,n,r);case"Intersect":return yield*CL(o,i,n,r);case"Iterator":return yield*NL(o,i,n,r);case"Literal":return yield*kL(o,i,n,r);case"Never":return yield*DL(o,i,n,r);case"Not":return yield*UL(o,i,n,r);case"Null":return yield*_L(o,i,n,r);case"Number":return yield*jL(o,i,n,r);case"Object":return yield*LL(o,i,n,r);case"Promise":return yield*BL(o,i,n,r);case"Record":return yield*FL(o,i,n,r);case"Ref":return yield*$L(o,i,n,r);case"RegExp":return yield*KL(o,i,n,r);case"String":return yield*zL(o,i,n,r);case"Symbol":return yield*HL(o,i,n,r);case"TemplateLiteral":return yield*GL(o,i,n,r);case"This":return yield*qL(o,i,n,r);case"Tuple":return yield*VL(o,i,n,r);case"Undefined":return yield*QL(o,i,n,r);case"Union":return yield*YL(o,i,n,r);case"Uint8Array":return yield*JL(o,i,n,r);case"Unknown":return yield*XL(o,i,n,r);case"Void":return yield*ZL(o,i,n,r);default:if(!Nn.Has(o[R]))throw new vg(e);return yield*WL(o,i,n,r)}}function _a(...e){let t=e.length===3?Zt(e[0],e[1],"",e[2]):Zt(e[0],[],"",e[1]);return new Vu(t)}u();u();u();u();u();u();var Mf=class extends Z{schema;constructor(t){super("Unknown type"),this.schema=t}};function eB(e){return e[R]==="Any"||e[R]==="Unknown"}function ce(e){return e!==void 0}function tB(e,t,n){return!0}function nB(e,t,n){if(!J(n)||ce(e.minItems)&&!(n.length>=e.minItems)||ce(e.maxItems)&&!(n.length<=e.maxItems)||!n.every(o=>Wt(e.items,t,o))||e.uniqueItems===!0&&!function(){let o=new Set;for(let s of n){let a=Ps(s);if(o.has(a))return!1;o.add(a)}return!0}())return!1;if(!(ce(e.contains)||Qe(e.minContains)||Qe(e.maxContains)))return!0;let r=ce(e.contains)?e.contains:je(),i=n.reduce((o,s)=>Wt(r,t,s)?o+1:o,0);return!(i===0||Qe(e.minContains)&&i<e.minContains||Qe(e.maxContains)&&i>e.maxContains)}function rB(e,t,n){return zu(n)}function iB(e,t,n){return!(!Tr(n)||ce(e.exclusiveMaximum)&&!(n<e.exclusiveMaximum)||ce(e.exclusiveMinimum)&&!(n>e.exclusiveMinimum)||ce(e.maximum)&&!(n<=e.maximum)||ce(e.minimum)&&!(n>=e.minimum)||ce(e.multipleOf)&&n%e.multipleOf!==BigInt(0))}function oB(e,t,n){return Hr(n)}function sB(e,t,n){return Wt(e.returns,t,n.prototype)}function aB(e,t,n){return!(!_n(n)||ce(e.exclusiveMaximumTimestamp)&&!(n.getTime()<e.exclusiveMaximumTimestamp)||ce(e.exclusiveMinimumTimestamp)&&!(n.getTime()>e.exclusiveMinimumTimestamp)||ce(e.maximumTimestamp)&&!(n.getTime()<=e.maximumTimestamp)||ce(e.minimumTimestamp)&&!(n.getTime()>=e.minimumTimestamp)||ce(e.multipleOfTimestamp)&&n.getTime()%e.multipleOfTimestamp!==0)}function cB(e,t,n){return ka(n)}function uB(e,t,n){return!(!qu(n)||ce(e.exclusiveMaximum)&&!(n<e.exclusiveMaximum)||ce(e.exclusiveMinimum)&&!(n>e.exclusiveMinimum)||ce(e.maximum)&&!(n<=e.maximum)||ce(e.minimum)&&!(n>=e.minimum)||ce(e.multipleOf)&&n%e.multipleOf!==0)}function lB(e,t,n){let r=e.allOf.every(i=>Wt(i,t,n));if(e.unevaluatedProperties===!1){let i=new RegExp(Ca(e)),o=Object.getOwnPropertyNames(n).every(s=>i.test(s));return r&&o}else if(fe(e.unevaluatedProperties)){let i=new RegExp(Ca(e)),o=Object.getOwnPropertyNames(n).every(s=>i.test(s)||Wt(e.unevaluatedProperties,t,n[s]));return r&&o}else return r}function pB(e,t,n){return Hu(n)}function fB(e,t,n){return n===e.const}function dB(e,t,n){return!1}function mB(e,t,n){return!Wt(e.not,t,n)}function hB(e,t,n){return ii(n)}function yB(e,t,n){return!(!jn.IsNumberLike(n)||ce(e.exclusiveMaximum)&&!(n<e.exclusiveMaximum)||ce(e.exclusiveMinimum)&&!(n>e.exclusiveMinimum)||ce(e.minimum)&&!(n>=e.minimum)||ce(e.maximum)&&!(n<=e.maximum)||ce(e.multipleOf)&&n%e.multipleOf!==0)}function gB(e,t,n){if(!jn.IsObjectLike(n)||ce(e.minProperties)&&!(Object.getOwnPropertyNames(n).length>=e.minProperties)||ce(e.maxProperties)&&!(Object.getOwnPropertyNames(n).length<=e.maxProperties))return!1;let r=Object.getOwnPropertyNames(e.properties);for(let i of r){let o=e.properties[i];if(e.required&&e.required.includes(i)){if(!Wt(o,t,n[i])||(Es(o)||eB(o))&&!(i in n))return!1}else if(jn.IsExactOptionalProperty(n,i)&&!Wt(o,t,n[i]))return!1}if(e.additionalProperties===!1){let i=Object.getOwnPropertyNames(n);return e.required&&e.required.length===r.length&&i.length===r.length?!0:i.every(o=>r.includes(o))}else return typeof e.additionalProperties=="object"?Object.getOwnPropertyNames(n).every(o=>r.includes(o)||Wt(e.additionalProperties,t,n[o])):!0}function bB(e,t,n){return Gu(n)}function SB(e,t,n){if(!jn.IsRecordLike(n)||ce(e.minProperties)&&!(Object.getOwnPropertyNames(n).length>=e.minProperties)||ce(e.maxProperties)&&!(Object.getOwnPropertyNames(n).length<=e.maxProperties))return!1;let[r,i]=Object.entries(e.patternProperties)[0],o=new RegExp(r),s=Object.entries(n).every(([l,p])=>o.test(l)?Wt(i,t,p):!0),a=typeof e.additionalProperties=="object"?Object.entries(n).every(([l,p])=>o.test(l)?!0:Wt(e.additionalProperties,t,p)):!0,c=e.additionalProperties===!1?Object.getOwnPropertyNames(n).every(l=>o.test(l)):!0;return s&&a&&c}function xB(e,t,n){return Wt(Re(e,t),t,n)}function TB(e,t,n){let r=new RegExp(e.source,e.flags);return ce(e.minLength)&&!(n.length>=e.minLength)||ce(e.maxLength)&&!(n.length<=e.maxLength)?!1:r.test(n)}function vB(e,t,n){return!se(n)||ce(e.minLength)&&!(n.length>=e.minLength)||ce(e.maxLength)&&!(n.length<=e.maxLength)||ce(e.pattern)&&!new RegExp(e.pattern).test(n)?!1:ce(e.format)?Cn.Has(e.format)?Cn.Get(e.format)(n):!1:!0}function IB(e,t,n){return In(n)}function EB(e,t,n){return se(n)&&new RegExp(e.pattern).test(n)}function wB(e,t,n){return Wt(Re(e,t),t,n)}function MB(e,t,n){if(!J(n)||e.items===void 0&&n.length!==0||n.length!==e.maxItems)return!1;if(!e.items)return!0;for(let r=0;r<e.items.length;r++)if(!Wt(e.items[r],t,n[r]))return!1;return!0}function OB(e,t,n){return et(n)}function AB(e,t,n){return e.anyOf.some(r=>Wt(r,t,n))}function RB(e,t,n){return!(!Rs(n)||ce(e.maxByteLength)&&!(n.length<=e.maxByteLength)||ce(e.minByteLength)&&!(n.length>=e.minByteLength))}function PB(e,t,n){return!0}function CB(e,t,n){return jn.IsVoidLike(n)}function NB(e,t,n){return Nn.Has(e[R])?Nn.Get(e[R])(e,n):!1}function Wt(e,t,n){let r=ce(e.$id)?[...t,e]:t,i=e;switch(i[R]){case"Any":return tB(i,r,n);case"Array":return nB(i,r,n);case"AsyncIterator":return rB(i,r,n);case"BigInt":return iB(i,r,n);case"Boolean":return oB(i,r,n);case"Constructor":return sB(i,r,n);case"Date":return aB(i,r,n);case"Function":return cB(i,r,n);case"Integer":return uB(i,r,n);case"Intersect":return lB(i,r,n);case"Iterator":return pB(i,r,n);case"Literal":return fB(i,r,n);case"Never":return dB(i,r,n);case"Not":return mB(i,r,n);case"Null":return hB(i,r,n);case"Number":return yB(i,r,n);case"Object":return gB(i,r,n);case"Promise":return bB(i,r,n);case"Record":return SB(i,r,n);case"Ref":return xB(i,r,n);case"RegExp":return TB(i,r,n);case"String":return vB(i,r,n);case"Symbol":return IB(i,r,n);case"TemplateLiteral":return EB(i,r,n);case"This":return wB(i,r,n);case"Tuple":return MB(i,r,n);case"Undefined":return OB(i,r,n);case"Union":return AB(i,r,n);case"Uint8Array":return RB(i,r,n);case"Unknown":return PB(i,r,n);case"Void":return CB(i,r,n);default:if(!Nn.Has(i[R]))throw new Mf(i);return NB(i,r,n)}}function ue(...e){return e.length===3?Wt(e[0],e[1],e[2]):Wt(e[0],[],e[1])}u();u();function kB(e){let t={};for(let n of Object.getOwnPropertyNames(e))t[n]=Pe(e[n]);for(let n of Object.getOwnPropertySymbols(e))t[n]=Pe(e[n]);return t}function DB(e){return e.map(t=>Pe(t))}function UB(e){return e.slice()}function _B(e){return new Date(e.toISOString())}function Pe(e){if(J(e))return DB(e);if(_n(e))return _B(e);if(Ae(e))return kB(e);if(cn(e))return UB(e);if(un(e))return e;throw new Error("ValueClone: Unable to clone value")}var Ln=class extends Z{schema;constructor(t,n){super(n),this.schema=t}};function be(e){return typeof e=="function"?e:Pe(e)}function jB(e,t){return W(e,"default")?be(e.default):{}}function LB(e,t){if(e.uniqueItems===!0&&!W(e,"default"))throw new Ln(e,"Array with the uniqueItems constraint requires a default value");if("contains"in e&&!W(e,"default"))throw new Ln(e,"Array with the contains constraint requires a default value");return"default"in e?be(e.default):e.minItems!==void 0?Array.from({length:e.minItems}).map(n=>Wn(e.items,t)):[]}function BB(e,t){return W(e,"default")?be(e.default):async function*(){}()}function FB(e,t){return W(e,"default")?be(e.default):BigInt(0)}function $B(e,t){return W(e,"default")?be(e.default):!1}function KB(e,t){if(W(e,"default"))return be(e.default);{let n=Wn(e.returns,t);return typeof n=="object"&&!Array.isArray(n)?class{constructor(){for(let[r,i]of Object.entries(n)){let o=this;o[r]=i}}}:class{}}}function zB(e,t){return W(e,"default")?be(e.default):e.minimumTimestamp!==void 0?new Date(e.minimumTimestamp):new Date}function HB(e,t){return W(e,"default")?be(e.default):()=>Wn(e.returns,t)}function GB(e,t){return W(e,"default")?be(e.default):e.minimum!==void 0?e.minimum:0}function qB(e,t){if(W(e,"default"))return be(e.default);{let n=e.allOf.reduce((r,i)=>{let o=Wn(i,t);return typeof o=="object"?{...r,...o}:o},{});if(!ue(e,t,n))throw new Ln(e,"Intersect produced invalid value. Consider using a default value.");return n}}function VB(e,t){return W(e,"default")?be(e.default):function*(){}()}function QB(e,t){return W(e,"default")?be(e.default):e.const}function YB(e,t){if(W(e,"default"))return be(e.default);throw new Ln(e,"Never types cannot be created. Consider using a default value.")}function JB(e,t){if(W(e,"default"))return be(e.default);throw new Ln(e,"Not types must have a default value")}function XB(e,t){return W(e,"default")?be(e.default):null}function ZB(e,t){return W(e,"default")?be(e.default):e.minimum!==void 0?e.minimum:0}function WB(e,t){if(W(e,"default"))return be(e.default);{let n=new Set(e.required),r={};for(let[i,o]of Object.entries(e.properties))n.has(i)&&(r[i]=Wn(o,t));return r}}function eF(e,t){return W(e,"default")?be(e.default):Promise.resolve(Wn(e.item,t))}function tF(e,t){let[n,r]=Object.entries(e.patternProperties)[0];if(W(e,"default"))return be(e.default);if(n===bo||n===Ui)return{};{let i=n.slice(1,n.length-1).split("|"),o={};for(let s of i)o[s]=Wn(r,t);return o}}function nF(e,t){return W(e,"default")?be(e.default):Wn(Re(e,t),t)}function rF(e,t){if(W(e,"default"))return be(e.default);throw new Ln(e,"RegExp types cannot be created. Consider using a default value.")}function iF(e,t){if(e.pattern!==void 0){if(W(e,"default"))return be(e.default);throw new Ln(e,"String types with patterns must specify a default value")}else if(e.format!==void 0){if(W(e,"default"))return be(e.default);throw new Ln(e,"String types with formats must specify a default value")}else return W(e,"default")?be(e.default):e.minLength!==void 0?Array.from({length:e.minLength}).map(()=>" ").join(""):""}function oF(e,t){return W(e,"default")?be(e.default):"value"in e?Symbol.for(e.value):Symbol()}function sF(e,t){if(W(e,"default"))return be(e.default);if(!Sf(e))throw new Ln(e,"Can only create template literals that produce a finite variants. Consider using a default value.");return Pa(e)[0]}function aF(e,t){if(lE++>hF)throw new Ln(e,"Cannot create recursive type as it appears possibly infinite. Consider using a default.");return W(e,"default")?be(e.default):Wn(Re(e,t),t)}function cF(e,t){return W(e,"default")?be(e.default):e.items===void 0?[]:Array.from({length:e.minItems}).map((n,r)=>Wn(e.items[r],t))}function uF(e,t){if(W(e,"default"))return be(e.default)}function lF(e,t){if(W(e,"default"))return be(e.default);if(e.anyOf.length===0)throw new Error("ValueCreate.Union: Cannot create Union with zero variants");return Wn(e.anyOf[0],t)}function pF(e,t){return W(e,"default")?be(e.default):e.minByteLength!==void 0?new Uint8Array(e.minByteLength):new Uint8Array(0)}function fF(e,t){return W(e,"default")?be(e.default):{}}function dF(e,t){if(W(e,"default"))return be(e.default)}function mF(e,t){if(W(e,"default"))return be(e.default);throw new Error("User defined types must specify a default value")}function Wn(e,t){let n=se(e.$id)?[...t,e]:t,r=e;switch(r[R]){case"Any":return jB(r,n);case"Array":return LB(r,n);case"AsyncIterator":return BB(r,n);case"BigInt":return FB(r,n);case"Boolean":return $B(r,n);case"Constructor":return KB(r,n);case"Date":return zB(r,n);case"Function":return HB(r,n);case"Integer":return GB(r,n);case"Intersect":return qB(r,n);case"Iterator":return VB(r,n);case"Literal":return QB(r,n);case"Never":return YB(r,n);case"Not":return JB(r,n);case"Null":return XB(r,n);case"Number":return ZB(r,n);case"Object":return WB(r,n);case"Promise":return eF(r,n);case"Record":return tF(r,n);case"Ref":return nF(r,n);case"RegExp":return rF(r,n);case"String":return iF(r,n);case"Symbol":return oF(r,n);case"TemplateLiteral":return sF(r,n);case"This":return aF(r,n);case"Tuple":return cF(r,n);case"Undefined":return uF(r,n);case"Union":return lF(r,n);case"Uint8Array":return pF(r,n);case"Unknown":return fF(r,n);case"Void":return dF(r,n);default:if(!Nn.Has(r[R]))throw new Ln(r,"Unknown type");return mF(r,n)}}var hF=512,lE=0;function pn(...e){return lE=0,e.length===2?Wn(e[0],e[1]):Wn(e[0],[])}var Qu=class extends Z{schema;constructor(t,n){super(n),this.schema=t}};function yF(e,t,n){if(e[R]==="Object"&&typeof n=="object"&&!ii(n)){let r=e,i=Object.getOwnPropertyNames(n),o=Object.entries(r.properties),[s,a]=[1/o.length,o.length];return o.reduce((c,[l,p])=>{let d=p[R]==="Literal"&&p.const===n[l]?a:0,m=ue(p,t,n[l])?s:0,y=i.includes(l)?s:0;return c+(d+m+y)},0)}else return ue(e,t,n)?1:0}function gF(e,t,n){let[r,i]=[e.anyOf[0],0];for(let o of e.anyOf){let s=yF(o,t,n);s>i&&(r=o,i=s)}return r}function bF(e,t,n){if("default"in e)return typeof n=="function"?e.default:Pe(e.default);{let r=gF(e,t,n);return Cs(r,t,n)}}function SF(e,t,n){return ue(e,t,n)?Pe(n):pn(e,t)}function xF(e,t,n){return ue(e,t,n)?n:pn(e,t)}function TF(e,t,n){if(ue(e,t,n))return Pe(n);let r=J(n)?Pe(n):pn(e,t),i=Qe(e.minItems)&&r.length<e.minItems?[...r,...Array.from({length:e.minItems-r.length},()=>null)]:r,s=(Qe(e.maxItems)&&i.length>e.maxItems?i.slice(0,e.maxItems):i).map(c=>oi(e.items,t,c));if(e.uniqueItems!==!0)return s;let a=[...new Set(s)];if(!ue(e,t,a))throw new Qu(e,"Array cast produced invalid data due to uniqueItems constraint");return a}function vF(e,t,n){if(ue(e,t,n))return pn(e,t);let r=new Set(e.returns.required||[]),i=function(){};for(let[o,s]of Object.entries(e.returns.properties))!r.has(o)&&n.prototype[o]===void 0||(i.prototype[o]=oi(s,t,n.prototype[o]));return i}function IF(e,t,n){let r=pn(e,t),i=Ae(r)&&Ae(n)?{...r,...n}:n;return ue(e,t,i)?i:pn(e,t)}function EF(e,t,n){throw new Qu(e,"Never types cannot be cast")}function wF(e,t,n){if(ue(e,t,n))return n;if(n===null||typeof n!="object")return pn(e,t);let r=new Set(e.required||[]),i={};for(let[o,s]of Object.entries(e.properties))!r.has(o)&&n[o]===void 0||(i[o]=oi(s,t,n[o]));if(typeof e.additionalProperties=="object"){let o=Object.getOwnPropertyNames(e.properties);for(let s of Object.getOwnPropertyNames(n))o.includes(s)||(i[s]=oi(e.additionalProperties,t,n[s]))}return i}function MF(e,t,n){if(ue(e,t,n))return Pe(n);if(n===null||typeof n!="object"||Array.isArray(n)||n instanceof Date)return pn(e,t);let r=Object.getOwnPropertyNames(e.patternProperties)[0],i=e.patternProperties[r],o={};for(let[s,a]of Object.entries(n))o[s]=oi(i,t,a);return o}function OF(e,t,n){return oi(Re(e,t),t,n)}function AF(e,t,n){return oi(Re(e,t),t,n)}function RF(e,t,n){return ue(e,t,n)?Pe(n):J(n)?e.items===void 0?[]:e.items.map((r,i)=>oi(r,t,n[i])):pn(e,t)}function PF(e,t,n){return ue(e,t,n)?Pe(n):bF(e,t,n)}function oi(e,t,n){let r=se(e.$id)?[...t,e]:t,i=e;switch(e[R]){case"Array":return TF(i,r,n);case"Constructor":return vF(i,r,n);case"Intersect":return IF(i,r,n);case"Never":return EF(i,r,n);case"Object":return wF(i,r,n);case"Record":return MF(i,r,n);case"Ref":return OF(i,r,n);case"This":return AF(i,r,n);case"Tuple":return RF(i,r,n);case"Union":return PF(i,r,n);case"Date":case"Symbol":case"Uint8Array":return SF(e,t,n);default:return xF(i,r,n)}}function Cs(...e){return e.length===3?oi(e[0],e[1],e[2]):oi(e[0],[],e[1])}u();u();function CF(e){return fe(e)&&e[R]!=="Unsafe"}function NF(e,t,n){return J(n)?n.map(r=>er(e.items,t,r)):n}function kF(e,t,n){let r=e.unevaluatedProperties,o=e.allOf.map(a=>er(a,t,Pe(n))).reduce((a,c)=>Ct(c)?{...a,...c}:c,{});if(!Ct(n)||!Ct(o)||!fe(r))return o;let s=Dn(e);for(let a of Object.getOwnPropertyNames(n))s.includes(a)||ue(r,t,n[a])&&(o[a]=er(r,t,n[a]));return o}function DF(e,t,n){if(!Ct(n)||J(n))return n;let r=e.additionalProperties;for(let i of Object.getOwnPropertyNames(n)){if(i in e.properties){n[i]=er(e.properties[i],t,n[i]);continue}if(fe(r)&&ue(r,t,n[i])){n[i]=er(r,t,n[i]);continue}delete n[i]}return n}function UF(e,t,n){if(!Ct(n))return n;let r=e.additionalProperties,i=Object.getOwnPropertyNames(n),[o,s]=Object.entries(e.patternProperties)[0],a=new RegExp(o);for(let c of i){if(a.test(c)){n[c]=er(s,t,n[c]);continue}if(fe(r)&&ue(r,t,n[c])){n[c]=er(r,t,n[c]);continue}delete n[c]}return n}function _F(e,t,n){return er(Re(e,t),t,n)}function jF(e,t,n){return er(Re(e,t),t,n)}function LF(e,t,n){if(!J(n))return n;if(et(e.items))return[];let r=Math.min(n.length,e.items.length);for(let i=0;i<r;i++)n[i]=er(e.items[i],t,n[i]);return n.length>r?n.slice(0,r):n}function BF(e,t,n){for(let r of e.anyOf)if(CF(r)&&ue(r,t,n))return er(r,t,n);return n}function er(e,t,n){let r=se(e.$id)?[...t,e]:t,i=e;switch(i[R]){case"Array":return NF(i,r,n);case"Intersect":return kF(i,r,n);case"Object":return DF(i,r,n);case"Record":return UF(i,r,n);case"Ref":return _F(i,r,n);case"This":return jF(i,r,n);case"Tuple":return LF(i,r,n);case"Union":return BF(i,r,n);default:return n}}function Of(...e){return e.length===3?er(e[0],e[1],e[2]):er(e[0],[],e[1])}u();u();function Af(e){return se(e)&&!isNaN(e)&&!isNaN(parseFloat(e))}function FF(e){return Tr(e)||Hr(e)||Qe(e)}function Yu(e){return e===!0||Qe(e)&&e===1||Tr(e)&&e===BigInt("1")||se(e)&&(e.toLowerCase()==="true"||e==="1")}function Ju(e){return e===!1||Qe(e)&&(e===0||Object.is(e,-0))||Tr(e)&&e===BigInt("0")||se(e)&&(e.toLowerCase()==="false"||e==="0"||e==="-0")}function $F(e){return se(e)&&/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)$/i.test(e)}function KF(e){return se(e)&&/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)?$/i.test(e)}function zF(e){return se(e)&&/^\d\d\d\d-[0-1]\d-[0-3]\dt(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)$/i.test(e)}function HF(e){return se(e)&&/^\d\d\d\d-[0-1]\d-[0-3]\dt(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)?$/i.test(e)}function GF(e){return se(e)&&/^\d\d\d\d-[0-1]\d-[0-3]\d$/i.test(e)}function qF(e,t){let n=fE(e);return n===t?n:e}function VF(e,t){let n=dE(e);return n===t?n:e}function QF(e,t){let n=pE(e);return n===t?n:e}function YF(e,t){return se(e.const)?qF(t,e.const):Qe(e.const)?VF(t,e.const):Hr(e.const)?QF(t,e.const):Pe(t)}function pE(e){return Yu(e)?!0:Ju(e)?!1:e}function JF(e){return Af(e)?BigInt(parseInt(e)):Qe(e)?BigInt(e|0):Ju(e)?BigInt(0):Yu(e)?BigInt(1):e}function fE(e){return FF(e)?e.toString():In(e)&&e.description!==void 0?e.description.toString():e}function dE(e){return Af(e)?parseFloat(e):Yu(e)?1:Ju(e)?0:e}function XF(e){return Af(e)?parseInt(e):Qe(e)?e|0:Yu(e)?1:Ju(e)?0:e}function ZF(e){return se(e)&&e.toLowerCase()==="null"?null:e}function WF(e){return se(e)&&e==="undefined"?void 0:e}function e2(e){return _n(e)?e:Qe(e)?new Date(e):Yu(e)?new Date(1):Ju(e)?new Date(0):Af(e)?new Date(parseInt(e)):KF(e)?new Date(`1970-01-01T${e}.000Z`):$F(e)?new Date(`1970-01-01T${e}`):HF(e)?new Date(`${e}.000Z`):zF(e)?new Date(e):GF(e)?new Date(`${e}T00:00:00.000Z`):e}function t2(e,t,n){return(J(n)?n:[n]).map(i=>si(e.items,t,i))}function n2(e,t,n){return JF(n)}function r2(e,t,n){return pE(n)}function i2(e,t,n){return e2(n)}function o2(e,t,n){return XF(n)}function s2(e,t,n){return e.allOf.reduce((r,i)=>si(i,t,r),n)}function a2(e,t,n){return YF(e,n)}function c2(e,t,n){return ZF(n)}function u2(e,t,n){return dE(n)}function l2(e,t,n){if(!Ct(n))return n;let i={};for(let o of Object.keys(n))i[o]=W(e.properties,o)?si(e.properties[o],t,n[o]):n[o];return i}function p2(e,t,n){let r=Object.getOwnPropertyNames(e.patternProperties)[0],i=e.patternProperties[r],o={};for(let[s,a]of Object.entries(n))o[s]=si(i,t,a);return o}function f2(e,t,n){return si(Re(e,t),t,n)}function d2(e,t,n){return fE(n)}function m2(e,t,n){return se(n)||Qe(n)?Symbol(n):n}function h2(e,t,n){return si(Re(e,t),t,n)}function y2(e,t,n){return J(n)&&!et(e.items)?n.map((i,o)=>o<e.items.length?si(e.items[o],t,i):i):n}function g2(e,t,n){return WF(n)}function b2(e,t,n){for(let r of e.anyOf){let i=si(r,t,n);if(ue(r,t,i))return i}return n}function si(e,t,n){let r=se(e.$id)?[...t,e]:t,i=e;switch(e[R]){case"Array":return t2(i,r,n);case"BigInt":return n2(i,r,n);case"Boolean":return r2(i,r,n);case"Date":return i2(i,r,n);case"Integer":return o2(i,r,n);case"Intersect":return s2(i,r,n);case"Literal":return a2(i,r,n);case"Null":return c2(i,r,n);case"Number":return u2(i,r,n);case"Object":return l2(i,r,n);case"Record":return p2(i,r,n);case"Ref":return f2(i,r,n);case"String":return d2(i,r,n);case"Symbol":return m2(i,r,n);case"This":return h2(i,r,n);case"Tuple":return y2(i,r,n);case"Undefined":return g2(i,r,n);case"Union":return b2(i,r,n);default:return n}}function Rf(...e){return e.length===3?si(e[0],e[1],e[2]):si(e[0],[],e[1])}u();u();function xo(e,t){return t===void 0&&"default"in e?Pe(e.default):t}function S2(e){return fe(e)&&e[R]!=="Unsafe"}function Pf(e){return fe(e)&&"default"in e}function x2(e,t,n){let r=xo(e,n);if(!J(r))return r;for(let i=0;i<r.length;i++)r[i]=vr(e.items,t,r[i]);return r}function T2(e,t,n){let r=xo(e,n);return e.allOf.reduce((i,o)=>{let s=vr(o,t,r);return Ct(s)?{...i,...s}:s},{})}function v2(e,t,n){let r=xo(e,n);if(!Ct(r))return r;let i=e.additionalProperties,o=Object.getOwnPropertyNames(e.properties);for(let s of o)Pf(e.properties[s])&&(r[s]=vr(e.properties[s],t,r[s]));if(!Pf(i))return r;for(let s of Object.getOwnPropertyNames(r))o.includes(s)||(r[s]=vr(i,t,r[s]));return r}function I2(e,t,n){let r=xo(e,n);if(!Ct(r))return r;let i=e.additionalProperties,[o,s]=Object.entries(e.patternProperties)[0],a=new RegExp(o);for(let c of Object.getOwnPropertyNames(r))a.test(c)&&Pf(s)&&(r[c]=vr(s,t,r[c]));if(!Pf(i))return r;for(let c of Object.getOwnPropertyNames(r))a.test(c)||(r[c]=vr(i,t,r[c]));return r}function E2(e,t,n){return vr(Re(e,t),t,xo(e,n))}function w2(e,t,n){return vr(Re(e,t),t,n)}function M2(e,t,n){let r=xo(e,n);if(!J(r)||et(e.items))return r;let[i,o]=[e.items,Math.max(e.items.length,r.length)];for(let s=0;s<o;s++)s<i.length&&(r[s]=vr(i[s],t,r[s]));return r}function O2(e,t,n){let r=xo(e,n);for(let i of e.anyOf){let o=vr(i,t,r);if(S2(i)&&ue(i,o))return o}return r}function vr(e,t,n){let r=se(e.$id)?[...t,e]:t,i=e;switch(i[R]){case"Array":return x2(i,r,n);case"Intersect":return T2(i,r,n);case"Object":return v2(i,r,n);case"Record":return I2(i,r,n);case"Ref":return E2(i,r,n);case"This":return w2(i,r,n);case"Tuple":return M2(i,r,n);case"Union":return O2(i,r,n);default:return xo(i,n)}}function Cf(...e){return e.length===3?vr(e[0],e[1],e[2]):vr(e[0],[],e[1])}u();u();u();var Ir={};Ci(Ir,{Delete:()=>R2,Format:()=>Xu,Get:()=>C2,Has:()=>P2,Set:()=>A2,ValuePointerRootDeleteError:()=>kf,ValuePointerRootSetError:()=>Nf});u();var Nf=class extends Z{value;path;update;constructor(t,n,r){super("Cannot set root value"),this.value=t,this.path=n,this.update=r}},kf=class extends Z{value;path;constructor(t,n){super("Cannot delete root value"),this.value=t,this.path=n}};function mE(e){return e.indexOf("~")===-1?e:e.replace(/~1/g,"/").replace(/~0/g,"~")}function*Xu(e){if(e==="")return;let[t,n]=[0,0];for(let r=0;r<e.length;r++)e.charAt(r)==="/"?(r===0||(n=r,yield mE(e.slice(t,n))),t=r+1):n=r;yield mE(e.slice(t))}function A2(e,t,n){if(t==="")throw new Nf(e,t,n);let[r,i,o]=[null,e,""];for(let s of Xu(t))i[s]===void 0&&(i[s]={}),r=i,i=i[s],o=s;r[o]=n}function R2(e,t){if(t==="")throw new kf(e,t);let[n,r,i]=[null,e,""];for(let o of Xu(t)){if(r[o]===void 0||r[o]===null)return;n=r,r=r[o],i=o}if(Array.isArray(n)){let o=parseInt(i);n.splice(o,1)}else delete n[i]}function P2(e,t){if(t==="")return!0;let[n,r,i]=[null,e,""];for(let o of Xu(t)){if(r[o]===void 0)return!1;n=r,r=r[o],i=o}return Object.getOwnPropertyNames(n).includes(i)}function C2(e,t){if(t==="")return e;let n=e;for(let r of Xu(t)){if(n[r]===void 0)return;n=n[r]}return n}var hE=Ne({type:oe("insert"),path:Tn(),value:Xn()}),yE=Ne({type:oe("update"),path:Tn(),value:Xn()}),gE=Ne({type:oe("delete"),path:Tn()}),N2=ve([hE,yE,gE]),Zu=class extends Z{value;constructor(t,n){super(n),this.value=t}},Ns=class extends Zu{value;constructor(t){super(t,"Cannot diff objects with symbol keys"),this.value=t}};function Wu(e,t){return{type:"update",path:e,value:t}}function bE(e,t){return{type:"insert",path:e,value:t}}function SE(e){return{type:"delete",path:e}}function*k2(e,t,n){if(!Ae(n))return yield Wu(e,n);let r=[...globalThis.Object.keys(t),...globalThis.Object.getOwnPropertySymbols(t)],i=[...globalThis.Object.keys(n),...globalThis.Object.getOwnPropertySymbols(n)];for(let o of r){if(In(o))throw new Ns(o);et(n[o])&&i.includes(o)&&(yield Wu(`${e}/${globalThis.String(o)}`,void 0))}for(let o of i)if(!(et(t[o])||et(n[o]))){if(In(o))throw new Ns(o);yield*Df(`${e}/${globalThis.String(o)}`,t[o],n[o])}for(let o of i){if(In(o))throw new Ns(o);et(t[o])&&(yield bE(`${e}/${globalThis.String(o)}`,n[o]))}for(let o of r.reverse()){if(In(o))throw new Ns(o);et(n[o])&&!i.includes(o)&&(yield SE(`${e}/${globalThis.String(o)}`))}}function*D2(e,t,n){if(!J(n))return yield Wu(e,n);for(let r=0;r<Math.min(t.length,n.length);r++)yield*Df(`${e}/${r}`,t[r],n[r]);for(let r=0;r<n.length;r++)r<t.length||(yield bE(`${e}/${r}`,n[r]));for(let r=t.length-1;r>=0;r--)r<n.length||(yield SE(`${e}/${r}`))}function*U2(e,t,n){if(!cn(n)||t.length!==n.length||globalThis.Object.getPrototypeOf(t).constructor.name!==globalThis.Object.getPrototypeOf(n).constructor.name)return yield Wu(e,n);for(let r=0;r<Math.min(t.length,n.length);r++)yield*Df(`${e}/${r}`,t[r],n[r])}function*_2(e,t,n){t!==n&&(yield Wu(e,n))}function*Df(e,t,n){if(Ae(t))return yield*k2(e,t,n);if(J(t))return yield*D2(e,t,n);if(cn(t))return yield*U2(e,t,n);if(un(t))return yield*_2(e,t,n);throw new Zu(t,"Unable to create diff edits for unknown value")}function Ig(e,t){return[...Df("",e,t)]}function j2(e){return e.length>0&&e[0].path===""&&e[0].type==="update"}function L2(e){return e.length===0}function Eg(e,t){if(j2(t))return Pe(t[0].value);if(L2(t))return Pe(e);let n=Pe(e);for(let r of t)switch(r.type){case"insert":{Ir.Set(n,r.path,r.value);break}case"update":{Ir.Set(n,r.path,r.value);break}case"delete":{Ir.Delete(n,r.path);break}}return n}u();u();function B2(e,t){if(!Ae(t))return!1;let n=[...Object.keys(e),...Object.getOwnPropertySymbols(e)],r=[...Object.keys(t),...Object.getOwnPropertySymbols(t)];return n.length!==r.length?!1:n.every(i=>To(e[i],t[i]))}function F2(e,t){return _n(t)&&e.getTime()===t.getTime()}function $2(e,t){return!J(t)||e.length!==t.length?!1:e.every((n,r)=>To(n,t[r]))}function K2(e,t){return!cn(t)||e.length!==t.length||Object.getPrototypeOf(e).constructor.name!==Object.getPrototypeOf(t).constructor.name?!1:e.every((n,r)=>To(n,t[r]))}function z2(e,t){return e===t}function To(e,t){if(Ae(e))return B2(e,t);if(_n(e))return F2(e,t);if(cn(e))return K2(e,t);if(J(e))return $2(e,t);if(un(e))return z2(e,t);throw new Error("ValueEquals: Unable to compare value")}u();u();var el=class extends Z{constructor(t){super(t)}};function H2(e,t,n,r){if(!Ae(n))Ir.Set(e,t,Pe(r));else{let i=Object.getOwnPropertyNames(n),o=Object.getOwnPropertyNames(r);for(let s of i)o.includes(s)||delete n[s];for(let s of o)i.includes(s)||(n[s]=null);for(let s of o)wg(e,`${t}/${s}`,n[s],r[s])}}function G2(e,t,n,r){if(!J(n))Ir.Set(e,t,Pe(r));else{for(let i=0;i<r.length;i++)wg(e,`${t}/${i}`,n[i],r[i]);n.splice(r.length)}}function q2(e,t,n,r){if(cn(n)&&n.length===r.length)for(let i=0;i<n.length;i++)n[i]=r[i];else Ir.Set(e,t,Pe(r))}function V2(e,t,n,r){n!==r&&Ir.Set(e,t,r)}function wg(e,t,n,r){if(J(r))return G2(e,t,n,r);if(cn(r))return q2(e,t,n,r);if(Ae(r))return H2(e,t,n,r);if(un(r))return V2(e,t,n,r)}function xE(e){return cn(e)||un(e)}function Q2(e,t){return Ae(e)&&J(t)||J(e)&&Ae(t)}function Mg(e,t){if(xE(e)||xE(t))throw new el("Only object and array types can be mutated at the root level");if(Q2(e,t))throw new el("Cannot assign due type mismatch of assignable values");wg(e,"",e,t)}u();u();var tl=class extends Z{schema;value;error;constructor(t,n,r){super("Unable to decode value as it does not match the expected schema"),this.schema=t,this.value=n,this.error=r}},Uf=class extends Z{schema;path;value;error;constructor(t,n,r,i){super(i instanceof Error?i.message:"Unknown error"),this.schema=t,this.path=n,this.value=r,this.error=i}};function st(e,t,n){try{return Ve(e)?e[mt].Decode(n):n}catch(r){throw new Uf(e,t,n,r)}}function Y2(e,t,n,r){return J(r)?st(e,n,r.map((i,o)=>ai(e.items,t,`${n}/${o}`,i))):st(e,n,r)}function J2(e,t,n,r){if(!Ae(r)||un(r))return st(e,n,r);let i=Tf(e),o=i.map(p=>p[0]),s={...r};for(let[p,d]of i)p in s&&(s[p]=ai(d,t,`${n}/${p}`,s[p]));if(!Ve(e.unevaluatedProperties))return st(e,n,s);let a=Object.getOwnPropertyNames(s),c=e.unevaluatedProperties,l={...s};for(let p of a)o.includes(p)||(l[p]=st(c,`${n}/${p}`,l[p]));return st(e,n,l)}function X2(e,t,n,r){return st(e,n,ai(e.not,t,n,r))}function Z2(e,t,n,r){if(!Ae(r))return st(e,n,r);let i=Dn(e),o={...r};for(let l of i)l in o&&(o[l]=ai(e.properties[l],t,`${n}/${l}`,o[l]));if(!fe(e.additionalProperties))return st(e,n,o);let s=Object.getOwnPropertyNames(o),a=e.additionalProperties,c={...o};for(let l of s)i.includes(l)||(c[l]=st(a,`${n}/${l}`,c[l]));return st(e,n,c)}function W2(e,t,n,r){if(!Ae(r))return st(e,n,r);let i=Object.getOwnPropertyNames(e.patternProperties)[0],o=new RegExp(i),s={...r};for(let p of Object.getOwnPropertyNames(r))o.test(p)&&(s[p]=ai(e.patternProperties[i],t,`${n}/${p}`,s[p]));if(!fe(e.additionalProperties))return st(e,n,s);let a=Object.getOwnPropertyNames(s),c=e.additionalProperties,l={...s};for(let p of a)o.test(p)||(l[p]=st(c,`${n}/${p}`,l[p]));return st(e,n,l)}function e$(e,t,n,r){let i=Re(e,t);return st(e,n,ai(i,t,n,r))}function t$(e,t,n,r){let i=Re(e,t);return st(e,n,ai(i,t,n,r))}function n$(e,t,n,r){return J(r)&&J(e.items)?st(e,n,e.items.map((i,o)=>ai(i,t,`${n}/${o}`,r[o]))):st(e,n,r)}function r$(e,t,n,r){for(let i of e.anyOf){if(!ue(i,t,r))continue;let o=ai(i,t,n,r);return st(e,n,o)}return st(e,n,r)}function ai(e,t,n,r){let i=typeof e.$id=="string"?[...t,e]:t,o=e;switch(e[R]){case"Array":return Y2(o,i,n,r);case"Intersect":return J2(o,i,n,r);case"Not":return X2(o,i,n,r);case"Object":return Z2(o,i,n,r);case"Record":return W2(o,i,n,r);case"Ref":return e$(o,i,n,r);case"Symbol":return st(o,n,r);case"This":return t$(o,i,n,r);case"Tuple":return n$(o,i,n,r);case"Union":return r$(o,i,n,r);default:return st(o,n,r)}}function Og(e,t,n){return ai(e,t,"",n)}u();var nl=class extends Z{schema;value;error;constructor(t,n,r){super("The encoded value does not match the expected schema"),this.schema=t,this.value=n,this.error=r}},_f=class extends Z{schema;path;value;error;constructor(t,n,r,i){super(`${i instanceof Error?i.message:"Unknown error"}`),this.schema=t,this.path=n,this.value=r,this.error=i}};function Kt(e,t,n){try{return Ve(e)?e[mt].Encode(n):n}catch(r){throw new _f(e,t,n,r)}}function i$(e,t,n,r){let i=Kt(e,n,r);return J(i)?i.map((o,s)=>ci(e.items,t,`${n}/${s}`,o)):i}function o$(e,t,n,r){let i=Kt(e,n,r);if(!Ae(r)||un(r))return i;let o=Tf(e),s=o.map(d=>d[0]),a={...i};for(let[d,m]of o)d in a&&(a[d]=ci(m,t,`${n}/${d}`,a[d]));if(!Ve(e.unevaluatedProperties))return Kt(e,n,a);let c=Object.getOwnPropertyNames(a),l=e.unevaluatedProperties,p={...a};for(let d of c)s.includes(d)||(p[d]=Kt(l,`${n}/${d}`,p[d]));return p}function s$(e,t,n,r){return Kt(e.not,n,Kt(e,n,r))}function a$(e,t,n,r){let i=Kt(e,n,r);if(!Ae(i))return i;let o=Dn(e),s={...i};for(let p of o)p in s&&(s[p]=ci(e.properties[p],t,`${n}/${p}`,s[p]));if(!fe(e.additionalProperties))return s;let a=Object.getOwnPropertyNames(s),c=e.additionalProperties,l={...s};for(let p of a)o.includes(p)||(l[p]=Kt(c,`${n}/${p}`,l[p]));return l}function c$(e,t,n,r){let i=Kt(e,n,r);if(!Ae(r))return i;let o=Object.getOwnPropertyNames(e.patternProperties)[0],s=new RegExp(o),a={...i};for(let d of Object.getOwnPropertyNames(r))s.test(d)&&(a[d]=ci(e.patternProperties[o],t,`${n}/${d}`,a[d]));if(!fe(e.additionalProperties))return Kt(e,n,a);let c=Object.getOwnPropertyNames(a),l=e.additionalProperties,p={...a};for(let d of c)s.test(d)||(p[d]=Kt(l,`${n}/${d}`,p[d]));return p}function u$(e,t,n,r){let i=Re(e,t),o=ci(i,t,n,r);return Kt(e,n,o)}function l$(e,t,n,r){let i=Re(e,t),o=ci(i,t,n,r);return Kt(e,n,o)}function p$(e,t,n,r){let i=Kt(e,n,r);return J(e.items)?e.items.map((o,s)=>ci(o,t,`${n}/${s}`,i[s])):[]}function f$(e,t,n,r){for(let i of e.anyOf){if(!ue(i,t,r))continue;let o=ci(i,t,n,r);return Kt(e,n,o)}for(let i of e.anyOf){let o=ci(i,t,n,r);if(ue(e,t,o))return Kt(e,n,o)}return Kt(e,n,r)}function ci(e,t,n,r){let i=typeof e.$id=="string"?[...t,e]:t,o=e;switch(e[R]){case"Array":return i$(o,i,n,r);case"Intersect":return o$(o,i,n,r);case"Not":return s$(o,i,n,r);case"Object":return a$(o,i,n,r);case"Record":return c$(o,i,n,r);case"Ref":return u$(o,i,n,r);case"This":return l$(o,i,n,r);case"Tuple":return p$(o,i,n,r);case"Union":return f$(o,i,n,r);default:return Kt(o,n,r)}}function Ag(e,t,n){return ci(e,t,"",n)}u();function d$(e,t){return Ve(e)||zt(e.items,t)}function m$(e,t){return Ve(e)||zt(e.items,t)}function h$(e,t){return Ve(e)||zt(e.returns,t)||e.parameters.some(n=>zt(n,t))}function y$(e,t){return Ve(e)||zt(e.returns,t)||e.parameters.some(n=>zt(n,t))}function g$(e,t){return Ve(e)||Ve(e.unevaluatedProperties)||e.allOf.some(n=>zt(n,t))}function b$(e,t){return Ve(e)||zt(e.items,t)}function S$(e,t){return Ve(e)||zt(e.not,t)}function x$(e,t){return Ve(e)||Object.values(e.properties).some(n=>zt(n,t))||fe(e.additionalProperties)&&zt(e.additionalProperties,t)}function T$(e,t){return Ve(e)||zt(e.item,t)}function v$(e,t){let n=Object.getOwnPropertyNames(e.patternProperties)[0],r=e.patternProperties[n];return Ve(e)||zt(r,t)||fe(e.additionalProperties)&&Ve(e.additionalProperties)}function I$(e,t){return Ve(e)?!0:zt(Re(e,t),t)}function E$(e,t){return Ve(e)?!0:zt(Re(e,t),t)}function w$(e,t){return Ve(e)||!et(e.items)&&e.items.some(n=>zt(n,t))}function M$(e,t){return Ve(e)||e.anyOf.some(n=>zt(n,t))}function zt(e,t){let n=se(e.$id)?[...t,e]:t,r=e;if(e.$id&&Rg.has(e.$id))return!1;switch(e.$id&&Rg.add(e.$id),e[R]){case"Array":return d$(r,n);case"AsyncIterator":return m$(r,n);case"Constructor":return h$(r,n);case"Function":return y$(r,n);case"Intersect":return g$(r,n);case"Iterator":return b$(r,n);case"Not":return S$(r,n);case"Object":return x$(r,n);case"Promise":return T$(r,n);case"Record":return v$(r,n);case"Ref":return I$(r,n);case"This":return E$(r,n);case"Tuple":return w$(r,n);case"Union":return M$(r,n);default:return Ve(e)}}var Rg=new Set;function jf(e,t){return Rg.clear(),zt(e,t)}u();var ks={};Ci(ks,{Cast:()=>O$,Check:()=>Pg,Clean:()=>R$,Clone:()=>C$,Convert:()=>P$,Create:()=>A$,Decode:()=>N$,Default:()=>k$,Diff:()=>_$,Encode:()=>D$,Equal:()=>U$,Errors:()=>Cg,Hash:()=>j$,Mutate:()=>B$,Patch:()=>L$});u();function O$(...e){return Cs.apply(Cs,e)}function A$(...e){return pn.apply(pn,e)}function Pg(...e){return ue.apply(ue,e)}function R$(...e){return Of.apply(Of,e)}function P$(...e){return Rf.apply(Rf,e)}function C$(e){return Pe(e)}function N$(...e){let[t,n,r]=e.length===3?[e[0],e[1],e[2]]:[e[0],[],e[1]];if(!Pg(t,n,r))throw new tl(t,r,Cg(t,n,r).First());return jf(t,n)?Og(t,n,r):r}function k$(...e){return Cf.apply(Cf,e)}function D$(...e){let[t,n,r]=e.length===3?[e[0],e[1],e[2]]:[e[0],[],e[1]],i=jf(t,n)?Ag(t,n,r):r;if(!Pg(t,n,i))throw new nl(t,i,Cg(t,n,i).First());return i}function Cg(...e){return _a.apply(_a,e)}function U$(e,t){return To(e,t)}function _$(e,t){return Ig(e,t)}function j$(e){return Ps(e)}function L$(e,t){return Eg(e,t)}function B$(e,t){Mg(e,t)}u();u();u();var YE=Q(DE()),Uz=Q(QE()),Ba=["/","."],_z=new RegExp(`[${Ba.join("")}]`);function vo(e,t=Ba){if(!e||e.length===0)return[];if(Array.isArray(e))return e;if(t.some(r=>e===r))return[];t.some(r=>e.startsWith(r))&&(e=e.slice(1));let n=t===Ba?_z:new RegExp(`[${t.join("")}]`);return e.split(n).filter(Boolean)}function JE(e){return!e||e.length===0?"":typeof e=="string"?vo(e).join("/"):e.join("/")}function Ht(e,t,n=Ba){let r=vo(t,n);return r.length===0?e:(0,YE.default)(e,r)}u();var ol=class e{root={hasValue:!1,children:new Map};set(t,n){let r=this.root;for(let i of t){if(typeof i!="string"&&typeof i!="number")throw new Error("Key must be a string or number");r.children.has(i)||r.children.set(i,{hasValue:!1,children:new Map}),r=r.children.get(i)}r.hasValue=!0,r.value=n}get(t){let n=this.root;for(let r of t){if(!n.children.has(r))return;n=n.children.get(r)}return n.hasValue?n.value:void 0}has(t){let n=this.root;for(let r of t){if(!n.children.has(r))return!1;n=n.children.get(r)}return n.hasValue}delete(t){if(t.length===0)return this.root.hasValue?(this.root.hasValue=!1,delete this.root.value,!0):!1;let n=[],r=this.root;for(let i=0;i<t.length;i++){let o=t[i];if(!r.children.has(o))return!1;n.push({parent:r,key:o}),r=r.children.get(o)}if(!r.hasValue)return!1;if(r.hasValue=!1,delete r.value,r.children.size===0)for(let i=n.length-1;i>=0;i--){let{parent:o,key:s}=n[i],a=o.children.get(s);if(!a.hasValue&&a.children.size===0)o.children.delete(s);else break}return!0}clear(){this.root={hasValue:!1,children:new Map}}getAllPaths(){let t=[],n=(r,i)=>{r.hasValue&&t.push([...i]);for(let[o,s]of r.children)n(s,[...i,o])};return n(this.root,[]),t}entries(){let t=[],n=(r,i)=>{r.hasValue&&r.value!==void 0&&t.push([[...i],r.value]);for(let[o,s]of r.children)n(s,[...i,o])};return n(this.root,[]),t}sortedEntries(){return this.entries().sort((t,n)=>{let r=t[0].join("/"),i=n[0].join("/");return r.localeCompare(i)})}get size(){let t=0,n=r=>{r.hasValue&&t++;for(let i of r.children.values())n(i)};return n(this.root),t}equals(t,n){if(this.size!==t.size)return!1;for(let[r,i]of this.entries()){let o=t.get(r);if(o===void 0||!n(i,o,{path:r}))return!1}return!0}clone(){let t=new e;for(let[n,r]of this.entries())t.set(n,r);return t}hasSamePaths(t){let n=this.getAllPaths(),r=t.getAllPaths();if(n.length!==r.length)return!1;let i=new Set(n.map(s=>s.join("/"))),o=new Set(r.map(s=>s.join("/")));for(let s of i)if(!o.has(s))return!1;return!0}};u();u();var Ee=class{constructor(t={}){this.bufferEventsIfNoListeners=t.bufferEventsIfNoListeners??!1}bufferEventsIfNoListeners;listeners=[];addListener=(t,n={})=>{if(n.once){let r=(...i)=>(this.removeListener(r),t(...i));this.listeners.push(r)}else this.listeners.push(t);if(this.bufferedEvents.length>0){let r=this.bufferedEvents;this.bufferedEvents=[],r.forEach(i=>{this.emit(...i)})}return()=>this.removeListener(t)};removeListener=t=>{let n=this.listeners.indexOf(t);n!==-1&&this.listeners.splice(n,1)};emit=(...t)=>{if(this.bufferEventsIfNoListeners&&this.listeners.length===0){this.bufferedEvents.push(t);return}this.listeners.forEach(n=>n(...t))};bufferedEvents=[]};u();function XE(e,{delay:t,setTimeout:n=globalThis.setTimeout,clearTimeout:r=globalThis.clearTimeout}){let i=null,o,s=()=>!!i,a=()=>{i&&(r(i),i=null)},c=()=>{i&&(a(),e(...o))};function l(...d){i&&r(i),o=d,i=n(()=>{e(...o),i=null},t)}return Object.assign(l,{cancel:a,flush:c,isPending:s})}u();function Fa(e,t){if(!e||typeof e!="object")return e;if(Array.isArray(e))return e.map(r=>typeof r=="object"&&r!==null?Fa(r,t):r);let n={};for(let r in t){let i=t[r];if(i===!0)n[r]=e[r];else if(typeof i=="object"&&i!==null&&"$select"in i){let o=e[r];o&&typeof o=="object"&&(Array.isArray(o)?n[r]=o.map(s=>typeof s=="object"&&s!==null?Fa(s,i.$select):s):n[r]=Fa(o,i.$select))}}return n}u();function Ls(e,t,n,r=Ba){let i=vo(t,r);return i.length===0?n:jz(e,i,n)}function jz(e,t,n){if(!t.length)return n;if(!e||typeof e!="object")return e;let[r,...i]=t;if(Array.isArray(e)){let a=typeof r=="number"?r:parseInt(r,10);if(!Number.isInteger(a))return e;let c=e[a],l=i.length?Ls(c,i,n):n;if(c===l)return e;let p=[...e];return p[a]=l,p}let o=e[r],s=i.length?Ls(o,i,n):n;return o===s?e:{...e,[r]:s}}u();function Kg(e,t){if(!e||typeof e!="object"||Array.isArray(e))return e;let n=!1,r={...e};for(let i in t){let o=t[i],s=e[i];if(o!==void 0)if(typeof o=="object"&&o!==null&&"$set"in o&&typeof o.$set=="object"&&o.$set!==null){let a=Kg(s,o.$set);a!==s&&(r[i]=a,n=!0)}else s!==o&&(r[i]=o,n=!0)}return n?r:e}u();function ZE(e,{delay:t,setTimeout:n=globalThis.setTimeout,now:r=Date.now}){let i=null,o=0;return function(...a){let c=r(),l=c-o;i||(l>=t?(o=c,e(...a)):i=n(()=>{o=r(),e(...a),i=null},t-l))}}function WE(e,t){return e===t}var _=class e{emitter=new Ee;value;isEqual;get listeners(){return this.emitter.listeners}version=0;constructor(t,n={}){this.value=t,this.isEqual=n.isEqual??WE}listenKeys={};get=t=>Ht(this.value,t);setFn=(...t)=>{if(t.length===2){let[n,r]=t,i=vo(n),o=Ls(this.value,i,r(this.get(n)));this.set(o)}else{let[n]=t;this.set(n(this.get()))}};set=(...t)=>{if(t.length===2){let[n,r]=t,i=vo(n);if(this.isEqual(this.value,r,{path:i}))return;let o=Ls(this.value,i,r);return this.set(o)}else{let[n]=t;if(this.isEqual(this.value,n,{path:[]}))return;this.value=n,this.version++,this.emitter.emit(n)}};setProperties=t=>{this.set(Kg(this.value,t))};next=this.set;subscriptionEmitter=new Ee;subscribe=(...t)=>{if(t.length===1){let[c]=t;c(this.value);let l=this.emitter.addListener(c);return this.subscriptionEmitter.emit("add"),()=>{l(),this.subscriptionEmitter.emit("remove")}}let[n,r]=t,i=vo(n);if(i.length===0){r(this.value);let c=this.emitter.addListener(r);return this.subscriptionEmitter.emit("add"),()=>{c(),this.subscriptionEmitter.emit("remove")}}let o=JE(i),s=this.get(n);r(s),this.listenKeys[o]=this.listenKeys[o]??{prev:s,version:this.version,callbacks:[]},this.listenKeys[o].callbacks.push(r);let a=this.emitter.addListener(()=>{let c=this.listenKeys[o].prev,l=this.get(n);this.listenKeys[o].version!==this.version&&!this.isEqual(l,c,{path:i})&&(this.listenKeys[o].callbacks.forEach(p=>{p(l)}),this.listenKeys[o].prev=l)});return this.subscriptionEmitter.emit("add"),()=>{a(),this.subscriptionEmitter.emit("remove"),this.listenKeys[o].callbacks=this.listenKeys[o].callbacks.filter(c=>c!==r),this.listenKeys[o].callbacks.length===0&&delete this.listenKeys[o]}};static from(t,n){let r=new e(t.get(),n);return t.subscribe(()=>{r.set(t.get())}),r}map(t,n){return e.from({get:()=>t(this.get()),subscribe:this.subscribe},n)}select(t,n){let r=new e(Fa(this.get(),t),n),i=n?.isEqual??WE,o=(p,d=[],m)=>{let y=[],S=m??this.get(d);if(d.length===0&&Array.isArray(S)){for(let T=0;T<S.length;T++){let E=o(p,[T],S[T]);y.push(...E)}return y}for(let T in p){let E=p[T],b=[...d,T],f=S?.[T];if(E===!0)y.push(b);else if(typeof E=="object"&&E!==null&&"$select"in E)if(Array.isArray(f))for(let g=0;g<f.length;g++){let v=o(E.$select,[...b,g],f[g]);y.push(...v)}else{let g=o(E.$select,b,f);y.push(...g)}}return y},s=null,a=new ol,c=()=>{let p=new ol,d=o(t);for(let m of d){let y=this.get(m);p.set(m,y)}return p};return(()=>{s||(a=c(),s=this.subscribe(()=>{let p=c();if(!p.equals(a,i)){a=p;let d=Fa(this.get(),t);r.set(d)}}))})(),r}observePath(t,n){let r=new e(this.get(t),n);return this.subscribe(t,i=>{r.set(i)}),r}readOnly(){return e.from({get:()=>this.get(),subscribe:this.subscribe},{isEqual:this.isEqual})}waitFor(t){return this.isEqual(this.value,t,{path:[]})?Promise.resolve():new Promise(n=>{this.emitter.addListener(r=>{this.isEqual(r,t,{path:[]})&&n()})})}throttle(t,n){let r=new e(this.get(),n),o=ZE(()=>{r.set(this.get())},typeof t=="number"?{delay:t}:t);return this.subscribe(()=>{o()}),r}debounce(t,n){let r=new zg(this.get(),n),o=XE(()=>{r.set(this.get())},typeof t=="number"?{delay:t}:t);r.cancel=o.cancel,r.flush=o.flush,r.isPending=o.isPending;let s=!1;return this.subscribe(()=>{s?o():(s=!0,r.set(this.get()))}),r}static combine(t,n,r){return e.from({get:()=>n(t.map(i=>i?.get())),subscribe:i=>{t.forEach(o=>o?.subscribe(i))}},r)}},zg=class extends _{cancel=()=>{};flush=()=>{};isPending=()=>!1};var sl=class{constructor(t){this.sendMessage=t}activityEventStreams={};subscribe(t){let n=t==="all"?"all":`resource-${t.resourceId}`;if(!this.activityEventStreams[n]){this.activityEventStreams[n]={activityEvents:new _([]),isInitialized:new _(!1)};let r=void 0;this.sendMessage?.({type:"activityEvents.subscribe",streamId:n,...r&&{cursor:r}})}return n}getStream(t){return this.activityEventStreams[t]?.activityEvents}unsubscribe(t){this.sendMessage?.({type:"activityEvents.unsubscribe",streamId:t}),delete this.activityEventStreams[t]}setStreamEvents(t,n){this.activityEventStreams[t]||(this.activityEventStreams[t]={activityEvents:new _([]),isInitialized:new _(!1)});let r=this.activityEventStreams[t].activityEvents.get(),i=Lz(r,n);this.activityEventStreams[t].activityEvents.set(i),this.activityEventStreams[t].isInitialized.set(!0)}};function Lz(e,t){let n=new Map,r=i=>i&&typeof i=="object"?i.id:void 0;for(let i of[...t||[],...e||[]]){let o=r(i);typeof o=="string"&&n.set(o,i)}return Array.from(n.values())}u();u();u();u();u();var lt=e=>x.Union([x.Null(),e]);var Bz=x.Object({id:x.String(),name:lt(x.String()),email:lt(x.String()),image:lt(x.String())}),Fz=x.Object({id:x.String(),name:x.String()}),$z=x.Object({id:x.String(),name:lt(x.String())}),Kz=x.Object({id:x.String(),path:x.String(),type:x.Union([x.Literal("asset"),x.Literal("file"),x.Literal("fileVersion"),x.Literal("directory"),x.Literal("resource")])}),zz=x.Object({id:x.String(),subdomain:lt(x.String())}),Tye=x.Object({id:x.String(),createdAt:x.String(),actorId:lt(x.String()),actor:x.Optional(Bz),type:x.Union([x.Literal("file"),x.Literal("resource"),x.Literal("site"),x.Literal("snapshot"),x.Literal("restore")]),workspaceId:lt(x.String()),workspace:x.Optional(Fz),fileId:lt(x.String()),file:x.Optional($z),fileVersionId:lt(x.String()),resourceId:lt(x.String()),resource:x.Optional(Kz),siteId:lt(x.String()),site:x.Optional(zz),previousData:lt(x.Any()),currentData:lt(x.Any()),metadata:lt(x.Any()),userAgent:lt(x.String())});u();var Hz=x.Union([x.Literal("immutable"),x.Literal("mutable")]),Mye=x.Object({id:x.String(),stableId:x.String(),url:x.String(),createdAt:x.String(),size:x.Number(),contentType:x.Optional(x.String()),width:x.Union([x.Null(),x.Number()]),height:x.Union([x.Null(),x.Number()]),userId:x.Union([x.Null(),x.String()]),mode:x.Optional(Hz),version:x.Optional(x.Number())});u();var ew=new Map([[R,"_kind"],[Pn,"_hint"]]),Gz=new Map(Array.from(ew.entries()).map(([e,t])=>[t,e]));function Io(e,t=ew){function n(r){if(Array.isArray(r))return r.map(n);if(typeof r=="object"&&r!==null){let i={};for(let o in r)if(Object.prototype.hasOwnProperty.call(r,o)){let s=r[o];i[o]=n(s)}for(let o of Object.getOwnPropertySymbols(r)){let s=t.get(o);s&&(i[s]=n(r[o]))}return i}return r}return n(e)}function Eo(e,t=Gz){function n(r){if(Array.isArray(r))return r.map(n);if(typeof r=="object"&&r!==null){let i={};for(let o in r)if(Object.prototype.hasOwnProperty.call(r,o)){let s=r[o],a=t.get(o);a?i[a]=n(s):i[o]=n(s)}return i}return r}return n(e)}u();var qz=x.Union([x.Literal("utf-8"),x.Literal("base64")]),Vz=x.Object({id:x.String({format:"uuid",default:""}),kind:x.Literal("folder")}),Qz=x.Object({id:x.String({format:"uuid",default:""}),kind:x.Literal("asset"),assetId:x.String()}),Yz=x.Object({id:x.String({format:"uuid",default:""}),kind:x.Literal("file"),content:x.String(),encoding:qz}),Jz=x.Object({id:x.String({format:"uuid",default:""}),kind:x.Literal("noyaFile"),fileId:x.String()}),Xz=x.Union([Vz,Qz,Yz,Jz],{discriminator:"kind"}),Uye=x.Record(x.String(),Xz);u();var Fye=x.Object({owner:x.Optional(x.String()),name:x.Optional(x.String()),ref:x.Optional(x.String()),path:x.Optional(x.String())}),$ye=x.Object({id:x.Optional(x.String())});u();u();u();var Hf=x.Recursive(e=>x.Union([x.Object({type:x.Literal("string"),default:x.Optional(x.String()),_kind:x.Literal("String")}),x.Object({type:x.Literal("number"),default:x.Optional(x.Number()),minimum:x.Optional(x.Number()),maximum:x.Optional(x.Number()),_kind:x.Literal("Number")}),x.Object({type:x.Literal("boolean"),default:x.Optional(x.Boolean()),_kind:x.Literal("Boolean")}),x.Object({type:x.Literal("null"),_kind:x.Literal("Null")}),x.Object({type:x.Literal("array"),items:e,_kind:x.Literal("Array")}),x.Object({type:x.Literal("object"),properties:x.Record(x.String(),e),required:x.Optional(x.Array(x.String())),_kind:x.Literal("Object")})],{discriminator:"type"}),{$id:"jsonSchema"});function Gf(e){return x.Union([e,x.Null()],{default:null})}var Hg={id:x.String({format:"uuid",default:""}),stableId:x.String({format:"uuid",default:""}),name:x.String(),description:Gf(x.String()),required:x.Boolean({default:!1})},Zz=x.Object({...Hg,kind:x.Literal("file"),toolId:Gf(x.String())}),Wz=x.Object({...Hg,kind:x.Literal("data"),schema:Gf(Hf)}),eH=x.Object({...Hg,kind:x.Literal("secret"),authProvider:x.Optional(x.Union([x.Null(),x.Literal("github"),x.Literal("figma")],{default:null})),authScope:x.Optional(Gf(x.String()))}),Gg=x.Union([Zz,Wz,eH],{discriminator:"kind"}),tw={id:x.String({format:"uuid",default:""}),stableId:x.String({format:"uuid",default:""}),order:x.Number()},tH=x.Object({...tw,kind:x.Literal("script"),location:x.Union([x.Literal("state"),x.Literal("url")]),value:x.String()}),nH=x.Object({...tw,kind:x.Literal("jsonPointer"),value:x.String()}),nge=x.Union([tH,nH],{discriminator:"kind"});u();u();var Nw=Q(ad()),s3=(0,Nw.defineTree)(e=>w.IsUnion(e)?e.anyOf:w.IsObject(e)?Object.values(e.properties):w.IsArray(e)?[e.items]:[]).withOptions({getLabel(e){return e[R]??"<UnknownKind>"}});function Er(e){return e?s3.flat(e).flatMap(t=>t.$id?[t]:[]):[]}function Fs(e){return Array.isArray(e)?e:Object.values(e)}u();var Ga={id:x.String(),stableId:x.String(),path:x.String(),createdAt:x.String(),updatedAt:x.String(),accessibleByFileId:lt(x.String()),accessibleByFile:x.Optional(x.Object({id:x.String(),name:x.String(),toolId:x.String()})),accessibleByFileVersionId:lt(x.String()),url:x.Optional(x.String())},a3=x.Object({content:x.String(),contentType:x.String(),encoding:x.Union([x.Literal("utf-8"),x.Literal("base64")])}),c3=x.Object({...Ga,type:x.Literal("asset"),assetId:x.String()}),u3=x.Object({...Ga,type:x.Literal("asset"),assetId:x.Optional(x.String()),asset:x.Optional(a3)}),Dw=x.Object({...Ga,type:x.Literal("file"),fileId:x.String()}),Uw=x.Object({...Ga,type:x.Literal("directory")}),_w=x.Object({...Ga,type:x.Literal("resource"),fileId:x.String(),resourceId:x.String()}),hbe=x.Union([c3,Dw,Uw,_w],{discriminator:"type"}),ybe=x.Union([u3,Dw,Uw,_w],{discriminator:"type"});var gbe=x.Object({...Ga,type:x.Union([x.Literal("asset"),x.Literal("file"),x.Literal("directory"),x.Literal("resource")]),assetId:lt(x.String()),fileId:lt(x.String()),resourceId:lt(x.String())});function kw({oldResource:e,newResource:t,oldPath:n,newPath:r}){let i={};r!==void 0&&(n??e.path)!==r&&(i.path=r);let o=e.type==="asset"?e.assetId:void 0,s=t.type==="asset"?t.assetId:void 0;return o!==s&&(i.assetId=s),t.type==="asset"&&t.asset!==void 0&&(i.asset=t.asset),i}function l3(e,t){return new Set([...e].filter(n=>t.has(n)))}function jw(e,t,n){let r=new Map(Object.entries(e).map(([E,b])=>[b[n],E])),i=new Map(Object.entries(t).map(([E,b])=>[b[n],E])),o=new Set(Object.values(e).map(E=>E[n])),s=new Set(Object.values(t).map(E=>E[n])),a=l3(o,s),c=Object.values(t).filter(E=>!o.has(E[n])),l=Object.values(e).filter(E=>!s.has(E[n])),p=[...a].flatMap(E=>{let b=Object.values(e).find(M=>M[n]===E),f=Object.values(t).find(M=>M[n]===E);if(!b||!f)return[];let g=r.get(E),v=i.get(E),I=kw({oldResource:b,newResource:f,oldPath:g,newPath:v});return Object.keys(I).length===0?[]:[{id:E,stableId:f.stableId,...I}]}),d=new Map(l.map(E=>[E.path,E])),m=new Set,y=[];for(let E of c){let b=d.get(E.path);if(!b||b.type!==E.type||b[n]===E[n])continue;m.add(E.path);let f=kw({oldResource:b,newResource:E,oldPath:b.path,newPath:E.path});if(Object.keys(f).length===0)continue;let g=b[n];y.push({id:g,stableId:b.stableId,...f})}let S=c.filter(E=>!m.has(E.path)),T=l.filter(E=>!m.has(E.path));return{addedResources:S,removedResources:T,modifiedResources:[...p,...y]}}u();var F3=Q(Qw()),$3=Q(ad());function K3(e){return/^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$/.test(e)}Cn.Set("color",()=>!0);Cn.Set("uuid",K3);u();u();function z3(e){let t=atob(e),n=t.length,r=new Uint8Array(n);for(let i=0;i<n;i++)r[i]=t.charCodeAt(i);return r}function H3(e){let t=new Uint8Array(e),n="",r=t.byteLength;for(let i=0;i<r;i++)n+=String.fromCharCode(t[i]);return globalThis.btoa(n)}var en={encode:H3,decode:z3};u();var Qa=class{capacity;map;constructor(t){let{capacity:n}=t;if(!Number.isFinite(n)||n<=0)throw new Error("LRUCache capacity must be a positive finite number");this.capacity=Math.floor(n),this.map=new Map}get size(){return this.map.size}has(t){return this.map.has(t)}get(t){if(!this.map.has(t))return;let n=this.map.get(t);return this.map.delete(t),this.map.set(t,n),n}set(t,n){if(this.map.has(t)&&this.map.delete(t),this.map.set(t,n),this.map.size>this.capacity){let[r]=this.map.keys();r!==void 0&&this.map.delete(r)}}delete(t){return this.map.delete(t)}clear(){this.map.clear()}peek(t){return this.map.get(t)}wrap(t,n){let r=n?.key??(i=>i);return i=>{let o=r(i),s=this.get(o);if(s!==void 0||this.has(o))return s;let a=t(i);return this.set(o,a),a}}};u();u();u();u();u();u();u();u();u();function Yw(e,t,n){let r=e.get(t);return!!r&&r.has(n)}function Jw(e,t,n){let r=e.get(t);r||(r=new WeakSet,e.set(t,r)),r.add(n)}function q3(e,t,n,r,i){if(e===t)return!0;if(e.length!==t.length)return!1;if(Yw(i,e,t))return!0;Jw(i,e,t);for(let o=0;o<e.length;o++)if(!(n?wb(e[o],t[o],n,r,i):e[o]===t[o]))return!1;return!0}function V3(e,t,n,r,i){if(e===t)return!0;if(!e||!t)return!1;if(Yw(i,e,t))return!0;Jw(i,e,t);let o=Object.keys(e),s=Object.keys(t);if(r){let a=r.shouldIgnoreKey;a&&(o=o.filter(c=>!a(c,e,t)),s=s.filter(c=>!a(c,e,t)))}if(o.length!==s.length)return!1;for(let a=0;a<o.length;a++){let c=o[a];if(!Object.prototype.hasOwnProperty.call(t,c)||!(n?wb(e[c],t[c],n,r,i):e[c]===t[c]))return!1}return!0}function wb(e,t,n,r,i){let o=typeof e;if(o!==typeof t)return!1;if(o!=="object"||!e||!t)return e===t;let a=Array.isArray(e),c=Array.isArray(t);return a!==c?!1:a&&c?q3(e,t,n,r,i):V3(e,t,n,r,i)}function bd(e,t,n,r){return wb(e,t,n,r,new WeakMap)}u();function Xw(e){return Object.fromEntries(Object.entries(e).map(([t,n])=>[n,t]))}var Q3={"image/png":"png","image/jpeg":"jpg","image/webp":"webp","image/svg+xml":"svg","application/pdf":"pdf","application/zip":"zip","application/x-7z-compressed":"7z"},RSe=Xw(Q3);u();u();u();u();u();u();function Zw(e,t){let n=t?.cache,r=t?.ignoreUndefinedProperties??!1,i=new WeakSet;function o(a){return s(a).toString(16).padStart(8,"0")}function s(a){if(a===null)return wt(2166136261,110);switch(typeof a){case"boolean":{let l=wt(2166136261,98);return l=wt(l,a?49:48),l}case"number":{let l=a;if(Number.isNaN(l))return Fi(2166136261,"nNaN");if(!Number.isFinite(l))return Fi(2166136261,l>0?"nInfinity":"n-Infinity");if(Object.is(l,-0))return Fi(2166136261,"n-0");let p=wt(2166136261,110);return p=Fi(p,String(l)),p}case"string":{let l=wt(2166136261,115);return l=Fi(l,JSON.stringify(a)),l}case"undefined":return wt(2166136261,117);case"bigint":{let l=wt(2166136261,105);return l=Fi(l,a.toString()),l}case"symbol":case"function":throw new TypeError("Unsupported type for hashing");case"object":{let l=a;if(Array.isArray(l)){if(i.has(l))throw new TypeError("Cannot hash circular structure");if(n?.has(l)){let d=n.peek(l);if(d!==void 0)return parseInt(d,16)>>>0}i.add(l);try{let d=wt(2166136261,91);for(let y=0;y<l.length;y+=1){y>0&&(d=wt(d,44));let S=l[y];if(S===void 0)d=wt(d,117);else{let T=o(S);d=wt(d,104),d=Fi(d,T)}}d=wt(d,93);let m=d.toString(16).padStart(8,"0");return n?.set(l,m),d}finally{i.delete(l)}}let p=l.toJSON;if(typeof p=="function"){let d=p.call(l);if(d!==void 0)return s(d)}if(i.has(l))throw new TypeError("Cannot hash circular structure");if(n?.has(l)){let d=n.peek(l);if(d!==void 0)return parseInt(d,16)>>>0}i.add(l);try{let d=l,m=Object.keys(d).map(T=>[T,d[T]]).filter(T=>r?T[1]!==void 0:!0).sort((T,E)=>T[0]<E[0]?-1:T[0]>E[0]?1:0),y=wt(2166136261,123);for(let T=0;T<m.length;T+=1){T>0&&(y=wt(y,44));let[E,b]=m[T];if(y=wt(y,107),y=Fi(y,JSON.stringify(E)),y=wt(y,58),b===void 0)y=wt(y,117);else{let f=o(b);y=wt(y,104),y=Fi(y,f)}}y=wt(y,125);let S=y.toString(16).padStart(8,"0");return n?.set(l,S),y}finally{i.delete(l)}}default:return wt(2166136261,117)}}return o(e)}function Fi(e,t){for(let n=0;n<t.length;n+=1)e^=t.charCodeAt(n),e=Math.imul(e,16777619),e>>>=0;return e}function wt(e,t){return e^=t,e=Math.imul(e,16777619),e>>>=0,e}u();u();u();u();function Gt(e,t,n){return bd(e,t,!0,n)}u();u();u();u();u();function Ww(e){let t=new Map,n=new Map,r=0;return(...i)=>{let o="";for(let s of i)t.has(s)||t.set(s,`${r++}`),o+=t.get(s)+":";return n.has(o)||n.set(o,e(...i)),n.get(o)}}u();var yxe=Symbol("object"),gxe=Symbol("array"),bxe=Symbol("key"),Sxe=Symbol("end"),xxe=Symbol("primitive"),Txe=Symbol("argsep");u();u();u();u();u();u();u();u();u();u();u();function Mb(e){return e.slice(0,1).toUpperCase()+e.slice(1)}u();u();u();u();var Sd,Y3=new Uint8Array(16);function Ob(){if(!Sd&&(Sd=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||typeof msCrypto<"u"&&typeof msCrypto.getRandomValues=="function"&&msCrypto.getRandomValues.bind(msCrypto),!Sd))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return Sd(Y3)}u();u();u();var eM=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;function J3(e){return typeof e=="string"&&eM.test(e)}var tM=J3;var tn=[];for(xd=0;xd<256;++xd)tn.push((xd+256).toString(16).substr(1));var xd;function X3(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,n=(tn[e[t+0]]+tn[e[t+1]]+tn[e[t+2]]+tn[e[t+3]]+"-"+tn[e[t+4]]+tn[e[t+5]]+"-"+tn[e[t+6]]+tn[e[t+7]]+"-"+tn[e[t+8]]+tn[e[t+9]]+"-"+tn[e[t+10]]+tn[e[t+11]]+tn[e[t+12]]+tn[e[t+13]]+tn[e[t+14]]+tn[e[t+15]]).toLowerCase();if(!tM(n))throw TypeError("Stringified UUID is invalid");return n}var nM=X3;u();function Z3(e,t,n){e=e||{};var r=e.random||(e.rng||Ob)();if(r[6]=r[6]&15|64,r[8]=r[8]&63|128,t){n=n||0;for(var i=0;i<16;++i)t[n+i]=r[i];return t}return nM(r)}var Ab=Z3;function te(){return Ab()}u();var fl=class{constructor(t){this.rpcManager=t;this.fetch=this.createFetch()}invocationEmitter=new Ee;responseEmitter=new Ee;tools$=new _([]);systemMessage$=new _(void 0);documentState$=new _(void 0);documentSchema$=new _(void 0);callableTools$=this.tools$.map(t=>Object.fromEntries(t.map(({functionName:n,description:r,parameters:i})=>[n,{description:r,parameters:i}])));configuration$=_.combine([this.callableTools$,this.systemMessage$],([t,n])=>({tools:t,systemMessage:n}),{isEqual:Gt});get callableTools(){return this.callableTools$.get()}createFetch(){return async(t,n)=>{let{readable:r,writable:i}=new TransformStream,o=i.getWriter();return this.rpcManager.requestStreamingRoute("POST /api/ai",{body:n?.body?.toString(),headers:n?.headers?Object.fromEntries(new Headers(n.headers).entries()):void 0,onStreamChunk:async a=>{await o.write(new TextEncoder().encode(a))},onStreamEnd:async()=>{await o.close()}}).then(async()=>{},async a=>{await o.abort(a)}),new Response(r,{status:200,statusText:"OK",headers:new Headers({"content-type":"text/plain; charset=utf-8"})})}}fetch;registerTool(t){return this.tools$.set([...this.tools$.get(),t]),()=>this.unregisterTool(t.functionName)}unregisterTool(t){this.tools$.set(this.tools$.get().filter(n=>n.functionName!==t))}callTool(t){let n=this.tools$.get().find(r=>r.functionName===t.name);if(!n){console.error(`Tool ${t.name} not found`);return}return n.onCall(t.parameters)}async requestGenerationStream(t,n,r){let i="",o,s,a=l=>{if(!l.trim())return;let p=JSON.parse(l);if(p.type==="error")o=p.error;else if(p.type==="text-delta"||p.type==="partial-object"||p.type==="object"||p.type==="text")r(p);else throw new Error("AI returned an unexpected stream event")},c=(l=!1)=>{let p=i.split(`
16
+ `);i=p.pop()??"",l&&i.trim()&&(p.push(i),i="");for(let d of p)a(d)};if(await this.rpcManager.requestStreamingRoute(t,{body:JSON.stringify(n),headers:{"Content-Type":"application/json"},onStreamChunk:l=>{if(!s)try{i+=l,c()}catch(p){s=p instanceof Error?p:new Error("AI returned invalid stream data")}},onStreamEnd:async()=>{if(!s)try{c(!0)}catch(l){s=l instanceof Error?l:new Error("AI returned invalid stream data")}}}),s)throw s;if(o)throw new Error(o)}async generateObject(t){let{prompt:n,schema:r,system:i,images:o=[],model:s}=t;pl(n,s);let a=Td(t),c={prompt:n,schema:r,encodedSchema:Io(r),...a,...i?{system:i}:{},...s?{model:s}:{},...o.length?{images:await Promise.all(o.map(Id))}:{}},l=await this.rpcManager.requestRoute("POST /api/ai/generate",{body:JSON.stringify(c),headers:{"Content-Type":"application/json"}}),p=this.rpcManager.getResponseBody(l);if(!p||!("object"in p))throw new Error("AI returned an unexpected response");return rM(r,p.object)}streamObject(t){let{prompt:n,schema:r,system:i,images:o=[],model:s}=t;pl(n,s);let a=Td(t),c=iM(),l=Promise.withResolvers();return(async()=>{try{let p={prompt:n,schema:r,encodedSchema:Io(r),stream:!0,...a,...i?{system:i}:{},...s?{model:s}:{},...o.length?{images:await Promise.all(o.map(Id))}:{}},d,m=!1;if(await this.requestGenerationStream("POST /api/ai/generate",p,S=>{if(S.type==="partial-object")c.push(S.object);else if(S.type==="object")d=S.object,m=!0;else throw new Error("AI returned an unexpected object stream event")}),!m)throw new Error("AI returned no result in its object stream");let y=rM(r,d);c.end(),l.resolve(y)}catch(p){let d=oM(p);c.fail(d),l.reject(d)}})(),{partialObjectStream:c.iterable,object:l.promise}}async generateText(t){let{prompt:n,system:r,images:i=[],model:o}=t;pl(n,o);let s=Td(t),a={prompt:n,...s,...r?{system:r}:{},...o?{model:o}:{},...i.length?{images:await Promise.all(i.map(Id))}:{}},c=await this.rpcManager.requestRoute("POST /api/ai/generate/text",{body:JSON.stringify(a),headers:{"Content-Type":"application/json"}}),l=this.rpcManager.getResponseBody(c);if(!l||typeof l.text!="string")throw new Error("AI returned an unexpected text response");return l.text}streamText(t){let{prompt:n,system:r,images:i=[],model:o}=t;pl(n,o);let s=Td(t),a=iM(),c=Promise.withResolvers();return(async()=>{try{let l={prompt:n,stream:!0,...s,...r?{system:r}:{},...o?{model:o}:{},...i.length?{images:await Promise.all(i.map(Id))}:{}},p;if(await this.requestGenerationStream("POST /api/ai/generate/text",l,d=>{if(d.type==="text-delta")a.push(d.textDelta);else if(d.type==="text")p=d.text;else throw new Error("AI returned an unexpected text stream event")}),p===void 0)throw new Error("AI returned no result in its text stream");a.end(),c.resolve(p)}catch(l){let p=oM(l);a.fail(p),c.reject(p)}})(),{textStream:a.iterable,text:c.promise}}async generateImage({prompt:t,model:n}){pl(t,n);let r={prompt:t,...n?{model:n}:{}},i=await this.rpcManager.requestRoute("POST /api/ai/generate/image",{body:JSON.stringify(r),headers:{"Content-Type":"application/json"}}),o=this.rpcManager.getResponseBody(i);if(!o||typeof o.base64!="string"||typeof o.mediaType!="string")throw new Error("AI returned an unexpected image response");return{data:en.decode(o.base64),mediaType:o.mediaType}}};function rM(e,t){if(!ks.Check(e,t)){let n=[...ks.Errors(e,t)].map(({path:r,message:i})=>`${r||"/"}: ${i}`).join(", ");throw new Error(`AI response does not match the requested schema: ${n}`)}return t}function iM(){let e=[],t=!1,n,r,i=()=>{r?.(),r=void 0},o=async()=>{if(e.length>0)return{done:!1,value:e.shift()};if(n)throw n;return t?{done:!0,value:void 0}:(await new Promise(a=>{r=a}),o())};return{iterable:{[Symbol.asyncIterator](){return{next:o}}},push(a){t||n||(e.push(a),i())},end(){t=!0,i()},fail(a){n=a,i()}}}function oM(e){return e instanceof Error?e:new Error(String(e))}function Td(e){if(vd(e.temperature,"temperature",0,1),vd(e.topP,"topP",0,1),vd(e.presencePenalty,"presencePenalty",-1,1),vd(e.frequencyPenalty,"frequencyPenalty",-1,1),e.topK!==void 0&&(!Number.isSafeInteger(e.topK)||e.topK<=0))throw new Error("AI topK must be a positive integer");if(e.seed!==void 0&&!Number.isSafeInteger(e.seed))throw new Error("AI seed must be an integer");return{temperature:e.temperature,topP:e.topP,topK:e.topK,presencePenalty:e.presencePenalty,frequencyPenalty:e.frequencyPenalty,seed:e.seed}}function vd(e,t,n,r){if(e!==void 0&&(!Number.isFinite(e)||e<n||e>r))throw new Error(`AI ${t} must be between ${n} and ${r}`)}function pl(e,t){if(!e.trim())throw new Error("AI prompt must not be empty");if(t!==void 0&&!t.trim())throw new Error("AI model must not be empty")}async function Id(e){if(e instanceof Blob)return sM(e.type),{type:"data",data:en.encode(await e.arrayBuffer()),mediaType:e.type};if("url"in e){let t=new URL(e.url).toString();if(!["http:","https:"].includes(new URL(t).protocol))throw new Error("AI image URLs must use http or https");return{type:"url",url:t}}return sM(e.mediaType),{type:"data",data:en.encode(e.data),mediaType:e.mediaType}}function sM(e){if(!e.toLowerCase().startsWith("image/"))throw new Error(`Invalid AI image media type: ${e||"(missing)"}`)}u();var dl=class{isInitialized$=new _(!1);assets$=new _([]);uploads$=new _({});_assetStore;get assetStore(){return this._assetStore}set assetStore(t){this._assetStore=t,this.fetch()}constructor(t={}){this._assetStore=t.assetStore??new Ja,t.initialAssets&&this.set(t.initialAssets)}_toNoyaAsset=t=>W3(t);set=t=>{let n=this.assets$.get(),r=Object.fromEntries(n.filter(o=>{try{return new URL(o.url).searchParams.get("token")!==null}catch{return!1}}).map(o=>[o.id,o.url])),i=t.map(o=>({...o,url:r[o.id]??o.url}));this.assets$.set(i),this.isInitialized$.set(!0)};fetch=async()=>{try{let t=await this.assetStore.list();this.set(t)}catch(t){console.warn("Failed to fetch assets. This is probably okay, they will be pushed to us later.",t)}};_withUploadProgress=async(t,n)=>{let r=te();try{return await n(i=>{this.uploads$.set({...this.uploads$.get(),[r]:{...i,name:t,id:r}})})}finally{let{[r]:i,...o}=this.uploads$.get();this.uploads$.set(o)}};create=async t=>{let n=await aM(t),{stableId:r,mode:i}=!(t instanceof Uint8Array)&&!(t instanceof File)&&!(t instanceof Blob)?{stableId:t.stableId,mode:t.mode}:{},o=await this._withUploadProgress(n.name,a=>this.assetStore.create({data:n.data,contentType:n.contentType,...r?{stableId:r}:{},...i?{mode:i}:{},onUploadProgress:a}));await this.fetch();let s=this.assets$.get().find(a=>a.id===o.id)??o;return this._toNoyaAsset(s)};delete=async t=>{let r=this.assets$.get().find(s=>s.id===t||s.stableId===t),i=r?.id??t,o=r?this._toNoyaAsset(r):void 0;return await this.assetStore.delete(i),await this.fetch(),o};update=async(t,n)=>{if(!this.assetStore.update)throw new Error("Asset store does not support updates");let o=this.assets$.get().find(l=>l.id===t||l.stableId===t)?.id??t,s=await aM(n),a=await this._withUploadProgress(s.name,l=>this.assetStore.update(o,{data:s.data,contentType:s.contentType,onUploadProgress:l}));await this.fetch();let c=this.assets$.get().find(l=>l.id===a.id)??a;return this._toNoyaAsset(c)};read=t=>{let n=this.assets$.get(),r=n.find(i=>i.stableId===t)||n.find(i=>i.id===t);return r?this._toNoyaAsset(r):void 0};getAsset=t=>this.read(t);_getServerAssetId=t=>{let n=this.assets$.get();return(n.find(i=>i.stableId===t)||n.find(i=>i.id===t))?.id};getRealAssetId=t=>this._getServerAssetId(t)};async function aM(e){return e instanceof Uint8Array?{data:e}:e instanceof File?{data:new Uint8Array(await e.arrayBuffer()),contentType:e.type,name:e.name}:e instanceof Blob?{data:new Uint8Array(await e.arrayBuffer()),contentType:e.type}:{data:e.data,contentType:e.contentType}}var cM=new WeakMap,W3=e=>{let t=cM.get(e);return t||(t={id:e.stableId,url:e.url,createdAt:e.createdAt,size:e.size,contentType:e.contentType,width:e.width??null,height:e.height??null,userId:e.userId??null,mode:e.mode,version:e.version},cM.set(e,t)),t},Ya=class{databaseName;randomId;db;constructor(t={}){this.databaseName=t.databaseName??"noya-assets",this.randomId=t.randomId??te,this.db=this._initialize(t)}async _initialize({indexedDB:t=globalThis.indexedDB}={}){let n=await new Promise((r,i)=>{let o=t.open(this.databaseName,1);o.onerror=()=>i(o.error),o.onsuccess=()=>r(o.result),o.onupgradeneeded=s=>{let a=s.target.result;a.objectStoreNames.contains("assets")||a.createObjectStore("assets",{keyPath:"id"})}});return await this._populateUrlCache(n),n}read=async t=>{let n=await this._readWithBytes(t);if(!n)return null;let{data:r,...i}=n;return{...i,url:this._getUrl(t)}};_readWithBytes=async t=>{let n=await this.db;return new Promise((r,i)=>{let a=n.transaction("assets","readonly").objectStore("assets").get(t);a.onerror=()=>i(a.error),a.onsuccess=()=>r(a.result)})};list=async()=>{let t=await this.db;return new Promise((n,r)=>{let s=t.transaction("assets","readonly").objectStore("assets").getAll();s.onerror=()=>r(s.error),s.onsuccess=()=>n(s.result.map(({data:a,...c})=>({...c,url:this._getUrl(c.id)})))})};_listWithBytes=async()=>{let t=await this.db;return this._list(t)};create=async t=>{let n=this.randomId(),r={id:n,stableId:t.stableId??te(),data:t.data,size:t.data.length,createdAt:new Date().toISOString(),contentType:t.contentType,width:null,height:null,userId:null,mode:void 0,version:void 0};return await(await this.db).transaction("assets","readwrite").objectStore("assets").put(r),this._createAssetUrl(r),{id:n,stableId:r.stableId,url:this._getUrl(n),createdAt:r.createdAt,size:r.size,contentType:r.contentType,width:r.width,height:r.height,userId:r.userId,mode:r.mode,version:r.version}};update=async(t,n)=>{let r=await this.db,i=await this._readWithBytes(t);if(!i)throw new Error(`Asset ${t} not found`);let o={...i,data:n.data,size:n.data.length,contentType:n.contentType??i.contentType,version:(i.version??0)+1};await r.transaction("assets","readwrite").objectStore("assets").put(o);let s=this._urlCache.get(t);return s&&URL.revokeObjectURL(s),this._createAssetUrl(o),{id:t,stableId:o.stableId,url:this._getUrl(t),createdAt:o.createdAt,size:o.size,contentType:o.contentType,width:o.width,height:o.height,userId:o.userId,mode:o.mode,version:o.version}};delete=async t=>{await(await this.db).transaction("assets","readwrite").objectStore("assets").delete(t)};_list=async t=>new Promise((n,r)=>{let s=t.transaction("assets","readonly").objectStore("assets").getAll();s.onerror=()=>r(s.error),s.onsuccess=()=>n(s.result)});_urlCache=new Map;_getUrl=t=>{let n=this._urlCache.get(t);if(!n)throw new Error(`URL for asset ${t} not found`);return n};_createAssetUrl(t){let n=new Blob([t.data],{...t.contentType?{type:t.contentType}:{}}),r=URL.createObjectURL(n);this._urlCache.set(t.id,r)}async _populateUrlCache(t){let n=await this._list(t);for(let r of n)this._createAssetUrl(r)}},Ja=class{assets=[];randomId;constructor(t={}){this.randomId=t.randomId??te,this.assets=t.initialAssets??[],this.assets.forEach(n=>{this._createAssetUrl(n)})}read=async t=>{let n=this.assets.find(r=>r.id===t);return n?{...n,url:this._getUrl(t)}:null};list=async()=>this.assets.map(({data:t,...n})=>({...n,url:this._getUrl(n.id)}));_listWithBytes=async()=>this.assets;create=async t=>{let n=this.randomId(),r={id:n,stableId:t.stableId??te(),data:t.data,size:t.data.length,createdAt:new Date().toISOString(),contentType:t.contentType,width:null,height:null,userId:null,mode:void 0,version:void 0};return this.assets.push(r),this._createAssetUrl(r),{id:n,stableId:r.stableId,url:this._getUrl(n),createdAt:r.createdAt,size:r.size,contentType:r.contentType,width:r.width,height:r.height,userId:r.userId,mode:r.mode,version:r.version}};update=async(t,n)=>{let r=this.assets.findIndex(a=>a.id===t);if(r===-1)throw new Error(`Asset ${t} not found`);let i=this.assets[r],o={...i,data:n.data,size:n.data.length,contentType:n.contentType??i.contentType,version:(i.version??0)+1};this.assets[r]=o;let s=this._urlCache.get(t);return s&&URL.revokeObjectURL(s),this._createAssetUrl(o),{id:t,stableId:o.stableId,url:this._getUrl(t),createdAt:o.createdAt,size:o.size,contentType:o.contentType,width:o.width,height:o.height,userId:o.userId,mode:o.mode,version:o.version}};delete=async t=>{this.assets=this.assets.filter(n=>n.id!==t)};_urlCache=new Map;_getUrl=t=>{let n=this._urlCache.get(t);if(!n)throw new Error(`URL for asset ${t} not found`);return n};_createAssetUrl(t){let n=t.contentType?new Blob([t.data],{type:t.contentType}):new Blob([t.data]),r=URL.createObjectURL(n);this._urlCache.set(t.id,r)}},$i=class{constructor(t){this.rpcManager=t}read=async t=>{let n=await this.list();return n.find(r=>r.id===t)||n.find(r=>r.stableId===t)||null};list=async()=>{let t=await this.rpcManager.requestRoute("GET /api/assets");return JSON.parse(t.body)};create=async t=>{let n=await this.rpcManager.requestRoute("POST /api/assets",{body:en.encode(t.data),headers:{...t.contentType?{"Content-Type":t.contentType}:{}},searchParams:{...t.mode?{mode:t.mode}:{}},onUploadProgress:t.onUploadProgress});return JSON.parse(n.body)};update=async(t,n)=>{let r=await this.rpcManager.requestRoute(`PUT /api/assets/${t}`,{body:en.encode(n.data),headers:{...n.contentType?{"Content-Type":n.contentType}:{}},onUploadProgress:n.onUploadProgress});return JSON.parse(r.body)};delete=async t=>{await this.rpcManager.requestRoute(`DELETE /api/assets/${t}`)}};u();u();function Rb(e,t){return t||(t=Er(e)),pn(e,Fs(t))}function ml(e,t,n){return t||(t=Er(e)),Cs(e,Fs(t),n)}function Ao(e,t,n,{debug:r=!1}={}){if(!t)return e;if(!ue(t,Fs(n),e)){let s=[..._a(t,e)].map(a=>{let{schema:c,type:l,...p}=a;return{...p}});throw r&&console.error("Schema typecheck failed",t,e),new Error(`State does not match schema:
17
17
  ${s.map(a=>JSON.stringify(a,null,2)).join(`
18
- `)}`)}return e}function uM(...e){let[t,n,r]=e;return n?ue(n,Fs(r),t):!0}function hl({schema:e,value:t,defs:n}){if(t!==void 0&&uM(t,e,n))return t;let r=ml(e,n,t);return Ao(r,e,n),r}u();var yl=class{constructor(t={}){this.options=t}events$=new _([]);addEvent(t){let r=[...this.events$.get(),t],i=this.options.maxEvents??50;this.events$.set(r.slice(-i))}getEvents(){return this.events$.get()}};u();var Ki="application/x-git-bundle";u();u();u();u();function lM(e,t){return t===void 0?["a",e]:["a",e,t]}function pM(e){return["r",e]}function Rb(e,t){return["m",e,t]}function gl(e,t,n=i=>i,r={}){if(e.length===0&&t.length===0)return[];if(e.length===0)return t.map((S,T)=>lM(S,T));if(t.length===0)return e.map((S,T)=>pM(r.removalMode==="key"?String(n(e[T])):T)).reverse();let i=e.map(n),o=t.map(n);if(e.length===t.length&&i.every((S,T)=>S===o[T]))return[];let s=[],a=new Map,c=new Map;for(let S=0;S<i.length;S++){let T=i[S];a.has(T)||a.set(T,[]),a.get(T).push(S)}for(let S=0;S<o.length;S++){let T=o[S];c.has(T)||c.set(T,[]),c.get(T).push(S)}let l=new Set,p=new Set;for(let S=0;S<t.length;S++){let T=o[S],E=a.get(T)?.filter(b=>!l.has(b))||[];if(E.length>0){let b=E[0];l.add(b),p.add(S)}}let d=0;for(let S=0;S<e.length;S++)l.has(S)||(s.push(pM(r.removalMode==="key"?String(i[S]):S-d)),d++);let m=e.length-d;for(let S=0;S<t.length;S++)if(!p.has(S)){let T=t[S];s.push(lM(T,S)),m++}let y=e4(e,t,i,o,l,p,n);return s.push(...y),s}function e4(e,t,n,r,i,o,s){let a=[],c=[];for(let m=0;m<e.length;m++)i.has(m)&&(a.push(e[m]),c.push(n[m]));for(let m=0;m<t.length;m++)if(!o.has(m)){let y=t[m];a.splice(m,0,y),c.splice(m,0,r[m])}let l=[];for(let m=0;m<t.length;m++){let y=r[m],S=-1;for(let T=m;T<a.length;T++)if(s(a[T])===y){S=T;break}if(S>m){l.push({from:S,to:m});let[T]=a.splice(S,1);a.splice(m,0,T);let[E]=c.splice(S,1);c.splice(m,0,E)}}if(l.length===0)return[];if(l.length===1)return[Rb(l[0].from,l[0].to)];let p=[...l].sort((m,y)=>m.to-y.to),d=!0;for(let m=0;m<p.length;m++)if(p[m].from!==m+1||p[m].to!==m){d=!1;break}return d?[Rb(0,p.length)]:l.map(m=>Rb(m.from,m.to))}function Ed(e,t){let n=[];for(let r=0;r<e;r++)n[r]=r;for(let r of t)switch(r[0]){case"a":r.length===3?n.splice(r[2],0,null):n.push(null);break;case"r":let i=typeof r[1]=="number"?r[1]:n.findIndex((a,c)=>c===r[1]);i>=0&&i<n.length&&n.splice(i,1);break;case"m":let[o,s]=[r[1],r[2]];if(o>=0&&o<n.length){let a=n[o];n.splice(o,1),n.splice(s,0,a)}break}return n}u();var yM=Symbol.for("__MUTATIVE_PROXY_DRAFT__"),t4=Symbol("__MUTATIVE_RAW_RETURN_SYMBOL__"),Md=Symbol.iterator,nr={mutable:"mutable",immutable:"immutable"};function bl(e,t){return e instanceof Map?e.has(t):Object.prototype.hasOwnProperty.call(e,t)}function fM(e,t){if(t in e){let n=Reflect.getPrototypeOf(e);for(;n;){let r=Reflect.getOwnPropertyDescriptor(n,t);if(r)return r;n=Reflect.getPrototypeOf(n)}}}function jb(e){return Object.getPrototypeOf(e)===Set.prototype}function Lb(e){return Object.getPrototypeOf(e)===Map.prototype}function tr(e){var t;return(t=e.copy)!==null&&t!==void 0?t:e.original}function Po(e){return!!de(e)}function de(e){return typeof e!="object"?null:e?.[yM]}function Bb(e){var t;let n=de(e);return n?(t=n.copy)!==null&&t!==void 0?t:n.original:e}function qr(e,t){if(!e||typeof e!="object")return!1;let n;return Object.getPrototypeOf(e)===Object.prototype||Array.isArray(e)||e instanceof Map||e instanceof Set||!!t?.mark&&((n=t.mark(e,nr))===nr.immutable||typeof n=="function")}function gM(e,t=[]){if(Object.hasOwnProperty.call(e,"key")){let n=e.parent.copy,r=de(di(n,e.key));if(r!==null&&r?.original!==e.original)return null;let i=e.parent.type===3,o=i?Array.from(e.parent.setMap.keys()).indexOf(e.key):e.key;if(!(i&&n.size>o||bl(n,o)))return null;t.push(o)}if(e.parent)return gM(e.parent,t);t.reverse();try{n4(e.copy,t)}catch{return null}return t}function fi(e){return Array.isArray(e)?1:e instanceof Map?2:e instanceof Set?3:0}function di(e,t){return fi(e)===2?e.get(t):e[t]}function xl(e,t,n){fi(e)===2?e.set(t,n):e[t]=n}function Pb(e,t){let n=de(e);return(n?tr(n):e)[t]}function zi(e,t){return e===t?e!==0||1/e===1/t:e!==e&&t!==t}function Nb(e){if(e)for(;e.finalities.revoke.length>0;)e.finalities.revoke.pop()()}function Od(e,t){return t?e:[""].concat(e).map(n=>{let r=`${n}`;return r.indexOf("/")===-1&&r.indexOf("~")===-1?r:r.replace(/~/g,"~0").replace(/\//g,"~1")}).join("/")}function Cb(e){return Array.isArray(e)?e:e.split("/").map(t=>t.replace(/~1/g,"/").replace(/~0/g,"~")).slice(1)}function n4(e,t){for(let n=0;n<t.length-1;n+=1){let r=t[n];if(e=di(fi(e)===3?Array.from(e):e,r),typeof e!="object")throw new Error(`Cannot resolve patch at '${t.join("/")}'.`)}return e}function r4(e){let t=Object.create(Object.getPrototypeOf(e));return Reflect.ownKeys(e).forEach(n=>{let r=Reflect.getOwnPropertyDescriptor(e,n);if(r.enumerable&&r.configurable&&r.writable){t[n]=e[n];return}r.writable||(r.writable=!0,r.configurable=!0),(r.get||r.set)&&(r={configurable:!0,writable:!0,enumerable:r.enumerable,value:e[n]}),Reflect.defineProperty(t,n,r)}),t}var i4=Object.prototype.propertyIsEnumerable;function bM(e,t){let n;if(Array.isArray(e))return Array.prototype.concat.call(e);if(e instanceof Set){if(!jb(e)){let r=Object.getPrototypeOf(e).constructor;return new r(e.values())}return Set.prototype.difference?Set.prototype.difference.call(e,new Set):new Set(e.values())}else if(e instanceof Map){if(!Lb(e)){let r=Object.getPrototypeOf(e).constructor;return new r(e)}return new Map(e)}else if(t?.mark&&(n=t.mark(e,nr),n!==void 0)&&n!==nr.mutable){if(n===nr.immutable)return r4(e);if(typeof n=="function"){if(t.enablePatches||t.enableAutoFreeze)throw new Error("You can't use mark and patches or auto freeze together.");return n()}throw new Error(`Unsupported mark result: ${n}`)}else if(typeof e=="object"&&Object.getPrototypeOf(e)===Object.prototype){let r={};return Object.keys(e).forEach(i=>{r[i]=e[i]}),Object.getOwnPropertySymbols(e).forEach(i=>{i4.call(e,i)&&(r[i]=e[i])}),r}else throw new Error("Please check mark() to ensure that it is a stable marker draftable function.")}function En(e){e.copy||(e.copy=bM(e.original,e.options))}function Ro(e){if(!qr(e))return Bb(e);if(Array.isArray(e))return e.map(Ro);if(e instanceof Map){let n=Array.from(e.entries()).map(([r,i])=>[r,Ro(i)]);if(!Lb(e)){let r=Object.getPrototypeOf(e).constructor;return new r(n)}return new Map(n)}if(e instanceof Set){let n=Array.from(e).map(Ro);if(!jb(e)){let r=Object.getPrototypeOf(e).constructor;return new r(n)}return new Set(n)}let t=Object.create(Object.getPrototypeOf(e));for(let n in e)t[n]=Ro(e[n]);return t}function SM(e){return Po(e)?Ro(e):e}function pi(e){var t;e.assignedMap=(t=e.assignedMap)!==null&&t!==void 0?t:new Map,e.operated||(e.operated=!0,e.parent&&pi(e.parent))}function dM(){throw new Error("Cannot modify frozen object")}function Xa(e,t,n,r,i){{n=n??new WeakMap,r=r??[],i=i??[];let s=n.has(e)?n.get(e):e;if(r.length>0){let a=r.indexOf(s);if(s&&typeof s=="object"&&a!==-1)throw r[0]===s?new Error("Forbids circular reference"):new Error(`Forbids circular reference: ~/${i.slice(0,a).map((c,l)=>{if(typeof c=="symbol")return`[${c.toString()}]`;let p=r[l];return typeof c=="object"&&(p instanceof Map||p instanceof Set)?Array.from(p.keys()).indexOf(c):c}).join("/")}`);r.push(s),i.push(t)}else r.push(s)}if(Object.isFrozen(e)||Po(e)){r.pop(),i.pop();return}switch(fi(e)){case 2:for(let[a,c]of e)Xa(a,a,n,r,i),Xa(c,a,n,r,i);e.set=e.clear=e.delete=dM;break;case 3:for(let a of e)Xa(a,a,n,r,i);e.add=e.clear=e.delete=dM;break;case 1:Object.freeze(e);let s=0;for(let a of e)Xa(a,s,n,r,i),s+=1;break;default:Object.freeze(e),Object.keys(e).forEach(a=>{let c=e[a];Xa(c,a,n,r,i)})}r.pop(),i.pop()}function Fb(e,t){let n=fi(e);if(n===0)Reflect.ownKeys(e).forEach(r=>{t(r,e[r],e)});else if(n===1){let r=0;for(let i of e)t(r,i,e),r+=1}else e.forEach((r,i)=>t(i,r,e))}function xM(e,t,n){if(Po(e)||!qr(e,n)||t.has(e)||Object.isFrozen(e))return;let r=e instanceof Set,i=r?new Map:void 0;if(t.add(e),Fb(e,(o,s)=>{var a;if(Po(s)){let c=de(s);En(c);let l=!((a=c.assignedMap)===null||a===void 0)&&a.size||c.operated?c.copy:c.original;xl(r?i:e,o,l)}else xM(s,t,n)}),i){let o=e,s=Array.from(o);o.clear(),s.forEach(a=>{o.add(i.has(a)?i.get(a):a)})}}function o4(e,t){let n=e.type===3?e.setMap:e.copy;e.finalities.revoke.length>1&&e.assignedMap.get(t)&&n&&xM(di(n,t),e.finalities.handledSet,e.options)}function kb(e){e.type===3&&e.copy&&(e.copy.clear(),e.setMap.forEach(t=>{e.copy.add(Bb(t))}))}function Db(e,t,n,r){if(e.operated&&e.assignedMap&&e.assignedMap.size>0&&!e.finalized){if(n&&r){let o=gM(e);o&&t(e,o,n,r)}e.finalized=!0}}function $b(e,t,n,r){let i=de(n);i&&(i.callbacks||(i.callbacks=[]),i.callbacks.push((o,s)=>{var a;let c=e.type===3?e.setMap:e.copy;if(zi(di(c,t),n)){let l=i.original;i.copy&&(l=i.copy),kb(e),Db(e,r,o,s),e.options.enableAutoFreeze&&(e.options.updatedValues=(a=e.options.updatedValues)!==null&&a!==void 0?a:new WeakMap,e.options.updatedValues.set(l,i.original)),xl(c,t,l)}}),e.options.enableAutoFreeze&&i.finalities!==e.finalities&&(e.options.enableAutoFreeze=!1)),qr(n,e.options)&&e.finalities.draft.push(()=>{let o=e.type===3?e.setMap:e.copy;zi(di(o,t),n)&&o4(e,t)})}function Ub(e){let{rootDraft:t,value:n,useRawReturn:r=!1,isRoot:i=!0}=e;Fb(n,(o,s,a)=>{let c=de(s);if(c&&t&&c.finalities===t.finalities){e.isContainDraft=!0;let l=c.original;if(a instanceof Set){let p=Array.from(a);a.clear(),p.forEach(d=>a.add(o===d?l:d))}else xl(a,o,l)}else typeof s=="object"&&s!==null&&(e.value=s,e.isRoot=!1,Ub(e))}),i&&(e.isContainDraft||console.warn("The return value does not contain any draft, please use 'rawReturn()' to wrap the return value to improve performance."),r&&console.warn("The return value contains drafts, please don't use 'rawReturn()' to wrap the return value."))}function TM(e){var t;let n=de(e);if(!qr(e,n?.options))return e;let r=fi(e);if(n&&!n.operated)return n.original;let i;function o(){i=r===2?Lb(e)?new Map(e):new(Object.getPrototypeOf(e)).constructor(e):r===3?Array.from(n.setMap.values()):bM(e,n?.options)}if(n){n.finalized=!0;try{o()}finally{n.finalized=!1}}else i=e;if(Fb(i,(s,a)=>{if(n&&zi(di(n.original,s),a))return;let c=TM(a);c!==a&&(i===e&&o(),xl(i,s,c))}),r===3){let s=(t=n?.original)!==null&&t!==void 0?t:i;return jb(s)?new Set(i):new(Object.getPrototypeOf(s)).constructor(i)}return i}function mM(e){if(!Po(e))throw new Error(`current() is only used for Draft, parameter: ${e}`);return TM(e)}var Le={Remove:"remove",Replace:"replace",Add:"add",Move:"move"},Kb={};function s4(e,t,n,r,i,o){let{original:s,assignedMap:a,options:c}=e,l=e.copy,p={isAssigned:d=>!!a.get(d.toString()),cloneIfNeeded:SM,concatPath:d=>{let m=t.concat([d]);return Od(m,i)},basePath:t,original:s,copy:l};if(o){let d=o(p);if(d){n.push(...d.patches),r.push(...d.inversePatches);return}}l.length<s.length&&([s,l]=[l,s],[n,r]=[r,n]);for(let d=0;d<s.length;d+=1)if(a.get(d.toString())&&l[d]!==s[d]){let m=p.concatPath(d);n.push({op:Le.Replace,path:m,value:p.cloneIfNeeded(l[d])}),r.push({op:Le.Replace,path:m,value:p.cloneIfNeeded(s[d])})}for(let d=s.length;d<l.length;d+=1){let m=p.concatPath(d);n.push({op:Le.Add,path:m,value:p.cloneIfNeeded(l[d])})}if(s.length<l.length){let{arrayLengthAssignment:d=!0}=c.enablePatches;if(d){let m=p.concatPath("length");r.push({op:Le.Replace,path:m,value:s.length})}else for(let m=l.length;s.length<m;m-=1){let y=p.concatPath(m-1);r.push({op:Le.Remove,path:y})}}}function a4({original:e,copy:t,assignedMap:n},r,i,o,s){n.forEach((a,c)=>{let l=di(e,c),p=SM(di(t,c)),d=a?bl(e,c)?Le.Replace:Le.Add:Le.Remove;if(zi(l,p)&&d===Le.Replace)return;let m=r.concat(c),y=Od(m,s);i.push(d===Le.Remove?{op:d,path:y}:{op:d,path:y,value:p}),o.push(d===Le.Add?{op:Le.Remove,path:y}:d===Le.Remove?{op:Le.Add,path:y,value:l}:{op:Le.Replace,path:y,value:l})})}function c4({original:e,copy:t},n,r,i,o){let s=0;e.forEach(a=>{if(!t.has(a)){let c=n.concat([s]),l=Od(c,o);r.push({op:Le.Remove,path:l,value:a}),i.unshift({op:Le.Add,path:l,value:a})}s+=1}),s=0,t.forEach(a=>{if(!e.has(a)){let c=n.concat([s]),l=Od(c,o);r.push({op:Le.Add,path:l,value:a}),i.unshift({op:Le.Remove,path:l,value:a})}s+=1})}function Sl(e,t,n,r){let{pathAsArray:i=!0}=e.options.enablePatches,o=e.options.createArrayPatches;switch(e.type){case 0:case 2:return a4(e,t,n,r,i);case 1:return s4(e,t,n,r,i,o);case 3:return c4(e,t,n,r,i)}}var u4=!1,Ad=(e,t,n=!1)=>{if(typeof e=="object"&&e!==null&&(!qr(e,t)||n)&&!u4)throw new Error("Strict mode: Mutable data cannot be accessed directly, please use 'unsafe(callback)' wrap.")};var _b={get size(){return tr(de(this)).size},has(e){return tr(de(this)).has(e)},set(e,t){let n=de(this),r=tr(n);return(!r.has(e)||!zi(r.get(e),t))&&(En(n),pi(n),n.assignedMap.set(e,!0),n.copy.set(e,t),$b(n,e,t,Sl)),this},delete(e){if(!this.has(e))return!1;let t=de(this);return En(t),pi(t),t.original.has(e)?t.assignedMap.set(e,!1):t.assignedMap.delete(e),t.copy.delete(e),!0},clear(){let e=de(this);if(this.size){En(e),pi(e),e.assignedMap=new Map;for(let[t]of e.original)e.assignedMap.set(t,!1);e.copy.clear()}},forEach(e,t){let n=de(this);tr(n).forEach((r,i)=>{e.call(t,this.get(i),i,this)})},get(e){var t,n;let r=de(this),i=tr(r).get(e),o=((n=(t=r.options).mark)===null||n===void 0?void 0:n.call(t,i,nr))===nr.mutable;if(r.options.strict&&Ad(i,r.options,o),o||r.finalized||!qr(i,r.options)||i!==r.original.get(e))return i;let s=Kb.createDraft({original:i,parentDraft:r,key:e,finalities:r.finalities,options:r.options});return En(r),r.copy.set(e,s),s},keys(){return tr(de(this)).keys()},values(){let e=this.keys();return{[Md]:()=>this.values(),next:()=>{let t=e.next();return t.done?t:{done:!1,value:this.get(t.value)}}}},entries(){let e=this.keys();return{[Md]:()=>this.entries(),next:()=>{let t=e.next();if(t.done)return t;let n=this.get(t.value);return{done:!1,value:[t.value,n]}}}},[Md](){return this.entries()}},l4=Reflect.ownKeys(_b),hM=(e,t,{isValuesIterator:n})=>()=>{var r,i;let o=t.next();if(o.done)return o;let s=o.value,a=e.setMap.get(s),c=de(a),l=((i=(r=e.options).mark)===null||i===void 0?void 0:i.call(r,a,nr))===nr.mutable;if(e.options.strict&&Ad(s,e.options,l),!l&&!c&&qr(s,e.options)&&!e.finalized&&e.original.has(s)){let p=Kb.createDraft({original:s,parentDraft:e,key:s,finalities:e.finalities,options:e.options});e.setMap.set(s,p),a=p}else c&&(a=c.proxy);return{done:!1,value:n?a:[a,a]}},Rd={get size(){return de(this).setMap.size},has(e){let t=de(this);if(t.setMap.has(e))return!0;En(t);let n=de(e);return!!(n&&t.setMap.has(n.original))},add(e){let t=de(this);return this.has(e)||(En(t),pi(t),t.assignedMap.set(e,!0),t.setMap.set(e,e),$b(t,e,e,Sl)),this},delete(e){if(!this.has(e))return!1;let t=de(this);En(t),pi(t);let n=de(e);return n&&t.setMap.has(n.original)?(t.assignedMap.set(n.original,!1),t.setMap.delete(n.original)):(!n&&t.setMap.has(e)?t.assignedMap.set(e,!1):t.assignedMap.delete(e),t.setMap.delete(e))},clear(){if(!this.size)return;let e=de(this);En(e),pi(e);for(let t of e.original)e.assignedMap.set(t,!1);e.setMap.clear()},values(){let e=de(this);En(e);let t=e.setMap.keys();return{[Symbol.iterator]:()=>this.values(),next:hM(e,t,{isValuesIterator:!0})}},entries(){let e=de(this);En(e);let t=e.setMap.keys();return{[Symbol.iterator]:()=>this.entries(),next:hM(e,t,{isValuesIterator:!1})}},keys(){return this.values()},[Md](){return this.values()},forEach(e,t){let n=this.values(),r=n.next();for(;!r.done;)e.call(t,r.value,r.value,this),r=n.next()}};Set.prototype.difference&&Object.assign(Rd,{intersection(e){return Set.prototype.intersection.call(new Set(this.values()),e)},union(e){return Set.prototype.union.call(new Set(this.values()),e)},difference(e){return Set.prototype.difference.call(new Set(this.values()),e)},symmetricDifference(e){return Set.prototype.symmetricDifference.call(new Set(this.values()),e)},isSubsetOf(e){return Set.prototype.isSubsetOf.call(new Set(this.values()),e)},isSupersetOf(e){return Set.prototype.isSupersetOf.call(new Set(this.values()),e)},isDisjointFrom(e){return Set.prototype.isDisjointFrom.call(new Set(this.values()),e)}});var p4=Reflect.ownKeys(Rd),vM=new WeakSet,IM={get(e,t,n){var r,i;let o=(r=e.copy)===null||r===void 0?void 0:r[t];if(o&&vM.has(o))return o;if(t===yM)return e;let s;if(e.options.mark){let l=t==="size"&&(e.original instanceof Map||e.original instanceof Set)?Reflect.get(e.original,t):Reflect.get(e.original,t,n);if(s=e.options.mark(l,nr),s===nr.mutable)return e.options.strict&&Ad(l,e.options,!0),l}let a=tr(e);if(a instanceof Map&&l4.includes(t)){if(t==="size")return Object.getOwnPropertyDescriptor(_b,"size").get.call(e.proxy);let l=_b[t];if(l)return l.bind(e.proxy)}if(a instanceof Set&&p4.includes(t)){if(t==="size")return Object.getOwnPropertyDescriptor(Rd,"size").get.call(e.proxy);let l=Rd[t];if(l)return l.bind(e.proxy)}if(!bl(a,t)){let l=fM(a,t);return l?"value"in l?l.value:(i=l.get)===null||i===void 0?void 0:i.call(e.proxy):void 0}let c=a[t];if(e.options.strict&&Ad(c,e.options),e.finalized||!qr(c,e.options))return c;if(c===Pb(e.original,t)){if(En(e),e.copy[t]=zb({original:e.original[t],parentDraft:e,key:e.type===1?Number(t):t,finalities:e.finalities,options:e.options}),typeof s=="function"){let l=de(e.copy[t]);return En(l),pi(l),l.copy}return e.copy[t]}return c},set(e,t,n){var r;if(e.type===3||e.type===2)throw new Error("Map/Set draft does not support any property assignment.");let i;if(e.type===1&&t!=="length"&&!(Number.isInteger(i=Number(t))&&i>=0&&(t===0||i===0||String(i)===String(t))))throw new Error("Only supports setting array indices and the 'length' property.");let o=fM(tr(e),t);if(o?.set)return o.set.call(e.proxy,n),!0;let s=Pb(tr(e),t),a=de(s);return a&&zi(a.original,n)?(e.copy[t]=n,e.assignedMap=(r=e.assignedMap)!==null&&r!==void 0?r:new Map,e.assignedMap.set(t,!1),!0):(zi(n,s)&&(n!==void 0||bl(e.original,t))||(En(e),pi(e),bl(e.original,t)&&zi(n,e.original[t])?e.assignedMap.delete(t):e.assignedMap.set(t,!0),e.copy[t]=n,$b(e,t,n,Sl)),!0)},has(e,t){return t in tr(e)},ownKeys(e){return Reflect.ownKeys(tr(e))},getOwnPropertyDescriptor(e,t){let n=tr(e),r=Reflect.getOwnPropertyDescriptor(n,t);return r&&{writable:!0,configurable:e.type!==1||t!=="length",enumerable:r.enumerable,value:n[t]}},getPrototypeOf(e){return Reflect.getPrototypeOf(e.original)},setPrototypeOf(){throw new Error("Cannot call 'setPrototypeOf()' on drafts")},defineProperty(){throw new Error("Cannot call 'defineProperty()' on drafts")},deleteProperty(e,t){var n;return e.type===1?IM.set.call(this,e,t,void 0,e.proxy):(Pb(e.original,t)!==void 0||t in e.original?(En(e),pi(e),e.assignedMap.set(t,!1)):(e.assignedMap=(n=e.assignedMap)!==null&&n!==void 0?n:new Map,e.assignedMap.delete(t)),e.copy&&delete e.copy[t],!0)}};function zb(e){let{original:t,parentDraft:n,key:r,finalities:i,options:o}=e,s=fi(t),a={type:s,finalized:!1,parent:n,original:t,copy:null,proxy:null,finalities:i,options:o,setMap:s===3?new Map(t.entries()):void 0};(r||"key"in e)&&(a.key=r);let{proxy:c,revoke:l}=Proxy.revocable(s===1?Object.assign([],a):a,IM);if(i.revoke.push(l),vM.add(c),a.proxy=c,n){let p=n;p.finalities.draft.push((d,m)=>{var y,S;let T=de(c),E=p.type===3?p.setMap:p.copy,b=di(E,r),f=de(b);if(f){let g=f.original;f.operated&&(g=Bb(b)),kb(f),Db(f,Sl,d,m),p.options.enableAutoFreeze&&(p.options.updatedValues=(y=p.options.updatedValues)!==null&&y!==void 0?y:new WeakMap,p.options.updatedValues.set(g,f.original)),xl(E,r,g)}(S=T.callbacks)===null||S===void 0||S.forEach(g=>{g(d,m)})})}else{let p=de(c);p.finalities.draft.push((d,m)=>{kb(p),Db(p,Sl,d,m)})}return c}Kb.createDraft=zb;function f4(e,t,n,r,i){var o;let s=de(e),a=(o=s?.original)!==null&&o!==void 0?o:e,c=!!t.length;if(s?.operated)for(;s.finalities.draft.length>0;)s.finalities.draft.pop()(n,r);let l=c?t[0]:s?s.operated?s.copy:s.original:e;return s&&Nb(s),i&&Xa(l,l,s?.options.updatedValues),[l,n&&c?[{op:Le.Replace,path:[],value:t[0]}]:n,r&&c?[{op:Le.Replace,path:[],value:a}]:r]}function d4(e,t){var n;let r={draft:[],revoke:[],handledSet:new WeakSet},i,o;t.enablePatches&&(i=[],o=[]);let a=((n=t.mark)===null||n===void 0?void 0:n.call(t,e,nr))===nr.mutable||!qr(e,t)?e:zb({original:e,parentDraft:null,finalities:r,options:t});return[a,(c=[])=>{let[l,p,d]=f4(a,c,i,o,t.enableAutoFreeze);return t.enablePatches?[l,p,d]:l}]}var m4=e=>{if(e!==void 0&&Object.prototype.toString.call(e)!=="[object Object]")throw new Error(`Invalid options: ${String(e)}, 'options' should be an object.`);return function t(n,r,i){var o,s,a;if(typeof n=="function"&&typeof r!="function")return function(I,...M){return t(I,O=>n.call(this,O,...M),r)};let c=n,l=r,p=i;if(typeof r!="function"&&(p=r),p!==void 0&&Object.prototype.toString.call(p)!=="[object Object]")throw new Error(`Invalid options: ${p}, 'options' should be an object.`);p=Object.assign(Object.assign({},e),p);let d=Po(c)?mM(c):c,m=Array.isArray(p.mark)?(I,M)=>{for(let O of p.mark){if(typeof O!="function")throw new Error(`Invalid mark: ${O}, 'mark' should be a function.`);let C=O(I,M);if(C)return C}}:p.mark,y=(o=p.enablePatches)!==null&&o!==void 0?o:!1,S=(s=p.strict)!==null&&s!==void 0?s:!1,E={enableAutoFreeze:(a=p.enableAutoFreeze)!==null&&a!==void 0?a:!1,mark:m,strict:S,enablePatches:y,createArrayPatches:p.createArrayPatches};if(!qr(d,E)&&typeof d=="object"&&d!==null)throw new Error("Invalid base state: create() only supports plain objects, arrays, Set, Map or using mark() to mark the state as immutable.");let[b,f]=d4(d,E);if(typeof r!="function"){if(!qr(d,E))throw new Error("Invalid base state: create() only supports plain objects, arrays, Set, Map or using mark() to mark the state as immutable.");return[b,f]}let g;try{g=l(b)}catch(I){throw Nb(de(b)),I}let v=I=>{let M=de(b);if(!Po(I)){if(I!==void 0&&!zi(I,b)&&M?.operated)throw new Error("Either the value is returned as a new non-draft value, or only the draft is modified without returning any value.");let C=I?.[t4];if(C){let z=C[0];return E.strict&&typeof I=="object"&&I!==null&&Ub({rootDraft:M,value:I,useRawReturn:!0}),f([z])}if(I!==void 0)return typeof I=="object"&&I!==null&&Ub({rootDraft:M,value:I}),f([I])}if(I===b||I===void 0)return f([]);let O=de(I);if(E===O.options){if(O.operated)throw new Error("Cannot return a modified child draft.");return f([mM(I)])}return f([I])};return g instanceof Promise?g.then(v,I=>{throw Nb(de(b)),I}):v(g)}},Hb=m4();function h4(e,t){var n;let r=Number(t.path[t.path.length-1]),i=(n=t.length)!==null&&n!==void 0?n:1;switch(t.op){case"add":return e.slice(0,r)+t.value+e.slice(r);case"remove":return e.slice(0,r)+e.slice(r+i);case"replace":return e.slice(0,r)+t.value+e.slice(r+i);default:return e}}function wd(e,t){let n=e;for(let r=0;r<t.length-1;r+=1){let i=fi(n),o=t[r];if(typeof o!="string"&&typeof o!="number"&&(o=String(o)),(i===0||i===1)&&(o==="__proto__"||o==="constructor")||typeof n=="function"&&o==="prototype")throw new Error("Patching reserved attributes like __proto__ and constructor is not allowed.");if(n=di(i===3?Array.from(n):n,o),typeof n!="object"&&typeof n!="string")throw new Error(`Cannot apply patch at '${t.join("/")}'.`)}return n}function EM(e,t,n){let r;for(r=t.length-1;r>=0;r-=1){let{value:o,op:s,path:a,from:c}=t[r];if(!a.length&&s===Le.Replace||a===""&&s===Le.Add){e=o;break}if(!a.length&&s===Le.Move){let l=Cb(c),p=wd(e,l),d=l[l.length-1];e=Ro(p[d]);break}}r>-1&&(t=t.slice(r+1));let i=o=>{t.forEach(s=>{let{path:a,from:c,op:l}=s,p=Cb(a),d=wd(o,p);if(typeof d=="string"){let T=p.slice(0,-1),E=wd(o,T),b=p[p.length-2];if(b===void 0)return;E[b]=h4(E[b],s);return}let m=fi(d),y=Ro(s.value),S=p[p.length-1];switch(l){case Le.Move:{let T=Cb(c),E=wd(o,T),b=T[T.length-1],f=fi(E);if(E===d&&b===S)return;let g=Ro(E[b]);if(p.length===0)return;if(E===d&&f===1&&m===1){let v=Number(b),I=Number(S);if(v<I){d.splice(v,1),d.splice(I,0,g);return}else{d.splice(I,0,g),d.splice(v+1,1);return}}switch(f){case 1:let v=Number(b);E.splice(v,1);break;case 2:E.delete(b);break;case 3:E.delete(y);break;default:{delete E[b];break}}switch(m){case 1:let v=Number(S);d.splice(v,0,g);break;case 2:d.set(S,g);break;case 3:d.add(g);break;default:{d[S]=g;break}}return}case Le.Replace:switch(m){case 2:return d.set(S,y);case 3:throw new Error("Cannot apply replace patch to set.");default:return d[S]=y}case Le.Add:switch(m){case 1:return S==="-"?d.push(y):d.splice(S,0,y);case 2:return d.set(S,y);case 3:return d.add(y);default:return d[S]=y}case Le.Remove:switch(m){case 1:return d.splice(S,1);case 2:return d.delete(S);case 3:return d.delete(s.value);default:return delete d[S]}default:throw new Error(`Unsupported patch operation: ${l}.`)}})};if(n?.mutable){Object.keys(n).filter(o=>o!=="mutable").length&&console.warn('The "mutable" option is not allowed to be used with other options.'),i(e);return}if(Po(e)){if(n!==void 0)throw new Error("Cannot apply patches with options to a draft.");return i(e),e}return Hb(e,i,Object.assign(Object.assign({},n),{enablePatches:!1}))}var Uve=Object.prototype.constructor.toString();u();var Tl=bs(ve([Tn(),Yn()])),y4=Object({op:oe("add"),path:Tl,value:Xn()}),g4=Object({op:oe("replace"),path:Tl,value:Xn()}),b4=Object({op:oe("remove"),path:Tl}),S4=Object({op:oe("move"),from:Tl,path:Tl}),Yve=ve([y4,g4,b4,S4]);function vl(e,t){return{op:"replace",path:e,value:t}}function wM(e,t){return{op:"add",path:e,value:t}}function MM(e){return{op:"remove",path:e}}function x4(e,t){return{op:"move",from:e,path:t}}function*T4(e,t,n){if(!Ae(n))return yield vl(e,n);let r=globalThis.Object.getOwnPropertyNames(t),i=globalThis.Object.getOwnPropertyNames(n);for(let o of i)W(t,o)||(yield wM([...e,o],n[o]));for(let o of r)W(n,o)&&(To(t,n)||(yield*Pd([...e,o],t[o],n[o])));for(let o of r)W(n,o)||(yield MM([...e,o]))}function v4(e){return typeof e=="object"&&e!==null&&"id"in e?e.id:e}function*I4(e,t,n){if(!J(n))return yield vl(e,n);let r=gl(t,n,v4);for(let o of r)switch(o[0]){case"a":{yield wM([...e,o[2]],o[1]);break}case"r":{yield MM([...e,o[1]]);break}case"m":{yield x4([...e,o[1]],[...e,o[2]]);break}}let i=Ed(t.length,r);for(let o=0;o<i.length;o++){let s=i[o];s!==null&&(yield*Pd([...e,o],t[s],n[o]))}}function*E4(e,t,n){if(!cn(n)||t.length!==n.length||globalThis.Object.getPrototypeOf(t).constructor.name!==globalThis.Object.getPrototypeOf(n).constructor.name)return yield vl(e,n);for(let r=0;r<Math.min(t.length,n.length);r++)yield*Pd([...e,r],t[r],n[r])}function*w4(e,t,n){t!==n&&(yield vl(e,n))}function*Pd(e,t,n){return Ae(t)?yield*T4(e,t,n):J(t)?yield*I4(e,t,n):cn(t)?yield*E4(e,t,n):un(t)?yield*w4(e,t,n):yield vl(e,n)}function Za(e,t){return[...Pd([],e,t)]}function AM(e,t){let n=Number(t.path[t.path.length-1]),r=t.length??1;switch(t.op){case"add":return e.slice(0,n)+t.value+e.slice(n);case"remove":return e.slice(0,n)+e.slice(n+r);case"replace":return e.slice(0,n)+t.value+e.slice(n+r);default:return e}}function qb(e,t){if(typeof e=="object"&&e!==null)return EM(e,t);if(typeof e=="string")return t.reduce((n,r)=>AM(n,r),e);if(typeof e=="number"&&t.length>0){let n=t[0];return n.op==="replace"?n.value:qb(e,t.slice(1))}return e}function ec(e){if(typeof e=="object"&&e!==null&&"id"in e&&(typeof e.id=="string"||typeof e.id=="number"))return e.id}function Gb(e,t,n){let r=[],i=e;for(let o=0;o<t.length;o++){let s=t[o];if(Array.isArray(i)){let a=typeof s=="number"?s:parseInt(s,10);isNaN(a)&&(a=-1);let c=i[a],l=c?ec(c):void 0,p=t[o+1]==="id",d=o===t.length-1;l!==void 0&&!p&&!(d&&n==="insert")?r.push({id:l}):r.push(a!==-1?a:s),i=c}else r.push(s),i=i[s]}return r}function Il(e,t){let n=[],r=e;for(let i=0;i<t.length;i++){let o=t[i];if(typeof o=="object"&&"id"in o)if(Array.isArray(r)){let s=r.findIndex(a=>a.id===o.id);if(s!==-1)n.push(s),r=r[s];else throw new Error(`ID ${o.id} not found in array`)}else throw new Error(`Expected array but found ${typeof r}`);else n.push(o),r=r[o]}return n}function Vr(e,t){return{op:t.op,...t.from?{from:Gb(e,t.from)}:{},path:Gb(e,t.path,t.op==="add"||t.op==="move"?"insert":void 0),..."value"in t?{value:t.value}:{}}}function RM(e,t){return{op:t.op,path:Il(e,t.path),..."value"in t?{value:t.value}:{},...t.from?{from:Il(e,t.from)}:{},...t.length?{length:t.length}:{}}}function De(e,t){for(let n of t)e=qb(e,[RM(e,n)]);return e}function Wa(e,t){let n=[];for(let r of t){let i=Vr(e,r);e=De(e,[i]),n.push(i)}return n}function Cd(e,t){let[n,r,i]=Hb(e,t,{enablePatches:!0,createArrayPatches:M4}),o=Wa(e,r),s=Wa(n,i);return[n,o,s]}function OM(e){return typeof e=="object"&&e!==null&&"id"in e?e.id:e}function M4(e){let t=gl(e.original,e.copy,OM),n=Ed(e.original.length,t),r=[],i=[];for(let l=0;l<n.length;l++){let p=n[l];if(p!==null&&e.isAssigned(p)&&e.original[p]!==e.copy[l]){let d=Za(e.original[p],e.copy[l]),m=Za(e.copy[l],e.original[p]),y=d.map(T=>({...T,path:[...e.basePath,p,...T.path]})),S=m.map(T=>({...T,path:[...e.basePath,p,...T.path]}));r.push(...y),i.push(...S)}}let o=gl(e.copy,e.original,OM);function s(l){switch(l[0]){case"a":{let[,p,d]=l;return{op:"add",path:e.concatPath(d??"~"),value:e.cloneIfNeeded(p)}}case"r":return{op:"remove",path:e.concatPath(l[1])};case"m":return{op:"move",from:e.concatPath(l[1]),path:e.concatPath(l[2])}}}let a=[...r,...t.map(s)],c=[...o.map(s),...i];return{patches:a,inversePatches:c}}var wl=Q(FM());function Jb(e,t){let n=(0,wl.default)(e,t),r=[],i=0;for(let[o,s]of n)switch(o){case wl.default.INSERT:r.push({op:"add",index:i,value:s}),i+=s.length;break;case wl.default.DELETE:r.push({op:"remove",index:i,length:s.length});break;case wl.default.EQUAL:i+=s.length;break}for(let o=0;o<r.length-1;o++){let s=r[o],a=r[o+1];s.op==="remove"&&a.op==="add"&&s.index===a.index&&r.splice(o,2,{op:"replace",index:s.index,value:a.value,length:s.length})}return r.map(({index:o,...s})=>({...s,path:[o]}))}function Qr(e,t,{useExtendedPatches:n=!1}={}){if(typeof e=="string"&&typeof t=="string")return[Jb(e,t),Jb(t,e)];let r=Za(e,t),i=Za(t,e);return n?[Wa(e,r),Wa(t,i)]:[r,i]}u();u();u();var Mr;(i=>{function e(o){let{previous:s,next:a,mergeMetadata:c}=o,l=c?c({previous:s.metadata,next:a.metadata}):a.metadata;if(!a.undoPatches||!a.redoPatches||!s.undoPatches||!s.redoPatches)return{metadata:l,undo:m=>(m=a.undo(m),m=s.undo(m),m),redo:m=>(m=s.redo(m),m=a.redo(m),m)};let p=n([...a.undoPatches,...s.undoPatches]),d=n([...s.redoPatches,...a.redoPatches]);return{metadata:l,undo:m=>De(m,p),redo:m=>De(m,d),undoPatches:p,redoPatches:d}}i.merge=e;function t(o){let{previous:s,next:a}=o;return s.op==="move"||a.op==="move"?"conflict":r(s.path,a.path)?a:"ok"}i.mergeOperations=t;function n(o){let s=[...o];for(let a=0;a<s.length;a++){let c=s[a];for(let l=a+1;l<s.length;l++){let p=s[l],d=t({previous:c,next:p});if(d==="conflict")break;if(d==="ok")continue;s[l]=d,s.splice(a,1),a--;break}}return s}i.compactPatches=n;function r(o,s){return o.length!==s.length?!1:o.every((a,c)=>{let l=s[c];return typeof a=="object"&&"id"in a&&typeof l=="object"&&"id"in l?a.id===l.id:a===l})}i.pathsEqual=r})(Mr||={});u();function Yr(e){if(Array.isArray(e))return e;if(e.length===0)return[];let t=e[0]==="/";return e.split("/").map(n=>n.replace(/~1/g,"/").replace(/~0/g,"~")).slice(t?1:0)}function Dd(e,t,n,r){let[i,o,s]=Cd(e,r);return o=Mr.compactPatches(o),s=Mr.compactPatches(s),t.allowEmptyEdits!==!0&&o.length===0&&s.length===0?void 0:{state:i,historyEntry:{undo:c=>De(c,s),redo:c=>De(c,o),undoPatches:s,redoPatches:o,metadata:n}}}function No(e,t,n,r,i){return t.allowEmptyEdits!==!0&&r.length===0&&i.length===0?void 0:{state:e,historyEntry:{undo:s=>De(s,i),redo:s=>De(s,r),undoPatches:i,redoPatches:r,metadata:n}}}var Co=class e{constructor(t){this.state=t}patches=[];inversePatches=[];getState=()=>this.state;get=t=>Ht(this.state,t);_replaceLastDashWithIndex=(t,n,r)=>{if(t.op==="remove"&&t.path[t.path.length-1]==="-"){let o=Ht(n,t.path.slice(0,-1).join("/"));if(Array.isArray(o)){let s=ec(r);s!==void 0?t.path[t.path.length-1]={id:s}:t.path[t.path.length-1]=o.length}}};set=(t,n)=>{let r=Ht(this.state,t),i=r!==void 0?{op:"replace",path:Yr(t),value:n}:{op:"add",path:Yr(t),value:n},o=r!==void 0?{op:"replace",path:Yr(t),value:r}:{op:"remove",path:Yr(t)},s=Vr(this.state,i),a=Vr(this.state,o);this._replaceLastDashWithIndex(a,this.state,n),this.patches.push(s),this.inversePatches.push(a),this.state=De(this.state,[s])};replace=this.set;add=(t,n)=>{let r={op:"add",path:Yr(t),value:n},i={op:"remove",path:Yr(t)},o=Vr(this.state,r),s=Vr(this.state,i);this._replaceLastDashWithIndex(s,this.state,n),this.patches.push(o),this.inversePatches.push(s),this.state=De(this.state,[o])};remove=t=>{let n=Ht(this.state,t),r={op:"remove",path:Yr(t)},i={op:"add",path:Yr(t),value:n},o=Vr(this.state,r),s=Vr(this.state,i);this.patches.push(o),this.inversePatches.push(s),this.state=De(this.state,[o])};delete=this.remove;static getInverseMoveIndexes({state:t,opFrom:n,opTo:r}){let i=r.slice(),o=n.slice();for(let s=0;s<Math.min(i.length,o.length);s++){let a=i[s],c=o[s],l=!1;if(t){let p=i.slice(0,s),d=o.slice(0,s),m=Ht(t,p),y=Ht(t,d);l=Array.isArray(m)&&Array.isArray(y)}else l=typeof a=="number"&&typeof c=="number";if(l)a=Number(a),c=Number(c),a<=c&&n.length>r.length&&(o[s]=c+1),a>=c&&n.length<r.length&&(i[s]=a-1);else if(a!==c)break}return{invFrom:i,invTo:o}}move=(t,n)=>{function r(m,y,S){return Ht(m,y.slice(0,-1))===Ht(m,S.slice(0,-1))}let i=[...Yr(t)],o=[...Yr(n)],s={op:"move",from:i,path:o},a=Vr(this.state,s);this.patches.push(a),this.state=De(this.state,[a]);let c=o.slice(),l=i.slice();if(!r(this.state,c,l)){let m=e.getInverseMoveIndexes({state:this.state,opFrom:i,opTo:o});c=m.invFrom,l=m.invTo}let p={op:"move",from:c,path:l},d=Vr(this.state,p);this.inversePatches.push(d)};editDraft=t=>{let[n,r,i]=Cd(this.state,t);this.patches.push(...r),this.inversePatches.unshift(...i),this.state=n}},$s=class extends Ee{constructor(n,r={}){super();this.options=r;this.state=n,this.schema=r.schema,this.getState=this.getState.bind(this),this.getHistorySnapshot=this._createVersionMemoizer(this.getHistorySnapshot)}state;schema;version=0;history=[];historyIndex$=new _(0);get historyIndex(){return this.historyIndex$.get()}set historyIndex(n){this.historyIndex$.set(n)}historyEmittor=new Ee;_setState(n){this.state=n,this.version++,this.emit(),this.historyEmittor.emit()}_setStateWithHistoryEntry(n,r,{shouldTypeCheck:i=!0}={}){if(i&&Ao(n,this.schema,Er(this.schema)),this.history.length=this.historyIndex,this.history.length>0&&this.options.mergeHistoryEntries){let o=this.options.mergeHistoryEntries({previous:this.history[this.history.length-1],next:r},this);if(o){this.history[this.history.length-1]=o,this._setState(n);return}}this.history.push(r),this.historyIndex++,this.options.maxHistoryEntries!==void 0&&this.history.length>this.options.maxHistoryEntries&&(this.history.shift(),this.historyIndex--),this._setState(n)}edit=(...n)=>{let[r,i]=n.length===1?[void 0,n[0]]:n,o=Dd(this.state,this.options,r,i);o&&this._setStateWithHistoryEntry(o.state,o.historyEntry)};operate=(...n)=>{let[r,i]=n.length===1?[void 0,n[0]]:n,o=new Co(this.getState());i(o);let s=Mr.compactPatches(o.patches),a=Mr.compactPatches(o.inversePatches),c=De(this.state,s);if(!(this.options.allowEmptyEdits!==!0&&s.length===0))return this._setStateWithHistoryEntry(c,{undo:l=>De(l,a),redo:l=>De(l,s),undoPatches:a,redoPatches:s,metadata:r}),s};performAction=(...n)=>{let[r,i]=n.length===1?[void 0,n[0]]:n;this._setStateWithHistoryEntry(i.run(this.state),{undo:i.undo,redo:i.run,metadata:r})};canUndo=()=>this.historyIndex>0;canUndo$=this.historyIndex$.map(n=>n>0);canRedo=()=>this.historyIndex<this.history.length;canRedo$=this.historyIndex$.map(n=>n<this.history.length);undo=()=>{if(!this.canUndo())return;let n=this.history[this.historyIndex-1];this.historyIndex--,this._setState(n.undo(this.state))};redo=()=>{if(!this.canRedo())return;let n=this.history[this.historyIndex];this.historyIndex++,this._setState(n.redo(this.state))};getState(n){return n===void 0?this.state:Ht(this.state,n)}clearHistory=()=>{this.history.length=0,this.historyIndex=0,this.historyEmittor.emit()};replaceState=n=>{this.clearHistory(),this._setState(n)};rebase=n=>{let r=n;for(let i=0;i<this.historyIndex;i++)r=this.history[i].redo(r);this._setState(r)};getStateAtHistoryIndex=n=>{let r=this.state;for(let i=this.historyIndex;i>n;i--)r=this.history[i-1].undo(r);return r};_rewindToIndex=(n,r)=>{let i=this.state;for(let o=this.historyIndex;o>n;o--)i=this.history[o-1].undo(i);i=r(i);for(let o=0;o<this.historyIndex;o++)i=this.history[o].redo(i);this._setState(i)};acceptPatchesAtIndex=(n,r,i)=>{let o=this.getStateAtHistoryIndex(n);o=De(o,r);for(let s=0;s<this.historyIndex;s++){if(i&&!i(this.history[s],s))continue;o=this.history[s].redo(o)}this._setState(o)};goToHistoryIndex=n=>{if(!(n<0||n>this.history.length))if(n<this.historyIndex)for(;this.historyIndex>n;)this.undo();else for(;this.historyIndex<n;)this.redo()};getHistorySnapshot=()=>({version:this.version,history:this.history.slice(),historyIndex:this.historyIndex,canUndo:this.canUndo(),canRedo:this.canRedo()});_createVersionMemoizer(n){let r,i;return(...o)=>(r!==this.version&&(i=n(...o),r=this.version),i)}};var tc=x.Array(x.Union([x.String(),x.Number()]),{description:"An exact path into the JSON document, expressed as string and number segments."}),_4=x.Union([x.Object({op:x.Literal("set"),path:tc,value:x.Any()}),x.Object({op:x.Literal("add"),path:tc,value:x.Any()}),x.Object({op:x.Literal("remove"),path:tc}),x.Object({op:x.Literal("move"),from:tc,path:tc})]),Zb=x.Object({path:x.Optional(tc)}),Wb=x.Object({operations:x.Array(_4,{minItems:1}),expectedHash:x.Optional(x.String({description:"The document hash returned by an earlier tool result. The edit is rejected if the document changed."})),summary:x.String({description:"A concise description of the requested document changes."})}),eS=x.Object({sourceCode:x.String({description:'JavaScript defining a named function "updateState(state)" which mutates state in place.'}),expectedHash:x.Optional(x.String({description:"The document hash returned by an earlier tool result. The edit is rejected if the document changed."})),summary:x.String({description:"A concise description of the requested document changes."})}),j4=2e4,L4=2e6,Ks=e=>JSON.stringify(e,(t,n)=>typeof n=="bigint"?n.toString():n);function Xb(e,t){return hl({schema:e,value:t,defs:{}})}function $M(e,t){return Ks({ok:!1,error:"The document changed since it was read. Read it again and retry.",expectedHash:e,actualHash:t})}function Ml(e){let{aiManager:t,multiplayerStateManager:n}=e,r=t.systemMessage$.get(),i=n.schema,o=["You are editing the user's current Noya document.","Inspect current values with readDocument before changing them.","Prefer applyDocumentOperations for precise changes. Use runDocumentScript only when path operations would be impractical.","Never invent paths or document structure. Use the exact JSON path segments returned by readDocument.",i&&`The document conforms to this schema:
18
+ `)}`)}return e}function uM(...e){let[t,n,r]=e;return n?ue(n,Fs(r),t):!0}function hl({schema:e,value:t,defs:n}){if(t!==void 0&&uM(t,e,n))return t;let r=ml(e,n,t);return Ao(r,e,n),r}u();var yl=class{constructor(t={}){this.options=t}events$=new _([]);addEvent(t){let r=[...this.events$.get(),t],i=this.options.maxEvents??50;this.events$.set(r.slice(-i))}getEvents(){return this.events$.get()}};u();var Ki="application/x-git-bundle";u();u();u();u();function lM(e,t){return t===void 0?["a",e]:["a",e,t]}function pM(e){return["r",e]}function Pb(e,t){return["m",e,t]}function gl(e,t,n=i=>i,r={}){if(e.length===0&&t.length===0)return[];if(e.length===0)return t.map((S,T)=>lM(S,T));if(t.length===0)return e.map((S,T)=>pM(r.removalMode==="key"?String(n(e[T])):T)).reverse();let i=e.map(n),o=t.map(n);if(e.length===t.length&&i.every((S,T)=>S===o[T]))return[];let s=[],a=new Map,c=new Map;for(let S=0;S<i.length;S++){let T=i[S];a.has(T)||a.set(T,[]),a.get(T).push(S)}for(let S=0;S<o.length;S++){let T=o[S];c.has(T)||c.set(T,[]),c.get(T).push(S)}let l=new Set,p=new Set;for(let S=0;S<t.length;S++){let T=o[S],E=a.get(T)?.filter(b=>!l.has(b))||[];if(E.length>0){let b=E[0];l.add(b),p.add(S)}}let d=0;for(let S=0;S<e.length;S++)l.has(S)||(s.push(pM(r.removalMode==="key"?String(i[S]):S-d)),d++);let m=e.length-d;for(let S=0;S<t.length;S++)if(!p.has(S)){let T=t[S];s.push(lM(T,S)),m++}let y=e4(e,t,i,o,l,p,n);return s.push(...y),s}function e4(e,t,n,r,i,o,s){let a=[],c=[];for(let m=0;m<e.length;m++)i.has(m)&&(a.push(e[m]),c.push(n[m]));for(let m=0;m<t.length;m++)if(!o.has(m)){let y=t[m];a.splice(m,0,y),c.splice(m,0,r[m])}let l=[];for(let m=0;m<t.length;m++){let y=r[m],S=-1;for(let T=m;T<a.length;T++)if(s(a[T])===y){S=T;break}if(S>m){l.push({from:S,to:m});let[T]=a.splice(S,1);a.splice(m,0,T);let[E]=c.splice(S,1);c.splice(m,0,E)}}if(l.length===0)return[];if(l.length===1)return[Pb(l[0].from,l[0].to)];let p=[...l].sort((m,y)=>m.to-y.to),d=!0;for(let m=0;m<p.length;m++)if(p[m].from!==m+1||p[m].to!==m){d=!1;break}return d?[Pb(0,p.length)]:l.map(m=>Pb(m.from,m.to))}function Ed(e,t){let n=[];for(let r=0;r<e;r++)n[r]=r;for(let r of t)switch(r[0]){case"a":r.length===3?n.splice(r[2],0,null):n.push(null);break;case"r":let i=typeof r[1]=="number"?r[1]:n.findIndex((a,c)=>c===r[1]);i>=0&&i<n.length&&n.splice(i,1);break;case"m":let[o,s]=[r[1],r[2]];if(o>=0&&o<n.length){let a=n[o];n.splice(o,1),n.splice(s,0,a)}break}return n}u();var yM=Symbol.for("__MUTATIVE_PROXY_DRAFT__"),t4=Symbol("__MUTATIVE_RAW_RETURN_SYMBOL__"),Md=Symbol.iterator,nr={mutable:"mutable",immutable:"immutable"};function bl(e,t){return e instanceof Map?e.has(t):Object.prototype.hasOwnProperty.call(e,t)}function fM(e,t){if(t in e){let n=Reflect.getPrototypeOf(e);for(;n;){let r=Reflect.getOwnPropertyDescriptor(n,t);if(r)return r;n=Reflect.getPrototypeOf(n)}}}function Lb(e){return Object.getPrototypeOf(e)===Set.prototype}function Bb(e){return Object.getPrototypeOf(e)===Map.prototype}function tr(e){var t;return(t=e.copy)!==null&&t!==void 0?t:e.original}function Po(e){return!!de(e)}function de(e){return typeof e!="object"?null:e?.[yM]}function Fb(e){var t;let n=de(e);return n?(t=n.copy)!==null&&t!==void 0?t:n.original:e}function qr(e,t){if(!e||typeof e!="object")return!1;let n;return Object.getPrototypeOf(e)===Object.prototype||Array.isArray(e)||e instanceof Map||e instanceof Set||!!t?.mark&&((n=t.mark(e,nr))===nr.immutable||typeof n=="function")}function gM(e,t=[]){if(Object.hasOwnProperty.call(e,"key")){let n=e.parent.copy,r=de(di(n,e.key));if(r!==null&&r?.original!==e.original)return null;let i=e.parent.type===3,o=i?Array.from(e.parent.setMap.keys()).indexOf(e.key):e.key;if(!(i&&n.size>o||bl(n,o)))return null;t.push(o)}if(e.parent)return gM(e.parent,t);t.reverse();try{n4(e.copy,t)}catch{return null}return t}function fi(e){return Array.isArray(e)?1:e instanceof Map?2:e instanceof Set?3:0}function di(e,t){return fi(e)===2?e.get(t):e[t]}function xl(e,t,n){fi(e)===2?e.set(t,n):e[t]=n}function Cb(e,t){let n=de(e);return(n?tr(n):e)[t]}function zi(e,t){return e===t?e!==0||1/e===1/t:e!==e&&t!==t}function kb(e){if(e)for(;e.finalities.revoke.length>0;)e.finalities.revoke.pop()()}function Od(e,t){return t?e:[""].concat(e).map(n=>{let r=`${n}`;return r.indexOf("/")===-1&&r.indexOf("~")===-1?r:r.replace(/~/g,"~0").replace(/\//g,"~1")}).join("/")}function Nb(e){return Array.isArray(e)?e:e.split("/").map(t=>t.replace(/~1/g,"/").replace(/~0/g,"~")).slice(1)}function n4(e,t){for(let n=0;n<t.length-1;n+=1){let r=t[n];if(e=di(fi(e)===3?Array.from(e):e,r),typeof e!="object")throw new Error(`Cannot resolve patch at '${t.join("/")}'.`)}return e}function r4(e){let t=Object.create(Object.getPrototypeOf(e));return Reflect.ownKeys(e).forEach(n=>{let r=Reflect.getOwnPropertyDescriptor(e,n);if(r.enumerable&&r.configurable&&r.writable){t[n]=e[n];return}r.writable||(r.writable=!0,r.configurable=!0),(r.get||r.set)&&(r={configurable:!0,writable:!0,enumerable:r.enumerable,value:e[n]}),Reflect.defineProperty(t,n,r)}),t}var i4=Object.prototype.propertyIsEnumerable;function bM(e,t){let n;if(Array.isArray(e))return Array.prototype.concat.call(e);if(e instanceof Set){if(!Lb(e)){let r=Object.getPrototypeOf(e).constructor;return new r(e.values())}return Set.prototype.difference?Set.prototype.difference.call(e,new Set):new Set(e.values())}else if(e instanceof Map){if(!Bb(e)){let r=Object.getPrototypeOf(e).constructor;return new r(e)}return new Map(e)}else if(t?.mark&&(n=t.mark(e,nr),n!==void 0)&&n!==nr.mutable){if(n===nr.immutable)return r4(e);if(typeof n=="function"){if(t.enablePatches||t.enableAutoFreeze)throw new Error("You can't use mark and patches or auto freeze together.");return n()}throw new Error(`Unsupported mark result: ${n}`)}else if(typeof e=="object"&&Object.getPrototypeOf(e)===Object.prototype){let r={};return Object.keys(e).forEach(i=>{r[i]=e[i]}),Object.getOwnPropertySymbols(e).forEach(i=>{i4.call(e,i)&&(r[i]=e[i])}),r}else throw new Error("Please check mark() to ensure that it is a stable marker draftable function.")}function En(e){e.copy||(e.copy=bM(e.original,e.options))}function Ro(e){if(!qr(e))return Fb(e);if(Array.isArray(e))return e.map(Ro);if(e instanceof Map){let n=Array.from(e.entries()).map(([r,i])=>[r,Ro(i)]);if(!Bb(e)){let r=Object.getPrototypeOf(e).constructor;return new r(n)}return new Map(n)}if(e instanceof Set){let n=Array.from(e).map(Ro);if(!Lb(e)){let r=Object.getPrototypeOf(e).constructor;return new r(n)}return new Set(n)}let t=Object.create(Object.getPrototypeOf(e));for(let n in e)t[n]=Ro(e[n]);return t}function SM(e){return Po(e)?Ro(e):e}function pi(e){var t;e.assignedMap=(t=e.assignedMap)!==null&&t!==void 0?t:new Map,e.operated||(e.operated=!0,e.parent&&pi(e.parent))}function dM(){throw new Error("Cannot modify frozen object")}function Xa(e,t,n,r,i){{n=n??new WeakMap,r=r??[],i=i??[];let s=n.has(e)?n.get(e):e;if(r.length>0){let a=r.indexOf(s);if(s&&typeof s=="object"&&a!==-1)throw r[0]===s?new Error("Forbids circular reference"):new Error(`Forbids circular reference: ~/${i.slice(0,a).map((c,l)=>{if(typeof c=="symbol")return`[${c.toString()}]`;let p=r[l];return typeof c=="object"&&(p instanceof Map||p instanceof Set)?Array.from(p.keys()).indexOf(c):c}).join("/")}`);r.push(s),i.push(t)}else r.push(s)}if(Object.isFrozen(e)||Po(e)){r.pop(),i.pop();return}switch(fi(e)){case 2:for(let[a,c]of e)Xa(a,a,n,r,i),Xa(c,a,n,r,i);e.set=e.clear=e.delete=dM;break;case 3:for(let a of e)Xa(a,a,n,r,i);e.add=e.clear=e.delete=dM;break;case 1:Object.freeze(e);let s=0;for(let a of e)Xa(a,s,n,r,i),s+=1;break;default:Object.freeze(e),Object.keys(e).forEach(a=>{let c=e[a];Xa(c,a,n,r,i)})}r.pop(),i.pop()}function $b(e,t){let n=fi(e);if(n===0)Reflect.ownKeys(e).forEach(r=>{t(r,e[r],e)});else if(n===1){let r=0;for(let i of e)t(r,i,e),r+=1}else e.forEach((r,i)=>t(i,r,e))}function xM(e,t,n){if(Po(e)||!qr(e,n)||t.has(e)||Object.isFrozen(e))return;let r=e instanceof Set,i=r?new Map:void 0;if(t.add(e),$b(e,(o,s)=>{var a;if(Po(s)){let c=de(s);En(c);let l=!((a=c.assignedMap)===null||a===void 0)&&a.size||c.operated?c.copy:c.original;xl(r?i:e,o,l)}else xM(s,t,n)}),i){let o=e,s=Array.from(o);o.clear(),s.forEach(a=>{o.add(i.has(a)?i.get(a):a)})}}function o4(e,t){let n=e.type===3?e.setMap:e.copy;e.finalities.revoke.length>1&&e.assignedMap.get(t)&&n&&xM(di(n,t),e.finalities.handledSet,e.options)}function Db(e){e.type===3&&e.copy&&(e.copy.clear(),e.setMap.forEach(t=>{e.copy.add(Fb(t))}))}function Ub(e,t,n,r){if(e.operated&&e.assignedMap&&e.assignedMap.size>0&&!e.finalized){if(n&&r){let o=gM(e);o&&t(e,o,n,r)}e.finalized=!0}}function Kb(e,t,n,r){let i=de(n);i&&(i.callbacks||(i.callbacks=[]),i.callbacks.push((o,s)=>{var a;let c=e.type===3?e.setMap:e.copy;if(zi(di(c,t),n)){let l=i.original;i.copy&&(l=i.copy),Db(e),Ub(e,r,o,s),e.options.enableAutoFreeze&&(e.options.updatedValues=(a=e.options.updatedValues)!==null&&a!==void 0?a:new WeakMap,e.options.updatedValues.set(l,i.original)),xl(c,t,l)}}),e.options.enableAutoFreeze&&i.finalities!==e.finalities&&(e.options.enableAutoFreeze=!1)),qr(n,e.options)&&e.finalities.draft.push(()=>{let o=e.type===3?e.setMap:e.copy;zi(di(o,t),n)&&o4(e,t)})}function _b(e){let{rootDraft:t,value:n,useRawReturn:r=!1,isRoot:i=!0}=e;$b(n,(o,s,a)=>{let c=de(s);if(c&&t&&c.finalities===t.finalities){e.isContainDraft=!0;let l=c.original;if(a instanceof Set){let p=Array.from(a);a.clear(),p.forEach(d=>a.add(o===d?l:d))}else xl(a,o,l)}else typeof s=="object"&&s!==null&&(e.value=s,e.isRoot=!1,_b(e))}),i&&(e.isContainDraft||console.warn("The return value does not contain any draft, please use 'rawReturn()' to wrap the return value to improve performance."),r&&console.warn("The return value contains drafts, please don't use 'rawReturn()' to wrap the return value."))}function TM(e){var t;let n=de(e);if(!qr(e,n?.options))return e;let r=fi(e);if(n&&!n.operated)return n.original;let i;function o(){i=r===2?Bb(e)?new Map(e):new(Object.getPrototypeOf(e)).constructor(e):r===3?Array.from(n.setMap.values()):bM(e,n?.options)}if(n){n.finalized=!0;try{o()}finally{n.finalized=!1}}else i=e;if($b(i,(s,a)=>{if(n&&zi(di(n.original,s),a))return;let c=TM(a);c!==a&&(i===e&&o(),xl(i,s,c))}),r===3){let s=(t=n?.original)!==null&&t!==void 0?t:i;return Lb(s)?new Set(i):new(Object.getPrototypeOf(s)).constructor(i)}return i}function mM(e){if(!Po(e))throw new Error(`current() is only used for Draft, parameter: ${e}`);return TM(e)}var Le={Remove:"remove",Replace:"replace",Add:"add",Move:"move"},zb={};function s4(e,t,n,r,i,o){let{original:s,assignedMap:a,options:c}=e,l=e.copy,p={isAssigned:d=>!!a.get(d.toString()),cloneIfNeeded:SM,concatPath:d=>{let m=t.concat([d]);return Od(m,i)},basePath:t,original:s,copy:l};if(o){let d=o(p);if(d){n.push(...d.patches),r.push(...d.inversePatches);return}}l.length<s.length&&([s,l]=[l,s],[n,r]=[r,n]);for(let d=0;d<s.length;d+=1)if(a.get(d.toString())&&l[d]!==s[d]){let m=p.concatPath(d);n.push({op:Le.Replace,path:m,value:p.cloneIfNeeded(l[d])}),r.push({op:Le.Replace,path:m,value:p.cloneIfNeeded(s[d])})}for(let d=s.length;d<l.length;d+=1){let m=p.concatPath(d);n.push({op:Le.Add,path:m,value:p.cloneIfNeeded(l[d])})}if(s.length<l.length){let{arrayLengthAssignment:d=!0}=c.enablePatches;if(d){let m=p.concatPath("length");r.push({op:Le.Replace,path:m,value:s.length})}else for(let m=l.length;s.length<m;m-=1){let y=p.concatPath(m-1);r.push({op:Le.Remove,path:y})}}}function a4({original:e,copy:t,assignedMap:n},r,i,o,s){n.forEach((a,c)=>{let l=di(e,c),p=SM(di(t,c)),d=a?bl(e,c)?Le.Replace:Le.Add:Le.Remove;if(zi(l,p)&&d===Le.Replace)return;let m=r.concat(c),y=Od(m,s);i.push(d===Le.Remove?{op:d,path:y}:{op:d,path:y,value:p}),o.push(d===Le.Add?{op:Le.Remove,path:y}:d===Le.Remove?{op:Le.Add,path:y,value:l}:{op:Le.Replace,path:y,value:l})})}function c4({original:e,copy:t},n,r,i,o){let s=0;e.forEach(a=>{if(!t.has(a)){let c=n.concat([s]),l=Od(c,o);r.push({op:Le.Remove,path:l,value:a}),i.unshift({op:Le.Add,path:l,value:a})}s+=1}),s=0,t.forEach(a=>{if(!e.has(a)){let c=n.concat([s]),l=Od(c,o);r.push({op:Le.Add,path:l,value:a}),i.unshift({op:Le.Remove,path:l,value:a})}s+=1})}function Sl(e,t,n,r){let{pathAsArray:i=!0}=e.options.enablePatches,o=e.options.createArrayPatches;switch(e.type){case 0:case 2:return a4(e,t,n,r,i);case 1:return s4(e,t,n,r,i,o);case 3:return c4(e,t,n,r,i)}}var u4=!1,Ad=(e,t,n=!1)=>{if(typeof e=="object"&&e!==null&&(!qr(e,t)||n)&&!u4)throw new Error("Strict mode: Mutable data cannot be accessed directly, please use 'unsafe(callback)' wrap.")};var jb={get size(){return tr(de(this)).size},has(e){return tr(de(this)).has(e)},set(e,t){let n=de(this),r=tr(n);return(!r.has(e)||!zi(r.get(e),t))&&(En(n),pi(n),n.assignedMap.set(e,!0),n.copy.set(e,t),Kb(n,e,t,Sl)),this},delete(e){if(!this.has(e))return!1;let t=de(this);return En(t),pi(t),t.original.has(e)?t.assignedMap.set(e,!1):t.assignedMap.delete(e),t.copy.delete(e),!0},clear(){let e=de(this);if(this.size){En(e),pi(e),e.assignedMap=new Map;for(let[t]of e.original)e.assignedMap.set(t,!1);e.copy.clear()}},forEach(e,t){let n=de(this);tr(n).forEach((r,i)=>{e.call(t,this.get(i),i,this)})},get(e){var t,n;let r=de(this),i=tr(r).get(e),o=((n=(t=r.options).mark)===null||n===void 0?void 0:n.call(t,i,nr))===nr.mutable;if(r.options.strict&&Ad(i,r.options,o),o||r.finalized||!qr(i,r.options)||i!==r.original.get(e))return i;let s=zb.createDraft({original:i,parentDraft:r,key:e,finalities:r.finalities,options:r.options});return En(r),r.copy.set(e,s),s},keys(){return tr(de(this)).keys()},values(){let e=this.keys();return{[Md]:()=>this.values(),next:()=>{let t=e.next();return t.done?t:{done:!1,value:this.get(t.value)}}}},entries(){let e=this.keys();return{[Md]:()=>this.entries(),next:()=>{let t=e.next();if(t.done)return t;let n=this.get(t.value);return{done:!1,value:[t.value,n]}}}},[Md](){return this.entries()}},l4=Reflect.ownKeys(jb),hM=(e,t,{isValuesIterator:n})=>()=>{var r,i;let o=t.next();if(o.done)return o;let s=o.value,a=e.setMap.get(s),c=de(a),l=((i=(r=e.options).mark)===null||i===void 0?void 0:i.call(r,a,nr))===nr.mutable;if(e.options.strict&&Ad(s,e.options,l),!l&&!c&&qr(s,e.options)&&!e.finalized&&e.original.has(s)){let p=zb.createDraft({original:s,parentDraft:e,key:s,finalities:e.finalities,options:e.options});e.setMap.set(s,p),a=p}else c&&(a=c.proxy);return{done:!1,value:n?a:[a,a]}},Rd={get size(){return de(this).setMap.size},has(e){let t=de(this);if(t.setMap.has(e))return!0;En(t);let n=de(e);return!!(n&&t.setMap.has(n.original))},add(e){let t=de(this);return this.has(e)||(En(t),pi(t),t.assignedMap.set(e,!0),t.setMap.set(e,e),Kb(t,e,e,Sl)),this},delete(e){if(!this.has(e))return!1;let t=de(this);En(t),pi(t);let n=de(e);return n&&t.setMap.has(n.original)?(t.assignedMap.set(n.original,!1),t.setMap.delete(n.original)):(!n&&t.setMap.has(e)?t.assignedMap.set(e,!1):t.assignedMap.delete(e),t.setMap.delete(e))},clear(){if(!this.size)return;let e=de(this);En(e),pi(e);for(let t of e.original)e.assignedMap.set(t,!1);e.setMap.clear()},values(){let e=de(this);En(e);let t=e.setMap.keys();return{[Symbol.iterator]:()=>this.values(),next:hM(e,t,{isValuesIterator:!0})}},entries(){let e=de(this);En(e);let t=e.setMap.keys();return{[Symbol.iterator]:()=>this.entries(),next:hM(e,t,{isValuesIterator:!1})}},keys(){return this.values()},[Md](){return this.values()},forEach(e,t){let n=this.values(),r=n.next();for(;!r.done;)e.call(t,r.value,r.value,this),r=n.next()}};Set.prototype.difference&&Object.assign(Rd,{intersection(e){return Set.prototype.intersection.call(new Set(this.values()),e)},union(e){return Set.prototype.union.call(new Set(this.values()),e)},difference(e){return Set.prototype.difference.call(new Set(this.values()),e)},symmetricDifference(e){return Set.prototype.symmetricDifference.call(new Set(this.values()),e)},isSubsetOf(e){return Set.prototype.isSubsetOf.call(new Set(this.values()),e)},isSupersetOf(e){return Set.prototype.isSupersetOf.call(new Set(this.values()),e)},isDisjointFrom(e){return Set.prototype.isDisjointFrom.call(new Set(this.values()),e)}});var p4=Reflect.ownKeys(Rd),vM=new WeakSet,IM={get(e,t,n){var r,i;let o=(r=e.copy)===null||r===void 0?void 0:r[t];if(o&&vM.has(o))return o;if(t===yM)return e;let s;if(e.options.mark){let l=t==="size"&&(e.original instanceof Map||e.original instanceof Set)?Reflect.get(e.original,t):Reflect.get(e.original,t,n);if(s=e.options.mark(l,nr),s===nr.mutable)return e.options.strict&&Ad(l,e.options,!0),l}let a=tr(e);if(a instanceof Map&&l4.includes(t)){if(t==="size")return Object.getOwnPropertyDescriptor(jb,"size").get.call(e.proxy);let l=jb[t];if(l)return l.bind(e.proxy)}if(a instanceof Set&&p4.includes(t)){if(t==="size")return Object.getOwnPropertyDescriptor(Rd,"size").get.call(e.proxy);let l=Rd[t];if(l)return l.bind(e.proxy)}if(!bl(a,t)){let l=fM(a,t);return l?"value"in l?l.value:(i=l.get)===null||i===void 0?void 0:i.call(e.proxy):void 0}let c=a[t];if(e.options.strict&&Ad(c,e.options),e.finalized||!qr(c,e.options))return c;if(c===Cb(e.original,t)){if(En(e),e.copy[t]=Hb({original:e.original[t],parentDraft:e,key:e.type===1?Number(t):t,finalities:e.finalities,options:e.options}),typeof s=="function"){let l=de(e.copy[t]);return En(l),pi(l),l.copy}return e.copy[t]}return c},set(e,t,n){var r;if(e.type===3||e.type===2)throw new Error("Map/Set draft does not support any property assignment.");let i;if(e.type===1&&t!=="length"&&!(Number.isInteger(i=Number(t))&&i>=0&&(t===0||i===0||String(i)===String(t))))throw new Error("Only supports setting array indices and the 'length' property.");let o=fM(tr(e),t);if(o?.set)return o.set.call(e.proxy,n),!0;let s=Cb(tr(e),t),a=de(s);return a&&zi(a.original,n)?(e.copy[t]=n,e.assignedMap=(r=e.assignedMap)!==null&&r!==void 0?r:new Map,e.assignedMap.set(t,!1),!0):(zi(n,s)&&(n!==void 0||bl(e.original,t))||(En(e),pi(e),bl(e.original,t)&&zi(n,e.original[t])?e.assignedMap.delete(t):e.assignedMap.set(t,!0),e.copy[t]=n,Kb(e,t,n,Sl)),!0)},has(e,t){return t in tr(e)},ownKeys(e){return Reflect.ownKeys(tr(e))},getOwnPropertyDescriptor(e,t){let n=tr(e),r=Reflect.getOwnPropertyDescriptor(n,t);return r&&{writable:!0,configurable:e.type!==1||t!=="length",enumerable:r.enumerable,value:n[t]}},getPrototypeOf(e){return Reflect.getPrototypeOf(e.original)},setPrototypeOf(){throw new Error("Cannot call 'setPrototypeOf()' on drafts")},defineProperty(){throw new Error("Cannot call 'defineProperty()' on drafts")},deleteProperty(e,t){var n;return e.type===1?IM.set.call(this,e,t,void 0,e.proxy):(Cb(e.original,t)!==void 0||t in e.original?(En(e),pi(e),e.assignedMap.set(t,!1)):(e.assignedMap=(n=e.assignedMap)!==null&&n!==void 0?n:new Map,e.assignedMap.delete(t)),e.copy&&delete e.copy[t],!0)}};function Hb(e){let{original:t,parentDraft:n,key:r,finalities:i,options:o}=e,s=fi(t),a={type:s,finalized:!1,parent:n,original:t,copy:null,proxy:null,finalities:i,options:o,setMap:s===3?new Map(t.entries()):void 0};(r||"key"in e)&&(a.key=r);let{proxy:c,revoke:l}=Proxy.revocable(s===1?Object.assign([],a):a,IM);if(i.revoke.push(l),vM.add(c),a.proxy=c,n){let p=n;p.finalities.draft.push((d,m)=>{var y,S;let T=de(c),E=p.type===3?p.setMap:p.copy,b=di(E,r),f=de(b);if(f){let g=f.original;f.operated&&(g=Fb(b)),Db(f),Ub(f,Sl,d,m),p.options.enableAutoFreeze&&(p.options.updatedValues=(y=p.options.updatedValues)!==null&&y!==void 0?y:new WeakMap,p.options.updatedValues.set(g,f.original)),xl(E,r,g)}(S=T.callbacks)===null||S===void 0||S.forEach(g=>{g(d,m)})})}else{let p=de(c);p.finalities.draft.push((d,m)=>{Db(p),Ub(p,Sl,d,m)})}return c}zb.createDraft=Hb;function f4(e,t,n,r,i){var o;let s=de(e),a=(o=s?.original)!==null&&o!==void 0?o:e,c=!!t.length;if(s?.operated)for(;s.finalities.draft.length>0;)s.finalities.draft.pop()(n,r);let l=c?t[0]:s?s.operated?s.copy:s.original:e;return s&&kb(s),i&&Xa(l,l,s?.options.updatedValues),[l,n&&c?[{op:Le.Replace,path:[],value:t[0]}]:n,r&&c?[{op:Le.Replace,path:[],value:a}]:r]}function d4(e,t){var n;let r={draft:[],revoke:[],handledSet:new WeakSet},i,o;t.enablePatches&&(i=[],o=[]);let a=((n=t.mark)===null||n===void 0?void 0:n.call(t,e,nr))===nr.mutable||!qr(e,t)?e:Hb({original:e,parentDraft:null,finalities:r,options:t});return[a,(c=[])=>{let[l,p,d]=f4(a,c,i,o,t.enableAutoFreeze);return t.enablePatches?[l,p,d]:l}]}var m4=e=>{if(e!==void 0&&Object.prototype.toString.call(e)!=="[object Object]")throw new Error(`Invalid options: ${String(e)}, 'options' should be an object.`);return function t(n,r,i){var o,s,a;if(typeof n=="function"&&typeof r!="function")return function(I,...M){return t(I,O=>n.call(this,O,...M),r)};let c=n,l=r,p=i;if(typeof r!="function"&&(p=r),p!==void 0&&Object.prototype.toString.call(p)!=="[object Object]")throw new Error(`Invalid options: ${p}, 'options' should be an object.`);p=Object.assign(Object.assign({},e),p);let d=Po(c)?mM(c):c,m=Array.isArray(p.mark)?(I,M)=>{for(let O of p.mark){if(typeof O!="function")throw new Error(`Invalid mark: ${O}, 'mark' should be a function.`);let C=O(I,M);if(C)return C}}:p.mark,y=(o=p.enablePatches)!==null&&o!==void 0?o:!1,S=(s=p.strict)!==null&&s!==void 0?s:!1,E={enableAutoFreeze:(a=p.enableAutoFreeze)!==null&&a!==void 0?a:!1,mark:m,strict:S,enablePatches:y,createArrayPatches:p.createArrayPatches};if(!qr(d,E)&&typeof d=="object"&&d!==null)throw new Error("Invalid base state: create() only supports plain objects, arrays, Set, Map or using mark() to mark the state as immutable.");let[b,f]=d4(d,E);if(typeof r!="function"){if(!qr(d,E))throw new Error("Invalid base state: create() only supports plain objects, arrays, Set, Map or using mark() to mark the state as immutable.");return[b,f]}let g;try{g=l(b)}catch(I){throw kb(de(b)),I}let v=I=>{let M=de(b);if(!Po(I)){if(I!==void 0&&!zi(I,b)&&M?.operated)throw new Error("Either the value is returned as a new non-draft value, or only the draft is modified without returning any value.");let C=I?.[t4];if(C){let z=C[0];return E.strict&&typeof I=="object"&&I!==null&&_b({rootDraft:M,value:I,useRawReturn:!0}),f([z])}if(I!==void 0)return typeof I=="object"&&I!==null&&_b({rootDraft:M,value:I}),f([I])}if(I===b||I===void 0)return f([]);let O=de(I);if(E===O.options){if(O.operated)throw new Error("Cannot return a modified child draft.");return f([mM(I)])}return f([I])};return g instanceof Promise?g.then(v,I=>{throw kb(de(b)),I}):v(g)}},Gb=m4();function h4(e,t){var n;let r=Number(t.path[t.path.length-1]),i=(n=t.length)!==null&&n!==void 0?n:1;switch(t.op){case"add":return e.slice(0,r)+t.value+e.slice(r);case"remove":return e.slice(0,r)+e.slice(r+i);case"replace":return e.slice(0,r)+t.value+e.slice(r+i);default:return e}}function wd(e,t){let n=e;for(let r=0;r<t.length-1;r+=1){let i=fi(n),o=t[r];if(typeof o!="string"&&typeof o!="number"&&(o=String(o)),(i===0||i===1)&&(o==="__proto__"||o==="constructor")||typeof n=="function"&&o==="prototype")throw new Error("Patching reserved attributes like __proto__ and constructor is not allowed.");if(n=di(i===3?Array.from(n):n,o),typeof n!="object"&&typeof n!="string")throw new Error(`Cannot apply patch at '${t.join("/")}'.`)}return n}function EM(e,t,n){let r;for(r=t.length-1;r>=0;r-=1){let{value:o,op:s,path:a,from:c}=t[r];if(!a.length&&s===Le.Replace||a===""&&s===Le.Add){e=o;break}if(!a.length&&s===Le.Move){let l=Nb(c),p=wd(e,l),d=l[l.length-1];e=Ro(p[d]);break}}r>-1&&(t=t.slice(r+1));let i=o=>{t.forEach(s=>{let{path:a,from:c,op:l}=s,p=Nb(a),d=wd(o,p);if(typeof d=="string"){let T=p.slice(0,-1),E=wd(o,T),b=p[p.length-2];if(b===void 0)return;E[b]=h4(E[b],s);return}let m=fi(d),y=Ro(s.value),S=p[p.length-1];switch(l){case Le.Move:{let T=Nb(c),E=wd(o,T),b=T[T.length-1],f=fi(E);if(E===d&&b===S)return;let g=Ro(E[b]);if(p.length===0)return;if(E===d&&f===1&&m===1){let v=Number(b),I=Number(S);if(v<I){d.splice(v,1),d.splice(I,0,g);return}else{d.splice(I,0,g),d.splice(v+1,1);return}}switch(f){case 1:let v=Number(b);E.splice(v,1);break;case 2:E.delete(b);break;case 3:E.delete(y);break;default:{delete E[b];break}}switch(m){case 1:let v=Number(S);d.splice(v,0,g);break;case 2:d.set(S,g);break;case 3:d.add(g);break;default:{d[S]=g;break}}return}case Le.Replace:switch(m){case 2:return d.set(S,y);case 3:throw new Error("Cannot apply replace patch to set.");default:return d[S]=y}case Le.Add:switch(m){case 1:return S==="-"?d.push(y):d.splice(S,0,y);case 2:return d.set(S,y);case 3:return d.add(y);default:return d[S]=y}case Le.Remove:switch(m){case 1:return d.splice(S,1);case 2:return d.delete(S);case 3:return d.delete(s.value);default:return delete d[S]}default:throw new Error(`Unsupported patch operation: ${l}.`)}})};if(n?.mutable){Object.keys(n).filter(o=>o!=="mutable").length&&console.warn('The "mutable" option is not allowed to be used with other options.'),i(e);return}if(Po(e)){if(n!==void 0)throw new Error("Cannot apply patches with options to a draft.");return i(e),e}return Gb(e,i,Object.assign(Object.assign({},n),{enablePatches:!1}))}var _ve=Object.prototype.constructor.toString();u();var Tl=bs(ve([Tn(),Yn()])),y4=Object({op:oe("add"),path:Tl,value:Xn()}),g4=Object({op:oe("replace"),path:Tl,value:Xn()}),b4=Object({op:oe("remove"),path:Tl}),S4=Object({op:oe("move"),from:Tl,path:Tl}),Jve=ve([y4,g4,b4,S4]);function vl(e,t){return{op:"replace",path:e,value:t}}function wM(e,t){return{op:"add",path:e,value:t}}function MM(e){return{op:"remove",path:e}}function x4(e,t){return{op:"move",from:e,path:t}}function*T4(e,t,n){if(!Ae(n))return yield vl(e,n);let r=globalThis.Object.getOwnPropertyNames(t),i=globalThis.Object.getOwnPropertyNames(n);for(let o of i)W(t,o)||(yield wM([...e,o],n[o]));for(let o of r)W(n,o)&&(To(t,n)||(yield*Pd([...e,o],t[o],n[o])));for(let o of r)W(n,o)||(yield MM([...e,o]))}function v4(e){return typeof e=="object"&&e!==null&&"id"in e?e.id:e}function*I4(e,t,n){if(!J(n))return yield vl(e,n);let r=gl(t,n,v4);for(let o of r)switch(o[0]){case"a":{yield wM([...e,o[2]],o[1]);break}case"r":{yield MM([...e,o[1]]);break}case"m":{yield x4([...e,o[1]],[...e,o[2]]);break}}let i=Ed(t.length,r);for(let o=0;o<i.length;o++){let s=i[o];s!==null&&(yield*Pd([...e,o],t[s],n[o]))}}function*E4(e,t,n){if(!cn(n)||t.length!==n.length||globalThis.Object.getPrototypeOf(t).constructor.name!==globalThis.Object.getPrototypeOf(n).constructor.name)return yield vl(e,n);for(let r=0;r<Math.min(t.length,n.length);r++)yield*Pd([...e,r],t[r],n[r])}function*w4(e,t,n){t!==n&&(yield vl(e,n))}function*Pd(e,t,n){return Ae(t)?yield*T4(e,t,n):J(t)?yield*I4(e,t,n):cn(t)?yield*E4(e,t,n):un(t)?yield*w4(e,t,n):yield vl(e,n)}function Za(e,t){return[...Pd([],e,t)]}function AM(e,t){let n=Number(t.path[t.path.length-1]),r=t.length??1;switch(t.op){case"add":return e.slice(0,n)+t.value+e.slice(n);case"remove":return e.slice(0,n)+e.slice(n+r);case"replace":return e.slice(0,n)+t.value+e.slice(n+r);default:return e}}function Vb(e,t){if(typeof e=="object"&&e!==null)return EM(e,t);if(typeof e=="string")return t.reduce((n,r)=>AM(n,r),e);if(typeof e=="number"&&t.length>0){let n=t[0];return n.op==="replace"?n.value:Vb(e,t.slice(1))}return e}function ec(e){if(typeof e=="object"&&e!==null&&"id"in e&&(typeof e.id=="string"||typeof e.id=="number"))return e.id}function qb(e,t,n){let r=[],i=e;for(let o=0;o<t.length;o++){let s=t[o];if(Array.isArray(i)){let a=typeof s=="number"?s:parseInt(s,10);isNaN(a)&&(a=-1);let c=i[a],l=c?ec(c):void 0,p=t[o+1]==="id",d=o===t.length-1;l!==void 0&&!p&&!(d&&n==="insert")?r.push({id:l}):r.push(a!==-1?a:s),i=c}else r.push(s),i=i[s]}return r}function Il(e,t){let n=[],r=e;for(let i=0;i<t.length;i++){let o=t[i];if(typeof o=="object"&&"id"in o)if(Array.isArray(r)){let s=r.findIndex(a=>a.id===o.id);if(s!==-1)n.push(s),r=r[s];else throw new Error(`ID ${o.id} not found in array`)}else throw new Error(`Expected array but found ${typeof r}`);else n.push(o),r=r[o]}return n}function Vr(e,t){return{op:t.op,...t.from?{from:qb(e,t.from)}:{},path:qb(e,t.path,t.op==="add"||t.op==="move"?"insert":void 0),..."value"in t?{value:t.value}:{}}}function RM(e,t){return{op:t.op,path:Il(e,t.path),..."value"in t?{value:t.value}:{},...t.from?{from:Il(e,t.from)}:{},...t.length?{length:t.length}:{}}}function De(e,t){for(let n of t)e=Vb(e,[RM(e,n)]);return e}function Wa(e,t){let n=[];for(let r of t){let i=Vr(e,r);e=De(e,[i]),n.push(i)}return n}function Cd(e,t){let[n,r,i]=Gb(e,t,{enablePatches:!0,createArrayPatches:M4}),o=Wa(e,r),s=Wa(n,i);return[n,o,s]}function OM(e){return typeof e=="object"&&e!==null&&"id"in e?e.id:e}function M4(e){let t=gl(e.original,e.copy,OM),n=Ed(e.original.length,t),r=[],i=[];for(let l=0;l<n.length;l++){let p=n[l];if(p!==null&&e.isAssigned(p)&&e.original[p]!==e.copy[l]){let d=Za(e.original[p],e.copy[l]),m=Za(e.copy[l],e.original[p]),y=d.map(T=>({...T,path:[...e.basePath,p,...T.path]})),S=m.map(T=>({...T,path:[...e.basePath,p,...T.path]}));r.push(...y),i.push(...S)}}let o=gl(e.copy,e.original,OM);function s(l){switch(l[0]){case"a":{let[,p,d]=l;return{op:"add",path:e.concatPath(d??"~"),value:e.cloneIfNeeded(p)}}case"r":return{op:"remove",path:e.concatPath(l[1])};case"m":return{op:"move",from:e.concatPath(l[1]),path:e.concatPath(l[2])}}}let a=[...r,...t.map(s)],c=[...o.map(s),...i];return{patches:a,inversePatches:c}}var wl=Q(FM());function Xb(e,t){let n=(0,wl.default)(e,t),r=[],i=0;for(let[o,s]of n)switch(o){case wl.default.INSERT:r.push({op:"add",index:i,value:s}),i+=s.length;break;case wl.default.DELETE:r.push({op:"remove",index:i,length:s.length});break;case wl.default.EQUAL:i+=s.length;break}for(let o=0;o<r.length-1;o++){let s=r[o],a=r[o+1];s.op==="remove"&&a.op==="add"&&s.index===a.index&&r.splice(o,2,{op:"replace",index:s.index,value:a.value,length:s.length})}return r.map(({index:o,...s})=>({...s,path:[o]}))}function Qr(e,t,{useExtendedPatches:n=!1}={}){if(typeof e=="string"&&typeof t=="string")return[Xb(e,t),Xb(t,e)];let r=Za(e,t),i=Za(t,e);return n?[Wa(e,r),Wa(t,i)]:[r,i]}u();u();u();var Mr;(i=>{function e(o){let{previous:s,next:a,mergeMetadata:c}=o,l=c?c({previous:s.metadata,next:a.metadata}):a.metadata;if(!a.undoPatches||!a.redoPatches||!s.undoPatches||!s.redoPatches)return{metadata:l,undo:m=>(m=a.undo(m),m=s.undo(m),m),redo:m=>(m=s.redo(m),m=a.redo(m),m)};let p=n([...a.undoPatches,...s.undoPatches]),d=n([...s.redoPatches,...a.redoPatches]);return{metadata:l,undo:m=>De(m,p),redo:m=>De(m,d),undoPatches:p,redoPatches:d}}i.merge=e;function t(o){let{previous:s,next:a}=o;return s.op==="move"||a.op==="move"?"conflict":r(s.path,a.path)?a:"ok"}i.mergeOperations=t;function n(o){let s=[...o];for(let a=0;a<s.length;a++){let c=s[a];for(let l=a+1;l<s.length;l++){let p=s[l],d=t({previous:c,next:p});if(d==="conflict")break;if(d==="ok")continue;s[l]=d,s.splice(a,1),a--;break}}return s}i.compactPatches=n;function r(o,s){return o.length!==s.length?!1:o.every((a,c)=>{let l=s[c];return typeof a=="object"&&"id"in a&&typeof l=="object"&&"id"in l?a.id===l.id:a===l})}i.pathsEqual=r})(Mr||={});u();function Yr(e){if(Array.isArray(e))return e;if(e.length===0)return[];let t=e[0]==="/";return e.split("/").map(n=>n.replace(/~1/g,"/").replace(/~0/g,"~")).slice(t?1:0)}function Dd(e,t,n,r){let[i,o,s]=Cd(e,r);return o=Mr.compactPatches(o),s=Mr.compactPatches(s),t.allowEmptyEdits!==!0&&o.length===0&&s.length===0?void 0:{state:i,historyEntry:{undo:c=>De(c,s),redo:c=>De(c,o),undoPatches:s,redoPatches:o,metadata:n}}}function No(e,t,n,r,i){return t.allowEmptyEdits!==!0&&r.length===0&&i.length===0?void 0:{state:e,historyEntry:{undo:s=>De(s,i),redo:s=>De(s,r),undoPatches:i,redoPatches:r,metadata:n}}}var Co=class e{constructor(t){this.state=t}patches=[];inversePatches=[];getState=()=>this.state;get=t=>Ht(this.state,t);_replaceLastDashWithIndex=(t,n,r)=>{if(t.op==="remove"&&t.path[t.path.length-1]==="-"){let o=Ht(n,t.path.slice(0,-1).join("/"));if(Array.isArray(o)){let s=ec(r);s!==void 0?t.path[t.path.length-1]={id:s}:t.path[t.path.length-1]=o.length}}};set=(t,n)=>{let r=Ht(this.state,t),i=r!==void 0?{op:"replace",path:Yr(t),value:n}:{op:"add",path:Yr(t),value:n},o=r!==void 0?{op:"replace",path:Yr(t),value:r}:{op:"remove",path:Yr(t)},s=Vr(this.state,i),a=Vr(this.state,o);this._replaceLastDashWithIndex(a,this.state,n),this.patches.push(s),this.inversePatches.push(a),this.state=De(this.state,[s])};replace=this.set;add=(t,n)=>{let r={op:"add",path:Yr(t),value:n},i={op:"remove",path:Yr(t)},o=Vr(this.state,r),s=Vr(this.state,i);this._replaceLastDashWithIndex(s,this.state,n),this.patches.push(o),this.inversePatches.push(s),this.state=De(this.state,[o])};remove=t=>{let n=Ht(this.state,t),r={op:"remove",path:Yr(t)},i={op:"add",path:Yr(t),value:n},o=Vr(this.state,r),s=Vr(this.state,i);this.patches.push(o),this.inversePatches.push(s),this.state=De(this.state,[o])};delete=this.remove;static getInverseMoveIndexes({state:t,opFrom:n,opTo:r}){let i=r.slice(),o=n.slice();for(let s=0;s<Math.min(i.length,o.length);s++){let a=i[s],c=o[s],l=!1;if(t){let p=i.slice(0,s),d=o.slice(0,s),m=Ht(t,p),y=Ht(t,d);l=Array.isArray(m)&&Array.isArray(y)}else l=typeof a=="number"&&typeof c=="number";if(l)a=Number(a),c=Number(c),a<=c&&n.length>r.length&&(o[s]=c+1),a>=c&&n.length<r.length&&(i[s]=a-1);else if(a!==c)break}return{invFrom:i,invTo:o}}move=(t,n)=>{function r(m,y,S){return Ht(m,y.slice(0,-1))===Ht(m,S.slice(0,-1))}let i=[...Yr(t)],o=[...Yr(n)],s={op:"move",from:i,path:o},a=Vr(this.state,s);this.patches.push(a),this.state=De(this.state,[a]);let c=o.slice(),l=i.slice();if(!r(this.state,c,l)){let m=e.getInverseMoveIndexes({state:this.state,opFrom:i,opTo:o});c=m.invFrom,l=m.invTo}let p={op:"move",from:c,path:l},d=Vr(this.state,p);this.inversePatches.push(d)};editDraft=t=>{let[n,r,i]=Cd(this.state,t);this.patches.push(...r),this.inversePatches.unshift(...i),this.state=n}},$s=class extends Ee{constructor(n,r={}){super();this.options=r;this.state=n,this.schema=r.schema,this.getState=this.getState.bind(this),this.getHistorySnapshot=this._createVersionMemoizer(this.getHistorySnapshot)}state;schema;version=0;history=[];historyIndex$=new _(0);get historyIndex(){return this.historyIndex$.get()}set historyIndex(n){this.historyIndex$.set(n)}historyEmittor=new Ee;_setState(n){this.state=n,this.version++,this.emit(),this.historyEmittor.emit()}_setStateWithHistoryEntry(n,r,{shouldTypeCheck:i=!0}={}){if(i&&Ao(n,this.schema,Er(this.schema)),this.history.length=this.historyIndex,this.history.length>0&&this.options.mergeHistoryEntries){let o=this.options.mergeHistoryEntries({previous:this.history[this.history.length-1],next:r},this);if(o){this.history[this.history.length-1]=o,this._setState(n);return}}this.history.push(r),this.historyIndex++,this.options.maxHistoryEntries!==void 0&&this.history.length>this.options.maxHistoryEntries&&(this.history.shift(),this.historyIndex--),this._setState(n)}edit=(...n)=>{let[r,i]=n.length===1?[void 0,n[0]]:n,o=Dd(this.state,this.options,r,i);o&&this._setStateWithHistoryEntry(o.state,o.historyEntry)};operate=(...n)=>{let[r,i]=n.length===1?[void 0,n[0]]:n,o=new Co(this.getState());i(o);let s=Mr.compactPatches(o.patches),a=Mr.compactPatches(o.inversePatches),c=De(this.state,s);if(!(this.options.allowEmptyEdits!==!0&&s.length===0))return this._setStateWithHistoryEntry(c,{undo:l=>De(l,a),redo:l=>De(l,s),undoPatches:a,redoPatches:s,metadata:r}),s};performAction=(...n)=>{let[r,i]=n.length===1?[void 0,n[0]]:n;this._setStateWithHistoryEntry(i.run(this.state),{undo:i.undo,redo:i.run,metadata:r})};canUndo=()=>this.historyIndex>0;canUndo$=this.historyIndex$.map(n=>n>0);canRedo=()=>this.historyIndex<this.history.length;canRedo$=this.historyIndex$.map(n=>n<this.history.length);undo=()=>{if(!this.canUndo())return;let n=this.history[this.historyIndex-1];this.historyIndex--,this._setState(n.undo(this.state))};redo=()=>{if(!this.canRedo())return;let n=this.history[this.historyIndex];this.historyIndex++,this._setState(n.redo(this.state))};getState(n){return n===void 0?this.state:Ht(this.state,n)}clearHistory=()=>{this.history.length=0,this.historyIndex=0,this.historyEmittor.emit()};replaceState=n=>{this.clearHistory(),this._setState(n)};rebase=n=>{let r=n;for(let i=0;i<this.historyIndex;i++)r=this.history[i].redo(r);this._setState(r)};getStateAtHistoryIndex=n=>{let r=this.state;for(let i=this.historyIndex;i>n;i--)r=this.history[i-1].undo(r);return r};_rewindToIndex=(n,r)=>{let i=this.state;for(let o=this.historyIndex;o>n;o--)i=this.history[o-1].undo(i);i=r(i);for(let o=0;o<this.historyIndex;o++)i=this.history[o].redo(i);this._setState(i)};acceptPatchesAtIndex=(n,r,i)=>{let o=this.getStateAtHistoryIndex(n);o=De(o,r);for(let s=0;s<this.historyIndex;s++){if(i&&!i(this.history[s],s))continue;o=this.history[s].redo(o)}this._setState(o)};goToHistoryIndex=n=>{if(!(n<0||n>this.history.length))if(n<this.historyIndex)for(;this.historyIndex>n;)this.undo();else for(;this.historyIndex<n;)this.redo()};getHistorySnapshot=()=>({version:this.version,history:this.history.slice(),historyIndex:this.historyIndex,canUndo:this.canUndo(),canRedo:this.canRedo()});_createVersionMemoizer(n){let r,i;return(...o)=>(r!==this.version&&(i=n(...o),r=this.version),i)}};var tc=x.Array(x.Union([x.String(),x.Number()]),{description:"An exact path into the JSON document, expressed as string and number segments."}),_4=x.Union([x.Object({op:x.Literal("set"),path:tc,value:x.Any()}),x.Object({op:x.Literal("add"),path:tc,value:x.Any()}),x.Object({op:x.Literal("remove"),path:tc}),x.Object({op:x.Literal("move"),from:tc,path:tc})]),Wb=x.Object({path:x.Optional(tc)}),eS=x.Object({operations:x.Array(_4,{minItems:1}),expectedHash:x.Optional(x.String({description:"The document hash returned by an earlier tool result. The edit is rejected if the document changed."})),summary:x.String({description:"A concise description of the requested document changes."})}),tS=x.Object({sourceCode:x.String({description:'JavaScript defining a named function "updateState(state)" which mutates state in place.'}),expectedHash:x.Optional(x.String({description:"The document hash returned by an earlier tool result. The edit is rejected if the document changed."})),summary:x.String({description:"A concise description of the requested document changes."})}),j4=2e4,L4=2e6,Ks=e=>JSON.stringify(e,(t,n)=>typeof n=="bigint"?n.toString():n);function Zb(e,t){return hl({schema:e,value:t,defs:{}})}function $M(e,t){return Ks({ok:!1,error:"The document changed since it was read. Read it again and retry.",expectedHash:e,actualHash:t})}function Ml(e){let{aiManager:t,multiplayerStateManager:n}=e,r=t.systemMessage$.get(),i=n.schema,o=["You are editing the user's current Noya document.","Inspect current values with readDocument before changing them.","Prefer applyDocumentOperations for precise changes. Use runDocumentScript only when path operations would be impractical.","Never invent paths or document structure. Use the exact JSON path segments returned by readDocument.",i&&`The document conforms to this schema:
19
19
  \`\`\`json
20
20
  ${JSON.stringify(i,null,2)}
21
21
  \`\`\``].filter(Boolean).join(`
22
22
 
23
- `);t.systemMessage$.set(o);let s=[t.registerTool({functionName:"readDocument",description:"Read the current JSON document or an exact value within it. Omit path to read the whole document.",parameters:Zb,onCall:async a=>{try{let c=Xb(Zb,a),l=n.getOptimisticState(),p=c.path===void 0?l:Ht(l,c.path);return Ks({ok:!0,path:c.path??[],value:p,hash:n.getOptimisticHash()})}catch(c){return Ks({ok:!1,error:c instanceof Error?c.message:String(c)})}}}),t.registerTool({functionName:"applyDocumentOperations",description:"Atomically set, add, remove, or move values at exact paths in the current JSON document.",parameters:Wb,onCall:async a=>{try{let c=Xb(Wb,a),l=n.getOptimisticHash();if(c.expectedHash&&c.expectedHash!==l)return $M(c.expectedHash,l);let p=new Co(n.getOptimisticState());for(let d of c.operations)switch(d.op){case"set":p.set(d.path,d.value);break;case"add":p.add(d.path,d.value);break;case"remove":p.remove(d.path);break;case"move":p.move(d.from,d.path);break}return n.applyPatch({name:c.summary},{patches:p.patches,inversePatches:p.inversePatches}),Ks({ok:!0,summary:c.summary,operationCount:c.operations.length,hash:n.getOptimisticHash()})}catch(c){return Ks({ok:!1,error:c instanceof Error?c.message:String(c)})}}}),t.registerTool({functionName:"runDocumentScript",description:'Run isolated JavaScript that defines updateState(state) and mutates the current JSON document. Use "crypto.randomUUID()" when new IDs are required.',parameters:eS,onCall:async a=>{try{let c=Xb(eS,a),l=n.getOptimisticHash();if(c.expectedHash&&c.expectedHash!==l)return $M(c.expectedHash,l);if(c.sourceCode.length>j4)throw new Error("The document script is too large.");let p=n.getOptimisticState(),d=JSON.stringify(p);if(d.length>L4)throw new Error("The document is too large for script execution.");let m=`const __state = ${d};
23
+ `);t.systemMessage$.set(o);let s=[t.registerTool({functionName:"readDocument",description:"Read the current JSON document or an exact value within it. Omit path to read the whole document.",parameters:Wb,onCall:async a=>{try{let c=Zb(Wb,a),l=n.getOptimisticState(),p=c.path===void 0?l:Ht(l,c.path);return Ks({ok:!0,path:c.path??[],value:p,hash:n.getOptimisticHash()})}catch(c){return Ks({ok:!1,error:c instanceof Error?c.message:String(c)})}}}),t.registerTool({functionName:"applyDocumentOperations",description:"Atomically set, add, remove, or move values at exact paths in the current JSON document.",parameters:eS,onCall:async a=>{try{let c=Zb(eS,a),l=n.getOptimisticHash();if(c.expectedHash&&c.expectedHash!==l)return $M(c.expectedHash,l);let p=new Co(n.getOptimisticState());for(let d of c.operations)switch(d.op){case"set":p.set(d.path,d.value);break;case"add":p.add(d.path,d.value);break;case"remove":p.remove(d.path);break;case"move":p.move(d.from,d.path);break}return n.applyPatch({name:c.summary},{patches:p.patches,inversePatches:p.inversePatches}),Ks({ok:!0,summary:c.summary,operationCount:c.operations.length,hash:n.getOptimisticHash()})}catch(c){return Ks({ok:!1,error:c instanceof Error?c.message:String(c)})}}}),t.registerTool({functionName:"runDocumentScript",description:'Run isolated JavaScript that defines updateState(state) and mutates the current JSON document. Use "crypto.randomUUID()" when new IDs are required.',parameters:tS,onCall:async a=>{try{let c=Zb(tS,a),l=n.getOptimisticHash();if(c.expectedHash&&c.expectedHash!==l)return $M(c.expectedHash,l);if(c.sourceCode.length>j4)throw new Error("The document script is too large.");let p=n.getOptimisticState(),d=JSON.stringify(p);if(d.length>L4)throw new Error("The document is too large for script execution.");let m=`const __state = ${d};
24
24
  ${c.sourceCode}
25
25
  if (typeof updateState !== "function") {
26
26
  throw new Error("The script must define updateState(state)");
@@ -32,11 +32,11 @@ __state;`,y=await e.evalManager.evaluate(m),[S,T]=Qr(p,y);return n.applyPatch({n
32
32
  `;)c++;let l=r.slice(a,c),p=`${i}`.padStart(4," "),d=" ".repeat(9+s);return`${e}
33
33
 
34
34
  > ${p} | ${l}
35
- ${d}^`}u();u();u();u();var U={EOF:0,NUMBER:1,STRING:2,BOOLEAN:3,NULL:4,IDENTIFIER:5,PLUS:6,MINUS:7,MULTIPLY:8,DIVIDE:9,MODULO:10,EQ:11,NE:12,LT:13,LE:14,GT:15,GE:16,AND:17,OR:18,NOT:19,IN:20,LPAREN:21,RPAREN:22,LBRACKET:23,RBRACKET:24,LBRACE:25,RBRACE:26,DOT:27,COMMA:28,COLON:29,QUESTION:30,BYTES:31},Je=class extends Array{#e;#t;constructor(t,n,r){super(),this.#e=t,this.#t=n,this.push(...r)}get input(){return this.#t}get pos(){return this.#e}},Ud={};for(let e in U)Ud[U[e]]=e;var $4=new Set(["as","break","const","continue","else","for","function","if","import","let","loop","package","namespace","return","var","void","while"]),zM=new Uint8Array(256);for(let e of"0123456789abcdefABCDEF")zM[e.charCodeAt(0)]=1;var tS=new Uint8Array(256);for(let e of"0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_")tS[e.charCodeAt(0)]=1;var KM={"\\":"\\","?":"?",'"':'"',"'":"'","`":"`",a:"\x07",b:"\b",f:"\f",n:`
36
- `,r:"\r",t:" ",v:"\v"},nS=class{constructor(t){this.input=t,this.pos=0,this.length=t.length}nextToken(){if(this.pos>=this.length)return{type:U.EOF,value:null,pos:this.pos};let t=this.input[this.pos],n=this.input[this.pos+1];switch(t){case" ":case" ":case`
35
+ ${d}^`}u();u();u();u();var U={EOF:0,NUMBER:1,STRING:2,BOOLEAN:3,NULL:4,IDENTIFIER:5,PLUS:6,MINUS:7,MULTIPLY:8,DIVIDE:9,MODULO:10,EQ:11,NE:12,LT:13,LE:14,GT:15,GE:16,AND:17,OR:18,NOT:19,IN:20,LPAREN:21,RPAREN:22,LBRACKET:23,RBRACKET:24,LBRACE:25,RBRACE:26,DOT:27,COMMA:28,COLON:29,QUESTION:30,BYTES:31},Je=class extends Array{#e;#t;constructor(t,n,r){super(),this.#e=t,this.#t=n,this.push(...r)}get input(){return this.#t}get pos(){return this.#e}},Ud={};for(let e in U)Ud[U[e]]=e;var $4=new Set(["as","break","const","continue","else","for","function","if","import","let","loop","package","namespace","return","var","void","while"]),zM=new Uint8Array(256);for(let e of"0123456789abcdefABCDEF")zM[e.charCodeAt(0)]=1;var nS=new Uint8Array(256);for(let e of"0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_")nS[e.charCodeAt(0)]=1;var KM={"\\":"\\","?":"?",'"':'"',"'":"'","`":"`",a:"\x07",b:"\b",f:"\f",n:`
36
+ `,r:"\r",t:" ",v:"\v"},rS=class{constructor(t){this.input=t,this.pos=0,this.length=t.length}nextToken(){if(this.pos>=this.length)return{type:U.EOF,value:null,pos:this.pos};let t=this.input[this.pos],n=this.input[this.pos+1];switch(t){case" ":case" ":case`
37
37
  `:case"\r":return this.pos++,this.nextToken();case"=":if(n!=="=")break;return{type:U.EQ,value:"==",pos:(this.pos+=2)-2};case"&":if(n!=="&")break;return{type:U.AND,value:"&&",pos:(this.pos+=2)-2};case"|":if(n!=="|")break;return{type:U.OR,value:"||",pos:(this.pos+=2)-2};case"+":return{type:U.PLUS,value:"+",pos:this.pos++};case"-":return{type:U.MINUS,value:"-",pos:this.pos++};case"*":return{type:U.MULTIPLY,value:"*",pos:this.pos++};case"/":if(n==="/"){for(;this.pos<this.length&&this.input[this.pos]!==`
38
- `;)this.pos++;return this.nextToken()}return{type:U.DIVIDE,value:"/",pos:this.pos++};case"%":return{type:U.MODULO,value:"%",pos:this.pos++};case"<":return n==="="?{type:U.LE,value:"<=",pos:(this.pos+=2)-2}:{type:U.LT,value:"<",pos:this.pos++};case">":return n==="="?{type:U.GE,value:">=",pos:(this.pos+=2)-2}:{type:U.GT,value:">",pos:this.pos++};case"!":return n==="="?{type:U.NE,value:"!=",pos:(this.pos+=2)-2}:{type:U.NOT,value:"!",pos:this.pos++};case"(":return{type:U.LPAREN,value:"(",pos:this.pos++};case")":return{type:U.RPAREN,value:")",pos:this.pos++};case"[":return{type:U.LBRACKET,value:"[",pos:this.pos++};case"]":return{type:U.RBRACKET,value:"]",pos:this.pos++};case"{":return{type:U.LBRACE,value:"{",pos:this.pos++};case"}":return{type:U.RBRACE,value:"}",pos:this.pos++};case".":return{type:U.DOT,value:".",pos:this.pos++};case",":return{type:U.COMMA,value:",",pos:this.pos++};case":":return{type:U.COLON,value:":",pos:this.pos++};case"?":return{type:U.QUESTION,value:"?",pos:this.pos++};case'"':case"'":return this.readString();case"b":case"B":case"r":case"R":return n==='"'||n==="'"?(this.pos++,this.readString(t.toLowerCase())):this.readIdentifier();default:{if(t>="0"&&t<="9")return this.readNumber();if(tS[t.charCodeAt(0)])return this.readIdentifier()}}throw new Ke(`Unexpected character: ${t}`,{pos:this.pos,input:this.input})}_parseAsBigInt(t,n,r,i){let o=this.input.substring(t,n);if(i==="u"||i==="U"){this.pos++;try{return{type:U.NUMBER,value:new ir(o),pos:t}}catch{}}else try{return{type:U.NUMBER,value:BigInt(o),pos:t}}catch{}throw new Ke(r?`Invalid hex integer: ${o}`:`Invalid integer: ${o}`,{pos:t,input:this.input})}readNumber(){let{input:t,length:n,pos:r}=this;if(t[r]==="0"&&(t[r+1]==="x"||t[r+1]==="X")){for(this.pos+=2;this.pos<n&&zM[t[this.pos].charCodeAt(0)];)this.pos++;return this._parseAsBigInt(r,this.pos,!0,t[this.pos])}let i;for(;this.pos<n&&(i=t[this.pos])>="0"&&i<="9";)this.pos++;if(i==="."&&(i=t[this.pos+1])>="0"&&i<="9"){for(this.pos++;this.pos<n&&(i=t[this.pos])>="0"&&i<="9";)this.pos++;let o=t.substring(r,this.pos),s=Number(o);if(Number.isFinite(s))return{type:U.NUMBER,value:s,pos:r};throw new Ke(`Invalid number: ${s}`,{pos:r,input:this.input})}return this._parseAsBigInt(r,this.pos,!1,t[this.pos])}readString(t){let n=this.input[this.pos++];return this.input[this.pos]===n&&this.input[this.pos+1]===n?(this.pos+=2,this.readTripleQuotedString(n,t)):this.readSingleQuotedString(n,t)}_closeQuotedString(t,n){if(n==="b"){let i=this.processEscapes(t,!0),o=new Uint8Array(i.length);for(let s=0;s<i.length;s++)o[s]=i.charCodeAt(s)&255;return{type:U.BYTES,value:o,pos:this.pos-t.length-2}}let r=n==="r"?t:this.processEscapes(t,!1);return{type:U.STRING,value:r,pos:this.pos-t.length}}readSingleQuotedString(t,n){let{input:r,length:i,pos:o}=this,s=n!=="r";for(;this.pos<i;){let a=r[this.pos];if(a===t){let c=r.slice(o,this.pos);return this.pos++,this._closeQuotedString(c,n)}if(a===`
39
- `||a==="\r")throw new Ke("Newlines not allowed in single-quoted strings",{pos:o-1,input:r});if(a==="\\"&&s){if(this.pos+=2,this.pos>i)throw new Ke("Unterminated escape sequence",{pos:o-1,input:r});continue}this.pos++}throw new Ke("Unterminated string",{pos:o-1,input:r})}readTripleQuotedString(t,n){let r=this.pos,i=n!=="r";for(;this.pos<this.length;){let o=this.input[this.pos];if(o===t&&this.input[this.pos+1]===t&&this.input[this.pos+2]===t){let s=this.input.slice(r,this.pos);return this.pos+=3,this._closeQuotedString(s,n)}if(o==="\\"&&i){if(this.pos+=2,this.pos>this.length)throw new Ke("Unterminated escape sequence",{pos:r-3,input:this.input});continue}this.pos++}throw new Ke("Unterminated triple-quoted string",{pos:r-3,input:this.input})}processEscapes(t,n){let r="",i=0;for(;i<t.length;){if(t[i]!=="\\"||i+1>=t.length){r+=t[i++];continue}let o=t[i+1];if(KM[o])r+=KM[o],i+=2;else if(o==="u"){if(n)throw new Ke("\\u not allowed in bytes literals");let s=t.substring(i+2,i+6);if(s.length!==4||!/^[0-9a-fA-F]{4}$/.test(s))throw new Ke(`Invalid Unicode escape: \\u${s}`);let a=Number.parseInt(s,16);if(a>=55296&&a<=57343)throw new Ke(`Invalid Unicode surrogate: \\u${s}`);r+=String.fromCharCode(a),i+=6}else if(o==="U"){if(n)throw new Ke("\\U not allowed in bytes literals");let s=t.substring(i+2,i+10);if(s.length!==8||!/^[0-9a-fA-F]{8}$/.test(s))throw new Ke(`Invalid Unicode escape: \\U${s}`);let a=Number.parseInt(s,16);if(a>1114111)throw new Ke(`Invalid Unicode escape: \\U${s}`);if(a>=55296&&a<=57343)throw new Ke(`Invalid Unicode surrogate: \\U${s}`);r+=String.fromCodePoint(a),i+=10}else if(o==="x"||o==="X"){let s=t.substring(i+2,i+4);if(s.length!==2||!/^[0-9a-fA-F]{2}$/.test(s))throw new Ke(`Invalid hex escape: \\${o}${s}`);r+=String.fromCharCode(Number.parseInt(s,16)),i+=4}else if(o>="0"&&o<="7"){let s=t.substring(i+1,i+4);if(s.length!==3||!/^[0-7]{3}$/.test(s))throw new Ke("Octal escape must be 3 digits");let a=Number.parseInt(s,8);if(a>255)throw new Ke(`Octal escape out of range: \\${s}`);r+=String.fromCharCode(a),i+=4}else throw new Ke(`Invalid escape sequence: \\${o}`)}return r}readIdentifier(){let t=this.pos;for(;this.pos<this.length&&tS[this.input[this.pos].charCodeAt(0)];)this.pos++;let n=this.input.substring(t,this.pos);switch(n){case"true":return{type:U.BOOLEAN,value:!0,pos:t};case"false":return{type:U.BOOLEAN,value:!1,pos:t};case"null":return{type:U.NULL,value:null,pos:t};case"in":return{type:U.IN,value:"in",pos:t};default:return{type:U.IDENTIFIER,value:n,pos:t}}}},rc=class{constructor(t){this.input=t,this.lexer=new nS(t),this.currentToken=this.lexer.nextToken()}consume(t){let n=this.currentToken;if(this.currentToken=this.lexer.nextToken(),n.type===t)return n;throw new Ke(`Expected ${Ud[t]}, got ${Ud[n.type]}`,{pos:n.pos,input:this.input})}match(t){return this.currentToken.type===t}parse(){let t=this.parseExpression();if(!this.match(U.EOF))throw new Ke(`Unexpected character: '${this.input[this.lexer.pos-1]}'`,{pos:this.currentToken.pos,input:this.input});return t}parseExpression(){let t=this.parseLogicalOr();if(this.match(U.QUESTION)){let n=this.consume(U.QUESTION),r=this.parseExpression();return this.consume(U.COLON),new Je(n.pos,this.input,["?:",t,r,this.parseExpression()])}return t}parseLogicalOr(){let t=this.parseLogicalAnd();for(;this.match(U.OR);){let n=this.consume(U.OR);t=new Je(n.pos,this.input,[n.value,t,this.parseLogicalAnd()])}return t}parseLogicalAnd(){let t=this.parseEquality();for(;this.match(U.AND);){let n=this.consume(U.AND);t=new Je(n.pos,this.input,[n.value,t,this.parseEquality()])}return t}parseEquality(){let t=this.parseRelational();for(;this.match(U.EQ)||this.match(U.NE);){let n=this.currentToken;this.currentToken=this.lexer.nextToken(),t=new Je(n.pos,this.input,[n.value,t,this.parseRelational()])}return t}parseRelational(){let t=this.parseAdditive();for(;this.match(U.LT)||this.match(U.LE)||this.match(U.GT)||this.match(U.GE)||this.match(U.IN);){let n=this.currentToken;this.currentToken=this.lexer.nextToken(),t=new Je(n.pos,this.input,[n.value,t,this.parseAdditive()])}return t}parseAdditive(){let t=this.parseMultiplicative();for(;this.match(U.PLUS)||this.match(U.MINUS);){let n=this.currentToken;this.currentToken=this.lexer.nextToken(),t=new Je(n.pos,this.input,[n.value,t,this.parseMultiplicative()])}return t}parseMultiplicative(){let t=this.parseUnary();for(;this.match(U.MULTIPLY)||this.match(U.DIVIDE)||this.match(U.MODULO);){let n=this.currentToken;this.currentToken=this.lexer.nextToken(),t=new Je(n.pos,this.input,[n.value,t,this.parseUnary()])}return t}parseUnary(){let t=this.currentToken;return t.type===U.NOT?(this.currentToken=this.lexer.nextToken(),new Je(t.pos,this.input,["!_",this.parseUnary()])):t.type===U.MINUS?(this.currentToken=this.lexer.nextToken(),new Je(t.pos,this.input,["-_",this.parseUnary()])):this.parsePostfix()}assertReservedIdentifier(t){if($4.has(t.value))throw new Ke(`Reserved identifier: ${t.value}`,{pos:t.pos,input:this.input})}parsePostfix(){let t=this.parsePrimary();for(;;)if(this.match(U.DOT)){this.consume(U.DOT);let n=this.consume(U.IDENTIFIER);if(this.match(U.LPAREN)){this.consume(U.LPAREN);let r=this.parseArgumentList();this.consume(U.RPAREN),t=new Je(n.pos,this.input,["rcall",n.value,t,r])}else t=new Je(n.pos,this.input,[".",t,n.value])}else if(this.match(U.LBRACKET)){let n=this.consume(U.LBRACKET),r=this.parseExpression();this.consume(U.RBRACKET),t=new Je(n.pos,this.input,["[]",t,r])}else break;return t}parsePrimary(){switch(this.currentToken.type){case U.NUMBER:{let t=this.consume(U.NUMBER);return new Je(t.pos,this.input,["value",t.value])}case U.STRING:{let t=this.consume(U.STRING);return new Je(t.pos,this.input,["value",t.value])}case U.BYTES:{let t=this.consume(U.BYTES);return new Je(t.pos,this.input,["value",t.value])}case U.BOOLEAN:{let t=this.consume(U.BOOLEAN);return new Je(t.pos,this.input,["value",t.value])}case U.NULL:{let t=this.consume(U.NULL);return new Je(t.pos,this.input,["value",t.value])}case U.IDENTIFIER:{let t=this.consume(U.IDENTIFIER);if(this.assertReservedIdentifier(t),this.match(U.LPAREN)){this.consume(U.LPAREN);let n=this.parseArgumentList();return this.consume(U.RPAREN),new Je(t.pos,this.input,["call",t.value,n])}return new Je(t.pos,this.input,["id",t.value])}case U.LPAREN:{this.consume(U.LPAREN);let t=this.parseExpression();return this.consume(U.RPAREN),t}case U.LBRACKET:return this.parseList();case U.LBRACE:return this.parseMap()}throw new Ke(`Unexpected token: ${Ud[this.currentToken.type]}`,{pos:this.currentToken.pos,input:this.input})}parseList(){let t=this.consume(U.LBRACKET),n=[];if(!this.match(U.RBRACKET))for(n.push(this.parseExpression());this.match(U.COMMA);)this.consume(U.COMMA),this.match(U.RBRACKET)||n.push(this.parseExpression());return this.consume(U.RBRACKET),new Je(t.pos,this.input,["list",n])}parseMap(){let t=this.consume(U.LBRACE),n=[];if(!this.match(U.RBRACE))for(n.push(this.parseProperty());this.match(U.COMMA);)this.consume(U.COMMA),this.match(U.RBRACE)||n.push(this.parseProperty());return this.consume(U.RBRACE),new Je(t.pos,this.input,["map",n])}parseProperty(){let t=this.parseExpression();this.consume(U.COLON);let n=this.parseExpression();return[t,n]}parseArgumentList(){let t=[];if(!this.match(U.RPAREN))for(t.push(this.parseExpression());this.match(U.COMMA);)this.consume(U.COMMA),this.match(U.RPAREN)||t.push(this.parseExpression());return t}};var ir=class{#e;constructor(t){this.verify(BigInt(t))}get value(){return this.#e}valueOf(){return this.#e}verify(t){if(t<0n||t>18446744073709551615n)throw new K("Unsigned integer overflow");this.#e=t}get[Symbol.toStringTag](){return`value = ${this.#e}`}[Symbol.for("nodejs.util.inspect.custom")](){return`UnsignedInteger { value: ${this.#e} }`}},K4={h:3600000000000n,m:60000000000n,s:1000000000n,ms:1000000n,us:1000n,\u00B5s:1000n,ns:1n},Hs=class e{#e;#t;constructor(t,n=0){this.#e=BigInt(t),this.#t=n}get seconds(){return this.#e}get nanos(){return this.#t}valueOf(){return Number(this.#e)*1e3+this.#t/1e6}addDuration(t){let n=this.#t+t.nanos;return new e(this.#e+t.seconds+BigInt(Math.floor(n/1e9)),n%1e9)}subtractDuration(t){let n=this.#t-t.nanos;return new e(this.#e-t.seconds+BigInt(Math.floor(n/1e9)),(n+1e9)%1e9)}extendTimestamp(t){return new Date(t.getTime()+Number(this.#e)*1e3+Math.floor(this.#t/1e6))}subtractTimestamp(t){return new Date(t.getTime()-Number(this.#e)*1e3-Math.floor(this.#t/1e6))}toString(){let t=this.#t?(this.#t/1e9).toLocaleString("en-US",{useGrouping:!1,maximumFractionDigits:9}).slice(1):"";return`${this.#e}${t}s`}getHours(){return this.#e/3600n}getMinutes(){return this.#e/60n}getSeconds(){return this.#e}getMilliseconds(){return this.#e*1000n+BigInt(Math.floor(this.#t/1e6))}get[Symbol.toStringTag](){return"google.protobuf.Duration"}[Symbol.for("nodejs.util.inspect.custom")](){return`google.protobuf.Duration { seconds: ${this.#e}, nanos: ${this.#t} }`}};function XM(e){let t=(f,g)=>e.registerFunctionOverload(f,g),n=f=>f;t("has(ast): bool",function(f){let g=f[2][0];if(g[0]===".")return r(this,g,f)!==void 0;throw new K("has() invalid argument",f)});function r(f,g,v){switch(g[0]){case"id":return f.eval(g);case".":{let I=r(f,g[1],v);if(!I)throw new K(`No such key: ${g[2]}`,g);return f.debugType(I).fieldLazy(I,g[2],v,f)}}throw new K("has() invalid argument",v)}t("dyn(dyn): dyn",n);for(let f in mi){let g=mi[f];g instanceof Dt&&t(`type(${g.name}): type`,()=>g)}t("bool(bool): bool",n),t("bool(string): bool",f=>{switch(f){case"1":case"t":case"true":case"TRUE":case"True":return!0;case"0":case"f":case"false":case"FALSE":case"False":return!1;default:throw new K(`bool() conversion error: invalid string value "${f}"`)}});let i=Object.keys;t("size(string): int",f=>BigInt(JM(f))),t("size(bytes): int",f=>BigInt(f.length)),t("size(list): int",f=>BigInt(f.length??f.size)),t("size(map): int",f=>BigInt(f instanceof Map?f.size:i(f).length)),t("string.size(): int",f=>BigInt(JM(f))),t("bytes.size(): int",f=>BigInt(f.length)),t("list.size(): int",f=>BigInt(f.length??f.size)),t("map.size(): int",f=>BigInt(f instanceof Map?f.size:i(f).length)),t("bytes(string): bytes",f=>a.fromString(f)),t("bytes(bytes): bytes",n),t("double(double): double",n),t("double(int): double",f=>Number(f)),t("double(string): double",f=>{if(!f||f!==f.trim())throw new K("double() type error: cannot convert to double");switch(f.toLowerCase()){case"inf":case"+inf":case"infinity":case"+infinity":return Number.POSITIVE_INFINITY;case"-inf":case"-infinity":return Number.NEGATIVE_INFINITY;case"nan":return Number.NaN;default:{let v=Number(f);if(!Number.isNaN(v))return v;throw new K("double() type error: cannot convert to double")}}}),t("int(int): int",n),t("int(double): int",f=>{if(Number.isFinite(f))return BigInt(Math.trunc(f));throw new K("int() type error: integer overflow")}),t("int(string): int",f=>{if(f!==f.trim()||f.length>20||f.includes("0x"))throw new K("int() type error: cannot convert to int");try{let g=BigInt(f);if(g<=9223372036854775807n&&g>=-9223372036854775808n)return g}catch{}throw new K("int() type error: cannot convert to int")}),t("uint(uint): uint",n),t("uint(double): uint",f=>{if(Number.isFinite(f))return BigInt(Math.trunc(f));throw new K("int() type error: integer overflow")}),t("uint(string): uint",f=>{if(f!==f.trim()||f.length>20||f.includes("0x"))throw new K("uint() type error: cannot convert to uint");try{let g=BigInt(f);if(g<=18446744073709551615n&&g>=0n)return g}catch{}throw new K("uint() type error: cannot convert to uint")}),t("string(string): string",n),t("string(bool): string",f=>`${f}`),t("string(int): string",f=>`${f}`),t("string(bytes): string",f=>a.toUtf8(f)),t("string(double): string",f=>f===1/0?"+Inf":f===-1/0?"-Inf":`${f}`),t("string.startsWith(string): bool",(f,g)=>f.startsWith(g)),t("string.endsWith(string): bool",(f,g)=>f.endsWith(g)),t("string.contains(string): bool",(f,g)=>f.includes(g)),t("string.indexOf(string): bool",(f,g)=>BigInt(f.indexOf(g))),t("string.indexOf(string, int): bool",(f,g,v)=>{if(g==="")return v;if(v=Number(v),v<0||v>=f.length)throw new K("string.indexOf(search, fromIndex): fromIndex out of range");return BigInt(f.indexOf(g,v))}),t("string.lastIndexOf(string): bool",(f,g)=>BigInt(f.lastIndexOf(g))),t("string.lastIndexOf(string, int): bool",(f,g,v)=>{if(g==="")return v;if(v=Number(v),v<0||v>=f.length)throw new K("string.lastIndexOf(search, fromIndex): fromIndex out of range");return BigInt(f.lastIndexOf(g,v))}),t("string.substring(int): string",(f,g)=>{if(g=Number(g),g<0||g>f.length)throw new K("string.substring(start, end): start index out of range");return f.substring(g)}),t("string.substring(int, int): string",(f,g,v)=>{if(g=Number(g),g<0||g>f.length)throw new K("string.substring(start, end): start index out of range");if(v=Number(v),v<g||v>f.length)throw new K("string.substring(start, end): end index out of range");return f.substring(g,v)}),t("string.matches(string): bool",(f,g)=>{try{return new RegExp(g).test(f)}catch{throw new K(`Invalid regular expression: ${g}`)}}),t("string.split(string): list",(f,g)=>f.split(g)),t("string.split(string, int): list",(f,g,v)=>f.split(g,v)),t("list.join(): string",f=>{for(let g=0;g<f.length;g++)if(typeof f[g]!="string")throw new K("string.join(): list must contain only strings");return f.join("")}),t("list.join(string): string",(f,g)=>{for(let v=0;v<f.length;v++)if(typeof f[v]!="string")throw new K("string.join(separator): list must contain only strings");return f.join(g)});let o=new TextEncoder("utf8"),s=new TextDecoder("utf8"),a=typeof Buffer<"u"?{byteLength:f=>Buffer.byteLength(f),fromString:f=>Buffer.from(f,"utf8"),toHex:f=>Buffer.prototype.hexSlice.call(f,0,f.length),toBase64:f=>Buffer.prototype.base64Slice.call(f,0,f.length),toUtf8:f=>Buffer.prototype.utf8Slice.call(f,0,f.length),jsonParse:f=>JSON.parse(f)}:{textEncoder:new TextEncoder("utf8"),byteLength:f=>o.encode(f).length,fromString:f=>o.encode(f),toHex:Uint8Array.prototype.toHex?f=>f.toHex():f=>Array.from(f,g=>g.toString(16).padStart(2,"0")).join(""),toBase64:Uint8Array.prototype.toBase64?f=>f.toBase64():f=>btoa(Array.from(f,g=>String.fromCodePoint(g)).join("")),toUtf8:f=>s.decode(f),jsonParse:f=>JSON.parse(o.decode(f))};t("bytes.json(): map",a.jsonParse),t("bytes.hex(): string",a.toHex),t("bytes.string(): string",a.toUtf8),t("bytes.base64(): string",a.toBase64),t("bytes.at(int): int",(f,g)=>{if(g<0||g>=f.length)throw new K("Bytes index out of range");return BigInt(f[g])});let c="google.protobuf.Timestamp";function l(f,g){return new Date(f.toLocaleString("en-US",{timeZone:g}))}function p(f,g){let v=g?l(f,g):new Date(f.getUTCFullYear(),f.getUTCMonth(),f.getUTCDate()),I=new Date(v.getFullYear(),0,0);return BigInt(Math.floor((v-I)/864e5)-1)}t(`timestamp(string): ${c}`,f=>{if(f.length<20||f.length>30)throw new K("timestamp() requires a string in ISO 8601 format");let g=new Date(f);if(g<=0xe677d21fdbff&&g>=-621355968e5)return g;throw new K("timestamp() requires a string in ISO 8601 format")}),t(`timestamp(int): ${c}`,f=>{if(f=Number(f)*1e3,f<=0xe677d21fdbff&&f>=-621355968e5)return new Date(f);throw new K("timestamp() requires a valid integer unix timestamp")}),t(`${c}.getDate(): int`,f=>BigInt(f.getUTCDate())),t(`${c}.getDate(string): int`,(f,g)=>BigInt(l(f,g).getDate())),t(`${c}.getDayOfMonth(): int`,f=>BigInt(f.getUTCDate()-1)),t(`${c}.getDayOfMonth(string): int`,(f,g)=>BigInt(l(f,g).getDate()-1)),t(`${c}.getDayOfWeek(): int`,f=>BigInt(f.getUTCDay())),t(`${c}.getDayOfWeek(string): int`,(f,g)=>BigInt(l(f,g).getDay())),t(`${c}.getDayOfYear(): int`,p),t(`${c}.getDayOfYear(string): int`,p),t(`${c}.getFullYear(): int`,f=>BigInt(f.getUTCFullYear())),t(`${c}.getFullYear(string): int`,(f,g)=>BigInt(l(f,g).getFullYear())),t(`${c}.getHours(): int`,f=>BigInt(f.getUTCHours())),t(`${c}.getHours(string): int`,(f,g)=>BigInt(l(f,g).getHours())),t(`${c}.getMilliseconds(): int`,f=>BigInt(f.getUTCMilliseconds())),t(`${c}.getMilliseconds(string): int`,f=>BigInt(f.getUTCMilliseconds())),t(`${c}.getMinutes(): int`,f=>BigInt(f.getUTCMinutes())),t(`${c}.getMinutes(string): int`,(f,g)=>BigInt(l(f,g).getMinutes())),t(`${c}.getMonth(): int`,f=>BigInt(f.getUTCMonth())),t(`${c}.getMonth(string): int`,(f,g)=>BigInt(l(f,g).getMonth())),t(`${c}.getSeconds(): int`,f=>BigInt(f.getUTCSeconds())),t(`${c}.getSeconds(string): int`,(f,g)=>BigInt(l(f,g).getSeconds()));let d=/(\d*\.?\d*)(ns|us|µs|ms|s|m|h)/;function m(f){if(!f)throw new K("Invalid duration string: ''");let g=f[0]==="-";(f[0]==="-"||f[0]==="+")&&(f=f.slice(1));let v=BigInt(0);for(;;){let O=d.exec(f);if(!O)throw new K(`Invalid duration string: ${f}`);if(O.index!==0)throw new K(`Invalid duration string: ${f}`);f=f.slice(O[0].length);let C=K4[O[2]],[z="0",F=""]=O[1].split("."),N=BigInt(z)*C,H=F?BigInt(F.slice(0,13).padEnd(13,"0"))*C/10000000000000n:0n;if(v+=N+H,f==="")break}let I=v>=1000000000n?v/1000000000n:0n,M=Number(v%1000000000n);return g?new Hs(-I,-M):new Hs(I,M)}t("duration(string): google.protobuf.Duration",f=>m(f)),t("google.protobuf.Duration.getHours(): int",f=>f.getHours()),t("google.protobuf.Duration.getMinutes(): int",f=>f.getMinutes()),t("google.protobuf.Duration.getSeconds(): int",f=>f.getSeconds()),t("google.protobuf.Duration.getMilliseconds(): int",f=>f.getMilliseconds());function y(f,g){return f.type==="list"?f.valueType:f.type==="map"?f.keyType:g.getType("dyn")}function S(f,g){let v=f[0];if(v instanceof Je&&v[0]==="id")return v[1];throw new ze(`${g} requires first argument to be an identifier`,v)}function T(f){return(g,v,I)=>{let M=S(I,`${f}(var, predicate)`),O=y(v,g),z=g.createOverlay(M,O).check(I[1]);if(z.isDynOrBool())return z;throw new ze(`predicate must return bool, got '${z}'`,I[1])}}function E(f,g,v){let I=`map(var, ${v.length===3?"filter, ":""}transform)`,M=S(v,I),O=y(g,f),C=f.createOverlay(M,O);if(v.length===3){let z=C.check(v[1]);if(!z.isDynOrBool())throw new ze(`${I} filter predicate must return bool, got '${z}'`,v[1])}return f.getType(`list<${C.check(v[v.length-1])}>`)}function b(f,g,v){let I="filter(var, filter)",M=S(v,I),O=y(g,f),z=f.createOverlay(M,O).check(v[1]);if(z.isDynOrBool())return f.getType(`list<${O}>`);throw new ze(`${I} predicate must return bool, got '${z}'`,v[1])}t("list.all(ast, ast): bool",{handler:HM,typeCheck:T("all")}),t("map.all(ast, ast): bool",{handler:HM,typeCheck:T("all")}),t("list.exists(ast, ast): bool",{handler:GM,typeCheck:T("exists")}),t("map.exists(ast, ast): bool",{handler:GM,typeCheck:T("exists")}),t("list.exists_one(ast, ast): bool",{handler:qM,typeCheck:T("exists_one")}),t("map.exists_one(ast, ast): bool",{handler:qM,typeCheck:T("exists_one")}),t("list.map(ast, ast): list",{handler:VM,typeCheck:E}),t("list.map(ast, ast, ast): list",{handler:QM,typeCheck:E}),t("map.map(ast, ast): list",{handler:VM,typeCheck:E}),t("map.map(ast, ast, ast): list",{handler:QM,typeCheck:E}),t("list.filter(ast, ast): list",{handler:YM,typeCheck:b}),t("map.filter(ast, ast): list",{handler:YM,typeCheck:b})}var ic=Symbol("predicateEvaluator");function HM(e,t){let n=t[ic]??=this.predicateEvaluator("all(var, predicate)",t),r=n.getIterableItems(e),i=null;for(let o=0;o<r.length;o++)try{if(n.childEvaluateBool(r[o]))continue;return!1}catch(s){if(s.message.includes("Unknown variable")||s.message.includes("predicate result is not a boolean"))throw s;i??=s}if(i)throw i;return!0}function GM(e,t){let n=t[ic]??=this.predicateEvaluator("exists(var, predicate)",t),r=n.getIterableItems(e),i;for(let o=0;o<r.length;o++)try{if(n.childEvaluateBool(r[o]))return!0}catch(s){if(s.message.includes("Unknown variable")||s.message.includes("predicate result is not a boolean"))throw s;i??=s}if(i)throw i;return!1}function qM(e,t){let n=t[ic]??=this.predicateEvaluator("exists_one(var, predicate)",t),r=n.getIterableItems(e),i=0;for(let o=0;o<r.length;o++)if(n.childEvaluateBool(r[o])!==!1&&++i>1)return!1;return i===1}function VM(e,t){let n=t[ic]??=this.predicateEvaluator("map(var, transform)",t),r=n.getIterableItems(e),i=[];for(let o=0;o<r.length;o++)i[o]=n.childEvaluate(r[o]);return i}function QM(e,t){let n=t[ic]??=this.predicateEvaluator("map(var, filter, transform)",t),r=t[3][2],i=n.getIterableItems(e),o=[];for(let s=0;s<i.length;s++)switch(n.childEvaluateBool(i[s])){case!1:continue;case!0:o.push(n.eval(r));continue}return o}function YM(e,t){let n=t[ic]??=this.predicateEvaluator("filter(var, predicate)",t),r=n.getIterableItems(e),i=[];for(let o=0;o<r.length;o++){let s=r[o];n.childEvaluateBool(s)!==!1&&i.push(s)}return i}function JM(e){let t=0;for(let n of e)t++;return t}var Dt=class{#e;constructor(t){this.#e=t,Object.freeze(this)}get name(){return this.#e}get[Symbol.toStringTag](){return`Type<${this.#e}>`}toString(){return`Type<${this.#e}>`}},mi={string:new Dt("string"),bool:new Dt("bool"),int:new Dt("int"),uint:new Dt("uint"),double:new Dt("double"),map:new Dt("map"),list:new Dt("list"),bytes:new Dt("bytes"),null_type:new Dt("null"),type:new Dt("type"),google:{protobuf:{Timestamp:new Dt("google.protobuf.Timestamp"),Duration:new Dt("google.protobuf.Duration")}}};mi["google.protobuf.Timestamp"]=mi.google.protobuf.Timestamp;mi["google.protobuf.Duration"]=mi.google.protobuf.Duration;var jd=class e{#e=null;#t=null;constructor(t){t instanceof e?(this.#e=t,this.#t=new Map):this.#t=new Map(t)}fork(t=!0){return t&&(this.set=this.#r),new this.constructor(this)}#r(){throw new Error("Cannot modify frozen registry")}set(t,n){return this.#t.set(t,n),this}has(t){return this.#t.has(t)||(this.#e?this.#e.has(t):!1)}get(t){return this.#t.get(t)||this.#e?.get(t)}*#n(){this.#e&&(yield*this.#e),yield*this.#t}[Symbol.iterator](){return this.#n()}get size(){return this.#t.size+(this.#e?this.#e.size:0)}},rS=class extends jd{constructor(t=null,n=null){super(t,n)}get(t){let n=super.get(t);return n===void 0?Xr:n}};function ko(e,t=jd,n=!0){return e instanceof t?e.fork(n):new t(e)}var Do=class{#e=new WeakMap;constructor({kind:t,type:n,name:r,keyType:i,valueType:o,values:s}){this.kind=t,this.type=n,this.name=r,i&&(this.keyType=i),o&&(this.valueType=o),s&&(this.values=s),t==="list"?this.fieldLazy=this.#n:t==="map"?this.fieldLazy=this.#r:t==="message"?this.fieldLazy=this.#t:t==="dyn"&&(this.fieldLazy=this.#r),Object.freeze(this)}isDynOrBool(){return this.type==="bool"||this.kind==="dyn"}toString(){return this.name}#t(t,n,r,i){let o=i.objectTypesByConstructor.get(t.constructor);if(!o)return;if(!o.fields)return Object.hasOwn(t,n)?t[n]:void 0;let s=o.fields[n];if(!s)return;let a=t[n];if(s.kind==="dyn")return a;let c=i.debugType(a);if(s.matches(c))return a;throw new K(`Field '${n}' is not of type '${s}', got '${c}'`,r)}#r(t,n,r,i){let o;if(t instanceof Map?o=t.get(n):o=Object.hasOwn(t,n)?t[n]:void 0,o===void 0)return;if(this.valueType.kind==="dyn")return o;let s=i.debugType(o);if(this.valueType.matches(s))return o;throw new K(`Field '${n}' is not of type '${this.valueType}', got '${s}'`,r)}#n(t,n,r,i){if(!(typeof n=="number"||typeof n=="bigint"))return;let o=t[n];if(o===void 0)throw new K(`No such key: index out of bounds, index ${n} ${n<0?"< 0":`>= size ${t.length}`}`,r);let s=i.debugType(o);if(this.valueType.matches(s))return o;throw new K(`List item with index '${n}' is not of type '${this.valueType}', got '${s}'`,r)}fieldLazy(){}field(t,n,r,i){let o=this.fieldLazy(t,n,r,i);if(o!==void 0)return o;throw new K(`No such key: ${n}`,r)}matchesBoth(t){return this.matches(t)&&t.matches(this)}matches(t){return this.#e.get(t)??this.#e.set(t,this.#o(t)).get(t)}#o(t){if(this===t)return!0;if(t.kind==="dyn")return t.valueType?this.matches(t.valueType):!0;switch(this.kind){case"dyn":return!0;case"list":return t.kind==="list"&&this.valueType.matches(t.valueType);case"map":return t.kind==="map"&&this.keyType.matches(t.keyType)&&this.valueType.matches(t.valueType);default:return this.name===t.name}}},iS=class{constructor({name:t,receiverType:n,argTypes:r,returnType:i,handler:o,typeCheck:s}){this.name=t,this.macro=r.includes(_d),this.receiverType=n||null,this.argTypes=r,this.returnType=i;let a=n?`${n}.`:"";this.signature=`${a}${t}(${r.join(", ")}): ${i}`,this.handler=o,this.typeCheck=s,Object.freeze(this)}matchesArgs(t){return t.length!==this.argTypes.length?!1:this.argTypes.every((n,r)=>n.matches(t[r]))}},Gs=class{constructor({operator:t,leftType:n,rightType:r,handler:i,returnType:o}){this.operator=t,this.leftType=n,this.rightType=r||null,this.handler=i,this.returnType=o,r?this.signature=`${n} ${t} ${r}: ${o}`:this.signature=`${t}${n}: ${o}`,Object.freeze(this)}get isUnary(){return this.rightType===null}get isBinary(){return this.rightType!==null}equals(t){return this.operator===t.operator&&this.leftType===t.leftType&&this.rightType===t.rightType}};function rO(e){return new Do({kind:"list",name:`list<${e}>`,type:"list",valueType:e})}function Jr(e){return new Do({kind:"primitive",name:e,type:e})}function z4(e){return new Do({kind:"message",name:e,type:e})}function iO(e){let t=e?`dyn<${e}>`:"dyn";return new Do({kind:"dyn",name:t,type:t,valueType:e})}function oO(e,t){return new Do({kind:"map",name:`map<${e}, ${t}>`,type:"map",keyType:e,valueType:t})}var Xr=iO(),_d=Jr("ast"),ZM=rO(Xr),WM=oO(Xr,Xr),Hi=Object.freeze({string:Jr("string"),bool:Jr("bool"),int:Jr("int"),uint:Jr("uint"),double:Jr("double"),bytes:Jr("bytes"),dyn:Xr,null:Jr("null"),type:Jr("type"),"google.protobuf.Timestamp":Jr("google.protobuf.Timestamp"),"google.protobuf.Duration":Jr("google.protobuf.Duration"),list:ZM,"list<dyn>":ZM,map:WM,"map<dyn, dyn>":WM}),Ld=class{functions=[];exists=!1;hasMacro=!1;add(t){this.exists=!0,t.macro&&(this.hasMacro=!0),this.functions.push(t)}findMatch(t){if(!this.exists)return null;for(let n of this.functions)if(n.matchesArgs(t))return n;return null}},eO=new Ld,oS=class{exists=!1;hasMacro=!1;returnType=null;#e=new Map;add(t){this.exists=!0,t.macro&&(this.hasMacro=!0),this.returnType?t.typeCheck?this.returnType=Xr:this.returnType!==t.returnType&&(this.returnType=Xr):this.returnType=t.returnType;let n=t.receiverType;(this.#e.get(n)||this.#e.set(n,new Ld).get(n)).add(t)}filterByReceiverType(t){return t===null?this.#e.get(null)||eO:this.#e.get(t)||(t.type==="list"||t.type==="map"?this.#e.get(Hi[t.type]):null)||eO}};function tO(e){let t=[],n="",r=0;for(let i of e){if(i==="<")r++;else if(i===">")r--;else if(i===","&&r===0){t.push(n),n="";continue}n+=i}return n&&t.push(n),t}var sO=[[void 0,"map"],[Object,"map"],[Map,"map"],[Array,"list"],[Uint8Array,"bytes"],[Date,"google.protobuf.Timestamp"],[Hs,"google.protobuf.Duration"],[ir,"uint"],[Dt,"type"]];typeof Buffer<"u"&&sO.push([Buffer,"bytes"]);var sS=class e{#e={};#t={};#r;#n;#o;#a=new Map;constructor(t={}){if(this.objectTypes=ko(t.objectTypes),this.objectTypesByConstructor=ko(t.objectTypesByConstructor),this.objectTypeInstances=ko(t.objectTypeInstances),this.#o=ko(t.functionDeclarations),this.#n=ko(t.operatorDeclarations),this.#r=ko(t.typeDeclarations||Object.entries(Hi),void 0,!1),this.variables=t.unlistedVariablesAreDyn?ko(t.variables,rS):ko(t.variables),!this.variables.size){for(let[r,i]of sO)this.registerType(i,r,!0);let n=new Map(Object.entries(mi));for(let[r,i]of n)i instanceof Dt&&this.registerVariable(r,"type")}}#s(){this.#e={},this.#t={}}registerVariable(t,n){if(this.variables.has(t))throw new Error(`Variable already registered: ${t}`);return this.variables.set(t,n instanceof Do?n:this.getType(n)),this}getFunctionCandidates(t,n,r){let i=new oS;for(let[,o]of this.#o)n===o.name&&(t===null&&o.receiverType||t&&o.receiverType===null||(i.exists=!0,o.macro&&(i.hasMacro=!0),!(t&&!t.matches(o.receiverType))&&o.argTypes.length===r&&i.add(o)));return i}getType(t){return this.#i(t,!0)}getDynType(t){return this.#a.get(t)||this.#a.set(t,this.#i(`dyn<${t}>`,!0)).get(t)}assertType(t,n,r){try{return this.#i(t,!0)}catch(i){throw i.message=`Invalid ${n} '${i.unknownType||t}' in '${r}'`,i}}getFunctionType(t){return t==="ast"?_d:this.#i(t,!0)}registerType(t,n,r){let i={name:t,type:this.#i(t,!1),ctor:typeof n=="function"?n:n?.ctor,fields:this.#x(t,n?.fields)};if(!r){if(this.objectTypes.has(t))throw new Error(`Type already registered: ${t}`);if(typeof i.ctor!="function")throw new Error(`Constructor function missing for type '${t}'`)}if(this.objectTypes.set(t,i),this.objectTypesByConstructor.set(i.ctor,i),r)return;let o=new Dt(t);this.objectTypeInstances.set(t,o),this.registerFunctionOverload(`type(${t}): type`,()=>o)}#i(t,n=!1){let r=this.#r.get(t);if(r)return r;let i=t.match(/^dyn<(.+)>$/);if(i){let a=this.#i(i[1].trim(),n);return this.#c(iO,`dyn<${a}>`,a)}let o=t.match(/^list<(.+)>$/);if(o){let a=this.#i(o[1].trim(),n);return this.#c(rO,`list<${a}>`,a)}let s=t.match(/^map<(.+)>$/);if(s){let a=tO(s[1]);if(a.length!==2)throw new Error(`Invalid map type: ${t}`);let c=this.#i(a[0].trim(),n),l=this.#i(a[1].trim(),n);return this.#c(oO,`map<${c}, ${l}>`,c,l)}if(n){let a=new Error(`Unknown type: ${t}`);throw a.unknownType=t,a}return this.#c(z4,t,t)}#c(t,n,...r){return this.#r.get(n)||this.#r.set(n,t(...r)).get(n)}#p(t,n,r){let i=[];for(let[,o]of this.#n)if(o.operator===t){if(this.#h(o,n,r))return[o];this.#y(o,n,r)&&i.push(o)}return i.length===0&&(t==="=="||t==="!=")&&this.#b(n,r)?[{handler:t==="=="?(s,a)=>s===a:(s,a)=>s!==a,returnType:this.getType("bool")}]:i}findUnaryOverload(t,n){let r=this.#e[t]?.get(n);if(r!==void 0)return r;let i=!1;for(let[,o]of this.#n)if(!(o.operator!==t||o.leftType!==n)){i=o;break}return(this.#e[t]??=new Map).set(n,i).get(n)}findBinaryOverload(t,n,r){return this.#e[t]?.get(n)?.get(r)??this.#f(this.#e,t,n,r,this.#d(t,n,r))}checkBinaryOverload(t,n,r){return this.#t[t]?.get(n)?.get(r)??this.#f(this.#t,t,n,r,this.#m(t,n,r))}#d(t,n,r){let i=this.#p(t,n,r);if(i.length===0)return!1;if(i.length===1)return i[0];throw new Error(`Operator overload '${i[0].signature}' overlaps with '${i[1].signature}'.`)}#m(t,n,r){let i=this.#p(t,n,r);if(i.length===0)return!1;let o=i[0].returnType;return i.every(s=>s.returnType===o)?o:(o.kind==="list"||o.kind==="map")&&i.every(s=>s.returnType.kind===o.kind)?o.kind==="list"?Hi.list:Hi.map:Hi.dyn}#f(t,n,r,i,o){let s=t[n]??=new Map;return(s.get(r)||s.set(r,new Map).get(r)).set(i,o),o}#h(t,n,r){return n===t.leftType&&r===t.rightType||n.name===`dyn<${t.leftType}>`&&r===t.rightType||n===t.leftType&&r.name===`dyn<${t.rightType}>`||n.name===`dyn<${t.leftType}>`&&r.name===`dyn<${t.rightType}>`}#y(t,n,r){return!this.#u(n,t.leftType)||!this.#u(r,t.rightType)?!1:this.#g(t.operator,n,r)}#u(t,n){return t===n?!0:t.kind==="dyn"?t.valueType?this.#u(t.valueType,n):!0:t.type!==n.type?!1:n===Hi.list||n===Hi.map}#g(t,n,r){return t==="in"?n.kind==="dyn"?!0:r.kind==="list"?r.valueType.matchesBoth(n):r.kind==="map"?r.keyType.matchesBoth(n):!0:(t==="+"||t==="=="||t==="!=")&&(n.kind==="list"&&r.kind==="list"||n.kind==="map"&&r.kind==="map")?n.matchesBoth(r):!0}#b(t,n){return t.kind==="dyn"||n.kind==="dyn"}#S(t,n,r,i=!1){try{let o=typeof n[r]=="string"?{type:n[r]}:{...n[r]};if(typeof o?.type!="string")throw new Error("unsupported declaration");return this.#i(o.type,i)}catch(o){throw o.message=`Field '${r}' in type '${t}' has unsupported declaration: ${JSON.stringify(n[r])}`,o}}#x(t,n){if(!n)return;let r={};for(let i of Object.keys(n))r[i]=this.#S(t,n,i);return r}clone(t={}){return new e({objectTypes:this.objectTypes,objectTypesByConstructor:this.objectTypesByConstructor,objectTypeInstances:this.objectTypeInstances,typeDeclarations:this.#r,operatorDeclarations:this.#n,functionDeclarations:this.#o,variables:this.variables,unlistedVariablesAreDyn:t.unlistedVariablesAreDyn})}#T(t,n,r){let i=t.match(/^(?:([a-zA-Z0-9.]+)\.)?(\w+)\((.*?)\):\s*(.+)$/);if(!i)throw new Error(`Invalid signature: ${t}`);let[,o,s,a,c]=i;try{return new iS({name:s,receiverType:o?this.getType(o.trim()):null,returnType:this.getType(c.trim()||"dyn"),argTypes:tO(a).map(l=>this.getFunctionType(l.trim())),handler:n,typeCheck:r})}catch{throw new Error(`Invalid function declaration: ${t}`)}}#v(t,n){return t.name!==n.name||t.argTypes.length!==n.argTypes.length||(t.receiverType||n.receiverType)&&(!t.receiverType||!n.receiverType)?!1:!(t.receiverType!==n.receiverType&&t.receiverType!==Xr&&n.receiverType!==Xr)&&(n.macro||t.macro||n.argTypes.every((i,o)=>{let s=t.argTypes[o];return i===s||i===_d||s===_d||i===Xr||s===Xr}))}#I(t){for(let[,n]of this.#o)if(this.#v(n,t))throw new Error(`Function signature '${t.signature}' overlaps with existing overload '${n.signature}'.`)}registerFunctionOverload(t,n){let r=typeof n=="function"?n:n.handler,i=typeof n=="function"?{}:n,o=this.#T(t,r,i.typeCheck);this.#I(o),this.#o.set(o.signature,o)}registerOperatorOverload(t,n){let r=t.match(/^([-!])([\w.<>]+)(?::\s*([\w.<>]+))?$/);if(r){let[,l,p,d]=r;return this.unaryOverload(l,p,n,d)}let i=t.match(/^([\w.<>]+) ([-+*%/]|==|!=|<|<=|>|>=|in) ([\w.<>]+)(?::\s*([\w.<>]+))?$/);if(!i)throw new Error(`Operator overload invalid: ${t}`);let[,o,s,a,c]=i;return this.binaryOverload(o,s,a,n,c)}unaryOverload(t,n,r,i){let o=this.assertType(n,"type",`${t}${n}`),s=this.assertType(i||n,"return type",`${t}${n}: ${i||n}`),a=new Gs({operator:`${t}_`,leftType:o,returnType:s,handler:r});if(this.#l(a))throw new Error(`Operator overload already registered: ${t}${n}`);this.#n.set(a.signature,a),this.#s()}#l(t){for(let[,n]of this.#n)if(t.equals(n))return!0;return!1}binaryOverload(t,n,r,i,o){o??=nO(n)?"bool":t;let s=`${t} ${n} ${r}: ${o}`,a=this.assertType(t,"left type",s),c=this.assertType(r,"right type",s),l=this.assertType(o,"return type",s);if(nO(n)&&l.type!=="bool")throw new Error(`Comparison operator '${n}' must return 'bool', got '${l.type}'`);let p=new Gs({operator:n,leftType:a,rightType:c,returnType:l,handler:i});if(this.#l(p))throw new Error(`Operator overload already registered: ${p.signature}`);if(n==="=="){let d=[new Gs({operator:"!=",leftType:a,rightType:c,handler(m,y,S,T){return!i(m,y,S,T)},returnType:l})];a!==c&&d.push(new Gs({operator:"==",leftType:c,rightType:a,handler(m,y,S,T){return i(y,m,S,T)},returnType:l}),new Gs({operator:"!=",leftType:c,rightType:a,handler(m,y,S,T){return!i(y,m,S,T)},returnType:l}));for(let m of d)if(this.#l(m))throw new Error(`Operator overload already registered: ${m.signature}`);for(let m of d)this.#n.set(m.signature,m)}this.#n.set(p.signature,p),this.#s()}};function nO(e){return e==="<"||e==="<="||e===">"||e===">="||e==="=="||e==="!="||e==="in"}function aO(e){return new sS(e)}u();function cO(e){let t=e.unaryOverload.bind(e),n=e.binaryOverload.bind(e);function r(c,l){if(c<=9223372036854775807n&&c>=-9223372036854775808n)return c;throw new K(`integer overflow: ${c}`,l)}t("!","bool",c=>!c),t("-","int",c=>-c),n("int","*","int",(c,l,p)=>r(c*l,p)),n("int","+","int",(c,l,p)=>r(c+l,p)),n("int","-","int",(c,l,p)=>r(c-l,p)),n("int","/","int",(c,l,p)=>{if(l===0n)throw new K("division by zero",p);return c/l}),n("int","%","int",(c,l,p)=>{if(l===0n)throw new K("modulo by zero",p);return c%l}),t("-","double",c=>-c),n("double","*","double",(c,l)=>c*l),n("double","+","double",(c,l)=>c+l),n("double","-","double",(c,l)=>c-l),n("double","/","double",(c,l,p)=>{if(l===0)throw new K("division by zero",p);return c/l}),n("string","+","string",(c,l)=>c+l),n("list","+","list",(c,l)=>[...c,...l]),n("bytes","+","bytes",(c,l)=>{let p=new Uint8Array(c.length+l.length);return p.set(c,0),p.set(l,c.length),p});let i="google.protobuf.Duration";n(i,"+",i,(c,l)=>c.addDuration(l)),n(i,"-",i,(c,l)=>c.subtractDuration(l)),n(i,"==",i,(c,l)=>c.seconds===l.seconds&&c.nanos===l.nanos);let o="google.protobuf.Timestamp";n(o,"==",o,(c,l)=>c.getTime()===l.getTime()),n(o,"-",i,(c,l)=>l.subtractTimestamp(c)),n(o,"+",i,(c,l)=>l.extendTimestamp(c)),n(i,"+",o,(c,l)=>c.extendTimestamp(l));function s(c,l,p,d){if(l instanceof Set&&l.has(c))return!0;for(let m of l)if(Rl(c,m,d))return!0;return!1}function a(c,l){return Array.isArray(l)?l.includes(c):l.has(c)}for(let c of["string","bool","null","type"])n(c,"in","list",a);for(let c of["int","double","list","map"])n(c,"in","list",s);for(let c of["string","int","double","bool","null"])n(c,"in","map",(l,p)=>p instanceof Map?p.get(l)!==void 0:Object.hasOwn(p,l)?p[l]!==void 0:!1);for(let c of["type","null","bool","string","int","uint","double"])n(c,"==",c,(l,p)=>l===p);n("int","==","dyn<double>",(c,l)=>c==l),n("int","==","dyn<uint>",(c,l)=>c==l.valueOf()),n("uint","==","dyn<double>",(c,l)=>c.valueOf()==l),n("uint","==","dyn<int>",(c,l)=>c.valueOf()==l),n("double","==","dyn<int>",(c,l)=>c==l),n("double","==","dyn<uint>",(c,l)=>c==l.valueOf()),n("bytes","==","bytes",(c,l)=>{let p=c.length;if(p!==l.length)return!1;for(;p--;)if(c[p]!==l[p])return!1;return!0}),n("list","==","list",(c,l,p,d)=>{if(Array.isArray(c)&&Array.isArray(l)){let S=c.length;if(S!==l.length)return!1;for(let T=0;T<S;T++)if(!Rl(c[T],l[T],d))return!1;return!0}if(c instanceof Set&&l instanceof Set){if(c.size!==l.size)return!1;for(let S of c)if(!l.has(S))return!1;return!0}let m=c instanceof Set?l:c,y=c instanceof Set?c:l;if(!Array.isArray(m)||m.length!==y?.size)return!1;for(let S=0;S<m.length;S++)if(!y.has(m[S]))return!1;return!0}),n("map","==","map",(c,l,p,d)=>{if(c instanceof Map&&l instanceof Map){if(c.size!==l.size)return!1;for(let[S,T]of c)if(!(l.has(S)&&Rl(T,l.get(S),d)))return!1;return!0}if(c instanceof Map||l instanceof Map){let S=c instanceof Map?l:c,T=c instanceof Map?c:l,E=Object.keys(S);if(T.size!==E.length)return!1;for(let[b,f]of T)if(!(b in S&&Rl(f,S[b],d)))return!1;return!0}let m=Object.keys(c),y=Object.keys(l);if(m.length!==y.length)return!1;for(let S=0;S<m.length;S++){let T=m[S];if(!(T in l&&Rl(c[T],l[T],d)))return!1}return!0}),n("uint","+","uint",(c,l)=>new ir(c.valueOf()+l.valueOf())),n("uint","-","uint",(c,l)=>new ir(c.valueOf()-l.valueOf())),n("uint","*","uint",(c,l)=>new ir(c.valueOf()*l.valueOf())),n("uint","/","uint",(c,l,p)=>{if(l.valueOf()===0n)throw new K("division by zero",p);return new ir(c.valueOf()/l.valueOf())}),n("uint","%","uint",(c,l,p)=>{if(l.valueOf()===0n)throw new K("modulo by zero",p);return new ir(c.valueOf()%l.valueOf())});for(let[c,l]of[["int","int"],["uint","uint"],["double","double"],["string","string"],["google.protobuf.Timestamp","google.protobuf.Timestamp"],["google.protobuf.Duration","google.protobuf.Duration"],["int","uint"],["int","double"],["double","int"],["double","uint"],["uint","int"],["uint","double"]])n(c,"<",l,(p,d)=>p<d),n(c,"<=",l,(p,d)=>p<=d),n(c,">",l,(p,d)=>p>d),n(c,">=",l,(p,d)=>p>=d)}function Rl(e,t,n){if(e===t)return!0;switch(typeof e){case"string":return!1;case"bigint":return typeof t=="number"?e==t:!1;case"number":return typeof t=="bigint"?e==t:!1;case"boolean":return!1;case"object":if(typeof t!="object"||e===null||t===null)return!1;let r=n.objectTypesByConstructor.get(e.constructor)?.type,i=n.objectTypesByConstructor.get(t.constructor)?.type;if(!r||r!==i)return!1;let o=n.registry.findBinaryOverload("==",r,i)?.handler;return o?o(e,t,null,n):!1}throw new K(`Cannot compare values of type ${typeof e}`)}u();var Bd=class{constructor({ctx:t,objectTypes:n,objectTypesByConstructor:r,registry:i}){this.ctx=t,this.objectTypes=n,this.objectTypesByConstructor=r,this.registry=i}getType(t){return this.registry.getType(t)}createOverlay(t,n){return new this.constructor({ctx:this.ctx.createOverlay(t,n),objectTypes:this.objectTypes,objectTypesByConstructor:this.objectTypesByConstructor,registry:this.registry})}check(t){if(t.checkedType)return t.checkedType;switch(t[0]){case"value":return t.checkedType??=this.inferLiteralType(t[1]);case"id":return t.checkedType??=this.checkVariable(t);case".":case"[]":return t.checkedType??=this.checkAccess(t);case"call":return t.checkedType??=this.checkCall(t);case"rcall":return t.checkedType??=this.checkReceiverCall(t);case"list":return t.checkedType??=this.checkList(t);case"map":return t.checkedType??=this.checkMap(t);case"?:":return t.checkedType??=this.checkTernary(t);case"||":case"&&":return t.checkedType??=this.checkLogicalOp(t);case"!_":case"-_":return t.checkedType??=this.checkUnaryOperator(t);case"==":case"!=":case"<":case"<=":case">":case">=":case"+":case"-":case"*":case"/":case"%":case"in":return t.checkedType??=this.checkBinaryOperator(t);default:throw new ze(`Unknown operation: ${t[0]}`,t)}}inferLiteralType(t){switch(typeof t){case"string":return this.getType("string");case"bigint":return this.getType("int");case"number":return this.getType("double");case"boolean":return this.getType("bool");case"object":if(t===null)return this.getType("null");let n=this.objectTypesByConstructor.get(t.constructor)?.type;if(n)return n;throw new ze(`Unsupported type: ${t.constructor?.name||typeof t}`);default:throw new ze(`Unsupported type: ${typeof t}`)}}checkVariable(t){let n=t[1],r=this.ctx.getType(n);if(r!==void 0)return r;throw new ze(`Unknown variable: ${n}`,t)}checkAccess(t){let n=this.check(t[1]);if(n.kind==="dyn")return n;let i=(t[0]==="[]"?this.check(t[2]):this.getType("string")).type;if(n.kind==="list"){if(i!=="int"&&i!=="dyn")throw new ze(`List index must be int, got '${i}'`,t);return n.valueType}if(n.kind==="map")return n.valueType;let o=this.objectTypes.get(n.name);if(o){if(!(i==="string"||i==="dyn"))throw new ze(`Cannot index type '${n.name}' with type '${i}'`,t);if(o.fields){let s=t[0]==="."?t[2]:void 0;if(s){let a=o.fields[s];if(a)return a;throw new ze(`No such key: ${s}`,t)}}return this.getType("dyn")}throw new ze(`Cannot index type '${n}'`,t)}checkCall(t){let n=t[1],r=t[2],i=(t.functionCandidates??=this.registry.getFunctionCandidates(null,n,r.length)).filterByReceiverType(null);if(!i.exists)throw new ze(`Function not found: '${n}'`,t);if(i.hasMacro)return this.#e(null,i,r,t);let o=r.map(this.check,this),s=i.findMatch(o);if(!s)throw new ze(`found no matching overload for '${n}(${o.join(", ")})'`,t);return s.returnType}#e(t,n,r,i){let o=n.functions[0];return o.typeCheck?o.typeCheck(this,t,r,i):o.returnType}checkReceiverCall(t){let n=t[1],r=t[3],i=this.check(t[2]),o=t.functionCandidates??=this.registry.getFunctionCandidates(i,n,r.length);if(!o.exists)throw new ze(`Function not found: '${n}' for value of type '${i}'`,t);if(i.kind==="dyn")return o.returnType||i;let s=o.filterByReceiverType(i);if(s.hasMacro)return this.#e(i,s,r,t);let a=r.map(this.check,this),c=s.findMatch(a);if(!c)throw new ze(`found no matching overload for '${i.type}.${n}(${a.join(", ")})'`,t);return c.returnType}checkList(t){let n=t[1];if(n.length===0)return this.getType("list");let r=this.check(n[0]);return n.every(o=>r===this.check(o))?this.getType(`list<${r}>`):this.getType("list")}checkMap(t){let n=t[1];if(n.length===0)return this.getType("map");let r=this.check(n[0][0]),i=this.check(n[0][1]),o=!0,s=!0;for(let l=1;l<n.length;l++){let[p,d]=n[l];r!==this.check(p)&&(o=!1),i!==this.check(d)&&(s=!1)}let a=o?r:"dyn",c=s?i:"dyn";return this.getType(`map<${a}, ${c}>`)}checkTernary(t){let n=this.check(t[1]);if(!n.isDynOrBool())throw new ze(`Ternary condition must be bool, got '${n}'`,t);let r=this.check(t[2]),i=this.check(t[3]);if(r===i||r.name==="dyn")return r;if(i.name==="dyn")return i;throw new ze(`Ternary branches must have the same type, got '${r}' and '${i}'`,t)}checkLogicalOp(t){let n=this.check(t[1]),r=this.check(t[2]);if(!n.isDynOrBool())throw new ze(`Logical operator requires bool operands, got '${n}'`,t);if(!r.isDynOrBool())throw new ze(`Logical operator requires bool operands, got '${r}'`,t);return this.getType("bool")}checkUnaryOperator(t){let n=t[0],r=this.check(t[1]);if(r.kind==="dyn")return n==="!_"?this.getType("bool"):r;let i=this.registry.findUnaryOverload(n,r);if(i)return i.returnType;throw new ze(`no such overload: ${n[0]}${r.type}`,t)}checkBinaryOperator(t){let n=t[0],r=this.check(t[1]),i=this.check(t[2]),o=this.registry.checkBinaryOverload(n,r,i);if(o)return o;throw new ze(`no such overload: ${r} ${n} ${i}`,t)}};var lS=aO();cO(lS);XM(lS);var H4=new Map(Object.entries({value(e){return e[1]},id(e,t){return t.value(e[1],e).value},"||"(e,t){try{let r=t.eval(e[1]);if(r===!0)return!0;if(r!==!1)throw new K("Left operand of || is not a boolean",e[1])}catch(r){if(r.message.includes("Unknown variable")||r.message.includes("is not a boolean"))throw r;let i=t.eval(e[2]);if(i===!0)return!0;throw i===!1?r:new K("Right operand of || is not a boolean",e[2])}let n=t.eval(e[2]);if(typeof n=="boolean")return n;throw new K("Right operand of || is not a boolean",e[2])},"&&"(e,t){try{let r=t.eval(e[1]);if(r===!1)return!1;if(r!==!0)throw new K("Left operand of && is not a boolean",e[1])}catch(r){if(r.message.includes("Unknown variable")||r.message.includes("is not a boolean"))throw r;let i=t.eval(e[2]);if(i===!1)return!1;throw i===!0?r:new K("Right operand of && is not a boolean",e[2])}let n=t.eval(e[2]);if(typeof n=="boolean")return n;throw new K("Right operand of && is not a boolean",e[2])},"."(e,t){let n=t.eval(e[1]);return t.debugType(n).field(n,e[2],e,t)},"[]"(e,t){let n=t.eval(e[1]);return t.debugType(n).field(n,t.eval(e[2]),e,t)},rcall(e,t){let n=e[1],r=t.eval(e[2]),i=e[2].checkedType||t.celTypes.dyn,o=e[3],s=o.length,a=e.functionCandidates??=t.registry.getFunctionCandidates(i,n,s),c=i.kind!=="dyn"?i:t.debugType(r);if(!a.exists)throw new K(`Function not found: '${n}' for value of type '${c}'`,e);let l=a.filterByReceiverType(c),p,d;if(l.hasMacro)p=o,d=e.argMacroTypes??=new Array(s).fill(t.registry.getFunctionType("ast"));else{p=e.argValues??=new Array(s),d=e.argTypes??=new Array(s);for(let y=0;y<s;y++){let S=o[y];p[y]=t.eval(S),d[y]=pO(S.checkedType,t.debugType(p[y]),t)}}let m=l.findMatch(d);if(!m)throw new K(`found no matching overload for '${c.type}.${n}(${d.join(", ")})'`,e);try{return m.macro?m.handler.call(t,r,e):m.handler.call(t,r,...p)}catch(y){throw y instanceof K?y.withAst(e):y}},call(e,t){let n=e[1],r=e[2],i=r.length,o=e.functionCandidates??=t.registry.getFunctionCandidates(null,n,i);if(o.exists===!1)throw new K(`Function not found: '${n}'`,e);let s=o.filterByReceiverType(null),a,c;if(o.hasMacro)a=r,c=e.argMacroTypes??=new Array(i).fill(t.registry.getFunctionType("ast"));else{a=e.argValues??=new Array(i),c=e.argTypes??=new Array(i);for(let p=0;p<i;p++){let d=r[p];a[p]=t.eval(d),c[p]=pO(d.checkedType,t.debugType(a[p]),t)}}let l=s.findMatch(c);if(!l)throw new K(`found no matching overload for '${n}(${c.join(", ")})'`,e);try{return l.macro?l.handler.call(t,e):l.handler.apply(t,a)}catch(p){throw p instanceof K?p.withAst(e):p}},list(e,t){let n=e[1],r=new Array(n.length);for(let i=0;i<n.length;i++)r[i]=t.eval(n[i]);return r},map(e,t){let n={},r=e[1];for(let i=0;i<r.length;i++){let o=r[i];n[t.eval(o[0])]=t.eval(o[1])}return n},"?:"(e,t){let n=t.eval(e[1]);if(n===!0)return t.eval(e[2]);if(n===!1)return t.eval(e[3]);throw new K("Ternary condition must be a boolean")},"!_":uO,"-_":uO,"!=":Or,"==":Or,in:Or,"+":Or,"-":Or,"*":Or,"/":Or,"%":Or,"<":Or,"<=":Or,">":Or,">=":Or}));function uO(e,t){let n=t.eval(e[1]),r=t.debugType(n),i=t.registry.findUnaryOverload(e[0],r);if(i)return i.handler(n);throw new K(`no such overload: ${e[0][0]}${r}`,e)}function Or(e,t){let n=t.eval(e[1]),r=t.eval(e[2]),i=lO(e[1].checkedType,t.debugType(n),t),o=lO(e[2].checkedType,t.debugType(r),t),s=t.registry.findBinaryOverload(e[0],i,o);if(s)return s.handler(n,r,e,t);throw new K(`no such overload: ${i} ${e[0]} ${o}`,e)}function lO(e,t,n){if(e===t||!e)return t;if(e.kind==="dyn")return n.registry.getDynType(t);if(e.kind!==t.kind)throw new K(`Type mismatch: expected ${e}, got ${t}`);return e}function pO(e,t){if(e===t||!e||e.kind==="dyn")return t;if(e.kind!==t.kind)throw new K(`Type mismatch: expected ${e}, got ${t}`);return e}var Fd=class{createOverlay(t,n){return new cS({parent:this,variableName:t,variableType:n})}getVariable(t){let n=this.getType(t);if(!n)return;let r=this.getValue(t);if(r!==void 0)return{type:n,value:r}}},aS=class extends Fd{constructor({variables:t,fallbackValues:n}){super(),this.variables=t,this.fallbackValues=n,this.primary=null,this.primaryGetter=this.#e}getType(t){return this.variables.get(t)}getValue(){}setPrimaryContext(t){if(typeof t!="object")throw new K("Context must be an object");this.primary=t,t?t instanceof Map?this.getValue=this.#r:this.getValue=this.#t:this.getValue=this.#e}#e(t){return this.fallbackValues.get(t)}#t(t){let n=Object.hasOwn(this.primary,t)?this.primary[t]:void 0;return n!==void 0?n:this.fallbackValues.get(t)}#r(t){let n=this.primary.get(t);return n!==void 0?n:this.fallbackValues.get(t)}},cS=class extends Fd{constructor({parent:t,variableName:n,variableType:r}){super(),this.parent=t,this.variableName=n,this.variableType=r,this.variableValue=void 0}getType(t){return this.variableName===t?this.variableType:this.parent.getType(t)}getValue(t){return this.variableName===t?this.variableValue:this.parent.getValue(t)}setVariableValue(t){this.variableValue=t}},fO=new WeakMap,G4=new Map(Object.entries(mi)),oc=class e{#e;#t;#r;#n;#o;constructor(t){this.#o=t,this.#t=(t?.inherit instanceof e?fO.get(t.inherit):lS).clone({unlistedVariablesAreDyn:t?.unlistedVariablesAreDyn??!1}),this.#e=this.#t.variables;let n={registry:this.#t,variables:this.#e,objectTypes:this.#t.objectTypes,objectTypesByConstructor:this.#t.objectTypesByConstructor,ctx:new aS({variables:this.#e,fallbackValues:G4})};this.#n=new Bd(n),this.#r=new $d({...n,typeChecker:this.#n}),fO.set(this,this.#t),Object.freeze(this)}clone(t){return new e({inherit:this,unlistedVariablesAreDyn:this.#o?.unlistedVariablesAreDyn??!1})}registerFunction(t,n){return this.#t.registerFunctionOverload(t,n),this}registerOperator(t,n){return this.#t.registerOperatorOverload(t,n),this}registerType(t,n){return this.#t.registerType(t,n),this}registerVariable(t,n){return this.#t.registerVariable(t,n),this}hasVariable(t){return this.#t.variables.has(t)}check(t){try{let n=this.#n.check(new rc(t).parse());return{valid:!0,type:this.#s(n)}}catch(n){return{valid:!1,error:n}}}#a(t){try{let n=this.#n.check(t);return{valid:!0,type:this.#s(n)}}catch(n){return{valid:!1,error:n}}}#s(t){return t.name==="list<dyn>"?"list":t.name==="map<dyn, dyn>"?"map":`${t.name}`}parse(t){let n=new rc(t).parse(),r=this.#i.bind(this,n);return r.check=this.#a.bind(this,n),r.ast=n,r}evaluate(t,n){return this.#i(new rc(t).parse(),n)}#i(t,n=null){let r=this.#r;return r.ctx.setPrimaryContext(n),r.tryCheck(t),r.eval(t)}};function dO(e){throw new K(`Unsupported type: ${e}`)}var $d=class{handlers=H4;celTypes=Hi;constructor({registry:t,objectTypes:n,objectTypesByConstructor:r,typeChecker:i,ctx:o}){this.objectTypes=n,this.objectTypesByConstructor=r,this.registry=t,this.typeChecker=i,this.ctx=o}value(t,n){let r=this.ctx.getVariable(t);if(!r)throw new K(`Unknown variable: ${t}`,n);let i=this.debugType(r.value);if(r.type.matches(i))return r;throw new K(`Variable '${t}' is not of type '${r.type}', got '${i}'`,n)}predicateEvaluator(t,n){return new uS(this,t,n)}debugType(t){switch(typeof t){case"string":return this.celTypes.string;case"bigint":return this.celTypes.int;case"number":return this.celTypes.double;case"boolean":return this.celTypes.bool;case"object":return t===null?this.celTypes.null:this.objectTypesByConstructor.get(t.constructor)?.type||dO(t.constructor?.name||typeof t);default:dO(typeof t)}}tryCheck(t){try{return t.checkedType||this.typeChecker.check(t)}catch{}}eval(t){let n=this.handlers.get(t[0]);if(n)return n(t,this);throw new K(`Unknown operation: ${t[0]}`,t)}},uS=class extends $d{constructor(t,n,r){super(t);let[i,o]=r[3];if(i?.[0]!=="id")throw new K(`${n} invalid predicate iteration variable`,r);this.ast=r,this.functionName=n,this.predicateVariable=i[1],this.predicateExpression=o;let s=r[2].checkedType||this.celTypes.dyn,a=this.celTypes.dyn;s.type==="list"&&(a=s.valueType),s.type==="map"&&(a=s.keyType),this.ctx=this.ctx.createOverlay(this.predicateVariable,a),this.tryCheck(o)}getIterableItems(t){if(Array.isArray(t))return t;if(t instanceof Set)return[...t];if(t instanceof Map)return[...t.keys()];if(typeof t=="object")return Object.keys(t);throw new K(`${this.functionName} cannot iterate over non-collection type. argument must be a list, map, or object`,this.ast)}childEvaluateBool(t){switch(this.ctx.setVariableValue(t),this.eval(this.predicateExpression)){case!0:return!0;case!1:return!1;default:throw new K(`${this.functionName} predicate result is not a boolean`,Array.isArray(this.predicateExpression)?this.predicateExpression:this.ast)}}childEvaluate(t){return this.ctx.setVariableValue(t),this.eval(this.predicateExpression)}},A0e=new oc({unlistedVariablesAreDyn:!0});u();var qs="noyaPolicy",zd="noyaServerComputed",hS="noyaServerScripts";function q4(e){let t=typeof e.compute=="string"?{kind:"expression",expression:e.compute}:e.compute;return{...e,compute:t}}function V4(e,t){return e[zd]=q4(t),e}function Q4(e,t){return e[qs]=t,e}function Y4(e,t){return e[hS]=t,e}function yS(e){return e?(e[hS]??[]).filter(n=>!!n&&typeof n.id=="string"&&typeof n.code=="string"):[]}function J4(e){return e?Array.isArray(e)?e:Object.entries(e):[]}function X4(e,t){let n=t.map(([s])=>s),r=new Map(t),i=new Set,o=yO(e,n);for(let s of o)hO(s,i,r,n,new Set);return i}function hO(e,t,n,r,i){if(t.has(e)||i.has(e))return;i.add(e);let o=yO(n.get(e),r);for(let s of o)hO(s,t,n,r,i);i.delete(e),t.add(e)}function yO(e,t){if(!e)return[];let n=[];for(let r of t)new RegExp(`\\b${Z4(r)}\\b`).test(e)&&n.push(r);return n}function Z4(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}var gO=new oc({unlistedVariablesAreDyn:!0}),W4=BigInt(Number.MAX_SAFE_INTEGER);gO.registerFunction("random(): double",()=>Math.random()).registerFunction("randomInt(int, int): int",(e,t)=>{if(t<e)throw new Error("randomInt requires the second argument to be greater than or equal to the first");if(t===e)return e;let n=t-e+1n;if(n>W4)throw new Error("randomInt range is too large to generate safely");let r=Number(n),i=BigInt(Math.floor(Math.random()*r));return e+i}).registerFunction("now(): double",function(){let t=this.ctx.getVariable("now")?.value??Date.now();return typeof t=="number"?t:Number(t)}).registerFunction("timestamp(): string",function(){let e=this.ctx.getVariable("now"),t=typeof e?.value=="number"?e.value:typeof e?.value=="string"?Number(e.value):Date.now();return new Date(t).toISOString()}).registerFunction("uuid(): string",()=>te());var mO=new Map;function e6(e){let t=mO.get(e);return t||(t=gO.parse(e),mO.set(e,t)),t}function pS(e,t){return e6(e)({auth:t.auth??{},data:t.data??null,newData:t.newData??null,patch:t.patch??null,now:t.now,...t.bindings})}function bO(e){let t=e.policy.allow?.[e.action];if(!t)return{allowed:!0};let n=J4(e.policy.let),r=X4(t,n),i={},o={...e.context,bindings:i};try{for(let[a,c]of n)r.has(a)&&(i[a]=pS(c,o));return{allowed:!!pS(t,o),expression:t}}catch(s){return{allowed:!1,expression:t,error:s instanceof Error?s.message:String(s)}}}function gS(e){let{schema:t,patches:n,previousState:r,nextState:i,auth:o,now:s}=e;if(t)for(let a of n){let c=IO(t,a.path);if(c.length===0)continue;let l=i6(a,c);if(!l)continue;let p=TO(c);if(!p?.schema[qs]){if((o?.access??"write")!=="write")return{action:l??"update",patch:a,message:"Insufficient access level to edit this field"};continue}let d=p.schema[qs],y=Il(r,a.path).slice(0,p.pathLength),S=mS(r,y),T=mS(i,y),E=bO({policy:d,action:l,context:{auth:o??{},data:S,newData:T,patch:a,now:s}});if(!E.allowed)return{action:l,patch:a,expression:E.expression,...E.error&&{message:E.error}}}}function bS(e){let{schema:t,patches:n,auth:r,now:i}=e;if(!t)return[];let o=[];for(let s of n){let a=IO(t,s.path);if(a.length===0)continue;let c=vO(s,a);if(!c)continue;let l=a[a.length-1]?.schema;l&&"value"in s&&(s.value=dS(l,s.value,c,r??{},i)),o.push(...r6({schemaPath:a,patch:s,event:c,auth:r??{},now:i}))}return o}var Kd=Symbol("readDenied");function t6(e){let{schema:t,state:n,auth:r,now:i}=e;if(!t)return n;let s=fS({schemaPath:[{schema:t,pathLength:0}],value:n,rootState:n,simplePath:[],auth:r??{},now:i});if(s!==Kd)return s}function fS(e){if(!n6({schemaPath:e.schemaPath,simplePath:e.simplePath,state:e.rootState,auth:e.auth,now:e.now}))return Kd;let n=e.schemaPath.at(-1)?.schema;if(!n)return e.value;if(Array.isArray(e.value)&&xS(n)){let r=!1,i=[];for(let o=0;o<e.value.length;o++){let s=e.value[o],a=ec(s),l=SS(n,a!==void 0?{id:a}:o),p=l?[...e.schemaPath,{schema:l,pathLength:e.simplePath.length+1}]:e.schemaPath,d=fS({schemaPath:p,value:s,rootState:e.rootState,simplePath:[...e.simplePath,o],auth:e.auth,now:e.now});if(d===Kd){r=!0;continue}i.push(d),d!==s&&(r=!0)}return r?i:e.value}if(TS(e.value)&&Pl(n)){let r=!1,i,o=()=>(i||(i={...e.value}),i);for(let s of Object.keys(e.value)){let a=e.value[s],c=n.properties?.[s],l=c?[...e.schemaPath,{schema:c,pathLength:e.simplePath.length+1}]:e.schemaPath,p=fS({schemaPath:l,value:a,rootState:e.rootState,simplePath:[...e.simplePath,s],auth:e.auth,now:e.now});if(p===Kd){let d=o();delete d[s],r=!0;continue}if(p!==a){let d=o();d[s]=p,r=!0}}return r?i??e.value:e.value}return e.value}function n6(e){let t=TO(e.schemaPath);if(!t?.schema[qs])return!0;let n=t.schema[qs],r=e.simplePath.slice(0,t.pathLength),i=mS(e.state,r),o=bO({policy:n,action:"read",context:{auth:e.auth??{},data:i,newData:i,now:e.now}});return o.error?!1:o.allowed}function r6(e){let{schemaPath:t,patch:n,event:r,auth:i,now:o}=e,s=[];for(let a of t){if(!Pl(a.schema))continue;let c=a.schema.properties??{},l=n.path.length===a.pathLength,p=l?n.value:void 0;for(let d of Object.keys(c)){let y=c[d][zd];!y||!SO(y,r,"object")||(y.targets??["value"]).includes("value")&&l&&TS(p)&&Object.prototype.hasOwnProperty.call(p,d)&&r==="create"||s.push({op:"add",path:[...n.path.slice(0,a.pathLength),d],value:xO(y.compute,{auth:i,now:o})})}}return s}function SO(e,t,n){let r=e.events??["create"],i=e.targets??["value"];return r.includes(t)&&i.includes(n)}function xO(e,t){switch(e.kind){case"timestamp":return e.format==="number"?t.now:new Date(t.now).toISOString();case"authId":return t.auth.id??null;case"uuid":return te();case"literal":return e.value;case"expression":return pS(e.expression,{auth:t.auth,data:void 0,newData:void 0,patch:void 0,now:t.now,bindings:{}})}}function dS(e,t,n,r,i){let o=e[zd];if(o&&SO(o,n,"value"))return xO(o.compute,{auth:r,now:i});if(Pl(e)&&TS(t)){let s=e.properties??{};for(let a of Object.keys(t)){let c=s[a];c&&(t[a]=dS(c,t[a],n,r,i))}}else if(xS(e)&&Array.isArray(t)){let s=e.items;if(s)for(let a=0;a<t.length;a++)t[a]=dS(s,t[a],n,r,i)}return t}function TO(e){for(let t=e.length-1;t>=0;t--){let n=e[t];if(n.schema[qs])return n}}function i6(e,t){if(e.op==="remove")return"delete";let n=vO(e,t);if(n)switch(n){case"create":return"create";case"update":return"update"}}function vO(e,t){let n=t[t.length-1];switch(e.op){case"add":return Pl(n.schema)?"create":"update";case"replace":return"update";default:return}}function IO(e,t){let n=[{schema:e,pathLength:0}],r=e;for(let i=0;i<t.length&&(r=SS(r,t[i]),!!r);i++)n.push({schema:r,pathLength:i+1});return n}function SS(e,t){if(e){if(Array.isArray(e.anyOf)&&e.anyOf[0])return SS(e.anyOf[0],t);if(xS(e))return e.items;if(Pl(e)&&typeof t=="string")return e.properties?.[t]??void 0}}function Pl(e){return e.type==="object"}function xS(e){return e.type==="array"}function TS(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function mS(e,t){let n=e;for(let r of t){if(n==null)return;n=n[r]}return n}u();var vS=100;function Vs(e,t=new WeakSet){if(e===null)return null;switch(typeof e){case"undefined":return"[undefined]";case"string":case"number":case"boolean":return e;case"bigint":return e.toString();case"symbol":return e.toString();case"function":return`[Function ${e.name||"anonymous"}]`}if(e instanceof Error)return{name:e.name,message:e.message,stack:e.stack};if(e instanceof Date)return`[Date ${e.toISOString()}]`;if(Array.isArray(e)){if(t.has(e))return"[Circular]";t.add(e);let n=e.map(r=>Vs(r,t));return t.delete(e),n}if(typeof e=="object"&&e!==null){let n=e;if(t.has(n))return"[Circular]";t.add(n);let r={};for(let i of Object.keys(n))r[i]=Vs(n[i],t);return t.delete(n),r}return e}function o6(e){return e.split(".").map(t=>t.trim()).filter(t=>t.length>0)}function s6(e){return(e.path??[]).map(t=>typeof t=="number"?t.toString():typeof t=="object"&&t!==null&&"key"in t?String(t.key):String(t))}function a6(e,t){if(t.length===0||t.length>e.length)return!1;for(let n=0;n<t.length;n+=1){let r=t[n];if(r!=="*"&&r!==e[n])return!1}return!0}function c6(e){if(!e)return null;let t=e.trim();if(!t)return null;let n=t.match(/^(\d+)(ms|s)$/i);if(!n)return vS;let r=Number(n[1]),i=n[2].toLowerCase();return Number.isNaN(r)?vS:i==="s"?r*1e3:r}function u6(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?()=>crypto.randomUUID():()=>te()}function l6(e){let t=e.mode??"live";return{target:e.target,mode:t,label:e.label??`${e.target}${t==="simulation"?"-sim":""}`,clock:e.clock??(()=>Date.now())}}var IS=class{constructor(t,n,r,i,o,s){this.definition=t;this.quickJSPromise=n;this.randomUUID=s;this.host=r,this.environment=i,this.logSink=o,this.updateTriggersFromDefinition(),this.lastTickTimestamp=null,this.invocation=r.getInitialInvocation?.(this.definition.id)??0}vm=null;runtime=null;interval=null;disposed=!1;active=!1;isRunning=!1;readyPromise=null;invocation=0;stateChangeMatchers=[];runsOnStateChange=!1;hasIntervalTrigger=!1;intervalDurationMs=null;runOnAnyStateChange=!1;runsOnInputQueue=!1;runOnAnyInputQueue=!1;runsOnUserEvent=!1;runOnAnyUserEvent=!1;runsOnSchemaMigration=!1;runOnAnyMigration=!1;pendingRun=!1;inputQueueMatchers=[];userEventMatchers=[];migrationVersionMatchers=[];lastTickTimestamp=null;host;environment;logSink;pendingTriggers=[];get id(){return this.definition.id}get intervalMs(){return this.intervalDurationMs??vS}getModuleSpecifier(){return`server-script:${encodeURIComponent(this.definition.id)}`}syncInvocation(t,n){t>this.invocation&&(this.invocation=t);let r=this.getNow();n!==void 0?this.lastTickTimestamp=Math.max(n,r):this.lastTickTimestamp=r,this.stopInterval(),this.active&&this.hasIntervalTrigger&&this.scheduleNextInterval()}isSameDefinition(t){return t.code===this.definition.code&&Gt(t.on??{},this.definition.on??{})}updateDefinition(t){let n=t.code!==this.definition.code,r=this.intervalDurationMs,i=this.hasIntervalTrigger,o=this.runsOnStateChange,s=this.runOnAnyStateChange,a=this.stateChangeMatchers.map(S=>[...S]),c=this.runsOnInputQueue,l=this.runOnAnyInputQueue,p=[...this.inputQueueMatchers];this.definition=t,this.invocation=this.host.getInitialInvocation?.(t.id)??0,this.updateTriggersFromDefinition();let d=r!==this.intervalDurationMs||i!==this.hasIntervalTrigger,m=o!==this.runsOnStateChange||s!==this.runOnAnyStateChange||!Gt(a,this.stateChangeMatchers),y=c!==this.runsOnInputQueue||l!==this.runOnAnyInputQueue||!Gt(p,this.inputQueueMatchers);n&&this.disposeVm(),d&&(this.hasIntervalTrigger?this.active&&this.restartInterval():this.stopInterval()),(n||m||y)&&this.active&&(this.runsOnStateChange||this.runsOnInputQueue)&&this.ensureVm()}setActive(t){this.disposed||this.active!==t&&(this.active=t,t?(this.hasIntervalTrigger&&this.ensureInterval(),(this.runsOnStateChange||this.runsOnInputQueue)&&!this.hasIntervalTrigger&&this.ensureVm()):this.stopInterval())}dispose(){this.disposed=!0,this.stopInterval(),this.disposeVm()}async ensureInterval(){this.interval||this.disposed||!this.active||this.hasIntervalTrigger&&(await this.ensureVm(),!(this.disposed||!this.active)&&this.tick(this.getNow()))}restartInterval(){this.stopInterval(),this.active&&this.ensureInterval()}stopInterval(){this.interval!==null&&(clearTimeout(this.interval),this.interval=null)}getNow(){return this.environment.clock()}log(t,...n){this.logSink({level:t,scriptId:this.definition.id,target:this.environment.target,mode:this.environment.mode,origin:this.environment.label,values:n})}scheduleNextInterval(){if(this.interval||this.disposed||!this.active||!this.hasIntervalTrigger)return;let t=this.getNow(),r=(this.lastTickTimestamp??t)+this.intervalMs,i=Math.max(0,r-t);this.interval=setTimeout(()=>{this.interval=null,this.tick(r)},i)}disposeVm(){this.vm?.dispose(),this.vm=null,this.runtime?.dispose(),this.runtime=null,this.readyPromise=null}async ensureVm(){if(this.vm||this.readyPromise)return this.readyPromise;this.readyPromise=(async()=>{let t=await this.quickJSPromise;if(this.disposed)return;let n=t.newRuntime(),r=this.getModuleSpecifier();n.setModuleLoader(E=>E===r?this.definition.code:{error:new Error(`Unknown module ${E}`)});let i=n.newContext();this.vm=i,this.runtime=n;let o=i.newObject(),s=E=>i.newFunction(E,(...b)=>{let f=b.map(g=>i.dump(g));return this.log(E,...f),i.undefined}),a=s("log"),c=s("warn"),l=s("error");i.setProp(o,"log",a),i.setProp(o,"warn",c),i.setProp(o,"error",l),a.dispose(),c.dispose(),l.dispose(),i.setProp(i.global,"console",o),o.dispose();let p=i.newObject(),d=i.newFunction("randomUUID",()=>i.newString(this.randomUUID()));i.setProp(p,"randomUUID",d),d.dispose(),i.setProp(i.global,"crypto",p),p.dispose();let m=i.newFunction("__noyaGetSharedConnectionData",()=>{let E=this.host.getSharedConnectionData();return i.newString(JSON.stringify(E??{}))});i.setProp(i.global,"__noyaGetSharedConnectionData",m);let y=i.newFunction("__noyaSetSharedConnectionData",E=>{let b=i.dump(E);if(typeof b!="object"||b===null)throw new Error("setSharedConnectionData requires an object argument");return this.host.setSharedConnectionData(b),i.undefined});i.setProp(i.global,"__noyaSetSharedConnectionData",y);let S=i.newFunction("__noyaDrainInputQueue",(...E)=>{let b=E[0],f;if(b){let v=i.dump(b);if(v&&typeof v=="object"){let I=v;f={connectionId:typeof I.connectionId=="string"?I.connectionId:void 0,queue:typeof I.queue=="string"?I.queue:void 0,maxEntries:typeof I.maxEntries=="number"?I.maxEntries:void 0}}}let g=this.host.drainInputQueue(f);return i.newString(JSON.stringify(g??[]))});i.setProp(i.global,"__noyaDrainInputQueue",S);let T=`
38
+ `;)this.pos++;return this.nextToken()}return{type:U.DIVIDE,value:"/",pos:this.pos++};case"%":return{type:U.MODULO,value:"%",pos:this.pos++};case"<":return n==="="?{type:U.LE,value:"<=",pos:(this.pos+=2)-2}:{type:U.LT,value:"<",pos:this.pos++};case">":return n==="="?{type:U.GE,value:">=",pos:(this.pos+=2)-2}:{type:U.GT,value:">",pos:this.pos++};case"!":return n==="="?{type:U.NE,value:"!=",pos:(this.pos+=2)-2}:{type:U.NOT,value:"!",pos:this.pos++};case"(":return{type:U.LPAREN,value:"(",pos:this.pos++};case")":return{type:U.RPAREN,value:")",pos:this.pos++};case"[":return{type:U.LBRACKET,value:"[",pos:this.pos++};case"]":return{type:U.RBRACKET,value:"]",pos:this.pos++};case"{":return{type:U.LBRACE,value:"{",pos:this.pos++};case"}":return{type:U.RBRACE,value:"}",pos:this.pos++};case".":return{type:U.DOT,value:".",pos:this.pos++};case",":return{type:U.COMMA,value:",",pos:this.pos++};case":":return{type:U.COLON,value:":",pos:this.pos++};case"?":return{type:U.QUESTION,value:"?",pos:this.pos++};case'"':case"'":return this.readString();case"b":case"B":case"r":case"R":return n==='"'||n==="'"?(this.pos++,this.readString(t.toLowerCase())):this.readIdentifier();default:{if(t>="0"&&t<="9")return this.readNumber();if(nS[t.charCodeAt(0)])return this.readIdentifier()}}throw new Ke(`Unexpected character: ${t}`,{pos:this.pos,input:this.input})}_parseAsBigInt(t,n,r,i){let o=this.input.substring(t,n);if(i==="u"||i==="U"){this.pos++;try{return{type:U.NUMBER,value:new ir(o),pos:t}}catch{}}else try{return{type:U.NUMBER,value:BigInt(o),pos:t}}catch{}throw new Ke(r?`Invalid hex integer: ${o}`:`Invalid integer: ${o}`,{pos:t,input:this.input})}readNumber(){let{input:t,length:n,pos:r}=this;if(t[r]==="0"&&(t[r+1]==="x"||t[r+1]==="X")){for(this.pos+=2;this.pos<n&&zM[t[this.pos].charCodeAt(0)];)this.pos++;return this._parseAsBigInt(r,this.pos,!0,t[this.pos])}let i;for(;this.pos<n&&(i=t[this.pos])>="0"&&i<="9";)this.pos++;if(i==="."&&(i=t[this.pos+1])>="0"&&i<="9"){for(this.pos++;this.pos<n&&(i=t[this.pos])>="0"&&i<="9";)this.pos++;let o=t.substring(r,this.pos),s=Number(o);if(Number.isFinite(s))return{type:U.NUMBER,value:s,pos:r};throw new Ke(`Invalid number: ${s}`,{pos:r,input:this.input})}return this._parseAsBigInt(r,this.pos,!1,t[this.pos])}readString(t){let n=this.input[this.pos++];return this.input[this.pos]===n&&this.input[this.pos+1]===n?(this.pos+=2,this.readTripleQuotedString(n,t)):this.readSingleQuotedString(n,t)}_closeQuotedString(t,n){if(n==="b"){let i=this.processEscapes(t,!0),o=new Uint8Array(i.length);for(let s=0;s<i.length;s++)o[s]=i.charCodeAt(s)&255;return{type:U.BYTES,value:o,pos:this.pos-t.length-2}}let r=n==="r"?t:this.processEscapes(t,!1);return{type:U.STRING,value:r,pos:this.pos-t.length}}readSingleQuotedString(t,n){let{input:r,length:i,pos:o}=this,s=n!=="r";for(;this.pos<i;){let a=r[this.pos];if(a===t){let c=r.slice(o,this.pos);return this.pos++,this._closeQuotedString(c,n)}if(a===`
39
+ `||a==="\r")throw new Ke("Newlines not allowed in single-quoted strings",{pos:o-1,input:r});if(a==="\\"&&s){if(this.pos+=2,this.pos>i)throw new Ke("Unterminated escape sequence",{pos:o-1,input:r});continue}this.pos++}throw new Ke("Unterminated string",{pos:o-1,input:r})}readTripleQuotedString(t,n){let r=this.pos,i=n!=="r";for(;this.pos<this.length;){let o=this.input[this.pos];if(o===t&&this.input[this.pos+1]===t&&this.input[this.pos+2]===t){let s=this.input.slice(r,this.pos);return this.pos+=3,this._closeQuotedString(s,n)}if(o==="\\"&&i){if(this.pos+=2,this.pos>this.length)throw new Ke("Unterminated escape sequence",{pos:r-3,input:this.input});continue}this.pos++}throw new Ke("Unterminated triple-quoted string",{pos:r-3,input:this.input})}processEscapes(t,n){let r="",i=0;for(;i<t.length;){if(t[i]!=="\\"||i+1>=t.length){r+=t[i++];continue}let o=t[i+1];if(KM[o])r+=KM[o],i+=2;else if(o==="u"){if(n)throw new Ke("\\u not allowed in bytes literals");let s=t.substring(i+2,i+6);if(s.length!==4||!/^[0-9a-fA-F]{4}$/.test(s))throw new Ke(`Invalid Unicode escape: \\u${s}`);let a=Number.parseInt(s,16);if(a>=55296&&a<=57343)throw new Ke(`Invalid Unicode surrogate: \\u${s}`);r+=String.fromCharCode(a),i+=6}else if(o==="U"){if(n)throw new Ke("\\U not allowed in bytes literals");let s=t.substring(i+2,i+10);if(s.length!==8||!/^[0-9a-fA-F]{8}$/.test(s))throw new Ke(`Invalid Unicode escape: \\U${s}`);let a=Number.parseInt(s,16);if(a>1114111)throw new Ke(`Invalid Unicode escape: \\U${s}`);if(a>=55296&&a<=57343)throw new Ke(`Invalid Unicode surrogate: \\U${s}`);r+=String.fromCodePoint(a),i+=10}else if(o==="x"||o==="X"){let s=t.substring(i+2,i+4);if(s.length!==2||!/^[0-9a-fA-F]{2}$/.test(s))throw new Ke(`Invalid hex escape: \\${o}${s}`);r+=String.fromCharCode(Number.parseInt(s,16)),i+=4}else if(o>="0"&&o<="7"){let s=t.substring(i+1,i+4);if(s.length!==3||!/^[0-7]{3}$/.test(s))throw new Ke("Octal escape must be 3 digits");let a=Number.parseInt(s,8);if(a>255)throw new Ke(`Octal escape out of range: \\${s}`);r+=String.fromCharCode(a),i+=4}else throw new Ke(`Invalid escape sequence: \\${o}`)}return r}readIdentifier(){let t=this.pos;for(;this.pos<this.length&&nS[this.input[this.pos].charCodeAt(0)];)this.pos++;let n=this.input.substring(t,this.pos);switch(n){case"true":return{type:U.BOOLEAN,value:!0,pos:t};case"false":return{type:U.BOOLEAN,value:!1,pos:t};case"null":return{type:U.NULL,value:null,pos:t};case"in":return{type:U.IN,value:"in",pos:t};default:return{type:U.IDENTIFIER,value:n,pos:t}}}},rc=class{constructor(t){this.input=t,this.lexer=new rS(t),this.currentToken=this.lexer.nextToken()}consume(t){let n=this.currentToken;if(this.currentToken=this.lexer.nextToken(),n.type===t)return n;throw new Ke(`Expected ${Ud[t]}, got ${Ud[n.type]}`,{pos:n.pos,input:this.input})}match(t){return this.currentToken.type===t}parse(){let t=this.parseExpression();if(!this.match(U.EOF))throw new Ke(`Unexpected character: '${this.input[this.lexer.pos-1]}'`,{pos:this.currentToken.pos,input:this.input});return t}parseExpression(){let t=this.parseLogicalOr();if(this.match(U.QUESTION)){let n=this.consume(U.QUESTION),r=this.parseExpression();return this.consume(U.COLON),new Je(n.pos,this.input,["?:",t,r,this.parseExpression()])}return t}parseLogicalOr(){let t=this.parseLogicalAnd();for(;this.match(U.OR);){let n=this.consume(U.OR);t=new Je(n.pos,this.input,[n.value,t,this.parseLogicalAnd()])}return t}parseLogicalAnd(){let t=this.parseEquality();for(;this.match(U.AND);){let n=this.consume(U.AND);t=new Je(n.pos,this.input,[n.value,t,this.parseEquality()])}return t}parseEquality(){let t=this.parseRelational();for(;this.match(U.EQ)||this.match(U.NE);){let n=this.currentToken;this.currentToken=this.lexer.nextToken(),t=new Je(n.pos,this.input,[n.value,t,this.parseRelational()])}return t}parseRelational(){let t=this.parseAdditive();for(;this.match(U.LT)||this.match(U.LE)||this.match(U.GT)||this.match(U.GE)||this.match(U.IN);){let n=this.currentToken;this.currentToken=this.lexer.nextToken(),t=new Je(n.pos,this.input,[n.value,t,this.parseAdditive()])}return t}parseAdditive(){let t=this.parseMultiplicative();for(;this.match(U.PLUS)||this.match(U.MINUS);){let n=this.currentToken;this.currentToken=this.lexer.nextToken(),t=new Je(n.pos,this.input,[n.value,t,this.parseMultiplicative()])}return t}parseMultiplicative(){let t=this.parseUnary();for(;this.match(U.MULTIPLY)||this.match(U.DIVIDE)||this.match(U.MODULO);){let n=this.currentToken;this.currentToken=this.lexer.nextToken(),t=new Je(n.pos,this.input,[n.value,t,this.parseUnary()])}return t}parseUnary(){let t=this.currentToken;return t.type===U.NOT?(this.currentToken=this.lexer.nextToken(),new Je(t.pos,this.input,["!_",this.parseUnary()])):t.type===U.MINUS?(this.currentToken=this.lexer.nextToken(),new Je(t.pos,this.input,["-_",this.parseUnary()])):this.parsePostfix()}assertReservedIdentifier(t){if($4.has(t.value))throw new Ke(`Reserved identifier: ${t.value}`,{pos:t.pos,input:this.input})}parsePostfix(){let t=this.parsePrimary();for(;;)if(this.match(U.DOT)){this.consume(U.DOT);let n=this.consume(U.IDENTIFIER);if(this.match(U.LPAREN)){this.consume(U.LPAREN);let r=this.parseArgumentList();this.consume(U.RPAREN),t=new Je(n.pos,this.input,["rcall",n.value,t,r])}else t=new Je(n.pos,this.input,[".",t,n.value])}else if(this.match(U.LBRACKET)){let n=this.consume(U.LBRACKET),r=this.parseExpression();this.consume(U.RBRACKET),t=new Je(n.pos,this.input,["[]",t,r])}else break;return t}parsePrimary(){switch(this.currentToken.type){case U.NUMBER:{let t=this.consume(U.NUMBER);return new Je(t.pos,this.input,["value",t.value])}case U.STRING:{let t=this.consume(U.STRING);return new Je(t.pos,this.input,["value",t.value])}case U.BYTES:{let t=this.consume(U.BYTES);return new Je(t.pos,this.input,["value",t.value])}case U.BOOLEAN:{let t=this.consume(U.BOOLEAN);return new Je(t.pos,this.input,["value",t.value])}case U.NULL:{let t=this.consume(U.NULL);return new Je(t.pos,this.input,["value",t.value])}case U.IDENTIFIER:{let t=this.consume(U.IDENTIFIER);if(this.assertReservedIdentifier(t),this.match(U.LPAREN)){this.consume(U.LPAREN);let n=this.parseArgumentList();return this.consume(U.RPAREN),new Je(t.pos,this.input,["call",t.value,n])}return new Je(t.pos,this.input,["id",t.value])}case U.LPAREN:{this.consume(U.LPAREN);let t=this.parseExpression();return this.consume(U.RPAREN),t}case U.LBRACKET:return this.parseList();case U.LBRACE:return this.parseMap()}throw new Ke(`Unexpected token: ${Ud[this.currentToken.type]}`,{pos:this.currentToken.pos,input:this.input})}parseList(){let t=this.consume(U.LBRACKET),n=[];if(!this.match(U.RBRACKET))for(n.push(this.parseExpression());this.match(U.COMMA);)this.consume(U.COMMA),this.match(U.RBRACKET)||n.push(this.parseExpression());return this.consume(U.RBRACKET),new Je(t.pos,this.input,["list",n])}parseMap(){let t=this.consume(U.LBRACE),n=[];if(!this.match(U.RBRACE))for(n.push(this.parseProperty());this.match(U.COMMA);)this.consume(U.COMMA),this.match(U.RBRACE)||n.push(this.parseProperty());return this.consume(U.RBRACE),new Je(t.pos,this.input,["map",n])}parseProperty(){let t=this.parseExpression();this.consume(U.COLON);let n=this.parseExpression();return[t,n]}parseArgumentList(){let t=[];if(!this.match(U.RPAREN))for(t.push(this.parseExpression());this.match(U.COMMA);)this.consume(U.COMMA),this.match(U.RPAREN)||t.push(this.parseExpression());return t}};var ir=class{#e;constructor(t){this.verify(BigInt(t))}get value(){return this.#e}valueOf(){return this.#e}verify(t){if(t<0n||t>18446744073709551615n)throw new K("Unsigned integer overflow");this.#e=t}get[Symbol.toStringTag](){return`value = ${this.#e}`}[Symbol.for("nodejs.util.inspect.custom")](){return`UnsignedInteger { value: ${this.#e} }`}},K4={h:3600000000000n,m:60000000000n,s:1000000000n,ms:1000000n,us:1000n,\u00B5s:1000n,ns:1n},Hs=class e{#e;#t;constructor(t,n=0){this.#e=BigInt(t),this.#t=n}get seconds(){return this.#e}get nanos(){return this.#t}valueOf(){return Number(this.#e)*1e3+this.#t/1e6}addDuration(t){let n=this.#t+t.nanos;return new e(this.#e+t.seconds+BigInt(Math.floor(n/1e9)),n%1e9)}subtractDuration(t){let n=this.#t-t.nanos;return new e(this.#e-t.seconds+BigInt(Math.floor(n/1e9)),(n+1e9)%1e9)}extendTimestamp(t){return new Date(t.getTime()+Number(this.#e)*1e3+Math.floor(this.#t/1e6))}subtractTimestamp(t){return new Date(t.getTime()-Number(this.#e)*1e3-Math.floor(this.#t/1e6))}toString(){let t=this.#t?(this.#t/1e9).toLocaleString("en-US",{useGrouping:!1,maximumFractionDigits:9}).slice(1):"";return`${this.#e}${t}s`}getHours(){return this.#e/3600n}getMinutes(){return this.#e/60n}getSeconds(){return this.#e}getMilliseconds(){return this.#e*1000n+BigInt(Math.floor(this.#t/1e6))}get[Symbol.toStringTag](){return"google.protobuf.Duration"}[Symbol.for("nodejs.util.inspect.custom")](){return`google.protobuf.Duration { seconds: ${this.#e}, nanos: ${this.#t} }`}};function XM(e){let t=(f,g)=>e.registerFunctionOverload(f,g),n=f=>f;t("has(ast): bool",function(f){let g=f[2][0];if(g[0]===".")return r(this,g,f)!==void 0;throw new K("has() invalid argument",f)});function r(f,g,v){switch(g[0]){case"id":return f.eval(g);case".":{let I=r(f,g[1],v);if(!I)throw new K(`No such key: ${g[2]}`,g);return f.debugType(I).fieldLazy(I,g[2],v,f)}}throw new K("has() invalid argument",v)}t("dyn(dyn): dyn",n);for(let f in mi){let g=mi[f];g instanceof Dt&&t(`type(${g.name}): type`,()=>g)}t("bool(bool): bool",n),t("bool(string): bool",f=>{switch(f){case"1":case"t":case"true":case"TRUE":case"True":return!0;case"0":case"f":case"false":case"FALSE":case"False":return!1;default:throw new K(`bool() conversion error: invalid string value "${f}"`)}});let i=Object.keys;t("size(string): int",f=>BigInt(JM(f))),t("size(bytes): int",f=>BigInt(f.length)),t("size(list): int",f=>BigInt(f.length??f.size)),t("size(map): int",f=>BigInt(f instanceof Map?f.size:i(f).length)),t("string.size(): int",f=>BigInt(JM(f))),t("bytes.size(): int",f=>BigInt(f.length)),t("list.size(): int",f=>BigInt(f.length??f.size)),t("map.size(): int",f=>BigInt(f instanceof Map?f.size:i(f).length)),t("bytes(string): bytes",f=>a.fromString(f)),t("bytes(bytes): bytes",n),t("double(double): double",n),t("double(int): double",f=>Number(f)),t("double(string): double",f=>{if(!f||f!==f.trim())throw new K("double() type error: cannot convert to double");switch(f.toLowerCase()){case"inf":case"+inf":case"infinity":case"+infinity":return Number.POSITIVE_INFINITY;case"-inf":case"-infinity":return Number.NEGATIVE_INFINITY;case"nan":return Number.NaN;default:{let v=Number(f);if(!Number.isNaN(v))return v;throw new K("double() type error: cannot convert to double")}}}),t("int(int): int",n),t("int(double): int",f=>{if(Number.isFinite(f))return BigInt(Math.trunc(f));throw new K("int() type error: integer overflow")}),t("int(string): int",f=>{if(f!==f.trim()||f.length>20||f.includes("0x"))throw new K("int() type error: cannot convert to int");try{let g=BigInt(f);if(g<=9223372036854775807n&&g>=-9223372036854775808n)return g}catch{}throw new K("int() type error: cannot convert to int")}),t("uint(uint): uint",n),t("uint(double): uint",f=>{if(Number.isFinite(f))return BigInt(Math.trunc(f));throw new K("int() type error: integer overflow")}),t("uint(string): uint",f=>{if(f!==f.trim()||f.length>20||f.includes("0x"))throw new K("uint() type error: cannot convert to uint");try{let g=BigInt(f);if(g<=18446744073709551615n&&g>=0n)return g}catch{}throw new K("uint() type error: cannot convert to uint")}),t("string(string): string",n),t("string(bool): string",f=>`${f}`),t("string(int): string",f=>`${f}`),t("string(bytes): string",f=>a.toUtf8(f)),t("string(double): string",f=>f===1/0?"+Inf":f===-1/0?"-Inf":`${f}`),t("string.startsWith(string): bool",(f,g)=>f.startsWith(g)),t("string.endsWith(string): bool",(f,g)=>f.endsWith(g)),t("string.contains(string): bool",(f,g)=>f.includes(g)),t("string.indexOf(string): bool",(f,g)=>BigInt(f.indexOf(g))),t("string.indexOf(string, int): bool",(f,g,v)=>{if(g==="")return v;if(v=Number(v),v<0||v>=f.length)throw new K("string.indexOf(search, fromIndex): fromIndex out of range");return BigInt(f.indexOf(g,v))}),t("string.lastIndexOf(string): bool",(f,g)=>BigInt(f.lastIndexOf(g))),t("string.lastIndexOf(string, int): bool",(f,g,v)=>{if(g==="")return v;if(v=Number(v),v<0||v>=f.length)throw new K("string.lastIndexOf(search, fromIndex): fromIndex out of range");return BigInt(f.lastIndexOf(g,v))}),t("string.substring(int): string",(f,g)=>{if(g=Number(g),g<0||g>f.length)throw new K("string.substring(start, end): start index out of range");return f.substring(g)}),t("string.substring(int, int): string",(f,g,v)=>{if(g=Number(g),g<0||g>f.length)throw new K("string.substring(start, end): start index out of range");if(v=Number(v),v<g||v>f.length)throw new K("string.substring(start, end): end index out of range");return f.substring(g,v)}),t("string.matches(string): bool",(f,g)=>{try{return new RegExp(g).test(f)}catch{throw new K(`Invalid regular expression: ${g}`)}}),t("string.split(string): list",(f,g)=>f.split(g)),t("string.split(string, int): list",(f,g,v)=>f.split(g,v)),t("list.join(): string",f=>{for(let g=0;g<f.length;g++)if(typeof f[g]!="string")throw new K("string.join(): list must contain only strings");return f.join("")}),t("list.join(string): string",(f,g)=>{for(let v=0;v<f.length;v++)if(typeof f[v]!="string")throw new K("string.join(separator): list must contain only strings");return f.join(g)});let o=new TextEncoder("utf8"),s=new TextDecoder("utf8"),a=typeof Buffer<"u"?{byteLength:f=>Buffer.byteLength(f),fromString:f=>Buffer.from(f,"utf8"),toHex:f=>Buffer.prototype.hexSlice.call(f,0,f.length),toBase64:f=>Buffer.prototype.base64Slice.call(f,0,f.length),toUtf8:f=>Buffer.prototype.utf8Slice.call(f,0,f.length),jsonParse:f=>JSON.parse(f)}:{textEncoder:new TextEncoder("utf8"),byteLength:f=>o.encode(f).length,fromString:f=>o.encode(f),toHex:Uint8Array.prototype.toHex?f=>f.toHex():f=>Array.from(f,g=>g.toString(16).padStart(2,"0")).join(""),toBase64:Uint8Array.prototype.toBase64?f=>f.toBase64():f=>btoa(Array.from(f,g=>String.fromCodePoint(g)).join("")),toUtf8:f=>s.decode(f),jsonParse:f=>JSON.parse(o.decode(f))};t("bytes.json(): map",a.jsonParse),t("bytes.hex(): string",a.toHex),t("bytes.string(): string",a.toUtf8),t("bytes.base64(): string",a.toBase64),t("bytes.at(int): int",(f,g)=>{if(g<0||g>=f.length)throw new K("Bytes index out of range");return BigInt(f[g])});let c="google.protobuf.Timestamp";function l(f,g){return new Date(f.toLocaleString("en-US",{timeZone:g}))}function p(f,g){let v=g?l(f,g):new Date(f.getUTCFullYear(),f.getUTCMonth(),f.getUTCDate()),I=new Date(v.getFullYear(),0,0);return BigInt(Math.floor((v-I)/864e5)-1)}t(`timestamp(string): ${c}`,f=>{if(f.length<20||f.length>30)throw new K("timestamp() requires a string in ISO 8601 format");let g=new Date(f);if(g<=0xe677d21fdbff&&g>=-621355968e5)return g;throw new K("timestamp() requires a string in ISO 8601 format")}),t(`timestamp(int): ${c}`,f=>{if(f=Number(f)*1e3,f<=0xe677d21fdbff&&f>=-621355968e5)return new Date(f);throw new K("timestamp() requires a valid integer unix timestamp")}),t(`${c}.getDate(): int`,f=>BigInt(f.getUTCDate())),t(`${c}.getDate(string): int`,(f,g)=>BigInt(l(f,g).getDate())),t(`${c}.getDayOfMonth(): int`,f=>BigInt(f.getUTCDate()-1)),t(`${c}.getDayOfMonth(string): int`,(f,g)=>BigInt(l(f,g).getDate()-1)),t(`${c}.getDayOfWeek(): int`,f=>BigInt(f.getUTCDay())),t(`${c}.getDayOfWeek(string): int`,(f,g)=>BigInt(l(f,g).getDay())),t(`${c}.getDayOfYear(): int`,p),t(`${c}.getDayOfYear(string): int`,p),t(`${c}.getFullYear(): int`,f=>BigInt(f.getUTCFullYear())),t(`${c}.getFullYear(string): int`,(f,g)=>BigInt(l(f,g).getFullYear())),t(`${c}.getHours(): int`,f=>BigInt(f.getUTCHours())),t(`${c}.getHours(string): int`,(f,g)=>BigInt(l(f,g).getHours())),t(`${c}.getMilliseconds(): int`,f=>BigInt(f.getUTCMilliseconds())),t(`${c}.getMilliseconds(string): int`,f=>BigInt(f.getUTCMilliseconds())),t(`${c}.getMinutes(): int`,f=>BigInt(f.getUTCMinutes())),t(`${c}.getMinutes(string): int`,(f,g)=>BigInt(l(f,g).getMinutes())),t(`${c}.getMonth(): int`,f=>BigInt(f.getUTCMonth())),t(`${c}.getMonth(string): int`,(f,g)=>BigInt(l(f,g).getMonth())),t(`${c}.getSeconds(): int`,f=>BigInt(f.getUTCSeconds())),t(`${c}.getSeconds(string): int`,(f,g)=>BigInt(l(f,g).getSeconds()));let d=/(\d*\.?\d*)(ns|us|µs|ms|s|m|h)/;function m(f){if(!f)throw new K("Invalid duration string: ''");let g=f[0]==="-";(f[0]==="-"||f[0]==="+")&&(f=f.slice(1));let v=BigInt(0);for(;;){let O=d.exec(f);if(!O)throw new K(`Invalid duration string: ${f}`);if(O.index!==0)throw new K(`Invalid duration string: ${f}`);f=f.slice(O[0].length);let C=K4[O[2]],[z="0",F=""]=O[1].split("."),N=BigInt(z)*C,H=F?BigInt(F.slice(0,13).padEnd(13,"0"))*C/10000000000000n:0n;if(v+=N+H,f==="")break}let I=v>=1000000000n?v/1000000000n:0n,M=Number(v%1000000000n);return g?new Hs(-I,-M):new Hs(I,M)}t("duration(string): google.protobuf.Duration",f=>m(f)),t("google.protobuf.Duration.getHours(): int",f=>f.getHours()),t("google.protobuf.Duration.getMinutes(): int",f=>f.getMinutes()),t("google.protobuf.Duration.getSeconds(): int",f=>f.getSeconds()),t("google.protobuf.Duration.getMilliseconds(): int",f=>f.getMilliseconds());function y(f,g){return f.type==="list"?f.valueType:f.type==="map"?f.keyType:g.getType("dyn")}function S(f,g){let v=f[0];if(v instanceof Je&&v[0]==="id")return v[1];throw new ze(`${g} requires first argument to be an identifier`,v)}function T(f){return(g,v,I)=>{let M=S(I,`${f}(var, predicate)`),O=y(v,g),z=g.createOverlay(M,O).check(I[1]);if(z.isDynOrBool())return z;throw new ze(`predicate must return bool, got '${z}'`,I[1])}}function E(f,g,v){let I=`map(var, ${v.length===3?"filter, ":""}transform)`,M=S(v,I),O=y(g,f),C=f.createOverlay(M,O);if(v.length===3){let z=C.check(v[1]);if(!z.isDynOrBool())throw new ze(`${I} filter predicate must return bool, got '${z}'`,v[1])}return f.getType(`list<${C.check(v[v.length-1])}>`)}function b(f,g,v){let I="filter(var, filter)",M=S(v,I),O=y(g,f),z=f.createOverlay(M,O).check(v[1]);if(z.isDynOrBool())return f.getType(`list<${O}>`);throw new ze(`${I} predicate must return bool, got '${z}'`,v[1])}t("list.all(ast, ast): bool",{handler:HM,typeCheck:T("all")}),t("map.all(ast, ast): bool",{handler:HM,typeCheck:T("all")}),t("list.exists(ast, ast): bool",{handler:GM,typeCheck:T("exists")}),t("map.exists(ast, ast): bool",{handler:GM,typeCheck:T("exists")}),t("list.exists_one(ast, ast): bool",{handler:qM,typeCheck:T("exists_one")}),t("map.exists_one(ast, ast): bool",{handler:qM,typeCheck:T("exists_one")}),t("list.map(ast, ast): list",{handler:VM,typeCheck:E}),t("list.map(ast, ast, ast): list",{handler:QM,typeCheck:E}),t("map.map(ast, ast): list",{handler:VM,typeCheck:E}),t("map.map(ast, ast, ast): list",{handler:QM,typeCheck:E}),t("list.filter(ast, ast): list",{handler:YM,typeCheck:b}),t("map.filter(ast, ast): list",{handler:YM,typeCheck:b})}var ic=Symbol("predicateEvaluator");function HM(e,t){let n=t[ic]??=this.predicateEvaluator("all(var, predicate)",t),r=n.getIterableItems(e),i=null;for(let o=0;o<r.length;o++)try{if(n.childEvaluateBool(r[o]))continue;return!1}catch(s){if(s.message.includes("Unknown variable")||s.message.includes("predicate result is not a boolean"))throw s;i??=s}if(i)throw i;return!0}function GM(e,t){let n=t[ic]??=this.predicateEvaluator("exists(var, predicate)",t),r=n.getIterableItems(e),i;for(let o=0;o<r.length;o++)try{if(n.childEvaluateBool(r[o]))return!0}catch(s){if(s.message.includes("Unknown variable")||s.message.includes("predicate result is not a boolean"))throw s;i??=s}if(i)throw i;return!1}function qM(e,t){let n=t[ic]??=this.predicateEvaluator("exists_one(var, predicate)",t),r=n.getIterableItems(e),i=0;for(let o=0;o<r.length;o++)if(n.childEvaluateBool(r[o])!==!1&&++i>1)return!1;return i===1}function VM(e,t){let n=t[ic]??=this.predicateEvaluator("map(var, transform)",t),r=n.getIterableItems(e),i=[];for(let o=0;o<r.length;o++)i[o]=n.childEvaluate(r[o]);return i}function QM(e,t){let n=t[ic]??=this.predicateEvaluator("map(var, filter, transform)",t),r=t[3][2],i=n.getIterableItems(e),o=[];for(let s=0;s<i.length;s++)switch(n.childEvaluateBool(i[s])){case!1:continue;case!0:o.push(n.eval(r));continue}return o}function YM(e,t){let n=t[ic]??=this.predicateEvaluator("filter(var, predicate)",t),r=n.getIterableItems(e),i=[];for(let o=0;o<r.length;o++){let s=r[o];n.childEvaluateBool(s)!==!1&&i.push(s)}return i}function JM(e){let t=0;for(let n of e)t++;return t}var Dt=class{#e;constructor(t){this.#e=t,Object.freeze(this)}get name(){return this.#e}get[Symbol.toStringTag](){return`Type<${this.#e}>`}toString(){return`Type<${this.#e}>`}},mi={string:new Dt("string"),bool:new Dt("bool"),int:new Dt("int"),uint:new Dt("uint"),double:new Dt("double"),map:new Dt("map"),list:new Dt("list"),bytes:new Dt("bytes"),null_type:new Dt("null"),type:new Dt("type"),google:{protobuf:{Timestamp:new Dt("google.protobuf.Timestamp"),Duration:new Dt("google.protobuf.Duration")}}};mi["google.protobuf.Timestamp"]=mi.google.protobuf.Timestamp;mi["google.protobuf.Duration"]=mi.google.protobuf.Duration;var jd=class e{#e=null;#t=null;constructor(t){t instanceof e?(this.#e=t,this.#t=new Map):this.#t=new Map(t)}fork(t=!0){return t&&(this.set=this.#r),new this.constructor(this)}#r(){throw new Error("Cannot modify frozen registry")}set(t,n){return this.#t.set(t,n),this}has(t){return this.#t.has(t)||(this.#e?this.#e.has(t):!1)}get(t){return this.#t.get(t)||this.#e?.get(t)}*#n(){this.#e&&(yield*this.#e),yield*this.#t}[Symbol.iterator](){return this.#n()}get size(){return this.#t.size+(this.#e?this.#e.size:0)}},iS=class extends jd{constructor(t=null,n=null){super(t,n)}get(t){let n=super.get(t);return n===void 0?Xr:n}};function ko(e,t=jd,n=!0){return e instanceof t?e.fork(n):new t(e)}var Do=class{#e=new WeakMap;constructor({kind:t,type:n,name:r,keyType:i,valueType:o,values:s}){this.kind=t,this.type=n,this.name=r,i&&(this.keyType=i),o&&(this.valueType=o),s&&(this.values=s),t==="list"?this.fieldLazy=this.#n:t==="map"?this.fieldLazy=this.#r:t==="message"?this.fieldLazy=this.#t:t==="dyn"&&(this.fieldLazy=this.#r),Object.freeze(this)}isDynOrBool(){return this.type==="bool"||this.kind==="dyn"}toString(){return this.name}#t(t,n,r,i){let o=i.objectTypesByConstructor.get(t.constructor);if(!o)return;if(!o.fields)return Object.hasOwn(t,n)?t[n]:void 0;let s=o.fields[n];if(!s)return;let a=t[n];if(s.kind==="dyn")return a;let c=i.debugType(a);if(s.matches(c))return a;throw new K(`Field '${n}' is not of type '${s}', got '${c}'`,r)}#r(t,n,r,i){let o;if(t instanceof Map?o=t.get(n):o=Object.hasOwn(t,n)?t[n]:void 0,o===void 0)return;if(this.valueType.kind==="dyn")return o;let s=i.debugType(o);if(this.valueType.matches(s))return o;throw new K(`Field '${n}' is not of type '${this.valueType}', got '${s}'`,r)}#n(t,n,r,i){if(!(typeof n=="number"||typeof n=="bigint"))return;let o=t[n];if(o===void 0)throw new K(`No such key: index out of bounds, index ${n} ${n<0?"< 0":`>= size ${t.length}`}`,r);let s=i.debugType(o);if(this.valueType.matches(s))return o;throw new K(`List item with index '${n}' is not of type '${this.valueType}', got '${s}'`,r)}fieldLazy(){}field(t,n,r,i){let o=this.fieldLazy(t,n,r,i);if(o!==void 0)return o;throw new K(`No such key: ${n}`,r)}matchesBoth(t){return this.matches(t)&&t.matches(this)}matches(t){return this.#e.get(t)??this.#e.set(t,this.#o(t)).get(t)}#o(t){if(this===t)return!0;if(t.kind==="dyn")return t.valueType?this.matches(t.valueType):!0;switch(this.kind){case"dyn":return!0;case"list":return t.kind==="list"&&this.valueType.matches(t.valueType);case"map":return t.kind==="map"&&this.keyType.matches(t.keyType)&&this.valueType.matches(t.valueType);default:return this.name===t.name}}},oS=class{constructor({name:t,receiverType:n,argTypes:r,returnType:i,handler:o,typeCheck:s}){this.name=t,this.macro=r.includes(_d),this.receiverType=n||null,this.argTypes=r,this.returnType=i;let a=n?`${n}.`:"";this.signature=`${a}${t}(${r.join(", ")}): ${i}`,this.handler=o,this.typeCheck=s,Object.freeze(this)}matchesArgs(t){return t.length!==this.argTypes.length?!1:this.argTypes.every((n,r)=>n.matches(t[r]))}},Gs=class{constructor({operator:t,leftType:n,rightType:r,handler:i,returnType:o}){this.operator=t,this.leftType=n,this.rightType=r||null,this.handler=i,this.returnType=o,r?this.signature=`${n} ${t} ${r}: ${o}`:this.signature=`${t}${n}: ${o}`,Object.freeze(this)}get isUnary(){return this.rightType===null}get isBinary(){return this.rightType!==null}equals(t){return this.operator===t.operator&&this.leftType===t.leftType&&this.rightType===t.rightType}};function rO(e){return new Do({kind:"list",name:`list<${e}>`,type:"list",valueType:e})}function Jr(e){return new Do({kind:"primitive",name:e,type:e})}function z4(e){return new Do({kind:"message",name:e,type:e})}function iO(e){let t=e?`dyn<${e}>`:"dyn";return new Do({kind:"dyn",name:t,type:t,valueType:e})}function oO(e,t){return new Do({kind:"map",name:`map<${e}, ${t}>`,type:"map",keyType:e,valueType:t})}var Xr=iO(),_d=Jr("ast"),ZM=rO(Xr),WM=oO(Xr,Xr),Hi=Object.freeze({string:Jr("string"),bool:Jr("bool"),int:Jr("int"),uint:Jr("uint"),double:Jr("double"),bytes:Jr("bytes"),dyn:Xr,null:Jr("null"),type:Jr("type"),"google.protobuf.Timestamp":Jr("google.protobuf.Timestamp"),"google.protobuf.Duration":Jr("google.protobuf.Duration"),list:ZM,"list<dyn>":ZM,map:WM,"map<dyn, dyn>":WM}),Ld=class{functions=[];exists=!1;hasMacro=!1;add(t){this.exists=!0,t.macro&&(this.hasMacro=!0),this.functions.push(t)}findMatch(t){if(!this.exists)return null;for(let n of this.functions)if(n.matchesArgs(t))return n;return null}},eO=new Ld,sS=class{exists=!1;hasMacro=!1;returnType=null;#e=new Map;add(t){this.exists=!0,t.macro&&(this.hasMacro=!0),this.returnType?t.typeCheck?this.returnType=Xr:this.returnType!==t.returnType&&(this.returnType=Xr):this.returnType=t.returnType;let n=t.receiverType;(this.#e.get(n)||this.#e.set(n,new Ld).get(n)).add(t)}filterByReceiverType(t){return t===null?this.#e.get(null)||eO:this.#e.get(t)||(t.type==="list"||t.type==="map"?this.#e.get(Hi[t.type]):null)||eO}};function tO(e){let t=[],n="",r=0;for(let i of e){if(i==="<")r++;else if(i===">")r--;else if(i===","&&r===0){t.push(n),n="";continue}n+=i}return n&&t.push(n),t}var sO=[[void 0,"map"],[Object,"map"],[Map,"map"],[Array,"list"],[Uint8Array,"bytes"],[Date,"google.protobuf.Timestamp"],[Hs,"google.protobuf.Duration"],[ir,"uint"],[Dt,"type"]];typeof Buffer<"u"&&sO.push([Buffer,"bytes"]);var aS=class e{#e={};#t={};#r;#n;#o;#a=new Map;constructor(t={}){if(this.objectTypes=ko(t.objectTypes),this.objectTypesByConstructor=ko(t.objectTypesByConstructor),this.objectTypeInstances=ko(t.objectTypeInstances),this.#o=ko(t.functionDeclarations),this.#n=ko(t.operatorDeclarations),this.#r=ko(t.typeDeclarations||Object.entries(Hi),void 0,!1),this.variables=t.unlistedVariablesAreDyn?ko(t.variables,iS):ko(t.variables),!this.variables.size){for(let[r,i]of sO)this.registerType(i,r,!0);let n=new Map(Object.entries(mi));for(let[r,i]of n)i instanceof Dt&&this.registerVariable(r,"type")}}#s(){this.#e={},this.#t={}}registerVariable(t,n){if(this.variables.has(t))throw new Error(`Variable already registered: ${t}`);return this.variables.set(t,n instanceof Do?n:this.getType(n)),this}getFunctionCandidates(t,n,r){let i=new sS;for(let[,o]of this.#o)n===o.name&&(t===null&&o.receiverType||t&&o.receiverType===null||(i.exists=!0,o.macro&&(i.hasMacro=!0),!(t&&!t.matches(o.receiverType))&&o.argTypes.length===r&&i.add(o)));return i}getType(t){return this.#i(t,!0)}getDynType(t){return this.#a.get(t)||this.#a.set(t,this.#i(`dyn<${t}>`,!0)).get(t)}assertType(t,n,r){try{return this.#i(t,!0)}catch(i){throw i.message=`Invalid ${n} '${i.unknownType||t}' in '${r}'`,i}}getFunctionType(t){return t==="ast"?_d:this.#i(t,!0)}registerType(t,n,r){let i={name:t,type:this.#i(t,!1),ctor:typeof n=="function"?n:n?.ctor,fields:this.#x(t,n?.fields)};if(!r){if(this.objectTypes.has(t))throw new Error(`Type already registered: ${t}`);if(typeof i.ctor!="function")throw new Error(`Constructor function missing for type '${t}'`)}if(this.objectTypes.set(t,i),this.objectTypesByConstructor.set(i.ctor,i),r)return;let o=new Dt(t);this.objectTypeInstances.set(t,o),this.registerFunctionOverload(`type(${t}): type`,()=>o)}#i(t,n=!1){let r=this.#r.get(t);if(r)return r;let i=t.match(/^dyn<(.+)>$/);if(i){let a=this.#i(i[1].trim(),n);return this.#c(iO,`dyn<${a}>`,a)}let o=t.match(/^list<(.+)>$/);if(o){let a=this.#i(o[1].trim(),n);return this.#c(rO,`list<${a}>`,a)}let s=t.match(/^map<(.+)>$/);if(s){let a=tO(s[1]);if(a.length!==2)throw new Error(`Invalid map type: ${t}`);let c=this.#i(a[0].trim(),n),l=this.#i(a[1].trim(),n);return this.#c(oO,`map<${c}, ${l}>`,c,l)}if(n){let a=new Error(`Unknown type: ${t}`);throw a.unknownType=t,a}return this.#c(z4,t,t)}#c(t,n,...r){return this.#r.get(n)||this.#r.set(n,t(...r)).get(n)}#p(t,n,r){let i=[];for(let[,o]of this.#n)if(o.operator===t){if(this.#h(o,n,r))return[o];this.#y(o,n,r)&&i.push(o)}return i.length===0&&(t==="=="||t==="!=")&&this.#b(n,r)?[{handler:t==="=="?(s,a)=>s===a:(s,a)=>s!==a,returnType:this.getType("bool")}]:i}findUnaryOverload(t,n){let r=this.#e[t]?.get(n);if(r!==void 0)return r;let i=!1;for(let[,o]of this.#n)if(!(o.operator!==t||o.leftType!==n)){i=o;break}return(this.#e[t]??=new Map).set(n,i).get(n)}findBinaryOverload(t,n,r){return this.#e[t]?.get(n)?.get(r)??this.#f(this.#e,t,n,r,this.#d(t,n,r))}checkBinaryOverload(t,n,r){return this.#t[t]?.get(n)?.get(r)??this.#f(this.#t,t,n,r,this.#m(t,n,r))}#d(t,n,r){let i=this.#p(t,n,r);if(i.length===0)return!1;if(i.length===1)return i[0];throw new Error(`Operator overload '${i[0].signature}' overlaps with '${i[1].signature}'.`)}#m(t,n,r){let i=this.#p(t,n,r);if(i.length===0)return!1;let o=i[0].returnType;return i.every(s=>s.returnType===o)?o:(o.kind==="list"||o.kind==="map")&&i.every(s=>s.returnType.kind===o.kind)?o.kind==="list"?Hi.list:Hi.map:Hi.dyn}#f(t,n,r,i,o){let s=t[n]??=new Map;return(s.get(r)||s.set(r,new Map).get(r)).set(i,o),o}#h(t,n,r){return n===t.leftType&&r===t.rightType||n.name===`dyn<${t.leftType}>`&&r===t.rightType||n===t.leftType&&r.name===`dyn<${t.rightType}>`||n.name===`dyn<${t.leftType}>`&&r.name===`dyn<${t.rightType}>`}#y(t,n,r){return!this.#u(n,t.leftType)||!this.#u(r,t.rightType)?!1:this.#g(t.operator,n,r)}#u(t,n){return t===n?!0:t.kind==="dyn"?t.valueType?this.#u(t.valueType,n):!0:t.type!==n.type?!1:n===Hi.list||n===Hi.map}#g(t,n,r){return t==="in"?n.kind==="dyn"?!0:r.kind==="list"?r.valueType.matchesBoth(n):r.kind==="map"?r.keyType.matchesBoth(n):!0:(t==="+"||t==="=="||t==="!=")&&(n.kind==="list"&&r.kind==="list"||n.kind==="map"&&r.kind==="map")?n.matchesBoth(r):!0}#b(t,n){return t.kind==="dyn"||n.kind==="dyn"}#S(t,n,r,i=!1){try{let o=typeof n[r]=="string"?{type:n[r]}:{...n[r]};if(typeof o?.type!="string")throw new Error("unsupported declaration");return this.#i(o.type,i)}catch(o){throw o.message=`Field '${r}' in type '${t}' has unsupported declaration: ${JSON.stringify(n[r])}`,o}}#x(t,n){if(!n)return;let r={};for(let i of Object.keys(n))r[i]=this.#S(t,n,i);return r}clone(t={}){return new e({objectTypes:this.objectTypes,objectTypesByConstructor:this.objectTypesByConstructor,objectTypeInstances:this.objectTypeInstances,typeDeclarations:this.#r,operatorDeclarations:this.#n,functionDeclarations:this.#o,variables:this.variables,unlistedVariablesAreDyn:t.unlistedVariablesAreDyn})}#T(t,n,r){let i=t.match(/^(?:([a-zA-Z0-9.]+)\.)?(\w+)\((.*?)\):\s*(.+)$/);if(!i)throw new Error(`Invalid signature: ${t}`);let[,o,s,a,c]=i;try{return new oS({name:s,receiverType:o?this.getType(o.trim()):null,returnType:this.getType(c.trim()||"dyn"),argTypes:tO(a).map(l=>this.getFunctionType(l.trim())),handler:n,typeCheck:r})}catch{throw new Error(`Invalid function declaration: ${t}`)}}#v(t,n){return t.name!==n.name||t.argTypes.length!==n.argTypes.length||(t.receiverType||n.receiverType)&&(!t.receiverType||!n.receiverType)?!1:!(t.receiverType!==n.receiverType&&t.receiverType!==Xr&&n.receiverType!==Xr)&&(n.macro||t.macro||n.argTypes.every((i,o)=>{let s=t.argTypes[o];return i===s||i===_d||s===_d||i===Xr||s===Xr}))}#I(t){for(let[,n]of this.#o)if(this.#v(n,t))throw new Error(`Function signature '${t.signature}' overlaps with existing overload '${n.signature}'.`)}registerFunctionOverload(t,n){let r=typeof n=="function"?n:n.handler,i=typeof n=="function"?{}:n,o=this.#T(t,r,i.typeCheck);this.#I(o),this.#o.set(o.signature,o)}registerOperatorOverload(t,n){let r=t.match(/^([-!])([\w.<>]+)(?::\s*([\w.<>]+))?$/);if(r){let[,l,p,d]=r;return this.unaryOverload(l,p,n,d)}let i=t.match(/^([\w.<>]+) ([-+*%/]|==|!=|<|<=|>|>=|in) ([\w.<>]+)(?::\s*([\w.<>]+))?$/);if(!i)throw new Error(`Operator overload invalid: ${t}`);let[,o,s,a,c]=i;return this.binaryOverload(o,s,a,n,c)}unaryOverload(t,n,r,i){let o=this.assertType(n,"type",`${t}${n}`),s=this.assertType(i||n,"return type",`${t}${n}: ${i||n}`),a=new Gs({operator:`${t}_`,leftType:o,returnType:s,handler:r});if(this.#l(a))throw new Error(`Operator overload already registered: ${t}${n}`);this.#n.set(a.signature,a),this.#s()}#l(t){for(let[,n]of this.#n)if(t.equals(n))return!0;return!1}binaryOverload(t,n,r,i,o){o??=nO(n)?"bool":t;let s=`${t} ${n} ${r}: ${o}`,a=this.assertType(t,"left type",s),c=this.assertType(r,"right type",s),l=this.assertType(o,"return type",s);if(nO(n)&&l.type!=="bool")throw new Error(`Comparison operator '${n}' must return 'bool', got '${l.type}'`);let p=new Gs({operator:n,leftType:a,rightType:c,returnType:l,handler:i});if(this.#l(p))throw new Error(`Operator overload already registered: ${p.signature}`);if(n==="=="){let d=[new Gs({operator:"!=",leftType:a,rightType:c,handler(m,y,S,T){return!i(m,y,S,T)},returnType:l})];a!==c&&d.push(new Gs({operator:"==",leftType:c,rightType:a,handler(m,y,S,T){return i(y,m,S,T)},returnType:l}),new Gs({operator:"!=",leftType:c,rightType:a,handler(m,y,S,T){return!i(y,m,S,T)},returnType:l}));for(let m of d)if(this.#l(m))throw new Error(`Operator overload already registered: ${m.signature}`);for(let m of d)this.#n.set(m.signature,m)}this.#n.set(p.signature,p),this.#s()}};function nO(e){return e==="<"||e==="<="||e===">"||e===">="||e==="=="||e==="!="||e==="in"}function aO(e){return new aS(e)}u();function cO(e){let t=e.unaryOverload.bind(e),n=e.binaryOverload.bind(e);function r(c,l){if(c<=9223372036854775807n&&c>=-9223372036854775808n)return c;throw new K(`integer overflow: ${c}`,l)}t("!","bool",c=>!c),t("-","int",c=>-c),n("int","*","int",(c,l,p)=>r(c*l,p)),n("int","+","int",(c,l,p)=>r(c+l,p)),n("int","-","int",(c,l,p)=>r(c-l,p)),n("int","/","int",(c,l,p)=>{if(l===0n)throw new K("division by zero",p);return c/l}),n("int","%","int",(c,l,p)=>{if(l===0n)throw new K("modulo by zero",p);return c%l}),t("-","double",c=>-c),n("double","*","double",(c,l)=>c*l),n("double","+","double",(c,l)=>c+l),n("double","-","double",(c,l)=>c-l),n("double","/","double",(c,l,p)=>{if(l===0)throw new K("division by zero",p);return c/l}),n("string","+","string",(c,l)=>c+l),n("list","+","list",(c,l)=>[...c,...l]),n("bytes","+","bytes",(c,l)=>{let p=new Uint8Array(c.length+l.length);return p.set(c,0),p.set(l,c.length),p});let i="google.protobuf.Duration";n(i,"+",i,(c,l)=>c.addDuration(l)),n(i,"-",i,(c,l)=>c.subtractDuration(l)),n(i,"==",i,(c,l)=>c.seconds===l.seconds&&c.nanos===l.nanos);let o="google.protobuf.Timestamp";n(o,"==",o,(c,l)=>c.getTime()===l.getTime()),n(o,"-",i,(c,l)=>l.subtractTimestamp(c)),n(o,"+",i,(c,l)=>l.extendTimestamp(c)),n(i,"+",o,(c,l)=>c.extendTimestamp(l));function s(c,l,p,d){if(l instanceof Set&&l.has(c))return!0;for(let m of l)if(Rl(c,m,d))return!0;return!1}function a(c,l){return Array.isArray(l)?l.includes(c):l.has(c)}for(let c of["string","bool","null","type"])n(c,"in","list",a);for(let c of["int","double","list","map"])n(c,"in","list",s);for(let c of["string","int","double","bool","null"])n(c,"in","map",(l,p)=>p instanceof Map?p.get(l)!==void 0:Object.hasOwn(p,l)?p[l]!==void 0:!1);for(let c of["type","null","bool","string","int","uint","double"])n(c,"==",c,(l,p)=>l===p);n("int","==","dyn<double>",(c,l)=>c==l),n("int","==","dyn<uint>",(c,l)=>c==l.valueOf()),n("uint","==","dyn<double>",(c,l)=>c.valueOf()==l),n("uint","==","dyn<int>",(c,l)=>c.valueOf()==l),n("double","==","dyn<int>",(c,l)=>c==l),n("double","==","dyn<uint>",(c,l)=>c==l.valueOf()),n("bytes","==","bytes",(c,l)=>{let p=c.length;if(p!==l.length)return!1;for(;p--;)if(c[p]!==l[p])return!1;return!0}),n("list","==","list",(c,l,p,d)=>{if(Array.isArray(c)&&Array.isArray(l)){let S=c.length;if(S!==l.length)return!1;for(let T=0;T<S;T++)if(!Rl(c[T],l[T],d))return!1;return!0}if(c instanceof Set&&l instanceof Set){if(c.size!==l.size)return!1;for(let S of c)if(!l.has(S))return!1;return!0}let m=c instanceof Set?l:c,y=c instanceof Set?c:l;if(!Array.isArray(m)||m.length!==y?.size)return!1;for(let S=0;S<m.length;S++)if(!y.has(m[S]))return!1;return!0}),n("map","==","map",(c,l,p,d)=>{if(c instanceof Map&&l instanceof Map){if(c.size!==l.size)return!1;for(let[S,T]of c)if(!(l.has(S)&&Rl(T,l.get(S),d)))return!1;return!0}if(c instanceof Map||l instanceof Map){let S=c instanceof Map?l:c,T=c instanceof Map?c:l,E=Object.keys(S);if(T.size!==E.length)return!1;for(let[b,f]of T)if(!(b in S&&Rl(f,S[b],d)))return!1;return!0}let m=Object.keys(c),y=Object.keys(l);if(m.length!==y.length)return!1;for(let S=0;S<m.length;S++){let T=m[S];if(!(T in l&&Rl(c[T],l[T],d)))return!1}return!0}),n("uint","+","uint",(c,l)=>new ir(c.valueOf()+l.valueOf())),n("uint","-","uint",(c,l)=>new ir(c.valueOf()-l.valueOf())),n("uint","*","uint",(c,l)=>new ir(c.valueOf()*l.valueOf())),n("uint","/","uint",(c,l,p)=>{if(l.valueOf()===0n)throw new K("division by zero",p);return new ir(c.valueOf()/l.valueOf())}),n("uint","%","uint",(c,l,p)=>{if(l.valueOf()===0n)throw new K("modulo by zero",p);return new ir(c.valueOf()%l.valueOf())});for(let[c,l]of[["int","int"],["uint","uint"],["double","double"],["string","string"],["google.protobuf.Timestamp","google.protobuf.Timestamp"],["google.protobuf.Duration","google.protobuf.Duration"],["int","uint"],["int","double"],["double","int"],["double","uint"],["uint","int"],["uint","double"]])n(c,"<",l,(p,d)=>p<d),n(c,"<=",l,(p,d)=>p<=d),n(c,">",l,(p,d)=>p>d),n(c,">=",l,(p,d)=>p>=d)}function Rl(e,t,n){if(e===t)return!0;switch(typeof e){case"string":return!1;case"bigint":return typeof t=="number"?e==t:!1;case"number":return typeof t=="bigint"?e==t:!1;case"boolean":return!1;case"object":if(typeof t!="object"||e===null||t===null)return!1;let r=n.objectTypesByConstructor.get(e.constructor)?.type,i=n.objectTypesByConstructor.get(t.constructor)?.type;if(!r||r!==i)return!1;let o=n.registry.findBinaryOverload("==",r,i)?.handler;return o?o(e,t,null,n):!1}throw new K(`Cannot compare values of type ${typeof e}`)}u();var Bd=class{constructor({ctx:t,objectTypes:n,objectTypesByConstructor:r,registry:i}){this.ctx=t,this.objectTypes=n,this.objectTypesByConstructor=r,this.registry=i}getType(t){return this.registry.getType(t)}createOverlay(t,n){return new this.constructor({ctx:this.ctx.createOverlay(t,n),objectTypes:this.objectTypes,objectTypesByConstructor:this.objectTypesByConstructor,registry:this.registry})}check(t){if(t.checkedType)return t.checkedType;switch(t[0]){case"value":return t.checkedType??=this.inferLiteralType(t[1]);case"id":return t.checkedType??=this.checkVariable(t);case".":case"[]":return t.checkedType??=this.checkAccess(t);case"call":return t.checkedType??=this.checkCall(t);case"rcall":return t.checkedType??=this.checkReceiverCall(t);case"list":return t.checkedType??=this.checkList(t);case"map":return t.checkedType??=this.checkMap(t);case"?:":return t.checkedType??=this.checkTernary(t);case"||":case"&&":return t.checkedType??=this.checkLogicalOp(t);case"!_":case"-_":return t.checkedType??=this.checkUnaryOperator(t);case"==":case"!=":case"<":case"<=":case">":case">=":case"+":case"-":case"*":case"/":case"%":case"in":return t.checkedType??=this.checkBinaryOperator(t);default:throw new ze(`Unknown operation: ${t[0]}`,t)}}inferLiteralType(t){switch(typeof t){case"string":return this.getType("string");case"bigint":return this.getType("int");case"number":return this.getType("double");case"boolean":return this.getType("bool");case"object":if(t===null)return this.getType("null");let n=this.objectTypesByConstructor.get(t.constructor)?.type;if(n)return n;throw new ze(`Unsupported type: ${t.constructor?.name||typeof t}`);default:throw new ze(`Unsupported type: ${typeof t}`)}}checkVariable(t){let n=t[1],r=this.ctx.getType(n);if(r!==void 0)return r;throw new ze(`Unknown variable: ${n}`,t)}checkAccess(t){let n=this.check(t[1]);if(n.kind==="dyn")return n;let i=(t[0]==="[]"?this.check(t[2]):this.getType("string")).type;if(n.kind==="list"){if(i!=="int"&&i!=="dyn")throw new ze(`List index must be int, got '${i}'`,t);return n.valueType}if(n.kind==="map")return n.valueType;let o=this.objectTypes.get(n.name);if(o){if(!(i==="string"||i==="dyn"))throw new ze(`Cannot index type '${n.name}' with type '${i}'`,t);if(o.fields){let s=t[0]==="."?t[2]:void 0;if(s){let a=o.fields[s];if(a)return a;throw new ze(`No such key: ${s}`,t)}}return this.getType("dyn")}throw new ze(`Cannot index type '${n}'`,t)}checkCall(t){let n=t[1],r=t[2],i=(t.functionCandidates??=this.registry.getFunctionCandidates(null,n,r.length)).filterByReceiverType(null);if(!i.exists)throw new ze(`Function not found: '${n}'`,t);if(i.hasMacro)return this.#e(null,i,r,t);let o=r.map(this.check,this),s=i.findMatch(o);if(!s)throw new ze(`found no matching overload for '${n}(${o.join(", ")})'`,t);return s.returnType}#e(t,n,r,i){let o=n.functions[0];return o.typeCheck?o.typeCheck(this,t,r,i):o.returnType}checkReceiverCall(t){let n=t[1],r=t[3],i=this.check(t[2]),o=t.functionCandidates??=this.registry.getFunctionCandidates(i,n,r.length);if(!o.exists)throw new ze(`Function not found: '${n}' for value of type '${i}'`,t);if(i.kind==="dyn")return o.returnType||i;let s=o.filterByReceiverType(i);if(s.hasMacro)return this.#e(i,s,r,t);let a=r.map(this.check,this),c=s.findMatch(a);if(!c)throw new ze(`found no matching overload for '${i.type}.${n}(${a.join(", ")})'`,t);return c.returnType}checkList(t){let n=t[1];if(n.length===0)return this.getType("list");let r=this.check(n[0]);return n.every(o=>r===this.check(o))?this.getType(`list<${r}>`):this.getType("list")}checkMap(t){let n=t[1];if(n.length===0)return this.getType("map");let r=this.check(n[0][0]),i=this.check(n[0][1]),o=!0,s=!0;for(let l=1;l<n.length;l++){let[p,d]=n[l];r!==this.check(p)&&(o=!1),i!==this.check(d)&&(s=!1)}let a=o?r:"dyn",c=s?i:"dyn";return this.getType(`map<${a}, ${c}>`)}checkTernary(t){let n=this.check(t[1]);if(!n.isDynOrBool())throw new ze(`Ternary condition must be bool, got '${n}'`,t);let r=this.check(t[2]),i=this.check(t[3]);if(r===i||r.name==="dyn")return r;if(i.name==="dyn")return i;throw new ze(`Ternary branches must have the same type, got '${r}' and '${i}'`,t)}checkLogicalOp(t){let n=this.check(t[1]),r=this.check(t[2]);if(!n.isDynOrBool())throw new ze(`Logical operator requires bool operands, got '${n}'`,t);if(!r.isDynOrBool())throw new ze(`Logical operator requires bool operands, got '${r}'`,t);return this.getType("bool")}checkUnaryOperator(t){let n=t[0],r=this.check(t[1]);if(r.kind==="dyn")return n==="!_"?this.getType("bool"):r;let i=this.registry.findUnaryOverload(n,r);if(i)return i.returnType;throw new ze(`no such overload: ${n[0]}${r.type}`,t)}checkBinaryOperator(t){let n=t[0],r=this.check(t[1]),i=this.check(t[2]),o=this.registry.checkBinaryOverload(n,r,i);if(o)return o;throw new ze(`no such overload: ${r} ${n} ${i}`,t)}};var pS=aO();cO(pS);XM(pS);var H4=new Map(Object.entries({value(e){return e[1]},id(e,t){return t.value(e[1],e).value},"||"(e,t){try{let r=t.eval(e[1]);if(r===!0)return!0;if(r!==!1)throw new K("Left operand of || is not a boolean",e[1])}catch(r){if(r.message.includes("Unknown variable")||r.message.includes("is not a boolean"))throw r;let i=t.eval(e[2]);if(i===!0)return!0;throw i===!1?r:new K("Right operand of || is not a boolean",e[2])}let n=t.eval(e[2]);if(typeof n=="boolean")return n;throw new K("Right operand of || is not a boolean",e[2])},"&&"(e,t){try{let r=t.eval(e[1]);if(r===!1)return!1;if(r!==!0)throw new K("Left operand of && is not a boolean",e[1])}catch(r){if(r.message.includes("Unknown variable")||r.message.includes("is not a boolean"))throw r;let i=t.eval(e[2]);if(i===!1)return!1;throw i===!0?r:new K("Right operand of && is not a boolean",e[2])}let n=t.eval(e[2]);if(typeof n=="boolean")return n;throw new K("Right operand of && is not a boolean",e[2])},"."(e,t){let n=t.eval(e[1]);return t.debugType(n).field(n,e[2],e,t)},"[]"(e,t){let n=t.eval(e[1]);return t.debugType(n).field(n,t.eval(e[2]),e,t)},rcall(e,t){let n=e[1],r=t.eval(e[2]),i=e[2].checkedType||t.celTypes.dyn,o=e[3],s=o.length,a=e.functionCandidates??=t.registry.getFunctionCandidates(i,n,s),c=i.kind!=="dyn"?i:t.debugType(r);if(!a.exists)throw new K(`Function not found: '${n}' for value of type '${c}'`,e);let l=a.filterByReceiverType(c),p,d;if(l.hasMacro)p=o,d=e.argMacroTypes??=new Array(s).fill(t.registry.getFunctionType("ast"));else{p=e.argValues??=new Array(s),d=e.argTypes??=new Array(s);for(let y=0;y<s;y++){let S=o[y];p[y]=t.eval(S),d[y]=pO(S.checkedType,t.debugType(p[y]),t)}}let m=l.findMatch(d);if(!m)throw new K(`found no matching overload for '${c.type}.${n}(${d.join(", ")})'`,e);try{return m.macro?m.handler.call(t,r,e):m.handler.call(t,r,...p)}catch(y){throw y instanceof K?y.withAst(e):y}},call(e,t){let n=e[1],r=e[2],i=r.length,o=e.functionCandidates??=t.registry.getFunctionCandidates(null,n,i);if(o.exists===!1)throw new K(`Function not found: '${n}'`,e);let s=o.filterByReceiverType(null),a,c;if(o.hasMacro)a=r,c=e.argMacroTypes??=new Array(i).fill(t.registry.getFunctionType("ast"));else{a=e.argValues??=new Array(i),c=e.argTypes??=new Array(i);for(let p=0;p<i;p++){let d=r[p];a[p]=t.eval(d),c[p]=pO(d.checkedType,t.debugType(a[p]),t)}}let l=s.findMatch(c);if(!l)throw new K(`found no matching overload for '${n}(${c.join(", ")})'`,e);try{return l.macro?l.handler.call(t,e):l.handler.apply(t,a)}catch(p){throw p instanceof K?p.withAst(e):p}},list(e,t){let n=e[1],r=new Array(n.length);for(let i=0;i<n.length;i++)r[i]=t.eval(n[i]);return r},map(e,t){let n={},r=e[1];for(let i=0;i<r.length;i++){let o=r[i];n[t.eval(o[0])]=t.eval(o[1])}return n},"?:"(e,t){let n=t.eval(e[1]);if(n===!0)return t.eval(e[2]);if(n===!1)return t.eval(e[3]);throw new K("Ternary condition must be a boolean")},"!_":uO,"-_":uO,"!=":Or,"==":Or,in:Or,"+":Or,"-":Or,"*":Or,"/":Or,"%":Or,"<":Or,"<=":Or,">":Or,">=":Or}));function uO(e,t){let n=t.eval(e[1]),r=t.debugType(n),i=t.registry.findUnaryOverload(e[0],r);if(i)return i.handler(n);throw new K(`no such overload: ${e[0][0]}${r}`,e)}function Or(e,t){let n=t.eval(e[1]),r=t.eval(e[2]),i=lO(e[1].checkedType,t.debugType(n),t),o=lO(e[2].checkedType,t.debugType(r),t),s=t.registry.findBinaryOverload(e[0],i,o);if(s)return s.handler(n,r,e,t);throw new K(`no such overload: ${i} ${e[0]} ${o}`,e)}function lO(e,t,n){if(e===t||!e)return t;if(e.kind==="dyn")return n.registry.getDynType(t);if(e.kind!==t.kind)throw new K(`Type mismatch: expected ${e}, got ${t}`);return e}function pO(e,t){if(e===t||!e||e.kind==="dyn")return t;if(e.kind!==t.kind)throw new K(`Type mismatch: expected ${e}, got ${t}`);return e}var Fd=class{createOverlay(t,n){return new uS({parent:this,variableName:t,variableType:n})}getVariable(t){let n=this.getType(t);if(!n)return;let r=this.getValue(t);if(r!==void 0)return{type:n,value:r}}},cS=class extends Fd{constructor({variables:t,fallbackValues:n}){super(),this.variables=t,this.fallbackValues=n,this.primary=null,this.primaryGetter=this.#e}getType(t){return this.variables.get(t)}getValue(){}setPrimaryContext(t){if(typeof t!="object")throw new K("Context must be an object");this.primary=t,t?t instanceof Map?this.getValue=this.#r:this.getValue=this.#t:this.getValue=this.#e}#e(t){return this.fallbackValues.get(t)}#t(t){let n=Object.hasOwn(this.primary,t)?this.primary[t]:void 0;return n!==void 0?n:this.fallbackValues.get(t)}#r(t){let n=this.primary.get(t);return n!==void 0?n:this.fallbackValues.get(t)}},uS=class extends Fd{constructor({parent:t,variableName:n,variableType:r}){super(),this.parent=t,this.variableName=n,this.variableType=r,this.variableValue=void 0}getType(t){return this.variableName===t?this.variableType:this.parent.getType(t)}getValue(t){return this.variableName===t?this.variableValue:this.parent.getValue(t)}setVariableValue(t){this.variableValue=t}},fO=new WeakMap,G4=new Map(Object.entries(mi)),oc=class e{#e;#t;#r;#n;#o;constructor(t){this.#o=t,this.#t=(t?.inherit instanceof e?fO.get(t.inherit):pS).clone({unlistedVariablesAreDyn:t?.unlistedVariablesAreDyn??!1}),this.#e=this.#t.variables;let n={registry:this.#t,variables:this.#e,objectTypes:this.#t.objectTypes,objectTypesByConstructor:this.#t.objectTypesByConstructor,ctx:new cS({variables:this.#e,fallbackValues:G4})};this.#n=new Bd(n),this.#r=new $d({...n,typeChecker:this.#n}),fO.set(this,this.#t),Object.freeze(this)}clone(t){return new e({inherit:this,unlistedVariablesAreDyn:this.#o?.unlistedVariablesAreDyn??!1})}registerFunction(t,n){return this.#t.registerFunctionOverload(t,n),this}registerOperator(t,n){return this.#t.registerOperatorOverload(t,n),this}registerType(t,n){return this.#t.registerType(t,n),this}registerVariable(t,n){return this.#t.registerVariable(t,n),this}hasVariable(t){return this.#t.variables.has(t)}check(t){try{let n=this.#n.check(new rc(t).parse());return{valid:!0,type:this.#s(n)}}catch(n){return{valid:!1,error:n}}}#a(t){try{let n=this.#n.check(t);return{valid:!0,type:this.#s(n)}}catch(n){return{valid:!1,error:n}}}#s(t){return t.name==="list<dyn>"?"list":t.name==="map<dyn, dyn>"?"map":`${t.name}`}parse(t){let n=new rc(t).parse(),r=this.#i.bind(this,n);return r.check=this.#a.bind(this,n),r.ast=n,r}evaluate(t,n){return this.#i(new rc(t).parse(),n)}#i(t,n=null){let r=this.#r;return r.ctx.setPrimaryContext(n),r.tryCheck(t),r.eval(t)}};function dO(e){throw new K(`Unsupported type: ${e}`)}var $d=class{handlers=H4;celTypes=Hi;constructor({registry:t,objectTypes:n,objectTypesByConstructor:r,typeChecker:i,ctx:o}){this.objectTypes=n,this.objectTypesByConstructor=r,this.registry=t,this.typeChecker=i,this.ctx=o}value(t,n){let r=this.ctx.getVariable(t);if(!r)throw new K(`Unknown variable: ${t}`,n);let i=this.debugType(r.value);if(r.type.matches(i))return r;throw new K(`Variable '${t}' is not of type '${r.type}', got '${i}'`,n)}predicateEvaluator(t,n){return new lS(this,t,n)}debugType(t){switch(typeof t){case"string":return this.celTypes.string;case"bigint":return this.celTypes.int;case"number":return this.celTypes.double;case"boolean":return this.celTypes.bool;case"object":return t===null?this.celTypes.null:this.objectTypesByConstructor.get(t.constructor)?.type||dO(t.constructor?.name||typeof t);default:dO(typeof t)}}tryCheck(t){try{return t.checkedType||this.typeChecker.check(t)}catch{}}eval(t){let n=this.handlers.get(t[0]);if(n)return n(t,this);throw new K(`Unknown operation: ${t[0]}`,t)}},lS=class extends $d{constructor(t,n,r){super(t);let[i,o]=r[3];if(i?.[0]!=="id")throw new K(`${n} invalid predicate iteration variable`,r);this.ast=r,this.functionName=n,this.predicateVariable=i[1],this.predicateExpression=o;let s=r[2].checkedType||this.celTypes.dyn,a=this.celTypes.dyn;s.type==="list"&&(a=s.valueType),s.type==="map"&&(a=s.keyType),this.ctx=this.ctx.createOverlay(this.predicateVariable,a),this.tryCheck(o)}getIterableItems(t){if(Array.isArray(t))return t;if(t instanceof Set)return[...t];if(t instanceof Map)return[...t.keys()];if(typeof t=="object")return Object.keys(t);throw new K(`${this.functionName} cannot iterate over non-collection type. argument must be a list, map, or object`,this.ast)}childEvaluateBool(t){switch(this.ctx.setVariableValue(t),this.eval(this.predicateExpression)){case!0:return!0;case!1:return!1;default:throw new K(`${this.functionName} predicate result is not a boolean`,Array.isArray(this.predicateExpression)?this.predicateExpression:this.ast)}}childEvaluate(t){return this.ctx.setVariableValue(t),this.eval(this.predicateExpression)}},R0e=new oc({unlistedVariablesAreDyn:!0});u();var qs="noyaPolicy",zd="noyaServerComputed",yS="noyaServerScripts";function q4(e){let t=typeof e.compute=="string"?{kind:"expression",expression:e.compute}:e.compute;return{...e,compute:t}}function V4(e,t){return e[zd]=q4(t),e}function Q4(e,t){return e[qs]=t,e}function Y4(e,t){return e[yS]=t,e}function gS(e){return e?(e[yS]??[]).filter(n=>!!n&&typeof n.id=="string"&&typeof n.code=="string"):[]}function J4(e){return e?Array.isArray(e)?e:Object.entries(e):[]}function X4(e,t){let n=t.map(([s])=>s),r=new Map(t),i=new Set,o=yO(e,n);for(let s of o)hO(s,i,r,n,new Set);return i}function hO(e,t,n,r,i){if(t.has(e)||i.has(e))return;i.add(e);let o=yO(n.get(e),r);for(let s of o)hO(s,t,n,r,i);i.delete(e),t.add(e)}function yO(e,t){if(!e)return[];let n=[];for(let r of t)new RegExp(`\\b${Z4(r)}\\b`).test(e)&&n.push(r);return n}function Z4(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}var gO=new oc({unlistedVariablesAreDyn:!0}),W4=BigInt(Number.MAX_SAFE_INTEGER);gO.registerFunction("random(): double",()=>Math.random()).registerFunction("randomInt(int, int): int",(e,t)=>{if(t<e)throw new Error("randomInt requires the second argument to be greater than or equal to the first");if(t===e)return e;let n=t-e+1n;if(n>W4)throw new Error("randomInt range is too large to generate safely");let r=Number(n),i=BigInt(Math.floor(Math.random()*r));return e+i}).registerFunction("now(): double",function(){let t=this.ctx.getVariable("now")?.value??Date.now();return typeof t=="number"?t:Number(t)}).registerFunction("timestamp(): string",function(){let e=this.ctx.getVariable("now"),t=typeof e?.value=="number"?e.value:typeof e?.value=="string"?Number(e.value):Date.now();return new Date(t).toISOString()}).registerFunction("uuid(): string",()=>te());var mO=new Map;function e6(e){let t=mO.get(e);return t||(t=gO.parse(e),mO.set(e,t)),t}function fS(e,t){return e6(e)({auth:t.auth??{},data:t.data??null,newData:t.newData??null,patch:t.patch??null,now:t.now,...t.bindings})}function bO(e){let t=e.policy.allow?.[e.action];if(!t)return{allowed:!0};let n=J4(e.policy.let),r=X4(t,n),i={},o={...e.context,bindings:i};try{for(let[a,c]of n)r.has(a)&&(i[a]=fS(c,o));return{allowed:!!fS(t,o),expression:t}}catch(s){return{allowed:!1,expression:t,error:s instanceof Error?s.message:String(s)}}}function bS(e){let{schema:t,patches:n,previousState:r,nextState:i,auth:o,now:s}=e;if(t)for(let a of n){let c=IO(t,a.path);if(c.length===0)continue;let l=i6(a,c);if(!l)continue;let p=TO(c);if(!p?.schema[qs]){if((o?.access??"write")!=="write")return{action:l??"update",patch:a,message:"Insufficient access level to edit this field"};continue}let d=p.schema[qs],y=Il(r,a.path).slice(0,p.pathLength),S=hS(r,y),T=hS(i,y),E=bO({policy:d,action:l,context:{auth:o??{},data:S,newData:T,patch:a,now:s}});if(!E.allowed)return{action:l,patch:a,expression:E.expression,...E.error&&{message:E.error}}}}function SS(e){let{schema:t,patches:n,auth:r,now:i}=e;if(!t)return[];let o=[];for(let s of n){let a=IO(t,s.path);if(a.length===0)continue;let c=vO(s,a);if(!c)continue;let l=a[a.length-1]?.schema;l&&"value"in s&&(s.value=mS(l,s.value,c,r??{},i)),o.push(...r6({schemaPath:a,patch:s,event:c,auth:r??{},now:i}))}return o}var Kd=Symbol("readDenied");function t6(e){let{schema:t,state:n,auth:r,now:i}=e;if(!t)return n;let s=dS({schemaPath:[{schema:t,pathLength:0}],value:n,rootState:n,simplePath:[],auth:r??{},now:i});if(s!==Kd)return s}function dS(e){if(!n6({schemaPath:e.schemaPath,simplePath:e.simplePath,state:e.rootState,auth:e.auth,now:e.now}))return Kd;let n=e.schemaPath.at(-1)?.schema;if(!n)return e.value;if(Array.isArray(e.value)&&TS(n)){let r=!1,i=[];for(let o=0;o<e.value.length;o++){let s=e.value[o],a=ec(s),l=xS(n,a!==void 0?{id:a}:o),p=l?[...e.schemaPath,{schema:l,pathLength:e.simplePath.length+1}]:e.schemaPath,d=dS({schemaPath:p,value:s,rootState:e.rootState,simplePath:[...e.simplePath,o],auth:e.auth,now:e.now});if(d===Kd){r=!0;continue}i.push(d),d!==s&&(r=!0)}return r?i:e.value}if(vS(e.value)&&Pl(n)){let r=!1,i,o=()=>(i||(i={...e.value}),i);for(let s of Object.keys(e.value)){let a=e.value[s],c=n.properties?.[s],l=c?[...e.schemaPath,{schema:c,pathLength:e.simplePath.length+1}]:e.schemaPath,p=dS({schemaPath:l,value:a,rootState:e.rootState,simplePath:[...e.simplePath,s],auth:e.auth,now:e.now});if(p===Kd){let d=o();delete d[s],r=!0;continue}if(p!==a){let d=o();d[s]=p,r=!0}}return r?i??e.value:e.value}return e.value}function n6(e){let t=TO(e.schemaPath);if(!t?.schema[qs])return!0;let n=t.schema[qs],r=e.simplePath.slice(0,t.pathLength),i=hS(e.state,r),o=bO({policy:n,action:"read",context:{auth:e.auth??{},data:i,newData:i,now:e.now}});return o.error?!1:o.allowed}function r6(e){let{schemaPath:t,patch:n,event:r,auth:i,now:o}=e,s=[];for(let a of t){if(!Pl(a.schema))continue;let c=a.schema.properties??{},l=n.path.length===a.pathLength,p=l?n.value:void 0;for(let d of Object.keys(c)){let y=c[d][zd];!y||!SO(y,r,"object")||(y.targets??["value"]).includes("value")&&l&&vS(p)&&Object.prototype.hasOwnProperty.call(p,d)&&r==="create"||s.push({op:"add",path:[...n.path.slice(0,a.pathLength),d],value:xO(y.compute,{auth:i,now:o})})}}return s}function SO(e,t,n){let r=e.events??["create"],i=e.targets??["value"];return r.includes(t)&&i.includes(n)}function xO(e,t){switch(e.kind){case"timestamp":return e.format==="number"?t.now:new Date(t.now).toISOString();case"authId":return t.auth.id??null;case"uuid":return te();case"literal":return e.value;case"expression":return fS(e.expression,{auth:t.auth,data:void 0,newData:void 0,patch:void 0,now:t.now,bindings:{}})}}function mS(e,t,n,r,i){let o=e[zd];if(o&&SO(o,n,"value"))return xO(o.compute,{auth:r,now:i});if(Pl(e)&&vS(t)){let s=e.properties??{};for(let a of Object.keys(t)){let c=s[a];c&&(t[a]=mS(c,t[a],n,r,i))}}else if(TS(e)&&Array.isArray(t)){let s=e.items;if(s)for(let a=0;a<t.length;a++)t[a]=mS(s,t[a],n,r,i)}return t}function TO(e){for(let t=e.length-1;t>=0;t--){let n=e[t];if(n.schema[qs])return n}}function i6(e,t){if(e.op==="remove")return"delete";let n=vO(e,t);if(n)switch(n){case"create":return"create";case"update":return"update"}}function vO(e,t){let n=t[t.length-1];switch(e.op){case"add":return Pl(n.schema)?"create":"update";case"replace":return"update";default:return}}function IO(e,t){let n=[{schema:e,pathLength:0}],r=e;for(let i=0;i<t.length&&(r=xS(r,t[i]),!!r);i++)n.push({schema:r,pathLength:i+1});return n}function xS(e,t){if(e){if(Array.isArray(e.anyOf)&&e.anyOf[0])return xS(e.anyOf[0],t);if(TS(e))return e.items;if(Pl(e)&&typeof t=="string")return e.properties?.[t]??void 0}}function Pl(e){return e.type==="object"}function TS(e){return e.type==="array"}function vS(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function hS(e,t){let n=e;for(let r of t){if(n==null)return;n=n[r]}return n}u();var IS=100;function Vs(e,t=new WeakSet){if(e===null)return null;switch(typeof e){case"undefined":return"[undefined]";case"string":case"number":case"boolean":return e;case"bigint":return e.toString();case"symbol":return e.toString();case"function":return`[Function ${e.name||"anonymous"}]`}if(e instanceof Error)return{name:e.name,message:e.message,stack:e.stack};if(e instanceof Date)return`[Date ${e.toISOString()}]`;if(Array.isArray(e)){if(t.has(e))return"[Circular]";t.add(e);let n=e.map(r=>Vs(r,t));return t.delete(e),n}if(typeof e=="object"&&e!==null){let n=e;if(t.has(n))return"[Circular]";t.add(n);let r={};for(let i of Object.keys(n))r[i]=Vs(n[i],t);return t.delete(n),r}return e}function o6(e){return e.split(".").map(t=>t.trim()).filter(t=>t.length>0)}function s6(e){return(e.path??[]).map(t=>typeof t=="number"?t.toString():typeof t=="object"&&t!==null&&"key"in t?String(t.key):String(t))}function a6(e,t){if(t.length===0||t.length>e.length)return!1;for(let n=0;n<t.length;n+=1){let r=t[n];if(r!=="*"&&r!==e[n])return!1}return!0}function c6(e){if(!e)return null;let t=e.trim();if(!t)return null;let n=t.match(/^(\d+)(ms|s)$/i);if(!n)return IS;let r=Number(n[1]),i=n[2].toLowerCase();return Number.isNaN(r)?IS:i==="s"?r*1e3:r}function u6(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?()=>crypto.randomUUID():()=>te()}function l6(e){let t=e.mode??"live";return{target:e.target,mode:t,label:e.label??`${e.target}${t==="simulation"?"-sim":""}`,clock:e.clock??(()=>Date.now())}}var ES=class{constructor(t,n,r,i,o,s){this.definition=t;this.quickJSPromise=n;this.randomUUID=s;this.host=r,this.environment=i,this.logSink=o,this.updateTriggersFromDefinition(),this.lastTickTimestamp=null,this.invocation=r.getInitialInvocation?.(this.definition.id)??0}vm=null;runtime=null;interval=null;disposed=!1;active=!1;isRunning=!1;readyPromise=null;invocation=0;stateChangeMatchers=[];runsOnStateChange=!1;hasIntervalTrigger=!1;intervalDurationMs=null;runOnAnyStateChange=!1;runsOnInputQueue=!1;runOnAnyInputQueue=!1;runsOnUserEvent=!1;runOnAnyUserEvent=!1;runsOnSchemaMigration=!1;runOnAnyMigration=!1;pendingRun=!1;inputQueueMatchers=[];userEventMatchers=[];migrationVersionMatchers=[];lastTickTimestamp=null;host;environment;logSink;pendingTriggers=[];get id(){return this.definition.id}get intervalMs(){return this.intervalDurationMs??IS}getModuleSpecifier(){return`server-script:${encodeURIComponent(this.definition.id)}`}syncInvocation(t,n){t>this.invocation&&(this.invocation=t);let r=this.getNow();n!==void 0?this.lastTickTimestamp=Math.max(n,r):this.lastTickTimestamp=r,this.stopInterval(),this.active&&this.hasIntervalTrigger&&this.scheduleNextInterval()}isSameDefinition(t){return t.code===this.definition.code&&Gt(t.on??{},this.definition.on??{})}updateDefinition(t){let n=t.code!==this.definition.code,r=this.intervalDurationMs,i=this.hasIntervalTrigger,o=this.runsOnStateChange,s=this.runOnAnyStateChange,a=this.stateChangeMatchers.map(S=>[...S]),c=this.runsOnInputQueue,l=this.runOnAnyInputQueue,p=[...this.inputQueueMatchers];this.definition=t,this.invocation=this.host.getInitialInvocation?.(t.id)??0,this.updateTriggersFromDefinition();let d=r!==this.intervalDurationMs||i!==this.hasIntervalTrigger,m=o!==this.runsOnStateChange||s!==this.runOnAnyStateChange||!Gt(a,this.stateChangeMatchers),y=c!==this.runsOnInputQueue||l!==this.runOnAnyInputQueue||!Gt(p,this.inputQueueMatchers);n&&this.disposeVm(),d&&(this.hasIntervalTrigger?this.active&&this.restartInterval():this.stopInterval()),(n||m||y)&&this.active&&(this.runsOnStateChange||this.runsOnInputQueue)&&this.ensureVm()}setActive(t){this.disposed||this.active!==t&&(this.active=t,t?(this.hasIntervalTrigger&&this.ensureInterval(),(this.runsOnStateChange||this.runsOnInputQueue)&&!this.hasIntervalTrigger&&this.ensureVm()):this.stopInterval())}dispose(){this.disposed=!0,this.stopInterval(),this.disposeVm()}async ensureInterval(){this.interval||this.disposed||!this.active||this.hasIntervalTrigger&&(await this.ensureVm(),!(this.disposed||!this.active)&&this.tick(this.getNow()))}restartInterval(){this.stopInterval(),this.active&&this.ensureInterval()}stopInterval(){this.interval!==null&&(clearTimeout(this.interval),this.interval=null)}getNow(){return this.environment.clock()}log(t,...n){this.logSink({level:t,scriptId:this.definition.id,target:this.environment.target,mode:this.environment.mode,origin:this.environment.label,values:n})}scheduleNextInterval(){if(this.interval||this.disposed||!this.active||!this.hasIntervalTrigger)return;let t=this.getNow(),r=(this.lastTickTimestamp??t)+this.intervalMs,i=Math.max(0,r-t);this.interval=setTimeout(()=>{this.interval=null,this.tick(r)},i)}disposeVm(){this.vm?.dispose(),this.vm=null,this.runtime?.dispose(),this.runtime=null,this.readyPromise=null}async ensureVm(){if(this.vm||this.readyPromise)return this.readyPromise;this.readyPromise=(async()=>{let t=await this.quickJSPromise;if(this.disposed)return;let n=t.newRuntime(),r=this.getModuleSpecifier();n.setModuleLoader(E=>E===r?this.definition.code:{error:new Error(`Unknown module ${E}`)});let i=n.newContext();this.vm=i,this.runtime=n;let o=i.newObject(),s=E=>i.newFunction(E,(...b)=>{let f=b.map(g=>i.dump(g));return this.log(E,...f),i.undefined}),a=s("log"),c=s("warn"),l=s("error");i.setProp(o,"log",a),i.setProp(o,"warn",c),i.setProp(o,"error",l),a.dispose(),c.dispose(),l.dispose(),i.setProp(i.global,"console",o),o.dispose();let p=i.newObject(),d=i.newFunction("randomUUID",()=>i.newString(this.randomUUID()));i.setProp(p,"randomUUID",d),d.dispose(),i.setProp(i.global,"crypto",p),p.dispose();let m=i.newFunction("__noyaGetSharedConnectionData",()=>{let E=this.host.getSharedConnectionData();return i.newString(JSON.stringify(E??{}))});i.setProp(i.global,"__noyaGetSharedConnectionData",m);let y=i.newFunction("__noyaSetSharedConnectionData",E=>{let b=i.dump(E);if(typeof b!="object"||b===null)throw new Error("setSharedConnectionData requires an object argument");return this.host.setSharedConnectionData(b),i.undefined});i.setProp(i.global,"__noyaSetSharedConnectionData",y);let S=i.newFunction("__noyaDrainInputQueue",(...E)=>{let b=E[0],f;if(b){let v=i.dump(b);if(v&&typeof v=="object"){let I=v;f={connectionId:typeof I.connectionId=="string"?I.connectionId:void 0,queue:typeof I.queue=="string"?I.queue:void 0,maxEntries:typeof I.maxEntries=="number"?I.maxEntries:void 0}}}let g=this.host.drainInputQueue(f);return i.newString(JSON.stringify(g??[]))});i.setProp(i.global,"__noyaDrainInputQueue",S);let T=`
40
40
  import loop from "${r}";
41
41
  if (typeof loop !== 'function') {
42
42
  throw new Error('export default function is required in server script ${this.definition.id}');
@@ -58,18 +58,18 @@ globalThis.__noyaLoop = (ctx) => loop({
58
58
  ctx.setSharedConnectionData = globalThis.__noyaSetSharedConnectionData;
59
59
  ctx.dequeueInput = globalThis.__noyaDrainInputQueueProxy;
60
60
  return globalThis.__noyaLoop(ctx);
61
- })()`,c;return this.vm.unwrapResult(this.vm.evalCode(a,`${this.definition.id}-migration.js`,{type:"global"})).consume(l=>{c=this.vm.dump(l)}),this.normalizeResult(c)}catch(s){this.log("error","Migration script error:",s);return}}},Qs=class{constructor(t){this.options=t;this.randomUUID=t.randomUUID??u6(),this.environment=l6(t.environment),this.log=t.log}isHot=!1;runners=new Map;quickJSPromise=null;randomUUID;environment;log;getQuickJSPromise(){if(!this.quickJSPromise){let t=this.options.getQuickJSModule();this.quickJSPromise=Promise.resolve(t)}return this.quickJSPromise}setIsHot(t){if(this.isHot!==t){this.isHot=t;for(let n of this.runners.values())n.setActive(t)}}syncInvocation(t,n,r){let i=t??(this.runners.size===1?Array.from(this.runners.keys())[0]:void 0);if(!i)return;this.runners.get(i)?.syncInvocation(n,r)}async updateSchema(t){let n=yS(t),r=new Set;for(let i of n){r.add(i.id);let o=this.runners.get(i.id);if(o){o.isSameDefinition(i)||o.updateDefinition(i),this.isHot&&o.setActive(!0);continue}let s=new IS(i,this.getQuickJSPromise(),this.options,this.environment,this.log,this.randomUUID);this.runners.set(i.id,s),this.isHot&&s.setActive(!0)}for(let[i,o]of Array.from(this.runners.entries()))r.has(i)||(o.dispose(),this.runners.delete(i))}handleStateChange(t){if(this.isHot&&t.length!==0)for(let n of this.runners.values())n.handleStateChange(t)}handleInputQueueActivity(t){if(this.isHot)for(let n of this.runners.values())n.handleInputQueue(t)}handleUserEvent(t,n){if(this.isHot)for(let r of this.runners.values())r.handleUserEvent(t,n)}async handleSchemaMigration(t,n,r){let i=r,o=!1;for(let s of this.runners.values())try{let a=await s.runMigration(t,n,i);a!==void 0&&(i=a,o=!0)}catch(a){console.error(`Migration script ${s.id} failed:`,a)}return o?i:void 0}dispose(){for(let t of this.runners.values())t.dispose();this.runners.clear(),this.quickJSPromise=null}};var Nl=(e,t)=>Zw(e,{...t,ignoreUndefinedProperties:!0}),Ys=class extends Error{constructor(n,r){super(r);this.reason=n}},Gi=class extends Ee{constructor(n,r={}){super();this.options=r;this.state=n instanceof Function?n():n,this.schema=r.schema,this.sm=new $s(this.state,r),this.optimisticState$=_.from({get:this.getOptimisticState,subscribe:this.addListener},{isEqual:(i,o)=>this.createHashCached(i)===this.createHashCached(o)}),this.options.mode==="standalone"&&this.autoConnect(),this.initializeServerSimulator()}get _metadataType(){throw new Error("Not implemented - this is just a type hint")}state;schema;errorEmitter=new Ee;sm;pendingCommits=[];connectionStatus$=new _("disconnected");isInitialized$=new _(!1);outgoingMessages=[];incomingMessages=[];optimisticState$;partialHashCache=new Qa({capacity:2e4});createHashCached=new Qa({capacity:100}).wrap(n=>Nl(n,{cache:this.partialHashCache}));applyCommitCache=new Qa({capacity:25});policyAuthContext;enforcePoliciesLocally=!0;enhanceMetadata(n){return{id:this.getRandomId(),timestamp:Date.now(),...n}}getRandomId(){return this.options.randomId?.()??te()}initializeServerSimulator(){let n=this.options.serverScripts;!n?.getQuickJSModule||n.simulateLocally!==!0||(this.serverScriptSimulator=new Qs({getQuickJSModule:n.getQuickJSModule,randomUUID:n.randomUUID,environment:{target:"client-simulator",mode:"simulation",label:"simulator",clock:n.getNow??(()=>this.getServerNowEstimate())},getState:()=>this.state,getSharedConnectionData:this.options.getSharedConnectionData??(()=>({})),setSharedConnectionData:()=>{},getInitialInvocation:r=>{let i=r??"default";return this.serverInvocationTracker.get(i)?.invocation},drainInputQueue:r=>this.options.drainInputQueue?.(r)??[],applyState:async({scriptId:r,nextState:i,invocation:o,timestamp:s})=>{this.applyServerPrediction({scriptId:r,nextState:i,invocation:o,timestamp:s})},log:r=>{console[r.level]("[server-sim]",r.scriptId,...r.values);let i=r.values.map(o=>Vs(o));this.serverSimulationLogManager.append({id:this.getRandomId(),scriptId:r.scriptId,level:r.level,values:i,timestamp:Date.now(),origin:r.origin,target:r.target,mode:r.mode})}}),this.serverScriptSimulator.setIsHot(!1),this.serverScriptSimulator.updateSchema(this.schema))}setPolicyAuthContext(n){this.policyAuthContext=n}setLocalPolicyEnforcement(n){this.enforcePoliciesLocally=n}autoConnect=()=>{let n=r=>{switch(r.type){case"init":{this.incomingMessages.push({type:"object",object:r.object,schema:r.schema}),this.processIncomingMessages();break}case"patch":{this.incomingMessages.push({type:"acceptPatch",id:r.id,patches:r.patches,serverInvocation:r.serverInvocation}),this.processIncomingMessages();break}}};this.messageEmitter.addListener(n),this.connect()};getHash(){return this.createHashCached(this.state)}_setState(n,r){this.state=n,this.schema=r,this.emitIfChanged(),this.sm._setState(n)}_lastEmittedHash;emitIfChanged=()=>{this._lastEmittedHash!==this.getOptimisticHash()&&(this._lastEmittedHash=this.getOptimisticHash(),this.emit())};get isConnected(){return this.connectionStatus$.get()==="connected"}_pushCommit(n,r,{addToHistory:i,shouldTypeCheck:o=!0,sendMessage:s=!0}){if(!this.isConnected){console.warn("Can't edit when not connected");return}o&&Ao(n,this.schema,Er(this.schema));let a=this.getOptimisticState(),l=this.enforcePoliciesLocally&&this.policyAuthContext!==void 0?this.getLocalPolicyViolation({previousState:a,nextState:n,patches:r.redoPatches,auth:this.policyAuthContext}):void 0;if(l){this.errorEmitter.emit(new Ys("policyViolation",l.message??"Policy violation"));return}let p={state:n,historyEntry:r,baseHash:this.getOptimisticHash()};this.pendingCommits.push(p),this.emitIfChanged(),i&&(this.applyCommitCache.set(r.metadata.id,{input:a,output:n}),this.sm._setStateWithHistoryEntry(n,r,{shouldTypeCheck:!1})),s&&this.sendMessage({type:"patch",id:p.historyEntry.metadata.id,name:p.historyEntry.metadata.name,patches:p.historyEntry.redoPatches,baseHash:p.baseHash,...r.metadata.serverInvocation&&{serverInvocation:r.metadata.serverInvocation}})}getLocalPolicyViolation(n){if(n.patches.length===0)return;let r=n.auth;if(!this.schema)return(r.access??"write")!=="write"?{action:"update",patch:n.patches[0],message:"Insufficient access level to edit this field"}:void 0;let i=this.options.getNow?.()??Date.now(),o=n.nextState;try{let s=n.patches.map(f6),a=bS({schema:this.schema,patches:s,auth:r,now:i});o=De(n.previousState,[...s,...a])}catch{o=n.nextState}return gS({schema:this.schema,patches:n.patches,previousState:n.previousState,nextState:o,auth:r,now:i})}canUndo=()=>this.sm.canUndo();canRedo=()=>this.sm.canRedo();undo=()=>{if(!this.sm.canUndo())return;let n=this.sm.history[this.sm.historyIndex-1];this.sm.historyIndex--;let r=No(this.getOptimisticState(),{},{...n.metadata,id:this.getRandomId()},n.undoPatches,n.redoPatches);if(r)return this._pushCommit(r.state,r.historyEntry,{addToHistory:!1}),this.sm.history[this.sm.historyIndex]};redo=()=>{if(!this.sm.canRedo())return;let n=this.sm.history[this.sm.historyIndex];this.sm.historyIndex++;let r=No(this.getOptimisticState(),{},{...n.metadata,id:this.getRandomId()},n.redoPatches,n.undoPatches);if(r)return this._pushCommit(r.state,r.historyEntry,{addToHistory:!1}),this.sm.history[this.sm.historyIndex-1]};editDraft=(...n)=>{let[r,i]=n.length===1?[{},n[0]]:n,o=this.getOptimisticState(),s=Dd(o,{},this.enhanceMetadata(r),i);s&&this._pushCommit(s.state,s.historyEntry,{addToHistory:!0})};applyPatch=(...n)=>{let[r,{patches:i,inversePatches:o}]=n.length===1?[{},n[0]]:n,s=this.getOptimisticState(),a=De(s,i);if(Ao(a,this.schema,Er(this.schema)),!o){let[,l]=Qr(s,a);o=l}let c=No(a,{},this.enhanceMetadata(r),i,o);c&&this._pushCommit(c.state,c.historyEntry,{addToHistory:!0})};setState=(...n)=>{let[r,i]=n.length===1?[{},n[0]]:n,o=this.getOptimisticState(),s=i instanceof Function?i(o):i;Ao(s,this.schema,Er(this.schema));let[a,c]=Qr(o,s,{useExtendedPatches:!0}),l=No(s,{},this.enhanceMetadata(r),a,c);l&&this._pushCommit(l.state,l.historyEntry,{addToHistory:!0})};setStateAtPath=(...n)=>{let[r,i,o]=n.length===2?[{},n[0],n[1]]:n,s=this.setState;if(!i||i.length===0)s(r,o);else{let a=this.getOptimisticState(),c=o instanceof Function?o(Ht(a,i)):o,l=Ls(a,i,c);this.setState(r,l)}};operate=(...n)=>{let[r,i]=n.length===1?[{},n[0]]:n,o=new Co(this.state);i(o);let s=Mr.compactPatches(o.patches),a=Mr.compactPatches(o.inversePatches),c=De(this.state,s);if(this.options.allowEmptyEdits!==!0&&s.length===0)return;let l=No(c,{},this.enhanceMetadata(r),s,a);l&&this._pushCommit(l.state,l.historyEntry,{addToHistory:!0})};getConfirmedState=()=>this.state;getOptimisticState=()=>this.pendingCommits.at(-1)?.state??this.state;getOptimisticHash(){return this.createHashCached(this.getOptimisticState())}reinitialize(n){this.pendingCommits=[],this.serverPredictionCommits.clear(),this.emitIfChanged(),this.sendMessage({type:"init",object:n,...this.schema&&{schema:Io(this.schema)}})}_handledMessages={};processIncomingMessages(){for(;this.incomingMessages.length>0;){let n=this.incomingMessages.shift();if("id"in n){if(this._handledMessages[n.id])continue;this._handledMessages[n.id]=!0}switch(n.type){case"object":{this._setState(n.object,n.schema?Eo(n.schema):void 0),this.serverScriptSimulator?.updateSchema(this.schema),this.isInitialized$.set(!0);break}case"acceptPatch":{let r=n.patches;this.handleServerInvocation(n.serverInvocation),n.serverInvocation||this.clearServerPredictions();let i=this.state,o,s=this.applyCommitCache.get(n.id),a=this.pendingCommits.find(l=>l.historyEntry.metadata.id===n.id),c=s&&s.input===i&&p6(a?.historyEntry.redoPatches,r);try{c?o=s.output:o=De(i,r)}catch{this.reinitialize(i);break}if(this.pendingCommits=this.pendingCommits.filter(l=>l.historyEntry.metadata.id!==n.id),n.hash!==void 0&&n.hash!==this.createHashCached(o)){this.reinitialize(i);break}this._setState(o,this.schema),this.serverScriptSimulator?.handleStateChange(r);break}case"rejectPatch":{switch(n.reason){default:{this.reinitialize(this.state),this.errorEmitter.emit(new Ys(n.reason,n.error));break}}break}case"rejectInit":{console.error("State initialized with invalid data type.",n.error),this.errorEmitter.emit(new Ys(n.reason,n.error));break}case"schemaMigration":{this.errorEmitter.emit(new Ys("schemaMigration","Schema migration requires a page reload."));break}}}}connect(){this.connectionStatus$.set("connected"),this.serverScriptSimulator?.setIsHot(!0),this.sendInit()}sendInit({force:n=this.options.overrideExistingState,state:r=this.state,schema:i=this.schema,outputTransforms:o=this.options.outputTransforms,inputs:s=this.options.inputs}={}){this.sendMessage({type:"init",object:r,...i&&{schema:Io(i)},...o&&{outputTransforms:o},...s&&{inputs:s},...n&&{force:n}})}sendMessage(n){this.outgoingMessages.push(n),this.messageEmitter.emit(n)}disconnect(){this.connectionStatus$.set("disconnected"),this.serverScriptSimulator?.setIsHot(!1)}hasPendingMessages(){return this.incomingMessages.length>0||this.outgoingMessages.length>0}messageEmitter=new Ee;serverSimulationLogManager=new zs;serverSimulationLogs$=this.serverSimulationLogManager.logs$;serverPredictionCommits=new Map;serverInvocationTracker=new Map;serverClockSkewMs=0;serverScriptSimulator;getNow(){return this.options.getNow?.()??Date.now()}getServerNowEstimate(){return this.getNow()+this.serverClockSkewMs}getServerSimulationDiagnostics(){let n=Array.from(this.serverInvocationTracker.entries()).map(([i,o])=>({scriptId:i==="default"?void 0:i,invocation:o.invocation,timestamp:o.timestamp})),r=Array.from(this.serverPredictionCommits.entries()).map(([i,o])=>{let[s,a]=i.split(":"),c=Number(a);return{scriptId:s==="default"?void 0:s,invocation:Number.isNaN(c)?void 0:c,commitId:o}});return{simulateLocally:this.options.serverScripts?.simulateLocally===!0,simulatorActive:!!this.serverScriptSimulator,clockSkewMs:this.serverClockSkewMs,invocations:n,pendingPredictions:r}}getLatestServerInvocation(n){let r=n??"default";return this.serverInvocationTracker.get(r)}getLatestPrediction(){let n=[...this.pendingCommits].reverse().find(r=>r.historyEntry.metadata.serverInvocation?.source==="client-sim");if(n)return{state:n.state,serverInvocation:n.historyEntry.metadata.serverInvocation}}clearServerPredictions(){if(this.serverPredictionCommits.size===0)return;let n=new Set(this.serverPredictionCommits.values());this.pendingCommits=this.pendingCommits.filter(r=>!n.has(r.historyEntry.metadata.id)),this.serverPredictionCommits.clear(),this.emitIfChanged()}applyServerPrediction(n){if(!this.isConnected)return;let r=n.scriptId??"default",i=this.serverInvocationTracker.get(r)?.invocation;if(i!==void 0&&n.invocation!==void 0&&n.invocation<=i)return;let o=this.state,[s,a]=Qr(o,n.nextState,{useExtendedPatches:!0});if(s.length===0)return;let c=i!==void 0?i+1:n.invocation??1,l=n.timestamp??this.getServerNowEstimate(),p=this.serverPredictionCommits.get(`${r}:${c}`);p&&(this.pendingCommits=this.pendingCommits.filter(y=>y.historyEntry.metadata.id!==p),this.serverPredictionCommits.delete(`${r}:${c}`));let d={name:`predicted ${r}#${c}`,serverInvocation:{scriptId:n.scriptId,invocation:c,timestamp:l,source:"client-sim"}},m=No(n.nextState,{},this.enhanceMetadata(d),s,a);m&&(this.serverInvocationTracker.set(r,{invocation:c,timestamp:l}),this._pushCommit(m.state,m.historyEntry,{addToHistory:!1,sendMessage:!1}),this.serverPredictionCommits.set(`${r}:${c}`,m.historyEntry.metadata.id),this.emitIfChanged())}handleServerInvocation(n){if(!n)return;let r=n.scriptId??"default",i=n.timestamp-this.getNow();this.serverClockSkewMs=this.serverClockSkewMs===0?i:this.serverClockSkewMs*.9+i*.1;let o=`${r}:${n.invocation}`,s=this.serverPredictionCommits.get(o),a=!1;s&&(this.pendingCommits=this.pendingCommits.filter(c=>c.historyEntry.metadata.id!==s),this.serverPredictionCommits.delete(o),a=!0);for(let[c,l]of Array.from(this.serverPredictionCommits.entries())){if(!c.startsWith(`${n.scriptId??"default"}:`))continue;let[,p]=c.split(":"),d=Number(p);Number.isNaN(d)||d<=n.invocation&&(this.pendingCommits=this.pendingCommits.filter(m=>m.historyEntry.metadata.id!==l),this.serverPredictionCommits.delete(c),a=!0)}a&&this.emitIfChanged(),this.serverInvocationTracker.set(r,{invocation:n.invocation,timestamp:n.timestamp}),this.serverScriptSimulator?.syncInvocation(n.scriptId,n.invocation,n.timestamp)}};function p6(e,t){return!e||!t?!1:Gt(e,t)}function f6(e){return{...e,path:e.path.map(EO),...e.from&&{from:e.from.map(EO)},..."value"in e?{value:ES(e.value)}:{}}}function EO(e){return typeof e=="object"?{id:e.id}:e}function ES(e){if(Array.isArray(e))return e.map(t=>ES(t));if(e&&typeof e=="object"){let t={};for(let[n,r]of Object.entries(e))t[n]=ES(r);return t}return e}var Cl=class extends Ee{data$=new _({});metadata$=new _({});currentConnectionId$=new _(void 0);currentConnectionDataEmitter=new Ee;setCurrentConnectionId=t=>{this.currentConnectionId$.set(t)};setForCurrentConnection=t=>{let n=this.currentConnectionId$.get();n&&(this.set(n,t),this.currentConnectionDataEmitter.emit(t))};set=(t,n)=>{this.metadata$.set({...this.metadata$.get(),[t]:{updatedAt:Date.now()}}),this.data$.set({...this.data$.get(),[t]:n}),this.emit(this.data$.get(),this.metadata$.get())};merge=t=>{this.data$.set({...this.data$.get(),...t});for(let n in t)this.metadata$.set({...this.metadata$.get(),[n]:{updatedAt:Date.now()}});this.emit(this.data$.get(),this.metadata$.get())};delete=t=>{let{[t]:n,...r}=this.data$.get();this.data$.set(r);let{[t]:i,...o}=this.metadata$.get();this.metadata$.set(o),this.emit(this.data$.get(),this.metadata$.get()),t===this.currentConnectionId$.get()&&this.currentConnectionDataEmitter.emit(void 0)};_snapshot;getSnapshot=()=>((!this._snapshot||this._snapshot.data!==this.data$.get()||this._snapshot.metadata!==this.metadata$.get()||this._snapshot.currentConnectionId!==this.currentConnectionId$.get())&&(this._snapshot={data:this.data$.get(),metadata:this.metadata$.get(),currentConnectionId:this.currentConnectionId$.get()}),this._snapshot)};var kl=class{constructor(t){this.options=t;this.ensureMessageSubscription()}multiplayer=new Gi("");unsubscribeMultiplayerMessages;isOpen=!1;getHandle(){return{repoId:this.options.repoId,filePath:this.options.filePath,ref:this.options.ref,content$:this.multiplayer.optimisticState$,isInitialized$:this.multiplayer.isInitialized$,sendPatches:(n,r)=>{this.sendPatches(n,r)},setState:(n,r)=>{this.setState(n,r)},close:()=>this.close()}}open(){if(this.ensureMessageSubscription(),!this.isOpen){this.isOpen=!0,this.multiplayer.connect();return}this.multiplayer.reinitialize(this.multiplayer.getConfirmedState())}close(){this.isOpen&&(this.isOpen=!1,this.multiplayer.disconnect(),this.options.sendMessage?.({type:"gitFileEdit.close",repoId:this.options.repoId,filePath:this.options.filePath,ref:this.options.ref}),this.unsubscribeMultiplayerMessages?.(),this.unsubscribeMultiplayerMessages=void 0,this.options.onClose?.())}sendPatches(t,n){this.multiplayer.applyPatch(n??{},{patches:t})}setState(t,n){let r=this.multiplayer.optimisticState$.get(),[i]=Qr(r,t,{useExtendedPatches:!0});i.length>0&&this.sendPatches(i,n)}handleServerMessage(t){let n=this.translateIncomingMessage(t);n&&(this.multiplayer.incomingMessages.push(n),this.multiplayer.processIncomingMessages())}flushOutgoingMessages(){for(;this.multiplayer.outgoingMessages.length>0;){let t=this.multiplayer.outgoingMessages.shift(),n=this.translateOutgoingMessage(t);n&&this.options.sendMessage?.(n)}}translateOutgoingMessage(t){switch(t.type){case"init":return{type:"gitFileEdit.open",repoId:this.options.repoId,filePath:this.options.filePath,ref:this.options.ref};case"patch":return{type:"gitFileEdit.patch",repoId:this.options.repoId,filePath:this.options.filePath,ref:this.options.ref,id:t.id,patches:t.patches,baseHash:t.baseHash};default:return}}translateIncomingMessage(t){switch(t.type){case"gitFileEdit.object":return{type:"object",object:t.content};case"gitFileEdit.acceptPatch":return{type:"acceptPatch",id:t.id,patches:t.patches,hash:t.hash};case"gitFileEdit.rejectPatch":return{type:"rejectPatch",id:t.id,reason:t.reason,error:t.error};default:return}}ensureMessageSubscription(){this.unsubscribeMultiplayerMessages||(this.unsubscribeMultiplayerMessages=this.multiplayer.messageEmitter.addListener(()=>{this.flushOutgoingMessages()}))}};u();var Dl=class{constructor(t,n,r={}){this.rpcManager=t;this.assetManager=n;this.includeContent=r.includeContent??!1,this.repos$=this.assetManager.assets$.map(i=>i.filter(o=>o.contentType===Ki).map(o=>this.assetManager._toNoyaAsset(o))),this.isInitialized$=this.assetManager.isInitialized$,this.repoFiles$=new _({}),this._sendMessage=r.sendMessage,r.subscribeConnectionEvents&&(this._unsubscribeConnectionEvents=r.subscribeConnectionEvents(this._handleConnectionEvent))}repos$;isInitialized$;repoFiles$;includeContent;getRepoState$(t){let n=`${t}:${this.includeContent}`,r=this._repoStateCache.get(n);if(r)return r;let i=this.repos$.map(s=>s.find(a=>a.id===t)?.id),o=_.combine([this.repoFiles$,i],([s,a])=>a&&a in s?s[a]:void 0);return _.combine([this.repoFiles$,i],([s,a])=>{a&&(a in s||this._autoFetchedRepos.has(a)||(this._autoFetchedRepos.add(a),this.fetchRepoFiles(a)))}),this._repoStateCache.set(n,o),o}async fetchRepoFiles(t,n){let i=this.repoFiles$.get()[t]?.branches??[];this.repoFiles$.set({...this.repoFiles$.get(),[t]:{fetchState:"loading",files:[],ref:n??"HEAD",oid:"",branches:i}});try{let[o,s]=await Promise.all([this.listFiles(t,n),i.length>0?Promise.resolve(i):this.listBranches(t)]);this.repoFiles$.set({...this.repoFiles$.get(),[t]:{fetchState:"idle",...o,branches:s,includeContent:this.includeContent}})}catch(o){this.repoFiles$.set({...this.repoFiles$.get(),[t]:{fetchState:"idle",files:[],ref:n??"HEAD",oid:"",branches:i,error:o instanceof Error?o.message:"Unknown error",includeContent:this.includeContent}})}}async refreshRepoFiles(t,n){let r=this.repoFiles$.get(),i=r[t];if(i){this.repoFiles$.set({...r,[t]:{...i,fetchState:"refreshing"}});try{let o=await this.listFiles(t,n),s=this.repoFiles$.get();this.repoFiles$.set({...s,[t]:{...s[t],fetchState:"idle",files:o.files,oid:o.oid,ref:o.ref,fileContents:o.fileContents,includeContent:this.includeContent}})}catch(o){let s=this.repoFiles$.get();this.repoFiles$.set({...s,[t]:{...s[t],fetchState:"idle"}}),console.error("[GitManager] Background refresh failed:",o)}}}async initRepo(t){let n=await this.rpcManager.requestRoute("POST /api/git/repos",{headers:{"Content-Type":"application/json"},body:JSON.stringify(t??{})}),{id:r}=this.rpcManager.getResponseBody(n);await this.assetManager.fetch();let i=this.assetManager.assets$.get().find(o=>(o.id===r||o.stableId===r)&&o.contentType===Ki);if(!i)throw new Error(`Failed to find created repo ${r}`);return this.assetManager._toNoyaAsset(i)}async listFiles(t,n){let r=await this.rpcManager.requestRoute(`GET /api/git/repos/${t}/files`,{searchParams:{ref:n,includeContent:this.includeContent?"true":void 0}});return this.rpcManager.getResponseBody(r)}async listBranches(t){let n=await this.rpcManager.requestRoute(`GET /api/git/repos/${t}/branches`),{branches:r}=this.rpcManager.getResponseBody(n);return r}async patchFiles(t,n,r){let o=this.repoFiles$.get()[t],s=await this.rpcManager.requestRoute(`PATCH /api/git/repos/${t}/files`,{body:JSON.stringify(n),headers:{"Content-Type":"application/json"},searchParams:{ref:r,includeContent:this.includeContent?"true":void 0}}),a=this.rpcManager.getResponseBody(s);return o&&this.repoFiles$.set({...this.repoFiles$.get(),[t]:{...o,files:a.files,oid:a.oid,ref:a.ref,fileContents:a.fileContents}}),a}_sendMessage;_unsubscribeConnectionEvents;_editSessions=new Map;_sessionSubscriptions=new Map;_autoFetchedRepos=new Set;_repoStateCache=new Map;_makeSessionKey(t,n,r){return`${t}:${n}:${r}`}_handleConnectionEvent=t=>{if(t.type!=="receive")return;let n=t.message;switch(n.type){case"gitFileEdit.object":case"gitFileEdit.acceptPatch":case"gitFileEdit.rejectPatch":{let r=this._makeSessionKey(n.repoId,n.ref,n.filePath),i=this._editSessions.get(r);i&&i.handleServerMessage(n);break}case"gitFileEdit.committed":{let r=this.assetManager.read(n.repoId)?.id??n.repoId,o=this.repoFiles$.get()[r];o&&o.ref===n.ref&&this.refreshRepoFiles(r,o.ref);break}}};openEditingHandle(t,n,r){let i=this._makeSessionKey(t,r,n),o=this._editSessions.get(i),s=!o;o||(o=new kl({repoId:t,filePath:n,ref:r,sendMessage:l=>{this._sendMessage?.(l)},onClose:()=>{this._editSessions.delete(i);let l=this._sessionSubscriptions.get(i);l&&(l(),this._sessionSubscriptions.delete(i))}}),this._editSessions.set(i,o)),o.open();let a=o.getHandle();if(s){let l=a.content$.subscribe(p=>{this._updateFileContent(t,r,n,p)});this._sessionSubscriptions.set(i,l)}let c=a.close;return a.close=()=>{let l=this._sessionSubscriptions.get(i);l&&(l(),this._sessionSubscriptions.delete(i)),c()},a}_updateFileContent(t,n,r,i){let o=this.repoFiles$.get(),s=o[t];if(!s||s.ref!==n||!s.fileContents)return;let a;try{let p=new TextEncoder().encode(i),d="";for(let m=0;m<p.length;m++)d+=String.fromCharCode(p[m]);a=btoa(d)}catch{return}let c=s.fileContents.findIndex(p=>p.path===r),l;c>=0?(l=[...s.fileContents],l[c]={path:r,content:a}):l=[...s.fileContents,{path:r,content:a}],this.repoFiles$.set({...o,[t]:{...s,fileContents:l}})}};u();function wS(e,t,n){let r=t.find(o=>o.id===e||o.stableId===e);return r?r.type!=="asset"?r.url:n.find(o=>o.id===r.assetId||o.stableId===r.assetId)?.url??r.url:void 0}u();var Ul=class{requestEmitter=new Ee;responseEmitter=new Ee;isAvailable$=new _(!1);setIsAvailable(t){this.isAvailable$.set(t)}async pickImage(){let t=te();return new Promise(n=>{let r=this.responseEmitter.addListener(i=>{i.id===t&&(r(),n(i.resourceStableId))});this.requestEmitter.emit({id:t})})}handleResponse(t){this.responseEmitter.emit(t)}};u();var d6=100;function MS({store:e,connectionId:t,queue:n,payload:r,onQueueActivity:i}){let o=typeof n=="string"&&n.trim().length>0?n.trim():"default",s={id:crypto.randomUUID(),queue:o,payload:r,enqueuedAt:Date.now()},a=e.get(t)??new Map,c=a.get(o)??[];c.push(s),c.length>100&&c.splice(0,c.length-100),a.set(o,c),e.set(t,a),i?.(o)}function OS(e,t){let{connectionId:n,queue:r,maxEntries:i}=t??{},o=n?[n]:Array.from(e.keys()),a=(i!==void 0?Math.max(0,Math.floor(i)):void 0)??Number.POSITIVE_INFINITY,c=[];for(let l of o){if(a<=0)break;let p=e.get(l);if(!p)continue;let d=r?[r]:Array.from(p.keys());for(let m of d){if(a<=0)break;let y=p.get(m);if(!y?.length)continue;let S=Math.min(y.length,a),T=y.splice(0,S);c.push(...T.map(E=>({...E,connectionId:l}))),a-=S,y.length===0?p.delete(m):p.set(m,y)}p.size===0&&e.delete(l)}return c}function m6(e,t){e.delete(t)}u();var _l=class{constructor(t){this.rpcManager=t}inputs$=new _([]);outputTransforms$=new _([]);inputsInitialized$=new _(!1);outputTransformsInitialized$=new _(!1);isInitialized$=_.combine([this.inputsInitialized$,this.outputTransformsInitialized$],([t,n])=>t&&n);async fetchInputs(){let t=await this.rpcManager.requestRoute("GET /api/inputs",{});return this.rpcManager.getResponseBody(t)}async fetchOutputTransforms(){let t=await this.rpcManager.requestRoute("GET /api/outputTransforms",{});return this.rpcManager.getResponseBody(t)}async createInput(t){let n=await this.rpcManager.requestRoute("POST /api/inputs",{headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});return this.rpcManager.getResponseBody(n)}async createOutputTransform(t){let n=await this.rpcManager.requestRoute("POST /api/outputTransforms",{headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});return this.rpcManager.getResponseBody(n)}async deleteInput(t){let n=await this.rpcManager.requestRoute("DELETE /api/inputs",{headers:{"Content-Type":"application/json"},body:JSON.stringify({id:t})});return this.rpcManager.getResponseBody(n)}async deleteOutputTransform(t){let n=await this.rpcManager.requestRoute("DELETE /api/outputTransforms",{headers:{"Content-Type":"application/json"},body:JSON.stringify({id:t})});return this.rpcManager.getResponseBody(n)}async applyInputPatches(t){let n=await this.rpcManager.requestRoute("PATCH /api/inputs",{headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});return this.rpcManager.getResponseBody(n)}async applyOutputTransformPatches(t){let n=await this.rpcManager.requestRoute("PATCH /api/outputTransforms",{headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});return this.rpcManager.getResponseBody(n)}};u();function AS(){return typeof window<"u"&&window.self!==window.top}u();function RS(e){return btoa(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}function PS(e){switch(e=e.replace(/-/g,"+").replace(/_/g,"/"),e.length%4){case 2:e+="==";break;case 3:e+="=";break}return atob(e)}var wO={alg:"HS256",typ:"JWT"},CS={INVALID_JWT_FORMAT:"Invalid JWT format"};async function h6({payload:e,secret:t,header:n}){let r=new TextEncoder,i=RS(JSON.stringify({...wO,...n})),o=RS(JSON.stringify(e)),s=`${i}.${o}`,a=await crypto.subtle.importKey("raw",r.encode(t),{name:"HMAC",hash:"SHA-256"},!1,["sign"]),c=await crypto.subtle.sign("HMAC",a,r.encode(s)),l=RS(String.fromCharCode(...new Uint8Array(c)));return`${s}.${l}`}async function y6({token:e,secret:t}){if(typeof e!="string")throw new Error(CS.INVALID_JWT_FORMAT);let[n,r,i]=e.split(".");if(!n||!r||!i)throw new Error(CS.INVALID_JWT_FORMAT);let o=PS(n),s=PS(r),a=JSON.parse(o),c=JSON.parse(s),l=`${n}.${r}`,p=new TextEncoder;if(t!==void 0){let d=await crypto.subtle.importKey("raw",p.encode(t),{name:"HMAC",hash:"SHA-256"},!1,["verify"]),m=PS(i),y=new Uint8Array([...m].map(T=>T.charCodeAt(0))),S=await crypto.subtle.verify("HMAC",d,y,p.encode(l));return{header:a,payload:c,valid:S}}return{header:a,payload:c,valid:!1}}var Hd;(i=>(i.encode=h6,i.decode=y6,i.ERROR=CS,i.DEFAULT_HEADER=wO))(Hd||={});u();var jl=class{constructor(t){this.assetManager=t}async initialize(){await this.assetManager.fetch()}findBundleAsset(t){return this.assetManager.assets$.get().find(r=>(r.id===t||r.stableId===t)&&r.contentType===Ki)}async readBundle(t){let n=this.findBundleAsset(t);if(!n||!n.url)return null;try{let r=await fetch(n.url);if(!r.ok)return console.error(`Failed to fetch bundle ${t}: ${r.status}`),null;let i=await r.arrayBuffer();return new Uint8Array(i)}catch(r){return console.error(`Error fetching bundle ${t}:`,r),null}}async writeBundle(t,n){let r=this.findBundleAsset(t);try{r?await this.assetManager.update(r.id,{data:n,contentType:Ki}):await this.assetManager.create({data:n,contentType:Ki,stableId:t})}catch(i){throw console.error(`Error writing bundle ${t}:`,i),i}}async listBundleIds(){return this.assetManager.assets$.get().filter(n=>n.contentType===Ki).map(n=>n.stableId)}async deleteBundle(t){let n=this.findBundleAsset(t);if(n)try{await this.assetManager.delete(n.id)}catch(r){throw console.error(`Error deleting bundle ${t}:`,r),r}}};u();var Ll=class extends Ee{leftMenuItems$=new _([],{isEqual:Gt});rightMenuItems$=new _([],{isEqual:Gt});allMenuItems$=_.combine([this.leftMenuItems$,this.rightMenuItems$],([t,n])=>[...t,...n],{isEqual:Gt});getLeftMenuItems(){return this.leftMenuItems$.get()}getRightMenuItems(){return this.rightMenuItems$.get()}getAllMenuItems(){return this.allMenuItems$.get()}setLeftMenuItems(t){this.leftMenuItems$.set(t)}setRightMenuItems(t){this.rightMenuItems$.set(t)}showCommandPaletteEmitter=new Ee};u();u();u();u();u();u();var NS=class{constructor(t,n){this.taskRunner=t;this.refs=n}addTask(...t){let[n,r]=t.length===1?[{},t[0]]:t,i=`task-${++this.taskRunner.internalTaskId}`,o={id:n.id??i,fn:r,refs:this.refs,status:"pending",log:[],name:n.name};return this.taskRunner.tasks[o.id]=o,this.taskRunner.notifySubscribers(),{id:o.id}}createContext(...t){return this.taskRunner.createContext(...t)}},Bl=class e{tasks={};subscribers=[];internalTaskId=0;version=0;maxConcurrentTasks;currentConcurrentTasks=0;constructor({maxConcurrentTasks:t=1/0}={}){this.maxConcurrentTasks=t}createContext(...t){return new NS(this,t)}addTask(...t){let[n,r]=t.length===1?[{},t[0]]:t,o=this.createContext().addTask(n,(s,a)=>r(a));return this.notifySubscribers(),o}waitUntilSlotOpens(){return new Promise(t=>{let n=()=>this.currentConcurrentTasks<this.maxConcurrentTasks?(this.currentConcurrentTasks++,t(),!0):!1;if(!n()){let r=this.subscribe(()=>{n()&&r()})}})}async runTask(t){await this.waitUntilSlotOpens();let n=this.tasks[t.id];if(!n)throw new Error(`Task ${t.id} not found`);if(n.status==="completed")return n.result;n.status="enqueued",n.log=[],n.metadata=void 0,this.notifySubscribers();let r=[];try{r=await Promise.all(n.refs.map(i=>this.runTask(i).then(()=>this.tasks[i.id].result)))}catch(i){throw n.status="cancelled",this.notifySubscribers(),i}try{let i={log:(...s)=>{n.log.push(s),this.notifySubscribers()},writeLog:s=>{let a=n.log.at(-1),c=a?.at(-1);a&&typeof c=="string"?a[a.length-1]+=c+s:n.log.push([s]),this.notifySubscribers()},setMetadata:s=>{n.metadata=s instanceof Function?s(n.metadata):s,this.notifySubscribers()}};n.status="in progress",this.notifySubscribers();let o=await n.fn(r,i);return n.result=o,n.status="completed",this.notifySubscribers(),o}catch(i){throw n.status="error",this.notifySubscribers(),i}finally{this.currentConcurrentTasks--,this.maxConcurrentTasks!==1/0&&this.notifySubscribers()}}subscribe=t=>(this.subscribers.push(t),()=>{this.subscribers=this.subscribers.filter(n=>n!==t)});_cachedSnapshot=[0,[]];getSnapshot=()=>{if(this.version===this._cachedSnapshot[0])return this._cachedSnapshot[1];let t=Object.values(this.tasks).map(n=>({id:n.id,name:n.name,status:n.status,log:n.log,metadata:n.metadata,deps:n.refs.map(r=>r.id)}));return this._cachedSnapshot=[this.version,t],t};notifySubscribers=()=>{this.version++,this.subscribers.forEach(t=>t())};clearCompletedTasks=()=>{let t;do{t=!1;for(let n of Object.values(this.tasks))n.status==="completed"&&(Object.values(this.tasks).flatMap(i=>i.refs).includes(n)||(delete this.tasks[n.id],t=!0))}while(t);this.notifySubscribers()};clearTasks=()=>{this.tasks={},this.notifySubscribers()};async rerunFailedTask(t){let n=this.tasks[t.id];if(!n)throw new Error(`Task ${t.id} not found`);return n.status="pending",n.log=[],this.notifySubscribers(),this.runTask(t)}async runAllTasks(){return Promise.all(Object.values(this.tasks).map(t=>this.runTask(e.toRef(t))))}static toRef(t){return{id:t.id}}};u();var MO="AES-GCM",Gd=e=>{let t=e.match(/[\dA-F]{2}/gi)||[];return new Uint8Array(t.map(n=>parseInt(n,16)))};async function OO({encrypted:e,iv:t,tag:n,ENCRYPTION_KEY:r}){let i=Gd(r),o=Gd(e),s=Gd(t),a=Gd(n),c=new Uint8Array([...o,...a]),l=await crypto.subtle.importKey("raw",i,{name:MO},!1,["decrypt"]),p=await crypto.subtle.decrypt({name:MO,iv:s,tagLength:128},l,c);return new TextDecoder().decode(p)}u();var AO=e=>{let{message:t,frames:n}=e,r=`Uncaught Error: ${t}`,i=n.map(o=>{let{functionName:s,contextLines:a}=o,c=Math.max(...a?.map(m=>m.lineNumber)??[]),l=`@ function ${s}`,p=c.toString().length;if(!a)return l;let d=a.map(m=>{let y=`${m.lineNumber.toString().padStart(p)}: ${m.content}`;if(m.errorColumn!==void 0){let S="X".repeat(p)+":"+" ".repeat(m.errorColumn)+"^";return`${y}
61
+ })()`,c;return this.vm.unwrapResult(this.vm.evalCode(a,`${this.definition.id}-migration.js`,{type:"global"})).consume(l=>{c=this.vm.dump(l)}),this.normalizeResult(c)}catch(s){this.log("error","Migration script error:",s);return}}},Qs=class{constructor(t){this.options=t;this.randomUUID=t.randomUUID??u6(),this.environment=l6(t.environment),this.log=t.log}isHot=!1;runners=new Map;quickJSPromise=null;randomUUID;environment;log;getQuickJSPromise(){if(!this.quickJSPromise){let t=this.options.getQuickJSModule();this.quickJSPromise=Promise.resolve(t)}return this.quickJSPromise}setIsHot(t){if(this.isHot!==t){this.isHot=t;for(let n of this.runners.values())n.setActive(t)}}syncInvocation(t,n,r){let i=t??(this.runners.size===1?Array.from(this.runners.keys())[0]:void 0);if(!i)return;this.runners.get(i)?.syncInvocation(n,r)}async updateSchema(t){let n=gS(t),r=new Set;for(let i of n){r.add(i.id);let o=this.runners.get(i.id);if(o){o.isSameDefinition(i)||o.updateDefinition(i),this.isHot&&o.setActive(!0);continue}let s=new ES(i,this.getQuickJSPromise(),this.options,this.environment,this.log,this.randomUUID);this.runners.set(i.id,s),this.isHot&&s.setActive(!0)}for(let[i,o]of Array.from(this.runners.entries()))r.has(i)||(o.dispose(),this.runners.delete(i))}handleStateChange(t){if(this.isHot&&t.length!==0)for(let n of this.runners.values())n.handleStateChange(t)}handleInputQueueActivity(t){if(this.isHot)for(let n of this.runners.values())n.handleInputQueue(t)}handleUserEvent(t,n){if(this.isHot)for(let r of this.runners.values())r.handleUserEvent(t,n)}async handleSchemaMigration(t,n,r){let i=r,o=!1;for(let s of this.runners.values())try{let a=await s.runMigration(t,n,i);a!==void 0&&(i=a,o=!0)}catch(a){console.error(`Migration script ${s.id} failed:`,a)}return o?i:void 0}dispose(){for(let t of this.runners.values())t.dispose();this.runners.clear(),this.quickJSPromise=null}};var Nl=(e,t)=>Zw(e,{...t,ignoreUndefinedProperties:!0}),Ys=class extends Error{constructor(n,r){super(r);this.reason=n}},Gi=class extends Ee{constructor(n,r={}){super();this.options=r;this.state=n instanceof Function?n():n,this.schema=r.schema,this.sm=new $s(this.state,r),this.optimisticState$=_.from({get:this.getOptimisticState,subscribe:this.addListener},{isEqual:(i,o)=>this.createHashCached(i)===this.createHashCached(o)}),this.options.mode==="standalone"&&this.autoConnect(),this.initializeServerSimulator()}get _metadataType(){throw new Error("Not implemented - this is just a type hint")}state;schema;errorEmitter=new Ee;sm;pendingCommits=[];connectionStatus$=new _("disconnected");isInitialized$=new _(!1);outgoingMessages=[];incomingMessages=[];optimisticState$;partialHashCache=new Qa({capacity:2e4});createHashCached=new Qa({capacity:100}).wrap(n=>Nl(n,{cache:this.partialHashCache}));applyCommitCache=new Qa({capacity:25});policyAuthContext;enforcePoliciesLocally=!0;enhanceMetadata(n){return{id:this.getRandomId(),timestamp:Date.now(),...n}}getRandomId(){return this.options.randomId?.()??te()}initializeServerSimulator(){let n=this.options.serverScripts;!n?.getQuickJSModule||n.simulateLocally!==!0||(this.serverScriptSimulator=new Qs({getQuickJSModule:n.getQuickJSModule,randomUUID:n.randomUUID,environment:{target:"client-simulator",mode:"simulation",label:"simulator",clock:n.getNow??(()=>this.getServerNowEstimate())},getState:()=>this.state,getSharedConnectionData:this.options.getSharedConnectionData??(()=>({})),setSharedConnectionData:()=>{},getInitialInvocation:r=>{let i=r??"default";return this.serverInvocationTracker.get(i)?.invocation},drainInputQueue:r=>this.options.drainInputQueue?.(r)??[],applyState:async({scriptId:r,nextState:i,invocation:o,timestamp:s})=>{this.applyServerPrediction({scriptId:r,nextState:i,invocation:o,timestamp:s})},log:r=>{console[r.level]("[server-sim]",r.scriptId,...r.values);let i=r.values.map(o=>Vs(o));this.serverSimulationLogManager.append({id:this.getRandomId(),scriptId:r.scriptId,level:r.level,values:i,timestamp:Date.now(),origin:r.origin,target:r.target,mode:r.mode})}}),this.serverScriptSimulator.setIsHot(!1),this.serverScriptSimulator.updateSchema(this.schema))}setPolicyAuthContext(n){this.policyAuthContext=n}setLocalPolicyEnforcement(n){this.enforcePoliciesLocally=n}autoConnect=()=>{let n=r=>{switch(r.type){case"init":{this.incomingMessages.push({type:"object",object:r.object,schema:r.schema}),this.processIncomingMessages();break}case"patch":{this.incomingMessages.push({type:"acceptPatch",id:r.id,patches:r.patches,serverInvocation:r.serverInvocation}),this.processIncomingMessages();break}}};this.messageEmitter.addListener(n),this.connect()};getHash(){return this.createHashCached(this.state)}_setState(n,r){this.state=n,this.schema=r,this.emitIfChanged(),this.sm._setState(n)}_lastEmittedHash;emitIfChanged=()=>{this._lastEmittedHash!==this.getOptimisticHash()&&(this._lastEmittedHash=this.getOptimisticHash(),this.emit())};get isConnected(){return this.connectionStatus$.get()==="connected"}_pushCommit(n,r,{addToHistory:i,shouldTypeCheck:o=!0,sendMessage:s=!0}){if(!this.isConnected){console.warn("Can't edit when not connected");return}o&&Ao(n,this.schema,Er(this.schema));let a=this.getOptimisticState(),l=this.enforcePoliciesLocally&&this.policyAuthContext!==void 0?this.getLocalPolicyViolation({previousState:a,nextState:n,patches:r.redoPatches,auth:this.policyAuthContext}):void 0;if(l){this.errorEmitter.emit(new Ys("policyViolation",l.message??"Policy violation"));return}let p={state:n,historyEntry:r,baseHash:this.getOptimisticHash()};this.pendingCommits.push(p),this.emitIfChanged(),i&&(this.applyCommitCache.set(r.metadata.id,{input:a,output:n}),this.sm._setStateWithHistoryEntry(n,r,{shouldTypeCheck:!1})),s&&this.sendMessage({type:"patch",id:p.historyEntry.metadata.id,name:p.historyEntry.metadata.name,patches:p.historyEntry.redoPatches,baseHash:p.baseHash,...r.metadata.serverInvocation&&{serverInvocation:r.metadata.serverInvocation}})}getLocalPolicyViolation(n){if(n.patches.length===0)return;let r=n.auth;if(!this.schema)return(r.access??"write")!=="write"?{action:"update",patch:n.patches[0],message:"Insufficient access level to edit this field"}:void 0;let i=this.options.getNow?.()??Date.now(),o=n.nextState;try{let s=n.patches.map(f6),a=SS({schema:this.schema,patches:s,auth:r,now:i});o=De(n.previousState,[...s,...a])}catch{o=n.nextState}return bS({schema:this.schema,patches:n.patches,previousState:n.previousState,nextState:o,auth:r,now:i})}canUndo=()=>this.sm.canUndo();canRedo=()=>this.sm.canRedo();undo=()=>{if(!this.sm.canUndo())return;let n=this.sm.history[this.sm.historyIndex-1];this.sm.historyIndex--;let r=No(this.getOptimisticState(),{},{...n.metadata,id:this.getRandomId()},n.undoPatches,n.redoPatches);if(r)return this._pushCommit(r.state,r.historyEntry,{addToHistory:!1}),this.sm.history[this.sm.historyIndex]};redo=()=>{if(!this.sm.canRedo())return;let n=this.sm.history[this.sm.historyIndex];this.sm.historyIndex++;let r=No(this.getOptimisticState(),{},{...n.metadata,id:this.getRandomId()},n.redoPatches,n.undoPatches);if(r)return this._pushCommit(r.state,r.historyEntry,{addToHistory:!1}),this.sm.history[this.sm.historyIndex-1]};editDraft=(...n)=>{let[r,i]=n.length===1?[{},n[0]]:n,o=this.getOptimisticState(),s=Dd(o,{},this.enhanceMetadata(r),i);s&&this._pushCommit(s.state,s.historyEntry,{addToHistory:!0})};applyPatch=(...n)=>{let[r,{patches:i,inversePatches:o}]=n.length===1?[{},n[0]]:n,s=this.getOptimisticState(),a=De(s,i);if(Ao(a,this.schema,Er(this.schema)),!o){let[,l]=Qr(s,a);o=l}let c=No(a,{},this.enhanceMetadata(r),i,o);c&&this._pushCommit(c.state,c.historyEntry,{addToHistory:!0})};setState=(...n)=>{let[r,i]=n.length===1?[{},n[0]]:n,o=this.getOptimisticState(),s=i instanceof Function?i(o):i;Ao(s,this.schema,Er(this.schema));let[a,c]=Qr(o,s,{useExtendedPatches:!0}),l=No(s,{},this.enhanceMetadata(r),a,c);l&&this._pushCommit(l.state,l.historyEntry,{addToHistory:!0})};setStateAtPath=(...n)=>{let[r,i,o]=n.length===2?[{},n[0],n[1]]:n,s=this.setState;if(!i||i.length===0)s(r,o);else{let a=this.getOptimisticState(),c=o instanceof Function?o(Ht(a,i)):o,l=Ls(a,i,c);this.setState(r,l)}};operate=(...n)=>{let[r,i]=n.length===1?[{},n[0]]:n,o=new Co(this.state);i(o);let s=Mr.compactPatches(o.patches),a=Mr.compactPatches(o.inversePatches),c=De(this.state,s);if(this.options.allowEmptyEdits!==!0&&s.length===0)return;let l=No(c,{},this.enhanceMetadata(r),s,a);l&&this._pushCommit(l.state,l.historyEntry,{addToHistory:!0})};getConfirmedState=()=>this.state;getOptimisticState=()=>this.pendingCommits.at(-1)?.state??this.state;getOptimisticHash(){return this.createHashCached(this.getOptimisticState())}reinitialize(n){this.pendingCommits=[],this.serverPredictionCommits.clear(),this.emitIfChanged(),this.sendMessage({type:"init",object:n,...this.schema&&{schema:Io(this.schema)}})}_handledMessages={};processIncomingMessages(){for(;this.incomingMessages.length>0;){let n=this.incomingMessages.shift();if("id"in n){if(this._handledMessages[n.id])continue;this._handledMessages[n.id]=!0}switch(n.type){case"object":{this._setState(n.object,n.schema?Eo(n.schema):void 0),this.serverScriptSimulator?.updateSchema(this.schema),this.isInitialized$.set(!0);break}case"acceptPatch":{let r=n.patches;this.handleServerInvocation(n.serverInvocation),n.serverInvocation||this.clearServerPredictions();let i=this.state,o,s=this.applyCommitCache.get(n.id),a=this.pendingCommits.find(l=>l.historyEntry.metadata.id===n.id),c=s&&s.input===i&&p6(a?.historyEntry.redoPatches,r);try{c?o=s.output:o=De(i,r)}catch{this.reinitialize(i);break}if(this.pendingCommits=this.pendingCommits.filter(l=>l.historyEntry.metadata.id!==n.id),n.hash!==void 0&&n.hash!==this.createHashCached(o)){this.reinitialize(i);break}this._setState(o,this.schema),this.serverScriptSimulator?.handleStateChange(r);break}case"rejectPatch":{switch(n.reason){default:{this.reinitialize(this.state),this.errorEmitter.emit(new Ys(n.reason,n.error));break}}break}case"rejectInit":{console.error("State initialized with invalid data type.",n.error),this.errorEmitter.emit(new Ys(n.reason,n.error));break}case"schemaMigration":{this.errorEmitter.emit(new Ys("schemaMigration","Schema migration requires a page reload."));break}}}}connect(){this.connectionStatus$.set("connected"),this.serverScriptSimulator?.setIsHot(!0),this.sendInit()}sendInit({force:n=this.options.overrideExistingState,state:r=this.state,schema:i=this.schema,outputTransforms:o=this.options.outputTransforms,inputs:s=this.options.inputs}={}){this.sendMessage({type:"init",object:r,...i&&{schema:Io(i)},...o&&{outputTransforms:o},...s&&{inputs:s},...n&&{force:n}})}sendMessage(n){this.outgoingMessages.push(n),this.messageEmitter.emit(n)}disconnect(){this.connectionStatus$.set("disconnected"),this.serverScriptSimulator?.setIsHot(!1)}hasPendingMessages(){return this.incomingMessages.length>0||this.outgoingMessages.length>0}messageEmitter=new Ee;serverSimulationLogManager=new zs;serverSimulationLogs$=this.serverSimulationLogManager.logs$;serverPredictionCommits=new Map;serverInvocationTracker=new Map;serverClockSkewMs=0;serverScriptSimulator;getNow(){return this.options.getNow?.()??Date.now()}getServerNowEstimate(){return this.getNow()+this.serverClockSkewMs}getServerSimulationDiagnostics(){let n=Array.from(this.serverInvocationTracker.entries()).map(([i,o])=>({scriptId:i==="default"?void 0:i,invocation:o.invocation,timestamp:o.timestamp})),r=Array.from(this.serverPredictionCommits.entries()).map(([i,o])=>{let[s,a]=i.split(":"),c=Number(a);return{scriptId:s==="default"?void 0:s,invocation:Number.isNaN(c)?void 0:c,commitId:o}});return{simulateLocally:this.options.serverScripts?.simulateLocally===!0,simulatorActive:!!this.serverScriptSimulator,clockSkewMs:this.serverClockSkewMs,invocations:n,pendingPredictions:r}}getLatestServerInvocation(n){let r=n??"default";return this.serverInvocationTracker.get(r)}getLatestPrediction(){let n=[...this.pendingCommits].reverse().find(r=>r.historyEntry.metadata.serverInvocation?.source==="client-sim");if(n)return{state:n.state,serverInvocation:n.historyEntry.metadata.serverInvocation}}clearServerPredictions(){if(this.serverPredictionCommits.size===0)return;let n=new Set(this.serverPredictionCommits.values());this.pendingCommits=this.pendingCommits.filter(r=>!n.has(r.historyEntry.metadata.id)),this.serverPredictionCommits.clear(),this.emitIfChanged()}applyServerPrediction(n){if(!this.isConnected)return;let r=n.scriptId??"default",i=this.serverInvocationTracker.get(r)?.invocation;if(i!==void 0&&n.invocation!==void 0&&n.invocation<=i)return;let o=this.state,[s,a]=Qr(o,n.nextState,{useExtendedPatches:!0});if(s.length===0)return;let c=i!==void 0?i+1:n.invocation??1,l=n.timestamp??this.getServerNowEstimate(),p=this.serverPredictionCommits.get(`${r}:${c}`);p&&(this.pendingCommits=this.pendingCommits.filter(y=>y.historyEntry.metadata.id!==p),this.serverPredictionCommits.delete(`${r}:${c}`));let d={name:`predicted ${r}#${c}`,serverInvocation:{scriptId:n.scriptId,invocation:c,timestamp:l,source:"client-sim"}},m=No(n.nextState,{},this.enhanceMetadata(d),s,a);m&&(this.serverInvocationTracker.set(r,{invocation:c,timestamp:l}),this._pushCommit(m.state,m.historyEntry,{addToHistory:!1,sendMessage:!1}),this.serverPredictionCommits.set(`${r}:${c}`,m.historyEntry.metadata.id),this.emitIfChanged())}handleServerInvocation(n){if(!n)return;let r=n.scriptId??"default",i=n.timestamp-this.getNow();this.serverClockSkewMs=this.serverClockSkewMs===0?i:this.serverClockSkewMs*.9+i*.1;let o=`${r}:${n.invocation}`,s=this.serverPredictionCommits.get(o),a=!1;s&&(this.pendingCommits=this.pendingCommits.filter(c=>c.historyEntry.metadata.id!==s),this.serverPredictionCommits.delete(o),a=!0);for(let[c,l]of Array.from(this.serverPredictionCommits.entries())){if(!c.startsWith(`${n.scriptId??"default"}:`))continue;let[,p]=c.split(":"),d=Number(p);Number.isNaN(d)||d<=n.invocation&&(this.pendingCommits=this.pendingCommits.filter(m=>m.historyEntry.metadata.id!==l),this.serverPredictionCommits.delete(c),a=!0)}a&&this.emitIfChanged(),this.serverInvocationTracker.set(r,{invocation:n.invocation,timestamp:n.timestamp}),this.serverScriptSimulator?.syncInvocation(n.scriptId,n.invocation,n.timestamp)}};function p6(e,t){return!e||!t?!1:Gt(e,t)}function f6(e){return{...e,path:e.path.map(EO),...e.from&&{from:e.from.map(EO)},..."value"in e?{value:wS(e.value)}:{}}}function EO(e){return typeof e=="object"?{id:e.id}:e}function wS(e){if(Array.isArray(e))return e.map(t=>wS(t));if(e&&typeof e=="object"){let t={};for(let[n,r]of Object.entries(e))t[n]=wS(r);return t}return e}var Cl=class extends Ee{data$=new _({});metadata$=new _({});currentConnectionId$=new _(void 0);currentConnectionDataEmitter=new Ee;setCurrentConnectionId=t=>{this.currentConnectionId$.set(t)};setForCurrentConnection=t=>{let n=this.currentConnectionId$.get();n&&(this.set(n,t),this.currentConnectionDataEmitter.emit(t))};set=(t,n)=>{this.metadata$.set({...this.metadata$.get(),[t]:{updatedAt:Date.now()}}),this.data$.set({...this.data$.get(),[t]:n}),this.emit(this.data$.get(),this.metadata$.get())};merge=t=>{this.data$.set({...this.data$.get(),...t});for(let n in t)this.metadata$.set({...this.metadata$.get(),[n]:{updatedAt:Date.now()}});this.emit(this.data$.get(),this.metadata$.get())};delete=t=>{let{[t]:n,...r}=this.data$.get();this.data$.set(r);let{[t]:i,...o}=this.metadata$.get();this.metadata$.set(o),this.emit(this.data$.get(),this.metadata$.get()),t===this.currentConnectionId$.get()&&this.currentConnectionDataEmitter.emit(void 0)};_snapshot;getSnapshot=()=>((!this._snapshot||this._snapshot.data!==this.data$.get()||this._snapshot.metadata!==this.metadata$.get()||this._snapshot.currentConnectionId!==this.currentConnectionId$.get())&&(this._snapshot={data:this.data$.get(),metadata:this.metadata$.get(),currentConnectionId:this.currentConnectionId$.get()}),this._snapshot)};var kl=class{constructor(t){this.options=t;this.ensureMessageSubscription()}multiplayer=new Gi("");unsubscribeMultiplayerMessages;isOpen=!1;getHandle(){return{repoId:this.options.repoId,filePath:this.options.filePath,ref:this.options.ref,content$:this.multiplayer.optimisticState$,isInitialized$:this.multiplayer.isInitialized$,sendPatches:(n,r)=>{this.sendPatches(n,r)},setState:(n,r)=>{this.setState(n,r)},close:()=>this.close()}}open(){if(this.ensureMessageSubscription(),!this.isOpen){this.isOpen=!0,this.multiplayer.connect();return}this.multiplayer.reinitialize(this.multiplayer.getConfirmedState())}close(){this.isOpen&&(this.isOpen=!1,this.multiplayer.disconnect(),this.options.sendMessage?.({type:"gitFileEdit.close",repoId:this.options.repoId,filePath:this.options.filePath,ref:this.options.ref}),this.unsubscribeMultiplayerMessages?.(),this.unsubscribeMultiplayerMessages=void 0,this.options.onClose?.())}sendPatches(t,n){this.multiplayer.applyPatch(n??{},{patches:t})}setState(t,n){let r=this.multiplayer.optimisticState$.get(),[i]=Qr(r,t,{useExtendedPatches:!0});i.length>0&&this.sendPatches(i,n)}handleServerMessage(t){let n=this.translateIncomingMessage(t);n&&(this.multiplayer.incomingMessages.push(n),this.multiplayer.processIncomingMessages())}flushOutgoingMessages(){for(;this.multiplayer.outgoingMessages.length>0;){let t=this.multiplayer.outgoingMessages.shift(),n=this.translateOutgoingMessage(t);n&&this.options.sendMessage?.(n)}}translateOutgoingMessage(t){switch(t.type){case"init":return{type:"gitFileEdit.open",repoId:this.options.repoId,filePath:this.options.filePath,ref:this.options.ref};case"patch":return{type:"gitFileEdit.patch",repoId:this.options.repoId,filePath:this.options.filePath,ref:this.options.ref,id:t.id,patches:t.patches,baseHash:t.baseHash};default:return}}translateIncomingMessage(t){switch(t.type){case"gitFileEdit.object":return{type:"object",object:t.content};case"gitFileEdit.acceptPatch":return{type:"acceptPatch",id:t.id,patches:t.patches,hash:t.hash};case"gitFileEdit.rejectPatch":return{type:"rejectPatch",id:t.id,reason:t.reason,error:t.error};default:return}}ensureMessageSubscription(){this.unsubscribeMultiplayerMessages||(this.unsubscribeMultiplayerMessages=this.multiplayer.messageEmitter.addListener(()=>{this.flushOutgoingMessages()}))}};u();var Dl=class{constructor(t,n,r={}){this.rpcManager=t;this.assetManager=n;this.includeContent=r.includeContent??!1,this.repos$=this.assetManager.assets$.map(i=>i.filter(o=>o.contentType===Ki).map(o=>this.assetManager._toNoyaAsset(o))),this.isInitialized$=this.assetManager.isInitialized$,this.repoFiles$=new _({}),this._sendMessage=r.sendMessage,r.subscribeConnectionEvents&&(this._unsubscribeConnectionEvents=r.subscribeConnectionEvents(this._handleConnectionEvent))}repos$;isInitialized$;repoFiles$;includeContent;getRepoState$(t){let n=`${t}:${this.includeContent}`,r=this._repoStateCache.get(n);if(r)return r;let i=this.repos$.map(s=>s.find(a=>a.id===t)?.id),o=_.combine([this.repoFiles$,i],([s,a])=>a&&a in s?s[a]:void 0);return _.combine([this.repoFiles$,i],([s,a])=>{a&&(a in s||this._autoFetchedRepos.has(a)||(this._autoFetchedRepos.add(a),this.fetchRepoFiles(a)))}),this._repoStateCache.set(n,o),o}async fetchRepoFiles(t,n){let i=this.repoFiles$.get()[t]?.branches??[];this.repoFiles$.set({...this.repoFiles$.get(),[t]:{fetchState:"loading",files:[],ref:n??"HEAD",oid:"",branches:i}});try{let[o,s]=await Promise.all([this.listFiles(t,n),i.length>0?Promise.resolve(i):this.listBranches(t)]);this.repoFiles$.set({...this.repoFiles$.get(),[t]:{fetchState:"idle",...o,branches:s,includeContent:this.includeContent}})}catch(o){this.repoFiles$.set({...this.repoFiles$.get(),[t]:{fetchState:"idle",files:[],ref:n??"HEAD",oid:"",branches:i,error:o instanceof Error?o.message:"Unknown error",includeContent:this.includeContent}})}}async refreshRepoFiles(t,n){let r=this.repoFiles$.get(),i=r[t];if(i){this.repoFiles$.set({...r,[t]:{...i,fetchState:"refreshing"}});try{let o=await this.listFiles(t,n),s=this.repoFiles$.get();this.repoFiles$.set({...s,[t]:{...s[t],fetchState:"idle",files:o.files,oid:o.oid,ref:o.ref,fileContents:o.fileContents,includeContent:this.includeContent}})}catch(o){let s=this.repoFiles$.get();this.repoFiles$.set({...s,[t]:{...s[t],fetchState:"idle"}}),console.error("[GitManager] Background refresh failed:",o)}}}async initRepo(t){let n=await this.rpcManager.requestRoute("POST /api/git/repos",{headers:{"Content-Type":"application/json"},body:JSON.stringify(t??{})}),{id:r}=this.rpcManager.getResponseBody(n);await this.assetManager.fetch();let i=this.assetManager.assets$.get().find(o=>(o.id===r||o.stableId===r)&&o.contentType===Ki);if(!i)throw new Error(`Failed to find created repo ${r}`);return this.assetManager._toNoyaAsset(i)}async listFiles(t,n){let r=await this.rpcManager.requestRoute(`GET /api/git/repos/${t}/files`,{searchParams:{ref:n,includeContent:this.includeContent?"true":void 0}});return this.rpcManager.getResponseBody(r)}async listBranches(t){let n=await this.rpcManager.requestRoute(`GET /api/git/repos/${t}/branches`),{branches:r}=this.rpcManager.getResponseBody(n);return r}async patchFiles(t,n,r){let o=this.repoFiles$.get()[t],s=await this.rpcManager.requestRoute(`PATCH /api/git/repos/${t}/files`,{body:JSON.stringify(n),headers:{"Content-Type":"application/json"},searchParams:{ref:r,includeContent:this.includeContent?"true":void 0}}),a=this.rpcManager.getResponseBody(s);return o&&this.repoFiles$.set({...this.repoFiles$.get(),[t]:{...o,files:a.files,oid:a.oid,ref:a.ref,fileContents:a.fileContents}}),a}_sendMessage;_unsubscribeConnectionEvents;_editSessions=new Map;_sessionSubscriptions=new Map;_autoFetchedRepos=new Set;_repoStateCache=new Map;_makeSessionKey(t,n,r){return`${t}:${n}:${r}`}_handleConnectionEvent=t=>{if(t.type!=="receive")return;let n=t.message;switch(n.type){case"gitFileEdit.object":case"gitFileEdit.acceptPatch":case"gitFileEdit.rejectPatch":{let r=this._makeSessionKey(n.repoId,n.ref,n.filePath),i=this._editSessions.get(r);i&&i.handleServerMessage(n);break}case"gitFileEdit.committed":{let r=this.assetManager.read(n.repoId)?.id??n.repoId,o=this.repoFiles$.get()[r];o&&o.ref===n.ref&&this.refreshRepoFiles(r,o.ref);break}}};openEditingHandle(t,n,r){let i=this._makeSessionKey(t,r,n),o=this._editSessions.get(i),s=!o;o||(o=new kl({repoId:t,filePath:n,ref:r,sendMessage:l=>{this._sendMessage?.(l)},onClose:()=>{this._editSessions.delete(i);let l=this._sessionSubscriptions.get(i);l&&(l(),this._sessionSubscriptions.delete(i))}}),this._editSessions.set(i,o)),o.open();let a=o.getHandle();if(s){let l=a.content$.subscribe(p=>{this._updateFileContent(t,r,n,p)});this._sessionSubscriptions.set(i,l)}let c=a.close;return a.close=()=>{let l=this._sessionSubscriptions.get(i);l&&(l(),this._sessionSubscriptions.delete(i)),c()},a}_updateFileContent(t,n,r,i){let o=this.repoFiles$.get(),s=o[t];if(!s||s.ref!==n||!s.fileContents)return;let a;try{let p=new TextEncoder().encode(i),d="";for(let m=0;m<p.length;m++)d+=String.fromCharCode(p[m]);a=btoa(d)}catch{return}let c=s.fileContents.findIndex(p=>p.path===r),l;c>=0?(l=[...s.fileContents],l[c]={path:r,content:a}):l=[...s.fileContents,{path:r,content:a}],this.repoFiles$.set({...o,[t]:{...s,fileContents:l}})}};u();function Hd(e,t,n){let r=t.find(o=>o.id===e||o.stableId===e);return r?r.type!=="asset"?r.url:n.find(o=>o.id===r.assetId||o.stableId===r.assetId)?.url??r.url:void 0}async function d6(e,t){let n=t.resourceManager.optimisticResources$.get(),r=n.find(s=>s.id===e||s.stableId===e);if(!r){let s=await t.resourceManager.listResources();t.resourceManager.setResources(s),n=t.resourceManager.optimisticResources$.get(),r=n.find(a=>a.id===e||a.stableId===e)}if(!r)throw new Error(`Resource not found: ${e}`);let i=r.type==="asset"?t.assetManager.read(r.assetId):void 0,o=Hd(r.stableId,n,t.assetManager.assets$.get());if(!o)throw new Error(`Resource URL not found: ${e}`);return{asset:i,resource:r,url:o}}u();var Ul=class{requestEmitter=new Ee;responseEmitter=new Ee;isAvailable$=new _(!1);setIsAvailable(t){this.isAvailable$.set(t)}async pickImage(){let t=te();return new Promise(n=>{let r=this.responseEmitter.addListener(i=>{i.id===t&&(r(),n(i.resourceStableId))});this.requestEmitter.emit({id:t})})}handleResponse(t){this.responseEmitter.emit(t)}};u();var m6=100;function MS({store:e,connectionId:t,queue:n,payload:r,onQueueActivity:i}){let o=typeof n=="string"&&n.trim().length>0?n.trim():"default",s={id:crypto.randomUUID(),queue:o,payload:r,enqueuedAt:Date.now()},a=e.get(t)??new Map,c=a.get(o)??[];c.push(s),c.length>100&&c.splice(0,c.length-100),a.set(o,c),e.set(t,a),i?.(o)}function OS(e,t){let{connectionId:n,queue:r,maxEntries:i}=t??{},o=n?[n]:Array.from(e.keys()),a=(i!==void 0?Math.max(0,Math.floor(i)):void 0)??Number.POSITIVE_INFINITY,c=[];for(let l of o){if(a<=0)break;let p=e.get(l);if(!p)continue;let d=r?[r]:Array.from(p.keys());for(let m of d){if(a<=0)break;let y=p.get(m);if(!y?.length)continue;let S=Math.min(y.length,a),T=y.splice(0,S);c.push(...T.map(E=>({...E,connectionId:l}))),a-=S,y.length===0?p.delete(m):p.set(m,y)}p.size===0&&e.delete(l)}return c}function h6(e,t){e.delete(t)}u();var _l=class{constructor(t){this.rpcManager=t}inputs$=new _([]);outputTransforms$=new _([]);inputsInitialized$=new _(!1);outputTransformsInitialized$=new _(!1);isInitialized$=_.combine([this.inputsInitialized$,this.outputTransformsInitialized$],([t,n])=>t&&n);async fetchInputs(){let t=await this.rpcManager.requestRoute("GET /api/inputs",{});return this.rpcManager.getResponseBody(t)}async fetchOutputTransforms(){let t=await this.rpcManager.requestRoute("GET /api/outputTransforms",{});return this.rpcManager.getResponseBody(t)}async createInput(t){let n=await this.rpcManager.requestRoute("POST /api/inputs",{headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});return this.rpcManager.getResponseBody(n)}async createOutputTransform(t){let n=await this.rpcManager.requestRoute("POST /api/outputTransforms",{headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});return this.rpcManager.getResponseBody(n)}async deleteInput(t){let n=await this.rpcManager.requestRoute("DELETE /api/inputs",{headers:{"Content-Type":"application/json"},body:JSON.stringify({id:t})});return this.rpcManager.getResponseBody(n)}async deleteOutputTransform(t){let n=await this.rpcManager.requestRoute("DELETE /api/outputTransforms",{headers:{"Content-Type":"application/json"},body:JSON.stringify({id:t})});return this.rpcManager.getResponseBody(n)}async applyInputPatches(t){let n=await this.rpcManager.requestRoute("PATCH /api/inputs",{headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});return this.rpcManager.getResponseBody(n)}async applyOutputTransformPatches(t){let n=await this.rpcManager.requestRoute("PATCH /api/outputTransforms",{headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});return this.rpcManager.getResponseBody(n)}};u();function AS(){return typeof window<"u"&&window.self!==window.top}u();function RS(e){return btoa(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}function PS(e){switch(e=e.replace(/-/g,"+").replace(/_/g,"/"),e.length%4){case 2:e+="==";break;case 3:e+="=";break}return atob(e)}var wO={alg:"HS256",typ:"JWT"},CS={INVALID_JWT_FORMAT:"Invalid JWT format"};async function y6({payload:e,secret:t,header:n}){let r=new TextEncoder,i=RS(JSON.stringify({...wO,...n})),o=RS(JSON.stringify(e)),s=`${i}.${o}`,a=await crypto.subtle.importKey("raw",r.encode(t),{name:"HMAC",hash:"SHA-256"},!1,["sign"]),c=await crypto.subtle.sign("HMAC",a,r.encode(s)),l=RS(String.fromCharCode(...new Uint8Array(c)));return`${s}.${l}`}async function g6({token:e,secret:t}){if(typeof e!="string")throw new Error(CS.INVALID_JWT_FORMAT);let[n,r,i]=e.split(".");if(!n||!r||!i)throw new Error(CS.INVALID_JWT_FORMAT);let o=PS(n),s=PS(r),a=JSON.parse(o),c=JSON.parse(s),l=`${n}.${r}`,p=new TextEncoder;if(t!==void 0){let d=await crypto.subtle.importKey("raw",p.encode(t),{name:"HMAC",hash:"SHA-256"},!1,["verify"]),m=PS(i),y=new Uint8Array([...m].map(T=>T.charCodeAt(0))),S=await crypto.subtle.verify("HMAC",d,y,p.encode(l));return{header:a,payload:c,valid:S}}return{header:a,payload:c,valid:!1}}var Gd;(i=>(i.encode=y6,i.decode=g6,i.ERROR=CS,i.DEFAULT_HEADER=wO))(Gd||={});u();var jl=class{constructor(t){this.assetManager=t}async initialize(){await this.assetManager.fetch()}findBundleAsset(t){return this.assetManager.assets$.get().find(r=>(r.id===t||r.stableId===t)&&r.contentType===Ki)}async readBundle(t){let n=this.findBundleAsset(t);if(!n||!n.url)return null;try{let r=await fetch(n.url);if(!r.ok)return console.error(`Failed to fetch bundle ${t}: ${r.status}`),null;let i=await r.arrayBuffer();return new Uint8Array(i)}catch(r){return console.error(`Error fetching bundle ${t}:`,r),null}}async writeBundle(t,n){let r=this.findBundleAsset(t);try{r?await this.assetManager.update(r.id,{data:n,contentType:Ki}):await this.assetManager.create({data:n,contentType:Ki,stableId:t})}catch(i){throw console.error(`Error writing bundle ${t}:`,i),i}}async listBundleIds(){return this.assetManager.assets$.get().filter(n=>n.contentType===Ki).map(n=>n.stableId)}async deleteBundle(t){let n=this.findBundleAsset(t);if(n)try{await this.assetManager.delete(n.id)}catch(r){throw console.error(`Error deleting bundle ${t}:`,r),r}}};u();var Ll=class extends Ee{leftMenuItems$=new _([],{isEqual:Gt});rightMenuItems$=new _([],{isEqual:Gt});allMenuItems$=_.combine([this.leftMenuItems$,this.rightMenuItems$],([t,n])=>[...t,...n],{isEqual:Gt});getLeftMenuItems(){return this.leftMenuItems$.get()}getRightMenuItems(){return this.rightMenuItems$.get()}getAllMenuItems(){return this.allMenuItems$.get()}setLeftMenuItems(t){this.leftMenuItems$.set(t)}setRightMenuItems(t){this.rightMenuItems$.set(t)}showCommandPaletteEmitter=new Ee};u();u();u();u();u();u();var NS=class{constructor(t,n){this.taskRunner=t;this.refs=n}addTask(...t){let[n,r]=t.length===1?[{},t[0]]:t,i=`task-${++this.taskRunner.internalTaskId}`,o={id:n.id??i,fn:r,refs:this.refs,status:"pending",log:[],name:n.name};return this.taskRunner.tasks[o.id]=o,this.taskRunner.notifySubscribers(),{id:o.id}}createContext(...t){return this.taskRunner.createContext(...t)}},Bl=class e{tasks={};subscribers=[];internalTaskId=0;version=0;maxConcurrentTasks;currentConcurrentTasks=0;constructor({maxConcurrentTasks:t=1/0}={}){this.maxConcurrentTasks=t}createContext(...t){return new NS(this,t)}addTask(...t){let[n,r]=t.length===1?[{},t[0]]:t,o=this.createContext().addTask(n,(s,a)=>r(a));return this.notifySubscribers(),o}waitUntilSlotOpens(){return new Promise(t=>{let n=()=>this.currentConcurrentTasks<this.maxConcurrentTasks?(this.currentConcurrentTasks++,t(),!0):!1;if(!n()){let r=this.subscribe(()=>{n()&&r()})}})}async runTask(t){await this.waitUntilSlotOpens();let n=this.tasks[t.id];if(!n)throw new Error(`Task ${t.id} not found`);if(n.status==="completed")return n.result;n.status="enqueued",n.log=[],n.metadata=void 0,this.notifySubscribers();let r=[];try{r=await Promise.all(n.refs.map(i=>this.runTask(i).then(()=>this.tasks[i.id].result)))}catch(i){throw n.status="cancelled",this.notifySubscribers(),i}try{let i={log:(...s)=>{n.log.push(s),this.notifySubscribers()},writeLog:s=>{let a=n.log.at(-1),c=a?.at(-1);a&&typeof c=="string"?a[a.length-1]+=c+s:n.log.push([s]),this.notifySubscribers()},setMetadata:s=>{n.metadata=s instanceof Function?s(n.metadata):s,this.notifySubscribers()}};n.status="in progress",this.notifySubscribers();let o=await n.fn(r,i);return n.result=o,n.status="completed",this.notifySubscribers(),o}catch(i){throw n.status="error",this.notifySubscribers(),i}finally{this.currentConcurrentTasks--,this.maxConcurrentTasks!==1/0&&this.notifySubscribers()}}subscribe=t=>(this.subscribers.push(t),()=>{this.subscribers=this.subscribers.filter(n=>n!==t)});_cachedSnapshot=[0,[]];getSnapshot=()=>{if(this.version===this._cachedSnapshot[0])return this._cachedSnapshot[1];let t=Object.values(this.tasks).map(n=>({id:n.id,name:n.name,status:n.status,log:n.log,metadata:n.metadata,deps:n.refs.map(r=>r.id)}));return this._cachedSnapshot=[this.version,t],t};notifySubscribers=()=>{this.version++,this.subscribers.forEach(t=>t())};clearCompletedTasks=()=>{let t;do{t=!1;for(let n of Object.values(this.tasks))n.status==="completed"&&(Object.values(this.tasks).flatMap(i=>i.refs).includes(n)||(delete this.tasks[n.id],t=!0))}while(t);this.notifySubscribers()};clearTasks=()=>{this.tasks={},this.notifySubscribers()};async rerunFailedTask(t){let n=this.tasks[t.id];if(!n)throw new Error(`Task ${t.id} not found`);return n.status="pending",n.log=[],this.notifySubscribers(),this.runTask(t)}async runAllTasks(){return Promise.all(Object.values(this.tasks).map(t=>this.runTask(e.toRef(t))))}static toRef(t){return{id:t.id}}};u();var MO="AES-GCM",qd=e=>{let t=e.match(/[\dA-F]{2}/gi)||[];return new Uint8Array(t.map(n=>parseInt(n,16)))};async function OO({encrypted:e,iv:t,tag:n,ENCRYPTION_KEY:r}){let i=qd(r),o=qd(e),s=qd(t),a=qd(n),c=new Uint8Array([...o,...a]),l=await crypto.subtle.importKey("raw",i,{name:MO},!1,["decrypt"]),p=await crypto.subtle.decrypt({name:MO,iv:s,tagLength:128},l,c);return new TextDecoder().decode(p)}u();var AO=e=>{let{message:t,frames:n}=e,r=`Uncaught Error: ${t}`,i=n.map(o=>{let{functionName:s,contextLines:a}=o,c=Math.max(...a?.map(m=>m.lineNumber)??[]),l=`@ function ${s}`,p=c.toString().length;if(!a)return l;let d=a.map(m=>{let y=`${m.lineNumber.toString().padStart(p)}: ${m.content}`;if(m.errorColumn!==void 0){let S="X".repeat(p)+":"+" ".repeat(m.errorColumn)+"^";return`${y}
62
62
  ${S}`}return y}).join(`
63
63
  `);return`${l}
64
64
  ${d}`});return`${r}
65
65
 
66
66
  ${i.join(`
67
67
 
68
- `)}`};u();u();var kS=class e{constructor(t,n=new Set,r){this.data=t;this.dependencies=n;this.getId=r}get id(){return this.getId(this.data)}clone(){return new e(this.data,new Set(this.dependencies),this.getId)}},DS=class e{constructor(t){this.options=t;this.getId=t.getId}getId;nodesById=new Map;addNode(t){return this.ensureNode(t),this}getNode(t){return this.nodesById.get(t)?.data}getNodeDependencies(t){return this.nodesById.get(t)?.dependencies||new Set}addEdge(t,n){let r=this.ensureNode(t);if(this.ensureNode(n).dependencies.add(r.id),!this.isAcyclic())throw new Error(`[${this.getId(t)}] -> [${this.getId(n)}] form a cycle`);return this}*topologicalSort(){let t=this.nodesById,n=new Set,r=function*(i){for(let o of i.dependencies||[])n.has(o)||(yield*r(t.get(o)),yield t.get(o).data,n.add(o))};for(let i of t.values())n.has(i.id)||(yield*r(i),yield i.data,n.add(i.id))}*roots(){for(let t of this.nodesById.values())t.dependencies.size===0&&(yield t.data)}*nodes(){for(let t of this.nodesById.values())yield t.data}reverse(){let t=new e(this.options);for(let n of this.nodesById.values()){t.addNode(n.data);for(let r of n.dependencies){let i=this.nodesById.get(r).data;t.addNode(i),t.addEdge(n.data,i)}}return t}assignLayers(t={}){let{adjustSiblingLayers:n=!1}=t,r=new Map,i=new Set,o=(s,a)=>{if(i.has(s.id)){r.set(s.id,Math.max(r.get(s.id),a));return}i.add(s.id),r.set(s.id,a);for(let c of this.nodesById.values())c.dependencies.has(s.id)&&o(c,a+1)};for(let s of this.nodesById.values())s.dependencies.size===0&&o(s,0);if(n)for(let s of this.nodesById.values()){let a=Array.from(this.nodesById.values()).filter(c=>c.id===s.id?!1:Array.from(s.dependencies).some(l=>c.dependencies.has(l)));if(a.length>0){let c=a.map(d=>r.get(d.id)),l=r.get(s.id),p=Math.max(l,...c);r.set(s.id,p),a.forEach(d=>r.set(d.id,p))}}return r}ensureNode(t){let n=this.nodesById.get(this.getId(t));return n||(n=new kS(t,new Set,this.getId),this.nodesById.set(this.getId(t),n),n)}isAcyclic(){let t=new Map;this.nodesById.forEach(i=>t.set(i.id,0)),this.nodesById.forEach(i=>i.dependencies.forEach(o=>{t.set(o,t.get(o)+1)}));let n=new Array;this.nodesById.forEach(i=>{t.get(i.id)===0&&n.push(i.id)});let r=0;for(;n.length>0;){let[i]=n.splice(0,1);r+=1,this.nodesById.get(i).dependencies.forEach(o=>{t.set(o,t.get(o)-1),t.get(o)===0&&n.push(o)})}return r===this.nodesById.size}clone(){let t=new e(this.options);return this.nodesById.forEach(n=>{t.nodesById.set(n.id,n.clone())}),t}findNode(t){for(let n of this.nodesById.values())if(t(n.data))return n.data}};function RO(e){return new DS(e)}u();var Rwe=x.Object({x:x.Number(),y:x.Number(),width:x.Number(),height:x.Number()}),Pwe=x.Union([x.Object({id:x.String({format:"uuid",default:""}),type:x.Literal("script"),location:x.Union([x.Literal("state"),x.Literal("url")]),value:x.String()}),x.Object({id:x.String({format:"uuid",default:""}),type:x.Literal("jsonPointer"),value:x.String()})],{discriminator:"type"}),Fl={id:x.String({format:"uuid",default:""}),name:x.String()},g6=x.Union([x.Literal("fileVersion"),x.Literal("file")],{default:"fileVersion"}),b6=x.Object({...Fl,type:x.Literal("file"),fileId:x.Optional(x.String()),fileVersionId:x.String(),preferredFileSource:g6}),S6=x.Object({...Fl,type:x.Literal("placeholder"),inputs:x.Array(Hg)}),CO=x.Union([x.Literal("canvas"),x.Literal("inspector")]),x6=x.Object({...Fl,type:x.Literal("data"),data:x.Any(),schema:x.Optional(Hf),display:x.Optional(CO)}),T6=x.Object({...Fl,type:x.Literal("secret"),secretStableId:x.String(),display:x.Optional(CO)}),v6=x.Object({...Fl,type:x.Literal("workflowOutput"),inputs:x.Array(Hg)}),I6=x.Union([b6,x6,T6,v6,S6],{discriminator:"type"}),E6=x.Object({id:x.String({format:"uuid",default:""}),sourceBlockId:x.String(),targetBlockId:x.String(),targetInputStableId:x.String()}),w6=x.Array(I6),Cwe=x.Object({blocks:w6,connections:x.Array(E6)},{version:18});var US=[],PO=[];function NO(e,t){let n;return e?e.type==="workflowOutput"||e.type==="placeholder"?n=e.inputs:e.type==="file"?n=t.getFileVersionInputs(e.fileVersionId)??US:n=US:n=US,n.toSorted((r,i)=>r.name.localeCompare(i.name))}function _S(e,t){return e?.type==="file"?t.getFileVersionTransforms(e.fileVersionId).toSorted((n,r)=>n.order-r.order)??PO:PO}function qd(e,t){return`${e}:${t}`}function Uo(e){switch(e.gType){case"block":return e.id;case"input":return qd(e.gBlockId,e.stableId);case"transform":return qd(e.gBlockId,e.stableId)}throw new Error(`Unknown graph node type: ${e.gType}`)}function kO(e,t){let n=RO({getId:Uo});for(let i of e.blocks){let o=i.type==="file"?i.fileVersionId:void 0,s={gType:"block",gFileVersionId:o,gBlockName:i.name,...i};n.addNode(s);let a=NO(i,t),c=_S(i,t);for(let l of c){let p={gType:"transform",gBlockId:i.id,gFileVersionId:o,gBlockName:i.name,...l};n.addNode(p),n.addEdge(s,p),s=p}for(let l of a){let p={gType:"input",gBlockId:i.id,gFileVersionId:o,gBlockName:i.name,...l};n.addNode(p),n.addEdge(p,{gType:"block",gFileVersionId:o,gBlockName:i.name,...i})}}let r=[];for(let i of e.connections){let o=e.blocks.find(l=>l.id===i.sourceBlockId),s=n.getNode(qd(i.targetBlockId,i.targetInputStableId));if(!o||!s){let l={connection:i,sourceBlock:e.blocks.find(d=>d.id===i.sourceBlockId),targetBlock:e.blocks.find(d=>d.id===i.targetBlockId),targetInput:s?s.id:void 0},p=[`Invalid connection = ${JSON.stringify(l.connection,null,2)}`,`sourceBlock = ${JSON.stringify(l.sourceBlock,null,2)}`,`targetBlock = ${JSON.stringify(l.targetBlock,null,2)}`,`targetInput = ${JSON.stringify(l.targetInput,null,2)}`,`targetInputGraphId = ${qd(i.targetBlockId,i.targetInputStableId)}`].join(`
68
+ `)}`};u();u();var kS=class e{constructor(t,n=new Set,r){this.data=t;this.dependencies=n;this.getId=r}get id(){return this.getId(this.data)}clone(){return new e(this.data,new Set(this.dependencies),this.getId)}},DS=class e{constructor(t){this.options=t;this.getId=t.getId}getId;nodesById=new Map;addNode(t){return this.ensureNode(t),this}getNode(t){return this.nodesById.get(t)?.data}getNodeDependencies(t){return this.nodesById.get(t)?.dependencies||new Set}addEdge(t,n){let r=this.ensureNode(t);if(this.ensureNode(n).dependencies.add(r.id),!this.isAcyclic())throw new Error(`[${this.getId(t)}] -> [${this.getId(n)}] form a cycle`);return this}*topologicalSort(){let t=this.nodesById,n=new Set,r=function*(i){for(let o of i.dependencies||[])n.has(o)||(yield*r(t.get(o)),yield t.get(o).data,n.add(o))};for(let i of t.values())n.has(i.id)||(yield*r(i),yield i.data,n.add(i.id))}*roots(){for(let t of this.nodesById.values())t.dependencies.size===0&&(yield t.data)}*nodes(){for(let t of this.nodesById.values())yield t.data}reverse(){let t=new e(this.options);for(let n of this.nodesById.values()){t.addNode(n.data);for(let r of n.dependencies){let i=this.nodesById.get(r).data;t.addNode(i),t.addEdge(n.data,i)}}return t}assignLayers(t={}){let{adjustSiblingLayers:n=!1}=t,r=new Map,i=new Set,o=(s,a)=>{if(i.has(s.id)){r.set(s.id,Math.max(r.get(s.id),a));return}i.add(s.id),r.set(s.id,a);for(let c of this.nodesById.values())c.dependencies.has(s.id)&&o(c,a+1)};for(let s of this.nodesById.values())s.dependencies.size===0&&o(s,0);if(n)for(let s of this.nodesById.values()){let a=Array.from(this.nodesById.values()).filter(c=>c.id===s.id?!1:Array.from(s.dependencies).some(l=>c.dependencies.has(l)));if(a.length>0){let c=a.map(d=>r.get(d.id)),l=r.get(s.id),p=Math.max(l,...c);r.set(s.id,p),a.forEach(d=>r.set(d.id,p))}}return r}ensureNode(t){let n=this.nodesById.get(this.getId(t));return n||(n=new kS(t,new Set,this.getId),this.nodesById.set(this.getId(t),n),n)}isAcyclic(){let t=new Map;this.nodesById.forEach(i=>t.set(i.id,0)),this.nodesById.forEach(i=>i.dependencies.forEach(o=>{t.set(o,t.get(o)+1)}));let n=new Array;this.nodesById.forEach(i=>{t.get(i.id)===0&&n.push(i.id)});let r=0;for(;n.length>0;){let[i]=n.splice(0,1);r+=1,this.nodesById.get(i).dependencies.forEach(o=>{t.set(o,t.get(o)-1),t.get(o)===0&&n.push(o)})}return r===this.nodesById.size}clone(){let t=new e(this.options);return this.nodesById.forEach(n=>{t.nodesById.set(n.id,n.clone())}),t}findNode(t){for(let n of this.nodesById.values())if(t(n.data))return n.data}};function RO(e){return new DS(e)}u();var Pwe=x.Object({x:x.Number(),y:x.Number(),width:x.Number(),height:x.Number()}),Cwe=x.Union([x.Object({id:x.String({format:"uuid",default:""}),type:x.Literal("script"),location:x.Union([x.Literal("state"),x.Literal("url")]),value:x.String()}),x.Object({id:x.String({format:"uuid",default:""}),type:x.Literal("jsonPointer"),value:x.String()})],{discriminator:"type"}),Fl={id:x.String({format:"uuid",default:""}),name:x.String()},b6=x.Union([x.Literal("fileVersion"),x.Literal("file")],{default:"fileVersion"}),S6=x.Object({...Fl,type:x.Literal("file"),fileId:x.Optional(x.String()),fileVersionId:x.String(),preferredFileSource:b6}),x6=x.Object({...Fl,type:x.Literal("placeholder"),inputs:x.Array(Gg)}),CO=x.Union([x.Literal("canvas"),x.Literal("inspector")]),T6=x.Object({...Fl,type:x.Literal("data"),data:x.Any(),schema:x.Optional(Hf),display:x.Optional(CO)}),v6=x.Object({...Fl,type:x.Literal("secret"),secretStableId:x.String(),display:x.Optional(CO)}),I6=x.Object({...Fl,type:x.Literal("workflowOutput"),inputs:x.Array(Gg)}),E6=x.Union([S6,T6,v6,I6,x6],{discriminator:"type"}),w6=x.Object({id:x.String({format:"uuid",default:""}),sourceBlockId:x.String(),targetBlockId:x.String(),targetInputStableId:x.String()}),M6=x.Array(E6),Nwe=x.Object({blocks:M6,connections:x.Array(w6)},{version:18});var US=[],PO=[];function NO(e,t){let n;return e?e.type==="workflowOutput"||e.type==="placeholder"?n=e.inputs:e.type==="file"?n=t.getFileVersionInputs(e.fileVersionId)??US:n=US:n=US,n.toSorted((r,i)=>r.name.localeCompare(i.name))}function _S(e,t){return e?.type==="file"?t.getFileVersionTransforms(e.fileVersionId).toSorted((n,r)=>n.order-r.order)??PO:PO}function Vd(e,t){return`${e}:${t}`}function Uo(e){switch(e.gType){case"block":return e.id;case"input":return Vd(e.gBlockId,e.stableId);case"transform":return Vd(e.gBlockId,e.stableId)}throw new Error(`Unknown graph node type: ${e.gType}`)}function kO(e,t){let n=RO({getId:Uo});for(let i of e.blocks){let o=i.type==="file"?i.fileVersionId:void 0,s={gType:"block",gFileVersionId:o,gBlockName:i.name,...i};n.addNode(s);let a=NO(i,t),c=_S(i,t);for(let l of c){let p={gType:"transform",gBlockId:i.id,gFileVersionId:o,gBlockName:i.name,...l};n.addNode(p),n.addEdge(s,p),s=p}for(let l of a){let p={gType:"input",gBlockId:i.id,gFileVersionId:o,gBlockName:i.name,...l};n.addNode(p),n.addEdge(p,{gType:"block",gFileVersionId:o,gBlockName:i.name,...i})}}let r=[];for(let i of e.connections){let o=e.blocks.find(l=>l.id===i.sourceBlockId),s=n.getNode(Vd(i.targetBlockId,i.targetInputStableId));if(!o||!s){let l={connection:i,sourceBlock:e.blocks.find(d=>d.id===i.sourceBlockId),targetBlock:e.blocks.find(d=>d.id===i.targetBlockId),targetInput:s?s.id:void 0},p=[`Invalid connection = ${JSON.stringify(l.connection,null,2)}`,`sourceBlock = ${JSON.stringify(l.sourceBlock,null,2)}`,`targetBlock = ${JSON.stringify(l.targetBlock,null,2)}`,`targetInput = ${JSON.stringify(l.targetInput,null,2)}`,`targetInputGraphId = ${Vd(i.targetBlockId,i.targetInputStableId)}`].join(`
69
69
 
70
- `);r.push({message:p,connection:i});continue}let a=n.getNode(i.sourceBlockId);if(!a)throw new Error(`Source node not found: ${i.sourceBlockId}`);let c=_S(o,t);if(o.type==="file"&&c?.length>0){let l=a;for(let p of n.nodes())p.gType==="transform"&&p.gFileVersionId===o.fileVersionId&&n.getNodeDependencies(Uo(p)).has(Uo(l))&&(l=p);a=l}n.addEdge(a,s)}return{graph:n,invalidConnections:r}}function M6(e){function t(o){if(o==null)throw new Error("Module exports is null or undefined");return o.__esModule&&"default"in o||typeof o=="object"&&"default"in o&&Object.keys(o).length===1?o.default:o}let n={},r={exports:n},i=()=>{};return new Function("exports","module","require",e)(n,r,i),t(r.exports)}function UO({fetch:e=globalThis.fetch}={}){return async(t,n)=>{let r=[];try{if(t.type==="url"){let a=await(await e(t.url)).text();t={...t,type:"code",code:a}}return{result:await M6(t.code)(...t.args),logs:r}}catch(i){return console.error(i),{error:i,logs:r}}finally{}}}function _O({url:e,bundlerUrl:t=e,fetch:n=globalThis.fetch}){return async(r,i)=>{let o;try{o=JSON.stringify(r)}catch(c){throw new Error(`Failed to encode parameters: ${c.message}`)}let s=r.type==="url"&&r.url.includes("/js/bundler")?t:e,a=await n(s,{method:"POST",body:o});if(!a.ok){let c;try{c=await a.text()}catch{c=a.statusText}throw new Error(`Remote evaluate failed: ${a.status} ${a.statusText} ${s}. ${c}`)}try{return await a.json()}catch(c){throw new Error(`Failed to decode response: ${c.message}`)}}}function jO({baseUrl:e,headers:t,fetch:n=globalThis.fetch,ENCRYPTION_KEY:r,MULTIPLAYER_SHARED_TOKEN:i}){return async o=>{let a=await(await n(`${e}/api/fileVersions/${o}/secrets?includeValues=true`,{headers:{"x-noya-shared-token":i,...t}})).json();return O6(a,r)}}async function O6(e,t){let n={};for(let r of e){let i=await A6(r,t);i&&(n[i.name]=i.value)}return n}async function A6(e,t){let{value:n,...r}=e;if(!n)return console.warn(`No value for secret ${r.name}`),null;let i=JSON.parse(n),o=await OO({...i,ENCRYPTION_KEY:t});return{...r,value:o}}var DO="__system__";function R6({state:e,node:t,api:n,taskRunner:r,dependencyTaskRefs:i}){let o;switch(t.gType){case"block":{o=`[Block] ${t.name}`;break}case"input":{o=`[Input] ${t.gBlockName} / ${t.name}`;break}case"transform":{let a=t.value;o=`[Transform] ${t.gBlockName} / ${t.kind}${a?` (${a})`:""}`;break}}return r.createContext(...i).addTask({id:Uo(t),name:o},async(a,{log:c,setMetadata:l})=>{let p=(...f)=>{let g=new Date().toISOString();c(g,...f)},d=(...f)=>{p(DO,...f)},m=(...f)=>{p(DO,"__error__",...f)},y=a[0];async function S(f){if(n.createArtifact)try{let g=f.type==="string"?f.value:JSON.stringify(f.value),v=new TextEncoder().encode(g),I=await n.createArtifact(v);l(M=>({...M,artifacts:[{name:f.name,size:v.byteLength,url:I}]}))}catch(g){m(`${o} failed to create ${o} artifact`),m(g.message)}}let T=f=>{try{return f.assets}catch{return{}}},E=f=>f.reduce((g,v)=>(g[v.name]=v.state,g),{}),b=f=>f.reduce((g,v)=>(Object.assign(g,T(v)),g),{});try{switch(t.gType){case"block":switch(t.type){case"file":{let{fileVersionId:f}=t;d(`fetching ${o} - ${f}`);try{let g=await n.getFileVersionData(f),v=await n.getFileVersionAssets(f),I={...b(a),...Object.fromEntries(v.map(M=>[M.id,M]))};return d(`fetched ${o} - ${f}`,g),{state:g,assets:I,inputs:E(a)}}catch(g){throw m(`error fetching ${o} - ${f}`,g.message),g}}case"data":return d(`evaluating data node ${o}`),{state:t.data,assets:{},inputs:{}};case"secret":{d(`[Secret] loading ${o}`);try{let f=await n.getFileSecret(t.secretStableId);return d(`[Secret] loaded ${o}`),{state:f.value,assets:{},inputs:{},__isSecret:!0}}catch(f){throw m(`[Secret] error loading ${o}`),f}}case"workflowOutput":{let f=E(a);return await S({type:"json",value:f,name:"output"}),{state:e,assets:{},inputs:f}}default:throw new Error(`Unknown node type: ${t.type}`)}case"input":{let f=a.map(O=>O.state),g=O=>Array.isArray(O),v=O=>O!==null&&typeof O=="object"&&!Array.isArray(O),I,M;if(f.length===0)I=void 0,M={};else if(f.every(g))I=f.flat(),M=b(a);else if(f.every(v))I=Object.assign({},...f),M=b(a);else{I=f[f.length-1];let O=a[a.length-1];M=T(O)}return a.some(O=>O?.__isSecret)?d(o,"secret value","\u2022".repeat(20)):d(o,"value",I),{name:t.name,state:I,assets:M}}case"transform":{d(`${o} - ${t.kind}`);async function f(g){let v={};t.gFileVersionId&&(v=await n.getFileVersionEnv(t.gFileVersionId));let I;try{I=await n.evaluateScript({...g,env:v},d)}catch(z){throw m(`${o} failed to evaluate`,z.message),z}let{result:M,logs:O,error:C}=I;await S({type:"json",value:M,name:"result"});for(let z of O)p(...z);if(C)throw m(`${o} failed to evaluate`),m(AO(C)),new Error(C.message);return d(`${o} evaluated script`),{state:M,assets:T(y),inputs:y.inputs}}switch(t.kind){case"jsonPointer":{if(d(`${o} json pointer`,t.value),!t.value.startsWith("/"))throw d(`${o} json pointer missing leading slash`,t.value),new Error(`${o} json pointer missing leading slash: ${t.value}`);let g=Ht(y.state,t.value,["/"]);return d(`${o} json pointer result`,JSON.stringify(g,null,2)),{state:g,assets:T(y),inputs:y.inputs}}case"script":{let g;switch(t.location){case"state":{if(typeof y.state!="string")throw new Error(`Script transform requires string input, got: ${typeof y.state} ${JSON.stringify(y).slice(0,1e3)}`);g=y.state;break}case"url":{let v;try{v=await(n.fetchScript??P6)(t.value)}catch(F){throw m(`${o} error fetching script: ${F.message}`),F}let{cid:I,url:M}=v,O=t.value.includes("/js/bundler")&&n.cache,C;if(O){d(`${o} - computing hash`);try{let F=JSON.stringify({cid:I,args:[y]});C=await O.hash(new TextEncoder().encode(F)),d(`${o} - computed hash: ${C}`)}catch(F){d(`${o} - error computing hash: ${F.message}`)}}if(C&&O){d(`${o} - checking cache for ${C}`);let F;try{let N=await O.getValue(C);F=JSON.parse(new TextDecoder().decode(N))}catch{d(`${o} - no cached result found for ${C}`)}if(F)return d(`${o} - found cached result`),{state:F,assets:T(y),inputs:y.inputs}}let z;try{z=await f({type:"url",url:M,cid:I,args:[y.inputs,{state:y.state,assets:T(y)}]})}catch(F){throw m(`${o} - error evaluating script: ${F.message}`),F}if(C&&O){d(`${o} - caching result for ${C}`);try{let F=JSON.stringify(z.state),N=new TextEncoder().encode(F);await O.setValue(C,N),d(`${o} - cached result for ${C}`)}catch(F){d(`${o} - error caching result for ${C}`),d(F.message)}}return z}default:throw new Error(`Unknown script location: ${t.location}`)}return await S({type:"string",value:g,name:"script"}),f({type:"code",code:g,args:[y.inputs,{state:y.state,assets:T(y)}]})}default:throw new Error(`Unknown transform type: ${t.type}`)}}default:throw new Error(`Unknown graph node type: ${t.gType}`)}}catch(f){throw m(`${o} failed to run`),m(f.message),f}})}async function P6(e){let t=await fetch(e);if(!t.ok)throw new Error(`Failed to fetch script ${e}: ${t.statusText}`);return{text:()=>t.text(),url:e,cid:t.headers.get("x-noya-cid")??void 0}}function LO({graph:e,state:t,api:n}){let r=new Bl;if(!e.isAcyclic())throw new Error("Workflow graph has cycles");let i=Array.from(e.nodes()).find(a=>a.gType==="block"&&a.type==="workflowOutput");function o(a){if(r.tasks[Uo(a)])return Bl.toRef(r.tasks[Uo(a)]);let l=[...e.getNodeDependencies(Uo(a))].map(p=>{let d=e.getNode(p);return o(d)});return R6({node:a,api:n,taskRunner:r,state:t,dependencyTaskRefs:l})}let s=o(i);return{taskRunner:r,rootTask:s}}async function BO({state:e,api:t}){let n=await Promise.all(e.blocks.map(async c=>{try{if(c.type==="file"&&c.preferredFileSource==="file"&&c.fileId){let l=await t.createFileVersion(c.fileId);return{...c,fileVersionId:l.id}}}catch(l){return console.error("error creating file version: ",l),c}return c})),r={...e,blocks:n},{graph:i,invalidConnections:o}=kO(r,t),{taskRunner:s,rootTask:a}=LO({graph:i,state:r,api:t});return{taskRunner:s,rootTask:a,invalidConnections:o}}var $l=class{constructor(t){this.rpcManager=t}status$=new _("idle");tasks$=new _([]);result$=new _(void 0);async run(t){let n=await this.rpcManager.requestRoute("POST /api/evaluate",{body:JSON.stringify(t),headers:{"Content-Type":"application/json"}});return JSON.parse(n.body).result}async runScript(t,n){let r=await fetch(t);if(!r.ok)throw new Error("Failed to fetch script");let i=await r.text();return this.run({type:"code",code:i,args:n.args,env:n.env})}async runScriptOnFileState(t,n){return await this.runScript(t,{args:[{state:n}],env:{}})}async runPipeline(t){let n=await this.rpcManager.requestRoute("POST /api/runWorkflow",{body:JSON.stringify({...t&&{pipelineState:t}}),headers:{"Content-Type":"application/json"}}),{result:r,snapshot:i}=JSON.parse(n.body);return{result:r,snapshot:i}}getPipelineGraphAPI(t){return{evaluateScript:t.executionEnvironment==="local"?UO():_O({url:process.env.NEXT_PUBLIC_DEV_EVALUATE_SCRIPT_URL,bundlerUrl:process.env.NEXT_PUBLIC_DEV_EVALUATE_SCRIPT_URL}),getFileVersionEnv:t.executionEnvironment==="local"?()=>Promise.resolve({}):jO({baseUrl:t.baseUrl,ENCRYPTION_KEY:process.env.NEXT_PUBLIC_DEV_ENCRYPTION_KEY,MULTIPLAYER_SHARED_TOKEN:process.env.NEXT_PUBLIC_DEV_MULTIPLAYER_SHARED_TOKEN}),getFileVersionData:t.getFileVersionData,getFileVersionInputs:t.getFileVersionInputs,getFileVersionTransforms:t.getFileVersionTransforms,getFileVersionIds:t.getFileVersionIds,getFileSecret:t.getFileSecret,getFileVersionAssets:t.getFileVersionAssets,getFileAssets:t.getFileAssets,createArtifact:t.executionEnvironment==="local"?async n=>{let r=new Blob([n]);return URL.createObjectURL(r)}:void 0,createFileVersion:t.createFileVersion}}async runPipelineLocally(t,n){let{taskRunner:r,rootTask:i}=await BO({state:t,api:this.getPipelineGraphAPI(n)});this.status$.set("running"),r.subscribe(()=>{this.tasks$.set(r.getSnapshot())});try{let o=await r.runTask(i);return this.status$.set("success"),this.result$.set(o),{result:o,snapshot:r.getSnapshot()}}catch(o){return this.status$.set("error"),{error:o,snapshot:r.getSnapshot()}}}};u();var Kl=class{enablePublishing$=new _(!1);setPublishingEnabled(t){this.enablePublishing$.set(t)}getFilesToPublish};u();u();var zl=class{constructor(t){this.options=t;this.ensureMessageSubscription()}multiplayer=new Gi("");unsubscribeMultiplayerMessages;isOpen=!1;getHandle(){return{resourceId:this.options.resourceId,content$:this.multiplayer.optimisticState$,isInitialized$:this.multiplayer.isInitialized$,sendPatches:(n,r)=>{this.sendPatches(n,r)},close:()=>this.close()}}open(){if(this.ensureMessageSubscription(),!this.isOpen){this.isOpen=!0,this.multiplayer.connect();return}this.multiplayer.reinitialize(this.multiplayer.getConfirmedState())}close(){this.isOpen&&(this.isOpen=!1,this.multiplayer.disconnect(),this.options.sendMessage?.({type:"resourceEdit.close",resourceId:this.options.resourceId}),this.unsubscribeMultiplayerMessages?.(),this.unsubscribeMultiplayerMessages=void 0,this.options.onClose?.())}sendPatches(t,n){this.multiplayer.applyPatch(n??{},{patches:t})}handleServerMessage(t){let n=this.translateIncomingMessage(t);n&&(this.multiplayer.incomingMessages.push(n),this.multiplayer.processIncomingMessages())}flushOutgoingMessages(){for(;this.multiplayer.outgoingMessages.length>0;){let t=this.multiplayer.outgoingMessages.shift(),n=this.translateOutgoingMessage(t);n&&this.options.sendMessage?.(n)}}translateOutgoingMessage(t){switch(t.type){case"init":return{type:"resourceEdit.open",resourceId:this.options.resourceId};case"patch":return{type:"resourceEdit.patch",resourceId:this.options.resourceId,id:t.id,patches:t.patches,baseHash:t.baseHash};default:return}}translateIncomingMessage(t){switch(t.type){case"resourceEdit.object":return{type:"object",object:t.content};case"resourceEdit.acceptPatch":return{type:"acceptPatch",id:t.id,patches:t.patches,hash:t.hash};case"resourceEdit.rejectPatch":return{type:"rejectPatch",id:t.id,reason:t.reason,error:t.error};default:return}}ensureMessageSubscription(){this.unsubscribeMultiplayerMessages||(this.unsubscribeMultiplayerMessages=this.multiplayer.messageEmitter.addListener(()=>{this.flushOutgoingMessages()}))}};var Hl=class{constructor(t,n={}){this.rpcManager=t;this._resourceUrlBase=n.resourceUrlBase??(typeof globalThis.location>"u"||globalThis.location.origin==="null"?void 0:globalThis.location.origin),this.setResources(n.initialResources??[]),this.isInitialized$.set(!!n.initialResources),this._sendMessage=n.sendMessage,n.subscribeConnectionEvents&&(this._unsubscribeConnectionEvents=n.subscribeConnectionEvents(this._handleConnectionEvent)),this._resolveAssetId=n.resolveAssetId}isInitialized$=new _(!1);resources$=new _([],{isEqual:Gt});patches$=new _([],{isEqual:Gt});optimisticResources$=_.combine([this.resources$,this.patches$],([t,n])=>n.reduce((r,i)=>{try{return De(r,i.patches)}catch{return r}},t),{isEqual:Gt});uploads$=new _({});setResources(t){let n=t.map(r=>({...r,url:C6(r,this._resourceUrlBase)}));this.resources$.set(n)}async createResource(t){let n=Array.isArray(t)?t:[t];if(n.length===0)throw new Error("No resources to create");let i=(await this.patchResources({create:n})).created;return Array.isArray(t)?i:i[0]}async _withPatch(t,n){let r=te();this.patches$.set([...this.patches$.get(),{id:r,patches:t}]);try{return await n()}finally{this.patches$.set(this.patches$.get().filter(i=>i.id!==r))}}async deleteResource(t){let n=Array.isArray(t)?t:[t],i=(await this.patchResources({delete:n})).deleted;return Array.isArray(t)?i:i[0]}async patchResources({create:t,update:n,delete:r}){let i=(t?.length??0)>0,o=(n?.length??0)>0,s=(r?.length??0)>0;if(!i&&!o&&!s)throw new Error("PATCH body must include create, update, or delete arrays");let a=m=>this._resolveAssetId?.(m)??m,c=i?t.map(m=>m.type==="asset"&&m.assetId?{...m,assetId:a(m.assetId)}:m):void 0,l=o?n.map(m=>({...m,...m.assetId?{assetId:a(m.assetId)}:{}})):void 0,p=[];if(r?.length&&p.push(...r.map(({id:m})=>({op:"remove",path:[{id:m}]}))),l?.length)for(let m of l)m.path!==void 0&&p.push({op:"replace",path:[{id:m.id},"path"],value:m.path}),m.type!==void 0&&p.push({op:"replace",path:[{id:m.id},"type"],value:m.type}),m.assetId!==void 0&&p.push({op:"replace",path:[{id:m.id},"assetId"],value:m.assetId}),m.fileId!==void 0&&p.push({op:"replace",path:[{id:m.id},"fileId"],value:m.fileId}),m.resourceId!==void 0&&p.push({op:"replace",path:[{id:m.id},"resourceId"],value:m.resourceId});let d=async()=>{let m={};c?.length&&(m.create=c),l?.length&&(m.update=l),r?.length&&(m.delete=r);let y=[...c?.flatMap(S=>S.type==="asset"&&S.asset?[{name:S.path}]:[])??[],...l?.flatMap(S=>S.asset?[{name:S.path??S.id}]:[])??[]].map(S=>({id:te(),name:S.name}));try{let S=await this.rpcManager.requestRoute("PATCH /api/resources",{body:JSON.stringify(m),headers:{"Content-Type":"application/json"},...y.length?{onUploadProgress:T=>{let E=y.map(b=>[b.id,{...T,name:b.name,id:b.id}]);this.uploads$.set({...this.uploads$.get(),...Object.fromEntries(E)})}}:{}});return this.rpcManager.getResponseBody(S)}finally{if(y.length){let S={...this.uploads$.get()};for(let T of y)delete S[T.id];this.uploads$.set(S)}}};return p.length>0?this._withPatch(p,d):d()}async updateResource({id:t,path:n,assetId:r,asset:i,type:o,fileId:s,fileVersionId:a,resourceId:c}){return(await this.patchResources({update:[{id:t,...n?{path:n}:{},...r?{assetId:r}:{},...i?{asset:i}:{},...o?{type:o}:{},...s?{fileId:s}:{},...a?{fileVersionId:a}:{},...c?{resourceId:c}:{}}]})).updated[0]}async listResources(){let t=await this.rpcManager.requestRoute("GET /api/resources");return this.rpcManager.getResponseBody(t)}_sendMessage;_unsubscribeConnectionEvents;_resolveAssetId;_resourceUrlBase;_editSessions=new Map;_handleConnectionEvent=t=>{if(t.type!=="receive")return;let n=t.message;switch(n.type){case"resourceEdit.object":case"resourceEdit.acceptPatch":case"resourceEdit.rejectPatch":{this._editSessions.get(n.resourceId)?.handleServerMessage(n);break}}};openEditingHandle(t){let n=this._editSessions.get(t);return n||(n=new zl({resourceId:t,sendMessage:r=>this._sendMessage?.(r),onClose:()=>this._editSessions.delete(t)}),this._editSessions.set(t,n)),n.open(),n.getHandle()}};function FO(e,t){let n=`/api/transform/${e}?format=image`;return t?new URL(n,t).toString():n}function C6(e,t){let n=e.url??FO(e.id,t);return t?new URL(n,t).toString():n}u();var N6=()=>new Date().toISOString(),$O=()=>({status:"idle",installLogs:"",devLogs:"",lastUpdated:N6()}),Gl=class{constructor(t){this.rpcManager=t}state$=new _($O());setState(t){this.state$.set(t)}setFromServer=t=>{this.setState(t)};async exec(t,n){let r=await this.rpcManager.requestRoute("POST /api/sandbox/exec",{headers:{"Content-Type":"application/json"},body:JSON.stringify({command:t,cwd:n})});return this.rpcManager.getResponseBody(r)}async listFiles(){let t=await this.rpcManager.requestRoute("GET /api/sandbox/files");return this.rpcManager.getResponseBody(t)}async exposePreview(){let t=await this.rpcManager.requestRoute("POST /api/sandbox/preview",{headers:{"Content-Type":"application/json"}});return this.rpcManager.getResponseBody(t)}async getBuildFilesZip(){let t=await this.rpcManager.requestRoute("GET /api/sandbox/build-files");return this.rpcManager.getResponseBody(t)}};u();var ql=class extends Ee{debug;constructor(t={}){super(),this.isConnected$=new _(t.isConnected??!1),this.debug=t.debug??!1}isConnected$;setIsConnected(t){this.isConnected$.set(t)}requests={};request=async(t,n)=>{this.debug&&console.info("[rpcManager] request waiting for connection"),await this.isConnected$.waitFor(!0),this.debug&&console.info("[rpcManager] request",t);let r=te(),i={...t,id:r},{promise:o,resolve:s,reject:a}=Promise.withResolvers();return this.requests[r]={request:i,status:"pending",resolve:s,reject:a,onStreamChunk:n?.onStreamChunk,onStreamEnd:n?.onStreamEnd,onUploadProgress:n?.onUploadProgress},this.emit(i),o};requestRoute=async(t,{body:n,headers:r,searchParams:i,onUploadProgress:o}={})=>{let[s,a]=t.split(" "),c=a;if(i&&Object.keys(i).length>0){let l=new URLSearchParams;for(let[p,d]of Object.entries(i))d!=null&&l.set(p,String(d));c=`${a}?${l.toString()}`}return this.request({url:c,options:{method:s,...n?{body:n}:{},...r?{headers:r}:{}}},{onUploadProgress:o})};requestStreamingRoute=async(t,{body:n,headers:r,onStreamChunk:i,onStreamEnd:o})=>{let[s,a]=t.split(" ");return this.request({url:a,options:{method:s,...n?{body:n}:{},...r?{headers:r}:{}},streaming:!0},{onStreamChunk:i,onStreamEnd:o})};handleMessage=t=>{let n=this.requests[t.id];this.debug&&console.info("[rpcManager] handleMessage",t),n?t.type==="chunk"?(n.status="streaming",n.onStreamChunk?.(t.chunk)):t.type==="end"?(n.status="resolved",n.onStreamEnd?n.onStreamEnd().then(()=>{n.resolve(t.response)}):n.resolve(t.response)):t.type==="error"&&(n.status="rejected",n.reject(t.error)):console.error("Response without corresponding request",t,this.requests)};getResponseBody=t=>{let n=Object.fromEntries(Object.entries(t.headers).map(([i,o])=>[i.toLowerCase(),o]));return("content-type"in n?n["content-type"]:null)?.includes("application/json")?JSON.parse(t.body):t.body}};u();var Vd=class extends Error{constructor(n,r){super(n.message);this.evaluationError=n;this.logs=r;this.name="ScriptEvaluationError"}},Vl=class{constructor(t){this.rpcManager=t}evaluateScript(t){return this.evaluate({type:"code",...t})}evaluateUrl(t){return this.evaluate({type:"url",...t})}evaluateFiles(t){return this.evaluate({type:"files",...t})}async evaluate(t){let n=await this.rpcManager.requestRoute("POST /api/scripts/evaluate",{body:JSON.stringify(t),headers:{"Content-Type":"application/json"}}),r=this.rpcManager.getResponseBody(n);if(!r||!Array.isArray(r.logs))throw new Error("Script evaluator returned an unexpected response");if(r.status==="error")throw new Vd(r.error,r.logs);return{result:r.result,logs:r.logs}}};u();var Ql=class{constructor(t,n){this.rpcManager=t;n.initialSecrets&&(this.secrets$.set(n.initialSecrets),this.isInitialized$.set(!0))}secrets$=new _([]);isInitialized$=new _(!1);async fetchSecrets(){let t=await this.rpcManager.requestRoute("GET /api/secrets",{}),n=this.rpcManager.getResponseBody(t);return this.secrets$.set(n),this.isInitialized$.set(!0),n}async createSecret(t,n,r){let i=await this.rpcManager.requestRoute("POST /api/secrets",{body:JSON.stringify({id:t,name:n,value:r}),headers:{"Content-Type":"application/json"}});return this.rpcManager.getResponseBody(i)}async deleteSecret(t){return await this.rpcManager.requestRoute("DELETE /api/secrets",{body:JSON.stringify({id:t}),headers:{"Content-Type":"application/json"}})}};u();var Yl=class{constructor(t={}){this.options=t}tasks$=new _([]);setTasks(t){let n=this.tasks$.get(),r=new Set(t.map(s=>s.id)),o=[...n.filter(s=>!r.has(s.id)),...t];this.tasks$.set(o.slice(0,this.options.maxTasks??20))}getTasks(){return this.tasks$.get()}};u();var k6={type:"processing"},Jl=class{constructor(t,n){this.rpcManager=t;this.assetManager=n}assetTranscriptions$=new _({});getAssetTranscription$(t,n){return this.assetTranscriptions$.get(t)||this.transcribe({assetId:t,...n}),this.assetTranscriptions$.map(i=>i[t]??k6)}async transcribe(t){let n;if("data"in t)n={...t,type:"data",data:en.encode(t.data)};else if("assetId"in t){let i=this.assetManager.getRealAssetId(t.assetId);if(!i)throw new Error(`Asset ${t.assetId} not found`);n={...t,type:"assetId",assetId:i}}let r=i=>{"assetId"in t&&this.assetTranscriptions$.set(t.assetId,i)};try{if(!n)throw new Error("Missing transcription data or assetId");r({type:"processing"});let i=await this.rpcManager.requestRoute("POST /api/transcriptions",{body:JSON.stringify(n),headers:{"Content-Type":"application/json"}}),o=this.rpcManager.getResponseBody(i);if(!o){let s=new Error("Transcription failed");throw r({type:"error",error:s}),s}return r({type:"success",...o}),o}catch(i){throw r({type:"error",error:i}),i}}};async function jS(e,{resolveAsset:t}){let n=e.fileName,r=e.contentType,i;if("assetId"in e){let l=await t(e.assetId);if(!l)throw new Error(`Asset ${e.assetId} not found`);i=l.data,r=r??l.contentType,n=n??e.assetId}else if("data"in e)i=en.decode(e.data).buffer;else throw new Error("Missing transcription payload");let o=new Blob([i],{type:r??"application/octet-stream"}),s=new FormData;s.append("file",o,n??"upload");let a=await fetch(e.endpoint,{method:"POST",body:s,headers:{...e.apiKey?{Authorization:`Bearer ${e.apiKey}`}:{}}});return await D6(a)}async function D6(e){let t=await e.text(),n;try{n=JSON.parse(t)}catch{n=void 0}if(!e.ok){let r=(typeof n=="object"&&n!==null&&"error"in n?String(n.error):void 0)??t??"Transcription failed";throw new Error(r)}if(!n||typeof n!="object"||!("success"in n))throw new Error("Unexpected transcription response format");return U6(n,t)}function U6(e,t){let n=a=>typeof a=="object"&&a!==null,r=n(e)?typeof e.transcription=="string"?e.transcription:typeof e.text=="string"?e.text:t:t,i=n(e)&&n(e.metadata)?e.metadata:{},o=n(e)&&Array.isArray(e.segments)?e.segments:[];return{success:n(e)&&"success"in e?!!e.success:!0,transcription:r,segments:o,metadata:i}}u();u();u();u();var zO=["cat","dog","owl","fish","horse","rabbit","snake","lion","bear","wolf","fox","elephant","giraffe","zebra","panda","monkey","penguin","koala","kangaroo","whale","shark","turtle","crocodile","hippo"],_6=["happy","sleepy","hungry","thirsty","healthy","rich","funky","cool","awesome","amazing","fantastic","incredible","super","mega","ultra"];function KO(e){return e[Math.floor(Math.random()*e.length)]}function LS(e){return`https://avatars.noya.site/animals/animals_${e}.svg`}function HO(){let e=KO(zO);return{name:`${wb(KO(_6))} ${wb(e)}`,animal:e,image:LS(e)}}function GO(e){let t=e.trim().split(/\s+/),n=t[t.length-1]?.toLowerCase();if(n)return zO.includes(n)?n:void 0}var Qd="noya-client-id",Yd="noya-client-name",Jd="noya-client-image",hi=new _(void 0),Js=new _(void 0),Xs=new _(void 0),BS=e=>{try{return typeof localStorage<"u"?localStorage.getItem(e):null}catch{return null}},sc=(e,t)=>{try{typeof localStorage<"u"&&localStorage.setItem(e,t)}catch{}},FS=e=>{try{typeof localStorage<"u"&&localStorage.removeItem(e)}catch{}};if(typeof window<"u"){let e=BS(Qd);if(e)hi.set(e);else{let i=te();sc(Qd,i),hi.set(i)}let t=BS(Yd)??void 0,n=BS(Jd)??void 0,r=HO();if(t||(t=r.name,sc(Yd,t)),!n){let i=(t&&GO(t))??r.animal;i&&(n=LS(i),sc(Jd,n))}Js.set(t),Xs.set(n)}function $S(e){Js.set(e),!(typeof window>"u")&&(e===void 0?FS(Yd):sc(Yd,e))}function KS(e){hi.set(e),!(typeof window>"u")&&(e===void 0?FS(Qd):sc(Qd,e))}function zS(e){Xs.set(e),!(typeof window>"u")&&(e===void 0?FS(Jd):sc(Jd,e))}u();u();u();function HS({status:e,statusText:t,body:n}){let r=n?.trim(),i;if(r)try{let o=JSON.parse(r);i=typeof o=="string"?o:typeof o?.message=="string"?o.message:typeof o?.error=="string"?o.error:typeof o?.error?.message=="string"?o.error.message:r}catch{i=r}return i?`RPC request failed (${e}): ${i}`:t?`RPC request failed (${e}): ${t}`:`RPC request failed (${e})`}async function*_o(e,t){let{baseUrl:n,token:r,debug:i=!1}=t;try{let o=new URL(e.url,n);o.protocol=o.protocol==="ws:"?"http:":"https:",i&&console.info("Fetching RPC stream",{url:o.toString(),body:e.options.body});let s=await fetch(o,{...e.options,headers:{...e.options?.headers,...r?{Authorization:`Bearer ${r}`}:{}}});if(!s.ok){let l=await s.text();throw new Error(HS({status:s.status,statusText:s.statusText,body:l}))}let a=s.body?.getReader(),c=new TextDecoder;if(!a)throw new Error("Stream not available");try{for(;;){let{done:l,value:p}=await a.read();if(l){let m=c.decode();m&&(yield{id:e.id,type:"chunk",chunk:m}),yield{id:e.id,type:"end",response:{status:s.status,statusText:s.statusText,headers:Object.fromEntries(s.headers.entries()),body:""}};break}let d=c.decode(p,{stream:!0});yield{id:e.id,type:"chunk",chunk:d}}}finally{a.releaseLock()}}catch(o){yield{id:e.id,type:"error",error:o instanceof Error?o.message:String(o)}}}async function jo(e,t){let{baseUrl:n,token:r,debug:i=!1}=t;try{let o=new URL(e.url,n);if(o.protocol=o.protocol==="ws:"?"http:":"https:",i&&console.info("Fetching RPC",{url:o.toString(),body:e.options.body}),!(typeof XMLHttpRequest<"u"&&typeof window<"u"&&!!t.onUploadProgress&&!e.streaming)){let p=await fetch(o,{...e.options,headers:{...e.options?.headers,...r?{Authorization:`Bearer ${r}`}:{}}});if(!p.ok){let m=await p.text();throw new Error(HS({status:p.status,statusText:p.statusText,body:m}))}let d=await p.text();return i&&console.info("RPC response",{text:d}),{id:e.id,type:"end",response:{status:p.status,statusText:p.statusText,headers:Object.fromEntries(p.headers.entries()),body:d}}}let a={...e.options?.headers,...r?{Authorization:`Bearer ${r}`}:{}},c=e.options.method??"GET",l=await new Promise((p,d)=>{let m=new XMLHttpRequest;m.open(c,o.toString(),!0),Object.entries(a).forEach(([S,T])=>{try{m.setRequestHeader(S,T)}catch{}}),t.onUploadProgress&&(m.upload.onprogress=S=>{let T=S.loaded,E=S.lengthComputable?S.total:void 0,b=E?T/E*100:void 0;t.onUploadProgress?.({loaded:T,total:E,percent:b})}),m.onreadystatechange=()=>{if(m.readyState!==XMLHttpRequest.DONE)return;let S={};m.getAllResponseHeaders().trim().split(/\r?\n/).forEach(E=>{let b=E.indexOf(": ");if(b>0){let f=E.slice(0,b).toLowerCase(),g=E.slice(b+2);S[f]=g}}),p({id:e.id,status:m.status,statusText:m.statusText,headers:S,body:m.responseText??""})},m.onerror=()=>{d(new Error("Network error"))},m.onabort=()=>{d(new Error("Request aborted"))};let y=e.options.body??void 0;m.send(y)});if(l.status<200||l.status>=300)throw new Error(HS({status:l.status,statusText:l.statusText,body:l.body}));return i&&console.info("RPC response",{text:l.body}),{id:e.id,type:"end",response:l}}catch(o){return{id:e.id,type:"error",error:o instanceof Error?o.message:String(o)}}}u();function GS(e){return typeof e=="string"||e instanceof URL?{url:e}:typeof e=="function"?{url:e}:e}async function j6(e){let t=typeof e=="string"||e instanceof URL?e:await e();return typeof t=="string"?new URL(t):t}async function Xd(e){let{url:t}=GS(e),n=await j6(t),r=hi.get(),i=Js.get(),o=Xs.get();r&&n.searchParams.set("clientId",r),i&&n.searchParams.set("clientName",i),o&&n.searchParams.set("clientImage",o);let s=n.searchParams.get("token");if(!s)throw new Error("No token provided in URL");let a=await Hd.decode({token:s});return{url:n,tokenString:s,tokenPayload:a.payload}}function Xl(e,t){switch(e.type){case"connectedUsers":{let n=e.users.map(a=>({...a,clientId:a.clientId??te(),inactive:a.inactive??!1}));t.userManager.setAllUsers(n);let r=n.filter(a=>!a.inactive),i=new Set(r.map(a=>a.connectionId)),o=t.sharedConnectionDataManager.currentConnectionId$.get(),s=t.sharedConnectionDataManager.data$.get();for(let a of Object.keys(s))!i.has(a)&&a!==o&&t.sharedConnectionDataManager.delete(a);break}case"sharedConnectionData":{let n=new Set(t.userManager.connectedUsers$.get().map(o=>o.connectionId)),r=e.data,i={};for(let o in r)n.has(o)&&(i[o]=r[o]);Object.keys(i).length>0&&t.sharedConnectionDataManager.merge(i);break}case"workflow":{t.pipelineManager.status$.set(e.workflow.status),t.pipelineManager.tasks$.set(e.workflow.tasks),t.pipelineManager.result$.set(e.workflow.result);break}case"tasks":{t.taskManager.setTasks(e.tasks);break}case"secrets":{t.secretManager.secrets$.set(e.secrets),t.secretManager.isInitialized$.set(!0);break}case"assets":{t.assetManager.set(e.assets);break}case"inputs":{t.ioManager.inputs$.set(e.inputs),t.ioManager.inputsInitialized$.set(!0);break}case"outputTransforms":{t.ioManager.outputTransforms$.set(e.outputTransforms),t.ioManager.outputTransformsInitialized$.set(!0);break}case"resources":{t.resourceManager.setResources(e.resources),t.resourceManager.isInitialized$.set(!0);break}case"fileName":{t.filePropertyManager.applyServerUpdate({name:e.name??"",changeId:e.changeId});break}case"activityEvents.update":{t.activityEventsManager.setStreamEvents(e.streamId,e.activityEvents);break}case"serverScript.log":{t.logManager.append(e.log);break}case"sandbox":{t.sandboxManager.setFromServer(e.state);break}}}function Lo(e,t,n={}){Xl(e,t),(n.pushToMSM??!0)&&e.type!=="pong"&&(t.multiplayerStateManager.incomingMessages.push(e),t.multiplayerStateManager.processIncomingMessages())}function qO(e,{url:t,debug:n},r={}){let{getSyncConfig:i=Xd,createWebSocketConnection:o=(b,f)=>new Bo(b,f),fetchRPC:s=jo,fetchRPCStream:a=_o,applyServerMessage:c=Lo}=r,l,p=!1,d=[],m=()=>{if(p)for(;d.length&&l;){let b=d.shift();b&&l.send(b)}},y=i(t).then(({url:b,tokenString:f,tokenPayload:g})=>{let v=g.connectionId,I=g.authId??void 0;return e.sharedConnectionDataManager.setCurrentConnectionId(v),e.userManager.setCurrentConnectionId(v),e.userManager.setCurrentUserId(I),e.assetManager.assetStore=new $i(e.rpcManager),l=o(b,{debug:n,onConnectionEvent:M=>{switch(e.connectionEventManager.addEvent(M),M.type){case"stateChange":{p=M.state==="OPEN",e.rpcManager.setIsConnected(p),p&&m();break}case"receive":{c(M.message,e,{pushToMSM:!1});break}}}}),l.connect(),{resolvedUrl:b,tokenString:f}}),S=e.rpcManager.addListener(async b=>{let{resolvedUrl:f,tokenString:g}=await y;if(b.streaming){let v=a(b,{baseUrl:f.toString(),token:g,streaming:!0,debug:n});for await(let I of v)e.rpcManager.handleMessage(I)}else{let v=await s(b,{baseUrl:f.toString(),token:g,debug:n,onUploadProgress:e.rpcManager.requests[b.id]?.onUploadProgress});e.rpcManager.handleMessage(v)}});return{sendMessage:b=>{if(p&&l){l.send(b);return}d.push(b)},destroy:()=>{p=!1,e.rpcManager.setIsConnected(!1),l?l.close():y.then(()=>{l?.close()}),S()}}}u();function qS(e,t){return e.connectionEventManager.events$.subscribe(n=>{if(n.length===0)return;let r=n[n.length-1];switch(r.type){case"stateChange":{let i={type:"connection",state:r.state==="OPEN"?"connected":"disconnected"};t(i);break}case"receive":{let i=r.message;if(i&&i.type==="object"&&i.object===null)break;t(i);break}}})}u();u();var VO=new WeakMap,L6=e=>{let[,t]=e.split(" ");return new RegExp(t.replace(/\//g,"\\/").replace(/:[^/]+/g,"([^/]+)")+"$")},Ut=(e,t)=>{let[n]=e.split(" ");return{key:e,method:n,pattern:L6(e),handler:t}},Zd=e=>({status:200,statusText:"OK",headers:{"content-type":"application/json"},body:JSON.stringify(e)}),B6="iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVR4nGNgAAIAAAUAAXpeqz8AAAAASUVORK5CYII=";function Wd(e){return[Ut("POST /api/ai/generate",async t=>{let n=t.options?.body??"{}",r=JSON.parse(n);if(!r.encodedSchema)throw new Error("Missing encoded schema for local AI generation");let i=Ab(Eo(r.encodedSchema));if(t.streaming===!0&&r.stream===!0){if(typeof i!="object"||i===null||Array.isArray(i))throw new Error("Local AI object generation returned a non-object");let o={};await e.emitStreamEvent(t,{type:"partial-object",object:o});for(let[s,a]of Object.entries(i))o[s]=a,await e.emitStreamEvent(t,{type:"partial-object",object:{...o}});await e.emitStreamEvent(t,{type:"object",object:i})}return{object:i}}),Ut("POST /api/ai/generate/text",async t=>{let n=t.options?.body??"{}",r=JSON.parse(n),i=t.streaming===!0&&r.stream===!0,o=i?"Local AI generated text.":"";if(i){for(let s of["Local AI ","generated ","text."])await e.emitStreamEvent(t,{type:"text-delta",textDelta:s});await e.emitStreamEvent(t,{type:"text",text:o})}return{text:o}}),Ut("POST /api/ai/generate/image",async()=>({base64:B6,mediaType:"image/png"}))]}var QO=(e,t)=>`data:${e??"application/octet-stream"};base64,${en.encode(t)}`;function ac(e,t){let n;try{t?n=new Ya({databaseName:`noya-assets-${t}`}):n=new Ya,e.assetManager.assetStore=n}catch(r){console.warn("[localRpcHelpers] IndexedDB unavailable; using memory asset store",r)}return n}var ZO=e=>{let t=Promise.resolve();return{...e,runExclusive:async n=>{let r=t,i;t=new Promise(o=>{i=o}),await r;try{return await n()}finally{i()}}}},F6=()=>{let e=new Map;return ZO({list:async()=>[...e.values()],read:async t=>e.get(t)??null,create:async t=>(e.set(t.id,t),t),update:async(t,n)=>e.has(t)?(e.set(t,n),n):null,delete:async t=>{let n=e.get(t)??null;return e.delete(t),n},replaceAll:async t=>{e=new Map(t.map(n=>[n.id,n]))}})},$6=(e,t)=>{let n=new Promise((l,p)=>{let d=t.open(e,1);d.onerror=()=>p(d.error),d.onsuccess=()=>l(d.result),d.onupgradeneeded=m=>{let y=m.target.result;y.objectStoreNames.contains("resources")||y.createObjectStore("resources",{keyPath:"id"})}}),r=async()=>{let l=await n;return await new Promise((p,d)=>{let m=l.transaction("resources","readonly").objectStore("resources").getAll();m.onerror=()=>d(m.error),m.onsuccess=()=>p(m.result??[])})},i=async l=>{let p=await n;return await new Promise((d,m)=>{let y=p.transaction("resources","readonly").objectStore("resources").get(l);y.onerror=()=>m(y.error),y.onsuccess=()=>d(y.result??null)})};return ZO({list:r,read:i,create:async l=>{let p=await n;return await new Promise((d,m)=>{let y=p.transaction("resources","readwrite").objectStore("resources").put(l);y.onerror=()=>m(y.error),y.onsuccess=()=>d()}),l},update:async(l,p)=>{if(!await i(l))return null;let m=await n;return await new Promise((y,S)=>{let T=m.transaction("resources","readwrite").objectStore("resources").put(p);T.onerror=()=>S(T.error),T.onsuccess=()=>y()}),p},delete:async l=>{let p=await i(l);if(!p)return null;let d=await n;return await new Promise((m,y)=>{let S=d.transaction("resources","readwrite").objectStore("resources").delete(l);S.onerror=()=>y(S.error),S.onsuccess=()=>m()}),p},replaceAll:async l=>{let p=await n;await new Promise((d,m)=>{let y=p.transaction("resources","readwrite"),S=y.objectStore("resources");S.clear();for(let T of l)S.put(T);y.oncomplete=()=>d(),y.onerror=()=>m(y.error??new Error("Resource transaction failed")),y.onabort=()=>m(y.error??new Error("Resource transaction aborted"))})}})};function Zs(e,t){let n=e,r=t??"",i=VO.get(n),o=i?.get(r);if(o)return o;let s;try{if(typeof globalThis.indexedDB>"u")throw new Error("IndexedDB is not available");s=$6(t?`noya-resources-${t}`:"noya-resources",globalThis.indexedDB)}catch(a){console.warn("[localRpcHelpers] IndexedDB unavailable; using memory resource store",a),s=F6()}return i||(i=new Map,VO.set(n,i)),i.set(r,s),s}function WO(e,t){return[Ut("PUT /api/file",async n=>{let r=n.options?.body??"{}",i;try{i=JSON.parse(r)}catch{throw new Error("Invalid request body")}let o=typeof i.name=="string"&&i.name.length>0?i.name:"";try{typeof localStorage<"u"&&localStorage.setItem(`${t.offlineStorageKey}:name`,o)}catch{}return e.filePropertyManager.applyServerUpdate({name:o,changeId:i.changeId}),{name:o,changeId:i.changeId}}),Ut("GET /api/secrets",async()=>[]),Ut("GET /api/inputs",async()=>[]),Ut("GET /api/outputTransforms",async()=>[]),Ut("GET /api/assets",async()=>{let n=e.assetManager.assetStore;return n._listWithBytes?(await n._listWithBytes()).map(({data:i,...o})=>({...o,url:QO(o.contentType,i)})):await n.list()}),Ut("POST /api/assets",async n=>{let r=n.options.headers?.["Content-Type"]||n.options.headers?.["content-type"],i=n.options.body??"",o=en.decode(i),s=await e.assetManager.assetStore.create({data:o,contentType:r});return await e.assetManager.fetch(),{...s,url:QO(r,o)}}),Ut("DELETE /api/assets/:id",async(n,r)=>{let i=r?.[1];if(!i)throw new Error("Missing asset id");return await e.assetManager.assetStore.delete(i),await e.assetManager.fetch(),{success:!0}})]}function K6(e){return e.encoding==="base64"?en.decode(e.content):new TextEncoder().encode(e.content)}function YO(e){if("fileId"in e&&typeof e.fileId=="string")return e.fileId}var JO=new Set(["directory","asset","file","resource"]),Zl=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),Fn=(e,t,n={})=>{if(!(e===void 0&&n.optional)&&typeof e!="string")throw new Error(`Invalid PATCH request: ${t} must be a string`)},XO=(e,t)=>{if(!Zl(e))throw new Error(`Invalid PATCH request: ${t} must be an object`);if(Fn(e.content,`${t}.content`),Fn(e.contentType,`${t}.contentType`),e.encoding!=="base64"&&e.encoding!=="utf-8")throw new Error(`Invalid PATCH request: ${t}.encoding must be base64 or utf-8`)},z6=e=>{if(!Zl(e))throw new Error("Invalid PATCH request: body must be an object");for(let i of["create","update","delete"])if(e[i]!==void 0&&!Array.isArray(e[i]))throw new Error(`Invalid PATCH request: ${i} must be an array`);let t=e.create,n=e.update,r=e.delete;if((t?.length??0)===0&&(n?.length??0)===0&&(r?.length??0)===0)throw new Error("PATCH body must include create, update, or delete arrays");return t?.forEach((i,o)=>{let s=`create[${o}]`;if(!Zl(i))throw new Error(`Invalid PATCH request: ${s} must be an object`);if(Fn(i.path,`${s}.path`),typeof i.type!="string"||!JO.has(i.type))throw new Error(`Invalid PATCH request: ${s}.type is invalid`);switch(i.type){case"asset":if(Fn(i.assetId,`${s}.assetId`,{optional:!0}),i.asset!==void 0&&XO(i.asset,`${s}.asset`),i.assetId===void 0&&i.asset===void 0)throw new Error(`Invalid PATCH request: ${s} requires assetId or asset`);break;case"file":Fn(i.fileId,`${s}.fileId`);break;case"resource":Fn(i.fileId,`${s}.fileId`),Fn(i.resourceId,`${s}.resourceId`);break}}),n?.forEach((i,o)=>{let s=`update[${o}]`;if(!Zl(i))throw new Error(`Invalid PATCH request: ${s} must be an object`);if(Fn(i.id,`${s}.id`),Fn(i.path,`${s}.path`,{optional:!0}),Fn(i.assetId,`${s}.assetId`,{optional:!0}),Fn(i.fileId,`${s}.fileId`,{optional:!0}),Fn(i.fileVersionId,`${s}.fileVersionId`,{optional:!0}),Fn(i.resourceId,`${s}.resourceId`,{optional:!0}),i.type!==void 0&&(typeof i.type!="string"||!JO.has(i.type)))throw new Error(`Invalid PATCH request: ${s}.type is invalid`);i.asset!==void 0&&XO(i.asset,`${s}.asset`)}),r?.forEach((i,o)=>{let s=`delete[${o}]`;if(!Zl(i))throw new Error(`Invalid PATCH request: ${s} must be an object`);Fn(i.id,`${s}.id`)}),e};function VS(e,t){if(typeof t.fileVersionId=="string")return t.fileVersionId;if(typeof t.fileId=="string")return t.fileId;if(e.type==="file"||e.type==="resource")return e.fileId}function em(e,t){return[Ut("GET /api/resources",async()=>{let n=Zs(e,t.offlineStorageKey);return await n.runExclusive(async()=>{let r=await n.list();return e.resourceManager.setResources(r),e.resourceManager.isInitialized$.set(!0),r})}),Ut("PATCH /api/resources",async n=>{let r=Zs(e,t.offlineStorageKey),i=n.options?.body??"{}",o;try{o=JSON.parse(i)}catch{throw new Error("Invalid request body")}let s=z6(o),a=s.create??[],c=s.update??[],l=s.delete??[];return await r.runExclusive(async()=>{let p=await r.list(),d=new Map(p.map(b=>[b.id,b]));for(let b of c){let f=d.get(b.id);if(!f)throw new Error(`Resource ${b.id} not found`);let g=b.type??f.type;if(g==="asset"&&!b.asset&&!b.assetId&&f.type!=="asset")throw new Error(`Missing assetId for resource ${f.id}`);if((g==="file"||g==="resource")&&!VS(f,b))throw new Error(`Missing fileId for resource ${f.id}`);if(g==="resource"&&!b.resourceId&&f.type!=="resource")throw new Error(`Missing resourceId for resource ${f.id}`)}for(let b of l)if(!d.has(b.id))throw new Error(`Resource ${b.id} not found`);let m=[],y=[],S=[],T=[],E=async({assetId:b,asset:f})=>{if(!f)return b;let g=await e.assetManager.create({data:K6(f),contentType:f.contentType}),v=e.assetManager._getServerAssetId(g.id)??g.id;return T.push(v),v};try{for(let f of a){let g=new Date().toISOString(),v={id:te(),stableId:te(),path:f.path,createdAt:g,updatedAt:g,accessibleByFileId:null,accessibleByFileVersionId:null},I;switch(f.type){case"directory":I={...v,type:"directory"};break;case"asset":{let M=await E(f);if(!M)throw new Error(`Missing assetId for resource ${f.path}`);I={...v,type:"asset",assetId:M};break}case"file":{let M=YO(f);if(!M)throw new Error(`Missing fileId for resource ${f.path}`);I={...v,type:"file",fileId:M};break}case"resource":{let M=YO(f);if(!M)throw new Error(`Missing fileId for resource ${f.path}`);I={...v,type:"resource",fileId:M,resourceId:f.resourceId};break}}d.set(I.id,I),m.push(I)}for(let f of c){let g=d.get(f.id);if(!g)throw new Error(`Resource ${f.id} not found`);let v=f.type??g.type,I={id:g.id,stableId:g.stableId,path:f.path??g.path,createdAt:g.createdAt,updatedAt:new Date().toISOString(),accessibleByFileId:g.accessibleByFileId??null,accessibleByFileVersionId:g.accessibleByFileVersionId??null,...g.url?{url:g.url}:{}},M;switch(v){case"directory":M={...I,type:"directory"};break;case"asset":{let O=await E({assetId:f.assetId??(g.type==="asset"?g.assetId:void 0),asset:f.asset});if(!O)throw new Error(`Missing assetId for resource ${g.id}`);M={...I,type:"asset",assetId:O};break}case"file":{let O=VS(g,f);if(!O)throw new Error(`Missing fileId for resource ${g.id}`);M={...I,type:"file",fileId:O};break}case"resource":{let O=VS(g,f),C=f.resourceId??(g.type==="resource"?g.resourceId:void 0);if(!O||!C)throw new Error(`Missing fileId/resourceId for resource ${g.id}`);M={...I,type:"resource",fileId:O,resourceId:C};break}}d.set(M.id,M),y.push(M)}for(let f of l){let g=d.get(f.id);if(!g)throw new Error(`Resource ${f.id} not found`);d.delete(f.id),S.push(g)}let b=[...d.values()];return await r.replaceAll(b),e.resourceManager.setResources(b),e.resourceManager.isInitialized$.set(!0),{created:m,updated:y,deleted:S}}catch(b){for(let f of T.reverse())try{await e.assetManager.delete(f)}catch(g){console.warn(`[localRpcHelpers] Failed to roll back asset ${f}`,g)}throw b}})})]}function tm(e,t,n){let r;try{if(typeof localStorage<"u"){let o=localStorage.getItem(`${n.offlineStorageKey}:name`);o!==null&&(r=o,e.filePropertyManager.setName(o))}}catch{}r===void 0&&(r=e.filePropertyManager.optimisticValue$.get()),r!==void 0&&t({type:"fileName",name:r}),t({type:"secrets",secrets:[]}),t({type:"inputs",inputs:[]}),t({type:"outputTransforms",outputTransforms:[]});let i=Zs(e,n.offlineStorageKey);i.runExclusive(async()=>{let o=await i.list();e.resourceManager.setResources(o),e.resourceManager.isInitialized$.set(!0),t({type:"resources",resources:o})}).catch(o=>{console.warn("[localRpcHelpers] Failed to load local resources for initialization",o);let s=e.resourceManager.resources$.get();e.resourceManager.isInitialized$.set(!0),t({type:"resources",resources:s})})}async function QS(e,t,n,r){let i=t.options?.method?.toUpperCase(),o=t.url.split("?")[0];try{let s=[...Wd({emitStreamEvent:async(a,c)=>{n({type:"chunk",id:a.id,chunk:`${JSON.stringify(c)}
71
- `}),(c.type==="text-delta"||c.type==="partial-object")&&await new Promise(l=>setTimeout(l,750))}}),...WO(e,{offlineStorageKey:r?.offlineStorageKey}),...em(e,{offlineStorageKey:r?.offlineStorageKey})];for(let a of s)if(a.method===i&&a.pattern.test(o)){let c=o.match(a.pattern),l=await a.handler(t,c);return(a.key==="GET /api/resources"||a.key==="PATCH /api/resources")&&n({type:"resources",resources:e.resourceManager.resources$.get()}),n({type:"end",id:t.id,response:Zd(l)}),!0}return!1}catch(s){return n({type:"error",id:t.id,error:s instanceof Error?s.message:String(s??"error")}),!0}}u();u();async function Wl(e,t,n){switch(t.type){case"init":{let r=typeof localStorage<"u"?localStorage.getItem(e):null,i=`${e}:schemaVersion`,o,s=t.schema?Eo(t.schema):void 0;if(t.force||!r)typeof localStorage<"u"&&(localStorage.setItem(e,JSON.stringify(t.object)),s&&typeof s.version=="number"&&localStorage.setItem(i,String(s.version))),o=t.object;else if(o=JSON.parse(r),s&&typeof s.version=="number"){let a=typeof localStorage<"u"?localStorage.getItem(i):null,c=a?parseInt(a,10):0,l=s.version;if(l>c&&n?.onSchemaMigration)try{let p=await Promise.resolve(n.onSchemaMigration({fromVersion:c,toVersion:l,currentState:o,newSchema:s}));p!==void 0&&(o=p)}catch(p){console.error("Schema migration failed:",p)}typeof localStorage<"u"&&localStorage.setItem(i,String(l))}return s&&(o=ml(s,void 0,o)),typeof localStorage<"u"&&r&&localStorage.setItem(e,JSON.stringify(o)),{type:"object",object:o,...s?{schema:t.schema}:{}}}case"patch":{let r=typeof localStorage<"u"?localStorage.getItem(e):null;if(!r)return{id:t.id,type:"rejectPatch",reason:"serverStateNotInitialized"};let i=JSON.parse(r);try{i=De(i,t.patches)}catch{return{id:t.id,type:"rejectPatch",reason:"errorApplyingPatch"}}return typeof localStorage<"u"&&localStorage.setItem(e,JSON.stringify(i)),{type:"acceptPatch",id:t.id,patches:t.patches}}default:return null}}async function YS(e,t,{isRemoteActive:n,sendRemoteMessage:r,localStorageKey:i,sendToChild:o}){if(n){if(!r){console.warn("[routeEmbeddedMultiplayerMessage] Remote active but no sendRemoteMessage provided");return}r(t);return}if(!i)return;let s=await Wl(i,t);s&&(Lo(s,e),o(s))}u();async function JS(e,{baseUrl:t,token:n,debug:r},i){try{if(e.streaming){let o=_o(e,{baseUrl:t,token:n,streaming:!0,debug:r});for await(let s of o)if(s.type==="chunk")i({type:"chunk",id:e.id,chunk:s.chunk});else if(s.type==="error"){i({type:"error",id:e.id,error:s.error});break}else s.type==="end"&&i({type:"end",id:e.id,response:s.response})}else{let o=await jo(e,{baseUrl:t,token:n,debug:r});o.type==="error"?i({type:"error",id:e.id,error:o.error}):o.type==="end"&&i({type:"end",id:e.id,response:o.response})}}catch(o){i({type:"error",id:e.id,error:o instanceof Error?o.message:String(o)})}}function H6(e,t,n={}){let{multiplayerUrl:r,offlineStorageKey:i,sendToChild:o,debug:s}=t,{createRemoteConnection:a=qO,routeEmbeddedMultiplayerMessage:c=YS}=n,l=r?a(e,{url:r,debug:s}):void 0,p=qS(e,o);return r||(ac(e,i),tm(e,o,{offlineStorageKey:i})),{destroy:()=>{p(),l?.destroy()},handleChildMultiplayer:d=>{c(e,d,{isRemoteActive:!!r,sendRemoteMessage:l?.sendMessage,localStorageKey:i,sendToChild:o})},bridgeChildRpc:async(d,m)=>{if(m&&m.baseUrl&&m.token){await JS(d,{baseUrl:m.baseUrl,token:m.token,debug:m.debug},S=>o(S));return}await QS(e,d,S=>o(S),{offlineStorageKey:i})||o({type:"error",id:d.id,error:"RPC URL not configured"})}}}u();u();function cc(e,t,n){return`${e}:${t}:${n}`}function eA(e){let t=0;for(let n=0;n<e.length;n++){let r=e.charCodeAt(n);t=(t<<5)-t+r,t=t&t}return t.toString(36)}var ep=class{constructor(t){this.options=t}files=new Map;async handleMessage(t){switch(t.type){case"gitFileEdit.open":return await this.open(t.repoId,t.filePath,t.ref),!0;case"gitFileEdit.close":return await this.close(t.repoId,t.filePath,t.ref),!0;case"gitFileEdit.patch":return this.patch(t.repoId,t.filePath,t.ref,t.id,t.patches),!0;default:return!1}}async open(t,n,r){let i=cc(t,r,n),o=this.files.get(i);if(o){this.options.sendMessage({type:"gitFileEdit.object",repoId:t,filePath:n,ref:r,content:o.content,hash:o.hash});return}let s="";try{s=(await(await this.options.getGit()).readFile(t,n,r)).content}catch{s=""}let a=eA(s);o={content:s,hash:a,dirty:!1},this.files.set(i,o),this.options.sendMessage({type:"gitFileEdit.object",repoId:t,filePath:n,ref:r,content:s,hash:a})}async close(t,n,r){let i=cc(t,r,n);this.files.get(i)?.dirty&&await this.persist(t,n,r),this.files.delete(i)}patch(t,n,r,i,o){let s=cc(t,r,n),a=this.files.get(s);if(!a){this.options.sendMessage({type:"gitFileEdit.rejectPatch",repoId:t,filePath:n,ref:r,id:i,reason:"serverStateNotInitialized"});return}try{let c=De(a.content,o),l=eA(c);a.content=c,a.hash=l,a.dirty=!0,this.options.sendMessage({type:"gitFileEdit.acceptPatch",repoId:t,filePath:n,ref:r,id:i,patches:o,hash:l}),this.options.onPersistNeeded?.(t,r,n)}catch(c){this.options.sendMessage({type:"gitFileEdit.rejectPatch",repoId:t,filePath:n,ref:r,id:i,reason:"errorApplyingPatch",error:c instanceof Error?c.message:String(c)})}}getContent(t,n,r){let i=cc(t,r,n);return this.files.get(i)?.content}isDirty(t,n,r){let i=cc(t,r,n);return this.files.get(i)?.dirty??!1}async persist(t,n,r){let i=cc(t,r,n),o=this.files.get(i);if(!o||!o.dirty)return;let a=await(await this.options.getGit()).patchFiles(t,{create:[{path:n,content:o.content}]},r);return o.dirty=!1,this.options.sendMessage({type:"gitFileEdit.committed",repoId:t,ref:r,oid:a.oid}),{oid:a.oid}}getDirtyFiles(){let t=[];for(let[n,r]of this.files.entries())if(r.dirty){let[i,o,...s]=n.split(":");t.push({repoId:i,ref:o,filePath:s.join(":")})}return t}};u();function XS(e){return({noyaManager:t})=>{let n=e.key,r=`${n}:name`,i=e.serverScripts,o=null,s={},a=new Map,c=(N,H,j)=>{MS({store:a,connectionId:N,queue:H,payload:j,onQueueActivity:L=>o?.handleInputQueueActivity(L)})},l=N=>OS(a,N),p=()=>i?.randomUUID?i.randomUUID():typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():te(),d=e.identity?.userId,m=e.identity?.clientId??hi.get()??te(),y=d??m??"me",S={id:d??y,authId:d??void 0,connectionId:y,clientId:m,name:e.identity?.name??Js.get()??"Me",image:e.identity?.image??Xs.get()};t.userManager.setAllUsers([S]),t.userManager.setCurrentConnectionId(y),t.userManager.setCurrentUserId(d??y),t.sharedConnectionDataManager.setCurrentConnectionId(y);let T=ac(t,n),E=Zs(t,n);if(t.secretManager.isInitialized$.set(!0),t.ioManager.inputsInitialized$.set(!0),t.ioManager.outputTransformsInitialized$.set(!0),E.runExclusive(async()=>{let N=await E.list();t.resourceManager.setResources(N),t.resourceManager.isInitialized$.set(!0)}).catch(N=>{console.warn("[localStorageSync] Failed to load local resources from IndexedDB",N),t.resourceManager.isInitialized$.set(!0)}),t.rpcManager.setIsConnected(!0),i){let N={getQuickJSModule:i.getQuickJSModule,randomUUID:i.randomUUID,environment:{target:"local-storage",mode:"live",label:"server"},getState:()=>t.multiplayerStateManager.getConfirmedState(),getSharedConnectionData:()=>s,setSharedConnectionData:H=>{s=H},drainInputQueue:H=>l(H),applyState:async({scriptId:H,nextState:j,invocation:L,timestamp:V})=>{let ne=t.multiplayerStateManager.getConfirmedState();if(ne===void 0)return;let[it]=Qr(ne,j,{useExtendedPatches:!0});if(it.length!==0){t.multiplayerStateManager.incomingMessages.push({type:"acceptPatch",id:`serverScript:${H}:${p()}`,patches:it,serverInvocation:L!==void 0&&V!==void 0?{scriptId:H,invocation:L,timestamp:V}:void 0}),t.multiplayerStateManager.processIncomingMessages();try{if(typeof localStorage<"u"){let xt=t.multiplayerStateManager.getConfirmedState();xt!==void 0&&localStorage.setItem(n,JSON.stringify(xt))}}catch{}o?.handleStateChange(it)}},log:H=>{let j=H.values.map(L=>Vs(L));console[H.level]("[server]",H.scriptId,...j),t.logManager.append({id:p(),scriptId:H.scriptId,level:H.level,values:j,timestamp:Date.now(),origin:H.origin,target:H.target,mode:H.mode})}};o=new Qs(N),o.setIsHot(!0),o.updateSchema(t.multiplayerStateManager.schema)}try{if(typeof localStorage<"u"){let N=localStorage.getItem(r);N!==null&&t.filePropertyManager.setName(N)}}catch{}let b,f=async N=>{if(N.type==="enqueueInput"){let j=N.connectionId??S.connectionId;c(j,N.queue,N.payload);return}if(b&&await b.handleMessage(N))return;let H=await Wl(n,N,{onSchemaMigration:async({fromVersion:j,toVersion:L,currentState:V,newSchema:ne})=>{if(o)return await o.updateSchema(ne),o.handleSchemaMigration(j,L,V)}});H&&(t.multiplayerStateManager.incomingMessages.push(H),t.multiplayerStateManager.processIncomingMessages(),o&&(H.type==="acceptPatch"&&o.handleStateChange(H.patches),o.updateSchema(t.multiplayerStateManager.schema)))},g=t.multiplayerStateManager.messageEmitter.addListener(f),v=t.multiplayerStateManager.errorEmitter.addListener(N=>{t.connectionEventManager.addEvent({type:"error",error:N})}),I=async(N,H)=>{t.rpcManager.handleMessage({type:"chunk",id:N.id,chunk:`${JSON.stringify(H)}
72
- `}),(H.type==="text-delta"||H.type==="partial-object")&&await new Promise(j=>setTimeout(j,750))},M=[Ut("PUT /api/file",async N=>{let H=N.options?.body??"{}",j=JSON.parse(H),L=typeof j.name=="string"?j.name:"";try{typeof localStorage<"u"&&localStorage.setItem(r,L)}catch{}return t.filePropertyManager.applyServerUpdate({name:L,changeId:j.changeId}),{name:L,changeId:j.changeId}}),...Wd({emitStreamEvent:I}),Ut("POST /api/transcriptions",async N=>{let H=N.options?.body??"{}",j=JSON.parse(H),L=j.endpoint;if(!L)throw new Error("Transcription is only supported on noya.io");return await jS({...j,endpoint:L},{resolveAsset:async V=>{let ne=await T?._readWithBytes(V);if(!ne)throw new Error(`Asset ${V} not found`);return{data:ne.data.buffer,contentType:ne.contentType}}})}),...em(t,{offlineStorageKey:n})],O=e.git,C=new Map,z=5e3;if(O){let N=new jl(t.assetManager),H,j=async()=>(H||(await N.initialize(),H=await O(N)),H);b=new ep({getGit:j,sendMessage:L=>{t.connectionEventManager.addEvent({type:"receive",message:L})},onPersistNeeded:(L,V,ne)=>{let it=`${L}:${V}:${ne}`,xt=C.get(it);xt&&clearTimeout(xt);let ti=setTimeout(async()=>{C.delete(it);try{await b?.persist(L,ne,V)}catch{}},z);C.set(it,ti)}}),M.push(Ut("POST /api/git/repos",async L=>{let V=await j(),ne=L.options?.body?JSON.parse(L.options.body):void 0;return await V.createRepo(ne)}),Ut("GET /api/git/repos/:id/files",async(L,V)=>{let ne=V?.[1];if(!ne)throw new Error("Repository ID is required");let it=await j(),xt=new URL(L.url,"http://localhost"),ti=xt.searchParams.get("ref")??void 0,Ia=xt.searchParams.get("includeContent")==="true";return await it.listFiles(ne,ti,Ia)}),Ut("GET /api/git/repos/:id/branches",async(L,V)=>{let ne=V?.[1];if(!ne)throw new Error("Repository ID is required");return await(await j()).listBranches(ne)}),Ut("PATCH /api/git/repos/:id/files",async(L,V)=>{let ne=V?.[1];if(!ne)throw new Error("Repository ID is required");let it=await j(),xt=L.options?.body??"{}",ti=JSON.parse(xt),Ia=new URL(L.url,"http://localhost"),uu=Ia.searchParams.get("ref")??void 0,ry=Ia.searchParams.get("includeContent")==="true";return await it.patchFiles(ne,ti,uu,ry)}))}let F=t.rpcManager.addListener(async N=>{let H=N.options?.method?.toUpperCase(),j=N.url.split("?")[0];for(let L of M)if(L.method===H&&L.pattern.test(j)){try{let V=j.match(L.pattern),ne=await L.handler(N,V);t.rpcManager.handleMessage({type:"end",id:N.id,response:Zd(ne)})}catch(V){t.rpcManager.handleMessage({type:"error",id:N.id,error:V instanceof Error?V.message:String(V??"error")})}return}t.rpcManager.handleMessage({type:"error",id:N.id,error:`RPC route is not available in local mode: ${H} ${j}`})});return t.multiplayerStateManager.connect(),()=>{g(),v(),F(),o?.setIsHot(!1),o?.dispose(),o=null,s={},a.clear();for(let N of C.values())clearTimeout(N);C.clear(),b=void 0,t.multiplayerStateManager.disconnect(),t.rpcManager.setIsConnected(!1)}}}function G6(e){if(!(typeof localStorage>"u"))for(let[t,n]of e)localStorage.setItem(t,n)}u();function q6(e,t){return e&&e.length>0?e:t?`${t}-local`:"noya-local"}u();u();u();u();var tA=require("react");u();var nm=e=>typeof e>"u"?"key":/Mac/.test(e.platform)?"mac":/Win/.test(e.platform)?"win":/Linux|X11/.test(e.platform)?"linux":"key";var nA="ignore-global-events";var PAe=typeof navigator<"u"?nm(navigator):"key";u();u();u();var qi={8:"Backspace",9:"Tab",10:"Enter",12:"NumLock",13:"Enter",16:"Shift",17:"Control",18:"Alt",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",44:"PrintScreen",45:"Insert",46:"Delete",59:";",61:"=",91:"Meta",92:"Meta",106:"*",107:"+",108:",",109:"-",110:".",111:"/",144:"NumLock",145:"ScrollLock",160:"Shift",161:"Shift",162:"Control",163:"Control",164:"Alt",165:"Alt",173:"-",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'"},im={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},V6=typeof navigator<"u"&&/Mac/.test(navigator.platform),Q6=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(Mt=0;Mt<10;Mt++)qi[48+Mt]=qi[96+Mt]=String(Mt);var Mt;for(Mt=1;Mt<=24;Mt++)qi[Mt+111]="F"+Mt;var Mt;for(Mt=65;Mt<=90;Mt++)qi[Mt]=String.fromCharCode(Mt+32),im[Mt]=String.fromCharCode(Mt);var Mt;for(rm in qi)im.hasOwnProperty(rm)||(im[rm]=qi[rm]);var rm;function rA(e){var t=V6&&e.metaKey&&e.shiftKey&&!e.ctrlKey&&!e.altKey||Q6&&e.shiftKey&&e.key&&e.key.length==1||e.key=="Unidentified",n=!t&&e.key||(e.shiftKey?im:qi)[e.keyCode]||e.key||"Unidentified";return n=="Esc"&&(n="Escape"),n=="Del"&&(n="Delete"),n=="Left"&&(n="ArrowLeft"),n=="Up"&&(n="ArrowUp"),n=="Right"&&(n="ArrowRight"),n=="Down"&&(n="ArrowDown"),n}u();function Y6(e,t){let n=e.split(/-(?!$)/),r=n[n.length-1];r==="Space"&&(r=" ");let i={altKey:!1,ctrlKey:!1,shiftKey:!1,metaKey:!1};if(n.length===1){if(/^(cmd|meta)$/i.test(r))return{key:"Meta",modifiers:i};if(/^alt$/i.test(r))return{key:"Alt",modifiers:i};if(/^(ctrl|control)$/i.test(r))return{key:"Ctrl",modifiers:i};if(/^shift$/i.test(r))return{key:"Shift",modifiers:i};if(/^mod$/i.test(r))return t==="mac"?{key:"Meta",modifiers:i}:{key:"Ctrl",modifiers:i}}for(let o=0;o<n.length-1;++o){let s=n[o];if(/^(cmd|meta)$/i.test(s))i.metaKey=!0;else if(/^alt$/i.test(s))i.altKey=!0;else if(/^(ctrl|control)$/i.test(s))i.ctrlKey=!0;else if(/^shift$/i.test(s))i.shiftKey=!0;else if(/^mod$/i.test(s))t==="mac"?i.metaKey=!0:i.ctrlKey=!0;else throw new Error("Unrecognized modifier name: "+s)}return{key:r,modifiers:i}}function tp(e,t){let n=Y6(e,t),r=n.key;return n.modifiers.altKey&&(r="Alt-"+r),n.modifiers.ctrlKey&&(r="Ctrl-"+r),n.modifiers.metaKey&&(r="Meta-"+r),n.modifiers.shiftKey&&(r="Shift-"+r),r}function om(e,t,n){return t.altKey&&(e="Alt-"+e),t.ctrlKey&&(e="Ctrl-"+e),t.metaKey&&(e="Meta-"+e),n!==!1&&t.shiftKey&&(e="Shift-"+e),e}function iA(e,t){let n=e[t]||e.key;return n?tp(n,t):void 0}var J6=new Set(["Alt","Control","Meta","Shift"]);function oA(e,t){let n=rA(e),r=n.length===1&&n!==" ",i={altKey:e.altKey,shiftKey:e.shiftKey,ctrlKey:e.ctrlKey,metaKey:e.metaKey},o=tp(J6.has(n)?n:om(n,i,!r),t),s=[o],a=qi[e.keyCode];if(r){let c;(e.shiftKey||e.altKey||e.metaKey)&&a&&a!==o?c=tp(om(a,i,!0),t):e.shiftKey&&(c=tp(om(o,i,!0),t)),c&&!s.includes(c)&&s.push(c)}return s}var ex="fallthrough";function sA(e,t){let n=Array.isArray(e)?e:Object.entries(e);return Object.fromEntries(n.flatMap(([r,i])=>{let o=iA(typeof r=="string"?{key:r}:r,t);return o?[[o,i]]:[]}))}var X6=(e,t,n,r={})=>{let i=sA(n,t),s=oA(e,t).find(l=>l in i);if(!s)return;let a=i[s],c=typeof a=="function"?{command:a}:a;if(!(r.invokedWithinInput&&!c.allowInInput))return c.command},ZS=(e,t,n,r={})=>{let i=X6(e,t,n,r);if(!i)return;i()!==ex&&(e.preventDefault(),e.stopImmediatePropagation())};function WS(e){if(!(e instanceof HTMLElement))return!0;let t=e,n=t.closest("[contenteditable]");return n&&(t=n),t.classList.contains(nA)?!1:!!(t instanceof HTMLInputElement&&t.type!=="checkbox"&&t.type!=="radio"||t instanceof HTMLTextAreaElement||t instanceof HTMLIFrameElement||t.hasAttribute("contenteditable"))}u();var aA=Q(ad()),cA=(0,aA.defineTree)(e=>e.type==="submenu"?e.items:[]),uA=e=>e.flatMap(t=>cA.flat(t)).flatMap(t=>t.type?[]:[t]),tx=e=>uA(e).filter(t=>!!t.shortcut);u();function sm(){return{postMessage:(e,t)=>window.parent.postMessage(e,t),addMessageListener:e=>(window.addEventListener("message",e),()=>window.removeEventListener("message",e))}}function lA(e){if(!e||typeof e!="object"||!("type"in e)||typeof e.type!="string")return!1;switch(e.type){case"connection":return"state"in e&&(e.state==="connected"||e.state==="disconnected");case"application.selectMenuItem":return"payload"in e&&typeof e.payload=="object";case"application.pickImage.result":return"payload"in e&&typeof e.payload=="object"&&typeof e.payload?.id=="string";case"rpc.response":case"rpc.chunk":case"rpc.error":return"payload"in e&&typeof e.payload=="object";default:return!0}}function pA(e){if(!e||typeof e!="object"||!("type"in e))return!1;switch(e.type){case"multiplayer.ready":return!0;case"multiplayer.message":return"payload"in e;case"application.setMenuItems":return"payload"in e&&Array.isArray(e.payload?.menuItems)&&typeof e.payload.position=="string"&&(e.payload.position==="left"||e.payload.position==="right");case"application.pickImage":return"payload"in e&&typeof e.payload=="object"&&typeof e.payload?.id=="string";case"ai.setConfig":return"payload"in e&&typeof e.payload=="object"&&typeof e.payload?.tools=="object";case"ai.tool.response":return"payload"in e&&typeof e.payload=="object"&&typeof e.payload?.invocation=="object";case"ai.setContext":return"payload"in e&&typeof e.payload=="object";case"rpc.request":return"payload"in e&&typeof e.payload=="object";default:return!1}}function Z6(e,t){let n=e?.access,r=t!==void 0?t:e?.id;if(n===void 0&&r===void 0)return;let i={};return n!==void 0&&(i.access=n),r!==void 0&&(i.id=r),i}function nx(e={}){let{debug:t=!1,origin:n="*",messageHandler:r=sm(),policyAuthContext:i,enableDocumentAI:o=!1}=e;return({noyaManager:s})=>{t&&console.info("[parentFrameSync] Initializing",s);let a=i,c,l=j=>{let L=Z6(a,j);L&&(c&&c.access===L.access&&c.id===L.id||(c=L,s.multiplayerStateManager.setPolicyAuthContext(L)))};l(s.userManager.currentUserId$.get());let p=s.userManager.currentUserId$.subscribe(j=>{l(j)});s.assetManager.assetStore=new $i(s.rpcManager),s.resourceManager.isInitialized$.set(!0),s.imagePickerManager.setIsAvailable(!0);let d=async j=>{if(t&&console.info("[parentFrameSync] receiving message",j.data),n!=="*"&&j.origin!==n)return;let V=j.data;switch(V.type){case"end":case"chunk":case"error":s.rpcManager.handleMessage(V);break;case"application.setAvoidRects":{s.avoidRects$.set(V.payload.rects);break}case"application.selectMenuItem":s.menuManager.emit(V.payload.value);break;case"application.pickImage.result":s.imagePickerManager.handleResponse(V.payload);break;case"connection":s.connectionEventManager.addEvent({type:"stateChange",state:V.state==="connected"?"OPEN":"CLOSED"});break;case"ai.tool.call":{let ne;try{ne=await s.aiManager.callTool(V.payload)}catch(xt){ne=JSON.stringify({ok:!1,error:xt instanceof Error?xt.message:String(xt)})}let it={type:"ai.tool.response",payload:{invocation:V.payload,response:ne}};r.postMessage(it,n);break}case"application.evaluate.result":{s.evalManager.responseEmitter.emit(V.payload);break}case"application.requestPublish":{if(!s.publishingManager.getFilesToPublish)break;let ne=await s.publishingManager.getFilesToPublish();if(!ne)break;let it={type:"application.publish",payload:{id:V.payload.id,files:ne}};r.postMessage(it,n);break}default:{if(V.type==="object"&&V.object===null){console.log("null object message",V),s.connectionEventManager.addEvent({type:"receive",message:V});break}if(Xl(V,s),V.type==="connectedUsers"){let ne=s.userManager.currentUserId$.get(),it=s.userManager.currentClientId$.get(),xt=V.users.find(ti=>ne!==void 0&&ti.authId===ne||it!==void 0&&ti.clientId===it);xt&&(s.userManager.setCurrentConnectionId(xt.connectionId),s.sharedConnectionDataManager.setCurrentConnectionId(xt.connectionId))}s.multiplayerStateManager.incomingMessages.push(V),s.multiplayerStateManager.processIncomingMessages(),s.connectionEventManager.addEvent({type:"receive",message:V});break}}},m=s.evalManager.requestEmitter.addListener(j=>{let L={type:"application.evaluate",payload:j};window.parent?.postMessage(L,n)}),y=s.menuManager.leftMenuItems$.subscribe(j=>{let L={type:"application.setMenuItems",payload:{menuItems:j,position:"left"}};t&&console.info("[parentFrameSync] sending left menu items",L),window.parent?.postMessage(L,"*")}),S=s.menuManager.showCommandPaletteEmitter.addListener(j=>{let L={type:"application.showCommandPalette",payload:j};window.parent?.postMessage(L,"*")}),T=s.imagePickerManager.requestEmitter.addListener(j=>{let L={type:"application.pickImage",payload:j};r.postMessage(L,n)}),E=s.menuManager.rightMenuItems$.subscribe(j=>{let L={type:"application.setMenuItems",payload:{menuItems:j,position:"right"}};t&&console.info("[parentFrameSync] sending right menu items",L),window.parent?.postMessage(L,"*")}),b=j=>{let L=tx(s.menuManager.allMenuItems$.get()).map(ne=>{let it={command:()=>s.menuManager.emit(ne.value)};return[ne.shortcut,it]}),V=WS(j.target);ZS(j,nm(navigator),L,{invokedWithinInput:V})};window.addEventListener("keydown",b);let f=()=>{window.removeEventListener("keydown",b)},g={type:"multiplayer.ready"};r.postMessage(g,n);let v=r.addMessageListener(d),I=s.multiplayerStateManager.messageEmitter.addListener(j=>{t&&console.info("[parentFrameSync] sending message",j),s.connectionEventManager.addEvent({type:"send",message:j});let L={type:"multiplayer.message",payload:j};r.postMessage(L,n)}),M=s.rpcManager.addListener(async j=>{if(!j.id){console.error("[parentFrameSync] RPC request has no id",j);return}let L={type:"rpc.request",payload:j};t&&console.info("[parentFrameSync] sending rpc request",L),r.postMessage(L,n)}),O=o?Ml(s):void 0,C=s.aiManager.configuration$.subscribe(({tools:j,systemMessage:L})=>{let V={type:"ai.setConfig",payload:{tools:j,systemMessage:L}};r.postMessage(V,n)}),z=o?s.multiplayerStateManager.optimisticState$.subscribe(j=>{let L={type:"ai.setContext",payload:{state:j,schema:s.multiplayerStateManager.schema}};r.postMessage(L,n)}):void 0,F=s.publishingManager.enablePublishing$.subscribe(j=>{let L={type:"application.enablePublishing",payload:j};r.postMessage(L,n)}),N=s.sharedConnectionDataManager.currentConnectionDataEmitter.addListener(j=>{let L=s.sharedConnectionDataManager.currentConnectionId$.get();if(!L)return;let V={type:"multiplayer.message",payload:{type:"setSharedConnectionData",connectionId:L,data:j}};r.postMessage(V,n)}),H=s.multiplayerStateManager.errorEmitter.addListener(j=>{s.connectionEventManager.addEvent({type:"error",error:j})});return s.multiplayerStateManager.connect(),s.rpcManager.setIsConnected(!0),()=>{t&&console.info("[parentFrameSync] Cleaning up"),v(),y(),E(),S(),T(),f(),I(),M(),H(),C(),z?.(),O?.(),m(),F(),N(),p(),s.imagePickerManager.setIsAvailable(!1),s.multiplayerStateManager.disconnect(),s.rpcManager.setIsConnected(!1)}}}u();function np(e={}){return({noyaManager:t})=>{e.initialStoreAssetsForDebugging&&(t.assetManager.assetStore=new Ja({initialAssets:e.initialStoreAssetsForDebugging})),t.secretManager.isInitialized$.set(!0),t.ioManager.inputsInitialized$.set(!0),t.ioManager.outputTransformsInitialized$.set(!0),t.resourceManager.isInitialized$.set(!0),t.assetManager.isInitialized$.set(!0);let n=o=>{switch(o.type){case"init":{t.multiplayerStateManager.incomingMessages.push({type:"object",object:o.object,schema:o.schema}),t.multiplayerStateManager.processIncomingMessages();break}case"patch":{let s=e.debugOptions?.transformPatches?.(o.patches)??o.patches;t.multiplayerStateManager.incomingMessages.push({type:"acceptPatch",id:o.id,patches:s}),e.debugOptions?.DEBUG_acceptSamePatchTwice&&t.multiplayerStateManager.incomingMessages.push({type:"acceptPatch",id:o.id,patches:s}),t.multiplayerStateManager.processIncomingMessages();break}}},r=t.multiplayerStateManager.messageEmitter.addListener(n),i=t.multiplayerStateManager.errorEmitter.addListener(o=>{t.connectionEventManager.addEvent({type:"error",error:o})});return t.multiplayerStateManager.connect(),()=>{r(),i(),t.multiplayerStateManager.disconnect()}}}u();u();var W6=0;function rx(e,t={}){let{debug:n=!1}=GS(e),r=t.createWebSocketConnection??((i,o)=>new Bo(i,o));return({noyaManager:i})=>{let o=W6++,s,a,c,l=Xd(e).then(({url:S,tokenString:T,tokenPayload:E})=>(s=E.connectionId,a=E.authId??void 0,i.sharedConnectionDataManager.setCurrentConnectionId(s),i.userManager.setCurrentConnectionId(s),i.userManager.setCurrentUserId(a),i.multiplayerStateManager.setPolicyAuthContext({id:a??null,access:E.access}),i.assetManager.assetStore=new $i(i.rpcManager),c=r(S,{debug:n,onConnectionEvent:b=>{switch(n&&console.info(`[webSocketSync] Connection event ${o}`,b),b.type){case"stateChange":{b.state==="OPEN"?(i.multiplayerStateManager.connect(),i.rpcManager.setIsConnected(!0)):b.state==="CLOSED"&&(i.multiplayerStateManager.disconnect(),i.rpcManager.setIsConnected(!1));break}case"receive":{i.connectionEventManager.addEvent(b);let f=b.message;Lo(f,i,{pushToMSM:!0});break}case"send":{i.connectionEventManager.addEvent(b);break}case"error":{i.connectionEventManager.addEvent(b);break}}}}),c.connect(),{url:S,tokenString:T,tokenPayload:E,wsConnection:c})),p=i.multiplayerStateManager.messageEmitter.addListener(S=>{l.then(({wsConnection:T})=>{T?.send(S)})}),d=i.sharedConnectionDataManager.currentConnectionDataEmitter.addListener(S=>{if(!s)return;let T={type:"setSharedConnectionData",connectionId:s,data:S};l.then(({wsConnection:E})=>{E?.send(T)})}),m=i.rpcManager.addListener(async S=>{let{url:T,tokenString:E}=await l;if(S.streaming){let b=_o(S,{baseUrl:T.toString(),token:E,streaming:!0,debug:n});for await(let f of b)i.rpcManager.handleMessage(f)}else{let b=await jo(S,{baseUrl:T.toString(),token:E,debug:n,onUploadProgress:i.rpcManager.requests[S.id]?.onUploadProgress});i.rpcManager.handleMessage(b)}}),y=i.aiManager.invocationEmitter.addListener(async S=>{let T=await i.aiManager.callTool(S);i.aiManager.responseEmitter.emit(S,T)});return n&&console.info(`[webSocketSync] Created ${o}`),()=>{n&&console.info(`[webSocketSync] Destroying ${o}`),c?(n&&console.info(`[webSocketSync] Closing connection ${o}`),c.close()):l.then(({wsConnection:S})=>{n&&console.info(`[webSocketSync] Closing connection ${o}`),S?.close()}),p(),d(),m(),y()}}}function am(e,t){let n,r,i;for(let o of e)o.authId===t&&(n=o),o.clientId===t&&(i=o),o.connectionId===t&&(r=o);return n??i??r}var rp=class{constructor(t){this.rpcManager=t}currentUserId$=new _(void 0);currentClientId$=hi;currentConnectionId$=new _(void 0);currentId$=_.combine([this.currentUserId$,this.currentClientId$,this.currentConnectionId$],([t,n,r])=>t??n??r);allUsers$=new _([]);connectedUsers$=new _([]);connectedUsersCount$=this.connectedUsers$.map(t=>t.length);currentUser$=_.combine([this.currentId$,this.allUsers$],([t,n])=>am(n,t));workspaceUsers$=new _([]);#e=!1;initializeWorkspaceUsers(){this.#e||!this.rpcManager||(this.#e=!0,this.fetchWorkspaceMembers().catch(t=>{console.error("Failed to fetch workspace members",t),this.#e=!1}))}setCurrentUserId(t){this.currentUserId$.set(t)}setCurrentConnectionId(t){this.currentConnectionId$.set(t)}setAllUsers(t){this.allUsers$.set(t),this.connectedUsers$.set(t.filter(n=>!n.inactive))}async fetchWorkspaceMembers(){if(!this.rpcManager)return;let t=await this.rpcManager.requestRoute("GET /api/file/members"),n=this.rpcManager.getResponseBody(t)??[];this.workspaceUsers$.set(n)}};function fA({previous:e,next:t}){if(e.metadata.name!==void 0&&e.metadata.name===t.metadata.name&&e.metadata.timestamp+500>t.metadata.timestamp)return Mr.merge({previous:e,next:t})}var Vi=class{id=te();multiplayerStateManager;rpcManager;pipelineManager;scriptEvaluatorManager;secretManager;aiManager;ioManager;imagePickerManager=new Ul;sharedConnectionDataManager=new Cl;assetManager;userManager;taskManager=new Yl;connectionEventManager=new yl;menuManager=new Ll;evalManager;publishingManager=new Kl;resourceManager;activityEventsManager;filePropertyManager;logManager;transcriptionManager;sandboxManager;gitManager;isProcessing$;avoidRects$=new _([]);initialState;options;unrecoverableError=new _(void 0);constructor(t,n={}){n={...n,getSharedConnectionData:n.getSharedConnectionData??(()=>this.sharedConnectionDataManager.data$.get()??{}),mergeHistoryEntries:n.mergeHistoryEntries===void 0?fA:n.mergeHistoryEntries},this.multiplayerStateManager=new Gi(t,n),this.initialState=t,this.options=n,this.assetManager=new dl({initialAssets:n.initialAssets}),this.rpcManager=new ql({debug:this.options.debug}),this.userManager=new rp(this.rpcManager),this.pipelineManager=new $l(this.rpcManager),this.scriptEvaluatorManager=new Vl(this.rpcManager),this.secretManager=new Ql(this.rpcManager,{initialSecrets:n.initialSecrets}),this.aiManager=new fl(this.rpcManager),this.ioManager=new _l(this.rpcManager),this.evalManager=new Ol({safeEval:this.options.safeEval}),this.resourceManager=new Hl(this.rpcManager,{initialResources:n.initialResources,resourceUrlBase:n.resourceUrlBase,sendMessage:i=>this.multiplayerStateManager.sendMessage(i),subscribeConnectionEvents:i=>this.connectionEventManager.events$.subscribe(o=>{let s=o.at(-1);s&&i(s)}),resolveAssetId:i=>this.assetManager._getServerAssetId(i)??i}),this.sandboxManager=new Gl(this.rpcManager),this.gitManager=new Dl(this.rpcManager,this.assetManager,{sendMessage:i=>this.multiplayerStateManager.sendMessage(i),subscribeConnectionEvents:i=>this.connectionEventManager.events$.subscribe(o=>{let s=o.at(-1);s&&i(s)}),includeContent:n.gitIncludeContent}),this.filePropertyManager=new Al(this.rpcManager,{initialName:n.initialFileName}),this.logManager=new zs,this.transcriptionManager=new Jl(this.rpcManager,this.assetManager),this.activityEventsManager=new sl(i=>this.multiplayerStateManager.sendMessage(i));let r=this.resourceManager.patches$.map(i=>i.length>0);this.isProcessing$=_.combine([r,this.filePropertyManager.isUpdating$],([i,o])=>i||o),this.multiplayerStateManager.errorEmitter.addListener(i=>{switch(i.reason){case"invalidDataType":case"schemaMismatch":case"outdatedSchema":case"dataMigrationFailure":case"schemaMigration":this.unrecoverableError.set(i);break}}),this.options.registerDefaultAITools===!0&&Ml(this)}enqueueInput=(t,n)=>{let r=this.userManager.currentConnectionId$.get();this.multiplayerStateManager.sendMessage({type:"enqueueInput",queue:t,payload:n,...r&&{connectionId:r}})};forceInit=()=>{let t=this.initialState instanceof Function?this.initialState():this.initialState,n=this.options?.schema;this.multiplayerStateManager.sm.clearHistory(),this.multiplayerStateManager.sendInit({force:!0,state:t,schema:n})};undo=()=>this.multiplayerStateManager.undo();redo=()=>this.multiplayerStateManager.redo();canUndo=()=>this.multiplayerStateManager.canUndo();canRedo=()=>this.multiplayerStateManager.canRedo();restoreSnapshot=async t=>{let n=await this.rpcManager.requestRoute("POST /api/snapshots/restore",{body:JSON.stringify(t),headers:{"Content-Type":"application/json"}});return JSON.parse(n.body)}};u();function e8(){return{url:"/api/workflow/run",options:{method:"POST"}}}function t8(e,t){return{url:"/api/secrets",options:{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:e,value:t})}}}function n8(e){return{url:"/api/secrets",options:{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:e})}}}u();u();var ix=class{history;prediction;options;constructor(t,n){this.history=[t],this.options={interpolate:n.interpolate,getNow:n.getNow??i8,interpolationDelayMs:n.interpolationDelayMs??100,historyWindowMs:n.historyWindowMs??1e3,maxHistoryEntries:n.maxHistoryEntries??6,maxPredictionBlend:n.maxPredictionBlend??.35,defaultPredictionDelayMs:n.defaultPredictionDelayMs??33,getLatestInvocation:n.getLatestInvocation}}getLatestEntry(){return this.history.at(-1)}getHistory(){return this.history.slice()}setPrediction(t){this.prediction=t}clearPrediction(){this.prediction=void 0}addConfirmedState(t,n={}){let r=n.timestamp??this.options.getNow(),i={state:t,timestamp:r,invocation:n.invocation},s=(n.resetHistory?[]:this.history).concat(i),a=r-this.options.historyWindowMs;this.history=s.filter(c=>c.timestamp>=a).slice(-this.options.maxHistoryEntries)}getRenderState(t=this.options.getNow()){if(this.history.length===0)throw new Error("StateInterpolator has no history to render");let n=t-this.options.interpolationDelayMs,r=this.history[this.history.length-1],i=this.history.slice(0,-1).reverse().find(l=>l.timestamp<=n),o=r.state;if(i){if(n<=i.timestamp||r.timestamp===i.timestamp)o=i.state;else if(n<r.timestamp){let l=(n-i.timestamp)/(r.timestamp-i.timestamp);o=this.options.interpolate(i.state,r.state,l)}}let s=r.invocation??this.options.getLatestInvocation?.(),a=this.prediction,c=a?.invocation;if(a&&s!==void 0&&c!==void 0&&c===s+1){let l=a.timestamp??r.timestamp+this.options.defaultPredictionDelayMs,p=l>r.timestamp?(n-r.timestamp)/(l-r.timestamp):0,d=r8(p,0,this.options.maxPredictionBlend);d>0&&(o=this.options.interpolate(o,a.state,d))}return o}};function r8(e,t,n){return Math.max(t,Math.min(n,e))}function i8(){return typeof performance<"u"&&typeof performance.now=="function"?performance.now():Date.now()}u();u();var uc=class{constructor(t){this.onActivity=t}_activityHandler=()=>{this.onActivity?.()};addListeners(){typeof window>"u"||(window.addEventListener("mousemove",this._activityHandler),window.addEventListener("keydown",this._activityHandler),window.addEventListener("touchstart",this._activityHandler),window.addEventListener("click",this._activityHandler))}removeListeners(){typeof window>"u"||(window.removeEventListener("mousemove",this._activityHandler),window.removeEventListener("keydown",this._activityHandler),window.removeEventListener("touchstart",this._activityHandler),window.removeEventListener("click",this._activityHandler))}setOnActivity(t){this.onActivity=t}},lc=class extends Ee{websocket=null;timeoutHandle=null;reconnectTimeoutHandle=null;state="CONNECTING";attempt=0;options;url="";protocols;constructor(t={}){super(),this.options={reconnectInterval:1e3,maxReconnectInterval:3e4,reconnectDecay:1.5,timeoutInterval:5e3,maxReconnectAttempts:5,...t},this.options.activityDetector&&this.options.activityDetector.setOnActivity(()=>{this.state==="MAX_ATTEMPTS_EXCEEDED"&&this.resetAndReconnect()})}transitionTo(t){switch(this.options.debug&&console.info(`Transitioning from ${this.state} to ${t}`),this.state=t,this.emit(this.state),this.state){case"CONNECTING":this.connect();break;case"OPEN":this.onOpen();break;case"CLOSING":this.onClosing();break;case"CLOSED":this.onClosed();break;case"RECONNECTING":this.onReconnecting();break;case"MAX_ATTEMPTS_EXCEEDED":this.onMaxAttemptsExceeded();break;case"SHUTDOWN":this.onShutdown();break}}connect(t=this.url,n){this.url=t,this.protocols=n,this.state==="CONNECTING"&&(this.websocket=new WebSocket(this.url,this.protocols),this.timeoutHandle=setTimeout(()=>{this.websocket&&this.websocket.readyState!==WebSocket.OPEN&&(this.options.debug&&console.info("Connection attempt timed out"),this.websocket.close())},this.options.timeoutInterval),this.websocket.onopen=r=>{this.state==="CLOSING"||this.state==="SHUTDOWN"?this.websocket?.close():(this.transitionTo("OPEN"),this.options.onopen?.(r))},this.websocket.onmessage=r=>{this.options.onmessage?.(r)},this.websocket.onclose=r=>{this.state!=="CLOSING"&&this.state!=="SHUTDOWN"&&this.transitionTo("CLOSED"),this.options.onclose?.(r)},this.websocket.onerror=r=>{this.options.onerror?.(r)})}onOpen(){this.timeoutHandle&&(clearTimeout(this.timeoutHandle),this.timeoutHandle=null),this.attempt=0}onClosing(){this.websocket?.close()}onClosed(){this.timeoutHandle&&(clearTimeout(this.timeoutHandle),this.timeoutHandle=null),this.reconnect()}onReconnecting(){if(this.attempt>=this.options.maxReconnectAttempts){this.options.debug&&console.info("Max reconnect attempts reached, not attempting to reconnect."),this.transitionTo("MAX_ATTEMPTS_EXCEEDED");return}let t=Math.min(this.options.reconnectInterval*Math.pow(this.options.reconnectDecay,this.attempt),this.options.maxReconnectInterval);this.options.debug&&console.info(`Reconnecting in ${t/1e3} seconds... (attempt ${this.attempt+1}/${this.options.maxReconnectAttempts})`),this.reconnectTimeoutHandle=setTimeout(()=>{this.attempt++,this.transitionTo("CONNECTING")},t)}onMaxAttemptsExceeded(){this.websocket?.close(),this.timeoutHandle&&(clearTimeout(this.timeoutHandle),this.timeoutHandle=null),this.reconnectTimeoutHandle&&(clearTimeout(this.reconnectTimeoutHandle),this.reconnectTimeoutHandle=null),this.websocket=null,this.options.activityDetector?.addListeners()}onShutdown(){this.websocket?.close(),this.timeoutHandle&&(clearTimeout(this.timeoutHandle),this.timeoutHandle=null),this.reconnectTimeoutHandle&&(clearTimeout(this.reconnectTimeoutHandle),this.reconnectTimeoutHandle=null),this.websocket=null,this.options.activityDetector?.removeListeners()}reconnect(){this.state!=="SHUTDOWN"&&this.transitionTo("RECONNECTING")}resetAndReconnect(){this.options.debug&&console.info("User activity detected after max attempts exceeded. Resetting attempts and reconnecting."),this.attempt=0,this.options.activityDetector?.removeListeners(),this.transitionTo("RECONNECTING")}send(t){this.websocket&&this.websocket.readyState===WebSocket.OPEN?this.websocket.send(t):this.websocket&&this.websocket.readyState===WebSocket.CONNECTING?setTimeout(()=>this.send(t),this.options.timeoutInterval):console.error("WebSocket is not open. Ready state:",this.websocket?.readyState)}close(){this.state!=="CLOSING"&&this.state!=="CLOSED"&&this.state!=="SHUTDOWN"&&this.transitionTo("CLOSING")}shutdown(){this.state!=="SHUTDOWN"&&this.transitionTo("SHUTDOWN")}};u();var BN=require("react");u();u();u();var Qi=Q(require("react"));u();var cm=Q(require("react"));function ox(e,t="both"){let[n,r]=cm.useState(void 0);return cm.useEffect(()=>{if(e.current){let i=e.current,o=new ResizeObserver(s=>{if(!Array.isArray(s)||!s.length)return;let a=s[0],c,l;if("borderBoxSize"in a){let p=a.borderBoxSize,d=Array.isArray(p)?p[0]:p;c=d.inlineSize,l=d.blockSize}else{let p=i.getBoundingClientRect();c=p.width,l=p.height}r(p=>p&&(p.width===c||t==="height")&&(p.height===l||t==="width")?p:{width:c,height:l})});return o.observe(i,{box:"border-box"}),()=>{r(void 0),o.unobserve(i)}}},[e,t]),n}var dA={display:"flex",flex:"1 0 0",flexDirection:"column"},qCe=Qi.memo(function({children:t,className:n}){let r=Qi.useRef(null),i=ox(r);return Qi.createElement("div",{ref:r,style:dA,className:n},i&&i.width>0&&i.height>0&&t(i))}),VCe=Qi.memo(function({children:t,dimension:n,className:r}){let i=Qi.useRef(null),o=ox(i,n);return Qi.createElement("div",{ref:i,style:dA,className:r},o&&o[n]>0&&t(o[n]))});u();var pc=Q(require("react"));u();var Ws=require("react");function mA(e,t){let[n,r]=(0,Ws.useState)(!1),i=(0,Ws.useCallback)(c=>{c.preventDefault()},[]),o=(0,Ws.useCallback)(c=>{c.preventDefault(),e.current?.contains(c.relatedTarget)||r(!0)},[e]),s=(0,Ws.useCallback)(c=>{c.preventDefault(),e.current?.contains(c.relatedTarget)||r(!1)},[e]),a=(0,Ws.useCallback)(c=>{c.preventDefault(),t?.(c),r(!1)},[t]);return t?{dropTargetProps:{onDragOver:i,onDragEnter:o,onDragLeave:s,onDrop:a},isDropTargetActive:n}:{dropTargetProps:{},isDropTargetActive:n}}u();var sx=require("react");var ea=sx.memo;function hA(e,t){return t.includes(e.type)||e.type===""&&e.name.endsWith(".sketch")}var s1e=ea(function({children:t,onDropFiles:n,supportedFileTypes:r,...i}){let o=(0,pc.useRef)(null),s=(0,pc.useCallback)(l=>{l.preventDefault();let p={offsetX:l.nativeEvent.offsetX,offsetY:l.nativeEvent.offsetY},d=Array.from(l.dataTransfer.files).flatMap(y=>hA(y,r)?[]:[y.type]);d.length>0&&alert(`Files of type ${d.join(", ")} aren't supported. The following types are supported: ${r.join(", ")}`);let m=Array.from(l.dataTransfer.files).flatMap(y=>hA(y,r)?[y]:[]);n(m,p)},[n,r]),{dropTargetProps:a,isDropTargetActive:c}=mA(o,s);return pc.default.createElement("div",{ref:o,...a,...i},typeof t=="function"?t(c):t)});u();var yA=require("react");u();var um=require("react");function gA(e){let t=(0,um.useMemo)(()=>e===void 0?void 0:JSON.stringify(e),[e]);return(0,um.useMemo)(()=>t===void 0?void 0:JSON.parse(t),[t])}u();var ax=require("react");u();var bA=require("react");u();u();var SA=require("react");u();var lm=Q(require("react")),ip=typeof window<"u"?lm.useLayoutEffect:lm.useEffect;u();var cx=require("react");u();var s8=require("react");u();var c8=require("react");u();u();var ux=require("react");u();var pm=require("react");u();var xA=require("react");u();var l8=require("react");u();var fm=require("react");var TA=()=>{};function vA(e){let t=(0,fm.useRef)(e||TA);return ip(()=>{t.current=e||TA},[e]),(0,fm.useCallback)((...n)=>t.current(...n),[t])}u();var IA=require("react");u();u();u();var EA=require("react");u();var wA=require("react");u();u();u();var lx=class{getItem(t){return typeof localStorage>"u"?null:localStorage.getItem(t)}setItem(t,n){typeof localStorage>"u"||(n===null?localStorage.removeItem(t):localStorage.setItem(t,n),this.emitter.emit(t,n))}emitter=new Ee;_isListening=!1;addListener(t,n){return!this._isListening&&typeof window<"u"&&(this._isListening=!0,window.addEventListener("storage",r=>{this.emitter.emit(r.key,r.newValue)})),this.emitter.addListener((r,i)=>{r===t&&n(i)})}},xNe=new lx;u();u();u();function p8(e,t){let n=document.createElement("a");n.href=e,t&&(n.download=t),n.style.display="none",document.body.appendChild(n),n.click(),document.body.removeChild(n)}function MA(...e){let t=URL.createObjectURL(e[0]),n=e.length===1?e[0].name:e[1];p8(t,n),URL.revokeObjectURL(t)}u();u();var Oe=Q(require("react"));u();var Ai=require("react");u();var Xt=require("react"),EN=Q(Bv());u();var yn=Q(require("react")),z1=yn.memo(function({error:t}){return yn.createElement("div",{style:{position:"fixed",top:"20px",left:"50%",transform:"translateX(-50%)",maxWidth:"80%",width:"fit-content",padding:"12px 20px",background:"white",color:"black",zIndex:1e4,display:"flex",flexDirection:"column",justifyContent:"center",borderRadius:"4px",boxShadow:"0 4px 6px rgba(0, 0, 0, 0.1)",fontFamily:"'__Inter_6b0edc', '__Inter_Fallback_6b0edc', -apple-system, BlinkMacSystemFont, 'Helvetica Neue', 'Segoe UI', Roboto, Helvetica, Arial, sans-serif",fontSize:"14px",fontWeight:400,lineHeight:"19px"}},t.reason==="schemaMigration"?yn.createElement(yn.Fragment,null,yn.createElement("p",null,"An updated version of Noya is available. Please reload the page to continue.")):yn.createElement(yn.Fragment,null,yn.createElement("p",null,"An error occurred:"," ",yn.createElement("code",{style:{background:"rgba(255, 0, 0, 0.1)",color:"rgba(255, 0, 0, 0.5)",padding:"2px 4px",borderRadius:"4px"}},t.reason),". Please reload the page to continue.",yn.createElement("br",null),yn.createElement("br",null),"If this happens repeatedly, please get in touch and the Noya team can help.")),yn.createElement("div",{style:{height:"1px",background:"rgba(0, 0, 0, 0.1)",margin:"12px -20px"}}),yn.createElement("button",{style:{background:"black",color:"white",padding:"8px 16px",borderRadius:"4px",cursor:"pointer",fontSize:"14px",fontWeight:700,lineHeight:"19px"},onClick:()=>{window.location.reload()}},"Reload"))});u();var cI=Q(require("react")),IN=Q(Bv());u();var k=Q(require("react"));u();var $h=Q(require("react"),1),sn=Q(require("react"),1),Y1=require("react"),mr=Q(require("react"),1),fo=Q(require("react"),1),ru=Q(require("react"),1),eN=Q(require("react"),1),gn=Q(require("react"),1),Jt=Q(require("react"),1),iu=Q(require("react"),1),Mi=Q(require("react"),1),wi=Q(require("react"),1),xa=Q(require("react"),1),Lr=Q(require("react"),1),nN=Q(require("react"),1),Rt=Q(require("react"),1),hV=Q(require("react"),1),Lq=Object.create,zv=Object.defineProperty,Bq=Object.getOwnPropertyDescriptor,Q1=Object.getOwnPropertyNames,Fq=Object.getPrototypeOf,$q=Object.prototype.hasOwnProperty,Hv=(e,t)=>function(){return t||(0,e[Q1(e)[0]])((t={exports:{}}).exports,t),t.exports},Kq=(e,t)=>{for(var n in t)zv(e,n,{get:t[n],enumerable:!0})},zq=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of Q1(t))!$q.call(e,i)&&i!==n&&zv(e,i,{get:()=>t[i],enumerable:!(r=Bq(t,i))||r.enumerable});return e},Hq=(e,t,n)=>(n=e!=null?Lq(Fq(e)):{},zq(t||!e||!e.__esModule?zv(n,"default",{value:e,enumerable:!0}):n,e)),Gq=Hv({"node_modules/is-object/index.js"(e,t){"use strict";t.exports=function(r){return typeof r=="object"&&r!==null}}}),qq=Hv({"node_modules/is-window/index.js"(e,t){"use strict";t.exports=function(n){if(n==null)return!1;var r=Object(n);return r===r.window}}}),Vq=Hv({"node_modules/is-dom/index.js"(e,t){var n=Gq(),r=qq();function i(o){return!n(o)||!r(window)||typeof window.Node!="function"?!1:typeof o.nodeType=="number"&&typeof o.nodeName=="string"}t.exports=i}}),Fh={};Kq(Fh,{chromeDark:()=>Gv,chromeLight:()=>qv});var Gv={BASE_FONT_FAMILY:"Menlo, monospace",BASE_FONT_SIZE:"11px",BASE_LINE_HEIGHT:1.2,BASE_BACKGROUND_COLOR:"rgb(36, 36, 36)",BASE_COLOR:"rgb(213, 213, 213)",OBJECT_PREVIEW_ARRAY_MAX_PROPERTIES:10,OBJECT_PREVIEW_OBJECT_MAX_PROPERTIES:5,OBJECT_NAME_COLOR:"rgb(227, 110, 236)",OBJECT_VALUE_NULL_COLOR:"rgb(127, 127, 127)",OBJECT_VALUE_UNDEFINED_COLOR:"rgb(127, 127, 127)",OBJECT_VALUE_REGEXP_COLOR:"rgb(233, 63, 59)",OBJECT_VALUE_STRING_COLOR:"rgb(233, 63, 59)",OBJECT_VALUE_SYMBOL_COLOR:"rgb(233, 63, 59)",OBJECT_VALUE_NUMBER_COLOR:"hsl(252, 100%, 75%)",OBJECT_VALUE_BOOLEAN_COLOR:"hsl(252, 100%, 75%)",OBJECT_VALUE_FUNCTION_PREFIX_COLOR:"rgb(85, 106, 242)",HTML_TAG_COLOR:"rgb(93, 176, 215)",HTML_TAGNAME_COLOR:"rgb(93, 176, 215)",HTML_TAGNAME_TEXT_TRANSFORM:"lowercase",HTML_ATTRIBUTE_NAME_COLOR:"rgb(155, 187, 220)",HTML_ATTRIBUTE_VALUE_COLOR:"rgb(242, 151, 102)",HTML_COMMENT_COLOR:"rgb(137, 137, 137)",HTML_DOCTYPE_COLOR:"rgb(192, 192, 192)",ARROW_COLOR:"rgb(145, 145, 145)",ARROW_MARGIN_RIGHT:3,ARROW_FONT_SIZE:12,ARROW_ANIMATION_DURATION:"0",TREENODE_FONT_FAMILY:"Menlo, monospace",TREENODE_FONT_SIZE:"11px",TREENODE_LINE_HEIGHT:1.2,TREENODE_PADDING_LEFT:12,TABLE_BORDER_COLOR:"rgb(85, 85, 85)",TABLE_TH_BACKGROUND_COLOR:"rgb(44, 44, 44)",TABLE_TH_HOVER_COLOR:"rgb(48, 48, 48)",TABLE_SORT_ICON_COLOR:"black",TABLE_DATA_BACKGROUND_IMAGE:"linear-gradient(rgba(255, 255, 255, 0), rgba(255, 255, 255, 0) 50%, rgba(51, 139, 255, 0.0980392) 50%, rgba(51, 139, 255, 0.0980392))",TABLE_DATA_BACKGROUND_SIZE:"128px 32px"},qv={BASE_FONT_FAMILY:"Menlo, monospace",BASE_FONT_SIZE:"11px",BASE_LINE_HEIGHT:1.2,BASE_BACKGROUND_COLOR:"white",BASE_COLOR:"black",OBJECT_PREVIEW_ARRAY_MAX_PROPERTIES:10,OBJECT_PREVIEW_OBJECT_MAX_PROPERTIES:5,OBJECT_NAME_COLOR:"rgb(136, 19, 145)",OBJECT_VALUE_NULL_COLOR:"rgb(128, 128, 128)",OBJECT_VALUE_UNDEFINED_COLOR:"rgb(128, 128, 128)",OBJECT_VALUE_REGEXP_COLOR:"rgb(196, 26, 22)",OBJECT_VALUE_STRING_COLOR:"rgb(196, 26, 22)",OBJECT_VALUE_SYMBOL_COLOR:"rgb(196, 26, 22)",OBJECT_VALUE_NUMBER_COLOR:"rgb(28, 0, 207)",OBJECT_VALUE_BOOLEAN_COLOR:"rgb(28, 0, 207)",OBJECT_VALUE_FUNCTION_PREFIX_COLOR:"rgb(13, 34, 170)",HTML_TAG_COLOR:"rgb(168, 148, 166)",HTML_TAGNAME_COLOR:"rgb(136, 18, 128)",HTML_TAGNAME_TEXT_TRANSFORM:"lowercase",HTML_ATTRIBUTE_NAME_COLOR:"rgb(153, 69, 0)",HTML_ATTRIBUTE_VALUE_COLOR:"rgb(26, 26, 166)",HTML_COMMENT_COLOR:"rgb(35, 110, 37)",HTML_DOCTYPE_COLOR:"rgb(192, 192, 192)",ARROW_COLOR:"#6e6e6e",ARROW_MARGIN_RIGHT:3,ARROW_FONT_SIZE:12,ARROW_ANIMATION_DURATION:"0",TREENODE_FONT_FAMILY:"Menlo, monospace",TREENODE_FONT_SIZE:"11px",TREENODE_LINE_HEIGHT:1.2,TREENODE_PADDING_LEFT:12,TABLE_BORDER_COLOR:"#aaa",TABLE_TH_BACKGROUND_COLOR:"#eee",TABLE_TH_HOVER_COLOR:"hsla(0, 0%, 90%, 1)",TABLE_SORT_ICON_COLOR:"#6e6e6e",TABLE_DATA_BACKGROUND_IMAGE:"linear-gradient(to bottom, white, white 50%, rgb(234, 243, 255) 50%, rgb(234, 243, 255))",TABLE_DATA_BACKGROUND_SIZE:"128px 32px"},J1=(0,Y1.createContext)([{},()=>{}]),Fv={WebkitTouchCallout:"none",WebkitUserSelect:"none",KhtmlUserSelect:"none",MozUserSelect:"none",msUserSelect:"none",OUserSelect:"none",userSelect:"none"},Lh=e=>({DOMNodePreview:{htmlOpenTag:{base:{color:e.HTML_TAG_COLOR},tagName:{color:e.HTML_TAGNAME_COLOR,textTransform:e.HTML_TAGNAME_TEXT_TRANSFORM},htmlAttributeName:{color:e.HTML_ATTRIBUTE_NAME_COLOR},htmlAttributeValue:{color:e.HTML_ATTRIBUTE_VALUE_COLOR}},htmlCloseTag:{base:{color:e.HTML_TAG_COLOR},offsetLeft:{marginLeft:-e.TREENODE_PADDING_LEFT},tagName:{color:e.HTML_TAGNAME_COLOR,textTransform:e.HTML_TAGNAME_TEXT_TRANSFORM}},htmlComment:{color:e.HTML_COMMENT_COLOR},htmlDoctype:{color:e.HTML_DOCTYPE_COLOR}},ObjectPreview:{objectDescription:{fontStyle:"italic"},preview:{fontStyle:"italic"},arrayMaxProperties:e.OBJECT_PREVIEW_ARRAY_MAX_PROPERTIES,objectMaxProperties:e.OBJECT_PREVIEW_OBJECT_MAX_PROPERTIES},ObjectName:{base:{color:e.OBJECT_NAME_COLOR},dimmed:{opacity:.6}},ObjectValue:{objectValueNull:{color:e.OBJECT_VALUE_NULL_COLOR},objectValueUndefined:{color:e.OBJECT_VALUE_UNDEFINED_COLOR},objectValueRegExp:{color:e.OBJECT_VALUE_REGEXP_COLOR},objectValueString:{color:e.OBJECT_VALUE_STRING_COLOR},objectValueSymbol:{color:e.OBJECT_VALUE_SYMBOL_COLOR},objectValueNumber:{color:e.OBJECT_VALUE_NUMBER_COLOR},objectValueBoolean:{color:e.OBJECT_VALUE_BOOLEAN_COLOR},objectValueFunctionPrefix:{color:e.OBJECT_VALUE_FUNCTION_PREFIX_COLOR,fontStyle:"italic"},objectValueFunctionName:{fontStyle:"italic"}},TreeView:{treeViewOutline:{padding:0,margin:0,listStyleType:"none"}},TreeNode:{treeNodeBase:{color:e.BASE_COLOR,backgroundColor:e.BASE_BACKGROUND_COLOR,lineHeight:e.TREENODE_LINE_HEIGHT,cursor:"default",boxSizing:"border-box",listStyle:"none",fontFamily:e.TREENODE_FONT_FAMILY,fontSize:e.TREENODE_FONT_SIZE},treeNodePreviewContainer:{},treeNodePlaceholder:{whiteSpace:"pre",fontSize:e.ARROW_FONT_SIZE,marginRight:e.ARROW_MARGIN_RIGHT,...Fv},treeNodeArrow:{base:{color:e.ARROW_COLOR,display:"inline-block",fontSize:e.ARROW_FONT_SIZE,marginRight:e.ARROW_MARGIN_RIGHT,...parseFloat(e.ARROW_ANIMATION_DURATION)>0?{transition:`transform ${e.ARROW_ANIMATION_DURATION} ease 0s`}:{},...Fv},expanded:{WebkitTransform:"rotateZ(90deg)",MozTransform:"rotateZ(90deg)",transform:"rotateZ(90deg)"},collapsed:{WebkitTransform:"rotateZ(0deg)",MozTransform:"rotateZ(0deg)",transform:"rotateZ(0deg)"}},treeNodeChildNodesContainer:{margin:0,paddingLeft:e.TREENODE_PADDING_LEFT}},TableInspector:{base:{color:e.BASE_COLOR,position:"relative",border:`1px solid ${e.TABLE_BORDER_COLOR}`,fontFamily:e.BASE_FONT_FAMILY,fontSize:e.BASE_FONT_SIZE,lineHeight:"120%",boxSizing:"border-box",cursor:"default"}},TableInspectorHeaderContainer:{base:{top:0,height:"17px",left:0,right:0,overflowX:"hidden"},table:{tableLayout:"fixed",borderSpacing:0,borderCollapse:"separate",height:"100%",width:"100%",margin:0}},TableInspectorDataContainer:{tr:{display:"table-row"},td:{boxSizing:"border-box",border:"none",height:"16px",verticalAlign:"top",padding:"1px 4px",WebkitUserSelect:"text",whiteSpace:"nowrap",textOverflow:"ellipsis",overflow:"hidden",lineHeight:"14px"},div:{position:"static",top:"17px",bottom:0,overflowY:"overlay",transform:"translateZ(0)",left:0,right:0,overflowX:"hidden"},table:{positon:"static",left:0,top:0,right:0,bottom:0,borderTop:"0 none transparent",margin:0,backgroundImage:e.TABLE_DATA_BACKGROUND_IMAGE,backgroundSize:e.TABLE_DATA_BACKGROUND_SIZE,tableLayout:"fixed",borderSpacing:0,borderCollapse:"separate",width:"100%",fontSize:e.BASE_FONT_SIZE,lineHeight:"120%"}},TableInspectorTH:{base:{position:"relative",height:"auto",textAlign:"left",backgroundColor:e.TABLE_TH_BACKGROUND_COLOR,borderBottom:`1px solid ${e.TABLE_BORDER_COLOR}`,fontWeight:"normal",verticalAlign:"middle",padding:"0 4px",whiteSpace:"nowrap",textOverflow:"ellipsis",overflow:"hidden",lineHeight:"14px",":hover":{backgroundColor:e.TABLE_TH_HOVER_COLOR}},div:{whiteSpace:"nowrap",textOverflow:"ellipsis",overflow:"hidden",fontSize:e.BASE_FONT_SIZE,lineHeight:"120%"}},TableInspectorLeftBorder:{none:{borderLeft:"none"},solid:{borderLeft:`1px solid ${e.TABLE_BORDER_COLOR}`}},TableInspectorSortIcon:{display:"block",marginRight:3,width:8,height:7,marginTop:-7,color:e.TABLE_SORT_ICON_COLOR,fontSize:12,...Fv}}),$v="chromeLight",X1=(0,fo.createContext)(Lh(Fh[$v])),hr=e=>(0,fo.useContext)(X1)[e],Vv=e=>({theme:n=$v,...r})=>{let i=(0,fo.useMemo)(()=>{switch(Object.prototype.toString.call(n)){case"[object String]":return Lh(Fh[n]);case"[object Object]":return Lh(n);default:return Lh(Fh[$v])}},[n]);return fo.default.createElement(X1.Provider,{value:i},fo.default.createElement(e,{...r}))},Qq=({expanded:e,styles:t})=>mr.default.createElement("span",{style:{...t.base,...e?t.expanded:t.collapsed}},"\u25B6"),Yq=(0,mr.memo)(e=>{e={expanded:!0,nodeRenderer:({name:p})=>mr.default.createElement("span",null,p),onClick:()=>{},shouldShowArrow:!1,shouldShowPlaceholder:!0,...e};let{expanded:t,onClick:n,children:r,nodeRenderer:i,title:o,shouldShowArrow:s,shouldShowPlaceholder:a}=e,c=hr("TreeNode"),l=i;return mr.default.createElement("li",{"aria-expanded":t,role:"treeitem",style:c.treeNodeBase,title:o},mr.default.createElement("div",{style:c.treeNodePreviewContainer,onClick:n},s||mr.Children.count(r)>0?mr.default.createElement(Qq,{expanded:t,styles:c.treeNodeArrow}):a&&mr.default.createElement("span",{style:c.treeNodePlaceholder},"\xA0"),mr.default.createElement(l,{...e})),mr.default.createElement("ol",{role:"group",style:c.treeNodeChildNodesContainer},t?r:void 0))}),Kh="$",H1="*";function Bh(e,t){return!t(e).next().done}var Jq=e=>Array.from({length:e},(t,n)=>[Kh].concat(Array.from({length:n},()=>"*")).join(".")),Xq=(e,t,n,r,i)=>{let o=[].concat(Jq(r)).concat(n).filter(a=>typeof a=="string"),s=[];return o.forEach(a=>{let c=a.split("."),l=(p,d,m)=>{if(m===c.length){s.push(d);return}let y=c[m];if(m===0)Bh(p,t)&&(y===Kh||y===H1)&&l(p,Kh,m+1);else if(y===H1)for(let{name:S,data:T}of t(p))Bh(T,t)&&l(T,`${d}.${S}`,m+1);else{let S=p[y];Bh(S,t)&&l(S,`${d}.${y}`,m+1)}};l(e,"",0)}),s.reduce((a,c)=>(a[c]=!0,a),{...i})},Z1=(0,sn.memo)(e=>{let{data:t,dataIterator:n,path:r,depth:i,nodeRenderer:o}=e,[s,a]=(0,sn.useContext)(J1),c=Bh(t,n),l=!!s[r],p=(0,sn.useCallback)(()=>c&&a(d=>({...d,[r]:!l})),[c,a,r,l]);return sn.default.createElement(Yq,{expanded:l,onClick:p,shouldShowArrow:c,shouldShowPlaceholder:i>0,nodeRenderer:o,...e},l?[...n(t)].map(({name:d,data:m,...y})=>sn.default.createElement(Z1,{name:d,data:m,depth:i+1,path:`${r}.${d}`,key:d,dataIterator:n,nodeRenderer:o,...y})):null)}),W1=(0,sn.memo)(({name:e,data:t,dataIterator:n,nodeRenderer:r,expandPaths:i,expandLevel:o})=>{let s=hr("TreeView"),a=(0,sn.useState)({}),[,c]=a;return(0,sn.useLayoutEffect)(()=>c(l=>Xq(t,n,i,o,l)),[t,n,i,o]),sn.default.createElement(J1.Provider,{value:a},sn.default.createElement("ol",{role:"tree",style:s.treeViewOutline},sn.default.createElement(Z1,{name:e,data:t,dataIterator:n,depth:0,path:Kh,nodeRenderer:r})))}),ff=({name:e,dimmed:t=!1,styles:n={}})=>{let r=hr("ObjectName"),i={...r.base,...t?r.dimmed:{},...n};return eN.default.createElement("span",{style:i},e)},pf=({object:e,styles:t})=>{let n=hr("ObjectValue"),r=i=>({...n[i],...t});switch(typeof e){case"bigint":return Jt.default.createElement("span",{style:r("objectValueNumber")},String(e),"n");case"number":return Jt.default.createElement("span",{style:r("objectValueNumber")},String(e));case"string":return Jt.default.createElement("span",{style:r("objectValueString")},'"',e,'"');case"boolean":return Jt.default.createElement("span",{style:r("objectValueBoolean")},String(e));case"undefined":return Jt.default.createElement("span",{style:r("objectValueUndefined")},"undefined");case"object":return e===null?Jt.default.createElement("span",{style:r("objectValueNull")},"null"):e instanceof Date?Jt.default.createElement("span",null,e.toString()):e instanceof RegExp?Jt.default.createElement("span",{style:r("objectValueRegExp")},e.toString()):Array.isArray(e)?Jt.default.createElement("span",null,`Array(${e.length})`):e.constructor?typeof e.constructor.isBuffer=="function"&&e.constructor.isBuffer(e)?Jt.default.createElement("span",null,`Buffer[${e.length}]`):Jt.default.createElement("span",null,e.constructor.name):Jt.default.createElement("span",null,"Object");case"function":return Jt.default.createElement("span",null,Jt.default.createElement("span",{style:r("objectValueFunctionPrefix")},"\u0192\xA0"),Jt.default.createElement("span",{style:r("objectValueFunctionName")},e.name,"()"));case"symbol":return Jt.default.createElement("span",{style:r("objectValueSymbol")},e.toString());default:return Jt.default.createElement("span",null)}},tN=Object.prototype.hasOwnProperty,Zq=Object.prototype.propertyIsEnumerable;function Kv(e,t){let n=Object.getOwnPropertyDescriptor(e,t);if(n.get)try{return n.get()}catch{return n.get}return e[t]}function G1(e,t){return e.length===0?[]:e.slice(1).reduce((n,r)=>n.concat([t,r]),[e[0]])}var Ta=({data:e})=>{let t=hr("ObjectPreview"),n=e;if(typeof n!="object"||n===null||n instanceof Date||n instanceof RegExp)return gn.default.createElement(pf,{object:n});if(Array.isArray(n)){let r=t.arrayMaxProperties,i=n.slice(0,r).map((s,a)=>gn.default.createElement(pf,{key:a,object:s}));n.length>r&&i.push(gn.default.createElement("span",{key:"ellipsis"},"\u2026"));let o=n.length;return gn.default.createElement(gn.default.Fragment,null,gn.default.createElement("span",{style:t.objectDescription},o===0?"":`(${o})\xA0`),gn.default.createElement("span",{style:t.preview},"[",G1(i,", "),"]"))}else{let r=t.objectMaxProperties,i=[];for(let s in n)if(tN.call(n,s)){let a;i.length===r-1&&Object.keys(n).length>r&&(a=gn.default.createElement("span",{key:"ellipsis"},"\u2026"));let c=Kv(n,s);if(i.push(gn.default.createElement("span",{key:s},gn.default.createElement(ff,{name:s||'""'}),":\xA0",gn.default.createElement(pf,{object:c}),a)),a)break}let o=n.constructor?n.constructor.name:"Object";return gn.default.createElement(gn.default.Fragment,null,gn.default.createElement("span",{style:t.objectDescription},o==="Object"?"":`${o} `),gn.default.createElement("span",{style:t.preview},"{",G1(i,", "),"}"))}},Wq=({name:e,data:t})=>typeof e=="string"?ru.default.createElement("span",null,ru.default.createElement(ff,{name:e}),ru.default.createElement("span",null,": "),ru.default.createElement(Ta,{data:t})):ru.default.createElement(Ta,{data:t}),Qv=({name:e,data:t,isNonenumerable:n=!1})=>{let r=t;return iu.default.createElement("span",null,typeof e=="string"?iu.default.createElement(ff,{name:e,dimmed:n}):iu.default.createElement(Ta,{data:e}),iu.default.createElement("span",null,": "),iu.default.createElement(pf,{object:r}))},eV=(e,t)=>function*(r){if(!(typeof r=="object"&&r!==null||typeof r=="function"))return;let o=Array.isArray(r);if(!o&&r[Symbol.iterator]){let s=0;for(let a of r){if(Array.isArray(a)&&a.length===2){let[c,l]=a;yield{name:c,data:l}}else yield{name:s.toString(),data:a};s++}}else{let s=Object.getOwnPropertyNames(r);t===!0&&!o?s.sort():typeof t=="function"&&s.sort(t);for(let a of s)if(Zq.call(r,a)){let c=Kv(r,a);yield{name:a||'""',data:c}}else if(e){let c;try{c=Kv(r,a)}catch{}c!==void 0&&(yield{name:a,data:c,isNonenumerable:!0})}e&&r!==Object.prototype&&(yield{name:"__proto__",data:Object.getPrototypeOf(r),isNonenumerable:!0})}},tV=({depth:e,name:t,data:n,isNonenumerable:r})=>e===0?$h.default.createElement(Wq,{name:t,data:n}):$h.default.createElement(Qv,{name:t,data:n,isNonenumerable:r}),nV=({showNonenumerable:e=!1,sortObjectKeys:t,nodeRenderer:n,...r})=>{let i=eV(e,t),o=n||tV;return $h.default.createElement(W1,{nodeRenderer:o,dataIterator:i,...r})},dt=Vv(nV);function rV(e){if(typeof e=="object"){let t=[];if(Array.isArray(e)){let r=e.length;t=[...Array(r).keys()]}else e!==null&&(t=Object.keys(e));let n=t.reduce((r,i)=>{let o=e[i];return typeof o=="object"&&o!==null&&Object.keys(o).reduce((a,c)=>(a.includes(c)||a.push(c),a),r),r},[]);return{rowHeaders:t,colHeaders:n}}}var iV=({rows:e,columns:t,rowsData:n})=>{let r=hr("TableInspectorDataContainer"),i=hr("TableInspectorLeftBorder");return wi.default.createElement("div",{style:r.div},wi.default.createElement("table",{style:r.table},wi.default.createElement("colgroup",null),wi.default.createElement("tbody",null,e.map((o,s)=>wi.default.createElement("tr",{key:o,style:r.tr},wi.default.createElement("td",{style:{...r.td,...i.none}},o),t.map(a=>{let c=n[s];return typeof c=="object"&&c!==null&&tN.call(c,a)?wi.default.createElement("td",{key:a,style:{...r.td,...i.solid}},wi.default.createElement(pf,{object:c[a]})):wi.default.createElement("td",{key:a,style:{...r.td,...i.solid}})}))))))},oV=e=>Lr.default.createElement("div",{style:{position:"absolute",top:1,right:0,bottom:1,display:"flex",alignItems:"center"}},e.children),sV=({sortAscending:e})=>{let t=hr("TableInspectorSortIcon"),n=e?"\u25B2":"\u25BC";return Lr.default.createElement("div",{style:t},n)},q1=({sortAscending:e=!1,sorted:t=!1,onClick:n=void 0,borderStyle:r={},children:i,...o})=>{let s=hr("TableInspectorTH"),[a,c]=(0,Lr.useState)(!1),l=(0,Lr.useCallback)(()=>c(!0),[]),p=(0,Lr.useCallback)(()=>c(!1),[]);return Lr.default.createElement("th",{...o,style:{...s.base,...r,...a?s.base[":hover"]:{}},onMouseEnter:l,onMouseLeave:p,onClick:n},Lr.default.createElement("div",{style:s.div},i),t&&Lr.default.createElement(oV,null,Lr.default.createElement(sV,{sortAscending:e})))},aV=({indexColumnText:e="(index)",columns:t=[],sorted:n,sortIndexColumn:r,sortColumn:i,sortAscending:o,onTHClick:s,onIndexTHClick:a})=>{let c=hr("TableInspectorHeaderContainer"),l=hr("TableInspectorLeftBorder");return xa.default.createElement("div",{style:c.base},xa.default.createElement("table",{style:c.table},xa.default.createElement("tbody",null,xa.default.createElement("tr",null,xa.default.createElement(q1,{borderStyle:l.none,sorted:n&&r,sortAscending:o,onClick:a},e),t.map(p=>xa.default.createElement(q1,{borderStyle:l.solid,key:p,sorted:n&&i===p,sortAscending:o,onClick:s.bind(null,p)},p))))))},cV=({data:e,columns:t})=>{let n=hr("TableInspector"),[{sorted:r,sortIndexColumn:i,sortColumn:o,sortAscending:s},a]=(0,Mi.useState)({sorted:!1,sortIndexColumn:!1,sortColumn:void 0,sortAscending:!1}),c=(0,Mi.useCallback)(()=>{a(({sortIndexColumn:S,sortAscending:T})=>({sorted:!0,sortIndexColumn:!0,sortColumn:void 0,sortAscending:S?!T:!0}))},[]),l=(0,Mi.useCallback)(S=>{a(({sortColumn:T,sortAscending:E})=>({sorted:!0,sortIndexColumn:!1,sortColumn:S,sortAscending:S===T?!E:!0}))},[]);if(typeof e!="object"||e===null)return Mi.default.createElement("div",null);let{rowHeaders:p,colHeaders:d}=rV(e);t!==void 0&&(d=t);let m=p.map(S=>e[S]),y;if(o!==void 0?y=m.map((S,T)=>typeof S=="object"&&S!==null?[S[o],T]:[void 0,T]):i&&(y=p.map((S,T)=>[p[T],T])),y!==void 0){let S=(E,b)=>(f,g)=>{let v=E(f),I=E(g),M=typeof v,O=typeof I,C=(F,N)=>F<N?-1:F>N?1:0,z;if(M===O)z=C(v,I);else{let F={string:0,number:1,object:2,symbol:3,boolean:4,undefined:5,function:6};z=C(F[M],F[O])}return b||(z=-z),z},T=y.sort(S(E=>E[0],s)).map(E=>E[1]);p=T.map(E=>p[E]),m=T.map(E=>m[E])}return Mi.default.createElement("div",{style:n.base},Mi.default.createElement(aV,{columns:d,sorted:r,sortIndexColumn:i,sortColumn:o,sortAscending:s,onTHClick:l,onIndexTHClick:c}),Mi.default.createElement(iV,{rows:p,columns:d,rowsData:m}))},wke=Vv(cV),uV=80,rN=e=>e.childNodes.length===0||e.childNodes.length===1&&e.childNodes[0].nodeType===Node.TEXT_NODE&&e.textContent.length<uV,lV=({tagName:e,attributes:t,styles:n})=>Rt.default.createElement("span",{style:n.base},"<",Rt.default.createElement("span",{style:n.tagName},e),(()=>{if(t){let r=[];for(let i=0;i<t.length;i++){let o=t[i];r.push(Rt.default.createElement("span",{key:i}," ",Rt.default.createElement("span",{style:n.htmlAttributeName},o.name),'="',Rt.default.createElement("span",{style:n.htmlAttributeValue},o.value),'"'))}return r}})(),">"),V1=({tagName:e,isChildNode:t=!1,styles:n})=>Rt.default.createElement("span",{style:Object.assign({},n.base,t&&n.offsetLeft)},"</",Rt.default.createElement("span",{style:n.tagName},e),">"),pV={1:"ELEMENT_NODE",3:"TEXT_NODE",7:"PROCESSING_INSTRUCTION_NODE",8:"COMMENT_NODE",9:"DOCUMENT_NODE",10:"DOCUMENT_TYPE_NODE",11:"DOCUMENT_FRAGMENT_NODE"},fV=({isCloseTag:e,data:t,expanded:n})=>{let r=hr("DOMNodePreview");if(e)return Rt.default.createElement(V1,{styles:r.htmlCloseTag,isChildNode:!0,tagName:t.tagName});switch(t.nodeType){case Node.ELEMENT_NODE:return Rt.default.createElement("span",null,Rt.default.createElement(lV,{tagName:t.tagName,attributes:t.attributes,styles:r.htmlOpenTag}),rN(t)?t.textContent:!n&&"\u2026",!n&&Rt.default.createElement(V1,{tagName:t.tagName,styles:r.htmlCloseTag}));case Node.TEXT_NODE:return Rt.default.createElement("span",null,t.textContent);case Node.CDATA_SECTION_NODE:return Rt.default.createElement("span",null,"<![CDATA["+t.textContent+"]]>");case Node.COMMENT_NODE:return Rt.default.createElement("span",{style:r.htmlComment},"<!--",t.textContent,"-->");case Node.PROCESSING_INSTRUCTION_NODE:return Rt.default.createElement("span",null,t.nodeName);case Node.DOCUMENT_TYPE_NODE:return Rt.default.createElement("span",{style:r.htmlDoctype},"<!DOCTYPE ",t.name,t.publicId?` PUBLIC "${t.publicId}"`:"",!t.publicId&&t.systemId?" SYSTEM":"",t.systemId?` "${t.systemId}"`:"",">");case Node.DOCUMENT_NODE:return Rt.default.createElement("span",null,t.nodeName);case Node.DOCUMENT_FRAGMENT_NODE:return Rt.default.createElement("span",null,t.nodeName);default:return Rt.default.createElement("span",null,pV[t.nodeType])}},dV=function*(e){if(e&&e.childNodes){if(rN(e))return;for(let n=0;n<e.childNodes.length;n++){let r=e.childNodes[n];r.nodeType===Node.TEXT_NODE&&r.textContent.trim().length===0||(yield{name:`${r.tagName}[${n}]`,data:r})}e.tagName&&(yield{name:"CLOSE_TAG",data:{tagName:e.tagName},isCloseTag:!0})}},mV=e=>nN.default.createElement(W1,{nodeRenderer:fV,dataIterator:dV,...e}),Mke=Vv(mV),Oke=Hq(Vq());u();var zh=require("react");function q(e,t,n){let{get:r,listen:i}=(0,zh.useMemo)(()=>{if(!e)return{get:()=>{},listen:()=>()=>{}};if(typeof t=="function"){let a=e.map(t,{isEqual:n?.isEqual});return{get:a.get,listen:a.subscribe}}let o=t?a=>e.subscribe(t,a):e.subscribe;return{get:t?()=>e.get(t):e.get,listen:o}},[e,t,n?.isEqual]);return(0,zh.useSyncExternalStore)(i,r,r)}u();var iN=Q(require("react"));function mo({type:e}){return iN.default.createElement("span",{style:{display:"inline-block",width:6,height:6,background:e==="success"?"rgba(0,200,0,0.8)":"rgba(200,0,0,0.8)",borderRadius:"50%",verticalAlign:"middle"}})}u();var Yv={...qv,BASE_BACKGROUND_COLOR:"transparent",OBJECT_NAME_COLOR:"rgba(0,0,0,0.7)"},Jv={...Gv,BASE_BACKGROUND_COLOR:"transparent",OBJECT_NAME_COLOR:"rgba(255,255,255,0.7)"},Br=e=>e==="light"?Yv:Jv,Hh=e=>e==="light"?"rgb(223 223 223)":"rgb(29 29 29)";u();var On=Q(require("react"));u();var oN=Q(require("react"));function me({children:e,onClick:t,style:n,theme:r,disabled:i}){return oN.default.createElement("button",{type:"button",disabled:i,onClick:o=>{o.stopPropagation(),t()},style:{flex:"0",appearance:"none",background:"none",color:r.BASE_COLOR,opacity:i?.25:1,border:"none",fontSize:"12px",whiteSpace:"nowrap",display:"inline-flex",alignItems:"center",justifyContent:"center",padding:"0",cursor:"pointer",...n}},e)}u();var fs=Q(require("react"));u();var sN=Q(require("react"));function aN({expanded:e,onClick:t,style:n}){return sN.default.createElement("span",{role:"button",onClick:t,style:{display:"inline-block",textAlign:"center",transform:e?"rotate(0deg)":"rotate(-90deg)",fontFamily:"Menlo, monospace",...n}},"\u25BC")}function bt({open:e,setOpen:t,title:n,right:r,children:i,colorScheme:o,isFirst:s,style:a}){let c=o==="light"?Yv:Jv,l=o==="light"?"rgba(0,0,0,0.1)":"rgba(255,255,255,0.1)";return fs.default.createElement("div",{style:{flex:e?"1 1 0":"0",display:"flex",flexDirection:"column",...a}},fs.default.createElement("div",{onClick:()=>t?.(!e),style:{cursor:"default",fontSize:"12px",padding:"4px 10px",display:"flex",alignItems:"center",...!s&&{borderTop:`1px solid ${l}`},...e&&{borderBottom:`1px solid ${l}`}}},t&&fs.default.createElement(aN,{expanded:e,style:{fontSize:c.ARROW_FONT_SIZE,marginRight:c.ARROW_MARGIN_RIGHT+1,color:c.ARROW_COLOR}}),fs.default.createElement("span",{style:{flex:"1 1 0",userSelect:"none"}},n),r),e&&i)}var St=(0,fs.forwardRef)(function(t,n){return fs.default.createElement("div",{style:{flex:"1 1 0",overflowY:"auto",overflowX:"hidden",display:"flex",flexDirection:"column",...t.style},...t,ref:n})});u();var Xv=Q(require("react"));function Bt({children:e,colorScheme:t,selected:n,style:r,variant:i,bordered:o=!0}){return Xv.default.createElement("div",{style:{borderBottom:o?`1px solid ${t==="light"?"rgb(223 223 223)":"rgb(29 29 29)"}`:void 0,fontSize:"12px",fontFamily:"Menlo, monospace",padding:"2px 12px 1px",display:"flex",alignItems:"center",background:i==="up"?"rgba(0,255,0,0.1)":i==="down"?"transparent":n?"rgb(59 130 246 / 15%)":void 0,...r}},Xv.default.createElement("span",{style:{fontFamily:"Menlo, monospace",fontSize:"11px",borderRadius:4,display:"inline-block"}},e))}function cN(e){return typeof e=="object"&&"resourceId"in e}function yV(e){return typeof e=="object"&&e!==null&&"type"in e&&e.type==="resource"&&"resourceId"in e&&typeof e.resourceId=="string"}function uN({showEvents:e,setShowEvents:t,colorScheme:n,activityEventsContainerRef:r,activityEventsManager:i}){let[o,s]=(0,On.useState)("all"),a=cN(o)?"resource":"all",c=Br(n),l=Gh(e?o:void 0,i);return On.default.createElement(bt,{open:e,setOpen:t,title:"Activity Events",colorScheme:n},On.default.createElement(St,{ref:r},On.default.createElement("div",{style:{padding:"4px 12px",display:"flex",gap:"4px"}},On.default.createElement("select",{name:"streamFilterType",value:a,style:{flex:"0 0 auto",height:"19px"},onChange:p=>{let d=p.target.value;s(d==="all"?"all":{resourceId:""})}},On.default.createElement("option",{value:"all"},"All"),On.default.createElement("option",{value:"resource"},"Resource")),cN(o)&&On.default.createElement("input",{name:"resourceId",type:"text",placeholder:"Resource ID",value:o.resourceId,style:{flex:"1 1 auto",height:"19px",padding:"0px 4px",boxSizing:"border-box"},onChange:p=>s({...o,resourceId:p.target.value})})),l?.map((p,d)=>On.default.createElement(Bt,{key:d,colorScheme:n,style:{padding:"0px 12px 1px"}},On.default.createElement(dt,{data:p,theme:c}),a==="all"&&yV(p)&&On.default.createElement(me,{theme:c,onClick:()=>{s({resourceId:p.resourceId})}},"Watch this resource"))),!l&&On.default.createElement("div",{style:{padding:"12px",fontSize:"12px",display:"flex",flexDirection:"column",gap:"4px"}},On.default.createElement("span",null,"No activity events"))))}u();var yr=Q(require("react"));u();var ho=Q(require("react"));var lN=({name:e,data:t,direction:n})=>typeof e=="string"?ho.default.createElement("span",null,ho.default.createElement(ff,{name:e}),ho.default.createElement("span",null,": "),ho.default.createElement(Ta,{data:t})):n==="up"||n==="down"?ho.default.createElement("span",null,ho.default.createElement("span",{style:{background:n==="up"?"rgba(0,255,0,0.2)":"rgba(255,0,0,0.2)",width:12,height:12,borderRadius:2,display:"inline-flex",justifyContent:"center",alignItems:"center",marginRight:4,lineHeight:"12px"}},n==="up"?"\u2191":"\u2193"),ho.default.createElement(Ta,{data:t})):ho.default.createElement(Ta,{data:t});function pN({showEvents:e,setShowEvents:t,colorScheme:n,eventsContainerRef:r,connectionEvents:i,paused:o,onTogglePaused:s}){let a=Br(n);return yr.default.createElement(bt,{open:e,setOpen:t,title:"Events",colorScheme:n,right:yr.default.createElement(me,{theme:a,onClick:s},o?"Resume":"Pause")},yr.default.createElement(St,{ref:r},o&&yr.default.createElement("div",{style:{padding:"4px 12px",fontSize:"11px",opacity:.7}},"Event streaming paused"),i?.map((c,l)=>c.type==="stateChange"?yr.default.createElement(Bt,{key:l,colorScheme:n},"connection:"," ",yr.default.createElement("span",{style:{fontStyle:"italic"}},c.state.toLowerCase())):yr.default.createElement(Bt,{key:l,colorScheme:n,variant:c.type==="send"?"up":"down",style:{padding:"0px 12px 1px"}},yr.default.createElement(dt,{data:c.type==="error"?c.error:c.message,theme:a,nodeRenderer:({depth:p,name:d,data:m,isNonenumerable:y})=>{let S=c.type==="send"?"up":"down";return p===0?yr.default.createElement(lN,{direction:S,data:m}):yr.default.createElement(Qv,{direction:S,name:d,data:m,isNonenumerable:y})}}))),!i?.length&&yr.default.createElement("div",{style:{padding:"12px",fontSize:"12px",display:"flex",flexDirection:"column",gap:"4px"}},yr.default.createElement("span",null,"No recorded events"))))}u();var Y=Q(require("react"));u();var fN=Q(require("react"));function yo({children:e}){return fN.default.createElement("span",{style:{display:"flex",alignItems:"center",gap:"4px"}},e)}function dN({showGit:e,setShowGit:t,colorScheme:n,gitManager:r}){let i=Br(n),o=q(r.repos$),s=q(r.isInitialized$),a=q(r.repoFiles$),[c,l]=(0,Y.useState)(null),[p,d]=(0,Y.useState)(null),m=(0,Y.useRef)(null),[y,S]=(0,Y.useState)(""),[T,E]=(0,Y.useState)(!1),b=c?o.find(N=>N.id===c):null,f=c?a[c]:null,g=async N=>{m.current&&(m.current.close(),m.current=null,d(null),S(""),E(!1)),l(N),N&&!a[N]&&await r.fetchRepoFiles(N)},v=N=>{if(!c||!f)return;m.current&&m.current.close();let H=r.openEditingHandle(c,N,f.ref);m.current=H,d(N),E(!1),S("")},I=()=>{m.current&&(m.current.close(),m.current=null),d(null),S(""),E(!1)};(0,Y.useEffect)(()=>{let N=m.current;if(!N)return;let H=N.content$.subscribe(L=>{S(L)}),j=N.isInitialized$.subscribe(L=>{E(L)});return()=>{H(),j()}},[p]);let M=N=>{let H=m.current;H&&H.setState(N)},O=async N=>{c&&await r.fetchRepoFiles(c,N)},C=async()=>{if(!c||!f)return;let N=prompt("Enter file path (e.g., src/index.ts):");if(N)try{await r.patchFiles(c,{create:[{path:N,content:""}]},f.ref)}catch(H){alert(`Failed to create file: ${H}`)}},z=async N=>{if(!c||!f)return;let H=prompt(`Rename "${N}" to:`,N);if(!(!H||H===N))try{await r.patchFiles(c,{rename:[{oldPath:N,newPath:H}]},f.ref)}catch(j){alert(`Failed to rename file: ${j}`)}},F=async N=>{if(!(!c||!f||!confirm(`Delete "${N}"?`)))try{await r.patchFiles(c,{delete:[{path:N}]},f.ref),p===N&&I()}catch(j){alert(`Failed to delete file: ${j}`)}};return Y.default.createElement(bt,{open:e,setOpen:t,title:Y.default.createElement(yo,null,"Git Repos (",o.length,")",Y.default.createElement(mo,{type:s?"success":"error"})),colorScheme:n,right:Y.default.createElement("span",{style:{display:"flex",gap:"10px"}},Y.default.createElement(me,{theme:i,onClick:async()=>{try{await r.initRepo()}catch(N){console.error("[GitSection] Failed to create repo:",N)}}},"Init Repo"))},Y.default.createElement(St,null,Y.default.createElement("div",{style:{padding:"4px 12px",display:"flex",gap:"4px"}},Y.default.createElement("select",{name:"repoSelector",value:c??"",style:{flex:"1 1 auto",height:"19px",minWidth:0},onChange:N=>{let H=N.target.value;g(H||null)}},Y.default.createElement("option",{value:""},"Select a repo..."),o.map(N=>Y.default.createElement("option",{key:N.id,value:N.id},N.id))),c&&Y.default.createElement(me,{theme:i,onClick:()=>r.fetchRepoFiles(c)},"Refresh"),Y.default.createElement("label",{style:{display:"flex",alignItems:"center",gap:"4px",fontSize:"11px",whiteSpace:"nowrap"}},"[Include Content = ",r.includeContent?"true":"false","]")),b&&f&&Y.default.createElement(Y.default.Fragment,null,Y.default.createElement("div",{style:{padding:"4px 12px",display:"flex",gap:"8px",alignItems:"center",fontSize:"12px"}},Y.default.createElement("span",{style:{color:i.BASE_COLOR}},"Branch:"),f.branches.length>0?Y.default.createElement("select",{value:f.ref,style:{flex:"1 1 auto",height:"19px"},onChange:N=>O(N.target.value)},f.branches.map(N=>Y.default.createElement("option",{key:N.name,value:N.name},N.name))):Y.default.createElement("span",{style:{opacity:.6,fontStyle:"italic"}},f.ref||"No branches"),f.oid&&Y.default.createElement("span",{style:{fontFamily:"monospace",fontSize:"10px",opacity:.6},title:f.oid},f.oid.slice(0,7),f.fetchState==="refreshing"&&"\u2026"),Y.default.createElement(me,{theme:i,onClick:C,style:{fontSize:"10px",padding:"2px 6px"}},"+ Add File")),f.fetchState==="loading"&&Y.default.createElement("div",{style:{padding:"12px",fontSize:"12px"}},"Loading files..."),f.error&&Y.default.createElement("div",{style:{padding:"12px",fontSize:"12px",color:"#f44"}},"Error: ",f.error),f.fetchState!=="loading"&&!f.error&&f.files.length===0&&Y.default.createElement("div",{style:{padding:"12px",fontSize:"12px"}},"No files (empty repo)"),!p&&f.files.map((N,H)=>{let j=f.fileContents?.find(V=>V.path===N),L="";if(j)try{let V=atob(j.content);L=V.slice(0,40).replace(/\n/g," ").replace(/\s+/g," "),V.length>40&&(L+="\u2026")}catch{}return Y.default.createElement("div",{key:H,style:{padding:"2px 12px",display:"flex",justifyContent:"space-between",alignItems:"center",gap:"8px",borderBottom:`1px solid ${n==="light"?"rgb(223 223 223)":"rgb(29 29 29)"}`}},Y.default.createElement("span",{style:{fontFamily:"monospace",fontSize:"11px",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",minWidth:0,display:"flex",gap:"8px"},title:N},Y.default.createElement("span",null,N),L&&Y.default.createElement("span",{style:{opacity:.5}},L)),Y.default.createElement("span",{style:{display:"flex",gap:"4px",flexShrink:0}},Y.default.createElement(me,{theme:i,onClick:()=>v(N),style:{fontSize:"10px",padding:"2px 6px"}},"Edit"),Y.default.createElement(me,{theme:i,onClick:()=>z(N),style:{fontSize:"10px",padding:"2px 6px"}},"Rename"),Y.default.createElement(me,{theme:i,onClick:()=>F(N),style:{fontSize:"10px",padding:"2px 6px"}},"Delete")))}),p&&Y.default.createElement("div",{style:{padding:"8px 12px",borderTop:`1px solid ${i.DIVIDER_COLOR}`,flex:"1 1 auto",display:"flex",flexDirection:"column",minHeight:0}},Y.default.createElement("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"8px",flexShrink:0}},Y.default.createElement("span",{style:{fontFamily:"monospace",fontSize:"11px",fontWeight:"bold"}},p,!T&&Y.default.createElement("span",{style:{opacity:.5,marginLeft:"8px"}},"Loading...")),Y.default.createElement(me,{theme:i,onClick:I,style:{fontSize:"10px",padding:"2px 6px"}},"Close")),Y.default.createElement("textarea",{value:y,onChange:N=>M(N.target.value),disabled:!T,style:{width:"100%",flex:"1 1 auto",minHeight:"100px",fontFamily:"monospace",fontSize:"11px",padding:"8px",border:`1px solid ${i.DIVIDER_COLOR}`,borderRadius:"4px",backgroundColor:i.ROW_BACKGROUND,color:i.BASE_COLOR,resize:"none",boxSizing:"border-box"}}))),o.length===0&&Y.default.createElement("div",{style:{padding:"12px",fontSize:"12px",display:"flex",flexDirection:"column",gap:"4px"}},Y.default.createElement("span",null,"No git repos"))))}u();var ie=Q(require("react"));u();function ou(e){return e.map(t=>typeof t=="object"?`:${Zv(t.id.toString(),8,"middle")}`:t).map((t,n)=>n===0||typeof t=="string"&&t.startsWith(":")?t:`.${t}`).join("")}function Zv(e,t,n="end"){if(e.length<=t)return e;switch(n){case"start":return`\u2026${e.slice(e.length-t)}`;case"middle":{let r=Math.floor(t/2);return`${e.slice(0,r)}\u2026${e.slice(e.length-r)}`}case"end":return`${e.slice(0,t)}\u2026`}}function su(){return new Promise((e,t)=>{let n=document.createElement("input");n.type="file",n.onchange=()=>{let r=n.files?.[0];if(r){let i=new FileReader;i.onload=()=>{let o=i.result,s=new File([o],r.name,{type:r.type});e(s)},i.onerror=()=>{t(new Error("Failed to read file"))},i.readAsArrayBuffer(r)}},n.click()})}var Wv="noya-multiplayer-history-";function mN({showHistory:e,setShowHistory:t,colorScheme:n,historySnapshot:r,multiplayerStateManager:i}){let o=(0,ie.useRef)(null),s=Br(n),a=Hh(n);return(0,ie.useEffect)(()=>{o.current&&(o.current.scrollTop=o.current.scrollHeight)},[r]),(0,ie.useEffect)(()=>{if(!o.current)return;let c=o.current.querySelector(`#${Wv}${r.historyIndex}`);c&&c.scrollIntoView({block:"nearest",inline:"nearest"})},[r.historyIndex]),ie.default.createElement(bt,{open:e,setOpen:t,title:"History",colorScheme:n,right:ie.default.createElement("span",{style:{display:"flex",gap:"4px"}},ie.default.createElement(me,{disabled:!r.canUndo,theme:s,onClick:()=>{i.undo()}},ie.default.createElement("span",{style:{width:"12px",height:"12px"}},ie.default.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 20 20"},ie.default.createElement("path",{fill:"currentColor",d:"M12 5H7V2L1 6l6 4V7h5c2.2 0 4 1.8 4 4s-1.8 4-4 4H7v2h5c3.3 0 6-2.7 6-6s-2.7-6-6-6"})))),ie.default.createElement(me,{disabled:!r.canRedo,theme:s,onClick:()=>{i.redo()}},ie.default.createElement("span",{style:{width:"12px",height:"12px"}},ie.default.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 20 20"},ie.default.createElement("path",{fill:"currentColor",d:"M8 5h5V2l6 4l-6 4V7H8c-2.2 0-4 1.8-4 4s1.8 4 4 4h5v2H8c-3.3 0-6-2.7-6-6s2.7-6 6-6"})))))},ie.default.createElement(St,{ref:o},ie.default.createElement("div",{id:`${Wv}0`,style:{borderBottom:`1px solid ${a}`,fontSize:"12px",fontFamily:"Menlo, monospace",padding:"2px 12px 1px",display:"flex",alignItems:"center",background:r.historyIndex===0?"rgb(59 130 246 / 15%)":void 0}},ie.default.createElement("span",{style:{fontFamily:"Menlo, monospace",fontSize:"11px",borderRadius:4,display:"inline-block"}},"Initial state")),r.history.map((c,l)=>{let p=c.metadata,{id:d,name:m,timestamp:y,...S}=p;return ie.default.createElement("div",{id:`${Wv}${l+1}`,key:l,style:{padding:"0px 12px 1px",borderBottom:`1px solid ${a}`,background:l+1===r.historyIndex?"rgb(59 130 246 / 15%)":void 0}},typeof m=="string"&&ie.default.createElement("pre",{style:{fontSize:"11px",display:"flex",flexWrap:"wrap",margin:0}},c.metadata.name,Object.keys(S).length>0&&ie.default.createElement(dt,{data:S,theme:s})),c.redoPatches?.map((T,E)=>ie.default.createElement("pre",{key:E,style:{fontSize:"11px",display:"flex",flexWrap:"wrap",margin:0}},T.op==="add"&&ie.default.createElement(ie.default.Fragment,null,ie.default.createElement("span",{style:{fontStyle:"italic"}},ou(T.path))," = ",ie.default.createElement(dt,{data:T.value,theme:s})),T.op==="replace"&&ie.default.createElement(ie.default.Fragment,null,ie.default.createElement("span",{style:{fontStyle:"italic"}},ou(T.path))," = ",ie.default.createElement(dt,{data:T.value,theme:s})),T.op==="remove"&&ie.default.createElement(ie.default.Fragment,null,ie.default.createElement("span",{style:{color:s.OBJECT_VALUE_STRING_COLOR}},"delete"," "),ie.default.createElement("span",{style:{fontStyle:"italic"}},ou(T.path))),T.op==="move"&&ie.default.createElement(ie.default.Fragment,null,ie.default.createElement("span",{style:{fontStyle:"italic"}},ou(T.from))," -> ",ie.default.createElement("span",{style:{fontStyle:"italic"}},ou(T.path))))))})))}u();var bn=Q(require("react"));var gV={error:"#f87171",warn:"#facc15",log:"#9ca3af"};function bV(e){return new Date(e).toLocaleTimeString()}function eI({showLogs:e,setShowLogs:t,colorScheme:n,logs:r,containerRef:i,paused:o,onTogglePaused:s,title:a="Server Script Logs"}){let c=Br(n);return bn.default.createElement(bt,{open:e,setOpen:t,title:a,colorScheme:n,right:bn.default.createElement(me,{theme:c,onClick:s},o?"Resume":"Pause")},bn.default.createElement(St,{ref:i},o&&bn.default.createElement("div",{style:{padding:"4px 12px",fontSize:"11px",opacity:.7}},"Log streaming paused"),r.map(l=>bn.default.createElement(Bt,{key:l.id,colorScheme:n},bn.default.createElement("div",{style:{display:"flex",gap:"6px",alignItems:"center",fontSize:"10px",color:"inherit",marginBottom:l.values.length?"4px":0,textTransform:"uppercase"}},bn.default.createElement("span",null,bV(l.timestamp)),bn.default.createElement("span",{style:{color:gV[l.level]}},l.level),(l.origin||l.target||l.mode)&&bn.default.createElement("span",{style:{fontFamily:"monospace",textTransform:"none",fontSize:"10px",opacity:.75}},[l.origin??l.target,l.mode].filter(Boolean).join(" / ")),bn.default.createElement("span",{style:{fontFamily:"monospace",textTransform:"none",fontSize:"10px"}},l.scriptId)),bn.default.createElement("div",{style:{display:"flex",flexDirection:"column",gap:"4px"}},l.values.length>0?l.values.map((p,d)=>bn.default.createElement(dt,{key:d,data:p,theme:c})):bn.default.createElement("span",{style:{fontSize:"11px",opacity:.7}},"No data")))),!r?.length&&bn.default.createElement("div",{style:{padding:"12px",fontSize:"12px",display:"flex",flexDirection:"column",gap:"4px"}},bn.default.createElement("span",null,"No logs received"))))}u();u();u();var SV=(()=>{let e=new Uint32Array(256);for(let t=0;t<256;t++){let n=t;for(let r=0;r<8;r++)n=n&1?3988292384^n>>>1:n>>>1;e[t]=n>>>0}return e})();function hN(e){let t=4294967295;for(let n=0;n<e.length;n++)t=SV[(t^e[n])&255]^t>>>8;return(t^4294967295)>>>0}u();var qh=e=>e,yN=e=>e;function xV(e,t){return e.type==="bytes"?typeof e.length=="function"?e.length(t):e.length:e.type==="u8"?1:e.type==="u16"?2:4}function au(e,t){let n=0,r={...t};for(let c of e)n+=xV(c,r);let i=new Uint8Array(n),o=new DataView(i.buffer),s=0,a=t;for(let c of e){if(c.type==="bytes"){let p=a[c.name];i.set(p,s),s+=p.length;continue}let l=Number(a[c.name])>>>0;c.type==="u8"?(o.setUint8(s,l),s+=1):c.type==="u16"?(o.setUint16(s,l,!0),s+=2):(o.setUint32(s,l,!0),s+=4)}return i}function Vh(e,t,n){let r={},i=t;for(let o of n)if(o.type==="bytes"){let s=typeof o.length=="function"?o.length(r):o.length,a=new Uint8Array(e.buffer,e.byteOffset+i,s);r[o.name]=new Uint8Array(a),i+=s}else o.type==="u8"?(r[o.name]=e.getUint8(i),i+=1):o.type==="u16"?(r[o.name]=e.getUint16(i,!0),i+=2):(r[o.name]=e.getUint32(i,!0),i+=4);return{value:r,offset:i}}var TV=new TextEncoder;function Qh(e){return TV.encode(e)}function tI(e=new Date){let t=e.getHours()<<11|e.getMinutes()<<5|Math.floor(e.getSeconds()/2),n=e.getFullYear()-1980<<9|e.getMonth()+1<<5|e.getDate();return{time:t,date:n}}var Oi={LocalFile:67324752,CentralFile:33639248,EOCD:101010256},ds=yN({LocalFile:qh([{name:"signature",type:"u32"},{name:"versionNeeded",type:"u16"},{name:"flags",type:"u16"},{name:"method",type:"u16"},{name:"time",type:"u16"},{name:"date",type:"u16"},{name:"crc32",type:"u32"},{name:"compSize",type:"u32"},{name:"uncompSize",type:"u32"},{name:"nameLen",type:"u16"},{name:"extraLen",type:"u16"},{name:"name",type:"bytes",length:e=>e.nameLen},{name:"extra",type:"bytes",length:e=>e.extraLen}]),CentralFile:qh([{name:"signature",type:"u32"},{name:"versionMadeBy",type:"u16"},{name:"versionNeeded",type:"u16"},{name:"flags",type:"u16"},{name:"method",type:"u16"},{name:"time",type:"u16"},{name:"date",type:"u16"},{name:"crc32",type:"u32"},{name:"compSize",type:"u32"},{name:"uncompSize",type:"u32"},{name:"nameLen",type:"u16"},{name:"extraLen",type:"u16"},{name:"commentLen",type:"u16"},{name:"diskStart",type:"u16"},{name:"intAttrs",type:"u16"},{name:"extAttrs",type:"u32"},{name:"localHeaderOffset",type:"u32"},{name:"name",type:"bytes",length:e=>e.nameLen},{name:"extra",type:"bytes",length:e=>e.extraLen},{name:"comment",type:"bytes",length:e=>e.commentLen}]),EOCD:qh([{name:"signature",type:"u32"},{name:"diskNum",type:"u16"},{name:"cdStartDisk",type:"u16"},{name:"cdRecordsOnDisk",type:"u16"},{name:"cdRecordsTotal",type:"u16"},{name:"cdSize",type:"u32"},{name:"cdOffset",type:"u32"},{name:"commentLen",type:"u16"},{name:"comment",type:"bytes",length:e=>e.commentLen}])});function nI(e,t,n){if(e!==t)throw new Error(`Invalid signature for ${n}: 0x${e.toString(16)}`)}var df=class e{_chunks=[];_offset=0;_files=[];_rootPrefix="";_rootDirAdded=!1;constructor(t={}){if(t.root){let n=t.root.replace(/^\/+|\/+$/g,"");n&&(this._rootPrefix=n+"/")}}_push(...t){for(let n of t)this._chunks.push(n),this._offset+=n.length}_withRoot(t){return this._rootPrefix&&!t.startsWith(this._rootPrefix)?this._rootPrefix+t.replace(/^\/+/,""):t}_ensureRootDir(t=new Date){if(!this._rootPrefix||this._rootDirAdded)return;this._rootDirAdded=!0;let n=this._rootPrefix,r=Qh(n),{time:i,date:o}=tI(t),s=au(ds.LocalFile,{signature:Oi.LocalFile,versionNeeded:20,flags:2048,method:0,time:i,date:o,crc32:0,compSize:0,uncompSize:0,nameLen:r.length,extraLen:0,name:r,extra:new Uint8Array(0)}),a=this._offset;this._push(s),this._files.push({nameBytes:r,crc:0,compSize:0,uncompSize:0,method:0,time:i,dosDate:o,localHeaderOffset:a,externalAttrs:16})}addFile(t,n,r={}){let{date:i=new Date}=r;this._ensureRootDir(i);let o=gN(n),s=this._withRoot(t),a=Qh(s),{time:c,date:l}=tI(i),p=hN(o),d=o.length>>>0,m=o.length>>>0,y=this._offset,S=au(ds.LocalFile,{signature:Oi.LocalFile,versionNeeded:20,flags:2048,method:0,time:c,date:l,crc32:p,compSize:d,uncompSize:m,nameLen:a.length,extraLen:0,name:a,extra:new Uint8Array(0)});this._push(S,o),this._files.push({nameBytes:a,crc:p,compSize:d,uncompSize:m,method:0,time:c,dosDate:l,localHeaderOffset:y,externalAttrs:0})}addDirectory(t,n={}){let{date:r=new Date}=n;this._ensureRootDir(r);let i=t.endsWith("/")?t:t+"/",o=this._withRoot(i),s=Qh(o),{time:a,date:c}=tI(r),l=au(ds.LocalFile,{signature:Oi.LocalFile,versionNeeded:20,flags:2048,method:0,time:a,date:c,crc32:0,compSize:0,uncompSize:0,nameLen:s.length,extraLen:0,name:s,extra:new Uint8Array(0)}),p=this._offset;this._push(l),this._files.push({nameBytes:s,crc:0,compSize:0,uncompSize:0,method:0,time:a,dosDate:c,localHeaderOffset:p,externalAttrs:16})}finish(){let t=this._offset;for(let s of this._files){let a=au(ds.CentralFile,{signature:Oi.CentralFile,versionMadeBy:20,versionNeeded:20,flags:2048,method:s.method,time:s.time,date:s.dosDate,crc32:s.crc,compSize:s.compSize,uncompSize:s.uncompSize,nameLen:s.nameBytes.length,extraLen:0,commentLen:0,diskStart:0,intAttrs:0,extAttrs:s.externalAttrs,localHeaderOffset:s.localHeaderOffset,name:s.nameBytes,extra:new Uint8Array(0),comment:new Uint8Array(0)});this._push(a)}let n=this._offset-t,r=au(ds.EOCD,{signature:Oi.EOCD,diskNum:0,cdStartDisk:0,cdRecordsOnDisk:this._files.length,cdRecordsTotal:this._files.length,cdSize:n,cdOffset:t,commentLen:0,comment:new Uint8Array(0)});this._push(r);let i=new Uint8Array(this._offset),o=0;for(let s of this._chunks)i.set(s,o),o+=s.length;return i}static create(t,n={}){let r=new e(n);for(let[i,o]of Object.entries(t))i.endsWith("/")?r.addDirectory(i):r.addFile(i,o);return r.finish()}static parse(t){let n=gN(t),r=new DataView(n.buffer,n.byteOffset,n.byteLength),i=vV(n),{value:o}=Vh(r,i,ds.EOCD);if(nI(o.signature,Oi.EOCD,"EOCD"),o.commentLen!==0)throw new Error("Unsupported: EOCD comment");if(o.diskNum!==0||o.cdStartDisk!==0)throw new Error("Unsupported: multi-disk");let s=[],a=o.cdOffset;for(let l=0;l<o.cdRecordsTotal;l++){let{value:p,offset:d}=Vh(r,a,ds.CentralFile);nI(p.signature,Oi.CentralFile,"Central Directory");let m=new TextDecoder().decode(p.name),y=(p.extAttrs&16)!==0||m.endsWith("/");if(p.extraLen!==0||p.commentLen!==0)throw new Error("Unsupported: extra/comment in central dir");s.push({name:m,isDirectory:y,crc32:p.crc32>>>0,size:p.uncompSize>>>0,compSize:p.compSize>>>0,time:p.time>>>0,dosDate:p.date>>>0,localHeaderOffset:p.localHeaderOffset>>>0}),a=d}let c=[];for(let l of s){let{value:p,offset:d}=Vh(r,l.localHeaderOffset,ds.LocalFile);if(nI(p.signature,Oi.LocalFile,"Local File"),p.flags!==2048)throw new Error("Unsupported: flags (expect UTF-8 only)");if(p.method!==0)throw new Error("Unsupported: compression (expect store only)");if(p.extraLen!==0)throw new Error("Unsupported: extra fields in local header");let m=d,y=m+p.compSize,S=l.isDirectory?new Uint8Array(0):new Uint8Array(n.subarray(m,y));c.push({...l,data:S})}return c}static extract(t){let n=this.parse(t),r={};for(let i of n)i.isDirectory||(r[i.name]=i.data);return r}};function gN(e){return typeof e=="string"?Qh(e):e instanceof Uint8Array?e:new Uint8Array(e)}function vV(e){let t=new DataView(e.buffer,e.byteOffset,e.byteLength),n=22;if(e.length>=n){let i=e.length-n;if(t.getUint32(i,!0)===Oi.EOCD)return i}let r=Math.max(0,e.length-1024);for(let i=e.length-4;i>=r;i--)if(t.getUint32(i,!0)===Oi.EOCD)return i;throw new Error("EOCD not found")}async function bN(e){let t=await Promise.all(e.map(async n=>{let r=n.url,o=await(await fetch(r)).arrayBuffer();return[n.id,o]}));return Object.fromEntries(t)}async function iI(e){let{multiplayerStateManager:t,assetManager:n}=e,r=await bN(n.assets$.get());return SN({state:t.optimisticState$.get(),schema:t.schema,assets:n.assets$.get(),assetMap:r})}function SN({state:e,schema:t,assets:n,assetMap:r}){let i=new df;if(i.addFile("state.json",JSON.stringify(e,null,2)),t){let o=Io(t);i.addFile("schema.json",JSON.stringify(o,null,2))}n.length&&i.addFile("assets.json",JSON.stringify(n,null,2));for(let[o,s]of Object.entries(r))i.addFile(`assets/${o}`,s);return i.finish()}async function oI(e,t,{shouldAllowSchemaChange:n}={}){let{state:r,schema:i,assets:o,assetMap:s}=await xN(e);if(n&&t.options.schema&&i){let a=Nl(t.options.schema),c=Nl(i);if(a!==c&&!n({oldSchema:t.options.schema,newSchema:i}))throw new Error("Schema change not allowed")}o.length&&(await Promise.all(t.assetManager.assets$.get().map(a=>t.assetManager.delete(a.stableId))),await Promise.all(o.map(async a=>{await t.assetManager.create({data:s[a.id],contentType:a.contentType,stableId:a.stableId})}))),t.initialState=r,t.forceInit()}function xN(e){let t=df.extract(e),n=t["state.json"],r=t["schema.json"],i=t["assets.json"];if(!n)throw new Error("State file not found");let o=JSON.parse(new TextDecoder().decode(n)),s;if(r){let l=JSON.parse(new TextDecoder().decode(r));s=Eo(l)}let a=[],c={};if(i){a=JSON.parse(new TextDecoder().decode(i));for(let l of a){let p=t[`assets/${l.id}`];if(!p)throw new Error(`Asset ${l.id} not found`);c[l.id]=p}}return{state:o,schema:s,assets:a,assetMap:c}}function rI(e,t){switch(typeof e){case"object":return e===null?e:Array.isArray(e)?e.map(n=>rI(n,t)):Object.fromEntries(Object.entries(e).map(([n,r])=>[n,rI(r,t)]));case"string":return t[e]??e;default:return e}}u();var va=Q(require("react"));function sI({showInspector:e,setShowInspector:t,theme:n,anchor:r}){let i=r==="right",o=va.default.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",className:"size-6"},va.default.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"m5.25 4.5 7.5 7.5-7.5 7.5m6-15 7.5 7.5-7.5 7.5"})),s=va.default.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",className:"size-6"},va.default.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"m18.75 4.5-7.5 7.5 7.5 7.5m-6-15L5.25 12l7.5 7.5"}));return va.default.createElement("span",{role:"button",style:{flex:"0",appearance:"none",color:n.BASE_COLOR,border:"none",fontSize:"12px",whiteSpace:"nowrap",display:"inline-flex",alignItems:"center",justifyContent:"center",padding:"2px 0"},onClick:a=>{a.stopPropagation(),t(!e)}},e?"Hide Inspector":va.default.createElement("span",{style:{width:"12px",height:"12px"}},i?o:s))}u();var vN=Q(require("react")),TN=typeof window<"u"?window.localStorage:null;function Ft(e,t){let[n,r]=vN.default.useState(()=>{let o=TN?.getItem(e),s=t;if(o)try{s=JSON.parse(o)}catch(a){console.error("Error parsing localStorage value",a)}return s});return[n,o=>{TN?.setItem(e,JSON.stringify(o)),r(o)}]}u();var mf=Q(require("react"));function Yh(e){let[t,n]=mf.default.useState(!1),[r,i]=mf.default.useState(e??[]),o=mf.default.useCallback(()=>{n(s=>(s||i(e??[]),!s))},[e]);return mf.default.useEffect(()=>{t||i(e??[])},[e,t]),{paused:t,setPaused:n,togglePaused:o,visibleItems:r}}var hf=ea(function({noyaManager:t,colorScheme:n="light",anchor:r="right",unstyled:i=!1,advanced:o=!1,defaultCollapsed:s=!1,...a}){let{multiplayerStateManager:c,assetManager:l,userManager:p,secretManager:d,sharedConnectionDataManager:m,connectionEventManager:y,taskManager:S,ioManager:T,resourceManager:E,activityEventsManager:b,logManager:f,gitManager:g}=t,[v,I]=k.default.useState(!1),M=q(S.tasks$),O=q(T.inputs$),C=q(T.outputTransforms$);(0,k.useLayoutEffect)(()=>{I(!0)},[]);let z=k.default.useRef(null),F=k.default.useRef(null),N=k.default.useRef(null),H=k.default.useRef(null),[j,L]=Ft("noya-multiplayer-react-show-inspector",!s),[V,ne]=Ft("noya-multiplayer-react-show-events",!1),[it,xt]=Ft("noya-multiplayer-react-show-history",!1),[ti,Ia]=Ft("noya-multiplayer-react-show-users",!0),[uu,ry]=Ft("noya-multiplayer-react-show-user-details",!1),[FN,$N]=Ft("noya-multiplayer-react-show-data",!0),[KN,zN]=Ft("noya-multiplayer-react-show-tasks",!1),[HN,GN]=Ft("noya-multiplayer-react-show-shared",!1),[qN,VN]=Ft("noya-multiplayer-react-show-assets",!1),[QN,YN]=Ft("noya-multiplayer-react-show-resources",!1),[JN,XN]=Ft("noya-multiplayer-react-show-secrets",!1),[ZN,WN]=Ft("noya-multiplayer-react-show-inputs",!1),[ek,tk]=Ft("noya-multiplayer-react-show-output-transforms",!1),[nk,rk]=Ft("noya-multiplayer-react-show-activity-events",!1),[iy,ik]=Ft("noya-multiplayer-react-show-server-logs",!1),[oy,ok]=Ft("noya-multiplayer-react-show-server-simulation-logs",!1),[sk,ak]=Ft("noya-multiplayer-react-show-git",!1),[ck,uk]=Ft("noya-multiplayer-react-show-simulation",!1),lk=q(y.events$),{visibleItems:dI,paused:pk,togglePaused:fk}=Yh(lk);(0,k.useEffect)(()=>{z.current&&(z.current.scrollTop=z.current.scrollHeight)},[dI]);let dk=q(f.logs$),{visibleItems:mI,paused:mk,togglePaused:hk}=Yh(dk),yk=q(c.serverSimulationLogs$),{visibleItems:sy,paused:gk,togglePaused:bk}=Yh(yk);(0,k.useEffect)(()=>{iy&&N.current&&(N.current.scrollTop=N.current.scrollHeight)},[iy,mI]),(0,k.useEffect)(()=>{oy&&H.current&&(H.current.scrollTop=H.current.scrollHeight)},[oy,sy]);let Sk=q(c.isInitialized$),xk=q(m.data$),Tk=aI(c.sm),ay=q(l.assets$),cy=q(E.resources$),vk=q(E.isInitialized$),Ik=q(l.isInitialized$),hI=q(d.secrets$),Ek=q(d.isInitialized$),yI=q(p.allUsers$),wk=q(p.currentConnectionId$),gI=c.getServerSimulationDiagnostics?.()??null,Mk=(gI?.simulateLocally??!1)||sy.length>0,Ok=q(c.optimisticState$),Ak=q(T.inputsInitialized$),Rk=q(T.outputTransformsInitialized$),Ie=Br(n),bI=Hh(n),SI={position:"fixed",top:12,...r.includes("right")?{right:12}:{left:12},bottom:12,width:400,background:n==="light"?"rgba(255,255,255,0.95)":"rgba(0,0,0,0.95)",backdropFilter:"blur(48px)",border:`1px solid ${bI}`,borderRadius:4,display:"flex",flexDirection:"column",color:Ie.BASE_COLOR,overflow:"hidden",zIndex:9999,lineHeight:"13px"},Pk=(0,k.useCallback)(async()=>{let G=await iI(t);MA(new Blob([G]),"state.zip")},[t]),Ck=(0,k.useCallback)(async()=>{let $t=await(await su()).arrayBuffer();oI($t,t,{shouldAllowSchemaChange:()=>confirm("The imported state uses a different schema than the schema this app expects. Do you want to continue?")})},[t]);return v?j?k.default.createElement("div",{...a,style:{...!i&&SI,...a.style}},k.default.createElement(bt,{isFirst:!0,open:ti,setOpen:Ia,title:"Users",colorScheme:n,style:{flex:"0 0 auto",maxHeight:"50%",overflowY:"auto"},right:k.default.createElement("span",{style:{display:"flex",gap:"10px"}},k.default.createElement(me,{theme:Ie,onClick:()=>ry(!uu)},"Toggle details"),k.default.createElement(sI,{showInspector:j,setShowInspector:L,theme:Ie,anchor:r}))},k.default.createElement(St,{style:{flex:"0 0 auto"}},yI?.filter(G=>uu||!G.inactive).map((G,$t,Nk)=>k.default.createElement(Bt,{key:G.connectionId,colorScheme:n,variant:G.connectionId===wk?"up":void 0,bordered:$t!==Nk.length-1,style:{opacity:G.inactive?.5:1}},G.image&&k.default.createElement("img",{src:G.image,alt:G.name,style:{width:"13px",height:"13px",borderRadius:"50%",marginRight:"4px",display:"inline-block",position:"relative",background:bI,verticalAlign:"middle"}}),uu?k.default.createElement(dt,{data:G,theme:Ie}):G.name)),!yI&&k.default.createElement("div",{style:{padding:"12px",fontSize:"12px",display:"flex",flexDirection:"column",gap:"4px"}},k.default.createElement("span",null,"No connected users")))),k.default.createElement(bt,{title:k.default.createElement(yo,null,"Data",k.default.createElement(mo,{type:Sk?"success":"error"})),colorScheme:n,setOpen:$N,open:FN,right:k.default.createElement("span",{style:{display:"flex",gap:"12px"}},k.default.createElement(me,{theme:Ie,onClick:Ck},"Import"),k.default.createElement(me,{theme:Ie,onClick:Pk},"Export"),k.default.createElement(me,{theme:Ie,onClick:()=>{t.forceInit()}},"Reset"))},k.default.createElement(St,null,k.default.createElement(Bt,{colorScheme:n},k.default.createElement(dt,{name:c.schema?"state":void 0,data:Ok,theme:Ie})),c.schema&&k.default.createElement(Bt,{colorScheme:n},k.default.createElement(dt,{name:"schema",data:c.schema,theme:Ie})))),k.default.createElement(mN,{showHistory:it,setShowHistory:xt,colorScheme:n,historySnapshot:Tk,multiplayerStateManager:c}),k.default.createElement(bt,{open:qN,setOpen:VN,title:k.default.createElement(yo,null,"Assets (",ay.length,")",k.default.createElement(mo,{type:Ik?"success":"error"})),colorScheme:n,right:k.default.createElement("span",{style:{display:"flex",gap:"10px"}},k.default.createElement(me,{theme:Ie,onClick:async()=>{confirm("Are you sure you want to delete all assets?")&&await Promise.all(ay.map($t=>l.delete($t.id)))}},"Delete all"),k.default.createElement(me,{theme:Ie,onClick:()=>{console.info("[StateInspector] Reloading assets",t.id),l.fetch()}},"Reload"),k.default.createElement(me,{theme:Ie,onClick:async()=>{let G=await su();l.create(G)}},"Upload"),k.default.createElement(me,{theme:Ie,onClick:async()=>{let G=await su();l.create({data:new Uint8Array(await G.arrayBuffer()),contentType:G.type,mode:"mutable"})}},"Upload Mutable"))},k.default.createElement(St,null,ay.map(G=>k.default.createElement(Bt,{key:G.id,colorScheme:n},k.default.createElement(dt,{name:G.id,data:IV(G),theme:Ie}),k.default.createElement("div",{style:{display:"flex",gap:"4px"}},G.mode==="mutable"&&k.default.createElement(me,{theme:Ie,onClick:async()=>{let $t=await su();l.update(G.id,{data:new Uint8Array(await $t.arrayBuffer()),contentType:$t.type})}},"Replace"),k.default.createElement(me,{theme:Ie,onClick:()=>l.delete(G.id)},"Delete")))))),o&&k.default.createElement(bt,{title:k.default.createElement(yo,null,"Resources (",cy.length,")",k.default.createElement(mo,{type:vk?"success":"error"})),colorScheme:n,open:QN,setOpen:YN,right:k.default.createElement("span",{style:{display:"flex",gap:"10px"}},k.default.createElement(me,{theme:Ie,onClick:async()=>{confirm("Are you sure you want to delete all resources?")&&await E.deleteResource(cy.map($t=>({id:$t.id})))}},"Delete all"),k.default.createElement(me,{theme:Ie,onClick:async()=>{let G=prompt("Enter directory path")||te();await E.createResource({type:"directory",path:G})}},"Create Directory"),k.default.createElement(me,{theme:Ie,onClick:async()=>{let G=await su();E.createResource({type:"asset",path:G.name||te(),asset:{content:en.encode(await G.arrayBuffer()),contentType:G.type,encoding:"base64"}})}},"Create Asset"))},k.default.createElement(St,null,cy?.map(G=>k.default.createElement(Bt,{key:G.id,colorScheme:n},k.default.createElement(dt,{name:G.path,data:G,theme:Ie}),k.default.createElement("div",{style:{display:"flex",gap:"4px"}},k.default.createElement(me,{theme:Ie,onClick:()=>E.deleteResource({id:G.id})},"Delete"),k.default.createElement(me,{theme:Ie,onClick:()=>{let $t=prompt("Enter new path",G.path);$t&&E.updateResource({id:G.id,path:$t})}},"Rename")))))),o&&k.default.createElement(bt,{title:k.default.createElement(yo,null,"Secrets (",hI.length,")",k.default.createElement(mo,{type:Ek?"success":"error"})),colorScheme:n,open:JN,setOpen:XN,right:k.default.createElement("span",{style:{display:"flex",gap:"10px"}},k.default.createElement(me,{theme:Ie,onClick:()=>{d.fetchSecrets()}},"Refresh"),k.default.createElement(me,{theme:Ie,onClick:()=>{let G=prompt("Enter secret name");if(!G)return;let $t=prompt("Enter secret value");$t&&d.createSecret(null,G,$t)}},"Create"))},k.default.createElement(St,null,hI.map(G=>k.default.createElement(Bt,{key:G.id,colorScheme:n},k.default.createElement(dt,{data:G,theme:Ie}),k.default.createElement(me,{theme:Ie,onClick:()=>d.deleteSecret(G.id)},"Delete"))))),o&&k.default.createElement(dN,{showGit:sk,setShowGit:ak,colorScheme:n,gitManager:g}),o&&k.default.createElement(bt,{open:ZN,setOpen:WN,title:k.default.createElement(yo,null,"Inputs (",O.length,")",k.default.createElement(mo,{type:Ak?"success":"error"})),colorScheme:n},k.default.createElement(St,null,O?.map(G=>k.default.createElement(Bt,{key:G.id,colorScheme:n},k.default.createElement(dt,{data:G,theme:Ie}))),!O?.length&&k.default.createElement("div",{style:{padding:"12px",fontSize:"12px",display:"flex",flexDirection:"column",gap:"4px"}},k.default.createElement("span",null,"No inputs")))),o&&k.default.createElement(bt,{open:ek,setOpen:tk,title:k.default.createElement(yo,null,"Output Transforms (",C.length,")",k.default.createElement(mo,{type:Rk?"success":"error"})),colorScheme:n},k.default.createElement(St,null,C?.map(G=>k.default.createElement(Bt,{key:G.id,colorScheme:n},k.default.createElement(dt,{data:G,theme:Ie}))),!C?.length&&k.default.createElement("div",{style:{padding:"12px",fontSize:"12px",display:"flex",flexDirection:"column",gap:"4px"}},k.default.createElement("span",null,"No output transforms")))),o&&k.default.createElement(bt,{title:"Tasks",colorScheme:n,open:KN,setOpen:zN},k.default.createElement(St,null,M?.map(G=>k.default.createElement(Bt,{key:G.id,colorScheme:n,style:{backgroundColor:G.status==="done"?"rgba(0,255,0,0.2)":G.status==="error"?"rgba(255,0,0,0.2)":void 0}},k.default.createElement(dt,{name:G.name,data:G.payload,theme:Ie}))))),k.default.createElement(bt,{open:HN,setOpen:GN,title:"Shared Connection Data",colorScheme:n},k.default.createElement(St,null,Object.entries(xk).map(([G,$t])=>k.default.createElement(Bt,{key:G,colorScheme:n},k.default.createElement(dt,{name:G,data:$t,theme:Ie,expandLevel:10}))))),k.default.createElement(eI,{colorScheme:n,showLogs:iy,setShowLogs:ik,logs:mI,paused:mk,onTogglePaused:hk,containerRef:N}),Mk&&k.default.createElement(eI,{title:"Server Script Simulation Logs",colorScheme:n,showLogs:oy,setShowLogs:ok,logs:sy,paused:gk,onTogglePaused:bk,containerRef:H}),k.default.createElement(bt,{open:ck,setOpen:uk,title:"Server Simulation",colorScheme:n},k.default.createElement(St,null,k.default.createElement(Bt,{colorScheme:n},k.default.createElement(dt,{name:"status",data:gI??{simulateLocally:!1,simulatorActive:!1,clockSkewMs:0,invocations:[],pendingPredictions:[]},theme:Ie,expandLevel:2})))),o&&k.default.createElement(uN,{colorScheme:n,activityEventsContainerRef:F,showEvents:nk,setShowEvents:rk,activityEventsManager:b}),k.default.createElement(pN,{connectionEvents:dI,paused:pk,onTogglePaused:fk,colorScheme:n,eventsContainerRef:z,showEvents:V,setShowEvents:ne})):k.default.createElement("div",{...a,style:{...SI,padding:"4px 10px",width:void 0,...r.includes("bottom")?{bottom:12,top:void 0}:{bottom:void 0}},onClick:()=>L(!0)},k.default.createElement(sI,{showInspector:j,setShowInspector:L,theme:Ie,anchor:r})):null}),IV=Ww(e=>e.url.startsWith("data:")||e.url.startsWith("blob:")?{...e,url:Zv(e.url,40)}:e);function EV(){let e=document.createElement("div");e.id="noya-multiplayer-react-inspector-host";let t=e.attachShadow({mode:"open"}),n=document.createElement("div");return t.appendChild(n),{host:e,container:n}}function Jh(){let{host:e,container:t}=EV(),n=(0,IN.createRoot)(t);return document.body.appendChild(e),{root:n,unmount:()=>{document.body.removeChild(e)}}}function uI({noyaManager:e,disabled:t=!1,advanced:n=!1,defaultCollapsed:r=!1,colorScheme:i,anchor:o}){let[s,a]=cI.default.useState(null);ip(()=>{if(t)return;let{root:c,unmount:l}=Jh();return a(c),l},[t]),ip(()=>{s&&s.render(cI.default.createElement(hf,{colorScheme:i,anchor:o,noyaManager:e,advanced:n,defaultCollapsed:r}))},[e,o,i,s,n,r])}function wV(e,t){let[n]=(0,Xt.useState)(()=>new $s(e(),t)),r=(0,Xt.useCallback)(()=>n.getState(),[n]),i=(0,Xt.useSyncExternalStore)(n.addListener,r,r),o=(0,Xt.useCallback)((...s)=>{let[a,c]=s.length===1?[void 0,s[0]]:s;if(a===void 0){let l=n.performAction;c instanceof Function?l({run:c,undo:()=>i}):l({run:()=>c,undo:()=>i})}else{let l=n.performAction;c instanceof Function?l(a,{run:c,undo:()=>i}):l(a,{run:()=>c,undo:()=>i})}},[i,n]);return[i,o,n]}function aI(e){return(0,Xt.useSyncExternalStore)(e.historyEmittor.addListener,e.getHistorySnapshot,e.getHistorySnapshot)}function Xh(e,t){let n=q(e.multiplayerStateManager.optimisticState$),r=q(e.assetManager.assets$),i=(0,Xt.useMemo)(()=>({noyaManager:e,taskManager:e.taskManager,connectionEventManager:e.connectionEventManager,userManager:e.userManager,sharedConnectionDataManager:e.sharedConnectionDataManager,multiplayerStateManager:e.multiplayerStateManager,assetManager:e.assetManager,aiManager:e.aiManager,rpcManager:e.rpcManager,pipelineManager:e.pipelineManager,secretManager:e.secretManager,menuItemsManager:e.menuManager,createAsset:e.assetManager.create,deleteAsset:e.assetManager.delete,assets:r}),[e,r]),o=(0,Xt.useRef)(t?.sync);return(0,Xt.useEffect)(()=>{if(o.current)return o.current({noyaManager:e})},[e]),OV(e),uI({noyaManager:e,disabled:!t?.inspector,advanced:!0,...typeof t?.inspector=="object"&&t?.inspector}),[n,e.multiplayerStateManager.setState,i]}function MV(e,t){let{sync:n=np(),inspector:r,...i}=t??{},[o]=(0,Xt.useState)(()=>new Vi(e,i));return Xh(o,{sync:n,inspector:r})}function OV(e){let t=q(e.unrecoverableError);(0,Xt.useEffect)(()=>{if(!t)return;let n=document.createElement("div");n.id="noya-multiplayer-react-error-overlay",document.body.appendChild(n);let r=(0,EN.createRoot)(n);return r.render((0,Xt.createElement)(z1,{error:t})),()=>{r.unmount(),n.remove()}})}function wN(e){return{theme:"light",viewType:"editable",initialState:e,inspector:!1,isDemo:!1,access:void 0}}function MN(e,t){return t?hl({schema:t,value:e,defs:Er(t)}):e}function ON(e){let n=(e?.window??globalThis).location;if(!n)return null;let r=(n.hash||"").replace(/^#/,""),o=new URLSearchParams(r).get("data");if(!o)return null;try{return JSON.parse(o)}catch{return null}}function AV(e){e.clientId!==void 0&&KS(e.clientId),e.clientName!==void 0&&$S(e.clientName),e.clientImage!==void 0&&zS(e.clientImage)}function Zh(e,t,n){let r=e instanceof Function?e():e,i=ON(n)??wN(r);(n?.overrideExistingState||i.initialState===null)&&(i.initialState=r),i.initialState=MN(i.initialState,t),i.isDemo=i.isDemo??!1;let o=i.viewType==="editable"?"write":"read";return i.access=i.access??o,AV(i),i}function Wh(e){let{multiplayerUrl:t,offlineStorageKey:n,debug:r,policyAuthContext:i,serverScripts:o,git:s,parentOrigin:a,enableDocumentAI:c}=e??{};return AS()?nx({debug:r,policyAuthContext:i,origin:a,enableDocumentAI:c}):t?rx({url:t,debug:r}):n?XS({key:n,...o?{serverScripts:o}:{},...s?{git:s}:{}}):np()}function lI(...e){let[t,n]=typeof e[0]=="object"&&e[0]!==null&&"schema"in e[0]&&w.IsSchema(e[0].schema)?[null,e[0]]:[e[0],e[1]],[{multiplayerUrl:r,inspector:i,initialState:o,theme:s,viewType:a,userId:c,isDemo:l,access:p,parentOrigin:d,enableDocumentAI:m}]=(0,Ai.useState)(()=>Zh(t,n?.schema,{overrideExistingState:n?.overrideExistingState})),y=(0,Ai.useMemo)(()=>{if(!p&&c===void 0)return;let g={};return p&&(g.access=p),c!==void 0&&(g.id=c??null),g},[p,c]),S=(0,Ai.useMemo)(()=>Wh({multiplayerUrl:r,offlineStorageKey:n?.offlineStorageKey,debug:n?.debug,policyAuthContext:y,serverScripts:n?.serverScripts,git:n?.git,parentOrigin:d,enableDocumentAI:m}),[r,n?.offlineStorageKey,n?.debug,y,n?.serverScripts,n?.git,d,m]),[T]=(0,Ai.useState)(()=>new Vi(o,{...n,resourceUrlBase:n?.resourceUrlBase??d??(typeof globalThis.location>"u"||globalThis.location.origin==="null"?void 0:globalThis.location.origin)}));(0,Ai.useEffect)(()=>{c&&(T.sharedConnectionDataManager.setCurrentConnectionId(c),T.userManager.setCurrentConnectionId(c),T.userManager.setCurrentUserId(c))},[T,c]),(0,Ai.useEffect)(()=>{y&&T.multiplayerStateManager.setPolicyAuthContext(y)},[T,y]);let E=Xh(T,{inspector:n?.inspector??i,sync:n?.sync??S}),[,,b]=E,f=(0,Ai.useMemo)(()=>({...b,theme:s,viewType:a,isDemo:l}),[b,s,a,l]);return[E[0],E[1],f]}u();var AN=Q(require("react"));var Ri,ey;function RV(e){if(Ri)throw new Error("Noya has already been initialized. Call `useNoyaState` instead.");let{initialState:t,sync:n,inspector:r,theme:i,viewType:o,offlineStorageKey:s,multiplayerUrl:a,...c}=e??{},l=Zh(t??null,c?.schema,{overrideExistingState:c?.overrideExistingState}),p=l.access||l.userId!==void 0?{...l.access?{access:l.access}:{},...l.userId!==void 0?{id:l.userId??null}:{}}:void 0;Ri=new Vi(l.initialState,{...c,resourceUrlBase:c.resourceUrlBase??l.parentOrigin??(typeof globalThis.location>"u"||globalThis.location.origin==="null"?void 0:globalThis.location.origin)}),l.userId&&(Ri.sharedConnectionDataManager.setCurrentConnectionId(l.userId),Ri.userManager.setCurrentConnectionId(l.userId),Ri.userManager.setCurrentUserId(l.userId));let d=n??Wh({multiplayerUrl:a??l.multiplayerUrl,offlineStorageKey:s,debug:c?.debug,serverScripts:c?.serverScripts,git:c?.git,policyAuthContext:p,parentOrigin:l.parentOrigin,enableDocumentAI:l.enableDocumentAI});try{d({noyaManager:Ri})}catch(T){console.warn("Failed to activate sync",T)}let m=r??l.inspector,y=i??l.theme??"light",S=o??l.viewType??"editable";if(m){let{root:T}=Jh();T.render(AN.default.createElement(hf,{noyaManager:Ri,colorScheme:m===!0?y:m.colorScheme,anchor:m===!0?"bottom right":m.anchor,advanced:m===!0?!1:m.advanced,defaultCollapsed:m===!0?!1:m.defaultCollapsed}))}ey={sync:d,inspector:m,theme:y,viewType:S,userId:l.userId,isDemo:l.isDemo}}function pI(){if(!Ri||!ey)throw new Error("Noya has not been initialized. Call initializeNoya once before using Noya hooks.");return Ri}function fI(){return ey}function PV(){Ri=void 0,ey=void 0}function RN(e){switch(e.type){case"directory":return{path:e.path,type:"directory"};case"asset":return{path:e.path,type:"asset",assetId:e.assetId,asset:e.asset};case"file":return{path:e.path,type:"file",fileId:e.fileId};case"resource":return{path:e.path,type:"resource",fileId:e.fileId,resourceId:e.resourceId};default:throw new Error(`Unknown resource type: ${e.type}`)}}function PN({addedResources:e,modifiedResources:t,removedResources:n}){let r=e.map(RN),i=Array.from(new Map(r.map(c=>[c.path,c])).values()),o=t.map(c=>({id:c.id,...c.path!==void 0?{path:c.path}:{},...c.assetId!==void 0?{assetId:c.assetId}:{},...c.asset?{asset:c.asset}:{}}))??[],s=n.map(c=>({id:c.id})),a={};return i.length&&(a.create=i),o.length&&(a.update=o),s.length&&(a.delete=s),a}var ty=(0,Oe.createContext)(void 0);function CN(){let e=(0,Oe.useContext)(ty),t=fI();if(e)return e;if(t)return{noyaManager:pI(),theme:t.theme,viewType:t.viewType}}function xe(){let e=CN();if(e)return e;throw new Error("useNoyaStateContext must be used within a NoyaStateProvider")}function CV(){let{noyaManager:e}=xe();return e}function NV(){let{theme:e}=xe();return e}function kV(){let{viewType:e}=xe();return e}function DV(){let{noyaManager:e}=xe();return q(e.assetManager.assets$)}function UV(e){let{noyaManager:t}=xe(),n=(0,Oe.useMemo)(()=>t.assetManager.assets$.map(r=>r.find(i=>i.stableId===e)??r.find(i=>i.id===e)),[t,e]);return q(n)}function NN(){let{noyaManager:e}=xe(),t=q(e.assetManager.isInitialized$);return(0,Oe.useMemo)(()=>({create:e.assetManager.create,delete:e.assetManager.delete,isInitialized:t}),[e,t])}function ny(){let{noyaManager:e}=xe();return e.aiManager}function _V(){let{noyaManager:e}=xe();return e.secretManager}function jV(){let{noyaManager:e}=xe();return q(e.secretManager.secrets$)}function LV(e){let{noyaManager:t}=xe();return q(t.secretManager.secrets$,(0,Oe.useCallback)(n=>n.find(r=>r.name===e),[e]))}function BV(){let{noyaManager:e}=xe();return q(e.ioManager.inputs$)}function FV(){let{noyaManager:e}=xe();return q(e.ioManager.outputTransforms$)}function $V(){let{noyaManager:e}=xe();return e.ioManager}function KV(e){let{noyaManager:t}=xe(),n=vA(e);(0,Oe.useEffect)(()=>(t.publishingManager.setPublishingEnabled(!0),t.publishingManager.getFilesToPublish=n,()=>{t.publishingManager.setPublishingEnabled(!1),t.publishingManager.getFilesToPublish=void 0}),[t,n])}function kN(){let{noyaManager:e,viewType:t}=xe(),n=(0,Oe.useMemo)(()=>_.combine([...t==="preview"?[]:[e.multiplayerStateManager.isInitialized$],e.secretManager.isInitialized$,e.assetManager.isInitialized$],r=>r.every(i=>i)),[e,t]);return q(n)}function zV(){let{noyaManager:e}=xe();return e.pipelineManager}function HV(){let{noyaManager:e}=xe();return e.scriptEvaluatorManager}function cu(){let{noyaManager:e}=xe();return e.userManager}function GV(){let e=cu();return q(e?.allUsers$)}function qV(e){let t=cu();return q(t?.allUsers$,(0,Oe.useCallback)(n=>am(n,e),[e]))}function VV(){let e=cu();return q(e?.connectedUsers$)}function QV(){let e=cu();return q(e?.currentUser$)}function YV(){let e=cu();return q(e?.currentId$)}function JV(){let{noyaManager:e}=xe();return e.sharedConnectionDataManager}function XV(){let{noyaManager:e}=xe();return e.enqueueInput}function ZV(){let{noyaManager:e}=xe();return q(e.isProcessing$)}function DN(){let{noyaManager:e}=xe();return q(e.filePropertyManager.optimisticValue$)}function UN(){let{noyaManager:e}=xe();return e.filePropertyManager}function WV(){let e=DN(),t=UN();return[e,t.updateName]}function _N(){let{noyaManager:e}=xe();return e.resourceManager}function jN(){let{noyaManager:e}=xe();return e.transcriptionManager}function e5(e,t){let n=jN(),r=(0,Oe.useMemo)(()=>{if(e)return n.getAssetTranscription$(e,{endpoint:t?.endpoint,apiKey:t?.apiKey})},[n,e,t?.endpoint,t?.apiKey]);return q(r)}function t5(e){switch(e.type){case"asset":return{kind:"asset",id:e.id,assetId:e.assetId};case"file":return{kind:"noyaFile",id:e.id,fileId:e.fileId};default:return{kind:"folder",id:e.id}}}function n5({shouldDeleteAssets:e=!0}={}){let t=_N(),n=NN(),r=q(t.optimisticResources$,(0,Oe.useCallback)(o=>Object.fromEntries(o.map(s=>[s.path,s])),[])),i=(0,Oe.useCallback)(async o=>{let s=o instanceof Function?o(r):o,{addedResources:a,removedResources:c,modifiedResources:l}=jw(r,s,"id"),p=PN({addedResources:a,modifiedResources:l,removedResources:c});if(((p.create?.length??0)>0||(p.update?.length??0)>0||(p.delete?.length??0)>0)&&await t.patchResources(p),e)for(let m of c)m.type==="asset"&&await n.delete(m.assetId)},[r,t,e,n]);return[r,i]}var r5=[];function i5(e){let{noyaManager:t}=xe();return Gh(e,t.activityEventsManager)}function Gh(e,t){let[n,r]=(0,Oe.useState)(void 0),i=gA(e);(0,Oe.useEffect)(()=>{if(!i)return;let s=t.subscribe(i);return r(s),()=>{r(void 0),t.unsubscribe(s)}},[t,i]);let o=n?t.getStream(n):void 0;return q(o)??r5}var LN=({children:e,fallback:t})=>kN()?e:t??null;function o5({schema:e,mergeHistoryEntries:t,outputTransforms:n,inputs:r,safeEval:i}){let o=ty;function s({children:I,contextValue:M}){return Oe.default.createElement(ty.Provider,{value:M},I)}function a({children:I,initialState:M,...O}){let[,,{noyaManager:C,theme:z,viewType:F}]=lI(M,{schema:e,mergeHistoryEntries:t,outputTransforms:n,inputs:r,safeEval:i,...O}),N=(0,Oe.useMemo)(()=>({noyaManager:C,theme:z,viewType:F}),[C,z,F]);return Oe.default.createElement(s,{contextValue:N},O.fallback!==void 0?Oe.default.createElement(LN,{fallback:O.fallback},I):I)}function c(I,M){let{noyaManager:O}=xe(),C=typeof I=="function"||!I?"":I,z=(0,Oe.useMemo)(()=>typeof I=="function"?O.multiplayerStateManager.optimisticState$.map(I,{isEqual:M?.isEqual}):O.multiplayerStateManager.optimisticState$,[O,I,M?.isEqual]);return q(z,C)}function l(I){let{noyaManager:M}=xe();return(0,Oe.useCallback)((...C)=>{let[z,F]=C.length===2?C:[{},C[0]];M.multiplayerStateManager.setStateAtPath(z,I??"",F)},[M,I])}function p(...I){let[M,O,C]=I.length>=1&&typeof I[0]=="function"?[I[0],I[1],void 0]:[void 0,void 0,I[0]],z=c(M??C??"",O),F=l(C??"");return[z,F]}function d(){let{noyaManager:I}=xe();return I.multiplayerStateManager}function m(){let{noyaManager:I}=xe();return I.sharedConnectionDataManager}function y(){return xe().noyaManager}function S(){let{menuManager:I}=y();return q(I.leftMenuItems$)}function T(I){let{menuManager:M}=y();(0,Oe.useEffect)(()=>{I&&M.setLeftMenuItems(I)},[M,I])}function E(){let{menuManager:I}=y();return q(I.rightMenuItems$)}function b(I){let{menuManager:M}=y();(0,Oe.useEffect)(()=>{I&&M.setRightMenuItems(I)},[M,I])}function f(I){let{menuManager:M}=y();(0,Oe.useEffect)(()=>M.addListener(I),[M,I])}function g(){let{menuManager:I}=y();return(0,Oe.useCallback)(M=>I.emit(M),[I])}function v(I){let{leftMenuItems:M,rightMenuItems:O,onSelectMenuItem:C}=I;T(M),b(O);let z=(0,Oe.useCallback)(()=>{},[]);f(C??z)}return{Context:o,Provider:a,NoyaContextProvider:s,useValue:c,useSetValue:l,useValueState:p,useStateManager:d,useSharedConnectionDataManager:m,useLeftMenuItems:S,useSetLeftMenuItems:T,useRightMenuItems:E,useSetRightMenuItems:b,useHandleMenuItem:f,useOnSelectMenuItemCallback:g,useNoyaManager:y,useMenu:v}}function s5(e){let t=ny();(0,BN.useEffect)(()=>t.registerTool(e),[t,e])}function a5(){let e=ny();return q(e.callableTools$)}u();var Pi=Q(require("react"));function c5(e,t){return!!t&&Date.now()-t<e}var u5=ea(function({user:t,sharedConnectionDataManager:n,hideAfter:r=5e3,renderUserPointer:i}){let o=(0,Pi.useMemo)(()=>{let d=n.metadata$.observePath([t.connectionId]).throttle(50),m=n.data$.observePath([t.connectionId]).throttle(50);return _.combine([d,m],([y,S])=>({metadata:y,data:S}))},[n,t.connectionId]),{metadata:s,data:a}=q(o),[,c]=(0,Pi.useState)(0),l=s?.updatedAt??0,p=c5(r,l);return(0,Pi.useEffect)(()=>{if(!p)return;let d=setTimeout(()=>{c(m=>m+1)},r);return()=>clearTimeout(d)},[r,p,l]),a?.pointer?i({userId:t.connectionId,name:t.name,point:a.pointer,visible:p}):null}),l5=ea(function({userManager:t,sharedConnectionDataManager:n,renderUserPointer:r}){let i=q(n.currentConnectionId$),o=q(t.connectedUsers$);return Pi.default.createElement(Pi.default.Fragment,null,o.map(s=>s.connectionId===i?null:Pi.default.createElement(u5,{key:s.connectionId,user:s,sharedConnectionDataManager:n,renderUserPointer:r})))});u();function p5(e){let{noyaManager:t}=xe(),n=q(t.resourceManager.optimisticResources$),r=q(t.assetManager.assets$);if(e)return wS(e,n,r)}u();var Bo=class{constructor(t,n={}){this.url=t;this.options=n;this.ws=new lc({debug:n.debug,onopen:this.handleOpen,onmessage:this.handleMessage,onclose:this.handleClose,activityDetector:new uc})}ws;closedForever=!1;async connect(){this.closedForever||this.ws.connect(this.url.toString())}handleOpen=()=>{this.closedForever||(this.options.debug&&console.info("ws connected"),this.options.onConnectionEvent?.({type:"stateChange",state:"OPEN"}))};handleMessage=t=>{if(this.closedForever)return;this.options.debug&&console.info("ws receiving message ",t.data);let n=JSON.parse(t.data);this.options.onConnectionEvent?.({type:"receive",message:n})};handleClose=()=>{this.closedForever||(this.options.debug&&console.info("ws disconnected"),this.options.onConnectionEvent?.({type:"stateChange",state:"CLOSED"}))};send(t){this.closedForever||(this.options.debug&&console.info("ws sending message",t),this.options.onConnectionEvent?.({type:"send",message:t}),this.ws.send(JSON.stringify(t)))}close(){this.closedForever||(this.closedForever=!0,this.ws.shutdown(),this.ws.listeners.forEach(t=>{this.ws.removeListener(t)}))}addListener(t){return this.ws.addListener(t)}removeListener(t){return this.ws.removeListener(t)}};
70
+ `);r.push({message:p,connection:i});continue}let a=n.getNode(i.sourceBlockId);if(!a)throw new Error(`Source node not found: ${i.sourceBlockId}`);let c=_S(o,t);if(o.type==="file"&&c?.length>0){let l=a;for(let p of n.nodes())p.gType==="transform"&&p.gFileVersionId===o.fileVersionId&&n.getNodeDependencies(Uo(p)).has(Uo(l))&&(l=p);a=l}n.addEdge(a,s)}return{graph:n,invalidConnections:r}}function O6(e){function t(o){if(o==null)throw new Error("Module exports is null or undefined");return o.__esModule&&"default"in o||typeof o=="object"&&"default"in o&&Object.keys(o).length===1?o.default:o}let n={},r={exports:n},i=()=>{};return new Function("exports","module","require",e)(n,r,i),t(r.exports)}function UO({fetch:e=globalThis.fetch}={}){return async(t,n)=>{let r=[];try{if(t.type==="url"){let a=await(await e(t.url)).text();t={...t,type:"code",code:a}}return{result:await O6(t.code)(...t.args),logs:r}}catch(i){return console.error(i),{error:i,logs:r}}finally{}}}function _O({url:e,bundlerUrl:t=e,fetch:n=globalThis.fetch}){return async(r,i)=>{let o;try{o=JSON.stringify(r)}catch(c){throw new Error(`Failed to encode parameters: ${c.message}`)}let s=r.type==="url"&&r.url.includes("/js/bundler")?t:e,a=await n(s,{method:"POST",body:o});if(!a.ok){let c;try{c=await a.text()}catch{c=a.statusText}throw new Error(`Remote evaluate failed: ${a.status} ${a.statusText} ${s}. ${c}`)}try{return await a.json()}catch(c){throw new Error(`Failed to decode response: ${c.message}`)}}}function jO({baseUrl:e,headers:t,fetch:n=globalThis.fetch,ENCRYPTION_KEY:r,MULTIPLAYER_SHARED_TOKEN:i}){return async o=>{let a=await(await n(`${e}/api/fileVersions/${o}/secrets?includeValues=true`,{headers:{"x-noya-shared-token":i,...t}})).json();return A6(a,r)}}async function A6(e,t){let n={};for(let r of e){let i=await R6(r,t);i&&(n[i.name]=i.value)}return n}async function R6(e,t){let{value:n,...r}=e;if(!n)return console.warn(`No value for secret ${r.name}`),null;let i=JSON.parse(n),o=await OO({...i,ENCRYPTION_KEY:t});return{...r,value:o}}var DO="__system__";function P6({state:e,node:t,api:n,taskRunner:r,dependencyTaskRefs:i}){let o;switch(t.gType){case"block":{o=`[Block] ${t.name}`;break}case"input":{o=`[Input] ${t.gBlockName} / ${t.name}`;break}case"transform":{let a=t.value;o=`[Transform] ${t.gBlockName} / ${t.kind}${a?` (${a})`:""}`;break}}return r.createContext(...i).addTask({id:Uo(t),name:o},async(a,{log:c,setMetadata:l})=>{let p=(...f)=>{let g=new Date().toISOString();c(g,...f)},d=(...f)=>{p(DO,...f)},m=(...f)=>{p(DO,"__error__",...f)},y=a[0];async function S(f){if(n.createArtifact)try{let g=f.type==="string"?f.value:JSON.stringify(f.value),v=new TextEncoder().encode(g),I=await n.createArtifact(v);l(M=>({...M,artifacts:[{name:f.name,size:v.byteLength,url:I}]}))}catch(g){m(`${o} failed to create ${o} artifact`),m(g.message)}}let T=f=>{try{return f.assets}catch{return{}}},E=f=>f.reduce((g,v)=>(g[v.name]=v.state,g),{}),b=f=>f.reduce((g,v)=>(Object.assign(g,T(v)),g),{});try{switch(t.gType){case"block":switch(t.type){case"file":{let{fileVersionId:f}=t;d(`fetching ${o} - ${f}`);try{let g=await n.getFileVersionData(f),v=await n.getFileVersionAssets(f),I={...b(a),...Object.fromEntries(v.map(M=>[M.id,M]))};return d(`fetched ${o} - ${f}`,g),{state:g,assets:I,inputs:E(a)}}catch(g){throw m(`error fetching ${o} - ${f}`,g.message),g}}case"data":return d(`evaluating data node ${o}`),{state:t.data,assets:{},inputs:{}};case"secret":{d(`[Secret] loading ${o}`);try{let f=await n.getFileSecret(t.secretStableId);return d(`[Secret] loaded ${o}`),{state:f.value,assets:{},inputs:{},__isSecret:!0}}catch(f){throw m(`[Secret] error loading ${o}`),f}}case"workflowOutput":{let f=E(a);return await S({type:"json",value:f,name:"output"}),{state:e,assets:{},inputs:f}}default:throw new Error(`Unknown node type: ${t.type}`)}case"input":{let f=a.map(O=>O.state),g=O=>Array.isArray(O),v=O=>O!==null&&typeof O=="object"&&!Array.isArray(O),I,M;if(f.length===0)I=void 0,M={};else if(f.every(g))I=f.flat(),M=b(a);else if(f.every(v))I=Object.assign({},...f),M=b(a);else{I=f[f.length-1];let O=a[a.length-1];M=T(O)}return a.some(O=>O?.__isSecret)?d(o,"secret value","\u2022".repeat(20)):d(o,"value",I),{name:t.name,state:I,assets:M}}case"transform":{d(`${o} - ${t.kind}`);async function f(g){let v={};t.gFileVersionId&&(v=await n.getFileVersionEnv(t.gFileVersionId));let I;try{I=await n.evaluateScript({...g,env:v},d)}catch(z){throw m(`${o} failed to evaluate`,z.message),z}let{result:M,logs:O,error:C}=I;await S({type:"json",value:M,name:"result"});for(let z of O)p(...z);if(C)throw m(`${o} failed to evaluate`),m(AO(C)),new Error(C.message);return d(`${o} evaluated script`),{state:M,assets:T(y),inputs:y.inputs}}switch(t.kind){case"jsonPointer":{if(d(`${o} json pointer`,t.value),!t.value.startsWith("/"))throw d(`${o} json pointer missing leading slash`,t.value),new Error(`${o} json pointer missing leading slash: ${t.value}`);let g=Ht(y.state,t.value,["/"]);return d(`${o} json pointer result`,JSON.stringify(g,null,2)),{state:g,assets:T(y),inputs:y.inputs}}case"script":{let g;switch(t.location){case"state":{if(typeof y.state!="string")throw new Error(`Script transform requires string input, got: ${typeof y.state} ${JSON.stringify(y).slice(0,1e3)}`);g=y.state;break}case"url":{let v;try{v=await(n.fetchScript??C6)(t.value)}catch(F){throw m(`${o} error fetching script: ${F.message}`),F}let{cid:I,url:M}=v,O=t.value.includes("/js/bundler")&&n.cache,C;if(O){d(`${o} - computing hash`);try{let F=JSON.stringify({cid:I,args:[y]});C=await O.hash(new TextEncoder().encode(F)),d(`${o} - computed hash: ${C}`)}catch(F){d(`${o} - error computing hash: ${F.message}`)}}if(C&&O){d(`${o} - checking cache for ${C}`);let F;try{let N=await O.getValue(C);F=JSON.parse(new TextDecoder().decode(N))}catch{d(`${o} - no cached result found for ${C}`)}if(F)return d(`${o} - found cached result`),{state:F,assets:T(y),inputs:y.inputs}}let z;try{z=await f({type:"url",url:M,cid:I,args:[y.inputs,{state:y.state,assets:T(y)}]})}catch(F){throw m(`${o} - error evaluating script: ${F.message}`),F}if(C&&O){d(`${o} - caching result for ${C}`);try{let F=JSON.stringify(z.state),N=new TextEncoder().encode(F);await O.setValue(C,N),d(`${o} - cached result for ${C}`)}catch(F){d(`${o} - error caching result for ${C}`),d(F.message)}}return z}default:throw new Error(`Unknown script location: ${t.location}`)}return await S({type:"string",value:g,name:"script"}),f({type:"code",code:g,args:[y.inputs,{state:y.state,assets:T(y)}]})}default:throw new Error(`Unknown transform type: ${t.type}`)}}default:throw new Error(`Unknown graph node type: ${t.gType}`)}}catch(f){throw m(`${o} failed to run`),m(f.message),f}})}async function C6(e){let t=await fetch(e);if(!t.ok)throw new Error(`Failed to fetch script ${e}: ${t.statusText}`);return{text:()=>t.text(),url:e,cid:t.headers.get("x-noya-cid")??void 0}}function LO({graph:e,state:t,api:n}){let r=new Bl;if(!e.isAcyclic())throw new Error("Workflow graph has cycles");let i=Array.from(e.nodes()).find(a=>a.gType==="block"&&a.type==="workflowOutput");function o(a){if(r.tasks[Uo(a)])return Bl.toRef(r.tasks[Uo(a)]);let l=[...e.getNodeDependencies(Uo(a))].map(p=>{let d=e.getNode(p);return o(d)});return P6({node:a,api:n,taskRunner:r,state:t,dependencyTaskRefs:l})}let s=o(i);return{taskRunner:r,rootTask:s}}async function BO({state:e,api:t}){let n=await Promise.all(e.blocks.map(async c=>{try{if(c.type==="file"&&c.preferredFileSource==="file"&&c.fileId){let l=await t.createFileVersion(c.fileId);return{...c,fileVersionId:l.id}}}catch(l){return console.error("error creating file version: ",l),c}return c})),r={...e,blocks:n},{graph:i,invalidConnections:o}=kO(r,t),{taskRunner:s,rootTask:a}=LO({graph:i,state:r,api:t});return{taskRunner:s,rootTask:a,invalidConnections:o}}var $l=class{constructor(t){this.rpcManager=t}status$=new _("idle");tasks$=new _([]);result$=new _(void 0);async run(t){let n=await this.rpcManager.requestRoute("POST /api/evaluate",{body:JSON.stringify(t),headers:{"Content-Type":"application/json"}});return JSON.parse(n.body).result}async runScript(t,n){let r=await fetch(t);if(!r.ok)throw new Error("Failed to fetch script");let i=await r.text();return this.run({type:"code",code:i,args:n.args,env:n.env})}async runScriptOnFileState(t,n){return await this.runScript(t,{args:[{state:n}],env:{}})}async runPipeline(t){let n=await this.rpcManager.requestRoute("POST /api/runWorkflow",{body:JSON.stringify({...t&&{pipelineState:t}}),headers:{"Content-Type":"application/json"}}),{result:r,snapshot:i}=JSON.parse(n.body);return{result:r,snapshot:i}}getPipelineGraphAPI(t){return{evaluateScript:t.executionEnvironment==="local"?UO():_O({url:process.env.NEXT_PUBLIC_DEV_EVALUATE_SCRIPT_URL,bundlerUrl:process.env.NEXT_PUBLIC_DEV_EVALUATE_SCRIPT_URL}),getFileVersionEnv:t.executionEnvironment==="local"?()=>Promise.resolve({}):jO({baseUrl:t.baseUrl,ENCRYPTION_KEY:process.env.NEXT_PUBLIC_DEV_ENCRYPTION_KEY,MULTIPLAYER_SHARED_TOKEN:process.env.NEXT_PUBLIC_DEV_MULTIPLAYER_SHARED_TOKEN}),getFileVersionData:t.getFileVersionData,getFileVersionInputs:t.getFileVersionInputs,getFileVersionTransforms:t.getFileVersionTransforms,getFileVersionIds:t.getFileVersionIds,getFileSecret:t.getFileSecret,getFileVersionAssets:t.getFileVersionAssets,getFileAssets:t.getFileAssets,createArtifact:t.executionEnvironment==="local"?async n=>{let r=new Blob([n]);return URL.createObjectURL(r)}:void 0,createFileVersion:t.createFileVersion}}async runPipelineLocally(t,n){let{taskRunner:r,rootTask:i}=await BO({state:t,api:this.getPipelineGraphAPI(n)});this.status$.set("running"),r.subscribe(()=>{this.tasks$.set(r.getSnapshot())});try{let o=await r.runTask(i);return this.status$.set("success"),this.result$.set(o),{result:o,snapshot:r.getSnapshot()}}catch(o){return this.status$.set("error"),{error:o,snapshot:r.getSnapshot()}}}};u();var Kl=class{enablePublishing$=new _(!1);setPublishingEnabled(t){this.enablePublishing$.set(t)}getFilesToPublish};u();u();var zl=class{constructor(t){this.options=t;this.ensureMessageSubscription()}multiplayer=new Gi("");unsubscribeMultiplayerMessages;isOpen=!1;getHandle(){return{resourceId:this.options.resourceId,content$:this.multiplayer.optimisticState$,isInitialized$:this.multiplayer.isInitialized$,sendPatches:(n,r)=>{this.sendPatches(n,r)},close:()=>this.close()}}open(){if(this.ensureMessageSubscription(),!this.isOpen){this.isOpen=!0,this.multiplayer.connect();return}this.multiplayer.reinitialize(this.multiplayer.getConfirmedState())}close(){this.isOpen&&(this.isOpen=!1,this.multiplayer.disconnect(),this.options.sendMessage?.({type:"resourceEdit.close",resourceId:this.options.resourceId}),this.unsubscribeMultiplayerMessages?.(),this.unsubscribeMultiplayerMessages=void 0,this.options.onClose?.())}sendPatches(t,n){this.multiplayer.applyPatch(n??{},{patches:t})}handleServerMessage(t){let n=this.translateIncomingMessage(t);n&&(this.multiplayer.incomingMessages.push(n),this.multiplayer.processIncomingMessages())}flushOutgoingMessages(){for(;this.multiplayer.outgoingMessages.length>0;){let t=this.multiplayer.outgoingMessages.shift(),n=this.translateOutgoingMessage(t);n&&this.options.sendMessage?.(n)}}translateOutgoingMessage(t){switch(t.type){case"init":return{type:"resourceEdit.open",resourceId:this.options.resourceId};case"patch":return{type:"resourceEdit.patch",resourceId:this.options.resourceId,id:t.id,patches:t.patches,baseHash:t.baseHash};default:return}}translateIncomingMessage(t){switch(t.type){case"resourceEdit.object":return{type:"object",object:t.content};case"resourceEdit.acceptPatch":return{type:"acceptPatch",id:t.id,patches:t.patches,hash:t.hash};case"resourceEdit.rejectPatch":return{type:"rejectPatch",id:t.id,reason:t.reason,error:t.error};default:return}}ensureMessageSubscription(){this.unsubscribeMultiplayerMessages||(this.unsubscribeMultiplayerMessages=this.multiplayer.messageEmitter.addListener(()=>{this.flushOutgoingMessages()}))}};var Hl=class{constructor(t,n={}){this.rpcManager=t;this._resourceUrlBase=n.resourceUrlBase??(typeof globalThis.location>"u"||globalThis.location.origin==="null"?void 0:globalThis.location.origin),this.setResources(n.initialResources??[]),this.isInitialized$.set(!!n.initialResources),this._sendMessage=n.sendMessage,n.subscribeConnectionEvents&&(this._unsubscribeConnectionEvents=n.subscribeConnectionEvents(this._handleConnectionEvent)),this._resolveAssetId=n.resolveAssetId}isInitialized$=new _(!1);resources$=new _([],{isEqual:Gt});patches$=new _([],{isEqual:Gt});optimisticResources$=_.combine([this.resources$,this.patches$],([t,n])=>n.reduce((r,i)=>{try{return De(r,i.patches)}catch{return r}},t),{isEqual:Gt});uploads$=new _({});setResources(t){let n=t.map(r=>({...r,url:N6(r,this._resourceUrlBase)}));this.resources$.set(n)}async createResource(t){let n=Array.isArray(t)?t:[t];if(n.length===0)throw new Error("No resources to create");let i=(await this.patchResources({create:n})).created;return Array.isArray(t)?i:i[0]}async _withPatch(t,n){let r=te();this.patches$.set([...this.patches$.get(),{id:r,patches:t}]);try{return await n()}finally{this.patches$.set(this.patches$.get().filter(i=>i.id!==r))}}async deleteResource(t){let n=Array.isArray(t)?t:[t],i=(await this.patchResources({delete:n})).deleted;return Array.isArray(t)?i:i[0]}async patchResources({create:t,update:n,delete:r}){let i=(t?.length??0)>0,o=(n?.length??0)>0,s=(r?.length??0)>0;if(!i&&!o&&!s)throw new Error("PATCH body must include create, update, or delete arrays");let a=m=>this._resolveAssetId?.(m)??m,c=i?t.map(m=>m.type==="asset"&&m.assetId?{...m,assetId:a(m.assetId)}:m):void 0,l=o?n.map(m=>({...m,...m.assetId?{assetId:a(m.assetId)}:{}})):void 0,p=[];if(r?.length&&p.push(...r.map(({id:m})=>({op:"remove",path:[{id:m}]}))),l?.length)for(let m of l)m.path!==void 0&&p.push({op:"replace",path:[{id:m.id},"path"],value:m.path}),m.type!==void 0&&p.push({op:"replace",path:[{id:m.id},"type"],value:m.type}),m.assetId!==void 0&&p.push({op:"replace",path:[{id:m.id},"assetId"],value:m.assetId}),m.fileId!==void 0&&p.push({op:"replace",path:[{id:m.id},"fileId"],value:m.fileId}),m.resourceId!==void 0&&p.push({op:"replace",path:[{id:m.id},"resourceId"],value:m.resourceId});let d=async()=>{let m={};c?.length&&(m.create=c),l?.length&&(m.update=l),r?.length&&(m.delete=r);let y=[...c?.flatMap(S=>S.type==="asset"&&S.asset?[{name:S.path}]:[])??[],...l?.flatMap(S=>S.asset?[{name:S.path??S.id}]:[])??[]].map(S=>({id:te(),name:S.name}));try{let S=await this.rpcManager.requestRoute("PATCH /api/resources",{body:JSON.stringify(m),headers:{"Content-Type":"application/json"},...y.length?{onUploadProgress:T=>{let E=y.map(b=>[b.id,{...T,name:b.name,id:b.id}]);this.uploads$.set({...this.uploads$.get(),...Object.fromEntries(E)})}}:{}});return this.rpcManager.getResponseBody(S)}finally{if(y.length){let S={...this.uploads$.get()};for(let T of y)delete S[T.id];this.uploads$.set(S)}}};return p.length>0?this._withPatch(p,d):d()}async updateResource({id:t,path:n,assetId:r,asset:i,type:o,fileId:s,fileVersionId:a,resourceId:c}){return(await this.patchResources({update:[{id:t,...n?{path:n}:{},...r?{assetId:r}:{},...i?{asset:i}:{},...o?{type:o}:{},...s?{fileId:s}:{},...a?{fileVersionId:a}:{},...c?{resourceId:c}:{}}]})).updated[0]}async listResources(){let t=await this.rpcManager.requestRoute("GET /api/resources");return this.rpcManager.getResponseBody(t)}_sendMessage;_unsubscribeConnectionEvents;_resolveAssetId;_resourceUrlBase;_editSessions=new Map;_handleConnectionEvent=t=>{if(t.type!=="receive")return;let n=t.message;switch(n.type){case"resourceEdit.object":case"resourceEdit.acceptPatch":case"resourceEdit.rejectPatch":{this._editSessions.get(n.resourceId)?.handleServerMessage(n);break}}};openEditingHandle(t){let n=this._editSessions.get(t);return n||(n=new zl({resourceId:t,sendMessage:r=>this._sendMessage?.(r),onClose:()=>this._editSessions.delete(t)}),this._editSessions.set(t,n)),n.open(),n.getHandle()}};function FO(e,t){let n=`/api/transform/${e}?format=image`;return t?new URL(n,t).toString():n}function N6(e,t){let n=e.url??FO(e.id,t);return t?new URL(n,t).toString():n}u();var k6=()=>new Date().toISOString(),$O=()=>({status:"idle",installLogs:"",devLogs:"",lastUpdated:k6()}),Gl=class{constructor(t){this.rpcManager=t}state$=new _($O());setState(t){this.state$.set(t)}setFromServer=t=>{this.setState(t)};async exec(t,n){let r=await this.rpcManager.requestRoute("POST /api/sandbox/exec",{headers:{"Content-Type":"application/json"},body:JSON.stringify({command:t,cwd:n})});return this.rpcManager.getResponseBody(r)}async listFiles(){let t=await this.rpcManager.requestRoute("GET /api/sandbox/files");return this.rpcManager.getResponseBody(t)}async exposePreview(){let t=await this.rpcManager.requestRoute("POST /api/sandbox/preview",{headers:{"Content-Type":"application/json"}});return this.rpcManager.getResponseBody(t)}async getBuildFilesZip(){let t=await this.rpcManager.requestRoute("GET /api/sandbox/build-files");return this.rpcManager.getResponseBody(t)}};u();var ql=class extends Ee{debug;constructor(t={}){super(),this.isConnected$=new _(t.isConnected??!1),this.debug=t.debug??!1}isConnected$;setIsConnected(t){this.isConnected$.set(t)}requests={};request=async(t,n)=>{this.debug&&console.info("[rpcManager] request waiting for connection"),await this.isConnected$.waitFor(!0),this.debug&&console.info("[rpcManager] request",t);let r=te(),i={...t,id:r},{promise:o,resolve:s,reject:a}=Promise.withResolvers();return this.requests[r]={request:i,status:"pending",resolve:s,reject:a,onStreamChunk:n?.onStreamChunk,onStreamEnd:n?.onStreamEnd,onUploadProgress:n?.onUploadProgress},this.emit(i),o};requestRoute=async(t,{body:n,headers:r,searchParams:i,onUploadProgress:o}={})=>{let[s,a]=t.split(" "),c=a;if(i&&Object.keys(i).length>0){let l=new URLSearchParams;for(let[p,d]of Object.entries(i))d!=null&&l.set(p,String(d));c=`${a}?${l.toString()}`}return this.request({url:c,options:{method:s,...n?{body:n}:{},...r?{headers:r}:{}}},{onUploadProgress:o})};requestStreamingRoute=async(t,{body:n,headers:r,onStreamChunk:i,onStreamEnd:o})=>{let[s,a]=t.split(" ");return this.request({url:a,options:{method:s,...n?{body:n}:{},...r?{headers:r}:{}},streaming:!0},{onStreamChunk:i,onStreamEnd:o})};handleMessage=t=>{let n=this.requests[t.id];this.debug&&console.info("[rpcManager] handleMessage",t),n?t.type==="chunk"?(n.status="streaming",n.onStreamChunk?.(t.chunk)):t.type==="end"?(n.status="resolved",n.onStreamEnd?n.onStreamEnd().then(()=>{n.resolve(t.response)}):n.resolve(t.response)):t.type==="error"&&(n.status="rejected",n.reject(t.error)):console.error("Response without corresponding request",t,this.requests)};getResponseBody=t=>{let n=Object.fromEntries(Object.entries(t.headers).map(([i,o])=>[i.toLowerCase(),o]));return("content-type"in n?n["content-type"]:null)?.includes("application/json")?JSON.parse(t.body):t.body}};u();var Qd=class extends Error{constructor(n,r){super(n.message);this.evaluationError=n;this.logs=r;this.name="ScriptEvaluationError"}},Vl=class{constructor(t){this.rpcManager=t}evaluateScript(t){return this.evaluate({type:"code",...t})}evaluateUrl(t){return this.evaluate({type:"url",...t})}evaluateFiles(t){return this.evaluate({type:"files",...t})}async evaluate(t){let n=await this.rpcManager.requestRoute("POST /api/scripts/evaluate",{body:JSON.stringify(t),headers:{"Content-Type":"application/json"}}),r=this.rpcManager.getResponseBody(n);if(!r||!Array.isArray(r.logs))throw new Error("Script evaluator returned an unexpected response");if(r.status==="error")throw new Qd(r.error,r.logs);return{result:r.result,logs:r.logs}}};u();var Ql=class{constructor(t,n){this.rpcManager=t;n.initialSecrets&&(this.secrets$.set(n.initialSecrets),this.isInitialized$.set(!0))}secrets$=new _([]);isInitialized$=new _(!1);async fetchSecrets(){let t=await this.rpcManager.requestRoute("GET /api/secrets",{}),n=this.rpcManager.getResponseBody(t);return this.secrets$.set(n),this.isInitialized$.set(!0),n}async createSecret(t,n,r){let i=await this.rpcManager.requestRoute("POST /api/secrets",{body:JSON.stringify({id:t,name:n,value:r}),headers:{"Content-Type":"application/json"}});return this.rpcManager.getResponseBody(i)}async deleteSecret(t){return await this.rpcManager.requestRoute("DELETE /api/secrets",{body:JSON.stringify({id:t}),headers:{"Content-Type":"application/json"}})}};u();var Yl=class{constructor(t={}){this.options=t}tasks$=new _([]);setTasks(t){let n=this.tasks$.get(),r=new Set(t.map(s=>s.id)),o=[...n.filter(s=>!r.has(s.id)),...t];this.tasks$.set(o.slice(0,this.options.maxTasks??20))}getTasks(){return this.tasks$.get()}};u();var D6={type:"processing"},Jl=class{constructor(t,n){this.rpcManager=t;this.assetManager=n}assetTranscriptions$=new _({});getAssetTranscription$(t,n){return this.assetTranscriptions$.get(t)||this.transcribe({assetId:t,...n}),this.assetTranscriptions$.map(i=>i[t]??D6)}async transcribe(t){let n;if("data"in t)n={...t,type:"data",data:en.encode(t.data)};else if("assetId"in t){let i=this.assetManager.getRealAssetId(t.assetId);if(!i)throw new Error(`Asset ${t.assetId} not found`);n={...t,type:"assetId",assetId:i}}let r=i=>{"assetId"in t&&this.assetTranscriptions$.set(t.assetId,i)};try{if(!n)throw new Error("Missing transcription data or assetId");r({type:"processing"});let i=await this.rpcManager.requestRoute("POST /api/transcriptions",{body:JSON.stringify(n),headers:{"Content-Type":"application/json"}}),o=this.rpcManager.getResponseBody(i);if(!o){let s=new Error("Transcription failed");throw r({type:"error",error:s}),s}return r({type:"success",...o}),o}catch(i){throw r({type:"error",error:i}),i}}};async function jS(e,{resolveAsset:t}){let n=e.fileName,r=e.contentType,i;if("assetId"in e){let l=await t(e.assetId);if(!l)throw new Error(`Asset ${e.assetId} not found`);i=l.data,r=r??l.contentType,n=n??e.assetId}else if("data"in e)i=en.decode(e.data).buffer;else throw new Error("Missing transcription payload");let o=new Blob([i],{type:r??"application/octet-stream"}),s=new FormData;s.append("file",o,n??"upload");let a=await fetch(e.endpoint,{method:"POST",body:s,headers:{...e.apiKey?{Authorization:`Bearer ${e.apiKey}`}:{}}});return await U6(a)}async function U6(e){let t=await e.text(),n;try{n=JSON.parse(t)}catch{n=void 0}if(!e.ok){let r=(typeof n=="object"&&n!==null&&"error"in n?String(n.error):void 0)??t??"Transcription failed";throw new Error(r)}if(!n||typeof n!="object"||!("success"in n))throw new Error("Unexpected transcription response format");return _6(n,t)}function _6(e,t){let n=a=>typeof a=="object"&&a!==null,r=n(e)?typeof e.transcription=="string"?e.transcription:typeof e.text=="string"?e.text:t:t,i=n(e)&&n(e.metadata)?e.metadata:{},o=n(e)&&Array.isArray(e.segments)?e.segments:[];return{success:n(e)&&"success"in e?!!e.success:!0,transcription:r,segments:o,metadata:i}}u();u();u();u();var zO=["cat","dog","owl","fish","horse","rabbit","snake","lion","bear","wolf","fox","elephant","giraffe","zebra","panda","monkey","penguin","koala","kangaroo","whale","shark","turtle","crocodile","hippo"],j6=["happy","sleepy","hungry","thirsty","healthy","rich","funky","cool","awesome","amazing","fantastic","incredible","super","mega","ultra"];function KO(e){return e[Math.floor(Math.random()*e.length)]}function LS(e){return`https://avatars.noya.site/animals/animals_${e}.svg`}function HO(){let e=KO(zO);return{name:`${Mb(KO(j6))} ${Mb(e)}`,animal:e,image:LS(e)}}function GO(e){let t=e.trim().split(/\s+/),n=t[t.length-1]?.toLowerCase();if(n)return zO.includes(n)?n:void 0}var Yd="noya-client-id",Jd="noya-client-name",Xd="noya-client-image",hi=new _(void 0),Js=new _(void 0),Xs=new _(void 0),BS=e=>{try{return typeof localStorage<"u"?localStorage.getItem(e):null}catch{return null}},sc=(e,t)=>{try{typeof localStorage<"u"&&localStorage.setItem(e,t)}catch{}},FS=e=>{try{typeof localStorage<"u"&&localStorage.removeItem(e)}catch{}};if(typeof window<"u"){let e=BS(Yd);if(e)hi.set(e);else{let i=te();sc(Yd,i),hi.set(i)}let t=BS(Jd)??void 0,n=BS(Xd)??void 0,r=HO();if(t||(t=r.name,sc(Jd,t)),!n){let i=(t&&GO(t))??r.animal;i&&(n=LS(i),sc(Xd,n))}Js.set(t),Xs.set(n)}function $S(e){Js.set(e),!(typeof window>"u")&&(e===void 0?FS(Jd):sc(Jd,e))}function KS(e){hi.set(e),!(typeof window>"u")&&(e===void 0?FS(Yd):sc(Yd,e))}function zS(e){Xs.set(e),!(typeof window>"u")&&(e===void 0?FS(Xd):sc(Xd,e))}u();u();u();function HS({status:e,statusText:t,body:n}){let r=n?.trim(),i;if(r)try{let o=JSON.parse(r);i=typeof o=="string"?o:typeof o?.message=="string"?o.message:typeof o?.error=="string"?o.error:typeof o?.error?.message=="string"?o.error.message:r}catch{i=r}return i?`RPC request failed (${e}): ${i}`:t?`RPC request failed (${e}): ${t}`:`RPC request failed (${e})`}async function*_o(e,t){let{baseUrl:n,token:r,debug:i=!1}=t;try{let o=new URL(e.url,n);o.protocol=o.protocol==="ws:"?"http:":"https:",i&&console.info("Fetching RPC stream",{url:o.toString(),body:e.options.body});let s=await fetch(o,{...e.options,headers:{...e.options?.headers,...r?{Authorization:`Bearer ${r}`}:{}}});if(!s.ok){let l=await s.text();throw new Error(HS({status:s.status,statusText:s.statusText,body:l}))}let a=s.body?.getReader(),c=new TextDecoder;if(!a)throw new Error("Stream not available");try{for(;;){let{done:l,value:p}=await a.read();if(l){let m=c.decode();m&&(yield{id:e.id,type:"chunk",chunk:m}),yield{id:e.id,type:"end",response:{status:s.status,statusText:s.statusText,headers:Object.fromEntries(s.headers.entries()),body:""}};break}let d=c.decode(p,{stream:!0});yield{id:e.id,type:"chunk",chunk:d}}}finally{a.releaseLock()}}catch(o){yield{id:e.id,type:"error",error:o instanceof Error?o.message:String(o)}}}async function jo(e,t){let{baseUrl:n,token:r,debug:i=!1}=t;try{let o=new URL(e.url,n);if(o.protocol=o.protocol==="ws:"?"http:":"https:",i&&console.info("Fetching RPC",{url:o.toString(),body:e.options.body}),!(typeof XMLHttpRequest<"u"&&typeof window<"u"&&!!t.onUploadProgress&&!e.streaming)){let p=await fetch(o,{...e.options,headers:{...e.options?.headers,...r?{Authorization:`Bearer ${r}`}:{}}});if(!p.ok){let m=await p.text();throw new Error(HS({status:p.status,statusText:p.statusText,body:m}))}let d=await p.text();return i&&console.info("RPC response",{text:d}),{id:e.id,type:"end",response:{status:p.status,statusText:p.statusText,headers:Object.fromEntries(p.headers.entries()),body:d}}}let a={...e.options?.headers,...r?{Authorization:`Bearer ${r}`}:{}},c=e.options.method??"GET",l=await new Promise((p,d)=>{let m=new XMLHttpRequest;m.open(c,o.toString(),!0),Object.entries(a).forEach(([S,T])=>{try{m.setRequestHeader(S,T)}catch{}}),t.onUploadProgress&&(m.upload.onprogress=S=>{let T=S.loaded,E=S.lengthComputable?S.total:void 0,b=E?T/E*100:void 0;t.onUploadProgress?.({loaded:T,total:E,percent:b})}),m.onreadystatechange=()=>{if(m.readyState!==XMLHttpRequest.DONE)return;let S={};m.getAllResponseHeaders().trim().split(/\r?\n/).forEach(E=>{let b=E.indexOf(": ");if(b>0){let f=E.slice(0,b).toLowerCase(),g=E.slice(b+2);S[f]=g}}),p({id:e.id,status:m.status,statusText:m.statusText,headers:S,body:m.responseText??""})},m.onerror=()=>{d(new Error("Network error"))},m.onabort=()=>{d(new Error("Request aborted"))};let y=e.options.body??void 0;m.send(y)});if(l.status<200||l.status>=300)throw new Error(HS({status:l.status,statusText:l.statusText,body:l.body}));return i&&console.info("RPC response",{text:l.body}),{id:e.id,type:"end",response:l}}catch(o){return{id:e.id,type:"error",error:o instanceof Error?o.message:String(o)}}}u();function GS(e){return typeof e=="string"||e instanceof URL?{url:e}:typeof e=="function"?{url:e}:e}async function L6(e){let t=typeof e=="string"||e instanceof URL?e:await e();return typeof t=="string"?new URL(t):t}async function Zd(e){let{url:t}=GS(e),n=await L6(t),r=hi.get(),i=Js.get(),o=Xs.get();r&&n.searchParams.set("clientId",r),i&&n.searchParams.set("clientName",i),o&&n.searchParams.set("clientImage",o);let s=n.searchParams.get("token");if(!s)throw new Error("No token provided in URL");let a=await Gd.decode({token:s});return{url:n,tokenString:s,tokenPayload:a.payload}}function Xl(e,t){switch(e.type){case"connectedUsers":{let n=e.users.map(a=>({...a,clientId:a.clientId??te(),inactive:a.inactive??!1}));t.userManager.setAllUsers(n);let r=n.filter(a=>!a.inactive),i=new Set(r.map(a=>a.connectionId)),o=t.sharedConnectionDataManager.currentConnectionId$.get(),s=t.sharedConnectionDataManager.data$.get();for(let a of Object.keys(s))!i.has(a)&&a!==o&&t.sharedConnectionDataManager.delete(a);break}case"sharedConnectionData":{let n=new Set(t.userManager.connectedUsers$.get().map(o=>o.connectionId)),r=e.data,i={};for(let o in r)n.has(o)&&(i[o]=r[o]);Object.keys(i).length>0&&t.sharedConnectionDataManager.merge(i);break}case"workflow":{t.pipelineManager.status$.set(e.workflow.status),t.pipelineManager.tasks$.set(e.workflow.tasks),t.pipelineManager.result$.set(e.workflow.result);break}case"tasks":{t.taskManager.setTasks(e.tasks);break}case"secrets":{t.secretManager.secrets$.set(e.secrets),t.secretManager.isInitialized$.set(!0);break}case"assets":{t.assetManager.set(e.assets);break}case"inputs":{t.ioManager.inputs$.set(e.inputs),t.ioManager.inputsInitialized$.set(!0);break}case"outputTransforms":{t.ioManager.outputTransforms$.set(e.outputTransforms),t.ioManager.outputTransformsInitialized$.set(!0);break}case"resources":{t.resourceManager.setResources(e.resources),t.resourceManager.isInitialized$.set(!0);break}case"fileName":{t.filePropertyManager.applyServerUpdate({name:e.name??"",changeId:e.changeId});break}case"activityEvents.update":{t.activityEventsManager.setStreamEvents(e.streamId,e.activityEvents);break}case"serverScript.log":{t.logManager.append(e.log);break}case"sandbox":{t.sandboxManager.setFromServer(e.state);break}}}function Lo(e,t,n={}){Xl(e,t),(n.pushToMSM??!0)&&e.type!=="pong"&&(t.multiplayerStateManager.incomingMessages.push(e),t.multiplayerStateManager.processIncomingMessages())}function qO(e,{url:t,debug:n},r={}){let{getSyncConfig:i=Zd,createWebSocketConnection:o=(b,f)=>new Bo(b,f),fetchRPC:s=jo,fetchRPCStream:a=_o,applyServerMessage:c=Lo}=r,l,p=!1,d=[],m=()=>{if(p)for(;d.length&&l;){let b=d.shift();b&&l.send(b)}},y=i(t).then(({url:b,tokenString:f,tokenPayload:g})=>{let v=g.connectionId,I=g.authId??void 0;return e.sharedConnectionDataManager.setCurrentConnectionId(v),e.userManager.setCurrentConnectionId(v),e.userManager.setCurrentUserId(I),e.assetManager.assetStore=new $i(e.rpcManager),l=o(b,{debug:n,onConnectionEvent:M=>{switch(e.connectionEventManager.addEvent(M),M.type){case"stateChange":{p=M.state==="OPEN",e.rpcManager.setIsConnected(p),p&&m();break}case"receive":{c(M.message,e,{pushToMSM:!1});break}}}}),l.connect(),{resolvedUrl:b,tokenString:f}}),S=e.rpcManager.addListener(async b=>{let{resolvedUrl:f,tokenString:g}=await y;if(b.streaming){let v=a(b,{baseUrl:f.toString(),token:g,streaming:!0,debug:n});for await(let I of v)e.rpcManager.handleMessage(I)}else{let v=await s(b,{baseUrl:f.toString(),token:g,debug:n,onUploadProgress:e.rpcManager.requests[b.id]?.onUploadProgress});e.rpcManager.handleMessage(v)}});return{sendMessage:b=>{if(p&&l){l.send(b);return}d.push(b)},destroy:()=>{p=!1,e.rpcManager.setIsConnected(!1),l?l.close():y.then(()=>{l?.close()}),S()}}}u();function qS(e,t){return e.connectionEventManager.events$.subscribe(n=>{if(n.length===0)return;let r=n[n.length-1];switch(r.type){case"stateChange":{let i={type:"connection",state:r.state==="OPEN"?"connected":"disconnected"};t(i);break}case"receive":{let i=r.message;if(i&&i.type==="object"&&i.object===null)break;t(i);break}}})}u();u();var VO=new WeakMap,B6=e=>{let[,t]=e.split(" ");return new RegExp(t.replace(/\//g,"\\/").replace(/:[^/]+/g,"([^/]+)")+"$")},Ut=(e,t)=>{let[n]=e.split(" ");return{key:e,method:n,pattern:B6(e),handler:t}},Wd=e=>({status:200,statusText:"OK",headers:{"content-type":"application/json"},body:JSON.stringify(e)}),F6="iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVR4nGNgAAIAAAUAAXpeqz8AAAAASUVORK5CYII=";function em(e){return[Ut("POST /api/ai/generate",async t=>{let n=t.options?.body??"{}",r=JSON.parse(n);if(!r.encodedSchema)throw new Error("Missing encoded schema for local AI generation");let i=Rb(Eo(r.encodedSchema));if(t.streaming===!0&&r.stream===!0){if(typeof i!="object"||i===null||Array.isArray(i))throw new Error("Local AI object generation returned a non-object");let o={};await e.emitStreamEvent(t,{type:"partial-object",object:o});for(let[s,a]of Object.entries(i))o[s]=a,await e.emitStreamEvent(t,{type:"partial-object",object:{...o}});await e.emitStreamEvent(t,{type:"object",object:i})}return{object:i}}),Ut("POST /api/ai/generate/text",async t=>{let n=t.options?.body??"{}",r=JSON.parse(n),i=t.streaming===!0&&r.stream===!0,o=i?"Local AI generated text.":"";if(i){for(let s of["Local AI ","generated ","text."])await e.emitStreamEvent(t,{type:"text-delta",textDelta:s});await e.emitStreamEvent(t,{type:"text",text:o})}return{text:o}}),Ut("POST /api/ai/generate/image",async()=>({base64:F6,mediaType:"image/png"}))]}var QO=(e,t)=>`data:${e??"application/octet-stream"};base64,${en.encode(t)}`;function ac(e,t){let n;try{t?n=new Ya({databaseName:`noya-assets-${t}`}):n=new Ya,e.assetManager.assetStore=n}catch(r){console.warn("[localRpcHelpers] IndexedDB unavailable; using memory asset store",r)}return n}var ZO=e=>{let t=Promise.resolve();return{...e,runExclusive:async n=>{let r=t,i;t=new Promise(o=>{i=o}),await r;try{return await n()}finally{i()}}}},$6=()=>{let e=new Map;return ZO({list:async()=>[...e.values()],read:async t=>e.get(t)??null,create:async t=>(e.set(t.id,t),t),update:async(t,n)=>e.has(t)?(e.set(t,n),n):null,delete:async t=>{let n=e.get(t)??null;return e.delete(t),n},replaceAll:async t=>{e=new Map(t.map(n=>[n.id,n]))}})},K6=(e,t)=>{let n=new Promise((l,p)=>{let d=t.open(e,1);d.onerror=()=>p(d.error),d.onsuccess=()=>l(d.result),d.onupgradeneeded=m=>{let y=m.target.result;y.objectStoreNames.contains("resources")||y.createObjectStore("resources",{keyPath:"id"})}}),r=async()=>{let l=await n;return await new Promise((p,d)=>{let m=l.transaction("resources","readonly").objectStore("resources").getAll();m.onerror=()=>d(m.error),m.onsuccess=()=>p(m.result??[])})},i=async l=>{let p=await n;return await new Promise((d,m)=>{let y=p.transaction("resources","readonly").objectStore("resources").get(l);y.onerror=()=>m(y.error),y.onsuccess=()=>d(y.result??null)})};return ZO({list:r,read:i,create:async l=>{let p=await n;return await new Promise((d,m)=>{let y=p.transaction("resources","readwrite").objectStore("resources").put(l);y.onerror=()=>m(y.error),y.onsuccess=()=>d()}),l},update:async(l,p)=>{if(!await i(l))return null;let m=await n;return await new Promise((y,S)=>{let T=m.transaction("resources","readwrite").objectStore("resources").put(p);T.onerror=()=>S(T.error),T.onsuccess=()=>y()}),p},delete:async l=>{let p=await i(l);if(!p)return null;let d=await n;return await new Promise((m,y)=>{let S=d.transaction("resources","readwrite").objectStore("resources").delete(l);S.onerror=()=>y(S.error),S.onsuccess=()=>m()}),p},replaceAll:async l=>{let p=await n;await new Promise((d,m)=>{let y=p.transaction("resources","readwrite"),S=y.objectStore("resources");S.clear();for(let T of l)S.put(T);y.oncomplete=()=>d(),y.onerror=()=>m(y.error??new Error("Resource transaction failed")),y.onabort=()=>m(y.error??new Error("Resource transaction aborted"))})}})};function Zs(e,t){let n=e,r=t??"",i=VO.get(n),o=i?.get(r);if(o)return o;let s;try{if(typeof globalThis.indexedDB>"u")throw new Error("IndexedDB is not available");s=K6(t?`noya-resources-${t}`:"noya-resources",globalThis.indexedDB)}catch(a){console.warn("[localRpcHelpers] IndexedDB unavailable; using memory resource store",a),s=$6()}return i||(i=new Map,VO.set(n,i)),i.set(r,s),s}function WO(e,t){return[Ut("PUT /api/file",async n=>{let r=n.options?.body??"{}",i;try{i=JSON.parse(r)}catch{throw new Error("Invalid request body")}let o=typeof i.name=="string"&&i.name.length>0?i.name:"";try{typeof localStorage<"u"&&localStorage.setItem(`${t.offlineStorageKey}:name`,o)}catch{}return e.filePropertyManager.applyServerUpdate({name:o,changeId:i.changeId}),{name:o,changeId:i.changeId}}),Ut("GET /api/secrets",async()=>[]),Ut("GET /api/inputs",async()=>[]),Ut("GET /api/outputTransforms",async()=>[]),Ut("GET /api/assets",async()=>{let n=e.assetManager.assetStore;return n._listWithBytes?(await n._listWithBytes()).map(({data:i,...o})=>({...o,url:QO(o.contentType,i)})):await n.list()}),Ut("POST /api/assets",async n=>{let r=n.options.headers?.["Content-Type"]||n.options.headers?.["content-type"],i=n.options.body??"",o=en.decode(i),s=await e.assetManager.assetStore.create({data:o,contentType:r});return await e.assetManager.fetch(),{...s,url:QO(r,o)}}),Ut("DELETE /api/assets/:id",async(n,r)=>{let i=r?.[1];if(!i)throw new Error("Missing asset id");return await e.assetManager.assetStore.delete(i),await e.assetManager.fetch(),{success:!0}})]}function z6(e){return e.encoding==="base64"?en.decode(e.content):new TextEncoder().encode(e.content)}function YO(e){if("fileId"in e&&typeof e.fileId=="string")return e.fileId}var JO=new Set(["directory","asset","file","resource"]),Zl=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),Fn=(e,t,n={})=>{if(!(e===void 0&&n.optional)&&typeof e!="string")throw new Error(`Invalid PATCH request: ${t} must be a string`)},XO=(e,t)=>{if(!Zl(e))throw new Error(`Invalid PATCH request: ${t} must be an object`);if(Fn(e.content,`${t}.content`),Fn(e.contentType,`${t}.contentType`),e.encoding!=="base64"&&e.encoding!=="utf-8")throw new Error(`Invalid PATCH request: ${t}.encoding must be base64 or utf-8`)},H6=e=>{if(!Zl(e))throw new Error("Invalid PATCH request: body must be an object");for(let i of["create","update","delete"])if(e[i]!==void 0&&!Array.isArray(e[i]))throw new Error(`Invalid PATCH request: ${i} must be an array`);let t=e.create,n=e.update,r=e.delete;if((t?.length??0)===0&&(n?.length??0)===0&&(r?.length??0)===0)throw new Error("PATCH body must include create, update, or delete arrays");return t?.forEach((i,o)=>{let s=`create[${o}]`;if(!Zl(i))throw new Error(`Invalid PATCH request: ${s} must be an object`);if(Fn(i.path,`${s}.path`),typeof i.type!="string"||!JO.has(i.type))throw new Error(`Invalid PATCH request: ${s}.type is invalid`);switch(i.type){case"asset":if(Fn(i.assetId,`${s}.assetId`,{optional:!0}),i.asset!==void 0&&XO(i.asset,`${s}.asset`),i.assetId===void 0&&i.asset===void 0)throw new Error(`Invalid PATCH request: ${s} requires assetId or asset`);break;case"file":Fn(i.fileId,`${s}.fileId`);break;case"resource":Fn(i.fileId,`${s}.fileId`),Fn(i.resourceId,`${s}.resourceId`);break}}),n?.forEach((i,o)=>{let s=`update[${o}]`;if(!Zl(i))throw new Error(`Invalid PATCH request: ${s} must be an object`);if(Fn(i.id,`${s}.id`),Fn(i.path,`${s}.path`,{optional:!0}),Fn(i.assetId,`${s}.assetId`,{optional:!0}),Fn(i.fileId,`${s}.fileId`,{optional:!0}),Fn(i.fileVersionId,`${s}.fileVersionId`,{optional:!0}),Fn(i.resourceId,`${s}.resourceId`,{optional:!0}),i.type!==void 0&&(typeof i.type!="string"||!JO.has(i.type)))throw new Error(`Invalid PATCH request: ${s}.type is invalid`);i.asset!==void 0&&XO(i.asset,`${s}.asset`)}),r?.forEach((i,o)=>{let s=`delete[${o}]`;if(!Zl(i))throw new Error(`Invalid PATCH request: ${s} must be an object`);Fn(i.id,`${s}.id`)}),e};function VS(e,t){if(typeof t.fileVersionId=="string")return t.fileVersionId;if(typeof t.fileId=="string")return t.fileId;if(e.type==="file"||e.type==="resource")return e.fileId}function tm(e,t){return[Ut("GET /api/resources",async()=>{let n=Zs(e,t.offlineStorageKey);return await n.runExclusive(async()=>{let r=await n.list();return e.resourceManager.setResources(r),e.resourceManager.isInitialized$.set(!0),r})}),Ut("PATCH /api/resources",async n=>{let r=Zs(e,t.offlineStorageKey),i=n.options?.body??"{}",o;try{o=JSON.parse(i)}catch{throw new Error("Invalid request body")}let s=H6(o),a=s.create??[],c=s.update??[],l=s.delete??[];return await r.runExclusive(async()=>{let p=await r.list(),d=new Map(p.map(b=>[b.id,b]));for(let b of c){let f=d.get(b.id);if(!f)throw new Error(`Resource ${b.id} not found`);let g=b.type??f.type;if(g==="asset"&&!b.asset&&!b.assetId&&f.type!=="asset")throw new Error(`Missing assetId for resource ${f.id}`);if((g==="file"||g==="resource")&&!VS(f,b))throw new Error(`Missing fileId for resource ${f.id}`);if(g==="resource"&&!b.resourceId&&f.type!=="resource")throw new Error(`Missing resourceId for resource ${f.id}`)}for(let b of l)if(!d.has(b.id))throw new Error(`Resource ${b.id} not found`);let m=[],y=[],S=[],T=[],E=async({assetId:b,asset:f})=>{if(!f)return b;let g=await e.assetManager.create({data:z6(f),contentType:f.contentType}),v=e.assetManager._getServerAssetId(g.id)??g.id;return T.push(v),v};try{for(let f of a){let g=new Date().toISOString(),v={id:te(),stableId:te(),path:f.path,createdAt:g,updatedAt:g,accessibleByFileId:null,accessibleByFileVersionId:null},I;switch(f.type){case"directory":I={...v,type:"directory"};break;case"asset":{let M=await E(f);if(!M)throw new Error(`Missing assetId for resource ${f.path}`);I={...v,type:"asset",assetId:M};break}case"file":{let M=YO(f);if(!M)throw new Error(`Missing fileId for resource ${f.path}`);I={...v,type:"file",fileId:M};break}case"resource":{let M=YO(f);if(!M)throw new Error(`Missing fileId for resource ${f.path}`);I={...v,type:"resource",fileId:M,resourceId:f.resourceId};break}}d.set(I.id,I),m.push(I)}for(let f of c){let g=d.get(f.id);if(!g)throw new Error(`Resource ${f.id} not found`);let v=f.type??g.type,I={id:g.id,stableId:g.stableId,path:f.path??g.path,createdAt:g.createdAt,updatedAt:new Date().toISOString(),accessibleByFileId:g.accessibleByFileId??null,accessibleByFileVersionId:g.accessibleByFileVersionId??null,...g.url?{url:g.url}:{}},M;switch(v){case"directory":M={...I,type:"directory"};break;case"asset":{let O=await E({assetId:f.assetId??(g.type==="asset"?g.assetId:void 0),asset:f.asset});if(!O)throw new Error(`Missing assetId for resource ${g.id}`);M={...I,type:"asset",assetId:O};break}case"file":{let O=VS(g,f);if(!O)throw new Error(`Missing fileId for resource ${g.id}`);M={...I,type:"file",fileId:O};break}case"resource":{let O=VS(g,f),C=f.resourceId??(g.type==="resource"?g.resourceId:void 0);if(!O||!C)throw new Error(`Missing fileId/resourceId for resource ${g.id}`);M={...I,type:"resource",fileId:O,resourceId:C};break}}d.set(M.id,M),y.push(M)}for(let f of l){let g=d.get(f.id);if(!g)throw new Error(`Resource ${f.id} not found`);d.delete(f.id),S.push(g)}let b=[...d.values()];return await r.replaceAll(b),e.resourceManager.setResources(b),e.resourceManager.isInitialized$.set(!0),{created:m,updated:y,deleted:S}}catch(b){for(let f of T.reverse())try{await e.assetManager.delete(f)}catch(g){console.warn(`[localRpcHelpers] Failed to roll back asset ${f}`,g)}throw b}})})]}function nm(e,t,n){let r;try{if(typeof localStorage<"u"){let o=localStorage.getItem(`${n.offlineStorageKey}:name`);o!==null&&(r=o,e.filePropertyManager.setName(o))}}catch{}r===void 0&&(r=e.filePropertyManager.optimisticValue$.get()),r!==void 0&&t({type:"fileName",name:r}),t({type:"secrets",secrets:[]}),t({type:"inputs",inputs:[]}),t({type:"outputTransforms",outputTransforms:[]});let i=Zs(e,n.offlineStorageKey);i.runExclusive(async()=>{let o=await i.list();e.resourceManager.setResources(o),e.resourceManager.isInitialized$.set(!0),t({type:"resources",resources:o})}).catch(o=>{console.warn("[localRpcHelpers] Failed to load local resources for initialization",o);let s=e.resourceManager.resources$.get();e.resourceManager.isInitialized$.set(!0),t({type:"resources",resources:s})})}async function QS(e,t,n,r){let i=t.options?.method?.toUpperCase(),o=t.url.split("?")[0];try{let s=[...em({emitStreamEvent:async(a,c)=>{n({type:"chunk",id:a.id,chunk:`${JSON.stringify(c)}
71
+ `}),(c.type==="text-delta"||c.type==="partial-object")&&await new Promise(l=>setTimeout(l,750))}}),...WO(e,{offlineStorageKey:r?.offlineStorageKey}),...tm(e,{offlineStorageKey:r?.offlineStorageKey})];for(let a of s)if(a.method===i&&a.pattern.test(o)){let c=o.match(a.pattern),l=await a.handler(t,c);return(a.key==="GET /api/resources"||a.key==="PATCH /api/resources")&&n({type:"resources",resources:e.resourceManager.resources$.get()}),n({type:"end",id:t.id,response:Wd(l)}),!0}return!1}catch(s){return n({type:"error",id:t.id,error:s instanceof Error?s.message:String(s??"error")}),!0}}u();u();async function Wl(e,t,n){switch(t.type){case"init":{let r=typeof localStorage<"u"?localStorage.getItem(e):null,i=`${e}:schemaVersion`,o,s=t.schema?Eo(t.schema):void 0;if(t.force||!r)typeof localStorage<"u"&&(localStorage.setItem(e,JSON.stringify(t.object)),s&&typeof s.version=="number"&&localStorage.setItem(i,String(s.version))),o=t.object;else if(o=JSON.parse(r),s&&typeof s.version=="number"){let a=typeof localStorage<"u"?localStorage.getItem(i):null,c=a?parseInt(a,10):0,l=s.version;if(l>c&&n?.onSchemaMigration)try{let p=await Promise.resolve(n.onSchemaMigration({fromVersion:c,toVersion:l,currentState:o,newSchema:s}));p!==void 0&&(o=p)}catch(p){console.error("Schema migration failed:",p)}typeof localStorage<"u"&&localStorage.setItem(i,String(l))}return s&&(o=ml(s,void 0,o)),typeof localStorage<"u"&&r&&localStorage.setItem(e,JSON.stringify(o)),{type:"object",object:o,...s?{schema:t.schema}:{}}}case"patch":{let r=typeof localStorage<"u"?localStorage.getItem(e):null;if(!r)return{id:t.id,type:"rejectPatch",reason:"serverStateNotInitialized"};let i=JSON.parse(r);try{i=De(i,t.patches)}catch{return{id:t.id,type:"rejectPatch",reason:"errorApplyingPatch"}}return typeof localStorage<"u"&&localStorage.setItem(e,JSON.stringify(i)),{type:"acceptPatch",id:t.id,patches:t.patches}}default:return null}}async function YS(e,t,{isRemoteActive:n,sendRemoteMessage:r,localStorageKey:i,sendToChild:o}){if(n){if(!r){console.warn("[routeEmbeddedMultiplayerMessage] Remote active but no sendRemoteMessage provided");return}r(t);return}if(!i)return;let s=await Wl(i,t);s&&(Lo(s,e),o(s))}u();async function JS(e,{baseUrl:t,token:n,debug:r},i){try{if(e.streaming){let o=_o(e,{baseUrl:t,token:n,streaming:!0,debug:r});for await(let s of o)if(s.type==="chunk")i({type:"chunk",id:e.id,chunk:s.chunk});else if(s.type==="error"){i({type:"error",id:e.id,error:s.error});break}else s.type==="end"&&i({type:"end",id:e.id,response:s.response})}else{let o=await jo(e,{baseUrl:t,token:n,debug:r});o.type==="error"?i({type:"error",id:e.id,error:o.error}):o.type==="end"&&i({type:"end",id:e.id,response:o.response})}}catch(o){i({type:"error",id:e.id,error:o instanceof Error?o.message:String(o)})}}function G6(e,t,n={}){let{multiplayerUrl:r,offlineStorageKey:i,sendToChild:o,debug:s}=t,{createRemoteConnection:a=qO,routeEmbeddedMultiplayerMessage:c=YS}=n,l=r?a(e,{url:r,debug:s}):void 0,p=qS(e,o);return r||(ac(e,i),nm(e,o,{offlineStorageKey:i})),{destroy:()=>{p(),l?.destroy()},handleChildMultiplayer:d=>{c(e,d,{isRemoteActive:!!r,sendRemoteMessage:l?.sendMessage,localStorageKey:i,sendToChild:o})},bridgeChildRpc:async(d,m)=>{if(m&&m.baseUrl&&m.token){await JS(d,{baseUrl:m.baseUrl,token:m.token,debug:m.debug},S=>o(S));return}await QS(e,d,S=>o(S),{offlineStorageKey:i})||o({type:"error",id:d.id,error:"RPC URL not configured"})}}}u();u();function cc(e,t,n){return`${e}:${t}:${n}`}function eA(e){let t=0;for(let n=0;n<e.length;n++){let r=e.charCodeAt(n);t=(t<<5)-t+r,t=t&t}return t.toString(36)}var ep=class{constructor(t){this.options=t}files=new Map;async handleMessage(t){switch(t.type){case"gitFileEdit.open":return await this.open(t.repoId,t.filePath,t.ref),!0;case"gitFileEdit.close":return await this.close(t.repoId,t.filePath,t.ref),!0;case"gitFileEdit.patch":return this.patch(t.repoId,t.filePath,t.ref,t.id,t.patches),!0;default:return!1}}async open(t,n,r){let i=cc(t,r,n),o=this.files.get(i);if(o){this.options.sendMessage({type:"gitFileEdit.object",repoId:t,filePath:n,ref:r,content:o.content,hash:o.hash});return}let s="";try{s=(await(await this.options.getGit()).readFile(t,n,r)).content}catch{s=""}let a=eA(s);o={content:s,hash:a,dirty:!1},this.files.set(i,o),this.options.sendMessage({type:"gitFileEdit.object",repoId:t,filePath:n,ref:r,content:s,hash:a})}async close(t,n,r){let i=cc(t,r,n);this.files.get(i)?.dirty&&await this.persist(t,n,r),this.files.delete(i)}patch(t,n,r,i,o){let s=cc(t,r,n),a=this.files.get(s);if(!a){this.options.sendMessage({type:"gitFileEdit.rejectPatch",repoId:t,filePath:n,ref:r,id:i,reason:"serverStateNotInitialized"});return}try{let c=De(a.content,o),l=eA(c);a.content=c,a.hash=l,a.dirty=!0,this.options.sendMessage({type:"gitFileEdit.acceptPatch",repoId:t,filePath:n,ref:r,id:i,patches:o,hash:l}),this.options.onPersistNeeded?.(t,r,n)}catch(c){this.options.sendMessage({type:"gitFileEdit.rejectPatch",repoId:t,filePath:n,ref:r,id:i,reason:"errorApplyingPatch",error:c instanceof Error?c.message:String(c)})}}getContent(t,n,r){let i=cc(t,r,n);return this.files.get(i)?.content}isDirty(t,n,r){let i=cc(t,r,n);return this.files.get(i)?.dirty??!1}async persist(t,n,r){let i=cc(t,r,n),o=this.files.get(i);if(!o||!o.dirty)return;let a=await(await this.options.getGit()).patchFiles(t,{create:[{path:n,content:o.content}]},r);return o.dirty=!1,this.options.sendMessage({type:"gitFileEdit.committed",repoId:t,ref:r,oid:a.oid}),{oid:a.oid}}getDirtyFiles(){let t=[];for(let[n,r]of this.files.entries())if(r.dirty){let[i,o,...s]=n.split(":");t.push({repoId:i,ref:o,filePath:s.join(":")})}return t}};u();function XS(e){return({noyaManager:t})=>{let n=e.key,r=`${n}:name`,i=e.serverScripts,o=null,s={},a=new Map,c=(N,H,j)=>{MS({store:a,connectionId:N,queue:H,payload:j,onQueueActivity:L=>o?.handleInputQueueActivity(L)})},l=N=>OS(a,N),p=()=>i?.randomUUID?i.randomUUID():typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():te(),d=e.identity?.userId,m=e.identity?.clientId??hi.get()??te(),y=d??m??"me",S={id:d??y,authId:d??void 0,connectionId:y,clientId:m,name:e.identity?.name??Js.get()??"Me",image:e.identity?.image??Xs.get()};t.userManager.setAllUsers([S]),t.userManager.setCurrentConnectionId(y),t.userManager.setCurrentUserId(d??y),t.sharedConnectionDataManager.setCurrentConnectionId(y);let T=ac(t,n),E=Zs(t,n);if(t.secretManager.isInitialized$.set(!0),t.ioManager.inputsInitialized$.set(!0),t.ioManager.outputTransformsInitialized$.set(!0),E.runExclusive(async()=>{let N=await E.list();t.resourceManager.setResources(N),t.resourceManager.isInitialized$.set(!0)}).catch(N=>{console.warn("[localStorageSync] Failed to load local resources from IndexedDB",N),t.resourceManager.isInitialized$.set(!0)}),t.rpcManager.setIsConnected(!0),i){let N={getQuickJSModule:i.getQuickJSModule,randomUUID:i.randomUUID,environment:{target:"local-storage",mode:"live",label:"server"},getState:()=>t.multiplayerStateManager.getConfirmedState(),getSharedConnectionData:()=>s,setSharedConnectionData:H=>{s=H},drainInputQueue:H=>l(H),applyState:async({scriptId:H,nextState:j,invocation:L,timestamp:V})=>{let ne=t.multiplayerStateManager.getConfirmedState();if(ne===void 0)return;let[it]=Qr(ne,j,{useExtendedPatches:!0});if(it.length!==0){t.multiplayerStateManager.incomingMessages.push({type:"acceptPatch",id:`serverScript:${H}:${p()}`,patches:it,serverInvocation:L!==void 0&&V!==void 0?{scriptId:H,invocation:L,timestamp:V}:void 0}),t.multiplayerStateManager.processIncomingMessages();try{if(typeof localStorage<"u"){let xt=t.multiplayerStateManager.getConfirmedState();xt!==void 0&&localStorage.setItem(n,JSON.stringify(xt))}}catch{}o?.handleStateChange(it)}},log:H=>{let j=H.values.map(L=>Vs(L));console[H.level]("[server]",H.scriptId,...j),t.logManager.append({id:p(),scriptId:H.scriptId,level:H.level,values:j,timestamp:Date.now(),origin:H.origin,target:H.target,mode:H.mode})}};o=new Qs(N),o.setIsHot(!0),o.updateSchema(t.multiplayerStateManager.schema)}try{if(typeof localStorage<"u"){let N=localStorage.getItem(r);N!==null&&t.filePropertyManager.setName(N)}}catch{}let b,f=async N=>{if(N.type==="enqueueInput"){let j=N.connectionId??S.connectionId;c(j,N.queue,N.payload);return}if(b&&await b.handleMessage(N))return;let H=await Wl(n,N,{onSchemaMigration:async({fromVersion:j,toVersion:L,currentState:V,newSchema:ne})=>{if(o)return await o.updateSchema(ne),o.handleSchemaMigration(j,L,V)}});H&&(t.multiplayerStateManager.incomingMessages.push(H),t.multiplayerStateManager.processIncomingMessages(),o&&(H.type==="acceptPatch"&&o.handleStateChange(H.patches),o.updateSchema(t.multiplayerStateManager.schema)))},g=t.multiplayerStateManager.messageEmitter.addListener(f),v=t.multiplayerStateManager.errorEmitter.addListener(N=>{t.connectionEventManager.addEvent({type:"error",error:N})}),I=async(N,H)=>{t.rpcManager.handleMessage({type:"chunk",id:N.id,chunk:`${JSON.stringify(H)}
72
+ `}),(H.type==="text-delta"||H.type==="partial-object")&&await new Promise(j=>setTimeout(j,750))},M=[Ut("PUT /api/file",async N=>{let H=N.options?.body??"{}",j=JSON.parse(H),L=typeof j.name=="string"?j.name:"";try{typeof localStorage<"u"&&localStorage.setItem(r,L)}catch{}return t.filePropertyManager.applyServerUpdate({name:L,changeId:j.changeId}),{name:L,changeId:j.changeId}}),...em({emitStreamEvent:I}),Ut("POST /api/transcriptions",async N=>{let H=N.options?.body??"{}",j=JSON.parse(H),L=j.endpoint;if(!L)throw new Error("Transcription is only supported on noya.io");return await jS({...j,endpoint:L},{resolveAsset:async V=>{let ne=await T?._readWithBytes(V);if(!ne)throw new Error(`Asset ${V} not found`);return{data:ne.data.buffer,contentType:ne.contentType}}})}),...tm(t,{offlineStorageKey:n})],O=e.git,C=new Map,z=5e3;if(O){let N=new jl(t.assetManager),H,j=async()=>(H||(await N.initialize(),H=await O(N)),H);b=new ep({getGit:j,sendMessage:L=>{t.connectionEventManager.addEvent({type:"receive",message:L})},onPersistNeeded:(L,V,ne)=>{let it=`${L}:${V}:${ne}`,xt=C.get(it);xt&&clearTimeout(xt);let ti=setTimeout(async()=>{C.delete(it);try{await b?.persist(L,ne,V)}catch{}},z);C.set(it,ti)}}),M.push(Ut("POST /api/git/repos",async L=>{let V=await j(),ne=L.options?.body?JSON.parse(L.options.body):void 0;return await V.createRepo(ne)}),Ut("GET /api/git/repos/:id/files",async(L,V)=>{let ne=V?.[1];if(!ne)throw new Error("Repository ID is required");let it=await j(),xt=new URL(L.url,"http://localhost"),ti=xt.searchParams.get("ref")??void 0,Ia=xt.searchParams.get("includeContent")==="true";return await it.listFiles(ne,ti,Ia)}),Ut("GET /api/git/repos/:id/branches",async(L,V)=>{let ne=V?.[1];if(!ne)throw new Error("Repository ID is required");return await(await j()).listBranches(ne)}),Ut("PATCH /api/git/repos/:id/files",async(L,V)=>{let ne=V?.[1];if(!ne)throw new Error("Repository ID is required");let it=await j(),xt=L.options?.body??"{}",ti=JSON.parse(xt),Ia=new URL(L.url,"http://localhost"),uu=Ia.searchParams.get("ref")??void 0,iy=Ia.searchParams.get("includeContent")==="true";return await it.patchFiles(ne,ti,uu,iy)}))}let F=t.rpcManager.addListener(async N=>{let H=N.options?.method?.toUpperCase(),j=N.url.split("?")[0];for(let L of M)if(L.method===H&&L.pattern.test(j)){try{let V=j.match(L.pattern),ne=await L.handler(N,V);t.rpcManager.handleMessage({type:"end",id:N.id,response:Wd(ne)})}catch(V){t.rpcManager.handleMessage({type:"error",id:N.id,error:V instanceof Error?V.message:String(V??"error")})}return}t.rpcManager.handleMessage({type:"error",id:N.id,error:`RPC route is not available in local mode: ${H} ${j}`})});return t.multiplayerStateManager.connect(),()=>{g(),v(),F(),o?.setIsHot(!1),o?.dispose(),o=null,s={},a.clear();for(let N of C.values())clearTimeout(N);C.clear(),b=void 0,t.multiplayerStateManager.disconnect(),t.rpcManager.setIsConnected(!1)}}}function q6(e){if(!(typeof localStorage>"u"))for(let[t,n]of e)localStorage.setItem(t,n)}u();function V6(e,t){return e&&e.length>0?e:t?`${t}-local`:"noya-local"}u();u();u();u();var tA=require("react");u();var rm=e=>typeof e>"u"?"key":/Mac/.test(e.platform)?"mac":/Win/.test(e.platform)?"win":/Linux|X11/.test(e.platform)?"linux":"key";var nA="ignore-global-events";var CAe=typeof navigator<"u"?rm(navigator):"key";u();u();u();var qi={8:"Backspace",9:"Tab",10:"Enter",12:"NumLock",13:"Enter",16:"Shift",17:"Control",18:"Alt",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",44:"PrintScreen",45:"Insert",46:"Delete",59:";",61:"=",91:"Meta",92:"Meta",106:"*",107:"+",108:",",109:"-",110:".",111:"/",144:"NumLock",145:"ScrollLock",160:"Shift",161:"Shift",162:"Control",163:"Control",164:"Alt",165:"Alt",173:"-",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'"},om={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},Q6=typeof navigator<"u"&&/Mac/.test(navigator.platform),Y6=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(Mt=0;Mt<10;Mt++)qi[48+Mt]=qi[96+Mt]=String(Mt);var Mt;for(Mt=1;Mt<=24;Mt++)qi[Mt+111]="F"+Mt;var Mt;for(Mt=65;Mt<=90;Mt++)qi[Mt]=String.fromCharCode(Mt+32),om[Mt]=String.fromCharCode(Mt);var Mt;for(im in qi)om.hasOwnProperty(im)||(om[im]=qi[im]);var im;function rA(e){var t=Q6&&e.metaKey&&e.shiftKey&&!e.ctrlKey&&!e.altKey||Y6&&e.shiftKey&&e.key&&e.key.length==1||e.key=="Unidentified",n=!t&&e.key||(e.shiftKey?om:qi)[e.keyCode]||e.key||"Unidentified";return n=="Esc"&&(n="Escape"),n=="Del"&&(n="Delete"),n=="Left"&&(n="ArrowLeft"),n=="Up"&&(n="ArrowUp"),n=="Right"&&(n="ArrowRight"),n=="Down"&&(n="ArrowDown"),n}u();function J6(e,t){let n=e.split(/-(?!$)/),r=n[n.length-1];r==="Space"&&(r=" ");let i={altKey:!1,ctrlKey:!1,shiftKey:!1,metaKey:!1};if(n.length===1){if(/^(cmd|meta)$/i.test(r))return{key:"Meta",modifiers:i};if(/^alt$/i.test(r))return{key:"Alt",modifiers:i};if(/^(ctrl|control)$/i.test(r))return{key:"Ctrl",modifiers:i};if(/^shift$/i.test(r))return{key:"Shift",modifiers:i};if(/^mod$/i.test(r))return t==="mac"?{key:"Meta",modifiers:i}:{key:"Ctrl",modifiers:i}}for(let o=0;o<n.length-1;++o){let s=n[o];if(/^(cmd|meta)$/i.test(s))i.metaKey=!0;else if(/^alt$/i.test(s))i.altKey=!0;else if(/^(ctrl|control)$/i.test(s))i.ctrlKey=!0;else if(/^shift$/i.test(s))i.shiftKey=!0;else if(/^mod$/i.test(s))t==="mac"?i.metaKey=!0:i.ctrlKey=!0;else throw new Error("Unrecognized modifier name: "+s)}return{key:r,modifiers:i}}function tp(e,t){let n=J6(e,t),r=n.key;return n.modifiers.altKey&&(r="Alt-"+r),n.modifiers.ctrlKey&&(r="Ctrl-"+r),n.modifiers.metaKey&&(r="Meta-"+r),n.modifiers.shiftKey&&(r="Shift-"+r),r}function sm(e,t,n){return t.altKey&&(e="Alt-"+e),t.ctrlKey&&(e="Ctrl-"+e),t.metaKey&&(e="Meta-"+e),n!==!1&&t.shiftKey&&(e="Shift-"+e),e}function iA(e,t){let n=e[t]||e.key;return n?tp(n,t):void 0}var X6=new Set(["Alt","Control","Meta","Shift"]);function oA(e,t){let n=rA(e),r=n.length===1&&n!==" ",i={altKey:e.altKey,shiftKey:e.shiftKey,ctrlKey:e.ctrlKey,metaKey:e.metaKey},o=tp(X6.has(n)?n:sm(n,i,!r),t),s=[o],a=qi[e.keyCode];if(r){let c;(e.shiftKey||e.altKey||e.metaKey)&&a&&a!==o?c=tp(sm(a,i,!0),t):e.shiftKey&&(c=tp(sm(o,i,!0),t)),c&&!s.includes(c)&&s.push(c)}return s}var ex="fallthrough";function sA(e,t){let n=Array.isArray(e)?e:Object.entries(e);return Object.fromEntries(n.flatMap(([r,i])=>{let o=iA(typeof r=="string"?{key:r}:r,t);return o?[[o,i]]:[]}))}var Z6=(e,t,n,r={})=>{let i=sA(n,t),s=oA(e,t).find(l=>l in i);if(!s)return;let a=i[s],c=typeof a=="function"?{command:a}:a;if(!(r.invokedWithinInput&&!c.allowInInput))return c.command},ZS=(e,t,n,r={})=>{let i=Z6(e,t,n,r);if(!i)return;i()!==ex&&(e.preventDefault(),e.stopImmediatePropagation())};function WS(e){if(!(e instanceof HTMLElement))return!0;let t=e,n=t.closest("[contenteditable]");return n&&(t=n),t.classList.contains(nA)?!1:!!(t instanceof HTMLInputElement&&t.type!=="checkbox"&&t.type!=="radio"||t instanceof HTMLTextAreaElement||t instanceof HTMLIFrameElement||t.hasAttribute("contenteditable"))}u();var aA=Q(ad()),cA=(0,aA.defineTree)(e=>e.type==="submenu"?e.items:[]),uA=e=>e.flatMap(t=>cA.flat(t)).flatMap(t=>t.type?[]:[t]),tx=e=>uA(e).filter(t=>!!t.shortcut);u();function am(){return{postMessage:(e,t)=>window.parent.postMessage(e,t),addMessageListener:e=>(window.addEventListener("message",e),()=>window.removeEventListener("message",e))}}function lA(e){if(!e||typeof e!="object"||!("type"in e)||typeof e.type!="string")return!1;switch(e.type){case"connection":return"state"in e&&(e.state==="connected"||e.state==="disconnected");case"application.selectMenuItem":return"payload"in e&&typeof e.payload=="object";case"application.pickImage.result":return"payload"in e&&typeof e.payload=="object"&&typeof e.payload?.id=="string";case"rpc.response":case"rpc.chunk":case"rpc.error":return"payload"in e&&typeof e.payload=="object";default:return!0}}function pA(e){if(!e||typeof e!="object"||!("type"in e))return!1;switch(e.type){case"multiplayer.ready":return!0;case"multiplayer.message":return"payload"in e;case"application.setMenuItems":return"payload"in e&&Array.isArray(e.payload?.menuItems)&&typeof e.payload.position=="string"&&(e.payload.position==="left"||e.payload.position==="right");case"application.pickImage":return"payload"in e&&typeof e.payload=="object"&&typeof e.payload?.id=="string";case"ai.setConfig":return"payload"in e&&typeof e.payload=="object"&&typeof e.payload?.tools=="object";case"ai.tool.response":return"payload"in e&&typeof e.payload=="object"&&typeof e.payload?.invocation=="object";case"ai.setContext":return"payload"in e&&typeof e.payload=="object";case"rpc.request":return"payload"in e&&typeof e.payload=="object";default:return!1}}function W6(e,t){let n=e?.access,r=t!==void 0?t:e?.id;if(n===void 0&&r===void 0)return;let i={};return n!==void 0&&(i.access=n),r!==void 0&&(i.id=r),i}function nx(e={}){let{debug:t=!1,origin:n="*",messageHandler:r=am(),policyAuthContext:i,enableDocumentAI:o=!1}=e;return({noyaManager:s})=>{t&&console.info("[parentFrameSync] Initializing",s);let a=i,c,l=j=>{let L=W6(a,j);L&&(c&&c.access===L.access&&c.id===L.id||(c=L,s.multiplayerStateManager.setPolicyAuthContext(L)))};l(s.userManager.currentUserId$.get());let p=s.userManager.currentUserId$.subscribe(j=>{l(j)});s.assetManager.assetStore=new $i(s.rpcManager),s.resourceManager.isInitialized$.set(!0),s.imagePickerManager.setIsAvailable(!0);let d=async j=>{if(t&&console.info("[parentFrameSync] receiving message",j.data),n!=="*"&&j.origin!==n)return;let V=j.data;switch(V.type){case"end":case"chunk":case"error":s.rpcManager.handleMessage(V);break;case"application.setAvoidRects":{s.avoidRects$.set(V.payload.rects);break}case"application.selectMenuItem":s.menuManager.emit(V.payload.value);break;case"application.pickImage.result":s.imagePickerManager.handleResponse(V.payload);break;case"connection":s.connectionEventManager.addEvent({type:"stateChange",state:V.state==="connected"?"OPEN":"CLOSED"});break;case"ai.tool.call":{let ne;try{ne=await s.aiManager.callTool(V.payload)}catch(xt){ne=JSON.stringify({ok:!1,error:xt instanceof Error?xt.message:String(xt)})}let it={type:"ai.tool.response",payload:{invocation:V.payload,response:ne}};r.postMessage(it,n);break}case"application.evaluate.result":{s.evalManager.responseEmitter.emit(V.payload);break}case"application.requestPublish":{if(!s.publishingManager.getFilesToPublish)break;let ne=await s.publishingManager.getFilesToPublish();if(!ne)break;let it={type:"application.publish",payload:{id:V.payload.id,files:ne}};r.postMessage(it,n);break}default:{if(V.type==="object"&&V.object===null){console.log("null object message",V),s.connectionEventManager.addEvent({type:"receive",message:V});break}if(Xl(V,s),V.type==="connectedUsers"){let ne=s.userManager.currentUserId$.get(),it=s.userManager.currentClientId$.get(),xt=V.users.find(ti=>ne!==void 0&&ti.authId===ne||it!==void 0&&ti.clientId===it);xt&&(s.userManager.setCurrentConnectionId(xt.connectionId),s.sharedConnectionDataManager.setCurrentConnectionId(xt.connectionId))}s.multiplayerStateManager.incomingMessages.push(V),s.multiplayerStateManager.processIncomingMessages(),s.connectionEventManager.addEvent({type:"receive",message:V});break}}},m=s.evalManager.requestEmitter.addListener(j=>{let L={type:"application.evaluate",payload:j};window.parent?.postMessage(L,n)}),y=s.menuManager.leftMenuItems$.subscribe(j=>{let L={type:"application.setMenuItems",payload:{menuItems:j,position:"left"}};t&&console.info("[parentFrameSync] sending left menu items",L),window.parent?.postMessage(L,"*")}),S=s.menuManager.showCommandPaletteEmitter.addListener(j=>{let L={type:"application.showCommandPalette",payload:j};window.parent?.postMessage(L,"*")}),T=s.imagePickerManager.requestEmitter.addListener(j=>{let L={type:"application.pickImage",payload:j};r.postMessage(L,n)}),E=s.menuManager.rightMenuItems$.subscribe(j=>{let L={type:"application.setMenuItems",payload:{menuItems:j,position:"right"}};t&&console.info("[parentFrameSync] sending right menu items",L),window.parent?.postMessage(L,"*")}),b=j=>{let L=tx(s.menuManager.allMenuItems$.get()).map(ne=>{let it={command:()=>s.menuManager.emit(ne.value)};return[ne.shortcut,it]}),V=WS(j.target);ZS(j,rm(navigator),L,{invokedWithinInput:V})};window.addEventListener("keydown",b);let f=()=>{window.removeEventListener("keydown",b)},g={type:"multiplayer.ready"};r.postMessage(g,n);let v=r.addMessageListener(d),I=s.multiplayerStateManager.messageEmitter.addListener(j=>{t&&console.info("[parentFrameSync] sending message",j),s.connectionEventManager.addEvent({type:"send",message:j});let L={type:"multiplayer.message",payload:j};r.postMessage(L,n)}),M=s.rpcManager.addListener(async j=>{if(!j.id){console.error("[parentFrameSync] RPC request has no id",j);return}let L={type:"rpc.request",payload:j};t&&console.info("[parentFrameSync] sending rpc request",L),r.postMessage(L,n)}),O=o?Ml(s):void 0,C=s.aiManager.configuration$.subscribe(({tools:j,systemMessage:L})=>{let V={type:"ai.setConfig",payload:{tools:j,systemMessage:L}};r.postMessage(V,n)}),z=o?s.multiplayerStateManager.optimisticState$.subscribe(j=>{let L={type:"ai.setContext",payload:{state:j,schema:s.multiplayerStateManager.schema}};r.postMessage(L,n)}):void 0,F=s.publishingManager.enablePublishing$.subscribe(j=>{let L={type:"application.enablePublishing",payload:j};r.postMessage(L,n)}),N=s.sharedConnectionDataManager.currentConnectionDataEmitter.addListener(j=>{let L=s.sharedConnectionDataManager.currentConnectionId$.get();if(!L)return;let V={type:"multiplayer.message",payload:{type:"setSharedConnectionData",connectionId:L,data:j}};r.postMessage(V,n)}),H=s.multiplayerStateManager.errorEmitter.addListener(j=>{s.connectionEventManager.addEvent({type:"error",error:j})});return s.multiplayerStateManager.connect(),s.rpcManager.setIsConnected(!0),()=>{t&&console.info("[parentFrameSync] Cleaning up"),v(),y(),E(),S(),T(),f(),I(),M(),H(),C(),z?.(),O?.(),m(),F(),N(),p(),s.imagePickerManager.setIsAvailable(!1),s.multiplayerStateManager.disconnect(),s.rpcManager.setIsConnected(!1)}}}u();function np(e={}){return({noyaManager:t})=>{e.initialStoreAssetsForDebugging&&(t.assetManager.assetStore=new Ja({initialAssets:e.initialStoreAssetsForDebugging})),t.secretManager.isInitialized$.set(!0),t.ioManager.inputsInitialized$.set(!0),t.ioManager.outputTransformsInitialized$.set(!0),t.resourceManager.isInitialized$.set(!0),t.assetManager.isInitialized$.set(!0);let n=o=>{switch(o.type){case"init":{t.multiplayerStateManager.incomingMessages.push({type:"object",object:o.object,schema:o.schema}),t.multiplayerStateManager.processIncomingMessages();break}case"patch":{let s=e.debugOptions?.transformPatches?.(o.patches)??o.patches;t.multiplayerStateManager.incomingMessages.push({type:"acceptPatch",id:o.id,patches:s}),e.debugOptions?.DEBUG_acceptSamePatchTwice&&t.multiplayerStateManager.incomingMessages.push({type:"acceptPatch",id:o.id,patches:s}),t.multiplayerStateManager.processIncomingMessages();break}}},r=t.multiplayerStateManager.messageEmitter.addListener(n),i=t.multiplayerStateManager.errorEmitter.addListener(o=>{t.connectionEventManager.addEvent({type:"error",error:o})});return t.multiplayerStateManager.connect(),()=>{r(),i(),t.multiplayerStateManager.disconnect()}}}u();u();var e8=0;function rx(e,t={}){let{debug:n=!1}=GS(e),r=t.createWebSocketConnection??((i,o)=>new Bo(i,o));return({noyaManager:i})=>{let o=e8++,s,a,c,l=Zd(e).then(({url:S,tokenString:T,tokenPayload:E})=>(s=E.connectionId,a=E.authId??void 0,i.sharedConnectionDataManager.setCurrentConnectionId(s),i.userManager.setCurrentConnectionId(s),i.userManager.setCurrentUserId(a),i.multiplayerStateManager.setPolicyAuthContext({id:a??null,access:E.access}),i.assetManager.assetStore=new $i(i.rpcManager),c=r(S,{debug:n,onConnectionEvent:b=>{switch(n&&console.info(`[webSocketSync] Connection event ${o}`,b),b.type){case"stateChange":{b.state==="OPEN"?(i.multiplayerStateManager.connect(),i.rpcManager.setIsConnected(!0)):b.state==="CLOSED"&&(i.multiplayerStateManager.disconnect(),i.rpcManager.setIsConnected(!1));break}case"receive":{i.connectionEventManager.addEvent(b);let f=b.message;Lo(f,i,{pushToMSM:!0});break}case"send":{i.connectionEventManager.addEvent(b);break}case"error":{i.connectionEventManager.addEvent(b);break}}}}),c.connect(),{url:S,tokenString:T,tokenPayload:E,wsConnection:c})),p=i.multiplayerStateManager.messageEmitter.addListener(S=>{l.then(({wsConnection:T})=>{T?.send(S)})}),d=i.sharedConnectionDataManager.currentConnectionDataEmitter.addListener(S=>{if(!s)return;let T={type:"setSharedConnectionData",connectionId:s,data:S};l.then(({wsConnection:E})=>{E?.send(T)})}),m=i.rpcManager.addListener(async S=>{let{url:T,tokenString:E}=await l;if(S.streaming){let b=_o(S,{baseUrl:T.toString(),token:E,streaming:!0,debug:n});for await(let f of b)i.rpcManager.handleMessage(f)}else{let b=await jo(S,{baseUrl:T.toString(),token:E,debug:n,onUploadProgress:i.rpcManager.requests[S.id]?.onUploadProgress});i.rpcManager.handleMessage(b)}}),y=i.aiManager.invocationEmitter.addListener(async S=>{let T=await i.aiManager.callTool(S);i.aiManager.responseEmitter.emit(S,T)});return n&&console.info(`[webSocketSync] Created ${o}`),()=>{n&&console.info(`[webSocketSync] Destroying ${o}`),c?(n&&console.info(`[webSocketSync] Closing connection ${o}`),c.close()):l.then(({wsConnection:S})=>{n&&console.info(`[webSocketSync] Closing connection ${o}`),S?.close()}),p(),d(),m(),y()}}}function cm(e,t){let n,r,i;for(let o of e)o.authId===t&&(n=o),o.clientId===t&&(i=o),o.connectionId===t&&(r=o);return n??i??r}var rp=class{constructor(t){this.rpcManager=t}currentUserId$=new _(void 0);currentClientId$=hi;currentConnectionId$=new _(void 0);currentId$=_.combine([this.currentUserId$,this.currentClientId$,this.currentConnectionId$],([t,n,r])=>t??n??r);allUsers$=new _([]);connectedUsers$=new _([]);connectedUsersCount$=this.connectedUsers$.map(t=>t.length);currentUser$=_.combine([this.currentId$,this.allUsers$],([t,n])=>cm(n,t));workspaceUsers$=new _([]);#e=!1;initializeWorkspaceUsers(){this.#e||!this.rpcManager||(this.#e=!0,this.fetchWorkspaceMembers().catch(t=>{console.error("Failed to fetch workspace members",t),this.#e=!1}))}setCurrentUserId(t){this.currentUserId$.set(t)}setCurrentConnectionId(t){this.currentConnectionId$.set(t)}setAllUsers(t){this.allUsers$.set(t),this.connectedUsers$.set(t.filter(n=>!n.inactive))}async fetchWorkspaceMembers(){if(!this.rpcManager)return;let t=await this.rpcManager.requestRoute("GET /api/file/members"),n=this.rpcManager.getResponseBody(t)??[];this.workspaceUsers$.set(n)}};function fA({previous:e,next:t}){if(e.metadata.name!==void 0&&e.metadata.name===t.metadata.name&&e.metadata.timestamp+500>t.metadata.timestamp)return Mr.merge({previous:e,next:t})}var Vi=class{id=te();multiplayerStateManager;rpcManager;pipelineManager;scriptEvaluatorManager;secretManager;aiManager;ioManager;imagePickerManager=new Ul;sharedConnectionDataManager=new Cl;assetManager;userManager;taskManager=new Yl;connectionEventManager=new yl;menuManager=new Ll;evalManager;publishingManager=new Kl;resourceManager;activityEventsManager;filePropertyManager;logManager;transcriptionManager;sandboxManager;gitManager;isProcessing$;avoidRects$=new _([]);initialState;options;unrecoverableError=new _(void 0);constructor(t,n={}){n={...n,getSharedConnectionData:n.getSharedConnectionData??(()=>this.sharedConnectionDataManager.data$.get()??{}),mergeHistoryEntries:n.mergeHistoryEntries===void 0?fA:n.mergeHistoryEntries},this.multiplayerStateManager=new Gi(t,n),this.initialState=t,this.options=n,this.assetManager=new dl({initialAssets:n.initialAssets}),this.rpcManager=new ql({debug:this.options.debug}),this.userManager=new rp(this.rpcManager),this.pipelineManager=new $l(this.rpcManager),this.scriptEvaluatorManager=new Vl(this.rpcManager),this.secretManager=new Ql(this.rpcManager,{initialSecrets:n.initialSecrets}),this.aiManager=new fl(this.rpcManager),this.ioManager=new _l(this.rpcManager),this.evalManager=new Ol({safeEval:this.options.safeEval}),this.resourceManager=new Hl(this.rpcManager,{initialResources:n.initialResources,resourceUrlBase:n.resourceUrlBase,sendMessage:i=>this.multiplayerStateManager.sendMessage(i),subscribeConnectionEvents:i=>this.connectionEventManager.events$.subscribe(o=>{let s=o.at(-1);s&&i(s)}),resolveAssetId:i=>this.assetManager._getServerAssetId(i)??i}),this.sandboxManager=new Gl(this.rpcManager),this.gitManager=new Dl(this.rpcManager,this.assetManager,{sendMessage:i=>this.multiplayerStateManager.sendMessage(i),subscribeConnectionEvents:i=>this.connectionEventManager.events$.subscribe(o=>{let s=o.at(-1);s&&i(s)}),includeContent:n.gitIncludeContent}),this.filePropertyManager=new Al(this.rpcManager,{initialName:n.initialFileName}),this.logManager=new zs,this.transcriptionManager=new Jl(this.rpcManager,this.assetManager),this.activityEventsManager=new sl(i=>this.multiplayerStateManager.sendMessage(i));let r=this.resourceManager.patches$.map(i=>i.length>0);this.isProcessing$=_.combine([r,this.filePropertyManager.isUpdating$],([i,o])=>i||o),this.multiplayerStateManager.errorEmitter.addListener(i=>{switch(i.reason){case"invalidDataType":case"schemaMismatch":case"outdatedSchema":case"dataMigrationFailure":case"schemaMigration":this.unrecoverableError.set(i);break}}),this.options.registerDefaultAITools===!0&&Ml(this)}enqueueInput=(t,n)=>{let r=this.userManager.currentConnectionId$.get();this.multiplayerStateManager.sendMessage({type:"enqueueInput",queue:t,payload:n,...r&&{connectionId:r}})};forceInit=()=>{let t=this.initialState instanceof Function?this.initialState():this.initialState,n=this.options?.schema;this.multiplayerStateManager.sm.clearHistory(),this.multiplayerStateManager.sendInit({force:!0,state:t,schema:n})};undo=()=>this.multiplayerStateManager.undo();redo=()=>this.multiplayerStateManager.redo();canUndo=()=>this.multiplayerStateManager.canUndo();canRedo=()=>this.multiplayerStateManager.canRedo();restoreSnapshot=async t=>{let n=await this.rpcManager.requestRoute("POST /api/snapshots/restore",{body:JSON.stringify(t),headers:{"Content-Type":"application/json"}});return JSON.parse(n.body)}};u();function t8(){return{url:"/api/workflow/run",options:{method:"POST"}}}function n8(e,t){return{url:"/api/secrets",options:{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:e,value:t})}}}function r8(e){return{url:"/api/secrets",options:{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:e})}}}u();u();var ix=class{history;prediction;options;constructor(t,n){this.history=[t],this.options={interpolate:n.interpolate,getNow:n.getNow??o8,interpolationDelayMs:n.interpolationDelayMs??100,historyWindowMs:n.historyWindowMs??1e3,maxHistoryEntries:n.maxHistoryEntries??6,maxPredictionBlend:n.maxPredictionBlend??.35,defaultPredictionDelayMs:n.defaultPredictionDelayMs??33,getLatestInvocation:n.getLatestInvocation}}getLatestEntry(){return this.history.at(-1)}getHistory(){return this.history.slice()}setPrediction(t){this.prediction=t}clearPrediction(){this.prediction=void 0}addConfirmedState(t,n={}){let r=n.timestamp??this.options.getNow(),i={state:t,timestamp:r,invocation:n.invocation},s=(n.resetHistory?[]:this.history).concat(i),a=r-this.options.historyWindowMs;this.history=s.filter(c=>c.timestamp>=a).slice(-this.options.maxHistoryEntries)}getRenderState(t=this.options.getNow()){if(this.history.length===0)throw new Error("StateInterpolator has no history to render");let n=t-this.options.interpolationDelayMs,r=this.history[this.history.length-1],i=this.history.slice(0,-1).reverse().find(l=>l.timestamp<=n),o=r.state;if(i){if(n<=i.timestamp||r.timestamp===i.timestamp)o=i.state;else if(n<r.timestamp){let l=(n-i.timestamp)/(r.timestamp-i.timestamp);o=this.options.interpolate(i.state,r.state,l)}}let s=r.invocation??this.options.getLatestInvocation?.(),a=this.prediction,c=a?.invocation;if(a&&s!==void 0&&c!==void 0&&c===s+1){let l=a.timestamp??r.timestamp+this.options.defaultPredictionDelayMs,p=l>r.timestamp?(n-r.timestamp)/(l-r.timestamp):0,d=i8(p,0,this.options.maxPredictionBlend);d>0&&(o=this.options.interpolate(o,a.state,d))}return o}};function i8(e,t,n){return Math.max(t,Math.min(n,e))}function o8(){return typeof performance<"u"&&typeof performance.now=="function"?performance.now():Date.now()}u();u();var uc=class{constructor(t){this.onActivity=t}_activityHandler=()=>{this.onActivity?.()};_visibilityHandler=()=>{document.visibilityState==="visible"&&this.onActivity?.()};addListeners(){typeof window>"u"||(window.addEventListener("mousemove",this._activityHandler),window.addEventListener("keydown",this._activityHandler),window.addEventListener("touchstart",this._activityHandler),window.addEventListener("click",this._activityHandler),document.addEventListener("visibilitychange",this._visibilityHandler))}removeListeners(){typeof window>"u"||(window.removeEventListener("mousemove",this._activityHandler),window.removeEventListener("keydown",this._activityHandler),window.removeEventListener("touchstart",this._activityHandler),window.removeEventListener("click",this._activityHandler),document.removeEventListener("visibilitychange",this._visibilityHandler))}setOnActivity(t){this.onActivity=t}},lc=class extends Ee{websocket=null;timeoutHandle=null;reconnectTimeoutHandle=null;state="CONNECTING";attempt=0;options;url="";protocols;constructor(t={}){super(),this.options={reconnectInterval:1e3,maxReconnectInterval:3e4,reconnectDecay:1.5,timeoutInterval:5e3,maxReconnectAttempts:5,...t},this.options.activityDetector&&this.options.activityDetector.setOnActivity(()=>{this.state==="MAX_ATTEMPTS_EXCEEDED"&&this.resetAndReconnect()})}transitionTo(t){switch(this.options.debug&&console.info(`Transitioning from ${this.state} to ${t}`),this.state=t,this.emit(this.state),this.state){case"CONNECTING":this.connect();break;case"OPEN":this.onOpen();break;case"CLOSING":this.onClosing();break;case"CLOSED":this.onClosed();break;case"RECONNECTING":this.onReconnecting();break;case"MAX_ATTEMPTS_EXCEEDED":this.onMaxAttemptsExceeded();break;case"SHUTDOWN":this.onShutdown();break}}connect(t=this.url,n){this.url=t,this.protocols=n,this.state==="CONNECTING"&&(this.websocket=new WebSocket(this.url,this.protocols),this.timeoutHandle=setTimeout(()=>{this.websocket&&this.websocket.readyState!==WebSocket.OPEN&&(this.options.debug&&console.info("Connection attempt timed out"),this.websocket.close())},this.options.timeoutInterval),this.websocket.onopen=r=>{this.state==="CLOSING"||this.state==="SHUTDOWN"?this.websocket?.close():(this.transitionTo("OPEN"),this.options.onopen?.(r))},this.websocket.onmessage=r=>{this.options.onmessage?.(r)},this.websocket.onclose=r=>{this.state!=="CLOSING"&&this.state!=="SHUTDOWN"&&this.transitionTo("CLOSED"),this.options.onclose?.(r)},this.websocket.onerror=r=>{this.options.onerror?.(r)})}onOpen(){this.timeoutHandle&&(clearTimeout(this.timeoutHandle),this.timeoutHandle=null),this.attempt=0}onClosing(){this.websocket?.close()}onClosed(){this.timeoutHandle&&(clearTimeout(this.timeoutHandle),this.timeoutHandle=null),this.reconnect()}onReconnecting(){if(this.attempt>=this.options.maxReconnectAttempts){this.options.debug&&console.info("Max reconnect attempts reached, not attempting to reconnect."),this.transitionTo("MAX_ATTEMPTS_EXCEEDED");return}let t=Math.min(this.options.reconnectInterval*Math.pow(this.options.reconnectDecay,this.attempt),this.options.maxReconnectInterval);this.options.debug&&console.info(`Reconnecting in ${t/1e3} seconds... (attempt ${this.attempt+1}/${this.options.maxReconnectAttempts})`),this.reconnectTimeoutHandle=setTimeout(()=>{this.attempt++,this.transitionTo("CONNECTING")},t)}onMaxAttemptsExceeded(){this.websocket?.close(),this.timeoutHandle&&(clearTimeout(this.timeoutHandle),this.timeoutHandle=null),this.reconnectTimeoutHandle&&(clearTimeout(this.reconnectTimeoutHandle),this.reconnectTimeoutHandle=null),this.websocket=null,this.options.activityDetector?.addListeners()}onShutdown(){this.websocket?.close(),this.timeoutHandle&&(clearTimeout(this.timeoutHandle),this.timeoutHandle=null),this.reconnectTimeoutHandle&&(clearTimeout(this.reconnectTimeoutHandle),this.reconnectTimeoutHandle=null),this.websocket=null,this.options.activityDetector?.removeListeners()}reconnect(){this.state!=="SHUTDOWN"&&this.transitionTo("RECONNECTING")}resetAndReconnect(){this.options.debug&&console.info("User activity detected after max attempts exceeded. Resetting attempts and reconnecting."),this.attempt=0,this.options.activityDetector?.removeListeners(),this.transitionTo("RECONNECTING")}send(t){this.websocket&&this.websocket.readyState===WebSocket.OPEN?this.websocket.send(t):this.websocket&&this.websocket.readyState===WebSocket.CONNECTING?setTimeout(()=>this.send(t),this.options.timeoutInterval):console.error("WebSocket is not open. Ready state:",this.websocket?.readyState)}close(){this.state!=="CLOSING"&&this.state!=="CLOSED"&&this.state!=="SHUTDOWN"&&this.transitionTo("CLOSING")}shutdown(){this.state!=="SHUTDOWN"&&this.transitionTo("SHUTDOWN")}};u();var BN=require("react");u();u();u();var Qi=Q(require("react"));u();var um=Q(require("react"));function ox(e,t="both"){let[n,r]=um.useState(void 0);return um.useEffect(()=>{if(e.current){let i=e.current,o=new ResizeObserver(s=>{if(!Array.isArray(s)||!s.length)return;let a=s[0],c,l;if("borderBoxSize"in a){let p=a.borderBoxSize,d=Array.isArray(p)?p[0]:p;c=d.inlineSize,l=d.blockSize}else{let p=i.getBoundingClientRect();c=p.width,l=p.height}r(p=>p&&(p.width===c||t==="height")&&(p.height===l||t==="width")?p:{width:c,height:l})});return o.observe(i,{box:"border-box"}),()=>{r(void 0),o.unobserve(i)}}},[e,t]),n}var dA={display:"flex",flex:"1 0 0",flexDirection:"column"},VCe=Qi.memo(function({children:t,className:n}){let r=Qi.useRef(null),i=ox(r);return Qi.createElement("div",{ref:r,style:dA,className:n},i&&i.width>0&&i.height>0&&t(i))}),QCe=Qi.memo(function({children:t,dimension:n,className:r}){let i=Qi.useRef(null),o=ox(i,n);return Qi.createElement("div",{ref:i,style:dA,className:r},o&&o[n]>0&&t(o[n]))});u();var pc=Q(require("react"));u();var Ws=require("react");function mA(e,t){let[n,r]=(0,Ws.useState)(!1),i=(0,Ws.useCallback)(c=>{c.preventDefault()},[]),o=(0,Ws.useCallback)(c=>{c.preventDefault(),e.current?.contains(c.relatedTarget)||r(!0)},[e]),s=(0,Ws.useCallback)(c=>{c.preventDefault(),e.current?.contains(c.relatedTarget)||r(!1)},[e]),a=(0,Ws.useCallback)(c=>{c.preventDefault(),t?.(c),r(!1)},[t]);return t?{dropTargetProps:{onDragOver:i,onDragEnter:o,onDragLeave:s,onDrop:a},isDropTargetActive:n}:{dropTargetProps:{},isDropTargetActive:n}}u();var sx=require("react");var ea=sx.memo;function hA(e,t){return t.includes(e.type)||e.type===""&&e.name.endsWith(".sketch")}var a1e=ea(function({children:t,onDropFiles:n,supportedFileTypes:r,...i}){let o=(0,pc.useRef)(null),s=(0,pc.useCallback)(l=>{l.preventDefault();let p={offsetX:l.nativeEvent.offsetX,offsetY:l.nativeEvent.offsetY},d=Array.from(l.dataTransfer.files).flatMap(y=>hA(y,r)?[]:[y.type]);d.length>0&&alert(`Files of type ${d.join(", ")} aren't supported. The following types are supported: ${r.join(", ")}`);let m=Array.from(l.dataTransfer.files).flatMap(y=>hA(y,r)?[y]:[]);n(m,p)},[n,r]),{dropTargetProps:a,isDropTargetActive:c}=mA(o,s);return pc.default.createElement("div",{ref:o,...a,...i},typeof t=="function"?t(c):t)});u();var yA=require("react");u();var lm=require("react");function gA(e){let t=(0,lm.useMemo)(()=>e===void 0?void 0:JSON.stringify(e),[e]);return(0,lm.useMemo)(()=>t===void 0?void 0:JSON.parse(t),[t])}u();var ax=require("react");u();var bA=require("react");u();u();var SA=require("react");u();var pm=Q(require("react")),ip=typeof window<"u"?pm.useLayoutEffect:pm.useEffect;u();var cx=require("react");u();var a8=require("react");u();var u8=require("react");u();u();var ux=require("react");u();var fm=require("react");u();var xA=require("react");u();var p8=require("react");u();var dm=require("react");var TA=()=>{};function vA(e){let t=(0,dm.useRef)(e||TA);return ip(()=>{t.current=e||TA},[e]),(0,dm.useCallback)((...n)=>t.current(...n),[t])}u();var IA=require("react");u();u();u();var EA=require("react");u();var wA=require("react");u();u();u();var lx=class{getItem(t){return typeof localStorage>"u"?null:localStorage.getItem(t)}setItem(t,n){typeof localStorage>"u"||(n===null?localStorage.removeItem(t):localStorage.setItem(t,n),this.emitter.emit(t,n))}emitter=new Ee;_isListening=!1;addListener(t,n){return!this._isListening&&typeof window<"u"&&(this._isListening=!0,window.addEventListener("storage",r=>{this.emitter.emit(r.key,r.newValue)})),this.emitter.addListener((r,i)=>{r===t&&n(i)})}},TNe=new lx;u();u();u();function f8(e,t){let n=document.createElement("a");n.href=e,t&&(n.download=t),n.style.display="none",document.body.appendChild(n),n.click(),document.body.removeChild(n)}function MA(...e){let t=URL.createObjectURL(e[0]),n=e.length===1?e[0].name:e[1];f8(t,n),URL.revokeObjectURL(t)}u();u();var Oe=Q(require("react"));u();var Ai=require("react");u();var Xt=require("react"),EN=Q(Bv());u();var yn=Q(require("react")),z1=yn.memo(function({error:t}){return yn.createElement("div",{style:{position:"fixed",top:"20px",left:"50%",transform:"translateX(-50%)",maxWidth:"80%",width:"fit-content",padding:"12px 20px",background:"white",color:"black",zIndex:1e4,display:"flex",flexDirection:"column",justifyContent:"center",borderRadius:"4px",boxShadow:"0 4px 6px rgba(0, 0, 0, 0.1)",fontFamily:"'__Inter_6b0edc', '__Inter_Fallback_6b0edc', -apple-system, BlinkMacSystemFont, 'Helvetica Neue', 'Segoe UI', Roboto, Helvetica, Arial, sans-serif",fontSize:"14px",fontWeight:400,lineHeight:"19px"}},t.reason==="schemaMigration"?yn.createElement(yn.Fragment,null,yn.createElement("p",null,"An updated version of Noya is available. Please reload the page to continue.")):yn.createElement(yn.Fragment,null,yn.createElement("p",null,"An error occurred:"," ",yn.createElement("code",{style:{background:"rgba(255, 0, 0, 0.1)",color:"rgba(255, 0, 0, 0.5)",padding:"2px 4px",borderRadius:"4px"}},t.reason),". Please reload the page to continue.",yn.createElement("br",null),yn.createElement("br",null),"If this happens repeatedly, please get in touch and the Noya team can help.")),yn.createElement("div",{style:{height:"1px",background:"rgba(0, 0, 0, 0.1)",margin:"12px -20px"}}),yn.createElement("button",{style:{background:"black",color:"white",padding:"8px 16px",borderRadius:"4px",cursor:"pointer",fontSize:"14px",fontWeight:700,lineHeight:"19px"},onClick:()=>{window.location.reload()}},"Reload"))});u();var cI=Q(require("react")),IN=Q(Bv());u();var k=Q(require("react"));u();var Kh=Q(require("react"),1),sn=Q(require("react"),1),Y1=require("react"),mr=Q(require("react"),1),fo=Q(require("react"),1),ru=Q(require("react"),1),eN=Q(require("react"),1),gn=Q(require("react"),1),Jt=Q(require("react"),1),iu=Q(require("react"),1),Mi=Q(require("react"),1),wi=Q(require("react"),1),xa=Q(require("react"),1),Lr=Q(require("react"),1),nN=Q(require("react"),1),Rt=Q(require("react"),1),yV=Q(require("react"),1),Bq=Object.create,zv=Object.defineProperty,Fq=Object.getOwnPropertyDescriptor,Q1=Object.getOwnPropertyNames,$q=Object.getPrototypeOf,Kq=Object.prototype.hasOwnProperty,Hv=(e,t)=>function(){return t||(0,e[Q1(e)[0]])((t={exports:{}}).exports,t),t.exports},zq=(e,t)=>{for(var n in t)zv(e,n,{get:t[n],enumerable:!0})},Hq=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of Q1(t))!Kq.call(e,i)&&i!==n&&zv(e,i,{get:()=>t[i],enumerable:!(r=Fq(t,i))||r.enumerable});return e},Gq=(e,t,n)=>(n=e!=null?Bq($q(e)):{},Hq(t||!e||!e.__esModule?zv(n,"default",{value:e,enumerable:!0}):n,e)),qq=Hv({"node_modules/is-object/index.js"(e,t){"use strict";t.exports=function(r){return typeof r=="object"&&r!==null}}}),Vq=Hv({"node_modules/is-window/index.js"(e,t){"use strict";t.exports=function(n){if(n==null)return!1;var r=Object(n);return r===r.window}}}),Qq=Hv({"node_modules/is-dom/index.js"(e,t){var n=qq(),r=Vq();function i(o){return!n(o)||!r(window)||typeof window.Node!="function"?!1:typeof o.nodeType=="number"&&typeof o.nodeName=="string"}t.exports=i}}),$h={};zq($h,{chromeDark:()=>Gv,chromeLight:()=>qv});var Gv={BASE_FONT_FAMILY:"Menlo, monospace",BASE_FONT_SIZE:"11px",BASE_LINE_HEIGHT:1.2,BASE_BACKGROUND_COLOR:"rgb(36, 36, 36)",BASE_COLOR:"rgb(213, 213, 213)",OBJECT_PREVIEW_ARRAY_MAX_PROPERTIES:10,OBJECT_PREVIEW_OBJECT_MAX_PROPERTIES:5,OBJECT_NAME_COLOR:"rgb(227, 110, 236)",OBJECT_VALUE_NULL_COLOR:"rgb(127, 127, 127)",OBJECT_VALUE_UNDEFINED_COLOR:"rgb(127, 127, 127)",OBJECT_VALUE_REGEXP_COLOR:"rgb(233, 63, 59)",OBJECT_VALUE_STRING_COLOR:"rgb(233, 63, 59)",OBJECT_VALUE_SYMBOL_COLOR:"rgb(233, 63, 59)",OBJECT_VALUE_NUMBER_COLOR:"hsl(252, 100%, 75%)",OBJECT_VALUE_BOOLEAN_COLOR:"hsl(252, 100%, 75%)",OBJECT_VALUE_FUNCTION_PREFIX_COLOR:"rgb(85, 106, 242)",HTML_TAG_COLOR:"rgb(93, 176, 215)",HTML_TAGNAME_COLOR:"rgb(93, 176, 215)",HTML_TAGNAME_TEXT_TRANSFORM:"lowercase",HTML_ATTRIBUTE_NAME_COLOR:"rgb(155, 187, 220)",HTML_ATTRIBUTE_VALUE_COLOR:"rgb(242, 151, 102)",HTML_COMMENT_COLOR:"rgb(137, 137, 137)",HTML_DOCTYPE_COLOR:"rgb(192, 192, 192)",ARROW_COLOR:"rgb(145, 145, 145)",ARROW_MARGIN_RIGHT:3,ARROW_FONT_SIZE:12,ARROW_ANIMATION_DURATION:"0",TREENODE_FONT_FAMILY:"Menlo, monospace",TREENODE_FONT_SIZE:"11px",TREENODE_LINE_HEIGHT:1.2,TREENODE_PADDING_LEFT:12,TABLE_BORDER_COLOR:"rgb(85, 85, 85)",TABLE_TH_BACKGROUND_COLOR:"rgb(44, 44, 44)",TABLE_TH_HOVER_COLOR:"rgb(48, 48, 48)",TABLE_SORT_ICON_COLOR:"black",TABLE_DATA_BACKGROUND_IMAGE:"linear-gradient(rgba(255, 255, 255, 0), rgba(255, 255, 255, 0) 50%, rgba(51, 139, 255, 0.0980392) 50%, rgba(51, 139, 255, 0.0980392))",TABLE_DATA_BACKGROUND_SIZE:"128px 32px"},qv={BASE_FONT_FAMILY:"Menlo, monospace",BASE_FONT_SIZE:"11px",BASE_LINE_HEIGHT:1.2,BASE_BACKGROUND_COLOR:"white",BASE_COLOR:"black",OBJECT_PREVIEW_ARRAY_MAX_PROPERTIES:10,OBJECT_PREVIEW_OBJECT_MAX_PROPERTIES:5,OBJECT_NAME_COLOR:"rgb(136, 19, 145)",OBJECT_VALUE_NULL_COLOR:"rgb(128, 128, 128)",OBJECT_VALUE_UNDEFINED_COLOR:"rgb(128, 128, 128)",OBJECT_VALUE_REGEXP_COLOR:"rgb(196, 26, 22)",OBJECT_VALUE_STRING_COLOR:"rgb(196, 26, 22)",OBJECT_VALUE_SYMBOL_COLOR:"rgb(196, 26, 22)",OBJECT_VALUE_NUMBER_COLOR:"rgb(28, 0, 207)",OBJECT_VALUE_BOOLEAN_COLOR:"rgb(28, 0, 207)",OBJECT_VALUE_FUNCTION_PREFIX_COLOR:"rgb(13, 34, 170)",HTML_TAG_COLOR:"rgb(168, 148, 166)",HTML_TAGNAME_COLOR:"rgb(136, 18, 128)",HTML_TAGNAME_TEXT_TRANSFORM:"lowercase",HTML_ATTRIBUTE_NAME_COLOR:"rgb(153, 69, 0)",HTML_ATTRIBUTE_VALUE_COLOR:"rgb(26, 26, 166)",HTML_COMMENT_COLOR:"rgb(35, 110, 37)",HTML_DOCTYPE_COLOR:"rgb(192, 192, 192)",ARROW_COLOR:"#6e6e6e",ARROW_MARGIN_RIGHT:3,ARROW_FONT_SIZE:12,ARROW_ANIMATION_DURATION:"0",TREENODE_FONT_FAMILY:"Menlo, monospace",TREENODE_FONT_SIZE:"11px",TREENODE_LINE_HEIGHT:1.2,TREENODE_PADDING_LEFT:12,TABLE_BORDER_COLOR:"#aaa",TABLE_TH_BACKGROUND_COLOR:"#eee",TABLE_TH_HOVER_COLOR:"hsla(0, 0%, 90%, 1)",TABLE_SORT_ICON_COLOR:"#6e6e6e",TABLE_DATA_BACKGROUND_IMAGE:"linear-gradient(to bottom, white, white 50%, rgb(234, 243, 255) 50%, rgb(234, 243, 255))",TABLE_DATA_BACKGROUND_SIZE:"128px 32px"},J1=(0,Y1.createContext)([{},()=>{}]),Fv={WebkitTouchCallout:"none",WebkitUserSelect:"none",KhtmlUserSelect:"none",MozUserSelect:"none",msUserSelect:"none",OUserSelect:"none",userSelect:"none"},Bh=e=>({DOMNodePreview:{htmlOpenTag:{base:{color:e.HTML_TAG_COLOR},tagName:{color:e.HTML_TAGNAME_COLOR,textTransform:e.HTML_TAGNAME_TEXT_TRANSFORM},htmlAttributeName:{color:e.HTML_ATTRIBUTE_NAME_COLOR},htmlAttributeValue:{color:e.HTML_ATTRIBUTE_VALUE_COLOR}},htmlCloseTag:{base:{color:e.HTML_TAG_COLOR},offsetLeft:{marginLeft:-e.TREENODE_PADDING_LEFT},tagName:{color:e.HTML_TAGNAME_COLOR,textTransform:e.HTML_TAGNAME_TEXT_TRANSFORM}},htmlComment:{color:e.HTML_COMMENT_COLOR},htmlDoctype:{color:e.HTML_DOCTYPE_COLOR}},ObjectPreview:{objectDescription:{fontStyle:"italic"},preview:{fontStyle:"italic"},arrayMaxProperties:e.OBJECT_PREVIEW_ARRAY_MAX_PROPERTIES,objectMaxProperties:e.OBJECT_PREVIEW_OBJECT_MAX_PROPERTIES},ObjectName:{base:{color:e.OBJECT_NAME_COLOR},dimmed:{opacity:.6}},ObjectValue:{objectValueNull:{color:e.OBJECT_VALUE_NULL_COLOR},objectValueUndefined:{color:e.OBJECT_VALUE_UNDEFINED_COLOR},objectValueRegExp:{color:e.OBJECT_VALUE_REGEXP_COLOR},objectValueString:{color:e.OBJECT_VALUE_STRING_COLOR},objectValueSymbol:{color:e.OBJECT_VALUE_SYMBOL_COLOR},objectValueNumber:{color:e.OBJECT_VALUE_NUMBER_COLOR},objectValueBoolean:{color:e.OBJECT_VALUE_BOOLEAN_COLOR},objectValueFunctionPrefix:{color:e.OBJECT_VALUE_FUNCTION_PREFIX_COLOR,fontStyle:"italic"},objectValueFunctionName:{fontStyle:"italic"}},TreeView:{treeViewOutline:{padding:0,margin:0,listStyleType:"none"}},TreeNode:{treeNodeBase:{color:e.BASE_COLOR,backgroundColor:e.BASE_BACKGROUND_COLOR,lineHeight:e.TREENODE_LINE_HEIGHT,cursor:"default",boxSizing:"border-box",listStyle:"none",fontFamily:e.TREENODE_FONT_FAMILY,fontSize:e.TREENODE_FONT_SIZE},treeNodePreviewContainer:{},treeNodePlaceholder:{whiteSpace:"pre",fontSize:e.ARROW_FONT_SIZE,marginRight:e.ARROW_MARGIN_RIGHT,...Fv},treeNodeArrow:{base:{color:e.ARROW_COLOR,display:"inline-block",fontSize:e.ARROW_FONT_SIZE,marginRight:e.ARROW_MARGIN_RIGHT,...parseFloat(e.ARROW_ANIMATION_DURATION)>0?{transition:`transform ${e.ARROW_ANIMATION_DURATION} ease 0s`}:{},...Fv},expanded:{WebkitTransform:"rotateZ(90deg)",MozTransform:"rotateZ(90deg)",transform:"rotateZ(90deg)"},collapsed:{WebkitTransform:"rotateZ(0deg)",MozTransform:"rotateZ(0deg)",transform:"rotateZ(0deg)"}},treeNodeChildNodesContainer:{margin:0,paddingLeft:e.TREENODE_PADDING_LEFT}},TableInspector:{base:{color:e.BASE_COLOR,position:"relative",border:`1px solid ${e.TABLE_BORDER_COLOR}`,fontFamily:e.BASE_FONT_FAMILY,fontSize:e.BASE_FONT_SIZE,lineHeight:"120%",boxSizing:"border-box",cursor:"default"}},TableInspectorHeaderContainer:{base:{top:0,height:"17px",left:0,right:0,overflowX:"hidden"},table:{tableLayout:"fixed",borderSpacing:0,borderCollapse:"separate",height:"100%",width:"100%",margin:0}},TableInspectorDataContainer:{tr:{display:"table-row"},td:{boxSizing:"border-box",border:"none",height:"16px",verticalAlign:"top",padding:"1px 4px",WebkitUserSelect:"text",whiteSpace:"nowrap",textOverflow:"ellipsis",overflow:"hidden",lineHeight:"14px"},div:{position:"static",top:"17px",bottom:0,overflowY:"overlay",transform:"translateZ(0)",left:0,right:0,overflowX:"hidden"},table:{positon:"static",left:0,top:0,right:0,bottom:0,borderTop:"0 none transparent",margin:0,backgroundImage:e.TABLE_DATA_BACKGROUND_IMAGE,backgroundSize:e.TABLE_DATA_BACKGROUND_SIZE,tableLayout:"fixed",borderSpacing:0,borderCollapse:"separate",width:"100%",fontSize:e.BASE_FONT_SIZE,lineHeight:"120%"}},TableInspectorTH:{base:{position:"relative",height:"auto",textAlign:"left",backgroundColor:e.TABLE_TH_BACKGROUND_COLOR,borderBottom:`1px solid ${e.TABLE_BORDER_COLOR}`,fontWeight:"normal",verticalAlign:"middle",padding:"0 4px",whiteSpace:"nowrap",textOverflow:"ellipsis",overflow:"hidden",lineHeight:"14px",":hover":{backgroundColor:e.TABLE_TH_HOVER_COLOR}},div:{whiteSpace:"nowrap",textOverflow:"ellipsis",overflow:"hidden",fontSize:e.BASE_FONT_SIZE,lineHeight:"120%"}},TableInspectorLeftBorder:{none:{borderLeft:"none"},solid:{borderLeft:`1px solid ${e.TABLE_BORDER_COLOR}`}},TableInspectorSortIcon:{display:"block",marginRight:3,width:8,height:7,marginTop:-7,color:e.TABLE_SORT_ICON_COLOR,fontSize:12,...Fv}}),$v="chromeLight",X1=(0,fo.createContext)(Bh($h[$v])),hr=e=>(0,fo.useContext)(X1)[e],Vv=e=>({theme:n=$v,...r})=>{let i=(0,fo.useMemo)(()=>{switch(Object.prototype.toString.call(n)){case"[object String]":return Bh($h[n]);case"[object Object]":return Bh(n);default:return Bh($h[$v])}},[n]);return fo.default.createElement(X1.Provider,{value:i},fo.default.createElement(e,{...r}))},Yq=({expanded:e,styles:t})=>mr.default.createElement("span",{style:{...t.base,...e?t.expanded:t.collapsed}},"\u25B6"),Jq=(0,mr.memo)(e=>{e={expanded:!0,nodeRenderer:({name:p})=>mr.default.createElement("span",null,p),onClick:()=>{},shouldShowArrow:!1,shouldShowPlaceholder:!0,...e};let{expanded:t,onClick:n,children:r,nodeRenderer:i,title:o,shouldShowArrow:s,shouldShowPlaceholder:a}=e,c=hr("TreeNode"),l=i;return mr.default.createElement("li",{"aria-expanded":t,role:"treeitem",style:c.treeNodeBase,title:o},mr.default.createElement("div",{style:c.treeNodePreviewContainer,onClick:n},s||mr.Children.count(r)>0?mr.default.createElement(Yq,{expanded:t,styles:c.treeNodeArrow}):a&&mr.default.createElement("span",{style:c.treeNodePlaceholder},"\xA0"),mr.default.createElement(l,{...e})),mr.default.createElement("ol",{role:"group",style:c.treeNodeChildNodesContainer},t?r:void 0))}),zh="$",H1="*";function Fh(e,t){return!t(e).next().done}var Xq=e=>Array.from({length:e},(t,n)=>[zh].concat(Array.from({length:n},()=>"*")).join(".")),Zq=(e,t,n,r,i)=>{let o=[].concat(Xq(r)).concat(n).filter(a=>typeof a=="string"),s=[];return o.forEach(a=>{let c=a.split("."),l=(p,d,m)=>{if(m===c.length){s.push(d);return}let y=c[m];if(m===0)Fh(p,t)&&(y===zh||y===H1)&&l(p,zh,m+1);else if(y===H1)for(let{name:S,data:T}of t(p))Fh(T,t)&&l(T,`${d}.${S}`,m+1);else{let S=p[y];Fh(S,t)&&l(S,`${d}.${y}`,m+1)}};l(e,"",0)}),s.reduce((a,c)=>(a[c]=!0,a),{...i})},Z1=(0,sn.memo)(e=>{let{data:t,dataIterator:n,path:r,depth:i,nodeRenderer:o}=e,[s,a]=(0,sn.useContext)(J1),c=Fh(t,n),l=!!s[r],p=(0,sn.useCallback)(()=>c&&a(d=>({...d,[r]:!l})),[c,a,r,l]);return sn.default.createElement(Jq,{expanded:l,onClick:p,shouldShowArrow:c,shouldShowPlaceholder:i>0,nodeRenderer:o,...e},l?[...n(t)].map(({name:d,data:m,...y})=>sn.default.createElement(Z1,{name:d,data:m,depth:i+1,path:`${r}.${d}`,key:d,dataIterator:n,nodeRenderer:o,...y})):null)}),W1=(0,sn.memo)(({name:e,data:t,dataIterator:n,nodeRenderer:r,expandPaths:i,expandLevel:o})=>{let s=hr("TreeView"),a=(0,sn.useState)({}),[,c]=a;return(0,sn.useLayoutEffect)(()=>c(l=>Zq(t,n,i,o,l)),[t,n,i,o]),sn.default.createElement(J1.Provider,{value:a},sn.default.createElement("ol",{role:"tree",style:s.treeViewOutline},sn.default.createElement(Z1,{name:e,data:t,dataIterator:n,depth:0,path:zh,nodeRenderer:r})))}),ff=({name:e,dimmed:t=!1,styles:n={}})=>{let r=hr("ObjectName"),i={...r.base,...t?r.dimmed:{},...n};return eN.default.createElement("span",{style:i},e)},pf=({object:e,styles:t})=>{let n=hr("ObjectValue"),r=i=>({...n[i],...t});switch(typeof e){case"bigint":return Jt.default.createElement("span",{style:r("objectValueNumber")},String(e),"n");case"number":return Jt.default.createElement("span",{style:r("objectValueNumber")},String(e));case"string":return Jt.default.createElement("span",{style:r("objectValueString")},'"',e,'"');case"boolean":return Jt.default.createElement("span",{style:r("objectValueBoolean")},String(e));case"undefined":return Jt.default.createElement("span",{style:r("objectValueUndefined")},"undefined");case"object":return e===null?Jt.default.createElement("span",{style:r("objectValueNull")},"null"):e instanceof Date?Jt.default.createElement("span",null,e.toString()):e instanceof RegExp?Jt.default.createElement("span",{style:r("objectValueRegExp")},e.toString()):Array.isArray(e)?Jt.default.createElement("span",null,`Array(${e.length})`):e.constructor?typeof e.constructor.isBuffer=="function"&&e.constructor.isBuffer(e)?Jt.default.createElement("span",null,`Buffer[${e.length}]`):Jt.default.createElement("span",null,e.constructor.name):Jt.default.createElement("span",null,"Object");case"function":return Jt.default.createElement("span",null,Jt.default.createElement("span",{style:r("objectValueFunctionPrefix")},"\u0192\xA0"),Jt.default.createElement("span",{style:r("objectValueFunctionName")},e.name,"()"));case"symbol":return Jt.default.createElement("span",{style:r("objectValueSymbol")},e.toString());default:return Jt.default.createElement("span",null)}},tN=Object.prototype.hasOwnProperty,Wq=Object.prototype.propertyIsEnumerable;function Kv(e,t){let n=Object.getOwnPropertyDescriptor(e,t);if(n.get)try{return n.get()}catch{return n.get}return e[t]}function G1(e,t){return e.length===0?[]:e.slice(1).reduce((n,r)=>n.concat([t,r]),[e[0]])}var Ta=({data:e})=>{let t=hr("ObjectPreview"),n=e;if(typeof n!="object"||n===null||n instanceof Date||n instanceof RegExp)return gn.default.createElement(pf,{object:n});if(Array.isArray(n)){let r=t.arrayMaxProperties,i=n.slice(0,r).map((s,a)=>gn.default.createElement(pf,{key:a,object:s}));n.length>r&&i.push(gn.default.createElement("span",{key:"ellipsis"},"\u2026"));let o=n.length;return gn.default.createElement(gn.default.Fragment,null,gn.default.createElement("span",{style:t.objectDescription},o===0?"":`(${o})\xA0`),gn.default.createElement("span",{style:t.preview},"[",G1(i,", "),"]"))}else{let r=t.objectMaxProperties,i=[];for(let s in n)if(tN.call(n,s)){let a;i.length===r-1&&Object.keys(n).length>r&&(a=gn.default.createElement("span",{key:"ellipsis"},"\u2026"));let c=Kv(n,s);if(i.push(gn.default.createElement("span",{key:s},gn.default.createElement(ff,{name:s||'""'}),":\xA0",gn.default.createElement(pf,{object:c}),a)),a)break}let o=n.constructor?n.constructor.name:"Object";return gn.default.createElement(gn.default.Fragment,null,gn.default.createElement("span",{style:t.objectDescription},o==="Object"?"":`${o} `),gn.default.createElement("span",{style:t.preview},"{",G1(i,", "),"}"))}},eV=({name:e,data:t})=>typeof e=="string"?ru.default.createElement("span",null,ru.default.createElement(ff,{name:e}),ru.default.createElement("span",null,": "),ru.default.createElement(Ta,{data:t})):ru.default.createElement(Ta,{data:t}),Qv=({name:e,data:t,isNonenumerable:n=!1})=>{let r=t;return iu.default.createElement("span",null,typeof e=="string"?iu.default.createElement(ff,{name:e,dimmed:n}):iu.default.createElement(Ta,{data:e}),iu.default.createElement("span",null,": "),iu.default.createElement(pf,{object:r}))},tV=(e,t)=>function*(r){if(!(typeof r=="object"&&r!==null||typeof r=="function"))return;let o=Array.isArray(r);if(!o&&r[Symbol.iterator]){let s=0;for(let a of r){if(Array.isArray(a)&&a.length===2){let[c,l]=a;yield{name:c,data:l}}else yield{name:s.toString(),data:a};s++}}else{let s=Object.getOwnPropertyNames(r);t===!0&&!o?s.sort():typeof t=="function"&&s.sort(t);for(let a of s)if(Wq.call(r,a)){let c=Kv(r,a);yield{name:a||'""',data:c}}else if(e){let c;try{c=Kv(r,a)}catch{}c!==void 0&&(yield{name:a,data:c,isNonenumerable:!0})}e&&r!==Object.prototype&&(yield{name:"__proto__",data:Object.getPrototypeOf(r),isNonenumerable:!0})}},nV=({depth:e,name:t,data:n,isNonenumerable:r})=>e===0?Kh.default.createElement(eV,{name:t,data:n}):Kh.default.createElement(Qv,{name:t,data:n,isNonenumerable:r}),rV=({showNonenumerable:e=!1,sortObjectKeys:t,nodeRenderer:n,...r})=>{let i=tV(e,t),o=n||nV;return Kh.default.createElement(W1,{nodeRenderer:o,dataIterator:i,...r})},dt=Vv(rV);function iV(e){if(typeof e=="object"){let t=[];if(Array.isArray(e)){let r=e.length;t=[...Array(r).keys()]}else e!==null&&(t=Object.keys(e));let n=t.reduce((r,i)=>{let o=e[i];return typeof o=="object"&&o!==null&&Object.keys(o).reduce((a,c)=>(a.includes(c)||a.push(c),a),r),r},[]);return{rowHeaders:t,colHeaders:n}}}var oV=({rows:e,columns:t,rowsData:n})=>{let r=hr("TableInspectorDataContainer"),i=hr("TableInspectorLeftBorder");return wi.default.createElement("div",{style:r.div},wi.default.createElement("table",{style:r.table},wi.default.createElement("colgroup",null),wi.default.createElement("tbody",null,e.map((o,s)=>wi.default.createElement("tr",{key:o,style:r.tr},wi.default.createElement("td",{style:{...r.td,...i.none}},o),t.map(a=>{let c=n[s];return typeof c=="object"&&c!==null&&tN.call(c,a)?wi.default.createElement("td",{key:a,style:{...r.td,...i.solid}},wi.default.createElement(pf,{object:c[a]})):wi.default.createElement("td",{key:a,style:{...r.td,...i.solid}})}))))))},sV=e=>Lr.default.createElement("div",{style:{position:"absolute",top:1,right:0,bottom:1,display:"flex",alignItems:"center"}},e.children),aV=({sortAscending:e})=>{let t=hr("TableInspectorSortIcon"),n=e?"\u25B2":"\u25BC";return Lr.default.createElement("div",{style:t},n)},q1=({sortAscending:e=!1,sorted:t=!1,onClick:n=void 0,borderStyle:r={},children:i,...o})=>{let s=hr("TableInspectorTH"),[a,c]=(0,Lr.useState)(!1),l=(0,Lr.useCallback)(()=>c(!0),[]),p=(0,Lr.useCallback)(()=>c(!1),[]);return Lr.default.createElement("th",{...o,style:{...s.base,...r,...a?s.base[":hover"]:{}},onMouseEnter:l,onMouseLeave:p,onClick:n},Lr.default.createElement("div",{style:s.div},i),t&&Lr.default.createElement(sV,null,Lr.default.createElement(aV,{sortAscending:e})))},cV=({indexColumnText:e="(index)",columns:t=[],sorted:n,sortIndexColumn:r,sortColumn:i,sortAscending:o,onTHClick:s,onIndexTHClick:a})=>{let c=hr("TableInspectorHeaderContainer"),l=hr("TableInspectorLeftBorder");return xa.default.createElement("div",{style:c.base},xa.default.createElement("table",{style:c.table},xa.default.createElement("tbody",null,xa.default.createElement("tr",null,xa.default.createElement(q1,{borderStyle:l.none,sorted:n&&r,sortAscending:o,onClick:a},e),t.map(p=>xa.default.createElement(q1,{borderStyle:l.solid,key:p,sorted:n&&i===p,sortAscending:o,onClick:s.bind(null,p)},p))))))},uV=({data:e,columns:t})=>{let n=hr("TableInspector"),[{sorted:r,sortIndexColumn:i,sortColumn:o,sortAscending:s},a]=(0,Mi.useState)({sorted:!1,sortIndexColumn:!1,sortColumn:void 0,sortAscending:!1}),c=(0,Mi.useCallback)(()=>{a(({sortIndexColumn:S,sortAscending:T})=>({sorted:!0,sortIndexColumn:!0,sortColumn:void 0,sortAscending:S?!T:!0}))},[]),l=(0,Mi.useCallback)(S=>{a(({sortColumn:T,sortAscending:E})=>({sorted:!0,sortIndexColumn:!1,sortColumn:S,sortAscending:S===T?!E:!0}))},[]);if(typeof e!="object"||e===null)return Mi.default.createElement("div",null);let{rowHeaders:p,colHeaders:d}=iV(e);t!==void 0&&(d=t);let m=p.map(S=>e[S]),y;if(o!==void 0?y=m.map((S,T)=>typeof S=="object"&&S!==null?[S[o],T]:[void 0,T]):i&&(y=p.map((S,T)=>[p[T],T])),y!==void 0){let S=(E,b)=>(f,g)=>{let v=E(f),I=E(g),M=typeof v,O=typeof I,C=(F,N)=>F<N?-1:F>N?1:0,z;if(M===O)z=C(v,I);else{let F={string:0,number:1,object:2,symbol:3,boolean:4,undefined:5,function:6};z=C(F[M],F[O])}return b||(z=-z),z},T=y.sort(S(E=>E[0],s)).map(E=>E[1]);p=T.map(E=>p[E]),m=T.map(E=>m[E])}return Mi.default.createElement("div",{style:n.base},Mi.default.createElement(cV,{columns:d,sorted:r,sortIndexColumn:i,sortColumn:o,sortAscending:s,onTHClick:l,onIndexTHClick:c}),Mi.default.createElement(oV,{rows:p,columns:d,rowsData:m}))},Mke=Vv(uV),lV=80,rN=e=>e.childNodes.length===0||e.childNodes.length===1&&e.childNodes[0].nodeType===Node.TEXT_NODE&&e.textContent.length<lV,pV=({tagName:e,attributes:t,styles:n})=>Rt.default.createElement("span",{style:n.base},"<",Rt.default.createElement("span",{style:n.tagName},e),(()=>{if(t){let r=[];for(let i=0;i<t.length;i++){let o=t[i];r.push(Rt.default.createElement("span",{key:i}," ",Rt.default.createElement("span",{style:n.htmlAttributeName},o.name),'="',Rt.default.createElement("span",{style:n.htmlAttributeValue},o.value),'"'))}return r}})(),">"),V1=({tagName:e,isChildNode:t=!1,styles:n})=>Rt.default.createElement("span",{style:Object.assign({},n.base,t&&n.offsetLeft)},"</",Rt.default.createElement("span",{style:n.tagName},e),">"),fV={1:"ELEMENT_NODE",3:"TEXT_NODE",7:"PROCESSING_INSTRUCTION_NODE",8:"COMMENT_NODE",9:"DOCUMENT_NODE",10:"DOCUMENT_TYPE_NODE",11:"DOCUMENT_FRAGMENT_NODE"},dV=({isCloseTag:e,data:t,expanded:n})=>{let r=hr("DOMNodePreview");if(e)return Rt.default.createElement(V1,{styles:r.htmlCloseTag,isChildNode:!0,tagName:t.tagName});switch(t.nodeType){case Node.ELEMENT_NODE:return Rt.default.createElement("span",null,Rt.default.createElement(pV,{tagName:t.tagName,attributes:t.attributes,styles:r.htmlOpenTag}),rN(t)?t.textContent:!n&&"\u2026",!n&&Rt.default.createElement(V1,{tagName:t.tagName,styles:r.htmlCloseTag}));case Node.TEXT_NODE:return Rt.default.createElement("span",null,t.textContent);case Node.CDATA_SECTION_NODE:return Rt.default.createElement("span",null,"<![CDATA["+t.textContent+"]]>");case Node.COMMENT_NODE:return Rt.default.createElement("span",{style:r.htmlComment},"<!--",t.textContent,"-->");case Node.PROCESSING_INSTRUCTION_NODE:return Rt.default.createElement("span",null,t.nodeName);case Node.DOCUMENT_TYPE_NODE:return Rt.default.createElement("span",{style:r.htmlDoctype},"<!DOCTYPE ",t.name,t.publicId?` PUBLIC "${t.publicId}"`:"",!t.publicId&&t.systemId?" SYSTEM":"",t.systemId?` "${t.systemId}"`:"",">");case Node.DOCUMENT_NODE:return Rt.default.createElement("span",null,t.nodeName);case Node.DOCUMENT_FRAGMENT_NODE:return Rt.default.createElement("span",null,t.nodeName);default:return Rt.default.createElement("span",null,fV[t.nodeType])}},mV=function*(e){if(e&&e.childNodes){if(rN(e))return;for(let n=0;n<e.childNodes.length;n++){let r=e.childNodes[n];r.nodeType===Node.TEXT_NODE&&r.textContent.trim().length===0||(yield{name:`${r.tagName}[${n}]`,data:r})}e.tagName&&(yield{name:"CLOSE_TAG",data:{tagName:e.tagName},isCloseTag:!0})}},hV=e=>nN.default.createElement(W1,{nodeRenderer:dV,dataIterator:mV,...e}),Oke=Vv(hV),Ake=Gq(Qq());u();var Hh=require("react");function q(e,t,n){let{get:r,listen:i}=(0,Hh.useMemo)(()=>{if(!e)return{get:()=>{},listen:()=>()=>{}};if(typeof t=="function"){let a=e.map(t,{isEqual:n?.isEqual});return{get:a.get,listen:a.subscribe}}let o=t?a=>e.subscribe(t,a):e.subscribe;return{get:t?()=>e.get(t):e.get,listen:o}},[e,t,n?.isEqual]);return(0,Hh.useSyncExternalStore)(i,r,r)}u();var iN=Q(require("react"));function mo({type:e}){return iN.default.createElement("span",{style:{display:"inline-block",width:6,height:6,background:e==="success"?"rgba(0,200,0,0.8)":"rgba(200,0,0,0.8)",borderRadius:"50%",verticalAlign:"middle"}})}u();var Yv={...qv,BASE_BACKGROUND_COLOR:"transparent",OBJECT_NAME_COLOR:"rgba(0,0,0,0.7)"},Jv={...Gv,BASE_BACKGROUND_COLOR:"transparent",OBJECT_NAME_COLOR:"rgba(255,255,255,0.7)"},Br=e=>e==="light"?Yv:Jv,Gh=e=>e==="light"?"rgb(223 223 223)":"rgb(29 29 29)";u();var On=Q(require("react"));u();var oN=Q(require("react"));function me({children:e,onClick:t,style:n,theme:r,disabled:i}){return oN.default.createElement("button",{type:"button",disabled:i,onClick:o=>{o.stopPropagation(),t()},style:{flex:"0",appearance:"none",background:"none",color:r.BASE_COLOR,opacity:i?.25:1,border:"none",fontSize:"12px",whiteSpace:"nowrap",display:"inline-flex",alignItems:"center",justifyContent:"center",padding:"0",cursor:"pointer",...n}},e)}u();var fs=Q(require("react"));u();var sN=Q(require("react"));function aN({expanded:e,onClick:t,style:n}){return sN.default.createElement("span",{role:"button",onClick:t,style:{display:"inline-block",textAlign:"center",transform:e?"rotate(0deg)":"rotate(-90deg)",fontFamily:"Menlo, monospace",...n}},"\u25BC")}function bt({open:e,setOpen:t,title:n,right:r,children:i,colorScheme:o,isFirst:s,style:a}){let c=o==="light"?Yv:Jv,l=o==="light"?"rgba(0,0,0,0.1)":"rgba(255,255,255,0.1)";return fs.default.createElement("div",{style:{flex:e?"1 1 0":"0",display:"flex",flexDirection:"column",...a}},fs.default.createElement("div",{onClick:()=>t?.(!e),style:{cursor:"default",fontSize:"12px",padding:"4px 10px",display:"flex",alignItems:"center",...!s&&{borderTop:`1px solid ${l}`},...e&&{borderBottom:`1px solid ${l}`}}},t&&fs.default.createElement(aN,{expanded:e,style:{fontSize:c.ARROW_FONT_SIZE,marginRight:c.ARROW_MARGIN_RIGHT+1,color:c.ARROW_COLOR}}),fs.default.createElement("span",{style:{flex:"1 1 0",userSelect:"none"}},n),r),e&&i)}var St=(0,fs.forwardRef)(function(t,n){return fs.default.createElement("div",{style:{flex:"1 1 0",overflowY:"auto",overflowX:"hidden",display:"flex",flexDirection:"column",...t.style},...t,ref:n})});u();var Xv=Q(require("react"));function Bt({children:e,colorScheme:t,selected:n,style:r,variant:i,bordered:o=!0}){return Xv.default.createElement("div",{style:{borderBottom:o?`1px solid ${t==="light"?"rgb(223 223 223)":"rgb(29 29 29)"}`:void 0,fontSize:"12px",fontFamily:"Menlo, monospace",padding:"2px 12px 1px",display:"flex",alignItems:"center",background:i==="up"?"rgba(0,255,0,0.1)":i==="down"?"transparent":n?"rgb(59 130 246 / 15%)":void 0,...r}},Xv.default.createElement("span",{style:{fontFamily:"Menlo, monospace",fontSize:"11px",borderRadius:4,display:"inline-block"}},e))}function cN(e){return typeof e=="object"&&"resourceId"in e}function gV(e){return typeof e=="object"&&e!==null&&"type"in e&&e.type==="resource"&&"resourceId"in e&&typeof e.resourceId=="string"}function uN({showEvents:e,setShowEvents:t,colorScheme:n,activityEventsContainerRef:r,activityEventsManager:i}){let[o,s]=(0,On.useState)("all"),a=cN(o)?"resource":"all",c=Br(n),l=qh(e?o:void 0,i);return On.default.createElement(bt,{open:e,setOpen:t,title:"Activity Events",colorScheme:n},On.default.createElement(St,{ref:r},On.default.createElement("div",{style:{padding:"4px 12px",display:"flex",gap:"4px"}},On.default.createElement("select",{name:"streamFilterType",value:a,style:{flex:"0 0 auto",height:"19px"},onChange:p=>{let d=p.target.value;s(d==="all"?"all":{resourceId:""})}},On.default.createElement("option",{value:"all"},"All"),On.default.createElement("option",{value:"resource"},"Resource")),cN(o)&&On.default.createElement("input",{name:"resourceId",type:"text",placeholder:"Resource ID",value:o.resourceId,style:{flex:"1 1 auto",height:"19px",padding:"0px 4px",boxSizing:"border-box"},onChange:p=>s({...o,resourceId:p.target.value})})),l?.map((p,d)=>On.default.createElement(Bt,{key:d,colorScheme:n,style:{padding:"0px 12px 1px"}},On.default.createElement(dt,{data:p,theme:c}),a==="all"&&gV(p)&&On.default.createElement(me,{theme:c,onClick:()=>{s({resourceId:p.resourceId})}},"Watch this resource"))),!l&&On.default.createElement("div",{style:{padding:"12px",fontSize:"12px",display:"flex",flexDirection:"column",gap:"4px"}},On.default.createElement("span",null,"No activity events"))))}u();var yr=Q(require("react"));u();var ho=Q(require("react"));var lN=({name:e,data:t,direction:n})=>typeof e=="string"?ho.default.createElement("span",null,ho.default.createElement(ff,{name:e}),ho.default.createElement("span",null,": "),ho.default.createElement(Ta,{data:t})):n==="up"||n==="down"?ho.default.createElement("span",null,ho.default.createElement("span",{style:{background:n==="up"?"rgba(0,255,0,0.2)":"rgba(255,0,0,0.2)",width:12,height:12,borderRadius:2,display:"inline-flex",justifyContent:"center",alignItems:"center",marginRight:4,lineHeight:"12px"}},n==="up"?"\u2191":"\u2193"),ho.default.createElement(Ta,{data:t})):ho.default.createElement(Ta,{data:t});function pN({showEvents:e,setShowEvents:t,colorScheme:n,eventsContainerRef:r,connectionEvents:i,paused:o,onTogglePaused:s}){let a=Br(n);return yr.default.createElement(bt,{open:e,setOpen:t,title:"Events",colorScheme:n,right:yr.default.createElement(me,{theme:a,onClick:s},o?"Resume":"Pause")},yr.default.createElement(St,{ref:r},o&&yr.default.createElement("div",{style:{padding:"4px 12px",fontSize:"11px",opacity:.7}},"Event streaming paused"),i?.map((c,l)=>c.type==="stateChange"?yr.default.createElement(Bt,{key:l,colorScheme:n},"connection:"," ",yr.default.createElement("span",{style:{fontStyle:"italic"}},c.state.toLowerCase())):yr.default.createElement(Bt,{key:l,colorScheme:n,variant:c.type==="send"?"up":"down",style:{padding:"0px 12px 1px"}},yr.default.createElement(dt,{data:c.type==="error"?c.error:c.message,theme:a,nodeRenderer:({depth:p,name:d,data:m,isNonenumerable:y})=>{let S=c.type==="send"?"up":"down";return p===0?yr.default.createElement(lN,{direction:S,data:m}):yr.default.createElement(Qv,{direction:S,name:d,data:m,isNonenumerable:y})}}))),!i?.length&&yr.default.createElement("div",{style:{padding:"12px",fontSize:"12px",display:"flex",flexDirection:"column",gap:"4px"}},yr.default.createElement("span",null,"No recorded events"))))}u();var Y=Q(require("react"));u();var fN=Q(require("react"));function yo({children:e}){return fN.default.createElement("span",{style:{display:"flex",alignItems:"center",gap:"4px"}},e)}function dN({showGit:e,setShowGit:t,colorScheme:n,gitManager:r}){let i=Br(n),o=q(r.repos$),s=q(r.isInitialized$),a=q(r.repoFiles$),[c,l]=(0,Y.useState)(null),[p,d]=(0,Y.useState)(null),m=(0,Y.useRef)(null),[y,S]=(0,Y.useState)(""),[T,E]=(0,Y.useState)(!1),b=c?o.find(N=>N.id===c):null,f=c?a[c]:null,g=async N=>{m.current&&(m.current.close(),m.current=null,d(null),S(""),E(!1)),l(N),N&&!a[N]&&await r.fetchRepoFiles(N)},v=N=>{if(!c||!f)return;m.current&&m.current.close();let H=r.openEditingHandle(c,N,f.ref);m.current=H,d(N),E(!1),S("")},I=()=>{m.current&&(m.current.close(),m.current=null),d(null),S(""),E(!1)};(0,Y.useEffect)(()=>{let N=m.current;if(!N)return;let H=N.content$.subscribe(L=>{S(L)}),j=N.isInitialized$.subscribe(L=>{E(L)});return()=>{H(),j()}},[p]);let M=N=>{let H=m.current;H&&H.setState(N)},O=async N=>{c&&await r.fetchRepoFiles(c,N)},C=async()=>{if(!c||!f)return;let N=prompt("Enter file path (e.g., src/index.ts):");if(N)try{await r.patchFiles(c,{create:[{path:N,content:""}]},f.ref)}catch(H){alert(`Failed to create file: ${H}`)}},z=async N=>{if(!c||!f)return;let H=prompt(`Rename "${N}" to:`,N);if(!(!H||H===N))try{await r.patchFiles(c,{rename:[{oldPath:N,newPath:H}]},f.ref)}catch(j){alert(`Failed to rename file: ${j}`)}},F=async N=>{if(!(!c||!f||!confirm(`Delete "${N}"?`)))try{await r.patchFiles(c,{delete:[{path:N}]},f.ref),p===N&&I()}catch(j){alert(`Failed to delete file: ${j}`)}};return Y.default.createElement(bt,{open:e,setOpen:t,title:Y.default.createElement(yo,null,"Git Repos (",o.length,")",Y.default.createElement(mo,{type:s?"success":"error"})),colorScheme:n,right:Y.default.createElement("span",{style:{display:"flex",gap:"10px"}},Y.default.createElement(me,{theme:i,onClick:async()=>{try{await r.initRepo()}catch(N){console.error("[GitSection] Failed to create repo:",N)}}},"Init Repo"))},Y.default.createElement(St,null,Y.default.createElement("div",{style:{padding:"4px 12px",display:"flex",gap:"4px"}},Y.default.createElement("select",{name:"repoSelector",value:c??"",style:{flex:"1 1 auto",height:"19px",minWidth:0},onChange:N=>{let H=N.target.value;g(H||null)}},Y.default.createElement("option",{value:""},"Select a repo..."),o.map(N=>Y.default.createElement("option",{key:N.id,value:N.id},N.id))),c&&Y.default.createElement(me,{theme:i,onClick:()=>r.fetchRepoFiles(c)},"Refresh"),Y.default.createElement("label",{style:{display:"flex",alignItems:"center",gap:"4px",fontSize:"11px",whiteSpace:"nowrap"}},"[Include Content = ",r.includeContent?"true":"false","]")),b&&f&&Y.default.createElement(Y.default.Fragment,null,Y.default.createElement("div",{style:{padding:"4px 12px",display:"flex",gap:"8px",alignItems:"center",fontSize:"12px"}},Y.default.createElement("span",{style:{color:i.BASE_COLOR}},"Branch:"),f.branches.length>0?Y.default.createElement("select",{value:f.ref,style:{flex:"1 1 auto",height:"19px"},onChange:N=>O(N.target.value)},f.branches.map(N=>Y.default.createElement("option",{key:N.name,value:N.name},N.name))):Y.default.createElement("span",{style:{opacity:.6,fontStyle:"italic"}},f.ref||"No branches"),f.oid&&Y.default.createElement("span",{style:{fontFamily:"monospace",fontSize:"10px",opacity:.6},title:f.oid},f.oid.slice(0,7),f.fetchState==="refreshing"&&"\u2026"),Y.default.createElement(me,{theme:i,onClick:C,style:{fontSize:"10px",padding:"2px 6px"}},"+ Add File")),f.fetchState==="loading"&&Y.default.createElement("div",{style:{padding:"12px",fontSize:"12px"}},"Loading files..."),f.error&&Y.default.createElement("div",{style:{padding:"12px",fontSize:"12px",color:"#f44"}},"Error: ",f.error),f.fetchState!=="loading"&&!f.error&&f.files.length===0&&Y.default.createElement("div",{style:{padding:"12px",fontSize:"12px"}},"No files (empty repo)"),!p&&f.files.map((N,H)=>{let j=f.fileContents?.find(V=>V.path===N),L="";if(j)try{let V=atob(j.content);L=V.slice(0,40).replace(/\n/g," ").replace(/\s+/g," "),V.length>40&&(L+="\u2026")}catch{}return Y.default.createElement("div",{key:H,style:{padding:"2px 12px",display:"flex",justifyContent:"space-between",alignItems:"center",gap:"8px",borderBottom:`1px solid ${n==="light"?"rgb(223 223 223)":"rgb(29 29 29)"}`}},Y.default.createElement("span",{style:{fontFamily:"monospace",fontSize:"11px",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",minWidth:0,display:"flex",gap:"8px"},title:N},Y.default.createElement("span",null,N),L&&Y.default.createElement("span",{style:{opacity:.5}},L)),Y.default.createElement("span",{style:{display:"flex",gap:"4px",flexShrink:0}},Y.default.createElement(me,{theme:i,onClick:()=>v(N),style:{fontSize:"10px",padding:"2px 6px"}},"Edit"),Y.default.createElement(me,{theme:i,onClick:()=>z(N),style:{fontSize:"10px",padding:"2px 6px"}},"Rename"),Y.default.createElement(me,{theme:i,onClick:()=>F(N),style:{fontSize:"10px",padding:"2px 6px"}},"Delete")))}),p&&Y.default.createElement("div",{style:{padding:"8px 12px",borderTop:`1px solid ${i.DIVIDER_COLOR}`,flex:"1 1 auto",display:"flex",flexDirection:"column",minHeight:0}},Y.default.createElement("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"8px",flexShrink:0}},Y.default.createElement("span",{style:{fontFamily:"monospace",fontSize:"11px",fontWeight:"bold"}},p,!T&&Y.default.createElement("span",{style:{opacity:.5,marginLeft:"8px"}},"Loading...")),Y.default.createElement(me,{theme:i,onClick:I,style:{fontSize:"10px",padding:"2px 6px"}},"Close")),Y.default.createElement("textarea",{value:y,onChange:N=>M(N.target.value),disabled:!T,style:{width:"100%",flex:"1 1 auto",minHeight:"100px",fontFamily:"monospace",fontSize:"11px",padding:"8px",border:`1px solid ${i.DIVIDER_COLOR}`,borderRadius:"4px",backgroundColor:i.ROW_BACKGROUND,color:i.BASE_COLOR,resize:"none",boxSizing:"border-box"}}))),o.length===0&&Y.default.createElement("div",{style:{padding:"12px",fontSize:"12px",display:"flex",flexDirection:"column",gap:"4px"}},Y.default.createElement("span",null,"No git repos"))))}u();var ie=Q(require("react"));u();function ou(e){return e.map(t=>typeof t=="object"?`:${Zv(t.id.toString(),8,"middle")}`:t).map((t,n)=>n===0||typeof t=="string"&&t.startsWith(":")?t:`.${t}`).join("")}function Zv(e,t,n="end"){if(e.length<=t)return e;switch(n){case"start":return`\u2026${e.slice(e.length-t)}`;case"middle":{let r=Math.floor(t/2);return`${e.slice(0,r)}\u2026${e.slice(e.length-r)}`}case"end":return`${e.slice(0,t)}\u2026`}}function su(){return new Promise((e,t)=>{let n=document.createElement("input");n.type="file",n.onchange=()=>{let r=n.files?.[0];if(r){let i=new FileReader;i.onload=()=>{let o=i.result,s=new File([o],r.name,{type:r.type});e(s)},i.onerror=()=>{t(new Error("Failed to read file"))},i.readAsArrayBuffer(r)}},n.click()})}var Wv="noya-multiplayer-history-";function mN({showHistory:e,setShowHistory:t,colorScheme:n,historySnapshot:r,multiplayerStateManager:i}){let o=(0,ie.useRef)(null),s=Br(n),a=Gh(n);return(0,ie.useEffect)(()=>{o.current&&(o.current.scrollTop=o.current.scrollHeight)},[r]),(0,ie.useEffect)(()=>{if(!o.current)return;let c=o.current.querySelector(`#${Wv}${r.historyIndex}`);c&&c.scrollIntoView({block:"nearest",inline:"nearest"})},[r.historyIndex]),ie.default.createElement(bt,{open:e,setOpen:t,title:"History",colorScheme:n,right:ie.default.createElement("span",{style:{display:"flex",gap:"4px"}},ie.default.createElement(me,{disabled:!r.canUndo,theme:s,onClick:()=>{i.undo()}},ie.default.createElement("span",{style:{width:"12px",height:"12px"}},ie.default.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 20 20"},ie.default.createElement("path",{fill:"currentColor",d:"M12 5H7V2L1 6l6 4V7h5c2.2 0 4 1.8 4 4s-1.8 4-4 4H7v2h5c3.3 0 6-2.7 6-6s-2.7-6-6-6"})))),ie.default.createElement(me,{disabled:!r.canRedo,theme:s,onClick:()=>{i.redo()}},ie.default.createElement("span",{style:{width:"12px",height:"12px"}},ie.default.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 20 20"},ie.default.createElement("path",{fill:"currentColor",d:"M8 5h5V2l6 4l-6 4V7H8c-2.2 0-4 1.8-4 4s1.8 4 4 4h5v2H8c-3.3 0-6-2.7-6-6s2.7-6 6-6"})))))},ie.default.createElement(St,{ref:o},ie.default.createElement("div",{id:`${Wv}0`,style:{borderBottom:`1px solid ${a}`,fontSize:"12px",fontFamily:"Menlo, monospace",padding:"2px 12px 1px",display:"flex",alignItems:"center",background:r.historyIndex===0?"rgb(59 130 246 / 15%)":void 0}},ie.default.createElement("span",{style:{fontFamily:"Menlo, monospace",fontSize:"11px",borderRadius:4,display:"inline-block"}},"Initial state")),r.history.map((c,l)=>{let p=c.metadata,{id:d,name:m,timestamp:y,...S}=p;return ie.default.createElement("div",{id:`${Wv}${l+1}`,key:l,style:{padding:"0px 12px 1px",borderBottom:`1px solid ${a}`,background:l+1===r.historyIndex?"rgb(59 130 246 / 15%)":void 0}},typeof m=="string"&&ie.default.createElement("pre",{style:{fontSize:"11px",display:"flex",flexWrap:"wrap",margin:0}},c.metadata.name,Object.keys(S).length>0&&ie.default.createElement(dt,{data:S,theme:s})),c.redoPatches?.map((T,E)=>ie.default.createElement("pre",{key:E,style:{fontSize:"11px",display:"flex",flexWrap:"wrap",margin:0}},T.op==="add"&&ie.default.createElement(ie.default.Fragment,null,ie.default.createElement("span",{style:{fontStyle:"italic"}},ou(T.path))," = ",ie.default.createElement(dt,{data:T.value,theme:s})),T.op==="replace"&&ie.default.createElement(ie.default.Fragment,null,ie.default.createElement("span",{style:{fontStyle:"italic"}},ou(T.path))," = ",ie.default.createElement(dt,{data:T.value,theme:s})),T.op==="remove"&&ie.default.createElement(ie.default.Fragment,null,ie.default.createElement("span",{style:{color:s.OBJECT_VALUE_STRING_COLOR}},"delete"," "),ie.default.createElement("span",{style:{fontStyle:"italic"}},ou(T.path))),T.op==="move"&&ie.default.createElement(ie.default.Fragment,null,ie.default.createElement("span",{style:{fontStyle:"italic"}},ou(T.from))," -> ",ie.default.createElement("span",{style:{fontStyle:"italic"}},ou(T.path))))))})))}u();var bn=Q(require("react"));var bV={error:"#f87171",warn:"#facc15",log:"#9ca3af"};function SV(e){return new Date(e).toLocaleTimeString()}function eI({showLogs:e,setShowLogs:t,colorScheme:n,logs:r,containerRef:i,paused:o,onTogglePaused:s,title:a="Server Script Logs"}){let c=Br(n);return bn.default.createElement(bt,{open:e,setOpen:t,title:a,colorScheme:n,right:bn.default.createElement(me,{theme:c,onClick:s},o?"Resume":"Pause")},bn.default.createElement(St,{ref:i},o&&bn.default.createElement("div",{style:{padding:"4px 12px",fontSize:"11px",opacity:.7}},"Log streaming paused"),r.map(l=>bn.default.createElement(Bt,{key:l.id,colorScheme:n},bn.default.createElement("div",{style:{display:"flex",gap:"6px",alignItems:"center",fontSize:"10px",color:"inherit",marginBottom:l.values.length?"4px":0,textTransform:"uppercase"}},bn.default.createElement("span",null,SV(l.timestamp)),bn.default.createElement("span",{style:{color:bV[l.level]}},l.level),(l.origin||l.target||l.mode)&&bn.default.createElement("span",{style:{fontFamily:"monospace",textTransform:"none",fontSize:"10px",opacity:.75}},[l.origin??l.target,l.mode].filter(Boolean).join(" / ")),bn.default.createElement("span",{style:{fontFamily:"monospace",textTransform:"none",fontSize:"10px"}},l.scriptId)),bn.default.createElement("div",{style:{display:"flex",flexDirection:"column",gap:"4px"}},l.values.length>0?l.values.map((p,d)=>bn.default.createElement(dt,{key:d,data:p,theme:c})):bn.default.createElement("span",{style:{fontSize:"11px",opacity:.7}},"No data")))),!r?.length&&bn.default.createElement("div",{style:{padding:"12px",fontSize:"12px",display:"flex",flexDirection:"column",gap:"4px"}},bn.default.createElement("span",null,"No logs received"))))}u();u();u();var xV=(()=>{let e=new Uint32Array(256);for(let t=0;t<256;t++){let n=t;for(let r=0;r<8;r++)n=n&1?3988292384^n>>>1:n>>>1;e[t]=n>>>0}return e})();function hN(e){let t=4294967295;for(let n=0;n<e.length;n++)t=xV[(t^e[n])&255]^t>>>8;return(t^4294967295)>>>0}u();var Vh=e=>e,yN=e=>e;function TV(e,t){return e.type==="bytes"?typeof e.length=="function"?e.length(t):e.length:e.type==="u8"?1:e.type==="u16"?2:4}function au(e,t){let n=0,r={...t};for(let c of e)n+=TV(c,r);let i=new Uint8Array(n),o=new DataView(i.buffer),s=0,a=t;for(let c of e){if(c.type==="bytes"){let p=a[c.name];i.set(p,s),s+=p.length;continue}let l=Number(a[c.name])>>>0;c.type==="u8"?(o.setUint8(s,l),s+=1):c.type==="u16"?(o.setUint16(s,l,!0),s+=2):(o.setUint32(s,l,!0),s+=4)}return i}function Qh(e,t,n){let r={},i=t;for(let o of n)if(o.type==="bytes"){let s=typeof o.length=="function"?o.length(r):o.length,a=new Uint8Array(e.buffer,e.byteOffset+i,s);r[o.name]=new Uint8Array(a),i+=s}else o.type==="u8"?(r[o.name]=e.getUint8(i),i+=1):o.type==="u16"?(r[o.name]=e.getUint16(i,!0),i+=2):(r[o.name]=e.getUint32(i,!0),i+=4);return{value:r,offset:i}}var vV=new TextEncoder;function Yh(e){return vV.encode(e)}function tI(e=new Date){let t=e.getHours()<<11|e.getMinutes()<<5|Math.floor(e.getSeconds()/2),n=e.getFullYear()-1980<<9|e.getMonth()+1<<5|e.getDate();return{time:t,date:n}}var Oi={LocalFile:67324752,CentralFile:33639248,EOCD:101010256},ds=yN({LocalFile:Vh([{name:"signature",type:"u32"},{name:"versionNeeded",type:"u16"},{name:"flags",type:"u16"},{name:"method",type:"u16"},{name:"time",type:"u16"},{name:"date",type:"u16"},{name:"crc32",type:"u32"},{name:"compSize",type:"u32"},{name:"uncompSize",type:"u32"},{name:"nameLen",type:"u16"},{name:"extraLen",type:"u16"},{name:"name",type:"bytes",length:e=>e.nameLen},{name:"extra",type:"bytes",length:e=>e.extraLen}]),CentralFile:Vh([{name:"signature",type:"u32"},{name:"versionMadeBy",type:"u16"},{name:"versionNeeded",type:"u16"},{name:"flags",type:"u16"},{name:"method",type:"u16"},{name:"time",type:"u16"},{name:"date",type:"u16"},{name:"crc32",type:"u32"},{name:"compSize",type:"u32"},{name:"uncompSize",type:"u32"},{name:"nameLen",type:"u16"},{name:"extraLen",type:"u16"},{name:"commentLen",type:"u16"},{name:"diskStart",type:"u16"},{name:"intAttrs",type:"u16"},{name:"extAttrs",type:"u32"},{name:"localHeaderOffset",type:"u32"},{name:"name",type:"bytes",length:e=>e.nameLen},{name:"extra",type:"bytes",length:e=>e.extraLen},{name:"comment",type:"bytes",length:e=>e.commentLen}]),EOCD:Vh([{name:"signature",type:"u32"},{name:"diskNum",type:"u16"},{name:"cdStartDisk",type:"u16"},{name:"cdRecordsOnDisk",type:"u16"},{name:"cdRecordsTotal",type:"u16"},{name:"cdSize",type:"u32"},{name:"cdOffset",type:"u32"},{name:"commentLen",type:"u16"},{name:"comment",type:"bytes",length:e=>e.commentLen}])});function nI(e,t,n){if(e!==t)throw new Error(`Invalid signature for ${n}: 0x${e.toString(16)}`)}var df=class e{_chunks=[];_offset=0;_files=[];_rootPrefix="";_rootDirAdded=!1;constructor(t={}){if(t.root){let n=t.root.replace(/^\/+|\/+$/g,"");n&&(this._rootPrefix=n+"/")}}_push(...t){for(let n of t)this._chunks.push(n),this._offset+=n.length}_withRoot(t){return this._rootPrefix&&!t.startsWith(this._rootPrefix)?this._rootPrefix+t.replace(/^\/+/,""):t}_ensureRootDir(t=new Date){if(!this._rootPrefix||this._rootDirAdded)return;this._rootDirAdded=!0;let n=this._rootPrefix,r=Yh(n),{time:i,date:o}=tI(t),s=au(ds.LocalFile,{signature:Oi.LocalFile,versionNeeded:20,flags:2048,method:0,time:i,date:o,crc32:0,compSize:0,uncompSize:0,nameLen:r.length,extraLen:0,name:r,extra:new Uint8Array(0)}),a=this._offset;this._push(s),this._files.push({nameBytes:r,crc:0,compSize:0,uncompSize:0,method:0,time:i,dosDate:o,localHeaderOffset:a,externalAttrs:16})}addFile(t,n,r={}){let{date:i=new Date}=r;this._ensureRootDir(i);let o=gN(n),s=this._withRoot(t),a=Yh(s),{time:c,date:l}=tI(i),p=hN(o),d=o.length>>>0,m=o.length>>>0,y=this._offset,S=au(ds.LocalFile,{signature:Oi.LocalFile,versionNeeded:20,flags:2048,method:0,time:c,date:l,crc32:p,compSize:d,uncompSize:m,nameLen:a.length,extraLen:0,name:a,extra:new Uint8Array(0)});this._push(S,o),this._files.push({nameBytes:a,crc:p,compSize:d,uncompSize:m,method:0,time:c,dosDate:l,localHeaderOffset:y,externalAttrs:0})}addDirectory(t,n={}){let{date:r=new Date}=n;this._ensureRootDir(r);let i=t.endsWith("/")?t:t+"/",o=this._withRoot(i),s=Yh(o),{time:a,date:c}=tI(r),l=au(ds.LocalFile,{signature:Oi.LocalFile,versionNeeded:20,flags:2048,method:0,time:a,date:c,crc32:0,compSize:0,uncompSize:0,nameLen:s.length,extraLen:0,name:s,extra:new Uint8Array(0)}),p=this._offset;this._push(l),this._files.push({nameBytes:s,crc:0,compSize:0,uncompSize:0,method:0,time:a,dosDate:c,localHeaderOffset:p,externalAttrs:16})}finish(){let t=this._offset;for(let s of this._files){let a=au(ds.CentralFile,{signature:Oi.CentralFile,versionMadeBy:20,versionNeeded:20,flags:2048,method:s.method,time:s.time,date:s.dosDate,crc32:s.crc,compSize:s.compSize,uncompSize:s.uncompSize,nameLen:s.nameBytes.length,extraLen:0,commentLen:0,diskStart:0,intAttrs:0,extAttrs:s.externalAttrs,localHeaderOffset:s.localHeaderOffset,name:s.nameBytes,extra:new Uint8Array(0),comment:new Uint8Array(0)});this._push(a)}let n=this._offset-t,r=au(ds.EOCD,{signature:Oi.EOCD,diskNum:0,cdStartDisk:0,cdRecordsOnDisk:this._files.length,cdRecordsTotal:this._files.length,cdSize:n,cdOffset:t,commentLen:0,comment:new Uint8Array(0)});this._push(r);let i=new Uint8Array(this._offset),o=0;for(let s of this._chunks)i.set(s,o),o+=s.length;return i}static create(t,n={}){let r=new e(n);for(let[i,o]of Object.entries(t))i.endsWith("/")?r.addDirectory(i):r.addFile(i,o);return r.finish()}static parse(t){let n=gN(t),r=new DataView(n.buffer,n.byteOffset,n.byteLength),i=IV(n),{value:o}=Qh(r,i,ds.EOCD);if(nI(o.signature,Oi.EOCD,"EOCD"),o.commentLen!==0)throw new Error("Unsupported: EOCD comment");if(o.diskNum!==0||o.cdStartDisk!==0)throw new Error("Unsupported: multi-disk");let s=[],a=o.cdOffset;for(let l=0;l<o.cdRecordsTotal;l++){let{value:p,offset:d}=Qh(r,a,ds.CentralFile);nI(p.signature,Oi.CentralFile,"Central Directory");let m=new TextDecoder().decode(p.name),y=(p.extAttrs&16)!==0||m.endsWith("/");if(p.extraLen!==0||p.commentLen!==0)throw new Error("Unsupported: extra/comment in central dir");s.push({name:m,isDirectory:y,crc32:p.crc32>>>0,size:p.uncompSize>>>0,compSize:p.compSize>>>0,time:p.time>>>0,dosDate:p.date>>>0,localHeaderOffset:p.localHeaderOffset>>>0}),a=d}let c=[];for(let l of s){let{value:p,offset:d}=Qh(r,l.localHeaderOffset,ds.LocalFile);if(nI(p.signature,Oi.LocalFile,"Local File"),p.flags!==2048)throw new Error("Unsupported: flags (expect UTF-8 only)");if(p.method!==0)throw new Error("Unsupported: compression (expect store only)");if(p.extraLen!==0)throw new Error("Unsupported: extra fields in local header");let m=d,y=m+p.compSize,S=l.isDirectory?new Uint8Array(0):new Uint8Array(n.subarray(m,y));c.push({...l,data:S})}return c}static extract(t){let n=this.parse(t),r={};for(let i of n)i.isDirectory||(r[i.name]=i.data);return r}};function gN(e){return typeof e=="string"?Yh(e):e instanceof Uint8Array?e:new Uint8Array(e)}function IV(e){let t=new DataView(e.buffer,e.byteOffset,e.byteLength),n=22;if(e.length>=n){let i=e.length-n;if(t.getUint32(i,!0)===Oi.EOCD)return i}let r=Math.max(0,e.length-1024);for(let i=e.length-4;i>=r;i--)if(t.getUint32(i,!0)===Oi.EOCD)return i;throw new Error("EOCD not found")}async function bN(e){let t=await Promise.all(e.map(async n=>{let r=n.url,o=await(await fetch(r)).arrayBuffer();return[n.id,o]}));return Object.fromEntries(t)}async function iI(e){let{multiplayerStateManager:t,assetManager:n}=e,r=await bN(n.assets$.get());return SN({state:t.optimisticState$.get(),schema:t.schema,assets:n.assets$.get(),assetMap:r})}function SN({state:e,schema:t,assets:n,assetMap:r}){let i=new df;if(i.addFile("state.json",JSON.stringify(e,null,2)),t){let o=Io(t);i.addFile("schema.json",JSON.stringify(o,null,2))}n.length&&i.addFile("assets.json",JSON.stringify(n,null,2));for(let[o,s]of Object.entries(r))i.addFile(`assets/${o}`,s);return i.finish()}async function oI(e,t,{shouldAllowSchemaChange:n}={}){let{state:r,schema:i,assets:o,assetMap:s}=await xN(e);if(n&&t.options.schema&&i){let a=Nl(t.options.schema),c=Nl(i);if(a!==c&&!n({oldSchema:t.options.schema,newSchema:i}))throw new Error("Schema change not allowed")}o.length&&(await Promise.all(t.assetManager.assets$.get().map(a=>t.assetManager.delete(a.stableId))),await Promise.all(o.map(async a=>{await t.assetManager.create({data:s[a.id],contentType:a.contentType,stableId:a.stableId})}))),t.initialState=r,t.forceInit()}function xN(e){let t=df.extract(e),n=t["state.json"],r=t["schema.json"],i=t["assets.json"];if(!n)throw new Error("State file not found");let o=JSON.parse(new TextDecoder().decode(n)),s;if(r){let l=JSON.parse(new TextDecoder().decode(r));s=Eo(l)}let a=[],c={};if(i){a=JSON.parse(new TextDecoder().decode(i));for(let l of a){let p=t[`assets/${l.id}`];if(!p)throw new Error(`Asset ${l.id} not found`);c[l.id]=p}}return{state:o,schema:s,assets:a,assetMap:c}}function rI(e,t){switch(typeof e){case"object":return e===null?e:Array.isArray(e)?e.map(n=>rI(n,t)):Object.fromEntries(Object.entries(e).map(([n,r])=>[n,rI(r,t)]));case"string":return t[e]??e;default:return e}}u();var va=Q(require("react"));function sI({showInspector:e,setShowInspector:t,theme:n,anchor:r}){let i=r==="right",o=va.default.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",className:"size-6"},va.default.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"m5.25 4.5 7.5 7.5-7.5 7.5m6-15 7.5 7.5-7.5 7.5"})),s=va.default.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",className:"size-6"},va.default.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"m18.75 4.5-7.5 7.5 7.5 7.5m-6-15L5.25 12l7.5 7.5"}));return va.default.createElement("span",{role:"button",style:{flex:"0",appearance:"none",color:n.BASE_COLOR,border:"none",fontSize:"12px",whiteSpace:"nowrap",display:"inline-flex",alignItems:"center",justifyContent:"center",padding:"2px 0"},onClick:a=>{a.stopPropagation(),t(!e)}},e?"Hide Inspector":va.default.createElement("span",{style:{width:"12px",height:"12px"}},i?o:s))}u();var vN=Q(require("react")),TN=typeof window<"u"?window.localStorage:null;function Ft(e,t){let[n,r]=vN.default.useState(()=>{let o=TN?.getItem(e),s=t;if(o)try{s=JSON.parse(o)}catch(a){console.error("Error parsing localStorage value",a)}return s});return[n,o=>{TN?.setItem(e,JSON.stringify(o)),r(o)}]}u();var mf=Q(require("react"));function Jh(e){let[t,n]=mf.default.useState(!1),[r,i]=mf.default.useState(e??[]),o=mf.default.useCallback(()=>{n(s=>(s||i(e??[]),!s))},[e]);return mf.default.useEffect(()=>{t||i(e??[])},[e,t]),{paused:t,setPaused:n,togglePaused:o,visibleItems:r}}var hf=ea(function({noyaManager:t,colorScheme:n="light",anchor:r="right",unstyled:i=!1,advanced:o=!1,defaultCollapsed:s=!1,...a}){let{multiplayerStateManager:c,assetManager:l,userManager:p,secretManager:d,sharedConnectionDataManager:m,connectionEventManager:y,taskManager:S,ioManager:T,resourceManager:E,activityEventsManager:b,logManager:f,gitManager:g}=t,[v,I]=k.default.useState(!1),M=q(S.tasks$),O=q(T.inputs$),C=q(T.outputTransforms$);(0,k.useLayoutEffect)(()=>{I(!0)},[]);let z=k.default.useRef(null),F=k.default.useRef(null),N=k.default.useRef(null),H=k.default.useRef(null),[j,L]=Ft("noya-multiplayer-react-show-inspector",!s),[V,ne]=Ft("noya-multiplayer-react-show-events",!1),[it,xt]=Ft("noya-multiplayer-react-show-history",!1),[ti,Ia]=Ft("noya-multiplayer-react-show-users",!0),[uu,iy]=Ft("noya-multiplayer-react-show-user-details",!1),[FN,$N]=Ft("noya-multiplayer-react-show-data",!0),[KN,zN]=Ft("noya-multiplayer-react-show-tasks",!1),[HN,GN]=Ft("noya-multiplayer-react-show-shared",!1),[qN,VN]=Ft("noya-multiplayer-react-show-assets",!1),[QN,YN]=Ft("noya-multiplayer-react-show-resources",!1),[JN,XN]=Ft("noya-multiplayer-react-show-secrets",!1),[ZN,WN]=Ft("noya-multiplayer-react-show-inputs",!1),[ek,tk]=Ft("noya-multiplayer-react-show-output-transforms",!1),[nk,rk]=Ft("noya-multiplayer-react-show-activity-events",!1),[oy,ik]=Ft("noya-multiplayer-react-show-server-logs",!1),[sy,ok]=Ft("noya-multiplayer-react-show-server-simulation-logs",!1),[sk,ak]=Ft("noya-multiplayer-react-show-git",!1),[ck,uk]=Ft("noya-multiplayer-react-show-simulation",!1),lk=q(y.events$),{visibleItems:dI,paused:pk,togglePaused:fk}=Jh(lk);(0,k.useEffect)(()=>{z.current&&(z.current.scrollTop=z.current.scrollHeight)},[dI]);let dk=q(f.logs$),{visibleItems:mI,paused:mk,togglePaused:hk}=Jh(dk),yk=q(c.serverSimulationLogs$),{visibleItems:ay,paused:gk,togglePaused:bk}=Jh(yk);(0,k.useEffect)(()=>{oy&&N.current&&(N.current.scrollTop=N.current.scrollHeight)},[oy,mI]),(0,k.useEffect)(()=>{sy&&H.current&&(H.current.scrollTop=H.current.scrollHeight)},[sy,ay]);let Sk=q(c.isInitialized$),xk=q(m.data$),Tk=aI(c.sm),cy=q(l.assets$),uy=q(E.resources$),vk=q(E.isInitialized$),Ik=q(l.isInitialized$),hI=q(d.secrets$),Ek=q(d.isInitialized$),yI=q(p.allUsers$),wk=q(p.currentConnectionId$),gI=c.getServerSimulationDiagnostics?.()??null,Mk=(gI?.simulateLocally??!1)||ay.length>0,Ok=q(c.optimisticState$),Ak=q(T.inputsInitialized$),Rk=q(T.outputTransformsInitialized$),Ie=Br(n),bI=Gh(n),SI={position:"fixed",top:12,...r.includes("right")?{right:12}:{left:12},bottom:12,width:400,background:n==="light"?"rgba(255,255,255,0.95)":"rgba(0,0,0,0.95)",backdropFilter:"blur(48px)",border:`1px solid ${bI}`,borderRadius:4,display:"flex",flexDirection:"column",color:Ie.BASE_COLOR,overflow:"hidden",zIndex:9999,lineHeight:"13px"},Pk=(0,k.useCallback)(async()=>{let G=await iI(t);MA(new Blob([G]),"state.zip")},[t]),Ck=(0,k.useCallback)(async()=>{let $t=await(await su()).arrayBuffer();oI($t,t,{shouldAllowSchemaChange:()=>confirm("The imported state uses a different schema than the schema this app expects. Do you want to continue?")})},[t]);return v?j?k.default.createElement("div",{...a,style:{...!i&&SI,...a.style}},k.default.createElement(bt,{isFirst:!0,open:ti,setOpen:Ia,title:"Users",colorScheme:n,style:{flex:"0 0 auto",maxHeight:"50%",overflowY:"auto"},right:k.default.createElement("span",{style:{display:"flex",gap:"10px"}},k.default.createElement(me,{theme:Ie,onClick:()=>iy(!uu)},"Toggle details"),k.default.createElement(sI,{showInspector:j,setShowInspector:L,theme:Ie,anchor:r}))},k.default.createElement(St,{style:{flex:"0 0 auto"}},yI?.filter(G=>uu||!G.inactive).map((G,$t,Nk)=>k.default.createElement(Bt,{key:G.connectionId,colorScheme:n,variant:G.connectionId===wk?"up":void 0,bordered:$t!==Nk.length-1,style:{opacity:G.inactive?.5:1}},G.image&&k.default.createElement("img",{src:G.image,alt:G.name,style:{width:"13px",height:"13px",borderRadius:"50%",marginRight:"4px",display:"inline-block",position:"relative",background:bI,verticalAlign:"middle"}}),uu?k.default.createElement(dt,{data:G,theme:Ie}):G.name)),!yI&&k.default.createElement("div",{style:{padding:"12px",fontSize:"12px",display:"flex",flexDirection:"column",gap:"4px"}},k.default.createElement("span",null,"No connected users")))),k.default.createElement(bt,{title:k.default.createElement(yo,null,"Data",k.default.createElement(mo,{type:Sk?"success":"error"})),colorScheme:n,setOpen:$N,open:FN,right:k.default.createElement("span",{style:{display:"flex",gap:"12px"}},k.default.createElement(me,{theme:Ie,onClick:Ck},"Import"),k.default.createElement(me,{theme:Ie,onClick:Pk},"Export"),k.default.createElement(me,{theme:Ie,onClick:()=>{t.forceInit()}},"Reset"))},k.default.createElement(St,null,k.default.createElement(Bt,{colorScheme:n},k.default.createElement(dt,{name:c.schema?"state":void 0,data:Ok,theme:Ie})),c.schema&&k.default.createElement(Bt,{colorScheme:n},k.default.createElement(dt,{name:"schema",data:c.schema,theme:Ie})))),k.default.createElement(mN,{showHistory:it,setShowHistory:xt,colorScheme:n,historySnapshot:Tk,multiplayerStateManager:c}),k.default.createElement(bt,{open:qN,setOpen:VN,title:k.default.createElement(yo,null,"Assets (",cy.length,")",k.default.createElement(mo,{type:Ik?"success":"error"})),colorScheme:n,right:k.default.createElement("span",{style:{display:"flex",gap:"10px"}},k.default.createElement(me,{theme:Ie,onClick:async()=>{confirm("Are you sure you want to delete all assets?")&&await Promise.all(cy.map($t=>l.delete($t.id)))}},"Delete all"),k.default.createElement(me,{theme:Ie,onClick:()=>{console.info("[StateInspector] Reloading assets",t.id),l.fetch()}},"Reload"),k.default.createElement(me,{theme:Ie,onClick:async()=>{let G=await su();l.create(G)}},"Upload"),k.default.createElement(me,{theme:Ie,onClick:async()=>{let G=await su();l.create({data:new Uint8Array(await G.arrayBuffer()),contentType:G.type,mode:"mutable"})}},"Upload Mutable"))},k.default.createElement(St,null,cy.map(G=>k.default.createElement(Bt,{key:G.id,colorScheme:n},k.default.createElement(dt,{name:G.id,data:EV(G),theme:Ie}),k.default.createElement("div",{style:{display:"flex",gap:"4px"}},G.mode==="mutable"&&k.default.createElement(me,{theme:Ie,onClick:async()=>{let $t=await su();l.update(G.id,{data:new Uint8Array(await $t.arrayBuffer()),contentType:$t.type})}},"Replace"),k.default.createElement(me,{theme:Ie,onClick:()=>l.delete(G.id)},"Delete")))))),o&&k.default.createElement(bt,{title:k.default.createElement(yo,null,"Resources (",uy.length,")",k.default.createElement(mo,{type:vk?"success":"error"})),colorScheme:n,open:QN,setOpen:YN,right:k.default.createElement("span",{style:{display:"flex",gap:"10px"}},k.default.createElement(me,{theme:Ie,onClick:async()=>{confirm("Are you sure you want to delete all resources?")&&await E.deleteResource(uy.map($t=>({id:$t.id})))}},"Delete all"),k.default.createElement(me,{theme:Ie,onClick:async()=>{let G=prompt("Enter directory path")||te();await E.createResource({type:"directory",path:G})}},"Create Directory"),k.default.createElement(me,{theme:Ie,onClick:async()=>{let G=await su();E.createResource({type:"asset",path:G.name||te(),asset:{content:en.encode(await G.arrayBuffer()),contentType:G.type,encoding:"base64"}})}},"Create Asset"))},k.default.createElement(St,null,uy?.map(G=>k.default.createElement(Bt,{key:G.id,colorScheme:n},k.default.createElement(dt,{name:G.path,data:G,theme:Ie}),k.default.createElement("div",{style:{display:"flex",gap:"4px"}},k.default.createElement(me,{theme:Ie,onClick:()=>E.deleteResource({id:G.id})},"Delete"),k.default.createElement(me,{theme:Ie,onClick:()=>{let $t=prompt("Enter new path",G.path);$t&&E.updateResource({id:G.id,path:$t})}},"Rename")))))),o&&k.default.createElement(bt,{title:k.default.createElement(yo,null,"Secrets (",hI.length,")",k.default.createElement(mo,{type:Ek?"success":"error"})),colorScheme:n,open:JN,setOpen:XN,right:k.default.createElement("span",{style:{display:"flex",gap:"10px"}},k.default.createElement(me,{theme:Ie,onClick:()=>{d.fetchSecrets()}},"Refresh"),k.default.createElement(me,{theme:Ie,onClick:()=>{let G=prompt("Enter secret name");if(!G)return;let $t=prompt("Enter secret value");$t&&d.createSecret(null,G,$t)}},"Create"))},k.default.createElement(St,null,hI.map(G=>k.default.createElement(Bt,{key:G.id,colorScheme:n},k.default.createElement(dt,{data:G,theme:Ie}),k.default.createElement(me,{theme:Ie,onClick:()=>d.deleteSecret(G.id)},"Delete"))))),o&&k.default.createElement(dN,{showGit:sk,setShowGit:ak,colorScheme:n,gitManager:g}),o&&k.default.createElement(bt,{open:ZN,setOpen:WN,title:k.default.createElement(yo,null,"Inputs (",O.length,")",k.default.createElement(mo,{type:Ak?"success":"error"})),colorScheme:n},k.default.createElement(St,null,O?.map(G=>k.default.createElement(Bt,{key:G.id,colorScheme:n},k.default.createElement(dt,{data:G,theme:Ie}))),!O?.length&&k.default.createElement("div",{style:{padding:"12px",fontSize:"12px",display:"flex",flexDirection:"column",gap:"4px"}},k.default.createElement("span",null,"No inputs")))),o&&k.default.createElement(bt,{open:ek,setOpen:tk,title:k.default.createElement(yo,null,"Output Transforms (",C.length,")",k.default.createElement(mo,{type:Rk?"success":"error"})),colorScheme:n},k.default.createElement(St,null,C?.map(G=>k.default.createElement(Bt,{key:G.id,colorScheme:n},k.default.createElement(dt,{data:G,theme:Ie}))),!C?.length&&k.default.createElement("div",{style:{padding:"12px",fontSize:"12px",display:"flex",flexDirection:"column",gap:"4px"}},k.default.createElement("span",null,"No output transforms")))),o&&k.default.createElement(bt,{title:"Tasks",colorScheme:n,open:KN,setOpen:zN},k.default.createElement(St,null,M?.map(G=>k.default.createElement(Bt,{key:G.id,colorScheme:n,style:{backgroundColor:G.status==="done"?"rgba(0,255,0,0.2)":G.status==="error"?"rgba(255,0,0,0.2)":void 0}},k.default.createElement(dt,{name:G.name,data:G.payload,theme:Ie}))))),k.default.createElement(bt,{open:HN,setOpen:GN,title:"Shared Connection Data",colorScheme:n},k.default.createElement(St,null,Object.entries(xk).map(([G,$t])=>k.default.createElement(Bt,{key:G,colorScheme:n},k.default.createElement(dt,{name:G,data:$t,theme:Ie,expandLevel:10}))))),k.default.createElement(eI,{colorScheme:n,showLogs:oy,setShowLogs:ik,logs:mI,paused:mk,onTogglePaused:hk,containerRef:N}),Mk&&k.default.createElement(eI,{title:"Server Script Simulation Logs",colorScheme:n,showLogs:sy,setShowLogs:ok,logs:ay,paused:gk,onTogglePaused:bk,containerRef:H}),k.default.createElement(bt,{open:ck,setOpen:uk,title:"Server Simulation",colorScheme:n},k.default.createElement(St,null,k.default.createElement(Bt,{colorScheme:n},k.default.createElement(dt,{name:"status",data:gI??{simulateLocally:!1,simulatorActive:!1,clockSkewMs:0,invocations:[],pendingPredictions:[]},theme:Ie,expandLevel:2})))),o&&k.default.createElement(uN,{colorScheme:n,activityEventsContainerRef:F,showEvents:nk,setShowEvents:rk,activityEventsManager:b}),k.default.createElement(pN,{connectionEvents:dI,paused:pk,onTogglePaused:fk,colorScheme:n,eventsContainerRef:z,showEvents:V,setShowEvents:ne})):k.default.createElement("div",{...a,style:{...SI,padding:"4px 10px",width:void 0,...r.includes("bottom")?{bottom:12,top:void 0}:{bottom:void 0}},onClick:()=>L(!0)},k.default.createElement(sI,{showInspector:j,setShowInspector:L,theme:Ie,anchor:r})):null}),EV=Ww(e=>e.url.startsWith("data:")||e.url.startsWith("blob:")?{...e,url:Zv(e.url,40)}:e);function wV(){let e=document.createElement("div");e.id="noya-multiplayer-react-inspector-host";let t=e.attachShadow({mode:"open"}),n=document.createElement("div");return t.appendChild(n),{host:e,container:n}}function Xh(){let{host:e,container:t}=wV(),n=(0,IN.createRoot)(t);return document.body.appendChild(e),{root:n,unmount:()=>{document.body.removeChild(e)}}}function uI({noyaManager:e,disabled:t=!1,advanced:n=!1,defaultCollapsed:r=!1,colorScheme:i,anchor:o}){let[s,a]=cI.default.useState(null);ip(()=>{if(t)return;let{root:c,unmount:l}=Xh();return a(c),l},[t]),ip(()=>{s&&s.render(cI.default.createElement(hf,{colorScheme:i,anchor:o,noyaManager:e,advanced:n,defaultCollapsed:r}))},[e,o,i,s,n,r])}function MV(e,t){let[n]=(0,Xt.useState)(()=>new $s(e(),t)),r=(0,Xt.useCallback)(()=>n.getState(),[n]),i=(0,Xt.useSyncExternalStore)(n.addListener,r,r),o=(0,Xt.useCallback)((...s)=>{let[a,c]=s.length===1?[void 0,s[0]]:s;if(a===void 0){let l=n.performAction;c instanceof Function?l({run:c,undo:()=>i}):l({run:()=>c,undo:()=>i})}else{let l=n.performAction;c instanceof Function?l(a,{run:c,undo:()=>i}):l(a,{run:()=>c,undo:()=>i})}},[i,n]);return[i,o,n]}function aI(e){return(0,Xt.useSyncExternalStore)(e.historyEmittor.addListener,e.getHistorySnapshot,e.getHistorySnapshot)}function Zh(e,t){let n=q(e.multiplayerStateManager.optimisticState$),r=q(e.assetManager.assets$),i=(0,Xt.useMemo)(()=>({noyaManager:e,taskManager:e.taskManager,connectionEventManager:e.connectionEventManager,userManager:e.userManager,sharedConnectionDataManager:e.sharedConnectionDataManager,multiplayerStateManager:e.multiplayerStateManager,assetManager:e.assetManager,aiManager:e.aiManager,rpcManager:e.rpcManager,pipelineManager:e.pipelineManager,secretManager:e.secretManager,menuItemsManager:e.menuManager,createAsset:e.assetManager.create,deleteAsset:e.assetManager.delete,assets:r}),[e,r]),o=(0,Xt.useRef)(t?.sync);return(0,Xt.useEffect)(()=>{if(o.current)return o.current({noyaManager:e})},[e]),AV(e),uI({noyaManager:e,disabled:!t?.inspector,advanced:!0,...typeof t?.inspector=="object"&&t?.inspector}),[n,e.multiplayerStateManager.setState,i]}function OV(e,t){let{sync:n=np(),inspector:r,...i}=t??{},[o]=(0,Xt.useState)(()=>new Vi(e,i));return Zh(o,{sync:n,inspector:r})}function AV(e){let t=q(e.unrecoverableError);(0,Xt.useEffect)(()=>{if(!t)return;let n=document.createElement("div");n.id="noya-multiplayer-react-error-overlay",document.body.appendChild(n);let r=(0,EN.createRoot)(n);return r.render((0,Xt.createElement)(z1,{error:t})),()=>{r.unmount(),n.remove()}})}function wN(e){return{theme:"light",viewType:"editable",initialState:e,inspector:!1,isDemo:!1,access:void 0}}function MN(e,t){return t?hl({schema:t,value:e,defs:Er(t)}):e}function ON(e){let n=(e?.window??globalThis).location;if(!n)return null;let r=(n.hash||"").replace(/^#/,""),o=new URLSearchParams(r).get("data");if(!o)return null;try{return JSON.parse(o)}catch{return null}}function RV(e){e.clientId!==void 0&&KS(e.clientId),e.clientName!==void 0&&$S(e.clientName),e.clientImage!==void 0&&zS(e.clientImage)}function Wh(e,t,n){let r=e instanceof Function?e():e,i=ON(n)??wN(r);(n?.overrideExistingState||i.initialState===null)&&(i.initialState=r),i.initialState=MN(i.initialState,t),i.isDemo=i.isDemo??!1;let o=i.viewType==="editable"?"write":"read";return i.access=i.access??o,RV(i),i}function ey(e){let{multiplayerUrl:t,offlineStorageKey:n,debug:r,policyAuthContext:i,serverScripts:o,git:s,parentOrigin:a,enableDocumentAI:c}=e??{};return AS()?nx({debug:r,policyAuthContext:i,origin:a,enableDocumentAI:c}):t?rx({url:t,debug:r}):n?XS({key:n,...o?{serverScripts:o}:{},...s?{git:s}:{}}):np()}function lI(...e){let[t,n]=typeof e[0]=="object"&&e[0]!==null&&"schema"in e[0]&&w.IsSchema(e[0].schema)?[null,e[0]]:[e[0],e[1]],[{multiplayerUrl:r,inspector:i,initialState:o,theme:s,viewType:a,userId:c,isDemo:l,access:p,parentOrigin:d,enableDocumentAI:m}]=(0,Ai.useState)(()=>Wh(t,n?.schema,{overrideExistingState:n?.overrideExistingState})),y=(0,Ai.useMemo)(()=>{if(!p&&c===void 0)return;let g={};return p&&(g.access=p),c!==void 0&&(g.id=c??null),g},[p,c]),S=(0,Ai.useMemo)(()=>ey({multiplayerUrl:r,offlineStorageKey:n?.offlineStorageKey,debug:n?.debug,policyAuthContext:y,serverScripts:n?.serverScripts,git:n?.git,parentOrigin:d,enableDocumentAI:m}),[r,n?.offlineStorageKey,n?.debug,y,n?.serverScripts,n?.git,d,m]),[T]=(0,Ai.useState)(()=>new Vi(o,{...n,resourceUrlBase:n?.resourceUrlBase??d??(typeof globalThis.location>"u"||globalThis.location.origin==="null"?void 0:globalThis.location.origin)}));(0,Ai.useEffect)(()=>{c&&(T.sharedConnectionDataManager.setCurrentConnectionId(c),T.userManager.setCurrentConnectionId(c),T.userManager.setCurrentUserId(c))},[T,c]),(0,Ai.useEffect)(()=>{y&&T.multiplayerStateManager.setPolicyAuthContext(y)},[T,y]);let E=Zh(T,{inspector:n?.inspector??i,sync:n?.sync??S}),[,,b]=E,f=(0,Ai.useMemo)(()=>({...b,theme:s,viewType:a,isDemo:l}),[b,s,a,l]);return[E[0],E[1],f]}u();var AN=Q(require("react"));var Ri,ty;function PV(e){if(Ri)throw new Error("Noya has already been initialized. Call `useNoyaState` instead.");let{initialState:t,sync:n,inspector:r,theme:i,viewType:o,offlineStorageKey:s,multiplayerUrl:a,...c}=e??{},l=Wh(t??null,c?.schema,{overrideExistingState:c?.overrideExistingState}),p=l.access||l.userId!==void 0?{...l.access?{access:l.access}:{},...l.userId!==void 0?{id:l.userId??null}:{}}:void 0;Ri=new Vi(l.initialState,{...c,resourceUrlBase:c.resourceUrlBase??l.parentOrigin??(typeof globalThis.location>"u"||globalThis.location.origin==="null"?void 0:globalThis.location.origin)}),l.userId&&(Ri.sharedConnectionDataManager.setCurrentConnectionId(l.userId),Ri.userManager.setCurrentConnectionId(l.userId),Ri.userManager.setCurrentUserId(l.userId));let d=n??ey({multiplayerUrl:a??l.multiplayerUrl,offlineStorageKey:s,debug:c?.debug,serverScripts:c?.serverScripts,git:c?.git,policyAuthContext:p,parentOrigin:l.parentOrigin,enableDocumentAI:l.enableDocumentAI});try{d({noyaManager:Ri})}catch(T){console.warn("Failed to activate sync",T)}let m=r??l.inspector,y=i??l.theme??"light",S=o??l.viewType??"editable";if(m){let{root:T}=Xh();T.render(AN.default.createElement(hf,{noyaManager:Ri,colorScheme:m===!0?y:m.colorScheme,anchor:m===!0?"bottom right":m.anchor,advanced:m===!0?!1:m.advanced,defaultCollapsed:m===!0?!1:m.defaultCollapsed}))}ty={sync:d,inspector:m,theme:y,viewType:S,userId:l.userId,isDemo:l.isDemo}}function pI(){if(!Ri||!ty)throw new Error("Noya has not been initialized. Call initializeNoya once before using Noya hooks.");return Ri}function fI(){return ty}function CV(){Ri=void 0,ty=void 0}function RN(e){switch(e.type){case"directory":return{path:e.path,type:"directory"};case"asset":return{path:e.path,type:"asset",assetId:e.assetId,asset:e.asset};case"file":return{path:e.path,type:"file",fileId:e.fileId};case"resource":return{path:e.path,type:"resource",fileId:e.fileId,resourceId:e.resourceId};default:throw new Error(`Unknown resource type: ${e.type}`)}}function PN({addedResources:e,modifiedResources:t,removedResources:n}){let r=e.map(RN),i=Array.from(new Map(r.map(c=>[c.path,c])).values()),o=t.map(c=>({id:c.id,...c.path!==void 0?{path:c.path}:{},...c.assetId!==void 0?{assetId:c.assetId}:{},...c.asset?{asset:c.asset}:{}}))??[],s=n.map(c=>({id:c.id})),a={};return i.length&&(a.create=i),o.length&&(a.update=o),s.length&&(a.delete=s),a}var ny=(0,Oe.createContext)(void 0);function CN(){let e=(0,Oe.useContext)(ny),t=fI();if(e)return e;if(t)return{noyaManager:pI(),theme:t.theme,viewType:t.viewType}}function xe(){let e=CN();if(e)return e;throw new Error("useNoyaStateContext must be used within a NoyaStateProvider")}function NV(){let{noyaManager:e}=xe();return e}function kV(){let{theme:e}=xe();return e}function DV(){let{viewType:e}=xe();return e}function UV(){let{noyaManager:e}=xe();return q(e.assetManager.assets$)}function _V(e){let{noyaManager:t}=xe(),n=(0,Oe.useMemo)(()=>t.assetManager.assets$.map(r=>r.find(i=>i.stableId===e)??r.find(i=>i.id===e)),[t,e]);return q(n)}function NN(){let{noyaManager:e}=xe(),t=q(e.assetManager.isInitialized$);return(0,Oe.useMemo)(()=>({create:e.assetManager.create,delete:e.assetManager.delete,isInitialized:t}),[e,t])}function ry(){let{noyaManager:e}=xe();return e.aiManager}function jV(){let{noyaManager:e}=xe();return e.secretManager}function LV(){let{noyaManager:e}=xe();return q(e.secretManager.secrets$)}function BV(e){let{noyaManager:t}=xe();return q(t.secretManager.secrets$,(0,Oe.useCallback)(n=>n.find(r=>r.name===e),[e]))}function FV(){let{noyaManager:e}=xe();return q(e.ioManager.inputs$)}function $V(){let{noyaManager:e}=xe();return q(e.ioManager.outputTransforms$)}function KV(){let{noyaManager:e}=xe();return e.ioManager}function zV(e){let{noyaManager:t}=xe(),n=vA(e);(0,Oe.useEffect)(()=>(t.publishingManager.setPublishingEnabled(!0),t.publishingManager.getFilesToPublish=n,()=>{t.publishingManager.setPublishingEnabled(!1),t.publishingManager.getFilesToPublish=void 0}),[t,n])}function kN(){let{noyaManager:e,viewType:t}=xe(),n=(0,Oe.useMemo)(()=>_.combine([...t==="preview"?[]:[e.multiplayerStateManager.isInitialized$],e.secretManager.isInitialized$,e.assetManager.isInitialized$],r=>r.every(i=>i)),[e,t]);return q(n)}function HV(){let{noyaManager:e}=xe();return e.pipelineManager}function GV(){let{noyaManager:e}=xe();return e.scriptEvaluatorManager}function cu(){let{noyaManager:e}=xe();return e.userManager}function qV(){let e=cu();return q(e?.allUsers$)}function VV(e){let t=cu();return q(t?.allUsers$,(0,Oe.useCallback)(n=>cm(n,e),[e]))}function QV(){let e=cu();return q(e?.connectedUsers$)}function YV(){let e=cu();return q(e?.currentUser$)}function JV(){let e=cu();return q(e?.currentId$)}function XV(){let{noyaManager:e}=xe();return e.sharedConnectionDataManager}function ZV(){let{noyaManager:e}=xe();return e.enqueueInput}function WV(){let{noyaManager:e}=xe();return q(e.isProcessing$)}function DN(){let{noyaManager:e}=xe();return q(e.filePropertyManager.optimisticValue$)}function UN(){let{noyaManager:e}=xe();return e.filePropertyManager}function e5(){let e=DN(),t=UN();return[e,t.updateName]}function _N(){let{noyaManager:e}=xe();return e.resourceManager}function jN(){let{noyaManager:e}=xe();return e.transcriptionManager}function t5(e,t){let n=jN(),r=(0,Oe.useMemo)(()=>{if(e)return n.getAssetTranscription$(e,{endpoint:t?.endpoint,apiKey:t?.apiKey})},[n,e,t?.endpoint,t?.apiKey]);return q(r)}function n5(e){switch(e.type){case"asset":return{kind:"asset",id:e.id,assetId:e.assetId};case"file":return{kind:"noyaFile",id:e.id,fileId:e.fileId};default:return{kind:"folder",id:e.id}}}function r5({shouldDeleteAssets:e=!0}={}){let t=_N(),n=NN(),r=q(t.optimisticResources$,(0,Oe.useCallback)(o=>Object.fromEntries(o.map(s=>[s.path,s])),[])),i=(0,Oe.useCallback)(async o=>{let s=o instanceof Function?o(r):o,{addedResources:a,removedResources:c,modifiedResources:l}=jw(r,s,"id"),p=PN({addedResources:a,modifiedResources:l,removedResources:c});if(((p.create?.length??0)>0||(p.update?.length??0)>0||(p.delete?.length??0)>0)&&await t.patchResources(p),e)for(let m of c)m.type==="asset"&&await n.delete(m.assetId)},[r,t,e,n]);return[r,i]}var i5=[];function o5(e){let{noyaManager:t}=xe();return qh(e,t.activityEventsManager)}function qh(e,t){let[n,r]=(0,Oe.useState)(void 0),i=gA(e);(0,Oe.useEffect)(()=>{if(!i)return;let s=t.subscribe(i);return r(s),()=>{r(void 0),t.unsubscribe(s)}},[t,i]);let o=n?t.getStream(n):void 0;return q(o)??i5}var LN=({children:e,fallback:t})=>kN()?e:t??null;function s5({schema:e,mergeHistoryEntries:t,outputTransforms:n,inputs:r,safeEval:i}){let o=ny;function s({children:I,contextValue:M}){return Oe.default.createElement(ny.Provider,{value:M},I)}function a({children:I,initialState:M,...O}){let[,,{noyaManager:C,theme:z,viewType:F}]=lI(M,{schema:e,mergeHistoryEntries:t,outputTransforms:n,inputs:r,safeEval:i,...O}),N=(0,Oe.useMemo)(()=>({noyaManager:C,theme:z,viewType:F}),[C,z,F]);return Oe.default.createElement(s,{contextValue:N},O.fallback!==void 0?Oe.default.createElement(LN,{fallback:O.fallback},I):I)}function c(I,M){let{noyaManager:O}=xe(),C=typeof I=="function"||!I?"":I,z=(0,Oe.useMemo)(()=>typeof I=="function"?O.multiplayerStateManager.optimisticState$.map(I,{isEqual:M?.isEqual}):O.multiplayerStateManager.optimisticState$,[O,I,M?.isEqual]);return q(z,C)}function l(I){let{noyaManager:M}=xe();return(0,Oe.useCallback)((...C)=>{let[z,F]=C.length===2?C:[{},C[0]];M.multiplayerStateManager.setStateAtPath(z,I??"",F)},[M,I])}function p(...I){let[M,O,C]=I.length>=1&&typeof I[0]=="function"?[I[0],I[1],void 0]:[void 0,void 0,I[0]],z=c(M??C??"",O),F=l(C??"");return[z,F]}function d(){let{noyaManager:I}=xe();return I.multiplayerStateManager}function m(){let{noyaManager:I}=xe();return I.sharedConnectionDataManager}function y(){return xe().noyaManager}function S(){let{menuManager:I}=y();return q(I.leftMenuItems$)}function T(I){let{menuManager:M}=y();(0,Oe.useEffect)(()=>{I&&M.setLeftMenuItems(I)},[M,I])}function E(){let{menuManager:I}=y();return q(I.rightMenuItems$)}function b(I){let{menuManager:M}=y();(0,Oe.useEffect)(()=>{I&&M.setRightMenuItems(I)},[M,I])}function f(I){let{menuManager:M}=y();(0,Oe.useEffect)(()=>M.addListener(I),[M,I])}function g(){let{menuManager:I}=y();return(0,Oe.useCallback)(M=>I.emit(M),[I])}function v(I){let{leftMenuItems:M,rightMenuItems:O,onSelectMenuItem:C}=I;T(M),b(O);let z=(0,Oe.useCallback)(()=>{},[]);f(C??z)}return{Context:o,Provider:a,NoyaContextProvider:s,useValue:c,useSetValue:l,useValueState:p,useStateManager:d,useSharedConnectionDataManager:m,useLeftMenuItems:S,useSetLeftMenuItems:T,useRightMenuItems:E,useSetRightMenuItems:b,useHandleMenuItem:f,useOnSelectMenuItemCallback:g,useNoyaManager:y,useMenu:v}}function a5(e){let t=ry();(0,BN.useEffect)(()=>t.registerTool(e),[t,e])}function c5(){let e=ry();return q(e.callableTools$)}u();var Pi=Q(require("react"));function u5(e,t){return!!t&&Date.now()-t<e}var l5=ea(function({user:t,sharedConnectionDataManager:n,hideAfter:r=5e3,renderUserPointer:i}){let o=(0,Pi.useMemo)(()=>{let d=n.metadata$.observePath([t.connectionId]).throttle(50),m=n.data$.observePath([t.connectionId]).throttle(50);return _.combine([d,m],([y,S])=>({metadata:y,data:S}))},[n,t.connectionId]),{metadata:s,data:a}=q(o),[,c]=(0,Pi.useState)(0),l=s?.updatedAt??0,p=u5(r,l);return(0,Pi.useEffect)(()=>{if(!p)return;let d=setTimeout(()=>{c(m=>m+1)},r);return()=>clearTimeout(d)},[r,p,l]),a?.pointer?i({userId:t.connectionId,name:t.name,point:a.pointer,visible:p}):null}),p5=ea(function({userManager:t,sharedConnectionDataManager:n,renderUserPointer:r}){let i=q(n.currentConnectionId$),o=q(t.connectedUsers$);return Pi.default.createElement(Pi.default.Fragment,null,o.map(s=>s.connectionId===i?null:Pi.default.createElement(l5,{key:s.connectionId,user:s,sharedConnectionDataManager:n,renderUserPointer:r})))});u();function f5(e){let{noyaManager:t}=xe(),n=q(t.resourceManager.optimisticResources$),r=q(t.assetManager.assets$);if(e)return Hd(e,n,r)}u();var Bo=class{constructor(t,n={}){this.url=t;this.options=n;this.ws=new lc({debug:n.debug,onopen:this.handleOpen,onmessage:this.handleMessage,onclose:this.handleClose,activityDetector:new uc})}ws;closedForever=!1;async connect(){this.closedForever||this.ws.connect(this.url.toString())}handleOpen=()=>{this.closedForever||(this.options.debug&&console.info("ws connected"),this.options.onConnectionEvent?.({type:"stateChange",state:"OPEN"}))};handleMessage=t=>{if(this.closedForever)return;this.options.debug&&console.info("ws receiving message ",t.data);let n=JSON.parse(t.data);this.options.onConnectionEvent?.({type:"receive",message:n})};handleClose=()=>{this.closedForever||(this.options.debug&&console.info("ws disconnected"),this.options.onConnectionEvent?.({type:"stateChange",state:"CLOSED"}))};send(t){this.closedForever||(this.options.debug&&console.info("ws sending message",t),this.options.onConnectionEvent?.({type:"send",message:t}),this.ws.send(JSON.stringify(t)))}close(){this.closedForever||(this.closedForever=!0,this.ws.shutdown(),this.ws.listeners.forEach(t=>{this.ws.removeListener(t)}))}addListener(t){return this.ws.addListener(t)}removeListener(t){return this.ws.removeListener(t)}};
73
73
  /*! Bundled license information:
74
74
 
75
75
  scheduler/cjs/scheduler.production.js: