@telepath-computer/television 1.4.17 → 1.4.18

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,7 +1,7 @@
1
1
  var J4=Object.defineProperty;var kv=n=>{throw TypeError(n)};var X4=(n,t,e)=>t in n?J4(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e;var $=(n,t,e)=>X4(n,typeof t!="symbol"?t+"":t,e),Kp=(n,t,e)=>t.has(n)||kv("Cannot "+e);var o=(n,t,e)=>(Kp(n,t,"read from private field"),e?e.call(n):t.get(n)),m=(n,t,e)=>t.has(n)?kv("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(n):t.set(n,e),d=(n,t,e,r)=>(Kp(n,t,"write to private field"),r?r.call(n,e):t.set(n,e),e),h=(n,t,e)=>(Kp(n,t,"access private method"),e);var Ah=(n,t,e,r)=>({set _(i){d(n,t,i,e)},get _(){return o(n,t,r)}});import{i as Q4,a as eA,b as tA,c as nA,d as rA,e as iA,f as sA,g as oA,U as aA,A as lA,h as cA}from"./artifact-bridge-BEUWXKq7.js";import{m as uA,a as hA,b as dA}from"./missing-artifact-page-DVzJ41AE.js";var Ks=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function pA(n){if(Object.prototype.hasOwnProperty.call(n,"__esModule"))return n;var t=n.default;if(typeof t=="function"){var e=function r(){return this instanceof r?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};e.prototype=t.prototype}else e={};return Object.defineProperty(e,"__esModule",{value:!0}),Object.keys(n).forEach(function(r){var i=Object.getOwnPropertyDescriptor(n,r);Object.defineProperty(e,r,i.get?i:{enumerable:!0,get:function(){return n[r]}})}),e}var Tv={},Cv={},Jp,Rv;function Bb(){if(Rv)return Jp;Rv=1;var n=Object.prototype.toString;return Jp=function(e){var r=n.call(e),i=r==="[object Arguments]";return i||(i=r!=="[object Array]"&&e!==null&&typeof e=="object"&&typeof e.length=="number"&&e.length>=0&&n.call(e.callee)==="[object Function]"),i},Jp}var Xp,Iv;function fA(){if(Iv)return Xp;Iv=1;var n;if(!Object.keys){var t=Object.prototype.hasOwnProperty,e=Object.prototype.toString,r=Bb(),i=Object.prototype.propertyIsEnumerable,s=!i.call({toString:null},"toString"),a=i.call(function(){},"prototype"),l=["toString","toLocaleString","valueOf","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","constructor"],c=function(y){var v=y.constructor;return v&&v.prototype===y},u={$applicationCache:!0,$console:!0,$external:!0,$frame:!0,$frameElement:!0,$frames:!0,$innerHeight:!0,$innerWidth:!0,$onmozfullscreenchange:!0,$onmozfullscreenerror:!0,$outerHeight:!0,$outerWidth:!0,$pageXOffset:!0,$pageYOffset:!0,$parent:!0,$scrollLeft:!0,$scrollTop:!0,$scrollX:!0,$scrollY:!0,$self:!0,$webkitIndexedDB:!0,$webkitStorageInfo:!0,$window:!0},p=(function(){if(typeof window>"u")return!1;for(var y in window)try{if(!u["$"+y]&&t.call(window,y)&&window[y]!==null&&typeof window[y]=="object")try{c(window[y])}catch{return!0}}catch{return!0}return!1})(),f=function(y){if(typeof window>"u"||!p)return c(y);try{return c(y)}catch{return!1}};n=function(v){var S=v!==null&&typeof v=="object",_=e.call(v)==="[object Function]",I=r(v),Z=S&&e.call(v)==="[object String]",L=[];if(!S&&!_&&!I)throw new TypeError("Object.keys called on a non-object");var z=a&&_;if(Z&&v.length>0&&!t.call(v,0))for(var P=0;P<v.length;++P)L.push(String(P));if(I&&v.length>0)for(var B=0;B<v.length;++B)L.push(String(B));else for(var F in v)!(z&&F==="prototype")&&t.call(v,F)&&L.push(String(F));if(s)for(var q=f(v),Q=0;Q<l.length;++Q)!(q&&l[Q]==="constructor")&&t.call(v,l[Q])&&L.push(l[Q]);return L}}return Xp=n,Xp}var Qp,$v;function mA(){if($v)return Qp;$v=1;var n=Array.prototype.slice,t=Bb(),e=Object.keys,r=e?function(a){return e(a)}:fA(),i=Object.keys;return r.shim=function(){if(Object.keys){var a=(function(){var l=Object.keys(arguments);return l&&l.length===arguments.length})(1,2);a||(Object.keys=function(c){return t(c)?i(n.call(c)):i(c)})}else Object.keys=r;return Object.keys||r},Qp=r,Qp}var ef,xv;function lh(){if(xv)return ef;xv=1;var n=Object.defineProperty||!1;if(n)try{n({},"a",{value:1})}catch{n=!1}return ef=n,ef}var tf,Pv;function Si(){return Pv||(Pv=1,tf=SyntaxError),tf}var nf,Dv;function pe(){return Dv||(Dv=1,nf=TypeError),nf}var rf,Lv;function gA(){return Lv||(Lv=1,rf=Object.getOwnPropertyDescriptor),rf}var sf,Mv;function Hl(){if(Mv)return sf;Mv=1;var n=gA();if(n)try{n([],"length")}catch{n=null}return sf=n,sf}var of,Ov;function Wb(){if(Ov)return of;Ov=1;var n=lh(),t=Si(),e=pe(),r=Hl();return of=function(s,a,l){if(!s||typeof s!="object"&&typeof s!="function")throw new e("`obj` must be an object or a function`");if(typeof a!="string"&&typeof a!="symbol")throw new e("`property` must be a string or a symbol`");if(arguments.length>3&&typeof arguments[3]!="boolean"&&arguments[3]!==null)throw new e("`nonEnumerable`, if provided, must be a boolean or null");if(arguments.length>4&&typeof arguments[4]!="boolean"&&arguments[4]!==null)throw new e("`nonWritable`, if provided, must be a boolean or null");if(arguments.length>5&&typeof arguments[5]!="boolean"&&arguments[5]!==null)throw new e("`nonConfigurable`, if provided, must be a boolean or null");if(arguments.length>6&&typeof arguments[6]!="boolean")throw new e("`loose`, if provided, must be a boolean");var c=arguments.length>3?arguments[3]:null,u=arguments.length>4?arguments[4]:null,p=arguments.length>5?arguments[5]:null,f=arguments.length>6?arguments[6]:!1,y=!!r&&r(s,a);if(n)n(s,a,{configurable:p===null&&y?y.configurable:!p,enumerable:c===null&&y?y.enumerable:!c,value:l,writable:u===null&&y?y.writable:!u});else if(f||!c&&!u&&!p)s[a]=l;else throw new t("This environment does not support defining a property as non-configurable, non-writable, or non-enumerable.")},of}var af,Nv;function Cp(){if(Nv)return af;Nv=1;var n=lh(),t=function(){return!!n};return t.hasArrayLengthDefineBug=function(){if(!n)return null;try{return n([],"length",{value:1}).length!==1}catch{return!0}},af=t,af}var lf,zv;function ta(){if(zv)return lf;zv=1;var n=mA(),t=typeof Symbol=="function"&&typeof Symbol("foo")=="symbol",e=Object.prototype.toString,r=Array.prototype.concat,i=Wb(),s=function(u){return typeof u=="function"&&e.call(u)==="[object Function]"},a=Cp()(),l=function(u,p,f,y){if(p in u){if(y===!0){if(u[p]===f)return}else if(!s(y)||!y())return}a?i(u,p,f,!0):i(u,p,f)},c=function(u,p){var f=arguments.length>2?arguments[2]:{},y=n(p);t&&(y=r.call(y,Object.getOwnPropertySymbols(p)));for(var v=0;v<y.length;v+=1)l(u,y[v],p[y[v]],f[y[v]])};return c.supportsDescriptors=!!a,lf=c,lf}var oc={exports:{}},Hv;function jb(){return Hv||(Hv=1,typeof self<"u"?oc.exports=self:typeof window<"u"?oc.exports=window:oc.exports=Function("return this")()),oc.exports}var cf,Zv;function Gb(){if(Zv)return cf;Zv=1;var n=jb();return cf=function(){return typeof Ks!="object"||!Ks||Ks.Math!==Math||Ks.Array!==Array?n:Ks},cf}var uf,Uv;function vA(){if(Uv)return uf;Uv=1;var n=ta(),t=Hl(),e=Gb();return uf=function(){var i=e();if(n.supportsDescriptors){var s=t(i,"globalThis");(!s||s.configurable&&(s.enumerable||!s.writable||globalThis!==i))&&Object.defineProperty(i,"globalThis",{configurable:!0,enumerable:!1,value:i,writable:!0})}else(typeof globalThis!="object"||globalThis!==i)&&(i.globalThis=i);return i},uf}var hf,Fv;function y1(){if(Fv)return hf;Fv=1;var n=ta(),t=jb(),e=Gb(),r=vA(),i=e(),s=function(){return i};return n(s,{getPolyfill:e,implementation:t,shim:r}),hf=s,hf}var df,qv;function _i(){return qv||(qv=1,df=function(t){return!!t&&(typeof t=="function"||typeof t=="object")}),df}var pf,Vv;function w1(){return Vv||(Vv=1,pf=Object),pf}var ff,Bv;function Yb(){return Bv||(Bv=1,ff=Error),ff}var mf,Wv;function yA(){return Wv||(Wv=1,mf=EvalError),mf}var gf,jv;function wA(){return jv||(jv=1,gf=RangeError),gf}var vf,Gv;function b1(){return Gv||(Gv=1,vf=ReferenceError),vf}var yf,Yv;function bA(){return Yv||(Yv=1,yf=URIError),yf}var wf,Kv;function SA(){return Kv||(Kv=1,wf=Math.abs),wf}var bf,Jv;function _A(){return Jv||(Jv=1,bf=Math.floor),bf}var Sf,Xv;function AA(){return Xv||(Xv=1,Sf=Math.max),Sf}var _f,Qv;function EA(){return Qv||(Qv=1,_f=Math.min),_f}var Af,ey;function kA(){return ey||(ey=1,Af=Math.pow),Af}var Ef,ty;function TA(){return ty||(ty=1,Ef=Math.round),Ef}var kf,ny;function S1(){return ny||(ny=1,kf=Number.isNaN||function(t){return t!==t}),kf}var Tf,ry;function CA(){if(ry)return Tf;ry=1;var n=S1();return Tf=function(e){return n(e)||e===0?e:e<0?-1:1},Tf}var Cf,iy;function Zl(){return iy||(iy=1,Cf=function(){if(typeof Symbol!="function"||typeof Object.getOwnPropertySymbols!="function")return!1;if(typeof Symbol.iterator=="symbol")return!0;var t={},e=Symbol("test"),r=Object(e);if(typeof e=="string"||Object.prototype.toString.call(e)!=="[object Symbol]"||Object.prototype.toString.call(r)!=="[object Symbol]")return!1;var i=42;t[e]=i;for(var s in t)return!1;if(typeof Object.keys=="function"&&Object.keys(t).length!==0||typeof Object.getOwnPropertyNames=="function"&&Object.getOwnPropertyNames(t).length!==0)return!1;var a=Object.getOwnPropertySymbols(t);if(a.length!==1||a[0]!==e||!Object.prototype.propertyIsEnumerable.call(t,e))return!1;if(typeof Object.getOwnPropertyDescriptor=="function"){var l=Object.getOwnPropertyDescriptor(t,e);if(l.value!==i||l.enumerable!==!0)return!1}return!0}),Cf}var Rf,sy;function _1(){if(sy)return Rf;sy=1;var n=typeof Symbol<"u"&&Symbol,t=Zl();return Rf=function(){return typeof n!="function"||typeof Symbol!="function"||typeof n("foo")!="symbol"||typeof Symbol("bar")!="symbol"?!1:t()},Rf}var If,oy;function Kb(){return oy||(oy=1,If=typeof Reflect<"u"&&Reflect.getPrototypeOf||null),If}var $f,ay;function Jb(){if(ay)return $f;ay=1;var n=w1();return $f=n.getPrototypeOf||null,$f}var xf,ly;function RA(){if(ly)return xf;ly=1;var n="Function.prototype.bind called on incompatible ",t=Object.prototype.toString,e=Math.max,r="[object Function]",i=function(c,u){for(var p=[],f=0;f<c.length;f+=1)p[f]=c[f];for(var y=0;y<u.length;y+=1)p[y+c.length]=u[y];return p},s=function(c,u){for(var p=[],f=u,y=0;f<c.length;f+=1,y+=1)p[y]=c[f];return p},a=function(l,c){for(var u="",p=0;p<l.length;p+=1)u+=l[p],p+1<l.length&&(u+=c);return u};return xf=function(c){var u=this;if(typeof u!="function"||t.apply(u)!==r)throw new TypeError(n+u);for(var p=s(arguments,1),f,y=function(){if(this instanceof f){var Z=u.apply(this,i(p,arguments));return Object(Z)===Z?Z:this}return u.apply(c,i(p,arguments))},v=e(0,u.length-p.length),S=[],_=0;_<v;_++)S[_]="$"+_;if(f=Function("binder","return function ("+a(S,",")+"){ return binder.apply(this,arguments); }")(y),u.prototype){var I=function(){};I.prototype=u.prototype,f.prototype=new I,I.prototype=null}return f},xf}var Pf,cy;function ch(){if(cy)return Pf;cy=1;var n=RA();return Pf=Function.prototype.bind||n,Pf}var Df,uy;function A1(){return uy||(uy=1,Df=Function.prototype.call),Df}var Lf,hy;function E1(){return hy||(hy=1,Lf=Function.prototype.apply),Lf}var Mf,dy;function IA(){return dy||(dy=1,Mf=typeof Reflect<"u"&&Reflect&&Reflect.apply),Mf}var Of,py;function Xb(){if(py)return Of;py=1;var n=ch(),t=E1(),e=A1(),r=IA();return Of=r||n.call(e,t),Of}var Nf,fy;function Rp(){if(fy)return Nf;fy=1;var n=ch(),t=pe(),e=A1(),r=Xb();return Nf=function(s){if(s.length<1||typeof s[0]!="function")throw new t("a function is required");return r(n,e,s)},Nf}var zf,my;function $A(){if(my)return zf;my=1;var n=Rp(),t=Hl(),e;try{e=[].__proto__===Array.prototype}catch(a){if(!a||typeof a!="object"||!("code"in a)||a.code!=="ERR_PROTO_ACCESS")throw a}var r=!!e&&t&&t(Object.prototype,"__proto__"),i=Object,s=i.getPrototypeOf;return zf=r&&typeof r.get=="function"?n([r.get]):typeof s=="function"?function(l){return s(l==null?l:i(l))}:!1,zf}var Hf,gy;function Qb(){if(gy)return Hf;gy=1;var n=Kb(),t=Jb(),e=$A();return Hf=n?function(i){return n(i)}:t?function(i){if(!i||typeof i!="object"&&typeof i!="function")throw new TypeError("getProto: not an object");return t(i)}:e?function(i){return e(i)}:null,Hf}var Zf,vy;function Ai(){if(vy)return Zf;vy=1;var n=Function.prototype.call,t=Object.prototype.hasOwnProperty,e=ch();return Zf=e.call(n,t),Zf}var Uf,yy;function Cn(){if(yy)return Uf;yy=1;var n,t=w1(),e=Yb(),r=yA(),i=wA(),s=b1(),a=Si(),l=pe(),c=bA(),u=SA(),p=_A(),f=AA(),y=EA(),v=kA(),S=TA(),_=CA(),I=Function,Z=function(bt){try{return I('"use strict"; return ('+bt+").constructor;")()}catch{}},L=Hl(),z=lh(),P=function(){throw new l},B=L?(function(){try{return arguments.callee,P}catch{try{return L(arguments,"callee").get}catch{return P}}})():P,F=_1()(),q=Qb(),Q=Jb(),V=Kb(),re=E1(),Ne=A1(),xe={},et=typeof Uint8Array>"u"||!q?n:q(Uint8Array),le={__proto__:null,"%AggregateError%":typeof AggregateError>"u"?n:AggregateError,"%Array%":Array,"%ArrayBuffer%":typeof ArrayBuffer>"u"?n:ArrayBuffer,"%ArrayIteratorPrototype%":F&&q?q([][Symbol.iterator]()):n,"%AsyncFromSyncIteratorPrototype%":n,"%AsyncFunction%":xe,"%AsyncGenerator%":xe,"%AsyncGeneratorFunction%":xe,"%AsyncIteratorPrototype%":xe,"%Atomics%":typeof Atomics>"u"?n:Atomics,"%BigInt%":typeof BigInt>"u"?n:BigInt,"%BigInt64Array%":typeof BigInt64Array>"u"?n:BigInt64Array,"%BigUint64Array%":typeof BigUint64Array>"u"?n:BigUint64Array,"%Boolean%":Boolean,"%DataView%":typeof DataView>"u"?n:DataView,"%Date%":Date,"%decodeURI%":decodeURI,"%decodeURIComponent%":decodeURIComponent,"%encodeURI%":encodeURI,"%encodeURIComponent%":encodeURIComponent,"%Error%":e,"%eval%":eval,"%EvalError%":r,"%Float16Array%":typeof Float16Array>"u"?n:Float16Array,"%Float32Array%":typeof Float32Array>"u"?n:Float32Array,"%Float64Array%":typeof Float64Array>"u"?n:Float64Array,"%FinalizationRegistry%":typeof FinalizationRegistry>"u"?n:FinalizationRegistry,"%Function%":I,"%GeneratorFunction%":xe,"%Int8Array%":typeof Int8Array>"u"?n:Int8Array,"%Int16Array%":typeof Int16Array>"u"?n:Int16Array,"%Int32Array%":typeof Int32Array>"u"?n:Int32Array,"%isFinite%":isFinite,"%isNaN%":isNaN,"%IteratorPrototype%":F&&q?q(q([][Symbol.iterator]())):n,"%JSON%":typeof JSON=="object"?JSON:n,"%Map%":typeof Map>"u"?n:Map,"%MapIteratorPrototype%":typeof Map>"u"||!F||!q?n:q(new Map()[Symbol.iterator]()),"%Math%":Math,"%Number%":Number,"%Object%":t,"%Object.getOwnPropertyDescriptor%":L,"%parseFloat%":parseFloat,"%parseInt%":parseInt,"%Promise%":typeof Promise>"u"?n:Promise,"%Proxy%":typeof Proxy>"u"?n:Proxy,"%RangeError%":i,"%ReferenceError%":s,"%Reflect%":typeof Reflect>"u"?n:Reflect,"%RegExp%":RegExp,"%Set%":typeof Set>"u"?n:Set,"%SetIteratorPrototype%":typeof Set>"u"||!F||!q?n:q(new Set()[Symbol.iterator]()),"%SharedArrayBuffer%":typeof SharedArrayBuffer>"u"?n:SharedArrayBuffer,"%String%":String,"%StringIteratorPrototype%":F&&q?q(""[Symbol.iterator]()):n,"%Symbol%":F?Symbol:n,"%SyntaxError%":a,"%ThrowTypeError%":B,"%TypedArray%":et,"%TypeError%":l,"%Uint8Array%":typeof Uint8Array>"u"?n:Uint8Array,"%Uint8ClampedArray%":typeof Uint8ClampedArray>"u"?n:Uint8ClampedArray,"%Uint16Array%":typeof Uint16Array>"u"?n:Uint16Array,"%Uint32Array%":typeof Uint32Array>"u"?n:Uint32Array,"%URIError%":c,"%WeakMap%":typeof WeakMap>"u"?n:WeakMap,"%WeakRef%":typeof WeakRef>"u"?n:WeakRef,"%WeakSet%":typeof WeakSet>"u"?n:WeakSet,"%Function.prototype.call%":Ne,"%Function.prototype.apply%":re,"%Object.defineProperty%":z,"%Object.getPrototypeOf%":Q,"%Math.abs%":u,"%Math.floor%":p,"%Math.max%":f,"%Math.min%":y,"%Math.pow%":v,"%Math.round%":S,"%Math.sign%":_,"%Reflect.getPrototypeOf%":V};if(q)try{null.error}catch(bt){var je=q(q(bt));le["%Error.prototype%"]=je}var Dt=function bt(Re){var Be;if(Re==="%AsyncFunction%")Be=Z("async function () {}");else if(Re==="%GeneratorFunction%")Be=Z("function* () {}");else if(Re==="%AsyncGeneratorFunction%")Be=Z("async function* () {}");else if(Re==="%AsyncGenerator%"){var Pe=bt("%AsyncGeneratorFunction%");Pe&&(Be=Pe.prototype)}else if(Re==="%AsyncIteratorPrototype%"){var Ge=bt("%AsyncGenerator%");Ge&&q&&(Be=q(Ge.prototype))}return le[Re]=Be,Be},$n={__proto__:null,"%ArrayBufferPrototype%":["ArrayBuffer","prototype"],"%ArrayPrototype%":["Array","prototype"],"%ArrayProto_entries%":["Array","prototype","entries"],"%ArrayProto_forEach%":["Array","prototype","forEach"],"%ArrayProto_keys%":["Array","prototype","keys"],"%ArrayProto_values%":["Array","prototype","values"],"%AsyncFunctionPrototype%":["AsyncFunction","prototype"],"%AsyncGenerator%":["AsyncGeneratorFunction","prototype"],"%AsyncGeneratorPrototype%":["AsyncGeneratorFunction","prototype","prototype"],"%BooleanPrototype%":["Boolean","prototype"],"%DataViewPrototype%":["DataView","prototype"],"%DatePrototype%":["Date","prototype"],"%ErrorPrototype%":["Error","prototype"],"%EvalErrorPrototype%":["EvalError","prototype"],"%Float32ArrayPrototype%":["Float32Array","prototype"],"%Float64ArrayPrototype%":["Float64Array","prototype"],"%FunctionPrototype%":["Function","prototype"],"%Generator%":["GeneratorFunction","prototype"],"%GeneratorPrototype%":["GeneratorFunction","prototype","prototype"],"%Int8ArrayPrototype%":["Int8Array","prototype"],"%Int16ArrayPrototype%":["Int16Array","prototype"],"%Int32ArrayPrototype%":["Int32Array","prototype"],"%JSONParse%":["JSON","parse"],"%JSONStringify%":["JSON","stringify"],"%MapPrototype%":["Map","prototype"],"%NumberPrototype%":["Number","prototype"],"%ObjectPrototype%":["Object","prototype"],"%ObjProto_toString%":["Object","prototype","toString"],"%ObjProto_valueOf%":["Object","prototype","valueOf"],"%PromisePrototype%":["Promise","prototype"],"%PromiseProto_then%":["Promise","prototype","then"],"%Promise_all%":["Promise","all"],"%Promise_reject%":["Promise","reject"],"%Promise_resolve%":["Promise","resolve"],"%RangeErrorPrototype%":["RangeError","prototype"],"%ReferenceErrorPrototype%":["ReferenceError","prototype"],"%RegExpPrototype%":["RegExp","prototype"],"%SetPrototype%":["Set","prototype"],"%SharedArrayBufferPrototype%":["SharedArrayBuffer","prototype"],"%StringPrototype%":["String","prototype"],"%SymbolPrototype%":["Symbol","prototype"],"%SyntaxErrorPrototype%":["SyntaxError","prototype"],"%TypedArrayPrototype%":["TypedArray","prototype"],"%TypeErrorPrototype%":["TypeError","prototype"],"%Uint8ArrayPrototype%":["Uint8Array","prototype"],"%Uint8ClampedArrayPrototype%":["Uint8ClampedArray","prototype"],"%Uint16ArrayPrototype%":["Uint16Array","prototype"],"%Uint32ArrayPrototype%":["Uint32Array","prototype"],"%URIErrorPrototype%":["URIError","prototype"],"%WeakMapPrototype%":["WeakMap","prototype"],"%WeakSetPrototype%":["WeakSet","prototype"]},ht=ch(),wt=Ai(),Ps=ht.call(Ne,Array.prototype.concat),ia=ht.call(re,Array.prototype.splice),Ds=ht.call(Ne,String.prototype.replace),ki=ht.call(Ne,String.prototype.slice),Ee=ht.call(Ne,RegExp.prototype.exec),Jl=/[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g,xn=/\\(\\)?/g,Ls=function(Re){var Be=ki(Re,0,1),Pe=ki(Re,-1);if(Be==="%"&&Pe!=="%")throw new a("invalid intrinsic syntax, expected closing `%`");if(Pe==="%"&&Be!=="%")throw new a("invalid intrinsic syntax, expected opening `%`");var Ge=[];return Ds(Re,Jl,function(ce,un,oe,at){Ge[Ge.length]=oe?Ds(at,xn,"$1"):un||ce}),Ge},Xl=function(Re,Be){var Pe=Re,Ge;if(wt($n,Pe)&&(Ge=$n[Pe],Pe="%"+Ge[0]+"%"),wt(le,Pe)){var ce=le[Pe];if(ce===xe&&(ce=Dt(Pe)),typeof ce>"u"&&!Be)throw new l("intrinsic "+Re+" exists, but is not available. Please file an issue!");return{alias:Ge,name:Pe,value:ce}}throw new a("intrinsic "+Re+" does not exist!")};return Uf=function(Re,Be){if(typeof Re!="string"||Re.length===0)throw new l("intrinsic name must be a non-empty string");if(arguments.length>1&&typeof Be!="boolean")throw new l('"allowMissing" argument must be a boolean');if(Ee(/^%?[^%]*%?$/,Re)===null)throw new a("`%` may not be present anywhere but at the beginning and end of the intrinsic name");var Pe=Ls(Re),Ge=Pe.length>0?Pe[0]:"",ce=Xl("%"+Ge+"%",Be),un=ce.name,oe=ce.value,at=!1,ze=ce.alias;ze&&(Ge=ze[0],ia(Pe,Ps([0,1],ze)));for(var hn=1,Pn=!0;hn<Pe.length;hn+=1){var Ye=Pe[hn],Ir=ki(Ye,0,1),Jn=ki(Ye,-1);if((Ir==='"'||Ir==="'"||Ir==="`"||Jn==='"'||Jn==="'"||Jn==="`")&&Ir!==Jn)throw new a("property names with quotes must have matching quotes");if((Ye==="constructor"||!Pn)&&(at=!0),Ge+="."+Ye,un="%"+Ge+"%",wt(le,un))oe=le[un];else if(oe!=null){if(!(Ye in oe)){if(!Be)throw new l("base intrinsic for "+Re+" exists, but the property is not available.");return}if(L&&hn+1>=Pe.length){var $r=L(oe,Ye);Pn=!!$r,Pn&&"get"in $r&&!("originalValue"in $r.get)?oe=$r.get:oe=oe[Ye]}else Pn=wt(oe,Ye),oe=oe[Ye];Pn&&!at&&(le[un]=oe)}}return oe},Uf}var Ff,wy;function Is(){if(wy)return Ff;wy=1;var n=Cn(),t=Rp(),e=t([n("%String.prototype.indexOf%")]);return Ff=function(i,s){var a=n(i,!!s);return typeof a=="function"&&e(i,".prototype.")>-1?t([a]):a},Ff}var qf,by;function k1(){if(by)return qf;by=1;var n=Cn(),t=n("%Array%"),e=!t.isArray&&Is()("Object.prototype.toString");return qf=t.isArray||function(i){return e(i)==="[object Array]"},qf}var Vf,Sy;function T1(){if(Sy)return Vf;Sy=1;var n=Cp(),t=lh(),e=n.hasArrayLengthDefineBug(),r=e&&k1(),i=Is(),s=i("Object.prototype.propertyIsEnumerable");return Vf=function(l,c,u,p,f,y){if(!t){if(!l(y)||!y["[[Configurable]]"]||!y["[[Writable]]"]||f in p&&s(p,f)!==!!y["[[Enumerable]]"])return!1;var v=y["[[Value]]"];return p[f]=v,c(p[f],v)}return e&&f==="length"&&"[[Value]]"in y&&r(p)&&p.length!==y["[[Value]]"]?(p.length=y["[[Value]]"],p.length===y["[[Value]]"]):(t(p,f,u(y)),!0)},Vf}var Bf,_y;function Ul(){if(_y)return Bf;_y=1;var n=pe(),t=Ai(),e={__proto__:null,"[[Configurable]]":!0,"[[Enumerable]]":!0,"[[Get]]":!0,"[[Set]]":!0,"[[Value]]":!0,"[[Writable]]":!0};return Bf=function(i){if(!i||typeof i!="object")return!1;for(var s in i)if(t(i,s)&&!e[s])return!1;var a=t(i,"[[Value]]")||t(i,"[[Writable]]"),l=t(i,"[[Get]]")||t(i,"[[Set]]");if(a&&l)throw new n("Property Descriptors may not be both accessor and data descriptors");return!0},Bf}var Wf,Ay;function e8(){return Ay||(Ay=1,Wf=function(t){if(typeof t>"u")return t;var e={};return"[[Value]]"in t&&(e.value=t["[[Value]]"]),"[[Writable]]"in t&&(e.writable=!!t["[[Writable]]"]),"[[Get]]"in t&&(e.get=t["[[Get]]"]),"[[Set]]"in t&&(e.set=t["[[Set]]"]),"[[Enumerable]]"in t&&(e.enumerable=!!t["[[Enumerable]]"]),"[[Configurable]]"in t&&(e.configurable=!!t["[[Configurable]]"]),e}),Wf}var jf,Ey;function t8(){if(Ey)return jf;Ey=1;var n=pe(),t=Ul(),e=e8();return jf=function(i){if(typeof i<"u"&&!t(i))throw new n("Assertion failed: `Desc` must be a Property Descriptor");return e(i)},jf}var Gf,ky;function n8(){if(ky)return Gf;ky=1;var n=pe(),t=Ai(),e=Ul();return Gf=function(i){if(typeof i>"u")return!1;if(!e(i))throw new n("Assertion failed: `Desc` must be a Property Descriptor");return!(!t(i,"[[Value]]")&&!t(i,"[[Writable]]"))},Gf}var Yf,Ty;function Fl(){return Ty||(Ty=1,Yf=function(t){return typeof t=="string"||typeof t=="symbol"}),Yf}var Kf,Cy;function r8(){if(Cy)return Kf;Cy=1;var n=S1();return Kf=function(e,r){return e===r?e===0?1/e===1/r:!0:n(e)&&n(r)},Kf}var Jf,Ry;function C1(){if(Ry)return Jf;Ry=1;var n=pe(),t=_i(),e=T1(),r=t8(),i=n8(),s=Fl(),a=r8();return Jf=function(c,u,p){if(!t(c))throw new n("Assertion failed: Type(O) is not Object");if(!s(u))throw new n("Assertion failed: P is not a Property Key");var f={"[[Configurable]]":!0,"[[Enumerable]]":!1,"[[Value]]":p,"[[Writable]]":!0};return e(i,a,r,c,u,f)},Jf}var Xf,Iy;function i8(){if(Iy)return Xf;Iy=1;var n=Function.prototype.toString,t=typeof Reflect=="object"&&Reflect!==null&&Reflect.apply,e,r;if(typeof t=="function"&&typeof Object.defineProperty=="function")try{e=Object.defineProperty({},"length",{get:function(){throw r}}),r={},t(function(){throw 42},null,e)}catch(L){L!==r&&(t=null)}else t=null;var i=/^\s*class\b/,s=function(z){try{var P=n.call(z);return i.test(P)}catch{return!1}},a=function(z){try{return s(z)?!1:(n.call(z),!0)}catch{return!1}},l=Object.prototype.toString,c="[object Object]",u="[object Function]",p="[object GeneratorFunction]",f="[object HTMLAllCollection]",y="[object HTML document.all class]",v="[object HTMLCollection]",S=typeof Symbol=="function"&&!!Symbol.toStringTag,_=!(0 in[,]),I=function(){return!1};if(typeof document=="object"){var Z=document.all;l.call(Z)===l.call(document.all)&&(I=function(z){if((_||!z)&&(typeof z>"u"||typeof z=="object"))try{var P=l.call(z);return(P===f||P===y||P===v||P===c)&&z("")==null}catch{}return!1})}return Xf=t?function(z){if(I(z))return!0;if(!z||typeof z!="function"&&typeof z!="object")return!1;try{t(z,null,e)}catch(P){if(P!==r)return!1}return!s(z)&&a(z)}:function(z){if(I(z))return!0;if(!z||typeof z!="function"&&typeof z!="object")return!1;if(S)return a(z);if(s(z))return!1;var P=l.call(z);return P!==u&&P!==p&&!/^\[object HTML/.test(P)?!1:a(z)},Xf}var Qf,$y;function xA(){return $y||($y=1,Qf=i8()),Qf}var e0,xy;function PA(){return xy||(xy=1,e0=function(t){return!!t}),e0}var t0,Py;function DA(){if(Py)return t0;Py=1;var n=Ai(),t=pe(),e=_i(),r=xA(),i=PA();return t0=function(a){if(!e(a))throw new t("ToPropertyDescriptor requires an object");var l={};if(n(a,"enumerable")&&(l["[[Enumerable]]"]=i(a.enumerable)),n(a,"configurable")&&(l["[[Configurable]]"]=i(a.configurable)),n(a,"value")&&(l["[[Value]]"]=a.value),n(a,"writable")&&(l["[[Writable]]"]=i(a.writable)),n(a,"get")){var c=a.get;if(typeof c<"u"&&!r(c))throw new t("getter must be a function");l["[[Get]]"]=c}if(n(a,"set")){var u=a.set;if(typeof u<"u"&&!r(u))throw new t("setter must be a function");l["[[Set]]"]=u}if((n(l,"[[Get]]")||n(l,"[[Set]]"))&&(n(l,"[[Value]]")||n(l,"[[Writable]]")))throw new t("Invalid property descriptor. Cannot both specify accessors and a value or writable attribute");return l},t0}var n0,Dy;function LA(){if(Dy)return n0;Dy=1;var n=pe(),t=_i(),e=Ul(),r=T1(),i=t8(),s=n8(),a=Fl(),l=r8(),c=DA();return n0=function(p,f,y){if(!t(p))throw new n("Assertion failed: Type(O) is not Object");if(!a(f))throw new n("Assertion failed: P is not a Property Key");var v=e(y)?y:c(y);if(!e(v))throw new n("Assertion failed: Desc is not a valid Property Descriptor");return r(s,l,i,p,f,v)},n0}var r0,Ly;function MA(){if(Ly)return r0;Ly=1;var n=pe(),t=_i(),e=LA(),r=Fl();return r0=function(s,a,l){if(!t(s))throw new n("Assertion failed: Type(O) is not Object");if(!r(a))throw new n("Assertion failed: P is not a Property Key");var c={"[[Configurable]]":!0,"[[Enumerable]]":!1,"[[Value]]":l,"[[Writable]]":!0};return e(s,a,c)},r0}var i0,My;function OA(){return My||(My=1,i0=typeof Reflect<"u"&&Reflect.setPrototypeOf||null),i0}var s0,Oy;function NA(){if(Oy)return s0;Oy=1;var n=w1();return s0=n.setPrototypeOf||null,s0}var o0,Ny;function zA(){if(Ny)return o0;Ny=1;var n=Rp(),t=Hl(),e=pe(),r={};try{r.__proto__=null}catch(a){if(!a||typeof a!="object"||!("code"in a)||a.code!=="ERR_PROTO_ACCESS")throw a}var i=!("toString"in r),s=t&&t(Object.prototype,"__proto__");return o0=i&&(!!s&&typeof s.set=="function"&&n([s.set])||function(l,c){if(l==null)throw new e("set Object.prototype.__proto__ called on null or undefined");return l.__proto__=c,c}),o0}var a0,zy;function HA(){if(zy)return a0;zy=1;var n=OA(),t=NA(),e=zA(),r=pe();return a0=n?function(s,a){if(n(s,a))return s;throw new r("Reflect.setPrototypeOf: failed to set [[Prototype]]")}:t||(e?function(s,a){return e(s,a),s}:null),a0}var l0,Hy;function ZA(){if(Hy)return l0;Hy=1;var n=pe(),t=_i(),e=Qb();return l0=function(i){if(!t(i))throw new n("Assertion failed: O must be an Object");if(!e)throw new n("This environment does not support fetching prototypes.");return e(i)},l0}var c0,Zy;function UA(){if(Zy)return c0;Zy=1;var n=pe(),t=HA(),e=_i(),r=ZA();return c0=function(s,a){if(a!==null&&!e(a))throw new n("Assertion failed: V must be Object or Null");try{t(s,a)}catch{return!1}return r(s)===a},c0}var u0,Uy;function FA(){if(Uy)return u0;Uy=1;var n=C1(),t=MA(),e=UA(),r=Cp()(),i=Yb();function s(l,c,u){var p=new i(u);return e(p,a),delete p.constructor,t(p,"error",l),t(p,"suppressed",c),p}r&&Object.defineProperty(s,"prototype",{writable:!1});var a=s.prototype;if(!n(a,"constructor",s)||!n(a,"message","")||!n(a,"name","SuppressedError"))throw new i("unable to install SuppressedError.prototype properties; please report this!");return e(s.prototype,i.prototype),u0=s,u0}var h0,Fy;function s8(){if(Fy)return h0;Fy=1;var n=FA();return h0=function(){return typeof SuppressedError=="function"?SuppressedError:n},h0}var d0,qy;function qA(){if(qy)return d0;qy=1;var n=ta(),t=y1()(),e=s8();return d0=function(){var i=e();return n(t,{SuppressedError:i},{SuppressedError:function(){return t.SuppressedError!==i}}),i},d0}var Vy;function VA(){return Vy||(Vy=1,qA()()),Cv}var p0,By;function BA(){if(By)return p0;By=1;var n=pe(),t=Ul(),e=e8();return p0=function(i){if(typeof i<"u"&&!t(i))throw new n("Assertion failed: `Desc` must be a Property Descriptor");return e(i)},p0}var f0,Wy;function WA(){if(Wy)return f0;Wy=1;var n=pe(),t=Ai(),e=Ul();return f0=function(i){if(typeof i>"u")return!1;if(!e(i))throw new n("Assertion failed: `Desc` must be a Property Descriptor");return!(!t(i,"[[Value]]")&&!t(i,"[[Writable]]"))},f0}var m0,jy;function jA(){if(jy)return m0;jy=1;var n=S1();return m0=function(e,r){return e===r?e===0?1/e===1/r:!0:n(e)&&n(r)},m0}var g0,Gy;function ql(){return Gy||(Gy=1,g0=i8()),g0}var v0,Yy;function GA(){return Yy||(Yy=1,v0=function(t){return!!t}),v0}var y0,Ky;function YA(){if(Ky)return y0;Ky=1;var n=Ai(),t=pe(),e=_i(),r=ql(),i=GA();return y0=function(a){if(!e(a))throw new t("ToPropertyDescriptor requires an object");var l={};if(n(a,"enumerable")&&(l["[[Enumerable]]"]=i(a.enumerable)),n(a,"configurable")&&(l["[[Configurable]]"]=i(a.configurable)),n(a,"value")&&(l["[[Value]]"]=a.value),n(a,"writable")&&(l["[[Writable]]"]=i(a.writable)),n(a,"get")){var c=a.get;if(typeof c<"u"&&!r(c))throw new t("getter must be a function");l["[[Get]]"]=c}if(n(a,"set")){var u=a.set;if(typeof u<"u"&&!r(u))throw new t("setter must be a function");l["[[Set]]"]=u}if((n(l,"[[Get]]")||n(l,"[[Set]]"))&&(n(l,"[[Value]]")||n(l,"[[Writable]]")))throw new t("Invalid property descriptor. Cannot both specify accessors and a value or writable attribute");return l},y0}var w0,Jy;function uh(){if(Jy)return w0;Jy=1;var n=pe(),t=_i(),e=Ul(),r=T1(),i=BA(),s=WA(),a=Fl(),l=jA(),c=YA();return w0=function(p,f,y){if(!t(p))throw new n("Assertion failed: Type(O) is not Object");if(!a(f))throw new n("Assertion failed: P is not a Property Key");var v=e(y)?y:c(y);if(!e(v))throw new n("Assertion failed: Desc is not a valid Property Descriptor");return r(s,l,i,p,f,v)},w0}var b0,Xy;function KA(){if(Xy)return b0;Xy=1;var n=Zl()();return b0=n?Symbol.dispose||Symbol("Symbol.dispose"):null,b0}var S0,Qy;function R1(){if(Qy)return S0;Qy=1;var n=Zl(),t=KA();return S0=function(){return n()&&Symbol.dispose||t},S0}var _0,ew;function JA(){if(ew)return _0;ew=1;var n=_1(),t=uh(),e=R1();return _0=function(){var i=e();return n()&&t(Symbol,"dispose",{"[[Configurable]]":!1,"[[Enumerable]]":!1,"[[Writable]]":!1,"[[Value]]":i}),i},_0}var A0,tw;function XA(){if(tw)return A0;tw=1;var n=Zl()();return A0=n?Symbol.asyncDispose||Symbol("Symbol.asyncDispose"):null,A0}var E0,nw;function I1(){if(nw)return E0;nw=1;var n=Zl(),t=XA();return E0=function(){return n()&&Symbol.asyncDispose||t},E0}var k0,rw;function QA(){if(rw)return k0;rw=1;var n=_1(),t=uh(),e=I1();return k0=function(){var i=e();return n()&&t(Symbol,"asyncDispose",{"[[Configurable]]":!1,"[[Enumerable]]":!1,"[[Writable]]":!1,"[[Value]]":i}),i},k0}var T0,iw;function eE(){return iw||(iw=1,T0=k1()),T0}var C0,sw;function Ip(){if(sw)return C0;sw=1;var n=Cn(),t=Is(),e=pe(),r=eE(),i=n("%Reflect.apply%",!0)||t("Function.prototype.apply");return C0=function(a,l){var c=arguments.length>2?arguments[2]:[];if(!r(c))throw new e("Assertion failed: optional `argumentsList`, if provided, must be a List");return i(a,l,c)},C0}const tE={},nE=Object.freeze(Object.defineProperty({__proto__:null,default:tE},Symbol.toStringTag,{value:"Module"})),rE=pA(nE);var R0,ow;function Vl(){if(ow)return R0;ow=1;var n=typeof Map=="function"&&Map.prototype,t=Object.getOwnPropertyDescriptor&&n?Object.getOwnPropertyDescriptor(Map.prototype,"size"):null,e=n&&t&&typeof t.get=="function"?t.get:null,r=n&&Map.prototype.forEach,i=typeof Set=="function"&&Set.prototype,s=Object.getOwnPropertyDescriptor&&i?Object.getOwnPropertyDescriptor(Set.prototype,"size"):null,a=i&&s&&typeof s.get=="function"?s.get:null,l=i&&Set.prototype.forEach,c=typeof WeakMap=="function"&&WeakMap.prototype,u=c?WeakMap.prototype.has:null,p=typeof WeakSet=="function"&&WeakSet.prototype,f=p?WeakSet.prototype.has:null,y=typeof WeakRef=="function"&&WeakRef.prototype,v=y?WeakRef.prototype.deref:null,S=Boolean.prototype.valueOf,_=Object.prototype.toString,I=Function.prototype.toString,Z=String.prototype.match,L=String.prototype.slice,z=String.prototype.replace,P=String.prototype.toUpperCase,B=String.prototype.toLowerCase,F=RegExp.prototype.test,q=Array.prototype.concat,Q=Array.prototype.join,V=Array.prototype.slice,re=Math.floor,Ne=typeof BigInt=="function"?BigInt.prototype.valueOf:null,xe=Object.getOwnPropertySymbols,et=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?Symbol.prototype.toString:null,le=typeof Symbol=="function"&&typeof Symbol.iterator=="object",je=typeof Symbol=="function"&&Symbol.toStringTag&&(typeof Symbol.toStringTag===le||!0)?Symbol.toStringTag:null,Dt=Object.prototype.propertyIsEnumerable,$n=(typeof Reflect=="function"?Reflect.getPrototypeOf:Object.getPrototypeOf)||([].__proto__===Array.prototype?function(k){return k.__proto__}:null);function ht(k,C){if(k===1/0||k===-1/0||k!==k||k&&k>-1e3&&k<1e3||F.call(/e/,C))return C;var fe=/[0-9](?=(?:[0-9]{3})+(?![0-9]))/g;if(typeof k=="number"){var Se=k<0?-re(-k):re(k);if(Se!==k){var ke=String(Se),te=L.call(C,ke.length+1);return z.call(ke,fe,"$&_")+"."+z.call(z.call(te,/([0-9]{3})/g,"$&_"),/_$/,"")}}return z.call(C,fe,"$&_")}var wt=rE,Ps=wt.custom,ia=ce(Ps)?Ps:null,Ds={__proto__:null,double:'"',single:"'"},ki={__proto__:null,double:/(["\\])/g,single:/(['\\])/g};R0=function k(C,fe,Se,ke){var te=fe||{};if(at(te,"quoteStyle")&&!at(Ds,te.quoteStyle))throw new TypeError('option "quoteStyle" must be "single" or "double"');if(at(te,"maxStringLength")&&(typeof te.maxStringLength=="number"?te.maxStringLength<0&&te.maxStringLength!==1/0:te.maxStringLength!==null))throw new TypeError('option "maxStringLength", if provided, must be a positive integer, Infinity, or `null`');var St=at(te,"customInspect")?te.customInspect:!0;if(typeof St!="boolean"&&St!=="symbol")throw new TypeError("option \"customInspect\", if provided, must be `true`, `false`, or `'symbol'`");if(at(te,"indent")&&te.indent!==null&&te.indent!==" "&&!(parseInt(te.indent,10)===te.indent&&te.indent>0))throw new TypeError('option "indent" must be "\\t", an integer > 0, or `null`');if(at(te,"numericSeparator")&&typeof te.numericSeparator!="boolean")throw new TypeError('option "numericSeparator", if provided, must be `true` or `false`');var er=te.numericSeparator;if(typeof C>"u")return"undefined";if(C===null)return"null";if(typeof C=="boolean")return C?"true":"false";if(typeof C=="string")return Qn(C,te);if(typeof C=="number"){if(C===0)return 1/0/C>0?"0":"-0";var dt=String(C);return er?ht(C,dt):dt}if(typeof C=="bigint"){var Dn=String(C)+"n";return er?ht(C,Dn):Dn}var sa=typeof te.depth>"u"?5:te.depth;if(typeof Se>"u"&&(Se=0),Se>=sa&&sa>0&&typeof C=="object")return Ls(C)?"[Array]":"[Object]";var Lr=Ci(te,Se);if(typeof ke>"u")ke=[];else if(Pn(ke,C)>=0)return"[Circular]";function pt($i,Hs,rc){if(Hs&&(ke=V.call(ke),ke.push(Hs)),rc){var ic={depth:te.depth};return at(te,"quoteStyle")&&(ic.quoteStyle=te.quoteStyle),k($i,ic,Se+1,ke)}return k($i,te,Se+1,ke)}if(typeof C=="function"&&!bt(C)){var Os=hn(C),Gt=Dr(C,pt);return"[Function"+(Os?": "+Os:" (anonymous)")+"]"+(Gt.length>0?" { "+Q.call(Gt,", ")+" }":"")}if(ce(C)){var Mr=le?z.call(String(C),/^(Symbol\(.*\))_[^)]*$/,"$1"):et.call(C);return typeof C=="object"&&!le?Pr(Mr):Mr}if(Xn(C)){for(var Or="<"+B.call(String(C.nodeName)),Ns=C.attributes||[],oa=0;oa<Ns.length;oa++)Or+=" "+Ns[oa].name+"="+Ee(Jl(Ns[oa].value),"double",te);return Or+=">",C.childNodes&&C.childNodes.length&&(Or+="..."),Or+="</"+B.call(String(C.nodeName))+">",Or}if(Ls(C)){if(C.length===0)return"[]";var aa=Dr(C,pt);return Lr&&!Ql(aa)?"["+Ri(aa,Lr)+"]":"[ "+Q.call(aa,", ")+" ]"}if(Re(C)){var zs=Dr(C,pt);return!("cause"in Error.prototype)&&"cause"in C&&!Dt.call(C,"cause")?"{ ["+String(C)+"] "+Q.call(q.call("[cause]: "+pt(C.cause),zs),", ")+" }":zs.length===0?"["+String(C)+"]":"{ ["+String(C)+"] "+Q.call(zs,", ")+" }"}if(typeof C=="object"&&St){if(ia&&typeof C[ia]=="function"&&wt)return wt(C,{depth:sa-Se});if(St!=="symbol"&&typeof C.inspect=="function")return C.inspect()}if(Ye(C)){var ec=[];return r&&r.call(C,function($i,Hs){ec.push(pt(Hs,C,!0)+" => "+pt($i,C))}),Ms("Map",e.call(C),ec,Lr)}if($r(C)){var la=[];return l&&l.call(C,function($i){la.push(pt($i,C))}),Ms("Set",a.call(C),la,Lr)}if(Ir(C))return Ti("WeakMap");if(mh(C))return Ti("WeakSet");if(Jn(C))return Ti("WeakRef");if(Pe(C))return Pr(pt(Number(C)));if(un(C))return Pr(pt(Ne.call(C)));if(Ge(C))return Pr(S.call(C));if(Be(C))return Pr(pt(String(C)));if(typeof window<"u"&&C===window)return"{ [object Window] }";if(typeof globalThis<"u"&&C===globalThis||typeof Ks<"u"&&C===Ks)return"{ [object globalThis] }";if(!Xl(C)&&!bt(C)){var tc=Dr(C,pt),Ii=$n?$n(C)===Object.prototype:C instanceof Object||C.constructor===Object,nc=C instanceof Object?"":"null prototype",gh=!Ii&&je&&Object(C)===C&&je in C?L.call(ze(C),8,-1):nc?"Object":"",He=Ii||typeof C.constructor!="function"?"":C.constructor.name?C.constructor.name+" ":"",tr=He+(gh||nc?"["+Q.call(q.call([],gh||[],nc||[]),": ")+"] ":"");return tc.length===0?tr+"{}":Lr?tr+"{"+Ri(tc,Lr)+"}":tr+"{ "+Q.call(tc,", ")+" }"}return String(C)};function Ee(k,C,fe){var Se=fe.quoteStyle||C,ke=Ds[Se];return ke+k+ke}function Jl(k){return z.call(String(k),/"/g,"&quot;")}function xn(k){return!je||!(typeof k=="object"&&(je in k||typeof k[je]<"u"))}function Ls(k){return ze(k)==="[object Array]"&&xn(k)}function Xl(k){return ze(k)==="[object Date]"&&xn(k)}function bt(k){return ze(k)==="[object RegExp]"&&xn(k)}function Re(k){return ze(k)==="[object Error]"&&xn(k)}function Be(k){return ze(k)==="[object String]"&&xn(k)}function Pe(k){return ze(k)==="[object Number]"&&xn(k)}function Ge(k){return ze(k)==="[object Boolean]"&&xn(k)}function ce(k){if(le)return k&&typeof k=="object"&&k instanceof Symbol;if(typeof k=="symbol")return!0;if(!k||typeof k!="object"||!et)return!1;try{return et.call(k),!0}catch{}return!1}function un(k){if(!k||typeof k!="object"||!Ne)return!1;try{return Ne.call(k),!0}catch{}return!1}var oe=Object.prototype.hasOwnProperty||function(k){return k in this};function at(k,C){return oe.call(k,C)}function ze(k){return _.call(k)}function hn(k){if(k.name)return k.name;var C=Z.call(I.call(k),/^function\s*([\w$]+)/);return C?C[1]:null}function Pn(k,C){if(k.indexOf)return k.indexOf(C);for(var fe=0,Se=k.length;fe<Se;fe++)if(k[fe]===C)return fe;return-1}function Ye(k){if(!e||!k||typeof k!="object")return!1;try{e.call(k);try{a.call(k)}catch{return!0}return k instanceof Map}catch{}return!1}function Ir(k){if(!u||!k||typeof k!="object")return!1;try{u.call(k,u);try{f.call(k,f)}catch{return!0}return k instanceof WeakMap}catch{}return!1}function Jn(k){if(!v||!k||typeof k!="object")return!1;try{return v.call(k),!0}catch{}return!1}function $r(k){if(!a||!k||typeof k!="object")return!1;try{a.call(k);try{e.call(k)}catch{return!0}return k instanceof Set}catch{}return!1}function mh(k){if(!f||!k||typeof k!="object")return!1;try{f.call(k,f);try{u.call(k,u)}catch{return!0}return k instanceof WeakSet}catch{}return!1}function Xn(k){return!k||typeof k!="object"?!1:typeof HTMLElement<"u"&&k instanceof HTMLElement?!0:typeof k.nodeName=="string"&&typeof k.getAttribute=="function"}function Qn(k,C){if(k.length>C.maxStringLength){var fe=k.length-C.maxStringLength,Se="... "+fe+" more character"+(fe>1?"s":"");return Qn(L.call(k,0,C.maxStringLength),C)+Se}var ke=ki[C.quoteStyle||"single"];ke.lastIndex=0;var te=z.call(z.call(k,ke,"\\$1"),/[\x00-\x1f]/g,xr);return Ee(te,"single",C)}function xr(k){var C=k.charCodeAt(0),fe={8:"b",9:"t",10:"n",12:"f",13:"r"}[C];return fe?"\\"+fe:"\\x"+(C<16?"0":"")+P.call(C.toString(16))}function Pr(k){return"Object("+k+")"}function Ti(k){return k+" { ? }"}function Ms(k,C,fe,Se){var ke=Se?Ri(fe,Se):Q.call(fe,", ");return k+" ("+C+") {"+ke+"}"}function Ql(k){for(var C=0;C<k.length;C++)if(Pn(k[C],`
2
2
  `)>=0)return!1;return!0}function Ci(k,C){var fe;if(k.indent===" ")fe=" ";else if(typeof k.indent=="number"&&k.indent>0)fe=Q.call(Array(k.indent+1)," ");else return null;return{base:fe,prev:Q.call(Array(C+1),fe)}}function Ri(k,C){if(k.length===0)return"";var fe=`
3
3
  `+C.prev+C.base;return fe+Q.call(k,","+fe)+`
4
- `+C.prev}function Dr(k,C){var fe=Ls(k),Se=[];if(fe){Se.length=k.length;for(var ke=0;ke<k.length;ke++)Se[ke]=at(k,ke)?C(k[ke],k):""}var te=typeof xe=="function"?xe(k):[],St;if(le){St={};for(var er=0;er<te.length;er++)St["$"+te[er]]=te[er]}for(var dt in k)at(k,dt)&&(fe&&String(Number(dt))===dt&&dt<k.length||le&&St["$"+dt]instanceof Symbol||(F.call(/[^\w$]/,dt)?Se.push(C(dt,k)+": "+C(k[dt],k)):Se.push(dt+": "+C(k[dt],k))));if(typeof xe=="function")for(var Dn=0;Dn<te.length;Dn++)Dt.call(k,te[Dn])&&Se.push("["+C(te[Dn])+"]: "+C(k[te[Dn]],k));return Se}return R0}var I0,aw;function iE(){if(aw)return I0;aw=1;var n=Vl(),t=pe(),e=function(l,c,u){for(var p=l,f;(f=p.next)!=null;p=f)if(f.key===c)return p.next=f.next,u||(f.next=l.next,l.next=f),f},r=function(l,c){if(l){var u=e(l,c);return u&&u.value}},i=function(l,c,u){var p=e(l,c);p?p.value=u:l.next={key:c,next:l.next,value:u}},s=function(l,c){return l?!!e(l,c):!1},a=function(l,c){if(l)return e(l,c,!0)};return I0=function(){var c,u={assert:function(p){if(!u.has(p))throw new t("Side channel does not contain "+n(p))},delete:function(p){var f=a(c,p);return f&&c&&!c.next&&(c=void 0),!!f},get:function(p){return r(c,p)},has:function(p){return s(c,p)},set:function(p,f){c||(c={next:void 0}),i(c,p,f)}};return u},I0}var $0,lw;function o8(){if(lw)return $0;lw=1;var n=Cn(),t=Is(),e=Vl(),r=pe(),i=n("%Map%",!0),s=t("Map.prototype.get",!0),a=t("Map.prototype.set",!0),l=t("Map.prototype.has",!0),c=t("Map.prototype.delete",!0),u=t("Map.prototype.size",!0);return $0=!!i&&function(){var f,y={assert:function(v){if(!y.has(v))throw new r("Side channel does not contain "+e(v))},delete:function(v){if(f){var S=c(f,v);return u(f)===0&&(f=void 0),S}return!1},get:function(v){if(f)return s(f,v)},has:function(v){return f?l(f,v):!1},set:function(v,S){f||(f=new i),a(f,v,S)}};return y},$0}var x0,cw;function sE(){if(cw)return x0;cw=1;var n=Cn(),t=Is(),e=Vl(),r=o8(),i=pe(),s=n("%WeakMap%",!0),a=t("WeakMap.prototype.get",!0),l=t("WeakMap.prototype.set",!0),c=t("WeakMap.prototype.has",!0),u=t("WeakMap.prototype.delete",!0);return x0=s?function(){var f,y,v={assert:function(S){if(!v.has(S))throw new i("Side channel does not contain "+e(S))},delete:function(S){if(s&&S&&(typeof S=="object"||typeof S=="function")){if(f)return u(f,S)}else if(r&&y)return y.delete(S);return!1},get:function(S){return s&&S&&(typeof S=="object"||typeof S=="function")&&f?a(f,S):y&&y.get(S)},has:function(S){return s&&S&&(typeof S=="object"||typeof S=="function")&&f?c(f,S):!!y&&y.has(S)},set:function(S,_){s&&S&&(typeof S=="object"||typeof S=="function")?(f||(f=new s),l(f,S,_)):r&&(y||(y=r()),y.set(S,_))}};return v}:r,x0}var P0,uw;function oE(){if(uw)return P0;uw=1;var n=pe(),t=Vl(),e=iE(),r=o8(),i=sE(),s=i||r||e;return P0=function(){var l,c={assert:function(u){if(!c.has(u)){var p=u&&Object(u)===u?"the given object key":t(u);throw new n("Side channel does not contain "+p)}},delete:function(u){return!!l&&l.delete(u)},get:function(u){return l&&l.get(u)},has:function(u){return!!l&&l.has(u)},set:function(u,p){l||(l=s()),l.set(u,p)}};return c},P0}var D0,hw;function $1(){if(hw)return D0;hw=1;var n=Ai(),t=oE()(),e=pe(),r={assert:function(i,s){if(!i||typeof i!="object"&&typeof i!="function")throw new e("`O` is not an object");if(typeof s!="string")throw new e("`slot` must be a string");if(t.assert(i),!r.has(i,s))throw new e("`"+s+"` is not present on `O`")},get:function(i,s){if(!i||typeof i!="object"&&typeof i!="function")throw new e("`O` is not an object");if(typeof s!="string")throw new e("`slot` must be a string");var a=t.get(i);return a&&a["$"+s]},has:function(i,s){if(!i||typeof i!="object"&&typeof i!="function")throw new e("`O` is not an object");if(typeof s!="string")throw new e("`slot` must be a string");var a=t.get(i);return!!a&&n(a,"$"+s)},set:function(i,s,a){if(!i||typeof i!="object"&&typeof i!="function")throw new e("`O` is not an object");if(typeof s!="string")throw new e("`slot` must be a string");var l=t.get(i);l||(l={},t.set(i,l)),l["$"+s]=a}};return Object.freeze&&Object.freeze(r),D0=r,D0}var L0,dw;function x1(){if(dw)return L0;dw=1;var n=Si(),t=$1(),e=function r(i,s){if(!(this instanceof r))return new r(i,s);if(i!=="normal"&&i!=="break"&&i!=="continue"&&i!=="return"&&i!=="throw")throw new n('Assertion failed: `type` must be one of "normal", "break", "continue", "return", or "throw"');t.set(this,"[[Type]]",i),t.set(this,"[[Value]]",s)};return e.prototype.type=function(){return t.get(this,"[[Type]]")},e.prototype.value=function(){return t.get(this,"[[Value]]")},e.prototype["?"]=function(){var i=t.get(this,"[[Type]]"),s=t.get(this,"[[Value]]");if(i==="throw")throw s;return s},e.prototype["!"]=function(){var i=t.get(this,"[[Type]]");if(i!=="normal")throw new n('Assertion failed: Completion Record is not of type "normal"');return t.get(this,"[[Value]]")},L0=e,L0}var M0,pw;function P1(){if(pw)return M0;pw=1;var n=x1();return M0=function(e){return new n("normal",e)},M0}var O0,fw;function aE(){if(fw)return O0;fw=1;var n=Zl();return O0=function(){return n()&&!!Symbol.toStringTag},O0}var N0,mw;function a8(){if(mw)return N0;mw=1;var n=Cn(),t=n("%Object.defineProperty%",!0),e=aE()(),r=Ai(),i=pe(),s=e?Symbol.toStringTag:null;return N0=function(l,c){var u=arguments.length>2&&!!arguments[2]&&arguments[2].force,p=arguments.length>2&&!!arguments[2]&&arguments[2].nonConfigurable;if(typeof u<"u"&&typeof u!="boolean"||typeof p<"u"&&typeof p!="boolean")throw new i("if provided, the `overrideIfSet` and `nonConfigurable` options must be booleans");s&&(u||!r(l,s))&&(t?t(l,s,{configurable:!p,enumerable:!1,value:c,writable:!1}):l[s]=c)},N0}var z0={exports:{}},H0,gw;function lE(){if(gw)return H0;gw=1;var n=Cn(),t=Wb(),e=Cp()(),r=Hl(),i=pe(),s=n("%Math.floor%");return H0=function(l,c){if(typeof l!="function")throw new i("`fn` is not a function");if(typeof c!="number"||c<0||c>4294967295||s(c)!==c)throw new i("`length` must be a positive 32-bit integer");var u=arguments.length>2&&!!arguments[2],p=!0,f=!0;if("length"in l&&r){var y=r(l,"length");y&&!y.configurable&&(p=!1),y&&!y.writable&&(f=!1)}return(p||f||!u)&&(e?t(l,"length",c,!0,!0):t(l,"length",c)),l},H0}var Z0,vw;function cE(){if(vw)return Z0;vw=1;var n=ch(),t=E1(),e=Xb();return Z0=function(){return e(n,t,arguments)},Z0}var yw;function D1(){return yw||(yw=1,(function(n){var t=lE(),e=lh(),r=Rp(),i=cE();n.exports=function(a){var l=r(arguments),c=1+a.length-(arguments.length-1);return t(l,c>0?c:0,!0)},e?e(n.exports,"apply",{value:i}):n.exports.apply=i})(z0)),z0.exports}var U0,ww;function uE(){return ww||(ww=1,U0=function(t,e){for(var r=0;r<t.length;r+=1)if(!e(t[r],r,t))return!1;return!0}),U0}var F0,bw;function hE(){if(bw)return F0;bw=1;var n=Object;return F0=function(e){return e&&typeof e=="object"&&(typeof e["[[ResourceValue]]"]>"u"||n(e["[[ResourceValue]]"])===e["[[ResourceValue]]"])&&(e["[[Hint]]"]==="SYNC-DISPOSE"||e["[[Hint]]"]==="ASYNC-DISPOSE")&&(typeof e["[[DisposeMethod]]"]=="function"||typeof e["[[DisposeMethod]]"]>"u")},F0}var q0,Sw;function dE(){if(Sw)return q0;Sw=1;var n=Ai(),t=k1(),e=uE(),r=hE();return q0=function(s){return s&&typeof s=="object"&&n(s,"[[DisposableResourceStack]]")&&t(s["[[DisposableResourceStack]]"])&&(s["[[DisposableResourceStack]]"].length===0||e(s["[[DisposableResourceStack]]"],r))},q0}var V0,_w;function pE(){if(_w)return V0;_w=1;var n=_i();return V0=function(e){if(e===null)return"Null";if(typeof e>"u")return"Undefined";if(n(e))return"Object";if(typeof e=="number")return"Number";if(typeof e=="boolean")return"Boolean";if(typeof e=="string")return"String"},V0}var B0,Aw;function L1(){if(Aw)return B0;Aw=1;var n=pE();return B0=function(e){return typeof e=="symbol"?"Symbol":typeof e=="bigint"?"BigInt":n(e)},B0}var W0,Ew;function fE(){if(Ew)return W0;Ew=1;var n=pe(),t=Vl(),e=Fl();return W0=function(i,s){if(!e(s))throw new n("Assertion failed: P is not a Property Key, got "+t(s));return i[s]},W0}var j0,kw;function mE(){if(kw)return j0;kw=1;var n=pe(),t=fE(),e=ql(),r=Fl(),i=Vl();return j0=function(a,l){if(!r(l))throw new n("Assertion failed: P is not a Property Key");var c=t(a,l);if(c!=null){if(!e(c))throw new n(i(l)+" is not a function: "+i(c));return c}},j0}var Eh={exports:{}},G0,Tw;function gE(){return Tw||(Tw=1,G0=Cn()),G0}var Cw;function vE(){if(Cw)return Eh.exports;Cw=1;var n=gE(),t=n("%Reflect.construct%",!0),e=uh();try{e({},"",{"[[Get]]":function(){}})}catch{e=null}if(e&&t){var r={},i={};e(i,"length",{"[[Get]]":function(){throw r},"[[Enumerable]]":!0}),Eh.exports=function(a){try{t(a,i)}catch(l){return l===r}}}else Eh.exports=function(a){return typeof a=="function"&&!!a.prototype};return Eh.exports}var Y0,Rw;function yE(){if(Rw)return Y0;Rw=1;var n=pe(),t=ql(),e=vE();return Y0=function(i){if(!e(i))throw new n("C must be a constructor");var s={"[[Resolve]]":void 0,"[[Reject]]":void 0},a=new i(function(l,c){if(typeof s["[[Resolve]]"]<"u"||typeof s["[[Reject]]"]<"u")throw new n("executor has already been called");s["[[Resolve]]"]=l,s["[[Reject]]"]=c});if(!t(s["[[Resolve]]"])||!t(s["[[Reject]]"]))throw new n("executor must provide valid resolve and reject functions");return{"[[Promise]]":a,"[[Resolve]]":s["[[Resolve]]"],"[[Reject]]":s["[[Reject]]"]}},Y0}var K0,Iw;function wE(){if(Iw)return K0;Iw=1;var n=Si(),t=pe(),e=Ip(),r=mE(),i=yE(),s=L1(),a=R1()(),l=I1()();return K0=function(u,p){if(s(u)!=="Object")throw new t("`V` must be an Object");if(p!=="SYNC-DISPOSE"&&p!=="ASYNC-DISPOSE")throw new n("Assertion failed: `hint` must be `~SYNC-DISPOSE~` or `~ASYNC-DISPOSE~`");var f;if(p==="ASYNC-DISPOSE"&&l&&(f=r(u,l)),!f){if(!a)throw new n("`Symbol.dispose` is not supported");if(f=r(u,a),typeof f<"u")return function(){var y=this;if(p==="ASYNC-DISPOSE"){var v=i(Promise);try{e(f,y),e(v["[[Resolve]]"],void 0,[void 0])}catch(S){v["[[Reject]]"](S)}return v["[[Promise]]"]}e(f,y)}}return f},K0}var J0,$w;function bE(){if($w)return J0;$w=1;var n=Si(),t=pe(),e=ql(),r=L1(),i=wE();return J0=function(a,l){if(l!=="SYNC-DISPOSE"&&l!=="ASYNC-DISPOSE")throw new n("Assertion failed: `hint` must be `~SYNC-DISPOSE~` or `~ASYNC-DISPOSE~`");var c;if(arguments.length<3)if(a==null)a=void 0,c=void 0;else{if(typeof a<"u"&&r(a)!=="Object")throw new t("`V` must be an Object, or `null` or `undefined`");if(c=i(a,l),typeof c>"u")throw new t("dispose method must not be `undefined` on `V` when an object `V` is provided")}else if(c=arguments[2],!e(c))throw new t("`method`, when provided, must be a function");return{"[[ResourceValue]]":a,"[[Hint]]":l,"[[DisposeMethod]]":c}},J0}var X0,xw;function l8(){if(xw)return X0;xw=1;var n=Si(),t=pe(),e=dE(),r=bE(),i=Is(),s=i("Array.prototype.push");return X0=function(l,c,u){if(!e(l))throw new t("Assertion failed: `disposeCapability` must be a DisposeCapability Record");if(u!=="SYNC-DISPOSE"&&u!=="ASYNC-DISPOSE")throw new n("Assertion failed: `hint` must be `~SYNC-DISPOSE~` or `~ASYNC-DISPOSE~`");var p=arguments.length>3?arguments[3]:void 0;if(arguments.length>3&&typeof p!="function")throw new t("Assertion failed: `method`, when present, must be a function");if(!l["[[DisposableResourceStack]]"])throw new t("Assertion failed: `disposeCapability.[[DisposableResourceStack]]` must not be ~EMPTY~");var f;if(arguments.length<4){if(c==null&&u==="SYNC_DISPOSE")return"UNUSED";f=r(c,u)}else{if(typeof c<"u")throw new t("Assertion failed: `V` must be undefined when `method` is present");f=r(void 0,u,p)}return s(l["[[DisposableResourceStack]]"],f),"UNUSED"},X0}var Q0,Pw;function M1(){if(Pw)return Q0;Pw=1;var n=Cn(),t=D1(),e=Si(),r=n("%Promise.resolve%",!0),i=r&&t(r);return Q0=function(a,l){if(!i)throw new e("This environment does not support Promises.");return i(a,l)},Q0}var em,Dw;function SE(){if(Dw)return em;Dw=1;var n=Cn(),t=Si(),e=n("%Promise%",!0),r=Ip(),i=M1(),s=L1();return em=function(l,c,u){if(typeof l<"u"&&s(l)!=="Object")throw new t("Assertion failed: `V` must be `undefined` or an Object");if(c!=="SYNC-DISPOSE"&&c!=="ASYNC-DISPOSE")throw new t("Assertion failed: `hint` must be `~SYNC-DISPOSE~` or `~ASYNC-DISPOSE~`");if(typeof u<"u"&&typeof u!="function")throw new t("Assertion failed: `method` must be `undefined` or a function");var p=typeof u>"u"?u:r(u,l);if(c==="ASYNC-DISPOSE")return i(e,p)},em}var tm,Lw;function _E(){if(Lw)return tm;Lw=1;var n=x1();return tm=function(e){return new n("throw",e)},tm}var nm,Mw;function c8(){if(Mw)return nm;Mw=1;var n=Cn(),t=Si(),e=pe(),r=n("%Promise%",!0),i=Is(),s=i("Promise.prototype.then",!0),a=x1(),l=SE(),c=P1(),u=M1(),p=_E(),f=s8()();return nm=function(v,S){if(!(S instanceof a))throw new e("`completion` must be a Completion Record");var _=v["[[DisposableResourceStack]]"];if(!_)throw new e("Assertion failed: `disposeCapability.[[DisposableResourceStack]]` must not be ~EMPTY~");for(var I,Z=_.length-1;Z>=0;Z-=1)if(!I)I=_[Z]["[[Hint]]"];else if(I!==_[Z]["[[Hint]]"])throw new t("mixed hint stacks are not supported");for(var L=I==="ASYNC-DISPOSE"&&u(r,S),z=function(Q){if(S.type()==="throw"){var V=S.value(),re=new f(Q,V);S=p(re)}else S=p(Q)},P=I==="ASYNC-DISPOSE"&&function(V){return s(L,function(){var re=l(V["[[ResourceValue]]"],V["[[Hint]]"],V["[[DisposeMethod]]"]);if(!re)throw new t("Assertion failed: non-`~ASYNC-DISPOSE~` resource returned a promise from Dispose");return s(re,c)},z)},B=_.length-1;B>=0;B-=1)if(I==="ASYNC-DISPOSE")L=P(_[B]);else{var F=_[B];try{var q=l(F["[[ResourceValue]]"],F["[[Hint]]"],F["[[DisposeMethod]]"]);if(q)throw new t("Assertion failed: `~SYNC-DISPOSE~` resource returned something from Dispose")}catch(Q){z(Q)}}return v["[[DisposableResourceStack]]"]=null,I==="ASYNC-DISPOSE"?L:S},nm}var rm,Ow;function u8(){return Ow||(Ow=1,rm=function(){var t=[];return{"[[DisposableResourceStack]]":t}}),rm}var im,Nw;function AE(){if(Nw)return im;Nw=1;var n=b1(),t=pe(),e=Ip(),r=C1(),i=uh(),s=ql(),a=P1(),l=$1(),c=a8(),u=ta().supportsDescriptors,p=D1(),f=l8(),y=c8(),v=u8(),S=R1()(),_=function z(){if(!(this instanceof z)||l.has(this,"[[DisposableState]]")||l.has(this,"[[DisposeCapability]]"))throw new t("can only be used with new");l.set(this,"[[DisposableState]]","PENDING"),l.set(this,"[[DisposeCapability]]",v())},I=function(){var P=this;return l.assert(P,"[[DisposableState]]"),l.get(P,"[[DisposableState]]")==="DISPOSED"},Z=p(I);u?i(_.prototype,"disposed",{"[[Configurable]]":!0,"[[Enumerable]]":!1,"[[Get]]":I}):_.prototype.disposed=!1;var L=function(P){l.set(P,"[[DisposableState]]","DISPOSED"),u||(P.disposed=!0)};return r(_.prototype,"dispose",function(){var P=this;if(!Z(P))return L(P),y(l.get(P,"[[DisposeCapability]]"),a())["?"]()}),r(_.prototype,"use",function(P){var B=this;if(Z(B))throw new n("a disposed stack can not use anything new");return f(l.get(B,"[[DisposeCapability]]"),P,"SYNC-DISPOSE"),P}),r(_.prototype,"adopt",function(P,B){var F=this;if(Z(F))throw new n("a disposed stack can not use anything new");if(!s(B))throw new t("`onDispose` must be a function");var q=(function(){return e(B,void 0,[P])});return f(l.get(F,"[[DisposeCapability]]"),void 0,"SYNC-DISPOSE",q),P}),r(_.prototype,"defer",function(P){var B=this;if(Z(B))throw new n("a disposed stack can not defer anything new");if(!s(P))throw new t("`onDispose` must be a function");f(l.get(B,"[[DisposeCapability]]"),void 0,"SYNC-DISPOSE",P)}),r(_.prototype,"move",function(){var P=this;if(Z(P))throw new n("a disposed stack can not use anything new");var B=new _;return l.set(B,"[[DisposeCapability]]",l.get(P,"[[DisposeCapability]]")),l.set(P,"[[DisposeCapability]]",v()),L(P),B}),S&&r(_.prototype,S,_.prototype.dispose),c(_.prototype,"DisposableStack"),im=_,im}var sm,zw;function EE(){if(zw)return sm;zw=1;var n=AE();return sm=function(){return typeof DisposableStack=="function"?DisposableStack:n},sm}var om,Hw;function kE(){if(Hw)return om;Hw=1;var n=ta(),t=y1()(),e=EE();return om=function(){var i=e();return n(t,{DisposableStack:i},{DisposableStack:!0}),i},om}var am,Zw;function TE(){if(Zw)return am;Zw=1;var n=Cn(),t=b1(),e=pe(),r=n("%Promise%",!0),i=l8(),s=Ip(),a=C1(),l=uh(),c=c8(),u=ql(),p=u8(),f=P1(),y=M1(),v=$1(),S=a8(),_=ta().supportsDescriptors,I=D1(),Z=Is(),L=Z("Promise.prototype.then",!0),z=I1()(),P=function Q(){if(!(this instanceof Q)||v.has(this,"[[AsyncDisposableState]]")||v.has(this,"[[DisposeCapability]]"))throw new e("can only be used with new");v.set(this,"[[AsyncDisposableState]]","pending"),v.set(this,"[[DisposeCapability]]",p())},B=function(){var V=this;return v.assert(V,"[[AsyncDisposableState]]"),v.get(V,"[[AsyncDisposableState]]")==="disposed"},F=I(B);_?l(P.prototype,"disposed",{"[[Configurable]]":!0,"[[Enumerable]]":!1,"[[Get]]":B}):P.prototype.disposed=!1;var q=function(V){v.set(V,"[[AsyncDisposableState]]","disposed"),_||(V.disposed=!0)};return a(P.prototype,"disposeAsync",function(){var V=this;return F(V)?y(r):(q(V),L(y(r,c(v.get(V,"[[DisposeCapability]]"),f())),function(re){return re["?"]()}))}),a(P.prototype,"use",function(V){var re=this;if(F(re))throw new t("a disposed stack can not use anything new");return i(v.get(re,"[[DisposeCapability]]"),V,"ASYNC-DISPOSE"),V}),a(P.prototype,"adopt",function(V,re){var Ne=this;if(F(Ne))throw new t("a disposed stack can not use anything new");if(!u(re))throw new e("`onDisposeAsync` must be a function");var xe=(function(){return s(re,void 0,[V])});return xe.value=V,i(v.get(Ne,"[[DisposeCapability]]"),void 0,"ASYNC-DISPOSE",xe),V}),a(P.prototype,"defer",function(V){var re=this;if(F(re))throw new t("a disposed stack can not defer anything new");if(!u(V))throw new e("`onDispose` must be a function");i(v.get(re,"[[DisposeCapability]]"),void 0,"ASYNC-DISPOSE",V)}),a(P.prototype,"move",function(){var V=this;if(F(V))throw new t("a disposed stack can not use anything new");var re=new P;return v.set(re,"[[DisposeCapability]]",v.get(V,"[[DisposeCapability]]")),v.set(V,"[[DisposeCapability]]",p()),q(V),re}),z&&a(P.prototype,z,P.prototype.disposeAsync),S(P.prototype,"AsyncDisposableStack"),am=P,am}var lm,Uw;function CE(){if(Uw)return lm;Uw=1;var n=TE();return lm=function(){return typeof AsyncDisposableStack=="function"?AsyncDisposableStack:n},lm}var cm,Fw;function RE(){if(Fw)return cm;Fw=1;var n=ta(),t=y1()(),e=CE();return cm=function(){var i=e();return n(t,{AsyncDisposableStack:i},{AsyncDisposableStack:!0}),i},cm}var um,qw;function IE(){if(qw)return um;qw=1;var n=JA(),t=QA(),e=kE(),r=RE();return um=function(){n(),t(),e(),r()},um}var Vw;function $E(){return Vw||(Vw=1,VA(),IE()()),Tv}$E();const Bw=new WeakMap;function xE(n){return(typeof n=="object"||typeof n=="function")&&n!==null&&"then"in n&&typeof n.then=="function"}function da(n){return typeof n=="string"?n:typeof n=="symbol"?n.description??n.toString():n.name||"(anonymous class)"}function Ww(){return new Error("register(Key, factory) requires a factory function. Wrap existing instances as () => instance.")}function PE(){return new Error("register(Key, factory) does not accept async factories. Await setup before registering.")}class DE{constructor(){$(this,"entries",new Map);$(this,"constructionStack",[])}register(t,e){if(e===void 0){if(typeof t!="function")throw Ww();this.validateClassRegistration(t),this.storeFactory(t,()=>this.instantiateClass(t));return}if(typeof e!="function")throw Ww();if(e.constructor.name==="AsyncFunction")throw PE();this.storeFactory(t,e)}has(t){var e;return((e=this.entries.get(t))==null?void 0:e.factory)!==void 0}resolve(t){return this.resolveAny(t)}storeFactory(t,e){const r=this.getOrCreateEntry(t);r.factory=e,r.instance=void 0,r.error=void 0}validateClassRegistration(t){const e=Bw.get(t);if(e){if(t.length!==e.length)throw new Error(`${da(t)} cannot be registered with register(Class). @injectable(...) declared ${e.length} dependencies but constructor arity is ${t.length}. Use register(Key, () => value) instead.`);return}if(t.length!==0)throw new Error(`${da(t)} cannot be registered with register(Class). Undecorated classes must have zero required constructor parameters. Use register(Key, () => value) instead.`)}instantiateClass(t){const e=Bw.get(t);if(!e)return new t;const r=e.map(i=>this.resolveAny(i));return new t(...r)}resolveAny(t){return this.getOrCreateEntry(t).proxy}getOrCreateEntry(t){let e=this.entries.get(t);return e||(e={key:t},e.proxy=this.createProxy(e),this.entries.set(t,e),e)}createProxy(t){return new Proxy({},{get:(e,r)=>{if(r==="then")return;const i=this.getInstance(t),s=Reflect.get(i,r,i);return typeof s=="function"?s.bind(i):s},set:(e,r,i)=>{const s=this.getInstance(t);return Reflect.set(s,r,i,s)},has:(e,r)=>{const i=this.getInstance(t);return r in i}})}getInstance(t){if(t.instance)return t.instance;if(t.error)throw t.error;if(!t.factory)throw new Error(`${da(t.key)} was resolved but never registered`);const e=this.constructionStack.indexOf(t.key);if(e!==-1){const r=[...this.constructionStack.slice(e),t.key].map(i=>da(i)).join(" -> ");throw new Error(`Circular dependency detected: ${r}`)}this.constructionStack.push(t.key);try{const r=t.factory();if(xE(r))throw new Error(`Factory for ${da(t.key)} returned a Promise. Await setup before registering.`);if(typeof r!="object"||r===null)throw new Error(`Factory for ${da(t.key)} returned a non-object value. Wrap primitives in an object.`);return t.instance=r,r}catch(r){throw t.error=r,r}finally{this.constructionStack.pop()}}}const h8=new DE,LE=new Set(["target","currentTarget","eventPhase","defaultPrevented","isTrusted","timeStamp","srcElement","returnValue","cancelBubble","NONE","CAPTURING_PHASE","AT_TARGET","BUBBLING_PHASE","composedPath","stopPropagation","stopImmediatePropagation","preventDefault","initEvent"]);function ME(n){for(const t of Object.keys(n))if(LE.has(t))throw new Error(`Event payload key "${t}" is reserved; choose a different property name`)}function OE(n,t){ME(t);for(const e of Object.keys(t))Object.defineProperty(n,e,{value:t[e],writable:!0,enumerable:!0,configurable:!0})}function Rn(){class n extends Event{constructor(e,r){const{type:i,bubbles:s,cancelable:a,composed:l,...c}=r??{};if(i!==void 0)throw new Error('Do not pass "type" in init; use the constructor argument instead');super(e,{bubbles:s,cancelable:a,composed:l}),OE(this,c)}}return n}class Ei extends globalThis.EventTarget{}const NE="X-Television-Client-Meta",zE="telemetry-activity",HE="telemetry-signal",d8={kind:"single",full_screen:!1},p8={width:560,height:740};function ZE(n){return n.layout.flatMap(t=>t.artifactIds)}function UE(n){if(!Array.isArray(n))return{valid:!1,errors:["Layout must be an array of pages"]};const t=[];for(const[e,r]of n.entries())FE(r,e,t);return{valid:t.length===0,errors:t}}function Fc(n){return n.flatMap(t=>t.artifactIds)}function Dm(n,t){return n.flatMap(e=>{if(!e.artifactIds.includes(t))return[e];const r=e.artifactIds.filter(i=>i!==t);return r.length===0?[]:[{...e,artifactIds:r}]})}function FE(n,t,e){if(!hm(n)){e.push(`Page ${t} must be an object`);return}for(const r of Object.keys(n))r!=="artifactIds"&&r!=="geometry"&&r!=="size"&&e.push(`Page ${t} has unknown field: ${r}`);if(!Array.isArray(n.artifactIds)||n.artifactIds.length===0?e.push(`Page ${t} must contain at least one artifact id`):n.artifactIds.some(r=>typeof r!="string"||r.length===0)&&e.push(`Page ${t} artifact ids must be non-empty strings`),!hm(n.geometry)){e.push(`Page ${t} geometry must be an object`);return}for(const r of Object.keys(n.geometry))r!=="kind"&&r!=="full_screen"&&e.push(`Page ${t} geometry has unknown field: ${r}`);if(n.geometry.kind!=="single"){e.push(`Page ${t} has unknown geometry kind: ${String(n.geometry.kind)}`);return}if(typeof n.geometry.full_screen!="boolean"&&e.push(`Page ${t} single geometry must include a boolean full_screen`),!hm(n.size)){e.push(`Page ${t} size must be an object`);return}for(const r of Object.keys(n.size))r!=="width"&&r!=="height"&&e.push(`Page ${t} size has unknown field: ${r}`);for(const r of["width","height"]){const i=n.size[r];(typeof i!="number"||!Number.isFinite(i)||i<=0)&&e.push(`Page ${t} size ${r} must be a finite positive number`)}}function hm(n){return typeof n=="object"&&n!==null&&!Array.isArray(n)}const Bt=Rn(),Zh=Rn(),jw=Rn(),qE=Rn(),VE=Rn(),BE=Rn();function f8(n){class t extends Error{constructor(r,i){super(r),this.name=n,i&&Object.assign(this,i)}}return t}const Bl=f8("RequestError"),Gw=f8("ValidationError"),WE=200,jE=300,kh=401;class GE{constructor(t,e){$(this,"serverURL");$(this,"token");$(this,"onUnauthorized");$(this,"telemetryMeta");this.serverURL=t.replace(/\/$/,""),this.token=e.token,this.onUnauthorized=e.onUnauthorized,this.telemetryMeta=e.telemetryMeta}async requestJSON(t,e,r){var a;const i=await this.request(t,e,r!==void 0?JSON.stringify(r):void 0,r!==void 0?{"content-type":"application/json"}:void 0),s=await YE(i);if(!i.ok||i.status<WE||i.status>=jE)throw i.status===kh&&((a=this.onUnauthorized)==null||a.call(this)),this.createError(typeof s.error=="string"?s.error:i.statusText,i.status);return s}async requestVoid(t,e,r){var s;const i=await this.request(t,e,r!==void 0?JSON.stringify(r):void 0,r!==void 0?{"content-type":"application/json"}:void 0);if(!i.ok)throw i.status===kh&&((s=this.onUnauthorized)==null||s.call(this)),this.createError(await dm(i,i.statusText),i.status)}async requestText(t,e){var i;const r=await this.request(t,e);if(!r.ok)throw r.status===kh&&((i=this.onUnauthorized)==null||i.call(this)),this.createError(await dm(r,r.statusText),r.status);return r.text()}async requestRawVoid(t,e,r){var s;const i=await this.request(t,e,r,{"content-type":"text/markdown; charset=utf-8"});if(!i.ok)throw i.status===kh&&((s=this.onUnauthorized)==null||s.call(this)),this.createError(await dm(i,i.statusText),i.status)}createError(t,e){const r={serverURL:this.serverURL};return e!==void 0&&(r.status=e),new Bl(t,r)}async request(t,e,r,i){const s=`${this.serverURL}${e}`;try{return await fetch(s,{method:t,headers:this.buildHeaders(i),body:r})}catch(a){throw this.createError(a instanceof Error?a.message:"Failed to reach server")}}buildHeaders(t){const e={...t??{}};return this.token&&(e.Authorization=`Bearer ${this.token}`),this.telemetryMeta&&(e[NE]=JSON.stringify(this.telemetryMeta)),Object.keys(e).length>0?e:void 0}}async function YE(n){try{return await n.json()}catch{const t=await n.text().catch(()=>"");return t?{message:t}:{}}}async function dm(n,t){try{const e=await n.json();if(typeof e.error=="string")return e.error;if(typeof e.message=="string")return e.message}catch{}return t}function KE(n){return n.map(t=>`${t.name} (${t.id})`).join(", ")}var Ur,Md,m8;class JE{constructor(t){m(this,Md);m(this,Ur);d(this,Ur,t)}list(){return o(this,Ur).requestJSON("GET","/channels")}async get(t={}){const e=await h(this,Md,m8).call(this,t.channelID);return o(this,Ur).requestJSON("GET",`/channels/${encodeURIComponent(e)}`)}create(t){const e={name:t.name};return t.id!==void 0&&(e.id=t.id),o(this,Ur).requestJSON("POST","/channels",e)}update(t){const{channelID:e,...r}=t;return o(this,Ur).requestJSON("PATCH",`/channels/${encodeURIComponent(e)}`,r)}remove(t){return o(this,Ur).requestJSON("DELETE",`/channels/${encodeURIComponent(t.channelID)}`)}}Ur=new WeakMap,Md=new WeakSet,m8=async function(t){if(t!==void 0)return t;const{channels:e}=await this.list();if(e.length===1)return e[0].id;throw e.length===0?new Gw("channelID is required, but no channels exist."):new Gw(`channelID is required when multiple channels exist. Available channels: ${KE(e)}`)};var Fr;class XE{constructor(t){m(this,Fr);d(this,Fr,t)}create(t){const e={kind:t.kind,title:t.title};switch(t.kind){case"path":e.path=t.path;break;case"url":e.url=t.url;break}return e.channelID=t.channelID,o(this,Fr).requestJSON("POST","/artifacts",e)}list(t={}){const e=new URLSearchParams;t.channelID!==void 0&&e.set("channelID",t.channelID);const r=e.toString();return o(this,Fr).requestJSON("GET",r?`/artifacts?${r}`:"/artifacts")}get(t){return o(this,Fr).requestJSON("GET",`/artifacts/${encodeURIComponent(t.artifactID)}`)}update(t){const e={};return t.title!==void 0&&(e.title=t.title),t.path!==void 0&&(e.path=t.path),t.url!==void 0&&(e.url=t.url),o(this,Fr).requestJSON("PATCH",`/artifacts/${encodeURIComponent(t.artifactID)}`,e)}delete(t){return o(this,Fr).requestJSON("DELETE",`/artifacts/${encodeURIComponent(t.artifactID)}`)}}Fr=new WeakMap;var Ma;class QE{constructor(t){m(this,Ma);d(this,Ma,t)}list(){return o(this,Ma).requestJSON("GET","/themes")}refresh(){return o(this,Ma).requestJSON("POST","/themes/refresh")}}Ma=new WeakMap;var Oa;class ek{constructor(t){m(this,Oa);d(this,Oa,t)}get(t){return o(this,Oa).requestText("GET",`/markdown/${encodeURIComponent(t.artifactID)}`)}update(t){return o(this,Oa).requestRawVoid("PUT",`/markdown/${encodeURIComponent(t.artifactID)}`,t.content)}}Oa=new WeakMap;var no;class tk{constructor(t){m(this,no);d(this,no,t)}status(){return o(this,no).requestJSON("GET","/telemetry")}enable(){return o(this,no).requestJSON("POST","/telemetry/enable")}disable(){return o(this,no).requestJSON("POST","/telemetry/disable")}}no=new WeakMap;var ro;class nk{constructor(t){m(this,ro);d(this,ro,t)}get(){return o(this,ro).requestJSON("GET","/display")}patch(t){const e={};return t.focusedChannelId!==void 0&&(e.focusedChannelId=t.focusedChannelId),t.pinnedChannelIds!==void 0&&(e.pinnedChannelIds=t.pinnedChannelIds),t.activeThemeName!==void 0&&(e.activeThemeName=t.activeThemeName),t.appearanceMode!==void 0&&(e.appearanceMode=t.appearanceMode),t.themeJavaScriptConsentIds!==void 0&&(e.themeJavaScriptConsentIds=t.themeJavaScriptConsentIds),o(this,ro).requestVoid("PATCH","/display",e)}focus(t){return o(this,ro).requestJSON("POST","/display/focus",{artifactID:t.artifactID})}}ro=new WeakMap;var fn;class rk{constructor(t,e={}){$(this,"channels");$(this,"artifacts");$(this,"display");$(this,"themes");$(this,"markdown");$(this,"telemetry");m(this,fn);d(this,fn,new GE(t,e)),this.channels=new JE(o(this,fn)),this.artifacts=new XE(o(this,fn)),this.display=new nk(o(this,fn)),this.themes=new QE(o(this,fn)),this.markdown=new ek(o(this,fn)),this.telemetry=new tk(o(this,fn))}health(){return o(this,fn).requestJSON("GET","/health")}demoMode(){return o(this,fn).requestJSON("GET","/demo-mode")}}fn=new WeakMap;const vd="0.0.0",ik=/^\d+\.\d+\.\d+$/,sk=3;function $p(n){return ik.test(n)}function O1(n,t){const e=n.split(".").map(Number),r=t.split(".").map(Number);for(let i=0;i<sk;i++)if(e[i]!==r[i])return e[i]>r[i];return!1}function ok(n,t){return n===vd||t===vd?!1:n!==t}const ak=400,lk=404,g8=500,ck=600,uk={focusedChannelId:null,pinnedChannelIds:[],activeThemeName:null,activeThemeColorScheme:null,appearanceMode:"system",themeJavaScriptConsentIds:[],acpEnabled:!1};var he,Yc,Kc,qr,Ke,_e,io,Ui,so,Vr,Xt,Na,Jc,U,rr,Lm,fa,v8,Mm,y8,Uh,Om,w8,ma,b8,zr,Nm,S8,tt;class hk extends Ei{constructor(e){super();m(this,U);m(this,he);m(this,Yc);m(this,Kc);m(this,qr,new Set);$(this,"pendingPageWrites",new Map);m(this,Ke,new Map);m(this,_e,fk());m(this,io);m(this,Ui,!1);m(this,so,!1);m(this,Vr,0);m(this,Xt,!1);m(this,Na,()=>{if(o(this,Xt))return;const e=o(this,he).connection.status==="connected";e&&!o(this,so)?(d(this,so,!0),h(this,U,b8).call(this)):!e&&o(this,so)&&(d(this,so,!1),d(this,Vr,o(this,Vr)+1)),h(this,U,zr).call(this)});m(this,Jc,e=>{if(o(this,Xt)||e.serverURL!==o(this,he).connection.url)return;for(const i of o(this,qr))i.push(e.event);const r=e.event;if(r.type==="artifact-content-changed"){this.dispatchEvent(new jw("artifact-content-changed",{artifactID:r.artifactID}));return}if(r.type==="artifact-focus"){o(this,Ui)&&yd(o(this,_e),o(this,Ke),r.channelID,r.artifactID)&&h(this,U,zr).call(this),this.dispatchEvent(new qE("artifact-focus",{channelID:r.channelID,artifactID:r.artifactID}));return}r.type==="theme-changed"&&this.dispatchEvent(new VE("theme-changed",{themeName:r.themeName,activeThemeColorScheme:r.activeThemeColorScheme,themeJavaScriptConsentIds:[...r.themeJavaScriptConsentIds]})),r.type==="appearance-changed"&&this.dispatchEvent(new BE("appearance-changed",{appearanceMode:r.appearanceMode})),o(this,Ui)&&(Th(o(this,_e),r,this.pendingPageWrites,o(this,Ke)),pm(o(this,_e),o(this,Ke)),h(this,U,zr).call(this))});d(this,he,e.connectionOwner),d(this,Yc,e.navigationKeyHandler),d(this,Kc,e.retainedGateHalted??(()=>!1)),d(this,io,h(this,U,Nm).call(this)),o(this,he).addEventListener("change",o(this,Na)),o(this,he).addEventListener("server-event",o(this,Jc)),o(this,Na).call(this)}get snapshot(){return o(this,io)}handleNavigationKey(e){var r;h(this,U,tt).call(this),(r=o(this,Yc))==null||r.call(this,e)}async createChannel(e){h(this,U,tt).call(this);const{channel:r}=await h(this,U,rr).call(this,o(this,he).connection.client.channels.create({name:e}),()=>h(this,U,v8).call(this));return r}focusChannel(e){return h(this,U,tt).call(this),h(this,U,rr).call(this,o(this,he).connection.client.display.patch({focusedChannelId:e}),()=>h(this,U,fa).call(this))}setPinnedChannelIds(e){return h(this,U,tt).call(this),h(this,U,rr).call(this,o(this,he).connection.client.display.patch({pinnedChannelIds:[...e]}),()=>h(this,U,fa).call(this))}listThemes(){return h(this,U,tt).call(this),o(this,he).connection.client.themes.list()}refreshThemes(){return h(this,U,tt).call(this),o(this,he).connection.client.themes.refresh()}setActiveTheme(e){return h(this,U,tt).call(this),h(this,U,rr).call(this,o(this,he).connection.client.display.patch({activeThemeName:e}),()=>h(this,U,fa).call(this))}setAppearanceMode(e){return h(this,U,tt).call(this),h(this,U,rr).call(this,o(this,he).connection.client.display.patch({appearanceMode:e}),()=>h(this,U,fa).call(this))}setThemeJavaScriptConsent(e,r){h(this,U,tt).call(this);const i=o(this,_e).display.themeJavaScriptConsentIds,s=r?i.includes(e)?[...i]:[...i,e]:i.filter(a=>a!==e);return h(this,U,rr).call(this,o(this,he).connection.client.display.patch({themeJavaScriptConsentIds:s}),()=>h(this,U,fa).call(this))}selectPage(e,r){h(this,U,tt).call(this),yd(o(this,_e),o(this,Ke),e,r)&&h(this,U,zr).call(this)}async renameChannel(e,r){h(this,U,tt).call(this),await h(this,U,rr).call(this,o(this,he).connection.client.channels.update({channelID:e,name:r}),()=>h(this,U,Mm).call(this,e))}async deleteChannel(e){h(this,U,tt).call(this),await h(this,U,rr).call(this,o(this,he).connection.client.channels.remove({channelID:e}),()=>h(this,U,y8).call(this,e))}updateChannelPages(e,r){h(this,U,tt).call(this);const i=UE(r),s=o(this,_e).channels.get(e);if(!i.valid||!s)return Promise.resolve();const a=Xs(r),l=Xs(s.channel.layout),c={previousPages:l};return Jo(o(this,Ke),e,l,a),s.channel={...s.channel,layout:a},this.pendingPageWrites.set(e,c),h(this,U,zr).call(this),o(this,he).connection.client.channels.update({channelID:e,layout:Xs(a)}).then(()=>{this.pendingPageWrites.get(e)===c&&this.pendingPageWrites.delete(e)},async u=>{if(o(this,Xt))throw u;const p=this.pendingPageWrites.get(e)===c;if(p&&this.pendingPageWrites.delete(e),Kw(u))throw await h(this,U,Lm).call(this,()=>h(this,U,Mm).call(this,e)),u;if(!p||!wk(u))throw u;const f=o(this,_e).channels.get(e);if(!f)throw u;const y=Xs(c.previousPages);throw Jo(o(this,Ke),e,f.channel.layout,y),f.channel={...f.channel,layout:y},h(this,U,zr).call(this),u})}async deleteArtifact(e){h(this,U,tt).call(this);const r=Jw(o(this,_e),e);await h(this,U,rr).call(this,o(this,he).connection.client.artifacts.delete({artifactID:e}),()=>h(this,U,w8).call(this,e,r))}readMarkdown(e){return h(this,U,tt).call(this),o(this,he).connection.client.markdown.get({artifactID:e})}writeMarkdown(e,r){return h(this,U,tt).call(this),o(this,he).connection.client.markdown.update({artifactID:e,content:r})}get browserDemoMode(){return o(this,he).connection.browserDemoMode}getArtifactViewURL(e){return h(this,U,tt).call(this),o(this,he).connection.getViewURL(e)}getArtifactContentURL(e){return h(this,U,tt).call(this),o(this,he).connection.getContentURL(e)}dispose(){o(this,Xt)||(d(this,Xt,!0),d(this,Vr,o(this,Vr)+1),o(this,qr).clear(),this.pendingPageWrites.clear(),o(this,Ke).clear(),o(this,he).removeEventListener("change",o(this,Na)),o(this,he).removeEventListener("server-event",o(this,Jc)))}}he=new WeakMap,Yc=new WeakMap,Kc=new WeakMap,qr=new WeakMap,Ke=new WeakMap,_e=new WeakMap,io=new WeakMap,Ui=new WeakMap,so=new WeakMap,Vr=new WeakMap,Xt=new WeakMap,Na=new WeakMap,Jc=new WeakMap,U=new WeakSet,rr=async function(e,r){try{return await e}catch(i){throw!o(this,Xt)&&Kw(i)&&await h(this,U,Lm).call(this,r),i}},Lm=async function(e){try{await e()}catch{}},fa=function(){const e=o(this,he).connection.client;return h(this,U,ma).call(this,()=>e.display.get(),r=>h(this,U,Uh).call(this,r))},v8=function(){const e=o(this,he).connection.client;return h(this,U,ma).call(this,async()=>{const[{channels:r},i]=await Promise.all([e.channels.list(),e.display.get()]);return{channels:r,display:i}},({channels:r,display:i})=>{const s=new Set(r.map(({id:a})=>a));for(const a of o(this,_e).channels.keys())s.has(a)||(this.pendingPageWrites.delete(a),o(this,Ke).delete(a),o(this,_e).channels.delete(a));for(const a of r)o(this,_e).channels.has(a.id)||o(this,_e).channels.set(a.id,{channel:Pa(a),artifacts:new Map});h(this,U,Uh).call(this,i)})},Mm=function(e){const r=o(this,he).connection.client;return h(this,U,ma).call(this,()=>fm(()=>r.channels.get({channelID:e})),i=>h(this,U,Om).call(this,e,i))},y8=function(e){const r=o(this,he).connection.client;return h(this,U,ma).call(this,async()=>{const[i,s]=await Promise.all([fm(()=>r.channels.get({channelID:e})),r.display.get()]);return{detail:i,display:s}},({detail:i,display:s})=>{h(this,U,Om).call(this,e,i),h(this,U,Uh).call(this,s)})},Uh=function(e){o(this,_e).display=Hm(e),o(this,he).connection.acpClient.setEnabled(e.acpEnabled)},Om=function(e,r){this.pendingPageWrites.delete(e);const i=o(this,_e).channels.get(e);if(r===null){o(this,Ke).delete(e),o(this,_e).channels.delete(e);return}Jo(o(this,Ke),e,(i==null?void 0:i.channel.layout)??[],r.channel.layout),o(this,_e).channels.set(e,{channel:Pa(r.channel),artifacts:new Map(r.artifacts.map(s=>[s.id,structuredClone(s)]))})},w8=function(e,r){const i=o(this,he).connection.client;return h(this,U,ma).call(this,()=>fm(()=>i.artifacts.get({artifactID:e})),s=>{const a=Jw(o(this,_e),e)??r;if(s===null){a!==null&&Th(o(this,_e),{type:"artifact-removed",channelID:a,artifactID:e},this.pendingPageWrites,o(this,Ke));return}const l=a===null?void 0:o(this,_e).channels.get(a);l==null||l.artifacts.set(e,structuredClone(s.artifact))})},ma=async function(e,r){const i=o(this,Vr),s=[];o(this,qr).add(s);try{const a=await e();if(o(this,Xt)||i!==o(this,Vr))return;r(a);for(const l of s)Th(o(this,_e),l,this.pendingPageWrites,o(this,Ke));pm(o(this,_e),o(this,Ke)),h(this,U,zr).call(this)}finally{o(this,qr).delete(s)}},b8=async function(){const e=++Ah(this,Vr)._,r=o(this,he).connection,i=r.client,s=[];o(this,qr).add(s);try{const[{channels:a},l]=await Promise.all([i.channels.list(),i.display.get()]),c=await Promise.all(a.map(({id:f})=>i.channels.get({channelID:f})));if(o(this,Xt)||e!==o(this,Vr))return;const u={channels:new Map,display:Hm(l)};for(const f of c)u.channels.set(f.channel.id,{channel:Pa(f.channel),artifacts:new Map(f.artifacts.map(y=>[y.id,structuredClone(y)]))});mk(o(this,Ke),o(this,_e),u);for(const f of s)Th(u,f,this.pendingPageWrites,o(this,Ke));pm(u,o(this,Ke));const p=o(this,Ui)?dk(o(this,_e),u):[];this.pendingPageWrites.clear(),d(this,_e,u),d(this,Ui,!0),r.acpClient.setEnabled(l.acpEnabled),h(this,U,zr).call(this);for(const f of p)this.dispatchEvent(new jw("artifact-content-changed",{artifactID:f}))}catch{}finally{o(this,qr).delete(s)}},zr=function(){o(this,Xt)||(d(this,io,h(this,U,Nm).call(this)),h(this,U,S8).call(this),this.dispatchEvent(new Bt("change")))},Nm=function(){var s;const e=[...o(this,_e).channels.values()].map(a=>vk(a,o(this,Ke).get(a.channel.id))),r=e.find(({id:a})=>a===o(this,_e).display.focusedChannelId)??null,i=o(this,he).connection;return Object.freeze({ready:o(this,Ui),channels:Object.freeze(e),display:yk(o(this,_e).display),focusedChannel:r,connection:Object.freeze({authorizationRequired:i.hasAuthRejected,gateHalted:i.bootState==="halted"||o(this,Kc).call(this),status:i.status,hasEverConnected:i.hasEverConnected,failedReconnectAttempts:i.failedReconnectAttempts,firstConnectError:i.hasEverConnected?null:o(this,he).connectError,nextRetryAt:i.nextRetryAt,upgradeInstructions:pk(((s=i.updateState)==null?void 0:s.desktop)??null)})})},S8=function(){const e=o(this,io).focusedChannel;o(this,he).connection.acpClient.setChannelContext(e?{channelID:e.id,channelName:e.name}:null)},tt=function(){if(o(this,Xt))throw new Error("ApplicationService is disposed")};function dk(n,t){const e=t.display.focusedChannelId;if(e===null||n.display.focusedChannelId!==e)return[];const r=n.channels.get(e),i=t.channels.get(e);if(!r||!i)return[];const s=new Set(Fc(r.channel.layout));return Fc(i.channel.layout).filter(a=>{var l,c;return s.has(a)&&((l=r.artifacts.get(a))==null?void 0:l.kind)==="path"&&((c=i.artifacts.get(a))==null?void 0:c.kind)==="path"})}function pk(n){return n===null?null:Object.freeze({...n})}function fk(){return{channels:new Map,display:Hm(uk)}}function Th(n,t,e,r){switch(t.type){case"channel-created":r.delete(t.channel.id),n.channels.set(t.channel.id,{channel:Pa(t.channel),artifacts:new Map});return;case"channel-updated":{e.delete(t.channel.id);const i=n.channels.get(t.channel.id);if(!i){r.delete(t.channel.id),n.channels.set(t.channel.id,{channel:Pa(t.channel),artifacts:new Map});return}Jo(r,t.channel.id,i.channel.layout,t.channel.layout);const s=new Set(Fc(t.channel.layout));i.channel=Pa(t.channel);for(const a of i.artifacts.keys())s.has(a)||i.artifacts.delete(a);return}case"channel-removed":e.delete(t.channelID),r.delete(t.channelID),n.channels.delete(t.channelID);return;case"channel-changed":n.display.focusedChannelId=t.channelID;return;case"pinned-channels-changed":n.display.pinnedChannelIds=[...t.pinnedChannelIds];return;case"theme-changed":n.display.activeThemeName=t.themeName,n.display.activeThemeColorScheme=t.activeThemeColorScheme,n.display.themeJavaScriptConsentIds=[...t.themeJavaScriptConsentIds];return;case"appearance-changed":n.display.appearanceMode=t.appearanceMode;return;case"artifact-created":{const i=n.channels.get(t.channelID);if(!i)return;const s=e.get(t.channelID);if(s&&(s.previousPages=Yw(s.previousPages,t.artifact.id)),!Fc(i.channel.layout).includes(t.artifact.id)){const a=i.channel.layout,l=Yw(a,t.artifact.id);Jo(r,t.channelID,a,l),i.channel={...i.channel,layout:l}}i.artifacts.set(t.artifact.id,structuredClone(t.artifact));return}case"artifact-updated":for(const i of n.channels.values())if(i.artifacts.has(t.artifact.id)){i.artifacts.set(t.artifact.id,structuredClone(t.artifact));return}return;case"artifact-removed":{const i=n.channels.get(t.channelID);if(!i)return;const s=e.get(t.channelID);s&&(s.previousPages=Dm(s.previousPages,t.artifactID)),i.artifacts.delete(t.artifactID);const a=i.channel.layout,l=Dm(a,t.artifactID);Jo(r,t.channelID,a,l),i.channel={...i.channel,layout:l};return}case"artifact-focus":yd(n,r,t.channelID,t.artifactID);return;case"artifact-content-changed":return;default:return bk(t)}}function mk(n,t,e){var r;for(const i of n.keys())e.channels.has(i)||n.delete(i);for(const[i,s]of e.channels)Jo(n,i,((r=t.channels.get(i))==null?void 0:r.channel.layout)??[],s.channel.layout)}function Jo(n,t,e,r){const i=n.get(t);if(i===void 0)return;if(r.length===0){n.delete(t);return}const s=zm(r,i);if(s!==-1){n.set(t,[...r[s].artifactIds]);return}const a=zm(e,i),l=a===-1?0:Math.min(a,r.length-1);n.set(t,[...r[l].artifactIds])}function yd(n,t,e,r){const i=n.channels.get(e),s=i==null?void 0:i.channel.layout.find(({artifactIds:l})=>l.includes(r));if(!s)return!1;const a=t.get(e);return a&&gk(a,s.artifactIds)?!1:(t.set(e,[...s.artifactIds]),!0)}function pm(n,t){var i,s;const e=n.display.focusedChannelId;if(e===null||t.has(e))return;const r=(s=(i=n.channels.get(e))==null?void 0:i.channel.layout[0])==null?void 0:s.artifactIds[0];r!==void 0&&yd(n,t,e,r)}function zm(n,t){const e=new Set(t);return n.findIndex(r=>r.artifactIds.some(i=>e.has(i)))}function gk(n,t){return n.length===t.length&&n.every((e,r)=>e===t[r])}function vk(n,t){const e=Object.freeze(n.channel.layout.map(l=>Object.freeze({artifactIds:Object.freeze([...l.artifactIds]),geometry:Object.freeze({...l.geometry}),size:Object.freeze({...l.size})}))),r=t===void 0?0:zm(n.channel.layout,t),i=e[r]??e[0]??null,s=Object.freeze([...n.artifacts.values()].map(l=>Object.freeze(structuredClone(l)))),a={id:n.channel.id,name:n.channel.name,pages:e,selectedPage:i,artifacts:s};return Object.freeze(n.channel.onboarding?{...a,onboarding:Object.freeze({...n.channel.onboarding})}:a)}function yk(n){return Object.freeze({focusedChannelId:n.focusedChannelId,pinnedChannelIds:Object.freeze([...n.pinnedChannelIds]),activeThemeName:n.activeThemeName,activeThemeColorScheme:n.activeThemeColorScheme,appearanceMode:n.appearanceMode,themeJavaScriptConsentIds:Object.freeze([...n.themeJavaScriptConsentIds]),acpEnabled:n.acpEnabled})}function Yw(n,t){return Fc(n).includes(t)?Xs(n):[...Xs(n),{artifactIds:[t],geometry:{...d8},size:{...p8}}]}function wk(n){return n instanceof Bl&&n.status!==void 0&&n.status>=ak&&n.status<g8}function Kw(n){return n instanceof Bl&&(n.status===void 0||n.status>=g8&&n.status<ck)}async function fm(n){try{return await n()}catch(t){if(t instanceof Bl&&t.status===lk)return null;throw t}}function Jw(n,t){for(const[e,r]of n.channels)if(r.artifacts.has(t))return e;return null}function Xs(n){return n.map(t=>({artifactIds:[...t.artifactIds],geometry:{...t.geometry},size:{...t.size}}))}function Pa(n){return{id:n.id,name:n.name,layout:Xs(n.layout),...n.onboarding?{onboarding:{...n.onboarding}}:{}}}function Hm(n){return{focusedChannelId:n.focusedChannelId,pinnedChannelIds:[...n.pinnedChannelIds],activeThemeName:n.activeThemeName,activeThemeColorScheme:n.activeThemeColorScheme,appearanceMode:n.appearanceMode,themeJavaScriptConsentIds:[...n.themeJavaScriptConsentIds],acpEnabled:n.acpEnabled}}function bk(n){throw new Error(`Unexpected server event: ${JSON.stringify(n)}`)}function Sk(n,t){var c;const e=n.snapshot,r=e.focusedChannel;if(t==="ArrowLeft"||t==="ArrowRight"){if(r===null||r.selectedPage===null)return!1;const u=r.pages.indexOf(r.selectedPage),p=u+(t==="ArrowLeft"?-1:1),f=(c=r.pages[p])==null?void 0:c.artifactIds[0];return u===-1||f===void 0?!1:(Xw(),n.selectPage(r.id,f),!0)}const i=_k(e),s=r===null?-1:i.indexOf(r.id),a=s+(t==="ArrowUp"?-1:1),l=i[a];return s===-1||l===void 0?!1:(Xw(),n.focusChannel(l).catch(()=>{}),!0)}function _k(n){const t=new Map(n.channels.map(s=>[s.id,s])),e=n.display.pinnedChannelIds.filter(s=>t.has(s)),r=new Set(e),i=n.channels.filter(({id:s})=>!r.has(s)).map(({id:s})=>s).sort((s,a)=>a.localeCompare(s));return[...e,...i]}function Xw(){const n=document.activeElement;n instanceof HTMLElement&&n.blur()}const _8="0123456789ABCDEFGHJKMNPQRSTVWXYZ",wd=32,Ak=16,A8=10,Qw=0xffffffffffff;var Qs;(function(n){n.Base32IncorrectEncoding="B32_ENC_INVALID",n.DecodeTimeInvalidCharacter="DEC_TIME_CHAR",n.DecodeTimeValueMalformed="DEC_TIME_MALFORMED",n.EncodeTimeNegative="ENC_TIME_NEG",n.EncodeTimeSizeExceeded="ENC_TIME_SIZE_EXCEED",n.EncodeTimeValueMalformed="ENC_TIME_MALFORMED",n.PRNGDetectFailure="PRNG_DETECT",n.ULIDInvalid="ULID_INVALID",n.Unexpected="UNEXPECTED",n.UUIDInvalid="UUID_INVALID"})(Qs||(Qs={}));class yc extends Error{constructor(t,e){super(`${e} (${t})`),this.name="ULIDError",this.code=t}}function Ek(n){const t=Math.floor(n()*wd)%wd;return _8.charAt(t)}function kk(n){const t=Tk(),e=t&&(t.crypto||t.msCrypto)||null;if(typeof(e==null?void 0:e.getRandomValues)=="function")return()=>{const r=new Uint8Array(1);return e.getRandomValues(r),r[0]/256};if(typeof(e==null?void 0:e.randomBytes)=="function")return()=>e.randomBytes(1).readUInt8()/256;throw new yc(Qs.PRNGDetectFailure,"Failed to find a reliable PRNG")}function Tk(){return Ik()?self:typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:null}function Ck(n,t){let e="";for(;n>0;n--)e=Ek(t)+e;return e}function Rk(n,t=A8){if(isNaN(n))throw new yc(Qs.EncodeTimeValueMalformed,`Time must be a number: ${n}`);if(n>Qw)throw new yc(Qs.EncodeTimeSizeExceeded,`Cannot encode a time larger than ${Qw}: ${n}`);if(n<0)throw new yc(Qs.EncodeTimeNegative,`Time must be positive: ${n}`);if(Number.isInteger(n)===!1)throw new yc(Qs.EncodeTimeValueMalformed,`Time must be an integer: ${n}`);let e,r="";for(let i=t;i>0;i--)e=n%wd,r=_8.charAt(e)+r,n=(n-e)/wd;return r}function Ik(){return typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope}function N1(n,t){const e=kk(),r=Date.now();return Rk(r,A8)+Ck(Ak,e)}const wc=Rn(),E8=Rn(),k8=Rn(),$k=Rn(),mm=Rn(),xk="store-";function Es(n){return new URL(n).origin}function Pk(){return{authTokens:{}}}var oo,ao,lo;class Dk extends Ei{constructor(e,r,i={}){super();m(this,oo);m(this,ao);m(this,lo);d(this,oo,`${xk}${e}`),d(this,ao,i.storage??Ok());const s=o(this,ao).getItem(o(this,oo));s===null?(d(this,lo,r),o(this,ao).setItem(o(this,oo),JSON.stringify(r))):d(this,lo,Nk(JSON.parse(s),r))}get(){return o(this,lo)}set(e){d(this,lo,e),o(this,ao).setItem(o(this,oo),JSON.stringify(e)),this.dispatchEvent(new Bt("change"))}}oo=new WeakMap,ao=new WeakMap,lo=new WeakMap;function e2(n,t){return n.authTokens[Es(t)]??null}function Lk(n,t,e){return{authTokens:{...n.authTokens,[Es(t)]:e}}}function Mk(n,t){const e=Es(t);if(!(e in n.authTokens))return n;const r={...n.authTokens};return delete r[e],{authTokens:r}}function Ok(){const n=globalThis.localStorage;if(!n)throw new Error("LocalStore: no storage adapter supplied and window.localStorage is unavailable");return n}function Nk(n,t){if(typeof n!="object"||n===null||Array.isArray(n))return t;const e=n.authTokens;if(typeof e!="object"||e===null||Array.isArray(e))return t;const r={};for(const[i,s]of Object.entries(e))if(typeof s=="string")try{r[Es(i)]=s}catch{}return{authTokens:r}}function R(n,t,e){function r(l,c){if(l._zod||Object.defineProperty(l,"_zod",{value:{def:c,constr:a,traits:new Set},enumerable:!1}),l._zod.traits.has(n))return;l._zod.traits.add(n),t(l,c);const u=a.prototype,p=Object.keys(u);for(let f=0;f<p.length;f++){const y=p[f];y in l||(l[y]=u[y].bind(l))}}const i=(e==null?void 0:e.Parent)??Object;class s extends i{}Object.defineProperty(s,"name",{value:n});function a(l){var c;const u=e!=null&&e.Parent?new s:this;r(u,l),(c=u._zod).deferred??(c.deferred=[]);for(const p of u._zod.deferred)p();return u}return Object.defineProperty(a,"init",{value:r}),Object.defineProperty(a,Symbol.hasInstance,{value:l=>{var c,u;return e!=null&&e.Parent&&l instanceof e.Parent?!0:(u=(c=l==null?void 0:l._zod)==null?void 0:c.traits)==null?void 0:u.has(n)}}),Object.defineProperty(a,"name",{value:n}),a}class Da extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class T8 extends Error{constructor(t){super(`Encountered unidirectional transform during encode: ${t}`),this.name="ZodEncodeError"}}const C8={};function ks(n){return C8}function R8(n){const t=Object.values(n).filter(r=>typeof r=="number");return Object.entries(n).filter(([r,i])=>t.indexOf(+r)===-1).map(([r,i])=>i)}function Zm(n,t){return typeof t=="bigint"?t.toString():t}function xp(n){return{get value(){{const t=n();return Object.defineProperty(this,"value",{value:t}),t}}}}function z1(n){return n==null}function H1(n){const t=n.startsWith("^")?1:0,e=n.endsWith("$")?n.length-1:n.length;return n.slice(t,e)}function zk(n,t){const e=(n.toString().split(".")[1]||"").length,r=t.toString();let i=(r.split(".")[1]||"").length;if(i===0&&/\d?e-\d?/.test(r)){const c=r.match(/\d?e-(\d?)/);c!=null&&c[1]&&(i=Number.parseInt(c[1]))}const s=e>i?e:i,a=Number.parseInt(n.toFixed(s).replace(".","")),l=Number.parseInt(t.toFixed(s).replace(".",""));return a%l/10**s}const t2=Symbol("evaluating");function Ae(n,t,e){let r;Object.defineProperty(n,t,{get(){if(r!==t2)return r===void 0&&(r=t2,r=e()),r},set(i){Object.defineProperty(n,t,{value:i})},configurable:!0})}function na(n,t,e){Object.defineProperty(n,t,{value:e,writable:!0,enumerable:!0,configurable:!0})}function $s(...n){const t={};for(const e of n){const r=Object.getOwnPropertyDescriptors(e);Object.assign(t,r)}return Object.defineProperties({},t)}function n2(n){return JSON.stringify(n)}function Hk(n){return n.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}const I8="captureStackTrace"in Error?Error.captureStackTrace:(...n)=>{};function qc(n){return typeof n=="object"&&n!==null&&!Array.isArray(n)}const Zk=xp(()=>{var n;if(typeof navigator<"u"&&((n=navigator==null?void 0:navigator.userAgent)!=null&&n.includes("Cloudflare")))return!1;try{const t=Function;return new t(""),!0}catch{return!1}});function Ll(n){if(qc(n)===!1)return!1;const t=n.constructor;if(t===void 0||typeof t!="function")return!0;const e=t.prototype;return!(qc(e)===!1||Object.prototype.hasOwnProperty.call(e,"isPrototypeOf")===!1)}function $8(n){return Ll(n)?{...n}:Array.isArray(n)?[...n]:n}const Uk=new Set(["string","number","symbol"]);function Ml(n){return n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function xs(n,t,e){const r=new n._zod.constr(t??n._zod.def);return(!t||e!=null&&e.parent)&&(r._zod.parent=n),r}function K(n){const t=n;if(!t)return{};if(typeof t=="string")return{error:()=>t};if((t==null?void 0:t.message)!==void 0){if((t==null?void 0:t.error)!==void 0)throw new Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error=="string"?{...t,error:()=>t.error}:t}function Fk(n){return Object.keys(n).filter(t=>n[t]._zod.optin==="optional"&&n[t]._zod.optout==="optional")}const qk={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function Vk(n,t){const e=n._zod.def,r=e.checks;if(r&&r.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");const s=$s(n._zod.def,{get shape(){const a={};for(const l in t){if(!(l in e.shape))throw new Error(`Unrecognized key: "${l}"`);t[l]&&(a[l]=e.shape[l])}return na(this,"shape",a),a},checks:[]});return xs(n,s)}function Bk(n,t){const e=n._zod.def,r=e.checks;if(r&&r.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");const s=$s(n._zod.def,{get shape(){const a={...n._zod.def.shape};for(const l in t){if(!(l in e.shape))throw new Error(`Unrecognized key: "${l}"`);t[l]&&delete a[l]}return na(this,"shape",a),a},checks:[]});return xs(n,s)}function Wk(n,t){if(!Ll(t))throw new Error("Invalid input to extend: expected a plain object");const e=n._zod.def.checks;if(e&&e.length>0){const s=n._zod.def.shape;for(const a in t)if(Object.getOwnPropertyDescriptor(s,a)!==void 0)throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}const i=$s(n._zod.def,{get shape(){const s={...n._zod.def.shape,...t};return na(this,"shape",s),s}});return xs(n,i)}function jk(n,t){if(!Ll(t))throw new Error("Invalid input to safeExtend: expected a plain object");const e=$s(n._zod.def,{get shape(){const r={...n._zod.def.shape,...t};return na(this,"shape",r),r}});return xs(n,e)}function Gk(n,t){const e=$s(n._zod.def,{get shape(){const r={...n._zod.def.shape,...t._zod.def.shape};return na(this,"shape",r),r},get catchall(){return t._zod.def.catchall},checks:[]});return xs(n,e)}function Yk(n,t,e){const i=t._zod.def.checks;if(i&&i.length>0)throw new Error(".partial() cannot be used on object schemas containing refinements");const a=$s(t._zod.def,{get shape(){const l=t._zod.def.shape,c={...l};if(e)for(const u in e){if(!(u in l))throw new Error(`Unrecognized key: "${u}"`);e[u]&&(c[u]=n?new n({type:"optional",innerType:l[u]}):l[u])}else for(const u in l)c[u]=n?new n({type:"optional",innerType:l[u]}):l[u];return na(this,"shape",c),c},checks:[]});return xs(t,a)}function Kk(n,t,e){const r=$s(t._zod.def,{get shape(){const i=t._zod.def.shape,s={...i};if(e)for(const a in e){if(!(a in s))throw new Error(`Unrecognized key: "${a}"`);e[a]&&(s[a]=new n({type:"nonoptional",innerType:i[a]}))}else for(const a in i)s[a]=new n({type:"nonoptional",innerType:i[a]});return na(this,"shape",s),s}});return xs(t,r)}function Ia(n,t=0){var e;if(n.aborted===!0)return!0;for(let r=t;r<n.issues.length;r++)if(((e=n.issues[r])==null?void 0:e.continue)!==!0)return!0;return!1}function $a(n,t){return t.map(e=>{var r;return(r=e).path??(r.path=[]),e.path.unshift(n),e})}function Ch(n){return typeof n=="string"?n:n==null?void 0:n.message}function Ts(n,t,e){var i,s,a,l,c,u;const r={...n,path:n.path??[]};if(!n.message){const p=Ch((a=(s=(i=n.inst)==null?void 0:i._zod.def)==null?void 0:s.error)==null?void 0:a.call(s,n))??Ch((l=t==null?void 0:t.error)==null?void 0:l.call(t,n))??Ch((c=e.customError)==null?void 0:c.call(e,n))??Ch((u=e.localeError)==null?void 0:u.call(e,n))??"Invalid input";r.message=p}return delete r.inst,delete r.continue,t!=null&&t.reportInput||delete r.input,r}function Z1(n){return Array.isArray(n)?"array":typeof n=="string"?"string":"unknown"}function Vc(...n){const[t,e,r]=n;return typeof t=="string"?{message:t,code:"custom",input:e,inst:r}:{...t}}const x8=(n,t)=>{n.name="$ZodError",Object.defineProperty(n,"_zod",{value:n._zod,enumerable:!1}),Object.defineProperty(n,"issues",{value:t,enumerable:!1}),n.message=JSON.stringify(t,Zm,2),Object.defineProperty(n,"toString",{value:()=>n.message,enumerable:!1})},P8=R("$ZodError",x8),D8=R("$ZodError",x8,{Parent:Error});function Jk(n,t=e=>e.message){const e={},r=[];for(const i of n.issues)i.path.length>0?(e[i.path[0]]=e[i.path[0]]||[],e[i.path[0]].push(t(i))):r.push(t(i));return{formErrors:r,fieldErrors:e}}function Xk(n,t=e=>e.message){const e={_errors:[]},r=i=>{for(const s of i.issues)if(s.code==="invalid_union"&&s.errors.length)s.errors.map(a=>r({issues:a}));else if(s.code==="invalid_key")r({issues:s.issues});else if(s.code==="invalid_element")r({issues:s.issues});else if(s.path.length===0)e._errors.push(t(s));else{let a=e,l=0;for(;l<s.path.length;){const c=s.path[l];l===s.path.length-1?(a[c]=a[c]||{_errors:[]},a[c]._errors.push(t(s))):a[c]=a[c]||{_errors:[]},a=a[c],l++}}};return r(n),e}const U1=n=>(t,e,r,i)=>{const s=r?Object.assign(r,{async:!1}):{async:!1},a=t._zod.run({value:e,issues:[]},s);if(a instanceof Promise)throw new Da;if(a.issues.length){const l=new((i==null?void 0:i.Err)??n)(a.issues.map(c=>Ts(c,s,ks())));throw I8(l,i==null?void 0:i.callee),l}return a.value},F1=n=>async(t,e,r,i)=>{const s=r?Object.assign(r,{async:!0}):{async:!0};let a=t._zod.run({value:e,issues:[]},s);if(a instanceof Promise&&(a=await a),a.issues.length){const l=new((i==null?void 0:i.Err)??n)(a.issues.map(c=>Ts(c,s,ks())));throw I8(l,i==null?void 0:i.callee),l}return a.value},Pp=n=>(t,e,r)=>{const i=r?{...r,async:!1}:{async:!1},s=t._zod.run({value:e,issues:[]},i);if(s instanceof Promise)throw new Da;return s.issues.length?{success:!1,error:new(n??P8)(s.issues.map(a=>Ts(a,i,ks())))}:{success:!0,data:s.value}},Qk=Pp(D8),Dp=n=>async(t,e,r)=>{const i=r?Object.assign(r,{async:!0}):{async:!0};let s=t._zod.run({value:e,issues:[]},i);return s instanceof Promise&&(s=await s),s.issues.length?{success:!1,error:new n(s.issues.map(a=>Ts(a,i,ks())))}:{success:!0,data:s.value}},eT=Dp(D8),tT=n=>(t,e,r)=>{const i=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return U1(n)(t,e,i)},nT=n=>(t,e,r)=>U1(n)(t,e,r),rT=n=>async(t,e,r)=>{const i=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return F1(n)(t,e,i)},iT=n=>async(t,e,r)=>F1(n)(t,e,r),sT=n=>(t,e,r)=>{const i=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return Pp(n)(t,e,i)},oT=n=>(t,e,r)=>Pp(n)(t,e,r),aT=n=>async(t,e,r)=>{const i=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return Dp(n)(t,e,i)},lT=n=>async(t,e,r)=>Dp(n)(t,e,r),cT=/^[cC][^\s-]{8,}$/,uT=/^[0-9a-z]+$/,hT=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,dT=/^[0-9a-vA-V]{20}$/,pT=/^[A-Za-z0-9]{27}$/,fT=/^[a-zA-Z0-9_-]{21}$/,mT=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,gT=/^([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})$/,r2=n=>n?new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${n}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,vT=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,yT="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function wT(){return new RegExp(yT,"u")}const bT=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,ST=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/,_T=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,AT=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,ET=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,L8=/^[A-Za-z0-9_-]*$/,kT=/^\+[1-9]\d{6,14}$/,M8="(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))",TT=new RegExp(`^${M8}$`);function O8(n){const t="(?:[01]\\d|2[0-3]):[0-5]\\d";return typeof n.precision=="number"?n.precision===-1?`${t}`:n.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${n.precision}}`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function CT(n){return new RegExp(`^${O8(n)}$`)}function RT(n){const t=O8({precision:n.precision}),e=["Z"];n.local&&e.push(""),n.offset&&e.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");const r=`${t}(?:${e.join("|")})`;return new RegExp(`^${M8}T(?:${r})$`)}const IT=n=>{const t=n?`[\\s\\S]{${(n==null?void 0:n.minimum)??0},${(n==null?void 0:n.maximum)??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)},$T=/^-?\d+$/,N8=/^-?\d+(?:\.\d+)?$/,xT=/^(?:true|false)$/i,PT=/^[^A-Z]*$/,DT=/^[^a-z]*$/,jt=R("$ZodCheck",(n,t)=>{var e;n._zod??(n._zod={}),n._zod.def=t,(e=n._zod).onattach??(e.onattach=[])}),z8={number:"number",bigint:"bigint",object:"date"},H8=R("$ZodCheckLessThan",(n,t)=>{jt.init(n,t);const e=z8[typeof t.value];n._zod.onattach.push(r=>{const i=r._zod.bag,s=(t.inclusive?i.maximum:i.exclusiveMaximum)??Number.POSITIVE_INFINITY;t.value<s&&(t.inclusive?i.maximum=t.value:i.exclusiveMaximum=t.value)}),n._zod.check=r=>{(t.inclusive?r.value<=t.value:r.value<t.value)||r.issues.push({origin:e,code:"too_big",maximum:typeof t.value=="object"?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:n,continue:!t.abort})}}),Z8=R("$ZodCheckGreaterThan",(n,t)=>{jt.init(n,t);const e=z8[typeof t.value];n._zod.onattach.push(r=>{const i=r._zod.bag,s=(t.inclusive?i.minimum:i.exclusiveMinimum)??Number.NEGATIVE_INFINITY;t.value>s&&(t.inclusive?i.minimum=t.value:i.exclusiveMinimum=t.value)}),n._zod.check=r=>{(t.inclusive?r.value>=t.value:r.value>t.value)||r.issues.push({origin:e,code:"too_small",minimum:typeof t.value=="object"?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:n,continue:!t.abort})}}),LT=R("$ZodCheckMultipleOf",(n,t)=>{jt.init(n,t),n._zod.onattach.push(e=>{var r;(r=e._zod.bag).multipleOf??(r.multipleOf=t.value)}),n._zod.check=e=>{if(typeof e.value!=typeof t.value)throw new Error("Cannot mix number and bigint in multiple_of check.");(typeof e.value=="bigint"?e.value%t.value===BigInt(0):zk(e.value,t.value)===0)||e.issues.push({origin:typeof e.value,code:"not_multiple_of",divisor:t.value,input:e.value,inst:n,continue:!t.abort})}}),MT=R("$ZodCheckNumberFormat",(n,t)=>{var a;jt.init(n,t),t.format=t.format||"float64";const e=(a=t.format)==null?void 0:a.includes("int"),r=e?"int":"number",[i,s]=qk[t.format];n._zod.onattach.push(l=>{const c=l._zod.bag;c.format=t.format,c.minimum=i,c.maximum=s,e&&(c.pattern=$T)}),n._zod.check=l=>{const c=l.value;if(e){if(!Number.isInteger(c)){l.issues.push({expected:r,format:t.format,code:"invalid_type",continue:!1,input:c,inst:n});return}if(!Number.isSafeInteger(c)){c>0?l.issues.push({input:c,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:n,origin:r,inclusive:!0,continue:!t.abort}):l.issues.push({input:c,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:n,origin:r,inclusive:!0,continue:!t.abort});return}}c<i&&l.issues.push({origin:"number",input:c,code:"too_small",minimum:i,inclusive:!0,inst:n,continue:!t.abort}),c>s&&l.issues.push({origin:"number",input:c,code:"too_big",maximum:s,inclusive:!0,inst:n,continue:!t.abort})}}),OT=R("$ZodCheckMaxLength",(n,t)=>{var e;jt.init(n,t),(e=n._zod.def).when??(e.when=r=>{const i=r.value;return!z1(i)&&i.length!==void 0}),n._zod.onattach.push(r=>{const i=r._zod.bag.maximum??Number.POSITIVE_INFINITY;t.maximum<i&&(r._zod.bag.maximum=t.maximum)}),n._zod.check=r=>{const i=r.value;if(i.length<=t.maximum)return;const a=Z1(i);r.issues.push({origin:a,code:"too_big",maximum:t.maximum,inclusive:!0,input:i,inst:n,continue:!t.abort})}}),NT=R("$ZodCheckMinLength",(n,t)=>{var e;jt.init(n,t),(e=n._zod.def).when??(e.when=r=>{const i=r.value;return!z1(i)&&i.length!==void 0}),n._zod.onattach.push(r=>{const i=r._zod.bag.minimum??Number.NEGATIVE_INFINITY;t.minimum>i&&(r._zod.bag.minimum=t.minimum)}),n._zod.check=r=>{const i=r.value;if(i.length>=t.minimum)return;const a=Z1(i);r.issues.push({origin:a,code:"too_small",minimum:t.minimum,inclusive:!0,input:i,inst:n,continue:!t.abort})}}),zT=R("$ZodCheckLengthEquals",(n,t)=>{var e;jt.init(n,t),(e=n._zod.def).when??(e.when=r=>{const i=r.value;return!z1(i)&&i.length!==void 0}),n._zod.onattach.push(r=>{const i=r._zod.bag;i.minimum=t.length,i.maximum=t.length,i.length=t.length}),n._zod.check=r=>{const i=r.value,s=i.length;if(s===t.length)return;const a=Z1(i),l=s>t.length;r.issues.push({origin:a,...l?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:r.value,inst:n,continue:!t.abort})}}),Lp=R("$ZodCheckStringFormat",(n,t)=>{var e,r;jt.init(n,t),n._zod.onattach.push(i=>{const s=i._zod.bag;s.format=t.format,t.pattern&&(s.patterns??(s.patterns=new Set),s.patterns.add(t.pattern))}),t.pattern?(e=n._zod).check??(e.check=i=>{t.pattern.lastIndex=0,!t.pattern.test(i.value)&&i.issues.push({origin:"string",code:"invalid_format",format:t.format,input:i.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:n,continue:!t.abort})}):(r=n._zod).check??(r.check=()=>{})}),HT=R("$ZodCheckRegex",(n,t)=>{Lp.init(n,t),n._zod.check=e=>{t.pattern.lastIndex=0,!t.pattern.test(e.value)&&e.issues.push({origin:"string",code:"invalid_format",format:"regex",input:e.value,pattern:t.pattern.toString(),inst:n,continue:!t.abort})}}),ZT=R("$ZodCheckLowerCase",(n,t)=>{t.pattern??(t.pattern=PT),Lp.init(n,t)}),UT=R("$ZodCheckUpperCase",(n,t)=>{t.pattern??(t.pattern=DT),Lp.init(n,t)}),FT=R("$ZodCheckIncludes",(n,t)=>{jt.init(n,t);const e=Ml(t.includes),r=new RegExp(typeof t.position=="number"?`^.{${t.position}}${e}`:e);t.pattern=r,n._zod.onattach.push(i=>{const s=i._zod.bag;s.patterns??(s.patterns=new Set),s.patterns.add(r)}),n._zod.check=i=>{i.value.includes(t.includes,t.position)||i.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:i.value,inst:n,continue:!t.abort})}}),qT=R("$ZodCheckStartsWith",(n,t)=>{jt.init(n,t);const e=new RegExp(`^${Ml(t.prefix)}.*`);t.pattern??(t.pattern=e),n._zod.onattach.push(r=>{const i=r._zod.bag;i.patterns??(i.patterns=new Set),i.patterns.add(e)}),n._zod.check=r=>{r.value.startsWith(t.prefix)||r.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:r.value,inst:n,continue:!t.abort})}}),VT=R("$ZodCheckEndsWith",(n,t)=>{jt.init(n,t);const e=new RegExp(`.*${Ml(t.suffix)}$`);t.pattern??(t.pattern=e),n._zod.onattach.push(r=>{const i=r._zod.bag;i.patterns??(i.patterns=new Set),i.patterns.add(e)}),n._zod.check=r=>{r.value.endsWith(t.suffix)||r.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:r.value,inst:n,continue:!t.abort})}}),BT=R("$ZodCheckOverwrite",(n,t)=>{jt.init(n,t),n._zod.check=e=>{e.value=t.tx(e.value)}});class WT{constructor(t=[]){this.content=[],this.indent=0,this&&(this.args=t)}indented(t){this.indent+=1,t(this),this.indent-=1}write(t){if(typeof t=="function"){t(this,{execution:"sync"}),t(this,{execution:"async"});return}const r=t.split(`
4
+ `+C.prev}function Dr(k,C){var fe=Ls(k),Se=[];if(fe){Se.length=k.length;for(var ke=0;ke<k.length;ke++)Se[ke]=at(k,ke)?C(k[ke],k):""}var te=typeof xe=="function"?xe(k):[],St;if(le){St={};for(var er=0;er<te.length;er++)St["$"+te[er]]=te[er]}for(var dt in k)at(k,dt)&&(fe&&String(Number(dt))===dt&&dt<k.length||le&&St["$"+dt]instanceof Symbol||(F.call(/[^\w$]/,dt)?Se.push(C(dt,k)+": "+C(k[dt],k)):Se.push(dt+": "+C(k[dt],k))));if(typeof xe=="function")for(var Dn=0;Dn<te.length;Dn++)Dt.call(k,te[Dn])&&Se.push("["+C(te[Dn])+"]: "+C(k[te[Dn]],k));return Se}return R0}var I0,aw;function iE(){if(aw)return I0;aw=1;var n=Vl(),t=pe(),e=function(l,c,u){for(var p=l,f;(f=p.next)!=null;p=f)if(f.key===c)return p.next=f.next,u||(f.next=l.next,l.next=f),f},r=function(l,c){if(l){var u=e(l,c);return u&&u.value}},i=function(l,c,u){var p=e(l,c);p?p.value=u:l.next={key:c,next:l.next,value:u}},s=function(l,c){return l?!!e(l,c):!1},a=function(l,c){if(l)return e(l,c,!0)};return I0=function(){var c,u={assert:function(p){if(!u.has(p))throw new t("Side channel does not contain "+n(p))},delete:function(p){var f=a(c,p);return f&&c&&!c.next&&(c=void 0),!!f},get:function(p){return r(c,p)},has:function(p){return s(c,p)},set:function(p,f){c||(c={next:void 0}),i(c,p,f)}};return u},I0}var $0,lw;function o8(){if(lw)return $0;lw=1;var n=Cn(),t=Is(),e=Vl(),r=pe(),i=n("%Map%",!0),s=t("Map.prototype.get",!0),a=t("Map.prototype.set",!0),l=t("Map.prototype.has",!0),c=t("Map.prototype.delete",!0),u=t("Map.prototype.size",!0);return $0=!!i&&function(){var f,y={assert:function(v){if(!y.has(v))throw new r("Side channel does not contain "+e(v))},delete:function(v){if(f){var S=c(f,v);return u(f)===0&&(f=void 0),S}return!1},get:function(v){if(f)return s(f,v)},has:function(v){return f?l(f,v):!1},set:function(v,S){f||(f=new i),a(f,v,S)}};return y},$0}var x0,cw;function sE(){if(cw)return x0;cw=1;var n=Cn(),t=Is(),e=Vl(),r=o8(),i=pe(),s=n("%WeakMap%",!0),a=t("WeakMap.prototype.get",!0),l=t("WeakMap.prototype.set",!0),c=t("WeakMap.prototype.has",!0),u=t("WeakMap.prototype.delete",!0);return x0=s?function(){var f,y,v={assert:function(S){if(!v.has(S))throw new i("Side channel does not contain "+e(S))},delete:function(S){if(s&&S&&(typeof S=="object"||typeof S=="function")){if(f)return u(f,S)}else if(r&&y)return y.delete(S);return!1},get:function(S){return s&&S&&(typeof S=="object"||typeof S=="function")&&f?a(f,S):y&&y.get(S)},has:function(S){return s&&S&&(typeof S=="object"||typeof S=="function")&&f?c(f,S):!!y&&y.has(S)},set:function(S,_){s&&S&&(typeof S=="object"||typeof S=="function")?(f||(f=new s),l(f,S,_)):r&&(y||(y=r()),y.set(S,_))}};return v}:r,x0}var P0,uw;function oE(){if(uw)return P0;uw=1;var n=pe(),t=Vl(),e=iE(),r=o8(),i=sE(),s=i||r||e;return P0=function(){var l,c={assert:function(u){if(!c.has(u)){var p=u&&Object(u)===u?"the given object key":t(u);throw new n("Side channel does not contain "+p)}},delete:function(u){return!!l&&l.delete(u)},get:function(u){return l&&l.get(u)},has:function(u){return!!l&&l.has(u)},set:function(u,p){l||(l=s()),l.set(u,p)}};return c},P0}var D0,hw;function $1(){if(hw)return D0;hw=1;var n=Ai(),t=oE()(),e=pe(),r={assert:function(i,s){if(!i||typeof i!="object"&&typeof i!="function")throw new e("`O` is not an object");if(typeof s!="string")throw new e("`slot` must be a string");if(t.assert(i),!r.has(i,s))throw new e("`"+s+"` is not present on `O`")},get:function(i,s){if(!i||typeof i!="object"&&typeof i!="function")throw new e("`O` is not an object");if(typeof s!="string")throw new e("`slot` must be a string");var a=t.get(i);return a&&a["$"+s]},has:function(i,s){if(!i||typeof i!="object"&&typeof i!="function")throw new e("`O` is not an object");if(typeof s!="string")throw new e("`slot` must be a string");var a=t.get(i);return!!a&&n(a,"$"+s)},set:function(i,s,a){if(!i||typeof i!="object"&&typeof i!="function")throw new e("`O` is not an object");if(typeof s!="string")throw new e("`slot` must be a string");var l=t.get(i);l||(l={},t.set(i,l)),l["$"+s]=a}};return Object.freeze&&Object.freeze(r),D0=r,D0}var L0,dw;function x1(){if(dw)return L0;dw=1;var n=Si(),t=$1(),e=function r(i,s){if(!(this instanceof r))return new r(i,s);if(i!=="normal"&&i!=="break"&&i!=="continue"&&i!=="return"&&i!=="throw")throw new n('Assertion failed: `type` must be one of "normal", "break", "continue", "return", or "throw"');t.set(this,"[[Type]]",i),t.set(this,"[[Value]]",s)};return e.prototype.type=function(){return t.get(this,"[[Type]]")},e.prototype.value=function(){return t.get(this,"[[Value]]")},e.prototype["?"]=function(){var i=t.get(this,"[[Type]]"),s=t.get(this,"[[Value]]");if(i==="throw")throw s;return s},e.prototype["!"]=function(){var i=t.get(this,"[[Type]]");if(i!=="normal")throw new n('Assertion failed: Completion Record is not of type "normal"');return t.get(this,"[[Value]]")},L0=e,L0}var M0,pw;function P1(){if(pw)return M0;pw=1;var n=x1();return M0=function(e){return new n("normal",e)},M0}var O0,fw;function aE(){if(fw)return O0;fw=1;var n=Zl();return O0=function(){return n()&&!!Symbol.toStringTag},O0}var N0,mw;function a8(){if(mw)return N0;mw=1;var n=Cn(),t=n("%Object.defineProperty%",!0),e=aE()(),r=Ai(),i=pe(),s=e?Symbol.toStringTag:null;return N0=function(l,c){var u=arguments.length>2&&!!arguments[2]&&arguments[2].force,p=arguments.length>2&&!!arguments[2]&&arguments[2].nonConfigurable;if(typeof u<"u"&&typeof u!="boolean"||typeof p<"u"&&typeof p!="boolean")throw new i("if provided, the `overrideIfSet` and `nonConfigurable` options must be booleans");s&&(u||!r(l,s))&&(t?t(l,s,{configurable:!p,enumerable:!1,value:c,writable:!1}):l[s]=c)},N0}var z0={exports:{}},H0,gw;function lE(){if(gw)return H0;gw=1;var n=Cn(),t=Wb(),e=Cp()(),r=Hl(),i=pe(),s=n("%Math.floor%");return H0=function(l,c){if(typeof l!="function")throw new i("`fn` is not a function");if(typeof c!="number"||c<0||c>4294967295||s(c)!==c)throw new i("`length` must be a positive 32-bit integer");var u=arguments.length>2&&!!arguments[2],p=!0,f=!0;if("length"in l&&r){var y=r(l,"length");y&&!y.configurable&&(p=!1),y&&!y.writable&&(f=!1)}return(p||f||!u)&&(e?t(l,"length",c,!0,!0):t(l,"length",c)),l},H0}var Z0,vw;function cE(){if(vw)return Z0;vw=1;var n=ch(),t=E1(),e=Xb();return Z0=function(){return e(n,t,arguments)},Z0}var yw;function D1(){return yw||(yw=1,(function(n){var t=lE(),e=lh(),r=Rp(),i=cE();n.exports=function(a){var l=r(arguments),c=1+a.length-(arguments.length-1);return t(l,c>0?c:0,!0)},e?e(n.exports,"apply",{value:i}):n.exports.apply=i})(z0)),z0.exports}var U0,ww;function uE(){return ww||(ww=1,U0=function(t,e){for(var r=0;r<t.length;r+=1)if(!e(t[r],r,t))return!1;return!0}),U0}var F0,bw;function hE(){if(bw)return F0;bw=1;var n=Object;return F0=function(e){return e&&typeof e=="object"&&(typeof e["[[ResourceValue]]"]>"u"||n(e["[[ResourceValue]]"])===e["[[ResourceValue]]"])&&(e["[[Hint]]"]==="SYNC-DISPOSE"||e["[[Hint]]"]==="ASYNC-DISPOSE")&&(typeof e["[[DisposeMethod]]"]=="function"||typeof e["[[DisposeMethod]]"]>"u")},F0}var q0,Sw;function dE(){if(Sw)return q0;Sw=1;var n=Ai(),t=k1(),e=uE(),r=hE();return q0=function(s){return s&&typeof s=="object"&&n(s,"[[DisposableResourceStack]]")&&t(s["[[DisposableResourceStack]]"])&&(s["[[DisposableResourceStack]]"].length===0||e(s["[[DisposableResourceStack]]"],r))},q0}var V0,_w;function pE(){if(_w)return V0;_w=1;var n=_i();return V0=function(e){if(e===null)return"Null";if(typeof e>"u")return"Undefined";if(n(e))return"Object";if(typeof e=="number")return"Number";if(typeof e=="boolean")return"Boolean";if(typeof e=="string")return"String"},V0}var B0,Aw;function L1(){if(Aw)return B0;Aw=1;var n=pE();return B0=function(e){return typeof e=="symbol"?"Symbol":typeof e=="bigint"?"BigInt":n(e)},B0}var W0,Ew;function fE(){if(Ew)return W0;Ew=1;var n=pe(),t=Vl(),e=Fl();return W0=function(i,s){if(!e(s))throw new n("Assertion failed: P is not a Property Key, got "+t(s));return i[s]},W0}var j0,kw;function mE(){if(kw)return j0;kw=1;var n=pe(),t=fE(),e=ql(),r=Fl(),i=Vl();return j0=function(a,l){if(!r(l))throw new n("Assertion failed: P is not a Property Key");var c=t(a,l);if(c!=null){if(!e(c))throw new n(i(l)+" is not a function: "+i(c));return c}},j0}var Eh={exports:{}},G0,Tw;function gE(){return Tw||(Tw=1,G0=Cn()),G0}var Cw;function vE(){if(Cw)return Eh.exports;Cw=1;var n=gE(),t=n("%Reflect.construct%",!0),e=uh();try{e({},"",{"[[Get]]":function(){}})}catch{e=null}if(e&&t){var r={},i={};e(i,"length",{"[[Get]]":function(){throw r},"[[Enumerable]]":!0}),Eh.exports=function(a){try{t(a,i)}catch(l){return l===r}}}else Eh.exports=function(a){return typeof a=="function"&&!!a.prototype};return Eh.exports}var Y0,Rw;function yE(){if(Rw)return Y0;Rw=1;var n=pe(),t=ql(),e=vE();return Y0=function(i){if(!e(i))throw new n("C must be a constructor");var s={"[[Resolve]]":void 0,"[[Reject]]":void 0},a=new i(function(l,c){if(typeof s["[[Resolve]]"]<"u"||typeof s["[[Reject]]"]<"u")throw new n("executor has already been called");s["[[Resolve]]"]=l,s["[[Reject]]"]=c});if(!t(s["[[Resolve]]"])||!t(s["[[Reject]]"]))throw new n("executor must provide valid resolve and reject functions");return{"[[Promise]]":a,"[[Resolve]]":s["[[Resolve]]"],"[[Reject]]":s["[[Reject]]"]}},Y0}var K0,Iw;function wE(){if(Iw)return K0;Iw=1;var n=Si(),t=pe(),e=Ip(),r=mE(),i=yE(),s=L1(),a=R1()(),l=I1()();return K0=function(u,p){if(s(u)!=="Object")throw new t("`V` must be an Object");if(p!=="SYNC-DISPOSE"&&p!=="ASYNC-DISPOSE")throw new n("Assertion failed: `hint` must be `~SYNC-DISPOSE~` or `~ASYNC-DISPOSE~`");var f;if(p==="ASYNC-DISPOSE"&&l&&(f=r(u,l)),!f){if(!a)throw new n("`Symbol.dispose` is not supported");if(f=r(u,a),typeof f<"u")return function(){var y=this;if(p==="ASYNC-DISPOSE"){var v=i(Promise);try{e(f,y),e(v["[[Resolve]]"],void 0,[void 0])}catch(S){v["[[Reject]]"](S)}return v["[[Promise]]"]}e(f,y)}}return f},K0}var J0,$w;function bE(){if($w)return J0;$w=1;var n=Si(),t=pe(),e=ql(),r=L1(),i=wE();return J0=function(a,l){if(l!=="SYNC-DISPOSE"&&l!=="ASYNC-DISPOSE")throw new n("Assertion failed: `hint` must be `~SYNC-DISPOSE~` or `~ASYNC-DISPOSE~`");var c;if(arguments.length<3)if(a==null)a=void 0,c=void 0;else{if(typeof a<"u"&&r(a)!=="Object")throw new t("`V` must be an Object, or `null` or `undefined`");if(c=i(a,l),typeof c>"u")throw new t("dispose method must not be `undefined` on `V` when an object `V` is provided")}else if(c=arguments[2],!e(c))throw new t("`method`, when provided, must be a function");return{"[[ResourceValue]]":a,"[[Hint]]":l,"[[DisposeMethod]]":c}},J0}var X0,xw;function l8(){if(xw)return X0;xw=1;var n=Si(),t=pe(),e=dE(),r=bE(),i=Is(),s=i("Array.prototype.push");return X0=function(l,c,u){if(!e(l))throw new t("Assertion failed: `disposeCapability` must be a DisposeCapability Record");if(u!=="SYNC-DISPOSE"&&u!=="ASYNC-DISPOSE")throw new n("Assertion failed: `hint` must be `~SYNC-DISPOSE~` or `~ASYNC-DISPOSE~`");var p=arguments.length>3?arguments[3]:void 0;if(arguments.length>3&&typeof p!="function")throw new t("Assertion failed: `method`, when present, must be a function");if(!l["[[DisposableResourceStack]]"])throw new t("Assertion failed: `disposeCapability.[[DisposableResourceStack]]` must not be ~EMPTY~");var f;if(arguments.length<4){if(c==null&&u==="SYNC_DISPOSE")return"UNUSED";f=r(c,u)}else{if(typeof c<"u")throw new t("Assertion failed: `V` must be undefined when `method` is present");f=r(void 0,u,p)}return s(l["[[DisposableResourceStack]]"],f),"UNUSED"},X0}var Q0,Pw;function M1(){if(Pw)return Q0;Pw=1;var n=Cn(),t=D1(),e=Si(),r=n("%Promise.resolve%",!0),i=r&&t(r);return Q0=function(a,l){if(!i)throw new e("This environment does not support Promises.");return i(a,l)},Q0}var em,Dw;function SE(){if(Dw)return em;Dw=1;var n=Cn(),t=Si(),e=n("%Promise%",!0),r=Ip(),i=M1(),s=L1();return em=function(l,c,u){if(typeof l<"u"&&s(l)!=="Object")throw new t("Assertion failed: `V` must be `undefined` or an Object");if(c!=="SYNC-DISPOSE"&&c!=="ASYNC-DISPOSE")throw new t("Assertion failed: `hint` must be `~SYNC-DISPOSE~` or `~ASYNC-DISPOSE~`");if(typeof u<"u"&&typeof u!="function")throw new t("Assertion failed: `method` must be `undefined` or a function");var p=typeof u>"u"?u:r(u,l);if(c==="ASYNC-DISPOSE")return i(e,p)},em}var tm,Lw;function _E(){if(Lw)return tm;Lw=1;var n=x1();return tm=function(e){return new n("throw",e)},tm}var nm,Mw;function c8(){if(Mw)return nm;Mw=1;var n=Cn(),t=Si(),e=pe(),r=n("%Promise%",!0),i=Is(),s=i("Promise.prototype.then",!0),a=x1(),l=SE(),c=P1(),u=M1(),p=_E(),f=s8()();return nm=function(v,S){if(!(S instanceof a))throw new e("`completion` must be a Completion Record");var _=v["[[DisposableResourceStack]]"];if(!_)throw new e("Assertion failed: `disposeCapability.[[DisposableResourceStack]]` must not be ~EMPTY~");for(var I,Z=_.length-1;Z>=0;Z-=1)if(!I)I=_[Z]["[[Hint]]"];else if(I!==_[Z]["[[Hint]]"])throw new t("mixed hint stacks are not supported");for(var L=I==="ASYNC-DISPOSE"&&u(r,S),z=function(Q){if(S.type()==="throw"){var V=S.value(),re=new f(Q,V);S=p(re)}else S=p(Q)},P=I==="ASYNC-DISPOSE"&&function(V){return s(L,function(){var re=l(V["[[ResourceValue]]"],V["[[Hint]]"],V["[[DisposeMethod]]"]);if(!re)throw new t("Assertion failed: non-`~ASYNC-DISPOSE~` resource returned a promise from Dispose");return s(re,c)},z)},B=_.length-1;B>=0;B-=1)if(I==="ASYNC-DISPOSE")L=P(_[B]);else{var F=_[B];try{var q=l(F["[[ResourceValue]]"],F["[[Hint]]"],F["[[DisposeMethod]]"]);if(q)throw new t("Assertion failed: `~SYNC-DISPOSE~` resource returned something from Dispose")}catch(Q){z(Q)}}return v["[[DisposableResourceStack]]"]=null,I==="ASYNC-DISPOSE"?L:S},nm}var rm,Ow;function u8(){return Ow||(Ow=1,rm=function(){var t=[];return{"[[DisposableResourceStack]]":t}}),rm}var im,Nw;function AE(){if(Nw)return im;Nw=1;var n=b1(),t=pe(),e=Ip(),r=C1(),i=uh(),s=ql(),a=P1(),l=$1(),c=a8(),u=ta().supportsDescriptors,p=D1(),f=l8(),y=c8(),v=u8(),S=R1()(),_=function z(){if(!(this instanceof z)||l.has(this,"[[DisposableState]]")||l.has(this,"[[DisposeCapability]]"))throw new t("can only be used with new");l.set(this,"[[DisposableState]]","PENDING"),l.set(this,"[[DisposeCapability]]",v())},I=function(){var P=this;return l.assert(P,"[[DisposableState]]"),l.get(P,"[[DisposableState]]")==="DISPOSED"},Z=p(I);u?i(_.prototype,"disposed",{"[[Configurable]]":!0,"[[Enumerable]]":!1,"[[Get]]":I}):_.prototype.disposed=!1;var L=function(P){l.set(P,"[[DisposableState]]","DISPOSED"),u||(P.disposed=!0)};return r(_.prototype,"dispose",function(){var P=this;if(!Z(P))return L(P),y(l.get(P,"[[DisposeCapability]]"),a())["?"]()}),r(_.prototype,"use",function(P){var B=this;if(Z(B))throw new n("a disposed stack can not use anything new");return f(l.get(B,"[[DisposeCapability]]"),P,"SYNC-DISPOSE"),P}),r(_.prototype,"adopt",function(P,B){var F=this;if(Z(F))throw new n("a disposed stack can not use anything new");if(!s(B))throw new t("`onDispose` must be a function");var q=(function(){return e(B,void 0,[P])});return f(l.get(F,"[[DisposeCapability]]"),void 0,"SYNC-DISPOSE",q),P}),r(_.prototype,"defer",function(P){var B=this;if(Z(B))throw new n("a disposed stack can not defer anything new");if(!s(P))throw new t("`onDispose` must be a function");f(l.get(B,"[[DisposeCapability]]"),void 0,"SYNC-DISPOSE",P)}),r(_.prototype,"move",function(){var P=this;if(Z(P))throw new n("a disposed stack can not use anything new");var B=new _;return l.set(B,"[[DisposeCapability]]",l.get(P,"[[DisposeCapability]]")),l.set(P,"[[DisposeCapability]]",v()),L(P),B}),S&&r(_.prototype,S,_.prototype.dispose),c(_.prototype,"DisposableStack"),im=_,im}var sm,zw;function EE(){if(zw)return sm;zw=1;var n=AE();return sm=function(){return typeof DisposableStack=="function"?DisposableStack:n},sm}var om,Hw;function kE(){if(Hw)return om;Hw=1;var n=ta(),t=y1()(),e=EE();return om=function(){var i=e();return n(t,{DisposableStack:i},{DisposableStack:!0}),i},om}var am,Zw;function TE(){if(Zw)return am;Zw=1;var n=Cn(),t=b1(),e=pe(),r=n("%Promise%",!0),i=l8(),s=Ip(),a=C1(),l=uh(),c=c8(),u=ql(),p=u8(),f=P1(),y=M1(),v=$1(),S=a8(),_=ta().supportsDescriptors,I=D1(),Z=Is(),L=Z("Promise.prototype.then",!0),z=I1()(),P=function Q(){if(!(this instanceof Q)||v.has(this,"[[AsyncDisposableState]]")||v.has(this,"[[DisposeCapability]]"))throw new e("can only be used with new");v.set(this,"[[AsyncDisposableState]]","pending"),v.set(this,"[[DisposeCapability]]",p())},B=function(){var V=this;return v.assert(V,"[[AsyncDisposableState]]"),v.get(V,"[[AsyncDisposableState]]")==="disposed"},F=I(B);_?l(P.prototype,"disposed",{"[[Configurable]]":!0,"[[Enumerable]]":!1,"[[Get]]":B}):P.prototype.disposed=!1;var q=function(V){v.set(V,"[[AsyncDisposableState]]","disposed"),_||(V.disposed=!0)};return a(P.prototype,"disposeAsync",function(){var V=this;return F(V)?y(r):(q(V),L(y(r,c(v.get(V,"[[DisposeCapability]]"),f())),function(re){return re["?"]()}))}),a(P.prototype,"use",function(V){var re=this;if(F(re))throw new t("a disposed stack can not use anything new");return i(v.get(re,"[[DisposeCapability]]"),V,"ASYNC-DISPOSE"),V}),a(P.prototype,"adopt",function(V,re){var Ne=this;if(F(Ne))throw new t("a disposed stack can not use anything new");if(!u(re))throw new e("`onDisposeAsync` must be a function");var xe=(function(){return s(re,void 0,[V])});return xe.value=V,i(v.get(Ne,"[[DisposeCapability]]"),void 0,"ASYNC-DISPOSE",xe),V}),a(P.prototype,"defer",function(V){var re=this;if(F(re))throw new t("a disposed stack can not defer anything new");if(!u(V))throw new e("`onDispose` must be a function");i(v.get(re,"[[DisposeCapability]]"),void 0,"ASYNC-DISPOSE",V)}),a(P.prototype,"move",function(){var V=this;if(F(V))throw new t("a disposed stack can not use anything new");var re=new P;return v.set(re,"[[DisposeCapability]]",v.get(V,"[[DisposeCapability]]")),v.set(V,"[[DisposeCapability]]",p()),q(V),re}),z&&a(P.prototype,z,P.prototype.disposeAsync),S(P.prototype,"AsyncDisposableStack"),am=P,am}var lm,Uw;function CE(){if(Uw)return lm;Uw=1;var n=TE();return lm=function(){return typeof AsyncDisposableStack=="function"?AsyncDisposableStack:n},lm}var cm,Fw;function RE(){if(Fw)return cm;Fw=1;var n=ta(),t=y1()(),e=CE();return cm=function(){var i=e();return n(t,{AsyncDisposableStack:i},{AsyncDisposableStack:!0}),i},cm}var um,qw;function IE(){if(qw)return um;qw=1;var n=JA(),t=QA(),e=kE(),r=RE();return um=function(){n(),t(),e(),r()},um}var Vw;function $E(){return Vw||(Vw=1,VA(),IE()()),Tv}$E();const Bw=new WeakMap;function xE(n){return(typeof n=="object"||typeof n=="function")&&n!==null&&"then"in n&&typeof n.then=="function"}function da(n){return typeof n=="string"?n:typeof n=="symbol"?n.description??n.toString():n.name||"(anonymous class)"}function Ww(){return new Error("register(Key, factory) requires a factory function. Wrap existing instances as () => instance.")}function PE(){return new Error("register(Key, factory) does not accept async factories. Await setup before registering.")}class DE{constructor(){$(this,"entries",new Map);$(this,"constructionStack",[])}register(t,e){if(e===void 0){if(typeof t!="function")throw Ww();this.validateClassRegistration(t),this.storeFactory(t,()=>this.instantiateClass(t));return}if(typeof e!="function")throw Ww();if(e.constructor.name==="AsyncFunction")throw PE();this.storeFactory(t,e)}has(t){var e;return((e=this.entries.get(t))==null?void 0:e.factory)!==void 0}resolve(t){return this.resolveAny(t)}storeFactory(t,e){const r=this.getOrCreateEntry(t);r.factory=e,r.instance=void 0,r.error=void 0}validateClassRegistration(t){const e=Bw.get(t);if(e){if(t.length!==e.length)throw new Error(`${da(t)} cannot be registered with register(Class). @injectable(...) declared ${e.length} dependencies but constructor arity is ${t.length}. Use register(Key, () => value) instead.`);return}if(t.length!==0)throw new Error(`${da(t)} cannot be registered with register(Class). Undecorated classes must have zero required constructor parameters. Use register(Key, () => value) instead.`)}instantiateClass(t){const e=Bw.get(t);if(!e)return new t;const r=e.map(i=>this.resolveAny(i));return new t(...r)}resolveAny(t){return this.getOrCreateEntry(t).proxy}getOrCreateEntry(t){let e=this.entries.get(t);return e||(e={key:t},e.proxy=this.createProxy(e),this.entries.set(t,e),e)}createProxy(t){return new Proxy({},{get:(e,r)=>{if(r==="then")return;const i=this.getInstance(t),s=Reflect.get(i,r,i);return typeof s=="function"?s.bind(i):s},set:(e,r,i)=>{const s=this.getInstance(t);return Reflect.set(s,r,i,s)},has:(e,r)=>{const i=this.getInstance(t);return r in i}})}getInstance(t){if(t.instance)return t.instance;if(t.error)throw t.error;if(!t.factory)throw new Error(`${da(t.key)} was resolved but never registered`);const e=this.constructionStack.indexOf(t.key);if(e!==-1){const r=[...this.constructionStack.slice(e),t.key].map(i=>da(i)).join(" -> ");throw new Error(`Circular dependency detected: ${r}`)}this.constructionStack.push(t.key);try{const r=t.factory();if(xE(r))throw new Error(`Factory for ${da(t.key)} returned a Promise. Await setup before registering.`);if(typeof r!="object"||r===null)throw new Error(`Factory for ${da(t.key)} returned a non-object value. Wrap primitives in an object.`);return t.instance=r,r}catch(r){throw t.error=r,r}finally{this.constructionStack.pop()}}}const h8=new DE,LE=new Set(["target","currentTarget","eventPhase","defaultPrevented","isTrusted","timeStamp","srcElement","returnValue","cancelBubble","NONE","CAPTURING_PHASE","AT_TARGET","BUBBLING_PHASE","composedPath","stopPropagation","stopImmediatePropagation","preventDefault","initEvent"]);function ME(n){for(const t of Object.keys(n))if(LE.has(t))throw new Error(`Event payload key "${t}" is reserved; choose a different property name`)}function OE(n,t){ME(t);for(const e of Object.keys(t))Object.defineProperty(n,e,{value:t[e],writable:!0,enumerable:!0,configurable:!0})}function Rn(){class n extends Event{constructor(e,r){const{type:i,bubbles:s,cancelable:a,composed:l,...c}=r??{};if(i!==void 0)throw new Error('Do not pass "type" in init; use the constructor argument instead');super(e,{bubbles:s,cancelable:a,composed:l}),OE(this,c)}}return n}class Ei extends globalThis.EventTarget{}const NE="X-Television-Client-Meta",zE="telemetry-activity",HE="telemetry-signal",d8={kind:"single",full_screen:!1},p8={width:760,height:770};function ZE(n){return n.layout.flatMap(t=>t.artifactIds)}function UE(n){if(!Array.isArray(n))return{valid:!1,errors:["Layout must be an array of pages"]};const t=[];for(const[e,r]of n.entries())FE(r,e,t);return{valid:t.length===0,errors:t}}function Fc(n){return n.flatMap(t=>t.artifactIds)}function Dm(n,t){return n.flatMap(e=>{if(!e.artifactIds.includes(t))return[e];const r=e.artifactIds.filter(i=>i!==t);return r.length===0?[]:[{...e,artifactIds:r}]})}function FE(n,t,e){if(!hm(n)){e.push(`Page ${t} must be an object`);return}for(const r of Object.keys(n))r!=="artifactIds"&&r!=="geometry"&&r!=="size"&&e.push(`Page ${t} has unknown field: ${r}`);if(!Array.isArray(n.artifactIds)||n.artifactIds.length===0?e.push(`Page ${t} must contain at least one artifact id`):n.artifactIds.some(r=>typeof r!="string"||r.length===0)&&e.push(`Page ${t} artifact ids must be non-empty strings`),!hm(n.geometry)){e.push(`Page ${t} geometry must be an object`);return}for(const r of Object.keys(n.geometry))r!=="kind"&&r!=="full_screen"&&e.push(`Page ${t} geometry has unknown field: ${r}`);if(n.geometry.kind!=="single"){e.push(`Page ${t} has unknown geometry kind: ${String(n.geometry.kind)}`);return}if(typeof n.geometry.full_screen!="boolean"&&e.push(`Page ${t} single geometry must include a boolean full_screen`),!hm(n.size)){e.push(`Page ${t} size must be an object`);return}for(const r of Object.keys(n.size))r!=="width"&&r!=="height"&&e.push(`Page ${t} size has unknown field: ${r}`);for(const r of["width","height"]){const i=n.size[r];(typeof i!="number"||!Number.isFinite(i)||i<=0)&&e.push(`Page ${t} size ${r} must be a finite positive number`)}}function hm(n){return typeof n=="object"&&n!==null&&!Array.isArray(n)}const Bt=Rn(),Zh=Rn(),jw=Rn(),qE=Rn(),VE=Rn(),BE=Rn();function f8(n){class t extends Error{constructor(r,i){super(r),this.name=n,i&&Object.assign(this,i)}}return t}const Bl=f8("RequestError"),Gw=f8("ValidationError"),WE=200,jE=300,kh=401;class GE{constructor(t,e){$(this,"serverURL");$(this,"token");$(this,"onUnauthorized");$(this,"telemetryMeta");this.serverURL=t.replace(/\/$/,""),this.token=e.token,this.onUnauthorized=e.onUnauthorized,this.telemetryMeta=e.telemetryMeta}async requestJSON(t,e,r){var a;const i=await this.request(t,e,r!==void 0?JSON.stringify(r):void 0,r!==void 0?{"content-type":"application/json"}:void 0),s=await YE(i);if(!i.ok||i.status<WE||i.status>=jE)throw i.status===kh&&((a=this.onUnauthorized)==null||a.call(this)),this.createError(typeof s.error=="string"?s.error:i.statusText,i.status);return s}async requestVoid(t,e,r){var s;const i=await this.request(t,e,r!==void 0?JSON.stringify(r):void 0,r!==void 0?{"content-type":"application/json"}:void 0);if(!i.ok)throw i.status===kh&&((s=this.onUnauthorized)==null||s.call(this)),this.createError(await dm(i,i.statusText),i.status)}async requestText(t,e){var i;const r=await this.request(t,e);if(!r.ok)throw r.status===kh&&((i=this.onUnauthorized)==null||i.call(this)),this.createError(await dm(r,r.statusText),r.status);return r.text()}async requestRawVoid(t,e,r){var s;const i=await this.request(t,e,r,{"content-type":"text/markdown; charset=utf-8"});if(!i.ok)throw i.status===kh&&((s=this.onUnauthorized)==null||s.call(this)),this.createError(await dm(i,i.statusText),i.status)}createError(t,e){const r={serverURL:this.serverURL};return e!==void 0&&(r.status=e),new Bl(t,r)}async request(t,e,r,i){const s=`${this.serverURL}${e}`;try{return await fetch(s,{method:t,headers:this.buildHeaders(i),body:r})}catch(a){throw this.createError(a instanceof Error?a.message:"Failed to reach server")}}buildHeaders(t){const e={...t??{}};return this.token&&(e.Authorization=`Bearer ${this.token}`),this.telemetryMeta&&(e[NE]=JSON.stringify(this.telemetryMeta)),Object.keys(e).length>0?e:void 0}}async function YE(n){try{return await n.json()}catch{const t=await n.text().catch(()=>"");return t?{message:t}:{}}}async function dm(n,t){try{const e=await n.json();if(typeof e.error=="string")return e.error;if(typeof e.message=="string")return e.message}catch{}return t}function KE(n){return n.map(t=>`${t.name} (${t.id})`).join(", ")}var Ur,Md,m8;class JE{constructor(t){m(this,Md);m(this,Ur);d(this,Ur,t)}list(){return o(this,Ur).requestJSON("GET","/channels")}async get(t={}){const e=await h(this,Md,m8).call(this,t.channelID);return o(this,Ur).requestJSON("GET",`/channels/${encodeURIComponent(e)}`)}create(t){const e={name:t.name};return t.id!==void 0&&(e.id=t.id),o(this,Ur).requestJSON("POST","/channels",e)}update(t){const{channelID:e,...r}=t;return o(this,Ur).requestJSON("PATCH",`/channels/${encodeURIComponent(e)}`,r)}remove(t){return o(this,Ur).requestJSON("DELETE",`/channels/${encodeURIComponent(t.channelID)}`)}}Ur=new WeakMap,Md=new WeakSet,m8=async function(t){if(t!==void 0)return t;const{channels:e}=await this.list();if(e.length===1)return e[0].id;throw e.length===0?new Gw("channelID is required, but no channels exist."):new Gw(`channelID is required when multiple channels exist. Available channels: ${KE(e)}`)};var Fr;class XE{constructor(t){m(this,Fr);d(this,Fr,t)}create(t){const e={kind:t.kind,title:t.title};switch(t.kind){case"path":e.path=t.path;break;case"url":e.url=t.url;break}return e.channelID=t.channelID,o(this,Fr).requestJSON("POST","/artifacts",e)}list(t={}){const e=new URLSearchParams;t.channelID!==void 0&&e.set("channelID",t.channelID);const r=e.toString();return o(this,Fr).requestJSON("GET",r?`/artifacts?${r}`:"/artifacts")}get(t){return o(this,Fr).requestJSON("GET",`/artifacts/${encodeURIComponent(t.artifactID)}`)}update(t){const e={};return t.title!==void 0&&(e.title=t.title),t.path!==void 0&&(e.path=t.path),t.url!==void 0&&(e.url=t.url),o(this,Fr).requestJSON("PATCH",`/artifacts/${encodeURIComponent(t.artifactID)}`,e)}delete(t){return o(this,Fr).requestJSON("DELETE",`/artifacts/${encodeURIComponent(t.artifactID)}`)}}Fr=new WeakMap;var Ma;class QE{constructor(t){m(this,Ma);d(this,Ma,t)}list(){return o(this,Ma).requestJSON("GET","/themes")}refresh(){return o(this,Ma).requestJSON("POST","/themes/refresh")}}Ma=new WeakMap;var Oa;class ek{constructor(t){m(this,Oa);d(this,Oa,t)}get(t){return o(this,Oa).requestText("GET",`/markdown/${encodeURIComponent(t.artifactID)}`)}update(t){return o(this,Oa).requestRawVoid("PUT",`/markdown/${encodeURIComponent(t.artifactID)}`,t.content)}}Oa=new WeakMap;var no;class tk{constructor(t){m(this,no);d(this,no,t)}status(){return o(this,no).requestJSON("GET","/telemetry")}enable(){return o(this,no).requestJSON("POST","/telemetry/enable")}disable(){return o(this,no).requestJSON("POST","/telemetry/disable")}}no=new WeakMap;var ro;class nk{constructor(t){m(this,ro);d(this,ro,t)}get(){return o(this,ro).requestJSON("GET","/display")}patch(t){const e={};return t.focusedChannelId!==void 0&&(e.focusedChannelId=t.focusedChannelId),t.pinnedChannelIds!==void 0&&(e.pinnedChannelIds=t.pinnedChannelIds),t.activeThemeName!==void 0&&(e.activeThemeName=t.activeThemeName),t.appearanceMode!==void 0&&(e.appearanceMode=t.appearanceMode),t.themeJavaScriptConsentIds!==void 0&&(e.themeJavaScriptConsentIds=t.themeJavaScriptConsentIds),o(this,ro).requestVoid("PATCH","/display",e)}focus(t){return o(this,ro).requestJSON("POST","/display/focus",{artifactID:t.artifactID})}}ro=new WeakMap;var fn;class rk{constructor(t,e={}){$(this,"channels");$(this,"artifacts");$(this,"display");$(this,"themes");$(this,"markdown");$(this,"telemetry");m(this,fn);d(this,fn,new GE(t,e)),this.channels=new JE(o(this,fn)),this.artifacts=new XE(o(this,fn)),this.display=new nk(o(this,fn)),this.themes=new QE(o(this,fn)),this.markdown=new ek(o(this,fn)),this.telemetry=new tk(o(this,fn))}health(){return o(this,fn).requestJSON("GET","/health")}demoMode(){return o(this,fn).requestJSON("GET","/demo-mode")}}fn=new WeakMap;const vd="0.0.0",ik=/^\d+\.\d+\.\d+$/,sk=3;function $p(n){return ik.test(n)}function O1(n,t){const e=n.split(".").map(Number),r=t.split(".").map(Number);for(let i=0;i<sk;i++)if(e[i]!==r[i])return e[i]>r[i];return!1}function ok(n,t){return n===vd||t===vd?!1:n!==t}const ak=400,lk=404,g8=500,ck=600,uk={focusedChannelId:null,pinnedChannelIds:[],activeThemeName:null,activeThemeColorScheme:null,appearanceMode:"system",themeJavaScriptConsentIds:[],acpEnabled:!1};var he,Yc,Kc,qr,Ke,_e,io,Ui,so,Vr,Xt,Na,Jc,U,rr,Lm,fa,v8,Mm,y8,Uh,Om,w8,ma,b8,zr,Nm,S8,tt;class hk extends Ei{constructor(e){super();m(this,U);m(this,he);m(this,Yc);m(this,Kc);m(this,qr,new Set);$(this,"pendingPageWrites",new Map);m(this,Ke,new Map);m(this,_e,fk());m(this,io);m(this,Ui,!1);m(this,so,!1);m(this,Vr,0);m(this,Xt,!1);m(this,Na,()=>{if(o(this,Xt))return;const e=o(this,he).connection.status==="connected";e&&!o(this,so)?(d(this,so,!0),h(this,U,b8).call(this)):!e&&o(this,so)&&(d(this,so,!1),d(this,Vr,o(this,Vr)+1)),h(this,U,zr).call(this)});m(this,Jc,e=>{if(o(this,Xt)||e.serverURL!==o(this,he).connection.url)return;for(const i of o(this,qr))i.push(e.event);const r=e.event;if(r.type==="artifact-content-changed"){this.dispatchEvent(new jw("artifact-content-changed",{artifactID:r.artifactID}));return}if(r.type==="artifact-focus"){o(this,Ui)&&yd(o(this,_e),o(this,Ke),r.channelID,r.artifactID)&&h(this,U,zr).call(this),this.dispatchEvent(new qE("artifact-focus",{channelID:r.channelID,artifactID:r.artifactID}));return}r.type==="theme-changed"&&this.dispatchEvent(new VE("theme-changed",{themeName:r.themeName,activeThemeColorScheme:r.activeThemeColorScheme,themeJavaScriptConsentIds:[...r.themeJavaScriptConsentIds]})),r.type==="appearance-changed"&&this.dispatchEvent(new BE("appearance-changed",{appearanceMode:r.appearanceMode})),o(this,Ui)&&(Th(o(this,_e),r,this.pendingPageWrites,o(this,Ke)),pm(o(this,_e),o(this,Ke)),h(this,U,zr).call(this))});d(this,he,e.connectionOwner),d(this,Yc,e.navigationKeyHandler),d(this,Kc,e.retainedGateHalted??(()=>!1)),d(this,io,h(this,U,Nm).call(this)),o(this,he).addEventListener("change",o(this,Na)),o(this,he).addEventListener("server-event",o(this,Jc)),o(this,Na).call(this)}get snapshot(){return o(this,io)}handleNavigationKey(e){var r;h(this,U,tt).call(this),(r=o(this,Yc))==null||r.call(this,e)}async createChannel(e){h(this,U,tt).call(this);const{channel:r}=await h(this,U,rr).call(this,o(this,he).connection.client.channels.create({name:e}),()=>h(this,U,v8).call(this));return r}focusChannel(e){return h(this,U,tt).call(this),h(this,U,rr).call(this,o(this,he).connection.client.display.patch({focusedChannelId:e}),()=>h(this,U,fa).call(this))}setPinnedChannelIds(e){return h(this,U,tt).call(this),h(this,U,rr).call(this,o(this,he).connection.client.display.patch({pinnedChannelIds:[...e]}),()=>h(this,U,fa).call(this))}listThemes(){return h(this,U,tt).call(this),o(this,he).connection.client.themes.list()}refreshThemes(){return h(this,U,tt).call(this),o(this,he).connection.client.themes.refresh()}setActiveTheme(e){return h(this,U,tt).call(this),h(this,U,rr).call(this,o(this,he).connection.client.display.patch({activeThemeName:e}),()=>h(this,U,fa).call(this))}setAppearanceMode(e){return h(this,U,tt).call(this),h(this,U,rr).call(this,o(this,he).connection.client.display.patch({appearanceMode:e}),()=>h(this,U,fa).call(this))}setThemeJavaScriptConsent(e,r){h(this,U,tt).call(this);const i=o(this,_e).display.themeJavaScriptConsentIds,s=r?i.includes(e)?[...i]:[...i,e]:i.filter(a=>a!==e);return h(this,U,rr).call(this,o(this,he).connection.client.display.patch({themeJavaScriptConsentIds:s}),()=>h(this,U,fa).call(this))}selectPage(e,r){h(this,U,tt).call(this),yd(o(this,_e),o(this,Ke),e,r)&&h(this,U,zr).call(this)}async renameChannel(e,r){h(this,U,tt).call(this),await h(this,U,rr).call(this,o(this,he).connection.client.channels.update({channelID:e,name:r}),()=>h(this,U,Mm).call(this,e))}async deleteChannel(e){h(this,U,tt).call(this),await h(this,U,rr).call(this,o(this,he).connection.client.channels.remove({channelID:e}),()=>h(this,U,y8).call(this,e))}updateChannelPages(e,r){h(this,U,tt).call(this);const i=UE(r),s=o(this,_e).channels.get(e);if(!i.valid||!s)return Promise.resolve();const a=Xs(r),l=Xs(s.channel.layout),c={previousPages:l};return Jo(o(this,Ke),e,l,a),s.channel={...s.channel,layout:a},this.pendingPageWrites.set(e,c),h(this,U,zr).call(this),o(this,he).connection.client.channels.update({channelID:e,layout:Xs(a)}).then(()=>{this.pendingPageWrites.get(e)===c&&this.pendingPageWrites.delete(e)},async u=>{if(o(this,Xt))throw u;const p=this.pendingPageWrites.get(e)===c;if(p&&this.pendingPageWrites.delete(e),Kw(u))throw await h(this,U,Lm).call(this,()=>h(this,U,Mm).call(this,e)),u;if(!p||!wk(u))throw u;const f=o(this,_e).channels.get(e);if(!f)throw u;const y=Xs(c.previousPages);throw Jo(o(this,Ke),e,f.channel.layout,y),f.channel={...f.channel,layout:y},h(this,U,zr).call(this),u})}async deleteArtifact(e){h(this,U,tt).call(this);const r=Jw(o(this,_e),e);await h(this,U,rr).call(this,o(this,he).connection.client.artifacts.delete({artifactID:e}),()=>h(this,U,w8).call(this,e,r))}readMarkdown(e){return h(this,U,tt).call(this),o(this,he).connection.client.markdown.get({artifactID:e})}writeMarkdown(e,r){return h(this,U,tt).call(this),o(this,he).connection.client.markdown.update({artifactID:e,content:r})}get browserDemoMode(){return o(this,he).connection.browserDemoMode}getArtifactViewURL(e){return h(this,U,tt).call(this),o(this,he).connection.getViewURL(e)}getArtifactContentURL(e){return h(this,U,tt).call(this),o(this,he).connection.getContentURL(e)}dispose(){o(this,Xt)||(d(this,Xt,!0),d(this,Vr,o(this,Vr)+1),o(this,qr).clear(),this.pendingPageWrites.clear(),o(this,Ke).clear(),o(this,he).removeEventListener("change",o(this,Na)),o(this,he).removeEventListener("server-event",o(this,Jc)))}}he=new WeakMap,Yc=new WeakMap,Kc=new WeakMap,qr=new WeakMap,Ke=new WeakMap,_e=new WeakMap,io=new WeakMap,Ui=new WeakMap,so=new WeakMap,Vr=new WeakMap,Xt=new WeakMap,Na=new WeakMap,Jc=new WeakMap,U=new WeakSet,rr=async function(e,r){try{return await e}catch(i){throw!o(this,Xt)&&Kw(i)&&await h(this,U,Lm).call(this,r),i}},Lm=async function(e){try{await e()}catch{}},fa=function(){const e=o(this,he).connection.client;return h(this,U,ma).call(this,()=>e.display.get(),r=>h(this,U,Uh).call(this,r))},v8=function(){const e=o(this,he).connection.client;return h(this,U,ma).call(this,async()=>{const[{channels:r},i]=await Promise.all([e.channels.list(),e.display.get()]);return{channels:r,display:i}},({channels:r,display:i})=>{const s=new Set(r.map(({id:a})=>a));for(const a of o(this,_e).channels.keys())s.has(a)||(this.pendingPageWrites.delete(a),o(this,Ke).delete(a),o(this,_e).channels.delete(a));for(const a of r)o(this,_e).channels.has(a.id)||o(this,_e).channels.set(a.id,{channel:Pa(a),artifacts:new Map});h(this,U,Uh).call(this,i)})},Mm=function(e){const r=o(this,he).connection.client;return h(this,U,ma).call(this,()=>fm(()=>r.channels.get({channelID:e})),i=>h(this,U,Om).call(this,e,i))},y8=function(e){const r=o(this,he).connection.client;return h(this,U,ma).call(this,async()=>{const[i,s]=await Promise.all([fm(()=>r.channels.get({channelID:e})),r.display.get()]);return{detail:i,display:s}},({detail:i,display:s})=>{h(this,U,Om).call(this,e,i),h(this,U,Uh).call(this,s)})},Uh=function(e){o(this,_e).display=Hm(e),o(this,he).connection.acpClient.setEnabled(e.acpEnabled)},Om=function(e,r){this.pendingPageWrites.delete(e);const i=o(this,_e).channels.get(e);if(r===null){o(this,Ke).delete(e),o(this,_e).channels.delete(e);return}Jo(o(this,Ke),e,(i==null?void 0:i.channel.layout)??[],r.channel.layout),o(this,_e).channels.set(e,{channel:Pa(r.channel),artifacts:new Map(r.artifacts.map(s=>[s.id,structuredClone(s)]))})},w8=function(e,r){const i=o(this,he).connection.client;return h(this,U,ma).call(this,()=>fm(()=>i.artifacts.get({artifactID:e})),s=>{const a=Jw(o(this,_e),e)??r;if(s===null){a!==null&&Th(o(this,_e),{type:"artifact-removed",channelID:a,artifactID:e},this.pendingPageWrites,o(this,Ke));return}const l=a===null?void 0:o(this,_e).channels.get(a);l==null||l.artifacts.set(e,structuredClone(s.artifact))})},ma=async function(e,r){const i=o(this,Vr),s=[];o(this,qr).add(s);try{const a=await e();if(o(this,Xt)||i!==o(this,Vr))return;r(a);for(const l of s)Th(o(this,_e),l,this.pendingPageWrites,o(this,Ke));pm(o(this,_e),o(this,Ke)),h(this,U,zr).call(this)}finally{o(this,qr).delete(s)}},b8=async function(){const e=++Ah(this,Vr)._,r=o(this,he).connection,i=r.client,s=[];o(this,qr).add(s);try{const[{channels:a},l]=await Promise.all([i.channels.list(),i.display.get()]),c=await Promise.all(a.map(({id:f})=>i.channels.get({channelID:f})));if(o(this,Xt)||e!==o(this,Vr))return;const u={channels:new Map,display:Hm(l)};for(const f of c)u.channels.set(f.channel.id,{channel:Pa(f.channel),artifacts:new Map(f.artifacts.map(y=>[y.id,structuredClone(y)]))});mk(o(this,Ke),o(this,_e),u);for(const f of s)Th(u,f,this.pendingPageWrites,o(this,Ke));pm(u,o(this,Ke));const p=o(this,Ui)?dk(o(this,_e),u):[];this.pendingPageWrites.clear(),d(this,_e,u),d(this,Ui,!0),r.acpClient.setEnabled(l.acpEnabled),h(this,U,zr).call(this);for(const f of p)this.dispatchEvent(new jw("artifact-content-changed",{artifactID:f}))}catch{}finally{o(this,qr).delete(s)}},zr=function(){o(this,Xt)||(d(this,io,h(this,U,Nm).call(this)),h(this,U,S8).call(this),this.dispatchEvent(new Bt("change")))},Nm=function(){var s;const e=[...o(this,_e).channels.values()].map(a=>vk(a,o(this,Ke).get(a.channel.id))),r=e.find(({id:a})=>a===o(this,_e).display.focusedChannelId)??null,i=o(this,he).connection;return Object.freeze({ready:o(this,Ui),channels:Object.freeze(e),display:yk(o(this,_e).display),focusedChannel:r,connection:Object.freeze({authorizationRequired:i.hasAuthRejected,gateHalted:i.bootState==="halted"||o(this,Kc).call(this),status:i.status,hasEverConnected:i.hasEverConnected,failedReconnectAttempts:i.failedReconnectAttempts,firstConnectError:i.hasEverConnected?null:o(this,he).connectError,nextRetryAt:i.nextRetryAt,upgradeInstructions:pk(((s=i.updateState)==null?void 0:s.desktop)??null)})})},S8=function(){const e=o(this,io).focusedChannel;o(this,he).connection.acpClient.setChannelContext(e?{channelID:e.id,channelName:e.name}:null)},tt=function(){if(o(this,Xt))throw new Error("ApplicationService is disposed")};function dk(n,t){const e=t.display.focusedChannelId;if(e===null||n.display.focusedChannelId!==e)return[];const r=n.channels.get(e),i=t.channels.get(e);if(!r||!i)return[];const s=new Set(Fc(r.channel.layout));return Fc(i.channel.layout).filter(a=>{var l,c;return s.has(a)&&((l=r.artifacts.get(a))==null?void 0:l.kind)==="path"&&((c=i.artifacts.get(a))==null?void 0:c.kind)==="path"})}function pk(n){return n===null?null:Object.freeze({...n})}function fk(){return{channels:new Map,display:Hm(uk)}}function Th(n,t,e,r){switch(t.type){case"channel-created":r.delete(t.channel.id),n.channels.set(t.channel.id,{channel:Pa(t.channel),artifacts:new Map});return;case"channel-updated":{e.delete(t.channel.id);const i=n.channels.get(t.channel.id);if(!i){r.delete(t.channel.id),n.channels.set(t.channel.id,{channel:Pa(t.channel),artifacts:new Map});return}Jo(r,t.channel.id,i.channel.layout,t.channel.layout);const s=new Set(Fc(t.channel.layout));i.channel=Pa(t.channel);for(const a of i.artifacts.keys())s.has(a)||i.artifacts.delete(a);return}case"channel-removed":e.delete(t.channelID),r.delete(t.channelID),n.channels.delete(t.channelID);return;case"channel-changed":n.display.focusedChannelId=t.channelID;return;case"pinned-channels-changed":n.display.pinnedChannelIds=[...t.pinnedChannelIds];return;case"theme-changed":n.display.activeThemeName=t.themeName,n.display.activeThemeColorScheme=t.activeThemeColorScheme,n.display.themeJavaScriptConsentIds=[...t.themeJavaScriptConsentIds];return;case"appearance-changed":n.display.appearanceMode=t.appearanceMode;return;case"artifact-created":{const i=n.channels.get(t.channelID);if(!i)return;const s=e.get(t.channelID);if(s&&(s.previousPages=Yw(s.previousPages,t.artifact.id)),!Fc(i.channel.layout).includes(t.artifact.id)){const a=i.channel.layout,l=Yw(a,t.artifact.id);Jo(r,t.channelID,a,l),i.channel={...i.channel,layout:l}}i.artifacts.set(t.artifact.id,structuredClone(t.artifact));return}case"artifact-updated":for(const i of n.channels.values())if(i.artifacts.has(t.artifact.id)){i.artifacts.set(t.artifact.id,structuredClone(t.artifact));return}return;case"artifact-removed":{const i=n.channels.get(t.channelID);if(!i)return;const s=e.get(t.channelID);s&&(s.previousPages=Dm(s.previousPages,t.artifactID)),i.artifacts.delete(t.artifactID);const a=i.channel.layout,l=Dm(a,t.artifactID);Jo(r,t.channelID,a,l),i.channel={...i.channel,layout:l};return}case"artifact-focus":yd(n,r,t.channelID,t.artifactID);return;case"artifact-content-changed":return;default:return bk(t)}}function mk(n,t,e){var r;for(const i of n.keys())e.channels.has(i)||n.delete(i);for(const[i,s]of e.channels)Jo(n,i,((r=t.channels.get(i))==null?void 0:r.channel.layout)??[],s.channel.layout)}function Jo(n,t,e,r){const i=n.get(t);if(i===void 0)return;if(r.length===0){n.delete(t);return}const s=zm(r,i);if(s!==-1){n.set(t,[...r[s].artifactIds]);return}const a=zm(e,i),l=a===-1?0:Math.min(a,r.length-1);n.set(t,[...r[l].artifactIds])}function yd(n,t,e,r){const i=n.channels.get(e),s=i==null?void 0:i.channel.layout.find(({artifactIds:l})=>l.includes(r));if(!s)return!1;const a=t.get(e);return a&&gk(a,s.artifactIds)?!1:(t.set(e,[...s.artifactIds]),!0)}function pm(n,t){var i,s;const e=n.display.focusedChannelId;if(e===null||t.has(e))return;const r=(s=(i=n.channels.get(e))==null?void 0:i.channel.layout[0])==null?void 0:s.artifactIds[0];r!==void 0&&yd(n,t,e,r)}function zm(n,t){const e=new Set(t);return n.findIndex(r=>r.artifactIds.some(i=>e.has(i)))}function gk(n,t){return n.length===t.length&&n.every((e,r)=>e===t[r])}function vk(n,t){const e=Object.freeze(n.channel.layout.map(l=>Object.freeze({artifactIds:Object.freeze([...l.artifactIds]),geometry:Object.freeze({...l.geometry}),size:Object.freeze({...l.size})}))),r=t===void 0?0:zm(n.channel.layout,t),i=e[r]??e[0]??null,s=Object.freeze([...n.artifacts.values()].map(l=>Object.freeze(structuredClone(l)))),a={id:n.channel.id,name:n.channel.name,pages:e,selectedPage:i,artifacts:s};return Object.freeze(n.channel.onboarding?{...a,onboarding:Object.freeze({...n.channel.onboarding})}:a)}function yk(n){return Object.freeze({focusedChannelId:n.focusedChannelId,pinnedChannelIds:Object.freeze([...n.pinnedChannelIds]),activeThemeName:n.activeThemeName,activeThemeColorScheme:n.activeThemeColorScheme,appearanceMode:n.appearanceMode,themeJavaScriptConsentIds:Object.freeze([...n.themeJavaScriptConsentIds]),acpEnabled:n.acpEnabled})}function Yw(n,t){return Fc(n).includes(t)?Xs(n):[...Xs(n),{artifactIds:[t],geometry:{...d8},size:{...p8}}]}function wk(n){return n instanceof Bl&&n.status!==void 0&&n.status>=ak&&n.status<g8}function Kw(n){return n instanceof Bl&&(n.status===void 0||n.status>=g8&&n.status<ck)}async function fm(n){try{return await n()}catch(t){if(t instanceof Bl&&t.status===lk)return null;throw t}}function Jw(n,t){for(const[e,r]of n.channels)if(r.artifacts.has(t))return e;return null}function Xs(n){return n.map(t=>({artifactIds:[...t.artifactIds],geometry:{...t.geometry},size:{...t.size}}))}function Pa(n){return{id:n.id,name:n.name,layout:Xs(n.layout),...n.onboarding?{onboarding:{...n.onboarding}}:{}}}function Hm(n){return{focusedChannelId:n.focusedChannelId,pinnedChannelIds:[...n.pinnedChannelIds],activeThemeName:n.activeThemeName,activeThemeColorScheme:n.activeThemeColorScheme,appearanceMode:n.appearanceMode,themeJavaScriptConsentIds:[...n.themeJavaScriptConsentIds],acpEnabled:n.acpEnabled}}function bk(n){throw new Error(`Unexpected server event: ${JSON.stringify(n)}`)}function Sk(n,t){var c;const e=n.snapshot,r=e.focusedChannel;if(t==="ArrowLeft"||t==="ArrowRight"){if(r===null||r.selectedPage===null)return!1;const u=r.pages.indexOf(r.selectedPage),p=u+(t==="ArrowLeft"?-1:1),f=(c=r.pages[p])==null?void 0:c.artifactIds[0];return u===-1||f===void 0?!1:(Xw(),n.selectPage(r.id,f),!0)}const i=_k(e),s=r===null?-1:i.indexOf(r.id),a=s+(t==="ArrowUp"?-1:1),l=i[a];return s===-1||l===void 0?!1:(Xw(),n.focusChannel(l).catch(()=>{}),!0)}function _k(n){const t=new Map(n.channels.map(s=>[s.id,s])),e=n.display.pinnedChannelIds.filter(s=>t.has(s)),r=new Set(e),i=n.channels.filter(({id:s})=>!r.has(s)).map(({id:s})=>s).sort((s,a)=>a.localeCompare(s));return[...e,...i]}function Xw(){const n=document.activeElement;n instanceof HTMLElement&&n.blur()}const _8="0123456789ABCDEFGHJKMNPQRSTVWXYZ",wd=32,Ak=16,A8=10,Qw=0xffffffffffff;var Qs;(function(n){n.Base32IncorrectEncoding="B32_ENC_INVALID",n.DecodeTimeInvalidCharacter="DEC_TIME_CHAR",n.DecodeTimeValueMalformed="DEC_TIME_MALFORMED",n.EncodeTimeNegative="ENC_TIME_NEG",n.EncodeTimeSizeExceeded="ENC_TIME_SIZE_EXCEED",n.EncodeTimeValueMalformed="ENC_TIME_MALFORMED",n.PRNGDetectFailure="PRNG_DETECT",n.ULIDInvalid="ULID_INVALID",n.Unexpected="UNEXPECTED",n.UUIDInvalid="UUID_INVALID"})(Qs||(Qs={}));class yc extends Error{constructor(t,e){super(`${e} (${t})`),this.name="ULIDError",this.code=t}}function Ek(n){const t=Math.floor(n()*wd)%wd;return _8.charAt(t)}function kk(n){const t=Tk(),e=t&&(t.crypto||t.msCrypto)||null;if(typeof(e==null?void 0:e.getRandomValues)=="function")return()=>{const r=new Uint8Array(1);return e.getRandomValues(r),r[0]/256};if(typeof(e==null?void 0:e.randomBytes)=="function")return()=>e.randomBytes(1).readUInt8()/256;throw new yc(Qs.PRNGDetectFailure,"Failed to find a reliable PRNG")}function Tk(){return Ik()?self:typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:null}function Ck(n,t){let e="";for(;n>0;n--)e=Ek(t)+e;return e}function Rk(n,t=A8){if(isNaN(n))throw new yc(Qs.EncodeTimeValueMalformed,`Time must be a number: ${n}`);if(n>Qw)throw new yc(Qs.EncodeTimeSizeExceeded,`Cannot encode a time larger than ${Qw}: ${n}`);if(n<0)throw new yc(Qs.EncodeTimeNegative,`Time must be positive: ${n}`);if(Number.isInteger(n)===!1)throw new yc(Qs.EncodeTimeValueMalformed,`Time must be an integer: ${n}`);let e,r="";for(let i=t;i>0;i--)e=n%wd,r=_8.charAt(e)+r,n=(n-e)/wd;return r}function Ik(){return typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope}function N1(n,t){const e=kk(),r=Date.now();return Rk(r,A8)+Ck(Ak,e)}const wc=Rn(),E8=Rn(),k8=Rn(),$k=Rn(),mm=Rn(),xk="store-";function Es(n){return new URL(n).origin}function Pk(){return{authTokens:{}}}var oo,ao,lo;class Dk extends Ei{constructor(e,r,i={}){super();m(this,oo);m(this,ao);m(this,lo);d(this,oo,`${xk}${e}`),d(this,ao,i.storage??Ok());const s=o(this,ao).getItem(o(this,oo));s===null?(d(this,lo,r),o(this,ao).setItem(o(this,oo),JSON.stringify(r))):d(this,lo,Nk(JSON.parse(s),r))}get(){return o(this,lo)}set(e){d(this,lo,e),o(this,ao).setItem(o(this,oo),JSON.stringify(e)),this.dispatchEvent(new Bt("change"))}}oo=new WeakMap,ao=new WeakMap,lo=new WeakMap;function e2(n,t){return n.authTokens[Es(t)]??null}function Lk(n,t,e){return{authTokens:{...n.authTokens,[Es(t)]:e}}}function Mk(n,t){const e=Es(t);if(!(e in n.authTokens))return n;const r={...n.authTokens};return delete r[e],{authTokens:r}}function Ok(){const n=globalThis.localStorage;if(!n)throw new Error("LocalStore: no storage adapter supplied and window.localStorage is unavailable");return n}function Nk(n,t){if(typeof n!="object"||n===null||Array.isArray(n))return t;const e=n.authTokens;if(typeof e!="object"||e===null||Array.isArray(e))return t;const r={};for(const[i,s]of Object.entries(e))if(typeof s=="string")try{r[Es(i)]=s}catch{}return{authTokens:r}}function R(n,t,e){function r(l,c){if(l._zod||Object.defineProperty(l,"_zod",{value:{def:c,constr:a,traits:new Set},enumerable:!1}),l._zod.traits.has(n))return;l._zod.traits.add(n),t(l,c);const u=a.prototype,p=Object.keys(u);for(let f=0;f<p.length;f++){const y=p[f];y in l||(l[y]=u[y].bind(l))}}const i=(e==null?void 0:e.Parent)??Object;class s extends i{}Object.defineProperty(s,"name",{value:n});function a(l){var c;const u=e!=null&&e.Parent?new s:this;r(u,l),(c=u._zod).deferred??(c.deferred=[]);for(const p of u._zod.deferred)p();return u}return Object.defineProperty(a,"init",{value:r}),Object.defineProperty(a,Symbol.hasInstance,{value:l=>{var c,u;return e!=null&&e.Parent&&l instanceof e.Parent?!0:(u=(c=l==null?void 0:l._zod)==null?void 0:c.traits)==null?void 0:u.has(n)}}),Object.defineProperty(a,"name",{value:n}),a}class Da extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class T8 extends Error{constructor(t){super(`Encountered unidirectional transform during encode: ${t}`),this.name="ZodEncodeError"}}const C8={};function ks(n){return C8}function R8(n){const t=Object.values(n).filter(r=>typeof r=="number");return Object.entries(n).filter(([r,i])=>t.indexOf(+r)===-1).map(([r,i])=>i)}function Zm(n,t){return typeof t=="bigint"?t.toString():t}function xp(n){return{get value(){{const t=n();return Object.defineProperty(this,"value",{value:t}),t}}}}function z1(n){return n==null}function H1(n){const t=n.startsWith("^")?1:0,e=n.endsWith("$")?n.length-1:n.length;return n.slice(t,e)}function zk(n,t){const e=(n.toString().split(".")[1]||"").length,r=t.toString();let i=(r.split(".")[1]||"").length;if(i===0&&/\d?e-\d?/.test(r)){const c=r.match(/\d?e-(\d?)/);c!=null&&c[1]&&(i=Number.parseInt(c[1]))}const s=e>i?e:i,a=Number.parseInt(n.toFixed(s).replace(".","")),l=Number.parseInt(t.toFixed(s).replace(".",""));return a%l/10**s}const t2=Symbol("evaluating");function Ae(n,t,e){let r;Object.defineProperty(n,t,{get(){if(r!==t2)return r===void 0&&(r=t2,r=e()),r},set(i){Object.defineProperty(n,t,{value:i})},configurable:!0})}function na(n,t,e){Object.defineProperty(n,t,{value:e,writable:!0,enumerable:!0,configurable:!0})}function $s(...n){const t={};for(const e of n){const r=Object.getOwnPropertyDescriptors(e);Object.assign(t,r)}return Object.defineProperties({},t)}function n2(n){return JSON.stringify(n)}function Hk(n){return n.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}const I8="captureStackTrace"in Error?Error.captureStackTrace:(...n)=>{};function qc(n){return typeof n=="object"&&n!==null&&!Array.isArray(n)}const Zk=xp(()=>{var n;if(typeof navigator<"u"&&((n=navigator==null?void 0:navigator.userAgent)!=null&&n.includes("Cloudflare")))return!1;try{const t=Function;return new t(""),!0}catch{return!1}});function Ll(n){if(qc(n)===!1)return!1;const t=n.constructor;if(t===void 0||typeof t!="function")return!0;const e=t.prototype;return!(qc(e)===!1||Object.prototype.hasOwnProperty.call(e,"isPrototypeOf")===!1)}function $8(n){return Ll(n)?{...n}:Array.isArray(n)?[...n]:n}const Uk=new Set(["string","number","symbol"]);function Ml(n){return n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function xs(n,t,e){const r=new n._zod.constr(t??n._zod.def);return(!t||e!=null&&e.parent)&&(r._zod.parent=n),r}function K(n){const t=n;if(!t)return{};if(typeof t=="string")return{error:()=>t};if((t==null?void 0:t.message)!==void 0){if((t==null?void 0:t.error)!==void 0)throw new Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error=="string"?{...t,error:()=>t.error}:t}function Fk(n){return Object.keys(n).filter(t=>n[t]._zod.optin==="optional"&&n[t]._zod.optout==="optional")}const qk={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function Vk(n,t){const e=n._zod.def,r=e.checks;if(r&&r.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");const s=$s(n._zod.def,{get shape(){const a={};for(const l in t){if(!(l in e.shape))throw new Error(`Unrecognized key: "${l}"`);t[l]&&(a[l]=e.shape[l])}return na(this,"shape",a),a},checks:[]});return xs(n,s)}function Bk(n,t){const e=n._zod.def,r=e.checks;if(r&&r.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");const s=$s(n._zod.def,{get shape(){const a={...n._zod.def.shape};for(const l in t){if(!(l in e.shape))throw new Error(`Unrecognized key: "${l}"`);t[l]&&delete a[l]}return na(this,"shape",a),a},checks:[]});return xs(n,s)}function Wk(n,t){if(!Ll(t))throw new Error("Invalid input to extend: expected a plain object");const e=n._zod.def.checks;if(e&&e.length>0){const s=n._zod.def.shape;for(const a in t)if(Object.getOwnPropertyDescriptor(s,a)!==void 0)throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}const i=$s(n._zod.def,{get shape(){const s={...n._zod.def.shape,...t};return na(this,"shape",s),s}});return xs(n,i)}function jk(n,t){if(!Ll(t))throw new Error("Invalid input to safeExtend: expected a plain object");const e=$s(n._zod.def,{get shape(){const r={...n._zod.def.shape,...t};return na(this,"shape",r),r}});return xs(n,e)}function Gk(n,t){const e=$s(n._zod.def,{get shape(){const r={...n._zod.def.shape,...t._zod.def.shape};return na(this,"shape",r),r},get catchall(){return t._zod.def.catchall},checks:[]});return xs(n,e)}function Yk(n,t,e){const i=t._zod.def.checks;if(i&&i.length>0)throw new Error(".partial() cannot be used on object schemas containing refinements");const a=$s(t._zod.def,{get shape(){const l=t._zod.def.shape,c={...l};if(e)for(const u in e){if(!(u in l))throw new Error(`Unrecognized key: "${u}"`);e[u]&&(c[u]=n?new n({type:"optional",innerType:l[u]}):l[u])}else for(const u in l)c[u]=n?new n({type:"optional",innerType:l[u]}):l[u];return na(this,"shape",c),c},checks:[]});return xs(t,a)}function Kk(n,t,e){const r=$s(t._zod.def,{get shape(){const i=t._zod.def.shape,s={...i};if(e)for(const a in e){if(!(a in s))throw new Error(`Unrecognized key: "${a}"`);e[a]&&(s[a]=new n({type:"nonoptional",innerType:i[a]}))}else for(const a in i)s[a]=new n({type:"nonoptional",innerType:i[a]});return na(this,"shape",s),s}});return xs(t,r)}function Ia(n,t=0){var e;if(n.aborted===!0)return!0;for(let r=t;r<n.issues.length;r++)if(((e=n.issues[r])==null?void 0:e.continue)!==!0)return!0;return!1}function $a(n,t){return t.map(e=>{var r;return(r=e).path??(r.path=[]),e.path.unshift(n),e})}function Ch(n){return typeof n=="string"?n:n==null?void 0:n.message}function Ts(n,t,e){var i,s,a,l,c,u;const r={...n,path:n.path??[]};if(!n.message){const p=Ch((a=(s=(i=n.inst)==null?void 0:i._zod.def)==null?void 0:s.error)==null?void 0:a.call(s,n))??Ch((l=t==null?void 0:t.error)==null?void 0:l.call(t,n))??Ch((c=e.customError)==null?void 0:c.call(e,n))??Ch((u=e.localeError)==null?void 0:u.call(e,n))??"Invalid input";r.message=p}return delete r.inst,delete r.continue,t!=null&&t.reportInput||delete r.input,r}function Z1(n){return Array.isArray(n)?"array":typeof n=="string"?"string":"unknown"}function Vc(...n){const[t,e,r]=n;return typeof t=="string"?{message:t,code:"custom",input:e,inst:r}:{...t}}const x8=(n,t)=>{n.name="$ZodError",Object.defineProperty(n,"_zod",{value:n._zod,enumerable:!1}),Object.defineProperty(n,"issues",{value:t,enumerable:!1}),n.message=JSON.stringify(t,Zm,2),Object.defineProperty(n,"toString",{value:()=>n.message,enumerable:!1})},P8=R("$ZodError",x8),D8=R("$ZodError",x8,{Parent:Error});function Jk(n,t=e=>e.message){const e={},r=[];for(const i of n.issues)i.path.length>0?(e[i.path[0]]=e[i.path[0]]||[],e[i.path[0]].push(t(i))):r.push(t(i));return{formErrors:r,fieldErrors:e}}function Xk(n,t=e=>e.message){const e={_errors:[]},r=i=>{for(const s of i.issues)if(s.code==="invalid_union"&&s.errors.length)s.errors.map(a=>r({issues:a}));else if(s.code==="invalid_key")r({issues:s.issues});else if(s.code==="invalid_element")r({issues:s.issues});else if(s.path.length===0)e._errors.push(t(s));else{let a=e,l=0;for(;l<s.path.length;){const c=s.path[l];l===s.path.length-1?(a[c]=a[c]||{_errors:[]},a[c]._errors.push(t(s))):a[c]=a[c]||{_errors:[]},a=a[c],l++}}};return r(n),e}const U1=n=>(t,e,r,i)=>{const s=r?Object.assign(r,{async:!1}):{async:!1},a=t._zod.run({value:e,issues:[]},s);if(a instanceof Promise)throw new Da;if(a.issues.length){const l=new((i==null?void 0:i.Err)??n)(a.issues.map(c=>Ts(c,s,ks())));throw I8(l,i==null?void 0:i.callee),l}return a.value},F1=n=>async(t,e,r,i)=>{const s=r?Object.assign(r,{async:!0}):{async:!0};let a=t._zod.run({value:e,issues:[]},s);if(a instanceof Promise&&(a=await a),a.issues.length){const l=new((i==null?void 0:i.Err)??n)(a.issues.map(c=>Ts(c,s,ks())));throw I8(l,i==null?void 0:i.callee),l}return a.value},Pp=n=>(t,e,r)=>{const i=r?{...r,async:!1}:{async:!1},s=t._zod.run({value:e,issues:[]},i);if(s instanceof Promise)throw new Da;return s.issues.length?{success:!1,error:new(n??P8)(s.issues.map(a=>Ts(a,i,ks())))}:{success:!0,data:s.value}},Qk=Pp(D8),Dp=n=>async(t,e,r)=>{const i=r?Object.assign(r,{async:!0}):{async:!0};let s=t._zod.run({value:e,issues:[]},i);return s instanceof Promise&&(s=await s),s.issues.length?{success:!1,error:new n(s.issues.map(a=>Ts(a,i,ks())))}:{success:!0,data:s.value}},eT=Dp(D8),tT=n=>(t,e,r)=>{const i=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return U1(n)(t,e,i)},nT=n=>(t,e,r)=>U1(n)(t,e,r),rT=n=>async(t,e,r)=>{const i=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return F1(n)(t,e,i)},iT=n=>async(t,e,r)=>F1(n)(t,e,r),sT=n=>(t,e,r)=>{const i=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return Pp(n)(t,e,i)},oT=n=>(t,e,r)=>Pp(n)(t,e,r),aT=n=>async(t,e,r)=>{const i=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return Dp(n)(t,e,i)},lT=n=>async(t,e,r)=>Dp(n)(t,e,r),cT=/^[cC][^\s-]{8,}$/,uT=/^[0-9a-z]+$/,hT=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,dT=/^[0-9a-vA-V]{20}$/,pT=/^[A-Za-z0-9]{27}$/,fT=/^[a-zA-Z0-9_-]{21}$/,mT=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,gT=/^([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})$/,r2=n=>n?new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${n}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,vT=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,yT="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function wT(){return new RegExp(yT,"u")}const bT=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,ST=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/,_T=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,AT=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,ET=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,L8=/^[A-Za-z0-9_-]*$/,kT=/^\+[1-9]\d{6,14}$/,M8="(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))",TT=new RegExp(`^${M8}$`);function O8(n){const t="(?:[01]\\d|2[0-3]):[0-5]\\d";return typeof n.precision=="number"?n.precision===-1?`${t}`:n.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${n.precision}}`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function CT(n){return new RegExp(`^${O8(n)}$`)}function RT(n){const t=O8({precision:n.precision}),e=["Z"];n.local&&e.push(""),n.offset&&e.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");const r=`${t}(?:${e.join("|")})`;return new RegExp(`^${M8}T(?:${r})$`)}const IT=n=>{const t=n?`[\\s\\S]{${(n==null?void 0:n.minimum)??0},${(n==null?void 0:n.maximum)??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)},$T=/^-?\d+$/,N8=/^-?\d+(?:\.\d+)?$/,xT=/^(?:true|false)$/i,PT=/^[^A-Z]*$/,DT=/^[^a-z]*$/,jt=R("$ZodCheck",(n,t)=>{var e;n._zod??(n._zod={}),n._zod.def=t,(e=n._zod).onattach??(e.onattach=[])}),z8={number:"number",bigint:"bigint",object:"date"},H8=R("$ZodCheckLessThan",(n,t)=>{jt.init(n,t);const e=z8[typeof t.value];n._zod.onattach.push(r=>{const i=r._zod.bag,s=(t.inclusive?i.maximum:i.exclusiveMaximum)??Number.POSITIVE_INFINITY;t.value<s&&(t.inclusive?i.maximum=t.value:i.exclusiveMaximum=t.value)}),n._zod.check=r=>{(t.inclusive?r.value<=t.value:r.value<t.value)||r.issues.push({origin:e,code:"too_big",maximum:typeof t.value=="object"?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:n,continue:!t.abort})}}),Z8=R("$ZodCheckGreaterThan",(n,t)=>{jt.init(n,t);const e=z8[typeof t.value];n._zod.onattach.push(r=>{const i=r._zod.bag,s=(t.inclusive?i.minimum:i.exclusiveMinimum)??Number.NEGATIVE_INFINITY;t.value>s&&(t.inclusive?i.minimum=t.value:i.exclusiveMinimum=t.value)}),n._zod.check=r=>{(t.inclusive?r.value>=t.value:r.value>t.value)||r.issues.push({origin:e,code:"too_small",minimum:typeof t.value=="object"?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:n,continue:!t.abort})}}),LT=R("$ZodCheckMultipleOf",(n,t)=>{jt.init(n,t),n._zod.onattach.push(e=>{var r;(r=e._zod.bag).multipleOf??(r.multipleOf=t.value)}),n._zod.check=e=>{if(typeof e.value!=typeof t.value)throw new Error("Cannot mix number and bigint in multiple_of check.");(typeof e.value=="bigint"?e.value%t.value===BigInt(0):zk(e.value,t.value)===0)||e.issues.push({origin:typeof e.value,code:"not_multiple_of",divisor:t.value,input:e.value,inst:n,continue:!t.abort})}}),MT=R("$ZodCheckNumberFormat",(n,t)=>{var a;jt.init(n,t),t.format=t.format||"float64";const e=(a=t.format)==null?void 0:a.includes("int"),r=e?"int":"number",[i,s]=qk[t.format];n._zod.onattach.push(l=>{const c=l._zod.bag;c.format=t.format,c.minimum=i,c.maximum=s,e&&(c.pattern=$T)}),n._zod.check=l=>{const c=l.value;if(e){if(!Number.isInteger(c)){l.issues.push({expected:r,format:t.format,code:"invalid_type",continue:!1,input:c,inst:n});return}if(!Number.isSafeInteger(c)){c>0?l.issues.push({input:c,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:n,origin:r,inclusive:!0,continue:!t.abort}):l.issues.push({input:c,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:n,origin:r,inclusive:!0,continue:!t.abort});return}}c<i&&l.issues.push({origin:"number",input:c,code:"too_small",minimum:i,inclusive:!0,inst:n,continue:!t.abort}),c>s&&l.issues.push({origin:"number",input:c,code:"too_big",maximum:s,inclusive:!0,inst:n,continue:!t.abort})}}),OT=R("$ZodCheckMaxLength",(n,t)=>{var e;jt.init(n,t),(e=n._zod.def).when??(e.when=r=>{const i=r.value;return!z1(i)&&i.length!==void 0}),n._zod.onattach.push(r=>{const i=r._zod.bag.maximum??Number.POSITIVE_INFINITY;t.maximum<i&&(r._zod.bag.maximum=t.maximum)}),n._zod.check=r=>{const i=r.value;if(i.length<=t.maximum)return;const a=Z1(i);r.issues.push({origin:a,code:"too_big",maximum:t.maximum,inclusive:!0,input:i,inst:n,continue:!t.abort})}}),NT=R("$ZodCheckMinLength",(n,t)=>{var e;jt.init(n,t),(e=n._zod.def).when??(e.when=r=>{const i=r.value;return!z1(i)&&i.length!==void 0}),n._zod.onattach.push(r=>{const i=r._zod.bag.minimum??Number.NEGATIVE_INFINITY;t.minimum>i&&(r._zod.bag.minimum=t.minimum)}),n._zod.check=r=>{const i=r.value;if(i.length>=t.minimum)return;const a=Z1(i);r.issues.push({origin:a,code:"too_small",minimum:t.minimum,inclusive:!0,input:i,inst:n,continue:!t.abort})}}),zT=R("$ZodCheckLengthEquals",(n,t)=>{var e;jt.init(n,t),(e=n._zod.def).when??(e.when=r=>{const i=r.value;return!z1(i)&&i.length!==void 0}),n._zod.onattach.push(r=>{const i=r._zod.bag;i.minimum=t.length,i.maximum=t.length,i.length=t.length}),n._zod.check=r=>{const i=r.value,s=i.length;if(s===t.length)return;const a=Z1(i),l=s>t.length;r.issues.push({origin:a,...l?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:r.value,inst:n,continue:!t.abort})}}),Lp=R("$ZodCheckStringFormat",(n,t)=>{var e,r;jt.init(n,t),n._zod.onattach.push(i=>{const s=i._zod.bag;s.format=t.format,t.pattern&&(s.patterns??(s.patterns=new Set),s.patterns.add(t.pattern))}),t.pattern?(e=n._zod).check??(e.check=i=>{t.pattern.lastIndex=0,!t.pattern.test(i.value)&&i.issues.push({origin:"string",code:"invalid_format",format:t.format,input:i.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:n,continue:!t.abort})}):(r=n._zod).check??(r.check=()=>{})}),HT=R("$ZodCheckRegex",(n,t)=>{Lp.init(n,t),n._zod.check=e=>{t.pattern.lastIndex=0,!t.pattern.test(e.value)&&e.issues.push({origin:"string",code:"invalid_format",format:"regex",input:e.value,pattern:t.pattern.toString(),inst:n,continue:!t.abort})}}),ZT=R("$ZodCheckLowerCase",(n,t)=>{t.pattern??(t.pattern=PT),Lp.init(n,t)}),UT=R("$ZodCheckUpperCase",(n,t)=>{t.pattern??(t.pattern=DT),Lp.init(n,t)}),FT=R("$ZodCheckIncludes",(n,t)=>{jt.init(n,t);const e=Ml(t.includes),r=new RegExp(typeof t.position=="number"?`^.{${t.position}}${e}`:e);t.pattern=r,n._zod.onattach.push(i=>{const s=i._zod.bag;s.patterns??(s.patterns=new Set),s.patterns.add(r)}),n._zod.check=i=>{i.value.includes(t.includes,t.position)||i.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:i.value,inst:n,continue:!t.abort})}}),qT=R("$ZodCheckStartsWith",(n,t)=>{jt.init(n,t);const e=new RegExp(`^${Ml(t.prefix)}.*`);t.pattern??(t.pattern=e),n._zod.onattach.push(r=>{const i=r._zod.bag;i.patterns??(i.patterns=new Set),i.patterns.add(e)}),n._zod.check=r=>{r.value.startsWith(t.prefix)||r.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:r.value,inst:n,continue:!t.abort})}}),VT=R("$ZodCheckEndsWith",(n,t)=>{jt.init(n,t);const e=new RegExp(`.*${Ml(t.suffix)}$`);t.pattern??(t.pattern=e),n._zod.onattach.push(r=>{const i=r._zod.bag;i.patterns??(i.patterns=new Set),i.patterns.add(e)}),n._zod.check=r=>{r.value.endsWith(t.suffix)||r.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:r.value,inst:n,continue:!t.abort})}}),BT=R("$ZodCheckOverwrite",(n,t)=>{jt.init(n,t),n._zod.check=e=>{e.value=t.tx(e.value)}});class WT{constructor(t=[]){this.content=[],this.indent=0,this&&(this.args=t)}indented(t){this.indent+=1,t(this),this.indent-=1}write(t){if(typeof t=="function"){t(this,{execution:"sync"}),t(this,{execution:"async"});return}const r=t.split(`
5
5
  `).filter(a=>a),i=Math.min(...r.map(a=>a.length-a.trimStart().length)),s=r.map(a=>a.slice(i)).map(a=>" ".repeat(this.indent*2)+a);for(const a of s)this.content.push(a)}compile(){const t=Function,e=this==null?void 0:this.args,i=[...((this==null?void 0:this.content)??[""]).map(s=>` ${s}`)];return new t(...e,i.join(`
6
6
  `))}}const jT={major:4,minor:3,patch:6},Ue=R("$ZodType",(n,t)=>{var i;var e;n??(n={}),n._zod.def=t,n._zod.bag=n._zod.bag||{},n._zod.version=jT;const r=[...n._zod.def.checks??[]];n._zod.traits.has("$ZodCheck")&&r.unshift(n);for(const s of r)for(const a of s._zod.onattach)a(n);if(r.length===0)(e=n._zod).deferred??(e.deferred=[]),(i=n._zod.deferred)==null||i.push(()=>{n._zod.run=n._zod.parse});else{const s=(l,c,u)=>{let p=Ia(l),f;for(const y of c){if(y._zod.def.when){if(!y._zod.def.when(l))continue}else if(p)continue;const v=l.issues.length,S=y._zod.check(l);if(S instanceof Promise&&(u==null?void 0:u.async)===!1)throw new Da;if(f||S instanceof Promise)f=(f??Promise.resolve()).then(async()=>{await S,l.issues.length!==v&&(p||(p=Ia(l,v)))});else{if(l.issues.length===v)continue;p||(p=Ia(l,v))}}return f?f.then(()=>l):l},a=(l,c,u)=>{if(Ia(l))return l.aborted=!0,l;const p=s(c,r,u);if(p instanceof Promise){if(u.async===!1)throw new Da;return p.then(f=>n._zod.parse(f,u))}return n._zod.parse(p,u)};n._zod.run=(l,c)=>{if(c.skipChecks)return n._zod.parse(l,c);if(c.direction==="backward"){const p=n._zod.parse({value:l.value,issues:[]},{...c,skipChecks:!0});return p instanceof Promise?p.then(f=>a(f,l,c)):a(p,l,c)}const u=n._zod.parse(l,c);if(u instanceof Promise){if(c.async===!1)throw new Da;return u.then(p=>s(p,r,c))}return s(u,r,c)}}Ae(n,"~standard",()=>({validate:s=>{var a;try{const l=Qk(n,s);return l.success?{value:l.data}:{issues:(a=l.error)==null?void 0:a.issues}}catch{return eT(n,s).then(c=>{var u;return c.success?{value:c.data}:{issues:(u=c.error)==null?void 0:u.issues}})}},vendor:"zod",version:1}))}),q1=R("$ZodString",(n,t)=>{var e;Ue.init(n,t),n._zod.pattern=[...((e=n==null?void 0:n._zod.bag)==null?void 0:e.patterns)??[]].pop()??IT(n._zod.bag),n._zod.parse=(r,i)=>{if(t.coerce)try{r.value=String(r.value)}catch{}return typeof r.value=="string"||r.issues.push({expected:"string",code:"invalid_type",input:r.value,inst:n}),r}}),Oe=R("$ZodStringFormat",(n,t)=>{Lp.init(n,t),q1.init(n,t)}),GT=R("$ZodGUID",(n,t)=>{t.pattern??(t.pattern=gT),Oe.init(n,t)}),YT=R("$ZodUUID",(n,t)=>{if(t.version){const r={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(r===void 0)throw new Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=r2(r))}else t.pattern??(t.pattern=r2());Oe.init(n,t)}),KT=R("$ZodEmail",(n,t)=>{t.pattern??(t.pattern=vT),Oe.init(n,t)}),JT=R("$ZodURL",(n,t)=>{Oe.init(n,t),n._zod.check=e=>{try{const r=e.value.trim(),i=new URL(r);t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(i.hostname)||e.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:t.hostname.source,input:e.value,inst:n,continue:!t.abort})),t.protocol&&(t.protocol.lastIndex=0,t.protocol.test(i.protocol.endsWith(":")?i.protocol.slice(0,-1):i.protocol)||e.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:e.value,inst:n,continue:!t.abort})),t.normalize?e.value=i.href:e.value=r;return}catch{e.issues.push({code:"invalid_format",format:"url",input:e.value,inst:n,continue:!t.abort})}}}),XT=R("$ZodEmoji",(n,t)=>{t.pattern??(t.pattern=wT()),Oe.init(n,t)}),QT=R("$ZodNanoID",(n,t)=>{t.pattern??(t.pattern=fT),Oe.init(n,t)}),eC=R("$ZodCUID",(n,t)=>{t.pattern??(t.pattern=cT),Oe.init(n,t)}),tC=R("$ZodCUID2",(n,t)=>{t.pattern??(t.pattern=uT),Oe.init(n,t)}),nC=R("$ZodULID",(n,t)=>{t.pattern??(t.pattern=hT),Oe.init(n,t)}),rC=R("$ZodXID",(n,t)=>{t.pattern??(t.pattern=dT),Oe.init(n,t)}),iC=R("$ZodKSUID",(n,t)=>{t.pattern??(t.pattern=pT),Oe.init(n,t)}),sC=R("$ZodISODateTime",(n,t)=>{t.pattern??(t.pattern=RT(t)),Oe.init(n,t)}),oC=R("$ZodISODate",(n,t)=>{t.pattern??(t.pattern=TT),Oe.init(n,t)}),aC=R("$ZodISOTime",(n,t)=>{t.pattern??(t.pattern=CT(t)),Oe.init(n,t)}),lC=R("$ZodISODuration",(n,t)=>{t.pattern??(t.pattern=mT),Oe.init(n,t)}),cC=R("$ZodIPv4",(n,t)=>{t.pattern??(t.pattern=bT),Oe.init(n,t),n._zod.bag.format="ipv4"}),uC=R("$ZodIPv6",(n,t)=>{t.pattern??(t.pattern=ST),Oe.init(n,t),n._zod.bag.format="ipv6",n._zod.check=e=>{try{new URL(`http://[${e.value}]`)}catch{e.issues.push({code:"invalid_format",format:"ipv6",input:e.value,inst:n,continue:!t.abort})}}}),hC=R("$ZodCIDRv4",(n,t)=>{t.pattern??(t.pattern=_T),Oe.init(n,t)}),dC=R("$ZodCIDRv6",(n,t)=>{t.pattern??(t.pattern=AT),Oe.init(n,t),n._zod.check=e=>{const r=e.value.split("/");try{if(r.length!==2)throw new Error;const[i,s]=r;if(!s)throw new Error;const a=Number(s);if(`${a}`!==s)throw new Error;if(a<0||a>128)throw new Error;new URL(`http://[${i}]`)}catch{e.issues.push({code:"invalid_format",format:"cidrv6",input:e.value,inst:n,continue:!t.abort})}}});function U8(n){if(n==="")return!0;if(n.length%4!==0)return!1;try{return atob(n),!0}catch{return!1}}const pC=R("$ZodBase64",(n,t)=>{t.pattern??(t.pattern=ET),Oe.init(n,t),n._zod.bag.contentEncoding="base64",n._zod.check=e=>{U8(e.value)||e.issues.push({code:"invalid_format",format:"base64",input:e.value,inst:n,continue:!t.abort})}});function fC(n){if(!L8.test(n))return!1;const t=n.replace(/[-_]/g,r=>r==="-"?"+":"/"),e=t.padEnd(Math.ceil(t.length/4)*4,"=");return U8(e)}const mC=R("$ZodBase64URL",(n,t)=>{t.pattern??(t.pattern=L8),Oe.init(n,t),n._zod.bag.contentEncoding="base64url",n._zod.check=e=>{fC(e.value)||e.issues.push({code:"invalid_format",format:"base64url",input:e.value,inst:n,continue:!t.abort})}}),gC=R("$ZodE164",(n,t)=>{t.pattern??(t.pattern=kT),Oe.init(n,t)});function vC(n,t=null){try{const e=n.split(".");if(e.length!==3)return!1;const[r]=e;if(!r)return!1;const i=JSON.parse(atob(r));return!("typ"in i&&(i==null?void 0:i.typ)!=="JWT"||!i.alg||t&&(!("alg"in i)||i.alg!==t))}catch{return!1}}const yC=R("$ZodJWT",(n,t)=>{Oe.init(n,t),n._zod.check=e=>{vC(e.value,t.alg)||e.issues.push({code:"invalid_format",format:"jwt",input:e.value,inst:n,continue:!t.abort})}}),F8=R("$ZodNumber",(n,t)=>{Ue.init(n,t),n._zod.pattern=n._zod.bag.pattern??N8,n._zod.parse=(e,r)=>{if(t.coerce)try{e.value=Number(e.value)}catch{}const i=e.value;if(typeof i=="number"&&!Number.isNaN(i)&&Number.isFinite(i))return e;const s=typeof i=="number"?Number.isNaN(i)?"NaN":Number.isFinite(i)?void 0:"Infinity":void 0;return e.issues.push({expected:"number",code:"invalid_type",input:i,inst:n,...s?{received:s}:{}}),e}}),wC=R("$ZodNumberFormat",(n,t)=>{MT.init(n,t),F8.init(n,t)}),bC=R("$ZodBoolean",(n,t)=>{Ue.init(n,t),n._zod.pattern=xT,n._zod.parse=(e,r)=>{if(t.coerce)try{e.value=!!e.value}catch{}const i=e.value;return typeof i=="boolean"||e.issues.push({expected:"boolean",code:"invalid_type",input:i,inst:n}),e}}),SC=R("$ZodUnknown",(n,t)=>{Ue.init(n,t),n._zod.parse=e=>e}),_C=R("$ZodNever",(n,t)=>{Ue.init(n,t),n._zod.parse=(e,r)=>(e.issues.push({expected:"never",code:"invalid_type",input:e.value,inst:n}),e)});function i2(n,t,e){n.issues.length&&t.issues.push(...$a(e,n.issues)),t.value[e]=n.value}const AC=R("$ZodArray",(n,t)=>{Ue.init(n,t),n._zod.parse=(e,r)=>{const i=e.value;if(!Array.isArray(i))return e.issues.push({expected:"array",code:"invalid_type",input:i,inst:n}),e;e.value=Array(i.length);const s=[];for(let a=0;a<i.length;a++){const l=i[a],c=t.element._zod.run({value:l,issues:[]},r);c instanceof Promise?s.push(c.then(u=>i2(u,e,a))):i2(c,e,a)}return s.length?Promise.all(s).then(()=>e):e}});function bd(n,t,e,r,i){if(n.issues.length){if(i&&!(e in r))return;t.issues.push(...$a(e,n.issues))}n.value===void 0?e in r&&(t.value[e]=void 0):t.value[e]=n.value}function q8(n){var r,i,s,a;const t=Object.keys(n.shape);for(const l of t)if(!((a=(s=(i=(r=n.shape)==null?void 0:r[l])==null?void 0:i._zod)==null?void 0:s.traits)!=null&&a.has("$ZodType")))throw new Error(`Invalid element at key "${l}": expected a Zod schema`);const e=Fk(n.shape);return{...n,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(e)}}function V8(n,t,e,r,i,s){const a=[],l=i.keySet,c=i.catchall._zod,u=c.def.type,p=c.optout==="optional";for(const f in t){if(l.has(f))continue;if(u==="never"){a.push(f);continue}const y=c.run({value:t[f],issues:[]},r);y instanceof Promise?n.push(y.then(v=>bd(v,e,f,t,p))):bd(y,e,f,t,p)}return a.length&&e.issues.push({code:"unrecognized_keys",keys:a,input:t,inst:s}),n.length?Promise.all(n).then(()=>e):e}const EC=R("$ZodObject",(n,t)=>{Ue.init(n,t);const e=Object.getOwnPropertyDescriptor(t,"shape");if(!(e!=null&&e.get)){const l=t.shape;Object.defineProperty(t,"shape",{get:()=>{const c={...l};return Object.defineProperty(t,"shape",{value:c}),c}})}const r=xp(()=>q8(t));Ae(n._zod,"propValues",()=>{const l=t.shape,c={};for(const u in l){const p=l[u]._zod;if(p.values){c[u]??(c[u]=new Set);for(const f of p.values)c[u].add(f)}}return c});const i=qc,s=t.catchall;let a;n._zod.parse=(l,c)=>{a??(a=r.value);const u=l.value;if(!i(u))return l.issues.push({expected:"object",code:"invalid_type",input:u,inst:n}),l;l.value={};const p=[],f=a.shape;for(const y of a.keys){const v=f[y],S=v._zod.optout==="optional",_=v._zod.run({value:u[y],issues:[]},c);_ instanceof Promise?p.push(_.then(I=>bd(I,l,y,u,S))):bd(_,l,y,u,S)}return s?V8(p,u,l,c,r.value,n):p.length?Promise.all(p).then(()=>l):l}}),kC=R("$ZodObjectJIT",(n,t)=>{EC.init(n,t);const e=n._zod.parse,r=xp(()=>q8(t)),i=y=>{var z;const v=new WT(["shape","payload","ctx"]),S=r.value,_=P=>{const B=n2(P);return`shape[${B}]._zod.run({ value: input[${B}], issues: [] }, ctx)`};v.write("const input = payload.value;");const I=Object.create(null);let Z=0;for(const P of S.keys)I[P]=`key_${Z++}`;v.write("const newResult = {};");for(const P of S.keys){const B=I[P],F=n2(P),q=y[P],Q=((z=q==null?void 0:q._zod)==null?void 0:z.optout)==="optional";v.write(`const ${B} = ${_(P)};`),Q?v.write(`
7
7
  if (${B}.issues.length) {
@@ -40,7 +40,7 @@ var J4=Object.defineProperty;var kv=n=>{throw TypeError(n)};var X4=(n,t,e)=>t in
40
40
  `)}v.write("payload.value = newResult;"),v.write("return payload;");const L=v.compile();return(P,B)=>L(y,P,B)};let s;const a=qc,l=!C8.jitless,u=l&&Zk.value,p=t.catchall;let f;n._zod.parse=(y,v)=>{f??(f=r.value);const S=y.value;return a(S)?l&&u&&(v==null?void 0:v.async)===!1&&v.jitless!==!0?(s||(s=i(t.shape)),y=s(y,v),p?V8([],S,y,v,f,n):y):e(y,v):(y.issues.push({expected:"object",code:"invalid_type",input:S,inst:n}),y)}});function s2(n,t,e,r){for(const s of n)if(s.issues.length===0)return t.value=s.value,t;const i=n.filter(s=>!Ia(s));return i.length===1?(t.value=i[0].value,i[0]):(t.issues.push({code:"invalid_union",input:t.value,inst:e,errors:n.map(s=>s.issues.map(a=>Ts(a,r,ks())))}),t)}const B8=R("$ZodUnion",(n,t)=>{Ue.init(n,t),Ae(n._zod,"optin",()=>t.options.some(i=>i._zod.optin==="optional")?"optional":void 0),Ae(n._zod,"optout",()=>t.options.some(i=>i._zod.optout==="optional")?"optional":void 0),Ae(n._zod,"values",()=>{if(t.options.every(i=>i._zod.values))return new Set(t.options.flatMap(i=>Array.from(i._zod.values)))}),Ae(n._zod,"pattern",()=>{if(t.options.every(i=>i._zod.pattern)){const i=t.options.map(s=>s._zod.pattern);return new RegExp(`^(${i.map(s=>H1(s.source)).join("|")})$`)}});const e=t.options.length===1,r=t.options[0]._zod.run;n._zod.parse=(i,s)=>{if(e)return r(i,s);let a=!1;const l=[];for(const c of t.options){const u=c._zod.run({value:i.value,issues:[]},s);if(u instanceof Promise)l.push(u),a=!0;else{if(u.issues.length===0)return u;l.push(u)}}return a?Promise.all(l).then(c=>s2(c,i,n,s)):s2(l,i,n,s)}}),TC=R("$ZodDiscriminatedUnion",(n,t)=>{t.inclusive=!1,B8.init(n,t);const e=n._zod.parse;Ae(n._zod,"propValues",()=>{const i={};for(const s of t.options){const a=s._zod.propValues;if(!a||Object.keys(a).length===0)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(s)}"`);for(const[l,c]of Object.entries(a)){i[l]||(i[l]=new Set);for(const u of c)i[l].add(u)}}return i});const r=xp(()=>{var a;const i=t.options,s=new Map;for(const l of i){const c=(a=l._zod.propValues)==null?void 0:a[t.discriminator];if(!c||c.size===0)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(l)}"`);for(const u of c){if(s.has(u))throw new Error(`Duplicate discriminator value "${String(u)}"`);s.set(u,l)}}return s});n._zod.parse=(i,s)=>{const a=i.value;if(!qc(a))return i.issues.push({code:"invalid_type",expected:"object",input:a,inst:n}),i;const l=r.value.get(a==null?void 0:a[t.discriminator]);return l?l._zod.run(i,s):t.unionFallback?e(i,s):(i.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:t.discriminator,input:a,path:[t.discriminator],inst:n}),i)}}),CC=R("$ZodIntersection",(n,t)=>{Ue.init(n,t),n._zod.parse=(e,r)=>{const i=e.value,s=t.left._zod.run({value:i,issues:[]},r),a=t.right._zod.run({value:i,issues:[]},r);return s instanceof Promise||a instanceof Promise?Promise.all([s,a]).then(([c,u])=>o2(e,c,u)):o2(e,s,a)}});function Um(n,t){if(n===t)return{valid:!0,data:n};if(n instanceof Date&&t instanceof Date&&+n==+t)return{valid:!0,data:n};if(Ll(n)&&Ll(t)){const e=Object.keys(t),r=Object.keys(n).filter(s=>e.indexOf(s)!==-1),i={...n,...t};for(const s of r){const a=Um(n[s],t[s]);if(!a.valid)return{valid:!1,mergeErrorPath:[s,...a.mergeErrorPath]};i[s]=a.data}return{valid:!0,data:i}}if(Array.isArray(n)&&Array.isArray(t)){if(n.length!==t.length)return{valid:!1,mergeErrorPath:[]};const e=[];for(let r=0;r<n.length;r++){const i=n[r],s=t[r],a=Um(i,s);if(!a.valid)return{valid:!1,mergeErrorPath:[r,...a.mergeErrorPath]};e.push(a.data)}return{valid:!0,data:e}}return{valid:!1,mergeErrorPath:[]}}function o2(n,t,e){const r=new Map;let i;for(const l of t.issues)if(l.code==="unrecognized_keys"){i??(i=l);for(const c of l.keys)r.has(c)||r.set(c,{}),r.get(c).l=!0}else n.issues.push(l);for(const l of e.issues)if(l.code==="unrecognized_keys")for(const c of l.keys)r.has(c)||r.set(c,{}),r.get(c).r=!0;else n.issues.push(l);const s=[...r].filter(([,l])=>l.l&&l.r).map(([l])=>l);if(s.length&&i&&n.issues.push({...i,keys:s}),Ia(n))return n;const a=Um(t.value,e.value);if(!a.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(a.mergeErrorPath)}`);return n.value=a.data,n}const RC=R("$ZodRecord",(n,t)=>{Ue.init(n,t),n._zod.parse=(e,r)=>{const i=e.value;if(!Ll(i))return e.issues.push({expected:"record",code:"invalid_type",input:i,inst:n}),e;const s=[],a=t.keyType._zod.values;if(a){e.value={};const l=new Set;for(const u of a)if(typeof u=="string"||typeof u=="number"||typeof u=="symbol"){l.add(typeof u=="number"?u.toString():u);const p=t.valueType._zod.run({value:i[u],issues:[]},r);p instanceof Promise?s.push(p.then(f=>{f.issues.length&&e.issues.push(...$a(u,f.issues)),e.value[u]=f.value})):(p.issues.length&&e.issues.push(...$a(u,p.issues)),e.value[u]=p.value)}let c;for(const u in i)l.has(u)||(c=c??[],c.push(u));c&&c.length>0&&e.issues.push({code:"unrecognized_keys",input:i,inst:n,keys:c})}else{e.value={};for(const l of Reflect.ownKeys(i)){if(l==="__proto__")continue;let c=t.keyType._zod.run({value:l,issues:[]},r);if(c instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(typeof l=="string"&&N8.test(l)&&c.issues.length){const f=t.keyType._zod.run({value:Number(l),issues:[]},r);if(f instanceof Promise)throw new Error("Async schemas not supported in object keys currently");f.issues.length===0&&(c=f)}if(c.issues.length){t.mode==="loose"?e.value[l]=i[l]:e.issues.push({code:"invalid_key",origin:"record",issues:c.issues.map(f=>Ts(f,r,ks())),input:l,path:[l],inst:n});continue}const p=t.valueType._zod.run({value:i[l],issues:[]},r);p instanceof Promise?s.push(p.then(f=>{f.issues.length&&e.issues.push(...$a(l,f.issues)),e.value[c.value]=f.value})):(p.issues.length&&e.issues.push(...$a(l,p.issues)),e.value[c.value]=p.value)}}return s.length?Promise.all(s).then(()=>e):e}}),IC=R("$ZodEnum",(n,t)=>{Ue.init(n,t);const e=R8(t.entries),r=new Set(e);n._zod.values=r,n._zod.pattern=new RegExp(`^(${e.filter(i=>Uk.has(typeof i)).map(i=>typeof i=="string"?Ml(i):i.toString()).join("|")})$`),n._zod.parse=(i,s)=>{const a=i.value;return r.has(a)||i.issues.push({code:"invalid_value",values:e,input:a,inst:n}),i}}),$C=R("$ZodLiteral",(n,t)=>{if(Ue.init(n,t),t.values.length===0)throw new Error("Cannot create literal schema with no valid values");const e=new Set(t.values);n._zod.values=e,n._zod.pattern=new RegExp(`^(${t.values.map(r=>typeof r=="string"?Ml(r):r?Ml(r.toString()):String(r)).join("|")})$`),n._zod.parse=(r,i)=>{const s=r.value;return e.has(s)||r.issues.push({code:"invalid_value",values:t.values,input:s,inst:n}),r}}),xC=R("$ZodTransform",(n,t)=>{Ue.init(n,t),n._zod.parse=(e,r)=>{if(r.direction==="backward")throw new T8(n.constructor.name);const i=t.transform(e.value,e);if(r.async)return(i instanceof Promise?i:Promise.resolve(i)).then(a=>(e.value=a,e));if(i instanceof Promise)throw new Da;return e.value=i,e}});function a2(n,t){return n.issues.length&&t===void 0?{issues:[],value:void 0}:n}const W8=R("$ZodOptional",(n,t)=>{Ue.init(n,t),n._zod.optin="optional",n._zod.optout="optional",Ae(n._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),Ae(n._zod,"pattern",()=>{const e=t.innerType._zod.pattern;return e?new RegExp(`^(${H1(e.source)})?$`):void 0}),n._zod.parse=(e,r)=>{if(t.innerType._zod.optin==="optional"){const i=t.innerType._zod.run(e,r);return i instanceof Promise?i.then(s=>a2(s,e.value)):a2(i,e.value)}return e.value===void 0?e:t.innerType._zod.run(e,r)}}),PC=R("$ZodExactOptional",(n,t)=>{W8.init(n,t),Ae(n._zod,"values",()=>t.innerType._zod.values),Ae(n._zod,"pattern",()=>t.innerType._zod.pattern),n._zod.parse=(e,r)=>t.innerType._zod.run(e,r)}),DC=R("$ZodNullable",(n,t)=>{Ue.init(n,t),Ae(n._zod,"optin",()=>t.innerType._zod.optin),Ae(n._zod,"optout",()=>t.innerType._zod.optout),Ae(n._zod,"pattern",()=>{const e=t.innerType._zod.pattern;return e?new RegExp(`^(${H1(e.source)}|null)$`):void 0}),Ae(n._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),n._zod.parse=(e,r)=>e.value===null?e:t.innerType._zod.run(e,r)}),LC=R("$ZodDefault",(n,t)=>{Ue.init(n,t),n._zod.optin="optional",Ae(n._zod,"values",()=>t.innerType._zod.values),n._zod.parse=(e,r)=>{if(r.direction==="backward")return t.innerType._zod.run(e,r);if(e.value===void 0)return e.value=t.defaultValue,e;const i=t.innerType._zod.run(e,r);return i instanceof Promise?i.then(s=>l2(s,t)):l2(i,t)}});function l2(n,t){return n.value===void 0&&(n.value=t.defaultValue),n}const MC=R("$ZodPrefault",(n,t)=>{Ue.init(n,t),n._zod.optin="optional",Ae(n._zod,"values",()=>t.innerType._zod.values),n._zod.parse=(e,r)=>(r.direction==="backward"||e.value===void 0&&(e.value=t.defaultValue),t.innerType._zod.run(e,r))}),OC=R("$ZodNonOptional",(n,t)=>{Ue.init(n,t),Ae(n._zod,"values",()=>{const e=t.innerType._zod.values;return e?new Set([...e].filter(r=>r!==void 0)):void 0}),n._zod.parse=(e,r)=>{const i=t.innerType._zod.run(e,r);return i instanceof Promise?i.then(s=>c2(s,n)):c2(i,n)}});function c2(n,t){return!n.issues.length&&n.value===void 0&&n.issues.push({code:"invalid_type",expected:"nonoptional",input:n.value,inst:t}),n}const NC=R("$ZodCatch",(n,t)=>{Ue.init(n,t),Ae(n._zod,"optin",()=>t.innerType._zod.optin),Ae(n._zod,"optout",()=>t.innerType._zod.optout),Ae(n._zod,"values",()=>t.innerType._zod.values),n._zod.parse=(e,r)=>{if(r.direction==="backward")return t.innerType._zod.run(e,r);const i=t.innerType._zod.run(e,r);return i instanceof Promise?i.then(s=>(e.value=s.value,s.issues.length&&(e.value=t.catchValue({...e,error:{issues:s.issues.map(a=>Ts(a,r,ks()))},input:e.value}),e.issues=[]),e)):(e.value=i.value,i.issues.length&&(e.value=t.catchValue({...e,error:{issues:i.issues.map(s=>Ts(s,r,ks()))},input:e.value}),e.issues=[]),e)}}),zC=R("$ZodPipe",(n,t)=>{Ue.init(n,t),Ae(n._zod,"values",()=>t.in._zod.values),Ae(n._zod,"optin",()=>t.in._zod.optin),Ae(n._zod,"optout",()=>t.out._zod.optout),Ae(n._zod,"propValues",()=>t.in._zod.propValues),n._zod.parse=(e,r)=>{if(r.direction==="backward"){const s=t.out._zod.run(e,r);return s instanceof Promise?s.then(a=>Rh(a,t.in,r)):Rh(s,t.in,r)}const i=t.in._zod.run(e,r);return i instanceof Promise?i.then(s=>Rh(s,t.out,r)):Rh(i,t.out,r)}});function Rh(n,t,e){return n.issues.length?(n.aborted=!0,n):t._zod.run({value:n.value,issues:n.issues},e)}const HC=R("$ZodReadonly",(n,t)=>{Ue.init(n,t),Ae(n._zod,"propValues",()=>t.innerType._zod.propValues),Ae(n._zod,"values",()=>t.innerType._zod.values),Ae(n._zod,"optin",()=>{var e,r;return(r=(e=t.innerType)==null?void 0:e._zod)==null?void 0:r.optin}),Ae(n._zod,"optout",()=>{var e,r;return(r=(e=t.innerType)==null?void 0:e._zod)==null?void 0:r.optout}),n._zod.parse=(e,r)=>{if(r.direction==="backward")return t.innerType._zod.run(e,r);const i=t.innerType._zod.run(e,r);return i instanceof Promise?i.then(u2):u2(i)}});function u2(n){return n.value=Object.freeze(n.value),n}const ZC=R("$ZodCustom",(n,t)=>{jt.init(n,t),Ue.init(n,t),n._zod.parse=(e,r)=>e,n._zod.check=e=>{const r=e.value,i=t.fn(r);if(i instanceof Promise)return i.then(s=>h2(s,e,r,n));h2(i,e,r,n)}});function h2(n,t,e,r){if(!n){const i={code:"custom",input:e,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(i.params=r._zod.def.params),t.issues.push(Vc(i))}}var d2;class UC{constructor(){this._map=new WeakMap,this._idmap=new Map}add(t,...e){const r=e[0];return this._map.set(t,r),r&&typeof r=="object"&&"id"in r&&this._idmap.set(r.id,t),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(t){const e=this._map.get(t);return e&&typeof e=="object"&&"id"in e&&this._idmap.delete(e.id),this._map.delete(t),this}get(t){const e=t._zod.parent;if(e){const r={...this.get(e)??{}};delete r.id;const i={...r,...this._map.get(t)};return Object.keys(i).length?i:void 0}return this._map.get(t)}has(t){return this._map.has(t)}}function FC(){return new UC}(d2=globalThis).__zod_globalRegistry??(d2.__zod_globalRegistry=FC());const bc=globalThis.__zod_globalRegistry;function qC(n,t){return new n({type:"string",...K(t)})}function VC(n,t){return new n({type:"string",format:"email",check:"string_format",abort:!1,...K(t)})}function p2(n,t){return new n({type:"string",format:"guid",check:"string_format",abort:!1,...K(t)})}function BC(n,t){return new n({type:"string",format:"uuid",check:"string_format",abort:!1,...K(t)})}function WC(n,t){return new n({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...K(t)})}function jC(n,t){return new n({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...K(t)})}function GC(n,t){return new n({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...K(t)})}function YC(n,t){return new n({type:"string",format:"url",check:"string_format",abort:!1,...K(t)})}function KC(n,t){return new n({type:"string",format:"emoji",check:"string_format",abort:!1,...K(t)})}function JC(n,t){return new n({type:"string",format:"nanoid",check:"string_format",abort:!1,...K(t)})}function XC(n,t){return new n({type:"string",format:"cuid",check:"string_format",abort:!1,...K(t)})}function QC(n,t){return new n({type:"string",format:"cuid2",check:"string_format",abort:!1,...K(t)})}function eR(n,t){return new n({type:"string",format:"ulid",check:"string_format",abort:!1,...K(t)})}function tR(n,t){return new n({type:"string",format:"xid",check:"string_format",abort:!1,...K(t)})}function nR(n,t){return new n({type:"string",format:"ksuid",check:"string_format",abort:!1,...K(t)})}function rR(n,t){return new n({type:"string",format:"ipv4",check:"string_format",abort:!1,...K(t)})}function iR(n,t){return new n({type:"string",format:"ipv6",check:"string_format",abort:!1,...K(t)})}function sR(n,t){return new n({type:"string",format:"cidrv4",check:"string_format",abort:!1,...K(t)})}function oR(n,t){return new n({type:"string",format:"cidrv6",check:"string_format",abort:!1,...K(t)})}function aR(n,t){return new n({type:"string",format:"base64",check:"string_format",abort:!1,...K(t)})}function lR(n,t){return new n({type:"string",format:"base64url",check:"string_format",abort:!1,...K(t)})}function cR(n,t){return new n({type:"string",format:"e164",check:"string_format",abort:!1,...K(t)})}function uR(n,t){return new n({type:"string",format:"jwt",check:"string_format",abort:!1,...K(t)})}function hR(n,t){return new n({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...K(t)})}function dR(n,t){return new n({type:"string",format:"date",check:"string_format",...K(t)})}function pR(n,t){return new n({type:"string",format:"time",check:"string_format",precision:null,...K(t)})}function fR(n,t){return new n({type:"string",format:"duration",check:"string_format",...K(t)})}function mR(n,t){return new n({type:"number",checks:[],...K(t)})}function gR(n,t){return new n({type:"number",check:"number_format",abort:!1,format:"safeint",...K(t)})}function vR(n,t){return new n({type:"boolean",...K(t)})}function yR(n){return new n({type:"unknown"})}function wR(n,t){return new n({type:"never",...K(t)})}function f2(n,t){return new H8({check:"less_than",...K(t),value:n,inclusive:!1})}function gm(n,t){return new H8({check:"less_than",...K(t),value:n,inclusive:!0})}function m2(n,t){return new Z8({check:"greater_than",...K(t),value:n,inclusive:!1})}function vm(n,t){return new Z8({check:"greater_than",...K(t),value:n,inclusive:!0})}function g2(n,t){return new LT({check:"multiple_of",...K(t),value:n})}function j8(n,t){return new OT({check:"max_length",...K(t),maximum:n})}function Sd(n,t){return new NT({check:"min_length",...K(t),minimum:n})}function G8(n,t){return new zT({check:"length_equals",...K(t),length:n})}function bR(n,t){return new HT({check:"string_format",format:"regex",...K(t),pattern:n})}function SR(n){return new ZT({check:"string_format",format:"lowercase",...K(n)})}function _R(n){return new UT({check:"string_format",format:"uppercase",...K(n)})}function AR(n,t){return new FT({check:"string_format",format:"includes",...K(t),includes:n})}function ER(n,t){return new qT({check:"string_format",format:"starts_with",...K(t),prefix:n})}function kR(n,t){return new VT({check:"string_format",format:"ends_with",...K(t),suffix:n})}function Wl(n){return new BT({check:"overwrite",tx:n})}function TR(n){return Wl(t=>t.normalize(n))}function CR(){return Wl(n=>n.trim())}function RR(){return Wl(n=>n.toLowerCase())}function IR(){return Wl(n=>n.toUpperCase())}function $R(){return Wl(n=>Hk(n))}function xR(n,t,e){return new n({type:"array",element:t,...K(e)})}function PR(n,t,e){return new n({type:"custom",check:"custom",fn:t,...K(e)})}function DR(n){const t=LR(e=>(e.addIssue=r=>{if(typeof r=="string")e.issues.push(Vc(r,e.value,t._zod.def));else{const i=r;i.fatal&&(i.continue=!1),i.code??(i.code="custom"),i.input??(i.input=e.value),i.inst??(i.inst=t),i.continue??(i.continue=!t._zod.def.abort),e.issues.push(Vc(i))}},n(e.value,e)));return t}function LR(n,t){const e=new jt({check:"custom",...K(t)});return e._zod.check=n,e}function Y8(n){let t=(n==null?void 0:n.target)??"draft-2020-12";return t==="draft-4"&&(t="draft-04"),t==="draft-7"&&(t="draft-07"),{processors:n.processors??{},metadataRegistry:(n==null?void 0:n.metadata)??bc,target:t,unrepresentable:(n==null?void 0:n.unrepresentable)??"throw",override:(n==null?void 0:n.override)??(()=>{}),io:(n==null?void 0:n.io)??"output",counter:0,seen:new Map,cycles:(n==null?void 0:n.cycles)??"ref",reused:(n==null?void 0:n.reused)??"inline",external:(n==null?void 0:n.external)??void 0}}function Xe(n,t,e={path:[],schemaPath:[]}){var p,f;var r;const i=n._zod.def,s=t.seen.get(n);if(s)return s.count++,e.schemaPath.includes(n)&&(s.cycle=e.path),s.schema;const a={schema:{},count:1,cycle:void 0,path:e.path};t.seen.set(n,a);const l=(f=(p=n._zod).toJSONSchema)==null?void 0:f.call(p);if(l)a.schema=l;else{const y={...e,schemaPath:[...e.schemaPath,n],path:e.path};if(n._zod.processJSONSchema)n._zod.processJSONSchema(t,a.schema,y);else{const S=a.schema,_=t.processors[i.type];if(!_)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${i.type}`);_(n,t,S,y)}const v=n._zod.parent;v&&(a.ref||(a.ref=v),Xe(v,t,y),t.seen.get(v).isParent=!0)}const c=t.metadataRegistry.get(n);return c&&Object.assign(a.schema,c),t.io==="input"&&At(n)&&(delete a.schema.examples,delete a.schema.default),t.io==="input"&&a.schema._prefault&&((r=a.schema).default??(r.default=a.schema._prefault)),delete a.schema._prefault,t.seen.get(n).schema}function K8(n,t){var a,l,c,u;const e=n.seen.get(t);if(!e)throw new Error("Unprocessed schema. This is a bug in Zod.");const r=new Map;for(const p of n.seen.entries()){const f=(a=n.metadataRegistry.get(p[0]))==null?void 0:a.id;if(f){const y=r.get(f);if(y&&y!==p[0])throw new Error(`Duplicate schema id "${f}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);r.set(f,p[0])}}const i=p=>{var _;const f=n.target==="draft-2020-12"?"$defs":"definitions";if(n.external){const I=(_=n.external.registry.get(p[0]))==null?void 0:_.id,Z=n.external.uri??(z=>z);if(I)return{ref:Z(I)};const L=p[1].defId??p[1].schema.id??`schema${n.counter++}`;return p[1].defId=L,{defId:L,ref:`${Z("__shared")}#/${f}/${L}`}}if(p[1]===e)return{ref:"#"};const v=`#/${f}/`,S=p[1].schema.id??`__schema${n.counter++}`;return{defId:S,ref:v+S}},s=p=>{if(p[1].schema.$ref)return;const f=p[1],{ref:y,defId:v}=i(p);f.def={...f.schema},v&&(f.defId=v);const S=f.schema;for(const _ in S)delete S[_];S.$ref=y};if(n.cycles==="throw")for(const p of n.seen.entries()){const f=p[1];if(f.cycle)throw new Error(`Cycle detected: #/${(l=f.cycle)==null?void 0:l.join("/")}/<root>
41
41
 
42
42
  Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(const p of n.seen.entries()){const f=p[1];if(t===p[0]){s(p);continue}if(n.external){const v=(c=n.external.registry.get(p[0]))==null?void 0:c.id;if(t!==p[0]&&v){s(p);continue}}if((u=n.metadataRegistry.get(p[0]))==null?void 0:u.id){s(p);continue}if(f.cycle){s(p);continue}if(f.count>1&&n.reused==="ref"){s(p);continue}}}function J8(n,t){var a,l,c;const e=n.seen.get(t);if(!e)throw new Error("Unprocessed schema. This is a bug in Zod.");const r=u=>{const p=n.seen.get(u);if(p.ref===null)return;const f=p.def??p.schema,y={...f},v=p.ref;if(p.ref=null,v){r(v);const _=n.seen.get(v),I=_.schema;if(I.$ref&&(n.target==="draft-07"||n.target==="draft-04"||n.target==="openapi-3.0")?(f.allOf=f.allOf??[],f.allOf.push(I)):Object.assign(f,I),Object.assign(f,y),u._zod.parent===v)for(const L in f)L==="$ref"||L==="allOf"||L in y||delete f[L];if(I.$ref&&_.def)for(const L in f)L==="$ref"||L==="allOf"||L in _.def&&JSON.stringify(f[L])===JSON.stringify(_.def[L])&&delete f[L]}const S=u._zod.parent;if(S&&S!==v){r(S);const _=n.seen.get(S);if(_!=null&&_.schema.$ref&&(f.$ref=_.schema.$ref,_.def))for(const I in f)I==="$ref"||I==="allOf"||I in _.def&&JSON.stringify(f[I])===JSON.stringify(_.def[I])&&delete f[I]}n.override({zodSchema:u,jsonSchema:f,path:p.path??[]})};for(const u of[...n.seen.entries()].reverse())r(u[0]);const i={};if(n.target==="draft-2020-12"?i.$schema="https://json-schema.org/draft/2020-12/schema":n.target==="draft-07"?i.$schema="http://json-schema.org/draft-07/schema#":n.target==="draft-04"?i.$schema="http://json-schema.org/draft-04/schema#":n.target,(a=n.external)!=null&&a.uri){const u=(l=n.external.registry.get(t))==null?void 0:l.id;if(!u)throw new Error("Schema is missing an `id` property");i.$id=n.external.uri(u)}Object.assign(i,e.def??e.schema);const s=((c=n.external)==null?void 0:c.defs)??{};for(const u of n.seen.entries()){const p=u[1];p.def&&p.defId&&(s[p.defId]=p.def)}n.external||Object.keys(s).length>0&&(n.target==="draft-2020-12"?i.$defs=s:i.definitions=s);try{const u=JSON.parse(JSON.stringify(i));return Object.defineProperty(u,"~standard",{value:{...t["~standard"],jsonSchema:{input:_d(t,"input",n.processors),output:_d(t,"output",n.processors)}},enumerable:!1,writable:!1}),u}catch{throw new Error("Error converting schema to JSON.")}}function At(n,t){const e=t??{seen:new Set};if(e.seen.has(n))return!1;e.seen.add(n);const r=n._zod.def;if(r.type==="transform")return!0;if(r.type==="array")return At(r.element,e);if(r.type==="set")return At(r.valueType,e);if(r.type==="lazy")return At(r.getter(),e);if(r.type==="promise"||r.type==="optional"||r.type==="nonoptional"||r.type==="nullable"||r.type==="readonly"||r.type==="default"||r.type==="prefault")return At(r.innerType,e);if(r.type==="intersection")return At(r.left,e)||At(r.right,e);if(r.type==="record"||r.type==="map")return At(r.keyType,e)||At(r.valueType,e);if(r.type==="pipe")return At(r.in,e)||At(r.out,e);if(r.type==="object"){for(const i in r.shape)if(At(r.shape[i],e))return!0;return!1}if(r.type==="union"){for(const i of r.options)if(At(i,e))return!0;return!1}if(r.type==="tuple"){for(const i of r.items)if(At(i,e))return!0;return!!(r.rest&&At(r.rest,e))}return!1}const MR=(n,t={})=>e=>{const r=Y8({...e,processors:t});return Xe(n,r),K8(r,n),J8(r,n)},_d=(n,t,e={})=>r=>{const{libraryOptions:i,target:s}=r??{},a=Y8({...i??{},target:s,io:t,processors:e});return Xe(n,a),K8(a,n),J8(a,n)},OR={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},NR=(n,t,e,r)=>{const i=e;i.type="string";const{minimum:s,maximum:a,format:l,patterns:c,contentEncoding:u}=n._zod.bag;if(typeof s=="number"&&(i.minLength=s),typeof a=="number"&&(i.maxLength=a),l&&(i.format=OR[l]??l,i.format===""&&delete i.format,l==="time"&&delete i.format),u&&(i.contentEncoding=u),c&&c.size>0){const p=[...c];p.length===1?i.pattern=p[0].source:p.length>1&&(i.allOf=[...p.map(f=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:f.source}))])}},zR=(n,t,e,r)=>{const i=e,{minimum:s,maximum:a,format:l,multipleOf:c,exclusiveMaximum:u,exclusiveMinimum:p}=n._zod.bag;typeof l=="string"&&l.includes("int")?i.type="integer":i.type="number",typeof p=="number"&&(t.target==="draft-04"||t.target==="openapi-3.0"?(i.minimum=p,i.exclusiveMinimum=!0):i.exclusiveMinimum=p),typeof s=="number"&&(i.minimum=s,typeof p=="number"&&t.target!=="draft-04"&&(p>=s?delete i.minimum:delete i.exclusiveMinimum)),typeof u=="number"&&(t.target==="draft-04"||t.target==="openapi-3.0"?(i.maximum=u,i.exclusiveMaximum=!0):i.exclusiveMaximum=u),typeof a=="number"&&(i.maximum=a,typeof u=="number"&&t.target!=="draft-04"&&(u<=a?delete i.maximum:delete i.exclusiveMaximum)),typeof c=="number"&&(i.multipleOf=c)},HR=(n,t,e,r)=>{e.type="boolean"},ZR=(n,t,e,r)=>{e.not={}},UR=(n,t,e,r)=>{},FR=(n,t,e,r)=>{const i=n._zod.def,s=R8(i.entries);s.every(a=>typeof a=="number")&&(e.type="number"),s.every(a=>typeof a=="string")&&(e.type="string"),e.enum=s},qR=(n,t,e,r)=>{const i=n._zod.def,s=[];for(const a of i.values)if(a===void 0){if(t.unrepresentable==="throw")throw new Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof a=="bigint"){if(t.unrepresentable==="throw")throw new Error("BigInt literals cannot be represented in JSON Schema");s.push(Number(a))}else s.push(a);if(s.length!==0)if(s.length===1){const a=s[0];e.type=a===null?"null":typeof a,t.target==="draft-04"||t.target==="openapi-3.0"?e.enum=[a]:e.const=a}else s.every(a=>typeof a=="number")&&(e.type="number"),s.every(a=>typeof a=="string")&&(e.type="string"),s.every(a=>typeof a=="boolean")&&(e.type="boolean"),s.every(a=>a===null)&&(e.type="null"),e.enum=s},VR=(n,t,e,r)=>{if(t.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema")},BR=(n,t,e,r)=>{if(t.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema")},WR=(n,t,e,r)=>{const i=e,s=n._zod.def,{minimum:a,maximum:l}=n._zod.bag;typeof a=="number"&&(i.minItems=a),typeof l=="number"&&(i.maxItems=l),i.type="array",i.items=Xe(s.element,t,{...r,path:[...r.path,"items"]})},jR=(n,t,e,r)=>{var u;const i=e,s=n._zod.def;i.type="object",i.properties={};const a=s.shape;for(const p in a)i.properties[p]=Xe(a[p],t,{...r,path:[...r.path,"properties",p]});const l=new Set(Object.keys(a)),c=new Set([...l].filter(p=>{const f=s.shape[p]._zod;return t.io==="input"?f.optin===void 0:f.optout===void 0}));c.size>0&&(i.required=Array.from(c)),((u=s.catchall)==null?void 0:u._zod.def.type)==="never"?i.additionalProperties=!1:s.catchall?s.catchall&&(i.additionalProperties=Xe(s.catchall,t,{...r,path:[...r.path,"additionalProperties"]})):t.io==="output"&&(i.additionalProperties=!1)},GR=(n,t,e,r)=>{const i=n._zod.def,s=i.inclusive===!1,a=i.options.map((l,c)=>Xe(l,t,{...r,path:[...r.path,s?"oneOf":"anyOf",c]}));s?e.oneOf=a:e.anyOf=a},YR=(n,t,e,r)=>{const i=n._zod.def,s=Xe(i.left,t,{...r,path:[...r.path,"allOf",0]}),a=Xe(i.right,t,{...r,path:[...r.path,"allOf",1]}),l=u=>"allOf"in u&&Object.keys(u).length===1,c=[...l(s)?s.allOf:[s],...l(a)?a.allOf:[a]];e.allOf=c},KR=(n,t,e,r)=>{const i=e,s=n._zod.def;i.type="object";const a=s.keyType,l=a._zod.bag,c=l==null?void 0:l.patterns;if(s.mode==="loose"&&c&&c.size>0){const p=Xe(s.valueType,t,{...r,path:[...r.path,"patternProperties","*"]});i.patternProperties={};for(const f of c)i.patternProperties[f.source]=p}else(t.target==="draft-07"||t.target==="draft-2020-12")&&(i.propertyNames=Xe(s.keyType,t,{...r,path:[...r.path,"propertyNames"]})),i.additionalProperties=Xe(s.valueType,t,{...r,path:[...r.path,"additionalProperties"]});const u=a._zod.values;if(u){const p=[...u].filter(f=>typeof f=="string"||typeof f=="number");p.length>0&&(i.required=p)}},JR=(n,t,e,r)=>{const i=n._zod.def,s=Xe(i.innerType,t,r),a=t.seen.get(n);t.target==="openapi-3.0"?(a.ref=i.innerType,e.nullable=!0):e.anyOf=[s,{type:"null"}]},XR=(n,t,e,r)=>{const i=n._zod.def;Xe(i.innerType,t,r);const s=t.seen.get(n);s.ref=i.innerType},QR=(n,t,e,r)=>{const i=n._zod.def;Xe(i.innerType,t,r);const s=t.seen.get(n);s.ref=i.innerType,e.default=JSON.parse(JSON.stringify(i.defaultValue))},e3=(n,t,e,r)=>{const i=n._zod.def;Xe(i.innerType,t,r);const s=t.seen.get(n);s.ref=i.innerType,t.io==="input"&&(e._prefault=JSON.parse(JSON.stringify(i.defaultValue)))},t3=(n,t,e,r)=>{const i=n._zod.def;Xe(i.innerType,t,r);const s=t.seen.get(n);s.ref=i.innerType;let a;try{a=i.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}e.default=a},n3=(n,t,e,r)=>{const i=n._zod.def,s=t.io==="input"?i.in._zod.def.type==="transform"?i.out:i.in:i.out;Xe(s,t,r);const a=t.seen.get(n);a.ref=s},r3=(n,t,e,r)=>{const i=n._zod.def;Xe(i.innerType,t,r);const s=t.seen.get(n);s.ref=i.innerType,e.readOnly=!0},X8=(n,t,e,r)=>{const i=n._zod.def;Xe(i.innerType,t,r);const s=t.seen.get(n);s.ref=i.innerType},i3=R("ZodISODateTime",(n,t)=>{sC.init(n,t),qe.init(n,t)});function s3(n){return hR(i3,n)}const o3=R("ZodISODate",(n,t)=>{oC.init(n,t),qe.init(n,t)});function a3(n){return dR(o3,n)}const l3=R("ZodISOTime",(n,t)=>{aC.init(n,t),qe.init(n,t)});function c3(n){return pR(l3,n)}const u3=R("ZodISODuration",(n,t)=>{lC.init(n,t),qe.init(n,t)});function h3(n){return fR(u3,n)}const Q8=(n,t)=>{P8.init(n,t),n.name="ZodError",Object.defineProperties(n,{format:{value:e=>Xk(n,e)},flatten:{value:e=>Jk(n,e)},addIssue:{value:e=>{n.issues.push(e),n.message=JSON.stringify(n.issues,Zm,2)}},addIssues:{value:e=>{n.issues.push(...e),n.message=JSON.stringify(n.issues,Zm,2)}},isEmpty:{get(){return n.issues.length===0}}})},v2=R("ZodError",Q8),In=R("ZodError",Q8,{Parent:Error}),d3=U1(In),p3=F1(In),f3=Pp(In),m3=Dp(In),g3=tT(In),v3=nT(In),y3=rT(In),w3=iT(In),b3=sT(In),S3=oT(In),_3=aT(In),A3=lT(In),Fe=R("ZodType",(n,t)=>(Ue.init(n,t),Object.assign(n["~standard"],{jsonSchema:{input:_d(n,"input"),output:_d(n,"output")}}),n.toJSONSchema=MR(n,{}),n.def=t,n.type=t.type,Object.defineProperty(n,"_def",{value:t}),n.check=(...e)=>n.clone($s(t,{checks:[...t.checks??[],...e.map(r=>typeof r=="function"?{_zod:{check:r,def:{check:"custom"},onattach:[]}}:r)]}),{parent:!0}),n.with=n.check,n.clone=(e,r)=>xs(n,e,r),n.brand=()=>n,n.register=((e,r)=>(e.add(n,r),n)),n.parse=(e,r)=>d3(n,e,r,{callee:n.parse}),n.safeParse=(e,r)=>f3(n,e,r),n.parseAsync=async(e,r)=>p3(n,e,r,{callee:n.parseAsync}),n.safeParseAsync=async(e,r)=>m3(n,e,r),n.spa=n.safeParseAsync,n.encode=(e,r)=>g3(n,e,r),n.decode=(e,r)=>v3(n,e,r),n.encodeAsync=async(e,r)=>y3(n,e,r),n.decodeAsync=async(e,r)=>w3(n,e,r),n.safeEncode=(e,r)=>b3(n,e,r),n.safeDecode=(e,r)=>S3(n,e,r),n.safeEncodeAsync=async(e,r)=>_3(n,e,r),n.safeDecodeAsync=async(e,r)=>A3(n,e,r),n.refine=(e,r)=>n.check(mI(e,r)),n.superRefine=e=>n.check(gI(e)),n.overwrite=e=>n.check(Wl(e)),n.optional=()=>b2(n),n.exactOptional=()=>nI(n),n.nullable=()=>S2(n),n.nullish=()=>b2(S2(n)),n.nonoptional=e=>lI(n,e),n.array=()=>G(n),n.or=e=>ae([n,e]),n.and=e=>Mp(n,e),n.transform=e=>_2(n,eI(e)),n.default=e=>sI(n,e),n.prefault=e=>aI(n,e),n.catch=e=>uI(n,e),n.pipe=e=>_2(n,e),n.readonly=()=>pI(n),n.describe=e=>{const r=n.clone();return bc.add(r,{description:e}),r},Object.defineProperty(n,"description",{get(){var e;return(e=bc.get(n))==null?void 0:e.description},configurable:!0}),n.meta=(...e)=>{if(e.length===0)return bc.get(n);const r=n.clone();return bc.add(r,e[0]),r},n.isOptional=()=>n.safeParse(void 0).success,n.isNullable=()=>n.safeParse(null).success,n.apply=e=>e(n),n)),e6=R("_ZodString",(n,t)=>{q1.init(n,t),Fe.init(n,t),n._zod.processJSONSchema=(r,i,s)=>NR(n,r,i);const e=n._zod.bag;n.format=e.format??null,n.minLength=e.minimum??null,n.maxLength=e.maximum??null,n.regex=(...r)=>n.check(bR(...r)),n.includes=(...r)=>n.check(AR(...r)),n.startsWith=(...r)=>n.check(ER(...r)),n.endsWith=(...r)=>n.check(kR(...r)),n.min=(...r)=>n.check(Sd(...r)),n.max=(...r)=>n.check(j8(...r)),n.length=(...r)=>n.check(G8(...r)),n.nonempty=(...r)=>n.check(Sd(1,...r)),n.lowercase=r=>n.check(SR(r)),n.uppercase=r=>n.check(_R(r)),n.trim=()=>n.check(CR()),n.normalize=(...r)=>n.check(TR(...r)),n.toLowerCase=()=>n.check(RR()),n.toUpperCase=()=>n.check(IR()),n.slugify=()=>n.check($R())}),E3=R("ZodString",(n,t)=>{q1.init(n,t),e6.init(n,t),n.email=e=>n.check(VC(k3,e)),n.url=e=>n.check(YC(T3,e)),n.jwt=e=>n.check(uR(U3,e)),n.emoji=e=>n.check(KC(C3,e)),n.guid=e=>n.check(p2(y2,e)),n.uuid=e=>n.check(BC(Ih,e)),n.uuidv4=e=>n.check(WC(Ih,e)),n.uuidv6=e=>n.check(jC(Ih,e)),n.uuidv7=e=>n.check(GC(Ih,e)),n.nanoid=e=>n.check(JC(R3,e)),n.guid=e=>n.check(p2(y2,e)),n.cuid=e=>n.check(XC(I3,e)),n.cuid2=e=>n.check(QC($3,e)),n.ulid=e=>n.check(eR(x3,e)),n.base64=e=>n.check(aR(z3,e)),n.base64url=e=>n.check(lR(H3,e)),n.xid=e=>n.check(tR(P3,e)),n.ksuid=e=>n.check(nR(D3,e)),n.ipv4=e=>n.check(rR(L3,e)),n.ipv6=e=>n.check(iR(M3,e)),n.cidrv4=e=>n.check(sR(O3,e)),n.cidrv6=e=>n.check(oR(N3,e)),n.e164=e=>n.check(cR(Z3,e)),n.datetime=e=>n.check(s3(e)),n.date=e=>n.check(a3(e)),n.time=e=>n.check(c3(e)),n.duration=e=>n.check(h3(e))});function g(n){return qC(E3,n)}const qe=R("ZodStringFormat",(n,t)=>{Oe.init(n,t),e6.init(n,t)}),k3=R("ZodEmail",(n,t)=>{KT.init(n,t),qe.init(n,t)}),y2=R("ZodGUID",(n,t)=>{GT.init(n,t),qe.init(n,t)}),Ih=R("ZodUUID",(n,t)=>{YT.init(n,t),qe.init(n,t)}),T3=R("ZodURL",(n,t)=>{JT.init(n,t),qe.init(n,t)}),C3=R("ZodEmoji",(n,t)=>{XT.init(n,t),qe.init(n,t)}),R3=R("ZodNanoID",(n,t)=>{QT.init(n,t),qe.init(n,t)}),I3=R("ZodCUID",(n,t)=>{eC.init(n,t),qe.init(n,t)}),$3=R("ZodCUID2",(n,t)=>{tC.init(n,t),qe.init(n,t)}),x3=R("ZodULID",(n,t)=>{nC.init(n,t),qe.init(n,t)}),P3=R("ZodXID",(n,t)=>{rC.init(n,t),qe.init(n,t)}),D3=R("ZodKSUID",(n,t)=>{iC.init(n,t),qe.init(n,t)}),L3=R("ZodIPv4",(n,t)=>{cC.init(n,t),qe.init(n,t)}),M3=R("ZodIPv6",(n,t)=>{uC.init(n,t),qe.init(n,t)}),O3=R("ZodCIDRv4",(n,t)=>{hC.init(n,t),qe.init(n,t)}),N3=R("ZodCIDRv6",(n,t)=>{dC.init(n,t),qe.init(n,t)}),z3=R("ZodBase64",(n,t)=>{pC.init(n,t),qe.init(n,t)}),H3=R("ZodBase64URL",(n,t)=>{mC.init(n,t),qe.init(n,t)}),Z3=R("ZodE164",(n,t)=>{gC.init(n,t),qe.init(n,t)}),U3=R("ZodJWT",(n,t)=>{yC.init(n,t),qe.init(n,t)}),t6=R("ZodNumber",(n,t)=>{F8.init(n,t),Fe.init(n,t),n._zod.processJSONSchema=(r,i,s)=>zR(n,r,i),n.gt=(r,i)=>n.check(m2(r,i)),n.gte=(r,i)=>n.check(vm(r,i)),n.min=(r,i)=>n.check(vm(r,i)),n.lt=(r,i)=>n.check(f2(r,i)),n.lte=(r,i)=>n.check(gm(r,i)),n.max=(r,i)=>n.check(gm(r,i)),n.int=r=>n.check(w2(r)),n.safe=r=>n.check(w2(r)),n.positive=r=>n.check(m2(0,r)),n.nonnegative=r=>n.check(vm(0,r)),n.negative=r=>n.check(f2(0,r)),n.nonpositive=r=>n.check(gm(0,r)),n.multipleOf=(r,i)=>n.check(g2(r,i)),n.step=(r,i)=>n.check(g2(r,i)),n.finite=()=>n;const e=n._zod.bag;n.minValue=Math.max(e.minimum??Number.NEGATIVE_INFINITY,e.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,n.maxValue=Math.min(e.maximum??Number.POSITIVE_INFINITY,e.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,n.isInt=(e.format??"").includes("int")||Number.isSafeInteger(e.multipleOf??.5),n.isFinite=!0,n.format=e.format??null});function ie(n){return mR(t6,n)}const F3=R("ZodNumberFormat",(n,t)=>{wC.init(n,t),t6.init(n,t)});function w2(n){return gR(F3,n)}const q3=R("ZodBoolean",(n,t)=>{bC.init(n,t),Fe.init(n,t),n._zod.processJSONSchema=(e,r,i)=>HR(n,e,r)});function lt(n){return vR(q3,n)}const V3=R("ZodUnknown",(n,t)=>{SC.init(n,t),Fe.init(n,t),n._zod.processJSONSchema=(e,r,i)=>UR()});function E(){return yR(V3)}const B3=R("ZodNever",(n,t)=>{_C.init(n,t),Fe.init(n,t),n._zod.processJSONSchema=(e,r,i)=>ZR(n,e,r)});function W3(n){return wR(B3,n)}const j3=R("ZodArray",(n,t)=>{AC.init(n,t),Fe.init(n,t),n._zod.processJSONSchema=(e,r,i)=>WR(n,e,r,i),n.element=t.element,n.min=(e,r)=>n.check(Sd(e,r)),n.nonempty=e=>n.check(Sd(1,e)),n.max=(e,r)=>n.check(j8(e,r)),n.length=(e,r)=>n.check(G8(e,r)),n.unwrap=()=>n.element});function G(n,t){return xR(j3,n,t)}const n6=R("ZodObject",(n,t)=>{kC.init(n,t),Fe.init(n,t),n._zod.processJSONSchema=(e,r,i)=>jR(n,e,r,i),Ae(n,"shape",()=>t.shape),n.keyof=()=>s6(Object.keys(n._zod.def.shape)),n.catchall=e=>n.clone({...n._zod.def,catchall:e}),n.passthrough=()=>n.clone({...n._zod.def,catchall:E()}),n.loose=()=>n.clone({...n._zod.def,catchall:E()}),n.strict=()=>n.clone({...n._zod.def,catchall:W3()}),n.strip=()=>n.clone({...n._zod.def,catchall:void 0}),n.extend=e=>Wk(n,e),n.safeExtend=e=>jk(n,e),n.merge=e=>Gk(n,e),n.pick=e=>Vk(n,e),n.omit=e=>Bk(n,e),n.partial=(...e)=>Yk(o6,n,e[0]),n.required=(...e)=>Kk(a6,n,e[0])});function r6(n,t){const e={type:"object",shape:n??{},...K(t)};return new n6(e)}function b(n,t){return new n6({type:"object",shape:n,catchall:E(),...K(t)})}const i6=R("ZodUnion",(n,t)=>{B8.init(n,t),Fe.init(n,t),n._zod.processJSONSchema=(e,r,i)=>GR(n,e,r,i),n.options=t.options});function ae(n,t){return new i6({type:"union",options:n,...K(t)})}const G3=R("ZodDiscriminatedUnion",(n,t)=>{i6.init(n,t),TC.init(n,t)});function Y3(n,t,e){return new G3({type:"union",options:t,discriminator:n,...K(e)})}const K3=R("ZodIntersection",(n,t)=>{CC.init(n,t),Fe.init(n,t),n._zod.processJSONSchema=(e,r,i)=>YR(n,e,r,i)});function Mp(n,t){return new K3({type:"intersection",left:n,right:t})}const J3=R("ZodRecord",(n,t)=>{RC.init(n,t),Fe.init(n,t),n._zod.processJSONSchema=(e,r,i)=>KR(n,e,r,i),n.keyType=t.keyType,n.valueType=t.valueType});function T(n,t,e){return new J3({type:"record",keyType:n,valueType:t,...K(e)})}const Fm=R("ZodEnum",(n,t)=>{IC.init(n,t),Fe.init(n,t),n._zod.processJSONSchema=(r,i,s)=>FR(n,r,i),n.enum=t.entries,n.options=Object.values(t.entries);const e=new Set(Object.keys(t.entries));n.extract=(r,i)=>{const s={};for(const a of r)if(e.has(a))s[a]=t.entries[a];else throw new Error(`Key ${a} not found in enum`);return new Fm({...t,checks:[],...K(i),entries:s})},n.exclude=(r,i)=>{const s={...t.entries};for(const a of r)if(e.has(a))delete s[a];else throw new Error(`Key ${a} not found in enum`);return new Fm({...t,checks:[],...K(i),entries:s})}});function s6(n,t){const e=Array.isArray(n)?Object.fromEntries(n.map(r=>[r,r])):n;return new Fm({type:"enum",entries:e,...K(t)})}const X3=R("ZodLiteral",(n,t)=>{$C.init(n,t),Fe.init(n,t),n._zod.processJSONSchema=(e,r,i)=>qR(n,e,r),n.values=new Set(t.values),Object.defineProperty(n,"value",{get(){if(t.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function D(n,t){return new X3({type:"literal",values:Array.isArray(n)?n:[n],...K(t)})}const Q3=R("ZodTransform",(n,t)=>{xC.init(n,t),Fe.init(n,t),n._zod.processJSONSchema=(e,r,i)=>BR(n,e),n._zod.parse=(e,r)=>{if(r.direction==="backward")throw new T8(n.constructor.name);e.addIssue=s=>{if(typeof s=="string")e.issues.push(Vc(s,e.value,t));else{const a=s;a.fatal&&(a.continue=!1),a.code??(a.code="custom"),a.input??(a.input=e.value),a.inst??(a.inst=n),e.issues.push(Vc(a))}};const i=t.transform(e.value,e);return i instanceof Promise?i.then(s=>(e.value=s,e)):(e.value=i,e)}});function eI(n){return new Q3({type:"transform",transform:n})}const o6=R("ZodOptional",(n,t)=>{W8.init(n,t),Fe.init(n,t),n._zod.processJSONSchema=(e,r,i)=>X8(n,e,r,i),n.unwrap=()=>n._zod.def.innerType});function b2(n){return new o6({type:"optional",innerType:n})}const tI=R("ZodExactOptional",(n,t)=>{PC.init(n,t),Fe.init(n,t),n._zod.processJSONSchema=(e,r,i)=>X8(n,e,r,i),n.unwrap=()=>n._zod.def.innerType});function nI(n){return new tI({type:"optional",innerType:n})}const rI=R("ZodNullable",(n,t)=>{DC.init(n,t),Fe.init(n,t),n._zod.processJSONSchema=(e,r,i)=>JR(n,e,r,i),n.unwrap=()=>n._zod.def.innerType});function S2(n){return new rI({type:"nullable",innerType:n})}const iI=R("ZodDefault",(n,t)=>{LC.init(n,t),Fe.init(n,t),n._zod.processJSONSchema=(e,r,i)=>QR(n,e,r,i),n.unwrap=()=>n._zod.def.innerType,n.removeDefault=n.unwrap});function sI(n,t){return new iI({type:"default",innerType:n,get defaultValue(){return typeof t=="function"?t():$8(t)}})}const oI=R("ZodPrefault",(n,t)=>{MC.init(n,t),Fe.init(n,t),n._zod.processJSONSchema=(e,r,i)=>e3(n,e,r,i),n.unwrap=()=>n._zod.def.innerType});function aI(n,t){return new oI({type:"prefault",innerType:n,get defaultValue(){return typeof t=="function"?t():$8(t)}})}const a6=R("ZodNonOptional",(n,t)=>{OC.init(n,t),Fe.init(n,t),n._zod.processJSONSchema=(e,r,i)=>XR(n,e,r,i),n.unwrap=()=>n._zod.def.innerType});function lI(n,t){return new a6({type:"nonoptional",innerType:n,...K(t)})}const cI=R("ZodCatch",(n,t)=>{NC.init(n,t),Fe.init(n,t),n._zod.processJSONSchema=(e,r,i)=>t3(n,e,r,i),n.unwrap=()=>n._zod.def.innerType,n.removeCatch=n.unwrap});function uI(n,t){return new cI({type:"catch",innerType:n,catchValue:typeof t=="function"?t:()=>t})}const hI=R("ZodPipe",(n,t)=>{zC.init(n,t),Fe.init(n,t),n._zod.processJSONSchema=(e,r,i)=>n3(n,e,r,i),n.in=t.in,n.out=t.out});function _2(n,t){return new hI({type:"pipe",in:n,out:t})}const dI=R("ZodReadonly",(n,t)=>{HC.init(n,t),Fe.init(n,t),n._zod.processJSONSchema=(e,r,i)=>r3(n,e,r,i),n.unwrap=()=>n._zod.def.innerType});function pI(n){return new dI({type:"readonly",innerType:n})}const fI=R("ZodCustom",(n,t)=>{ZC.init(n,t),Fe.init(n,t),n._zod.processJSONSchema=(e,r,i)=>VR(n,e)});function mI(n,t={}){return PR(fI,n,t)}function gI(n){return DR(n)}const vI=[".md",".markdown"];function l6(n){if(n.length===0)return!1;const t=n.at(-1);return t==="/"||t==="\\"}function c6(n){const t=n.lastIndexOf("/"),e=n.lastIndexOf("\\");return n.slice(Math.max(t,e)+1)}function yI(n){return c6(n).toLowerCase()}function wI(n,t){const e=yI(n);return t.some(r=>e.endsWith(r))}function qm(n){return!l6(n)&&wI(n,vI)}function bI(n){let t;try{t=new URL(n)}catch{return!1}return t.protocol==="http:"||t.protocol==="https:"}function Zr(n){try{const{pathname:t}=new URL(n);return/^\/artifact\/[0-9A-Za-z]{26}(\/|$)/.test(t)}catch{return!1}}const SI=r6({id:g().min(1),kind:D("path"),title:g(),path:g()}).strict(),_I=r6({id:g().min(1),kind:D("url"),title:g(),url:g().refine(bI,{message:"url must be an http(s) URL"})}).strict();Y3("kind",[SI,_I]);const AI=new Set(["about:","blob:","chrome-extension:","chrome:","data:","devtools:","file:","filesystem:","javascript:","view-source:"]);function EI(n,t){try{const e=new URL(t),r=new URL(n,e);return r.protocol==="http:"||r.protocol==="https:"?{kind:"web",url:r.href}:AI.has(r.protocol)?{kind:"browser-local",url:r.href}:{kind:"application",url:r.href}}catch{return{kind:"invalid"}}}function A2(n,t){return EI(n,t).kind==="web"}const kI="/views/markdown/",TI="/views/url-unsupported/";function CI(n){try{const{protocol:t}=new URL(n);return t==="http:"||t==="https:"}catch{return!1}}function u6(n){return`/artifact/${encodeURIComponent(n)}`}function RI(n,t){return`${u6(n)}/${encodeURIComponent(t)}`}function II(n){return`/markdown/${encodeURIComponent(n)}`}function Ad(n,t={electron:!1}){if(n.kind==="url")return t.electron?{renderer:"url-webview",viewURL:n.url,contentURL:null}:Zr(n.url)?{renderer:"proxy-iframe",viewURL:n.url,contentURL:null}:t.browserDemo&&CI(n.url)?{renderer:"url-direct",viewURL:n.url,contentURL:null}:{renderer:"url-unsupported",viewURL:TI,contentURL:null};if(qm(n.path)){const r={viewURL:kI,contentURL:II(n.id)};return t.electron?{renderer:"url-webview",...r}:{renderer:"markdown",...r}}const e=l6(n.path)?`${u6(n.id)}/`:RI(n.id,c6(n.path));return t.electron?{renderer:"url-webview",viewURL:e,contentURL:null}:{renderer:"proxy-iframe",viewURL:e,contentURL:null}}const $I="serverURL",xI="token",PI="mode",DI="desktopAppVersion",LI="electron";function MI(n=window.location.search,t=window.location.origin){const r=new URLSearchParams(n).get($I);return r?new URL(r).origin:new URL(t).origin}function OI(n=window.location.search){return new URLSearchParams(n).get(xI)}function gi(n=typeof window>"u"?"":window.location.search){return new URLSearchParams(n).get(PI)===LI}function h6(n=typeof window>"u"?"":window.location.search){return new URLSearchParams(n).get(DI)}const E2="tv.telemetry.clientId",NI=5,zI=60,HI=1e3,ZI=NI*zI*HI,k2=["pointerdown","scroll","keydown"],T2=["focus"],C2=["visibilitychange"],UI="hidden";function FI(n,t=jI){const e=n.getItem(E2);if(e)return e;const r=t();return n.setItem(E2,r),r}function qI(n){return{clientId:FI(n.storage,n.idFactory),userAgent:n.userAgent??(typeof navigator>"u"?"":navigator.userAgent),clientApp:n.clientApp,...n.desktopAppVersion?{desktopAppVersion:n.desktopAppVersion}:{}}}function VI(n){const t=new URLSearchParams;return t.set("clientId",n.clientId),t.set("userAgent",n.userAgent),t.set("clientApp",n.clientApp),n.desktopAppVersion&&t.set("desktopAppVersion",n.desktopAppVersion),t}function BI(n){return new WI(n)}var Xc,Br,Fi,Qc,eu,mn,co,tu,Od,d6;class WI{constructor(t){m(this,Od);m(this,Xc);m(this,Br);m(this,Fi);m(this,Qc);m(this,eu);m(this,mn);m(this,co,!1);m(this,tu,Number.NEGATIVE_INFINITY);d(this,Xc,t.meta),d(this,Br,t.documentTarget),d(this,Fi,t.windowTarget),d(this,Qc,t.send),d(this,eu,t.nowMs??Date.now),d(this,mn,()=>h(this,Od,d6).call(this))}start(){if(!o(this,co)){d(this,co,!0);for(const t of k2)o(this,Fi).addEventListener(t,o(this,mn)),o(this,Br).addEventListener(t,o(this,mn));for(const t of T2)o(this,Fi).addEventListener(t,o(this,mn));for(const t of C2)o(this,Br).addEventListener(t,o(this,mn))}}stop(){if(o(this,co)){d(this,co,!1);for(const t of k2)o(this,Fi).removeEventListener(t,o(this,mn)),o(this,Br).removeEventListener(t,o(this,mn));for(const t of T2)o(this,Fi).removeEventListener(t,o(this,mn));for(const t of C2)o(this,Br).removeEventListener(t,o(this,mn))}}}Xc=new WeakMap,Br=new WeakMap,Fi=new WeakMap,Qc=new WeakMap,eu=new WeakMap,mn=new WeakMap,co=new WeakMap,tu=new WeakMap,Od=new WeakSet,d6=function(){if(o(this,Br).visibilityState===UI)return;const t=o(this,eu).call(this);t-o(this,tu)<ZI||(d(this,tu,t),o(this,Qc).call(this,{type:zE,clientId:o(this,Xc).clientId}))};function jI(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():N1().toLowerCase()}const De={authenticate:"authenticate",document_did_change:"document/didChange",document_did_close:"document/didClose",document_did_focus:"document/didFocus",document_did_open:"document/didOpen",document_did_save:"document/didSave",initialize:"initialize",logout:"logout",nes_accept:"nes/accept",nes_close:"nes/close",nes_reject:"nes/reject",nes_start:"nes/start",nes_suggest:"nes/suggest",session_cancel:"session/cancel",session_close:"session/close",session_fork:"session/fork",session_list:"session/list",session_load:"session/load",session_new:"session/new",session_prompt:"session/prompt",session_resume:"session/resume",session_set_config_option:"session/set_config_option",session_set_mode:"session/set_mode",session_set_model:"session/set_model"},Nr={fs_read_text_file:"fs/read_text_file",fs_write_text_file:"fs/write_text_file",session_request_permission:"session/request_permission",session_update:"session/update",terminal_create:"terminal/create",terminal_kill:"terminal/kill",terminal_output:"terminal/output",terminal_release:"terminal/release",terminal_wait_for_exit:"terminal/wait_for_exit"},GI=1,YI=b({_meta:T(g(),E()).nullish(),terminal:lt().optional().default(!1)}),KI=b({_meta:T(g(),E()).nullish(),label:g().nullish(),name:g(),optional:lt().optional().default(!1),secret:lt().optional().default(!0)}),JI=b({_meta:T(g(),E()).nullish(),description:g().nullish(),id:g(),name:g()}),XI=b({_meta:T(g(),E()).nullish(),description:g().nullish(),id:g(),link:g().nullish(),name:g(),vars:G(KI)}),QI=b({_meta:T(g(),E()).nullish(),args:G(g()).optional(),description:g().nullish(),env:T(g(),g()).optional(),id:g(),name:g()}),e$=ae([XI.and(b({type:D("env_var")})),QI.and(b({type:D("terminal")})),JI]),t$=b({_meta:T(g(),E()).nullish(),methodId:g()}),n$=b({_meta:T(g(),E()).nullish()}),r$=b({_meta:T(g(),E()).nullish(),blob:g(),mimeType:g().nullish(),uri:g()}),i$=b({default:lt().nullish(),description:g().nullish(),title:g().nullish()}),s$=b({_meta:T(g(),E()).nullish()}),o$=b({_meta:T(g(),E()).nullish()}),a$=b({amount:ie(),currency:g()}),l$=b({_meta:T(g(),E()).nullish(),terminalId:g()}),c$=b({_meta:T(g(),E()).nullish(),newText:g(),oldText:g().nullish(),path:g()}),u$=ae([g(),ie(),ie(),lt(),G(g())]),h$=b({content:T(g(),u$).nullish()}),d$=ae([h$.and(b({action:D("accept")})),b({action:D("decline")}),b({action:D("cancel")})]),p$=b({_meta:T(g(),E()).nullish()}),p6=g(),f$=b({_meta:T(g(),E()).nullish(),elicitationId:p6}),m$=b({_meta:T(g(),E()).nullish(),action:d$}),g$=D("object"),v$=D("string"),y$=b({_meta:T(g(),E()).nullish()}),w$=b({_meta:T(g(),E()).nullish(),form:p$.nullish(),url:y$.nullish()}),b$=b({elicitationId:p6,url:g().url()}),f6=b({const:g(),title:g()}),m6=b({_meta:T(g(),E()).nullish(),name:g(),value:g()}),S$=ae([D(-32700),D(-32600),D(-32601),D(-32602),D(-32603),D(-32800),D(-32e3),D(-32002),D(-32042),ie().int().min(-2147483648,{message:"Invalid value: Expected int32 to be >= -2147483648"}).max(2147483647,{message:"Invalid value: Expected int32 to be <= 2147483647"})]),g6=b({code:S$,data:E().optional(),message:g()}),v6=E(),y6=E(),w6=E(),_$=b({_meta:T(g(),E()).nullish(),readTextFile:lt().optional().default(!1),writeTextFile:lt().optional().default(!1)}),b6=b({_meta:T(g(),E()).nullish(),name:g(),value:g()}),S6=b({_meta:T(g(),E()).nullish(),name:g(),title:g().nullish(),version:g()}),A$=b({default:ie().nullish(),description:g().nullish(),maximum:ie().nullish(),minimum:ie().nullish(),title:g().nullish()}),E$=b({_meta:T(g(),E()).nullish()}),k$=b({_meta:T(g(),E()).nullish(),additionalDirectories:G(g()).optional(),cursor:g().nullish(),cwd:g().nullish()}),T$=b({_meta:T(g(),E()).nullish()}),C$=b({_meta:T(g(),E()).nullish(),logout:T$.nullish()}),R$=b({_meta:T(g(),E()).nullish()}),I$=b({_meta:T(g(),E()).nullish()}),$$=b({_meta:T(g(),E()).nullish(),http:lt().optional().default(!1),sse:lt().optional().default(!1)}),x$=b({_meta:T(g(),E()).nullish(),headers:G(b6),name:g(),url:g()}),P$=b({_meta:T(g(),E()).nullish(),headers:G(b6),name:g(),url:g()}),D$=b({_meta:T(g(),E()).nullish(),args:G(g()),command:g(),env:G(m6),name:g()}),Op=ae([x$.and(b({type:D("http")})),P$.and(b({type:D("sse")})),D$]),V1=g(),L$=b({_meta:T(g(),E()).nullish(),description:g().nullish(),modelId:V1,name:g()}),M$=ae([D("error"),D("warning"),D("information"),D("hint")]),O$=b({_meta:T(g(),E()).nullish()}),N$=b({_meta:T(g(),E()).nullish()}),z$=b({_meta:T(g(),E()).nullish()}),H$=b({_meta:T(g(),E()).nullish()}),Z$=b({_meta:T(g(),E()).nullish()}),U$=b({_meta:T(g(),E()).nullish(),maxCount:ie().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish()}),F$=b({diff:g(),uri:g()}),q$=b({endLine:ie().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}),startLine:ie().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}),text:g()}),V$=b({_meta:T(g(),E()).nullish()}),B$=b({_meta:T(g(),E()).nullish()}),W$=b({languageId:g(),text:g(),uri:g()}),j$=b({_meta:T(g(),E()).nullish(),maxCount:ie().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish()}),G$=ae([D("rejected"),D("ignored"),D("replaced"),D("cancelled")]),Y$=b({excerpts:G(q$),uri:g()}),K$=b({_meta:T(g(),E()).nullish()}),J$=b({_meta:T(g(),E()).nullish()}),X$=b({name:g(),owner:g(),remoteUrl:g()}),Q$=b({_meta:T(g(),E()).nullish()}),ex=b({_meta:T(g(),E()).nullish(),jump:V$.nullish(),rename:J$.nullish(),searchAndReplace:Q$.nullish()}),tx=b({id:g(),isRegex:lt().nullish(),replace:g(),search:g(),uri:g()}),nx=ae([D("automatic"),D("diagnostic"),D("manual")]),rx=b({_meta:T(g(),E()).nullish(),maxCount:ie().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish()}),ix=b({_meta:T(g(),E()).nullish(),diagnostics:O$.nullish(),editHistory:U$.nullish(),openFiles:B$.nullish(),recentFiles:j$.nullish(),relatedSnippets:K$.nullish(),userActions:rx.nullish()}),sx=b({_meta:T(g(),E()).nullish(),additionalDirectories:G(g()).optional(),cwd:g(),mcpServers:G(Op)}),ox=b({default:ie().nullish(),description:g().nullish(),maximum:ie().nullish(),minimum:ie().nullish(),title:g().nullish()}),_6=g(),ax=ae([D("allow_once"),D("allow_always"),D("reject_once"),D("reject_always")]),lx=b({_meta:T(g(),E()).nullish(),kind:ax,name:g(),optionId:_6}),cx=ae([D("high"),D("medium"),D("low")]),ux=ae([D("pending"),D("in_progress"),D("completed")]),hx=b({_meta:T(g(),E()).nullish(),content:g(),priority:cx,status:ux}),dx=b({_meta:T(g(),E()).nullish(),entries:G(hx)}),Cs=b({character:ie().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}),line:ie().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"})}),px=b({id:g(),position:Cs,uri:g()}),fx=b({id:g(),newName:g(),position:Cs,uri:g()}),mx=b({action:g(),position:Cs,timestampMs:ie(),uri:g()}),A6=ae([D("utf-16"),D("utf-32"),D("utf-8")]),gx=b({_meta:T(g(),E()).nullish(),auth:YI.optional().default({terminal:!1}),elicitation:w$.nullish(),fs:_$.optional().default({readTextFile:!1,writeTextFile:!1}),nes:ex.nullish(),positionEncodings:G(A6).optional(),terminal:lt().optional().default(!1)}),vx=b({_meta:T(g(),E()).nullish(),audio:lt().optional().default(!1),embeddedContext:lt().optional().default(!1),image:lt().optional().default(!1)}),E6=ie().int().gte(0).lte(65535),yx=b({_meta:T(g(),E()).nullish(),clientCapabilities:gx.optional().default({auth:{terminal:!1},fs:{readTextFile:!1,writeTextFile:!1},terminal:!1}),clientInfo:S6.nullish(),protocolVersion:E6}),jl=b({end:Cs,start:Cs}),wx=b({message:g(),range:jl,severity:M$,uri:g()}),bx=b({languageId:g(),lastFocusedMs:ie().nullish(),uri:g(),visibleRange:jl.nullish()}),Sx=b({_meta:T(g(),E()).nullish(),diagnostics:G(wx).nullish(),editHistory:G(F$).nullish(),openFiles:G(bx).nullish(),recentFiles:G(W$).nullish(),relatedSnippets:G(Y$).nullish(),userActions:G(mx).nullish()}),_x=b({newText:g(),range:jl}),Ax=b({cursorPosition:Cs.nullish(),edits:G(_x),id:g(),uri:g()}),Ex=ae([Ax.and(b({kind:D("edit")})),px.and(b({kind:D("jump")})),fx.and(b({kind:D("rename")})),tx.and(b({kind:D("searchAndReplace")}))]),kx=b({_meta:T(g(),E()).nullish(),content:g()}),Tx=b({_meta:T(g(),E()).nullish()}),Xo=ae([ie(),g()]).nullable();b({_meta:T(g(),E()).nullish(),requestId:Xo});const Cx=s6(["assistant","user"]),hh=b({_meta:T(g(),E()).nullish(),audience:G(Cx).nullish(),lastModified:g().nullish(),priority:ie().nullish()}),Rx=b({_meta:T(g(),E()).nullish(),annotations:hh.nullish(),data:g(),mimeType:g()}),Ix=b({_meta:T(g(),E()).nullish(),annotations:hh.nullish(),data:g(),mimeType:g(),uri:g().nullish()}),$x=b({_meta:T(g(),E()).nullish(),annotations:hh.nullish(),description:g().nullish(),mimeType:g().nullish(),name:g(),size:ie().nullish(),title:g().nullish(),uri:g()}),xx=b({_meta:T(g(),E()).nullish(),optionId:_6}),Px=ae([b({outcome:D("cancelled")}),xx.and(b({outcome:D("selected")}))]),Dx=b({_meta:T(g(),E()).nullish(),outcome:Px}),Lx=b({_meta:T(g(),E()).nullish()}),Mx=b({_meta:T(g(),E()).nullish()}),Ox=b({currentValue:lt()}),Nx=g(),k6=g(),zx=ae([D("mode"),D("model"),D("thought_level"),g()]),B1=g(),T6=b({_meta:T(g(),E()).nullish(),description:g().nullish(),name:g(),value:B1}),Hx=b({_meta:T(g(),E()).nullish(),group:Nx,name:g(),options:G(T6)}),Zx=ae([G(T6),G(Hx)]),Ux=b({currentValue:B1,options:Zx}),Gl=Mp(ae([Ux.and(b({type:D("select")})),Ox.and(b({type:D("boolean")}))]),b({_meta:T(g(),E()).nullish(),category:zx.nullish(),description:g().nullish(),id:k6,name:g()})),Fx=b({_meta:T(g(),E()).nullish(),configOptions:G(Gl)}),qx=b({_meta:T(g(),E()).nullish()}),be=g(),Vx=b({_meta:T(g(),E()).nullish(),id:g(),sessionId:be}),Bx=b({_meta:T(g(),E()).nullish(),sessionId:be}),Wx=b({_meta:T(g(),E()).nullish(),sessionId:be}),jx=b({_meta:T(g(),E()).nullish(),sessionId:be}),C6=b({_meta:T(g(),E()).nullish(),args:G(g()).optional(),command:g(),cwd:g().nullish(),env:G(m6).optional(),outputByteLimit:ie().nullish(),sessionId:be}),Gx=b({_meta:T(g(),E()).nullish(),sessionId:be,uri:g()}),Yx=b({_meta:T(g(),E()).nullish(),position:Cs,sessionId:be,uri:g(),version:ie(),visibleRange:jl}),Kx=b({_meta:T(g(),E()).nullish(),languageId:g(),sessionId:be,text:g(),uri:g(),version:ie()}),Jx=b({_meta:T(g(),E()).nullish(),sessionId:be,uri:g()}),Xx=b({_meta:T(g(),E()).nullish(),additionalDirectories:G(g()).optional(),cwd:g(),mcpServers:G(Op).optional(),sessionId:be}),R6=b({_meta:T(g(),E()).nullish(),sessionId:be,terminalId:g()}),Qx=b({_meta:T(g(),E()).nullish(),additionalDirectories:G(g()).optional(),cwd:g(),mcpServers:G(Op),sessionId:be}),I6=b({_meta:T(g(),E()).nullish(),limit:ie().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),line:ie().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),path:g(),sessionId:be}),eP=b({_meta:T(g(),E()).nullish(),id:g(),reason:G$.nullish(),sessionId:be}),$6=b({_meta:T(g(),E()).nullish(),sessionId:be,terminalId:g()}),tP=b({_meta:T(g(),E()).nullish(),additionalDirectories:G(g()).optional(),cwd:g(),mcpServers:G(Op).optional(),sessionId:be}),nP=b({_meta:T(g(),E()).nullish(),additionalDirectories:G(g()).optional(),cwd:g(),sessionId:be,title:g().nullish(),updatedAt:g().nullish()}),rP=b({_meta:T(g(),E()).nullish(),nextCursor:g().nullish(),sessions:G(nP)}),iP=b({_meta:T(g(),E()).nullish(),title:g().nullish(),updatedAt:g().nullish()}),sP=b({_meta:T(g(),E()).nullish()}),Np=g(),oP=b({_meta:T(g(),E()).nullish(),currentModeId:Np}),aP=b({_meta:T(g(),E()).nullish(),description:g().nullish(),id:Np,name:g()}),zp=b({_meta:T(g(),E()).nullish(),availableModes:G(aP),currentModeId:Np}),Hp=b({_meta:T(g(),E()).nullish(),availableModels:G(L$),currentModelId:V1}),lP=b({_meta:T(g(),E()).nullish(),configOptions:G(Gl).nullish(),models:Hp.nullish(),modes:zp.nullish(),sessionId:be}),cP=b({_meta:T(g(),E()).nullish(),configOptions:G(Gl).nullish(),models:Hp.nullish(),modes:zp.nullish()}),uP=b({_meta:T(g(),E()).nullish(),configOptions:G(Gl).nullish(),models:Hp.nullish(),modes:zp.nullish(),sessionId:be}),hP=b({_meta:T(g(),E()).nullish(),configOptions:G(Gl).nullish(),models:Hp.nullish(),modes:zp.nullish()}),dP=b({_meta:T(g(),E()).nullish()}),pP=b({_meta:T(g(),E()).nullish(),additionalDirectories:Lx.nullish(),close:Mx.nullish(),fork:qx.nullish(),list:sP.nullish(),resume:dP.nullish()}),fP=Mp(ae([b({type:D("boolean"),value:lt()}),b({value:B1})]),b({_meta:T(g(),E()).nullish(),configId:k6,sessionId:be})),mP=b({_meta:T(g(),E()).nullish(),configOptions:G(Gl)}),gP=b({_meta:T(g(),E()).nullish(),modeId:Np,sessionId:be}),vP=b({_meta:T(g(),E()).nullish()}),yP=b({_meta:T(g(),E()).nullish(),modelId:V1,sessionId:be}),wP=b({_meta:T(g(),E()).nullish()}),bP=b({_meta:T(g(),E()).nullish(),sessionId:be}),SP=ae([D("end_turn"),D("max_tokens"),D("max_turn_requests"),D("refusal"),D("cancelled")]),_P=ae([D("email"),D("uri"),D("date"),D("date-time")]),AP=b({default:g().nullish(),description:g().nullish(),enum:G(g()).nullish(),format:_P.nullish(),maxLength:ie().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),minLength:ie().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),oneOf:G(f6).nullish(),pattern:g().nullish(),title:g().nullish()}),EP=b({_meta:T(g(),E()).nullish(),context:Sx.nullish(),position:Cs,selection:jl.nullish(),sessionId:be,triggerKind:nx,uri:g(),version:ie()}),kP=b({_meta:T(g(),E()).nullish(),suggestions:G(Ex)}),TP=b({_meta:T(g(),E()).nullish(),terminalId:g()}),CP=b({_meta:T(g(),E()).nullish(),exitCode:ie().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),signal:g().nullish()}),x6=b({_meta:T(g(),E()).nullish(),sessionId:be,terminalId:g()}),RP=b({_meta:T(g(),E()).nullish(),exitStatus:CP.nullish(),output:g(),truncated:lt()}),IP=b({_meta:T(g(),E()).nullish(),annotations:hh.nullish(),text:g()}),$P=b({range:jl.nullish(),text:g()}),xP=b({_meta:T(g(),E()).nullish(),contentChanges:G($P),sessionId:be,uri:g(),version:ie()});b({method:g(),params:ae([Bx,Kx,xP,Gx,Jx,Yx,Vx,eP,v6]).nullish()});const PP=ae([D("full"),D("incremental")]),DP=b({_meta:T(g(),E()).nullish(),syncKind:PP}),LP=b({_meta:T(g(),E()).nullish(),didChange:DP.nullish(),didClose:N$.nullish(),didFocus:z$.nullish(),didOpen:H$.nullish(),didSave:Z$.nullish()}),MP=b({_meta:T(g(),E()).nullish(),document:LP.nullish()}),OP=b({_meta:T(g(),E()).nullish(),context:ix.nullish(),events:MP.nullish()}),NP=b({_meta:T(g(),E()).nullish(),auth:C$.optional().default({}),loadSession:lt().optional().default(!1),mcpCapabilities:$$.optional().default({http:!1,sse:!1}),nes:OP.nullish(),positionEncoding:A6.nullish(),promptCapabilities:vx.optional().default({audio:!1,embeddedContext:!1,image:!1}),sessionCapabilities:pP.optional().default({})}),zP=b({_meta:T(g(),E()).nullish(),agentCapabilities:NP.optional().default({auth:{},loadSession:!1,mcpCapabilities:{http:!1,sse:!1},promptCapabilities:{audio:!1,embeddedContext:!1,image:!1},sessionCapabilities:{}}),agentInfo:S6.nullish(),authMethods:G(e$).optional().default([]),protocolVersion:E6}),HP=b({_meta:T(g(),E()).nullish(),mimeType:g().nullish(),text:g(),uri:g()}),ZP=ae([HP,r$]),UP=b({_meta:T(g(),E()).nullish(),annotations:hh.nullish(),resource:ZP}),W1=ae([IP.and(b({type:D("text")})),Ix.and(b({type:D("image")})),Rx.and(b({type:D("audio")})),$x.and(b({type:D("resource_link")})),UP.and(b({type:D("resource")}))]),FP=b({_meta:T(g(),E()).nullish(),content:W1}),ym=b({_meta:T(g(),E()).nullish(),content:W1,messageId:g().nullish()}),qP=b({_meta:T(g(),E()).nullish(),messageId:g().nullish(),prompt:G(W1),sessionId:be}),VP=b({anyOf:G(f6)}),P6=ae([FP.and(b({type:D("content")})),c$.and(b({type:D("diff")})),TP.and(b({type:D("terminal")}))]),D6=g(),L6=b({_meta:T(g(),E()).nullish(),line:ie().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),path:g()}),M6=ae([D("pending"),D("in_progress"),D("completed"),D("failed")]),O6=ae([D("read"),D("edit"),D("delete"),D("move"),D("search"),D("execute"),D("think"),D("fetch"),D("switch_mode"),D("other")]),BP=b({_meta:T(g(),E()).nullish(),content:G(P6).optional(),kind:O6.optional(),locations:G(L6).optional(),rawInput:E().optional(),rawOutput:E().optional(),status:M6.optional(),title:g(),toolCallId:D6}),N6=b({_meta:T(g(),E()).nullish(),content:G(P6).nullish(),kind:O6.nullish(),locations:G(L6).nullish(),rawInput:E().optional(),rawOutput:E().optional(),status:M6.nullish(),title:g().nullish(),toolCallId:D6}),z6=b({_meta:T(g(),E()).nullish(),options:G(lx),sessionId:be,toolCall:N6}),WP=b({_meta:T(g(),E()).nullish(),hint:g()}),jP=WP,GP=b({_meta:T(g(),E()).nullish(),description:g(),input:jP.nullish(),name:g()}),YP=b({_meta:T(g(),E()).nullish(),availableCommands:G(GP)}),KP=b({enum:G(g()),type:v$}),JP=ae([KP,VP]),XP=b({default:G(g()).nullish(),description:g().nullish(),items:JP,maxItems:ie().nullish(),minItems:ie().nullish(),title:g().nullish()}),QP=ae([AP.and(b({type:D("string")})),ox.and(b({type:D("number")})),A$.and(b({type:D("integer")})),i$.and(b({type:D("boolean")})),XP.and(b({type:D("array")}))]),e5=b({description:g().nullish(),properties:T(g(),QP).optional().default({}),required:G(g()).nullish(),title:g().nullish(),type:g$.optional().default("object")}),t5=b({requestedSchema:e5}),n5=Mp(ae([t5.and(b({mode:D("form")})),b$.and(b({mode:D("url")}))]),b({_meta:T(g(),E()).nullish(),message:g(),sessionId:be})),r5=b({cachedReadTokens:ie().nullish(),cachedWriteTokens:ie().nullish(),inputTokens:ie(),outputTokens:ie(),thoughtTokens:ie().nullish(),totalTokens:ie()}),i5=b({_meta:T(g(),E()).nullish(),stopReason:SP,usage:r5.nullish(),userMessageId:g().nullish()});ae([b({id:Xo,result:ae([zP,n$,I$,uP,cP,rP,lP,hP,o$,vP,mP,i5,wP,bP,kP,s$,w6])}),b({error:g6,id:Xo})]);const s5=b({_meta:T(g(),E()).nullish(),cost:a$.nullish(),size:ie(),used:ie()}),o5=ae([ym.and(b({sessionUpdate:D("user_message_chunk")})),ym.and(b({sessionUpdate:D("agent_message_chunk")})),ym.and(b({sessionUpdate:D("agent_thought_chunk")})),BP.and(b({sessionUpdate:D("tool_call")})),N6.and(b({sessionUpdate:D("tool_call_update")})),dx.and(b({sessionUpdate:D("plan")})),YP.and(b({sessionUpdate:D("available_commands_update")})),oP.and(b({sessionUpdate:D("current_mode_update")})),Fx.and(b({sessionUpdate:D("config_option_update")})),iP.and(b({sessionUpdate:D("session_info_update")})),s5.and(b({sessionUpdate:D("usage_update")}))]),H6=b({_meta:T(g(),E()).nullish(),sessionId:be,update:o5});b({method:g(),params:ae([H6,f$,v6]).nullish()});const Z6=b({_meta:T(g(),E()).nullish(),sessionId:be,terminalId:g()}),a5=b({_meta:T(g(),E()).nullish(),exitCode:ie().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),signal:g().nullish()}),l5=b({name:g(),uri:g()}),c5=b({_meta:T(g(),E()).nullish(),repository:X$.nullish(),workspaceFolders:G(l5).nullish(),workspaceUri:g().nullish()});b({id:Xo,method:g(),params:ae([yx,t$,R$,sx,Qx,k$,Xx,tP,jx,gP,fP,qP,yP,c5,EP,Wx,y6]).nullish()});const U6=b({_meta:T(g(),E()).nullish(),content:g(),path:g(),sessionId:be});b({id:Xo,method:g(),params:ae([U6,I6,z6,C6,x6,$6,Z6,R6,n5,y6]).nullish()});const u5=b({_meta:T(g(),E()).nullish()});ae([b({id:Xo,result:ae([u5,kx,Dx,l$,RP,Tx,a5,E$,m$,w6])}),b({error:g6,id:Xo})]);var we;class h5{constructor(t,e){m(this,we);const r=t(this),i=async(a,l)=>{var c,u,p,f,y,v,S;switch(a){case Nr.fs_write_text_file:{const _=U6.parse(l);return(c=r.writeTextFile)==null?void 0:c.call(r,_)}case Nr.fs_read_text_file:{const _=I6.parse(l);return(u=r.readTextFile)==null?void 0:u.call(r,_)}case Nr.session_request_permission:{const _=z6.parse(l);return r.requestPermission(_)}case Nr.terminal_create:{const _=C6.parse(l);return(p=r.createTerminal)==null?void 0:p.call(r,_)}case Nr.terminal_output:{const _=x6.parse(l);return(f=r.terminalOutput)==null?void 0:f.call(r,_)}case Nr.terminal_release:{const _=$6.parse(l);return await((y=r.releaseTerminal)==null?void 0:y.call(r,_))??{}}case Nr.terminal_wait_for_exit:{const _=Z6.parse(l);return(v=r.waitForTerminalExit)==null?void 0:v.call(r,_)}case Nr.terminal_kill:{const _=R6.parse(l);return await((S=r.killTerminal)==null?void 0:S.call(r,_))??{}}default:if(r.extMethod)return r.extMethod(a,l);throw rt.methodNotFound(a)}},s=async(a,l)=>{switch(a){case Nr.session_update:{const c=H6.parse(l);return r.sessionUpdate(c)}default:if(r.extNotification)return r.extNotification(a,l);throw rt.methodNotFound(a)}};d(this,we,new d5(i,s,e))}async initialize(t){return await o(this,we).sendRequest(De.initialize,t)}async newSession(t){return await o(this,we).sendRequest(De.session_new,t)}async loadSession(t){return await o(this,we).sendRequest(De.session_load,t)??{}}async unstable_forkSession(t){return await o(this,we).sendRequest(De.session_fork,t)}async listSessions(t){return await o(this,we).sendRequest(De.session_list,t)}async unstable_resumeSession(t){return await o(this,we).sendRequest(De.session_resume,t)}async unstable_closeSession(t){return await o(this,we).sendRequest(De.session_close,t)}async setSessionMode(t){return await o(this,we).sendRequest(De.session_set_mode,t)??{}}async unstable_setSessionModel(t){return await o(this,we).sendRequest(De.session_set_model,t)??{}}async setSessionConfigOption(t){return await o(this,we).sendRequest(De.session_set_config_option,t)}async authenticate(t){return await o(this,we).sendRequest(De.authenticate,t)??{}}async unstable_logout(t){return await o(this,we).sendRequest(De.logout,t)??{}}async prompt(t){return await o(this,we).sendRequest(De.session_prompt,t)}async cancel(t){return await o(this,we).sendNotification(De.session_cancel,t)}async unstable_startNes(t){return await o(this,we).sendRequest(De.nes_start,t)}async unstable_suggestNes(t){return await o(this,we).sendRequest(De.nes_suggest,t)}async unstable_closeNes(t){return await o(this,we).sendRequest(De.nes_close,t)??{}}async unstable_didOpenDocument(t){return await o(this,we).sendNotification(De.document_did_open,t)}async unstable_didChangeDocument(t){return await o(this,we).sendNotification(De.document_did_change,t)}async unstable_didCloseDocument(t){return await o(this,we).sendNotification(De.document_did_close,t)}async unstable_didSaveDocument(t){return await o(this,we).sendNotification(De.document_did_save,t)}async unstable_didFocusDocument(t){return await o(this,we).sendNotification(De.document_did_focus,t)}async unstable_acceptNes(t){return await o(this,we).sendNotification(De.nes_accept,t)}async unstable_rejectNes(t){return await o(this,we).sendNotification(De.nes_reject,t)}async extMethod(t,e){return await o(this,we).sendRequest(t,e)}async extNotification(t,e){return await o(this,we).sendNotification(t,e)}get signal(){return o(this,we).signal}get closed(){return o(this,we).closed}}we=new WeakMap;var qi,Nd,nu,ru,za,Ha,sr,iu,Ze,F6,Vm,q6,V6,B6,W6,Bm,Sc;class d5{constructor(t,e,r){m(this,Ze);m(this,qi,new Map);m(this,Nd,0);m(this,nu);m(this,ru);m(this,za);m(this,Ha,Promise.resolve());m(this,sr,new AbortController);m(this,iu);d(this,nu,t),d(this,ru,e),d(this,za,r),d(this,iu,new Promise(i=>{o(this,sr).signal.addEventListener("abort",()=>i())})),h(this,Ze,F6).call(this)}get signal(){return o(this,sr).signal}get closed(){return o(this,iu)}async sendRequest(t,e){h(this,Ze,Bm).call(this);const r=Ah(this,Nd)._++,i=new Promise((s,a)=>{o(this,qi).set(r,{resolve:s,reject:a})});return await h(this,Ze,Sc).call(this,{jsonrpc:"2.0",id:r,method:t,params:e}),i}async sendNotification(t,e){h(this,Ze,Bm).call(this),await h(this,Ze,Sc).call(this,{jsonrpc:"2.0",method:t,params:e})}}qi=new WeakMap,Nd=new WeakMap,nu=new WeakMap,ru=new WeakMap,za=new WeakMap,Ha=new WeakMap,sr=new WeakMap,iu=new WeakMap,Ze=new WeakSet,F6=async function(){let t;try{const e=o(this,za).readable.getReader();try{for(;!o(this,sr).signal.aborted;){const{value:r,done:i}=await e.read();if(i)break;if(r)try{h(this,Ze,q6).call(this,r)}catch(s){console.error("Unexpected error during message processing:",r,s),"id"in r&&r.id!==void 0&&h(this,Ze,Sc).call(this,{jsonrpc:"2.0",id:r.id,error:{code:-32700,message:"Parse error"}})}}}finally{e.releaseLock()}}catch(e){t=e}finally{h(this,Ze,Vm).call(this,t)}},Vm=function(t){if(o(this,sr).signal.aborted)return;const e=t??new Error("ACP connection closed");for(const r of o(this,qi).values())r.reject(e);o(this,qi).clear(),o(this,sr).abort(e)},q6=async function(t){if("method"in t&&"id"in t){const e=await h(this,Ze,V6).call(this,t.method,t.params);"error"in e&&console.error("Error handling request",t,e.error),await h(this,Ze,Sc).call(this,{jsonrpc:"2.0",id:t.id,...e})}else if("method"in t){const e=await h(this,Ze,B6).call(this,t.method,t.params);"error"in e&&console.error("Error handling notification",t,e.error)}else"id"in t?h(this,Ze,W6).call(this,t):console.error("Invalid message",{message:t})},V6=async function(t,e){try{return{result:await o(this,nu).call(this,t,e)??null}}catch(r){if(r instanceof rt)return r.toResult();if(r instanceof v2)return rt.invalidParams(r.format()).toResult();let i;(r instanceof Error||typeof r=="object"&&r!=null&&"message"in r&&typeof r.message=="string")&&(i=r.message);try{return rt.internalError(i?JSON.parse(i):{}).toResult()}catch{return rt.internalError({details:i}).toResult()}}},B6=async function(t,e){try{return await o(this,ru).call(this,t,e),{result:null}}catch(r){if(r instanceof rt)return r.toResult();if(r instanceof v2)return rt.invalidParams(r.format()).toResult();let i;(r instanceof Error||typeof r=="object"&&r!=null&&"message"in r&&typeof r.message=="string")&&(i=r.message);try{return rt.internalError(i?JSON.parse(i):{}).toResult()}catch{return rt.internalError({details:i}).toResult()}}},W6=function(t){const e=o(this,qi).get(t.id);if(e){if("result"in t)e.resolve(t.result);else if("error"in t){const{code:r,message:i,data:s}=t.error;e.reject(new rt(r,i,s))}o(this,qi).delete(t.id)}else console.error("Got response to unknown request",t.id)},Bm=function(){if(o(this,sr).signal.aborted)throw o(this,sr).signal.reason??new Error("ACP connection closed")},Sc=async function(t){return d(this,Ha,o(this,Ha).then(async()=>{const e=o(this,za).writable.getWriter();try{await e.write(t)}finally{e.releaseLock()}}).catch(e=>{h(this,Ze,Vm).call(this,e)})),o(this,Ha)};class rt extends Error{constructor(e,r,i){super(r);$(this,"code");$(this,"data");this.code=e,this.name="RequestError",this.data=i}static parseError(e,r){return new rt(-32700,`Parse error${r?`: ${r}`:""}`,e)}static invalidRequest(e,r){return new rt(-32600,`Invalid request${r?`: ${r}`:""}`,e)}static methodNotFound(e){return new rt(-32601,`"Method not found": ${e}`,{method:e})}static invalidParams(e,r){return new rt(-32602,`Invalid params${r?`: ${r}`:""}`,e)}static internalError(e,r){return new rt(-32603,`Internal error${r?`: ${r}`:""}`,e)}static authRequired(e,r){return new rt(-32e3,`Authentication required${r?`: ${r}`:""}`,e)}static resourceNotFound(e){return new rt(-32002,`Resource not found${e?`: ${e}`:""}`,e&&{uri:e})}toResult(){return{error:{code:this.code,message:this.message,data:this.data}}}toErrorResponse(){return{code:this.code,message:this.message,data:this.data}}}function p5(n,t,e){const r=n.dispose.bind(n);n.dispose=(()=>{if(!t())return e(),r()})}function j6(n){var e;class t extends n{constructor(...s){super(...s);m(this,e,!1);p5(this,()=>o(this,e),()=>{d(this,e,!0)})}[Symbol.dispose](){this.dispose()}get disposed(){return o(this,e)}}return e=new WeakMap,t}const f5=/^Sender \(untrusted metadata\):\n```json\n[\s\S]*?\n```\n\n?/,m5=/^\[[^\n]*Working directory:[^\n]*\]\n\n?/,g5=/\[Television channel context\][\s\S]*?\[\/Television channel context\]\n*/,v5=/\b(tv|television|channel|artifact|artifacts|viewer|filmstrip|layout|focus)\b/i,y5=/^[A-Za-z0-9_@%+=:,./-]+$/,w5=/\[\[\s*(?:reply_to_current|reply_to\s*:\s*[^\]\n]+|audio_as_voice)\s*\]\]\s*/gi,b5="single_session",S5={name:"television-acp-client",version:"0.0.0"},G6="agent:main:television",_5=j6(Ei);var Za,or,Qt,ar,Vi,Mn,Wr,lr,On,Bi,Nn,Ua,Fa,cr,Et,jr,qa,uo,Gr,Wi,su,zn,ur,zd,hr,M,Wm,Y6,K6,J6,Fh,X6,Q6,eS,tS,nS,rS,iS,Vs,ga,va,Hr,sS,ya,jm,Gm,qh,oS,Vh,Ym,Km,ou,au,Bh,wa,Jm,aS;class A5 extends _5{constructor(e){super();m(this,M);m(this,Za,"disconnected");m(this,or,null);m(this,Qt,new Map);m(this,ar,null);m(this,Vi,null);m(this,Mn,null);m(this,Wr,null);m(this,lr,null);m(this,On,null);m(this,Bi);m(this,Nn,null);m(this,Ua,0);m(this,Fa,1);m(this,cr,null);m(this,Et,null);m(this,jr,!1);m(this,qa,!1);m(this,uo,!1);m(this,Gr,null);m(this,Wi,new Set);m(this,su);m(this,zn);m(this,ur);m(this,zd,e=>{h(this,M,K6).call(this,e)});m(this,hr,null);m(this,ou,()=>{h(this,M,wa).call(this,"ACP bridge websocket closed")});m(this,au,()=>{h(this,M,wa).call(this,"ACP bridge websocket error")});d(this,zn,e),d(this,ur,e.sessionMode??b5),d(this,Bi,e.mappedSessionStore??E5()),d(this,su,e.createSocket??(r=>new WebSocket(r)))}get status(){return o(this,Za)}get messages(){return[...o(this,Qt).values()]}get enabled(){return o(this,zn).enabled??!1}setToken(e){o(this,zn).token=e??""}setEnabled(e){o(this,zn).enabled=e,e||(h(this,M,Bh).call(this),d(this,or,null),h(this,M,Hr).call(this,"disconnected"))}async connect(){if(this.disposed)throw new Error("ACPClient has been disposed");if(this.enabled&&this.status==="disconnected"){o(this,Vi)===null&&(d(this,or,null),d(this,Vi,h(this,M,Y6).call(this)));try{await o(this,Vi),await h(this,M,Fh).call(this)}catch(e){throw h(this,M,wa).call(this,wm(e)),e}}}dispose(){h(this,M,Bh).call(this),d(this,or,null),h(this,M,Hr).call(this,"disposed")}async sendMessage(e){if(await this.connect(),(this.status==="running"||this.status==="cancelling")&&(await this.cancel(),await h(this,M,Wm).call(this,"ready")),(o(this,lr)===null||o(this,Nn)!==h(this,M,Vh).call(this))&&await h(this,M,Fh).call(this),this.status!=="ready")throw new Error("ACPClient is not ready to send a new message");const r=e.text.trim();if(!r)throw new Error("Cannot send an empty message");h(this,M,ga).call(this,{id:h(this,M,ya).call(this,"user"),kind:"user",text:r,status:"final"}),h(this,M,Hr).call(this,"running");try{const i=await h(this,M,qh).call(this).prompt({sessionId:h(this,M,Gm).call(this),prompt:[{type:"text",text:h(this,M,sS).call(this,r)}]});h(this,M,Vs).call(this,i.stopReason==="cancelled"?"cancelled":"final"),h(this,M,Hr).call(this,"ready")}catch(i){throw h(this,M,aS).call(this)||(h(this,M,Vs).call(this,"error"),h(this,M,Hr).call(this,"ready")),i}}async startNewSession(){var r;await this.connect(),(this.status==="running"||this.status==="cancelling")&&(await this.cancel(),await h(this,M,Wm).call(this,"ready"));const e=h(this,M,Vh).call(this);((r=o(this,On))==null?void 0:r.sessionIdStrategy)==="mapped"?o(this,Bi).clearActualSessionId(e):d(this,Ua,o(this,Ua)+1),d(this,Mn,null),d(this,Wr,null),d(this,lr,null),d(this,Nn,null),h(this,M,Jm).call(this)}async cancel(){this.status==="running"&&(h(this,M,Hr).call(this,"cancelling"),await h(this,M,qh).call(this).cancel({sessionId:h(this,M,Gm).call(this)}))}setChannelContext(e){var s,a,l;if(e===null){if(o(this,Et)===null)return;d(this,Et,null),d(this,jr,!1);return}const r={channelID:e.channelID,channelName:e.channelName};if(((s=o(this,Et))==null?void 0:s.channelID)===r.channelID&&((a=o(this,Et))==null?void 0:a.channelName)===r.channelName)return;const i=((l=o(this,Et))==null?void 0:l.channelID)??null;if(d(this,Et,r),o(this,ur)==="single_session"){(!o(this,Nn)||i!==r.channelID)&&d(this,jr,!0);return}o(this,Nn)!==h(this,M,Ym).call(this,r.channelID)&&(d(this,Mn,null),d(this,Wr,null),o(this,ar)&&this.status==="ready"&&h(this,M,Fh).call(this).catch(c=>{h(this,M,wa).call(this,wm(c))}))}}Za=new WeakMap,or=new WeakMap,Qt=new WeakMap,ar=new WeakMap,Vi=new WeakMap,Mn=new WeakMap,Wr=new WeakMap,lr=new WeakMap,On=new WeakMap,Bi=new WeakMap,Nn=new WeakMap,Ua=new WeakMap,Fa=new WeakMap,cr=new WeakMap,Et=new WeakMap,jr=new WeakMap,qa=new WeakMap,uo=new WeakMap,Gr=new WeakMap,Wi=new WeakMap,su=new WeakMap,zn=new WeakMap,ur=new WeakMap,zd=new WeakMap,hr=new WeakMap,M=new WeakSet,Wm=async function(e){if(this.status!==e){if(this.status==="disposed")throw new Error("ACPClient has been disposed");if(this.status==="disconnected")throw new Error(o(this,or)??"ACPClient is disconnected");await new Promise((r,i)=>{const s=()=>{this.removeEventListener("status-changed",a)},a=()=>{if(this.status===e){s(),r();return}if(this.status==="disposed"){s(),i(new Error("ACPClient has been disposed"));return}this.status==="disconnected"&&(s(),i(new Error(o(this,or)??"ACPClient is disconnected")))};this.addEventListener("status-changed",a)})}},Y6=async function(){try{const{stream:e,socket:r,metadata:i}=await R5({serverURL:o(this,zn).serverURL,token:o(this,zn).token,createSocket:o(this,su),onDisconnect:o(this,zd)});d(this,On,i),d(this,hr,r),r.addEventListener("close",o(this,ou)),r.addEventListener("error",o(this,au)),d(this,ar,new h5(s=>({connection:s,sessionUpdate:async a=>{await h(this,M,Q6).call(this,a)},requestPermission:async a=>h(this,M,eS).call(this,a)}),e)),await o(this,ar).initialize({protocolVersion:GI,clientCapabilities:{},clientInfo:S5})}catch(e){throw e}},K6=function(e){h(this,M,wa).call(this,wm(e))},J6=function(e){const r=e==null?void 0:e.models;if(!(r!=null&&r.currentModelId))return;const i=r.availableModels.find(s=>s.modelId===r.currentModelId);console.info("[ACPClient] Current model:",(i==null?void 0:i.name)??r.currentModelId,`(${r.currentModelId})`)},Fh=async function(){const e=h(this,M,Vh).call(this);if(o(this,Mn)&&o(this,Wr)===e){await o(this,Mn);return}d(this,Wr,e),d(this,Mn,h(this,M,X6).call(this,e)),await o(this,Mn)},X6=async function(e){var c;const r=h(this,M,qh).call(this);h(this,M,Jm).call(this);let i,s=!1,a=null;const l={cwd:h(this,M,oS).call(this),mcpServers:[],_meta:{sessionKey:e}};try{if(d(this,uo,!0),d(this,Gr,null),((c=o(this,On))==null?void 0:c.sessionIdStrategy)==="mapped"){const u=o(this,Bi).getActualSessionId(e);if(u)try{const p=await r.loadSession({...l,sessionId:u});if(k5(p))throw new Error("Mapped ACP session was not found");a=p,i=u,s=!0}catch{const p=await r.newSession(l);a=p,i=p.sessionId,o(this,Bi).setActualSessionId(e,i),s=!1}else{const p=await r.newSession(l);a=p,i=p.sessionId,o(this,Bi).setActualSessionId(e,i),s=!1}}else try{a=await r.loadSession({...l,sessionId:e}),i=e,s=o(this,Qt).size>0}catch{const u=await r.newSession(l);a=u,i=u.sessionId,s=!1}}finally{d(this,uo,!1),d(this,Gr,null),h(this,M,Vs).call(this,"final")}h(this,M,J6).call(this,a),await r.setSessionConfigOption({sessionId:i,configId:"verbose_level",value:"full"}),d(this,lr,i),d(this,Nn,e),d(this,qa,!0),s?(o(this,Wi).add(e),o(this,ur)==="single_session"&&d(this,jr,!1)):(o(this,Wi).delete(e),d(this,jr,o(this,ur)==="single_session")),d(this,or,null),h(this,M,Hr).call(this,"ready")},Q6=async function(e){const r=e.update;switch(r.sessionUpdate){case"user_message_chunk":r.content.type==="text"&&h(this,M,iS).call(this,r.content.text);return;case"agent_message_chunk":r.content.type==="text"&&h(this,M,tS).call(this,r.content.text);return;case"tool_call":h(this,M,nS).call(this,r);return;case"tool_call_update":h(this,M,rS).call(this,r);return;case"agent_thought_chunk":return;default:return}},eS=async function(e){return{outcome:{outcome:"cancelled"}}},tS=function(e){d(this,Gr,null);const r=C5(e);if(!r)return;if(!o(this,cr)){const s={id:h(this,M,ya).call(this,"assistant"),kind:"assistant",text:r,status:"streaming"};d(this,cr,s.id),h(this,M,ga).call(this,s);return}const i=o(this,Qt).get(o(this,cr));if(!i||i.kind!=="assistant")throw new Error("Open assistant message invariant violated");h(this,M,va).call(this,{...i,text:`${i.text}${r}`,status:"streaming"})},nS=function(e){h(this,M,Vs).call(this,"final");const r=h(this,M,jm).call(this,e.toolCallId),i=I2("content"in e?e.content:void 0),s={id:(r==null?void 0:r.id)??h(this,M,ya).call(this,"tool"),kind:"tool_call",toolCallId:e.toolCallId,title:e.title,toolKind:e.kind??"other",status:e.status==="failed"?"failed":e.status==="completed"?"completed":"in_progress",text:(r==null?void 0:r.text)??i,locations:e.locations??(r==null?void 0:r.locations)};if(r){h(this,M,va).call(this,s);return}h(this,M,ga).call(this,s)},rS=function(e){const r=h(this,M,jm).call(this,e.toolCallId),i=(r==null?void 0:r.text)??"",s=I2(e.content),a=s?`${i}${s}`:i,l={id:(r==null?void 0:r.id)??h(this,M,ya).call(this,"tool"),kind:"tool_call",toolCallId:e.toolCallId,title:(r==null?void 0:r.title)??e.toolCallId,toolKind:(r==null?void 0:r.toolKind)??"other",status:e.status==="failed"?"failed":e.status==="completed"?"completed":"in_progress",text:a,locations:e.locations??(r==null?void 0:r.locations)};if(r){h(this,M,va).call(this,l);return}h(this,M,ga).call(this,l)},iS=function(e){if(h(this,M,Vs).call(this,"final"),!e)return;const r=o(this,uo)?o(this,Gr):null;if(!r){const s=R2(e);if(!s)return;const a={id:h(this,M,ya).call(this,"user"),kind:"user",text:s,status:"final"};h(this,M,ga).call(this,a),o(this,uo)&&d(this,Gr,a.id);return}const i=o(this,Qt).get(r);if(!i||i.kind!=="user")throw new Error("Replay user message invariant violated");h(this,M,va).call(this,{...i,text:R2(`${i.text}${e}`)})},Vs=function(e){if(!o(this,cr))return;const r=o(this,Qt).get(o(this,cr));(r==null?void 0:r.kind)==="assistant"&&h(this,M,va).call(this,{...r,status:e}),d(this,cr,null)},ga=function(e){o(this,Qt).set(e.id,e),this.dispatchEvent(new mm("messages-changed"))},va=function(e){o(this,Qt).set(e.id,e),this.dispatchEvent(new mm("messages-changed"))},Hr=function(e){o(this,Za)!==e&&(d(this,Za,e),this.dispatchEvent(new $k("status-changed")))},sS=function(e){var u;const r=o(this,Nn);if(!r)return e;const i=o(this,Et)?o(this,ur)==="single_session"?o(this,jr)||!o(this,Wi).has(r):!o(this,Wi).has(r):!1,s=o(this,qa)&&(o(this,Et)!==null||v5.test(e));if(!(s||i))return e;s&&d(this,qa,!1),i&&(d(this,jr,!1),o(this,Wi).add(r));const l=["[Television channel context]","This chat session is coming from a Television client.","Using Television requires the knowledge in the `television` skill. Re-read it only if it is not already in context or you know it changed.","If the skill is not installed, it can be installed via `tv skills install <your agent skills path>`."],c=((u=o(this,On))==null?void 0:u.tvArgs)??[];return c.length>0&&l.push(`To reach this Television server, add these arguments to each tv command that contacts it: ${c.map(x5).join(" ")}`),o(this,Et)?(l.push("This conversation is currently attached to the channel below."),l.push(`channel_id: ${o(this,Et).channelID}`),l.push(`channel_name: ${o(this,Et).channelName??""}`),l.push("When the user asks to inspect or change Television state with the tv CLI, use this channel ID with the --channel argument.")):l.push("There is currently no active Television channel."),l.push("[/Television channel context]","",e),l.join(`
43
- `)},ya=function(e){const r=`${e}-${o(this,Fa)}`;return d(this,Fa,o(this,Fa)+1),r},jm=function(e){for(const r of o(this,Qt).values())if((r==null?void 0:r.kind)==="tool_call"&&r.toolCallId===e)return r;return null},Gm=function(){if(!o(this,lr))throw new Error("ACP session is not ready");return o(this,lr)},qh=function(){if(!o(this,ar))throw new Error("ACP connection is not ready");return o(this,ar)},oS=function(){var r;const e=(r=o(this,On))==null?void 0:r.sessionCwd;if(!e)throw new Error("ACP bridge session cwd is not ready");return e},Vh=function(){var r;if(o(this,ur)==="single_session")return h(this,M,Km).call(this,`${G6}-${(o(this,zn).clientGUID??"default-client").toLowerCase()}`);const e=(r=o(this,Et))==null?void 0:r.channelID;if(!e)throw new Error("Channel context is required for per-channel session mode");return h(this,M,Ym).call(this,e)},Ym=function(e){return h(this,M,Km).call(this,T5(o(this,ur),e,o(this,zn).clientGUID??"default-client"))},Km=function(e){var r;return((r=o(this,On))==null?void 0:r.sessionIdStrategy)==="deterministic"&&o(this,Ua)>0?`${e}:epoch-${o(this,Ua)}`:e},ou=new WeakMap,au=new WeakMap,Bh=function(){d(this,ar,null),d(this,Vi,null),d(this,Mn,null),d(this,Wr,null),d(this,lr,null),d(this,Nn,null),d(this,On,null),o(this,hr)&&(o(this,hr).removeEventListener("close",o(this,ou)),o(this,hr).removeEventListener("error",o(this,au)),o(this,hr).close(),d(this,hr,null))},wa=function(e){const r=o(this,ar)!==null||o(this,Vi)!==null||o(this,Mn)!==null||o(this,Wr)!==null||o(this,lr)!==null||o(this,Nn)!==null||o(this,On)!==null||o(this,hr)!==null;this.disposed||this.status==="disconnected"&&!r||(h(this,M,Vs).call(this,"error"),h(this,M,Bh).call(this),d(this,or,e??null),h(this,M,Hr).call(this,"disconnected"))},Jm=function(){const e=o(this,Qt).size>0;d(this,cr,null),d(this,Gr,null),d(this,Fa,1),o(this,Qt).clear(),e&&this.dispatchEvent(new mm("messages-changed"))},aS=function(){return this.status==="disconnected"};function E5(){const n=new Map;return{getActualSessionId(t){return n.get(t)??null},setActualSessionId(t,e){n.set(t,e)},clearActualSessionId(t){n.delete(t)}}}function k5(n){return n==null?!0:typeof n=="object"&&Object.keys(n).length===0}function T5(n,t,e){return n==="single_session"?`${G6}-${e.toLowerCase()}`:`agent:main:television-${e.toLowerCase()}-${t.toLowerCase()}`}function lS(n){return n.replace(/^(?:\s*\n)+/,"")}function R2(n){let t=n;return t=t.replace(f5,""),t=t.replace(m5,""),t=t.replace(g5,""),t=lS(t),t}function C5(n){let t=n;return t=t.replace(w5,""),t=lS(t),t}function I2(n){return!n||n.length===0?"":n.flatMap(t=>t.type==="content"&&t.content.type==="text"?[t.content.text]:[]).join("")}async function R5(n){const t=n.createSocket(D5(n.serverURL,n.token));let e=!1,r,i;const s=new Promise((u,p)=>{r=u,i=p}),a=new ReadableStream({start(u){let p=!1;const f=()=>{t.send(JSON.stringify({type:"acp-bridge-connect"}))},y=_=>{const I=P5(_);if(!I)return;let Z;try{Z=JSON.parse(I)}catch(L){const z=L instanceof Error?L:new Error(String(L));i(z),u.error(z);return}switch(Z.type){case"acp-bridge-status":if(Z.status==="ready"){let L;try{L=I5(Z)}catch(z){const P=z instanceof Error?z:new Error(String(z));e||i(P),u.error(P);return}e||(e=!0,r(L));return}if(Z.status==="error"||Z.status==="exited"){const L=new Error(Z.error??`ACP bridge ${Z.status}`);e||i(L),u.error(L)}return;case"acp-bridge-message":u.enqueue(Z.message);return}},v=()=>{var I;if(p)return;p=!0;const _=new Error("ACP bridge websocket closed");e||i(_),(I=n.onDisconnect)==null||I.call(n,_),u.close()},S=()=>{var I;if(p)return;p=!0;const _=new Error("ACP bridge websocket error");e||i(_),(I=n.onDisconnect)==null||I.call(n,_),u.error(_)};t.addEventListener("open",f),t.addEventListener("message",y),t.addEventListener("close",v),t.addEventListener("error",S)}}),l=new WritableStream({async write(u){await s,t.send(JSON.stringify({type:"acp-bridge-message",message:u}))},close(){t.close()},abort(){t.close()}}),c=await s;return{stream:{readable:a,writable:l},socket:t,metadata:c}}function I5(n){const{agent:t,sessionIdStrategy:e,sessionCwd:r,tvArgs:i}=n;if((t==="openclaw"||t==="hermes")&&(e==="deterministic"||e==="mapped")&&typeof r=="string"&&r.length>0&&$5(i))return{agent:t,sessionIdStrategy:e,sessionCwd:r,tvArgs:i};throw new Error("ACP bridge ready status missing bootstrap metadata")}function $5(n){return Array.isArray(n)&&n.every(t=>typeof t=="string")}function x5(n){return y5.test(n)?n:`'${n.replace(/'/g,"'\\''")}'`}function P5(n){if(typeof n=="string")return n;if(n instanceof Uint8Array)return new TextDecoder().decode(n);if(typeof Buffer<"u"&&n instanceof Buffer)return n.toString("utf8");if(typeof n=="object"&&n!==null&&"data"in n){const t=n.data;if(typeof t=="string")return t;if(t instanceof Uint8Array)return new TextDecoder().decode(t);if(Array.isArray(t))return Buffer.concat(t).toString("utf8")}return null}function D5(n,t){const e=new URL(n);return e.protocol=e.protocol==="https:"?"wss:":"ws:",e.pathname="/acp",e.search="",e.searchParams.set("token",t),e.hash="",e.toString()}function wm(n){return n instanceof Error?n.message:String(n)}const $2="television.acpClientGUID",x2="television.acpMappedSessions",P2=1;var Va;class L5{constructor(){m(this,Va,new Map)}getActualSessionId(t){return o(this,Va).get(t)??null}setActualSessionId(t,e){o(this,Va).set(t,e)}clearActualSessionId(t){o(this,Va).delete(t)}}Va=new WeakMap;var Ba,lu,on,Wh,jh,Xm;class M5{constructor(t,e){m(this,on);m(this,Ba);m(this,lu);d(this,Ba,t),d(this,lu,e)}getActualSessionId(t){const e=h(this,on,jh).call(this)[h(this,on,Wh).call(this,t)];return typeof e=="string"&&e.length>0?e:null}setActualSessionId(t,e){const r=h(this,on,jh).call(this);r[h(this,on,Wh).call(this,t)]=e,h(this,on,Xm).call(this,r)}clearActualSessionId(t){const e=h(this,on,jh).call(this);delete e[h(this,on,Wh).call(this,t)],h(this,on,Xm).call(this,e)}}Ba=new WeakMap,lu=new WeakMap,on=new WeakSet,Wh=function(t){return JSON.stringify([o(this,lu),t])},jh=function(){const t=o(this,Ba).getItem(x2);if(!t)return{};let e;try{e=JSON.parse(t)}catch{return{}}if(typeof e!="object"||e===null||Array.isArray(e))return{};const r=e;return r.version!==P2?{}:typeof r.entries!="object"||r.entries===null||Array.isArray(r.entries)?{}:Object.fromEntries(Object.entries(r.entries).filter(i=>typeof i[1]=="string"))},Xm=function(t){const e={version:P2,entries:t};o(this,Ba).setItem(x2,JSON.stringify(e))};function cS(){return typeof window>"u"?null:window.localStorage}function O5(n){const t=n.getItem($2);if(t)return t;const e=N1().toLowerCase();return n.setItem($2,e),e}const D2=4401,N5=401,$h=1e3,z5=3e4;class Gh extends Error{constructor(t="Authentication required"){super(t),this.name="AuthError"}}class H5 extends Ei{constructor(e){var a,l;super();$(this,"url");$(this,"name");$(this,"telemetryMeta");$(this,"status","unauthorized");$(this,"channels",new Map);$(this,"client");$(this,"acpClient");$(this,"_token");$(this,"attempting",!1);$(this,"nextRetryAt",null);$(this,"hasEverConnected",!1);$(this,"failedReconnectAttempts",0);$(this,"browserDemoMode",!1);$(this,"hasAuthRejected",!1);$(this,"bootState","pending");$(this,"serverVersion",null);$(this,"updateState",null);$(this,"decideBoot");$(this,"navigationPending");$(this,"createSocket");$(this,"createClient");$(this,"socket",null);$(this,"connectAttempt",0);$(this,"autoReconnect",!1);$(this,"retryTimer",null);$(this,"retryDelay",$h);$(this,"visibilityEventTarget");$(this,"networkEventTarget");$(this,"onVisibilityChange");$(this,"onNetworkOnline");$(this,"telemetryActivityAgent");this.url=Es(e.url),this.name=e.name,this.decideBoot=e.decideBoot??null,this.navigationPending=e.navigationPending??(()=>!1),this._token=e.token??null,this.telemetryMeta=e.telemetryMeta??null,this.createSocket=e.createSocket??(c=>new WebSocket(c)),this.createClient=e.createClient??((c,u,p)=>new rk(c,{token:u??void 0,onUnauthorized:()=>this.handleAuthRejected(),...p?{telemetryMeta:p}:{}})),this.client=this.createClient(this.url,this._token,this.telemetryMeta);const r=e.mappedSessionStore??(e.acpStorage?new M5(e.acpStorage,this.url):new L5);this.acpClient=new A5({serverURL:this.url,token:this._token??"",...e.createACPSocket?{createSocket:e.createACPSocket}:e.createSocket?{createSocket:e.createSocket}:{},...e.clientGUID?{clientGUID:e.clientGUID}:{},mappedSessionStore:r}),this.visibilityEventTarget=e.visibilityEventTarget!==void 0?e.visibilityEventTarget:typeof document<"u"?document:null,this.networkEventTarget=e.networkEventTarget!==void 0?e.networkEventTarget:typeof window<"u"?window:null,this.onVisibilityChange=()=>{this.isPageVisible()&&this.kickReconnect()},this.onNetworkOnline=()=>{this.kickReconnect()},(a=this.visibilityEventTarget)==null||a.addEventListener("visibilitychange",this.onVisibilityChange),(l=this.networkEventTarget)==null||l.addEventListener("online",this.onNetworkOnline);const i=e.telemetryDocumentTarget!==void 0?e.telemetryDocumentTarget:typeof document<"u"?document:null,s=e.telemetryWindowTarget!==void 0?e.telemetryWindowTarget:typeof window<"u"?window:null;this.telemetryActivityAgent=this.telemetryMeta&&i&&s?BI({meta:this.telemetryMeta,documentTarget:i,windowTarget:s,send:c=>this.sendTelemetryActivity(c)}):null}get token(){return this._token}clearToken(){this._token=null,this.acpClient.setToken(null),this.client=this.createClient(this.url,null,this.telemetryMeta)}async connect(e){this._token=e,this.hasAuthRejected=!1,this.acpClient.setToken(e),this.cancelRetryTimer(),this.retryDelay=$h,this.autoReconnect=!0,await this.attempt()}dispose(){var e,r,i,s;this.autoReconnect=!1,this.connectAttempt+=1,this.cancelRetryTimer(),(e=this.socket)==null||e.close(),this.socket=null,this.setStatus("unauthorized"),(r=this.visibilityEventTarget)==null||r.removeEventListener("visibilitychange",this.onVisibilityChange),(i=this.networkEventTarget)==null||i.removeEventListener("online",this.onNetworkOnline),(s=this.telemetryActivityAgent)==null||s.stop(),this.acpClient.dispose()}getViewURL(e){const r=Ad(e,this.renderOptions());return gi()?new URL(r.viewURL,this.url).toString():r.renderer==="proxy-iframe"?new URL(r.viewURL,this.url).toString():r.viewURL}async readDemoMode(){try{return await this.client.demoMode()}catch{return null}}renderOptions(){return{electron:gi(),browserDemo:this.browserDemoMode}}getContentURL(e){const r=Ad(e,this.renderOptions()).contentURL;return r===null?null:new URL(r,this.url).toString()}async createChannel(e){const{channel:r}=await this.client.channels.create({name:e});return this.channels.set(r.id,structuredClone(r)),r}applyServerEvent(e){switch(e.type){case"channel-created":this.channels.set(e.channel.id,structuredClone(e.channel)),this.dispatchEvent(new wc("channels-changed"));break;case"channel-updated":this.channels.set(e.channel.id,structuredClone(e.channel)),this.dispatchEvent(new wc("channels-changed"));break;case"channel-removed":this.channels.delete(e.channelID),this.dispatchEvent(new wc("channels-changed"));break;case"artifact-created":{const r=this.channels.get(e.channelID);r&&!ZE(r).includes(e.artifact.id)&&(r.layout=[...r.layout,{artifactIds:[e.artifact.id],geometry:{...d8},size:{...p8}}]);break}case"artifact-removed":{const r=this.channels.get(e.channelID);r&&(r.layout=Dm(r.layout,e.artifactID));break}case"artifact-updated":case"artifact-content-changed":case"channel-changed":case"pinned-channels-changed":case"theme-changed":case"appearance-changed":case"artifact-focus":break;default:return Z5(e,"server event")}}async attempt(){var i;this.attempting=!0,this.nextRetryAt=null,this.connectAttempt+=1,this.bootState="pending";const e=this.connectAttempt;(i=this.socket)==null||i.close(),this.client=this.createClient(this.url,this._token,this.telemetryMeta),this.setStatus("disconnected"),this.dispatchEvent(new Bt("change"));const r=this.createSocket(U5(this.url,this._token,this.telemetryMeta));return this.socket=r,await new Promise((s,a)=>{let l=!1,c=!1;const u=()=>{var y;l||this.connectAttempt!==e||(l=!0,c=!0,this.retryDelay=$h,this.hasEverConnected=!0,this.failedReconnectAttempts=0,this.setStatus("connected"),(y=this.telemetryActivityAgent)==null||y.start(),s())},p=y=>{l||this.connectAttempt!==e||(l=!0,a(y))},f=async()=>{const y=this.hasEverConnected;try{const[{channels:v},S,_]=await Promise.all([this.client.channels.list(),this.client.display.get(),y?null:this.readDemoMode()]);y||(this.browserDemoMode=(_==null?void 0:_.browserExternalPages)===!0),this.channels=new Map(v.map(I=>[I.id,structuredClone(I)])),this.acpClient.setEnabled(S.acpEnabled),this.dispatchEvent(new Bt("change")),y&&this.dispatchEvent(new wc("channels-changed")),this.dispatchEvent(new Zh("server-event",{serverURL:this.url,event:{type:"channel-changed",channelID:S.focusedChannelId}})),this.dispatchEvent(new Zh("server-event",{serverURL:this.url,event:{type:"pinned-channels-changed",pinnedChannelIds:[...S.pinnedChannelIds]}})),u(),y&&this.connectAttempt===e&&this.dispatchEvent(new E8("server-reconnected",{serverURL:this.url}))}catch(v){if(j5(v)){p(new Gh);return}p(v instanceof Error?v:new Error(String(v)))}};r.addEventListener("open",()=>{this.decideBoot===null&&(this.bootState="booted",this.navigationPending()||f())}),r.addEventListener("message",y=>{const v=W5(y);if(!v)return;if(v.type==="server-status"){const _=v;this.serverVersion=_.version,this.updateState=_.update??null;let I=!1;this.decideBoot!==null&&this.bootState==="pending"&&this.connectAttempt===e&&(this.decideBoot(_)==="boot"?(this.bootState="booted",I=!0):(this.bootState="halted",this.attempting=!1)),this.dispatchEvent(new k8("server-status",{serverURL:this.url,message:_})),I?this.navigationPending()||f():this.bootState==="halted"&&!this.navigationPending()&&this.dispatchEvent(new Bt("change"));return}if(!B5(v.type))return;const S=v;this.applyServerEvent(S),this.dispatchEvent(new Zh("server-event",{serverURL:this.url,event:S}))}),r.addEventListener("close",y=>{if(this.connectAttempt!==e)return;this.socket=null;const v=F5(y);if(!l){p(v===D2?new Gh:new Error("Connection closed before initialization"));return}if(c){if(v===D2){this.handleAuthRejected();return}this.handleTransportFailure(new Error("Connection closed"))}}),r.addEventListener("error",()=>{if(this.connectAttempt===e){if(l){if(!c)return;this.handleTransportFailure(new Error("WebSocket error"));return}p(new Error("WebSocket connection failed"))}})}).then(()=>{this.attempting=!1},s=>{throw this.attempting=!1,this.handleAttemptFailure(s),s})}handleAuthRejected(){this.hasAuthRejected=!0,this.autoReconnect=!1,this.cancelRetryTimer(),this.setStatus("unauthorized")}handleAttemptFailure(e){if(e instanceof Gh){this.handleAuthRejected();return}this.autoReconnect&&(this.hasEverConnected&&(this.failedReconnectAttempts+=1),this.scheduleRetry())}handleTransportFailure(e){this.autoReconnect&&(this.setStatus("disconnected"),this.scheduleRetry())}scheduleRetry(){this.cancelRetryTimer(),this.connectAttempt+=1;const e=this.retryDelay;this.retryDelay=Math.min(this.retryDelay*2,z5),this.nextRetryAt=Date.now()+e,this.retryTimer=setTimeout(()=>{this.retryTimer=null,this.attempt().catch(()=>{})},e),this.dispatchEvent(new Bt("change"))}cancelRetryTimer(){this.retryTimer!==null&&(clearTimeout(this.retryTimer),this.retryTimer=null),this.nextRetryAt!==null&&(this.nextRetryAt=null,this.dispatchEvent(new Bt("change")))}kickReconnect(){this.autoReconnect&&this.status!=="connected"&&(this.attempting||(this.cancelRetryTimer(),this.retryDelay=$h,this.attempt().catch(()=>{})))}sendTelemetryActivity(e){var r;this.status==="connected"&&((r=this.socket)==null||r.send(JSON.stringify(e)))}sendTelemetrySignal(e,r){var s;if(!this.telemetryMeta||this.status!=="connected"&&this.bootState!=="halted")return;const i={type:HE,clientId:this.telemetryMeta.clientId,event:e,properties:r};(s=this.socket)==null||s.send(JSON.stringify(i))}setStatus(e){this.status!==e&&(this.status=e,this.dispatchEvent(new Bt("change")))}isPageVisible(){return this.visibilityEventTarget===null?!0:this.visibilityEventTarget.visibilityState==="visible"}}function Z5(n,t){throw new Error(`Unexpected ${t}: ${JSON.stringify(n)}`)}function U5(n,t,e=null){const r=new URL(n);if(r.protocol=r.protocol==="https:"?"wss:":"ws:",r.pathname="/events",r.search="",t&&r.searchParams.set("token",t),e)for(const[i,s]of VI(e))r.searchParams.set(i,s);return r.hash="",r.toString()}function F5(n){return typeof n=="object"&&n!==null&&"code"in n&&typeof n.code=="number"?n.code:null}const q5={"artifact-created":!0,"artifact-updated":!0,"artifact-content-changed":!0,"artifact-removed":!0,"channel-created":!0,"channel-updated":!0,"channel-removed":!0,"channel-changed":!0,"pinned-channels-changed":!0,"theme-changed":!0,"appearance-changed":!0,"artifact-focus":!0},V5=new Set(Object.keys(q5));function B5(n){return V5.has(n)}function W5(n){const t=typeof n=="string"?n:typeof n=="object"&&n!==null&&"data"in n&&typeof n.data=="string"?n.data:"";if(!t)return null;let e;try{e=JSON.parse(t)}catch{return null}return typeof e!="object"||e===null||!("type"in e)||typeof e.type!="string"?null:e}function j5(n){return n instanceof Bl&&n.status===N5}const G5="Local";var dr,Hn,bi,uS,Qm,hS,cu,uu,hu,du,pu;class Y5 extends Ei{constructor(e){super();m(this,bi);$(this,"connection");$(this,"clientGUID");$(this,"acpStorage");$(this,"connectError",null);m(this,dr);m(this,Hn,!1);m(this,cu,()=>{o(this,Hn)||(h(this,bi,hS).call(this),this.dispatchEvent(new Bt("change")))});m(this,uu,e=>{o(this,Hn)||this.dispatchEvent(new Zh("server-event",{serverURL:e.serverURL,event:e.event}))});m(this,hu,()=>{o(this,Hn)||this.dispatchEvent(new wc("channels-changed"))});m(this,du,e=>{o(this,Hn)||this.dispatchEvent(new E8("server-reconnected",{serverURL:e.serverURL}))});m(this,pu,e=>{o(this,Hn)||this.dispatchEvent(new k8("server-status",{serverURL:e.serverURL,message:e.message}))});d(this,dr,e.localStore),this.acpStorage=e.acpStorage===void 0?cS():e.acpStorage,this.clientGUID=e.clientGUID??(this.acpStorage?O5(this.acpStorage):N1().toLowerCase());const r=Es(e.serverURL);e.launchToken!==void 0&&e.launchToken!==null&&o(this,dr).set(Lk(o(this,dr).get(),r,e.launchToken));const i=e.launchToken??e2(o(this,dr).get(),r),s=e.createSocket??(l=>new WebSocket(l)),a=e.createConnection??(l=>new H5(l));this.connection=a({url:r,name:e.connectionName??G5,token:i,createSocket:s,clientGUID:this.clientGUID,acpStorage:this.acpStorage,telemetryMeta:e.telemetryMeta??null,decideBoot:e.decideBoot,navigationPending:e.navigationPending}),this.connection.addEventListener("change",o(this,cu)),this.connection.addEventListener("server-event",o(this,uu)),this.connection.addEventListener("channels-changed",o(this,hu)),this.connection.addEventListener("server-reconnected",o(this,du)),this.connection.addEventListener("server-status",o(this,pu))}get storedAuthToken(){return e2(o(this,dr).get(),this.connection.url)}async connect(){await h(this,bi,uS).call(this,this.connection.token)}dispose(){o(this,Hn)||(d(this,Hn,!0),this.connection.removeEventListener("change",o(this,cu)),this.connection.removeEventListener("server-event",o(this,uu)),this.connection.removeEventListener("channels-changed",o(this,hu)),this.connection.removeEventListener("server-reconnected",o(this,du)),this.connection.removeEventListener("server-status",o(this,pu)),this.connection.dispose())}}dr=new WeakMap,Hn=new WeakMap,bi=new WeakSet,uS=async function(e){if(!o(this,Hn)){h(this,bi,Qm).call(this,null);try{await this.connection.connect(e)}catch(r){h(this,bi,Qm).call(this,r instanceof Gh?null:r instanceof Error?r.message:String(r))}}},Qm=function(e){this.connectError!==e&&(this.connectError=e,this.dispatchEvent(new Bt("change")))},hS=function(){if(this.connection.status!=="unauthorized"||!this.connection.hasAuthRejected)return;const e=o(this,dr).get(),r=Mk(e,this.connection.url);r!==e&&o(this,dr).set(r),this.connection.token!==null&&this.connection.clearToken()},cu=new WeakMap,uu=new WeakMap,hu=new WeakMap,du=new WeakMap,pu=new WeakMap;const eg="tv-nav:",Ol="tv-reload",L2=100,K5=1e3,J5=60,X5=60,Q5=24,eD=30,tD=eD*Q5*X5*J5*K5;function vi(n){try{const t=new URL(n,window.location.href),e=t.searchParams.has(Ol);return t.searchParams.delete(Ol),t.origin===window.location.origin?`${t.pathname}${t.search}${t.hash}`:e?t.toString():n}catch{return n}}var fu,Wa,$e,Ce,ho,Je,dS,Li,pS,tg,ng;class nD extends Ei{constructor(e,r){super();m(this,Je);m(this,fu);m(this,Wa);m(this,$e,[]);m(this,Ce,-1);m(this,ho,0);d(this,fu,e),d(this,Wa,vi(r)),h(this,Je,dS).call(this)}get currentURL(){var e;return o(this,Ce)===-1?null:((e=o(this,$e)[o(this,Ce)])==null?void 0:e.url)??null}get canGoBack(){return o(this,Ce)>-1}get canGoForward(){return o(this,Ce)<o(this,$e).length-1}get entries(){return o(this,$e).map(e=>({...e}))}get cursor(){return o(this,Ce)}navigate(e){const r=vi(e);if(r===o(this,Wa)){if(o(this,Ce)===-1)return;d(this,Ce,-1),h(this,Je,Li).call(this);return}o(this,Ce)<o(this,$e).length-1&&d(this,$e,o(this,$e).slice(0,o(this,Ce)+1)),o(this,$e).push({url:r}),d(this,Ce,o(this,$e).length-1),h(this,Je,tg).call(this),h(this,Je,Li).call(this)}replace(e){var i;if(o(this,Ce)===-1){this.navigate(e);return}const r=vi(e);if(r===o(this,Wa)){d(this,$e,o(this,$e).filter((s,a)=>a!==o(this,Ce))),d(this,Ce,-1),h(this,Je,Li).call(this);return}((i=o(this,$e)[o(this,Ce)])==null?void 0:i.url)!==r&&(d(this,$e,o(this,$e).map((s,a)=>a===o(this,Ce)?{url:r}:s)),h(this,Je,Li).call(this))}back(){o(this,Ce)!==-1&&(d(this,Ce,o(this,Ce)-1),h(this,Je,Li).call(this))}forward(){this.canGoForward&&(d(this,Ce,o(this,Ce)+1),h(this,Je,Li).call(this))}reset(){o(this,Ce)===-1&&o(this,$e).length===0||(d(this,$e,[]),d(this,Ce,-1),h(this,Je,Li).call(this))}}fu=new WeakMap,Wa=new WeakMap,$e=new WeakMap,Ce=new WeakMap,ho=new WeakMap,Je=new WeakSet,dS=function(){const e=localStorage.getItem(o(this,Je,ng));if(e!==null)try{const r=JSON.parse(e);if(!fS(r))return;d(this,$e,r.entries.map(i=>({url:i.url}))),d(this,Ce,r.cursor),d(this,ho,r.lastWritten),h(this,Je,tg).call(this)}catch{d(this,$e,[]),d(this,Ce,-1),d(this,ho,0)}},Li=function(){d(this,ho,Date.now());try{localStorage.setItem(o(this,Je,ng),JSON.stringify(h(this,Je,pS).call(this)))}catch(e){if(!sD(e))throw e}this.dispatchEvent(new Bt("change"))},pS=function(){return{v:1,entries:o(this,$e).map(e=>({...e})),cursor:o(this,Ce),lastWritten:o(this,ho)}},tg=function(){if(o(this,$e).length<=L2)return;const e=o(this,$e).length-L2;d(this,$e,o(this,$e).slice(e)),d(this,Ce,Math.max(-1,o(this,Ce)-e))},ng=function(){return rD(o(this,fu))};function rD(n){return`${eg}${n}`}function iD(n){const t=Date.now()-tD,e=[];for(let r=0;r<localStorage.length;r+=1){const i=localStorage.key(r);if(!(i!=null&&i.startsWith(eg)))continue;const s=i.slice(eg.length),a=localStorage.getItem(i);if(a===null)continue;let l;try{l=JSON.parse(a)}catch{e.push(i);continue}if(!fS(l)){e.push(i);continue}!n.has(s)&&l.lastWritten<t&&e.push(i)}for(const r of e)localStorage.removeItem(r)}function sD(n){return n instanceof DOMException&&n.name==="QuotaExceededError"}function fS(n){if(typeof n!="object"||n===null)return!1;const t=n;if(t.v!==1||!Array.isArray(t.entries))return!1;const e=t.cursor;return typeof e!="number"||!Number.isInteger(e)||typeof t.lastWritten!="number"||!Number.isFinite(t.lastWritten)||e<-1||e>=t.entries.length?!1:t.entries.every(r=>typeof r=="object"&&r!==null&&typeof r.url=="string")}const bm="tv-channel-sidebar-collapsed";var po;class oD{constructor(t){m(this,po);d(this,po,t)}read(){return o(this,po).getItem(bm)==="true"}setCollapsed(t){try{t?o(this,po).setItem(bm,"true"):o(this,po).removeItem(bm)}catch{}}}po=new WeakMap;const Sm="tv-channel-sidebar-width",rg=160,ig=350,xh=260,aD=/^-?\d+$/;var fo;class lD{constructor(t){m(this,fo);d(this,fo,t)}read(){const t=o(this,fo).getItem(Sm);if(t===null||!aD.test(t))return null;const e=BigInt(t);return e<BigInt(rg)?rg:e>BigInt(ig)?ig:Number(e)}commit(t){const e=mS(Math.round(t));try{o(this,fo).setItem(Sm,String(e))}catch{}return e}clear(){try{o(this,fo).removeItem(Sm)}catch{}}}fo=new WeakMap;function mS(n){return Math.min(Math.max(n,rg),ig)}const cD="1.4.17";function j1(n=cD){return n!==void 0&&n.length>0?n:"0.0.0"}function G1(){let n=!1;return{get pending(){return n},begin(t){n||(n=!0,t())}}}const sg="tv-reload-attempted";function uD(n){return n.originMatch?n.marker!==null&&n.bundleVersion===n.serverVersion?{action:"signal-autoreloaded",fromVersion:n.marker.fromVersion,toVersion:n.bundleVersion}:ok(n.bundleVersion,n.serverVersion)?n.marker!==null&&n.marker.serverVersion===n.serverVersion?{action:"none"}:{action:"reload",marker:{serverVersion:n.serverVersion,fromVersion:n.bundleVersion}}:{action:"none"}:{action:"none"}}function hD(n){const t=n.getItem(sg);if(t===null)return null;let e;try{e=JSON.parse(t)}catch{return null}if(!e||typeof e!="object")return null;const r=e;return typeof r.serverVersion!="string"||typeof r.fromVersion!="string"?null:{serverVersion:r.serverVersion,fromVersion:r.fromVersion}}function dD(n){const t=n.storage!==void 0?n.storage:typeof sessionStorage<"u"?sessionStorage:null,e=n.reload??(()=>location.reload()),r=n.navigationLatch??G1(),i=n.bundleVersion??j1();if(t===null)return{dispose(){}};let s=null;const a=()=>{if(s===null)return;const u=n.owner.connection;if(u.url!==n.primaryServerURL||u.status!=="connected")return;const p=s;s=null,u.sendTelemetrySignal("client_autoreloaded",{from_version:p.fromVersion,to_version:p.toVersion})},l=u=>{if(r.pending)return;const p=uD({bundleVersion:i,serverVersion:u.message.version,originMatch:u.serverURL===n.primaryServerURL,marker:hD(t)});switch(p.action){case"reload":t.setItem(sg,JSON.stringify(p.marker)),r.begin(e);return;case"signal-autoreloaded":t.removeItem(sg),s={fromVersion:p.fromVersion,toVersion:p.toVersion},a();return;case"none":return}},c=()=>{a()};return n.owner.addEventListener("server-status",l),n.owner.addEventListener("change",c),{dispose(){n.owner.removeEventListener("server-status",l),n.owner.removeEventListener("change",c)}}}function pD(n){const t=gi(n.search),e=h6(n.search),r=e!==null&&$p(e)?e:null;return{electron:t,shellVersion:r}}function fD(n){return!n.electron||n.requiredDesktopVersion===null||!$p(n.requiredDesktopVersion)?!1:n.shellVersion===null?!0:n.shellVersion===vd?!1:O1(n.requiredDesktopVersion,n.shellVersion)}const mD=`# Desktop app update required
43
+ `)},ya=function(e){const r=`${e}-${o(this,Fa)}`;return d(this,Fa,o(this,Fa)+1),r},jm=function(e){for(const r of o(this,Qt).values())if((r==null?void 0:r.kind)==="tool_call"&&r.toolCallId===e)return r;return null},Gm=function(){if(!o(this,lr))throw new Error("ACP session is not ready");return o(this,lr)},qh=function(){if(!o(this,ar))throw new Error("ACP connection is not ready");return o(this,ar)},oS=function(){var r;const e=(r=o(this,On))==null?void 0:r.sessionCwd;if(!e)throw new Error("ACP bridge session cwd is not ready");return e},Vh=function(){var r;if(o(this,ur)==="single_session")return h(this,M,Km).call(this,`${G6}-${(o(this,zn).clientGUID??"default-client").toLowerCase()}`);const e=(r=o(this,Et))==null?void 0:r.channelID;if(!e)throw new Error("Channel context is required for per-channel session mode");return h(this,M,Ym).call(this,e)},Ym=function(e){return h(this,M,Km).call(this,T5(o(this,ur),e,o(this,zn).clientGUID??"default-client"))},Km=function(e){var r;return((r=o(this,On))==null?void 0:r.sessionIdStrategy)==="deterministic"&&o(this,Ua)>0?`${e}:epoch-${o(this,Ua)}`:e},ou=new WeakMap,au=new WeakMap,Bh=function(){d(this,ar,null),d(this,Vi,null),d(this,Mn,null),d(this,Wr,null),d(this,lr,null),d(this,Nn,null),d(this,On,null),o(this,hr)&&(o(this,hr).removeEventListener("close",o(this,ou)),o(this,hr).removeEventListener("error",o(this,au)),o(this,hr).close(),d(this,hr,null))},wa=function(e){const r=o(this,ar)!==null||o(this,Vi)!==null||o(this,Mn)!==null||o(this,Wr)!==null||o(this,lr)!==null||o(this,Nn)!==null||o(this,On)!==null||o(this,hr)!==null;this.disposed||this.status==="disconnected"&&!r||(h(this,M,Vs).call(this,"error"),h(this,M,Bh).call(this),d(this,or,e??null),h(this,M,Hr).call(this,"disconnected"))},Jm=function(){const e=o(this,Qt).size>0;d(this,cr,null),d(this,Gr,null),d(this,Fa,1),o(this,Qt).clear(),e&&this.dispatchEvent(new mm("messages-changed"))},aS=function(){return this.status==="disconnected"};function E5(){const n=new Map;return{getActualSessionId(t){return n.get(t)??null},setActualSessionId(t,e){n.set(t,e)},clearActualSessionId(t){n.delete(t)}}}function k5(n){return n==null?!0:typeof n=="object"&&Object.keys(n).length===0}function T5(n,t,e){return n==="single_session"?`${G6}-${e.toLowerCase()}`:`agent:main:television-${e.toLowerCase()}-${t.toLowerCase()}`}function lS(n){return n.replace(/^(?:\s*\n)+/,"")}function R2(n){let t=n;return t=t.replace(f5,""),t=t.replace(m5,""),t=t.replace(g5,""),t=lS(t),t}function C5(n){let t=n;return t=t.replace(w5,""),t=lS(t),t}function I2(n){return!n||n.length===0?"":n.flatMap(t=>t.type==="content"&&t.content.type==="text"?[t.content.text]:[]).join("")}async function R5(n){const t=n.createSocket(D5(n.serverURL,n.token));let e=!1,r,i;const s=new Promise((u,p)=>{r=u,i=p}),a=new ReadableStream({start(u){let p=!1;const f=()=>{t.send(JSON.stringify({type:"acp-bridge-connect"}))},y=_=>{const I=P5(_);if(!I)return;let Z;try{Z=JSON.parse(I)}catch(L){const z=L instanceof Error?L:new Error(String(L));i(z),u.error(z);return}switch(Z.type){case"acp-bridge-status":if(Z.status==="ready"){let L;try{L=I5(Z)}catch(z){const P=z instanceof Error?z:new Error(String(z));e||i(P),u.error(P);return}e||(e=!0,r(L));return}if(Z.status==="error"||Z.status==="exited"){const L=new Error(Z.error??`ACP bridge ${Z.status}`);e||i(L),u.error(L)}return;case"acp-bridge-message":u.enqueue(Z.message);return}},v=()=>{var I;if(p)return;p=!0;const _=new Error("ACP bridge websocket closed");e||i(_),(I=n.onDisconnect)==null||I.call(n,_),u.close()},S=()=>{var I;if(p)return;p=!0;const _=new Error("ACP bridge websocket error");e||i(_),(I=n.onDisconnect)==null||I.call(n,_),u.error(_)};t.addEventListener("open",f),t.addEventListener("message",y),t.addEventListener("close",v),t.addEventListener("error",S)}}),l=new WritableStream({async write(u){await s,t.send(JSON.stringify({type:"acp-bridge-message",message:u}))},close(){t.close()},abort(){t.close()}}),c=await s;return{stream:{readable:a,writable:l},socket:t,metadata:c}}function I5(n){const{agent:t,sessionIdStrategy:e,sessionCwd:r,tvArgs:i}=n;if((t==="openclaw"||t==="hermes")&&(e==="deterministic"||e==="mapped")&&typeof r=="string"&&r.length>0&&$5(i))return{agent:t,sessionIdStrategy:e,sessionCwd:r,tvArgs:i};throw new Error("ACP bridge ready status missing bootstrap metadata")}function $5(n){return Array.isArray(n)&&n.every(t=>typeof t=="string")}function x5(n){return y5.test(n)?n:`'${n.replace(/'/g,"'\\''")}'`}function P5(n){if(typeof n=="string")return n;if(n instanceof Uint8Array)return new TextDecoder().decode(n);if(typeof Buffer<"u"&&n instanceof Buffer)return n.toString("utf8");if(typeof n=="object"&&n!==null&&"data"in n){const t=n.data;if(typeof t=="string")return t;if(t instanceof Uint8Array)return new TextDecoder().decode(t);if(Array.isArray(t))return Buffer.concat(t).toString("utf8")}return null}function D5(n,t){const e=new URL(n);return e.protocol=e.protocol==="https:"?"wss:":"ws:",e.pathname="/acp",e.search="",e.searchParams.set("token",t),e.hash="",e.toString()}function wm(n){return n instanceof Error?n.message:String(n)}const $2="television.acpClientGUID",x2="television.acpMappedSessions",P2=1;var Va;class L5{constructor(){m(this,Va,new Map)}getActualSessionId(t){return o(this,Va).get(t)??null}setActualSessionId(t,e){o(this,Va).set(t,e)}clearActualSessionId(t){o(this,Va).delete(t)}}Va=new WeakMap;var Ba,lu,on,Wh,jh,Xm;class M5{constructor(t,e){m(this,on);m(this,Ba);m(this,lu);d(this,Ba,t),d(this,lu,e)}getActualSessionId(t){const e=h(this,on,jh).call(this)[h(this,on,Wh).call(this,t)];return typeof e=="string"&&e.length>0?e:null}setActualSessionId(t,e){const r=h(this,on,jh).call(this);r[h(this,on,Wh).call(this,t)]=e,h(this,on,Xm).call(this,r)}clearActualSessionId(t){const e=h(this,on,jh).call(this);delete e[h(this,on,Wh).call(this,t)],h(this,on,Xm).call(this,e)}}Ba=new WeakMap,lu=new WeakMap,on=new WeakSet,Wh=function(t){return JSON.stringify([o(this,lu),t])},jh=function(){const t=o(this,Ba).getItem(x2);if(!t)return{};let e;try{e=JSON.parse(t)}catch{return{}}if(typeof e!="object"||e===null||Array.isArray(e))return{};const r=e;return r.version!==P2?{}:typeof r.entries!="object"||r.entries===null||Array.isArray(r.entries)?{}:Object.fromEntries(Object.entries(r.entries).filter(i=>typeof i[1]=="string"))},Xm=function(t){const e={version:P2,entries:t};o(this,Ba).setItem(x2,JSON.stringify(e))};function cS(){return typeof window>"u"?null:window.localStorage}function O5(n){const t=n.getItem($2);if(t)return t;const e=N1().toLowerCase();return n.setItem($2,e),e}const D2=4401,N5=401,$h=1e3,z5=3e4;class Gh extends Error{constructor(t="Authentication required"){super(t),this.name="AuthError"}}class H5 extends Ei{constructor(e){var a,l;super();$(this,"url");$(this,"name");$(this,"telemetryMeta");$(this,"status","unauthorized");$(this,"channels",new Map);$(this,"client");$(this,"acpClient");$(this,"_token");$(this,"attempting",!1);$(this,"nextRetryAt",null);$(this,"hasEverConnected",!1);$(this,"failedReconnectAttempts",0);$(this,"browserDemoMode",!1);$(this,"hasAuthRejected",!1);$(this,"bootState","pending");$(this,"serverVersion",null);$(this,"updateState",null);$(this,"decideBoot");$(this,"navigationPending");$(this,"createSocket");$(this,"createClient");$(this,"socket",null);$(this,"connectAttempt",0);$(this,"autoReconnect",!1);$(this,"retryTimer",null);$(this,"retryDelay",$h);$(this,"visibilityEventTarget");$(this,"networkEventTarget");$(this,"onVisibilityChange");$(this,"onNetworkOnline");$(this,"telemetryActivityAgent");this.url=Es(e.url),this.name=e.name,this.decideBoot=e.decideBoot??null,this.navigationPending=e.navigationPending??(()=>!1),this._token=e.token??null,this.telemetryMeta=e.telemetryMeta??null,this.createSocket=e.createSocket??(c=>new WebSocket(c)),this.createClient=e.createClient??((c,u,p)=>new rk(c,{token:u??void 0,onUnauthorized:()=>this.handleAuthRejected(),...p?{telemetryMeta:p}:{}})),this.client=this.createClient(this.url,this._token,this.telemetryMeta);const r=e.mappedSessionStore??(e.acpStorage?new M5(e.acpStorage,this.url):new L5);this.acpClient=new A5({serverURL:this.url,token:this._token??"",...e.createACPSocket?{createSocket:e.createACPSocket}:e.createSocket?{createSocket:e.createSocket}:{},...e.clientGUID?{clientGUID:e.clientGUID}:{},mappedSessionStore:r}),this.visibilityEventTarget=e.visibilityEventTarget!==void 0?e.visibilityEventTarget:typeof document<"u"?document:null,this.networkEventTarget=e.networkEventTarget!==void 0?e.networkEventTarget:typeof window<"u"?window:null,this.onVisibilityChange=()=>{this.isPageVisible()&&this.kickReconnect()},this.onNetworkOnline=()=>{this.kickReconnect()},(a=this.visibilityEventTarget)==null||a.addEventListener("visibilitychange",this.onVisibilityChange),(l=this.networkEventTarget)==null||l.addEventListener("online",this.onNetworkOnline);const i=e.telemetryDocumentTarget!==void 0?e.telemetryDocumentTarget:typeof document<"u"?document:null,s=e.telemetryWindowTarget!==void 0?e.telemetryWindowTarget:typeof window<"u"?window:null;this.telemetryActivityAgent=this.telemetryMeta&&i&&s?BI({meta:this.telemetryMeta,documentTarget:i,windowTarget:s,send:c=>this.sendTelemetryActivity(c)}):null}get token(){return this._token}clearToken(){this._token=null,this.acpClient.setToken(null),this.client=this.createClient(this.url,null,this.telemetryMeta)}async connect(e){this._token=e,this.hasAuthRejected=!1,this.acpClient.setToken(e),this.cancelRetryTimer(),this.retryDelay=$h,this.autoReconnect=!0,await this.attempt()}dispose(){var e,r,i,s;this.autoReconnect=!1,this.connectAttempt+=1,this.cancelRetryTimer(),(e=this.socket)==null||e.close(),this.socket=null,this.setStatus("unauthorized"),(r=this.visibilityEventTarget)==null||r.removeEventListener("visibilitychange",this.onVisibilityChange),(i=this.networkEventTarget)==null||i.removeEventListener("online",this.onNetworkOnline),(s=this.telemetryActivityAgent)==null||s.stop(),this.acpClient.dispose()}getViewURL(e){const r=Ad(e,this.renderOptions());return gi()?new URL(r.viewURL,this.url).toString():r.renderer==="proxy-iframe"?new URL(r.viewURL,this.url).toString():r.viewURL}async readDemoMode(){try{return await this.client.demoMode()}catch{return null}}renderOptions(){return{electron:gi(),browserDemo:this.browserDemoMode}}getContentURL(e){const r=Ad(e,this.renderOptions()).contentURL;return r===null?null:new URL(r,this.url).toString()}async createChannel(e){const{channel:r}=await this.client.channels.create({name:e});return this.channels.set(r.id,structuredClone(r)),r}applyServerEvent(e){switch(e.type){case"channel-created":this.channels.set(e.channel.id,structuredClone(e.channel)),this.dispatchEvent(new wc("channels-changed"));break;case"channel-updated":this.channels.set(e.channel.id,structuredClone(e.channel)),this.dispatchEvent(new wc("channels-changed"));break;case"channel-removed":this.channels.delete(e.channelID),this.dispatchEvent(new wc("channels-changed"));break;case"artifact-created":{const r=this.channels.get(e.channelID);r&&!ZE(r).includes(e.artifact.id)&&(r.layout=[...r.layout,{artifactIds:[e.artifact.id],geometry:{...d8},size:{...p8}}]);break}case"artifact-removed":{const r=this.channels.get(e.channelID);r&&(r.layout=Dm(r.layout,e.artifactID));break}case"artifact-updated":case"artifact-content-changed":case"channel-changed":case"pinned-channels-changed":case"theme-changed":case"appearance-changed":case"artifact-focus":break;default:return Z5(e,"server event")}}async attempt(){var i;this.attempting=!0,this.nextRetryAt=null,this.connectAttempt+=1,this.bootState="pending";const e=this.connectAttempt;(i=this.socket)==null||i.close(),this.client=this.createClient(this.url,this._token,this.telemetryMeta),this.setStatus("disconnected"),this.dispatchEvent(new Bt("change"));const r=this.createSocket(U5(this.url,this._token,this.telemetryMeta));return this.socket=r,await new Promise((s,a)=>{let l=!1,c=!1;const u=()=>{var y;l||this.connectAttempt!==e||(l=!0,c=!0,this.retryDelay=$h,this.hasEverConnected=!0,this.failedReconnectAttempts=0,this.setStatus("connected"),(y=this.telemetryActivityAgent)==null||y.start(),s())},p=y=>{l||this.connectAttempt!==e||(l=!0,a(y))},f=async()=>{const y=this.hasEverConnected;try{const[{channels:v},S,_]=await Promise.all([this.client.channels.list(),this.client.display.get(),y?null:this.readDemoMode()]);y||(this.browserDemoMode=(_==null?void 0:_.browserExternalPages)===!0),this.channels=new Map(v.map(I=>[I.id,structuredClone(I)])),this.acpClient.setEnabled(S.acpEnabled),this.dispatchEvent(new Bt("change")),y&&this.dispatchEvent(new wc("channels-changed")),this.dispatchEvent(new Zh("server-event",{serverURL:this.url,event:{type:"channel-changed",channelID:S.focusedChannelId}})),this.dispatchEvent(new Zh("server-event",{serverURL:this.url,event:{type:"pinned-channels-changed",pinnedChannelIds:[...S.pinnedChannelIds]}})),u(),y&&this.connectAttempt===e&&this.dispatchEvent(new E8("server-reconnected",{serverURL:this.url}))}catch(v){if(j5(v)){p(new Gh);return}p(v instanceof Error?v:new Error(String(v)))}};r.addEventListener("open",()=>{this.decideBoot===null&&(this.bootState="booted",this.navigationPending()||f())}),r.addEventListener("message",y=>{const v=W5(y);if(!v)return;if(v.type==="server-status"){const _=v;this.serverVersion=_.version,this.updateState=_.update??null;let I=!1;this.decideBoot!==null&&this.bootState==="pending"&&this.connectAttempt===e&&(this.decideBoot(_)==="boot"?(this.bootState="booted",I=!0):(this.bootState="halted",this.attempting=!1)),this.dispatchEvent(new k8("server-status",{serverURL:this.url,message:_})),I?this.navigationPending()||f():this.bootState==="halted"&&!this.navigationPending()&&this.dispatchEvent(new Bt("change"));return}if(!B5(v.type))return;const S=v;this.applyServerEvent(S),this.dispatchEvent(new Zh("server-event",{serverURL:this.url,event:S}))}),r.addEventListener("close",y=>{if(this.connectAttempt!==e)return;this.socket=null;const v=F5(y);if(!l){p(v===D2?new Gh:new Error("Connection closed before initialization"));return}if(c){if(v===D2){this.handleAuthRejected();return}this.handleTransportFailure(new Error("Connection closed"))}}),r.addEventListener("error",()=>{if(this.connectAttempt===e){if(l){if(!c)return;this.handleTransportFailure(new Error("WebSocket error"));return}p(new Error("WebSocket connection failed"))}})}).then(()=>{this.attempting=!1},s=>{throw this.attempting=!1,this.handleAttemptFailure(s),s})}handleAuthRejected(){this.hasAuthRejected=!0,this.autoReconnect=!1,this.cancelRetryTimer(),this.setStatus("unauthorized")}handleAttemptFailure(e){if(e instanceof Gh){this.handleAuthRejected();return}this.autoReconnect&&(this.hasEverConnected&&(this.failedReconnectAttempts+=1),this.scheduleRetry())}handleTransportFailure(e){this.autoReconnect&&(this.setStatus("disconnected"),this.scheduleRetry())}scheduleRetry(){this.cancelRetryTimer(),this.connectAttempt+=1;const e=this.retryDelay;this.retryDelay=Math.min(this.retryDelay*2,z5),this.nextRetryAt=Date.now()+e,this.retryTimer=setTimeout(()=>{this.retryTimer=null,this.attempt().catch(()=>{})},e),this.dispatchEvent(new Bt("change"))}cancelRetryTimer(){this.retryTimer!==null&&(clearTimeout(this.retryTimer),this.retryTimer=null),this.nextRetryAt!==null&&(this.nextRetryAt=null,this.dispatchEvent(new Bt("change")))}kickReconnect(){this.autoReconnect&&this.status!=="connected"&&(this.attempting||(this.cancelRetryTimer(),this.retryDelay=$h,this.attempt().catch(()=>{})))}sendTelemetryActivity(e){var r;this.status==="connected"&&((r=this.socket)==null||r.send(JSON.stringify(e)))}sendTelemetrySignal(e,r){var s;if(!this.telemetryMeta||this.status!=="connected"&&this.bootState!=="halted")return;const i={type:HE,clientId:this.telemetryMeta.clientId,event:e,properties:r};(s=this.socket)==null||s.send(JSON.stringify(i))}setStatus(e){this.status!==e&&(this.status=e,this.dispatchEvent(new Bt("change")))}isPageVisible(){return this.visibilityEventTarget===null?!0:this.visibilityEventTarget.visibilityState==="visible"}}function Z5(n,t){throw new Error(`Unexpected ${t}: ${JSON.stringify(n)}`)}function U5(n,t,e=null){const r=new URL(n);if(r.protocol=r.protocol==="https:"?"wss:":"ws:",r.pathname="/events",r.search="",t&&r.searchParams.set("token",t),e)for(const[i,s]of VI(e))r.searchParams.set(i,s);return r.hash="",r.toString()}function F5(n){return typeof n=="object"&&n!==null&&"code"in n&&typeof n.code=="number"?n.code:null}const q5={"artifact-created":!0,"artifact-updated":!0,"artifact-content-changed":!0,"artifact-removed":!0,"channel-created":!0,"channel-updated":!0,"channel-removed":!0,"channel-changed":!0,"pinned-channels-changed":!0,"theme-changed":!0,"appearance-changed":!0,"artifact-focus":!0},V5=new Set(Object.keys(q5));function B5(n){return V5.has(n)}function W5(n){const t=typeof n=="string"?n:typeof n=="object"&&n!==null&&"data"in n&&typeof n.data=="string"?n.data:"";if(!t)return null;let e;try{e=JSON.parse(t)}catch{return null}return typeof e!="object"||e===null||!("type"in e)||typeof e.type!="string"?null:e}function j5(n){return n instanceof Bl&&n.status===N5}const G5="Local";var dr,Hn,bi,uS,Qm,hS,cu,uu,hu,du,pu;class Y5 extends Ei{constructor(e){super();m(this,bi);$(this,"connection");$(this,"clientGUID");$(this,"acpStorage");$(this,"connectError",null);m(this,dr);m(this,Hn,!1);m(this,cu,()=>{o(this,Hn)||(h(this,bi,hS).call(this),this.dispatchEvent(new Bt("change")))});m(this,uu,e=>{o(this,Hn)||this.dispatchEvent(new Zh("server-event",{serverURL:e.serverURL,event:e.event}))});m(this,hu,()=>{o(this,Hn)||this.dispatchEvent(new wc("channels-changed"))});m(this,du,e=>{o(this,Hn)||this.dispatchEvent(new E8("server-reconnected",{serverURL:e.serverURL}))});m(this,pu,e=>{o(this,Hn)||this.dispatchEvent(new k8("server-status",{serverURL:e.serverURL,message:e.message}))});d(this,dr,e.localStore),this.acpStorage=e.acpStorage===void 0?cS():e.acpStorage,this.clientGUID=e.clientGUID??(this.acpStorage?O5(this.acpStorage):N1().toLowerCase());const r=Es(e.serverURL);e.launchToken!==void 0&&e.launchToken!==null&&o(this,dr).set(Lk(o(this,dr).get(),r,e.launchToken));const i=e.launchToken??e2(o(this,dr).get(),r),s=e.createSocket??(l=>new WebSocket(l)),a=e.createConnection??(l=>new H5(l));this.connection=a({url:r,name:e.connectionName??G5,token:i,createSocket:s,clientGUID:this.clientGUID,acpStorage:this.acpStorage,telemetryMeta:e.telemetryMeta??null,decideBoot:e.decideBoot,navigationPending:e.navigationPending}),this.connection.addEventListener("change",o(this,cu)),this.connection.addEventListener("server-event",o(this,uu)),this.connection.addEventListener("channels-changed",o(this,hu)),this.connection.addEventListener("server-reconnected",o(this,du)),this.connection.addEventListener("server-status",o(this,pu))}get storedAuthToken(){return e2(o(this,dr).get(),this.connection.url)}async connect(){await h(this,bi,uS).call(this,this.connection.token)}dispose(){o(this,Hn)||(d(this,Hn,!0),this.connection.removeEventListener("change",o(this,cu)),this.connection.removeEventListener("server-event",o(this,uu)),this.connection.removeEventListener("channels-changed",o(this,hu)),this.connection.removeEventListener("server-reconnected",o(this,du)),this.connection.removeEventListener("server-status",o(this,pu)),this.connection.dispose())}}dr=new WeakMap,Hn=new WeakMap,bi=new WeakSet,uS=async function(e){if(!o(this,Hn)){h(this,bi,Qm).call(this,null);try{await this.connection.connect(e)}catch(r){h(this,bi,Qm).call(this,r instanceof Gh?null:r instanceof Error?r.message:String(r))}}},Qm=function(e){this.connectError!==e&&(this.connectError=e,this.dispatchEvent(new Bt("change")))},hS=function(){if(this.connection.status!=="unauthorized"||!this.connection.hasAuthRejected)return;const e=o(this,dr).get(),r=Mk(e,this.connection.url);r!==e&&o(this,dr).set(r),this.connection.token!==null&&this.connection.clearToken()},cu=new WeakMap,uu=new WeakMap,hu=new WeakMap,du=new WeakMap,pu=new WeakMap;const eg="tv-nav:",Ol="tv-reload",L2=100,K5=1e3,J5=60,X5=60,Q5=24,eD=30,tD=eD*Q5*X5*J5*K5;function vi(n){try{const t=new URL(n,window.location.href),e=t.searchParams.has(Ol);return t.searchParams.delete(Ol),t.origin===window.location.origin?`${t.pathname}${t.search}${t.hash}`:e?t.toString():n}catch{return n}}var fu,Wa,$e,Ce,ho,Je,dS,Li,pS,tg,ng;class nD extends Ei{constructor(e,r){super();m(this,Je);m(this,fu);m(this,Wa);m(this,$e,[]);m(this,Ce,-1);m(this,ho,0);d(this,fu,e),d(this,Wa,vi(r)),h(this,Je,dS).call(this)}get currentURL(){var e;return o(this,Ce)===-1?null:((e=o(this,$e)[o(this,Ce)])==null?void 0:e.url)??null}get canGoBack(){return o(this,Ce)>-1}get canGoForward(){return o(this,Ce)<o(this,$e).length-1}get entries(){return o(this,$e).map(e=>({...e}))}get cursor(){return o(this,Ce)}navigate(e){const r=vi(e);if(r===o(this,Wa)){if(o(this,Ce)===-1)return;d(this,Ce,-1),h(this,Je,Li).call(this);return}o(this,Ce)<o(this,$e).length-1&&d(this,$e,o(this,$e).slice(0,o(this,Ce)+1)),o(this,$e).push({url:r}),d(this,Ce,o(this,$e).length-1),h(this,Je,tg).call(this),h(this,Je,Li).call(this)}replace(e){var i;if(o(this,Ce)===-1){this.navigate(e);return}const r=vi(e);if(r===o(this,Wa)){d(this,$e,o(this,$e).filter((s,a)=>a!==o(this,Ce))),d(this,Ce,-1),h(this,Je,Li).call(this);return}((i=o(this,$e)[o(this,Ce)])==null?void 0:i.url)!==r&&(d(this,$e,o(this,$e).map((s,a)=>a===o(this,Ce)?{url:r}:s)),h(this,Je,Li).call(this))}back(){o(this,Ce)!==-1&&(d(this,Ce,o(this,Ce)-1),h(this,Je,Li).call(this))}forward(){this.canGoForward&&(d(this,Ce,o(this,Ce)+1),h(this,Je,Li).call(this))}reset(){o(this,Ce)===-1&&o(this,$e).length===0||(d(this,$e,[]),d(this,Ce,-1),h(this,Je,Li).call(this))}}fu=new WeakMap,Wa=new WeakMap,$e=new WeakMap,Ce=new WeakMap,ho=new WeakMap,Je=new WeakSet,dS=function(){const e=localStorage.getItem(o(this,Je,ng));if(e!==null)try{const r=JSON.parse(e);if(!fS(r))return;d(this,$e,r.entries.map(i=>({url:i.url}))),d(this,Ce,r.cursor),d(this,ho,r.lastWritten),h(this,Je,tg).call(this)}catch{d(this,$e,[]),d(this,Ce,-1),d(this,ho,0)}},Li=function(){d(this,ho,Date.now());try{localStorage.setItem(o(this,Je,ng),JSON.stringify(h(this,Je,pS).call(this)))}catch(e){if(!sD(e))throw e}this.dispatchEvent(new Bt("change"))},pS=function(){return{v:1,entries:o(this,$e).map(e=>({...e})),cursor:o(this,Ce),lastWritten:o(this,ho)}},tg=function(){if(o(this,$e).length<=L2)return;const e=o(this,$e).length-L2;d(this,$e,o(this,$e).slice(e)),d(this,Ce,Math.max(-1,o(this,Ce)-e))},ng=function(){return rD(o(this,fu))};function rD(n){return`${eg}${n}`}function iD(n){const t=Date.now()-tD,e=[];for(let r=0;r<localStorage.length;r+=1){const i=localStorage.key(r);if(!(i!=null&&i.startsWith(eg)))continue;const s=i.slice(eg.length),a=localStorage.getItem(i);if(a===null)continue;let l;try{l=JSON.parse(a)}catch{e.push(i);continue}if(!fS(l)){e.push(i);continue}!n.has(s)&&l.lastWritten<t&&e.push(i)}for(const r of e)localStorage.removeItem(r)}function sD(n){return n instanceof DOMException&&n.name==="QuotaExceededError"}function fS(n){if(typeof n!="object"||n===null)return!1;const t=n;if(t.v!==1||!Array.isArray(t.entries))return!1;const e=t.cursor;return typeof e!="number"||!Number.isInteger(e)||typeof t.lastWritten!="number"||!Number.isFinite(t.lastWritten)||e<-1||e>=t.entries.length?!1:t.entries.every(r=>typeof r=="object"&&r!==null&&typeof r.url=="string")}const bm="tv-channel-sidebar-collapsed";var po;class oD{constructor(t){m(this,po);d(this,po,t)}read(){return o(this,po).getItem(bm)==="true"}setCollapsed(t){try{t?o(this,po).setItem(bm,"true"):o(this,po).removeItem(bm)}catch{}}}po=new WeakMap;const Sm="tv-channel-sidebar-width",rg=160,ig=350,xh=260,aD=/^-?\d+$/;var fo;class lD{constructor(t){m(this,fo);d(this,fo,t)}read(){const t=o(this,fo).getItem(Sm);if(t===null||!aD.test(t))return null;const e=BigInt(t);return e<BigInt(rg)?rg:e>BigInt(ig)?ig:Number(e)}commit(t){const e=mS(Math.round(t));try{o(this,fo).setItem(Sm,String(e))}catch{}return e}clear(){try{o(this,fo).removeItem(Sm)}catch{}}}fo=new WeakMap;function mS(n){return Math.min(Math.max(n,rg),ig)}const cD="1.4.18";function j1(n=cD){return n!==void 0&&n.length>0?n:"0.0.0"}function G1(){let n=!1;return{get pending(){return n},begin(t){n||(n=!0,t())}}}const sg="tv-reload-attempted";function uD(n){return n.originMatch?n.marker!==null&&n.bundleVersion===n.serverVersion?{action:"signal-autoreloaded",fromVersion:n.marker.fromVersion,toVersion:n.bundleVersion}:ok(n.bundleVersion,n.serverVersion)?n.marker!==null&&n.marker.serverVersion===n.serverVersion?{action:"none"}:{action:"reload",marker:{serverVersion:n.serverVersion,fromVersion:n.bundleVersion}}:{action:"none"}:{action:"none"}}function hD(n){const t=n.getItem(sg);if(t===null)return null;let e;try{e=JSON.parse(t)}catch{return null}if(!e||typeof e!="object")return null;const r=e;return typeof r.serverVersion!="string"||typeof r.fromVersion!="string"?null:{serverVersion:r.serverVersion,fromVersion:r.fromVersion}}function dD(n){const t=n.storage!==void 0?n.storage:typeof sessionStorage<"u"?sessionStorage:null,e=n.reload??(()=>location.reload()),r=n.navigationLatch??G1(),i=n.bundleVersion??j1();if(t===null)return{dispose(){}};let s=null;const a=()=>{if(s===null)return;const u=n.owner.connection;if(u.url!==n.primaryServerURL||u.status!=="connected")return;const p=s;s=null,u.sendTelemetrySignal("client_autoreloaded",{from_version:p.fromVersion,to_version:p.toVersion})},l=u=>{if(r.pending)return;const p=uD({bundleVersion:i,serverVersion:u.message.version,originMatch:u.serverURL===n.primaryServerURL,marker:hD(t)});switch(p.action){case"reload":t.setItem(sg,JSON.stringify(p.marker)),r.begin(e);return;case"signal-autoreloaded":t.removeItem(sg),s={fromVersion:p.fromVersion,toVersion:p.toVersion},a();return;case"none":return}},c=()=>{a()};return n.owner.addEventListener("server-status",l),n.owner.addEventListener("change",c),{dispose(){n.owner.removeEventListener("server-status",l),n.owner.removeEventListener("change",c)}}}function pD(n){const t=gi(n.search),e=h6(n.search),r=e!==null&&$p(e)?e:null;return{electron:t,shellVersion:r}}function fD(n){return!n.electron||n.requiredDesktopVersion===null||!$p(n.requiredDesktopVersion)?!1:n.shellVersion===null?!0:n.shellVersion===vd?!1:O1(n.requiredDesktopVersion,n.shellVersion)}const mD=`# Desktop app update required
44
44
 
45
45
  This version of the Television desktop app does not work with this server and needs to be updated. The new version has already downloaded and installs when you restart the app.`,gD=`# Desktop app update required
46
46