@telepath-computer/television 0.1.36 → 0.1.37
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,9 +1,9 @@
|
|
|
1
|
-
var Av=Object.defineProperty;var Au=t=>{throw TypeError(t)};var xv=(t,e,n)=>e in t?Av(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var v=(t,e,n)=>xv(t,typeof e!="symbol"?e+"":e,n),da=(t,e,n)=>e.has(t)||Au("Cannot "+n);var u=(t,e,n)=>(da(t,e,"read from private field"),n?n.call(t):e.get(t)),$=(t,e,n)=>e.has(t)?Au("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,n),x=(t,e,n,r)=>(da(t,e,"write to private field"),r?r.call(t,n):e.set(t,n),n),b=(t,e,n)=>(da(t,e,"access private method"),n);var xu=(t,e,n,r)=>({set _(s){x(t,e,s,n)},get _(){return u(t,e,r)}});(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const s of document.querySelectorAll('link[rel="modulepreload"]'))r(s);new MutationObserver(s=>{for(const i of s)if(i.type==="childList")for(const o of i.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&r(o)}).observe(document,{childList:!0,subtree:!0});function n(s){const i={};return s.integrity&&(i.integrity=s.integrity),s.referrerPolicy&&(i.referrerPolicy=s.referrerPolicy),s.crossOrigin==="use-credentials"?i.credentials="include":s.crossOrigin==="anonymous"?i.credentials="omit":i.credentials="same-origin",i}function r(s){if(s.ep)return;s.ep=!0;const i=n(s);fetch(s.href,i)}})();var Sn=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Tv(t){if(t.__esModule)return t;var e=t.default;if(typeof e=="function"){var n=function r(){return this instanceof r?Reflect.construct(e,arguments,this.constructor):e.apply(this,arguments)};n.prototype=e.prototype}else n={};return Object.defineProperty(n,"__esModule",{value:!0}),Object.keys(t).forEach(function(r){var s=Object.getOwnPropertyDescriptor(t,r);Object.defineProperty(n,r,s.get?s:{enumerable:!0,get:function(){return t[r]}})}),n}var Tu=Object.prototype.toString,cp=function(e){var n=Tu.call(e),r=n==="[object Arguments]";return r||(r=n!=="[object Array]"&&e!==null&&typeof e=="object"&&typeof e.length=="number"&&e.length>=0&&Tu.call(e.callee)==="[object Function]"),r},pa,Cu;function Cv(){if(Cu)return pa;Cu=1;var t;if(!Object.keys){var e=Object.prototype.hasOwnProperty,n=Object.prototype.toString,r=cp,s=Object.prototype.propertyIsEnumerable,i=!s.call({toString:null},"toString"),o=s.call(function(){},"prototype"),a=["toString","toLocaleString","valueOf","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","constructor"],l=function(y){var m=y.constructor;return m&&m.prototype===y},c={$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},d=function(){if(typeof window>"u")return!1;for(var y in window)try{if(!c["$"+y]&&e.call(window,y)&&window[y]!==null&&typeof window[y]=="object")try{l(window[y])}catch{return!0}}catch{return!0}return!1}(),p=function(y){if(typeof window>"u"||!d)return l(y);try{return l(y)}catch{return!1}};t=function(m){var E=m!==null&&typeof m=="object",k=n.call(m)==="[object Function]",I=r(m),G=E&&n.call(m)==="[object String]",N=[];if(!E&&!k&&!I)throw new TypeError("Object.keys called on a non-object");var j=o&&k;if(G&&m.length>0&&!e.call(m,0))for(var F=0;F<m.length;++F)N.push(String(F));if(I&&m.length>0)for(var L=0;L<m.length;++L)N.push(String(L));else for(var J in m)!(j&&J==="prototype")&&e.call(m,J)&&N.push(String(J));if(i)for(var H=p(m),he=0;he<a.length;++he)!(H&&a[he]==="constructor")&&e.call(m,a[he])&&N.push(a[he]);return N}}return pa=t,pa}var Iv=Array.prototype.slice,Pv=cp,Iu=Object.keys,Hi=Iu?function(e){return Iu(e)}:Cv(),Pu=Object.keys;Hi.shim=function(){if(Object.keys){var e=function(){var n=Object.keys(arguments);return n&&n.length===arguments.length}(1,2);e||(Object.keys=function(r){return Pv(r)?Pu(Iv.call(r)):Pu(r)})}else Object.keys=Hi;return Object.keys||Hi};var Rv=Hi,qi=Object.defineProperty||!1;if(qi)try{qi({},"a",{value:1})}catch{qi=!1}var ai=qi,Ft=SyntaxError,V=TypeError,Dv=Object.getOwnPropertyDescriptor,Yi=Dv;if(Yi)try{Yi([],"length")}catch{Yi=null}var Ur=Yi,Ru=ai,Ov=Ft,ir=V,Du=Ur,up=function(e,n,r){if(!e||typeof e!="object"&&typeof e!="function")throw new ir("`obj` must be an object or a function`");if(typeof n!="string"&&typeof n!="symbol")throw new ir("`property` must be a string or a symbol`");if(arguments.length>3&&typeof arguments[3]!="boolean"&&arguments[3]!==null)throw new ir("`nonEnumerable`, if provided, must be a boolean or null");if(arguments.length>4&&typeof arguments[4]!="boolean"&&arguments[4]!==null)throw new ir("`nonWritable`, if provided, must be a boolean or null");if(arguments.length>5&&typeof arguments[5]!="boolean"&&arguments[5]!==null)throw new ir("`nonConfigurable`, if provided, must be a boolean or null");if(arguments.length>6&&typeof arguments[6]!="boolean")throw new ir("`loose`, if provided, must be a boolean");var s=arguments.length>3?arguments[3]:null,i=arguments.length>4?arguments[4]:null,o=arguments.length>5?arguments[5]:null,a=arguments.length>6?arguments[6]:!1,l=!!Du&&Du(e,n);if(Ru)Ru(e,n,{configurable:o===null&&l?l.configurable:!o,enumerable:s===null&&l?l.enumerable:!s,value:r,writable:i===null&&l?l.writable:!i});else if(a||!s&&!i&&!o)e[n]=r;else throw new Ov("This environment does not support defining a property as non-configurable, non-writable, or non-enumerable.")},rl=ai,hp=function(){return!!rl};hp.hasArrayLengthDefineBug=function(){if(!rl)return null;try{return rl([],"length",{value:1}).length!==1}catch{return!0}};var Oo=hp,zv=Rv,Lv=typeof Symbol=="function"&&typeof Symbol("foo")=="symbol",Mv=Object.prototype.toString,Nv=Array.prototype.concat,Ou=up,Uv=function(t){return typeof t=="function"&&Mv.call(t)==="[object Function]"},dp=Oo(),Fv=function(t,e,n,r){if(e in t){if(r===!0){if(t[e]===n)return}else if(!Uv(r)||!r())return}dp?Ou(t,e,n,!0):Ou(t,e,n)},pp=function(t,e){var n=arguments.length>2?arguments[2]:{},r=zv(e);Lv&&(r=Nv.call(r,Object.getOwnPropertySymbols(e)));for(var s=0;s<r.length;s+=1)Fv(t,r[s],e[r[s]],n[r[s]])};pp.supportsDescriptors=!!dp;var Yn=pp,Ki={exports:{}};typeof self<"u"?Ki.exports=self:typeof window<"u"?Ki.exports=window:Ki.exports=Function("return this")();var fp=Ki.exports,Zv=fp,gp=function(){return typeof Sn!="object"||!Sn||Sn.Math!==Math||Sn.Array!==Array?Zv:Sn},jv=Yn,Wv=Ur,Bv=gp,Gv=function(){var e=Bv();if(jv.supportsDescriptors){var n=Wv(e,"globalThis");(!n||n.configurable&&(n.enumerable||!n.writable||globalThis!==e))&&Object.defineProperty(e,"globalThis",{configurable:!0,enumerable:!1,value:e,writable:!0})}else(typeof globalThis!="object"||globalThis!==e)&&(e.globalThis=e);return e},Vv=Yn,Hv=fp,mp=gp,qv=Gv,Yv=mp(),vp=function(){return Yv};Vv(vp,{getPolyfill:mp,implementation:Hv,shim:qv});var ec=vp,Zt=function(e){return!!e&&(typeof e=="function"||typeof e=="object")},tc=Object,yp=Error,Kv=EvalError,Jv=RangeError,nc=ReferenceError,Xv=URIError,Qv=Math.abs,ey=Math.floor,ty=Math.max,ny=Math.min,ry=Math.pow,sy=Math.round,rc=Number.isNaN||function(e){return e!==e},iy=rc,oy=function(e){return iy(e)||e===0?e:e<0?-1:1},Fr=function(){if(typeof Symbol!="function"||typeof Object.getOwnPropertySymbols!="function")return!1;if(typeof Symbol.iterator=="symbol")return!0;var e={},n=Symbol("test"),r=Object(n);if(typeof n=="string"||Object.prototype.toString.call(n)!=="[object Symbol]"||Object.prototype.toString.call(r)!=="[object Symbol]")return!1;var s=42;e[n]=s;for(var i in e)return!1;if(typeof Object.keys=="function"&&Object.keys(e).length!==0||typeof Object.getOwnPropertyNames=="function"&&Object.getOwnPropertyNames(e).length!==0)return!1;var o=Object.getOwnPropertySymbols(e);if(o.length!==1||o[0]!==n||!Object.prototype.propertyIsEnumerable.call(e,n))return!1;if(typeof Object.getOwnPropertyDescriptor=="function"){var a=Object.getOwnPropertyDescriptor(e,n);if(a.value!==s||a.enumerable!==!0)return!1}return!0},zu=typeof Symbol<"u"&&Symbol,ay=Fr,sc=function(){return typeof zu!="function"||typeof Symbol!="function"||typeof zu("foo")!="symbol"||typeof Symbol("bar")!="symbol"?!1:ay()},fa,Lu;function bp(){return Lu||(Lu=1,fa=typeof Reflect<"u"&&Reflect.getPrototypeOf||null),fa}var ga,Mu;function wp(){if(Mu)return ga;Mu=1;var t=tc;return ga=t.getPrototypeOf||null,ga}var ly="Function.prototype.bind called on incompatible ",cy=Object.prototype.toString,uy=Math.max,hy="[object Function]",Nu=function(e,n){for(var r=[],s=0;s<e.length;s+=1)r[s]=e[s];for(var i=0;i<n.length;i+=1)r[i+e.length]=n[i];return r},dy=function(e,n){for(var r=[],s=n,i=0;s<e.length;s+=1,i+=1)r[i]=e[s];return r},py=function(t,e){for(var n="",r=0;r<t.length;r+=1)n+=t[r],r+1<t.length&&(n+=e);return n},fy=function(e){var n=this;if(typeof n!="function"||cy.apply(n)!==hy)throw new TypeError(ly+n);for(var r=dy(arguments,1),s,i=function(){if(this instanceof s){var d=n.apply(this,Nu(r,arguments));return Object(d)===d?d:this}return n.apply(e,Nu(r,arguments))},o=uy(0,n.length-r.length),a=[],l=0;l<o;l++)a[l]="$"+l;if(s=Function("binder","return function ("+py(a,",")+"){ return binder.apply(this,arguments); }")(i),n.prototype){var c=function(){};c.prototype=n.prototype,s.prototype=new c,c.prototype=null}return s},gy=fy,li=Function.prototype.bind||gy,ic=Function.prototype.call,oc=Function.prototype.apply,my=typeof Reflect<"u"&&Reflect&&Reflect.apply,vy=li,yy=oc,by=ic,wy=my,_p=wy||vy.call(by,yy),_y=li,Sy=V,ky=ic,Ey=_p,zo=function(e){if(e.length<1||typeof e[0]!="function")throw new Sy("a function is required");return Ey(_y,ky,e)},ma,Uu;function $y(){if(Uu)return ma;Uu=1;var t=zo,e=Ur,n;try{n=[].__proto__===Array.prototype}catch(o){if(!o||typeof o!="object"||!("code"in o)||o.code!=="ERR_PROTO_ACCESS")throw o}var r=!!n&&e&&e(Object.prototype,"__proto__"),s=Object,i=s.getPrototypeOf;return ma=r&&typeof r.get=="function"?t([r.get]):typeof i=="function"?function(a){return i(a==null?a:s(a))}:!1,ma}var va,Fu;function Sp(){if(Fu)return va;Fu=1;var t=bp(),e=wp(),n=$y();return va=t?function(s){return t(s)}:e?function(s){if(!s||typeof s!="object"&&typeof s!="function")throw new TypeError("getProto: not an object");return e(s)}:n?function(s){return n(s)}:null,va}var Ay=Function.prototype.call,xy=Object.prototype.hasOwnProperty,Ty=li,jt=Ty.call(Ay,xy),B,Cy=tc,Iy=yp,Py=Kv,Ry=Jv,Dy=nc,Dr=Ft,wr=V,Oy=Xv,zy=Qv,Ly=ey,My=ty,Ny=ny,Uy=ry,Fy=sy,Zy=oy,kp=Function,ya=function(t){try{return kp('"use strict"; return ('+t+").constructor;")()}catch{}},xs=Ur,jy=ai,ba=function(){throw new wr},Wy=xs?function(){try{return arguments.callee,ba}catch{try{return xs(arguments,"callee").get}catch{return ba}}}():ba,or=sc(),_e=Sp(),By=wp(),Gy=bp(),Ep=oc,ci=ic,cr={},Vy=typeof Uint8Array>"u"||!_e?B:_e(Uint8Array),Wn={__proto__:null,"%AggregateError%":typeof AggregateError>"u"?B:AggregateError,"%Array%":Array,"%ArrayBuffer%":typeof ArrayBuffer>"u"?B:ArrayBuffer,"%ArrayIteratorPrototype%":or&&_e?_e([][Symbol.iterator]()):B,"%AsyncFromSyncIteratorPrototype%":B,"%AsyncFunction%":cr,"%AsyncGenerator%":cr,"%AsyncGeneratorFunction%":cr,"%AsyncIteratorPrototype%":cr,"%Atomics%":typeof Atomics>"u"?B:Atomics,"%BigInt%":typeof BigInt>"u"?B:BigInt,"%BigInt64Array%":typeof BigInt64Array>"u"?B:BigInt64Array,"%BigUint64Array%":typeof BigUint64Array>"u"?B:BigUint64Array,"%Boolean%":Boolean,"%DataView%":typeof DataView>"u"?B:DataView,"%Date%":Date,"%decodeURI%":decodeURI,"%decodeURIComponent%":decodeURIComponent,"%encodeURI%":encodeURI,"%encodeURIComponent%":encodeURIComponent,"%Error%":Iy,"%eval%":eval,"%EvalError%":Py,"%Float16Array%":typeof Float16Array>"u"?B:Float16Array,"%Float32Array%":typeof Float32Array>"u"?B:Float32Array,"%Float64Array%":typeof Float64Array>"u"?B:Float64Array,"%FinalizationRegistry%":typeof FinalizationRegistry>"u"?B:FinalizationRegistry,"%Function%":kp,"%GeneratorFunction%":cr,"%Int8Array%":typeof Int8Array>"u"?B:Int8Array,"%Int16Array%":typeof Int16Array>"u"?B:Int16Array,"%Int32Array%":typeof Int32Array>"u"?B:Int32Array,"%isFinite%":isFinite,"%isNaN%":isNaN,"%IteratorPrototype%":or&&_e?_e(_e([][Symbol.iterator]())):B,"%JSON%":typeof JSON=="object"?JSON:B,"%Map%":typeof Map>"u"?B:Map,"%MapIteratorPrototype%":typeof Map>"u"||!or||!_e?B:_e(new Map()[Symbol.iterator]()),"%Math%":Math,"%Number%":Number,"%Object%":Cy,"%Object.getOwnPropertyDescriptor%":xs,"%parseFloat%":parseFloat,"%parseInt%":parseInt,"%Promise%":typeof Promise>"u"?B:Promise,"%Proxy%":typeof Proxy>"u"?B:Proxy,"%RangeError%":Ry,"%ReferenceError%":Dy,"%Reflect%":typeof Reflect>"u"?B:Reflect,"%RegExp%":RegExp,"%Set%":typeof Set>"u"?B:Set,"%SetIteratorPrototype%":typeof Set>"u"||!or||!_e?B:_e(new Set()[Symbol.iterator]()),"%SharedArrayBuffer%":typeof SharedArrayBuffer>"u"?B:SharedArrayBuffer,"%String%":String,"%StringIteratorPrototype%":or&&_e?_e(""[Symbol.iterator]()):B,"%Symbol%":or?Symbol:B,"%SyntaxError%":Dr,"%ThrowTypeError%":Wy,"%TypedArray%":Vy,"%TypeError%":wr,"%Uint8Array%":typeof Uint8Array>"u"?B:Uint8Array,"%Uint8ClampedArray%":typeof Uint8ClampedArray>"u"?B:Uint8ClampedArray,"%Uint16Array%":typeof Uint16Array>"u"?B:Uint16Array,"%Uint32Array%":typeof Uint32Array>"u"?B:Uint32Array,"%URIError%":Oy,"%WeakMap%":typeof WeakMap>"u"?B:WeakMap,"%WeakRef%":typeof WeakRef>"u"?B:WeakRef,"%WeakSet%":typeof WeakSet>"u"?B:WeakSet,"%Function.prototype.call%":ci,"%Function.prototype.apply%":Ep,"%Object.defineProperty%":jy,"%Object.getPrototypeOf%":By,"%Math.abs%":zy,"%Math.floor%":Ly,"%Math.max%":My,"%Math.min%":Ny,"%Math.pow%":Uy,"%Math.round%":Fy,"%Math.sign%":Zy,"%Reflect.getPrototypeOf%":Gy};if(_e)try{null.error}catch(t){var Hy=_e(_e(t));Wn["%Error.prototype%"]=Hy}var qy=function t(e){var n;if(e==="%AsyncFunction%")n=ya("async function () {}");else if(e==="%GeneratorFunction%")n=ya("function* () {}");else if(e==="%AsyncGeneratorFunction%")n=ya("async function* () {}");else if(e==="%AsyncGenerator%"){var r=t("%AsyncGeneratorFunction%");r&&(n=r.prototype)}else if(e==="%AsyncIteratorPrototype%"){var s=t("%AsyncGenerator%");s&&_e&&(n=_e(s.prototype))}return Wn[e]=n,n},Zu={__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"]},ui=li,ao=jt,Yy=ui.call(ci,Array.prototype.concat),Ky=ui.call(Ep,Array.prototype.splice),ju=ui.call(ci,String.prototype.replace),lo=ui.call(ci,String.prototype.slice),Jy=ui.call(ci,RegExp.prototype.exec),Xy=/[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g,Qy=/\\(\\)?/g,eb=function(e){var n=lo(e,0,1),r=lo(e,-1);if(n==="%"&&r!=="%")throw new Dr("invalid intrinsic syntax, expected closing `%`");if(r==="%"&&n!=="%")throw new Dr("invalid intrinsic syntax, expected opening `%`");var s=[];return ju(e,Xy,function(i,o,a,l){s[s.length]=a?ju(l,Qy,"$1"):o||i}),s},tb=function(e,n){var r=e,s;if(ao(Zu,r)&&(s=Zu[r],r="%"+s[0]+"%"),ao(Wn,r)){var i=Wn[r];if(i===cr&&(i=qy(r)),typeof i>"u"&&!n)throw new wr("intrinsic "+e+" exists, but is not available. Please file an issue!");return{alias:s,name:r,value:i}}throw new Dr("intrinsic "+e+" does not exist!")},Qe=function(e,n){if(typeof e!="string"||e.length===0)throw new wr("intrinsic name must be a non-empty string");if(arguments.length>1&&typeof n!="boolean")throw new wr('"allowMissing" argument must be a boolean');if(Jy(/^%?[^%]*%?$/,e)===null)throw new Dr("`%` may not be present anywhere but at the beginning and end of the intrinsic name");var r=eb(e),s=r.length>0?r[0]:"",i=tb("%"+s+"%",n),o=i.name,a=i.value,l=!1,c=i.alias;c&&(s=c[0],Ky(r,Yy([0,1],c)));for(var d=1,p=!0;d<r.length;d+=1){var y=r[d],m=lo(y,0,1),E=lo(y,-1);if((m==='"'||m==="'"||m==="`"||E==='"'||E==="'"||E==="`")&&m!==E)throw new Dr("property names with quotes must have matching quotes");if((y==="constructor"||!p)&&(l=!0),s+="."+y,o="%"+s+"%",ao(Wn,o))a=Wn[o];else if(a!=null){if(!(y in a)){if(!n)throw new wr("base intrinsic for "+e+" exists, but the property is not available.");return}if(xs&&d+1>=r.length){var k=xs(a,y);p=!!k,p&&"get"in k&&!("originalValue"in k.get)?a=k.get:a=a[y]}else p=ao(a,y),a=a[y];p&&!l&&(Wn[o]=a)}}return a},$p=Qe,Ap=zo,nb=Ap([$p("%String.prototype.indexOf%")]),hn=function(e,n){var r=$p(e,!!n);return typeof r=="function"&&nb(e,".prototype.")>-1?Ap([r]):r},wa,Wu;function ac(){if(Wu)return wa;Wu=1;var t=Qe,e=t("%Array%"),n=!e.isArray&&hn("Object.prototype.toString");return wa=e.isArray||function(s){return n(s)==="[object Array]"},wa}var rb=Oo,Bu=ai,xp=rb.hasArrayLengthDefineBug(),sb=xp&&ac(),ib=hn,ob=ib("Object.prototype.propertyIsEnumerable"),lc=function(e,n,r,s,i,o){if(!Bu){if(!e(o)||!o["[[Configurable]]"]||!o["[[Writable]]"]||i in s&&ob(s,i)!==!!o["[[Enumerable]]"])return!1;var a=o["[[Value]]"];return s[i]=a,n(s[i],a)}return xp&&i==="length"&&"[[Value]]"in o&&sb(s)&&s.length!==o["[[Value]]"]?(s.length=o["[[Value]]"],s.length===o["[[Value]]"]):(Bu(s,i,r(o)),!0)},ab=V,ts=jt,lb={__proto__:null,"[[Configurable]]":!0,"[[Enumerable]]":!0,"[[Get]]":!0,"[[Set]]":!0,"[[Value]]":!0,"[[Writable]]":!0},Zr=function(e){if(!e||typeof e!="object")return!1;for(var n in e)if(ts(e,n)&&!lb[n])return!1;var r=ts(e,"[[Value]]")||ts(e,"[[Writable]]"),s=ts(e,"[[Get]]")||ts(e,"[[Set]]");if(r&&s)throw new ab("Property Descriptors may not be both accessor and data descriptors");return!0},Tp=function(e){if(typeof e>"u")return e;var n={};return"[[Value]]"in e&&(n.value=e["[[Value]]"]),"[[Writable]]"in e&&(n.writable=!!e["[[Writable]]"]),"[[Get]]"in e&&(n.get=e["[[Get]]"]),"[[Set]]"in e&&(n.set=e["[[Set]]"]),"[[Enumerable]]"in e&&(n.enumerable=!!e["[[Enumerable]]"]),"[[Configurable]]"in e&&(n.configurable=!!e["[[Configurable]]"]),n},cb=V,ub=Zr,hb=Tp,Cp=function(e){if(typeof e<"u"&&!ub(e))throw new cb("Assertion failed: `Desc` must be a Property Descriptor");return hb(e)},db=V,Gu=jt,pb=Zr,Ip=function(e){if(typeof e>"u")return!1;if(!pb(e))throw new db("Assertion failed: `Desc` must be a Property Descriptor");return!(!Gu(e,"[[Value]]")&&!Gu(e,"[[Writable]]"))},jr=function(e){return typeof e=="string"||typeof e=="symbol"},Vu=rc,Pp=function(e,n){return e===n?e===0?1/e===1/n:!0:Vu(e)&&Vu(n)},Hu=V,fb=Zt,gb=lc,mb=Cp,vb=Ip,yb=jr,bb=Pp,cc=function(e,n,r){if(!fb(e))throw new Hu("Assertion failed: Type(O) is not Object");if(!yb(n))throw new Hu("Assertion failed: P is not a Property Key");var s={"[[Configurable]]":!0,"[[Enumerable]]":!1,"[[Value]]":r,"[[Writable]]":!0};return gb(vb,bb,mb,e,n,s)},Rp=Function.prototype.toString,mr=typeof Reflect=="object"&&Reflect!==null&&Reflect.apply,sl,Ji;if(typeof mr=="function"&&typeof Object.defineProperty=="function")try{sl=Object.defineProperty({},"length",{get:function(){throw Ji}}),Ji={},mr(function(){throw 42},null,sl)}catch(t){t!==Ji&&(mr=null)}else mr=null;var wb=/^\s*class\b/,il=function(e){try{var n=Rp.call(e);return wb.test(n)}catch{return!1}},_a=function(e){try{return il(e)?!1:(Rp.call(e),!0)}catch{return!1}},Xi=Object.prototype.toString,_b="[object Object]",Sb="[object Function]",kb="[object GeneratorFunction]",Eb="[object HTMLAllCollection]",$b="[object HTML document.all class]",Ab="[object HTMLCollection]",xb=typeof Symbol=="function"&&!!Symbol.toStringTag,Tb=!(0 in[,]),ol=function(){return!1};if(typeof document=="object"){var Cb=document.all;Xi.call(Cb)===Xi.call(document.all)&&(ol=function(e){if((Tb||!e)&&(typeof e>"u"||typeof e=="object"))try{var n=Xi.call(e);return(n===Eb||n===$b||n===Ab||n===_b)&&e("")==null}catch{}return!1})}var Dp=mr?function(e){if(ol(e))return!0;if(!e||typeof e!="function"&&typeof e!="object")return!1;try{mr(e,null,sl)}catch(n){if(n!==Ji)return!1}return!il(e)&&_a(e)}:function(e){if(ol(e))return!0;if(!e||typeof e!="function"&&typeof e!="object")return!1;if(xb)return _a(e);if(il(e))return!1;var n=Xi.call(e);return n!==Sb&&n!==kb&&!/^\[object HTML/.test(n)?!1:_a(e)},Ib=Dp,Pb=function(e){return!!e},dt=jt,Ii=V,Rb=Zt,qu=Ib,Sa=Pb,Db=function(e){if(!Rb(e))throw new Ii("ToPropertyDescriptor requires an object");var n={};if(dt(e,"enumerable")&&(n["[[Enumerable]]"]=Sa(e.enumerable)),dt(e,"configurable")&&(n["[[Configurable]]"]=Sa(e.configurable)),dt(e,"value")&&(n["[[Value]]"]=e.value),dt(e,"writable")&&(n["[[Writable]]"]=Sa(e.writable)),dt(e,"get")){var r=e.get;if(typeof r<"u"&&!qu(r))throw new Ii("getter must be a function");n["[[Get]]"]=r}if(dt(e,"set")){var s=e.set;if(typeof s<"u"&&!qu(s))throw new Ii("setter must be a function");n["[[Set]]"]=s}if((dt(n,"[[Get]]")||dt(n,"[[Set]]"))&&(dt(n,"[[Value]]")||dt(n,"[[Writable]]")))throw new Ii("Invalid property descriptor. Cannot both specify accessors and a value or writable attribute");return n},ka=V,Ob=Zt,Yu=Zr,zb=lc,Lb=Cp,Mb=Ip,Nb=jr,Ub=Pp,Fb=Db,Zb=function(e,n,r){if(!Ob(e))throw new ka("Assertion failed: Type(O) is not Object");if(!Nb(n))throw new ka("Assertion failed: P is not a Property Key");var s=Yu(r)?r:Fb(r);if(!Yu(s))throw new ka("Assertion failed: Desc is not a valid Property Descriptor");return zb(Mb,Ub,Lb,e,n,s)},Ku=V,jb=Zt,Wb=Zb,Bb=jr,Gb=function(e,n,r){if(!jb(e))throw new Ku("Assertion failed: Type(O) is not Object");if(!Bb(n))throw new Ku("Assertion failed: P is not a Property Key");var s={"[[Configurable]]":!0,"[[Enumerable]]":!1,"[[Value]]":r,"[[Writable]]":!0};return Wb(e,n,s)},Vb=typeof Reflect<"u"&&Reflect.setPrototypeOf||null,Hb=tc,qb=Hb.setPrototypeOf||null,Yb=zo,Ju=Ur,Kb=V,Op={};try{Op.__proto__=null}catch(t){if(!t||typeof t!="object"||!("code"in t)||t.code!=="ERR_PROTO_ACCESS")throw t}var Jb=!("toString"in Op),Ea=Ju&&Ju(Object.prototype,"__proto__"),Xb=Jb&&(!!Ea&&typeof Ea.set=="function"&&Yb([Ea.set])||function(e,n){if(e==null)throw new Kb("set Object.prototype.__proto__ called on null or undefined");return e.__proto__=n,n}),Xu=Vb,Qb=qb,Qu=Xb,ew=V,tw=Xu?function(e,n){if(Xu(e,n))return e;throw new ew("Reflect.setPrototypeOf: failed to set [[Prototype]]")}:Qb||(Qu?function(e,n){return Qu(e,n),e}:null),eh=V,nw=Zt,th=Sp(),rw=function(e){if(!nw(e))throw new eh("Assertion failed: O must be an Object");if(!th)throw new eh("This environment does not support fetching prototypes.");return th(e)},sw=V,iw=tw,ow=Zt,aw=rw,lw=function(e,n){if(n!==null&&!ow(n))throw new sw("Assertion failed: V must be Object or Null");try{iw(e,n)}catch{return!1}return aw(e)===n},$a=cc,nh=Gb,zp=lw,cw=Oo(),uc=yp;function hi(t,e,n){var r=new uc(n);return zp(r,Qi),delete r.constructor,nh(r,"error",t),nh(r,"suppressed",e),r}cw&&Object.defineProperty(hi,"prototype",{writable:!1});var Qi=hi.prototype;if(!$a(Qi,"constructor",hi)||!$a(Qi,"message","")||!$a(Qi,"name","SuppressedError"))throw new uc("unable to install SuppressedError.prototype properties; please report this!");zp(hi.prototype,uc.prototype);var uw=hi,hw=uw,Lp=function(){return typeof SuppressedError=="function"?SuppressedError:hw},dw=Yn,rh=ec(),pw=Lp,fw=function(){var e=pw();return dw(rh,{SuppressedError:e},{SuppressedError:function(){return rh.SuppressedError!==e}}),e};fw();var gw=V,mw=Zr,vw=Tp,yw=function(e){if(typeof e<"u"&&!mw(e))throw new gw("Assertion failed: `Desc` must be a Property Descriptor");return vw(e)},bw=V,sh=jt,ww=Zr,_w=function(e){if(typeof e>"u")return!1;if(!ww(e))throw new bw("Assertion failed: `Desc` must be a Property Descriptor");return!(!sh(e,"[[Value]]")&&!sh(e,"[[Writable]]"))},ih=rc,Sw=function(e,n){return e===n?e===0?1/e===1/n:!0:ih(e)&&ih(n)},Wr=Dp,kw=function(e){return!!e},pt=jt,Pi=V,Ew=Zt,oh=Wr,Aa=kw,$w=function(e){if(!Ew(e))throw new Pi("ToPropertyDescriptor requires an object");var n={};if(pt(e,"enumerable")&&(n["[[Enumerable]]"]=Aa(e.enumerable)),pt(e,"configurable")&&(n["[[Configurable]]"]=Aa(e.configurable)),pt(e,"value")&&(n["[[Value]]"]=e.value),pt(e,"writable")&&(n["[[Writable]]"]=Aa(e.writable)),pt(e,"get")){var r=e.get;if(typeof r<"u"&&!oh(r))throw new Pi("getter must be a function");n["[[Get]]"]=r}if(pt(e,"set")){var s=e.set;if(typeof s<"u"&&!oh(s))throw new Pi("setter must be a function");n["[[Set]]"]=s}if((pt(n,"[[Get]]")||pt(n,"[[Set]]"))&&(pt(n,"[[Value]]")||pt(n,"[[Writable]]")))throw new Pi("Invalid property descriptor. Cannot both specify accessors and a value or writable attribute");return n},xa=V,Aw=Zt,ah=Zr,xw=lc,Tw=yw,Cw=_w,Iw=jr,Pw=Sw,Rw=$w,di=function(e,n,r){if(!Aw(e))throw new xa("Assertion failed: Type(O) is not Object");if(!Iw(n))throw new xa("Assertion failed: P is not a Property Key");var s=ah(r)?r:Rw(r);if(!ah(s))throw new xa("Assertion failed: Desc is not a valid Property Descriptor");return xw(Cw,Pw,Tw,e,n,s)},Dw=Fr(),Ow=Dw?Symbol.dispose||Symbol("Symbol.dispose"):null,zw=Fr,Lw=Ow,hc=function(){return zw()&&Symbol.dispose||Lw},Mw=sc,Nw=di,Uw=hc,Fw=function(){var e=Uw();return Mw()&&Nw(Symbol,"dispose",{"[[Configurable]]":!1,"[[Enumerable]]":!1,"[[Writable]]":!1,"[[Value]]":e}),e},Zw=Fr(),jw=Zw?Symbol.asyncDispose||Symbol("Symbol.asyncDispose"):null,Ww=Fr,Bw=jw,dc=function(){return Ww()&&Symbol.asyncDispose||Bw},Gw=sc,Vw=di,Hw=dc,qw=function(){var e=Hw();return Gw()&&Vw(Symbol,"asyncDispose",{"[[Configurable]]":!1,"[[Enumerable]]":!1,"[[Writable]]":!1,"[[Value]]":e}),e},Yw=ac(),Kw=Qe,Jw=hn,Xw=V,Qw=Yw,e_=Kw("%Reflect.apply%",!0)||Jw("Function.prototype.apply"),Lo=function(e,n){var r=arguments.length>2?arguments[2]:[];if(!Qw(r))throw new Xw("Assertion failed: optional `argumentsList`, if provided, must be a List");return e_(e,n,r)};const t_={},n_=Object.freeze(Object.defineProperty({__proto__:null,default:t_},Symbol.toStringTag,{value:"Module"})),r_=Tv(n_);var pc=typeof Map=="function"&&Map.prototype,Ta=Object.getOwnPropertyDescriptor&&pc?Object.getOwnPropertyDescriptor(Map.prototype,"size"):null,co=pc&&Ta&&typeof Ta.get=="function"?Ta.get:null,lh=pc&&Map.prototype.forEach,fc=typeof Set=="function"&&Set.prototype,Ca=Object.getOwnPropertyDescriptor&&fc?Object.getOwnPropertyDescriptor(Set.prototype,"size"):null,uo=fc&&Ca&&typeof Ca.get=="function"?Ca.get:null,ch=fc&&Set.prototype.forEach,s_=typeof WeakMap=="function"&&WeakMap.prototype,Ss=s_?WeakMap.prototype.has:null,i_=typeof WeakSet=="function"&&WeakSet.prototype,ks=i_?WeakSet.prototype.has:null,o_=typeof WeakRef=="function"&&WeakRef.prototype,uh=o_?WeakRef.prototype.deref:null,a_=Boolean.prototype.valueOf,l_=Object.prototype.toString,c_=Function.prototype.toString,u_=String.prototype.match,gc=String.prototype.slice,en=String.prototype.replace,h_=String.prototype.toUpperCase,hh=String.prototype.toLowerCase,Mp=RegExp.prototype.test,dh=Array.prototype.concat,_t=Array.prototype.join,d_=Array.prototype.slice,ph=Math.floor,al=typeof BigInt=="function"?BigInt.prototype.valueOf:null,Ia=Object.getOwnPropertySymbols,ll=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?Symbol.prototype.toString:null,Or=typeof Symbol=="function"&&typeof Symbol.iterator=="object",Es=typeof Symbol=="function"&&Symbol.toStringTag&&(typeof Symbol.toStringTag===Or||!0)?Symbol.toStringTag:null,Np=Object.prototype.propertyIsEnumerable,fh=(typeof Reflect=="function"?Reflect.getPrototypeOf:Object.getPrototypeOf)||([].__proto__===Array.prototype?function(t){return t.__proto__}:null);function gh(t,e){if(t===1/0||t===-1/0||t!==t||t&&t>-1e3&&t<1e3||Mp.call(/e/,e))return e;var n=/[0-9](?=(?:[0-9]{3})+(?![0-9]))/g;if(typeof t=="number"){var r=t<0?-ph(-t):ph(t);if(r!==t){var s=String(r),i=gc.call(e,s.length+1);return en.call(s,n,"$&_")+"."+en.call(en.call(i,/([0-9]{3})/g,"$&_"),/_$/,"")}}return en.call(e,n,"$&_")}var cl=r_,mh=cl.custom,vh=Zp(mh)?mh:null,Up={__proto__:null,double:'"',single:"'"},p_={__proto__:null,double:/(["\\])/g,single:/(['\\])/g},Br=function t(e,n,r,s){var i=n||{};if(It(i,"quoteStyle")&&!It(Up,i.quoteStyle))throw new TypeError('option "quoteStyle" must be "single" or "double"');if(It(i,"maxStringLength")&&(typeof i.maxStringLength=="number"?i.maxStringLength<0&&i.maxStringLength!==1/0:i.maxStringLength!==null))throw new TypeError('option "maxStringLength", if provided, must be a positive integer, Infinity, or `null`');var o=It(i,"customInspect")?i.customInspect:!0;if(typeof o!="boolean"&&o!=="symbol")throw new TypeError("option \"customInspect\", if provided, must be `true`, `false`, or `'symbol'`");if(It(i,"indent")&&i.indent!==null&&i.indent!==" "&&!(parseInt(i.indent,10)===i.indent&&i.indent>0))throw new TypeError('option "indent" must be "\\t", an integer > 0, or `null`');if(It(i,"numericSeparator")&&typeof i.numericSeparator!="boolean")throw new TypeError('option "numericSeparator", if provided, must be `true` or `false`');var a=i.numericSeparator;if(typeof e>"u")return"undefined";if(e===null)return"null";if(typeof e=="boolean")return e?"true":"false";if(typeof e=="string")return Wp(e,i);if(typeof e=="number"){if(e===0)return 1/0/e>0?"0":"-0";var l=String(e);return a?gh(e,l):l}if(typeof e=="bigint"){var c=String(e)+"n";return a?gh(e,c):c}var d=typeof i.depth>"u"?5:i.depth;if(typeof r>"u"&&(r=0),r>=d&&d>0&&typeof e=="object")return ul(e)?"[Array]":"[Object]";var p=P_(i,r);if(typeof s>"u")s=[];else if(jp(s,e)>=0)return"[Circular]";function y(ct,Wt,ea){if(Wt&&(s=d_.call(s),s.push(Wt)),ea){var _i={depth:i.depth};return It(i,"quoteStyle")&&(_i.quoteStyle=i.quoteStyle),t(ct,_i,r+1,s)}return t(ct,i,r+1,s)}if(typeof e=="function"&&!yh(e)){var m=S_(e),E=Ri(e,y);return"[Function"+(m?": "+m:" (anonymous)")+"]"+(E.length>0?" { "+_t.call(E,", ")+" }":"")}if(Zp(e)){var k=Or?en.call(String(e),/^(Symbol\(.*\))_[^)]*$/,"$1"):ll.call(e);return typeof e=="object"&&!Or?ns(k):k}if(T_(e)){for(var I="<"+hh.call(String(e.nodeName)),G=e.attributes||[],N=0;N<G.length;N++)I+=" "+G[N].name+"="+Fp(f_(G[N].value),"double",i);return I+=">",e.childNodes&&e.childNodes.length&&(I+="..."),I+="</"+hh.call(String(e.nodeName))+">",I}if(ul(e)){if(e.length===0)return"[]";var j=Ri(e,y);return p&&!I_(j)?"["+hl(j,p)+"]":"[ "+_t.call(j,", ")+" ]"}if(m_(e)){var F=Ri(e,y);return!("cause"in Error.prototype)&&"cause"in e&&!Np.call(e,"cause")?"{ ["+String(e)+"] "+_t.call(dh.call("[cause]: "+y(e.cause),F),", ")+" }":F.length===0?"["+String(e)+"]":"{ ["+String(e)+"] "+_t.call(F,", ")+" }"}if(typeof e=="object"&&o){if(vh&&typeof e[vh]=="function"&&cl)return cl(e,{depth:d-r});if(o!=="symbol"&&typeof e.inspect=="function")return e.inspect()}if(k_(e)){var L=[];return lh&&lh.call(e,function(ct,Wt){L.push(y(Wt,e,!0)+" => "+y(ct,e))}),bh("Map",co.call(e),L,p)}if(A_(e)){var J=[];return ch&&ch.call(e,function(ct){J.push(y(ct,e))}),bh("Set",uo.call(e),J,p)}if(E_(e))return Pa("WeakMap");if(x_(e))return Pa("WeakSet");if($_(e))return Pa("WeakRef");if(y_(e))return ns(y(Number(e)));if(w_(e))return ns(y(al.call(e)));if(b_(e))return ns(a_.call(e));if(v_(e))return ns(y(String(e)));if(typeof window<"u"&&e===window)return"{ [object Window] }";if(typeof globalThis<"u"&&e===globalThis||typeof Sn<"u"&&e===Sn)return"{ [object globalThis] }";if(!g_(e)&&!yh(e)){var H=Ri(e,y),he=fh?fh(e)===Object.prototype:e instanceof Object||e.constructor===Object,lt=e instanceof Object?"":"null prototype",wi=!he&&Es&&Object(e)===e&&Es in e?gc.call(dn(e),8,-1):lt?"Object":"",Ee=he||typeof e.constructor!="function"?"":e.constructor.name?e.constructor.name+" ":"",gn=Ee+(wi||lt?"["+_t.call(dh.call([],wi||[],lt||[]),": ")+"] ":"");return H.length===0?gn+"{}":p?gn+"{"+hl(H,p)+"}":gn+"{ "+_t.call(H,", ")+" }"}return String(e)};function Fp(t,e,n){var r=n.quoteStyle||e,s=Up[r];return s+t+s}function f_(t){return en.call(String(t),/"/g,""")}function Kn(t){return!Es||!(typeof t=="object"&&(Es in t||typeof t[Es]<"u"))}function ul(t){return dn(t)==="[object Array]"&&Kn(t)}function g_(t){return dn(t)==="[object Date]"&&Kn(t)}function yh(t){return dn(t)==="[object RegExp]"&&Kn(t)}function m_(t){return dn(t)==="[object Error]"&&Kn(t)}function v_(t){return dn(t)==="[object String]"&&Kn(t)}function y_(t){return dn(t)==="[object Number]"&&Kn(t)}function b_(t){return dn(t)==="[object Boolean]"&&Kn(t)}function Zp(t){if(Or)return t&&typeof t=="object"&&t instanceof Symbol;if(typeof t=="symbol")return!0;if(!t||typeof t!="object"||!ll)return!1;try{return ll.call(t),!0}catch{}return!1}function w_(t){if(!t||typeof t!="object"||!al)return!1;try{return al.call(t),!0}catch{}return!1}var __=Object.prototype.hasOwnProperty||function(t){return t in this};function It(t,e){return __.call(t,e)}function dn(t){return l_.call(t)}function S_(t){if(t.name)return t.name;var e=u_.call(c_.call(t),/^function\s*([\w$]+)/);return e?e[1]:null}function jp(t,e){if(t.indexOf)return t.indexOf(e);for(var n=0,r=t.length;n<r;n++)if(t[n]===e)return n;return-1}function k_(t){if(!co||!t||typeof t!="object")return!1;try{co.call(t);try{uo.call(t)}catch{return!0}return t instanceof Map}catch{}return!1}function E_(t){if(!Ss||!t||typeof t!="object")return!1;try{Ss.call(t,Ss);try{ks.call(t,ks)}catch{return!0}return t instanceof WeakMap}catch{}return!1}function $_(t){if(!uh||!t||typeof t!="object")return!1;try{return uh.call(t),!0}catch{}return!1}function A_(t){if(!uo||!t||typeof t!="object")return!1;try{uo.call(t);try{co.call(t)}catch{return!0}return t instanceof Set}catch{}return!1}function x_(t){if(!ks||!t||typeof t!="object")return!1;try{ks.call(t,ks);try{Ss.call(t,Ss)}catch{return!0}return t instanceof WeakSet}catch{}return!1}function T_(t){return!t||typeof t!="object"?!1:typeof HTMLElement<"u"&&t instanceof HTMLElement?!0:typeof t.nodeName=="string"&&typeof t.getAttribute=="function"}function Wp(t,e){if(t.length>e.maxStringLength){var n=t.length-e.maxStringLength,r="... "+n+" more character"+(n>1?"s":"");return Wp(gc.call(t,0,e.maxStringLength),e)+r}var s=p_[e.quoteStyle||"single"];s.lastIndex=0;var i=en.call(en.call(t,s,"\\$1"),/[\x00-\x1f]/g,C_);return Fp(i,"single",e)}function C_(t){var e=t.charCodeAt(0),n={8:"b",9:"t",10:"n",12:"f",13:"r"}[e];return n?"\\"+n:"\\x"+(e<16?"0":"")+h_.call(e.toString(16))}function ns(t){return"Object("+t+")"}function Pa(t){return t+" { ? }"}function bh(t,e,n,r){var s=r?hl(n,r):_t.call(n,", ");return t+" ("+e+") {"+s+"}"}function I_(t){for(var e=0;e<t.length;e++)if(jp(t[e],`
|
|
2
|
-
`)>=0)return!1;return!0}function
|
|
1
|
+
var Av=Object.defineProperty;var Eu=t=>{throw TypeError(t)};var xv=(t,e,n)=>e in t?Av(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var v=(t,e,n)=>xv(t,typeof e!="symbol"?e+"":e,n),da=(t,e,n)=>e.has(t)||Eu("Cannot "+n);var u=(t,e,n)=>(da(t,e,"read from private field"),n?n.call(t):e.get(t)),$=(t,e,n)=>e.has(t)?Eu("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,n),x=(t,e,n,r)=>(da(t,e,"write to private field"),r?r.call(t,n):e.set(t,n),n),b=(t,e,n)=>(da(t,e,"access private method"),n);var $u=(t,e,n,r)=>({set _(s){x(t,e,s,n)},get _(){return u(t,e,r)}});(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const s of document.querySelectorAll('link[rel="modulepreload"]'))r(s);new MutationObserver(s=>{for(const i of s)if(i.type==="childList")for(const o of i.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&r(o)}).observe(document,{childList:!0,subtree:!0});function n(s){const i={};return s.integrity&&(i.integrity=s.integrity),s.referrerPolicy&&(i.referrerPolicy=s.referrerPolicy),s.crossOrigin==="use-credentials"?i.credentials="include":s.crossOrigin==="anonymous"?i.credentials="omit":i.credentials="same-origin",i}function r(s){if(s.ep)return;s.ep=!0;const i=n(s);fetch(s.href,i)}})();var Sn=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Tv(t){if(t.__esModule)return t;var e=t.default;if(typeof e=="function"){var n=function r(){return this instanceof r?Reflect.construct(e,arguments,this.constructor):e.apply(this,arguments)};n.prototype=e.prototype}else n={};return Object.defineProperty(n,"__esModule",{value:!0}),Object.keys(t).forEach(function(r){var s=Object.getOwnPropertyDescriptor(t,r);Object.defineProperty(n,r,s.get?s:{enumerable:!0,get:function(){return t[r]}})}),n}var Au=Object.prototype.toString,cp=function(e){var n=Au.call(e),r=n==="[object Arguments]";return r||(r=n!=="[object Array]"&&e!==null&&typeof e=="object"&&typeof e.length=="number"&&e.length>=0&&Au.call(e.callee)==="[object Function]"),r},pa,xu;function Cv(){if(xu)return pa;xu=1;var t;if(!Object.keys){var e=Object.prototype.hasOwnProperty,n=Object.prototype.toString,r=cp,s=Object.prototype.propertyIsEnumerable,i=!s.call({toString:null},"toString"),o=s.call(function(){},"prototype"),a=["toString","toLocaleString","valueOf","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","constructor"],l=function(y){var m=y.constructor;return m&&m.prototype===y},c={$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},d=function(){if(typeof window>"u")return!1;for(var y in window)try{if(!c["$"+y]&&e.call(window,y)&&window[y]!==null&&typeof window[y]=="object")try{l(window[y])}catch{return!0}}catch{return!0}return!1}(),p=function(y){if(typeof window>"u"||!d)return l(y);try{return l(y)}catch{return!1}};t=function(m){var E=m!==null&&typeof m=="object",k=n.call(m)==="[object Function]",I=r(m),G=E&&n.call(m)==="[object String]",N=[];if(!E&&!k&&!I)throw new TypeError("Object.keys called on a non-object");var j=o&&k;if(G&&m.length>0&&!e.call(m,0))for(var F=0;F<m.length;++F)N.push(String(F));if(I&&m.length>0)for(var L=0;L<m.length;++L)N.push(String(L));else for(var J in m)!(j&&J==="prototype")&&e.call(m,J)&&N.push(String(J));if(i)for(var H=p(m),he=0;he<a.length;++he)!(H&&a[he]==="constructor")&&e.call(m,a[he])&&N.push(a[he]);return N}}return pa=t,pa}var Iv=Array.prototype.slice,Pv=cp,Tu=Object.keys,Hi=Tu?function(e){return Tu(e)}:Cv(),Cu=Object.keys;Hi.shim=function(){if(Object.keys){var e=function(){var n=Object.keys(arguments);return n&&n.length===arguments.length}(1,2);e||(Object.keys=function(r){return Pv(r)?Cu(Iv.call(r)):Cu(r)})}else Object.keys=Hi;return Object.keys||Hi};var Rv=Hi,qi=Object.defineProperty||!1;if(qi)try{qi({},"a",{value:1})}catch{qi=!1}var ai=qi,Ft=SyntaxError,V=TypeError,Dv=Object.getOwnPropertyDescriptor,Yi=Dv;if(Yi)try{Yi([],"length")}catch{Yi=null}var Ur=Yi,Iu=ai,Ov=Ft,ir=V,Pu=Ur,up=function(e,n,r){if(!e||typeof e!="object"&&typeof e!="function")throw new ir("`obj` must be an object or a function`");if(typeof n!="string"&&typeof n!="symbol")throw new ir("`property` must be a string or a symbol`");if(arguments.length>3&&typeof arguments[3]!="boolean"&&arguments[3]!==null)throw new ir("`nonEnumerable`, if provided, must be a boolean or null");if(arguments.length>4&&typeof arguments[4]!="boolean"&&arguments[4]!==null)throw new ir("`nonWritable`, if provided, must be a boolean or null");if(arguments.length>5&&typeof arguments[5]!="boolean"&&arguments[5]!==null)throw new ir("`nonConfigurable`, if provided, must be a boolean or null");if(arguments.length>6&&typeof arguments[6]!="boolean")throw new ir("`loose`, if provided, must be a boolean");var s=arguments.length>3?arguments[3]:null,i=arguments.length>4?arguments[4]:null,o=arguments.length>5?arguments[5]:null,a=arguments.length>6?arguments[6]:!1,l=!!Pu&&Pu(e,n);if(Iu)Iu(e,n,{configurable:o===null&&l?l.configurable:!o,enumerable:s===null&&l?l.enumerable:!s,value:r,writable:i===null&&l?l.writable:!i});else if(a||!s&&!i&&!o)e[n]=r;else throw new Ov("This environment does not support defining a property as non-configurable, non-writable, or non-enumerable.")},tl=ai,hp=function(){return!!tl};hp.hasArrayLengthDefineBug=function(){if(!tl)return null;try{return tl([],"length",{value:1}).length!==1}catch{return!0}};var Oo=hp,zv=Rv,Lv=typeof Symbol=="function"&&typeof Symbol("foo")=="symbol",Mv=Object.prototype.toString,Nv=Array.prototype.concat,Ru=up,Uv=function(t){return typeof t=="function"&&Mv.call(t)==="[object Function]"},dp=Oo(),Fv=function(t,e,n,r){if(e in t){if(r===!0){if(t[e]===n)return}else if(!Uv(r)||!r())return}dp?Ru(t,e,n,!0):Ru(t,e,n)},pp=function(t,e){var n=arguments.length>2?arguments[2]:{},r=zv(e);Lv&&(r=Nv.call(r,Object.getOwnPropertySymbols(e)));for(var s=0;s<r.length;s+=1)Fv(t,r[s],e[r[s]],n[r[s]])};pp.supportsDescriptors=!!dp;var Yn=pp,Ki={exports:{}};typeof self<"u"?Ki.exports=self:typeof window<"u"?Ki.exports=window:Ki.exports=Function("return this")();var fp=Ki.exports,Zv=fp,gp=function(){return typeof Sn!="object"||!Sn||Sn.Math!==Math||Sn.Array!==Array?Zv:Sn},jv=Yn,Wv=Ur,Bv=gp,Gv=function(){var e=Bv();if(jv.supportsDescriptors){var n=Wv(e,"globalThis");(!n||n.configurable&&(n.enumerable||!n.writable||globalThis!==e))&&Object.defineProperty(e,"globalThis",{configurable:!0,enumerable:!1,value:e,writable:!0})}else(typeof globalThis!="object"||globalThis!==e)&&(e.globalThis=e);return e},Vv=Yn,Hv=fp,mp=gp,qv=Gv,Yv=mp(),vp=function(){return Yv};Vv(vp,{getPolyfill:mp,implementation:Hv,shim:qv});var Xl=vp,Zt=function(e){return!!e&&(typeof e=="function"||typeof e=="object")},Ql=Object,yp=Error,Kv=EvalError,Jv=RangeError,ec=ReferenceError,Xv=URIError,Qv=Math.abs,ey=Math.floor,ty=Math.max,ny=Math.min,ry=Math.pow,sy=Math.round,tc=Number.isNaN||function(e){return e!==e},iy=tc,oy=function(e){return iy(e)||e===0?e:e<0?-1:1},Fr=function(){if(typeof Symbol!="function"||typeof Object.getOwnPropertySymbols!="function")return!1;if(typeof Symbol.iterator=="symbol")return!0;var e={},n=Symbol("test"),r=Object(n);if(typeof n=="string"||Object.prototype.toString.call(n)!=="[object Symbol]"||Object.prototype.toString.call(r)!=="[object Symbol]")return!1;var s=42;e[n]=s;for(var i in e)return!1;if(typeof Object.keys=="function"&&Object.keys(e).length!==0||typeof Object.getOwnPropertyNames=="function"&&Object.getOwnPropertyNames(e).length!==0)return!1;var o=Object.getOwnPropertySymbols(e);if(o.length!==1||o[0]!==n||!Object.prototype.propertyIsEnumerable.call(e,n))return!1;if(typeof Object.getOwnPropertyDescriptor=="function"){var a=Object.getOwnPropertyDescriptor(e,n);if(a.value!==s||a.enumerable!==!0)return!1}return!0},Du=typeof Symbol<"u"&&Symbol,ay=Fr,nc=function(){return typeof Du!="function"||typeof Symbol!="function"||typeof Du("foo")!="symbol"||typeof Symbol("bar")!="symbol"?!1:ay()},bp=typeof Reflect<"u"&&Reflect.getPrototypeOf||null,ly=Ql,wp=ly.getPrototypeOf||null,cy="Function.prototype.bind called on incompatible ",uy=Object.prototype.toString,hy=Math.max,dy="[object Function]",Ou=function(e,n){for(var r=[],s=0;s<e.length;s+=1)r[s]=e[s];for(var i=0;i<n.length;i+=1)r[i+e.length]=n[i];return r},py=function(e,n){for(var r=[],s=n,i=0;s<e.length;s+=1,i+=1)r[i]=e[s];return r},fy=function(t,e){for(var n="",r=0;r<t.length;r+=1)n+=t[r],r+1<t.length&&(n+=e);return n},gy=function(e){var n=this;if(typeof n!="function"||uy.apply(n)!==dy)throw new TypeError(cy+n);for(var r=py(arguments,1),s,i=function(){if(this instanceof s){var d=n.apply(this,Ou(r,arguments));return Object(d)===d?d:this}return n.apply(e,Ou(r,arguments))},o=hy(0,n.length-r.length),a=[],l=0;l<o;l++)a[l]="$"+l;if(s=Function("binder","return function ("+fy(a,",")+"){ return binder.apply(this,arguments); }")(i),n.prototype){var c=function(){};c.prototype=n.prototype,s.prototype=new c,c.prototype=null}return s},my=gy,li=Function.prototype.bind||my,rc=Function.prototype.call,sc=Function.prototype.apply,vy=typeof Reflect<"u"&&Reflect&&Reflect.apply,yy=li,by=sc,wy=rc,_y=vy,_p=_y||yy.call(wy,by),Sy=li,ky=V,Ey=rc,$y=_p,zo=function(e){if(e.length<1||typeof e[0]!="function")throw new ky("a function is required");return $y(Sy,Ey,e)},Ay=zo,zu=Ur,Sp;try{Sp=[].__proto__===Array.prototype}catch(t){if(!t||typeof t!="object"||!("code"in t)||t.code!=="ERR_PROTO_ACCESS")throw t}var fa=!!Sp&&zu&&zu(Object.prototype,"__proto__"),kp=Object,Lu=kp.getPrototypeOf,xy=fa&&typeof fa.get=="function"?Ay([fa.get]):typeof Lu=="function"?function(e){return Lu(e==null?e:kp(e))}:!1,Mu=bp,Nu=wp,Uu=xy,Ep=Mu?function(e){return Mu(e)}:Nu?function(e){if(!e||typeof e!="object"&&typeof e!="function")throw new TypeError("getProto: not an object");return Nu(e)}:Uu?function(e){return Uu(e)}:null,Ty=Function.prototype.call,Cy=Object.prototype.hasOwnProperty,Iy=li,jt=Iy.call(Ty,Cy),B,Py=Ql,Ry=yp,Dy=Kv,Oy=Jv,zy=ec,Dr=Ft,wr=V,Ly=Xv,My=Qv,Ny=ey,Uy=ty,Fy=ny,Zy=ry,jy=sy,Wy=oy,$p=Function,ga=function(t){try{return $p('"use strict"; return ('+t+").constructor;")()}catch{}},xs=Ur,By=ai,ma=function(){throw new wr},Gy=xs?function(){try{return arguments.callee,ma}catch{try{return xs(arguments,"callee").get}catch{return ma}}}():ma,or=nc(),_e=Ep,Vy=wp,Hy=bp,Ap=sc,ci=rc,cr={},qy=typeof Uint8Array>"u"||!_e?B:_e(Uint8Array),Wn={__proto__:null,"%AggregateError%":typeof AggregateError>"u"?B:AggregateError,"%Array%":Array,"%ArrayBuffer%":typeof ArrayBuffer>"u"?B:ArrayBuffer,"%ArrayIteratorPrototype%":or&&_e?_e([][Symbol.iterator]()):B,"%AsyncFromSyncIteratorPrototype%":B,"%AsyncFunction%":cr,"%AsyncGenerator%":cr,"%AsyncGeneratorFunction%":cr,"%AsyncIteratorPrototype%":cr,"%Atomics%":typeof Atomics>"u"?B:Atomics,"%BigInt%":typeof BigInt>"u"?B:BigInt,"%BigInt64Array%":typeof BigInt64Array>"u"?B:BigInt64Array,"%BigUint64Array%":typeof BigUint64Array>"u"?B:BigUint64Array,"%Boolean%":Boolean,"%DataView%":typeof DataView>"u"?B:DataView,"%Date%":Date,"%decodeURI%":decodeURI,"%decodeURIComponent%":decodeURIComponent,"%encodeURI%":encodeURI,"%encodeURIComponent%":encodeURIComponent,"%Error%":Ry,"%eval%":eval,"%EvalError%":Dy,"%Float16Array%":typeof Float16Array>"u"?B:Float16Array,"%Float32Array%":typeof Float32Array>"u"?B:Float32Array,"%Float64Array%":typeof Float64Array>"u"?B:Float64Array,"%FinalizationRegistry%":typeof FinalizationRegistry>"u"?B:FinalizationRegistry,"%Function%":$p,"%GeneratorFunction%":cr,"%Int8Array%":typeof Int8Array>"u"?B:Int8Array,"%Int16Array%":typeof Int16Array>"u"?B:Int16Array,"%Int32Array%":typeof Int32Array>"u"?B:Int32Array,"%isFinite%":isFinite,"%isNaN%":isNaN,"%IteratorPrototype%":or&&_e?_e(_e([][Symbol.iterator]())):B,"%JSON%":typeof JSON=="object"?JSON:B,"%Map%":typeof Map>"u"?B:Map,"%MapIteratorPrototype%":typeof Map>"u"||!or||!_e?B:_e(new Map()[Symbol.iterator]()),"%Math%":Math,"%Number%":Number,"%Object%":Py,"%Object.getOwnPropertyDescriptor%":xs,"%parseFloat%":parseFloat,"%parseInt%":parseInt,"%Promise%":typeof Promise>"u"?B:Promise,"%Proxy%":typeof Proxy>"u"?B:Proxy,"%RangeError%":Oy,"%ReferenceError%":zy,"%Reflect%":typeof Reflect>"u"?B:Reflect,"%RegExp%":RegExp,"%Set%":typeof Set>"u"?B:Set,"%SetIteratorPrototype%":typeof Set>"u"||!or||!_e?B:_e(new Set()[Symbol.iterator]()),"%SharedArrayBuffer%":typeof SharedArrayBuffer>"u"?B:SharedArrayBuffer,"%String%":String,"%StringIteratorPrototype%":or&&_e?_e(""[Symbol.iterator]()):B,"%Symbol%":or?Symbol:B,"%SyntaxError%":Dr,"%ThrowTypeError%":Gy,"%TypedArray%":qy,"%TypeError%":wr,"%Uint8Array%":typeof Uint8Array>"u"?B:Uint8Array,"%Uint8ClampedArray%":typeof Uint8ClampedArray>"u"?B:Uint8ClampedArray,"%Uint16Array%":typeof Uint16Array>"u"?B:Uint16Array,"%Uint32Array%":typeof Uint32Array>"u"?B:Uint32Array,"%URIError%":Ly,"%WeakMap%":typeof WeakMap>"u"?B:WeakMap,"%WeakRef%":typeof WeakRef>"u"?B:WeakRef,"%WeakSet%":typeof WeakSet>"u"?B:WeakSet,"%Function.prototype.call%":ci,"%Function.prototype.apply%":Ap,"%Object.defineProperty%":By,"%Object.getPrototypeOf%":Vy,"%Math.abs%":My,"%Math.floor%":Ny,"%Math.max%":Uy,"%Math.min%":Fy,"%Math.pow%":Zy,"%Math.round%":jy,"%Math.sign%":Wy,"%Reflect.getPrototypeOf%":Hy};if(_e)try{null.error}catch(t){var Yy=_e(_e(t));Wn["%Error.prototype%"]=Yy}var Ky=function t(e){var n;if(e==="%AsyncFunction%")n=ga("async function () {}");else if(e==="%GeneratorFunction%")n=ga("function* () {}");else if(e==="%AsyncGeneratorFunction%")n=ga("async function* () {}");else if(e==="%AsyncGenerator%"){var r=t("%AsyncGeneratorFunction%");r&&(n=r.prototype)}else if(e==="%AsyncIteratorPrototype%"){var s=t("%AsyncGenerator%");s&&_e&&(n=_e(s.prototype))}return Wn[e]=n,n},Fu={__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"]},ui=li,ao=jt,Jy=ui.call(ci,Array.prototype.concat),Xy=ui.call(Ap,Array.prototype.splice),Zu=ui.call(ci,String.prototype.replace),lo=ui.call(ci,String.prototype.slice),Qy=ui.call(ci,RegExp.prototype.exec),eb=/[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g,tb=/\\(\\)?/g,nb=function(e){var n=lo(e,0,1),r=lo(e,-1);if(n==="%"&&r!=="%")throw new Dr("invalid intrinsic syntax, expected closing `%`");if(r==="%"&&n!=="%")throw new Dr("invalid intrinsic syntax, expected opening `%`");var s=[];return Zu(e,eb,function(i,o,a,l){s[s.length]=a?Zu(l,tb,"$1"):o||i}),s},rb=function(e,n){var r=e,s;if(ao(Fu,r)&&(s=Fu[r],r="%"+s[0]+"%"),ao(Wn,r)){var i=Wn[r];if(i===cr&&(i=Ky(r)),typeof i>"u"&&!n)throw new wr("intrinsic "+e+" exists, but is not available. Please file an issue!");return{alias:s,name:r,value:i}}throw new Dr("intrinsic "+e+" does not exist!")},Qe=function(e,n){if(typeof e!="string"||e.length===0)throw new wr("intrinsic name must be a non-empty string");if(arguments.length>1&&typeof n!="boolean")throw new wr('"allowMissing" argument must be a boolean');if(Qy(/^%?[^%]*%?$/,e)===null)throw new Dr("`%` may not be present anywhere but at the beginning and end of the intrinsic name");var r=nb(e),s=r.length>0?r[0]:"",i=rb("%"+s+"%",n),o=i.name,a=i.value,l=!1,c=i.alias;c&&(s=c[0],Xy(r,Jy([0,1],c)));for(var d=1,p=!0;d<r.length;d+=1){var y=r[d],m=lo(y,0,1),E=lo(y,-1);if((m==='"'||m==="'"||m==="`"||E==='"'||E==="'"||E==="`")&&m!==E)throw new Dr("property names with quotes must have matching quotes");if((y==="constructor"||!p)&&(l=!0),s+="."+y,o="%"+s+"%",ao(Wn,o))a=Wn[o];else if(a!=null){if(!(y in a)){if(!n)throw new wr("base intrinsic for "+e+" exists, but the property is not available.");return}if(xs&&d+1>=r.length){var k=xs(a,y);p=!!k,p&&"get"in k&&!("originalValue"in k.get)?a=k.get:a=a[y]}else p=ao(a,y),a=a[y];p&&!l&&(Wn[o]=a)}}return a},va,ju;function hn(){if(ju)return va;ju=1;var t=Qe,e=zo,n=e([t("%String.prototype.indexOf%")]);return va=function(s,i){var o=t(s,!!i);return typeof o=="function"&&n(s,".prototype.")>-1?e([o]):o},va}var ya,Wu;function ic(){if(Wu)return ya;Wu=1;var t=Qe,e=t("%Array%"),n=!e.isArray&&hn()("Object.prototype.toString");return ya=e.isArray||function(s){return n(s)==="[object Array]"},ya}var sb=Oo,Bu=ai,xp=sb.hasArrayLengthDefineBug(),ib=xp&&ic(),ob=hn(),ab=ob("Object.prototype.propertyIsEnumerable"),oc=function(e,n,r,s,i,o){if(!Bu){if(!e(o)||!o["[[Configurable]]"]||!o["[[Writable]]"]||i in s&&ab(s,i)!==!!o["[[Enumerable]]"])return!1;var a=o["[[Value]]"];return s[i]=a,n(s[i],a)}return xp&&i==="length"&&"[[Value]]"in o&&ib(s)&&s.length!==o["[[Value]]"]?(s.length=o["[[Value]]"],s.length===o["[[Value]]"]):(Bu(s,i,r(o)),!0)},lb=V,ts=jt,cb={__proto__:null,"[[Configurable]]":!0,"[[Enumerable]]":!0,"[[Get]]":!0,"[[Set]]":!0,"[[Value]]":!0,"[[Writable]]":!0},Zr=function(e){if(!e||typeof e!="object")return!1;for(var n in e)if(ts(e,n)&&!cb[n])return!1;var r=ts(e,"[[Value]]")||ts(e,"[[Writable]]"),s=ts(e,"[[Get]]")||ts(e,"[[Set]]");if(r&&s)throw new lb("Property Descriptors may not be both accessor and data descriptors");return!0},Tp=function(e){if(typeof e>"u")return e;var n={};return"[[Value]]"in e&&(n.value=e["[[Value]]"]),"[[Writable]]"in e&&(n.writable=!!e["[[Writable]]"]),"[[Get]]"in e&&(n.get=e["[[Get]]"]),"[[Set]]"in e&&(n.set=e["[[Set]]"]),"[[Enumerable]]"in e&&(n.enumerable=!!e["[[Enumerable]]"]),"[[Configurable]]"in e&&(n.configurable=!!e["[[Configurable]]"]),n},ub=V,hb=Zr,db=Tp,Cp=function(e){if(typeof e<"u"&&!hb(e))throw new ub("Assertion failed: `Desc` must be a Property Descriptor");return db(e)},pb=V,Gu=jt,fb=Zr,Ip=function(e){if(typeof e>"u")return!1;if(!fb(e))throw new pb("Assertion failed: `Desc` must be a Property Descriptor");return!(!Gu(e,"[[Value]]")&&!Gu(e,"[[Writable]]"))},jr=function(e){return typeof e=="string"||typeof e=="symbol"},Vu=tc,Pp=function(e,n){return e===n?e===0?1/e===1/n:!0:Vu(e)&&Vu(n)},Hu=V,gb=Zt,mb=oc,vb=Cp,yb=Ip,bb=jr,wb=Pp,ac=function(e,n,r){if(!gb(e))throw new Hu("Assertion failed: Type(O) is not Object");if(!bb(n))throw new Hu("Assertion failed: P is not a Property Key");var s={"[[Configurable]]":!0,"[[Enumerable]]":!1,"[[Value]]":r,"[[Writable]]":!0};return mb(yb,wb,vb,e,n,s)},Rp=Function.prototype.toString,mr=typeof Reflect=="object"&&Reflect!==null&&Reflect.apply,nl,Ji;if(typeof mr=="function"&&typeof Object.defineProperty=="function")try{nl=Object.defineProperty({},"length",{get:function(){throw Ji}}),Ji={},mr(function(){throw 42},null,nl)}catch(t){t!==Ji&&(mr=null)}else mr=null;var _b=/^\s*class\b/,rl=function(e){try{var n=Rp.call(e);return _b.test(n)}catch{return!1}},ba=function(e){try{return rl(e)?!1:(Rp.call(e),!0)}catch{return!1}},Xi=Object.prototype.toString,Sb="[object Object]",kb="[object Function]",Eb="[object GeneratorFunction]",$b="[object HTMLAllCollection]",Ab="[object HTML document.all class]",xb="[object HTMLCollection]",Tb=typeof Symbol=="function"&&!!Symbol.toStringTag,Cb=!(0 in[,]),sl=function(){return!1};if(typeof document=="object"){var Ib=document.all;Xi.call(Ib)===Xi.call(document.all)&&(sl=function(e){if((Cb||!e)&&(typeof e>"u"||typeof e=="object"))try{var n=Xi.call(e);return(n===$b||n===Ab||n===xb||n===Sb)&&e("")==null}catch{}return!1})}var Dp=mr?function(e){if(sl(e))return!0;if(!e||typeof e!="function"&&typeof e!="object")return!1;try{mr(e,null,nl)}catch(n){if(n!==Ji)return!1}return!rl(e)&&ba(e)}:function(e){if(sl(e))return!0;if(!e||typeof e!="function"&&typeof e!="object")return!1;if(Tb)return ba(e);if(rl(e))return!1;var n=Xi.call(e);return n!==kb&&n!==Eb&&!/^\[object HTML/.test(n)?!1:ba(e)},Pb=Dp,Rb=function(e){return!!e},dt=jt,Ii=V,Db=Zt,qu=Pb,wa=Rb,Ob=function(e){if(!Db(e))throw new Ii("ToPropertyDescriptor requires an object");var n={};if(dt(e,"enumerable")&&(n["[[Enumerable]]"]=wa(e.enumerable)),dt(e,"configurable")&&(n["[[Configurable]]"]=wa(e.configurable)),dt(e,"value")&&(n["[[Value]]"]=e.value),dt(e,"writable")&&(n["[[Writable]]"]=wa(e.writable)),dt(e,"get")){var r=e.get;if(typeof r<"u"&&!qu(r))throw new Ii("getter must be a function");n["[[Get]]"]=r}if(dt(e,"set")){var s=e.set;if(typeof s<"u"&&!qu(s))throw new Ii("setter must be a function");n["[[Set]]"]=s}if((dt(n,"[[Get]]")||dt(n,"[[Set]]"))&&(dt(n,"[[Value]]")||dt(n,"[[Writable]]")))throw new Ii("Invalid property descriptor. Cannot both specify accessors and a value or writable attribute");return n},_a=V,zb=Zt,Yu=Zr,Lb=oc,Mb=Cp,Nb=Ip,Ub=jr,Fb=Pp,Zb=Ob,jb=function(e,n,r){if(!zb(e))throw new _a("Assertion failed: Type(O) is not Object");if(!Ub(n))throw new _a("Assertion failed: P is not a Property Key");var s=Yu(r)?r:Zb(r);if(!Yu(s))throw new _a("Assertion failed: Desc is not a valid Property Descriptor");return Lb(Nb,Fb,Mb,e,n,s)},Ku=V,Wb=Zt,Bb=jb,Gb=jr,Vb=function(e,n,r){if(!Wb(e))throw new Ku("Assertion failed: Type(O) is not Object");if(!Gb(n))throw new Ku("Assertion failed: P is not a Property Key");var s={"[[Configurable]]":!0,"[[Enumerable]]":!1,"[[Value]]":r,"[[Writable]]":!0};return Bb(e,n,s)},Hb=typeof Reflect<"u"&&Reflect.setPrototypeOf||null,qb=Ql,Yb=qb.setPrototypeOf||null,Kb=zo,Ju=Ur,Jb=V,Op={};try{Op.__proto__=null}catch(t){if(!t||typeof t!="object"||!("code"in t)||t.code!=="ERR_PROTO_ACCESS")throw t}var Xb=!("toString"in Op),Sa=Ju&&Ju(Object.prototype,"__proto__"),Qb=Xb&&(!!Sa&&typeof Sa.set=="function"&&Kb([Sa.set])||function(e,n){if(e==null)throw new Jb("set Object.prototype.__proto__ called on null or undefined");return e.__proto__=n,n}),Xu=Hb,ew=Yb,Qu=Qb,tw=V,nw=Xu?function(e,n){if(Xu(e,n))return e;throw new tw("Reflect.setPrototypeOf: failed to set [[Prototype]]")}:ew||(Qu?function(e,n){return Qu(e,n),e}:null),eh=V,rw=Zt,th=Ep,sw=function(e){if(!rw(e))throw new eh("Assertion failed: O must be an Object");if(!th)throw new eh("This environment does not support fetching prototypes.");return th(e)},iw=V,ow=nw,aw=Zt,lw=sw,cw=function(e,n){if(n!==null&&!aw(n))throw new iw("Assertion failed: V must be Object or Null");try{ow(e,n)}catch{return!1}return lw(e)===n},ka=ac,nh=Vb,zp=cw,uw=Oo(),lc=yp;function hi(t,e,n){var r=new lc(n);return zp(r,Qi),delete r.constructor,nh(r,"error",t),nh(r,"suppressed",e),r}uw&&Object.defineProperty(hi,"prototype",{writable:!1});var Qi=hi.prototype;if(!ka(Qi,"constructor",hi)||!ka(Qi,"message","")||!ka(Qi,"name","SuppressedError"))throw new lc("unable to install SuppressedError.prototype properties; please report this!");zp(hi.prototype,lc.prototype);var hw=hi,dw=hw,Lp=function(){return typeof SuppressedError=="function"?SuppressedError:dw},pw=Yn,rh=Xl(),fw=Lp,gw=function(){var e=fw();return pw(rh,{SuppressedError:e},{SuppressedError:function(){return rh.SuppressedError!==e}}),e};gw();var mw=V,vw=Zr,yw=Tp,bw=function(e){if(typeof e<"u"&&!vw(e))throw new mw("Assertion failed: `Desc` must be a Property Descriptor");return yw(e)},ww=V,sh=jt,_w=Zr,Sw=function(e){if(typeof e>"u")return!1;if(!_w(e))throw new ww("Assertion failed: `Desc` must be a Property Descriptor");return!(!sh(e,"[[Value]]")&&!sh(e,"[[Writable]]"))},ih=tc,kw=function(e,n){return e===n?e===0?1/e===1/n:!0:ih(e)&&ih(n)},Wr=Dp,Ew=function(e){return!!e},pt=jt,Pi=V,$w=Zt,oh=Wr,Ea=Ew,Aw=function(e){if(!$w(e))throw new Pi("ToPropertyDescriptor requires an object");var n={};if(pt(e,"enumerable")&&(n["[[Enumerable]]"]=Ea(e.enumerable)),pt(e,"configurable")&&(n["[[Configurable]]"]=Ea(e.configurable)),pt(e,"value")&&(n["[[Value]]"]=e.value),pt(e,"writable")&&(n["[[Writable]]"]=Ea(e.writable)),pt(e,"get")){var r=e.get;if(typeof r<"u"&&!oh(r))throw new Pi("getter must be a function");n["[[Get]]"]=r}if(pt(e,"set")){var s=e.set;if(typeof s<"u"&&!oh(s))throw new Pi("setter must be a function");n["[[Set]]"]=s}if((pt(n,"[[Get]]")||pt(n,"[[Set]]"))&&(pt(n,"[[Value]]")||pt(n,"[[Writable]]")))throw new Pi("Invalid property descriptor. Cannot both specify accessors and a value or writable attribute");return n},$a=V,xw=Zt,ah=Zr,Tw=oc,Cw=bw,Iw=Sw,Pw=jr,Rw=kw,Dw=Aw,di=function(e,n,r){if(!xw(e))throw new $a("Assertion failed: Type(O) is not Object");if(!Pw(n))throw new $a("Assertion failed: P is not a Property Key");var s=ah(r)?r:Dw(r);if(!ah(s))throw new $a("Assertion failed: Desc is not a valid Property Descriptor");return Tw(Iw,Rw,Cw,e,n,s)},Ow=Fr(),zw=Ow?Symbol.dispose||Symbol("Symbol.dispose"):null,Lw=Fr,Mw=zw,cc=function(){return Lw()&&Symbol.dispose||Mw},Nw=nc,Uw=di,Fw=cc,Zw=function(){var e=Fw();return Nw()&&Uw(Symbol,"dispose",{"[[Configurable]]":!1,"[[Enumerable]]":!1,"[[Writable]]":!1,"[[Value]]":e}),e},jw=Fr(),Ww=jw?Symbol.asyncDispose||Symbol("Symbol.asyncDispose"):null,Bw=Fr,Gw=Ww,uc=function(){return Bw()&&Symbol.asyncDispose||Gw},Vw=nc,Hw=di,qw=uc,Yw=function(){var e=qw();return Vw()&&Hw(Symbol,"asyncDispose",{"[[Configurable]]":!1,"[[Enumerable]]":!1,"[[Writable]]":!1,"[[Value]]":e}),e},Kw=ic(),Jw=Qe,Xw=hn(),Qw=V,e_=Kw,t_=Jw("%Reflect.apply%",!0)||Xw("Function.prototype.apply"),Lo=function(e,n){var r=arguments.length>2?arguments[2]:[];if(!e_(r))throw new Qw("Assertion failed: optional `argumentsList`, if provided, must be a List");return t_(e,n,r)};const n_={},r_=Object.freeze(Object.defineProperty({__proto__:null,default:n_},Symbol.toStringTag,{value:"Module"})),s_=Tv(r_);var hc=typeof Map=="function"&&Map.prototype,Aa=Object.getOwnPropertyDescriptor&&hc?Object.getOwnPropertyDescriptor(Map.prototype,"size"):null,co=hc&&Aa&&typeof Aa.get=="function"?Aa.get:null,lh=hc&&Map.prototype.forEach,dc=typeof Set=="function"&&Set.prototype,xa=Object.getOwnPropertyDescriptor&&dc?Object.getOwnPropertyDescriptor(Set.prototype,"size"):null,uo=dc&&xa&&typeof xa.get=="function"?xa.get:null,ch=dc&&Set.prototype.forEach,i_=typeof WeakMap=="function"&&WeakMap.prototype,Ss=i_?WeakMap.prototype.has:null,o_=typeof WeakSet=="function"&&WeakSet.prototype,ks=o_?WeakSet.prototype.has:null,a_=typeof WeakRef=="function"&&WeakRef.prototype,uh=a_?WeakRef.prototype.deref:null,l_=Boolean.prototype.valueOf,c_=Object.prototype.toString,u_=Function.prototype.toString,h_=String.prototype.match,pc=String.prototype.slice,en=String.prototype.replace,d_=String.prototype.toUpperCase,hh=String.prototype.toLowerCase,Mp=RegExp.prototype.test,dh=Array.prototype.concat,_t=Array.prototype.join,p_=Array.prototype.slice,ph=Math.floor,il=typeof BigInt=="function"?BigInt.prototype.valueOf:null,Ta=Object.getOwnPropertySymbols,ol=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?Symbol.prototype.toString:null,Or=typeof Symbol=="function"&&typeof Symbol.iterator=="object",Es=typeof Symbol=="function"&&Symbol.toStringTag&&(typeof Symbol.toStringTag===Or||!0)?Symbol.toStringTag:null,Np=Object.prototype.propertyIsEnumerable,fh=(typeof Reflect=="function"?Reflect.getPrototypeOf:Object.getPrototypeOf)||([].__proto__===Array.prototype?function(t){return t.__proto__}:null);function gh(t,e){if(t===1/0||t===-1/0||t!==t||t&&t>-1e3&&t<1e3||Mp.call(/e/,e))return e;var n=/[0-9](?=(?:[0-9]{3})+(?![0-9]))/g;if(typeof t=="number"){var r=t<0?-ph(-t):ph(t);if(r!==t){var s=String(r),i=pc.call(e,s.length+1);return en.call(s,n,"$&_")+"."+en.call(en.call(i,/([0-9]{3})/g,"$&_"),/_$/,"")}}return en.call(e,n,"$&_")}var al=s_,mh=al.custom,vh=Zp(mh)?mh:null,Up={__proto__:null,double:'"',single:"'"},f_={__proto__:null,double:/(["\\])/g,single:/(['\\])/g},Br=function t(e,n,r,s){var i=n||{};if(It(i,"quoteStyle")&&!It(Up,i.quoteStyle))throw new TypeError('option "quoteStyle" must be "single" or "double"');if(It(i,"maxStringLength")&&(typeof i.maxStringLength=="number"?i.maxStringLength<0&&i.maxStringLength!==1/0:i.maxStringLength!==null))throw new TypeError('option "maxStringLength", if provided, must be a positive integer, Infinity, or `null`');var o=It(i,"customInspect")?i.customInspect:!0;if(typeof o!="boolean"&&o!=="symbol")throw new TypeError("option \"customInspect\", if provided, must be `true`, `false`, or `'symbol'`");if(It(i,"indent")&&i.indent!==null&&i.indent!==" "&&!(parseInt(i.indent,10)===i.indent&&i.indent>0))throw new TypeError('option "indent" must be "\\t", an integer > 0, or `null`');if(It(i,"numericSeparator")&&typeof i.numericSeparator!="boolean")throw new TypeError('option "numericSeparator", if provided, must be `true` or `false`');var a=i.numericSeparator;if(typeof e>"u")return"undefined";if(e===null)return"null";if(typeof e=="boolean")return e?"true":"false";if(typeof e=="string")return Wp(e,i);if(typeof e=="number"){if(e===0)return 1/0/e>0?"0":"-0";var l=String(e);return a?gh(e,l):l}if(typeof e=="bigint"){var c=String(e)+"n";return a?gh(e,c):c}var d=typeof i.depth>"u"?5:i.depth;if(typeof r>"u"&&(r=0),r>=d&&d>0&&typeof e=="object")return ll(e)?"[Array]":"[Object]";var p=R_(i,r);if(typeof s>"u")s=[];else if(jp(s,e)>=0)return"[Circular]";function y(ct,Wt,ea){if(Wt&&(s=p_.call(s),s.push(Wt)),ea){var _i={depth:i.depth};return It(i,"quoteStyle")&&(_i.quoteStyle=i.quoteStyle),t(ct,_i,r+1,s)}return t(ct,i,r+1,s)}if(typeof e=="function"&&!yh(e)){var m=k_(e),E=Ri(e,y);return"[Function"+(m?": "+m:" (anonymous)")+"]"+(E.length>0?" { "+_t.call(E,", ")+" }":"")}if(Zp(e)){var k=Or?en.call(String(e),/^(Symbol\(.*\))_[^)]*$/,"$1"):ol.call(e);return typeof e=="object"&&!Or?ns(k):k}if(C_(e)){for(var I="<"+hh.call(String(e.nodeName)),G=e.attributes||[],N=0;N<G.length;N++)I+=" "+G[N].name+"="+Fp(g_(G[N].value),"double",i);return I+=">",e.childNodes&&e.childNodes.length&&(I+="..."),I+="</"+hh.call(String(e.nodeName))+">",I}if(ll(e)){if(e.length===0)return"[]";var j=Ri(e,y);return p&&!P_(j)?"["+cl(j,p)+"]":"[ "+_t.call(j,", ")+" ]"}if(v_(e)){var F=Ri(e,y);return!("cause"in Error.prototype)&&"cause"in e&&!Np.call(e,"cause")?"{ ["+String(e)+"] "+_t.call(dh.call("[cause]: "+y(e.cause),F),", ")+" }":F.length===0?"["+String(e)+"]":"{ ["+String(e)+"] "+_t.call(F,", ")+" }"}if(typeof e=="object"&&o){if(vh&&typeof e[vh]=="function"&&al)return al(e,{depth:d-r});if(o!=="symbol"&&typeof e.inspect=="function")return e.inspect()}if(E_(e)){var L=[];return lh&&lh.call(e,function(ct,Wt){L.push(y(Wt,e,!0)+" => "+y(ct,e))}),bh("Map",co.call(e),L,p)}if(x_(e)){var J=[];return ch&&ch.call(e,function(ct){J.push(y(ct,e))}),bh("Set",uo.call(e),J,p)}if($_(e))return Ca("WeakMap");if(T_(e))return Ca("WeakSet");if(A_(e))return Ca("WeakRef");if(b_(e))return ns(y(Number(e)));if(__(e))return ns(y(il.call(e)));if(w_(e))return ns(l_.call(e));if(y_(e))return ns(y(String(e)));if(typeof window<"u"&&e===window)return"{ [object Window] }";if(typeof globalThis<"u"&&e===globalThis||typeof Sn<"u"&&e===Sn)return"{ [object globalThis] }";if(!m_(e)&&!yh(e)){var H=Ri(e,y),he=fh?fh(e)===Object.prototype:e instanceof Object||e.constructor===Object,lt=e instanceof Object?"":"null prototype",wi=!he&&Es&&Object(e)===e&&Es in e?pc.call(dn(e),8,-1):lt?"Object":"",Ee=he||typeof e.constructor!="function"?"":e.constructor.name?e.constructor.name+" ":"",gn=Ee+(wi||lt?"["+_t.call(dh.call([],wi||[],lt||[]),": ")+"] ":"");return H.length===0?gn+"{}":p?gn+"{"+cl(H,p)+"}":gn+"{ "+_t.call(H,", ")+" }"}return String(e)};function Fp(t,e,n){var r=n.quoteStyle||e,s=Up[r];return s+t+s}function g_(t){return en.call(String(t),/"/g,""")}function Kn(t){return!Es||!(typeof t=="object"&&(Es in t||typeof t[Es]<"u"))}function ll(t){return dn(t)==="[object Array]"&&Kn(t)}function m_(t){return dn(t)==="[object Date]"&&Kn(t)}function yh(t){return dn(t)==="[object RegExp]"&&Kn(t)}function v_(t){return dn(t)==="[object Error]"&&Kn(t)}function y_(t){return dn(t)==="[object String]"&&Kn(t)}function b_(t){return dn(t)==="[object Number]"&&Kn(t)}function w_(t){return dn(t)==="[object Boolean]"&&Kn(t)}function Zp(t){if(Or)return t&&typeof t=="object"&&t instanceof Symbol;if(typeof t=="symbol")return!0;if(!t||typeof t!="object"||!ol)return!1;try{return ol.call(t),!0}catch{}return!1}function __(t){if(!t||typeof t!="object"||!il)return!1;try{return il.call(t),!0}catch{}return!1}var S_=Object.prototype.hasOwnProperty||function(t){return t in this};function It(t,e){return S_.call(t,e)}function dn(t){return c_.call(t)}function k_(t){if(t.name)return t.name;var e=h_.call(u_.call(t),/^function\s*([\w$]+)/);return e?e[1]:null}function jp(t,e){if(t.indexOf)return t.indexOf(e);for(var n=0,r=t.length;n<r;n++)if(t[n]===e)return n;return-1}function E_(t){if(!co||!t||typeof t!="object")return!1;try{co.call(t);try{uo.call(t)}catch{return!0}return t instanceof Map}catch{}return!1}function $_(t){if(!Ss||!t||typeof t!="object")return!1;try{Ss.call(t,Ss);try{ks.call(t,ks)}catch{return!0}return t instanceof WeakMap}catch{}return!1}function A_(t){if(!uh||!t||typeof t!="object")return!1;try{return uh.call(t),!0}catch{}return!1}function x_(t){if(!uo||!t||typeof t!="object")return!1;try{uo.call(t);try{co.call(t)}catch{return!0}return t instanceof Set}catch{}return!1}function T_(t){if(!ks||!t||typeof t!="object")return!1;try{ks.call(t,ks);try{Ss.call(t,Ss)}catch{return!0}return t instanceof WeakSet}catch{}return!1}function C_(t){return!t||typeof t!="object"?!1:typeof HTMLElement<"u"&&t instanceof HTMLElement?!0:typeof t.nodeName=="string"&&typeof t.getAttribute=="function"}function Wp(t,e){if(t.length>e.maxStringLength){var n=t.length-e.maxStringLength,r="... "+n+" more character"+(n>1?"s":"");return Wp(pc.call(t,0,e.maxStringLength),e)+r}var s=f_[e.quoteStyle||"single"];s.lastIndex=0;var i=en.call(en.call(t,s,"\\$1"),/[\x00-\x1f]/g,I_);return Fp(i,"single",e)}function I_(t){var e=t.charCodeAt(0),n={8:"b",9:"t",10:"n",12:"f",13:"r"}[e];return n?"\\"+n:"\\x"+(e<16?"0":"")+d_.call(e.toString(16))}function ns(t){return"Object("+t+")"}function Ca(t){return t+" { ? }"}function bh(t,e,n,r){var s=r?cl(n,r):_t.call(n,", ");return t+" ("+e+") {"+s+"}"}function P_(t){for(var e=0;e<t.length;e++)if(jp(t[e],`
|
|
2
|
+
`)>=0)return!1;return!0}function R_(t,e){var n;if(t.indent===" ")n=" ";else if(typeof t.indent=="number"&&t.indent>0)n=_t.call(Array(t.indent+1)," ");else return null;return{base:n,prev:_t.call(Array(e+1),n)}}function cl(t,e){if(t.length===0)return"";var n=`
|
|
3
3
|
`+e.prev+e.base;return n+_t.call(t,","+n)+`
|
|
4
|
-
`+e.prev}function Ri(t,e){var n=ul(t),r=[];if(n){r.length=t.length;for(var s=0;s<t.length;s++)r[s]=It(t,s)?e(t[s],t):""}var i=typeof Ia=="function"?Ia(t):[],o;if(Or){o={};for(var a=0;a<i.length;a++)o["$"+i[a]]=i[a]}for(var l in t)It(t,l)&&(n&&String(Number(l))===l&&l<t.length||Or&&o["$"+l]instanceof Symbol||(Mp.call(/[^\w$]/,l)?r.push(e(l,t)+": "+e(t[l],t)):r.push(l+": "+e(t[l],t))));if(typeof Ia=="function")for(var c=0;c<i.length;c++)Np.call(t,i[c])&&r.push("["+e(i[c])+"]: "+e(t[i[c]],t));return r}var R_=Br,D_=V,Mo=function(t,e,n){for(var r=t,s;(s=r.next)!=null;r=s)if(s.key===e)return r.next=s.next,n||(s.next=t.next,t.next=s),s},O_=function(t,e){if(t){var n=Mo(t,e);return n&&n.value}},z_=function(t,e,n){var r=Mo(t,e);r?r.value=n:t.next={key:e,next:t.next,value:n}},L_=function(t,e){return t?!!Mo(t,e):!1},M_=function(t,e){if(t)return Mo(t,e,!0)},N_=function(){var e,n={assert:function(r){if(!n.has(r))throw new D_("Side channel does not contain "+R_(r))},delete:function(r){var s=e&&e.next,i=M_(e,r);return i&&s&&s===i&&(e=void 0),!!i},get:function(r){return O_(e,r)},has:function(r){return L_(e,r)},set:function(r,s){e||(e={next:void 0}),z_(e,r,s)}};return n},U_=Qe,pi=hn,F_=Br,Z_=V,wh=U_("%Map%",!0),j_=pi("Map.prototype.get",!0),W_=pi("Map.prototype.set",!0),B_=pi("Map.prototype.has",!0),G_=pi("Map.prototype.delete",!0),V_=pi("Map.prototype.size",!0),Bp=!!wh&&function(){var e,n={assert:function(r){if(!n.has(r))throw new Z_("Side channel does not contain "+F_(r))},delete:function(r){if(e){var s=G_(e,r);return V_(e)===0&&(e=void 0),s}return!1},get:function(r){if(e)return j_(e,r)},has:function(r){return e?B_(e,r):!1},set:function(r,s){e||(e=new wh),W_(e,r,s)}};return n},H_=Qe,No=hn,q_=Br,Di=Bp,Y_=V,ar=H_("%WeakMap%",!0),K_=No("WeakMap.prototype.get",!0),J_=No("WeakMap.prototype.set",!0),X_=No("WeakMap.prototype.has",!0),Q_=No("WeakMap.prototype.delete",!0),eS=ar?function(){var e,n,r={assert:function(s){if(!r.has(s))throw new Y_("Side channel does not contain "+q_(s))},delete:function(s){if(ar&&s&&(typeof s=="object"||typeof s=="function")){if(e)return Q_(e,s)}else if(Di&&n)return n.delete(s);return!1},get:function(s){return ar&&s&&(typeof s=="object"||typeof s=="function")&&e?K_(e,s):n&&n.get(s)},has:function(s){return ar&&s&&(typeof s=="object"||typeof s=="function")&&e?X_(e,s):!!n&&n.has(s)},set:function(s,i){ar&&s&&(typeof s=="object"||typeof s=="function")?(e||(e=new ar),J_(e,s,i)):Di&&(n||(n=Di()),n.set(s,i))}};return r}:Di,tS=V,nS=Br,rS=N_,sS=Bp,iS=eS,oS=iS||sS||rS,aS=function(){var e,n={assert:function(r){if(!n.has(r))throw new tS("Side channel does not contain "+nS(r))},delete:function(r){return!!e&&e.delete(r)},get:function(r){return e&&e.get(r)},has:function(r){return!!e&&e.has(r)},set:function(r,s){e||(e=oS()),e.set(r,s)}};return n},lS=jt,rs=aS(),xt=V,mc={assert:function(t,e){if(!t||typeof t!="object"&&typeof t!="function")throw new xt("`O` is not an object");if(typeof e!="string")throw new xt("`slot` must be a string");if(rs.assert(t),!mc.has(t,e))throw new xt("`"+e+"` is not present on `O`")},get:function(t,e){if(!t||typeof t!="object"&&typeof t!="function")throw new xt("`O` is not an object");if(typeof e!="string")throw new xt("`slot` must be a string");var n=rs.get(t);return n&&n["$"+e]},has:function(t,e){if(!t||typeof t!="object"&&typeof t!="function")throw new xt("`O` is not an object");if(typeof e!="string")throw new xt("`slot` must be a string");var n=rs.get(t);return!!n&&lS(n,"$"+e)},set:function(t,e,n){if(!t||typeof t!="object"&&typeof t!="function")throw new xt("`O` is not an object");if(typeof e!="string")throw new xt("`slot` must be a string");var r=rs.get(t);r||(r={},rs.set(t,r)),r["$"+e]=n}};Object.freeze&&Object.freeze(mc);var vc=mc,Gp=Ft,rn=vc,fi=function t(e,n){if(!(this instanceof t))return new t(e,n);if(e!=="normal"&&e!=="break"&&e!=="continue"&&e!=="return"&&e!=="throw")throw new Gp('Assertion failed: `type` must be one of "normal", "break", "continue", "return", or "throw"');rn.set(this,"[[Type]]",e),rn.set(this,"[[Value]]",n)};fi.prototype.type=function(){return rn.get(this,"[[Type]]")};fi.prototype.value=function(){return rn.get(this,"[[Value]]")};fi.prototype["?"]=function(){var e=rn.get(this,"[[Type]]"),n=rn.get(this,"[[Value]]");if(e==="throw")throw n;return n};fi.prototype["!"]=function(){var e=rn.get(this,"[[Type]]");if(e!=="normal")throw new Gp('Assertion failed: Completion Record is not of type "normal"');return rn.get(this,"[[Value]]")};var yc=fi,cS=yc,bc=function(e){return new cS("normal",e)},Ra,_h;function uS(){if(_h)return Ra;_h=1;var t=Fr;return Ra=function(){return t()&&!!Symbol.toStringTag},Ra}var hS=Qe,Sh=hS("%Object.defineProperty%",!0),dS=uS()(),pS=jt,fS=V,Oi=dS?Symbol.toStringTag:null,Vp=function(e,n){var r=arguments.length>2&&!!arguments[2]&&arguments[2].force,s=arguments.length>2&&!!arguments[2]&&arguments[2].nonConfigurable;if(typeof r<"u"&&typeof r!="boolean"||typeof s<"u"&&typeof s!="boolean")throw new fS("if provided, the `overrideIfSet` and `nonConfigurable` options must be booleans");Oi&&(r||!pS(e,Oi))&&(Sh?Sh(e,Oi,{configurable:!s,enumerable:!1,value:n,writable:!1}):e[Oi]=n)},Hp={exports:{}},gS=Qe,kh=up,mS=Oo(),Eh=Ur,$h=V,vS=gS("%Math.floor%"),yS=function(e,n){if(typeof e!="function")throw new $h("`fn` is not a function");if(typeof n!="number"||n<0||n>4294967295||vS(n)!==n)throw new $h("`length` must be a positive 32-bit integer");var r=arguments.length>2&&!!arguments[2],s=!0,i=!0;if("length"in e&&Eh){var o=Eh(e,"length");o&&!o.configurable&&(s=!1),o&&!o.writable&&(i=!1)}return(s||i||!r)&&(mS?kh(e,"length",n,!0,!0):kh(e,"length",n)),e},bS=li,wS=oc,_S=_p,SS=function(){return _S(bS,wS,arguments)};(function(t){var e=yS,n=ai,r=zo,s=SS;t.exports=function(o){var a=r(arguments),l=1+o.length-(arguments.length-1);return e(a,l>0?l:0,!0)},n?n(t.exports,"apply",{value:s}):t.exports.apply=s})(Hp);var wc=Hp.exports,kS=function(e,n){for(var r=0;r<e.length;r+=1)if(!n(e[r],r,e))return!1;return!0},ES=Object,$S=function(e){return e&&typeof e=="object"&&(typeof e["[[ResourceValue]]"]>"u"||ES(e["[[ResourceValue]]"])===e["[[ResourceValue]]"])&&(e["[[Hint]]"]==="SYNC-DISPOSE"||e["[[Hint]]"]==="ASYNC-DISPOSE")&&(typeof e["[[DisposeMethod]]"]=="function"||typeof e["[[DisposeMethod]]"]>"u")},AS=jt,xS=ac(),TS=kS,CS=$S,IS=function(e){return e&&typeof e=="object"&&AS(e,"[[DisposableResourceStack]]")&&xS(e["[[DisposableResourceStack]]"])&&(e["[[DisposableResourceStack]]"].length===0||TS(e["[[DisposableResourceStack]]"],CS))},PS=Zt,RS=function(e){if(e===null)return"Null";if(typeof e>"u")return"Undefined";if(PS(e))return"Object";if(typeof e=="number")return"Number";if(typeof e=="boolean")return"Boolean";if(typeof e=="string")return"String"},DS=RS,_c=function(e){return typeof e=="symbol"?"Symbol":typeof e=="bigint"?"BigInt":DS(e)},OS=V,zS=Br,LS=jr,MS=function(e,n){if(!LS(n))throw new OS("Assertion failed: P is not a Property Key, got "+zS(n));return e[n]},Ah=V,NS=MS,US=Wr,FS=jr,xh=Br,ZS=function(e,n){if(!FS(n))throw new Ah("Assertion failed: P is not a Property Key");var r=NS(e,n);if(r!=null){if(!US(r))throw new Ah(xh(n)+" is not a function: "+xh(r));return r}},dl={exports:{}},jS=Qe,WS=jS,Th=WS("%Reflect.construct%",!0),ho=di;try{ho({},"",{"[[Get]]":function(){}})}catch{ho=null}if(ho&&Th){var Ch={},Ih={};ho(Ih,"length",{"[[Get]]":function(){throw Ch},"[[Enumerable]]":!0}),dl.exports=function(e){try{Th(e,Ih)}catch(n){return n===Ch}}}else dl.exports=function(e){return typeof e=="function"&&!!e.prototype};var BS=dl.exports,Da=V,Ph=Wr,GS=BS,VS=function(e){if(!GS(e))throw new Da("C must be a constructor");var n={"[[Resolve]]":void 0,"[[Reject]]":void 0},r=new e(function(s,i){if(typeof n["[[Resolve]]"]<"u"||typeof n["[[Reject]]"]<"u")throw new Da("executor has already been called");n["[[Resolve]]"]=s,n["[[Reject]]"]=i});if(!Ph(n["[[Resolve]]"])||!Ph(n["[[Reject]]"]))throw new Da("executor must provide valid resolve and reject functions");return{"[[Promise]]":r,"[[Resolve]]":n["[[Resolve]]"],"[[Reject]]":n["[[Reject]]"]}},Rh=Ft,HS=V,Oa=Lo,Dh=ZS,qS=VS,YS=_c,Oh=hc(),zh=dc(),KS=function(e,n){if(YS(e)!=="Object")throw new HS("`V` must be an Object");if(n!=="SYNC-DISPOSE"&&n!=="ASYNC-DISPOSE")throw new Rh("Assertion failed: `hint` must be `~SYNC-DISPOSE~` or `~ASYNC-DISPOSE~`");var r;if(n==="ASYNC-DISPOSE"&&zh&&(r=Dh(e,zh)),!r){if(!Oh)throw new Rh("`Symbol.dispose` is not supported");if(r=Dh(e,Oh),typeof r<"u")return function(){var s=this;if(n==="ASYNC-DISPOSE"){var i=qS(Promise);try{Oa(r,s),Oa(i["[[Resolve]]"],void 0,[void 0])}catch(o){i["[[Reject]]"](o)}return i["[[Promise]]"]}Oa(r,s)}}return r},JS=Ft,za=V,XS=Wr,QS=_c,ek=KS,tk=function(e,n){if(n!=="SYNC-DISPOSE"&&n!=="ASYNC-DISPOSE")throw new JS("Assertion failed: `hint` must be `~SYNC-DISPOSE~` or `~ASYNC-DISPOSE~`");var r;if(arguments.length<3)if(e==null)e=void 0,r=void 0;else{if(typeof e<"u"&&QS(e)!=="Object")throw new za("`V` must be an Object, or `null` or `undefined`");if(r=ek(e,n),typeof r>"u")throw new za("dispose method must not be `undefined` on `V` when an object `V` is provided")}else if(r=arguments[2],!XS(r))throw new za("`method`, when provided, must be a function");return{"[[ResourceValue]]":e,"[[Hint]]":n,"[[DisposeMethod]]":r}},nk=Ft,zi=V,rk=IS,Lh=tk,sk=hn,ik=sk("Array.prototype.push"),qp=function(e,n,r){if(!rk(e))throw new zi("Assertion failed: `disposeCapability` must be a DisposeCapability Record");if(r!=="SYNC-DISPOSE"&&r!=="ASYNC-DISPOSE")throw new nk("Assertion failed: `hint` must be `~SYNC-DISPOSE~` or `~ASYNC-DISPOSE~`");var s=arguments.length>3?arguments[3]:void 0;if(arguments.length>3&&typeof s!="function")throw new zi("Assertion failed: `method`, when present, must be a function");if(!e["[[DisposableResourceStack]]"])throw new zi("Assertion failed: `disposeCapability.[[DisposableResourceStack]]` must not be ~EMPTY~");var i;if(arguments.length<4){if(n==null&&r==="SYNC_DISPOSE")return"UNUSED";i=Lh(n,r)}else{if(typeof n<"u")throw new zi("Assertion failed: `V` must be undefined when `method` is present");i=Lh(void 0,r,s)}return ik(e["[[DisposableResourceStack]]"],i),"UNUSED"},La,Mh;function Sc(){if(Mh)return La;Mh=1;var t=Qe,e=wc,n=Ft,r=t("%Promise.resolve%",!0),s=r&&e(r);return La=function(o,a){if(!s)throw new n("This environment does not support Promises.");return s(o,a)},La}var Ma,Nh;function ok(){if(Nh)return Ma;Nh=1;var t=Qe,e=Ft,n=t("%Promise%",!0),r=Lo,s=Sc(),i=_c;return Ma=function(a,l,c){if(typeof a<"u"&&i(a)!=="Object")throw new e("Assertion failed: `V` must be `undefined` or an Object");if(l!=="SYNC-DISPOSE"&&l!=="ASYNC-DISPOSE")throw new e("Assertion failed: `hint` must be `~SYNC-DISPOSE~` or `~ASYNC-DISPOSE~`");if(typeof c<"u"&&typeof c!="function")throw new e("Assertion failed: `method` must be `undefined` or a function");var d=typeof c>"u"?c:r(c,a);if(l==="ASYNC-DISPOSE")return s(n,d)},Ma}var Na,Uh;function ak(){if(Uh)return Na;Uh=1;var t=yc;return Na=function(n){return new t("throw",n)},Na}var lk=Qe,Ua=Ft,Fh=V,ck=lk("%Promise%",!0),uk=hn,Zh=uk("Promise.prototype.then",!0),hk=yc,jh=ok(),dk=bc,pk=Sc(),Wh=ak(),fk=Lp(),Yp=function(e,n){if(!(n instanceof hk))throw new Fh("`completion` must be a Completion Record");var r=e["[[DisposableResourceStack]]"];if(!r)throw new Fh("Assertion failed: `disposeCapability.[[DisposableResourceStack]]` must not be ~EMPTY~");for(var s,i=r.length-1;i>=0;i-=1)if(!s)s=r[i]["[[Hint]]"];else if(s!==r[i]["[[Hint]]"])throw new Ua("mixed hint stacks are not supported");for(var o=s==="ASYNC-DISPOSE"&&pk(ck,n),a=function(y){if(n.type()==="throw"){var m=n.value(),E=new fk(y,m);n=Wh(E)}else n=Wh(y)},l=s==="ASYNC-DISPOSE"&&function(m){return Zh(o,function(){var E=jh(m["[[ResourceValue]]"],m["[[Hint]]"],m["[[DisposeMethod]]"]);if(!E)throw new Ua("Assertion failed: non-`~ASYNC-DISPOSE~` resource returned a promise from Dispose");return Zh(E,dk)},a)},c=r.length-1;c>=0;c-=1)if(s==="ASYNC-DISPOSE")o=l(r[c]);else{var d=r[c];try{var p=jh(d["[[ResourceValue]]"],d["[[Hint]]"],d["[[DisposeMethod]]"]);if(p)throw new Ua("Assertion failed: `~SYNC-DISPOSE~` resource returned something from Dispose")}catch(y){a(y)}}return e["[[DisposableResourceStack]]"]=null,s==="ASYNC-DISPOSE"?o:n},Kp=function(){var e=[];return{"[[DisposableResourceStack]]":e}},Uo=nc,kc=V,gk=Lo,Gr=cc,mk=di,Jp=Wr,vk=bc,Ze=vc,yk=Vp,Xp=Yn.supportsDescriptors,bk=wc,Ec=qp,wk=Yp,Qp=Kp,Bh=hc(),Ke=function t(){if(!(this instanceof t)||Ze.has(this,"[[DisposableState]]")||Ze.has(this,"[[DisposeCapability]]"))throw new kc("can only be used with new");Ze.set(this,"[[DisposableState]]","PENDING"),Ze.set(this,"[[DisposeCapability]]",Qp())},ef=function(){var e=this;return Ze.assert(e,"[[DisposableState]]"),Ze.get(e,"[[DisposableState]]")==="DISPOSED"},gi=bk(ef);Xp?mk(Ke.prototype,"disposed",{"[[Configurable]]":!0,"[[Enumerable]]":!1,"[[Get]]":ef}):Ke.prototype.disposed=!1;var tf=function(e){Ze.set(e,"[[DisposableState]]","DISPOSED"),Xp||(e.disposed=!0)};Gr(Ke.prototype,"dispose",function(){var e=this;if(!gi(e))return tf(e),wk(Ze.get(e,"[[DisposeCapability]]"),vk())["?"]()});Gr(Ke.prototype,"use",function(e){var n=this;if(gi(n))throw new Uo("a disposed stack can not use anything new");return Ec(Ze.get(n,"[[DisposeCapability]]"),e,"SYNC-DISPOSE"),e});Gr(Ke.prototype,"adopt",function(e,n){var r=this;if(gi(r))throw new Uo("a disposed stack can not use anything new");if(!Jp(n))throw new kc("`onDispose` must be a function");var s=function(){return gk(n,void 0,[e])};return Ec(Ze.get(r,"[[DisposeCapability]]"),void 0,"SYNC-DISPOSE",s),e});Gr(Ke.prototype,"defer",function(e){var n=this;if(gi(n))throw new Uo("a disposed stack can not defer anything new");if(!Jp(e))throw new kc("`onDispose` must be a function");Ec(Ze.get(n,"[[DisposeCapability]]"),void 0,"SYNC-DISPOSE",e)});Gr(Ke.prototype,"move",function(){var e=this;if(gi(e))throw new Uo("a disposed stack can not use anything new");var n=new Ke;return Ze.set(n,"[[DisposeCapability]]",Ze.get(e,"[[DisposeCapability]]")),Ze.set(e,"[[DisposeCapability]]",Qp()),tf(e),n});Bh&&Gr(Ke.prototype,Bh,Ke.prototype.dispose);yk(Ke.prototype,"DisposableStack");var _k=Ke,Sk=_k,kk=function(){return typeof DisposableStack=="function"?DisposableStack:Sk},Ek=Yn,$k=ec(),Ak=kk,xk=function(){var e=Ak();return Ek($k,{DisposableStack:e},{DisposableStack:!0}),e},Tk=Qe,Fo=nc,$c=V,Gh=Tk("%Promise%",!0),Ac=qp,Ck=Lo,Vr=cc,Ik=di,Pk=Yp,nf=Wr,rf=Kp,Rk=bc,Vh=Sc(),je=vc,Dk=Vp,sf=Yn.supportsDescriptors,Ok=wc,zk=hn,Lk=zk("Promise.prototype.then",!0),Hh=dc(),Je=function t(){if(!(this instanceof t)||je.has(this,"[[AsyncDisposableState]]")||je.has(this,"[[DisposeCapability]]"))throw new $c("can only be used with new");je.set(this,"[[AsyncDisposableState]]","pending"),je.set(this,"[[DisposeCapability]]",rf())},of=function(){var e=this;return je.assert(e,"[[AsyncDisposableState]]"),je.get(e,"[[AsyncDisposableState]]")==="disposed"},mi=Ok(of);sf?Ik(Je.prototype,"disposed",{"[[Configurable]]":!0,"[[Enumerable]]":!1,"[[Get]]":of}):Je.prototype.disposed=!1;var af=function(e){je.set(e,"[[AsyncDisposableState]]","disposed"),sf||(e.disposed=!0)};Vr(Je.prototype,"disposeAsync",function(){var e=this;return mi(e)?Vh(Gh):(af(e),Lk(Vh(Gh,Pk(je.get(e,"[[DisposeCapability]]"),Rk())),function(n){return n["?"]()}))});Vr(Je.prototype,"use",function(e){var n=this;if(mi(n))throw new Fo("a disposed stack can not use anything new");return Ac(je.get(n,"[[DisposeCapability]]"),e,"ASYNC-DISPOSE"),e});Vr(Je.prototype,"adopt",function(e,n){var r=this;if(mi(r))throw new Fo("a disposed stack can not use anything new");if(!nf(n))throw new $c("`onDisposeAsync` must be a function");var s=function(){return Ck(n,void 0,[e])};return s.value=e,Ac(je.get(r,"[[DisposeCapability]]"),void 0,"ASYNC-DISPOSE",s),e});Vr(Je.prototype,"defer",function(e){var n=this;if(mi(n))throw new Fo("a disposed stack can not defer anything new");if(!nf(e))throw new $c("`onDispose` must be a function");Ac(je.get(n,"[[DisposeCapability]]"),void 0,"ASYNC-DISPOSE",e)});Vr(Je.prototype,"move",function(){var e=this;if(mi(e))throw new Fo("a disposed stack can not use anything new");var n=new Je;return je.set(n,"[[DisposeCapability]]",je.get(e,"[[DisposeCapability]]")),je.set(e,"[[DisposeCapability]]",rf()),af(e),n});Hh&&Vr(Je.prototype,Hh,Je.prototype.disposeAsync);Dk(Je.prototype,"AsyncDisposableStack");var Mk=Je,Nk=Mk,Uk=function(){return typeof AsyncDisposableStack=="function"?AsyncDisposableStack:Nk},Fk=Yn,Zk=ec(),jk=Uk,Wk=function(){var e=jk();return Fk(Zk,{AsyncDisposableStack:e},{AsyncDisposableStack:!0}),e},Bk=Fw,Gk=qw,Vk=xk,Hk=Wk,qk=function(){Bk(),Gk(),Vk(),Hk()};qk();const qh=new WeakMap;function Yk(t){return(typeof t=="object"||typeof t=="function")&&t!==null&&"then"in t&&typeof t.then=="function"}function lr(t){return typeof t=="string"?t:typeof t=="symbol"?t.description??t.toString():t.name||"(anonymous class)"}function Yh(){return new Error("register(Key, factory) requires a factory function. Wrap existing instances as () => instance.")}function Kk(){return new Error("register(Key, factory) does not accept async factories. Await setup before registering.")}class Jk{constructor(){v(this,"entries",new Map);v(this,"constructionStack",[])}register(e,n){if(n===void 0){if(typeof e!="function")throw Yh();this.validateClassRegistration(e),this.storeFactory(e,()=>this.instantiateClass(e));return}if(typeof n!="function")throw Yh();if(n.constructor.name==="AsyncFunction")throw Kk();this.storeFactory(e,n)}has(e){var n;return((n=this.entries.get(e))==null?void 0:n.factory)!==void 0}resolve(e){return this.resolveAny(e)}storeFactory(e,n){const r=this.getOrCreateEntry(e);r.factory=n,r.instance=void 0,r.error=void 0}validateClassRegistration(e){const n=qh.get(e);if(n){if(e.length!==n.length)throw new Error(`${lr(e)} cannot be registered with register(Class). @injectable(...) declared ${n.length} dependencies but constructor arity is ${e.length}. Use register(Key, () => value) instead.`);return}if(e.length!==0)throw new Error(`${lr(e)} cannot be registered with register(Class). Undecorated classes must have zero required constructor parameters. Use register(Key, () => value) instead.`)}instantiateClass(e){const n=qh.get(e);if(!n)return new e;const r=n.map(s=>this.resolveAny(s));return new e(...r)}resolveAny(e){return this.getOrCreateEntry(e).proxy}getOrCreateEntry(e){let n=this.entries.get(e);return n||(n={key:e},n.proxy=this.createProxy(n),this.entries.set(e,n),n)}createProxy(e){return new Proxy({},{get:(n,r)=>{if(r==="then")return;const s=this.getInstance(e),i=Reflect.get(s,r,s);return typeof i=="function"?i.bind(s):i},set:(n,r,s)=>{const i=this.getInstance(e);return Reflect.set(i,r,s,i)},has:(n,r)=>{const s=this.getInstance(e);return r in s}})}getInstance(e){if(e.instance)return e.instance;if(e.error)throw e.error;if(!e.factory)throw new Error(`${lr(e.key)} was resolved but never registered`);const n=this.constructionStack.indexOf(e.key);if(n!==-1){const r=[...this.constructionStack.slice(n),e.key].map(s=>lr(s)).join(" -> ");throw new Error(`Circular dependency detected: ${r}`)}this.constructionStack.push(e.key);try{const r=e.factory();if(Yk(r))throw new Error(`Factory for ${lr(e.key)} returned a Promise. Await setup before registering.`);if(typeof r!="object"||r===null)throw new Error(`Factory for ${lr(e.key)} returned a non-object value. Wrap primitives in an object.`);return e.instance=r,r}catch(r){throw e.error=r,r}finally{this.constructionStack.pop()}}}const Ve=new Jk,Xk=new Set(["target","currentTarget","eventPhase","defaultPrevented","isTrusted","timeStamp","srcElement","returnValue","cancelBubble","NONE","CAPTURING_PHASE","AT_TARGET","BUBBLING_PHASE","composedPath","stopPropagation","stopImmediatePropagation","preventDefault","initEvent"]);function Qk(t){for(const e of Object.keys(t))if(Xk.has(e))throw new Error(`Event payload key "${e}" is reserved; choose a different property name`)}function eE(t,e){Qk(e);for(const n of Object.keys(e))Object.defineProperty(t,n,{value:e[n],writable:!0,enumerable:!0,configurable:!0})}function et(){class t extends Event{constructor(n,r){const{type:s,bubbles:i,cancelable:o,composed:a,...l}=r??{};if(s!==void 0)throw new Error('Do not pass "type" in init; use the constructor argument instead');super(n,{bubbles:i,cancelable:o,composed:a}),eE(this,l)}}return t}class kt extends globalThis.EventTarget{}function tE(t,e,n){const r=t.dispose.bind(t);t.dispose=()=>{if(!e())return n(),r()}}function Hr(t){var n;class e extends t{constructor(...i){super(...i);$(this,n,!1);tE(this,()=>u(this,n),()=>{x(this,n,!0)})}[Symbol.dispose](){this.dispose()}get disposed(){return u(this,n)}}return n=new WeakMap,e}const nE=et(),eo=et(),lf="0123456789ABCDEFGHJKMNPQRSTVWXYZ",po=32,rE=16,cf=10,Kh=0xffffffffffff;var xn;(function(t){t.Base32IncorrectEncoding="B32_ENC_INVALID",t.DecodeTimeInvalidCharacter="DEC_TIME_CHAR",t.DecodeTimeValueMalformed="DEC_TIME_MALFORMED",t.EncodeTimeNegative="ENC_TIME_NEG",t.EncodeTimeSizeExceeded="ENC_TIME_SIZE_EXCEED",t.EncodeTimeValueMalformed="ENC_TIME_MALFORMED",t.PRNGDetectFailure="PRNG_DETECT",t.ULIDInvalid="ULID_INVALID",t.Unexpected="UNEXPECTED",t.UUIDInvalid="UUID_INVALID"})(xn||(xn={}));class fs extends Error{constructor(e,n){super(`${n} (${e})`),this.name="ULIDError",this.code=e}}function sE(t){const e=Math.floor(t()*po)%po;return lf.charAt(e)}function iE(t){const e=oE(),n=e&&(e.crypto||e.msCrypto)||null;if(typeof(n==null?void 0:n.getRandomValues)=="function")return()=>{const r=new Uint8Array(1);return n.getRandomValues(r),r[0]/256};if(typeof(n==null?void 0:n.randomBytes)=="function")return()=>n.randomBytes(1).readUInt8()/256;throw new fs(xn.PRNGDetectFailure,"Failed to find a reliable PRNG")}function oE(){return cE()?self:typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:null}function aE(t,e){let n="";for(;t>0;t--)n=sE(e)+n;return n}function lE(t,e=cf){if(isNaN(t))throw new fs(xn.EncodeTimeValueMalformed,`Time must be a number: ${t}`);if(t>Kh)throw new fs(xn.EncodeTimeSizeExceeded,`Cannot encode a time larger than ${Kh}: ${t}`);if(t<0)throw new fs(xn.EncodeTimeNegative,`Time must be positive: ${t}`);if(Number.isInteger(t)===!1)throw new fs(xn.EncodeTimeValueMalformed,`Time must be an integer: ${t}`);let n,r="";for(let s=e;s>0;s--)n=t%po,r=lf.charAt(n)+r,t=(t-n)/po;return r}function cE(){return typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope}function xc(t,e){const n=iE(),r=Date.now();return lE(r,cf)+aE(rE,n)}const St=4,He=6,uf=2,pl=2,uE=St,hE=He,Tc="auto",sn="auto",kn=120,Jh=75,de=16,tn=kn*St+de*(St-1),vr=kn*He+de*(He-1),dE=200,pE=4,Li=150,fE=10,Xh=2,gE=4;function hf(t){return ff(t)}function df(t,e){return ff(t.flatMap(n=>mf(n,e)))}function pf(t){const e=[],n=new Set;for(const r of t){if(r.type==="row"){e.push(`Top-level rows are invalid: ${r.id}`);continue}vf(r,"strip",e,n)}return{valid:e.length===0,errors:e}}function $s(t){const e=hf(t),n=pf(e);if(!n.valid)throw new Error(`Invalid layout: ${n.errors.join("; ")}`);return{totalNodes:e.length,nodes:e.filter(r=>r.type!=="row").map(bE)}}function ff(t){const e=[];for(const n of t){const r=gf(n);for(const s of r){if(s.type==="row"){e.push(...s.children.map(Ut));continue}e.push(s)}}return e}function gf(t){switch(t.type){case"card":return[Ut(t)];case"row":{const e=t.children.map(Ut);return e.length===0?[]:e.length===1?[e[0]]:[{...t,children:e}]}case"stack":{const e=[];for(const n of t.children){const r=gf(n);for(const s of r){if(s.type==="stack"){e.push(...s.children.map(fl));continue}if(s.type==="row"){e.push({...s,children:s.children.map(Ut)});continue}e.push(Ut(s))}}return e.length===0?[]:e.length===1?[fl(e[0])]:[{...t,children:e}]}}}function mf(t,e){switch(t.type){case"card":return t.artifactID===e?[]:[Ut(t)];case"row":{const n=t.children.filter(r=>r.artifactID!==e).map(Ut);return n.length===0?[]:n.length===1?[n[0]]:[{...t,children:n}]}case"stack":{const n=t.children.flatMap(r=>mf(r,e).filter(i=>i.type!=="stack"));return n.length===0?[]:n.length===1?[fl(n[0])]:[{...t,children:n}]}}}function vf(t,e,n,r){switch(t.type){case"card":yf(t,e,n,r);return;case"row":mE(t,e,n,r);return;case"stack":vE(t,e,n,r);return}}function yf(t,e,n,r){Cc(t.id,n),typeof t.artifactID!="string"||t.artifactID.length===0?n.push(`Card ${t.id} is missing artifactID`):r.has(t.artifactID)?n.push(`Duplicate artifactID in layout: ${t.artifactID}`):r.add(t.artifactID),yE(t.width)||n.push(`Card ${t.id} width must be an integer in the range 2-4`),bf(t.height)||n.push(`Card ${t.id} height must be an integer in the range 2-6 or "auto"`);const s=En(t.width);e==="row"&&s<uf&&n.push(`Row child ${t.id} must be at least 2 columns wide`)}function mE(t,e,n,r){if(Cc(t.id,n),e!=="stack"&&n.push(`Row ${t.id} may only appear inside a stack`),bf(t.height,gE)||n.push(`Row ${t.id} height must be an integer in the range 2-4 or "auto"`),!Array.isArray(t.children)||t.children.length===0){n.push(`Row ${t.id} must contain card nodes`);return}let s=0;for(const i of t.children){if(i.type!=="card"){n.push(`Row ${t.id} must contain only card nodes`);continue}yf(i,"row",n,r),s+=En(i.width)}s!==St&&n.push(`Row ${t.id} children must sum to 4 columns`)}function vE(t,e,n,r){if(Cc(t.id,n),e!=="strip"&&n.push(`Invalid nested stack at ${t.id}; stack children cannot contain another nested stack`),!Array.isArray(t.children)||t.children.length===0){n.push(`Stack ${t.id} must contain at least one child`);return}let s=0,i=0;for(const a of t.children){if(a.type==="stack"){n.push(`Stack ${t.id} cannot contain another nested stack`);continue}if(vf(a,"stack",n,r),a.height===sn){i+=1;continue}s+=a.height}if(s>He&&n.push(`Stack ${t.id} exceeds the 6-row budget`),i===0)return;const o=He-s;if(o<i*pl||o%i!==0){n.push(`Stack ${t.id} has auto-height children that cannot resolve to whole height >= 2`);return}o/i<pl&&n.push(`Stack ${t.id} has auto-height children below the minimum row size`)}function Cc(t,e){(typeof t!="string"||t.length===0)&&e.push(`Node id must be a non-empty string: ${String(t)}`)}function yE(t){return t===Tc||Number.isInteger(t)&&t>=uf&&t<=uE}function bf(t,e=hE){return t===sn||Number.isInteger(t)&&t>=pl&&t<=e}function En(t){return t===Tc?St:t}function bE(t){if(t.type==="card")return{id:t.id,type:"card",width:En(t.width),cards:[{id:t.id,artifactID:t.artifactID,col:1,row:1,width:En(t.width),height:wf(t.height,He)}]};const e=wE(t.children),n=[];let r=1;for(let s=0;s<t.children.length;s+=1){const i=t.children[s],o=e[s];if(i.type==="card")n.push({id:i.id,artifactID:i.artifactID,col:1,row:r,width:En(i.width),height:o});else{let a=1;for(const l of i.children)n.push({id:l.id,artifactID:l.artifactID,col:a,row:r,width:En(l.width),height:o}),a+=En(l.width)}r+=o}return{id:t.id,type:"stack",width:n.reduce((s,i)=>Math.max(s,i.col+i.width-1),1),cards:n}}function wE(t){let e=0,n=0;for(const s of t)s.height===sn?n+=1:e+=s.height;const r=n>0?(He-e)/n:0;return t.map(s=>wf(s.height,r))}function wf(t,e){return t===sn?e:t}function Ut(t){return{...t}}function fl(t){return t.type==="card"?Ut(t):{...t,children:t.children.map(Ut)}}function _f(t,e={}){return{id:e.id??xc(),type:"card",artifactID:t,width:e.width??Tc,height:e.height??sn}}function Sf(t,e){return t.some(n=>kf(n,e))}function kf(t,e){switch(t.type){case"card":return t.artifactID===e;case"row":return t.children.some(n=>n.artifactID===e);case"stack":return t.children.some(n=>kf(n,e))}}function Qh(t){return t.layout.flatMap(Ef)}function Ef(t){switch(t.type){case"card":return[t.artifactID];case"row":return t.children.map(e=>e.artifactID);case"stack":return t.children.flatMap(Ef)}}const te=et(),$f=et(),ss=et(),_E=et();function SE(t){class e extends Error{constructor(r,s){super(r),this.name=t,s&&Object.assign(this,s)}}return e}const kE=SE("RequestError"),EE=200,$E=300;class AE{constructor(e,n){v(this,"serverURL");v(this,"token");this.serverURL=e.replace(/\/$/,""),this.token=n.token}async requestJSON(e,n,r){const s=await this.request(e,n,r!==void 0?JSON.stringify(r):void 0,r!==void 0?{"content-type":"application/json"}:void 0),i=await xE(s);if(!s.ok||s.status<EE||s.status>=$E)throw this.createError(typeof i.error=="string"?i.error:s.statusText,s.status);return i}async requestVoid(e,n){const r=await this.request(e,n);if(!r.ok)throw this.createError(await Fa(r,r.statusText),r.status)}async requestText(e,n){const r=await this.request(e,n);if(!r.ok)throw this.createError(await Fa(r,r.statusText),r.status);return r.text()}async requestRawVoid(e,n,r){const s=await this.request(e,n,r,{"content-type":"text/plain"});if(!s.ok)throw this.createError(await Fa(s,s.statusText),s.status)}createError(e,n){const r={serverURL:this.serverURL};return n!==void 0&&(r.status=n),new kE(e,r)}async request(e,n,r,s){const i=`${this.serverURL}${n}`;try{return await fetch(i,{method:e,headers:this.buildHeaders(s),body:r})}catch(o){throw this.createError(o instanceof Error?o.message:"Failed to reach server")}}buildHeaders(e){const n={...e??{}};return this.token&&(n.Authorization=`Bearer ${this.token}`),Object.keys(n).length>0?n:void 0}}async function xE(t){try{return await t.json()}catch{const e=await t.text().catch(()=>"");return e?{message:e}:{}}}async function Fa(t,e){try{const n=await t.json();if(typeof n.error=="string")return n.error;if(typeof n.message=="string")return n.message}catch{}return e}function Af(t){return t.map(e=>`${e.name} (${e.id})`).join(", ")}var mt,Eo,xf;class TE{constructor(e){$(this,Eo);$(this,mt);x(this,mt,e)}list(){return u(this,mt).requestJSON("GET","/screens")}async get(e={}){const n=await b(this,Eo,xf).call(this,e.screenID);return u(this,mt).requestJSON("GET",`/screens/${encodeURIComponent(n)}`)}create(e){const n={name:e.name};return e.id!==void 0&&(n.id=e.id),u(this,mt).requestJSON("POST","/screens",n)}update(e){const n={};return e.name!==void 0&&(n.name=e.name),e.layout!==void 0&&(n.layout=e.layout),u(this,mt).requestJSON("PATCH",`/screens/${encodeURIComponent(e.screenID)}`,n)}remove(e){return u(this,mt).requestJSON("DELETE",`/screens/${encodeURIComponent(e.screenID)}`)}}mt=new WeakMap,Eo=new WeakSet,xf=async function(e){if(e!==void 0)return e;const{screens:n}=await this.list();if(n.length===1)return n[0].id;throw u(this,mt).createError(`screenID is required when multiple screens exist. Available screens: ${Af(n)}`)};var Ne,Ds,$o,Tf;class CE{constructor(e,n){$(this,$o);$(this,Ne);$(this,Ds);x(this,Ne,e),x(this,Ds,n)}async create(e){const n=await b(this,$o,Tf).call(this,e.screenID);return u(this,Ne).requestJSON("POST",`/screens/${encodeURIComponent(n)}/artifact`,{type:e.type,title:e.title,externalFilePath:e.externalFilePath})}get(e){return u(this,Ne).requestJSON("GET",`/artifacts/${encodeURIComponent(e.artifactID)}`)}update(e){const n={};return e.title!==void 0&&(n.title=e.title),u(this,Ne).requestJSON("PATCH",`/artifacts/${encodeURIComponent(e.artifactID)}`,n)}edit(e){return u(this,Ne).requestJSON("POST",`/artifacts/${encodeURIComponent(e.artifactID)}/edit`)}commitPending(e){return u(this,Ne).requestJSON("POST",`/artifacts/${encodeURIComponent(e.artifactID)}/commit`)}abandonPending(e){return u(this,Ne).requestVoid("POST",`/artifacts/${encodeURIComponent(e.artifactID)}/abandon`)}remove(e){return u(this,Ne).requestJSON("DELETE",`/screens/${encodeURIComponent(e.screenID)}/artifacts/${encodeURIComponent(e.artifactID)}`)}getContent(e){return u(this,Ne).requestText("GET",`/artifacts/${encodeURIComponent(e.artifactID)}/content`)}putContent(e){return u(this,Ne).requestRawVoid("PUT",`/artifacts/${encodeURIComponent(e.artifactID)}/content`,e.content)}}Ne=new WeakMap,Ds=new WeakMap,$o=new WeakSet,Tf=async function(e){if(e!==void 0)return e;const{screens:n}=await u(this,Ds).list();if(n.length===1)return n[0].id;throw u(this,Ne).createError(`screenID is required when multiple screens exist. Available screens: ${Af(n)}`)};var Os;class IE{constructor(e){$(this,Os);x(this,Os,e)}async list(){const{views:e}=await u(this,Os).requestJSON("GET","/views");return e}}Os=new WeakMap;var Vt;class PE{constructor(e,n={}){v(this,"screens");v(this,"artifacts");v(this,"views");$(this,Vt);x(this,Vt,new AE(e,n)),this.screens=new TE(u(this,Vt)),this.artifacts=new CE(u(this,Vt),this.screens),this.views=new IE(u(this,Vt))}health(){return u(this,Vt).requestJSON("GET","/health")}}Vt=new WeakMap;const RE=Hr(kt);var Cn,Ue,In,De,Ht,qt,Q,ur,Cf,zs,If,Pf,Rf,Df,gl,ml,vl,Of;class DE extends RE{constructor(n){var s;super();$(this,Q);v(this,"id");v(this,"server");$(this,Cn);$(this,Ue,new Map);$(this,In);$(this,De);$(this,Ht);$(this,qt,null);$(this,zs,n=>{if(this.disposed)return;const r=n.event;switch(r.type){case"screen-updated":r.screen.id===this.id&&b(this,Q,If).call(this,r.screen);break;case"artifact-created":r.screenID===this.id&&b(this,Q,Pf).call(this,r.artifact);break;case"artifact-updated":b(this,Q,Rf).call(this,r.artifact);break;case"artifact-removed":r.screenID===this.id&&b(this,Q,Df).call(this,r.artifactID);break;case"artifact-content-changed":u(this,Ue).has(r.artifactID)&&this.dispatchEvent(new _E("artifact-content-changed",{artifactID:r.artifactID}));break}});this.id=n.screen.id,this.server=n.server,x(this,Cn,n.localStore),x(this,In,n.screen.name),x(this,De,structuredClone(n.screen.layout));const r=((s=u(this,Cn).get().screens[this.id])==null?void 0:s.scrollPosition)??0;x(this,Ht,Math.max(0,r)),this.server.addEventListener("server-event",u(this,zs)),b(this,Q,Cf).call(this)}get name(){return u(this,In)}get layout(){return u(this,De)}get scrollPosition(){return u(this,Ht)}get artifacts(){return u(this,Ue)}setScrollPosition(n){b(this,Q,ur).call(this);const r=Math.max(0,n);r!==u(this,Ht)&&(x(this,Ht,r),b(this,Q,Of).call(this),this.dispatchEvent(new te("change")))}setLayout(n){b(this,Q,ur).call(this);const r=hf(n);if(!pf(r).valid)return;const i=b(this,Q,ml).call(this);x(this,De,r),x(this,qt,{layout:r,snapshot:i}),this.dispatchEvent(new te("change")),this.server.client.screens.update({screenID:this.id,layout:r.map(o=>structuredClone(o))}).catch(()=>{var o;this.disposed||((o=u(this,qt))==null?void 0:o.layout)===r&&(x(this,qt,null),b(this,Q,vl).call(this,i),this.dispatchEvent(new te("change")))})}rename(n){b(this,Q,ur).call(this),x(this,In,n),this.dispatchEvent(new te("change")),this.server.client.screens.update({screenID:this.id,name:n}).catch(()=>{})}async remove(){b(this,Q,ur).call(this),await this.server.client.screens.remove({screenID:this.id})}removeArtifact(n){if(b(this,Q,ur).call(this),!u(this,Ue).has(n))return;const r=b(this,Q,ml).call(this);b(this,Q,gl).call(this,n),this.dispatchEvent(new te("change")),this.server.client.artifacts.remove({artifactID:n,screenID:this.id}).catch(()=>{this.disposed||(b(this,Q,vl).call(this,r),this.dispatchEvent(new te("change")))})}dispose(){this.server.removeEventListener("server-event",u(this,zs))}}Cn=new WeakMap,Ue=new WeakMap,In=new WeakMap,De=new WeakMap,Ht=new WeakMap,qt=new WeakMap,Q=new WeakSet,ur=function(){if(this.disposed)throw new Error("ScreenModel is disposed")},Cf=async function(){try{const n=await this.server.client.screens.get({screenID:this.id});if(this.disposed)return;for(const r of n.artifacts)u(this,Ue).set(r.id,r);this.dispatchEvent(new te("change"))}catch{}},zs=new WeakMap,If=function(n){u(this,qt)&&x(this,qt,null),x(this,In,n.name),x(this,De,structuredClone(n.layout)),this.dispatchEvent(new te("change"))},Pf=function(n){Sf(u(this,De),n.id)||x(this,De,[...u(this,De),_f(n.id)]),u(this,Ue).set(n.id,n),this.dispatchEvent(new te("change"))},Rf=function(n){const r=u(this,Ue).get(n.id);r&&(u(this,Ue).set(n.id,{...r,...n}),this.dispatchEvent(new te("change")))},Df=function(n){b(this,Q,gl).call(this,n)&&this.dispatchEvent(new te("change"))},gl=function(n){const r=u(this,Ue).delete(n),s=Qh({layout:u(this,De)}).length,i=df(u(this,De),n),o=Qh({layout:i}).length;return x(this,De,i),r||s!==o},ml=function(){return{layout:structuredClone(u(this,De)),artifacts:new Map([...u(this,Ue).entries()].map(([n,r])=>[n,structuredClone(r)]))}},vl=function(n){x(this,De,structuredClone(n.layout)),u(this,Ue).clear();for(const[r,s]of n.artifacts)u(this,Ue).set(r,structuredClone(s))},Of=function(){const n=u(this,Cn).get();u(this,Cn).set({...n,screens:{...n.screens,[this.id]:{scrollPosition:u(this,Ht)}}})};const OE=Hr(kt);var Fe,vt,nt,Ls,Ms,Ns,nn,to,zf;class zE extends OE{constructor(n){super();$(this,nn);$(this,Fe);$(this,vt);$(this,nt,null);$(this,Ls,()=>{this.disposed||b(this,nn,to).call(this)});$(this,Ms,()=>{this.disposed||b(this,nn,to).call(this)});$(this,Ns,n=>{var s;if(this.disposed)return;const r=n.event;r.type==="screen-removed"&&((s=u(this,nt))==null?void 0:s.id)===r.screenID&&this.clearActive()});x(this,Fe,n.localStore),x(this,vt,n.serverManager),u(this,Fe).addEventListener("change",u(this,Ls)),u(this,vt).addEventListener("change",u(this,Ms)),u(this,vt).addEventListener("server-event",u(this,Ns)),b(this,nn,to).call(this)}get activeScreen(){return u(this,nt)}setActive(n,r){const s=u(this,Fe).get();s.activeServerURL===n&&s.activeScreenID===r||u(this,Fe).set({...s,activeServerURL:n,activeScreenID:r})}clearActive(){const n=u(this,Fe).get();n.activeServerURL===null&&n.activeScreenID===null||u(this,Fe).set({...n,activeServerURL:null,activeScreenID:null})}dispose(){var n;u(this,Fe).removeEventListener("change",u(this,Ls)),u(this,vt).removeEventListener("change",u(this,Ms)),u(this,vt).removeEventListener("server-event",u(this,Ns)),(n=u(this,nt))==null||n.dispose(),x(this,nt,null)}}Fe=new WeakMap,vt=new WeakMap,nt=new WeakMap,Ls=new WeakMap,Ms=new WeakMap,Ns=new WeakMap,nn=new WeakSet,to=function(){var l,c,d;const{activeServerURL:n,activeScreenID:r}=u(this,Fe).get();let s=n?u(this,vt).servers.get(n)??null:null,i=s&&r?s.screens.get(r)??null:null;if(!i){const p=b(this,nn,zf).call(this);if(p){s=p.server,i=p.screen,u(this,Fe).set({...u(this,Fe).get(),activeServerURL:p.server.url,activeScreenID:p.screen.id});return}}const o=((l=u(this,nt))==null?void 0:l.id)??null,a=(i==null?void 0:i.id)??null;o===a&&((c=u(this,nt))==null?void 0:c.server)===s||((d=u(this,nt))==null||d.dispose(),x(this,nt,s&&i?new DE({screen:i,server:s,localStore:u(this,Fe)}):null),this.dispatchEvent(new nE("active-screen-changed")))},zf=function(){for(const n of u(this,vt).servers.values()){const r=n.screens.values().next().value;if(r)return{server:n,screen:r}}return null};const LE="Local",ME="store-";function Pt(t){return new URL(t).origin}function NE(t){return{servers:[{url:Pt(t),name:LE}],activeServerURL:null,activeScreenID:null,screens:{}}}var Pn,Rn,Dn;class UE extends kt{constructor(n,r,s={}){super();$(this,Pn);$(this,Rn);$(this,Dn);x(this,Pn,`${ME}${n}`),x(this,Rn,s.storage??FE());const i=u(this,Rn).getItem(u(this,Pn));i===null?(x(this,Dn,r),u(this,Rn).setItem(u(this,Pn),JSON.stringify(r))):x(this,Dn,JSON.parse(i))}get(){return u(this,Dn)}set(n){x(this,Dn,n),u(this,Rn).setItem(u(this,Pn),JSON.stringify(n)),this.dispatchEvent(new te("change"))}}Pn=new WeakMap,Rn=new WeakMap,Dn=new WeakMap;function FE(){const t=globalThis.localStorage;if(!t)throw new Error("LocalStore: no storage adapter supplied and window.localStorage is unavailable");return t}function S(t,e,n){function r(a,l){if(a._zod||Object.defineProperty(a,"_zod",{value:{def:l,constr:o,traits:new Set},enumerable:!1}),a._zod.traits.has(t))return;a._zod.traits.add(t),e(a,l);const c=o.prototype,d=Object.keys(c);for(let p=0;p<d.length;p++){const y=d[p];y in a||(a[y]=c[y].bind(a))}}const s=(n==null?void 0:n.Parent)??Object;class i extends s{}Object.defineProperty(i,"name",{value:t});function o(a){var l;const c=n!=null&&n.Parent?new i:this;r(c,a),(l=c._zod).deferred??(l.deferred=[]);for(const d of c._zod.deferred)d();return c}return Object.defineProperty(o,"init",{value:r}),Object.defineProperty(o,Symbol.hasInstance,{value:a=>{var l,c;return n!=null&&n.Parent&&a instanceof n.Parent?!0:(c=(l=a==null?void 0:a._zod)==null?void 0:l.traits)==null?void 0:c.has(t)}}),Object.defineProperty(o,"name",{value:t}),o}class _r extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class Lf extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name="ZodEncodeError"}}const Mf={};function on(t){return Mf}function Nf(t){const e=Object.values(t).filter(r=>typeof r=="number");return Object.entries(t).filter(([r,s])=>e.indexOf(+r)===-1).map(([r,s])=>s)}function yl(t,e){return typeof e=="bigint"?e.toString():e}function Ic(t){return{get value(){{const e=t();return Object.defineProperty(this,"value",{value:e}),e}}}}function Pc(t){return t==null}function Rc(t){const e=t.startsWith("^")?1:0,n=t.endsWith("$")?t.length-1:t.length;return t.slice(e,n)}function ZE(t,e){const n=(t.toString().split(".")[1]||"").length,r=e.toString();let s=(r.split(".")[1]||"").length;if(s===0&&/\d?e-\d?/.test(r)){const l=r.match(/\d?e-(\d?)/);l!=null&&l[1]&&(s=Number.parseInt(l[1]))}const i=n>s?n:s,o=Number.parseInt(t.toFixed(i).replace(".","")),a=Number.parseInt(e.toFixed(i).replace(".",""));return o%a/10**i}const ed=Symbol("evaluating");function ee(t,e,n){let r;Object.defineProperty(t,e,{get(){if(r!==ed)return r===void 0&&(r=ed,r=n()),r},set(s){Object.defineProperty(t,e,{value:s})},configurable:!0})}function Jn(t,e,n){Object.defineProperty(t,e,{value:n,writable:!0,enumerable:!0,configurable:!0})}function pn(...t){const e={};for(const n of t){const r=Object.getOwnPropertyDescriptors(n);Object.assign(e,r)}return Object.defineProperties({},e)}function td(t){return JSON.stringify(t)}function jE(t){return t.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}const Uf="captureStackTrace"in Error?Error.captureStackTrace:(...t)=>{};function fo(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}const WE=Ic(()=>{var t;if(typeof navigator<"u"&&((t=navigator==null?void 0:navigator.userAgent)!=null&&t.includes("Cloudflare")))return!1;try{const e=Function;return new e(""),!0}catch{return!1}});function zr(t){if(fo(t)===!1)return!1;const e=t.constructor;if(e===void 0||typeof e!="function")return!0;const n=e.prototype;return!(fo(n)===!1||Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")===!1)}function Ff(t){return zr(t)?{...t}:Array.isArray(t)?[...t]:t}const BE=new Set(["string","number","symbol"]);function Lr(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function fn(t,e,n){const r=new t._zod.constr(e??t._zod.def);return(!e||n!=null&&n.parent)&&(r._zod.parent=t),r}function O(t){const e=t;if(!e)return{};if(typeof e=="string")return{error:()=>e};if((e==null?void 0:e.message)!==void 0){if((e==null?void 0:e.error)!==void 0)throw new Error("Cannot specify both `message` and `error` params");e.error=e.message}return delete e.message,typeof e.error=="string"?{...e,error:()=>e.error}:e}function GE(t){return Object.keys(t).filter(e=>t[e]._zod.optin==="optional"&&t[e]._zod.optout==="optional")}const VE={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 HE(t,e){const n=t._zod.def,r=n.checks;if(r&&r.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");const i=pn(t._zod.def,{get shape(){const o={};for(const a in e){if(!(a in n.shape))throw new Error(`Unrecognized key: "${a}"`);e[a]&&(o[a]=n.shape[a])}return Jn(this,"shape",o),o},checks:[]});return fn(t,i)}function qE(t,e){const n=t._zod.def,r=n.checks;if(r&&r.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");const i=pn(t._zod.def,{get shape(){const o={...t._zod.def.shape};for(const a in e){if(!(a in n.shape))throw new Error(`Unrecognized key: "${a}"`);e[a]&&delete o[a]}return Jn(this,"shape",o),o},checks:[]});return fn(t,i)}function YE(t,e){if(!zr(e))throw new Error("Invalid input to extend: expected a plain object");const n=t._zod.def.checks;if(n&&n.length>0){const i=t._zod.def.shape;for(const o in e)if(Object.getOwnPropertyDescriptor(i,o)!==void 0)throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}const s=pn(t._zod.def,{get shape(){const i={...t._zod.def.shape,...e};return Jn(this,"shape",i),i}});return fn(t,s)}function KE(t,e){if(!zr(e))throw new Error("Invalid input to safeExtend: expected a plain object");const n=pn(t._zod.def,{get shape(){const r={...t._zod.def.shape,...e};return Jn(this,"shape",r),r}});return fn(t,n)}function JE(t,e){const n=pn(t._zod.def,{get shape(){const r={...t._zod.def.shape,...e._zod.def.shape};return Jn(this,"shape",r),r},get catchall(){return e._zod.def.catchall},checks:[]});return fn(t,n)}function XE(t,e,n){const s=e._zod.def.checks;if(s&&s.length>0)throw new Error(".partial() cannot be used on object schemas containing refinements");const o=pn(e._zod.def,{get shape(){const a=e._zod.def.shape,l={...a};if(n)for(const c in n){if(!(c in a))throw new Error(`Unrecognized key: "${c}"`);n[c]&&(l[c]=t?new t({type:"optional",innerType:a[c]}):a[c])}else for(const c in a)l[c]=t?new t({type:"optional",innerType:a[c]}):a[c];return Jn(this,"shape",l),l},checks:[]});return fn(e,o)}function QE(t,e,n){const r=pn(e._zod.def,{get shape(){const s=e._zod.def.shape,i={...s};if(n)for(const o in n){if(!(o in i))throw new Error(`Unrecognized key: "${o}"`);n[o]&&(i[o]=new t({type:"nonoptional",innerType:s[o]}))}else for(const o in s)i[o]=new t({type:"nonoptional",innerType:s[o]});return Jn(this,"shape",i),i}});return fn(e,r)}function yr(t,e=0){var n;if(t.aborted===!0)return!0;for(let r=e;r<t.issues.length;r++)if(((n=t.issues[r])==null?void 0:n.continue)!==!0)return!0;return!1}function br(t,e){return e.map(n=>{var r;return(r=n).path??(r.path=[]),n.path.unshift(t),n})}function Mi(t){return typeof t=="string"?t:t==null?void 0:t.message}function an(t,e,n){var s,i,o,a,l,c;const r={...t,path:t.path??[]};if(!t.message){const d=Mi((o=(i=(s=t.inst)==null?void 0:s._zod.def)==null?void 0:i.error)==null?void 0:o.call(i,t))??Mi((a=e==null?void 0:e.error)==null?void 0:a.call(e,t))??Mi((l=n.customError)==null?void 0:l.call(n,t))??Mi((c=n.localeError)==null?void 0:c.call(n,t))??"Invalid input";r.message=d}return delete r.inst,delete r.continue,e!=null&&e.reportInput||delete r.input,r}function Dc(t){return Array.isArray(t)?"array":typeof t=="string"?"string":"unknown"}function Ts(...t){const[e,n,r]=t;return typeof e=="string"?{message:e,code:"custom",input:n,inst:r}:{...e}}const Zf=(t,e)=>{t.name="$ZodError",Object.defineProperty(t,"_zod",{value:t._zod,enumerable:!1}),Object.defineProperty(t,"issues",{value:e,enumerable:!1}),t.message=JSON.stringify(e,yl,2),Object.defineProperty(t,"toString",{value:()=>t.message,enumerable:!1})},jf=S("$ZodError",Zf),Wf=S("$ZodError",Zf,{Parent:Error});function e$(t,e=n=>n.message){const n={},r=[];for(const s of t.issues)s.path.length>0?(n[s.path[0]]=n[s.path[0]]||[],n[s.path[0]].push(e(s))):r.push(e(s));return{formErrors:r,fieldErrors:n}}function t$(t,e=n=>n.message){const n={_errors:[]},r=s=>{for(const i of s.issues)if(i.code==="invalid_union"&&i.errors.length)i.errors.map(o=>r({issues:o}));else if(i.code==="invalid_key")r({issues:i.issues});else if(i.code==="invalid_element")r({issues:i.issues});else if(i.path.length===0)n._errors.push(e(i));else{let o=n,a=0;for(;a<i.path.length;){const l=i.path[a];a===i.path.length-1?(o[l]=o[l]||{_errors:[]},o[l]._errors.push(e(i))):o[l]=o[l]||{_errors:[]},o=o[l],a++}}};return r(t),n}const Oc=t=>(e,n,r,s)=>{const i=r?Object.assign(r,{async:!1}):{async:!1},o=e._zod.run({value:n,issues:[]},i);if(o instanceof Promise)throw new _r;if(o.issues.length){const a=new((s==null?void 0:s.Err)??t)(o.issues.map(l=>an(l,i,on())));throw Uf(a,s==null?void 0:s.callee),a}return o.value},zc=t=>async(e,n,r,s)=>{const i=r?Object.assign(r,{async:!0}):{async:!0};let o=e._zod.run({value:n,issues:[]},i);if(o instanceof Promise&&(o=await o),o.issues.length){const a=new((s==null?void 0:s.Err)??t)(o.issues.map(l=>an(l,i,on())));throw Uf(a,s==null?void 0:s.callee),a}return o.value},Zo=t=>(e,n,r)=>{const s=r?{...r,async:!1}:{async:!1},i=e._zod.run({value:n,issues:[]},s);if(i instanceof Promise)throw new _r;return i.issues.length?{success:!1,error:new(t??jf)(i.issues.map(o=>an(o,s,on())))}:{success:!0,data:i.value}},n$=Zo(Wf),jo=t=>async(e,n,r)=>{const s=r?Object.assign(r,{async:!0}):{async:!0};let i=e._zod.run({value:n,issues:[]},s);return i instanceof Promise&&(i=await i),i.issues.length?{success:!1,error:new t(i.issues.map(o=>an(o,s,on())))}:{success:!0,data:i.value}},r$=jo(Wf),s$=t=>(e,n,r)=>{const s=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return Oc(t)(e,n,s)},i$=t=>(e,n,r)=>Oc(t)(e,n,r),o$=t=>async(e,n,r)=>{const s=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return zc(t)(e,n,s)},a$=t=>async(e,n,r)=>zc(t)(e,n,r),l$=t=>(e,n,r)=>{const s=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return Zo(t)(e,n,s)},c$=t=>(e,n,r)=>Zo(t)(e,n,r),u$=t=>async(e,n,r)=>{const s=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return jo(t)(e,n,s)},h$=t=>async(e,n,r)=>jo(t)(e,n,r),d$=/^[cC][^\s-]{8,}$/,p$=/^[0-9a-z]+$/,f$=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,g$=/^[0-9a-vA-V]{20}$/,m$=/^[A-Za-z0-9]{27}$/,v$=/^[a-zA-Z0-9_-]{21}$/,y$=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,b$=/^([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})$/,nd=t=>t?new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${t}[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)$/,w$=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,_$="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function S$(){return new RegExp(_$,"u")}const k$=/^(?:(?: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])$/,E$=/^(([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}|:))$/,$$=/^((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])$/,A$=/^(([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])$/,x$=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Bf=/^[A-Za-z0-9_-]*$/,T$=/^\+[1-9]\d{6,14}$/,Gf="(?:(?:\\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])))",C$=new RegExp(`^${Gf}$`);function Vf(t){const e="(?:[01]\\d|2[0-3]):[0-5]\\d";return typeof t.precision=="number"?t.precision===-1?`${e}`:t.precision===0?`${e}:[0-5]\\d`:`${e}:[0-5]\\d\\.\\d{${t.precision}}`:`${e}(?::[0-5]\\d(?:\\.\\d+)?)?`}function I$(t){return new RegExp(`^${Vf(t)}$`)}function P$(t){const e=Vf({precision:t.precision}),n=["Z"];t.local&&n.push(""),t.offset&&n.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");const r=`${e}(?:${n.join("|")})`;return new RegExp(`^${Gf}T(?:${r})$`)}const R$=t=>{const e=t?`[\\s\\S]{${(t==null?void 0:t.minimum)??0},${(t==null?void 0:t.maximum)??""}}`:"[\\s\\S]*";return new RegExp(`^${e}$`)},D$=/^-?\d+$/,Hf=/^-?\d+(?:\.\d+)?$/,O$=/^(?:true|false)$/i,z$=/^[^A-Z]*$/,L$=/^[^a-z]*$/,We=S("$ZodCheck",(t,e)=>{var n;t._zod??(t._zod={}),t._zod.def=e,(n=t._zod).onattach??(n.onattach=[])}),qf={number:"number",bigint:"bigint",object:"date"},Yf=S("$ZodCheckLessThan",(t,e)=>{We.init(t,e);const n=qf[typeof e.value];t._zod.onattach.push(r=>{const s=r._zod.bag,i=(e.inclusive?s.maximum:s.exclusiveMaximum)??Number.POSITIVE_INFINITY;e.value<i&&(e.inclusive?s.maximum=e.value:s.exclusiveMaximum=e.value)}),t._zod.check=r=>{(e.inclusive?r.value<=e.value:r.value<e.value)||r.issues.push({origin:n,code:"too_big",maximum:typeof e.value=="object"?e.value.getTime():e.value,input:r.value,inclusive:e.inclusive,inst:t,continue:!e.abort})}}),Kf=S("$ZodCheckGreaterThan",(t,e)=>{We.init(t,e);const n=qf[typeof e.value];t._zod.onattach.push(r=>{const s=r._zod.bag,i=(e.inclusive?s.minimum:s.exclusiveMinimum)??Number.NEGATIVE_INFINITY;e.value>i&&(e.inclusive?s.minimum=e.value:s.exclusiveMinimum=e.value)}),t._zod.check=r=>{(e.inclusive?r.value>=e.value:r.value>e.value)||r.issues.push({origin:n,code:"too_small",minimum:typeof e.value=="object"?e.value.getTime():e.value,input:r.value,inclusive:e.inclusive,inst:t,continue:!e.abort})}}),M$=S("$ZodCheckMultipleOf",(t,e)=>{We.init(t,e),t._zod.onattach.push(n=>{var r;(r=n._zod.bag).multipleOf??(r.multipleOf=e.value)}),t._zod.check=n=>{if(typeof n.value!=typeof e.value)throw new Error("Cannot mix number and bigint in multiple_of check.");(typeof n.value=="bigint"?n.value%e.value===BigInt(0):ZE(n.value,e.value)===0)||n.issues.push({origin:typeof n.value,code:"not_multiple_of",divisor:e.value,input:n.value,inst:t,continue:!e.abort})}}),N$=S("$ZodCheckNumberFormat",(t,e)=>{var o;We.init(t,e),e.format=e.format||"float64";const n=(o=e.format)==null?void 0:o.includes("int"),r=n?"int":"number",[s,i]=VE[e.format];t._zod.onattach.push(a=>{const l=a._zod.bag;l.format=e.format,l.minimum=s,l.maximum=i,n&&(l.pattern=D$)}),t._zod.check=a=>{const l=a.value;if(n){if(!Number.isInteger(l)){a.issues.push({expected:r,format:e.format,code:"invalid_type",continue:!1,input:l,inst:t});return}if(!Number.isSafeInteger(l)){l>0?a.issues.push({input:l,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:t,origin:r,inclusive:!0,continue:!e.abort}):a.issues.push({input:l,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:t,origin:r,inclusive:!0,continue:!e.abort});return}}l<s&&a.issues.push({origin:"number",input:l,code:"too_small",minimum:s,inclusive:!0,inst:t,continue:!e.abort}),l>i&&a.issues.push({origin:"number",input:l,code:"too_big",maximum:i,inclusive:!0,inst:t,continue:!e.abort})}}),U$=S("$ZodCheckMaxLength",(t,e)=>{var n;We.init(t,e),(n=t._zod.def).when??(n.when=r=>{const s=r.value;return!Pc(s)&&s.length!==void 0}),t._zod.onattach.push(r=>{const s=r._zod.bag.maximum??Number.POSITIVE_INFINITY;e.maximum<s&&(r._zod.bag.maximum=e.maximum)}),t._zod.check=r=>{const s=r.value;if(s.length<=e.maximum)return;const o=Dc(s);r.issues.push({origin:o,code:"too_big",maximum:e.maximum,inclusive:!0,input:s,inst:t,continue:!e.abort})}}),F$=S("$ZodCheckMinLength",(t,e)=>{var n;We.init(t,e),(n=t._zod.def).when??(n.when=r=>{const s=r.value;return!Pc(s)&&s.length!==void 0}),t._zod.onattach.push(r=>{const s=r._zod.bag.minimum??Number.NEGATIVE_INFINITY;e.minimum>s&&(r._zod.bag.minimum=e.minimum)}),t._zod.check=r=>{const s=r.value;if(s.length>=e.minimum)return;const o=Dc(s);r.issues.push({origin:o,code:"too_small",minimum:e.minimum,inclusive:!0,input:s,inst:t,continue:!e.abort})}}),Z$=S("$ZodCheckLengthEquals",(t,e)=>{var n;We.init(t,e),(n=t._zod.def).when??(n.when=r=>{const s=r.value;return!Pc(s)&&s.length!==void 0}),t._zod.onattach.push(r=>{const s=r._zod.bag;s.minimum=e.length,s.maximum=e.length,s.length=e.length}),t._zod.check=r=>{const s=r.value,i=s.length;if(i===e.length)return;const o=Dc(s),a=i>e.length;r.issues.push({origin:o,...a?{code:"too_big",maximum:e.length}:{code:"too_small",minimum:e.length},inclusive:!0,exact:!0,input:r.value,inst:t,continue:!e.abort})}}),Wo=S("$ZodCheckStringFormat",(t,e)=>{var n,r;We.init(t,e),t._zod.onattach.push(s=>{const i=s._zod.bag;i.format=e.format,e.pattern&&(i.patterns??(i.patterns=new Set),i.patterns.add(e.pattern))}),e.pattern?(n=t._zod).check??(n.check=s=>{e.pattern.lastIndex=0,!e.pattern.test(s.value)&&s.issues.push({origin:"string",code:"invalid_format",format:e.format,input:s.value,...e.pattern?{pattern:e.pattern.toString()}:{},inst:t,continue:!e.abort})}):(r=t._zod).check??(r.check=()=>{})}),j$=S("$ZodCheckRegex",(t,e)=>{Wo.init(t,e),t._zod.check=n=>{e.pattern.lastIndex=0,!e.pattern.test(n.value)&&n.issues.push({origin:"string",code:"invalid_format",format:"regex",input:n.value,pattern:e.pattern.toString(),inst:t,continue:!e.abort})}}),W$=S("$ZodCheckLowerCase",(t,e)=>{e.pattern??(e.pattern=z$),Wo.init(t,e)}),B$=S("$ZodCheckUpperCase",(t,e)=>{e.pattern??(e.pattern=L$),Wo.init(t,e)}),G$=S("$ZodCheckIncludes",(t,e)=>{We.init(t,e);const n=Lr(e.includes),r=new RegExp(typeof e.position=="number"?`^.{${e.position}}${n}`:n);e.pattern=r,t._zod.onattach.push(s=>{const i=s._zod.bag;i.patterns??(i.patterns=new Set),i.patterns.add(r)}),t._zod.check=s=>{s.value.includes(e.includes,e.position)||s.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:e.includes,input:s.value,inst:t,continue:!e.abort})}}),V$=S("$ZodCheckStartsWith",(t,e)=>{We.init(t,e);const n=new RegExp(`^${Lr(e.prefix)}.*`);e.pattern??(e.pattern=n),t._zod.onattach.push(r=>{const s=r._zod.bag;s.patterns??(s.patterns=new Set),s.patterns.add(n)}),t._zod.check=r=>{r.value.startsWith(e.prefix)||r.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:e.prefix,input:r.value,inst:t,continue:!e.abort})}}),H$=S("$ZodCheckEndsWith",(t,e)=>{We.init(t,e);const n=new RegExp(`.*${Lr(e.suffix)}$`);e.pattern??(e.pattern=n),t._zod.onattach.push(r=>{const s=r._zod.bag;s.patterns??(s.patterns=new Set),s.patterns.add(n)}),t._zod.check=r=>{r.value.endsWith(e.suffix)||r.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:e.suffix,input:r.value,inst:t,continue:!e.abort})}}),q$=S("$ZodCheckOverwrite",(t,e)=>{We.init(t,e),t._zod.check=n=>{n.value=e.tx(n.value)}});class Y${constructor(e=[]){this.content=[],this.indent=0,this&&(this.args=e)}indented(e){this.indent+=1,e(this),this.indent-=1}write(e){if(typeof e=="function"){e(this,{execution:"sync"}),e(this,{execution:"async"});return}const r=e.split(`
|
|
4
|
+
`+e.prev}function Ri(t,e){var n=ll(t),r=[];if(n){r.length=t.length;for(var s=0;s<t.length;s++)r[s]=It(t,s)?e(t[s],t):""}var i=typeof Ta=="function"?Ta(t):[],o;if(Or){o={};for(var a=0;a<i.length;a++)o["$"+i[a]]=i[a]}for(var l in t)It(t,l)&&(n&&String(Number(l))===l&&l<t.length||Or&&o["$"+l]instanceof Symbol||(Mp.call(/[^\w$]/,l)?r.push(e(l,t)+": "+e(t[l],t)):r.push(l+": "+e(t[l],t))));if(typeof Ta=="function")for(var c=0;c<i.length;c++)Np.call(t,i[c])&&r.push("["+e(i[c])+"]: "+e(t[i[c]],t));return r}var D_=Br,O_=V,Mo=function(t,e,n){for(var r=t,s;(s=r.next)!=null;r=s)if(s.key===e)return r.next=s.next,n||(s.next=t.next,t.next=s),s},z_=function(t,e){if(t){var n=Mo(t,e);return n&&n.value}},L_=function(t,e,n){var r=Mo(t,e);r?r.value=n:t.next={key:e,next:t.next,value:n}},M_=function(t,e){return t?!!Mo(t,e):!1},N_=function(t,e){if(t)return Mo(t,e,!0)},U_=function(){var e,n={assert:function(r){if(!n.has(r))throw new O_("Side channel does not contain "+D_(r))},delete:function(r){var s=e&&e.next,i=N_(e,r);return i&&s&&s===i&&(e=void 0),!!i},get:function(r){return z_(e,r)},has:function(r){return M_(e,r)},set:function(r,s){e||(e={next:void 0}),L_(e,r,s)}};return n},F_=Qe,pi=hn(),Z_=Br,j_=V,wh=F_("%Map%",!0),W_=pi("Map.prototype.get",!0),B_=pi("Map.prototype.set",!0),G_=pi("Map.prototype.has",!0),V_=pi("Map.prototype.delete",!0),H_=pi("Map.prototype.size",!0),Bp=!!wh&&function(){var e,n={assert:function(r){if(!n.has(r))throw new j_("Side channel does not contain "+Z_(r))},delete:function(r){if(e){var s=V_(e,r);return H_(e)===0&&(e=void 0),s}return!1},get:function(r){if(e)return W_(e,r)},has:function(r){return e?G_(e,r):!1},set:function(r,s){e||(e=new wh),B_(e,r,s)}};return n},q_=Qe,No=hn(),Y_=Br,Di=Bp,K_=V,ar=q_("%WeakMap%",!0),J_=No("WeakMap.prototype.get",!0),X_=No("WeakMap.prototype.set",!0),Q_=No("WeakMap.prototype.has",!0),eS=No("WeakMap.prototype.delete",!0),tS=ar?function(){var e,n,r={assert:function(s){if(!r.has(s))throw new K_("Side channel does not contain "+Y_(s))},delete:function(s){if(ar&&s&&(typeof s=="object"||typeof s=="function")){if(e)return eS(e,s)}else if(Di&&n)return n.delete(s);return!1},get:function(s){return ar&&s&&(typeof s=="object"||typeof s=="function")&&e?J_(e,s):n&&n.get(s)},has:function(s){return ar&&s&&(typeof s=="object"||typeof s=="function")&&e?Q_(e,s):!!n&&n.has(s)},set:function(s,i){ar&&s&&(typeof s=="object"||typeof s=="function")?(e||(e=new ar),X_(e,s,i)):Di&&(n||(n=Di()),n.set(s,i))}};return r}:Di,nS=V,rS=Br,sS=U_,iS=Bp,oS=tS,aS=oS||iS||sS,lS=function(){var e,n={assert:function(r){if(!n.has(r))throw new nS("Side channel does not contain "+rS(r))},delete:function(r){return!!e&&e.delete(r)},get:function(r){return e&&e.get(r)},has:function(r){return!!e&&e.has(r)},set:function(r,s){e||(e=aS()),e.set(r,s)}};return n},cS=jt,rs=lS(),xt=V,fc={assert:function(t,e){if(!t||typeof t!="object"&&typeof t!="function")throw new xt("`O` is not an object");if(typeof e!="string")throw new xt("`slot` must be a string");if(rs.assert(t),!fc.has(t,e))throw new xt("`"+e+"` is not present on `O`")},get:function(t,e){if(!t||typeof t!="object"&&typeof t!="function")throw new xt("`O` is not an object");if(typeof e!="string")throw new xt("`slot` must be a string");var n=rs.get(t);return n&&n["$"+e]},has:function(t,e){if(!t||typeof t!="object"&&typeof t!="function")throw new xt("`O` is not an object");if(typeof e!="string")throw new xt("`slot` must be a string");var n=rs.get(t);return!!n&&cS(n,"$"+e)},set:function(t,e,n){if(!t||typeof t!="object"&&typeof t!="function")throw new xt("`O` is not an object");if(typeof e!="string")throw new xt("`slot` must be a string");var r=rs.get(t);r||(r={},rs.set(t,r)),r["$"+e]=n}};Object.freeze&&Object.freeze(fc);var gc=fc,Gp=Ft,rn=gc,fi=function t(e,n){if(!(this instanceof t))return new t(e,n);if(e!=="normal"&&e!=="break"&&e!=="continue"&&e!=="return"&&e!=="throw")throw new Gp('Assertion failed: `type` must be one of "normal", "break", "continue", "return", or "throw"');rn.set(this,"[[Type]]",e),rn.set(this,"[[Value]]",n)};fi.prototype.type=function(){return rn.get(this,"[[Type]]")};fi.prototype.value=function(){return rn.get(this,"[[Value]]")};fi.prototype["?"]=function(){var e=rn.get(this,"[[Type]]"),n=rn.get(this,"[[Value]]");if(e==="throw")throw n;return n};fi.prototype["!"]=function(){var e=rn.get(this,"[[Type]]");if(e!=="normal")throw new Gp('Assertion failed: Completion Record is not of type "normal"');return rn.get(this,"[[Value]]")};var mc=fi,uS=mc,vc=function(e){return new uS("normal",e)},Ia,_h;function hS(){if(_h)return Ia;_h=1;var t=Fr;return Ia=function(){return t()&&!!Symbol.toStringTag},Ia}var dS=Qe,Sh=dS("%Object.defineProperty%",!0),pS=hS()(),fS=jt,gS=V,Oi=pS?Symbol.toStringTag:null,Vp=function(e,n){var r=arguments.length>2&&!!arguments[2]&&arguments[2].force,s=arguments.length>2&&!!arguments[2]&&arguments[2].nonConfigurable;if(typeof r<"u"&&typeof r!="boolean"||typeof s<"u"&&typeof s!="boolean")throw new gS("if provided, the `overrideIfSet` and `nonConfigurable` options must be booleans");Oi&&(r||!fS(e,Oi))&&(Sh?Sh(e,Oi,{configurable:!s,enumerable:!1,value:n,writable:!1}):e[Oi]=n)},Hp={exports:{}},mS=Qe,kh=up,vS=Oo(),Eh=Ur,$h=V,yS=mS("%Math.floor%"),bS=function(e,n){if(typeof e!="function")throw new $h("`fn` is not a function");if(typeof n!="number"||n<0||n>4294967295||yS(n)!==n)throw new $h("`length` must be a positive 32-bit integer");var r=arguments.length>2&&!!arguments[2],s=!0,i=!0;if("length"in e&&Eh){var o=Eh(e,"length");o&&!o.configurable&&(s=!1),o&&!o.writable&&(i=!1)}return(s||i||!r)&&(vS?kh(e,"length",n,!0,!0):kh(e,"length",n)),e},wS=li,_S=sc,SS=_p,kS=function(){return SS(wS,_S,arguments)};(function(t){var e=bS,n=ai,r=zo,s=kS;t.exports=function(o){var a=r(arguments),l=1+o.length-(arguments.length-1);return e(a,l>0?l:0,!0)},n?n(t.exports,"apply",{value:s}):t.exports.apply=s})(Hp);var yc=Hp.exports,ES=function(e,n){for(var r=0;r<e.length;r+=1)if(!n(e[r],r,e))return!1;return!0},$S=Object,AS=function(e){return e&&typeof e=="object"&&(typeof e["[[ResourceValue]]"]>"u"||$S(e["[[ResourceValue]]"])===e["[[ResourceValue]]"])&&(e["[[Hint]]"]==="SYNC-DISPOSE"||e["[[Hint]]"]==="ASYNC-DISPOSE")&&(typeof e["[[DisposeMethod]]"]=="function"||typeof e["[[DisposeMethod]]"]>"u")},xS=jt,TS=ic(),CS=ES,IS=AS,PS=function(e){return e&&typeof e=="object"&&xS(e,"[[DisposableResourceStack]]")&&TS(e["[[DisposableResourceStack]]"])&&(e["[[DisposableResourceStack]]"].length===0||CS(e["[[DisposableResourceStack]]"],IS))},RS=Zt,DS=function(e){if(e===null)return"Null";if(typeof e>"u")return"Undefined";if(RS(e))return"Object";if(typeof e=="number")return"Number";if(typeof e=="boolean")return"Boolean";if(typeof e=="string")return"String"},OS=DS,bc=function(e){return typeof e=="symbol"?"Symbol":typeof e=="bigint"?"BigInt":OS(e)},zS=V,LS=Br,MS=jr,NS=function(e,n){if(!MS(n))throw new zS("Assertion failed: P is not a Property Key, got "+LS(n));return e[n]},Ah=V,US=NS,FS=Wr,ZS=jr,xh=Br,jS=function(e,n){if(!ZS(n))throw new Ah("Assertion failed: P is not a Property Key");var r=US(e,n);if(r!=null){if(!FS(r))throw new Ah(xh(n)+" is not a function: "+xh(r));return r}},ul={exports:{}},WS=Qe,BS=WS,Th=BS("%Reflect.construct%",!0),ho=di;try{ho({},"",{"[[Get]]":function(){}})}catch{ho=null}if(ho&&Th){var Ch={},Ih={};ho(Ih,"length",{"[[Get]]":function(){throw Ch},"[[Enumerable]]":!0}),ul.exports=function(e){try{Th(e,Ih)}catch(n){return n===Ch}}}else ul.exports=function(e){return typeof e=="function"&&!!e.prototype};var GS=ul.exports,Pa=V,Ph=Wr,VS=GS,HS=function(e){if(!VS(e))throw new Pa("C must be a constructor");var n={"[[Resolve]]":void 0,"[[Reject]]":void 0},r=new e(function(s,i){if(typeof n["[[Resolve]]"]<"u"||typeof n["[[Reject]]"]<"u")throw new Pa("executor has already been called");n["[[Resolve]]"]=s,n["[[Reject]]"]=i});if(!Ph(n["[[Resolve]]"])||!Ph(n["[[Reject]]"]))throw new Pa("executor must provide valid resolve and reject functions");return{"[[Promise]]":r,"[[Resolve]]":n["[[Resolve]]"],"[[Reject]]":n["[[Reject]]"]}},Rh=Ft,qS=V,Ra=Lo,Dh=jS,YS=HS,KS=bc,Oh=cc(),zh=uc(),JS=function(e,n){if(KS(e)!=="Object")throw new qS("`V` must be an Object");if(n!=="SYNC-DISPOSE"&&n!=="ASYNC-DISPOSE")throw new Rh("Assertion failed: `hint` must be `~SYNC-DISPOSE~` or `~ASYNC-DISPOSE~`");var r;if(n==="ASYNC-DISPOSE"&&zh&&(r=Dh(e,zh)),!r){if(!Oh)throw new Rh("`Symbol.dispose` is not supported");if(r=Dh(e,Oh),typeof r<"u")return function(){var s=this;if(n==="ASYNC-DISPOSE"){var i=YS(Promise);try{Ra(r,s),Ra(i["[[Resolve]]"],void 0,[void 0])}catch(o){i["[[Reject]]"](o)}return i["[[Promise]]"]}Ra(r,s)}}return r},XS=Ft,Da=V,QS=Wr,ek=bc,tk=JS,nk=function(e,n){if(n!=="SYNC-DISPOSE"&&n!=="ASYNC-DISPOSE")throw new XS("Assertion failed: `hint` must be `~SYNC-DISPOSE~` or `~ASYNC-DISPOSE~`");var r;if(arguments.length<3)if(e==null)e=void 0,r=void 0;else{if(typeof e<"u"&&ek(e)!=="Object")throw new Da("`V` must be an Object, or `null` or `undefined`");if(r=tk(e,n),typeof r>"u")throw new Da("dispose method must not be `undefined` on `V` when an object `V` is provided")}else if(r=arguments[2],!QS(r))throw new Da("`method`, when provided, must be a function");return{"[[ResourceValue]]":e,"[[Hint]]":n,"[[DisposeMethod]]":r}},rk=Ft,zi=V,sk=PS,Lh=nk,ik=hn(),ok=ik("Array.prototype.push"),qp=function(e,n,r){if(!sk(e))throw new zi("Assertion failed: `disposeCapability` must be a DisposeCapability Record");if(r!=="SYNC-DISPOSE"&&r!=="ASYNC-DISPOSE")throw new rk("Assertion failed: `hint` must be `~SYNC-DISPOSE~` or `~ASYNC-DISPOSE~`");var s=arguments.length>3?arguments[3]:void 0;if(arguments.length>3&&typeof s!="function")throw new zi("Assertion failed: `method`, when present, must be a function");if(!e["[[DisposableResourceStack]]"])throw new zi("Assertion failed: `disposeCapability.[[DisposableResourceStack]]` must not be ~EMPTY~");var i;if(arguments.length<4){if(n==null&&r==="SYNC_DISPOSE")return"UNUSED";i=Lh(n,r)}else{if(typeof n<"u")throw new zi("Assertion failed: `V` must be undefined when `method` is present");i=Lh(void 0,r,s)}return ok(e["[[DisposableResourceStack]]"],i),"UNUSED"},Oa,Mh;function wc(){if(Mh)return Oa;Mh=1;var t=Qe,e=yc,n=Ft,r=t("%Promise.resolve%",!0),s=r&&e(r);return Oa=function(o,a){if(!s)throw new n("This environment does not support Promises.");return s(o,a)},Oa}var za,Nh;function ak(){if(Nh)return za;Nh=1;var t=Qe,e=Ft,n=t("%Promise%",!0),r=Lo,s=wc(),i=bc;return za=function(a,l,c){if(typeof a<"u"&&i(a)!=="Object")throw new e("Assertion failed: `V` must be `undefined` or an Object");if(l!=="SYNC-DISPOSE"&&l!=="ASYNC-DISPOSE")throw new e("Assertion failed: `hint` must be `~SYNC-DISPOSE~` or `~ASYNC-DISPOSE~`");if(typeof c<"u"&&typeof c!="function")throw new e("Assertion failed: `method` must be `undefined` or a function");var d=typeof c>"u"?c:r(c,a);if(l==="ASYNC-DISPOSE")return s(n,d)},za}var La,Uh;function lk(){if(Uh)return La;Uh=1;var t=mc;return La=function(n){return new t("throw",n)},La}var ck=Qe,Ma=Ft,Fh=V,uk=ck("%Promise%",!0),hk=hn(),Zh=hk("Promise.prototype.then",!0),dk=mc,jh=ak(),pk=vc,fk=wc(),Wh=lk(),gk=Lp(),Yp=function(e,n){if(!(n instanceof dk))throw new Fh("`completion` must be a Completion Record");var r=e["[[DisposableResourceStack]]"];if(!r)throw new Fh("Assertion failed: `disposeCapability.[[DisposableResourceStack]]` must not be ~EMPTY~");for(var s,i=r.length-1;i>=0;i-=1)if(!s)s=r[i]["[[Hint]]"];else if(s!==r[i]["[[Hint]]"])throw new Ma("mixed hint stacks are not supported");for(var o=s==="ASYNC-DISPOSE"&&fk(uk,n),a=function(y){if(n.type()==="throw"){var m=n.value(),E=new gk(y,m);n=Wh(E)}else n=Wh(y)},l=s==="ASYNC-DISPOSE"&&function(m){return Zh(o,function(){var E=jh(m["[[ResourceValue]]"],m["[[Hint]]"],m["[[DisposeMethod]]"]);if(!E)throw new Ma("Assertion failed: non-`~ASYNC-DISPOSE~` resource returned a promise from Dispose");return Zh(E,pk)},a)},c=r.length-1;c>=0;c-=1)if(s==="ASYNC-DISPOSE")o=l(r[c]);else{var d=r[c];try{var p=jh(d["[[ResourceValue]]"],d["[[Hint]]"],d["[[DisposeMethod]]"]);if(p)throw new Ma("Assertion failed: `~SYNC-DISPOSE~` resource returned something from Dispose")}catch(y){a(y)}}return e["[[DisposableResourceStack]]"]=null,s==="ASYNC-DISPOSE"?o:n},Kp=function(){var e=[];return{"[[DisposableResourceStack]]":e}},Uo=ec,_c=V,mk=Lo,Gr=ac,vk=di,Jp=Wr,yk=vc,Ze=gc,bk=Vp,Xp=Yn.supportsDescriptors,wk=yc,Sc=qp,_k=Yp,Qp=Kp,Bh=cc(),Ke=function t(){if(!(this instanceof t)||Ze.has(this,"[[DisposableState]]")||Ze.has(this,"[[DisposeCapability]]"))throw new _c("can only be used with new");Ze.set(this,"[[DisposableState]]","PENDING"),Ze.set(this,"[[DisposeCapability]]",Qp())},ef=function(){var e=this;return Ze.assert(e,"[[DisposableState]]"),Ze.get(e,"[[DisposableState]]")==="DISPOSED"},gi=wk(ef);Xp?vk(Ke.prototype,"disposed",{"[[Configurable]]":!0,"[[Enumerable]]":!1,"[[Get]]":ef}):Ke.prototype.disposed=!1;var tf=function(e){Ze.set(e,"[[DisposableState]]","DISPOSED"),Xp||(e.disposed=!0)};Gr(Ke.prototype,"dispose",function(){var e=this;if(!gi(e))return tf(e),_k(Ze.get(e,"[[DisposeCapability]]"),yk())["?"]()});Gr(Ke.prototype,"use",function(e){var n=this;if(gi(n))throw new Uo("a disposed stack can not use anything new");return Sc(Ze.get(n,"[[DisposeCapability]]"),e,"SYNC-DISPOSE"),e});Gr(Ke.prototype,"adopt",function(e,n){var r=this;if(gi(r))throw new Uo("a disposed stack can not use anything new");if(!Jp(n))throw new _c("`onDispose` must be a function");var s=function(){return mk(n,void 0,[e])};return Sc(Ze.get(r,"[[DisposeCapability]]"),void 0,"SYNC-DISPOSE",s),e});Gr(Ke.prototype,"defer",function(e){var n=this;if(gi(n))throw new Uo("a disposed stack can not defer anything new");if(!Jp(e))throw new _c("`onDispose` must be a function");Sc(Ze.get(n,"[[DisposeCapability]]"),void 0,"SYNC-DISPOSE",e)});Gr(Ke.prototype,"move",function(){var e=this;if(gi(e))throw new Uo("a disposed stack can not use anything new");var n=new Ke;return Ze.set(n,"[[DisposeCapability]]",Ze.get(e,"[[DisposeCapability]]")),Ze.set(e,"[[DisposeCapability]]",Qp()),tf(e),n});Bh&&Gr(Ke.prototype,Bh,Ke.prototype.dispose);bk(Ke.prototype,"DisposableStack");var Sk=Ke,kk=Sk,Ek=function(){return typeof DisposableStack=="function"?DisposableStack:kk},$k=Yn,Ak=Xl(),xk=Ek,Tk=function(){var e=xk();return $k(Ak,{DisposableStack:e},{DisposableStack:!0}),e},Ck=Qe,Fo=ec,kc=V,Gh=Ck("%Promise%",!0),Ec=qp,Ik=Lo,Vr=ac,Pk=di,Rk=Yp,nf=Wr,rf=Kp,Dk=vc,Vh=wc(),je=gc,Ok=Vp,sf=Yn.supportsDescriptors,zk=yc,Lk=hn(),Mk=Lk("Promise.prototype.then",!0),Hh=uc(),Je=function t(){if(!(this instanceof t)||je.has(this,"[[AsyncDisposableState]]")||je.has(this,"[[DisposeCapability]]"))throw new kc("can only be used with new");je.set(this,"[[AsyncDisposableState]]","pending"),je.set(this,"[[DisposeCapability]]",rf())},of=function(){var e=this;return je.assert(e,"[[AsyncDisposableState]]"),je.get(e,"[[AsyncDisposableState]]")==="disposed"},mi=zk(of);sf?Pk(Je.prototype,"disposed",{"[[Configurable]]":!0,"[[Enumerable]]":!1,"[[Get]]":of}):Je.prototype.disposed=!1;var af=function(e){je.set(e,"[[AsyncDisposableState]]","disposed"),sf||(e.disposed=!0)};Vr(Je.prototype,"disposeAsync",function(){var e=this;return mi(e)?Vh(Gh):(af(e),Mk(Vh(Gh,Rk(je.get(e,"[[DisposeCapability]]"),Dk())),function(n){return n["?"]()}))});Vr(Je.prototype,"use",function(e){var n=this;if(mi(n))throw new Fo("a disposed stack can not use anything new");return Ec(je.get(n,"[[DisposeCapability]]"),e,"ASYNC-DISPOSE"),e});Vr(Je.prototype,"adopt",function(e,n){var r=this;if(mi(r))throw new Fo("a disposed stack can not use anything new");if(!nf(n))throw new kc("`onDisposeAsync` must be a function");var s=function(){return Ik(n,void 0,[e])};return s.value=e,Ec(je.get(r,"[[DisposeCapability]]"),void 0,"ASYNC-DISPOSE",s),e});Vr(Je.prototype,"defer",function(e){var n=this;if(mi(n))throw new Fo("a disposed stack can not defer anything new");if(!nf(e))throw new kc("`onDispose` must be a function");Ec(je.get(n,"[[DisposeCapability]]"),void 0,"ASYNC-DISPOSE",e)});Vr(Je.prototype,"move",function(){var e=this;if(mi(e))throw new Fo("a disposed stack can not use anything new");var n=new Je;return je.set(n,"[[DisposeCapability]]",je.get(e,"[[DisposeCapability]]")),je.set(e,"[[DisposeCapability]]",rf()),af(e),n});Hh&&Vr(Je.prototype,Hh,Je.prototype.disposeAsync);Ok(Je.prototype,"AsyncDisposableStack");var Nk=Je,Uk=Nk,Fk=function(){return typeof AsyncDisposableStack=="function"?AsyncDisposableStack:Uk},Zk=Yn,jk=Xl(),Wk=Fk,Bk=function(){var e=Wk();return Zk(jk,{AsyncDisposableStack:e},{AsyncDisposableStack:!0}),e},Gk=Zw,Vk=Yw,Hk=Tk,qk=Bk,Yk=function(){Gk(),Vk(),Hk(),qk()};Yk();const qh=new WeakMap;function Kk(t){return(typeof t=="object"||typeof t=="function")&&t!==null&&"then"in t&&typeof t.then=="function"}function lr(t){return typeof t=="string"?t:typeof t=="symbol"?t.description??t.toString():t.name||"(anonymous class)"}function Yh(){return new Error("register(Key, factory) requires a factory function. Wrap existing instances as () => instance.")}function Jk(){return new Error("register(Key, factory) does not accept async factories. Await setup before registering.")}class Xk{constructor(){v(this,"entries",new Map);v(this,"constructionStack",[])}register(e,n){if(n===void 0){if(typeof e!="function")throw Yh();this.validateClassRegistration(e),this.storeFactory(e,()=>this.instantiateClass(e));return}if(typeof n!="function")throw Yh();if(n.constructor.name==="AsyncFunction")throw Jk();this.storeFactory(e,n)}has(e){var n;return((n=this.entries.get(e))==null?void 0:n.factory)!==void 0}resolve(e){return this.resolveAny(e)}storeFactory(e,n){const r=this.getOrCreateEntry(e);r.factory=n,r.instance=void 0,r.error=void 0}validateClassRegistration(e){const n=qh.get(e);if(n){if(e.length!==n.length)throw new Error(`${lr(e)} cannot be registered with register(Class). @injectable(...) declared ${n.length} dependencies but constructor arity is ${e.length}. Use register(Key, () => value) instead.`);return}if(e.length!==0)throw new Error(`${lr(e)} cannot be registered with register(Class). Undecorated classes must have zero required constructor parameters. Use register(Key, () => value) instead.`)}instantiateClass(e){const n=qh.get(e);if(!n)return new e;const r=n.map(s=>this.resolveAny(s));return new e(...r)}resolveAny(e){return this.getOrCreateEntry(e).proxy}getOrCreateEntry(e){let n=this.entries.get(e);return n||(n={key:e},n.proxy=this.createProxy(n),this.entries.set(e,n),n)}createProxy(e){return new Proxy({},{get:(n,r)=>{if(r==="then")return;const s=this.getInstance(e),i=Reflect.get(s,r,s);return typeof i=="function"?i.bind(s):i},set:(n,r,s)=>{const i=this.getInstance(e);return Reflect.set(i,r,s,i)},has:(n,r)=>{const s=this.getInstance(e);return r in s}})}getInstance(e){if(e.instance)return e.instance;if(e.error)throw e.error;if(!e.factory)throw new Error(`${lr(e.key)} was resolved but never registered`);const n=this.constructionStack.indexOf(e.key);if(n!==-1){const r=[...this.constructionStack.slice(n),e.key].map(s=>lr(s)).join(" -> ");throw new Error(`Circular dependency detected: ${r}`)}this.constructionStack.push(e.key);try{const r=e.factory();if(Kk(r))throw new Error(`Factory for ${lr(e.key)} returned a Promise. Await setup before registering.`);if(typeof r!="object"||r===null)throw new Error(`Factory for ${lr(e.key)} returned a non-object value. Wrap primitives in an object.`);return e.instance=r,r}catch(r){throw e.error=r,r}finally{this.constructionStack.pop()}}}const Ve=new Xk,Qk=new Set(["target","currentTarget","eventPhase","defaultPrevented","isTrusted","timeStamp","srcElement","returnValue","cancelBubble","NONE","CAPTURING_PHASE","AT_TARGET","BUBBLING_PHASE","composedPath","stopPropagation","stopImmediatePropagation","preventDefault","initEvent"]);function eE(t){for(const e of Object.keys(t))if(Qk.has(e))throw new Error(`Event payload key "${e}" is reserved; choose a different property name`)}function tE(t,e){eE(e);for(const n of Object.keys(e))Object.defineProperty(t,n,{value:e[n],writable:!0,enumerable:!0,configurable:!0})}function et(){class t extends Event{constructor(n,r){const{type:s,bubbles:i,cancelable:o,composed:a,...l}=r??{};if(s!==void 0)throw new Error('Do not pass "type" in init; use the constructor argument instead');super(n,{bubbles:i,cancelable:o,composed:a}),tE(this,l)}}return t}class kt extends globalThis.EventTarget{}function nE(t,e,n){const r=t.dispose.bind(t);t.dispose=()=>{if(!e())return n(),r()}}function Hr(t){var n;class e extends t{constructor(...i){super(...i);$(this,n,!1);nE(this,()=>u(this,n),()=>{x(this,n,!0)})}[Symbol.dispose](){this.dispose()}get disposed(){return u(this,n)}}return n=new WeakMap,e}const rE=et(),eo=et(),lf="0123456789ABCDEFGHJKMNPQRSTVWXYZ",po=32,sE=16,cf=10,Kh=0xffffffffffff;var xn;(function(t){t.Base32IncorrectEncoding="B32_ENC_INVALID",t.DecodeTimeInvalidCharacter="DEC_TIME_CHAR",t.DecodeTimeValueMalformed="DEC_TIME_MALFORMED",t.EncodeTimeNegative="ENC_TIME_NEG",t.EncodeTimeSizeExceeded="ENC_TIME_SIZE_EXCEED",t.EncodeTimeValueMalformed="ENC_TIME_MALFORMED",t.PRNGDetectFailure="PRNG_DETECT",t.ULIDInvalid="ULID_INVALID",t.Unexpected="UNEXPECTED",t.UUIDInvalid="UUID_INVALID"})(xn||(xn={}));class fs extends Error{constructor(e,n){super(`${n} (${e})`),this.name="ULIDError",this.code=e}}function iE(t){const e=Math.floor(t()*po)%po;return lf.charAt(e)}function oE(t){const e=aE(),n=e&&(e.crypto||e.msCrypto)||null;if(typeof(n==null?void 0:n.getRandomValues)=="function")return()=>{const r=new Uint8Array(1);return n.getRandomValues(r),r[0]/256};if(typeof(n==null?void 0:n.randomBytes)=="function")return()=>n.randomBytes(1).readUInt8()/256;throw new fs(xn.PRNGDetectFailure,"Failed to find a reliable PRNG")}function aE(){return uE()?self:typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:null}function lE(t,e){let n="";for(;t>0;t--)n=iE(e)+n;return n}function cE(t,e=cf){if(isNaN(t))throw new fs(xn.EncodeTimeValueMalformed,`Time must be a number: ${t}`);if(t>Kh)throw new fs(xn.EncodeTimeSizeExceeded,`Cannot encode a time larger than ${Kh}: ${t}`);if(t<0)throw new fs(xn.EncodeTimeNegative,`Time must be positive: ${t}`);if(Number.isInteger(t)===!1)throw new fs(xn.EncodeTimeValueMalformed,`Time must be an integer: ${t}`);let n,r="";for(let s=e;s>0;s--)n=t%po,r=lf.charAt(n)+r,t=(t-n)/po;return r}function uE(){return typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope}function $c(t,e){const n=oE(),r=Date.now();return cE(r,cf)+lE(sE,n)}const St=4,He=6,uf=2,hl=2,hE=St,dE=He,Ac="auto",sn="auto",kn=120,Jh=75,de=16,tn=kn*St+de*(St-1),vr=kn*He+de*(He-1),pE=200,fE=4,Li=150,gE=10,Xh=2,mE=4;function hf(t){return ff(t)}function df(t,e){return ff(t.flatMap(n=>mf(n,e)))}function pf(t){const e=[],n=new Set;for(const r of t){if(r.type==="row"){e.push(`Top-level rows are invalid: ${r.id}`);continue}vf(r,"strip",e,n)}return{valid:e.length===0,errors:e}}function $s(t){const e=hf(t),n=pf(e);if(!n.valid)throw new Error(`Invalid layout: ${n.errors.join("; ")}`);return{totalNodes:e.length,nodes:e.filter(r=>r.type!=="row").map(wE)}}function ff(t){const e=[];for(const n of t){const r=gf(n);for(const s of r){if(s.type==="row"){e.push(...s.children.map(Ut));continue}e.push(s)}}return e}function gf(t){switch(t.type){case"card":return[Ut(t)];case"row":{const e=t.children.map(Ut);return e.length===0?[]:e.length===1?[e[0]]:[{...t,children:e}]}case"stack":{const e=[];for(const n of t.children){const r=gf(n);for(const s of r){if(s.type==="stack"){e.push(...s.children.map(dl));continue}if(s.type==="row"){e.push({...s,children:s.children.map(Ut)});continue}e.push(Ut(s))}}return e.length===0?[]:e.length===1?[dl(e[0])]:[{...t,children:e}]}}}function mf(t,e){switch(t.type){case"card":return t.artifactID===e?[]:[Ut(t)];case"row":{const n=t.children.filter(r=>r.artifactID!==e).map(Ut);return n.length===0?[]:n.length===1?[n[0]]:[{...t,children:n}]}case"stack":{const n=t.children.flatMap(r=>mf(r,e).filter(i=>i.type!=="stack"));return n.length===0?[]:n.length===1?[dl(n[0])]:[{...t,children:n}]}}}function vf(t,e,n,r){switch(t.type){case"card":yf(t,e,n,r);return;case"row":vE(t,e,n,r);return;case"stack":yE(t,e,n,r);return}}function yf(t,e,n,r){xc(t.id,n),typeof t.artifactID!="string"||t.artifactID.length===0?n.push(`Card ${t.id} is missing artifactID`):r.has(t.artifactID)?n.push(`Duplicate artifactID in layout: ${t.artifactID}`):r.add(t.artifactID),bE(t.width)||n.push(`Card ${t.id} width must be an integer in the range 2-4`),bf(t.height)||n.push(`Card ${t.id} height must be an integer in the range 2-6 or "auto"`);const s=En(t.width);e==="row"&&s<uf&&n.push(`Row child ${t.id} must be at least 2 columns wide`)}function vE(t,e,n,r){if(xc(t.id,n),e!=="stack"&&n.push(`Row ${t.id} may only appear inside a stack`),bf(t.height,mE)||n.push(`Row ${t.id} height must be an integer in the range 2-4 or "auto"`),!Array.isArray(t.children)||t.children.length===0){n.push(`Row ${t.id} must contain card nodes`);return}let s=0;for(const i of t.children){if(i.type!=="card"){n.push(`Row ${t.id} must contain only card nodes`);continue}yf(i,"row",n,r),s+=En(i.width)}s!==St&&n.push(`Row ${t.id} children must sum to 4 columns`)}function yE(t,e,n,r){if(xc(t.id,n),e!=="strip"&&n.push(`Invalid nested stack at ${t.id}; stack children cannot contain another nested stack`),!Array.isArray(t.children)||t.children.length===0){n.push(`Stack ${t.id} must contain at least one child`);return}let s=0,i=0;for(const a of t.children){if(a.type==="stack"){n.push(`Stack ${t.id} cannot contain another nested stack`);continue}if(vf(a,"stack",n,r),a.height===sn){i+=1;continue}s+=a.height}if(s>He&&n.push(`Stack ${t.id} exceeds the 6-row budget`),i===0)return;const o=He-s;if(o<i*hl||o%i!==0){n.push(`Stack ${t.id} has auto-height children that cannot resolve to whole height >= 2`);return}o/i<hl&&n.push(`Stack ${t.id} has auto-height children below the minimum row size`)}function xc(t,e){(typeof t!="string"||t.length===0)&&e.push(`Node id must be a non-empty string: ${String(t)}`)}function bE(t){return t===Ac||Number.isInteger(t)&&t>=uf&&t<=hE}function bf(t,e=dE){return t===sn||Number.isInteger(t)&&t>=hl&&t<=e}function En(t){return t===Ac?St:t}function wE(t){if(t.type==="card")return{id:t.id,type:"card",width:En(t.width),cards:[{id:t.id,artifactID:t.artifactID,col:1,row:1,width:En(t.width),height:wf(t.height,He)}]};const e=_E(t.children),n=[];let r=1;for(let s=0;s<t.children.length;s+=1){const i=t.children[s],o=e[s];if(i.type==="card")n.push({id:i.id,artifactID:i.artifactID,col:1,row:r,width:En(i.width),height:o});else{let a=1;for(const l of i.children)n.push({id:l.id,artifactID:l.artifactID,col:a,row:r,width:En(l.width),height:o}),a+=En(l.width)}r+=o}return{id:t.id,type:"stack",width:n.reduce((s,i)=>Math.max(s,i.col+i.width-1),1),cards:n}}function _E(t){let e=0,n=0;for(const s of t)s.height===sn?n+=1:e+=s.height;const r=n>0?(He-e)/n:0;return t.map(s=>wf(s.height,r))}function wf(t,e){return t===sn?e:t}function Ut(t){return{...t}}function dl(t){return t.type==="card"?Ut(t):{...t,children:t.children.map(Ut)}}function _f(t,e={}){return{id:e.id??$c(),type:"card",artifactID:t,width:e.width??Ac,height:e.height??sn}}function Sf(t,e){return t.some(n=>kf(n,e))}function kf(t,e){switch(t.type){case"card":return t.artifactID===e;case"row":return t.children.some(n=>n.artifactID===e);case"stack":return t.children.some(n=>kf(n,e))}}function Qh(t){return t.layout.flatMap(Ef)}function Ef(t){switch(t.type){case"card":return[t.artifactID];case"row":return t.children.map(e=>e.artifactID);case"stack":return t.children.flatMap(Ef)}}const te=et(),$f=et(),ss=et(),SE=et();function kE(t){class e extends Error{constructor(r,s){super(r),this.name=t,s&&Object.assign(this,s)}}return e}const EE=kE("RequestError"),$E=200,AE=300;class xE{constructor(e,n){v(this,"serverURL");v(this,"token");this.serverURL=e.replace(/\/$/,""),this.token=n.token}async requestJSON(e,n,r){const s=await this.request(e,n,r!==void 0?JSON.stringify(r):void 0,r!==void 0?{"content-type":"application/json"}:void 0),i=await TE(s);if(!s.ok||s.status<$E||s.status>=AE)throw this.createError(typeof i.error=="string"?i.error:s.statusText,s.status);return i}async requestVoid(e,n){const r=await this.request(e,n);if(!r.ok)throw this.createError(await Na(r,r.statusText),r.status)}async requestText(e,n){const r=await this.request(e,n);if(!r.ok)throw this.createError(await Na(r,r.statusText),r.status);return r.text()}async requestRawVoid(e,n,r){const s=await this.request(e,n,r,{"content-type":"text/plain"});if(!s.ok)throw this.createError(await Na(s,s.statusText),s.status)}createError(e,n){const r={serverURL:this.serverURL};return n!==void 0&&(r.status=n),new EE(e,r)}async request(e,n,r,s){const i=`${this.serverURL}${n}`;try{return await fetch(i,{method:e,headers:this.buildHeaders(s),body:r})}catch(o){throw this.createError(o instanceof Error?o.message:"Failed to reach server")}}buildHeaders(e){const n={...e??{}};return this.token&&(n.Authorization=`Bearer ${this.token}`),Object.keys(n).length>0?n:void 0}}async function TE(t){try{return await t.json()}catch{const e=await t.text().catch(()=>"");return e?{message:e}:{}}}async function Na(t,e){try{const n=await t.json();if(typeof n.error=="string")return n.error;if(typeof n.message=="string")return n.message}catch{}return e}function Af(t){return t.map(e=>`${e.name} (${e.id})`).join(", ")}var mt,Eo,xf;class CE{constructor(e){$(this,Eo);$(this,mt);x(this,mt,e)}list(){return u(this,mt).requestJSON("GET","/screens")}async get(e={}){const n=await b(this,Eo,xf).call(this,e.screenID);return u(this,mt).requestJSON("GET",`/screens/${encodeURIComponent(n)}`)}create(e){const n={name:e.name};return e.id!==void 0&&(n.id=e.id),u(this,mt).requestJSON("POST","/screens",n)}update(e){const n={};return e.name!==void 0&&(n.name=e.name),e.layout!==void 0&&(n.layout=e.layout),u(this,mt).requestJSON("PATCH",`/screens/${encodeURIComponent(e.screenID)}`,n)}remove(e){return u(this,mt).requestJSON("DELETE",`/screens/${encodeURIComponent(e.screenID)}`)}}mt=new WeakMap,Eo=new WeakSet,xf=async function(e){if(e!==void 0)return e;const{screens:n}=await this.list();if(n.length===1)return n[0].id;throw u(this,mt).createError(`screenID is required when multiple screens exist. Available screens: ${Af(n)}`)};var Ne,Ds,$o,Tf;class IE{constructor(e,n){$(this,$o);$(this,Ne);$(this,Ds);x(this,Ne,e),x(this,Ds,n)}async create(e){const n=await b(this,$o,Tf).call(this,e.screenID);return u(this,Ne).requestJSON("POST",`/screens/${encodeURIComponent(n)}/artifact`,{type:e.type,title:e.title,externalFilePath:e.externalFilePath})}get(e){return u(this,Ne).requestJSON("GET",`/artifacts/${encodeURIComponent(e.artifactID)}`)}update(e){const n={};return e.title!==void 0&&(n.title=e.title),u(this,Ne).requestJSON("PATCH",`/artifacts/${encodeURIComponent(e.artifactID)}`,n)}edit(e){return u(this,Ne).requestJSON("POST",`/artifacts/${encodeURIComponent(e.artifactID)}/edit`)}commitPending(e){return u(this,Ne).requestJSON("POST",`/artifacts/${encodeURIComponent(e.artifactID)}/commit`)}abandonPending(e){return u(this,Ne).requestVoid("POST",`/artifacts/${encodeURIComponent(e.artifactID)}/abandon`)}remove(e){return u(this,Ne).requestJSON("DELETE",`/screens/${encodeURIComponent(e.screenID)}/artifacts/${encodeURIComponent(e.artifactID)}`)}getContent(e){return u(this,Ne).requestText("GET",`/artifacts/${encodeURIComponent(e.artifactID)}/content`)}putContent(e){return u(this,Ne).requestRawVoid("PUT",`/artifacts/${encodeURIComponent(e.artifactID)}/content`,e.content)}}Ne=new WeakMap,Ds=new WeakMap,$o=new WeakSet,Tf=async function(e){if(e!==void 0)return e;const{screens:n}=await u(this,Ds).list();if(n.length===1)return n[0].id;throw u(this,Ne).createError(`screenID is required when multiple screens exist. Available screens: ${Af(n)}`)};var Os;class PE{constructor(e){$(this,Os);x(this,Os,e)}async list(){const{views:e}=await u(this,Os).requestJSON("GET","/views");return e}}Os=new WeakMap;var Vt;class RE{constructor(e,n={}){v(this,"screens");v(this,"artifacts");v(this,"views");$(this,Vt);x(this,Vt,new xE(e,n)),this.screens=new CE(u(this,Vt)),this.artifacts=new IE(u(this,Vt),this.screens),this.views=new PE(u(this,Vt))}health(){return u(this,Vt).requestJSON("GET","/health")}}Vt=new WeakMap;const DE=Hr(kt);var Cn,Ue,In,De,Ht,qt,Q,ur,Cf,zs,If,Pf,Rf,Df,pl,fl,gl,Of;class OE extends DE{constructor(n){var s;super();$(this,Q);v(this,"id");v(this,"server");$(this,Cn);$(this,Ue,new Map);$(this,In);$(this,De);$(this,Ht);$(this,qt,null);$(this,zs,n=>{if(this.disposed)return;const r=n.event;switch(r.type){case"screen-updated":r.screen.id===this.id&&b(this,Q,If).call(this,r.screen);break;case"artifact-created":r.screenID===this.id&&b(this,Q,Pf).call(this,r.artifact);break;case"artifact-updated":b(this,Q,Rf).call(this,r.artifact);break;case"artifact-removed":r.screenID===this.id&&b(this,Q,Df).call(this,r.artifactID);break;case"artifact-content-changed":u(this,Ue).has(r.artifactID)&&this.dispatchEvent(new SE("artifact-content-changed",{artifactID:r.artifactID}));break}});this.id=n.screen.id,this.server=n.server,x(this,Cn,n.localStore),x(this,In,n.screen.name),x(this,De,structuredClone(n.screen.layout));const r=((s=u(this,Cn).get().screens[this.id])==null?void 0:s.scrollPosition)??0;x(this,Ht,Math.max(0,r)),this.server.addEventListener("server-event",u(this,zs)),b(this,Q,Cf).call(this)}get name(){return u(this,In)}get layout(){return u(this,De)}get scrollPosition(){return u(this,Ht)}get artifacts(){return u(this,Ue)}setScrollPosition(n){b(this,Q,ur).call(this);const r=Math.max(0,n);r!==u(this,Ht)&&(x(this,Ht,r),b(this,Q,Of).call(this),this.dispatchEvent(new te("change")))}setLayout(n){b(this,Q,ur).call(this);const r=hf(n);if(!pf(r).valid)return;const i=b(this,Q,fl).call(this);x(this,De,r),x(this,qt,{layout:r,snapshot:i}),this.dispatchEvent(new te("change")),this.server.client.screens.update({screenID:this.id,layout:r.map(o=>structuredClone(o))}).catch(()=>{var o;this.disposed||((o=u(this,qt))==null?void 0:o.layout)===r&&(x(this,qt,null),b(this,Q,gl).call(this,i),this.dispatchEvent(new te("change")))})}rename(n){b(this,Q,ur).call(this),x(this,In,n),this.dispatchEvent(new te("change")),this.server.client.screens.update({screenID:this.id,name:n}).catch(()=>{})}async remove(){b(this,Q,ur).call(this),await this.server.client.screens.remove({screenID:this.id})}removeArtifact(n){if(b(this,Q,ur).call(this),!u(this,Ue).has(n))return;const r=b(this,Q,fl).call(this);b(this,Q,pl).call(this,n),this.dispatchEvent(new te("change")),this.server.client.artifacts.remove({artifactID:n,screenID:this.id}).catch(()=>{this.disposed||(b(this,Q,gl).call(this,r),this.dispatchEvent(new te("change")))})}dispose(){this.server.removeEventListener("server-event",u(this,zs))}}Cn=new WeakMap,Ue=new WeakMap,In=new WeakMap,De=new WeakMap,Ht=new WeakMap,qt=new WeakMap,Q=new WeakSet,ur=function(){if(this.disposed)throw new Error("ScreenModel is disposed")},Cf=async function(){try{const n=await this.server.client.screens.get({screenID:this.id});if(this.disposed)return;for(const r of n.artifacts)u(this,Ue).set(r.id,r);this.dispatchEvent(new te("change"))}catch{}},zs=new WeakMap,If=function(n){u(this,qt)&&x(this,qt,null),x(this,In,n.name),x(this,De,structuredClone(n.layout)),this.dispatchEvent(new te("change"))},Pf=function(n){Sf(u(this,De),n.id)||x(this,De,[...u(this,De),_f(n.id)]),u(this,Ue).set(n.id,n),this.dispatchEvent(new te("change"))},Rf=function(n){const r=u(this,Ue).get(n.id);r&&(u(this,Ue).set(n.id,{...r,...n}),this.dispatchEvent(new te("change")))},Df=function(n){b(this,Q,pl).call(this,n)&&this.dispatchEvent(new te("change"))},pl=function(n){const r=u(this,Ue).delete(n),s=Qh({layout:u(this,De)}).length,i=df(u(this,De),n),o=Qh({layout:i}).length;return x(this,De,i),r||s!==o},fl=function(){return{layout:structuredClone(u(this,De)),artifacts:new Map([...u(this,Ue).entries()].map(([n,r])=>[n,structuredClone(r)]))}},gl=function(n){x(this,De,structuredClone(n.layout)),u(this,Ue).clear();for(const[r,s]of n.artifacts)u(this,Ue).set(r,structuredClone(s))},Of=function(){const n=u(this,Cn).get();u(this,Cn).set({...n,screens:{...n.screens,[this.id]:{scrollPosition:u(this,Ht)}}})};const zE=Hr(kt);var Fe,vt,nt,Ls,Ms,Ns,nn,to,zf;class LE extends zE{constructor(n){super();$(this,nn);$(this,Fe);$(this,vt);$(this,nt,null);$(this,Ls,()=>{this.disposed||b(this,nn,to).call(this)});$(this,Ms,()=>{this.disposed||b(this,nn,to).call(this)});$(this,Ns,n=>{var s;if(this.disposed)return;const r=n.event;r.type==="screen-removed"&&((s=u(this,nt))==null?void 0:s.id)===r.screenID&&this.clearActive()});x(this,Fe,n.localStore),x(this,vt,n.serverManager),u(this,Fe).addEventListener("change",u(this,Ls)),u(this,vt).addEventListener("change",u(this,Ms)),u(this,vt).addEventListener("server-event",u(this,Ns)),b(this,nn,to).call(this)}get activeScreen(){return u(this,nt)}setActive(n,r){const s=u(this,Fe).get();s.activeServerURL===n&&s.activeScreenID===r||u(this,Fe).set({...s,activeServerURL:n,activeScreenID:r})}clearActive(){const n=u(this,Fe).get();n.activeServerURL===null&&n.activeScreenID===null||u(this,Fe).set({...n,activeServerURL:null,activeScreenID:null})}dispose(){var n;u(this,Fe).removeEventListener("change",u(this,Ls)),u(this,vt).removeEventListener("change",u(this,Ms)),u(this,vt).removeEventListener("server-event",u(this,Ns)),(n=u(this,nt))==null||n.dispose(),x(this,nt,null)}}Fe=new WeakMap,vt=new WeakMap,nt=new WeakMap,Ls=new WeakMap,Ms=new WeakMap,Ns=new WeakMap,nn=new WeakSet,to=function(){var l,c,d;const{activeServerURL:n,activeScreenID:r}=u(this,Fe).get();let s=n?u(this,vt).servers.get(n)??null:null,i=s&&r?s.screens.get(r)??null:null;if(!i){const p=b(this,nn,zf).call(this);if(p){s=p.server,i=p.screen,u(this,Fe).set({...u(this,Fe).get(),activeServerURL:p.server.url,activeScreenID:p.screen.id});return}}const o=((l=u(this,nt))==null?void 0:l.id)??null,a=(i==null?void 0:i.id)??null;o===a&&((c=u(this,nt))==null?void 0:c.server)===s||((d=u(this,nt))==null||d.dispose(),x(this,nt,s&&i?new OE({screen:i,server:s,localStore:u(this,Fe)}):null),this.dispatchEvent(new rE("active-screen-changed")))},zf=function(){for(const n of u(this,vt).servers.values()){const r=n.screens.values().next().value;if(r)return{server:n,screen:r}}return null};const ME="Local",NE="store-";function Pt(t){return new URL(t).origin}function UE(t){return{servers:[{url:Pt(t),name:ME}],activeServerURL:null,activeScreenID:null,screens:{}}}var Pn,Rn,Dn;class FE extends kt{constructor(n,r,s={}){super();$(this,Pn);$(this,Rn);$(this,Dn);x(this,Pn,`${NE}${n}`),x(this,Rn,s.storage??ZE());const i=u(this,Rn).getItem(u(this,Pn));i===null?(x(this,Dn,r),u(this,Rn).setItem(u(this,Pn),JSON.stringify(r))):x(this,Dn,JSON.parse(i))}get(){return u(this,Dn)}set(n){x(this,Dn,n),u(this,Rn).setItem(u(this,Pn),JSON.stringify(n)),this.dispatchEvent(new te("change"))}}Pn=new WeakMap,Rn=new WeakMap,Dn=new WeakMap;function ZE(){const t=globalThis.localStorage;if(!t)throw new Error("LocalStore: no storage adapter supplied and window.localStorage is unavailable");return t}function S(t,e,n){function r(a,l){if(a._zod||Object.defineProperty(a,"_zod",{value:{def:l,constr:o,traits:new Set},enumerable:!1}),a._zod.traits.has(t))return;a._zod.traits.add(t),e(a,l);const c=o.prototype,d=Object.keys(c);for(let p=0;p<d.length;p++){const y=d[p];y in a||(a[y]=c[y].bind(a))}}const s=(n==null?void 0:n.Parent)??Object;class i extends s{}Object.defineProperty(i,"name",{value:t});function o(a){var l;const c=n!=null&&n.Parent?new i:this;r(c,a),(l=c._zod).deferred??(l.deferred=[]);for(const d of c._zod.deferred)d();return c}return Object.defineProperty(o,"init",{value:r}),Object.defineProperty(o,Symbol.hasInstance,{value:a=>{var l,c;return n!=null&&n.Parent&&a instanceof n.Parent?!0:(c=(l=a==null?void 0:a._zod)==null?void 0:l.traits)==null?void 0:c.has(t)}}),Object.defineProperty(o,"name",{value:t}),o}class _r extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class Lf extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name="ZodEncodeError"}}const Mf={};function on(t){return Mf}function Nf(t){const e=Object.values(t).filter(r=>typeof r=="number");return Object.entries(t).filter(([r,s])=>e.indexOf(+r)===-1).map(([r,s])=>s)}function ml(t,e){return typeof e=="bigint"?e.toString():e}function Tc(t){return{get value(){{const e=t();return Object.defineProperty(this,"value",{value:e}),e}}}}function Cc(t){return t==null}function Ic(t){const e=t.startsWith("^")?1:0,n=t.endsWith("$")?t.length-1:t.length;return t.slice(e,n)}function jE(t,e){const n=(t.toString().split(".")[1]||"").length,r=e.toString();let s=(r.split(".")[1]||"").length;if(s===0&&/\d?e-\d?/.test(r)){const l=r.match(/\d?e-(\d?)/);l!=null&&l[1]&&(s=Number.parseInt(l[1]))}const i=n>s?n:s,o=Number.parseInt(t.toFixed(i).replace(".","")),a=Number.parseInt(e.toFixed(i).replace(".",""));return o%a/10**i}const ed=Symbol("evaluating");function ee(t,e,n){let r;Object.defineProperty(t,e,{get(){if(r!==ed)return r===void 0&&(r=ed,r=n()),r},set(s){Object.defineProperty(t,e,{value:s})},configurable:!0})}function Jn(t,e,n){Object.defineProperty(t,e,{value:n,writable:!0,enumerable:!0,configurable:!0})}function pn(...t){const e={};for(const n of t){const r=Object.getOwnPropertyDescriptors(n);Object.assign(e,r)}return Object.defineProperties({},e)}function td(t){return JSON.stringify(t)}function WE(t){return t.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}const Uf="captureStackTrace"in Error?Error.captureStackTrace:(...t)=>{};function fo(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}const BE=Tc(()=>{var t;if(typeof navigator<"u"&&((t=navigator==null?void 0:navigator.userAgent)!=null&&t.includes("Cloudflare")))return!1;try{const e=Function;return new e(""),!0}catch{return!1}});function zr(t){if(fo(t)===!1)return!1;const e=t.constructor;if(e===void 0||typeof e!="function")return!0;const n=e.prototype;return!(fo(n)===!1||Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")===!1)}function Ff(t){return zr(t)?{...t}:Array.isArray(t)?[...t]:t}const GE=new Set(["string","number","symbol"]);function Lr(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function fn(t,e,n){const r=new t._zod.constr(e??t._zod.def);return(!e||n!=null&&n.parent)&&(r._zod.parent=t),r}function O(t){const e=t;if(!e)return{};if(typeof e=="string")return{error:()=>e};if((e==null?void 0:e.message)!==void 0){if((e==null?void 0:e.error)!==void 0)throw new Error("Cannot specify both `message` and `error` params");e.error=e.message}return delete e.message,typeof e.error=="string"?{...e,error:()=>e.error}:e}function VE(t){return Object.keys(t).filter(e=>t[e]._zod.optin==="optional"&&t[e]._zod.optout==="optional")}const HE={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 qE(t,e){const n=t._zod.def,r=n.checks;if(r&&r.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");const i=pn(t._zod.def,{get shape(){const o={};for(const a in e){if(!(a in n.shape))throw new Error(`Unrecognized key: "${a}"`);e[a]&&(o[a]=n.shape[a])}return Jn(this,"shape",o),o},checks:[]});return fn(t,i)}function YE(t,e){const n=t._zod.def,r=n.checks;if(r&&r.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");const i=pn(t._zod.def,{get shape(){const o={...t._zod.def.shape};for(const a in e){if(!(a in n.shape))throw new Error(`Unrecognized key: "${a}"`);e[a]&&delete o[a]}return Jn(this,"shape",o),o},checks:[]});return fn(t,i)}function KE(t,e){if(!zr(e))throw new Error("Invalid input to extend: expected a plain object");const n=t._zod.def.checks;if(n&&n.length>0){const i=t._zod.def.shape;for(const o in e)if(Object.getOwnPropertyDescriptor(i,o)!==void 0)throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}const s=pn(t._zod.def,{get shape(){const i={...t._zod.def.shape,...e};return Jn(this,"shape",i),i}});return fn(t,s)}function JE(t,e){if(!zr(e))throw new Error("Invalid input to safeExtend: expected a plain object");const n=pn(t._zod.def,{get shape(){const r={...t._zod.def.shape,...e};return Jn(this,"shape",r),r}});return fn(t,n)}function XE(t,e){const n=pn(t._zod.def,{get shape(){const r={...t._zod.def.shape,...e._zod.def.shape};return Jn(this,"shape",r),r},get catchall(){return e._zod.def.catchall},checks:[]});return fn(t,n)}function QE(t,e,n){const s=e._zod.def.checks;if(s&&s.length>0)throw new Error(".partial() cannot be used on object schemas containing refinements");const o=pn(e._zod.def,{get shape(){const a=e._zod.def.shape,l={...a};if(n)for(const c in n){if(!(c in a))throw new Error(`Unrecognized key: "${c}"`);n[c]&&(l[c]=t?new t({type:"optional",innerType:a[c]}):a[c])}else for(const c in a)l[c]=t?new t({type:"optional",innerType:a[c]}):a[c];return Jn(this,"shape",l),l},checks:[]});return fn(e,o)}function e$(t,e,n){const r=pn(e._zod.def,{get shape(){const s=e._zod.def.shape,i={...s};if(n)for(const o in n){if(!(o in i))throw new Error(`Unrecognized key: "${o}"`);n[o]&&(i[o]=new t({type:"nonoptional",innerType:s[o]}))}else for(const o in s)i[o]=new t({type:"nonoptional",innerType:s[o]});return Jn(this,"shape",i),i}});return fn(e,r)}function yr(t,e=0){var n;if(t.aborted===!0)return!0;for(let r=e;r<t.issues.length;r++)if(((n=t.issues[r])==null?void 0:n.continue)!==!0)return!0;return!1}function br(t,e){return e.map(n=>{var r;return(r=n).path??(r.path=[]),n.path.unshift(t),n})}function Mi(t){return typeof t=="string"?t:t==null?void 0:t.message}function an(t,e,n){var s,i,o,a,l,c;const r={...t,path:t.path??[]};if(!t.message){const d=Mi((o=(i=(s=t.inst)==null?void 0:s._zod.def)==null?void 0:i.error)==null?void 0:o.call(i,t))??Mi((a=e==null?void 0:e.error)==null?void 0:a.call(e,t))??Mi((l=n.customError)==null?void 0:l.call(n,t))??Mi((c=n.localeError)==null?void 0:c.call(n,t))??"Invalid input";r.message=d}return delete r.inst,delete r.continue,e!=null&&e.reportInput||delete r.input,r}function Pc(t){return Array.isArray(t)?"array":typeof t=="string"?"string":"unknown"}function Ts(...t){const[e,n,r]=t;return typeof e=="string"?{message:e,code:"custom",input:n,inst:r}:{...e}}const Zf=(t,e)=>{t.name="$ZodError",Object.defineProperty(t,"_zod",{value:t._zod,enumerable:!1}),Object.defineProperty(t,"issues",{value:e,enumerable:!1}),t.message=JSON.stringify(e,ml,2),Object.defineProperty(t,"toString",{value:()=>t.message,enumerable:!1})},jf=S("$ZodError",Zf),Wf=S("$ZodError",Zf,{Parent:Error});function t$(t,e=n=>n.message){const n={},r=[];for(const s of t.issues)s.path.length>0?(n[s.path[0]]=n[s.path[0]]||[],n[s.path[0]].push(e(s))):r.push(e(s));return{formErrors:r,fieldErrors:n}}function n$(t,e=n=>n.message){const n={_errors:[]},r=s=>{for(const i of s.issues)if(i.code==="invalid_union"&&i.errors.length)i.errors.map(o=>r({issues:o}));else if(i.code==="invalid_key")r({issues:i.issues});else if(i.code==="invalid_element")r({issues:i.issues});else if(i.path.length===0)n._errors.push(e(i));else{let o=n,a=0;for(;a<i.path.length;){const l=i.path[a];a===i.path.length-1?(o[l]=o[l]||{_errors:[]},o[l]._errors.push(e(i))):o[l]=o[l]||{_errors:[]},o=o[l],a++}}};return r(t),n}const Rc=t=>(e,n,r,s)=>{const i=r?Object.assign(r,{async:!1}):{async:!1},o=e._zod.run({value:n,issues:[]},i);if(o instanceof Promise)throw new _r;if(o.issues.length){const a=new((s==null?void 0:s.Err)??t)(o.issues.map(l=>an(l,i,on())));throw Uf(a,s==null?void 0:s.callee),a}return o.value},Dc=t=>async(e,n,r,s)=>{const i=r?Object.assign(r,{async:!0}):{async:!0};let o=e._zod.run({value:n,issues:[]},i);if(o instanceof Promise&&(o=await o),o.issues.length){const a=new((s==null?void 0:s.Err)??t)(o.issues.map(l=>an(l,i,on())));throw Uf(a,s==null?void 0:s.callee),a}return o.value},Zo=t=>(e,n,r)=>{const s=r?{...r,async:!1}:{async:!1},i=e._zod.run({value:n,issues:[]},s);if(i instanceof Promise)throw new _r;return i.issues.length?{success:!1,error:new(t??jf)(i.issues.map(o=>an(o,s,on())))}:{success:!0,data:i.value}},r$=Zo(Wf),jo=t=>async(e,n,r)=>{const s=r?Object.assign(r,{async:!0}):{async:!0};let i=e._zod.run({value:n,issues:[]},s);return i instanceof Promise&&(i=await i),i.issues.length?{success:!1,error:new t(i.issues.map(o=>an(o,s,on())))}:{success:!0,data:i.value}},s$=jo(Wf),i$=t=>(e,n,r)=>{const s=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return Rc(t)(e,n,s)},o$=t=>(e,n,r)=>Rc(t)(e,n,r),a$=t=>async(e,n,r)=>{const s=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return Dc(t)(e,n,s)},l$=t=>async(e,n,r)=>Dc(t)(e,n,r),c$=t=>(e,n,r)=>{const s=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return Zo(t)(e,n,s)},u$=t=>(e,n,r)=>Zo(t)(e,n,r),h$=t=>async(e,n,r)=>{const s=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return jo(t)(e,n,s)},d$=t=>async(e,n,r)=>jo(t)(e,n,r),p$=/^[cC][^\s-]{8,}$/,f$=/^[0-9a-z]+$/,g$=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,m$=/^[0-9a-vA-V]{20}$/,v$=/^[A-Za-z0-9]{27}$/,y$=/^[a-zA-Z0-9_-]{21}$/,b$=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,w$=/^([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})$/,nd=t=>t?new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${t}[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)$/,_$=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,S$="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function k$(){return new RegExp(S$,"u")}const E$=/^(?:(?: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-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}|:))$/,A$=/^((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])$/,x$=/^(([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])$/,T$=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Bf=/^[A-Za-z0-9_-]*$/,C$=/^\+[1-9]\d{6,14}$/,Gf="(?:(?:\\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])))",I$=new RegExp(`^${Gf}$`);function Vf(t){const e="(?:[01]\\d|2[0-3]):[0-5]\\d";return typeof t.precision=="number"?t.precision===-1?`${e}`:t.precision===0?`${e}:[0-5]\\d`:`${e}:[0-5]\\d\\.\\d{${t.precision}}`:`${e}(?::[0-5]\\d(?:\\.\\d+)?)?`}function P$(t){return new RegExp(`^${Vf(t)}$`)}function R$(t){const e=Vf({precision:t.precision}),n=["Z"];t.local&&n.push(""),t.offset&&n.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");const r=`${e}(?:${n.join("|")})`;return new RegExp(`^${Gf}T(?:${r})$`)}const D$=t=>{const e=t?`[\\s\\S]{${(t==null?void 0:t.minimum)??0},${(t==null?void 0:t.maximum)??""}}`:"[\\s\\S]*";return new RegExp(`^${e}$`)},O$=/^-?\d+$/,Hf=/^-?\d+(?:\.\d+)?$/,z$=/^(?:true|false)$/i,L$=/^[^A-Z]*$/,M$=/^[^a-z]*$/,We=S("$ZodCheck",(t,e)=>{var n;t._zod??(t._zod={}),t._zod.def=e,(n=t._zod).onattach??(n.onattach=[])}),qf={number:"number",bigint:"bigint",object:"date"},Yf=S("$ZodCheckLessThan",(t,e)=>{We.init(t,e);const n=qf[typeof e.value];t._zod.onattach.push(r=>{const s=r._zod.bag,i=(e.inclusive?s.maximum:s.exclusiveMaximum)??Number.POSITIVE_INFINITY;e.value<i&&(e.inclusive?s.maximum=e.value:s.exclusiveMaximum=e.value)}),t._zod.check=r=>{(e.inclusive?r.value<=e.value:r.value<e.value)||r.issues.push({origin:n,code:"too_big",maximum:typeof e.value=="object"?e.value.getTime():e.value,input:r.value,inclusive:e.inclusive,inst:t,continue:!e.abort})}}),Kf=S("$ZodCheckGreaterThan",(t,e)=>{We.init(t,e);const n=qf[typeof e.value];t._zod.onattach.push(r=>{const s=r._zod.bag,i=(e.inclusive?s.minimum:s.exclusiveMinimum)??Number.NEGATIVE_INFINITY;e.value>i&&(e.inclusive?s.minimum=e.value:s.exclusiveMinimum=e.value)}),t._zod.check=r=>{(e.inclusive?r.value>=e.value:r.value>e.value)||r.issues.push({origin:n,code:"too_small",minimum:typeof e.value=="object"?e.value.getTime():e.value,input:r.value,inclusive:e.inclusive,inst:t,continue:!e.abort})}}),N$=S("$ZodCheckMultipleOf",(t,e)=>{We.init(t,e),t._zod.onattach.push(n=>{var r;(r=n._zod.bag).multipleOf??(r.multipleOf=e.value)}),t._zod.check=n=>{if(typeof n.value!=typeof e.value)throw new Error("Cannot mix number and bigint in multiple_of check.");(typeof n.value=="bigint"?n.value%e.value===BigInt(0):jE(n.value,e.value)===0)||n.issues.push({origin:typeof n.value,code:"not_multiple_of",divisor:e.value,input:n.value,inst:t,continue:!e.abort})}}),U$=S("$ZodCheckNumberFormat",(t,e)=>{var o;We.init(t,e),e.format=e.format||"float64";const n=(o=e.format)==null?void 0:o.includes("int"),r=n?"int":"number",[s,i]=HE[e.format];t._zod.onattach.push(a=>{const l=a._zod.bag;l.format=e.format,l.minimum=s,l.maximum=i,n&&(l.pattern=O$)}),t._zod.check=a=>{const l=a.value;if(n){if(!Number.isInteger(l)){a.issues.push({expected:r,format:e.format,code:"invalid_type",continue:!1,input:l,inst:t});return}if(!Number.isSafeInteger(l)){l>0?a.issues.push({input:l,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:t,origin:r,inclusive:!0,continue:!e.abort}):a.issues.push({input:l,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:t,origin:r,inclusive:!0,continue:!e.abort});return}}l<s&&a.issues.push({origin:"number",input:l,code:"too_small",minimum:s,inclusive:!0,inst:t,continue:!e.abort}),l>i&&a.issues.push({origin:"number",input:l,code:"too_big",maximum:i,inclusive:!0,inst:t,continue:!e.abort})}}),F$=S("$ZodCheckMaxLength",(t,e)=>{var n;We.init(t,e),(n=t._zod.def).when??(n.when=r=>{const s=r.value;return!Cc(s)&&s.length!==void 0}),t._zod.onattach.push(r=>{const s=r._zod.bag.maximum??Number.POSITIVE_INFINITY;e.maximum<s&&(r._zod.bag.maximum=e.maximum)}),t._zod.check=r=>{const s=r.value;if(s.length<=e.maximum)return;const o=Pc(s);r.issues.push({origin:o,code:"too_big",maximum:e.maximum,inclusive:!0,input:s,inst:t,continue:!e.abort})}}),Z$=S("$ZodCheckMinLength",(t,e)=>{var n;We.init(t,e),(n=t._zod.def).when??(n.when=r=>{const s=r.value;return!Cc(s)&&s.length!==void 0}),t._zod.onattach.push(r=>{const s=r._zod.bag.minimum??Number.NEGATIVE_INFINITY;e.minimum>s&&(r._zod.bag.minimum=e.minimum)}),t._zod.check=r=>{const s=r.value;if(s.length>=e.minimum)return;const o=Pc(s);r.issues.push({origin:o,code:"too_small",minimum:e.minimum,inclusive:!0,input:s,inst:t,continue:!e.abort})}}),j$=S("$ZodCheckLengthEquals",(t,e)=>{var n;We.init(t,e),(n=t._zod.def).when??(n.when=r=>{const s=r.value;return!Cc(s)&&s.length!==void 0}),t._zod.onattach.push(r=>{const s=r._zod.bag;s.minimum=e.length,s.maximum=e.length,s.length=e.length}),t._zod.check=r=>{const s=r.value,i=s.length;if(i===e.length)return;const o=Pc(s),a=i>e.length;r.issues.push({origin:o,...a?{code:"too_big",maximum:e.length}:{code:"too_small",minimum:e.length},inclusive:!0,exact:!0,input:r.value,inst:t,continue:!e.abort})}}),Wo=S("$ZodCheckStringFormat",(t,e)=>{var n,r;We.init(t,e),t._zod.onattach.push(s=>{const i=s._zod.bag;i.format=e.format,e.pattern&&(i.patterns??(i.patterns=new Set),i.patterns.add(e.pattern))}),e.pattern?(n=t._zod).check??(n.check=s=>{e.pattern.lastIndex=0,!e.pattern.test(s.value)&&s.issues.push({origin:"string",code:"invalid_format",format:e.format,input:s.value,...e.pattern?{pattern:e.pattern.toString()}:{},inst:t,continue:!e.abort})}):(r=t._zod).check??(r.check=()=>{})}),W$=S("$ZodCheckRegex",(t,e)=>{Wo.init(t,e),t._zod.check=n=>{e.pattern.lastIndex=0,!e.pattern.test(n.value)&&n.issues.push({origin:"string",code:"invalid_format",format:"regex",input:n.value,pattern:e.pattern.toString(),inst:t,continue:!e.abort})}}),B$=S("$ZodCheckLowerCase",(t,e)=>{e.pattern??(e.pattern=L$),Wo.init(t,e)}),G$=S("$ZodCheckUpperCase",(t,e)=>{e.pattern??(e.pattern=M$),Wo.init(t,e)}),V$=S("$ZodCheckIncludes",(t,e)=>{We.init(t,e);const n=Lr(e.includes),r=new RegExp(typeof e.position=="number"?`^.{${e.position}}${n}`:n);e.pattern=r,t._zod.onattach.push(s=>{const i=s._zod.bag;i.patterns??(i.patterns=new Set),i.patterns.add(r)}),t._zod.check=s=>{s.value.includes(e.includes,e.position)||s.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:e.includes,input:s.value,inst:t,continue:!e.abort})}}),H$=S("$ZodCheckStartsWith",(t,e)=>{We.init(t,e);const n=new RegExp(`^${Lr(e.prefix)}.*`);e.pattern??(e.pattern=n),t._zod.onattach.push(r=>{const s=r._zod.bag;s.patterns??(s.patterns=new Set),s.patterns.add(n)}),t._zod.check=r=>{r.value.startsWith(e.prefix)||r.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:e.prefix,input:r.value,inst:t,continue:!e.abort})}}),q$=S("$ZodCheckEndsWith",(t,e)=>{We.init(t,e);const n=new RegExp(`.*${Lr(e.suffix)}$`);e.pattern??(e.pattern=n),t._zod.onattach.push(r=>{const s=r._zod.bag;s.patterns??(s.patterns=new Set),s.patterns.add(n)}),t._zod.check=r=>{r.value.endsWith(e.suffix)||r.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:e.suffix,input:r.value,inst:t,continue:!e.abort})}}),Y$=S("$ZodCheckOverwrite",(t,e)=>{We.init(t,e),t._zod.check=n=>{n.value=e.tx(n.value)}});class K${constructor(e=[]){this.content=[],this.indent=0,this&&(this.args=e)}indented(e){this.indent+=1,e(this),this.indent-=1}write(e){if(typeof e=="function"){e(this,{execution:"sync"}),e(this,{execution:"async"});return}const r=e.split(`
|
|
5
5
|
`).filter(o=>o),s=Math.min(...r.map(o=>o.length-o.trimStart().length)),i=r.map(o=>o.slice(s)).map(o=>" ".repeat(this.indent*2)+o);for(const o of i)this.content.push(o)}compile(){const e=Function,n=this==null?void 0:this.args,s=[...((this==null?void 0:this.content)??[""]).map(i=>` ${i}`)];return new e(...n,s.join(`
|
|
6
|
-
`))}}const
|
|
6
|
+
`))}}const J$={major:4,minor:3,patch:6},le=S("$ZodType",(t,e)=>{var s;var n;t??(t={}),t._zod.def=e,t._zod.bag=t._zod.bag||{},t._zod.version=J$;const r=[...t._zod.def.checks??[]];t._zod.traits.has("$ZodCheck")&&r.unshift(t);for(const i of r)for(const o of i._zod.onattach)o(t);if(r.length===0)(n=t._zod).deferred??(n.deferred=[]),(s=t._zod.deferred)==null||s.push(()=>{t._zod.run=t._zod.parse});else{const i=(a,l,c)=>{let d=yr(a),p;for(const y of l){if(y._zod.def.when){if(!y._zod.def.when(a))continue}else if(d)continue;const m=a.issues.length,E=y._zod.check(a);if(E instanceof Promise&&(c==null?void 0:c.async)===!1)throw new _r;if(p||E instanceof Promise)p=(p??Promise.resolve()).then(async()=>{await E,a.issues.length!==m&&(d||(d=yr(a,m)))});else{if(a.issues.length===m)continue;d||(d=yr(a,m))}}return p?p.then(()=>a):a},o=(a,l,c)=>{if(yr(a))return a.aborted=!0,a;const d=i(l,r,c);if(d instanceof Promise){if(c.async===!1)throw new _r;return d.then(p=>t._zod.parse(p,c))}return t._zod.parse(d,c)};t._zod.run=(a,l)=>{if(l.skipChecks)return t._zod.parse(a,l);if(l.direction==="backward"){const d=t._zod.parse({value:a.value,issues:[]},{...l,skipChecks:!0});return d instanceof Promise?d.then(p=>o(p,a,l)):o(d,a,l)}const c=t._zod.parse(a,l);if(c instanceof Promise){if(l.async===!1)throw new _r;return c.then(d=>i(d,r,l))}return i(c,r,l)}}ee(t,"~standard",()=>({validate:i=>{var o;try{const a=r$(t,i);return a.success?{value:a.data}:{issues:(o=a.error)==null?void 0:o.issues}}catch{return s$(t,i).then(l=>{var c;return l.success?{value:l.data}:{issues:(c=l.error)==null?void 0:c.issues}})}},vendor:"zod",version:1}))}),Oc=S("$ZodString",(t,e)=>{var n;le.init(t,e),t._zod.pattern=[...((n=t==null?void 0:t._zod.bag)==null?void 0:n.patterns)??[]].pop()??D$(t._zod.bag),t._zod.parse=(r,s)=>{if(e.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:t}),r}}),oe=S("$ZodStringFormat",(t,e)=>{Wo.init(t,e),Oc.init(t,e)}),X$=S("$ZodGUID",(t,e)=>{e.pattern??(e.pattern=w$),oe.init(t,e)}),Q$=S("$ZodUUID",(t,e)=>{if(e.version){const r={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[e.version];if(r===void 0)throw new Error(`Invalid UUID version: "${e.version}"`);e.pattern??(e.pattern=nd(r))}else e.pattern??(e.pattern=nd());oe.init(t,e)}),eA=S("$ZodEmail",(t,e)=>{e.pattern??(e.pattern=_$),oe.init(t,e)}),tA=S("$ZodURL",(t,e)=>{oe.init(t,e),t._zod.check=n=>{try{const r=n.value.trim(),s=new URL(r);e.hostname&&(e.hostname.lastIndex=0,e.hostname.test(s.hostname)||n.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:e.hostname.source,input:n.value,inst:t,continue:!e.abort})),e.protocol&&(e.protocol.lastIndex=0,e.protocol.test(s.protocol.endsWith(":")?s.protocol.slice(0,-1):s.protocol)||n.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:e.protocol.source,input:n.value,inst:t,continue:!e.abort})),e.normalize?n.value=s.href:n.value=r;return}catch{n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:t,continue:!e.abort})}}}),nA=S("$ZodEmoji",(t,e)=>{e.pattern??(e.pattern=k$()),oe.init(t,e)}),rA=S("$ZodNanoID",(t,e)=>{e.pattern??(e.pattern=y$),oe.init(t,e)}),sA=S("$ZodCUID",(t,e)=>{e.pattern??(e.pattern=p$),oe.init(t,e)}),iA=S("$ZodCUID2",(t,e)=>{e.pattern??(e.pattern=f$),oe.init(t,e)}),oA=S("$ZodULID",(t,e)=>{e.pattern??(e.pattern=g$),oe.init(t,e)}),aA=S("$ZodXID",(t,e)=>{e.pattern??(e.pattern=m$),oe.init(t,e)}),lA=S("$ZodKSUID",(t,e)=>{e.pattern??(e.pattern=v$),oe.init(t,e)}),cA=S("$ZodISODateTime",(t,e)=>{e.pattern??(e.pattern=R$(e)),oe.init(t,e)}),uA=S("$ZodISODate",(t,e)=>{e.pattern??(e.pattern=I$),oe.init(t,e)}),hA=S("$ZodISOTime",(t,e)=>{e.pattern??(e.pattern=P$(e)),oe.init(t,e)}),dA=S("$ZodISODuration",(t,e)=>{e.pattern??(e.pattern=b$),oe.init(t,e)}),pA=S("$ZodIPv4",(t,e)=>{e.pattern??(e.pattern=E$),oe.init(t,e),t._zod.bag.format="ipv4"}),fA=S("$ZodIPv6",(t,e)=>{e.pattern??(e.pattern=$$),oe.init(t,e),t._zod.bag.format="ipv6",t._zod.check=n=>{try{new URL(`http://[${n.value}]`)}catch{n.issues.push({code:"invalid_format",format:"ipv6",input:n.value,inst:t,continue:!e.abort})}}}),gA=S("$ZodCIDRv4",(t,e)=>{e.pattern??(e.pattern=A$),oe.init(t,e)}),mA=S("$ZodCIDRv6",(t,e)=>{e.pattern??(e.pattern=x$),oe.init(t,e),t._zod.check=n=>{const r=n.value.split("/");try{if(r.length!==2)throw new Error;const[s,i]=r;if(!i)throw new Error;const o=Number(i);if(`${o}`!==i)throw new Error;if(o<0||o>128)throw new Error;new URL(`http://[${s}]`)}catch{n.issues.push({code:"invalid_format",format:"cidrv6",input:n.value,inst:t,continue:!e.abort})}}});function Jf(t){if(t==="")return!0;if(t.length%4!==0)return!1;try{return atob(t),!0}catch{return!1}}const vA=S("$ZodBase64",(t,e)=>{e.pattern??(e.pattern=T$),oe.init(t,e),t._zod.bag.contentEncoding="base64",t._zod.check=n=>{Jf(n.value)||n.issues.push({code:"invalid_format",format:"base64",input:n.value,inst:t,continue:!e.abort})}});function yA(t){if(!Bf.test(t))return!1;const e=t.replace(/[-_]/g,r=>r==="-"?"+":"/"),n=e.padEnd(Math.ceil(e.length/4)*4,"=");return Jf(n)}const bA=S("$ZodBase64URL",(t,e)=>{e.pattern??(e.pattern=Bf),oe.init(t,e),t._zod.bag.contentEncoding="base64url",t._zod.check=n=>{yA(n.value)||n.issues.push({code:"invalid_format",format:"base64url",input:n.value,inst:t,continue:!e.abort})}}),wA=S("$ZodE164",(t,e)=>{e.pattern??(e.pattern=C$),oe.init(t,e)});function _A(t,e=null){try{const n=t.split(".");if(n.length!==3)return!1;const[r]=n;if(!r)return!1;const s=JSON.parse(atob(r));return!("typ"in s&&(s==null?void 0:s.typ)!=="JWT"||!s.alg||e&&(!("alg"in s)||s.alg!==e))}catch{return!1}}const SA=S("$ZodJWT",(t,e)=>{oe.init(t,e),t._zod.check=n=>{_A(n.value,e.alg)||n.issues.push({code:"invalid_format",format:"jwt",input:n.value,inst:t,continue:!e.abort})}}),Xf=S("$ZodNumber",(t,e)=>{le.init(t,e),t._zod.pattern=t._zod.bag.pattern??Hf,t._zod.parse=(n,r)=>{if(e.coerce)try{n.value=Number(n.value)}catch{}const s=n.value;if(typeof s=="number"&&!Number.isNaN(s)&&Number.isFinite(s))return n;const i=typeof s=="number"?Number.isNaN(s)?"NaN":Number.isFinite(s)?void 0:"Infinity":void 0;return n.issues.push({expected:"number",code:"invalid_type",input:s,inst:t,...i?{received:i}:{}}),n}}),kA=S("$ZodNumberFormat",(t,e)=>{U$.init(t,e),Xf.init(t,e)}),EA=S("$ZodBoolean",(t,e)=>{le.init(t,e),t._zod.pattern=z$,t._zod.parse=(n,r)=>{if(e.coerce)try{n.value=!!n.value}catch{}const s=n.value;return typeof s=="boolean"||n.issues.push({expected:"boolean",code:"invalid_type",input:s,inst:t}),n}}),$A=S("$ZodUnknown",(t,e)=>{le.init(t,e),t._zod.parse=n=>n}),AA=S("$ZodNever",(t,e)=>{le.init(t,e),t._zod.parse=(n,r)=>(n.issues.push({expected:"never",code:"invalid_type",input:n.value,inst:t}),n)});function rd(t,e,n){t.issues.length&&e.issues.push(...br(n,t.issues)),e.value[n]=t.value}const xA=S("$ZodArray",(t,e)=>{le.init(t,e),t._zod.parse=(n,r)=>{const s=n.value;if(!Array.isArray(s))return n.issues.push({expected:"array",code:"invalid_type",input:s,inst:t}),n;n.value=Array(s.length);const i=[];for(let o=0;o<s.length;o++){const a=s[o],l=e.element._zod.run({value:a,issues:[]},r);l instanceof Promise?i.push(l.then(c=>rd(c,n,o))):rd(l,n,o)}return i.length?Promise.all(i).then(()=>n):n}});function go(t,e,n,r,s){if(t.issues.length){if(s&&!(n in r))return;e.issues.push(...br(n,t.issues))}t.value===void 0?n in r&&(e.value[n]=void 0):e.value[n]=t.value}function Qf(t){var r,s,i,o;const e=Object.keys(t.shape);for(const a of e)if(!((o=(i=(s=(r=t.shape)==null?void 0:r[a])==null?void 0:s._zod)==null?void 0:i.traits)!=null&&o.has("$ZodType")))throw new Error(`Invalid element at key "${a}": expected a Zod schema`);const n=VE(t.shape);return{...t,keys:e,keySet:new Set(e),numKeys:e.length,optionalKeys:new Set(n)}}function eg(t,e,n,r,s,i){const o=[],a=s.keySet,l=s.catchall._zod,c=l.def.type,d=l.optout==="optional";for(const p in e){if(a.has(p))continue;if(c==="never"){o.push(p);continue}const y=l.run({value:e[p],issues:[]},r);y instanceof Promise?t.push(y.then(m=>go(m,n,p,e,d))):go(y,n,p,e,d)}return o.length&&n.issues.push({code:"unrecognized_keys",keys:o,input:e,inst:i}),t.length?Promise.all(t).then(()=>n):n}const TA=S("$ZodObject",(t,e)=>{le.init(t,e);const n=Object.getOwnPropertyDescriptor(e,"shape");if(!(n!=null&&n.get)){const a=e.shape;Object.defineProperty(e,"shape",{get:()=>{const l={...a};return Object.defineProperty(e,"shape",{value:l}),l}})}const r=Tc(()=>Qf(e));ee(t._zod,"propValues",()=>{const a=e.shape,l={};for(const c in a){const d=a[c]._zod;if(d.values){l[c]??(l[c]=new Set);for(const p of d.values)l[c].add(p)}}return l});const s=fo,i=e.catchall;let o;t._zod.parse=(a,l)=>{o??(o=r.value);const c=a.value;if(!s(c))return a.issues.push({expected:"object",code:"invalid_type",input:c,inst:t}),a;a.value={};const d=[],p=o.shape;for(const y of o.keys){const m=p[y],E=m._zod.optout==="optional",k=m._zod.run({value:c[y],issues:[]},l);k instanceof Promise?d.push(k.then(I=>go(I,a,y,c,E))):go(k,a,y,c,E)}return i?eg(d,c,a,l,r.value,t):d.length?Promise.all(d).then(()=>a):a}}),CA=S("$ZodObjectJIT",(t,e)=>{TA.init(t,e);const n=t._zod.parse,r=Tc(()=>Qf(e)),s=y=>{var j;const m=new K$(["shape","payload","ctx"]),E=r.value,k=F=>{const L=td(F);return`shape[${L}]._zod.run({ value: input[${L}], issues: [] }, ctx)`};m.write("const input = payload.value;");const I=Object.create(null);let G=0;for(const F of E.keys)I[F]=`key_${G++}`;m.write("const newResult = {};");for(const F of E.keys){const L=I[F],J=td(F),H=y[F],he=((j=H==null?void 0:H._zod)==null?void 0:j.optout)==="optional";m.write(`const ${L} = ${k(F)};`),he?m.write(`
|
|
7
7
|
if (${L}.issues.length) {
|
|
8
8
|
if (${J} in input) {
|
|
9
9
|
payload.issues = payload.issues.concat(${L}.issues.map(iss => ({
|
|
@@ -37,40 +37,40 @@ var Av=Object.defineProperty;var Au=t=>{throw TypeError(t)};var xv=(t,e,n)=>e in
|
|
|
37
37
|
newResult[${J}] = ${L}.value;
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
-
`)}m.write("payload.value = newResult;"),m.write("return payload;");const N=m.compile();return(F,L)=>N(y,F,L)};let i;const o=fo,a=!Mf.jitless,c=a&&WE.value,d=e.catchall;let p;t._zod.parse=(y,m)=>{p??(p=r.value);const E=y.value;return o(E)?a&&c&&(m==null?void 0:m.async)===!1&&m.jitless!==!0?(i||(i=s(e.shape)),y=i(y,m),d?eg([],E,y,m,p,t):y):n(y,m):(y.issues.push({expected:"object",code:"invalid_type",input:E,inst:t}),y)}});function sd(t,e,n,r){for(const i of t)if(i.issues.length===0)return e.value=i.value,e;const s=t.filter(i=>!yr(i));return s.length===1?(e.value=s[0].value,s[0]):(e.issues.push({code:"invalid_union",input:e.value,inst:n,errors:t.map(i=>i.issues.map(o=>an(o,r,on())))}),e)}const CA=S("$ZodUnion",(t,e)=>{le.init(t,e),ee(t._zod,"optin",()=>e.options.some(s=>s._zod.optin==="optional")?"optional":void 0),ee(t._zod,"optout",()=>e.options.some(s=>s._zod.optout==="optional")?"optional":void 0),ee(t._zod,"values",()=>{if(e.options.every(s=>s._zod.values))return new Set(e.options.flatMap(s=>Array.from(s._zod.values)))}),ee(t._zod,"pattern",()=>{if(e.options.every(s=>s._zod.pattern)){const s=e.options.map(i=>i._zod.pattern);return new RegExp(`^(${s.map(i=>Rc(i.source)).join("|")})$`)}});const n=e.options.length===1,r=e.options[0]._zod.run;t._zod.parse=(s,i)=>{if(n)return r(s,i);let o=!1;const a=[];for(const l of e.options){const c=l._zod.run({value:s.value,issues:[]},i);if(c instanceof Promise)a.push(c),o=!0;else{if(c.issues.length===0)return c;a.push(c)}}return o?Promise.all(a).then(l=>sd(l,s,t,i)):sd(a,s,t,i)}}),IA=S("$ZodIntersection",(t,e)=>{le.init(t,e),t._zod.parse=(n,r)=>{const s=n.value,i=e.left._zod.run({value:s,issues:[]},r),o=e.right._zod.run({value:s,issues:[]},r);return i instanceof Promise||o instanceof Promise?Promise.all([i,o]).then(([l,c])=>id(n,l,c)):id(n,i,o)}});function bl(t,e){if(t===e)return{valid:!0,data:t};if(t instanceof Date&&e instanceof Date&&+t==+e)return{valid:!0,data:t};if(zr(t)&&zr(e)){const n=Object.keys(e),r=Object.keys(t).filter(i=>n.indexOf(i)!==-1),s={...t,...e};for(const i of r){const o=bl(t[i],e[i]);if(!o.valid)return{valid:!1,mergeErrorPath:[i,...o.mergeErrorPath]};s[i]=o.data}return{valid:!0,data:s}}if(Array.isArray(t)&&Array.isArray(e)){if(t.length!==e.length)return{valid:!1,mergeErrorPath:[]};const n=[];for(let r=0;r<t.length;r++){const s=t[r],i=e[r],o=bl(s,i);if(!o.valid)return{valid:!1,mergeErrorPath:[r,...o.mergeErrorPath]};n.push(o.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function id(t,e,n){const r=new Map;let s;for(const a of e.issues)if(a.code==="unrecognized_keys"){s??(s=a);for(const l of a.keys)r.has(l)||r.set(l,{}),r.get(l).l=!0}else t.issues.push(a);for(const a of n.issues)if(a.code==="unrecognized_keys")for(const l of a.keys)r.has(l)||r.set(l,{}),r.get(l).r=!0;else t.issues.push(a);const i=[...r].filter(([,a])=>a.l&&a.r).map(([a])=>a);if(i.length&&s&&t.issues.push({...s,keys:i}),yr(t))return t;const o=bl(e.value,n.value);if(!o.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(o.mergeErrorPath)}`);return t.value=o.data,t}const PA=S("$ZodRecord",(t,e)=>{le.init(t,e),t._zod.parse=(n,r)=>{const s=n.value;if(!zr(s))return n.issues.push({expected:"record",code:"invalid_type",input:s,inst:t}),n;const i=[],o=e.keyType._zod.values;if(o){n.value={};const a=new Set;for(const c of o)if(typeof c=="string"||typeof c=="number"||typeof c=="symbol"){a.add(typeof c=="number"?c.toString():c);const d=e.valueType._zod.run({value:s[c],issues:[]},r);d instanceof Promise?i.push(d.then(p=>{p.issues.length&&n.issues.push(...br(c,p.issues)),n.value[c]=p.value})):(d.issues.length&&n.issues.push(...br(c,d.issues)),n.value[c]=d.value)}let l;for(const c in s)a.has(c)||(l=l??[],l.push(c));l&&l.length>0&&n.issues.push({code:"unrecognized_keys",input:s,inst:t,keys:l})}else{n.value={};for(const a of Reflect.ownKeys(s)){if(a==="__proto__")continue;let l=e.keyType._zod.run({value:a,issues:[]},r);if(l instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(typeof a=="string"&&Hf.test(a)&&l.issues.length){const p=e.keyType._zod.run({value:Number(a),issues:[]},r);if(p instanceof Promise)throw new Error("Async schemas not supported in object keys currently");p.issues.length===0&&(l=p)}if(l.issues.length){e.mode==="loose"?n.value[a]=s[a]:n.issues.push({code:"invalid_key",origin:"record",issues:l.issues.map(p=>an(p,r,on())),input:a,path:[a],inst:t});continue}const d=e.valueType._zod.run({value:s[a],issues:[]},r);d instanceof Promise?i.push(d.then(p=>{p.issues.length&&n.issues.push(...br(a,p.issues)),n.value[l.value]=p.value})):(d.issues.length&&n.issues.push(...br(a,d.issues)),n.value[l.value]=d.value)}}return i.length?Promise.all(i).then(()=>n):n}}),RA=S("$ZodEnum",(t,e)=>{le.init(t,e);const n=Nf(e.entries),r=new Set(n);t._zod.values=r,t._zod.pattern=new RegExp(`^(${n.filter(s=>BE.has(typeof s)).map(s=>typeof s=="string"?Lr(s):s.toString()).join("|")})$`),t._zod.parse=(s,i)=>{const o=s.value;return r.has(o)||s.issues.push({code:"invalid_value",values:n,input:o,inst:t}),s}}),DA=S("$ZodLiteral",(t,e)=>{if(le.init(t,e),e.values.length===0)throw new Error("Cannot create literal schema with no valid values");const n=new Set(e.values);t._zod.values=n,t._zod.pattern=new RegExp(`^(${e.values.map(r=>typeof r=="string"?Lr(r):r?Lr(r.toString()):String(r)).join("|")})$`),t._zod.parse=(r,s)=>{const i=r.value;return n.has(i)||r.issues.push({code:"invalid_value",values:e.values,input:i,inst:t}),r}}),OA=S("$ZodTransform",(t,e)=>{le.init(t,e),t._zod.parse=(n,r)=>{if(r.direction==="backward")throw new Lf(t.constructor.name);const s=e.transform(n.value,n);if(r.async)return(s instanceof Promise?s:Promise.resolve(s)).then(o=>(n.value=o,n));if(s instanceof Promise)throw new _r;return n.value=s,n}});function od(t,e){return t.issues.length&&e===void 0?{issues:[],value:void 0}:t}const tg=S("$ZodOptional",(t,e)=>{le.init(t,e),t._zod.optin="optional",t._zod.optout="optional",ee(t._zod,"values",()=>e.innerType._zod.values?new Set([...e.innerType._zod.values,void 0]):void 0),ee(t._zod,"pattern",()=>{const n=e.innerType._zod.pattern;return n?new RegExp(`^(${Rc(n.source)})?$`):void 0}),t._zod.parse=(n,r)=>{if(e.innerType._zod.optin==="optional"){const s=e.innerType._zod.run(n,r);return s instanceof Promise?s.then(i=>od(i,n.value)):od(s,n.value)}return n.value===void 0?n:e.innerType._zod.run(n,r)}}),zA=S("$ZodExactOptional",(t,e)=>{tg.init(t,e),ee(t._zod,"values",()=>e.innerType._zod.values),ee(t._zod,"pattern",()=>e.innerType._zod.pattern),t._zod.parse=(n,r)=>e.innerType._zod.run(n,r)}),LA=S("$ZodNullable",(t,e)=>{le.init(t,e),ee(t._zod,"optin",()=>e.innerType._zod.optin),ee(t._zod,"optout",()=>e.innerType._zod.optout),ee(t._zod,"pattern",()=>{const n=e.innerType._zod.pattern;return n?new RegExp(`^(${Rc(n.source)}|null)$`):void 0}),ee(t._zod,"values",()=>e.innerType._zod.values?new Set([...e.innerType._zod.values,null]):void 0),t._zod.parse=(n,r)=>n.value===null?n:e.innerType._zod.run(n,r)}),MA=S("$ZodDefault",(t,e)=>{le.init(t,e),t._zod.optin="optional",ee(t._zod,"values",()=>e.innerType._zod.values),t._zod.parse=(n,r)=>{if(r.direction==="backward")return e.innerType._zod.run(n,r);if(n.value===void 0)return n.value=e.defaultValue,n;const s=e.innerType._zod.run(n,r);return s instanceof Promise?s.then(i=>ad(i,e)):ad(s,e)}});function ad(t,e){return t.value===void 0&&(t.value=e.defaultValue),t}const NA=S("$ZodPrefault",(t,e)=>{le.init(t,e),t._zod.optin="optional",ee(t._zod,"values",()=>e.innerType._zod.values),t._zod.parse=(n,r)=>(r.direction==="backward"||n.value===void 0&&(n.value=e.defaultValue),e.innerType._zod.run(n,r))}),UA=S("$ZodNonOptional",(t,e)=>{le.init(t,e),ee(t._zod,"values",()=>{const n=e.innerType._zod.values;return n?new Set([...n].filter(r=>r!==void 0)):void 0}),t._zod.parse=(n,r)=>{const s=e.innerType._zod.run(n,r);return s instanceof Promise?s.then(i=>ld(i,t)):ld(s,t)}});function ld(t,e){return!t.issues.length&&t.value===void 0&&t.issues.push({code:"invalid_type",expected:"nonoptional",input:t.value,inst:e}),t}const FA=S("$ZodCatch",(t,e)=>{le.init(t,e),ee(t._zod,"optin",()=>e.innerType._zod.optin),ee(t._zod,"optout",()=>e.innerType._zod.optout),ee(t._zod,"values",()=>e.innerType._zod.values),t._zod.parse=(n,r)=>{if(r.direction==="backward")return e.innerType._zod.run(n,r);const s=e.innerType._zod.run(n,r);return s instanceof Promise?s.then(i=>(n.value=i.value,i.issues.length&&(n.value=e.catchValue({...n,error:{issues:i.issues.map(o=>an(o,r,on()))},input:n.value}),n.issues=[]),n)):(n.value=s.value,s.issues.length&&(n.value=e.catchValue({...n,error:{issues:s.issues.map(i=>an(i,r,on()))},input:n.value}),n.issues=[]),n)}}),ZA=S("$ZodPipe",(t,e)=>{le.init(t,e),ee(t._zod,"values",()=>e.in._zod.values),ee(t._zod,"optin",()=>e.in._zod.optin),ee(t._zod,"optout",()=>e.out._zod.optout),ee(t._zod,"propValues",()=>e.in._zod.propValues),t._zod.parse=(n,r)=>{if(r.direction==="backward"){const i=e.out._zod.run(n,r);return i instanceof Promise?i.then(o=>Ni(o,e.in,r)):Ni(i,e.in,r)}const s=e.in._zod.run(n,r);return s instanceof Promise?s.then(i=>Ni(i,e.out,r)):Ni(s,e.out,r)}});function Ni(t,e,n){return t.issues.length?(t.aborted=!0,t):e._zod.run({value:t.value,issues:t.issues},n)}const jA=S("$ZodReadonly",(t,e)=>{le.init(t,e),ee(t._zod,"propValues",()=>e.innerType._zod.propValues),ee(t._zod,"values",()=>e.innerType._zod.values),ee(t._zod,"optin",()=>{var n,r;return(r=(n=e.innerType)==null?void 0:n._zod)==null?void 0:r.optin}),ee(t._zod,"optout",()=>{var n,r;return(r=(n=e.innerType)==null?void 0:n._zod)==null?void 0:r.optout}),t._zod.parse=(n,r)=>{if(r.direction==="backward")return e.innerType._zod.run(n,r);const s=e.innerType._zod.run(n,r);return s instanceof Promise?s.then(cd):cd(s)}});function cd(t){return t.value=Object.freeze(t.value),t}const WA=S("$ZodCustom",(t,e)=>{We.init(t,e),le.init(t,e),t._zod.parse=(n,r)=>n,t._zod.check=n=>{const r=n.value,s=e.fn(r);if(s instanceof Promise)return s.then(i=>ud(i,n,r,t));ud(s,n,r,t)}});function ud(t,e,n,r){if(!t){const s={code:"custom",input:n,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(s.params=r._zod.def.params),e.issues.push(Ts(s))}}var hd;class BA{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...n){const r=n[0];return this._map.set(e,r),r&&typeof r=="object"&&"id"in r&&this._idmap.set(r.id,e),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(e){const n=this._map.get(e);return n&&typeof n=="object"&&"id"in n&&this._idmap.delete(n.id),this._map.delete(e),this}get(e){const n=e._zod.parent;if(n){const r={...this.get(n)??{}};delete r.id;const s={...r,...this._map.get(e)};return Object.keys(s).length?s:void 0}return this._map.get(e)}has(e){return this._map.has(e)}}function GA(){return new BA}(hd=globalThis).__zod_globalRegistry??(hd.__zod_globalRegistry=GA());const gs=globalThis.__zod_globalRegistry;function VA(t,e){return new t({type:"string",...O(e)})}function HA(t,e){return new t({type:"string",format:"email",check:"string_format",abort:!1,...O(e)})}function dd(t,e){return new t({type:"string",format:"guid",check:"string_format",abort:!1,...O(e)})}function qA(t,e){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,...O(e)})}function YA(t,e){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...O(e)})}function KA(t,e){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...O(e)})}function JA(t,e){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...O(e)})}function XA(t,e){return new t({type:"string",format:"url",check:"string_format",abort:!1,...O(e)})}function QA(t,e){return new t({type:"string",format:"emoji",check:"string_format",abort:!1,...O(e)})}function ex(t,e){return new t({type:"string",format:"nanoid",check:"string_format",abort:!1,...O(e)})}function tx(t,e){return new t({type:"string",format:"cuid",check:"string_format",abort:!1,...O(e)})}function nx(t,e){return new t({type:"string",format:"cuid2",check:"string_format",abort:!1,...O(e)})}function rx(t,e){return new t({type:"string",format:"ulid",check:"string_format",abort:!1,...O(e)})}function sx(t,e){return new t({type:"string",format:"xid",check:"string_format",abort:!1,...O(e)})}function ix(t,e){return new t({type:"string",format:"ksuid",check:"string_format",abort:!1,...O(e)})}function ox(t,e){return new t({type:"string",format:"ipv4",check:"string_format",abort:!1,...O(e)})}function ax(t,e){return new t({type:"string",format:"ipv6",check:"string_format",abort:!1,...O(e)})}function lx(t,e){return new t({type:"string",format:"cidrv4",check:"string_format",abort:!1,...O(e)})}function cx(t,e){return new t({type:"string",format:"cidrv6",check:"string_format",abort:!1,...O(e)})}function ux(t,e){return new t({type:"string",format:"base64",check:"string_format",abort:!1,...O(e)})}function hx(t,e){return new t({type:"string",format:"base64url",check:"string_format",abort:!1,...O(e)})}function dx(t,e){return new t({type:"string",format:"e164",check:"string_format",abort:!1,...O(e)})}function px(t,e){return new t({type:"string",format:"jwt",check:"string_format",abort:!1,...O(e)})}function fx(t,e){return new t({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...O(e)})}function gx(t,e){return new t({type:"string",format:"date",check:"string_format",...O(e)})}function mx(t,e){return new t({type:"string",format:"time",check:"string_format",precision:null,...O(e)})}function vx(t,e){return new t({type:"string",format:"duration",check:"string_format",...O(e)})}function yx(t,e){return new t({type:"number",checks:[],...O(e)})}function bx(t,e){return new t({type:"number",check:"number_format",abort:!1,format:"safeint",...O(e)})}function wx(t,e){return new t({type:"boolean",...O(e)})}function _x(t){return new t({type:"unknown"})}function Sx(t,e){return new t({type:"never",...O(e)})}function pd(t,e){return new Yf({check:"less_than",...O(e),value:t,inclusive:!1})}function Za(t,e){return new Yf({check:"less_than",...O(e),value:t,inclusive:!0})}function fd(t,e){return new Kf({check:"greater_than",...O(e),value:t,inclusive:!1})}function ja(t,e){return new Kf({check:"greater_than",...O(e),value:t,inclusive:!0})}function gd(t,e){return new M$({check:"multiple_of",...O(e),value:t})}function ng(t,e){return new U$({check:"max_length",...O(e),maximum:t})}function mo(t,e){return new F$({check:"min_length",...O(e),minimum:t})}function rg(t,e){return new Z$({check:"length_equals",...O(e),length:t})}function kx(t,e){return new j$({check:"string_format",format:"regex",...O(e),pattern:t})}function Ex(t){return new W$({check:"string_format",format:"lowercase",...O(t)})}function $x(t){return new B$({check:"string_format",format:"uppercase",...O(t)})}function Ax(t,e){return new G$({check:"string_format",format:"includes",...O(e),includes:t})}function xx(t,e){return new V$({check:"string_format",format:"starts_with",...O(e),prefix:t})}function Tx(t,e){return new H$({check:"string_format",format:"ends_with",...O(e),suffix:t})}function qr(t){return new q$({check:"overwrite",tx:t})}function Cx(t){return qr(e=>e.normalize(t))}function Ix(){return qr(t=>t.trim())}function Px(){return qr(t=>t.toLowerCase())}function Rx(){return qr(t=>t.toUpperCase())}function Dx(){return qr(t=>jE(t))}function Ox(t,e,n){return new t({type:"array",element:e,...O(n)})}function zx(t,e,n){return new t({type:"custom",check:"custom",fn:e,...O(n)})}function Lx(t){const e=Mx(n=>(n.addIssue=r=>{if(typeof r=="string")n.issues.push(Ts(r,n.value,e._zod.def));else{const s=r;s.fatal&&(s.continue=!1),s.code??(s.code="custom"),s.input??(s.input=n.value),s.inst??(s.inst=e),s.continue??(s.continue=!e._zod.def.abort),n.issues.push(Ts(s))}},t(n.value,n)));return e}function Mx(t,e){const n=new We({check:"custom",...O(e)});return n._zod.check=t,n}function sg(t){let e=(t==null?void 0:t.target)??"draft-2020-12";return e==="draft-4"&&(e="draft-04"),e==="draft-7"&&(e="draft-07"),{processors:t.processors??{},metadataRegistry:(t==null?void 0:t.metadata)??gs,target:e,unrepresentable:(t==null?void 0:t.unrepresentable)??"throw",override:(t==null?void 0:t.override)??(()=>{}),io:(t==null?void 0:t.io)??"output",counter:0,seen:new Map,cycles:(t==null?void 0:t.cycles)??"ref",reused:(t==null?void 0:t.reused)??"inline",external:(t==null?void 0:t.external)??void 0}}function me(t,e,n={path:[],schemaPath:[]}){var d,p;var r;const s=t._zod.def,i=e.seen.get(t);if(i)return i.count++,n.schemaPath.includes(t)&&(i.cycle=n.path),i.schema;const o={schema:{},count:1,cycle:void 0,path:n.path};e.seen.set(t,o);const a=(p=(d=t._zod).toJSONSchema)==null?void 0:p.call(d);if(a)o.schema=a;else{const y={...n,schemaPath:[...n.schemaPath,t],path:n.path};if(t._zod.processJSONSchema)t._zod.processJSONSchema(e,o.schema,y);else{const E=o.schema,k=e.processors[s.type];if(!k)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${s.type}`);k(t,e,E,y)}const m=t._zod.parent;m&&(o.ref||(o.ref=m),me(m,e,y),e.seen.get(m).isParent=!0)}const l=e.metadataRegistry.get(t);return l&&Object.assign(o.schema,l),e.io==="input"&&Re(t)&&(delete o.schema.examples,delete o.schema.default),e.io==="input"&&o.schema._prefault&&((r=o.schema).default??(r.default=o.schema._prefault)),delete o.schema._prefault,e.seen.get(t).schema}function ig(t,e){var o,a,l,c;const n=t.seen.get(e);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");const r=new Map;for(const d of t.seen.entries()){const p=(o=t.metadataRegistry.get(d[0]))==null?void 0:o.id;if(p){const y=r.get(p);if(y&&y!==d[0])throw new Error(`Duplicate schema id "${p}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);r.set(p,d[0])}}const s=d=>{var k;const p=t.target==="draft-2020-12"?"$defs":"definitions";if(t.external){const I=(k=t.external.registry.get(d[0]))==null?void 0:k.id,G=t.external.uri??(j=>j);if(I)return{ref:G(I)};const N=d[1].defId??d[1].schema.id??`schema${t.counter++}`;return d[1].defId=N,{defId:N,ref:`${G("__shared")}#/${p}/${N}`}}if(d[1]===n)return{ref:"#"};const m=`#/${p}/`,E=d[1].schema.id??`__schema${t.counter++}`;return{defId:E,ref:m+E}},i=d=>{if(d[1].schema.$ref)return;const p=d[1],{ref:y,defId:m}=s(d);p.def={...p.schema},m&&(p.defId=m);const E=p.schema;for(const k in E)delete E[k];E.$ref=y};if(t.cycles==="throw")for(const d of t.seen.entries()){const p=d[1];if(p.cycle)throw new Error(`Cycle detected: #/${(a=p.cycle)==null?void 0:a.join("/")}/<root>
|
|
40
|
+
`)}m.write("payload.value = newResult;"),m.write("return payload;");const N=m.compile();return(F,L)=>N(y,F,L)};let i;const o=fo,a=!Mf.jitless,c=a&&BE.value,d=e.catchall;let p;t._zod.parse=(y,m)=>{p??(p=r.value);const E=y.value;return o(E)?a&&c&&(m==null?void 0:m.async)===!1&&m.jitless!==!0?(i||(i=s(e.shape)),y=i(y,m),d?eg([],E,y,m,p,t):y):n(y,m):(y.issues.push({expected:"object",code:"invalid_type",input:E,inst:t}),y)}});function sd(t,e,n,r){for(const i of t)if(i.issues.length===0)return e.value=i.value,e;const s=t.filter(i=>!yr(i));return s.length===1?(e.value=s[0].value,s[0]):(e.issues.push({code:"invalid_union",input:e.value,inst:n,errors:t.map(i=>i.issues.map(o=>an(o,r,on())))}),e)}const IA=S("$ZodUnion",(t,e)=>{le.init(t,e),ee(t._zod,"optin",()=>e.options.some(s=>s._zod.optin==="optional")?"optional":void 0),ee(t._zod,"optout",()=>e.options.some(s=>s._zod.optout==="optional")?"optional":void 0),ee(t._zod,"values",()=>{if(e.options.every(s=>s._zod.values))return new Set(e.options.flatMap(s=>Array.from(s._zod.values)))}),ee(t._zod,"pattern",()=>{if(e.options.every(s=>s._zod.pattern)){const s=e.options.map(i=>i._zod.pattern);return new RegExp(`^(${s.map(i=>Ic(i.source)).join("|")})$`)}});const n=e.options.length===1,r=e.options[0]._zod.run;t._zod.parse=(s,i)=>{if(n)return r(s,i);let o=!1;const a=[];for(const l of e.options){const c=l._zod.run({value:s.value,issues:[]},i);if(c instanceof Promise)a.push(c),o=!0;else{if(c.issues.length===0)return c;a.push(c)}}return o?Promise.all(a).then(l=>sd(l,s,t,i)):sd(a,s,t,i)}}),PA=S("$ZodIntersection",(t,e)=>{le.init(t,e),t._zod.parse=(n,r)=>{const s=n.value,i=e.left._zod.run({value:s,issues:[]},r),o=e.right._zod.run({value:s,issues:[]},r);return i instanceof Promise||o instanceof Promise?Promise.all([i,o]).then(([l,c])=>id(n,l,c)):id(n,i,o)}});function vl(t,e){if(t===e)return{valid:!0,data:t};if(t instanceof Date&&e instanceof Date&&+t==+e)return{valid:!0,data:t};if(zr(t)&&zr(e)){const n=Object.keys(e),r=Object.keys(t).filter(i=>n.indexOf(i)!==-1),s={...t,...e};for(const i of r){const o=vl(t[i],e[i]);if(!o.valid)return{valid:!1,mergeErrorPath:[i,...o.mergeErrorPath]};s[i]=o.data}return{valid:!0,data:s}}if(Array.isArray(t)&&Array.isArray(e)){if(t.length!==e.length)return{valid:!1,mergeErrorPath:[]};const n=[];for(let r=0;r<t.length;r++){const s=t[r],i=e[r],o=vl(s,i);if(!o.valid)return{valid:!1,mergeErrorPath:[r,...o.mergeErrorPath]};n.push(o.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function id(t,e,n){const r=new Map;let s;for(const a of e.issues)if(a.code==="unrecognized_keys"){s??(s=a);for(const l of a.keys)r.has(l)||r.set(l,{}),r.get(l).l=!0}else t.issues.push(a);for(const a of n.issues)if(a.code==="unrecognized_keys")for(const l of a.keys)r.has(l)||r.set(l,{}),r.get(l).r=!0;else t.issues.push(a);const i=[...r].filter(([,a])=>a.l&&a.r).map(([a])=>a);if(i.length&&s&&t.issues.push({...s,keys:i}),yr(t))return t;const o=vl(e.value,n.value);if(!o.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(o.mergeErrorPath)}`);return t.value=o.data,t}const RA=S("$ZodRecord",(t,e)=>{le.init(t,e),t._zod.parse=(n,r)=>{const s=n.value;if(!zr(s))return n.issues.push({expected:"record",code:"invalid_type",input:s,inst:t}),n;const i=[],o=e.keyType._zod.values;if(o){n.value={};const a=new Set;for(const c of o)if(typeof c=="string"||typeof c=="number"||typeof c=="symbol"){a.add(typeof c=="number"?c.toString():c);const d=e.valueType._zod.run({value:s[c],issues:[]},r);d instanceof Promise?i.push(d.then(p=>{p.issues.length&&n.issues.push(...br(c,p.issues)),n.value[c]=p.value})):(d.issues.length&&n.issues.push(...br(c,d.issues)),n.value[c]=d.value)}let l;for(const c in s)a.has(c)||(l=l??[],l.push(c));l&&l.length>0&&n.issues.push({code:"unrecognized_keys",input:s,inst:t,keys:l})}else{n.value={};for(const a of Reflect.ownKeys(s)){if(a==="__proto__")continue;let l=e.keyType._zod.run({value:a,issues:[]},r);if(l instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(typeof a=="string"&&Hf.test(a)&&l.issues.length){const p=e.keyType._zod.run({value:Number(a),issues:[]},r);if(p instanceof Promise)throw new Error("Async schemas not supported in object keys currently");p.issues.length===0&&(l=p)}if(l.issues.length){e.mode==="loose"?n.value[a]=s[a]:n.issues.push({code:"invalid_key",origin:"record",issues:l.issues.map(p=>an(p,r,on())),input:a,path:[a],inst:t});continue}const d=e.valueType._zod.run({value:s[a],issues:[]},r);d instanceof Promise?i.push(d.then(p=>{p.issues.length&&n.issues.push(...br(a,p.issues)),n.value[l.value]=p.value})):(d.issues.length&&n.issues.push(...br(a,d.issues)),n.value[l.value]=d.value)}}return i.length?Promise.all(i).then(()=>n):n}}),DA=S("$ZodEnum",(t,e)=>{le.init(t,e);const n=Nf(e.entries),r=new Set(n);t._zod.values=r,t._zod.pattern=new RegExp(`^(${n.filter(s=>GE.has(typeof s)).map(s=>typeof s=="string"?Lr(s):s.toString()).join("|")})$`),t._zod.parse=(s,i)=>{const o=s.value;return r.has(o)||s.issues.push({code:"invalid_value",values:n,input:o,inst:t}),s}}),OA=S("$ZodLiteral",(t,e)=>{if(le.init(t,e),e.values.length===0)throw new Error("Cannot create literal schema with no valid values");const n=new Set(e.values);t._zod.values=n,t._zod.pattern=new RegExp(`^(${e.values.map(r=>typeof r=="string"?Lr(r):r?Lr(r.toString()):String(r)).join("|")})$`),t._zod.parse=(r,s)=>{const i=r.value;return n.has(i)||r.issues.push({code:"invalid_value",values:e.values,input:i,inst:t}),r}}),zA=S("$ZodTransform",(t,e)=>{le.init(t,e),t._zod.parse=(n,r)=>{if(r.direction==="backward")throw new Lf(t.constructor.name);const s=e.transform(n.value,n);if(r.async)return(s instanceof Promise?s:Promise.resolve(s)).then(o=>(n.value=o,n));if(s instanceof Promise)throw new _r;return n.value=s,n}});function od(t,e){return t.issues.length&&e===void 0?{issues:[],value:void 0}:t}const tg=S("$ZodOptional",(t,e)=>{le.init(t,e),t._zod.optin="optional",t._zod.optout="optional",ee(t._zod,"values",()=>e.innerType._zod.values?new Set([...e.innerType._zod.values,void 0]):void 0),ee(t._zod,"pattern",()=>{const n=e.innerType._zod.pattern;return n?new RegExp(`^(${Ic(n.source)})?$`):void 0}),t._zod.parse=(n,r)=>{if(e.innerType._zod.optin==="optional"){const s=e.innerType._zod.run(n,r);return s instanceof Promise?s.then(i=>od(i,n.value)):od(s,n.value)}return n.value===void 0?n:e.innerType._zod.run(n,r)}}),LA=S("$ZodExactOptional",(t,e)=>{tg.init(t,e),ee(t._zod,"values",()=>e.innerType._zod.values),ee(t._zod,"pattern",()=>e.innerType._zod.pattern),t._zod.parse=(n,r)=>e.innerType._zod.run(n,r)}),MA=S("$ZodNullable",(t,e)=>{le.init(t,e),ee(t._zod,"optin",()=>e.innerType._zod.optin),ee(t._zod,"optout",()=>e.innerType._zod.optout),ee(t._zod,"pattern",()=>{const n=e.innerType._zod.pattern;return n?new RegExp(`^(${Ic(n.source)}|null)$`):void 0}),ee(t._zod,"values",()=>e.innerType._zod.values?new Set([...e.innerType._zod.values,null]):void 0),t._zod.parse=(n,r)=>n.value===null?n:e.innerType._zod.run(n,r)}),NA=S("$ZodDefault",(t,e)=>{le.init(t,e),t._zod.optin="optional",ee(t._zod,"values",()=>e.innerType._zod.values),t._zod.parse=(n,r)=>{if(r.direction==="backward")return e.innerType._zod.run(n,r);if(n.value===void 0)return n.value=e.defaultValue,n;const s=e.innerType._zod.run(n,r);return s instanceof Promise?s.then(i=>ad(i,e)):ad(s,e)}});function ad(t,e){return t.value===void 0&&(t.value=e.defaultValue),t}const UA=S("$ZodPrefault",(t,e)=>{le.init(t,e),t._zod.optin="optional",ee(t._zod,"values",()=>e.innerType._zod.values),t._zod.parse=(n,r)=>(r.direction==="backward"||n.value===void 0&&(n.value=e.defaultValue),e.innerType._zod.run(n,r))}),FA=S("$ZodNonOptional",(t,e)=>{le.init(t,e),ee(t._zod,"values",()=>{const n=e.innerType._zod.values;return n?new Set([...n].filter(r=>r!==void 0)):void 0}),t._zod.parse=(n,r)=>{const s=e.innerType._zod.run(n,r);return s instanceof Promise?s.then(i=>ld(i,t)):ld(s,t)}});function ld(t,e){return!t.issues.length&&t.value===void 0&&t.issues.push({code:"invalid_type",expected:"nonoptional",input:t.value,inst:e}),t}const ZA=S("$ZodCatch",(t,e)=>{le.init(t,e),ee(t._zod,"optin",()=>e.innerType._zod.optin),ee(t._zod,"optout",()=>e.innerType._zod.optout),ee(t._zod,"values",()=>e.innerType._zod.values),t._zod.parse=(n,r)=>{if(r.direction==="backward")return e.innerType._zod.run(n,r);const s=e.innerType._zod.run(n,r);return s instanceof Promise?s.then(i=>(n.value=i.value,i.issues.length&&(n.value=e.catchValue({...n,error:{issues:i.issues.map(o=>an(o,r,on()))},input:n.value}),n.issues=[]),n)):(n.value=s.value,s.issues.length&&(n.value=e.catchValue({...n,error:{issues:s.issues.map(i=>an(i,r,on()))},input:n.value}),n.issues=[]),n)}}),jA=S("$ZodPipe",(t,e)=>{le.init(t,e),ee(t._zod,"values",()=>e.in._zod.values),ee(t._zod,"optin",()=>e.in._zod.optin),ee(t._zod,"optout",()=>e.out._zod.optout),ee(t._zod,"propValues",()=>e.in._zod.propValues),t._zod.parse=(n,r)=>{if(r.direction==="backward"){const i=e.out._zod.run(n,r);return i instanceof Promise?i.then(o=>Ni(o,e.in,r)):Ni(i,e.in,r)}const s=e.in._zod.run(n,r);return s instanceof Promise?s.then(i=>Ni(i,e.out,r)):Ni(s,e.out,r)}});function Ni(t,e,n){return t.issues.length?(t.aborted=!0,t):e._zod.run({value:t.value,issues:t.issues},n)}const WA=S("$ZodReadonly",(t,e)=>{le.init(t,e),ee(t._zod,"propValues",()=>e.innerType._zod.propValues),ee(t._zod,"values",()=>e.innerType._zod.values),ee(t._zod,"optin",()=>{var n,r;return(r=(n=e.innerType)==null?void 0:n._zod)==null?void 0:r.optin}),ee(t._zod,"optout",()=>{var n,r;return(r=(n=e.innerType)==null?void 0:n._zod)==null?void 0:r.optout}),t._zod.parse=(n,r)=>{if(r.direction==="backward")return e.innerType._zod.run(n,r);const s=e.innerType._zod.run(n,r);return s instanceof Promise?s.then(cd):cd(s)}});function cd(t){return t.value=Object.freeze(t.value),t}const BA=S("$ZodCustom",(t,e)=>{We.init(t,e),le.init(t,e),t._zod.parse=(n,r)=>n,t._zod.check=n=>{const r=n.value,s=e.fn(r);if(s instanceof Promise)return s.then(i=>ud(i,n,r,t));ud(s,n,r,t)}});function ud(t,e,n,r){if(!t){const s={code:"custom",input:n,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(s.params=r._zod.def.params),e.issues.push(Ts(s))}}var hd;class GA{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...n){const r=n[0];return this._map.set(e,r),r&&typeof r=="object"&&"id"in r&&this._idmap.set(r.id,e),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(e){const n=this._map.get(e);return n&&typeof n=="object"&&"id"in n&&this._idmap.delete(n.id),this._map.delete(e),this}get(e){const n=e._zod.parent;if(n){const r={...this.get(n)??{}};delete r.id;const s={...r,...this._map.get(e)};return Object.keys(s).length?s:void 0}return this._map.get(e)}has(e){return this._map.has(e)}}function VA(){return new GA}(hd=globalThis).__zod_globalRegistry??(hd.__zod_globalRegistry=VA());const gs=globalThis.__zod_globalRegistry;function HA(t,e){return new t({type:"string",...O(e)})}function qA(t,e){return new t({type:"string",format:"email",check:"string_format",abort:!1,...O(e)})}function dd(t,e){return new t({type:"string",format:"guid",check:"string_format",abort:!1,...O(e)})}function YA(t,e){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,...O(e)})}function KA(t,e){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...O(e)})}function JA(t,e){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...O(e)})}function XA(t,e){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...O(e)})}function QA(t,e){return new t({type:"string",format:"url",check:"string_format",abort:!1,...O(e)})}function ex(t,e){return new t({type:"string",format:"emoji",check:"string_format",abort:!1,...O(e)})}function tx(t,e){return new t({type:"string",format:"nanoid",check:"string_format",abort:!1,...O(e)})}function nx(t,e){return new t({type:"string",format:"cuid",check:"string_format",abort:!1,...O(e)})}function rx(t,e){return new t({type:"string",format:"cuid2",check:"string_format",abort:!1,...O(e)})}function sx(t,e){return new t({type:"string",format:"ulid",check:"string_format",abort:!1,...O(e)})}function ix(t,e){return new t({type:"string",format:"xid",check:"string_format",abort:!1,...O(e)})}function ox(t,e){return new t({type:"string",format:"ksuid",check:"string_format",abort:!1,...O(e)})}function ax(t,e){return new t({type:"string",format:"ipv4",check:"string_format",abort:!1,...O(e)})}function lx(t,e){return new t({type:"string",format:"ipv6",check:"string_format",abort:!1,...O(e)})}function cx(t,e){return new t({type:"string",format:"cidrv4",check:"string_format",abort:!1,...O(e)})}function ux(t,e){return new t({type:"string",format:"cidrv6",check:"string_format",abort:!1,...O(e)})}function hx(t,e){return new t({type:"string",format:"base64",check:"string_format",abort:!1,...O(e)})}function dx(t,e){return new t({type:"string",format:"base64url",check:"string_format",abort:!1,...O(e)})}function px(t,e){return new t({type:"string",format:"e164",check:"string_format",abort:!1,...O(e)})}function fx(t,e){return new t({type:"string",format:"jwt",check:"string_format",abort:!1,...O(e)})}function gx(t,e){return new t({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...O(e)})}function mx(t,e){return new t({type:"string",format:"date",check:"string_format",...O(e)})}function vx(t,e){return new t({type:"string",format:"time",check:"string_format",precision:null,...O(e)})}function yx(t,e){return new t({type:"string",format:"duration",check:"string_format",...O(e)})}function bx(t,e){return new t({type:"number",checks:[],...O(e)})}function wx(t,e){return new t({type:"number",check:"number_format",abort:!1,format:"safeint",...O(e)})}function _x(t,e){return new t({type:"boolean",...O(e)})}function Sx(t){return new t({type:"unknown"})}function kx(t,e){return new t({type:"never",...O(e)})}function pd(t,e){return new Yf({check:"less_than",...O(e),value:t,inclusive:!1})}function Ua(t,e){return new Yf({check:"less_than",...O(e),value:t,inclusive:!0})}function fd(t,e){return new Kf({check:"greater_than",...O(e),value:t,inclusive:!1})}function Fa(t,e){return new Kf({check:"greater_than",...O(e),value:t,inclusive:!0})}function gd(t,e){return new N$({check:"multiple_of",...O(e),value:t})}function ng(t,e){return new F$({check:"max_length",...O(e),maximum:t})}function mo(t,e){return new Z$({check:"min_length",...O(e),minimum:t})}function rg(t,e){return new j$({check:"length_equals",...O(e),length:t})}function Ex(t,e){return new W$({check:"string_format",format:"regex",...O(e),pattern:t})}function $x(t){return new B$({check:"string_format",format:"lowercase",...O(t)})}function Ax(t){return new G$({check:"string_format",format:"uppercase",...O(t)})}function xx(t,e){return new V$({check:"string_format",format:"includes",...O(e),includes:t})}function Tx(t,e){return new H$({check:"string_format",format:"starts_with",...O(e),prefix:t})}function Cx(t,e){return new q$({check:"string_format",format:"ends_with",...O(e),suffix:t})}function qr(t){return new Y$({check:"overwrite",tx:t})}function Ix(t){return qr(e=>e.normalize(t))}function Px(){return qr(t=>t.trim())}function Rx(){return qr(t=>t.toLowerCase())}function Dx(){return qr(t=>t.toUpperCase())}function Ox(){return qr(t=>WE(t))}function zx(t,e,n){return new t({type:"array",element:e,...O(n)})}function Lx(t,e,n){return new t({type:"custom",check:"custom",fn:e,...O(n)})}function Mx(t){const e=Nx(n=>(n.addIssue=r=>{if(typeof r=="string")n.issues.push(Ts(r,n.value,e._zod.def));else{const s=r;s.fatal&&(s.continue=!1),s.code??(s.code="custom"),s.input??(s.input=n.value),s.inst??(s.inst=e),s.continue??(s.continue=!e._zod.def.abort),n.issues.push(Ts(s))}},t(n.value,n)));return e}function Nx(t,e){const n=new We({check:"custom",...O(e)});return n._zod.check=t,n}function sg(t){let e=(t==null?void 0:t.target)??"draft-2020-12";return e==="draft-4"&&(e="draft-04"),e==="draft-7"&&(e="draft-07"),{processors:t.processors??{},metadataRegistry:(t==null?void 0:t.metadata)??gs,target:e,unrepresentable:(t==null?void 0:t.unrepresentable)??"throw",override:(t==null?void 0:t.override)??(()=>{}),io:(t==null?void 0:t.io)??"output",counter:0,seen:new Map,cycles:(t==null?void 0:t.cycles)??"ref",reused:(t==null?void 0:t.reused)??"inline",external:(t==null?void 0:t.external)??void 0}}function me(t,e,n={path:[],schemaPath:[]}){var d,p;var r;const s=t._zod.def,i=e.seen.get(t);if(i)return i.count++,n.schemaPath.includes(t)&&(i.cycle=n.path),i.schema;const o={schema:{},count:1,cycle:void 0,path:n.path};e.seen.set(t,o);const a=(p=(d=t._zod).toJSONSchema)==null?void 0:p.call(d);if(a)o.schema=a;else{const y={...n,schemaPath:[...n.schemaPath,t],path:n.path};if(t._zod.processJSONSchema)t._zod.processJSONSchema(e,o.schema,y);else{const E=o.schema,k=e.processors[s.type];if(!k)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${s.type}`);k(t,e,E,y)}const m=t._zod.parent;m&&(o.ref||(o.ref=m),me(m,e,y),e.seen.get(m).isParent=!0)}const l=e.metadataRegistry.get(t);return l&&Object.assign(o.schema,l),e.io==="input"&&Re(t)&&(delete o.schema.examples,delete o.schema.default),e.io==="input"&&o.schema._prefault&&((r=o.schema).default??(r.default=o.schema._prefault)),delete o.schema._prefault,e.seen.get(t).schema}function ig(t,e){var o,a,l,c;const n=t.seen.get(e);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");const r=new Map;for(const d of t.seen.entries()){const p=(o=t.metadataRegistry.get(d[0]))==null?void 0:o.id;if(p){const y=r.get(p);if(y&&y!==d[0])throw new Error(`Duplicate schema id "${p}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);r.set(p,d[0])}}const s=d=>{var k;const p=t.target==="draft-2020-12"?"$defs":"definitions";if(t.external){const I=(k=t.external.registry.get(d[0]))==null?void 0:k.id,G=t.external.uri??(j=>j);if(I)return{ref:G(I)};const N=d[1].defId??d[1].schema.id??`schema${t.counter++}`;return d[1].defId=N,{defId:N,ref:`${G("__shared")}#/${p}/${N}`}}if(d[1]===n)return{ref:"#"};const m=`#/${p}/`,E=d[1].schema.id??`__schema${t.counter++}`;return{defId:E,ref:m+E}},i=d=>{if(d[1].schema.$ref)return;const p=d[1],{ref:y,defId:m}=s(d);p.def={...p.schema},m&&(p.defId=m);const E=p.schema;for(const k in E)delete E[k];E.$ref=y};if(t.cycles==="throw")for(const d of t.seen.entries()){const p=d[1];if(p.cycle)throw new Error(`Cycle detected: #/${(a=p.cycle)==null?void 0:a.join("/")}/<root>
|
|
41
41
|
|
|
42
|
-
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(const d of t.seen.entries()){const p=d[1];if(e===d[0]){i(d);continue}if(t.external){const m=(l=t.external.registry.get(d[0]))==null?void 0:l.id;if(e!==d[0]&&m){i(d);continue}}if((c=t.metadataRegistry.get(d[0]))==null?void 0:c.id){i(d);continue}if(p.cycle){i(d);continue}if(p.count>1&&t.reused==="ref"){i(d);continue}}}function og(t,e){var o,a,l;const n=t.seen.get(e);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");const r=c=>{const d=t.seen.get(c);if(d.ref===null)return;const p=d.def??d.schema,y={...p},m=d.ref;if(d.ref=null,m){r(m);const k=t.seen.get(m),I=k.schema;if(I.$ref&&(t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0")?(p.allOf=p.allOf??[],p.allOf.push(I)):Object.assign(p,I),Object.assign(p,y),c._zod.parent===m)for(const N in p)N==="$ref"||N==="allOf"||N in y||delete p[N];if(I.$ref&&k.def)for(const N in p)N==="$ref"||N==="allOf"||N in k.def&&JSON.stringify(p[N])===JSON.stringify(k.def[N])&&delete p[N]}const E=c._zod.parent;if(E&&E!==m){r(E);const k=t.seen.get(E);if(k!=null&&k.schema.$ref&&(p.$ref=k.schema.$ref,k.def))for(const I in p)I==="$ref"||I==="allOf"||I in k.def&&JSON.stringify(p[I])===JSON.stringify(k.def[I])&&delete p[I]}t.override({zodSchema:c,jsonSchema:p,path:d.path??[]})};for(const c of[...t.seen.entries()].reverse())r(c[0]);const s={};if(t.target==="draft-2020-12"?s.$schema="https://json-schema.org/draft/2020-12/schema":t.target==="draft-07"?s.$schema="http://json-schema.org/draft-07/schema#":t.target==="draft-04"?s.$schema="http://json-schema.org/draft-04/schema#":t.target,(o=t.external)!=null&&o.uri){const c=(a=t.external.registry.get(e))==null?void 0:a.id;if(!c)throw new Error("Schema is missing an `id` property");s.$id=t.external.uri(c)}Object.assign(s,n.def??n.schema);const i=((l=t.external)==null?void 0:l.defs)??{};for(const c of t.seen.entries()){const d=c[1];d.def&&d.defId&&(i[d.defId]=d.def)}t.external||Object.keys(i).length>0&&(t.target==="draft-2020-12"?s.$defs=i:s.definitions=i);try{const c=JSON.parse(JSON.stringify(s));return Object.defineProperty(c,"~standard",{value:{...e["~standard"],jsonSchema:{input:vo(e,"input",t.processors),output:vo(e,"output",t.processors)}},enumerable:!1,writable:!1}),c}catch{throw new Error("Error converting schema to JSON.")}}function Re(t,e){const n=e??{seen:new Set};if(n.seen.has(t))return!1;n.seen.add(t);const r=t._zod.def;if(r.type==="transform")return!0;if(r.type==="array")return Re(r.element,n);if(r.type==="set")return Re(r.valueType,n);if(r.type==="lazy")return Re(r.getter(),n);if(r.type==="promise"||r.type==="optional"||r.type==="nonoptional"||r.type==="nullable"||r.type==="readonly"||r.type==="default"||r.type==="prefault")return Re(r.innerType,n);if(r.type==="intersection")return Re(r.left,n)||Re(r.right,n);if(r.type==="record"||r.type==="map")return Re(r.keyType,n)||Re(r.valueType,n);if(r.type==="pipe")return Re(r.in,n)||Re(r.out,n);if(r.type==="object"){for(const s in r.shape)if(Re(r.shape[s],n))return!0;return!1}if(r.type==="union"){for(const s of r.options)if(Re(s,n))return!0;return!1}if(r.type==="tuple"){for(const s of r.items)if(Re(s,n))return!0;return!!(r.rest&&Re(r.rest,n))}return!1}const Nx=(t,e={})=>n=>{const r=sg({...n,processors:e});return me(t,r),ig(r,t),og(r,t)},vo=(t,e,n={})=>r=>{const{libraryOptions:s,target:i}=r??{},o=sg({...s??{},target:i,io:e,processors:n});return me(t,o),ig(o,t),og(o,t)},Ux={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},Fx=(t,e,n,r)=>{const s=n;s.type="string";const{minimum:i,maximum:o,format:a,patterns:l,contentEncoding:c}=t._zod.bag;if(typeof i=="number"&&(s.minLength=i),typeof o=="number"&&(s.maxLength=o),a&&(s.format=Ux[a]??a,s.format===""&&delete s.format,a==="time"&&delete s.format),c&&(s.contentEncoding=c),l&&l.size>0){const d=[...l];d.length===1?s.pattern=d[0].source:d.length>1&&(s.allOf=[...d.map(p=>({...e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0"?{type:"string"}:{},pattern:p.source}))])}},Zx=(t,e,n,r)=>{const s=n,{minimum:i,maximum:o,format:a,multipleOf:l,exclusiveMaximum:c,exclusiveMinimum:d}=t._zod.bag;typeof a=="string"&&a.includes("int")?s.type="integer":s.type="number",typeof d=="number"&&(e.target==="draft-04"||e.target==="openapi-3.0"?(s.minimum=d,s.exclusiveMinimum=!0):s.exclusiveMinimum=d),typeof i=="number"&&(s.minimum=i,typeof d=="number"&&e.target!=="draft-04"&&(d>=i?delete s.minimum:delete s.exclusiveMinimum)),typeof c=="number"&&(e.target==="draft-04"||e.target==="openapi-3.0"?(s.maximum=c,s.exclusiveMaximum=!0):s.exclusiveMaximum=c),typeof o=="number"&&(s.maximum=o,typeof c=="number"&&e.target!=="draft-04"&&(c<=o?delete s.maximum:delete s.exclusiveMaximum)),typeof l=="number"&&(s.multipleOf=l)},jx=(t,e,n,r)=>{n.type="boolean"},Wx=(t,e,n,r)=>{n.not={}},Bx=(t,e,n,r)=>{},Gx=(t,e,n,r)=>{const s=t._zod.def,i=Nf(s.entries);i.every(o=>typeof o=="number")&&(n.type="number"),i.every(o=>typeof o=="string")&&(n.type="string"),n.enum=i},Vx=(t,e,n,r)=>{const s=t._zod.def,i=[];for(const o of s.values)if(o===void 0){if(e.unrepresentable==="throw")throw new Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof o=="bigint"){if(e.unrepresentable==="throw")throw new Error("BigInt literals cannot be represented in JSON Schema");i.push(Number(o))}else i.push(o);if(i.length!==0)if(i.length===1){const o=i[0];n.type=o===null?"null":typeof o,e.target==="draft-04"||e.target==="openapi-3.0"?n.enum=[o]:n.const=o}else i.every(o=>typeof o=="number")&&(n.type="number"),i.every(o=>typeof o=="string")&&(n.type="string"),i.every(o=>typeof o=="boolean")&&(n.type="boolean"),i.every(o=>o===null)&&(n.type="null"),n.enum=i},Hx=(t,e,n,r)=>{if(e.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema")},qx=(t,e,n,r)=>{if(e.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema")},Yx=(t,e,n,r)=>{const s=n,i=t._zod.def,{minimum:o,maximum:a}=t._zod.bag;typeof o=="number"&&(s.minItems=o),typeof a=="number"&&(s.maxItems=a),s.type="array",s.items=me(i.element,e,{...r,path:[...r.path,"items"]})},Kx=(t,e,n,r)=>{var c;const s=n,i=t._zod.def;s.type="object",s.properties={};const o=i.shape;for(const d in o)s.properties[d]=me(o[d],e,{...r,path:[...r.path,"properties",d]});const a=new Set(Object.keys(o)),l=new Set([...a].filter(d=>{const p=i.shape[d]._zod;return e.io==="input"?p.optin===void 0:p.optout===void 0}));l.size>0&&(s.required=Array.from(l)),((c=i.catchall)==null?void 0:c._zod.def.type)==="never"?s.additionalProperties=!1:i.catchall?i.catchall&&(s.additionalProperties=me(i.catchall,e,{...r,path:[...r.path,"additionalProperties"]})):e.io==="output"&&(s.additionalProperties=!1)},Jx=(t,e,n,r)=>{const s=t._zod.def,i=s.inclusive===!1,o=s.options.map((a,l)=>me(a,e,{...r,path:[...r.path,i?"oneOf":"anyOf",l]}));i?n.oneOf=o:n.anyOf=o},Xx=(t,e,n,r)=>{const s=t._zod.def,i=me(s.left,e,{...r,path:[...r.path,"allOf",0]}),o=me(s.right,e,{...r,path:[...r.path,"allOf",1]}),a=c=>"allOf"in c&&Object.keys(c).length===1,l=[...a(i)?i.allOf:[i],...a(o)?o.allOf:[o]];n.allOf=l},Qx=(t,e,n,r)=>{const s=n,i=t._zod.def;s.type="object";const o=i.keyType,a=o._zod.bag,l=a==null?void 0:a.patterns;if(i.mode==="loose"&&l&&l.size>0){const d=me(i.valueType,e,{...r,path:[...r.path,"patternProperties","*"]});s.patternProperties={};for(const p of l)s.patternProperties[p.source]=d}else(e.target==="draft-07"||e.target==="draft-2020-12")&&(s.propertyNames=me(i.keyType,e,{...r,path:[...r.path,"propertyNames"]})),s.additionalProperties=me(i.valueType,e,{...r,path:[...r.path,"additionalProperties"]});const c=o._zod.values;if(c){const d=[...c].filter(p=>typeof p=="string"||typeof p=="number");d.length>0&&(s.required=d)}},eT=(t,e,n,r)=>{const s=t._zod.def,i=me(s.innerType,e,r),o=e.seen.get(t);e.target==="openapi-3.0"?(o.ref=s.innerType,n.nullable=!0):n.anyOf=[i,{type:"null"}]},tT=(t,e,n,r)=>{const s=t._zod.def;me(s.innerType,e,r);const i=e.seen.get(t);i.ref=s.innerType},nT=(t,e,n,r)=>{const s=t._zod.def;me(s.innerType,e,r);const i=e.seen.get(t);i.ref=s.innerType,n.default=JSON.parse(JSON.stringify(s.defaultValue))},rT=(t,e,n,r)=>{const s=t._zod.def;me(s.innerType,e,r);const i=e.seen.get(t);i.ref=s.innerType,e.io==="input"&&(n._prefault=JSON.parse(JSON.stringify(s.defaultValue)))},sT=(t,e,n,r)=>{const s=t._zod.def;me(s.innerType,e,r);const i=e.seen.get(t);i.ref=s.innerType;let o;try{o=s.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}n.default=o},iT=(t,e,n,r)=>{const s=t._zod.def,i=e.io==="input"?s.in._zod.def.type==="transform"?s.out:s.in:s.out;me(i,e,r);const o=e.seen.get(t);o.ref=i},oT=(t,e,n,r)=>{const s=t._zod.def;me(s.innerType,e,r);const i=e.seen.get(t);i.ref=s.innerType,n.readOnly=!0},ag=(t,e,n,r)=>{const s=t._zod.def;me(s.innerType,e,r);const i=e.seen.get(t);i.ref=s.innerType},aT=S("ZodISODateTime",(t,e)=>{lA.init(t,e),ue.init(t,e)});function lT(t){return fx(aT,t)}const cT=S("ZodISODate",(t,e)=>{cA.init(t,e),ue.init(t,e)});function uT(t){return gx(cT,t)}const hT=S("ZodISOTime",(t,e)=>{uA.init(t,e),ue.init(t,e)});function dT(t){return mx(hT,t)}const pT=S("ZodISODuration",(t,e)=>{hA.init(t,e),ue.init(t,e)});function fT(t){return vx(pT,t)}const lg=(t,e)=>{jf.init(t,e),t.name="ZodError",Object.defineProperties(t,{format:{value:n=>t$(t,n)},flatten:{value:n=>e$(t,n)},addIssue:{value:n=>{t.issues.push(n),t.message=JSON.stringify(t.issues,yl,2)}},addIssues:{value:n=>{t.issues.push(...n),t.message=JSON.stringify(t.issues,yl,2)}},isEmpty:{get(){return t.issues.length===0}}})},md=S("ZodError",lg),tt=S("ZodError",lg,{Parent:Error}),gT=Oc(tt),mT=zc(tt),vT=Zo(tt),yT=jo(tt),bT=s$(tt),wT=i$(tt),_T=o$(tt),ST=a$(tt),kT=l$(tt),ET=c$(tt),$T=u$(tt),AT=h$(tt),ce=S("ZodType",(t,e)=>(le.init(t,e),Object.assign(t["~standard"],{jsonSchema:{input:vo(t,"input"),output:vo(t,"output")}}),t.toJSONSchema=Nx(t,{}),t.def=e,t.type=e.type,Object.defineProperty(t,"_def",{value:e}),t.check=(...n)=>t.clone(pn(e,{checks:[...e.checks??[],...n.map(r=>typeof r=="function"?{_zod:{check:r,def:{check:"custom"},onattach:[]}}:r)]}),{parent:!0}),t.with=t.check,t.clone=(n,r)=>fn(t,n,r),t.brand=()=>t,t.register=(n,r)=>(n.add(t,r),t),t.parse=(n,r)=>gT(t,n,r,{callee:t.parse}),t.safeParse=(n,r)=>vT(t,n,r),t.parseAsync=async(n,r)=>mT(t,n,r,{callee:t.parseAsync}),t.safeParseAsync=async(n,r)=>yT(t,n,r),t.spa=t.safeParseAsync,t.encode=(n,r)=>bT(t,n,r),t.decode=(n,r)=>wT(t,n,r),t.encodeAsync=async(n,r)=>_T(t,n,r),t.decodeAsync=async(n,r)=>ST(t,n,r),t.safeEncode=(n,r)=>kT(t,n,r),t.safeDecode=(n,r)=>ET(t,n,r),t.safeEncodeAsync=async(n,r)=>$T(t,n,r),t.safeDecodeAsync=async(n,r)=>AT(t,n,r),t.refine=(n,r)=>t.check(vC(n,r)),t.superRefine=n=>t.check(yC(n)),t.overwrite=n=>t.check(qr(n)),t.optional=()=>bd(t),t.exactOptional=()=>sC(t),t.nullable=()=>wd(t),t.nullish=()=>bd(wd(t)),t.nonoptional=n=>uC(t,n),t.array=()=>R(t),t.or=n=>Z([t,n]),t.and=n=>Bo(t,n),t.transform=n=>_d(t,nC(n)),t.default=n=>aC(t,n),t.prefault=n=>cC(t,n),t.catch=n=>dC(t,n),t.pipe=n=>_d(t,n),t.readonly=()=>gC(t),t.describe=n=>{const r=t.clone();return gs.add(r,{description:n}),r},Object.defineProperty(t,"description",{get(){var n;return(n=gs.get(t))==null?void 0:n.description},configurable:!0}),t.meta=(...n)=>{if(n.length===0)return gs.get(t);const r=t.clone();return gs.add(r,n[0]),r},t.isOptional=()=>t.safeParse(void 0).success,t.isNullable=()=>t.safeParse(null).success,t.apply=n=>n(t),t)),cg=S("_ZodString",(t,e)=>{Lc.init(t,e),ce.init(t,e),t._zod.processJSONSchema=(r,s,i)=>Fx(t,r,s);const n=t._zod.bag;t.format=n.format??null,t.minLength=n.minimum??null,t.maxLength=n.maximum??null,t.regex=(...r)=>t.check(kx(...r)),t.includes=(...r)=>t.check(Ax(...r)),t.startsWith=(...r)=>t.check(xx(...r)),t.endsWith=(...r)=>t.check(Tx(...r)),t.min=(...r)=>t.check(mo(...r)),t.max=(...r)=>t.check(ng(...r)),t.length=(...r)=>t.check(rg(...r)),t.nonempty=(...r)=>t.check(mo(1,...r)),t.lowercase=r=>t.check(Ex(r)),t.uppercase=r=>t.check($x(r)),t.trim=()=>t.check(Ix()),t.normalize=(...r)=>t.check(Cx(...r)),t.toLowerCase=()=>t.check(Px()),t.toUpperCase=()=>t.check(Rx()),t.slugify=()=>t.check(Dx())}),xT=S("ZodString",(t,e)=>{Lc.init(t,e),cg.init(t,e),t.email=n=>t.check(HA(TT,n)),t.url=n=>t.check(XA(CT,n)),t.jwt=n=>t.check(px(BT,n)),t.emoji=n=>t.check(QA(IT,n)),t.guid=n=>t.check(dd(vd,n)),t.uuid=n=>t.check(qA(Ui,n)),t.uuidv4=n=>t.check(YA(Ui,n)),t.uuidv6=n=>t.check(KA(Ui,n)),t.uuidv7=n=>t.check(JA(Ui,n)),t.nanoid=n=>t.check(ex(PT,n)),t.guid=n=>t.check(dd(vd,n)),t.cuid=n=>t.check(tx(RT,n)),t.cuid2=n=>t.check(nx(DT,n)),t.ulid=n=>t.check(rx(OT,n)),t.base64=n=>t.check(ux(ZT,n)),t.base64url=n=>t.check(hx(jT,n)),t.xid=n=>t.check(sx(zT,n)),t.ksuid=n=>t.check(ix(LT,n)),t.ipv4=n=>t.check(ox(MT,n)),t.ipv6=n=>t.check(ax(NT,n)),t.cidrv4=n=>t.check(lx(UT,n)),t.cidrv6=n=>t.check(cx(FT,n)),t.e164=n=>t.check(dx(WT,n)),t.datetime=n=>t.check(lT(n)),t.date=n=>t.check(uT(n)),t.time=n=>t.check(dT(n)),t.duration=n=>t.check(fT(n))});function h(t){return VA(xT,t)}const ue=S("ZodStringFormat",(t,e)=>{oe.init(t,e),cg.init(t,e)}),TT=S("ZodEmail",(t,e)=>{Q$.init(t,e),ue.init(t,e)}),vd=S("ZodGUID",(t,e)=>{J$.init(t,e),ue.init(t,e)}),Ui=S("ZodUUID",(t,e)=>{X$.init(t,e),ue.init(t,e)}),CT=S("ZodURL",(t,e)=>{eA.init(t,e),ue.init(t,e)}),IT=S("ZodEmoji",(t,e)=>{tA.init(t,e),ue.init(t,e)}),PT=S("ZodNanoID",(t,e)=>{nA.init(t,e),ue.init(t,e)}),RT=S("ZodCUID",(t,e)=>{rA.init(t,e),ue.init(t,e)}),DT=S("ZodCUID2",(t,e)=>{sA.init(t,e),ue.init(t,e)}),OT=S("ZodULID",(t,e)=>{iA.init(t,e),ue.init(t,e)}),zT=S("ZodXID",(t,e)=>{oA.init(t,e),ue.init(t,e)}),LT=S("ZodKSUID",(t,e)=>{aA.init(t,e),ue.init(t,e)}),MT=S("ZodIPv4",(t,e)=>{dA.init(t,e),ue.init(t,e)}),NT=S("ZodIPv6",(t,e)=>{pA.init(t,e),ue.init(t,e)}),UT=S("ZodCIDRv4",(t,e)=>{fA.init(t,e),ue.init(t,e)}),FT=S("ZodCIDRv6",(t,e)=>{gA.init(t,e),ue.init(t,e)}),ZT=S("ZodBase64",(t,e)=>{mA.init(t,e),ue.init(t,e)}),jT=S("ZodBase64URL",(t,e)=>{yA.init(t,e),ue.init(t,e)}),WT=S("ZodE164",(t,e)=>{bA.init(t,e),ue.init(t,e)}),BT=S("ZodJWT",(t,e)=>{_A.init(t,e),ue.init(t,e)}),ug=S("ZodNumber",(t,e)=>{Xf.init(t,e),ce.init(t,e),t._zod.processJSONSchema=(r,s,i)=>Zx(t,r,s),t.gt=(r,s)=>t.check(fd(r,s)),t.gte=(r,s)=>t.check(ja(r,s)),t.min=(r,s)=>t.check(ja(r,s)),t.lt=(r,s)=>t.check(pd(r,s)),t.lte=(r,s)=>t.check(Za(r,s)),t.max=(r,s)=>t.check(Za(r,s)),t.int=r=>t.check(yd(r)),t.safe=r=>t.check(yd(r)),t.positive=r=>t.check(fd(0,r)),t.nonnegative=r=>t.check(ja(0,r)),t.negative=r=>t.check(pd(0,r)),t.nonpositive=r=>t.check(Za(0,r)),t.multipleOf=(r,s)=>t.check(gd(r,s)),t.step=(r,s)=>t.check(gd(r,s)),t.finite=()=>t;const n=t._zod.bag;t.minValue=Math.max(n.minimum??Number.NEGATIVE_INFINITY,n.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,t.maxValue=Math.min(n.maximum??Number.POSITIVE_INFINITY,n.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,t.isInt=(n.format??"").includes("int")||Number.isSafeInteger(n.multipleOf??.5),t.isFinite=!0,t.format=n.format??null});function U(t){return yx(ug,t)}const GT=S("ZodNumberFormat",(t,e)=>{SA.init(t,e),ug.init(t,e)});function yd(t){return bx(GT,t)}const VT=S("ZodBoolean",(t,e)=>{kA.init(t,e),ce.init(t,e),t._zod.processJSONSchema=(n,r,s)=>jx(t,n,r)});function ke(t){return wx(VT,t)}const HT=S("ZodUnknown",(t,e)=>{EA.init(t,e),ce.init(t,e),t._zod.processJSONSchema=(n,r,s)=>Bx()});function w(){return _x(HT)}const qT=S("ZodNever",(t,e)=>{$A.init(t,e),ce.init(t,e),t._zod.processJSONSchema=(n,r,s)=>Wx(t,n,r)});function YT(t){return Sx(qT,t)}const KT=S("ZodArray",(t,e)=>{AA.init(t,e),ce.init(t,e),t._zod.processJSONSchema=(n,r,s)=>Yx(t,n,r,s),t.element=e.element,t.min=(n,r)=>t.check(mo(n,r)),t.nonempty=n=>t.check(mo(1,n)),t.max=(n,r)=>t.check(ng(n,r)),t.length=(n,r)=>t.check(rg(n,r)),t.unwrap=()=>t.element});function R(t,e){return Ox(KT,t,e)}const hg=S("ZodObject",(t,e)=>{TA.init(t,e),ce.init(t,e),t._zod.processJSONSchema=(n,r,s)=>Kx(t,n,r,s),ee(t,"shape",()=>e.shape),t.keyof=()=>yo(Object.keys(t._zod.def.shape)),t.catchall=n=>t.clone({...t._zod.def,catchall:n}),t.passthrough=()=>t.clone({...t._zod.def,catchall:w()}),t.loose=()=>t.clone({...t._zod.def,catchall:w()}),t.strict=()=>t.clone({...t._zod.def,catchall:YT()}),t.strip=()=>t.clone({...t._zod.def,catchall:void 0}),t.extend=n=>YE(t,n),t.safeExtend=n=>KE(t,n),t.merge=n=>JE(t,n),t.pick=n=>HE(t,n),t.omit=n=>qE(t,n),t.partial=(...n)=>XE(pg,t,n[0]),t.required=(...n)=>QE(fg,t,n[0])});function dg(t,e){const n={type:"object",shape:t??{},...O(e)};return new hg(n)}function f(t,e){return new hg({type:"object",shape:t,catchall:w(),...O(e)})}const JT=S("ZodUnion",(t,e)=>{CA.init(t,e),ce.init(t,e),t._zod.processJSONSchema=(n,r,s)=>Jx(t,n,r,s),t.options=e.options});function Z(t,e){return new JT({type:"union",options:t,...O(e)})}const XT=S("ZodIntersection",(t,e)=>{IA.init(t,e),ce.init(t,e),t._zod.processJSONSchema=(n,r,s)=>Xx(t,n,r,s)});function Bo(t,e){return new XT({type:"intersection",left:t,right:e})}const QT=S("ZodRecord",(t,e)=>{PA.init(t,e),ce.init(t,e),t._zod.processJSONSchema=(n,r,s)=>Qx(t,n,r,s),t.keyType=e.keyType,t.valueType=e.valueType});function _(t,e,n){return new QT({type:"record",keyType:t,valueType:e,...O(n)})}const wl=S("ZodEnum",(t,e)=>{RA.init(t,e),ce.init(t,e),t._zod.processJSONSchema=(r,s,i)=>Gx(t,r,s),t.enum=e.entries,t.options=Object.values(e.entries);const n=new Set(Object.keys(e.entries));t.extract=(r,s)=>{const i={};for(const o of r)if(n.has(o))i[o]=e.entries[o];else throw new Error(`Key ${o} not found in enum`);return new wl({...e,checks:[],...O(s),entries:i})},t.exclude=(r,s)=>{const i={...e.entries};for(const o of r)if(n.has(o))delete i[o];else throw new Error(`Key ${o} not found in enum`);return new wl({...e,checks:[],...O(s),entries:i})}});function yo(t,e){const n=Array.isArray(t)?Object.fromEntries(t.map(r=>[r,r])):t;return new wl({type:"enum",entries:n,...O(e)})}const eC=S("ZodLiteral",(t,e)=>{DA.init(t,e),ce.init(t,e),t._zod.processJSONSchema=(n,r,s)=>Vx(t,n,r),t.values=new Set(e.values),Object.defineProperty(t,"value",{get(){if(e.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return e.values[0]}})});function A(t,e){return new eC({type:"literal",values:Array.isArray(t)?t:[t],...O(e)})}const tC=S("ZodTransform",(t,e)=>{OA.init(t,e),ce.init(t,e),t._zod.processJSONSchema=(n,r,s)=>qx(t,n),t._zod.parse=(n,r)=>{if(r.direction==="backward")throw new Lf(t.constructor.name);n.addIssue=i=>{if(typeof i=="string")n.issues.push(Ts(i,n.value,e));else{const o=i;o.fatal&&(o.continue=!1),o.code??(o.code="custom"),o.input??(o.input=n.value),o.inst??(o.inst=t),n.issues.push(Ts(o))}};const s=e.transform(n.value,n);return s instanceof Promise?s.then(i=>(n.value=i,n)):(n.value=s,n)}});function nC(t){return new tC({type:"transform",transform:t})}const pg=S("ZodOptional",(t,e)=>{tg.init(t,e),ce.init(t,e),t._zod.processJSONSchema=(n,r,s)=>ag(t,n,r,s),t.unwrap=()=>t._zod.def.innerType});function bd(t){return new pg({type:"optional",innerType:t})}const rC=S("ZodExactOptional",(t,e)=>{zA.init(t,e),ce.init(t,e),t._zod.processJSONSchema=(n,r,s)=>ag(t,n,r,s),t.unwrap=()=>t._zod.def.innerType});function sC(t){return new rC({type:"optional",innerType:t})}const iC=S("ZodNullable",(t,e)=>{LA.init(t,e),ce.init(t,e),t._zod.processJSONSchema=(n,r,s)=>eT(t,n,r,s),t.unwrap=()=>t._zod.def.innerType});function wd(t){return new iC({type:"nullable",innerType:t})}const oC=S("ZodDefault",(t,e)=>{MA.init(t,e),ce.init(t,e),t._zod.processJSONSchema=(n,r,s)=>nT(t,n,r,s),t.unwrap=()=>t._zod.def.innerType,t.removeDefault=t.unwrap});function aC(t,e){return new oC({type:"default",innerType:t,get defaultValue(){return typeof e=="function"?e():Ff(e)}})}const lC=S("ZodPrefault",(t,e)=>{NA.init(t,e),ce.init(t,e),t._zod.processJSONSchema=(n,r,s)=>rT(t,n,r,s),t.unwrap=()=>t._zod.def.innerType});function cC(t,e){return new lC({type:"prefault",innerType:t,get defaultValue(){return typeof e=="function"?e():Ff(e)}})}const fg=S("ZodNonOptional",(t,e)=>{UA.init(t,e),ce.init(t,e),t._zod.processJSONSchema=(n,r,s)=>tT(t,n,r,s),t.unwrap=()=>t._zod.def.innerType});function uC(t,e){return new fg({type:"nonoptional",innerType:t,...O(e)})}const hC=S("ZodCatch",(t,e)=>{FA.init(t,e),ce.init(t,e),t._zod.processJSONSchema=(n,r,s)=>sT(t,n,r,s),t.unwrap=()=>t._zod.def.innerType,t.removeCatch=t.unwrap});function dC(t,e){return new hC({type:"catch",innerType:t,catchValue:typeof e=="function"?e:()=>e})}const pC=S("ZodPipe",(t,e)=>{ZA.init(t,e),ce.init(t,e),t._zod.processJSONSchema=(n,r,s)=>iT(t,n,r,s),t.in=e.in,t.out=e.out});function _d(t,e){return new pC({type:"pipe",in:t,out:e})}const fC=S("ZodReadonly",(t,e)=>{jA.init(t,e),ce.init(t,e),t._zod.processJSONSchema=(n,r,s)=>oT(t,n,r,s),t.unwrap=()=>t._zod.def.innerType});function gC(t){return new fC({type:"readonly",innerType:t})}const mC=S("ZodCustom",(t,e)=>{WA.init(t,e),ce.init(t,e),t._zod.processJSONSchema=(n,r,s)=>Hx(t,n)});function vC(t,e={}){return zx(mC,t,e)}function yC(t){return Lx(t)}const bC=["text/markdown","text/html"],wC=["committed","pending"];dg({id:h().min(1),type:yo(bC),title:h(),status:yo(wC),externalFilePath:h().optional()});dg({name:h().min(1),description:h(),accepts:R(h().min(1)).min(1)});function Mc(t){return typeof t=="object"&&t!==null}function _C(t){return!Mc(t)||t.type!=="ready"?!1:!("id"in t)}function SC(t){return!(!Mc(t)||t.type!=="update-content"||typeof t.id!="string"||typeof t.content!="string")}function kC(t){return!Mc(t)||t.type!=="wheel"||typeof t.deltaX!="number"||typeof t.deltaY!="number"||typeof t.shiftKey!="boolean"?!1:!("id"in t)}function EC(t,e){if(t===e)return 2;if(t==="*/*")return 0;const n=t.indexOf("/");if(n>0&&t.slice(n+1)==="*"){const r=t.slice(0,n),s=e.indexOf("/");if(s>0&&e.slice(0,s)===r)return 1}return null}function $C(t,e){let n=null;for(const r of t.accepts){const s=EC(r,e);s!==null&&(n===null||s>n)&&(n=s)}return n}function AC(t,e){let n=-1,r=null;for(const s of e){const i=$C(s,t);i!==null&&(i>n||i===n&&r!==null&&s.id<r.id)&&(n=i,r=s)}return r}const xC=4401;class _l extends Error{constructor(e="Authentication required"){super(e),this.name="AuthError"}}class Sl extends kt{constructor(n){super();v(this,"url");v(this,"name");v(this,"token");v(this,"status","disconnected");v(this,"screens",new Map);v(this,"views",[]);v(this,"client");v(this,"createSocket");v(this,"createClient");v(this,"socket",null);v(this,"connectAttempt",0);this.url=Pt(n.url),this.name=n.name,this.token=n.token??null,this.createSocket=n.createSocket??(r=>new WebSocket(r)),this.createClient=n.createClient??((r,s)=>new PE(r,{token:s??void 0})),this.client=this.createClient(this.url,this.token)}async connect(){var s;this.connectAttempt+=1;const n=this.connectAttempt;(s=this.socket)==null||s.close(),this.client=this.createClient(this.url,this.token),this.status="connecting",this.dispatchEvent(new te("change"));const r=this.createSocket(TC(this.url,this.token));return this.socket=r,await new Promise((i,o)=>{let a=!1;const l=()=>{a||this.connectAttempt!==n||(a=!0,this.status="connected",this.dispatchEvent(new te("change")),i())},c=p=>{a||this.connectAttempt!==n||(a=!0,this.status="disconnected",this.dispatchEvent(new te("change")),o(p))},d=async()=>{try{const[{screens:p},y]=await Promise.all([this.client.screens.list(),this.client.views.list()]);this.screens=new Map(p.map(m=>[m.id,structuredClone(m)])),this.views=y,this.dispatchEvent(new te("change")),l()}catch(p){c(p instanceof Error?p:new Error(String(p)))}};r.addEventListener("open",()=>{d()}),r.addEventListener("message",p=>{const y=IC(p);y&&(this.applyServerEvent(y),this.dispatchEvent(new $f("server-event",{serverURL:this.url,event:y})))}),r.addEventListener("close",p=>{if(this.connectAttempt===n){if(this.socket=null,CC(p)===xC){c(new _l);return}if(!a){c(new Error("Connection closed before initialization"));return}this.status="disconnected",this.dispatchEvent(new te("change"))}}),r.addEventListener("error",()=>{c(new Error("WebSocket connection failed"))})})}disconnect(){var n;this.connectAttempt+=1,(n=this.socket)==null||n.close(),this.socket=null,this.status="disconnected",this.dispatchEvent(new te("change"))}getViewURL(n){const r=AC(n.type,this.views);if(!r)return null;const s=`${this.url}/views/${encodeURIComponent(r.id)}/`;return this.token===null?s:`${s}?token=${encodeURIComponent(this.token)}`}getContentURL(n){const r=`${this.url}/artifacts/${encodeURIComponent(n)}/content`;return this.token===null?r:`${r}?token=${encodeURIComponent(this.token)}`}async createScreen(n){const{screen:r}=await this.client.screens.create({name:n});return this.screens.set(r.id,structuredClone(r)),r}applyServerEvent(n){switch(n.type){case"screen-created":this.screens.set(n.screen.id,structuredClone(n.screen)),this.dispatchEvent(new eo("screens-changed"));break;case"screen-updated":this.screens.set(n.screen.id,structuredClone(n.screen)),this.dispatchEvent(new eo("screens-changed"));break;case"screen-removed":this.screens.delete(n.screenID),this.dispatchEvent(new eo("screens-changed"));break;case"artifact-created":{const r=this.screens.get(n.screenID);r&&!Sf(r.layout,n.artifact.id)&&(r.layout=[...r.layout,_f(n.artifact.id)]);break}case"artifact-removed":{const r=this.screens.get(n.screenID);r&&(r.layout=df(r.layout,n.artifactID));break}}}}function TC(t,e){const n=new URL(t);return n.protocol=n.protocol==="https:"?"wss:":"ws:",n.pathname="/events",n.search="",e&&n.searchParams.set("token",e),n.hash="",n.toString()}function CC(t){return typeof t=="object"&&t!==null&&"code"in t&&typeof t.code=="number"?t.code:null}function IC(t){const e=typeof t=="string"?t:typeof t=="object"&&t!==null&&"data"in t&&typeof t.data=="string"?t.data:"";if(!e)return null;try{return JSON.parse(e)}catch{return null}}class PC extends kt{constructor(n){super();v(this,"servers",new Map);v(this,"localServerURL");v(this,"localStore");v(this,"createSocket");v(this,"lastActiveServerURL");v(this,"serverListeners",new Map);v(this,"handleLocalStoreChange",()=>{const n=this.localStore.get().activeServerURL;n!==this.lastActiveServerURL&&(this.lastActiveServerURL=n,this.dispatchEvent(new te("change")))});this.localStore=n.localStore,this.localServerURL=n.localServerURL?Pt(n.localServerURL):null,this.createSocket=n.createSocket??(r=>new WebSocket(r)),this.lastActiveServerURL=this.localStore.get().activeServerURL,this.localStore.addEventListener("change",this.handleLocalStoreChange)}get activeServer(){const n=this.localStore.get().activeServerURL;return n===null?null:this.servers.get(n)??null}add(n){const r=Pt(n.url);this.servers.get(r)&&this.remove(r),this.servers.set(r,n);const i=()=>{this.dispatchEvent(new te("change"))},o=l=>{this.dispatchEvent(new $f("server-event",{serverURL:l.serverURL,event:l.event}))},a=()=>{this.dispatchEvent(new eo("screens-changed"))};n.addEventListener("change",i),n.addEventListener("server-event",o),n.addEventListener("screens-changed",a),this.serverListeners.set(r,{onServerChange:i,onServerEvent:o,onScreensChanged:a}),this.dispatchEvent(new te("change"))}remove(n){const r=Pt(n);if(this.localServerURL&&r===this.localServerURL)return;const s=this.servers.get(r);if(!s)return;const i=this.serverListeners.get(r);i&&(s.removeEventListener("change",i.onServerChange),s.removeEventListener("server-event",i.onServerEvent),s.removeEventListener("screens-changed",i.onScreensChanged),this.serverListeners.delete(r)),s.disconnect(),this.servers.delete(r);const o=this.localStore.get(),a=o.activeServerURL===r;this.localStore.set({...o,servers:o.servers.filter(l=>l.url!==r),activeServerURL:a?null:o.activeServerURL}),this.dispatchEvent(new te("change"))}setActive(n){const r=this.localStore.get(),s=n?Pt(n.url):null;r.activeServerURL!==s&&this.localStore.set({...r,activeServerURL:s})}connectConfiguredServers(n){const r=this.localStore.get().servers;for(const i of r){const o=new Sl({url:i.url,name:i.name,createSocket:this.createSocket});this.add(o),o.connect().catch(()=>{})}const s=n?this.servers.get(Pt(n))??null:null;this.setActive(s??this.servers.values().next().value??null)}addServer(n,r){const s=Pt(n);this.remove(s);const i=this.localStore.get();this.localStore.set({...i,servers:[...i.servers.filter(a=>Pt(a.url)!==s),{url:s,name:r}]});const o=new Sl({url:s,name:r,createSocket:this.createSocket});this.add(o),this.setActive(o),o.connect().catch(()=>{})}removeServer(n){this.remove(n)}}const ie={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"},Tt={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"},RC=1,DC=f({_meta:_(h(),w()).nullish(),terminal:ke().optional().default(!1)}),OC=f({_meta:_(h(),w()).nullish(),label:h().nullish(),name:h(),optional:ke().optional().default(!1),secret:ke().optional().default(!0)}),zC=f({_meta:_(h(),w()).nullish(),description:h().nullish(),id:h(),name:h()}),LC=f({_meta:_(h(),w()).nullish(),description:h().nullish(),id:h(),link:h().nullish(),name:h(),vars:R(OC)}),MC=f({_meta:_(h(),w()).nullish(),args:R(h()).optional(),description:h().nullish(),env:_(h(),h()).optional(),id:h(),name:h()}),NC=Z([LC.and(f({type:A("env_var")})),MC.and(f({type:A("terminal")})),zC]),UC=f({_meta:_(h(),w()).nullish(),methodId:h()}),FC=f({_meta:_(h(),w()).nullish()}),ZC=f({_meta:_(h(),w()).nullish(),blob:h(),mimeType:h().nullish(),uri:h()}),jC=f({default:ke().nullish(),description:h().nullish(),title:h().nullish()}),WC=f({_meta:_(h(),w()).nullish()}),BC=f({_meta:_(h(),w()).nullish()}),GC=f({amount:U(),currency:h()}),VC=f({_meta:_(h(),w()).nullish(),terminalId:h()}),HC=f({_meta:_(h(),w()).nullish(),newText:h(),oldText:h().nullish(),path:h()}),qC=Z([h(),U(),U(),ke(),R(h())]),YC=f({content:_(h(),qC).nullish()}),KC=Z([YC.and(f({action:A("accept")})),f({action:A("decline")}),f({action:A("cancel")})]),JC=f({_meta:_(h(),w()).nullish()}),gg=h(),XC=f({_meta:_(h(),w()).nullish(),elicitationId:gg}),QC=f({_meta:_(h(),w()).nullish(),action:KC}),eI=A("object"),tI=A("string"),nI=f({_meta:_(h(),w()).nullish()}),rI=f({_meta:_(h(),w()).nullish(),form:JC.nullish(),url:nI.nullish()}),sI=f({elicitationId:gg,url:h().url()}),mg=f({const:h(),title:h()}),vg=f({_meta:_(h(),w()).nullish(),name:h(),value:h()}),iI=Z([A(-32700),A(-32600),A(-32601),A(-32602),A(-32603),A(-32800),A(-32e3),A(-32002),A(-32042),U().int().min(-2147483648,{message:"Invalid value: Expected int32 to be >= -2147483648"}).max(2147483647,{message:"Invalid value: Expected int32 to be <= 2147483647"})]),yg=f({code:iI,data:w().optional(),message:h()}),bg=w(),wg=w(),_g=w(),oI=f({_meta:_(h(),w()).nullish(),readTextFile:ke().optional().default(!1),writeTextFile:ke().optional().default(!1)}),Sg=f({_meta:_(h(),w()).nullish(),name:h(),value:h()}),kg=f({_meta:_(h(),w()).nullish(),name:h(),title:h().nullish(),version:h()}),aI=f({default:U().nullish(),description:h().nullish(),maximum:U().nullish(),minimum:U().nullish(),title:h().nullish()}),lI=f({_meta:_(h(),w()).nullish()}),cI=f({_meta:_(h(),w()).nullish(),additionalDirectories:R(h()).optional(),cursor:h().nullish(),cwd:h().nullish()}),uI=f({_meta:_(h(),w()).nullish()}),hI=f({_meta:_(h(),w()).nullish(),logout:uI.nullish()}),dI=f({_meta:_(h(),w()).nullish()}),pI=f({_meta:_(h(),w()).nullish()}),fI=f({_meta:_(h(),w()).nullish(),http:ke().optional().default(!1),sse:ke().optional().default(!1)}),gI=f({_meta:_(h(),w()).nullish(),headers:R(Sg),name:h(),url:h()}),mI=f({_meta:_(h(),w()).nullish(),headers:R(Sg),name:h(),url:h()}),vI=f({_meta:_(h(),w()).nullish(),args:R(h()),command:h(),env:R(vg),name:h()}),Go=Z([gI.and(f({type:A("http")})),mI.and(f({type:A("sse")})),vI]),Nc=h(),yI=f({_meta:_(h(),w()).nullish(),description:h().nullish(),modelId:Nc,name:h()}),bI=Z([A("error"),A("warning"),A("information"),A("hint")]),wI=f({_meta:_(h(),w()).nullish()}),_I=f({_meta:_(h(),w()).nullish()}),SI=f({_meta:_(h(),w()).nullish()}),kI=f({_meta:_(h(),w()).nullish()}),EI=f({_meta:_(h(),w()).nullish()}),$I=f({_meta:_(h(),w()).nullish(),maxCount:U().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish()}),AI=f({diff:h(),uri:h()}),xI=f({endLine:U().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}),startLine:U().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}),text:h()}),TI=f({_meta:_(h(),w()).nullish()}),CI=f({_meta:_(h(),w()).nullish()}),II=f({languageId:h(),text:h(),uri:h()}),PI=f({_meta:_(h(),w()).nullish(),maxCount:U().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish()}),RI=Z([A("rejected"),A("ignored"),A("replaced"),A("cancelled")]),DI=f({excerpts:R(xI),uri:h()}),OI=f({_meta:_(h(),w()).nullish()}),zI=f({_meta:_(h(),w()).nullish()}),LI=f({name:h(),owner:h(),remoteUrl:h()}),MI=f({_meta:_(h(),w()).nullish()}),NI=f({_meta:_(h(),w()).nullish(),jump:TI.nullish(),rename:zI.nullish(),searchAndReplace:MI.nullish()}),UI=f({id:h(),isRegex:ke().nullish(),replace:h(),search:h(),uri:h()}),FI=Z([A("automatic"),A("diagnostic"),A("manual")]),ZI=f({_meta:_(h(),w()).nullish(),maxCount:U().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish()}),jI=f({_meta:_(h(),w()).nullish(),diagnostics:wI.nullish(),editHistory:$I.nullish(),openFiles:CI.nullish(),recentFiles:PI.nullish(),relatedSnippets:OI.nullish(),userActions:ZI.nullish()}),WI=f({_meta:_(h(),w()).nullish(),additionalDirectories:R(h()).optional(),cwd:h(),mcpServers:R(Go)}),BI=f({default:U().nullish(),description:h().nullish(),maximum:U().nullish(),minimum:U().nullish(),title:h().nullish()}),Eg=h(),GI=Z([A("allow_once"),A("allow_always"),A("reject_once"),A("reject_always")]),VI=f({_meta:_(h(),w()).nullish(),kind:GI,name:h(),optionId:Eg}),HI=Z([A("high"),A("medium"),A("low")]),qI=Z([A("pending"),A("in_progress"),A("completed")]),YI=f({_meta:_(h(),w()).nullish(),content:h(),priority:HI,status:qI}),KI=f({_meta:_(h(),w()).nullish(),entries:R(YI)}),ln=f({character:U().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}),line:U().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"})}),JI=f({id:h(),position:ln,uri:h()}),XI=f({id:h(),newName:h(),position:ln,uri:h()}),QI=f({action:h(),position:ln,timestampMs:U(),uri:h()}),$g=Z([A("utf-16"),A("utf-32"),A("utf-8")]),e0=f({_meta:_(h(),w()).nullish(),auth:DC.optional().default({terminal:!1}),elicitation:rI.nullish(),fs:oI.optional().default({readTextFile:!1,writeTextFile:!1}),nes:NI.nullish(),positionEncodings:R($g).optional(),terminal:ke().optional().default(!1)}),t0=f({_meta:_(h(),w()).nullish(),audio:ke().optional().default(!1),embeddedContext:ke().optional().default(!1),image:ke().optional().default(!1)}),Ag=U().int().gte(0).lte(65535),n0=f({_meta:_(h(),w()).nullish(),clientCapabilities:e0.optional().default({auth:{terminal:!1},fs:{readTextFile:!1,writeTextFile:!1},terminal:!1}),clientInfo:kg.nullish(),protocolVersion:Ag}),Yr=f({end:ln,start:ln}),r0=f({message:h(),range:Yr,severity:bI,uri:h()}),s0=f({languageId:h(),lastFocusedMs:U().nullish(),uri:h(),visibleRange:Yr.nullish()}),i0=f({_meta:_(h(),w()).nullish(),diagnostics:R(r0).nullish(),editHistory:R(AI).nullish(),openFiles:R(s0).nullish(),recentFiles:R(II).nullish(),relatedSnippets:R(DI).nullish(),userActions:R(QI).nullish()}),o0=f({newText:h(),range:Yr}),a0=f({cursorPosition:ln.nullish(),edits:R(o0),id:h(),uri:h()}),l0=Z([a0.and(f({kind:A("edit")})),JI.and(f({kind:A("jump")})),XI.and(f({kind:A("rename")})),UI.and(f({kind:A("searchAndReplace")}))]),c0=f({_meta:_(h(),w()).nullish(),content:h()}),u0=f({_meta:_(h(),w()).nullish()}),Bn=Z([U(),h()]).nullable();f({_meta:_(h(),w()).nullish(),requestId:Bn});const h0=yo(["assistant","user"]),vi=f({_meta:_(h(),w()).nullish(),audience:R(h0).nullish(),lastModified:h().nullish(),priority:U().nullish()}),d0=f({_meta:_(h(),w()).nullish(),annotations:vi.nullish(),data:h(),mimeType:h()}),p0=f({_meta:_(h(),w()).nullish(),annotations:vi.nullish(),data:h(),mimeType:h(),uri:h().nullish()}),f0=f({_meta:_(h(),w()).nullish(),annotations:vi.nullish(),description:h().nullish(),mimeType:h().nullish(),name:h(),size:U().nullish(),title:h().nullish(),uri:h()}),g0=f({_meta:_(h(),w()).nullish(),optionId:Eg}),m0=Z([f({outcome:A("cancelled")}),g0.and(f({outcome:A("selected")}))]),v0=f({_meta:_(h(),w()).nullish(),outcome:m0}),y0=f({_meta:_(h(),w()).nullish()}),b0=f({_meta:_(h(),w()).nullish()}),w0=f({currentValue:ke()}),_0=h(),xg=h(),S0=Z([A("mode"),A("model"),A("thought_level"),h()]),Uc=h(),Tg=f({_meta:_(h(),w()).nullish(),description:h().nullish(),name:h(),value:Uc}),k0=f({_meta:_(h(),w()).nullish(),group:_0,name:h(),options:R(Tg)}),E0=Z([R(Tg),R(k0)]),$0=f({currentValue:Uc,options:E0}),Kr=Bo(Z([$0.and(f({type:A("select")})),w0.and(f({type:A("boolean")}))]),f({_meta:_(h(),w()).nullish(),category:S0.nullish(),description:h().nullish(),id:xg,name:h()})),A0=f({_meta:_(h(),w()).nullish(),configOptions:R(Kr)}),x0=f({_meta:_(h(),w()).nullish()}),K=h(),T0=f({_meta:_(h(),w()).nullish(),id:h(),sessionId:K}),C0=f({_meta:_(h(),w()).nullish(),sessionId:K}),I0=f({_meta:_(h(),w()).nullish(),sessionId:K}),P0=f({_meta:_(h(),w()).nullish(),sessionId:K}),Cg=f({_meta:_(h(),w()).nullish(),args:R(h()).optional(),command:h(),cwd:h().nullish(),env:R(vg).optional(),outputByteLimit:U().nullish(),sessionId:K}),R0=f({_meta:_(h(),w()).nullish(),sessionId:K,uri:h()}),D0=f({_meta:_(h(),w()).nullish(),position:ln,sessionId:K,uri:h(),version:U(),visibleRange:Yr}),O0=f({_meta:_(h(),w()).nullish(),languageId:h(),sessionId:K,text:h(),uri:h(),version:U()}),z0=f({_meta:_(h(),w()).nullish(),sessionId:K,uri:h()}),L0=f({_meta:_(h(),w()).nullish(),additionalDirectories:R(h()).optional(),cwd:h(),mcpServers:R(Go).optional(),sessionId:K}),Ig=f({_meta:_(h(),w()).nullish(),sessionId:K,terminalId:h()}),M0=f({_meta:_(h(),w()).nullish(),additionalDirectories:R(h()).optional(),cwd:h(),mcpServers:R(Go),sessionId:K}),Pg=f({_meta:_(h(),w()).nullish(),limit:U().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),line:U().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),path:h(),sessionId:K}),N0=f({_meta:_(h(),w()).nullish(),id:h(),reason:RI.nullish(),sessionId:K}),Rg=f({_meta:_(h(),w()).nullish(),sessionId:K,terminalId:h()}),U0=f({_meta:_(h(),w()).nullish(),additionalDirectories:R(h()).optional(),cwd:h(),mcpServers:R(Go).optional(),sessionId:K}),F0=f({_meta:_(h(),w()).nullish(),additionalDirectories:R(h()).optional(),cwd:h(),sessionId:K,title:h().nullish(),updatedAt:h().nullish()}),Z0=f({_meta:_(h(),w()).nullish(),nextCursor:h().nullish(),sessions:R(F0)}),j0=f({_meta:_(h(),w()).nullish(),title:h().nullish(),updatedAt:h().nullish()}),W0=f({_meta:_(h(),w()).nullish()}),Vo=h(),B0=f({_meta:_(h(),w()).nullish(),currentModeId:Vo}),G0=f({_meta:_(h(),w()).nullish(),description:h().nullish(),id:Vo,name:h()}),Ho=f({_meta:_(h(),w()).nullish(),availableModes:R(G0),currentModeId:Vo}),qo=f({_meta:_(h(),w()).nullish(),availableModels:R(yI),currentModelId:Nc}),V0=f({_meta:_(h(),w()).nullish(),configOptions:R(Kr).nullish(),models:qo.nullish(),modes:Ho.nullish(),sessionId:K}),H0=f({_meta:_(h(),w()).nullish(),configOptions:R(Kr).nullish(),models:qo.nullish(),modes:Ho.nullish()}),q0=f({_meta:_(h(),w()).nullish(),configOptions:R(Kr).nullish(),models:qo.nullish(),modes:Ho.nullish(),sessionId:K}),Y0=f({_meta:_(h(),w()).nullish(),configOptions:R(Kr).nullish(),models:qo.nullish(),modes:Ho.nullish()}),K0=f({_meta:_(h(),w()).nullish()}),J0=f({_meta:_(h(),w()).nullish(),additionalDirectories:y0.nullish(),close:b0.nullish(),fork:x0.nullish(),list:W0.nullish(),resume:K0.nullish()}),X0=Bo(Z([f({type:A("boolean"),value:ke()}),f({value:Uc})]),f({_meta:_(h(),w()).nullish(),configId:xg,sessionId:K})),Q0=f({_meta:_(h(),w()).nullish(),configOptions:R(Kr)}),eP=f({_meta:_(h(),w()).nullish(),modeId:Vo,sessionId:K}),tP=f({_meta:_(h(),w()).nullish()}),nP=f({_meta:_(h(),w()).nullish(),modelId:Nc,sessionId:K}),rP=f({_meta:_(h(),w()).nullish()}),sP=f({_meta:_(h(),w()).nullish(),sessionId:K}),iP=Z([A("end_turn"),A("max_tokens"),A("max_turn_requests"),A("refusal"),A("cancelled")]),oP=Z([A("email"),A("uri"),A("date"),A("date-time")]),aP=f({default:h().nullish(),description:h().nullish(),enum:R(h()).nullish(),format:oP.nullish(),maxLength:U().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),minLength:U().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),oneOf:R(mg).nullish(),pattern:h().nullish(),title:h().nullish()}),lP=f({_meta:_(h(),w()).nullish(),context:i0.nullish(),position:ln,selection:Yr.nullish(),sessionId:K,triggerKind:FI,uri:h(),version:U()}),cP=f({_meta:_(h(),w()).nullish(),suggestions:R(l0)}),uP=f({_meta:_(h(),w()).nullish(),terminalId:h()}),hP=f({_meta:_(h(),w()).nullish(),exitCode:U().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),signal:h().nullish()}),Dg=f({_meta:_(h(),w()).nullish(),sessionId:K,terminalId:h()}),dP=f({_meta:_(h(),w()).nullish(),exitStatus:hP.nullish(),output:h(),truncated:ke()}),pP=f({_meta:_(h(),w()).nullish(),annotations:vi.nullish(),text:h()}),fP=f({range:Yr.nullish(),text:h()}),gP=f({_meta:_(h(),w()).nullish(),contentChanges:R(fP),sessionId:K,uri:h(),version:U()});f({method:h(),params:Z([C0,O0,gP,R0,z0,D0,T0,N0,bg]).nullish()});const mP=Z([A("full"),A("incremental")]),vP=f({_meta:_(h(),w()).nullish(),syncKind:mP}),yP=f({_meta:_(h(),w()).nullish(),didChange:vP.nullish(),didClose:_I.nullish(),didFocus:SI.nullish(),didOpen:kI.nullish(),didSave:EI.nullish()}),bP=f({_meta:_(h(),w()).nullish(),document:yP.nullish()}),wP=f({_meta:_(h(),w()).nullish(),context:jI.nullish(),events:bP.nullish()}),_P=f({_meta:_(h(),w()).nullish(),auth:hI.optional().default({}),loadSession:ke().optional().default(!1),mcpCapabilities:fI.optional().default({http:!1,sse:!1}),nes:wP.nullish(),positionEncoding:$g.nullish(),promptCapabilities:t0.optional().default({audio:!1,embeddedContext:!1,image:!1}),sessionCapabilities:J0.optional().default({})}),SP=f({_meta:_(h(),w()).nullish(),agentCapabilities:_P.optional().default({auth:{},loadSession:!1,mcpCapabilities:{http:!1,sse:!1},promptCapabilities:{audio:!1,embeddedContext:!1,image:!1},sessionCapabilities:{}}),agentInfo:kg.nullish(),authMethods:R(NC).optional().default([]),protocolVersion:Ag}),kP=f({_meta:_(h(),w()).nullish(),mimeType:h().nullish(),text:h(),uri:h()}),EP=Z([kP,ZC]),$P=f({_meta:_(h(),w()).nullish(),annotations:vi.nullish(),resource:EP}),Fc=Z([pP.and(f({type:A("text")})),p0.and(f({type:A("image")})),d0.and(f({type:A("audio")})),f0.and(f({type:A("resource_link")})),$P.and(f({type:A("resource")}))]),AP=f({_meta:_(h(),w()).nullish(),content:Fc}),Wa=f({_meta:_(h(),w()).nullish(),content:Fc,messageId:h().nullish()}),xP=f({_meta:_(h(),w()).nullish(),messageId:h().nullish(),prompt:R(Fc),sessionId:K}),TP=f({anyOf:R(mg)}),Og=Z([AP.and(f({type:A("content")})),HC.and(f({type:A("diff")})),uP.and(f({type:A("terminal")}))]),zg=h(),Lg=f({_meta:_(h(),w()).nullish(),line:U().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),path:h()}),Mg=Z([A("pending"),A("in_progress"),A("completed"),A("failed")]),Ng=Z([A("read"),A("edit"),A("delete"),A("move"),A("search"),A("execute"),A("think"),A("fetch"),A("switch_mode"),A("other")]),CP=f({_meta:_(h(),w()).nullish(),content:R(Og).optional(),kind:Ng.optional(),locations:R(Lg).optional(),rawInput:w().optional(),rawOutput:w().optional(),status:Mg.optional(),title:h(),toolCallId:zg}),Ug=f({_meta:_(h(),w()).nullish(),content:R(Og).nullish(),kind:Ng.nullish(),locations:R(Lg).nullish(),rawInput:w().optional(),rawOutput:w().optional(),status:Mg.nullish(),title:h().nullish(),toolCallId:zg}),Fg=f({_meta:_(h(),w()).nullish(),options:R(VI),sessionId:K,toolCall:Ug}),IP=f({_meta:_(h(),w()).nullish(),hint:h()}),PP=IP,RP=f({_meta:_(h(),w()).nullish(),description:h(),input:PP.nullish(),name:h()}),DP=f({_meta:_(h(),w()).nullish(),availableCommands:R(RP)}),OP=f({enum:R(h()),type:tI}),zP=Z([OP,TP]),LP=f({default:R(h()).nullish(),description:h().nullish(),items:zP,maxItems:U().nullish(),minItems:U().nullish(),title:h().nullish()}),MP=Z([aP.and(f({type:A("string")})),BI.and(f({type:A("number")})),aI.and(f({type:A("integer")})),jC.and(f({type:A("boolean")})),LP.and(f({type:A("array")}))]),NP=f({description:h().nullish(),properties:_(h(),MP).optional().default({}),required:R(h()).nullish(),title:h().nullish(),type:eI.optional().default("object")}),UP=f({requestedSchema:NP}),FP=Bo(Z([UP.and(f({mode:A("form")})),sI.and(f({mode:A("url")}))]),f({_meta:_(h(),w()).nullish(),message:h(),sessionId:K})),ZP=f({cachedReadTokens:U().nullish(),cachedWriteTokens:U().nullish(),inputTokens:U(),outputTokens:U(),thoughtTokens:U().nullish(),totalTokens:U()}),jP=f({_meta:_(h(),w()).nullish(),stopReason:iP,usage:ZP.nullish(),userMessageId:h().nullish()});Z([f({id:Bn,result:Z([SP,FC,pI,q0,H0,Z0,V0,Y0,BC,tP,Q0,jP,rP,sP,cP,WC,_g])}),f({error:yg,id:Bn})]);const WP=f({_meta:_(h(),w()).nullish(),cost:GC.nullish(),size:U(),used:U()}),BP=Z([Wa.and(f({sessionUpdate:A("user_message_chunk")})),Wa.and(f({sessionUpdate:A("agent_message_chunk")})),Wa.and(f({sessionUpdate:A("agent_thought_chunk")})),CP.and(f({sessionUpdate:A("tool_call")})),Ug.and(f({sessionUpdate:A("tool_call_update")})),KI.and(f({sessionUpdate:A("plan")})),DP.and(f({sessionUpdate:A("available_commands_update")})),B0.and(f({sessionUpdate:A("current_mode_update")})),A0.and(f({sessionUpdate:A("config_option_update")})),j0.and(f({sessionUpdate:A("session_info_update")})),WP.and(f({sessionUpdate:A("usage_update")}))]),Zg=f({_meta:_(h(),w()).nullish(),sessionId:K,update:BP});f({method:h(),params:Z([Zg,XC,bg]).nullish()});const jg=f({_meta:_(h(),w()).nullish(),sessionId:K,terminalId:h()}),GP=f({_meta:_(h(),w()).nullish(),exitCode:U().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),signal:h().nullish()}),VP=f({name:h(),uri:h()}),HP=f({_meta:_(h(),w()).nullish(),repository:LI.nullish(),workspaceFolders:R(VP).nullish(),workspaceUri:h().nullish()});f({id:Bn,method:h(),params:Z([n0,UC,dI,WI,M0,cI,L0,U0,P0,eP,X0,xP,nP,HP,lP,I0,wg]).nullish()});const Wg=f({_meta:_(h(),w()).nullish(),content:h(),path:h(),sessionId:K});f({id:Bn,method:h(),params:Z([Wg,Pg,Fg,Cg,Dg,Rg,jg,Ig,FP,wg]).nullish()});const qP=f({_meta:_(h(),w()).nullish()});Z([f({id:Bn,result:Z([qP,c0,v0,VC,dP,u0,GP,lI,QC,_g])}),f({error:yg,id:Bn})]);var Y;class YP{constructor(e,n){$(this,Y);const r=e(this),s=async(o,a)=>{var l,c,d,p,y,m,E;switch(o){case Tt.fs_write_text_file:{const k=Wg.parse(a);return(l=r.writeTextFile)==null?void 0:l.call(r,k)}case Tt.fs_read_text_file:{const k=Pg.parse(a);return(c=r.readTextFile)==null?void 0:c.call(r,k)}case Tt.session_request_permission:{const k=Fg.parse(a);return r.requestPermission(k)}case Tt.terminal_create:{const k=Cg.parse(a);return(d=r.createTerminal)==null?void 0:d.call(r,k)}case Tt.terminal_output:{const k=Dg.parse(a);return(p=r.terminalOutput)==null?void 0:p.call(r,k)}case Tt.terminal_release:{const k=Rg.parse(a);return await((y=r.releaseTerminal)==null?void 0:y.call(r,k))??{}}case Tt.terminal_wait_for_exit:{const k=jg.parse(a);return(m=r.waitForTerminalExit)==null?void 0:m.call(r,k)}case Tt.terminal_kill:{const k=Ig.parse(a);return await((E=r.killTerminal)==null?void 0:E.call(r,k))??{}}default:if(r.extMethod)return r.extMethod(o,a);throw ye.methodNotFound(o)}},i=async(o,a)=>{switch(o){case Tt.session_update:{const l=Zg.parse(a);return r.sessionUpdate(l)}default:if(r.extNotification)return r.extNotification(o,a);throw ye.methodNotFound(o)}};x(this,Y,new KP(s,i,n))}async initialize(e){return await u(this,Y).sendRequest(ie.initialize,e)}async newSession(e){return await u(this,Y).sendRequest(ie.session_new,e)}async loadSession(e){return await u(this,Y).sendRequest(ie.session_load,e)??{}}async unstable_forkSession(e){return await u(this,Y).sendRequest(ie.session_fork,e)}async listSessions(e){return await u(this,Y).sendRequest(ie.session_list,e)}async unstable_resumeSession(e){return await u(this,Y).sendRequest(ie.session_resume,e)}async unstable_closeSession(e){return await u(this,Y).sendRequest(ie.session_close,e)}async setSessionMode(e){return await u(this,Y).sendRequest(ie.session_set_mode,e)??{}}async unstable_setSessionModel(e){return await u(this,Y).sendRequest(ie.session_set_model,e)??{}}async setSessionConfigOption(e){return await u(this,Y).sendRequest(ie.session_set_config_option,e)}async authenticate(e){return await u(this,Y).sendRequest(ie.authenticate,e)??{}}async unstable_logout(e){return await u(this,Y).sendRequest(ie.logout,e)??{}}async prompt(e){return await u(this,Y).sendRequest(ie.session_prompt,e)}async cancel(e){return await u(this,Y).sendNotification(ie.session_cancel,e)}async unstable_startNes(e){return await u(this,Y).sendRequest(ie.nes_start,e)}async unstable_suggestNes(e){return await u(this,Y).sendRequest(ie.nes_suggest,e)}async unstable_closeNes(e){return await u(this,Y).sendRequest(ie.nes_close,e)??{}}async unstable_didOpenDocument(e){return await u(this,Y).sendNotification(ie.document_did_open,e)}async unstable_didChangeDocument(e){return await u(this,Y).sendNotification(ie.document_did_change,e)}async unstable_didCloseDocument(e){return await u(this,Y).sendNotification(ie.document_did_close,e)}async unstable_didSaveDocument(e){return await u(this,Y).sendNotification(ie.document_did_save,e)}async unstable_didFocusDocument(e){return await u(this,Y).sendNotification(ie.document_did_focus,e)}async unstable_acceptNes(e){return await u(this,Y).sendNotification(ie.nes_accept,e)}async unstable_rejectNes(e){return await u(this,Y).sendNotification(ie.nes_reject,e)}async extMethod(e,n){return await u(this,Y).sendRequest(e,n)}async extNotification(e,n){return await u(this,Y).sendNotification(e,n)}get signal(){return u(this,Y).signal}get closed(){return u(this,Y).closed}}Y=new WeakMap;var Yt,Ao,Us,Fs,Sr,kr,yt,Zs,ae,Bg,kl,Gg,Vg,Hg,qg,El,ms;class KP{constructor(e,n,r){$(this,ae);$(this,Yt,new Map);$(this,Ao,0);$(this,Us);$(this,Fs);$(this,Sr);$(this,kr,Promise.resolve());$(this,yt,new AbortController);$(this,Zs);x(this,Us,e),x(this,Fs,n),x(this,Sr,r),x(this,Zs,new Promise(s=>{u(this,yt).signal.addEventListener("abort",()=>s())})),b(this,ae,Bg).call(this)}get signal(){return u(this,yt).signal}get closed(){return u(this,Zs)}async sendRequest(e,n){b(this,ae,El).call(this);const r=xu(this,Ao)._++,s=new Promise((i,o)=>{u(this,Yt).set(r,{resolve:i,reject:o})});return await b(this,ae,ms).call(this,{jsonrpc:"2.0",id:r,method:e,params:n}),s}async sendNotification(e,n){b(this,ae,El).call(this),await b(this,ae,ms).call(this,{jsonrpc:"2.0",method:e,params:n})}}Yt=new WeakMap,Ao=new WeakMap,Us=new WeakMap,Fs=new WeakMap,Sr=new WeakMap,kr=new WeakMap,yt=new WeakMap,Zs=new WeakMap,ae=new WeakSet,Bg=async function(){let e;try{const n=u(this,Sr).readable.getReader();try{for(;!u(this,yt).signal.aborted;){const{value:r,done:s}=await n.read();if(s)break;if(r)try{b(this,ae,Gg).call(this,r)}catch(i){console.error("Unexpected error during message processing:",r,i),"id"in r&&r.id!==void 0&&b(this,ae,ms).call(this,{jsonrpc:"2.0",id:r.id,error:{code:-32700,message:"Parse error"}})}}}finally{n.releaseLock()}}catch(n){e=n}finally{b(this,ae,kl).call(this,e)}},kl=function(e){if(u(this,yt).signal.aborted)return;const n=e??new Error("ACP connection closed");for(const r of u(this,Yt).values())r.reject(n);u(this,Yt).clear(),u(this,yt).abort(n)},Gg=async function(e){if("method"in e&&"id"in e){const n=await b(this,ae,Vg).call(this,e.method,e.params);"error"in n&&console.error("Error handling request",e,n.error),await b(this,ae,ms).call(this,{jsonrpc:"2.0",id:e.id,...n})}else if("method"in e){const n=await b(this,ae,Hg).call(this,e.method,e.params);"error"in n&&console.error("Error handling notification",e,n.error)}else"id"in e?b(this,ae,qg).call(this,e):console.error("Invalid message",{message:e})},Vg=async function(e,n){try{return{result:await u(this,Us).call(this,e,n)??null}}catch(r){if(r instanceof ye)return r.toResult();if(r instanceof md)return ye.invalidParams(r.format()).toResult();let s;(r instanceof Error||typeof r=="object"&&r!=null&&"message"in r&&typeof r.message=="string")&&(s=r.message);try{return ye.internalError(s?JSON.parse(s):{}).toResult()}catch{return ye.internalError({details:s}).toResult()}}},Hg=async function(e,n){try{return await u(this,Fs).call(this,e,n),{result:null}}catch(r){if(r instanceof ye)return r.toResult();if(r instanceof md)return ye.invalidParams(r.format()).toResult();let s;(r instanceof Error||typeof r=="object"&&r!=null&&"message"in r&&typeof r.message=="string")&&(s=r.message);try{return ye.internalError(s?JSON.parse(s):{}).toResult()}catch{return ye.internalError({details:s}).toResult()}}},qg=function(e){const n=u(this,Yt).get(e.id);if(n){if("result"in e)n.resolve(e.result);else if("error"in e){const{code:r,message:s,data:i}=e.error;n.reject(new ye(r,s,i))}u(this,Yt).delete(e.id)}else console.error("Got response to unknown request",e.id)},El=function(){if(u(this,yt).signal.aborted)throw u(this,yt).signal.reason??new Error("ACP connection closed")},ms=async function(e){return x(this,kr,u(this,kr).then(async()=>{const n=u(this,Sr).writable.getWriter();try{await n.write(e)}finally{n.releaseLock()}}).catch(n=>{b(this,ae,kl).call(this,n)})),u(this,kr)};class ye extends Error{constructor(n,r,s){super(r);v(this,"code");v(this,"data");this.code=n,this.name="RequestError",this.data=s}static parseError(n,r){return new ye(-32700,`Parse error${r?`: ${r}`:""}`,n)}static invalidRequest(n,r){return new ye(-32600,`Invalid request${r?`: ${r}`:""}`,n)}static methodNotFound(n){return new ye(-32601,`"Method not found": ${n}`,{method:n})}static invalidParams(n,r){return new ye(-32602,`Invalid params${r?`: ${r}`:""}`,n)}static internalError(n,r){return new ye(-32603,`Internal error${r?`: ${r}`:""}`,n)}static authRequired(n,r){return new ye(-32e3,`Authentication required${r?`: ${r}`:""}`,n)}static resourceNotFound(n){return new ye(-32002,`Resource not found${n?`: ${n}`:""}`,n&&{uri:n})}toResult(){return{error:{code:this.code,message:this.message,data:this.data}}}toErrorResponse(){return{code:this.code,message:this.message,data:this.data}}}const JP=/^Sender \(untrusted metadata\):\n```json\n[\s\S]*?\n```\n\n?/,XP=/^\[[^\n]*Working directory:[^\n]*\]\n\n?/,QP=/\[Television screen context\][\s\S]*?\[\/Television screen context\]\n*/,eR=/\[\[\s*(?:reply_to_current|reply_to\s*:\s*[^\]\n]+|audio_as_voice)\s*\]\]\s*/gi,tR="single_session",nR={name:"television-acp-client",version:"0.0.0"},Yg="agent:main:television",rR=Hr(kt);var ne,Rt,Er,Dt,On,zn,Kt,$r,bt,rt,Jt,Ln,Ot,Xt,js,zt,st,xo,Lt,C,Kg,Jg,$l,Xg,Qg,em,tm,nm,rm,sm,wn,hr,dr,Be,im,pr,Al,xl,no,om,Ws,Bs,Tl,fr,am,lm;class sR extends rR{constructor(n){super();$(this,C);$(this,ne,iR());$(this,Rt,null);$(this,Er,null);$(this,Dt,null);$(this,On,null);$(this,zn,null);$(this,Kt,null);$(this,$r,1);$(this,bt,null);$(this,rt,null);$(this,Jt,!1);$(this,Ln,!1);$(this,Ot,null);$(this,Xt,new Set);$(this,js);$(this,zt);$(this,st);$(this,xo,n=>{b(this,C,Jg).call(this,n)});$(this,Lt,null);$(this,Ws,()=>{b(this,C,fr).call(this,"ACP bridge websocket closed")});$(this,Bs,()=>{b(this,C,fr).call(this,"ACP bridge websocket error")});x(this,zt,n),x(this,st,n.sessionMode??tR),x(this,js,n.createSocket??(r=>new WebSocket(r)))}getState(){return u(this,ne)}get messages(){return u(this,ne).messageOrder.map(n=>u(this,ne).messagesById[n]).filter(n=>n!==void 0)}async connect(){if(this.disposed)throw new Error("ACPClient has been disposed");if(u(this,ne).lifecycle.status!=="ready"){b(this,C,Be).call(this,{lifecycle:{status:"connecting"}}),u(this,Er)??x(this,Er,b(this,C,Kg).call(this));try{await u(this,Er),await b(this,C,$l).call(this)}catch(n){throw b(this,C,fr).call(this,Fi(n)),n}}}dispose(){b(this,C,Tl).call(this),b(this,C,Be).call(this,{lifecycle:{status:"disposed"},run:{status:"idle",stopReason:null,canCancel:!1,error:null}})}async sendMessage(n){if(await this.connect(),u(this,ne).lifecycle.status!=="ready"||u(this,ne).run.status==="running"||u(this,ne).run.status==="cancelling")throw new Error("ACPClient is not ready to send a new message");const r=n.text.trim();if(!r)throw new Error("Cannot send an empty message");b(this,C,hr).call(this,{id:b(this,C,pr).call(this,"user"),kind:"user",text:r,status:"final"}),b(this,C,Be).call(this,{run:{status:"running",stopReason:null,canCancel:!0,error:null}});try{const s=await b(this,C,no).call(this).prompt({sessionId:b(this,C,xl).call(this),prompt:[{type:"text",text:b(this,C,im).call(this,r)}]});b(this,C,wn).call(this,s.stopReason==="cancelled"?"cancelled":"final"),b(this,C,Be).call(this,{run:{status:s.stopReason==="cancelled"?"cancelled":"completed",stopReason:s.stopReason,canCancel:!1,error:null}})}catch(s){throw b(this,C,lm).call(this)||(b(this,C,wn).call(this,"error"),b(this,C,Be).call(this,{run:{status:"error",stopReason:null,canCancel:!1,error:Fi(s)}})),s}}async cancel(){if(await this.connect(),!u(this,ne).run.canCancel||u(this,ne).run.status!=="running")throw new Error("No active cancellable run");b(this,C,Be).call(this,{run:{...u(this,ne).run,status:"cancelling"}}),await b(this,C,no).call(this).cancel({sessionId:b(this,C,xl).call(this)})}setScreenContext(n){var i,o,a;const r={screenID:n.screenID,screenName:n.screenName};if(((i=u(this,rt))==null?void 0:i.screenID)===r.screenID&&((o=u(this,rt))==null?void 0:o.screenName)===r.screenName)return;const s=((a=u(this,rt))==null?void 0:a.screenID)??null;if(x(this,rt,r),u(this,st)==="single_session"){(!u(this,Kt)||s!==r.screenID)&&x(this,Jt,!0);return}u(this,Kt)!==Sd(u(this,st),r.screenID,u(this,zt).clientGUID??"default-client")&&(x(this,Dt,null),x(this,On,null),u(this,Rt)&&u(this,ne).run.status==="idle"&&b(this,C,$l).call(this).catch(l=>{b(this,C,fr).call(this,Fi(l))}))}}ne=new WeakMap,Rt=new WeakMap,Er=new WeakMap,Dt=new WeakMap,On=new WeakMap,zn=new WeakMap,Kt=new WeakMap,$r=new WeakMap,bt=new WeakMap,rt=new WeakMap,Jt=new WeakMap,Ln=new WeakMap,Ot=new WeakMap,Xt=new WeakMap,js=new WeakMap,zt=new WeakMap,st=new WeakMap,xo=new WeakMap,Lt=new WeakMap,C=new WeakSet,Kg=async function(){try{b(this,C,Be).call(this,{lifecycle:{status:"connecting"}});const{stream:n,socket:r}=await lR({serverURL:u(this,zt).serverURL,token:u(this,zt).token,createSocket:u(this,js),onDisconnect:u(this,xo)});x(this,Lt,r),r.addEventListener("close",u(this,Ws)),r.addEventListener("error",u(this,Bs)),x(this,Rt,new YP(s=>({connection:s,sessionUpdate:async i=>{await b(this,C,Qg).call(this,i)},requestPermission:async i=>b(this,C,em).call(this,i)}),n)),await u(this,Rt).initialize({protocolVersion:RC,clientCapabilities:{},clientInfo:nR})}catch(n){throw n}},Jg=function(n){b(this,C,fr).call(this,Fi(n))},$l=async function(){const n=b(this,C,om).call(this);if(u(this,Dt)&&u(this,On)===n){await u(this,Dt);return}x(this,On,n),x(this,Dt,b(this,C,Xg).call(this,n)),await u(this,Dt)},Xg=async function(n){const r=b(this,C,no).call(this);b(this,C,am).call(this);let s,i=!1;try{x(this,Ln,!0),x(this,Ot,null),await r.loadSession({sessionId:n,cwd:"/",mcpServers:[],_meta:{sessionKey:n}}),s=n,i=u(this,ne).messageOrder.length>0}catch{s=(await r.newSession({cwd:"/",mcpServers:[],_meta:{sessionKey:n}})).sessionId,i=!1}finally{x(this,Ln,!1),x(this,Ot,null),b(this,C,wn).call(this,"final")}await r.setSessionConfigOption({sessionId:s,configId:"verbose_level",value:"full"}),x(this,zn,s),x(this,Kt,n),i?(u(this,Xt).add(n),u(this,st)==="single_session"&&x(this,Jt,!1)):(u(this,Xt).delete(n),x(this,Jt,u(this,st)==="single_session")),b(this,C,Be).call(this,{lifecycle:{status:"ready"}})},Qg=async function(n){const r=n.update;switch(r.sessionUpdate){case"user_message_chunk":r.content.type==="text"&&b(this,C,sm).call(this,r.content.text);return;case"agent_message_chunk":r.content.type==="text"&&b(this,C,tm).call(this,r.content.text);return;case"tool_call":b(this,C,nm).call(this,r);return;case"tool_call_update":b(this,C,rm).call(this,r);return;case"agent_thought_chunk":return;default:return}},em=async function(n){return{outcome:{outcome:"cancelled"}}},tm=function(n){x(this,Ot,null);const r=oR(n);if(!r)return;if(!u(this,bt)){const i={id:b(this,C,pr).call(this,"assistant"),kind:"assistant",text:r,status:"streaming"};x(this,bt,i.id),b(this,C,hr).call(this,i);return}const s=u(this,ne).messagesById[u(this,bt)];if(!s||s.kind!=="assistant")throw new Error("Open assistant message invariant violated");b(this,C,dr).call(this,{...s,text:`${s.text}${r}`,status:"streaming"})},nm=function(n){b(this,C,wn).call(this,"final");const r=b(this,C,Al).call(this,n.toolCallId),s={id:(r==null?void 0:r.id)??b(this,C,pr).call(this,"tool"),kind:"tool_call",toolCallId:n.toolCallId,title:n.title,toolKind:n.kind??"other",status:n.status==="failed"?"failed":n.status==="completed"?"completed":"in_progress",text:(r==null?void 0:r.text)??"",locations:n.locations??(r==null?void 0:r.locations)};if(r){b(this,C,dr).call(this,s);return}b(this,C,hr).call(this,s)},rm=function(n){const r=b(this,C,Al).call(this,n.toolCallId),s=(r==null?void 0:r.text)??"",i=aR(n.content),o=i?`${s}${i}`:s,a={id:(r==null?void 0:r.id)??b(this,C,pr).call(this,"tool"),kind:"tool_call",toolCallId:n.toolCallId,title:(r==null?void 0:r.title)??n.toolCallId,toolKind:(r==null?void 0:r.toolKind)??"other",status:n.status==="failed"?"failed":n.status==="completed"?"completed":"in_progress",text:o,locations:n.locations??(r==null?void 0:r.locations)};if(r){b(this,C,dr).call(this,a);return}b(this,C,hr).call(this,a)},sm=function(n){if(b(this,C,wn).call(this,"final"),!n)return;const r=u(this,Ln)?u(this,Ot):null;if(!r){const i=kd(n);if(!i)return;const o={id:b(this,C,pr).call(this,"user"),kind:"user",text:i,status:"final"};b(this,C,hr).call(this,o),u(this,Ln)&&x(this,Ot,o.id);return}const s=u(this,ne).messagesById[r];if(!s||s.kind!=="user")throw new Error("Replay user message invariant violated");b(this,C,dr).call(this,{...s,text:kd(`${s.text}${n}`)})},wn=function(n){if(!u(this,bt))return;const r=u(this,ne).messagesById[u(this,bt)];(r==null?void 0:r.kind)==="assistant"&&b(this,C,dr).call(this,{...r,status:n}),x(this,bt,null)},hr=function(n){b(this,C,Be).call(this,{messagesById:{...u(this,ne).messagesById,[n.id]:n},messageOrder:[...u(this,ne).messageOrder,n.id]})},dr=function(n){b(this,C,Be).call(this,{messagesById:{...u(this,ne).messagesById,[n.id]:n}})},Be=function(n){const r={...u(this,ne),...n};x(this,ne,{...r,sendDisabled:r.lifecycle.status!=="ready"||r.run.status==="running"||r.run.status==="cancelling",cancelDisabled:!(r.run.status==="running"||r.run.status==="cancelling")||!r.run.canCancel}),this.dispatchEvent(new te("change"))},im=function(n){const r=u(this,Kt);return!u(this,rt)||!r||!(u(this,st)==="single_session"?u(this,Jt)||!u(this,Xt).has(r):!u(this,Xt).has(r))?n:(x(this,Jt,!1),u(this,Xt).add(r),["[Television screen context]","This chat session is coming from a Television client in the screen below.",`screen_id: ${u(this,rt).screenID}`,`screen_name: ${u(this,rt).screenName??""}`,"When the user asks to inspect or change Television state with the tv CLI, use this screen ID with the --screen argument.","[/Television screen context]","",n].join(`
|
|
43
|
-
`))},pr=function(n){const r=`${n}-${u(this,$r)}`;return x(this,$r,u(this,$r)+1),r},
|
|
42
|
+
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(const d of t.seen.entries()){const p=d[1];if(e===d[0]){i(d);continue}if(t.external){const m=(l=t.external.registry.get(d[0]))==null?void 0:l.id;if(e!==d[0]&&m){i(d);continue}}if((c=t.metadataRegistry.get(d[0]))==null?void 0:c.id){i(d);continue}if(p.cycle){i(d);continue}if(p.count>1&&t.reused==="ref"){i(d);continue}}}function og(t,e){var o,a,l;const n=t.seen.get(e);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");const r=c=>{const d=t.seen.get(c);if(d.ref===null)return;const p=d.def??d.schema,y={...p},m=d.ref;if(d.ref=null,m){r(m);const k=t.seen.get(m),I=k.schema;if(I.$ref&&(t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0")?(p.allOf=p.allOf??[],p.allOf.push(I)):Object.assign(p,I),Object.assign(p,y),c._zod.parent===m)for(const N in p)N==="$ref"||N==="allOf"||N in y||delete p[N];if(I.$ref&&k.def)for(const N in p)N==="$ref"||N==="allOf"||N in k.def&&JSON.stringify(p[N])===JSON.stringify(k.def[N])&&delete p[N]}const E=c._zod.parent;if(E&&E!==m){r(E);const k=t.seen.get(E);if(k!=null&&k.schema.$ref&&(p.$ref=k.schema.$ref,k.def))for(const I in p)I==="$ref"||I==="allOf"||I in k.def&&JSON.stringify(p[I])===JSON.stringify(k.def[I])&&delete p[I]}t.override({zodSchema:c,jsonSchema:p,path:d.path??[]})};for(const c of[...t.seen.entries()].reverse())r(c[0]);const s={};if(t.target==="draft-2020-12"?s.$schema="https://json-schema.org/draft/2020-12/schema":t.target==="draft-07"?s.$schema="http://json-schema.org/draft-07/schema#":t.target==="draft-04"?s.$schema="http://json-schema.org/draft-04/schema#":t.target,(o=t.external)!=null&&o.uri){const c=(a=t.external.registry.get(e))==null?void 0:a.id;if(!c)throw new Error("Schema is missing an `id` property");s.$id=t.external.uri(c)}Object.assign(s,n.def??n.schema);const i=((l=t.external)==null?void 0:l.defs)??{};for(const c of t.seen.entries()){const d=c[1];d.def&&d.defId&&(i[d.defId]=d.def)}t.external||Object.keys(i).length>0&&(t.target==="draft-2020-12"?s.$defs=i:s.definitions=i);try{const c=JSON.parse(JSON.stringify(s));return Object.defineProperty(c,"~standard",{value:{...e["~standard"],jsonSchema:{input:vo(e,"input",t.processors),output:vo(e,"output",t.processors)}},enumerable:!1,writable:!1}),c}catch{throw new Error("Error converting schema to JSON.")}}function Re(t,e){const n=e??{seen:new Set};if(n.seen.has(t))return!1;n.seen.add(t);const r=t._zod.def;if(r.type==="transform")return!0;if(r.type==="array")return Re(r.element,n);if(r.type==="set")return Re(r.valueType,n);if(r.type==="lazy")return Re(r.getter(),n);if(r.type==="promise"||r.type==="optional"||r.type==="nonoptional"||r.type==="nullable"||r.type==="readonly"||r.type==="default"||r.type==="prefault")return Re(r.innerType,n);if(r.type==="intersection")return Re(r.left,n)||Re(r.right,n);if(r.type==="record"||r.type==="map")return Re(r.keyType,n)||Re(r.valueType,n);if(r.type==="pipe")return Re(r.in,n)||Re(r.out,n);if(r.type==="object"){for(const s in r.shape)if(Re(r.shape[s],n))return!0;return!1}if(r.type==="union"){for(const s of r.options)if(Re(s,n))return!0;return!1}if(r.type==="tuple"){for(const s of r.items)if(Re(s,n))return!0;return!!(r.rest&&Re(r.rest,n))}return!1}const Ux=(t,e={})=>n=>{const r=sg({...n,processors:e});return me(t,r),ig(r,t),og(r,t)},vo=(t,e,n={})=>r=>{const{libraryOptions:s,target:i}=r??{},o=sg({...s??{},target:i,io:e,processors:n});return me(t,o),ig(o,t),og(o,t)},Fx={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},Zx=(t,e,n,r)=>{const s=n;s.type="string";const{minimum:i,maximum:o,format:a,patterns:l,contentEncoding:c}=t._zod.bag;if(typeof i=="number"&&(s.minLength=i),typeof o=="number"&&(s.maxLength=o),a&&(s.format=Fx[a]??a,s.format===""&&delete s.format,a==="time"&&delete s.format),c&&(s.contentEncoding=c),l&&l.size>0){const d=[...l];d.length===1?s.pattern=d[0].source:d.length>1&&(s.allOf=[...d.map(p=>({...e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0"?{type:"string"}:{},pattern:p.source}))])}},jx=(t,e,n,r)=>{const s=n,{minimum:i,maximum:o,format:a,multipleOf:l,exclusiveMaximum:c,exclusiveMinimum:d}=t._zod.bag;typeof a=="string"&&a.includes("int")?s.type="integer":s.type="number",typeof d=="number"&&(e.target==="draft-04"||e.target==="openapi-3.0"?(s.minimum=d,s.exclusiveMinimum=!0):s.exclusiveMinimum=d),typeof i=="number"&&(s.minimum=i,typeof d=="number"&&e.target!=="draft-04"&&(d>=i?delete s.minimum:delete s.exclusiveMinimum)),typeof c=="number"&&(e.target==="draft-04"||e.target==="openapi-3.0"?(s.maximum=c,s.exclusiveMaximum=!0):s.exclusiveMaximum=c),typeof o=="number"&&(s.maximum=o,typeof c=="number"&&e.target!=="draft-04"&&(c<=o?delete s.maximum:delete s.exclusiveMaximum)),typeof l=="number"&&(s.multipleOf=l)},Wx=(t,e,n,r)=>{n.type="boolean"},Bx=(t,e,n,r)=>{n.not={}},Gx=(t,e,n,r)=>{},Vx=(t,e,n,r)=>{const s=t._zod.def,i=Nf(s.entries);i.every(o=>typeof o=="number")&&(n.type="number"),i.every(o=>typeof o=="string")&&(n.type="string"),n.enum=i},Hx=(t,e,n,r)=>{const s=t._zod.def,i=[];for(const o of s.values)if(o===void 0){if(e.unrepresentable==="throw")throw new Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof o=="bigint"){if(e.unrepresentable==="throw")throw new Error("BigInt literals cannot be represented in JSON Schema");i.push(Number(o))}else i.push(o);if(i.length!==0)if(i.length===1){const o=i[0];n.type=o===null?"null":typeof o,e.target==="draft-04"||e.target==="openapi-3.0"?n.enum=[o]:n.const=o}else i.every(o=>typeof o=="number")&&(n.type="number"),i.every(o=>typeof o=="string")&&(n.type="string"),i.every(o=>typeof o=="boolean")&&(n.type="boolean"),i.every(o=>o===null)&&(n.type="null"),n.enum=i},qx=(t,e,n,r)=>{if(e.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema")},Yx=(t,e,n,r)=>{if(e.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema")},Kx=(t,e,n,r)=>{const s=n,i=t._zod.def,{minimum:o,maximum:a}=t._zod.bag;typeof o=="number"&&(s.minItems=o),typeof a=="number"&&(s.maxItems=a),s.type="array",s.items=me(i.element,e,{...r,path:[...r.path,"items"]})},Jx=(t,e,n,r)=>{var c;const s=n,i=t._zod.def;s.type="object",s.properties={};const o=i.shape;for(const d in o)s.properties[d]=me(o[d],e,{...r,path:[...r.path,"properties",d]});const a=new Set(Object.keys(o)),l=new Set([...a].filter(d=>{const p=i.shape[d]._zod;return e.io==="input"?p.optin===void 0:p.optout===void 0}));l.size>0&&(s.required=Array.from(l)),((c=i.catchall)==null?void 0:c._zod.def.type)==="never"?s.additionalProperties=!1:i.catchall?i.catchall&&(s.additionalProperties=me(i.catchall,e,{...r,path:[...r.path,"additionalProperties"]})):e.io==="output"&&(s.additionalProperties=!1)},Xx=(t,e,n,r)=>{const s=t._zod.def,i=s.inclusive===!1,o=s.options.map((a,l)=>me(a,e,{...r,path:[...r.path,i?"oneOf":"anyOf",l]}));i?n.oneOf=o:n.anyOf=o},Qx=(t,e,n,r)=>{const s=t._zod.def,i=me(s.left,e,{...r,path:[...r.path,"allOf",0]}),o=me(s.right,e,{...r,path:[...r.path,"allOf",1]}),a=c=>"allOf"in c&&Object.keys(c).length===1,l=[...a(i)?i.allOf:[i],...a(o)?o.allOf:[o]];n.allOf=l},eT=(t,e,n,r)=>{const s=n,i=t._zod.def;s.type="object";const o=i.keyType,a=o._zod.bag,l=a==null?void 0:a.patterns;if(i.mode==="loose"&&l&&l.size>0){const d=me(i.valueType,e,{...r,path:[...r.path,"patternProperties","*"]});s.patternProperties={};for(const p of l)s.patternProperties[p.source]=d}else(e.target==="draft-07"||e.target==="draft-2020-12")&&(s.propertyNames=me(i.keyType,e,{...r,path:[...r.path,"propertyNames"]})),s.additionalProperties=me(i.valueType,e,{...r,path:[...r.path,"additionalProperties"]});const c=o._zod.values;if(c){const d=[...c].filter(p=>typeof p=="string"||typeof p=="number");d.length>0&&(s.required=d)}},tT=(t,e,n,r)=>{const s=t._zod.def,i=me(s.innerType,e,r),o=e.seen.get(t);e.target==="openapi-3.0"?(o.ref=s.innerType,n.nullable=!0):n.anyOf=[i,{type:"null"}]},nT=(t,e,n,r)=>{const s=t._zod.def;me(s.innerType,e,r);const i=e.seen.get(t);i.ref=s.innerType},rT=(t,e,n,r)=>{const s=t._zod.def;me(s.innerType,e,r);const i=e.seen.get(t);i.ref=s.innerType,n.default=JSON.parse(JSON.stringify(s.defaultValue))},sT=(t,e,n,r)=>{const s=t._zod.def;me(s.innerType,e,r);const i=e.seen.get(t);i.ref=s.innerType,e.io==="input"&&(n._prefault=JSON.parse(JSON.stringify(s.defaultValue)))},iT=(t,e,n,r)=>{const s=t._zod.def;me(s.innerType,e,r);const i=e.seen.get(t);i.ref=s.innerType;let o;try{o=s.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}n.default=o},oT=(t,e,n,r)=>{const s=t._zod.def,i=e.io==="input"?s.in._zod.def.type==="transform"?s.out:s.in:s.out;me(i,e,r);const o=e.seen.get(t);o.ref=i},aT=(t,e,n,r)=>{const s=t._zod.def;me(s.innerType,e,r);const i=e.seen.get(t);i.ref=s.innerType,n.readOnly=!0},ag=(t,e,n,r)=>{const s=t._zod.def;me(s.innerType,e,r);const i=e.seen.get(t);i.ref=s.innerType},lT=S("ZodISODateTime",(t,e)=>{cA.init(t,e),ue.init(t,e)});function cT(t){return gx(lT,t)}const uT=S("ZodISODate",(t,e)=>{uA.init(t,e),ue.init(t,e)});function hT(t){return mx(uT,t)}const dT=S("ZodISOTime",(t,e)=>{hA.init(t,e),ue.init(t,e)});function pT(t){return vx(dT,t)}const fT=S("ZodISODuration",(t,e)=>{dA.init(t,e),ue.init(t,e)});function gT(t){return yx(fT,t)}const lg=(t,e)=>{jf.init(t,e),t.name="ZodError",Object.defineProperties(t,{format:{value:n=>n$(t,n)},flatten:{value:n=>t$(t,n)},addIssue:{value:n=>{t.issues.push(n),t.message=JSON.stringify(t.issues,ml,2)}},addIssues:{value:n=>{t.issues.push(...n),t.message=JSON.stringify(t.issues,ml,2)}},isEmpty:{get(){return t.issues.length===0}}})},md=S("ZodError",lg),tt=S("ZodError",lg,{Parent:Error}),mT=Rc(tt),vT=Dc(tt),yT=Zo(tt),bT=jo(tt),wT=i$(tt),_T=o$(tt),ST=a$(tt),kT=l$(tt),ET=c$(tt),$T=u$(tt),AT=h$(tt),xT=d$(tt),ce=S("ZodType",(t,e)=>(le.init(t,e),Object.assign(t["~standard"],{jsonSchema:{input:vo(t,"input"),output:vo(t,"output")}}),t.toJSONSchema=Ux(t,{}),t.def=e,t.type=e.type,Object.defineProperty(t,"_def",{value:e}),t.check=(...n)=>t.clone(pn(e,{checks:[...e.checks??[],...n.map(r=>typeof r=="function"?{_zod:{check:r,def:{check:"custom"},onattach:[]}}:r)]}),{parent:!0}),t.with=t.check,t.clone=(n,r)=>fn(t,n,r),t.brand=()=>t,t.register=(n,r)=>(n.add(t,r),t),t.parse=(n,r)=>mT(t,n,r,{callee:t.parse}),t.safeParse=(n,r)=>yT(t,n,r),t.parseAsync=async(n,r)=>vT(t,n,r,{callee:t.parseAsync}),t.safeParseAsync=async(n,r)=>bT(t,n,r),t.spa=t.safeParseAsync,t.encode=(n,r)=>wT(t,n,r),t.decode=(n,r)=>_T(t,n,r),t.encodeAsync=async(n,r)=>ST(t,n,r),t.decodeAsync=async(n,r)=>kT(t,n,r),t.safeEncode=(n,r)=>ET(t,n,r),t.safeDecode=(n,r)=>$T(t,n,r),t.safeEncodeAsync=async(n,r)=>AT(t,n,r),t.safeDecodeAsync=async(n,r)=>xT(t,n,r),t.refine=(n,r)=>t.check(yC(n,r)),t.superRefine=n=>t.check(bC(n)),t.overwrite=n=>t.check(qr(n)),t.optional=()=>bd(t),t.exactOptional=()=>iC(t),t.nullable=()=>wd(t),t.nullish=()=>bd(wd(t)),t.nonoptional=n=>hC(t,n),t.array=()=>R(t),t.or=n=>Z([t,n]),t.and=n=>Bo(t,n),t.transform=n=>_d(t,rC(n)),t.default=n=>lC(t,n),t.prefault=n=>uC(t,n),t.catch=n=>pC(t,n),t.pipe=n=>_d(t,n),t.readonly=()=>mC(t),t.describe=n=>{const r=t.clone();return gs.add(r,{description:n}),r},Object.defineProperty(t,"description",{get(){var n;return(n=gs.get(t))==null?void 0:n.description},configurable:!0}),t.meta=(...n)=>{if(n.length===0)return gs.get(t);const r=t.clone();return gs.add(r,n[0]),r},t.isOptional=()=>t.safeParse(void 0).success,t.isNullable=()=>t.safeParse(null).success,t.apply=n=>n(t),t)),cg=S("_ZodString",(t,e)=>{Oc.init(t,e),ce.init(t,e),t._zod.processJSONSchema=(r,s,i)=>Zx(t,r,s);const n=t._zod.bag;t.format=n.format??null,t.minLength=n.minimum??null,t.maxLength=n.maximum??null,t.regex=(...r)=>t.check(Ex(...r)),t.includes=(...r)=>t.check(xx(...r)),t.startsWith=(...r)=>t.check(Tx(...r)),t.endsWith=(...r)=>t.check(Cx(...r)),t.min=(...r)=>t.check(mo(...r)),t.max=(...r)=>t.check(ng(...r)),t.length=(...r)=>t.check(rg(...r)),t.nonempty=(...r)=>t.check(mo(1,...r)),t.lowercase=r=>t.check($x(r)),t.uppercase=r=>t.check(Ax(r)),t.trim=()=>t.check(Px()),t.normalize=(...r)=>t.check(Ix(...r)),t.toLowerCase=()=>t.check(Rx()),t.toUpperCase=()=>t.check(Dx()),t.slugify=()=>t.check(Ox())}),TT=S("ZodString",(t,e)=>{Oc.init(t,e),cg.init(t,e),t.email=n=>t.check(qA(CT,n)),t.url=n=>t.check(QA(IT,n)),t.jwt=n=>t.check(fx(GT,n)),t.emoji=n=>t.check(ex(PT,n)),t.guid=n=>t.check(dd(vd,n)),t.uuid=n=>t.check(YA(Ui,n)),t.uuidv4=n=>t.check(KA(Ui,n)),t.uuidv6=n=>t.check(JA(Ui,n)),t.uuidv7=n=>t.check(XA(Ui,n)),t.nanoid=n=>t.check(tx(RT,n)),t.guid=n=>t.check(dd(vd,n)),t.cuid=n=>t.check(nx(DT,n)),t.cuid2=n=>t.check(rx(OT,n)),t.ulid=n=>t.check(sx(zT,n)),t.base64=n=>t.check(hx(jT,n)),t.base64url=n=>t.check(dx(WT,n)),t.xid=n=>t.check(ix(LT,n)),t.ksuid=n=>t.check(ox(MT,n)),t.ipv4=n=>t.check(ax(NT,n)),t.ipv6=n=>t.check(lx(UT,n)),t.cidrv4=n=>t.check(cx(FT,n)),t.cidrv6=n=>t.check(ux(ZT,n)),t.e164=n=>t.check(px(BT,n)),t.datetime=n=>t.check(cT(n)),t.date=n=>t.check(hT(n)),t.time=n=>t.check(pT(n)),t.duration=n=>t.check(gT(n))});function h(t){return HA(TT,t)}const ue=S("ZodStringFormat",(t,e)=>{oe.init(t,e),cg.init(t,e)}),CT=S("ZodEmail",(t,e)=>{eA.init(t,e),ue.init(t,e)}),vd=S("ZodGUID",(t,e)=>{X$.init(t,e),ue.init(t,e)}),Ui=S("ZodUUID",(t,e)=>{Q$.init(t,e),ue.init(t,e)}),IT=S("ZodURL",(t,e)=>{tA.init(t,e),ue.init(t,e)}),PT=S("ZodEmoji",(t,e)=>{nA.init(t,e),ue.init(t,e)}),RT=S("ZodNanoID",(t,e)=>{rA.init(t,e),ue.init(t,e)}),DT=S("ZodCUID",(t,e)=>{sA.init(t,e),ue.init(t,e)}),OT=S("ZodCUID2",(t,e)=>{iA.init(t,e),ue.init(t,e)}),zT=S("ZodULID",(t,e)=>{oA.init(t,e),ue.init(t,e)}),LT=S("ZodXID",(t,e)=>{aA.init(t,e),ue.init(t,e)}),MT=S("ZodKSUID",(t,e)=>{lA.init(t,e),ue.init(t,e)}),NT=S("ZodIPv4",(t,e)=>{pA.init(t,e),ue.init(t,e)}),UT=S("ZodIPv6",(t,e)=>{fA.init(t,e),ue.init(t,e)}),FT=S("ZodCIDRv4",(t,e)=>{gA.init(t,e),ue.init(t,e)}),ZT=S("ZodCIDRv6",(t,e)=>{mA.init(t,e),ue.init(t,e)}),jT=S("ZodBase64",(t,e)=>{vA.init(t,e),ue.init(t,e)}),WT=S("ZodBase64URL",(t,e)=>{bA.init(t,e),ue.init(t,e)}),BT=S("ZodE164",(t,e)=>{wA.init(t,e),ue.init(t,e)}),GT=S("ZodJWT",(t,e)=>{SA.init(t,e),ue.init(t,e)}),ug=S("ZodNumber",(t,e)=>{Xf.init(t,e),ce.init(t,e),t._zod.processJSONSchema=(r,s,i)=>jx(t,r,s),t.gt=(r,s)=>t.check(fd(r,s)),t.gte=(r,s)=>t.check(Fa(r,s)),t.min=(r,s)=>t.check(Fa(r,s)),t.lt=(r,s)=>t.check(pd(r,s)),t.lte=(r,s)=>t.check(Ua(r,s)),t.max=(r,s)=>t.check(Ua(r,s)),t.int=r=>t.check(yd(r)),t.safe=r=>t.check(yd(r)),t.positive=r=>t.check(fd(0,r)),t.nonnegative=r=>t.check(Fa(0,r)),t.negative=r=>t.check(pd(0,r)),t.nonpositive=r=>t.check(Ua(0,r)),t.multipleOf=(r,s)=>t.check(gd(r,s)),t.step=(r,s)=>t.check(gd(r,s)),t.finite=()=>t;const n=t._zod.bag;t.minValue=Math.max(n.minimum??Number.NEGATIVE_INFINITY,n.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,t.maxValue=Math.min(n.maximum??Number.POSITIVE_INFINITY,n.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,t.isInt=(n.format??"").includes("int")||Number.isSafeInteger(n.multipleOf??.5),t.isFinite=!0,t.format=n.format??null});function U(t){return bx(ug,t)}const VT=S("ZodNumberFormat",(t,e)=>{kA.init(t,e),ug.init(t,e)});function yd(t){return wx(VT,t)}const HT=S("ZodBoolean",(t,e)=>{EA.init(t,e),ce.init(t,e),t._zod.processJSONSchema=(n,r,s)=>Wx(t,n,r)});function ke(t){return _x(HT,t)}const qT=S("ZodUnknown",(t,e)=>{$A.init(t,e),ce.init(t,e),t._zod.processJSONSchema=(n,r,s)=>Gx()});function w(){return Sx(qT)}const YT=S("ZodNever",(t,e)=>{AA.init(t,e),ce.init(t,e),t._zod.processJSONSchema=(n,r,s)=>Bx(t,n,r)});function KT(t){return kx(YT,t)}const JT=S("ZodArray",(t,e)=>{xA.init(t,e),ce.init(t,e),t._zod.processJSONSchema=(n,r,s)=>Kx(t,n,r,s),t.element=e.element,t.min=(n,r)=>t.check(mo(n,r)),t.nonempty=n=>t.check(mo(1,n)),t.max=(n,r)=>t.check(ng(n,r)),t.length=(n,r)=>t.check(rg(n,r)),t.unwrap=()=>t.element});function R(t,e){return zx(JT,t,e)}const hg=S("ZodObject",(t,e)=>{CA.init(t,e),ce.init(t,e),t._zod.processJSONSchema=(n,r,s)=>Jx(t,n,r,s),ee(t,"shape",()=>e.shape),t.keyof=()=>yo(Object.keys(t._zod.def.shape)),t.catchall=n=>t.clone({...t._zod.def,catchall:n}),t.passthrough=()=>t.clone({...t._zod.def,catchall:w()}),t.loose=()=>t.clone({...t._zod.def,catchall:w()}),t.strict=()=>t.clone({...t._zod.def,catchall:KT()}),t.strip=()=>t.clone({...t._zod.def,catchall:void 0}),t.extend=n=>KE(t,n),t.safeExtend=n=>JE(t,n),t.merge=n=>XE(t,n),t.pick=n=>qE(t,n),t.omit=n=>YE(t,n),t.partial=(...n)=>QE(pg,t,n[0]),t.required=(...n)=>e$(fg,t,n[0])});function dg(t,e){const n={type:"object",shape:t??{},...O(e)};return new hg(n)}function f(t,e){return new hg({type:"object",shape:t,catchall:w(),...O(e)})}const XT=S("ZodUnion",(t,e)=>{IA.init(t,e),ce.init(t,e),t._zod.processJSONSchema=(n,r,s)=>Xx(t,n,r,s),t.options=e.options});function Z(t,e){return new XT({type:"union",options:t,...O(e)})}const QT=S("ZodIntersection",(t,e)=>{PA.init(t,e),ce.init(t,e),t._zod.processJSONSchema=(n,r,s)=>Qx(t,n,r,s)});function Bo(t,e){return new QT({type:"intersection",left:t,right:e})}const eC=S("ZodRecord",(t,e)=>{RA.init(t,e),ce.init(t,e),t._zod.processJSONSchema=(n,r,s)=>eT(t,n,r,s),t.keyType=e.keyType,t.valueType=e.valueType});function _(t,e,n){return new eC({type:"record",keyType:t,valueType:e,...O(n)})}const yl=S("ZodEnum",(t,e)=>{DA.init(t,e),ce.init(t,e),t._zod.processJSONSchema=(r,s,i)=>Vx(t,r,s),t.enum=e.entries,t.options=Object.values(e.entries);const n=new Set(Object.keys(e.entries));t.extract=(r,s)=>{const i={};for(const o of r)if(n.has(o))i[o]=e.entries[o];else throw new Error(`Key ${o} not found in enum`);return new yl({...e,checks:[],...O(s),entries:i})},t.exclude=(r,s)=>{const i={...e.entries};for(const o of r)if(n.has(o))delete i[o];else throw new Error(`Key ${o} not found in enum`);return new yl({...e,checks:[],...O(s),entries:i})}});function yo(t,e){const n=Array.isArray(t)?Object.fromEntries(t.map(r=>[r,r])):t;return new yl({type:"enum",entries:n,...O(e)})}const tC=S("ZodLiteral",(t,e)=>{OA.init(t,e),ce.init(t,e),t._zod.processJSONSchema=(n,r,s)=>Hx(t,n,r),t.values=new Set(e.values),Object.defineProperty(t,"value",{get(){if(e.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return e.values[0]}})});function A(t,e){return new tC({type:"literal",values:Array.isArray(t)?t:[t],...O(e)})}const nC=S("ZodTransform",(t,e)=>{zA.init(t,e),ce.init(t,e),t._zod.processJSONSchema=(n,r,s)=>Yx(t,n),t._zod.parse=(n,r)=>{if(r.direction==="backward")throw new Lf(t.constructor.name);n.addIssue=i=>{if(typeof i=="string")n.issues.push(Ts(i,n.value,e));else{const o=i;o.fatal&&(o.continue=!1),o.code??(o.code="custom"),o.input??(o.input=n.value),o.inst??(o.inst=t),n.issues.push(Ts(o))}};const s=e.transform(n.value,n);return s instanceof Promise?s.then(i=>(n.value=i,n)):(n.value=s,n)}});function rC(t){return new nC({type:"transform",transform:t})}const pg=S("ZodOptional",(t,e)=>{tg.init(t,e),ce.init(t,e),t._zod.processJSONSchema=(n,r,s)=>ag(t,n,r,s),t.unwrap=()=>t._zod.def.innerType});function bd(t){return new pg({type:"optional",innerType:t})}const sC=S("ZodExactOptional",(t,e)=>{LA.init(t,e),ce.init(t,e),t._zod.processJSONSchema=(n,r,s)=>ag(t,n,r,s),t.unwrap=()=>t._zod.def.innerType});function iC(t){return new sC({type:"optional",innerType:t})}const oC=S("ZodNullable",(t,e)=>{MA.init(t,e),ce.init(t,e),t._zod.processJSONSchema=(n,r,s)=>tT(t,n,r,s),t.unwrap=()=>t._zod.def.innerType});function wd(t){return new oC({type:"nullable",innerType:t})}const aC=S("ZodDefault",(t,e)=>{NA.init(t,e),ce.init(t,e),t._zod.processJSONSchema=(n,r,s)=>rT(t,n,r,s),t.unwrap=()=>t._zod.def.innerType,t.removeDefault=t.unwrap});function lC(t,e){return new aC({type:"default",innerType:t,get defaultValue(){return typeof e=="function"?e():Ff(e)}})}const cC=S("ZodPrefault",(t,e)=>{UA.init(t,e),ce.init(t,e),t._zod.processJSONSchema=(n,r,s)=>sT(t,n,r,s),t.unwrap=()=>t._zod.def.innerType});function uC(t,e){return new cC({type:"prefault",innerType:t,get defaultValue(){return typeof e=="function"?e():Ff(e)}})}const fg=S("ZodNonOptional",(t,e)=>{FA.init(t,e),ce.init(t,e),t._zod.processJSONSchema=(n,r,s)=>nT(t,n,r,s),t.unwrap=()=>t._zod.def.innerType});function hC(t,e){return new fg({type:"nonoptional",innerType:t,...O(e)})}const dC=S("ZodCatch",(t,e)=>{ZA.init(t,e),ce.init(t,e),t._zod.processJSONSchema=(n,r,s)=>iT(t,n,r,s),t.unwrap=()=>t._zod.def.innerType,t.removeCatch=t.unwrap});function pC(t,e){return new dC({type:"catch",innerType:t,catchValue:typeof e=="function"?e:()=>e})}const fC=S("ZodPipe",(t,e)=>{jA.init(t,e),ce.init(t,e),t._zod.processJSONSchema=(n,r,s)=>oT(t,n,r,s),t.in=e.in,t.out=e.out});function _d(t,e){return new fC({type:"pipe",in:t,out:e})}const gC=S("ZodReadonly",(t,e)=>{WA.init(t,e),ce.init(t,e),t._zod.processJSONSchema=(n,r,s)=>aT(t,n,r,s),t.unwrap=()=>t._zod.def.innerType});function mC(t){return new gC({type:"readonly",innerType:t})}const vC=S("ZodCustom",(t,e)=>{BA.init(t,e),ce.init(t,e),t._zod.processJSONSchema=(n,r,s)=>qx(t,n)});function yC(t,e={}){return Lx(vC,t,e)}function bC(t){return Mx(t)}const wC=["text/markdown","text/html"],_C=["committed","pending"];dg({id:h().min(1),type:yo(wC),title:h(),status:yo(_C),externalFilePath:h().optional()});dg({name:h().min(1),description:h(),accepts:R(h().min(1)).min(1)});function zc(t){return typeof t=="object"&&t!==null}function SC(t){return!zc(t)||t.type!=="ready"?!1:!("id"in t)}function kC(t){return!(!zc(t)||t.type!=="update-content"||typeof t.id!="string"||typeof t.content!="string")}function EC(t){return!zc(t)||t.type!=="wheel"||typeof t.deltaX!="number"||typeof t.deltaY!="number"||typeof t.shiftKey!="boolean"?!1:!("id"in t)}function $C(t,e){if(t===e)return 2;if(t==="*/*")return 0;const n=t.indexOf("/");if(n>0&&t.slice(n+1)==="*"){const r=t.slice(0,n),s=e.indexOf("/");if(s>0&&e.slice(0,s)===r)return 1}return null}function AC(t,e){let n=null;for(const r of t.accepts){const s=$C(r,e);s!==null&&(n===null||s>n)&&(n=s)}return n}function xC(t,e){let n=-1,r=null;for(const s of e){const i=AC(s,t);i!==null&&(i>n||i===n&&r!==null&&s.id<r.id)&&(n=i,r=s)}return r}const TC=4401;class bl extends Error{constructor(e="Authentication required"){super(e),this.name="AuthError"}}class wl extends kt{constructor(n){super();v(this,"url");v(this,"name");v(this,"token");v(this,"status","disconnected");v(this,"screens",new Map);v(this,"views",[]);v(this,"client");v(this,"createSocket");v(this,"createClient");v(this,"socket",null);v(this,"connectAttempt",0);this.url=Pt(n.url),this.name=n.name,this.token=n.token??null,this.createSocket=n.createSocket??(r=>new WebSocket(r)),this.createClient=n.createClient??((r,s)=>new RE(r,{token:s??void 0})),this.client=this.createClient(this.url,this.token)}async connect(){var s;this.connectAttempt+=1;const n=this.connectAttempt;(s=this.socket)==null||s.close(),this.client=this.createClient(this.url,this.token),this.status="connecting",this.dispatchEvent(new te("change"));const r=this.createSocket(CC(this.url,this.token));return this.socket=r,await new Promise((i,o)=>{let a=!1;const l=()=>{a||this.connectAttempt!==n||(a=!0,this.status="connected",this.dispatchEvent(new te("change")),i())},c=p=>{a||this.connectAttempt!==n||(a=!0,this.status="disconnected",this.dispatchEvent(new te("change")),o(p))},d=async()=>{try{const[{screens:p},y]=await Promise.all([this.client.screens.list(),this.client.views.list()]);this.screens=new Map(p.map(m=>[m.id,structuredClone(m)])),this.views=y,this.dispatchEvent(new te("change")),l()}catch(p){c(p instanceof Error?p:new Error(String(p)))}};r.addEventListener("open",()=>{d()}),r.addEventListener("message",p=>{const y=PC(p);y&&(this.applyServerEvent(y),this.dispatchEvent(new $f("server-event",{serverURL:this.url,event:y})))}),r.addEventListener("close",p=>{if(this.connectAttempt===n){if(this.socket=null,IC(p)===TC){c(new bl);return}if(!a){c(new Error("Connection closed before initialization"));return}this.status="disconnected",this.dispatchEvent(new te("change"))}}),r.addEventListener("error",()=>{c(new Error("WebSocket connection failed"))})})}disconnect(){var n;this.connectAttempt+=1,(n=this.socket)==null||n.close(),this.socket=null,this.status="disconnected",this.dispatchEvent(new te("change"))}getViewURL(n){const r=xC(n.type,this.views);if(!r)return null;const s=`${this.url}/views/${encodeURIComponent(r.id)}/`;return this.token===null?s:`${s}?token=${encodeURIComponent(this.token)}`}getContentURL(n){const r=`${this.url}/artifacts/${encodeURIComponent(n)}/content`;return this.token===null?r:`${r}?token=${encodeURIComponent(this.token)}`}async createScreen(n){const{screen:r}=await this.client.screens.create({name:n});return this.screens.set(r.id,structuredClone(r)),r}applyServerEvent(n){switch(n.type){case"screen-created":this.screens.set(n.screen.id,structuredClone(n.screen)),this.dispatchEvent(new eo("screens-changed"));break;case"screen-updated":this.screens.set(n.screen.id,structuredClone(n.screen)),this.dispatchEvent(new eo("screens-changed"));break;case"screen-removed":this.screens.delete(n.screenID),this.dispatchEvent(new eo("screens-changed"));break;case"artifact-created":{const r=this.screens.get(n.screenID);r&&!Sf(r.layout,n.artifact.id)&&(r.layout=[...r.layout,_f(n.artifact.id)]);break}case"artifact-removed":{const r=this.screens.get(n.screenID);r&&(r.layout=df(r.layout,n.artifactID));break}}}}function CC(t,e){const n=new URL(t);return n.protocol=n.protocol==="https:"?"wss:":"ws:",n.pathname="/events",n.search="",e&&n.searchParams.set("token",e),n.hash="",n.toString()}function IC(t){return typeof t=="object"&&t!==null&&"code"in t&&typeof t.code=="number"?t.code:null}function PC(t){const e=typeof t=="string"?t:typeof t=="object"&&t!==null&&"data"in t&&typeof t.data=="string"?t.data:"";if(!e)return null;try{return JSON.parse(e)}catch{return null}}class RC extends kt{constructor(n){super();v(this,"servers",new Map);v(this,"localServerURL");v(this,"localStore");v(this,"createSocket");v(this,"lastActiveServerURL");v(this,"serverListeners",new Map);v(this,"handleLocalStoreChange",()=>{const n=this.localStore.get().activeServerURL;n!==this.lastActiveServerURL&&(this.lastActiveServerURL=n,this.dispatchEvent(new te("change")))});this.localStore=n.localStore,this.localServerURL=n.localServerURL?Pt(n.localServerURL):null,this.createSocket=n.createSocket??(r=>new WebSocket(r)),this.lastActiveServerURL=this.localStore.get().activeServerURL,this.localStore.addEventListener("change",this.handleLocalStoreChange)}get activeServer(){const n=this.localStore.get().activeServerURL;return n===null?null:this.servers.get(n)??null}add(n){const r=Pt(n.url);this.servers.get(r)&&this.remove(r),this.servers.set(r,n);const i=()=>{this.dispatchEvent(new te("change"))},o=l=>{this.dispatchEvent(new $f("server-event",{serverURL:l.serverURL,event:l.event}))},a=()=>{this.dispatchEvent(new eo("screens-changed"))};n.addEventListener("change",i),n.addEventListener("server-event",o),n.addEventListener("screens-changed",a),this.serverListeners.set(r,{onServerChange:i,onServerEvent:o,onScreensChanged:a}),this.dispatchEvent(new te("change"))}remove(n){const r=Pt(n);if(this.localServerURL&&r===this.localServerURL)return;const s=this.servers.get(r);if(!s)return;const i=this.serverListeners.get(r);i&&(s.removeEventListener("change",i.onServerChange),s.removeEventListener("server-event",i.onServerEvent),s.removeEventListener("screens-changed",i.onScreensChanged),this.serverListeners.delete(r)),s.disconnect(),this.servers.delete(r);const o=this.localStore.get(),a=o.activeServerURL===r;this.localStore.set({...o,servers:o.servers.filter(l=>l.url!==r),activeServerURL:a?null:o.activeServerURL}),this.dispatchEvent(new te("change"))}setActive(n){const r=this.localStore.get(),s=n?Pt(n.url):null;r.activeServerURL!==s&&this.localStore.set({...r,activeServerURL:s})}connectConfiguredServers(n){const r=this.localStore.get().servers;for(const i of r){const o=new wl({url:i.url,name:i.name,createSocket:this.createSocket});this.add(o),o.connect().catch(()=>{})}const s=n?this.servers.get(Pt(n))??null:null;this.setActive(s??this.servers.values().next().value??null)}addServer(n,r){const s=Pt(n);this.remove(s);const i=this.localStore.get();this.localStore.set({...i,servers:[...i.servers.filter(a=>Pt(a.url)!==s),{url:s,name:r}]});const o=new wl({url:s,name:r,createSocket:this.createSocket});this.add(o),this.setActive(o),o.connect().catch(()=>{})}removeServer(n){this.remove(n)}}const ie={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"},Tt={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"},DC=1,OC=f({_meta:_(h(),w()).nullish(),terminal:ke().optional().default(!1)}),zC=f({_meta:_(h(),w()).nullish(),label:h().nullish(),name:h(),optional:ke().optional().default(!1),secret:ke().optional().default(!0)}),LC=f({_meta:_(h(),w()).nullish(),description:h().nullish(),id:h(),name:h()}),MC=f({_meta:_(h(),w()).nullish(),description:h().nullish(),id:h(),link:h().nullish(),name:h(),vars:R(zC)}),NC=f({_meta:_(h(),w()).nullish(),args:R(h()).optional(),description:h().nullish(),env:_(h(),h()).optional(),id:h(),name:h()}),UC=Z([MC.and(f({type:A("env_var")})),NC.and(f({type:A("terminal")})),LC]),FC=f({_meta:_(h(),w()).nullish(),methodId:h()}),ZC=f({_meta:_(h(),w()).nullish()}),jC=f({_meta:_(h(),w()).nullish(),blob:h(),mimeType:h().nullish(),uri:h()}),WC=f({default:ke().nullish(),description:h().nullish(),title:h().nullish()}),BC=f({_meta:_(h(),w()).nullish()}),GC=f({_meta:_(h(),w()).nullish()}),VC=f({amount:U(),currency:h()}),HC=f({_meta:_(h(),w()).nullish(),terminalId:h()}),qC=f({_meta:_(h(),w()).nullish(),newText:h(),oldText:h().nullish(),path:h()}),YC=Z([h(),U(),U(),ke(),R(h())]),KC=f({content:_(h(),YC).nullish()}),JC=Z([KC.and(f({action:A("accept")})),f({action:A("decline")}),f({action:A("cancel")})]),XC=f({_meta:_(h(),w()).nullish()}),gg=h(),QC=f({_meta:_(h(),w()).nullish(),elicitationId:gg}),eI=f({_meta:_(h(),w()).nullish(),action:JC}),tI=A("object"),nI=A("string"),rI=f({_meta:_(h(),w()).nullish()}),sI=f({_meta:_(h(),w()).nullish(),form:XC.nullish(),url:rI.nullish()}),iI=f({elicitationId:gg,url:h().url()}),mg=f({const:h(),title:h()}),vg=f({_meta:_(h(),w()).nullish(),name:h(),value:h()}),oI=Z([A(-32700),A(-32600),A(-32601),A(-32602),A(-32603),A(-32800),A(-32e3),A(-32002),A(-32042),U().int().min(-2147483648,{message:"Invalid value: Expected int32 to be >= -2147483648"}).max(2147483647,{message:"Invalid value: Expected int32 to be <= 2147483647"})]),yg=f({code:oI,data:w().optional(),message:h()}),bg=w(),wg=w(),_g=w(),aI=f({_meta:_(h(),w()).nullish(),readTextFile:ke().optional().default(!1),writeTextFile:ke().optional().default(!1)}),Sg=f({_meta:_(h(),w()).nullish(),name:h(),value:h()}),kg=f({_meta:_(h(),w()).nullish(),name:h(),title:h().nullish(),version:h()}),lI=f({default:U().nullish(),description:h().nullish(),maximum:U().nullish(),minimum:U().nullish(),title:h().nullish()}),cI=f({_meta:_(h(),w()).nullish()}),uI=f({_meta:_(h(),w()).nullish(),additionalDirectories:R(h()).optional(),cursor:h().nullish(),cwd:h().nullish()}),hI=f({_meta:_(h(),w()).nullish()}),dI=f({_meta:_(h(),w()).nullish(),logout:hI.nullish()}),pI=f({_meta:_(h(),w()).nullish()}),fI=f({_meta:_(h(),w()).nullish()}),gI=f({_meta:_(h(),w()).nullish(),http:ke().optional().default(!1),sse:ke().optional().default(!1)}),mI=f({_meta:_(h(),w()).nullish(),headers:R(Sg),name:h(),url:h()}),vI=f({_meta:_(h(),w()).nullish(),headers:R(Sg),name:h(),url:h()}),yI=f({_meta:_(h(),w()).nullish(),args:R(h()),command:h(),env:R(vg),name:h()}),Go=Z([mI.and(f({type:A("http")})),vI.and(f({type:A("sse")})),yI]),Lc=h(),bI=f({_meta:_(h(),w()).nullish(),description:h().nullish(),modelId:Lc,name:h()}),wI=Z([A("error"),A("warning"),A("information"),A("hint")]),_I=f({_meta:_(h(),w()).nullish()}),SI=f({_meta:_(h(),w()).nullish()}),kI=f({_meta:_(h(),w()).nullish()}),EI=f({_meta:_(h(),w()).nullish()}),$I=f({_meta:_(h(),w()).nullish()}),AI=f({_meta:_(h(),w()).nullish(),maxCount:U().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish()}),xI=f({diff:h(),uri:h()}),TI=f({endLine:U().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}),startLine:U().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}),text:h()}),CI=f({_meta:_(h(),w()).nullish()}),II=f({_meta:_(h(),w()).nullish()}),PI=f({languageId:h(),text:h(),uri:h()}),RI=f({_meta:_(h(),w()).nullish(),maxCount:U().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish()}),DI=Z([A("rejected"),A("ignored"),A("replaced"),A("cancelled")]),OI=f({excerpts:R(TI),uri:h()}),zI=f({_meta:_(h(),w()).nullish()}),LI=f({_meta:_(h(),w()).nullish()}),MI=f({name:h(),owner:h(),remoteUrl:h()}),NI=f({_meta:_(h(),w()).nullish()}),UI=f({_meta:_(h(),w()).nullish(),jump:CI.nullish(),rename:LI.nullish(),searchAndReplace:NI.nullish()}),FI=f({id:h(),isRegex:ke().nullish(),replace:h(),search:h(),uri:h()}),ZI=Z([A("automatic"),A("diagnostic"),A("manual")]),jI=f({_meta:_(h(),w()).nullish(),maxCount:U().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish()}),WI=f({_meta:_(h(),w()).nullish(),diagnostics:_I.nullish(),editHistory:AI.nullish(),openFiles:II.nullish(),recentFiles:RI.nullish(),relatedSnippets:zI.nullish(),userActions:jI.nullish()}),BI=f({_meta:_(h(),w()).nullish(),additionalDirectories:R(h()).optional(),cwd:h(),mcpServers:R(Go)}),GI=f({default:U().nullish(),description:h().nullish(),maximum:U().nullish(),minimum:U().nullish(),title:h().nullish()}),Eg=h(),VI=Z([A("allow_once"),A("allow_always"),A("reject_once"),A("reject_always")]),HI=f({_meta:_(h(),w()).nullish(),kind:VI,name:h(),optionId:Eg}),qI=Z([A("high"),A("medium"),A("low")]),YI=Z([A("pending"),A("in_progress"),A("completed")]),KI=f({_meta:_(h(),w()).nullish(),content:h(),priority:qI,status:YI}),JI=f({_meta:_(h(),w()).nullish(),entries:R(KI)}),ln=f({character:U().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}),line:U().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"})}),XI=f({id:h(),position:ln,uri:h()}),QI=f({id:h(),newName:h(),position:ln,uri:h()}),e0=f({action:h(),position:ln,timestampMs:U(),uri:h()}),$g=Z([A("utf-16"),A("utf-32"),A("utf-8")]),t0=f({_meta:_(h(),w()).nullish(),auth:OC.optional().default({terminal:!1}),elicitation:sI.nullish(),fs:aI.optional().default({readTextFile:!1,writeTextFile:!1}),nes:UI.nullish(),positionEncodings:R($g).optional(),terminal:ke().optional().default(!1)}),n0=f({_meta:_(h(),w()).nullish(),audio:ke().optional().default(!1),embeddedContext:ke().optional().default(!1),image:ke().optional().default(!1)}),Ag=U().int().gte(0).lte(65535),r0=f({_meta:_(h(),w()).nullish(),clientCapabilities:t0.optional().default({auth:{terminal:!1},fs:{readTextFile:!1,writeTextFile:!1},terminal:!1}),clientInfo:kg.nullish(),protocolVersion:Ag}),Yr=f({end:ln,start:ln}),s0=f({message:h(),range:Yr,severity:wI,uri:h()}),i0=f({languageId:h(),lastFocusedMs:U().nullish(),uri:h(),visibleRange:Yr.nullish()}),o0=f({_meta:_(h(),w()).nullish(),diagnostics:R(s0).nullish(),editHistory:R(xI).nullish(),openFiles:R(i0).nullish(),recentFiles:R(PI).nullish(),relatedSnippets:R(OI).nullish(),userActions:R(e0).nullish()}),a0=f({newText:h(),range:Yr}),l0=f({cursorPosition:ln.nullish(),edits:R(a0),id:h(),uri:h()}),c0=Z([l0.and(f({kind:A("edit")})),XI.and(f({kind:A("jump")})),QI.and(f({kind:A("rename")})),FI.and(f({kind:A("searchAndReplace")}))]),u0=f({_meta:_(h(),w()).nullish(),content:h()}),h0=f({_meta:_(h(),w()).nullish()}),Bn=Z([U(),h()]).nullable();f({_meta:_(h(),w()).nullish(),requestId:Bn});const d0=yo(["assistant","user"]),vi=f({_meta:_(h(),w()).nullish(),audience:R(d0).nullish(),lastModified:h().nullish(),priority:U().nullish()}),p0=f({_meta:_(h(),w()).nullish(),annotations:vi.nullish(),data:h(),mimeType:h()}),f0=f({_meta:_(h(),w()).nullish(),annotations:vi.nullish(),data:h(),mimeType:h(),uri:h().nullish()}),g0=f({_meta:_(h(),w()).nullish(),annotations:vi.nullish(),description:h().nullish(),mimeType:h().nullish(),name:h(),size:U().nullish(),title:h().nullish(),uri:h()}),m0=f({_meta:_(h(),w()).nullish(),optionId:Eg}),v0=Z([f({outcome:A("cancelled")}),m0.and(f({outcome:A("selected")}))]),y0=f({_meta:_(h(),w()).nullish(),outcome:v0}),b0=f({_meta:_(h(),w()).nullish()}),w0=f({_meta:_(h(),w()).nullish()}),_0=f({currentValue:ke()}),S0=h(),xg=h(),k0=Z([A("mode"),A("model"),A("thought_level"),h()]),Mc=h(),Tg=f({_meta:_(h(),w()).nullish(),description:h().nullish(),name:h(),value:Mc}),E0=f({_meta:_(h(),w()).nullish(),group:S0,name:h(),options:R(Tg)}),$0=Z([R(Tg),R(E0)]),A0=f({currentValue:Mc,options:$0}),Kr=Bo(Z([A0.and(f({type:A("select")})),_0.and(f({type:A("boolean")}))]),f({_meta:_(h(),w()).nullish(),category:k0.nullish(),description:h().nullish(),id:xg,name:h()})),x0=f({_meta:_(h(),w()).nullish(),configOptions:R(Kr)}),T0=f({_meta:_(h(),w()).nullish()}),K=h(),C0=f({_meta:_(h(),w()).nullish(),id:h(),sessionId:K}),I0=f({_meta:_(h(),w()).nullish(),sessionId:K}),P0=f({_meta:_(h(),w()).nullish(),sessionId:K}),R0=f({_meta:_(h(),w()).nullish(),sessionId:K}),Cg=f({_meta:_(h(),w()).nullish(),args:R(h()).optional(),command:h(),cwd:h().nullish(),env:R(vg).optional(),outputByteLimit:U().nullish(),sessionId:K}),D0=f({_meta:_(h(),w()).nullish(),sessionId:K,uri:h()}),O0=f({_meta:_(h(),w()).nullish(),position:ln,sessionId:K,uri:h(),version:U(),visibleRange:Yr}),z0=f({_meta:_(h(),w()).nullish(),languageId:h(),sessionId:K,text:h(),uri:h(),version:U()}),L0=f({_meta:_(h(),w()).nullish(),sessionId:K,uri:h()}),M0=f({_meta:_(h(),w()).nullish(),additionalDirectories:R(h()).optional(),cwd:h(),mcpServers:R(Go).optional(),sessionId:K}),Ig=f({_meta:_(h(),w()).nullish(),sessionId:K,terminalId:h()}),N0=f({_meta:_(h(),w()).nullish(),additionalDirectories:R(h()).optional(),cwd:h(),mcpServers:R(Go),sessionId:K}),Pg=f({_meta:_(h(),w()).nullish(),limit:U().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),line:U().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),path:h(),sessionId:K}),U0=f({_meta:_(h(),w()).nullish(),id:h(),reason:DI.nullish(),sessionId:K}),Rg=f({_meta:_(h(),w()).nullish(),sessionId:K,terminalId:h()}),F0=f({_meta:_(h(),w()).nullish(),additionalDirectories:R(h()).optional(),cwd:h(),mcpServers:R(Go).optional(),sessionId:K}),Z0=f({_meta:_(h(),w()).nullish(),additionalDirectories:R(h()).optional(),cwd:h(),sessionId:K,title:h().nullish(),updatedAt:h().nullish()}),j0=f({_meta:_(h(),w()).nullish(),nextCursor:h().nullish(),sessions:R(Z0)}),W0=f({_meta:_(h(),w()).nullish(),title:h().nullish(),updatedAt:h().nullish()}),B0=f({_meta:_(h(),w()).nullish()}),Vo=h(),G0=f({_meta:_(h(),w()).nullish(),currentModeId:Vo}),V0=f({_meta:_(h(),w()).nullish(),description:h().nullish(),id:Vo,name:h()}),Ho=f({_meta:_(h(),w()).nullish(),availableModes:R(V0),currentModeId:Vo}),qo=f({_meta:_(h(),w()).nullish(),availableModels:R(bI),currentModelId:Lc}),H0=f({_meta:_(h(),w()).nullish(),configOptions:R(Kr).nullish(),models:qo.nullish(),modes:Ho.nullish(),sessionId:K}),q0=f({_meta:_(h(),w()).nullish(),configOptions:R(Kr).nullish(),models:qo.nullish(),modes:Ho.nullish()}),Y0=f({_meta:_(h(),w()).nullish(),configOptions:R(Kr).nullish(),models:qo.nullish(),modes:Ho.nullish(),sessionId:K}),K0=f({_meta:_(h(),w()).nullish(),configOptions:R(Kr).nullish(),models:qo.nullish(),modes:Ho.nullish()}),J0=f({_meta:_(h(),w()).nullish()}),X0=f({_meta:_(h(),w()).nullish(),additionalDirectories:b0.nullish(),close:w0.nullish(),fork:T0.nullish(),list:B0.nullish(),resume:J0.nullish()}),Q0=Bo(Z([f({type:A("boolean"),value:ke()}),f({value:Mc})]),f({_meta:_(h(),w()).nullish(),configId:xg,sessionId:K})),eP=f({_meta:_(h(),w()).nullish(),configOptions:R(Kr)}),tP=f({_meta:_(h(),w()).nullish(),modeId:Vo,sessionId:K}),nP=f({_meta:_(h(),w()).nullish()}),rP=f({_meta:_(h(),w()).nullish(),modelId:Lc,sessionId:K}),sP=f({_meta:_(h(),w()).nullish()}),iP=f({_meta:_(h(),w()).nullish(),sessionId:K}),oP=Z([A("end_turn"),A("max_tokens"),A("max_turn_requests"),A("refusal"),A("cancelled")]),aP=Z([A("email"),A("uri"),A("date"),A("date-time")]),lP=f({default:h().nullish(),description:h().nullish(),enum:R(h()).nullish(),format:aP.nullish(),maxLength:U().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),minLength:U().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),oneOf:R(mg).nullish(),pattern:h().nullish(),title:h().nullish()}),cP=f({_meta:_(h(),w()).nullish(),context:o0.nullish(),position:ln,selection:Yr.nullish(),sessionId:K,triggerKind:ZI,uri:h(),version:U()}),uP=f({_meta:_(h(),w()).nullish(),suggestions:R(c0)}),hP=f({_meta:_(h(),w()).nullish(),terminalId:h()}),dP=f({_meta:_(h(),w()).nullish(),exitCode:U().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),signal:h().nullish()}),Dg=f({_meta:_(h(),w()).nullish(),sessionId:K,terminalId:h()}),pP=f({_meta:_(h(),w()).nullish(),exitStatus:dP.nullish(),output:h(),truncated:ke()}),fP=f({_meta:_(h(),w()).nullish(),annotations:vi.nullish(),text:h()}),gP=f({range:Yr.nullish(),text:h()}),mP=f({_meta:_(h(),w()).nullish(),contentChanges:R(gP),sessionId:K,uri:h(),version:U()});f({method:h(),params:Z([I0,z0,mP,D0,L0,O0,C0,U0,bg]).nullish()});const vP=Z([A("full"),A("incremental")]),yP=f({_meta:_(h(),w()).nullish(),syncKind:vP}),bP=f({_meta:_(h(),w()).nullish(),didChange:yP.nullish(),didClose:SI.nullish(),didFocus:kI.nullish(),didOpen:EI.nullish(),didSave:$I.nullish()}),wP=f({_meta:_(h(),w()).nullish(),document:bP.nullish()}),_P=f({_meta:_(h(),w()).nullish(),context:WI.nullish(),events:wP.nullish()}),SP=f({_meta:_(h(),w()).nullish(),auth:dI.optional().default({}),loadSession:ke().optional().default(!1),mcpCapabilities:gI.optional().default({http:!1,sse:!1}),nes:_P.nullish(),positionEncoding:$g.nullish(),promptCapabilities:n0.optional().default({audio:!1,embeddedContext:!1,image:!1}),sessionCapabilities:X0.optional().default({})}),kP=f({_meta:_(h(),w()).nullish(),agentCapabilities:SP.optional().default({auth:{},loadSession:!1,mcpCapabilities:{http:!1,sse:!1},promptCapabilities:{audio:!1,embeddedContext:!1,image:!1},sessionCapabilities:{}}),agentInfo:kg.nullish(),authMethods:R(UC).optional().default([]),protocolVersion:Ag}),EP=f({_meta:_(h(),w()).nullish(),mimeType:h().nullish(),text:h(),uri:h()}),$P=Z([EP,jC]),AP=f({_meta:_(h(),w()).nullish(),annotations:vi.nullish(),resource:$P}),Nc=Z([fP.and(f({type:A("text")})),f0.and(f({type:A("image")})),p0.and(f({type:A("audio")})),g0.and(f({type:A("resource_link")})),AP.and(f({type:A("resource")}))]),xP=f({_meta:_(h(),w()).nullish(),content:Nc}),Za=f({_meta:_(h(),w()).nullish(),content:Nc,messageId:h().nullish()}),TP=f({_meta:_(h(),w()).nullish(),messageId:h().nullish(),prompt:R(Nc),sessionId:K}),CP=f({anyOf:R(mg)}),Og=Z([xP.and(f({type:A("content")})),qC.and(f({type:A("diff")})),hP.and(f({type:A("terminal")}))]),zg=h(),Lg=f({_meta:_(h(),w()).nullish(),line:U().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),path:h()}),Mg=Z([A("pending"),A("in_progress"),A("completed"),A("failed")]),Ng=Z([A("read"),A("edit"),A("delete"),A("move"),A("search"),A("execute"),A("think"),A("fetch"),A("switch_mode"),A("other")]),IP=f({_meta:_(h(),w()).nullish(),content:R(Og).optional(),kind:Ng.optional(),locations:R(Lg).optional(),rawInput:w().optional(),rawOutput:w().optional(),status:Mg.optional(),title:h(),toolCallId:zg}),Ug=f({_meta:_(h(),w()).nullish(),content:R(Og).nullish(),kind:Ng.nullish(),locations:R(Lg).nullish(),rawInput:w().optional(),rawOutput:w().optional(),status:Mg.nullish(),title:h().nullish(),toolCallId:zg}),Fg=f({_meta:_(h(),w()).nullish(),options:R(HI),sessionId:K,toolCall:Ug}),PP=f({_meta:_(h(),w()).nullish(),hint:h()}),RP=PP,DP=f({_meta:_(h(),w()).nullish(),description:h(),input:RP.nullish(),name:h()}),OP=f({_meta:_(h(),w()).nullish(),availableCommands:R(DP)}),zP=f({enum:R(h()),type:nI}),LP=Z([zP,CP]),MP=f({default:R(h()).nullish(),description:h().nullish(),items:LP,maxItems:U().nullish(),minItems:U().nullish(),title:h().nullish()}),NP=Z([lP.and(f({type:A("string")})),GI.and(f({type:A("number")})),lI.and(f({type:A("integer")})),WC.and(f({type:A("boolean")})),MP.and(f({type:A("array")}))]),UP=f({description:h().nullish(),properties:_(h(),NP).optional().default({}),required:R(h()).nullish(),title:h().nullish(),type:tI.optional().default("object")}),FP=f({requestedSchema:UP}),ZP=Bo(Z([FP.and(f({mode:A("form")})),iI.and(f({mode:A("url")}))]),f({_meta:_(h(),w()).nullish(),message:h(),sessionId:K})),jP=f({cachedReadTokens:U().nullish(),cachedWriteTokens:U().nullish(),inputTokens:U(),outputTokens:U(),thoughtTokens:U().nullish(),totalTokens:U()}),WP=f({_meta:_(h(),w()).nullish(),stopReason:oP,usage:jP.nullish(),userMessageId:h().nullish()});Z([f({id:Bn,result:Z([kP,ZC,fI,Y0,q0,j0,H0,K0,GC,nP,eP,WP,sP,iP,uP,BC,_g])}),f({error:yg,id:Bn})]);const BP=f({_meta:_(h(),w()).nullish(),cost:VC.nullish(),size:U(),used:U()}),GP=Z([Za.and(f({sessionUpdate:A("user_message_chunk")})),Za.and(f({sessionUpdate:A("agent_message_chunk")})),Za.and(f({sessionUpdate:A("agent_thought_chunk")})),IP.and(f({sessionUpdate:A("tool_call")})),Ug.and(f({sessionUpdate:A("tool_call_update")})),JI.and(f({sessionUpdate:A("plan")})),OP.and(f({sessionUpdate:A("available_commands_update")})),G0.and(f({sessionUpdate:A("current_mode_update")})),x0.and(f({sessionUpdate:A("config_option_update")})),W0.and(f({sessionUpdate:A("session_info_update")})),BP.and(f({sessionUpdate:A("usage_update")}))]),Zg=f({_meta:_(h(),w()).nullish(),sessionId:K,update:GP});f({method:h(),params:Z([Zg,QC,bg]).nullish()});const jg=f({_meta:_(h(),w()).nullish(),sessionId:K,terminalId:h()}),VP=f({_meta:_(h(),w()).nullish(),exitCode:U().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),signal:h().nullish()}),HP=f({name:h(),uri:h()}),qP=f({_meta:_(h(),w()).nullish(),repository:MI.nullish(),workspaceFolders:R(HP).nullish(),workspaceUri:h().nullish()});f({id:Bn,method:h(),params:Z([r0,FC,pI,BI,N0,uI,M0,F0,R0,tP,Q0,TP,rP,qP,cP,P0,wg]).nullish()});const Wg=f({_meta:_(h(),w()).nullish(),content:h(),path:h(),sessionId:K});f({id:Bn,method:h(),params:Z([Wg,Pg,Fg,Cg,Dg,Rg,jg,Ig,ZP,wg]).nullish()});const YP=f({_meta:_(h(),w()).nullish()});Z([f({id:Bn,result:Z([YP,u0,y0,HC,pP,h0,VP,cI,eI,_g])}),f({error:yg,id:Bn})]);var Y;class KP{constructor(e,n){$(this,Y);const r=e(this),s=async(o,a)=>{var l,c,d,p,y,m,E;switch(o){case Tt.fs_write_text_file:{const k=Wg.parse(a);return(l=r.writeTextFile)==null?void 0:l.call(r,k)}case Tt.fs_read_text_file:{const k=Pg.parse(a);return(c=r.readTextFile)==null?void 0:c.call(r,k)}case Tt.session_request_permission:{const k=Fg.parse(a);return r.requestPermission(k)}case Tt.terminal_create:{const k=Cg.parse(a);return(d=r.createTerminal)==null?void 0:d.call(r,k)}case Tt.terminal_output:{const k=Dg.parse(a);return(p=r.terminalOutput)==null?void 0:p.call(r,k)}case Tt.terminal_release:{const k=Rg.parse(a);return await((y=r.releaseTerminal)==null?void 0:y.call(r,k))??{}}case Tt.terminal_wait_for_exit:{const k=jg.parse(a);return(m=r.waitForTerminalExit)==null?void 0:m.call(r,k)}case Tt.terminal_kill:{const k=Ig.parse(a);return await((E=r.killTerminal)==null?void 0:E.call(r,k))??{}}default:if(r.extMethod)return r.extMethod(o,a);throw ye.methodNotFound(o)}},i=async(o,a)=>{switch(o){case Tt.session_update:{const l=Zg.parse(a);return r.sessionUpdate(l)}default:if(r.extNotification)return r.extNotification(o,a);throw ye.methodNotFound(o)}};x(this,Y,new JP(s,i,n))}async initialize(e){return await u(this,Y).sendRequest(ie.initialize,e)}async newSession(e){return await u(this,Y).sendRequest(ie.session_new,e)}async loadSession(e){return await u(this,Y).sendRequest(ie.session_load,e)??{}}async unstable_forkSession(e){return await u(this,Y).sendRequest(ie.session_fork,e)}async listSessions(e){return await u(this,Y).sendRequest(ie.session_list,e)}async unstable_resumeSession(e){return await u(this,Y).sendRequest(ie.session_resume,e)}async unstable_closeSession(e){return await u(this,Y).sendRequest(ie.session_close,e)}async setSessionMode(e){return await u(this,Y).sendRequest(ie.session_set_mode,e)??{}}async unstable_setSessionModel(e){return await u(this,Y).sendRequest(ie.session_set_model,e)??{}}async setSessionConfigOption(e){return await u(this,Y).sendRequest(ie.session_set_config_option,e)}async authenticate(e){return await u(this,Y).sendRequest(ie.authenticate,e)??{}}async unstable_logout(e){return await u(this,Y).sendRequest(ie.logout,e)??{}}async prompt(e){return await u(this,Y).sendRequest(ie.session_prompt,e)}async cancel(e){return await u(this,Y).sendNotification(ie.session_cancel,e)}async unstable_startNes(e){return await u(this,Y).sendRequest(ie.nes_start,e)}async unstable_suggestNes(e){return await u(this,Y).sendRequest(ie.nes_suggest,e)}async unstable_closeNes(e){return await u(this,Y).sendRequest(ie.nes_close,e)??{}}async unstable_didOpenDocument(e){return await u(this,Y).sendNotification(ie.document_did_open,e)}async unstable_didChangeDocument(e){return await u(this,Y).sendNotification(ie.document_did_change,e)}async unstable_didCloseDocument(e){return await u(this,Y).sendNotification(ie.document_did_close,e)}async unstable_didSaveDocument(e){return await u(this,Y).sendNotification(ie.document_did_save,e)}async unstable_didFocusDocument(e){return await u(this,Y).sendNotification(ie.document_did_focus,e)}async unstable_acceptNes(e){return await u(this,Y).sendNotification(ie.nes_accept,e)}async unstable_rejectNes(e){return await u(this,Y).sendNotification(ie.nes_reject,e)}async extMethod(e,n){return await u(this,Y).sendRequest(e,n)}async extNotification(e,n){return await u(this,Y).sendNotification(e,n)}get signal(){return u(this,Y).signal}get closed(){return u(this,Y).closed}}Y=new WeakMap;var Yt,Ao,Us,Fs,Sr,kr,yt,Zs,ae,Bg,_l,Gg,Vg,Hg,qg,Sl,ms;class JP{constructor(e,n,r){$(this,ae);$(this,Yt,new Map);$(this,Ao,0);$(this,Us);$(this,Fs);$(this,Sr);$(this,kr,Promise.resolve());$(this,yt,new AbortController);$(this,Zs);x(this,Us,e),x(this,Fs,n),x(this,Sr,r),x(this,Zs,new Promise(s=>{u(this,yt).signal.addEventListener("abort",()=>s())})),b(this,ae,Bg).call(this)}get signal(){return u(this,yt).signal}get closed(){return u(this,Zs)}async sendRequest(e,n){b(this,ae,Sl).call(this);const r=$u(this,Ao)._++,s=new Promise((i,o)=>{u(this,Yt).set(r,{resolve:i,reject:o})});return await b(this,ae,ms).call(this,{jsonrpc:"2.0",id:r,method:e,params:n}),s}async sendNotification(e,n){b(this,ae,Sl).call(this),await b(this,ae,ms).call(this,{jsonrpc:"2.0",method:e,params:n})}}Yt=new WeakMap,Ao=new WeakMap,Us=new WeakMap,Fs=new WeakMap,Sr=new WeakMap,kr=new WeakMap,yt=new WeakMap,Zs=new WeakMap,ae=new WeakSet,Bg=async function(){let e;try{const n=u(this,Sr).readable.getReader();try{for(;!u(this,yt).signal.aborted;){const{value:r,done:s}=await n.read();if(s)break;if(r)try{b(this,ae,Gg).call(this,r)}catch(i){console.error("Unexpected error during message processing:",r,i),"id"in r&&r.id!==void 0&&b(this,ae,ms).call(this,{jsonrpc:"2.0",id:r.id,error:{code:-32700,message:"Parse error"}})}}}finally{n.releaseLock()}}catch(n){e=n}finally{b(this,ae,_l).call(this,e)}},_l=function(e){if(u(this,yt).signal.aborted)return;const n=e??new Error("ACP connection closed");for(const r of u(this,Yt).values())r.reject(n);u(this,Yt).clear(),u(this,yt).abort(n)},Gg=async function(e){if("method"in e&&"id"in e){const n=await b(this,ae,Vg).call(this,e.method,e.params);"error"in n&&console.error("Error handling request",e,n.error),await b(this,ae,ms).call(this,{jsonrpc:"2.0",id:e.id,...n})}else if("method"in e){const n=await b(this,ae,Hg).call(this,e.method,e.params);"error"in n&&console.error("Error handling notification",e,n.error)}else"id"in e?b(this,ae,qg).call(this,e):console.error("Invalid message",{message:e})},Vg=async function(e,n){try{return{result:await u(this,Us).call(this,e,n)??null}}catch(r){if(r instanceof ye)return r.toResult();if(r instanceof md)return ye.invalidParams(r.format()).toResult();let s;(r instanceof Error||typeof r=="object"&&r!=null&&"message"in r&&typeof r.message=="string")&&(s=r.message);try{return ye.internalError(s?JSON.parse(s):{}).toResult()}catch{return ye.internalError({details:s}).toResult()}}},Hg=async function(e,n){try{return await u(this,Fs).call(this,e,n),{result:null}}catch(r){if(r instanceof ye)return r.toResult();if(r instanceof md)return ye.invalidParams(r.format()).toResult();let s;(r instanceof Error||typeof r=="object"&&r!=null&&"message"in r&&typeof r.message=="string")&&(s=r.message);try{return ye.internalError(s?JSON.parse(s):{}).toResult()}catch{return ye.internalError({details:s}).toResult()}}},qg=function(e){const n=u(this,Yt).get(e.id);if(n){if("result"in e)n.resolve(e.result);else if("error"in e){const{code:r,message:s,data:i}=e.error;n.reject(new ye(r,s,i))}u(this,Yt).delete(e.id)}else console.error("Got response to unknown request",e.id)},Sl=function(){if(u(this,yt).signal.aborted)throw u(this,yt).signal.reason??new Error("ACP connection closed")},ms=async function(e){return x(this,kr,u(this,kr).then(async()=>{const n=u(this,Sr).writable.getWriter();try{await n.write(e)}finally{n.releaseLock()}}).catch(n=>{b(this,ae,_l).call(this,n)})),u(this,kr)};class ye extends Error{constructor(n,r,s){super(r);v(this,"code");v(this,"data");this.code=n,this.name="RequestError",this.data=s}static parseError(n,r){return new ye(-32700,`Parse error${r?`: ${r}`:""}`,n)}static invalidRequest(n,r){return new ye(-32600,`Invalid request${r?`: ${r}`:""}`,n)}static methodNotFound(n){return new ye(-32601,`"Method not found": ${n}`,{method:n})}static invalidParams(n,r){return new ye(-32602,`Invalid params${r?`: ${r}`:""}`,n)}static internalError(n,r){return new ye(-32603,`Internal error${r?`: ${r}`:""}`,n)}static authRequired(n,r){return new ye(-32e3,`Authentication required${r?`: ${r}`:""}`,n)}static resourceNotFound(n){return new ye(-32002,`Resource not found${n?`: ${n}`:""}`,n&&{uri:n})}toResult(){return{error:{code:this.code,message:this.message,data:this.data}}}toErrorResponse(){return{code:this.code,message:this.message,data:this.data}}}const XP=/^Sender \(untrusted metadata\):\n```json\n[\s\S]*?\n```\n\n?/,QP=/^\[[^\n]*Working directory:[^\n]*\]\n\n?/,eR=/\[Television screen context\][\s\S]*?\[\/Television screen context\]\n*/,tR=/\[\[\s*(?:reply_to_current|reply_to\s*:\s*[^\]\n]+|audio_as_voice)\s*\]\]\s*/gi,nR="single_session",rR={name:"television-acp-client",version:"0.0.0"},Yg="agent:main:television",sR=Hr(kt);var ne,Rt,Er,Dt,On,zn,Kt,$r,bt,rt,Jt,Ln,Ot,Xt,js,zt,st,xo,Lt,C,Kg,Jg,kl,Xg,Qg,em,tm,nm,rm,sm,wn,hr,dr,Be,im,pr,El,$l,no,om,Ws,Bs,Al,fr,am,lm;class iR extends sR{constructor(n){super();$(this,C);$(this,ne,oR());$(this,Rt,null);$(this,Er,null);$(this,Dt,null);$(this,On,null);$(this,zn,null);$(this,Kt,null);$(this,$r,1);$(this,bt,null);$(this,rt,null);$(this,Jt,!1);$(this,Ln,!1);$(this,Ot,null);$(this,Xt,new Set);$(this,js);$(this,zt);$(this,st);$(this,xo,n=>{b(this,C,Jg).call(this,n)});$(this,Lt,null);$(this,Ws,()=>{b(this,C,fr).call(this,"ACP bridge websocket closed")});$(this,Bs,()=>{b(this,C,fr).call(this,"ACP bridge websocket error")});x(this,zt,n),x(this,st,n.sessionMode??nR),x(this,js,n.createSocket??(r=>new WebSocket(r)))}getState(){return u(this,ne)}get messages(){return u(this,ne).messageOrder.map(n=>u(this,ne).messagesById[n]).filter(n=>n!==void 0)}async connect(){if(this.disposed)throw new Error("ACPClient has been disposed");if(u(this,ne).lifecycle.status!=="ready"){b(this,C,Be).call(this,{lifecycle:{status:"connecting"}}),u(this,Er)??x(this,Er,b(this,C,Kg).call(this));try{await u(this,Er),await b(this,C,kl).call(this)}catch(n){throw b(this,C,fr).call(this,Fi(n)),n}}}dispose(){b(this,C,Al).call(this),b(this,C,Be).call(this,{lifecycle:{status:"disposed"},run:{status:"idle",stopReason:null,canCancel:!1,error:null}})}async sendMessage(n){if(await this.connect(),u(this,ne).lifecycle.status!=="ready"||u(this,ne).run.status==="running"||u(this,ne).run.status==="cancelling")throw new Error("ACPClient is not ready to send a new message");const r=n.text.trim();if(!r)throw new Error("Cannot send an empty message");b(this,C,hr).call(this,{id:b(this,C,pr).call(this,"user"),kind:"user",text:r,status:"final"}),b(this,C,Be).call(this,{run:{status:"running",stopReason:null,canCancel:!0,error:null}});try{const s=await b(this,C,no).call(this).prompt({sessionId:b(this,C,$l).call(this),prompt:[{type:"text",text:b(this,C,im).call(this,r)}]});b(this,C,wn).call(this,s.stopReason==="cancelled"?"cancelled":"final"),b(this,C,Be).call(this,{run:{status:s.stopReason==="cancelled"?"cancelled":"completed",stopReason:s.stopReason,canCancel:!1,error:null}})}catch(s){throw b(this,C,lm).call(this)||(b(this,C,wn).call(this,"error"),b(this,C,Be).call(this,{run:{status:"error",stopReason:null,canCancel:!1,error:Fi(s)}})),s}}async cancel(){if(await this.connect(),!u(this,ne).run.canCancel||u(this,ne).run.status!=="running")throw new Error("No active cancellable run");b(this,C,Be).call(this,{run:{...u(this,ne).run,status:"cancelling"}}),await b(this,C,no).call(this).cancel({sessionId:b(this,C,$l).call(this)})}setScreenContext(n){var i,o,a;const r={screenID:n.screenID,screenName:n.screenName};if(((i=u(this,rt))==null?void 0:i.screenID)===r.screenID&&((o=u(this,rt))==null?void 0:o.screenName)===r.screenName)return;const s=((a=u(this,rt))==null?void 0:a.screenID)??null;if(x(this,rt,r),u(this,st)==="single_session"){(!u(this,Kt)||s!==r.screenID)&&x(this,Jt,!0);return}u(this,Kt)!==Sd(u(this,st),r.screenID,u(this,zt).clientGUID??"default-client")&&(x(this,Dt,null),x(this,On,null),u(this,Rt)&&u(this,ne).run.status==="idle"&&b(this,C,kl).call(this).catch(l=>{b(this,C,fr).call(this,Fi(l))}))}}ne=new WeakMap,Rt=new WeakMap,Er=new WeakMap,Dt=new WeakMap,On=new WeakMap,zn=new WeakMap,Kt=new WeakMap,$r=new WeakMap,bt=new WeakMap,rt=new WeakMap,Jt=new WeakMap,Ln=new WeakMap,Ot=new WeakMap,Xt=new WeakMap,js=new WeakMap,zt=new WeakMap,st=new WeakMap,xo=new WeakMap,Lt=new WeakMap,C=new WeakSet,Kg=async function(){try{b(this,C,Be).call(this,{lifecycle:{status:"connecting"}});const{stream:n,socket:r}=await cR({serverURL:u(this,zt).serverURL,token:u(this,zt).token,createSocket:u(this,js),onDisconnect:u(this,xo)});x(this,Lt,r),r.addEventListener("close",u(this,Ws)),r.addEventListener("error",u(this,Bs)),x(this,Rt,new KP(s=>({connection:s,sessionUpdate:async i=>{await b(this,C,Qg).call(this,i)},requestPermission:async i=>b(this,C,em).call(this,i)}),n)),await u(this,Rt).initialize({protocolVersion:DC,clientCapabilities:{},clientInfo:rR})}catch(n){throw n}},Jg=function(n){b(this,C,fr).call(this,Fi(n))},kl=async function(){const n=b(this,C,om).call(this);if(u(this,Dt)&&u(this,On)===n){await u(this,Dt);return}x(this,On,n),x(this,Dt,b(this,C,Xg).call(this,n)),await u(this,Dt)},Xg=async function(n){const r=b(this,C,no).call(this);b(this,C,am).call(this);let s,i=!1;try{x(this,Ln,!0),x(this,Ot,null),await r.loadSession({sessionId:n,cwd:"/",mcpServers:[],_meta:{sessionKey:n}}),s=n,i=u(this,ne).messageOrder.length>0}catch{s=(await r.newSession({cwd:"/",mcpServers:[],_meta:{sessionKey:n}})).sessionId,i=!1}finally{x(this,Ln,!1),x(this,Ot,null),b(this,C,wn).call(this,"final")}await r.setSessionConfigOption({sessionId:s,configId:"verbose_level",value:"full"}),x(this,zn,s),x(this,Kt,n),i?(u(this,Xt).add(n),u(this,st)==="single_session"&&x(this,Jt,!1)):(u(this,Xt).delete(n),x(this,Jt,u(this,st)==="single_session")),b(this,C,Be).call(this,{lifecycle:{status:"ready"}})},Qg=async function(n){const r=n.update;switch(r.sessionUpdate){case"user_message_chunk":r.content.type==="text"&&b(this,C,sm).call(this,r.content.text);return;case"agent_message_chunk":r.content.type==="text"&&b(this,C,tm).call(this,r.content.text);return;case"tool_call":b(this,C,nm).call(this,r);return;case"tool_call_update":b(this,C,rm).call(this,r);return;case"agent_thought_chunk":return;default:return}},em=async function(n){return{outcome:{outcome:"cancelled"}}},tm=function(n){x(this,Ot,null);const r=aR(n);if(!r)return;if(!u(this,bt)){const i={id:b(this,C,pr).call(this,"assistant"),kind:"assistant",text:r,status:"streaming"};x(this,bt,i.id),b(this,C,hr).call(this,i);return}const s=u(this,ne).messagesById[u(this,bt)];if(!s||s.kind!=="assistant")throw new Error("Open assistant message invariant violated");b(this,C,dr).call(this,{...s,text:`${s.text}${r}`,status:"streaming"})},nm=function(n){b(this,C,wn).call(this,"final");const r=b(this,C,El).call(this,n.toolCallId),s={id:(r==null?void 0:r.id)??b(this,C,pr).call(this,"tool"),kind:"tool_call",toolCallId:n.toolCallId,title:n.title,toolKind:n.kind??"other",status:n.status==="failed"?"failed":n.status==="completed"?"completed":"in_progress",text:(r==null?void 0:r.text)??"",locations:n.locations??(r==null?void 0:r.locations)};if(r){b(this,C,dr).call(this,s);return}b(this,C,hr).call(this,s)},rm=function(n){const r=b(this,C,El).call(this,n.toolCallId),s=(r==null?void 0:r.text)??"",i=lR(n.content),o=i?`${s}${i}`:s,a={id:(r==null?void 0:r.id)??b(this,C,pr).call(this,"tool"),kind:"tool_call",toolCallId:n.toolCallId,title:(r==null?void 0:r.title)??n.toolCallId,toolKind:(r==null?void 0:r.toolKind)??"other",status:n.status==="failed"?"failed":n.status==="completed"?"completed":"in_progress",text:o,locations:n.locations??(r==null?void 0:r.locations)};if(r){b(this,C,dr).call(this,a);return}b(this,C,hr).call(this,a)},sm=function(n){if(b(this,C,wn).call(this,"final"),!n)return;const r=u(this,Ln)?u(this,Ot):null;if(!r){const i=kd(n);if(!i)return;const o={id:b(this,C,pr).call(this,"user"),kind:"user",text:i,status:"final"};b(this,C,hr).call(this,o),u(this,Ln)&&x(this,Ot,o.id);return}const s=u(this,ne).messagesById[r];if(!s||s.kind!=="user")throw new Error("Replay user message invariant violated");b(this,C,dr).call(this,{...s,text:kd(`${s.text}${n}`)})},wn=function(n){if(!u(this,bt))return;const r=u(this,ne).messagesById[u(this,bt)];(r==null?void 0:r.kind)==="assistant"&&b(this,C,dr).call(this,{...r,status:n}),x(this,bt,null)},hr=function(n){b(this,C,Be).call(this,{messagesById:{...u(this,ne).messagesById,[n.id]:n},messageOrder:[...u(this,ne).messageOrder,n.id]})},dr=function(n){b(this,C,Be).call(this,{messagesById:{...u(this,ne).messagesById,[n.id]:n}})},Be=function(n){const r={...u(this,ne),...n};x(this,ne,{...r,sendDisabled:r.lifecycle.status!=="ready"||r.run.status==="running"||r.run.status==="cancelling",cancelDisabled:!(r.run.status==="running"||r.run.status==="cancelling")||!r.run.canCancel}),this.dispatchEvent(new te("change"))},im=function(n){const r=u(this,Kt);return!u(this,rt)||!r||!(u(this,st)==="single_session"?u(this,Jt)||!u(this,Xt).has(r):!u(this,Xt).has(r))?n:(x(this,Jt,!1),u(this,Xt).add(r),["[Television screen context]","This chat session is coming from a Television client in the screen below.",`screen_id: ${u(this,rt).screenID}`,`screen_name: ${u(this,rt).screenName??""}`,"When the user asks to inspect or change Television state with the tv CLI, use this screen ID with the --screen argument.","[/Television screen context]","",n].join(`
|
|
43
|
+
`))},pr=function(n){const r=`${n}-${u(this,$r)}`;return x(this,$r,u(this,$r)+1),r},El=function(n){for(const r of u(this,ne).messageOrder){const s=u(this,ne).messagesById[r];if((s==null?void 0:s.kind)==="tool_call"&&s.toolCallId===n)return s}return null},$l=function(){if(!u(this,zn))throw new Error("ACP session is not ready");return u(this,zn)},no=function(){if(!u(this,Rt))throw new Error("ACP connection is not ready");return u(this,Rt)},om=function(){var r;if(u(this,st)==="single_session")return`${Yg}-${(u(this,zt).clientGUID??"default-client").toLowerCase()}`;const n=(r=u(this,rt))==null?void 0:r.screenID;if(!n)throw new Error("Screen context is required for per-screen session mode");return Sd(u(this,st),n,u(this,zt).clientGUID??"default-client")},Ws=new WeakMap,Bs=new WeakMap,Al=function(){x(this,Rt,null),x(this,Er,null),x(this,Dt,null),x(this,On,null),x(this,zn,null),x(this,Kt,null),u(this,Lt)&&(u(this,Lt).removeEventListener("close",u(this,Ws)),u(this,Lt).removeEventListener("error",u(this,Bs)),u(this,Lt).close(),x(this,Lt,null))},fr=function(n){this.disposed||u(this,ne).lifecycle.status==="disconnected"||(b(this,C,wn).call(this,"error"),b(this,C,Al).call(this),b(this,C,Be).call(this,{lifecycle:{status:"disconnected",...n?{error:n}:{}},run:{status:"idle",stopReason:null,canCancel:!1,error:null}}))},am=function(){x(this,bt,null),x(this,Ot,null),x(this,$r,1),b(this,C,Be).call(this,{run:{status:"idle",stopReason:null,canCancel:!1,error:null},messagesById:{},messageOrder:[]})},lm=function(){return u(this,ne).lifecycle.status==="disconnected"};function oR(){return{lifecycle:{status:"connecting"},run:{status:"idle",stopReason:null,canCancel:!1,error:null},messagesById:{},messageOrder:[],sendDisabled:!0,cancelDisabled:!0}}function Sd(t,e,n){return t==="single_session"?`${Yg}-${n.toLowerCase()}`:`agent:main:television-${n.toLowerCase()}-${e.toLowerCase()}`}function cm(t){return t.replace(/^(?:\s*\n)+/,"")}function kd(t){let e=t;return e=e.replace(XP,""),e=e.replace(QP,""),e=e.replace(eR,""),e=cm(e),e}function aR(t){let e=t;return e=e.replace(tR,""),e=cm(e),e}function lR(t){return!t||t.length===0?"":t.flatMap(e=>e.type==="content"&&e.content.type==="text"?[e.content.text]:[]).join("")}async function cR(t){const e=t.createSocket(hR(t.serverURL,t.token));let n=!1,r,s;const i=new Promise((l,c)=>{r=l,s=c}),o=new ReadableStream({start(l){let c=!1;const d=()=>{e.send(JSON.stringify({type:"acp-bridge-connect"}))},p=E=>{const k=uR(E);if(!k)return;let I;try{I=JSON.parse(k)}catch(G){const N=G instanceof Error?G:new Error(String(G));s(N),l.error(N);return}switch(I.type){case"acp-bridge-status":if(I.status==="ready"){n||(n=!0,r());return}if(I.status==="error"||I.status==="exited"){const G=new Error(I.error??`ACP bridge ${I.status}`);n||s(G),l.error(G)}return;case"acp-bridge-message":l.enqueue(I.message);return}},y=()=>{var k;if(c)return;c=!0;const E=new Error("ACP bridge websocket closed");n||s(E),(k=t.onDisconnect)==null||k.call(t,E),l.close()},m=()=>{var k;if(c)return;c=!0;const E=new Error("ACP bridge websocket error");n||s(E),(k=t.onDisconnect)==null||k.call(t,E),l.error(E)};e.addEventListener("open",d),e.addEventListener("message",p),e.addEventListener("close",y),e.addEventListener("error",m)}}),a=new WritableStream({async write(l){await i,e.send(JSON.stringify({type:"acp-bridge-message",message:l}))},close(){e.close()},abort(){e.close()}});return await i,{stream:{readable:o,writable:a},socket:e}}function uR(t){if(typeof t=="string")return t;if(t instanceof Uint8Array)return new TextDecoder().decode(t);if(typeof Buffer<"u"&&t instanceof Buffer)return t.toString("utf8");if(typeof t=="object"&&t!==null&&"data"in t){const e=t.data;if(typeof e=="string")return e;if(e instanceof Uint8Array)return new TextDecoder().decode(e);if(Array.isArray(e))return Buffer.concat(e).toString("utf8")}return null}function hR(t,e){const n=new URL(t);return n.protocol=n.protocol==="https:"?"wss:":"ws:",n.pathname="/acp",n.search="",n.searchParams.set("token",e),n.hash="",n.toString()}function Fi(t){return t instanceof Error?t.message:String(t)}const Ed="television.acpClientGUID",dR=Hr(kt);class pR extends dR{constructor(n){super();v(this,"screenManager");v(this,"clients",new Map);v(this,"options");v(this,"sessionMode");v(this,"clientGUID");v(this,"activeClient",null);v(this,"handleActiveScreenChanged",()=>{this.syncActiveClient()});this.screenManager=n.screenManager,this.sessionMode=n.sessionMode??"single_session",this.options={serverURL:n.serverURL,token:n.token,...n.createSocket?{createSocket:n.createSocket}:{},...n.sessionMode?{sessionMode:n.sessionMode}:{}},this.clientGUID=n.clientGUID??fR(n.storage??window.localStorage),this.screenManager.addEventListener("active-screen-changed",this.handleActiveScreenChanged),this.syncActiveClient()}getActiveClient(){return this.activeClient}dispose(){this.screenManager.removeEventListener("active-screen-changed",this.handleActiveScreenChanged);for(const n of this.clients.values())n.dispose();this.clients.clear(),this.activeClient=null}syncActiveClient(){const n=this.screenManager.activeScreen,r=n?this.getClientForScreen(n):null;this.activeClient!==r&&(this.activeClient=r,this.dispatchEvent(new te("change")))}getClientForScreen(n){const r=this.sessionMode==="single_session"?"single_session":n.id;let s=this.clients.get(r);return s||(s=new iR({...this.options,sessionMode:this.sessionMode,clientGUID:this.clientGUID}),this.clients.set(r,s)),s.setScreenContext({screenID:n.id,screenName:n.name}),s}}function fR(t){const e=t.getItem(Ed);if(e)return e;const n=$c().toLowerCase();return t.setItem(Ed,n),n}const gR="serverURL",mR="token",vR="mode",yR="electron";function um(t=window.location.search,e=window.location.origin){const r=new URLSearchParams(t).get(gR);return r?new URL(r).origin:new URL(e).origin}function hm(t=window.location.search){return new URLSearchParams(t).get(mR)}function dm(t=window.location.search){return new URLSearchParams(t).get(vR)===yR}/**
|
|
44
44
|
* @license
|
|
45
45
|
* Copyright 2017 Google LLC
|
|
46
46
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
47
|
-
*/const As=globalThis,$d=t=>t,bo=As.trustedTypes,Ad=bo?bo.createPolicy("lit-html",{createHTML:t=>t}):void 0,pm="$lit$",Gt=`lit$${Math.random().toFixed(9).slice(2)}$`,fm="?"+Gt,
|
|
48
|
-
\f\r]`,is=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,xd=/-->/g,Td=/>/g,yn=RegExp(`>|${
|
|
49
|
-
\f\r"'\`<>=]|("|')|))|$)`,"g"),Cd=/'/g,Id=/"/g,gm=/^(?:script|style|textarea|title)$/i,
|
|
47
|
+
*/const As=globalThis,$d=t=>t,bo=As.trustedTypes,Ad=bo?bo.createPolicy("lit-html",{createHTML:t=>t}):void 0,pm="$lit$",Gt=`lit$${Math.random().toFixed(9).slice(2)}$`,fm="?"+Gt,bR=`<${fm}>`,Gn=document,Cs=()=>Gn.createComment(""),Is=t=>t===null||typeof t!="object"&&typeof t!="function",Uc=Array.isArray,wR=t=>Uc(t)||typeof(t==null?void 0:t[Symbol.iterator])=="function",ja=`[
|
|
48
|
+
\f\r]`,is=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,xd=/-->/g,Td=/>/g,yn=RegExp(`>|${ja}(?:([^\\s"'>=/]+)(${ja}*=${ja}*(?:[^
|
|
49
|
+
\f\r"'\`<>=]|("|')|))|$)`,"g"),Cd=/'/g,Id=/"/g,gm=/^(?:script|style|textarea|title)$/i,_R=t=>(e,...n)=>({_$litType$:t,strings:e,values:n}),M=_R(1),Mr=Symbol.for("lit-noChange"),ge=Symbol.for("lit-nothing"),Pd=new WeakMap,Tn=Gn.createTreeWalker(Gn,129);function mm(t,e){if(!Uc(t)||!t.hasOwnProperty("raw"))throw Error("invalid template strings array");return Ad!==void 0?Ad.createHTML(e):e}const SR=(t,e)=>{const n=t.length-1,r=[];let s,i=e===2?"<svg>":e===3?"<math>":"",o=is;for(let a=0;a<n;a++){const l=t[a];let c,d,p=-1,y=0;for(;y<l.length&&(o.lastIndex=y,d=o.exec(l),d!==null);)y=o.lastIndex,o===is?d[1]==="!--"?o=xd:d[1]!==void 0?o=Td:d[2]!==void 0?(gm.test(d[2])&&(s=RegExp("</"+d[2],"g")),o=yn):d[3]!==void 0&&(o=yn):o===yn?d[0]===">"?(o=s??is,p=-1):d[1]===void 0?p=-2:(p=o.lastIndex-d[2].length,c=d[1],o=d[3]===void 0?yn:d[3]==='"'?Id:Cd):o===Id||o===Cd?o=yn:o===xd||o===Td?o=is:(o=yn,s=void 0);const m=o===yn&&t[a+1].startsWith("/>")?" ":"";i+=o===is?l+bR:p>=0?(r.push(c),l.slice(0,p)+pm+l.slice(p)+Gt+m):l+Gt+(p===-2?a:m)}return[mm(t,i+(t[n]||"<?>")+(e===2?"</svg>":e===3?"</math>":"")),r]};class Ps{constructor({strings:e,_$litType$:n},r){let s;this.parts=[];let i=0,o=0;const a=e.length-1,l=this.parts,[c,d]=SR(e,n);if(this.el=Ps.createElement(c,r),Tn.currentNode=this.el.content,n===2||n===3){const p=this.el.content.firstChild;p.replaceWith(...p.childNodes)}for(;(s=Tn.nextNode())!==null&&l.length<a;){if(s.nodeType===1){if(s.hasAttributes())for(const p of s.getAttributeNames())if(p.endsWith(pm)){const y=d[o++],m=s.getAttribute(p).split(Gt),E=/([.?@])?(.*)/.exec(y);l.push({type:1,index:i,name:E[2],strings:m,ctor:E[1]==="."?ER:E[1]==="?"?$R:E[1]==="@"?AR:Yo}),s.removeAttribute(p)}else p.startsWith(Gt)&&(l.push({type:6,index:i}),s.removeAttribute(p));if(gm.test(s.tagName)){const p=s.textContent.split(Gt),y=p.length-1;if(y>0){s.textContent=bo?bo.emptyScript:"";for(let m=0;m<y;m++)s.append(p[m],Cs()),Tn.nextNode(),l.push({type:2,index:++i});s.append(p[y],Cs())}}}else if(s.nodeType===8)if(s.data===fm)l.push({type:2,index:i});else{let p=-1;for(;(p=s.data.indexOf(Gt,p+1))!==-1;)l.push({type:7,index:i}),p+=Gt.length-1}i++}}static createElement(e,n){const r=Gn.createElement("template");return r.innerHTML=e,r}}function Nr(t,e,n=t,r){var o,a;if(e===Mr)return e;let s=r!==void 0?(o=n._$Co)==null?void 0:o[r]:n._$Cl;const i=Is(e)?void 0:e._$litDirective$;return(s==null?void 0:s.constructor)!==i&&((a=s==null?void 0:s._$AO)==null||a.call(s,!1),i===void 0?s=void 0:(s=new i(t),s._$AT(t,n,r)),r!==void 0?(n._$Co??(n._$Co=[]))[r]=s:n._$Cl=s),s!==void 0&&(e=Nr(t,s._$AS(t,e.values),s,r)),e}class kR{constructor(e,n){this._$AV=[],this._$AN=void 0,this._$AD=e,this._$AM=n}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(e){const{el:{content:n},parts:r}=this._$AD,s=((e==null?void 0:e.creationScope)??Gn).importNode(n,!0);Tn.currentNode=s;let i=Tn.nextNode(),o=0,a=0,l=r[0];for(;l!==void 0;){if(o===l.index){let c;l.type===2?c=new Fc(i,i.nextSibling,this,e):l.type===1?c=new l.ctor(i,l.name,l.strings,this,e):l.type===6&&(c=new xR(i,this,e)),this._$AV.push(c),l=r[++a]}o!==(l==null?void 0:l.index)&&(i=Tn.nextNode(),o++)}return Tn.currentNode=Gn,s}p(e){let n=0;for(const r of this._$AV)r!==void 0&&(r.strings!==void 0?(r._$AI(e,r,n),n+=r.strings.length-2):r._$AI(e[n])),n++}}let Fc=class vm{get _$AU(){var e;return((e=this._$AM)==null?void 0:e._$AU)??this._$Cv}constructor(e,n,r,s){this.type=2,this._$AH=ge,this._$AN=void 0,this._$AA=e,this._$AB=n,this._$AM=r,this.options=s,this._$Cv=(s==null?void 0:s.isConnected)??!0}get parentNode(){let e=this._$AA.parentNode;const n=this._$AM;return n!==void 0&&(e==null?void 0:e.nodeType)===11&&(e=n.parentNode),e}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(e,n=this){e=Nr(this,e,n),Is(e)?e===ge||e==null||e===""?(this._$AH!==ge&&this._$AR(),this._$AH=ge):e!==this._$AH&&e!==Mr&&this._(e):e._$litType$!==void 0?this.$(e):e.nodeType!==void 0?this.T(e):wR(e)?this.k(e):this._(e)}O(e){return this._$AA.parentNode.insertBefore(e,this._$AB)}T(e){this._$AH!==e&&(this._$AR(),this._$AH=this.O(e))}_(e){this._$AH!==ge&&Is(this._$AH)?this._$AA.nextSibling.data=e:this.T(Gn.createTextNode(e)),this._$AH=e}$(e){var i;const{values:n,_$litType$:r}=e,s=typeof r=="number"?this._$AC(e):(r.el===void 0&&(r.el=Ps.createElement(mm(r.h,r.h[0]),this.options)),r);if(((i=this._$AH)==null?void 0:i._$AD)===s)this._$AH.p(n);else{const o=new kR(s,this),a=o.u(this.options);o.p(n),this.T(a),this._$AH=o}}_$AC(e){let n=Pd.get(e.strings);return n===void 0&&Pd.set(e.strings,n=new Ps(e)),n}k(e){Uc(this._$AH)||(this._$AH=[],this._$AR());const n=this._$AH;let r,s=0;for(const i of e)s===n.length?n.push(r=new vm(this.O(Cs()),this.O(Cs()),this,this.options)):r=n[s],r._$AI(i),s++;s<n.length&&(this._$AR(r&&r._$AB.nextSibling,s),n.length=s)}_$AR(e=this._$AA.nextSibling,n){var r;for((r=this._$AP)==null?void 0:r.call(this,!1,!0,n);e!==this._$AB;){const s=$d(e).nextSibling;$d(e).remove(),e=s}}setConnected(e){var n;this._$AM===void 0&&(this._$Cv=e,(n=this._$AP)==null||n.call(this,e))}},Yo=class{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(e,n,r,s,i){this.type=1,this._$AH=ge,this._$AN=void 0,this.element=e,this.name=n,this._$AM=s,this.options=i,r.length>2||r[0]!==""||r[1]!==""?(this._$AH=Array(r.length-1).fill(new String),this.strings=r):this._$AH=ge}_$AI(e,n=this,r,s){const i=this.strings;let o=!1;if(i===void 0)e=Nr(this,e,n,0),o=!Is(e)||e!==this._$AH&&e!==Mr,o&&(this._$AH=e);else{const a=e;let l,c;for(e=i[0],l=0;l<i.length-1;l++)c=Nr(this,a[r+l],n,l),c===Mr&&(c=this._$AH[l]),o||(o=!Is(c)||c!==this._$AH[l]),c===ge?e=ge:e!==ge&&(e+=(c??"")+i[l+1]),this._$AH[l]=c}o&&!s&&this.j(e)}j(e){e===ge?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,e??"")}},ER=class extends Yo{constructor(){super(...arguments),this.type=3}j(e){this.element[this.name]=e===ge?void 0:e}},$R=class extends Yo{constructor(){super(...arguments),this.type=4}j(e){this.element.toggleAttribute(this.name,!!e&&e!==ge)}},AR=class extends Yo{constructor(e,n,r,s,i){super(e,n,r,s,i),this.type=5}_$AI(e,n=this){if((e=Nr(this,e,n,0)??ge)===Mr)return;const r=this._$AH,s=e===ge&&r!==ge||e.capture!==r.capture||e.once!==r.once||e.passive!==r.passive,i=e!==ge&&(r===ge||s);s&&this.element.removeEventListener(this.name,this,r),i&&this.element.addEventListener(this.name,this,e),this._$AH=e}handleEvent(e){var n;typeof this._$AH=="function"?this._$AH.call(((n=this.options)==null?void 0:n.host)??this.element,e):this._$AH.handleEvent(e)}};class xR{constructor(e,n,r){this.element=e,this.type=6,this._$AN=void 0,this._$AM=n,this.options=r}get _$AU(){return this._$AM._$AU}_$AI(e){Nr(this,e)}}const Wa=As.litHtmlPolyfillSupport;Wa==null||Wa(Ps,Fc),(As.litHtmlVersions??(As.litHtmlVersions=[])).push("3.3.2");const be=(t,e,n)=>{const r=e;let s=r._$litPart$;return s===void 0&&(r._$litPart$=s=new Fc(e.insertBefore(Cs(),null),null,void 0,{})),s._$AI(t),s};/**
|
|
50
50
|
* @license
|
|
51
51
|
* Copyright 2017 Google LLC
|
|
52
52
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
53
|
-
*/const
|
|
53
|
+
*/const TR={CHILD:2},ym=t=>(...e)=>({_$litDirective$:t,values:e});class CR{constructor(e){}get _$AU(){return this._$AM._$AU}_$AT(e,n,r){this._$Ct=e,this._$AM=n,this._$Ci=r}_$AS(e,n){return this.update(e,n)}update(e,n){return this.render(...n)}}/**
|
|
54
54
|
* @license
|
|
55
55
|
* Copyright 2017 Google LLC
|
|
56
56
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
57
|
-
*/class wo extends
|
|
57
|
+
*/class wo extends CR{constructor(e){if(super(e),this.it=ge,e.type!==TR.CHILD)throw Error(this.constructor.directiveName+"() can only be used in child bindings")}render(e){if(e===ge||e==null)return this._t=void 0,this.it=e;if(e===Mr)return e;if(typeof e!="string")throw Error(this.constructor.directiveName+"() called with a non-string value");if(e===this.it)return this._t;this.it=e;const n=[e];return n.raw=n,this._t={_$litType$:this.constructor.resultType,strings:n,values:[]}}}wo.directiveName="unsafeHTML",wo.resultType=1;const IR=ym(wo);/**
|
|
58
58
|
* @license
|
|
59
59
|
* Copyright 2017 Google LLC
|
|
60
60
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
61
|
-
*/class
|
|
61
|
+
*/class xl extends wo{}xl.directiveName="unsafeSVG",xl.resultType=2;const PR=ym(xl),RR={size:16,color:"currentColor",weight:"regular"};function DR(t){return typeof t=="string"?{regular:t}:t}function Ko(t,e="0 0 256 256"){const n=DR(t);return r=>{const{size:s,color:i,weight:o}={...RR,...r},a=n[o]??n.regular;return M`<svg
|
|
62
62
|
xmlns="http://www.w3.org/2000/svg"
|
|
63
63
|
data-ui-icon=""
|
|
64
64
|
width="${s}"
|
|
65
65
|
height="${s}"
|
|
66
66
|
viewBox="${e}"
|
|
67
67
|
fill="${i}"
|
|
68
|
-
>${
|
|
69
|
-
<span class="trigger-label" data-dropdown-trigger-label>${u(this,D,
|
|
68
|
+
>${PR(a)}</svg>`}}const OR=Ko('<path fill="none" stroke="currentColor" stroke-width="16" stroke-linecap="round" stroke-linejoin="round" d="M200 224H56C53.8783 224 51.8434 223.157 50.3431 221.657C48.8429 220.157 48 218.122 48 216V40C48 37.8783 48.8429 35.8434 50.3431 34.3431C51.8434 32.8429 53.8783 32 56 32H152L208 88V216C208 218.122 207.157 220.157 205.657 221.657C204.157 223.157 202.122 224 200 224Z"/><path fill="none" stroke="currentColor" stroke-width="16" stroke-linecap="round" stroke-linejoin="round" d="M152 32V88H208"/><path fill="none" stroke="currentColor" stroke-width="16" stroke-linecap="round" d="M80 88H124.5"/><path fill="none" stroke="currentColor" stroke-width="16" stroke-linecap="round" d="M80 128H175"/><path fill="none" stroke="currentColor" stroke-width="16" stroke-linecap="round" d="M80 169H175"/>'),bm=Ko('<path d="M205.66,194.34a8,8,0,0,1-11.32,11.32L128,139.31,61.66,205.66a8,8,0,0,1-11.32-11.32L116.69,128,50.34,61.66A8,8,0,0,1,61.66,50.34L128,116.69l66.34-66.35a8,8,0,0,1,11.32,11.32L139.31,128Z"/>'),wm=Ko('<path d="M213.66,93.66l-80,80a8,8,0,0,1-11.32,0l-80-80A8,8,0,0,1,53.66,82.34L128,156.69l74.34-74.35a8,8,0,0,1,11.32,11.32Z"/>'),zR=Ko('<path d="M213.66,162.34l-80-80a8,8,0,0,0-11.32,0l-80,80A8,8,0,0,0,53.66,173.66L128,99.31l74.34,74.35a8,8,0,0,0,11.32-11.32Z"/>');class _m extends Event{constructor(n){super("dropdown-item-select",{bubbles:!0,composed:!0});v(this,"value");this.value=n}}class LR extends Event{constructor(n){super("select",{bubbles:!0,composed:!0});v(this,"value");this.value=n}}var qe,it,Qt,Ar,re,Gs,D,km,vs,Em,$m,Tl,Cl,ro,_n,Mn,Vs,Hs,qs,To,Am,xm,Il,ys,Pl,Rl,Ct;class Sm extends HTMLElement{constructor(){super();$(this,D);$(this,qe,!1);$(this,it,null);$(this,Qt,null);$(this,Ar);$(this,re,null);$(this,Gs,new MutationObserver(n=>b(this,D,Am).call(this,n)));$(this,Mn,()=>{b(this,D,ro).call(this,!u(this,qe))});$(this,Vs,n=>{n.key!=="Enter"&&n.key!==" "||(n.preventDefault(),u(this,Mn).call(this))});$(this,Hs,n=>{u(this,qe)&&(n.composedPath().includes(this)||b(this,D,ro).call(this,!1))});$(this,qs,n=>{n instanceof _m&&(n.stopPropagation(),x(this,qe,!1),b(this,D,vs).call(this,n.value),b(this,D,Ct).call(this),this.dispatchEvent(new LR(n.value)))});$(this,To,()=>{b(this,D,Il).call(this)});x(this,Ar,this.attachShadow({mode:"open"}))}connectedCallback(){this.addEventListener("dropdown-item-select",u(this,qs)),document.addEventListener("click",u(this,Hs),!0),b(this,D,km).call(this),u(this,Gs).observe(this,{childList:!0,subtree:!0,characterData:!0,attributes:!0,attributeFilter:["selected","value","slot"]}),b(this,D,Ct).call(this)}disconnectedCallback(){this.removeEventListener("dropdown-item-select",u(this,qs)),document.removeEventListener("click",u(this,Hs),!0),u(this,Gs).disconnect(),b(this,D,Rl).call(this)}attributeChangedCallback(){b(this,D,Ct).call(this)}get title(){return this.getAttribute("title")??""}get placement(){return this.getAttribute("placement")==="top"?"top":"bottom"}get value(){return u(this,it)}set value(n){n===null?(b(this,D,_n).call(this,null,null),b(this,D,Em).call(this)):b(this,D,vs).call(this,n),b(this,D,Ct).call(this)}close(){b(this,D,ro).call(this,!1)}}qe=new WeakMap,it=new WeakMap,Qt=new WeakMap,Ar=new WeakMap,re=new WeakMap,Gs=new WeakMap,D=new WeakSet,km=function(){var r;const n=this.querySelector("dropdown-item[selected]");n&&b(this,D,_n).call(this,n.value,((r=n.textContent)==null?void 0:r.trim())??null)},vs=function(n){var r;for(const s of u(this,D,Tl))s.value===n?(b(this,D,_n).call(this,n,((r=s.textContent)==null?void 0:r.trim())??null),s.hasAttribute("selected")||s.setAttribute("selected","")):s.hasAttribute("selected")&&s.removeAttribute("selected")},Em=function(){const n=this.querySelectorAll("dropdown-item[selected]");for(const r of n)r.removeAttribute("selected")},$m=function(n){for(const r of u(this,D,Tl))if(r.value===n)return r;return null},Tl=function(){return this.querySelectorAll("dropdown-item")},Cl=function(){return u(this,Qt)??this.title},ro=function(n){u(this,qe)!==n&&(x(this,qe,n),b(this,D,Ct).call(this))},_n=function(n,r){x(this,it,n),x(this,Qt,r)},Mn=new WeakMap,Vs=new WeakMap,Hs=new WeakMap,qs=new WeakMap,To=new WeakMap,Am=function(n){n.every(s=>s.target instanceof Element?s.target.closest('[slot="trigger"]')!==null:!1)||b(this,D,xm).call(this)},xm=function(){var r,s;const n=this.querySelector("dropdown-item[selected]");if(n){const i=n.value,o=((r=n.textContent)==null?void 0:r.trim())??null,a=u(this,it)!==i||u(this,Qt)!==o;b(this,D,_n).call(this,i,o),b(this,D,vs).call(this,i),a?b(this,D,Ct).call(this):b(this,D,ys).call(this);return}if(u(this,it)!==null){const i=b(this,D,$m).call(this,u(this,it));if(i){const o=((s=i.textContent)==null?void 0:s.trim())??null,a=u(this,Qt)!==o;b(this,D,_n).call(this,u(this,it),o),b(this,D,vs).call(this,u(this,it)),a?b(this,D,Ct).call(this):b(this,D,ys).call(this);return}}if(u(this,it)!==null||u(this,Qt)!==null){b(this,D,_n).call(this,null,null),b(this,D,Ct).call(this);return}b(this,D,ys).call(this)},Il=function(){const n=u(this,Ar).querySelector('slot[name="trigger"]'),r=n instanceof HTMLSlotElement?n.assignedElements()[0]??null:null;u(this,re)!==r&&(b(this,D,Rl).call(this),x(this,re,r),u(this,re)&&(u(this,re).addEventListener("click",u(this,Mn)),u(this,re)instanceof HTMLButtonElement?u(this,re).hasAttribute("type")||(u(this,re).type="button"):(u(this,re).hasAttribute("role")||u(this,re).setAttribute("role","button"),u(this,re).hasAttribute("tabindex")||(u(this,re).tabIndex=0),u(this,re).addEventListener("keydown",u(this,Vs))))),b(this,D,ys).call(this)},ys=function(){u(this,re)&&(u(this,re).setAttribute("data-dropdown-trigger",""),u(this,re).setAttribute("aria-haspopup","listbox"),u(this,re).setAttribute("aria-expanded",u(this,qe)?"true":"false"),be(M`
|
|
69
|
+
<span class="trigger-label" data-dropdown-trigger-label>${u(this,D,Cl)}</span>
|
|
70
70
|
<span class="trigger-icon" data-dropdown-trigger-icon aria-hidden="true">
|
|
71
|
-
${u(this,D,
|
|
71
|
+
${u(this,D,Pl).call(this,{size:16})}
|
|
72
72
|
</span>
|
|
73
|
-
`,u(this,re)))},
|
|
73
|
+
`,u(this,re)))},Pl=function(){return this.placement==="top"?zR:wm},Rl=function(){u(this,re)&&(u(this,re).removeEventListener("click",u(this,Mn)),u(this,re).removeEventListener("keydown",u(this,Vs)),u(this,re).removeAttribute("data-dropdown-trigger"),u(this,re).removeAttribute("aria-haspopup"),u(this,re).removeAttribute("aria-expanded"),x(this,re,null))},Ct=function(){this.toggleAttribute("open",u(this,qe)),be(M`
|
|
74
74
|
<slot name="trigger" @slotchange=${u(this,To)}>
|
|
75
75
|
<button
|
|
76
76
|
class="fallback-trigger"
|
|
@@ -80,9 +80,9 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
80
80
|
aria-expanded=${u(this,qe)?"true":"false"}
|
|
81
81
|
@click=${u(this,Mn)}
|
|
82
82
|
>
|
|
83
|
-
<span class="trigger-label" part="trigger-label">${u(this,D,
|
|
83
|
+
<span class="trigger-label" part="trigger-label">${u(this,D,Cl)}</span>
|
|
84
84
|
<span class="trigger-icon" part="trigger-icon" aria-hidden="true">
|
|
85
|
-
${u(this,D,
|
|
85
|
+
${u(this,D,Pl).call(this,{size:16})}
|
|
86
86
|
</span>
|
|
87
87
|
</button>
|
|
88
88
|
</slot>
|
|
@@ -95,13 +95,13 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
95
95
|
<slot></slot>
|
|
96
96
|
</div>
|
|
97
97
|
`:null}
|
|
98
|
-
`,u(this,Ar)),queueMicrotask(()=>b(this,D,
|
|
98
|
+
`,u(this,Ar)),queueMicrotask(()=>b(this,D,Il).call(this))},v(Sm,"observedAttributes",["title","placement"]);class MR extends HTMLElement{}class NR extends HTMLElement{}class UR extends HTMLElement{}var qn,Dl,Cm,Ys,Ks;class Tm extends HTMLElement{constructor(){super(...arguments);$(this,qn);$(this,Ys,()=>{this.action||b(this,qn,Cm).call(this)});$(this,Ks,n=>{n.key!=="Enter"&&n.key!==" "||(n.preventDefault(),this.click())})}connectedCallback(){this.hasAttribute("role")||this.setAttribute("role","option"),this.hasAttribute("tabindex")||(this.tabIndex=0),this.addEventListener("click",u(this,Ys)),this.addEventListener("keydown",u(this,Ks)),b(this,qn,Dl).call(this)}disconnectedCallback(){this.removeEventListener("click",u(this,Ys)),this.removeEventListener("keydown",u(this,Ks))}attributeChangedCallback(){b(this,qn,Dl).call(this)}get value(){return this.getAttribute("value")??""}get selected(){return this.hasAttribute("selected")}get action(){return this.hasAttribute("action")}}qn=new WeakSet,Dl=function(){if(this.action){this.setAttribute("role","button"),this.removeAttribute("aria-selected");return}this.setAttribute("role","option"),this.setAttribute("aria-selected",this.selected?"true":"false")},Cm=function(){this.dispatchEvent(new _m(this.value))},Ys=new WeakMap,Ks=new WeakMap,v(Tm,"observedAttributes",["action","selected","value"]);customElements.get("dropdown-menu")||customElements.define("dropdown-menu",Sm);customElements.get("dropdown-group")||customElements.define("dropdown-group",MR);customElements.get("dropdown-label")||customElements.define("dropdown-label",NR);customElements.get("dropdown-divider")||customElements.define("dropdown-divider",UR);customElements.get("dropdown-item")||customElements.define("dropdown-item",Tm);class FR extends Event{constructor(){super("close",{bubbles:!0,composed:!0})}}var Js,cn,Ol,Co,Xs,zl;class Im extends HTMLElement{constructor(){super();$(this,cn);$(this,Js);$(this,Co,n=>{n.target===n.currentTarget&&b(this,cn,Ol).call(this)});$(this,Xs,n=>{this.open&&n.key==="Escape"&&b(this,cn,Ol).call(this)});x(this,Js,this.attachShadow({mode:"open"}))}connectedCallback(){document.addEventListener("keydown",u(this,Xs)),b(this,cn,zl).call(this)}disconnectedCallback(){document.removeEventListener("keydown",u(this,Xs))}attributeChangedCallback(){b(this,cn,zl).call(this)}get open(){return this.hasAttribute("open")}}Js=new WeakMap,cn=new WeakSet,Ol=function(){this.dispatchEvent(new FR)},Co=new WeakMap,Xs=new WeakMap,zl=function(){be(M`
|
|
99
99
|
${this.open?M`
|
|
100
100
|
<div class="backdrop" part="backdrop" @click=${u(this,Co)}>
|
|
101
101
|
<slot></slot>
|
|
102
102
|
</div>
|
|
103
103
|
`:null}
|
|
104
|
-
`,u(this,Js))},v(Im,"observedAttributes",["open"]);customElements.get("modal-overlay")||customElements.define("modal-overlay",Im);class Pm extends Event{constructor(){super("close",{bubbles:!0,composed:!0})}}class
|
|
104
|
+
`,u(this,Js))},v(Im,"observedAttributes",["open"]);customElements.get("modal-overlay")||customElements.define("modal-overlay",Im);class Pm extends Event{constructor(){super("close",{bubbles:!0,composed:!0})}}class ZR extends HTMLElement{}var Qs,ei,Ll;class Rm extends HTMLElement{constructor(){super();$(this,ei);$(this,Qs);x(this,Qs,this.attachShadow({mode:"open"}))}connectedCallback(){b(this,ei,Ll).call(this)}attributeChangedCallback(){b(this,ei,Ll).call(this)}get closable(){return this.hasAttribute("closable")}}Qs=new WeakMap,ei=new WeakSet,Ll=function(){const n=this.querySelector("panel-page");be(M`
|
|
105
105
|
<section class="panel" part="panel">
|
|
106
106
|
<header class="title-bar" part="header">
|
|
107
107
|
<h2 class="title" part="title">${(n==null?void 0:n.getAttribute("title"))??""}</h2>
|
|
@@ -119,8 +119,8 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
119
119
|
</header>
|
|
120
120
|
<slot></slot>
|
|
121
121
|
</section>
|
|
122
|
-
`,u(this,Qs))},v(Rm,"observedAttributes",["closable"]);customElements.get("panel-view")||customElements.define("panel-view",Rm);customElements.get("panel-page")||customElements.define("panel-page",
|
|
123
|
-
${r.documentElement.outerHTML}`],{type:"text/html"});return URL.createObjectURL(o)}const zm=et();class
|
|
122
|
+
`,u(this,Qs))},v(Rm,"observedAttributes",["closable"]);customElements.get("panel-view")||customElements.define("panel-view",Rm);customElements.get("panel-page")||customElements.define("panel-page",ZR);const jR=et(),WR="No handler registered for update-content",BR="handleUpdateContent: handler already registered";function GR(t){return t instanceof Error&&typeof t.message=="string"?t.message:String(t)}const VR=Hr(kt);var xr,Tr,Cr,Nn,Un,ti,Te,Ml,Dm,Om,bs,Nl,lp;let HR=(lp=class extends VR{constructor(n){super();$(this,Te);$(this,xr);$(this,Tr);$(this,Cr);$(this,Nn,null);$(this,Un,null);$(this,ti,!1);x(this,xr,n);const r=n.ownerDocument.defaultView;if(!r)throw new Error("ArtifactView: iframe has no owner window");x(this,Tr,r),x(this,Cr,s=>b(this,Te,Dm).call(this,s)),u(this,Tr).addEventListener("message",u(this,Cr))}get content(){return u(this,Un)}set content(n){b(this,Te,Nl).call(this),x(this,Un,n),u(this,ti)&&b(this,Te,Ml).call(this,n)}handleUpdateContent(n){if(b(this,Te,Nl).call(this),u(this,Nn)!==null)throw new Error(BR);x(this,Nn,n)}dispose(){u(this,Tr).removeEventListener("message",u(this,Cr)),x(this,Nn,null)}},xr=new WeakMap,Tr=new WeakMap,Cr=new WeakMap,Nn=new WeakMap,Un=new WeakMap,ti=new WeakMap,Te=new WeakSet,Ml=function(n){const r={type:"content-updated",content:n};b(this,Te,bs).call(this,r)},Dm=function(n){if(this.disposed||n.source!==u(this,xr).contentWindow)return;const r=n.data;if(SC(r)){x(this,ti,!0),this.dispatchEvent(new jR("ready")),u(this,Un)!==null&&b(this,Te,Ml).call(this,u(this,Un));return}if(kC(r)){b(this,Te,Om).call(this,r);return}},Om=async function(n){const r=u(this,Nn);if(r===null){b(this,Te,bs).call(this,{type:"response",id:n.id,error:{message:WR}});return}try{await r(n.content)}catch(s){if(this.disposed)return;b(this,Te,bs).call(this,{type:"response",id:n.id,error:{message:GR(s)}});return}this.disposed||b(this,Te,bs).call(this,{type:"response",id:n.id,result:{}})},bs=function(n){const r=u(this,xr).contentWindow;r&&r.postMessage(n,"*")},Nl=function(){if(this.disposed)throw new Error("ArtifactView is disposed")},lp);function qR(t=window){t.parent!==t&&(t.addEventListener("wheel",e=>{const n=e;t.parent.postMessage({type:"wheel",deltaX:n.deltaX,deltaY:n.deltaY,shiftKey:n.shiftKey},"*"),n.preventDefault()},{passive:!1}),t.addEventListener("message",e=>{const n=e.data;if(n!==null&&typeof n=="object"&&n.type==="scroll"){const r=n,s=typeof r.deltaX=="number"?r.deltaX:0,i=typeof r.deltaY=="number"?r.deltaY:0;t.scrollBy(s,i)}}))}function YR(){return`(${qR.toString()})(window);`}async function KR(t){const e=await fetch(t);if(!e.ok)throw new Error(`Failed to fetch artifact content: ${e.status}`);const n=await e.text(),r=new DOMParser().parseFromString(n,"text/html"),s=r.createElement("base");s.href=t,r.head.insertBefore(s,r.head.firstChild);const i=r.createElement("script");i.textContent=YR(),r.head.appendChild(i);const o=new Blob([`<!DOCTYPE html>
|
|
123
|
+
${r.documentElement.outerHTML}`],{type:"text/html"});return URL.createObjectURL(o)}const zm=et();class JR extends HTMLElement{constructor(){super(...arguments);v(this,"_artifact",null);v(this,"_viewURL",null);v(this,"_contentURL",null);v(this,"_screen",null);v(this,"_subscribedScreen",null);v(this,"_activeView",null);v(this,"_contentState",{kind:"idle"});v(this,"_fetchSequence",0);v(this,"_blobSequence",0);v(this,"_mountedViewURL",null);v(this,"_directRender",!1);v(this,"_blobURL",null);v(this,"handleScreenContentChanged",n=>{!this._artifact||n.artifactID!==this._artifact.id||this._activeView!==null&&this.refetchContent()})}set artifact(n){const r=this._artifact;this._artifact=n,this.render(),r!==null&&r!==n&&this.syncView()}get artifact(){return this._artifact}set viewURL(n){this._viewURL!==n&&(this._viewURL=n,this.syncView())}get viewURL(){return this._viewURL}set contentURL(n){this._contentURL!==n&&(this._contentURL=n,this.syncView())}get contentURL(){return this._contentURL}set screen(n){this._screen!==n&&(this._screen=n,this.syncScreenSubscription())}get screen(){return this._screen}set dragging(n){n?this.setAttribute("dragging","true"):this.removeAttribute("dragging")}get dragging(){return this.getAttribute("dragging")==="true"}get activeView(){return this._activeView}connectedCallback(){this.render(),this.syncView(),this.syncScreenSubscription()}disconnectedCallback(){this.teardownView(),this.unsubscribeFromScreen()}handleClose(){this._artifact&&this.dispatchEvent(new zm("close-artifact",{artifactID:this._artifact.id,bubbles:!0,composed:!0}))}syncView(){var n;if(this.isConnected){if(this._viewURL!==null){if(this._directRender&&this.teardownView(),this._mountedViewURL!==this._viewURL){this.teardownView(),this._contentState={kind:"loading"},this._mountedViewURL=this._viewURL,this.render();const r=this.querySelector("iframe.artifact-frame");if(!r){this._contentState={kind:"error"},this.render();return}this._activeView=new HR(r),this._activeView.handleUpdateContent(async s=>{await this.saveContent(s)}),this.loadBlobFrame(this._viewURL),this.startContentFetch();return}this._activeView!==null&&this.startContentFetch();return}if(this._contentURL!==null){this.teardownView(),this._directRender=!0,this._contentState={kind:"idle"},this.render(),((n=this._artifact)==null?void 0:n.status)==="committed"&&this.loadBlobFrame(this._contentURL);return}this.teardownView(),this._contentState={kind:"idle"},this.render()}}async saveContent(n){const r=this._screen,s=this._artifact;if(!r||!s)throw new Error("artifact-view: cannot save without a screen and artifact");await r.server.client.artifacts.putContent({artifactID:s.id,content:n})}syncScreenSubscription(){if(!this.isConnected){this.unsubscribeFromScreen();return}this._subscribedScreen!==this._screen&&(this.unsubscribeFromScreen(),this._screen!==null&&(this._screen.addEventListener("artifact-content-changed",this.handleScreenContentChanged),this._subscribedScreen=this._screen))}unsubscribeFromScreen(){this._subscribedScreen!==null&&(this._subscribedScreen.removeEventListener("artifact-content-changed",this.handleScreenContentChanged),this._subscribedScreen=null)}startContentFetch(){this._fetchSequence+=1;const n=this._fetchSequence,r=this._contentURL,s=this._activeView;if(!s||r===null){this._contentState={kind:"error"},this.render();return}this._contentState={kind:"loading"},(async()=>{try{const i=await fetch(r);if(n!==this._fetchSequence)return;if(!i.ok){this._contentState={kind:"error"},this.teardownView(),this.render();return}const o=await i.text();if(n!==this._fetchSequence||this._activeView!==s)return;this._activeView.content=o,this._contentState={kind:"ready"}}catch{if(n!==this._fetchSequence)return;this._contentState={kind:"error"},this.teardownView(),this.render()}})()}refetchContent(){this._fetchSequence+=1;const n=this._fetchSequence,r=this._contentURL,s=this._activeView;!s||r===null||(async()=>{try{const i=await fetch(r);if(n!==this._fetchSequence||!i.ok)return;const o=await i.text();if(n!==this._fetchSequence||this._activeView!==s)return;this._activeView.content=o}catch{}})()}loadBlobFrame(n){this._blobSequence+=1;const r=this._blobSequence;(async()=>{try{const s=await KR(n);if(r!==this._blobSequence){URL.revokeObjectURL(s);return}this._blobURL=s,this.render();const i=this.querySelector("iframe.artifact-frame");i&&(i.src=s)}catch{if(r!==this._blobSequence)return;this._contentState={kind:"error"},this.teardownView(),this.render()}})()}teardownView(){this._activeView!==null&&(this._activeView.dispose(),this._activeView=null),this._blobURL!==null&&(URL.revokeObjectURL(this._blobURL),this._blobURL=null),this._mountedViewURL=null,this._directRender=!1,this._fetchSequence+=1,this._blobSequence+=1}contentTemplate(){return this._contentState.kind==="error"?M`
|
|
124
124
|
<div class="artifact-content artifact-placeholder">
|
|
125
125
|
<em>Failed to load content</em>
|
|
126
126
|
</div>
|
|
@@ -138,7 +138,7 @@ ${r.documentElement.outerHTML}`],{type:"text/html"});return URL.createObjectURL(
|
|
|
138
138
|
${this.contentTemplate()}
|
|
139
139
|
<footer class="artifact-title-bar" drag-handle>
|
|
140
140
|
<div class="artifact-title-group">
|
|
141
|
-
<span class="artifact-title-icon">${
|
|
141
|
+
<span class="artifact-title-icon">${OR({size:16})}</span>
|
|
142
142
|
<span class="artifact-title">${n.title}</span>
|
|
143
143
|
</div>
|
|
144
144
|
<button
|
|
@@ -149,7 +149,7 @@ ${r.documentElement.outerHTML}`],{type:"text/html"});return URL.createObjectURL(
|
|
|
149
149
|
${bm({size:16})}
|
|
150
150
|
</button>
|
|
151
151
|
</footer>
|
|
152
|
-
`}render(){this._artifact&&(this.setAttribute("type",this._artifact.type),be(this.template(),this))}}customElements.define("artifact-view",KR);const Se=t=>({type:"px",...t}),xe=t=>({type:"unit",...t}),Zi=2,JR=2;class XR{constructor(e){v(this,"basis");v(this,"min");v(this,"_gap");v(this,"_viewport");v(this,"_unit");this.basis=e.basis,this.min=e.min,this._viewport=e.viewport,this._gap=e.gap??Se({x:de,y:de});const n=this._viewport.x??tn,r=this._viewport.y??vr,s=this._gap.x??de,i=this._gap.y??de,o=tn+s*JR,a=n<=o,l=a?n-s*Zi:Math.min(tn,n-s*Zi),c=a?r-i*Zi:Math.min(vr,r-i*Zi),d=(l-s*(St-1))/St,p=(c-i*(He-1))/He,y=this.basis.x??0,m=this.basis.y??0,E=this.min.x??0,k=this.min.y??0;this._unit=Se(a?{x:Math.max(E,d),y:Math.max(k,p)}:{x:Math.max(E,Math.min(y,d)),y:Math.max(k,Math.min(m,p))})}get unit(){return this._unit}get viewport(){return this._viewport}get gap(){return this._gap}toUnits(e){return xe({x:e.x==null?void 0:e.x/(this._unit.x??1),y:e.y==null?void 0:e.y/(this._unit.y??1)})}toPixels(e){const n=this._unit.x??0,r=this._unit.y??0,s=this._gap.x??de,i=this._gap.y??de,o=e.x==null?void 0:e.x*n+Math.max(0,e.x-1)*s,a=e.y==null?void 0:e.y*r+Math.max(0,e.y-1)*i;return Se({x:o,y:a})}}const Vn=1e-4,Nt=1e-6,QR=40,eD=24;function Lm(t,e){return Math.max(0,t-e*2)}function Mm(t){const e=[0];for(const n of t)e.push((e[e.length-1]??0)+n);return e}function Nm(t){const e=[0];for(let n=0;n<t.length;n+=1){const r=e[n]??0;e.push(r+t[n]+de)}return e}function Um(t,e,n){if(e<0||e>=t.length)return 0;let r=0,s=0;for(let i=e;i<t.length;i+=1){const o=t[i],a=s===0?o:r+de+o;if(a>n+Vn)break;r=a,s+=1}return Math.max(1,s)}function tD(t,e,n){if(e<0||e>=t.length)return 0;let r=0,s=0;for(let i=e;i>=0;i-=1){const o=t[i],a=s===0?o:r+de+o;if(a>n+Vn)break;r=a,s+=1}return Math.max(1,s)}function nD(t,e){if(t.length===0)return 0;let n=0,r=0;for(let s=t.length-1;s>=0;s-=1){const i=t[s],o=r===0?i:n+de+i;if(o>e+Vn)break;n=o,r+=1}return Math.max(1,r)}function Wc(t,e){if(t.length===0)return 0;const n=nD(t,e);return Math.max(0,t.length-n)}function Rd(t,e,n){if(t.length===0)return 0;const r=Um(t,e,n),s=Math.min(t.length,e+r);if(s<=e)return 0;const i=t.slice(e,s);return i.reduce((o,a)=>o+a,0)+Math.max(0,i.length-1)*de}function Zl(t,e,n){const r=t[e]??0;return n-r}function gr(t,e,n,r,s){if(t.length===0)return 0;const i=Wc(t,s),o=e[i]??0,a=Math.max(0,Math.min(o,n));let l=0;for(let L=0;L<i;L+=1){const J=e[L]??0,H=e[L+1]??J;if(a>=J&&a<=H+Vn){l=L;break}l=L+1}const c=Math.min(l+1,i),d=e[l]??0,p=e[c]??d,y=Math.max(p-d,Vn),m=c===l?0:(a-d)/y,E=Nm(t),k=Rd(t,l,s),I=Rd(t,c,s),G=(r-k)/2,N=(r-I)/2,j=Zl(E,l,G),F=Zl(E,c,N);return j+(F-j)*m}function Dd(t,e,n,r,s){const i=Wc(t,r),o=e[i]??0;let a=0,l=o;for(let c=0;c<QR;c+=1){const d=(a+l)/2;gr(t,e,d,n,r)>s?a=d:l=d}return(a+l)/2}function Od(t,e,n){const r=Nm(t),[s,i]=e,o=t.slice(s,i+1),a=o.reduce((c,d)=>c+d,0)+Math.max(0,o.length-1)*de,l=(n-a)/2;return Zl(r,s,l)}function rD(t,e,n){const r=Um(t,e,n);return[e,Math.min(t.length-1,e+r-1)]}function sD(t,e,n){const r=tD(t,e,n);return[Math.max(0,e-r+1),e]}function iD(t){const e=new Set,n=[];for(const r of t){const s=`${r.nodeRange[0]}:${r.nodeRange[1]}`;if(e.has(s))continue;const i=n[n.length-1];i&&Math.abs(i.anchor-r.anchor)<=Nt||(e.add(s),n.push(r))}return n}function oD(t){const{nodeCols:e,nodeWidthsPx:n,viewportWidthPx:r}=t;if(e.length===0||n.length===0)return{viewspans:[],minScroll:0,maxScroll:0};const s=t.gapPx??de,i=Lm(r,s),o=Mm(e),a=Wc(n,i),l=o[a]??0,c=[];for(let d=0;d<=a;d+=1){const p=rD(n,d,i),y=Od(n,p,r),m=Dd(n,o,r,i,y);c.push({nodeRange:p,anchor:Math.max(0,Math.min(l,m))})}for(let d=n.length-1;d>=0;d-=1){const p=sD(n,d,i),y=`${p[0]}:${p[1]}`;if(c.some(k=>`${k.nodeRange[0]}:${k.nodeRange[1]}`===y))continue;const m=Od(n,p,r),E=Dd(n,o,r,i,m);c.push({nodeRange:p,anchor:Math.max(0,Math.min(l,E))})}return c.sort((d,p)=>Math.abs(d.anchor-p.anchor)>Nt?d.anchor-p.anchor:d.nodeRange[0]!==p.nodeRange[0]?d.nodeRange[0]-p.nodeRange[0]:d.nodeRange[1]-p.nodeRange[1]),{viewspans:iD(c),minScroll:0,maxScroll:l}}function aD(t,e){var s;let n=0,r=Number.POSITIVE_INFINITY;for(let i=0;i<t.length;i+=1){const o=Math.abs((((s=t[i])==null?void 0:s.anchor)??0)-e);if(o+Nt<r){r=o,n=i;continue}Math.abs(o-r)<=Nt&&i<n&&(n=i)}return n}function lD(t,e,n){return n<=0?0:Math.max(0,Math.min(n-1,t+e))}function os(t,e,n){return Math.max(e,Math.min(n,t))}class cD extends kt{constructor(n){super();v(this,"_scroll",0);v(this,"minScroll",0);v(this,"maxScroll",0);v(this,"viewspans",[]);v(this,"activeViewspanIndex",null);v(this,"nodeWidthsPx",[]);v(this,"boundaryCols",[0]);v(this,"viewportWidthPx",0);v(this,"framedViewportWidthPx",0);this._scroll=(n==null?void 0:n.x)??0}get scroll(){return xe({x:this._scroll})}get translate(){return Se({x:gr(this.nodeWidthsPx,this.boundaryCols,this._scroll,this.viewportWidthPx,this.framedViewportWidthPx)})}set scroll(n){const r=os(n.x??this._scroll,this.minScroll,this.maxScroll);Math.abs(r-this._scroll)<=Nt||(this._scroll=r,this.activeViewspanIndex=null,this.dispatchEvent(new ss("layout-scroll",{scroll:this.scroll})))}rebuild(n){const r=n.nodeWidths.map(c=>Math.max(0,c.x??0)),s=r.map(c=>n.grid.toPixels(xe({x:c})).x??0),i=n.grid.viewport.x??0,o=n.grid.gap.x??de,a=oD({nodeCols:r,nodeWidthsPx:s,viewportWidthPx:i,gapPx:o});this.nodeWidthsPx=s,this.boundaryCols=Mm(r),this.viewportWidthPx=i,this.framedViewportWidthPx=Lm(i,o),this.viewspans=a.viewspans,this.minScroll=a.minScroll,this.maxScroll=a.maxScroll,this.activeViewspanIndex=null;const l=os(this._scroll,this.minScroll,this.maxScroll);Math.abs(l-this._scroll)>Nt&&(this._scroll=l,this.dispatchEvent(new ss("layout-scroll",{scroll:this.scroll})))}step(n){var a;if(this.viewspans.length===0)return;const r=this.activeViewspanIndex??aD(this.viewspans,this._scroll),s=lD(r,n,this.viewspans.length),i=((a=this.viewspans[s])==null?void 0:a.anchor)??this._scroll,o=os(i,this.minScroll,this.maxScroll);this.activeViewspanIndex=s,!(Math.abs(o-this._scroll)<=Nt)&&(this._scroll=o,this.dispatchEvent(new ss("layout-scroll",{scroll:this.scroll})))}wheel(n){const r=os(this._scroll+(n.x??0),this.minScroll,this.maxScroll);this.activeViewspanIndex=null,!(Math.abs(r-this._scroll)<=Nt)&&(this._scroll=r,this.dispatchEvent(new ss("layout-scroll",{scroll:this.scroll})))}wheelPixels(n){const r=n.x??0;if(Math.abs(r)<=Vn)return;this.activeViewspanIndex=null;const s=gr(this.nodeWidthsPx,this.boundaryCols,this._scroll,this.viewportWidthPx,this.framedViewportWidthPx),i=s-r,o=gr(this.nodeWidthsPx,this.boundaryCols,this.maxScroll,this.viewportWidthPx,this.framedViewportWidthPx),a=gr(this.nodeWidthsPx,this.boundaryCols,this.minScroll,this.viewportWidthPx,this.framedViewportWidthPx),l=Math.max(o,Math.min(a,i));if(Math.abs(l-s)<=Vn)return;let c=this.minScroll,d=this.maxScroll;for(let y=0;y<eD;y+=1){const m=(c+d)/2;gr(this.nodeWidthsPx,this.boundaryCols,m,this.viewportWidthPx,this.framedViewportWidthPx)>l?c=m:d=m}const p=os((c+d)/2,this.minScroll,this.maxScroll);Math.abs(p-this._scroll)<=Nt||(this._scroll=p,this.dispatchEvent(new ss("layout-scroll",{scroll:this.scroll})))}}const Va={"stack-above":{left:.25,top:0,width:.5,height:.5},"stack-below":{left:.25,top:.5,width:.5,height:.5},"reorder-before":{left:0,top:0,width:.25,height:1},"reorder-after":{left:.75,top:0,width:.25,height:1}},uD=["stack-above","stack-below","reorder-before","reorder-after"];function Ha(t,e){return{left:t.left+t.width*e.left,top:t.top+t.height*e.top,width:t.width*e.width,height:t.height*e.height}}function bn(t,e,n){return t>=n.left&&t<n.left+n.width&&e>=n.top&&e<n.top+n.height}function Bc(t,e){for(const n of t){if(n.type==="card"&&n.id===e)return n;if(n.type==="stack")for(const r of n.children){if(r.type==="card"&&r.id===e)return r;if(r.type==="row"){for(const s of r.children)if(s.id===e)return s}}}return null}function jl(t){return t.height===He||t.height===sn?{...t,height:sn}:t}function Wl(t){return t.height===sn?{...t,height:He}:t}function hD(t,e,n,r){const s=t.findIndex(d=>d.type==="stack"&&d.id===e);if(s===-1)return t;const i=t[s];if(!i||i.type!=="stack")return t;const o=i.children.find(d=>d.type==="card"&&d.id===n);if(!o||o.type!=="card")return t;const a=i.children.filter(d=>d.id!==n);if(a.length===i.children.length||a.length<1)return t;const l=[...t];if(a.length===1){const[d]=a;l[s]=d.type==="card"?Wl(d):d}else l[s]={...i,children:a};const c=Math.max(0,Math.min(r,l.length));return l.splice(c,0,Wl(o)),l}const dD=et(),pD=et(),fD=50;function gD(t,e){if(t.type!==e.type)return!1;switch(t.type){case"reorder":return e.index===t.index;case"stack":return e.targetCardId===t.targetCardId&&e.position===t.position;case"stack-child-noop":return!0;case"stack-child-extract":return e.toIndex===t.toIndex;case"stack-child-reorder":return e.position===t.position;default:return!1}}function yi(t){return{id:t.id,type:"drop-target",width:t.width,height:t.height}}function zd(t){return t.map(vD)}function mD(t){return t.type==="drop-target"?{id:t.id,type:"card",artifactID:t.id,width:t.width,height:t.height}:t}function vD(t){return t.type==="drop-target"?{id:t.id,type:"card",artifactID:t.id,width:t.width,height:t.height}:t.type==="stack"?{...t,children:t.children.map(mD)}:t}function Fm(t,e){return t.find(r=>r.type==="card"&&r.id===e)??null}function Ld(t,e){return t.find(r=>r.type==="stack"&&r.id===e)??null}function yD(t,e){const n=[...e],r=n.findIndex(a=>a.type==="card"&&a.id===t.nodeId);if(r===-1)return null;const s=n[r];if(!s||s.type!=="card")return null;n.splice(r,1);const i=Math.max(0,Math.min(t.lastReorderIndex,n.length));n.splice(i,0,s);const o=n.findIndex(a=>a.type==="card"&&a.id===t.nodeId);return o===-1?null:{base:n,visualDraggedIndex:o}}function bD(t,e,n,r){const s=[...t.base];s.splice(t.visualDraggedIndex,1);const i=s.findIndex(y=>y.type==="card"&&y.id===n.targetCardId),o=i===-1?null:s[i];if(!o||o.type!=="card")return null;const a=Fm(r,e.nodeId);if(!a)return null;const l=jl(a),c=jl(o),d=yi(l),p=n.position==="above"?[d,c]:[c,d];return s[i]={id:o.id,type:"stack",children:p},s}function qa(t,e){return t.parentStackId?_D(t,e):wD(t,e)}function wD(t,e){const n=t.hitTarget;if(n.type==="reorder"){const r=e[t.sourceIndex];if(!r||r.type!=="card")return[...e];const s=[...e];return s.splice(t.sourceIndex,1),s.splice(n.index,0,yi(r)),s}if(n.type==="stack"){const r=yD(t,e);return r?bD(r,t,n,e)??[...e]:[...e]}return[...e]}function _D(t,e){const n=t.hitTarget;switch(n.type){case"stack-child-reorder":return SD(t,e,n.position);case"stack-child-extract":return kD(t,e,n.toIndex);case"stack-child-noop":return ED(t,e);default:return[...e]}}function SD(t,e,n){const r=e.findIndex(y=>y.type==="stack"&&y.id===t.parentStackId);if(r===-1)return[...e];const s=e[r];if(!s||s.type!=="stack")return[...e];if(!s.children.every(y=>y.type==="card"))return[...e];const i=s.children,o=i.findIndex(y=>y.id===t.nodeId);if(o===-1)return[...e];const a=i[o],l=i.filter(y=>y.id!==t.nodeId),c=yi(a),d=n==="above"?[c,...l]:[...l,c],p=[...e];return p[r]={...s,children:d},p}function kD(t,e,n){if(!t.parentStackId)return[...e];const r=hD(e,t.parentStackId,t.nodeId,n);if(r===e)return[...e];const s=r.findIndex(a=>a.type==="card"&&a.id===t.nodeId);if(s===-1)return[...e];const i=r[s];if(!i||i.type!=="card")return[...e];const o=[...r];return o[s]=yi(i),o}function ED(t,e){const n=e.findIndex(l=>l.type==="stack"&&l.id===t.parentStackId);if(n===-1)return[...e];const r=e[n];if(!r||r.type!=="stack")return[...e];const s=r.children.findIndex(l=>l.type==="card"&&l.id===t.nodeId);if(s===-1)return[...e];const i=r.children[s];if(!i||i.type!=="card")return[...e];const o=[...e],a=[...r.children];return a[s]=yi(i),o[n]={...r,children:a},o}function $D(t,e){return e.find(r=>r.type==="stack"&&r.id===t.id)?t.id:xc()}function AD(t,e,n){if(t.type==="drop-target"){const r=Bc(e,n);if(!r)throw new Error(`finalize: missing dragged card ${n}`);return jl(r)}return t}function xD(t,e,n){const r=t.children.map(i=>AD(i,e,n));return{id:$D(t,e),type:"stack",children:r}}function TD(t,e,n){if(t.type==="drop-target"){const r=Bc(e,n);if(!r)throw new Error(`finalize: missing dragged card ${n}`);return Fm(e,n)!==null?r:Wl(r)}return t.type==="card"||t.type==="row"?t:xD(t,e,n)}function CD(t,e,n){return t.map(r=>TD(r,e,n))}function ID(t,e){return JSON.stringify(t)===JSON.stringify(e)}const PD=Hr(kt);class RD extends PD{constructor(n={}){super();v(this,"pending",null);v(this,"active",null)}start(n){if(this.pending||this.active)return;const r=n.pointer.x??0,s=n.pointer.y??0;this.pending={startX:r,startY:s,grabOffsetX:n.grabOffset.x??0,grabOffsetY:n.grabOffset.y??0,nodeId:n.nodeId,sourceIndex:n.source.index,parentStackId:n.source.parentId,width:n.size.x??0,height:n.size.y??0,baseLayout:n.layout}}update(n){const r=n.pointer.x??0,s=n.pointer.y??0,i=this.pending;if(i){const c=r-i.startX,d=s-i.startY;Math.hypot(c,d)>=pE&&(this.pending=null,this.active={...i,pointerX:r,pointerY:s,hitTarget:{type:"reorder",index:i.sourceIndex},lastReorderIndex:i.sourceIndex},this.emitDrag(),this.dispatchEvent(new te("change")));return}if(!this.active)return;const o=qa(this.active,this.active.baseLayout),a=this.getHitTargetForPointer(r,s,n,o),l=a.type==="reorder"?a.index:this.active.lastReorderIndex;this.active.pointerX===r&&this.active.pointerY===s&&gD(this.active.hitTarget,a)&&this.active.lastReorderIndex===l||(this.active={...this.active,pointerX:r,pointerY:s,hitTarget:a,lastReorderIndex:l},this.emitDrag(),this.dispatchEvent(new te("change")))}drop(){if(this.pending){this.cancel();return}if(!this.active)return;const n=this.active.baseLayout;let r=null;try{const s=qa(this.active,n),i=CD(s,n,this.active.nodeId);ID(i,n)||(r=i)}catch{r=null}this.reset(),r&&this.dispatchEvent(new pD("drop",{layout:r})),this.dispatchEvent(new te("change"))}cancel(){!this.pending&&!this.active||(this.reset(),this.dispatchEvent(new te("change")))}dispose(){this.reset()}get status(){return this.active?"active":this.pending?"pending":"idle"}reset(){this.pending=null,this.active=null}emitDrag(){if(!this.active)return;const n=qa(this.active,this.active.baseLayout);this.dispatchEvent(new dD("drag",{nodeId:this.active.nodeId,source:{index:this.active.sourceIndex,parentId:this.active.parentStackId},grabOffset:Se({x:this.active.grabOffsetX,y:this.active.grabOffsetY}),pointer:Se({x:this.active.pointerX,y:this.active.pointerY}),size:Se({x:this.active.width,y:this.active.height}),projectedLayout:n}))}getHitTargetForPointer(n,r,s,i){return this.active?this.isPointerInsideDragBounds(n,r,s.viewport)?this.active.parentStackId?this.getStackChildHitTarget(n,r,s,i):this.getTopLevelCardHitTarget(n,r,s,i):{type:"reorder",index:this.active.sourceIndex}:{type:"reorder",index:0}}getStackChildHitTarget(n,r,s,i){var c;if(!((c=this.active)!=null&&c.parentStackId))return{type:"stack-child-noop"};const o=this.getSourceStackInteractionRect(s.geometry);if(o&&bn(n,r,o)){const d=o.top+o.height/2;return{type:"stack-child-reorder",position:r<d?"above":"below"}}const a=this.getSourceRemainingSiblingRect(s.geometry);if(a&&bn(n,r,a)){const d=a.top+a.height/2;return{type:"stack-child-reorder",position:r<d?"above":"below"}}return{type:"stack-child-extract",toIndex:this.getTopLevelReorderIndexForPointer(n,r,s,i)}}getSourceRemainingSiblingRect(n){var i,o;if(!((i=this.active)!=null&&i.parentStackId))return;const r=Ld(this.active.baseLayout,this.active.parentStackId);if(!r)return;const s=r.children.find(a=>{var l;return a.type==="card"&&a.id!==((l=this.active)==null?void 0:l.nodeId)});if(s)return(o=n.find(a=>a.id===s.id))==null?void 0:o.rect}getSourceStackInteractionRect(n){var o;if(!((o=this.active)!=null&&o.parentStackId))return;const r=n.find(a=>{var l;return a.id===((l=this.active)==null?void 0:l.parentStackId)});if(r)return this.active.sourceStackRect=r.rect,r.rect;const s=Ld(this.active.baseLayout,this.active.parentStackId);if(!s)return this.active.sourceStackRect;const i=s.children.find(a=>{var l;return a.type==="card"&&a.id!==((l=this.active)==null?void 0:l.nodeId)});if(i){const a=n.find(l=>l.id===i.id);if(a)return a.rect}return this.active.sourceStackRect}getTopLevelCardHitTarget(n,r,s,i){var m,E,k;const o=this.getTopLevelZoneNodes(s.geometry,i);if(o.length===0)return{type:"reorder",index:((m=this.active)==null?void 0:m.sourceIndex)??0};const l=(s.effectiveVelocity??0)<=fD;for(const I of o){const G=I.rect;if(!bn(n,r,G))continue;const N=this.resolveTopLevelTargetForCard(n,r,I,I.logicalIndex,l);if(N)return N;if(!l&&((E=this.active)!=null&&E.hitTarget))return this.active.hitTarget}const c=this.getNearestTargetableZone(n,o);if(!c)return{type:"reorder",index:((k=this.active)==null?void 0:k.sourceIndex)??0};const d=Math.max(c.rect.left,Math.min(c.rect.left+c.rect.width,n)),p=this.resolveTopLevelTargetForCard(d,r,c,c.logicalIndex,l);if(p)return p;const y=c.rect.left+c.rect.width/2;return{type:"reorder",index:n<y?c.logicalIndex:c.logicalIndex+1}}getTopLevelReorderIndexForPointer(n,r,s,i){var c,d;const o=this.getTopLevelZoneNodes(s.geometry,i);if(o.length===0)return((c=this.active)==null?void 0:c.sourceIndex)??0;for(const p of o){if(!bn(n,r,p.rect))continue;const y=Ha(p.rect,Va["reorder-before"]);if(bn(n,r,y))return p.logicalIndex;const m=Ha(p.rect,Va["reorder-after"]);if(bn(n,r,m))return p.logicalIndex+1}const a=this.getNearestTargetableZone(n,o);if(!a)return((d=this.active)==null?void 0:d.sourceIndex)??0;const l=a.rect.left+a.rect.width/2;return n<l?a.logicalIndex:a.logicalIndex+1}getTopLevelZoneNodes(n,r){const s=new Map(r.map(a=>[a.id,a])),i=[];let o=0;for(const a of n){const l=s.get(a.id);l&&l.type!=="drop-target"&&(l.type==="card"||l.type==="stack")&&(i.push({id:l.id,rect:a.rect,logicalIndex:o}),o+=1)}return i}resolveTopLevelTargetForCard(n,r,s,i,o){const a=s.rect;for(const l of uD){if(!o&&(l==="stack-above"||l==="stack-below"))continue;const c=Va[l],d=Ha(a,c);if(bn(n,r,d))return l==="stack-above"?{type:"stack",targetCardId:s.id,position:"above"}:l==="stack-below"?{type:"stack",targetCardId:s.id,position:"below"}:l==="reorder-before"?{type:"reorder",index:i}:{type:"reorder",index:i+1}}return null}getNearestTargetableZone(n,r){let s=null,i=Number.POSITIVE_INFINITY;for(const o of r){const a=o.rect.left,l=o.rect.left+o.rect.width,c=n<a?a-n:n>l?n-l:0;c<i&&(i=c,s=o)}return s}isPointerInsideDragBounds(n,r,s){return n>=s.left&&n<=s.left+s.width&&r>=s.top&&r<=s.top+s.height}}const Md=60,DD=80,Nd=.5,Ud=10;class OD{constructor(){v(this,"awaitingFreshWheelGesture",!1);v(this,"lastWheelEventAt",Number.NEGATIVE_INFINITY);v(this,"lastWheelDeltaX",0);v(this,"activeGestureType","none");v(this,"lastWheelGestureAt",Number.NEGATIVE_INFINITY)}markKeyboardNavigation(e){this.awaitingFreshWheelGesture=!0,this.lastWheelEventAt=e,this.activeGestureType="none"}reset(){this.awaitingFreshWheelGesture=!1,this.lastWheelEventAt=Number.NEGATIVE_INFINITY,this.lastWheelDeltaX=0,this.activeGestureType="none",this.lastWheelGestureAt=Number.NEGATIVE_INFINITY}decide(e){const{now:n,shiftKey:r,deltaX:s,deltaY:i,overArtifactContent:o}=e;n-this.lastWheelGestureAt>=Md&&(this.activeGestureType="none");const l=r&&i!==0,c=l?i:s,d=Math.abs(c),p=Math.abs(i);return this.activeGestureType==="vertical-artifact"&&o?d>=Nd&&d>=p*Ud?this.classifyHorizontal(n,c):(this.lastWheelGestureAt=n,{type:"scroll-native"}):this.activeGestureType==="horizontal-filmstrip"?!l&&o&&p>0&&p>=d*Ud?(this.activeGestureType="vertical-artifact",this.lastWheelGestureAt=n,{type:"scroll-native"}):this.classifyHorizontal(n,c):d<Nd?(o&&(this.activeGestureType="vertical-artifact"),this.lastWheelGestureAt=n,{type:"scroll-native"}):l||d>p?this.classifyHorizontal(n,c):p>d?(o&&(this.activeGestureType="vertical-artifact"),this.lastWheelGestureAt=n,{type:"scroll-native"}):o?(this.activeGestureType="vertical-artifact",this.lastWheelGestureAt=n,{type:"scroll-native"}):this.classifyHorizontal(n,c)}classifyHorizontal(e,n){const r=e-this.lastWheelEventAt,s=Math.sign(this.lastWheelDeltaX),i=Math.sign(n),o=s!==0&&i!==0&&s!==i,a=s!==0&&Math.abs(n)>=Math.abs(this.lastWheelDeltaX)+DD;return this.awaitingFreshWheelGesture&&r<Md&&!o&&!a?{type:"ignore"}:(this.lastWheelEventAt=e,this.lastWheelDeltaX=n,this.lastWheelGestureAt=e,this.awaitingFreshWheelGesture=!1,this.activeGestureType="horizontal-filmstrip",{type:"scroll-horizontal",horizontalDelta:n})}}const zD=2,Fd=1e3,ji=1e-4;function Zd(t,e,n){if(t===0)return 0;const r=e.toPixels(xe({y:He})).y??0;return(n-r)/zD}class LD extends Event{constructor(n){super("scroll",{bubbles:!0,composed:!0});v(this,"scrollPosition");this.scrollPosition=n}}class Zm extends Event{constructor(n){super("layout-change",{bubbles:!0,composed:!0});v(this,"layout");this.layout=n}}class MD extends HTMLElement{constructor(){super();v(this,"_layout",[]);v(this,"_scrollPosition",0);v(this,"layoutGrid",null);v(this,"layoutScroll",new cD(xe({x:0})));v(this,"scrollModelKey","");v(this,"resizeObserver",null);v(this,"renderPending",!1);v(this,"animateNextRender",!0);v(this,"wheelGesture",new OD);v(this,"dragController",new RD);v(this,"dragState",null);v(this,"activeDragPointerId",null);v(this,"dragListenersAttached",!1);v(this,"dragFrame",0);v(this,"lastDragFrameTime",0);v(this,"lastPointerX",0);v(this,"lastPointerY",0);v(this,"pointerVelocityPxPerSec",0);v(this,"scrollVelocityPxPerSec",0);v(this,"motionSampleTime",0);v(this,"motionSampleX",0);v(this,"motionSampleY",0);v(this,"dragTrackOffsetXPx",0);v(this,"previousProjectedLayoutForOffset",null);v(this,"renderContent",()=>M``);v(this,"onDragControllerChange",()=>{this.dragController.status==="idle"&&(this.dragState=null,this.dragTrackOffsetXPx=0,this.previousProjectedLayoutForOffset=null),this.scheduleRender()});v(this,"onDragControllerDrag",n=>{const r=zd(n.projectedLayout),s=this.shouldApplyTrackOffset(n.projectedLayout,n.source.parentId),i=n.source.parentId?this.getStackChildAnchorCardId(n.source.parentId,n.nodeId):null;this.dragTrackOffsetXPx=s?this.computeDragTrackOffset(this.previousProjectedLayoutForOffset,r,n.nodeId,n.source.parentId,i,this.dragTrackOffsetXPx):0,this.previousProjectedLayoutForOffset=r,this.dragState={nodeId:n.nodeId,source:n.source,grabOffset:n.grabOffset,pointer:n.pointer,size:n.size,projectedLayout:n.projectedLayout},this.scheduleRender()});v(this,"onDragControllerDrop",n=>{this.dragState=null,this.dragTrackOffsetXPx=0,this.previousProjectedLayoutForOffset=null,this.commitLayout(n.layout)});v(this,"onLayoutScrollInternal",n=>{const s=n.scroll.x??0;Math.abs(s-this._scrollPosition)<ji||(this._scrollPosition=s,this.emitScrollPositionChanged(s),this.scheduleRender())});v(this,"handleKeyDown",n=>{if(n.key==="Escape"&&this.dragController.status!=="idle"){n.preventDefault(),this.stopDragFrameLoop(),this.releaseActiveDragPointerCapture(),this.dragController.cancel(),this.detachDragListeners();return}this.dragController.status==="idle"&&(n.key==="ArrowRight"?(n.preventDefault(),this.wheelGesture.markKeyboardNavigation(Date.now()),this.shiftWindow(1)):n.key==="ArrowLeft"&&(n.preventDefault(),this.wheelGesture.markKeyboardNavigation(Date.now()),this.shiftWindow(-1)))});v(this,"handleWheel",n=>{if(this._layout.length===0)return;const r=this.wheelGesture.decide({now:Date.now(),shiftKey:n.shiftKey,deltaX:n.deltaX,deltaY:n.deltaY,overArtifactContent:!1});r.type==="scroll-horizontal"&&(n.preventDefault(),this.applyHorizontalWheel(r.horizontalDelta))});v(this,"handleWindowMessage",n=>{var o;if(this._layout.length===0)return;const r=this.findManagedArtifactFrame(n.source);if(!r||!this.isTrustedArtifactFrameMessage(n,r)||!kC(n.data))return;const s=this.wheelGesture.decide({now:Date.now(),shiftKey:n.data.shiftKey,deltaX:n.data.deltaX,deltaY:n.data.deltaY,overArtifactContent:!0});if(s.type==="scroll-horizontal"){this.applyHorizontalWheel(s.horizontalDelta);return}if(s.type!=="scroll-native")return;const i={type:"scroll",deltaX:0,deltaY:n.data.deltaY};(o=r.contentWindow)==null||o.postMessage(i,this.getArtifactFrameTargetOrigin(r))});v(this,"handlePointerDown",n=>{if(n.button!==0||this.dragController.status!=="idle")return;const r=n.target;if(!(r instanceof Element)||!r.closest("[drag-handle]")||r.closest("button, input, textarea, select, a, [role='button']"))return;const s=r.closest(".card-slot");if(!s)return;const i=s.getAttribute("data-layout-node-id");if(!i)return;const o=UD(this._layout,i);if(!o)return;const a=s.getBoundingClientRect();this.lastPointerX=n.clientX,this.lastPointerY=n.clientY,this.resetMotionTracking(n.clientX,n.clientY),this.focus(),this.dragController.start({nodeId:i,source:{index:o.topLevelIndex,parentId:o.sourceStackId},pointer:Se({x:n.clientX,y:n.clientY}),grabOffset:Se({x:n.clientX-a.left,y:n.clientY-a.top}),size:Se({x:a.width,y:a.height}),layout:this._layout}),this.attachDragListeners(),this.activeDragPointerId=n.pointerId;try{this.setPointerCapture(n.pointerId)}catch{}n.preventDefault()});v(this,"handleWindowPointerMove",n=>{this.lastPointerX=n.clientX,this.lastPointerY=n.clientY,this.updatePointerVelocity(n.clientX,n.clientY),this.syncDragTargetForLatestPointer(),this.ensureDragFrameLoop()});v(this,"handleWindowPointerUp",n=>{this.stopDragFrameLoop(),this.releasePointerCaptureForEvent(n.pointerId),this.dragController.drop(),this.clearMotionTracking(),this.detachDragListeners()});v(this,"handleWindowPointerCancel",n=>{this.stopDragFrameLoop(),this.releasePointerCaptureForEvent(n.pointerId),this.dragController.cancel(),this.clearMotionTracking(),this.detachDragListeners()});v(this,"handleWindowBlur",()=>{this.releaseActiveDragPointerCapture(),this.stopDragFrameLoop(),this.dragController.cancel(),this.clearMotionTracking(),this.detachDragListeners()});v(this,"runDragFrame",n=>{if(this.dragController.status==="idle"){this.dragFrame=0;return}const r=Math.max(0,n-this.lastDragFrameTime)/Fd;this.lastDragFrameTime=n,this.samplePointerVelocityAt(n,this.lastPointerX,this.lastPointerY);const s=this.getBoundingClientRect(),i=this.clampPointerToViewport(this.lastPointerX,this.lastPointerY,s),o=this.getDragEdgeScrollDeltaPixels(i.x,s,r);this.scrollVelocityPxPerSec=r>ji?Math.abs(o)/r:0,Math.abs(o)>ji&&(this.animateNextRender=!1,this.layoutScroll.wheelPixels(Se({x:o}))),this.dragController.status==="active"&&this.syncDragTarget(i.x,i.y,s),this.dragFrame=requestAnimationFrame(this.runDragFrame)});this.dragController.addEventListener("change",this.onDragControllerChange),this.dragController.addEventListener("drag",this.onDragControllerDrag),this.dragController.addEventListener("drop",this.onDragControllerDrop),this.layoutScroll.addEventListener("layout-scroll",this.onLayoutScrollInternal)}set layout(n){this._layout=[...n],this.stopDragFrameLoop(),this.dragController.cancel(),this.scrollModelKey="",this.syncScrollModel(),this.layoutScroll.scroll=xe({x:this._scrollPosition}),this.scheduleRender()}get layout(){return this._layout}commitLayout(n){this.layout=n,this.emitLayoutChanged()}set scrollPosition(n){Math.abs(n-this._scrollPosition)<ji||(this.animateNextRender=!1,this.syncScrollModel(),this.layoutScroll.scroll=xe({x:n}))}get scrollPosition(){return this._scrollPosition}connectedCallback(){this.hasAttribute("tabindex")||(this.tabIndex=0),this.focus(),this.addEventListener("keydown",this.handleKeyDown),this.addEventListener("wheel",this.handleWheel,{passive:!1}),this.addEventListener("pointerdown",this.handlePointerDown),window.addEventListener("message",this.handleWindowMessage),typeof ResizeObserver<"u"&&(this.resizeObserver=new ResizeObserver(()=>this.render()),this.resizeObserver.observe(this)),this.render()}disconnectedCallback(){var n;this.removeEventListener("keydown",this.handleKeyDown),this.removeEventListener("wheel",this.handleWheel),this.removeEventListener("pointerdown",this.handlePointerDown),window.removeEventListener("message",this.handleWindowMessage),(n=this.resizeObserver)==null||n.disconnect(),this.resizeObserver=null,this.wheelGesture.reset(),this.detachDragListeners(),this.dragController.removeEventListener("change",this.onDragControllerChange),this.dragController.removeEventListener("drag",this.onDragControllerDrag),this.dragController.removeEventListener("drop",this.onDragControllerDrop),this.layoutScroll.removeEventListener("layout-scroll",this.onLayoutScrollInternal),this.dragController.dispose(),this.stopDragFrameLoop()}scheduleRender(){this.renderPending||(this.renderPending=!0,queueMicrotask(()=>{this.renderPending=!1,this.render()}))}createGrid(n,r){return new XR({basis:Se({x:kn,y:kn}),min:Se({x:Jh,y:Jh}),viewport:Se({x:n,y:r}),gap:Se({x:de,y:de})})}syncScrollModel(){const n=this.clientWidth>0?this.clientWidth:tn,r=this.clientHeight>0?this.clientHeight:vr,i=$s(this._layout).nodes.map(a=>a.width),o=`${n}x${r}:${i.join(",")}`;o===this.scrollModelKey&&this.layoutGrid||(this.scrollModelKey=o,this.layoutGrid=this.createGrid(n,r),this.layoutScroll.rebuild({grid:this.layoutGrid,nodeWidths:i.map(a=>xe({x:a}))}))}emitScrollPositionChanged(n){this.dispatchEvent(new LD(n))}emitLayoutChanged(){this.dispatchEvent(new Zm([...this._layout]))}shiftWindow(n){this.syncScrollModel(),this.animateNextRender=!0,this.layoutScroll.step(n)}applyHorizontalWheel(n){this.syncScrollModel();const r=this.layoutGrid;if(!r)return;this.animateNextRender=!1;const s=r.toUnits(Se({x:n}));this.layoutScroll.wheel(xe({x:s.x??0}))}findManagedArtifactFrame(n){if(!n)return null;const r=this.querySelectorAll("iframe.artifact-frame");for(const s of r)if(s.contentWindow===n)return s;return null}isTrustedArtifactFrameMessage(n,r){if(n.origin==="null")return!0;const s=this.getArtifactFrameOrigin(r);return s===null||n.origin===s}getArtifactFrameTargetOrigin(n){const r=n.getAttribute("sandbox")??"";return new Set(r.split(/\s+/).filter(Boolean)).has("allow-same-origin")?this.getArtifactFrameOrigin(n)??"*":"*"}getArtifactFrameOrigin(n){const r=n.getAttribute("src")??n.src;if(!r)return null;try{return new URL(r,window.location.href).origin}catch{return null}}releaseActiveDragPointerCapture(){this.activeDragPointerId!==null&&this.releasePointerCaptureForEvent(this.activeDragPointerId)}releasePointerCaptureForEvent(n){try{this.hasPointerCapture(n)&&this.releasePointerCapture(n)}catch{}}attachDragListeners(){this.dragListenersAttached||(window.addEventListener("pointermove",this.handleWindowPointerMove),window.addEventListener("pointerup",this.handleWindowPointerUp),window.addEventListener("pointercancel",this.handleWindowPointerCancel),this.addEventListener("pointermove",this.handleWindowPointerMove),this.addEventListener("pointerup",this.handleWindowPointerUp),this.addEventListener("pointercancel",this.handleWindowPointerCancel),window.addEventListener("blur",this.handleWindowBlur),this.dragListenersAttached=!0)}detachDragListeners(){this.dragListenersAttached&&(window.removeEventListener("pointermove",this.handleWindowPointerMove),window.removeEventListener("pointerup",this.handleWindowPointerUp),window.removeEventListener("pointercancel",this.handleWindowPointerCancel),this.removeEventListener("pointermove",this.handleWindowPointerMove),this.removeEventListener("pointerup",this.handleWindowPointerUp),this.removeEventListener("pointercancel",this.handleWindowPointerCancel),window.removeEventListener("blur",this.handleWindowBlur),this.dragListenersAttached=!1,this.activeDragPointerId=null)}getDisplayModel(){if(this.dragController.status!=="active"||!this.dragState)return{layout:this._layout,activePlaceholderId:null,placeholdersById:new Map};const n=new Map;return n.set(this.dragState.nodeId,{id:this.dragState.nodeId,sourceCardId:this.dragState.nodeId}),{layout:zd(this.dragState.projectedLayout),activePlaceholderId:this.dragState.nodeId,placeholdersById:n}}render(){const n=this.clientWidth>0?this.clientWidth:tn,r=this.clientHeight>0?this.clientHeight:vr,s=this.createGrid(n,r);this.layoutGrid=s;const i=this.getDisplayModel(),o=i.layout,a=this.dragController.status==="active",l=$s(o),c=l.nodes.map(L=>L.width),d=`${n}x${r}:${c.join(",")}`;!a&&d!==this.scrollModelKey&&(this.scrollModelKey=d,this.layoutScroll.rebuild({grid:s,nodeWidths:c.map(L=>xe({x:L}))}),this._scrollPosition=this.layoutScroll.scroll.x??this._scrollPosition);const p=ND(o),y=s.unit.x??kn,m=s.unit.y??kn,E=a?this.dragTrackOffsetXPx:0,k=(this.layoutScroll.translate.x??0)+E,I=Zd(l.nodes.length,s,r),G=this.animateNextRender&&!a,N=[`transform: translate(${k}px, ${I}px);`,`transition-duration: ${G?dE:0}ms;`,`pointer-events: ${a?"none":"auto"};`].join(" ");this.animateNextRender=!0,this.style.setProperty("--layout-unit-x",`${y}px`),this.style.setProperty("--layout-unit-y",`${m}px`),this.style.setProperty("--layout-gap",`${de}px`);const j=this.dragState,F={width:(j==null?void 0:j.size.x)??0,height:(j==null?void 0:j.size.y)??0};be(M`
|
|
152
|
+
`}render(){this._artifact&&(this.setAttribute("type",this._artifact.type),be(this.template(),this))}}customElements.define("artifact-view",JR);const Se=t=>({type:"px",...t}),xe=t=>({type:"unit",...t}),Zi=2,XR=2;class QR{constructor(e){v(this,"basis");v(this,"min");v(this,"_gap");v(this,"_viewport");v(this,"_unit");this.basis=e.basis,this.min=e.min,this._viewport=e.viewport,this._gap=e.gap??Se({x:de,y:de});const n=this._viewport.x??tn,r=this._viewport.y??vr,s=this._gap.x??de,i=this._gap.y??de,o=tn+s*XR,a=n<=o,l=a?n-s*Zi:Math.min(tn,n-s*Zi),c=a?r-i*Zi:Math.min(vr,r-i*Zi),d=(l-s*(St-1))/St,p=(c-i*(He-1))/He,y=this.basis.x??0,m=this.basis.y??0,E=this.min.x??0,k=this.min.y??0;this._unit=Se(a?{x:Math.max(E,d),y:Math.max(k,p)}:{x:Math.max(E,Math.min(y,d)),y:Math.max(k,Math.min(m,p))})}get unit(){return this._unit}get viewport(){return this._viewport}get gap(){return this._gap}toUnits(e){return xe({x:e.x==null?void 0:e.x/(this._unit.x??1),y:e.y==null?void 0:e.y/(this._unit.y??1)})}toPixels(e){const n=this._unit.x??0,r=this._unit.y??0,s=this._gap.x??de,i=this._gap.y??de,o=e.x==null?void 0:e.x*n+Math.max(0,e.x-1)*s,a=e.y==null?void 0:e.y*r+Math.max(0,e.y-1)*i;return Se({x:o,y:a})}}const Vn=1e-4,Nt=1e-6,eD=40,tD=24;function Lm(t,e){return Math.max(0,t-e*2)}function Mm(t){const e=[0];for(const n of t)e.push((e[e.length-1]??0)+n);return e}function Nm(t){const e=[0];for(let n=0;n<t.length;n+=1){const r=e[n]??0;e.push(r+t[n]+de)}return e}function Um(t,e,n){if(e<0||e>=t.length)return 0;let r=0,s=0;for(let i=e;i<t.length;i+=1){const o=t[i],a=s===0?o:r+de+o;if(a>n+Vn)break;r=a,s+=1}return Math.max(1,s)}function nD(t,e,n){if(e<0||e>=t.length)return 0;let r=0,s=0;for(let i=e;i>=0;i-=1){const o=t[i],a=s===0?o:r+de+o;if(a>n+Vn)break;r=a,s+=1}return Math.max(1,s)}function rD(t,e){if(t.length===0)return 0;let n=0,r=0;for(let s=t.length-1;s>=0;s-=1){const i=t[s],o=r===0?i:n+de+i;if(o>e+Vn)break;n=o,r+=1}return Math.max(1,r)}function Zc(t,e){if(t.length===0)return 0;const n=rD(t,e);return Math.max(0,t.length-n)}function Rd(t,e,n){if(t.length===0)return 0;const r=Um(t,e,n),s=Math.min(t.length,e+r);if(s<=e)return 0;const i=t.slice(e,s);return i.reduce((o,a)=>o+a,0)+Math.max(0,i.length-1)*de}function Ul(t,e,n){const r=t[e]??0;return n-r}function gr(t,e,n,r,s){if(t.length===0)return 0;const i=Zc(t,s),o=e[i]??0,a=Math.max(0,Math.min(o,n));let l=0;for(let L=0;L<i;L+=1){const J=e[L]??0,H=e[L+1]??J;if(a>=J&&a<=H+Vn){l=L;break}l=L+1}const c=Math.min(l+1,i),d=e[l]??0,p=e[c]??d,y=Math.max(p-d,Vn),m=c===l?0:(a-d)/y,E=Nm(t),k=Rd(t,l,s),I=Rd(t,c,s),G=(r-k)/2,N=(r-I)/2,j=Ul(E,l,G),F=Ul(E,c,N);return j+(F-j)*m}function Dd(t,e,n,r,s){const i=Zc(t,r),o=e[i]??0;let a=0,l=o;for(let c=0;c<eD;c+=1){const d=(a+l)/2;gr(t,e,d,n,r)>s?a=d:l=d}return(a+l)/2}function Od(t,e,n){const r=Nm(t),[s,i]=e,o=t.slice(s,i+1),a=o.reduce((c,d)=>c+d,0)+Math.max(0,o.length-1)*de,l=(n-a)/2;return Ul(r,s,l)}function sD(t,e,n){const r=Um(t,e,n);return[e,Math.min(t.length-1,e+r-1)]}function iD(t,e,n){const r=nD(t,e,n);return[Math.max(0,e-r+1),e]}function oD(t){const e=new Set,n=[];for(const r of t){const s=`${r.nodeRange[0]}:${r.nodeRange[1]}`;if(e.has(s))continue;const i=n[n.length-1];i&&Math.abs(i.anchor-r.anchor)<=Nt||(e.add(s),n.push(r))}return n}function aD(t){const{nodeCols:e,nodeWidthsPx:n,viewportWidthPx:r}=t;if(e.length===0||n.length===0)return{viewspans:[],minScroll:0,maxScroll:0};const s=t.gapPx??de,i=Lm(r,s),o=Mm(e),a=Zc(n,i),l=o[a]??0,c=[];for(let d=0;d<=a;d+=1){const p=sD(n,d,i),y=Od(n,p,r),m=Dd(n,o,r,i,y);c.push({nodeRange:p,anchor:Math.max(0,Math.min(l,m))})}for(let d=n.length-1;d>=0;d-=1){const p=iD(n,d,i),y=`${p[0]}:${p[1]}`;if(c.some(k=>`${k.nodeRange[0]}:${k.nodeRange[1]}`===y))continue;const m=Od(n,p,r),E=Dd(n,o,r,i,m);c.push({nodeRange:p,anchor:Math.max(0,Math.min(l,E))})}return c.sort((d,p)=>Math.abs(d.anchor-p.anchor)>Nt?d.anchor-p.anchor:d.nodeRange[0]!==p.nodeRange[0]?d.nodeRange[0]-p.nodeRange[0]:d.nodeRange[1]-p.nodeRange[1]),{viewspans:oD(c),minScroll:0,maxScroll:l}}function lD(t,e){var s;let n=0,r=Number.POSITIVE_INFINITY;for(let i=0;i<t.length;i+=1){const o=Math.abs((((s=t[i])==null?void 0:s.anchor)??0)-e);if(o+Nt<r){r=o,n=i;continue}Math.abs(o-r)<=Nt&&i<n&&(n=i)}return n}function cD(t,e,n){return n<=0?0:Math.max(0,Math.min(n-1,t+e))}function os(t,e,n){return Math.max(e,Math.min(n,t))}class uD extends kt{constructor(n){super();v(this,"_scroll",0);v(this,"minScroll",0);v(this,"maxScroll",0);v(this,"viewspans",[]);v(this,"activeViewspanIndex",null);v(this,"nodeWidthsPx",[]);v(this,"boundaryCols",[0]);v(this,"viewportWidthPx",0);v(this,"framedViewportWidthPx",0);this._scroll=(n==null?void 0:n.x)??0}get scroll(){return xe({x:this._scroll})}get translate(){return Se({x:gr(this.nodeWidthsPx,this.boundaryCols,this._scroll,this.viewportWidthPx,this.framedViewportWidthPx)})}set scroll(n){const r=os(n.x??this._scroll,this.minScroll,this.maxScroll);Math.abs(r-this._scroll)<=Nt||(this._scroll=r,this.activeViewspanIndex=null,this.dispatchEvent(new ss("layout-scroll",{scroll:this.scroll})))}rebuild(n){const r=n.nodeWidths.map(c=>Math.max(0,c.x??0)),s=r.map(c=>n.grid.toPixels(xe({x:c})).x??0),i=n.grid.viewport.x??0,o=n.grid.gap.x??de,a=aD({nodeCols:r,nodeWidthsPx:s,viewportWidthPx:i,gapPx:o});this.nodeWidthsPx=s,this.boundaryCols=Mm(r),this.viewportWidthPx=i,this.framedViewportWidthPx=Lm(i,o),this.viewspans=a.viewspans,this.minScroll=a.minScroll,this.maxScroll=a.maxScroll,this.activeViewspanIndex=null;const l=os(this._scroll,this.minScroll,this.maxScroll);Math.abs(l-this._scroll)>Nt&&(this._scroll=l,this.dispatchEvent(new ss("layout-scroll",{scroll:this.scroll})))}step(n){var a;if(this.viewspans.length===0)return;const r=this.activeViewspanIndex??lD(this.viewspans,this._scroll),s=cD(r,n,this.viewspans.length),i=((a=this.viewspans[s])==null?void 0:a.anchor)??this._scroll,o=os(i,this.minScroll,this.maxScroll);this.activeViewspanIndex=s,!(Math.abs(o-this._scroll)<=Nt)&&(this._scroll=o,this.dispatchEvent(new ss("layout-scroll",{scroll:this.scroll})))}wheel(n){const r=os(this._scroll+(n.x??0),this.minScroll,this.maxScroll);this.activeViewspanIndex=null,!(Math.abs(r-this._scroll)<=Nt)&&(this._scroll=r,this.dispatchEvent(new ss("layout-scroll",{scroll:this.scroll})))}wheelPixels(n){const r=n.x??0;if(Math.abs(r)<=Vn)return;this.activeViewspanIndex=null;const s=gr(this.nodeWidthsPx,this.boundaryCols,this._scroll,this.viewportWidthPx,this.framedViewportWidthPx),i=s-r,o=gr(this.nodeWidthsPx,this.boundaryCols,this.maxScroll,this.viewportWidthPx,this.framedViewportWidthPx),a=gr(this.nodeWidthsPx,this.boundaryCols,this.minScroll,this.viewportWidthPx,this.framedViewportWidthPx),l=Math.max(o,Math.min(a,i));if(Math.abs(l-s)<=Vn)return;let c=this.minScroll,d=this.maxScroll;for(let y=0;y<tD;y+=1){const m=(c+d)/2;gr(this.nodeWidthsPx,this.boundaryCols,m,this.viewportWidthPx,this.framedViewportWidthPx)>l?c=m:d=m}const p=os((c+d)/2,this.minScroll,this.maxScroll);Math.abs(p-this._scroll)<=Nt||(this._scroll=p,this.dispatchEvent(new ss("layout-scroll",{scroll:this.scroll})))}}const Ba={"stack-above":{left:.25,top:0,width:.5,height:.5},"stack-below":{left:.25,top:.5,width:.5,height:.5},"reorder-before":{left:0,top:0,width:.25,height:1},"reorder-after":{left:.75,top:0,width:.25,height:1}},hD=["stack-above","stack-below","reorder-before","reorder-after"];function Ga(t,e){return{left:t.left+t.width*e.left,top:t.top+t.height*e.top,width:t.width*e.width,height:t.height*e.height}}function bn(t,e,n){return t>=n.left&&t<n.left+n.width&&e>=n.top&&e<n.top+n.height}function jc(t,e){for(const n of t){if(n.type==="card"&&n.id===e)return n;if(n.type==="stack")for(const r of n.children){if(r.type==="card"&&r.id===e)return r;if(r.type==="row"){for(const s of r.children)if(s.id===e)return s}}}return null}function Fl(t){return t.height===He||t.height===sn?{...t,height:sn}:t}function Zl(t){return t.height===sn?{...t,height:He}:t}function dD(t,e,n,r){const s=t.findIndex(d=>d.type==="stack"&&d.id===e);if(s===-1)return t;const i=t[s];if(!i||i.type!=="stack")return t;const o=i.children.find(d=>d.type==="card"&&d.id===n);if(!o||o.type!=="card")return t;const a=i.children.filter(d=>d.id!==n);if(a.length===i.children.length||a.length<1)return t;const l=[...t];if(a.length===1){const[d]=a;l[s]=d.type==="card"?Zl(d):d}else l[s]={...i,children:a};const c=Math.max(0,Math.min(r,l.length));return l.splice(c,0,Zl(o)),l}const pD=et(),fD=et(),gD=50;function mD(t,e){if(t.type!==e.type)return!1;switch(t.type){case"reorder":return e.index===t.index;case"stack":return e.targetCardId===t.targetCardId&&e.position===t.position;case"stack-child-noop":return!0;case"stack-child-extract":return e.toIndex===t.toIndex;case"stack-child-reorder":return e.position===t.position;default:return!1}}function yi(t){return{id:t.id,type:"drop-target",width:t.width,height:t.height}}function zd(t){return t.map(yD)}function vD(t){return t.type==="drop-target"?{id:t.id,type:"card",artifactID:t.id,width:t.width,height:t.height}:t}function yD(t){return t.type==="drop-target"?{id:t.id,type:"card",artifactID:t.id,width:t.width,height:t.height}:t.type==="stack"?{...t,children:t.children.map(vD)}:t}function Fm(t,e){return t.find(r=>r.type==="card"&&r.id===e)??null}function Ld(t,e){return t.find(r=>r.type==="stack"&&r.id===e)??null}function bD(t,e){const n=[...e],r=n.findIndex(a=>a.type==="card"&&a.id===t.nodeId);if(r===-1)return null;const s=n[r];if(!s||s.type!=="card")return null;n.splice(r,1);const i=Math.max(0,Math.min(t.lastReorderIndex,n.length));n.splice(i,0,s);const o=n.findIndex(a=>a.type==="card"&&a.id===t.nodeId);return o===-1?null:{base:n,visualDraggedIndex:o}}function wD(t,e,n,r){const s=[...t.base];s.splice(t.visualDraggedIndex,1);const i=s.findIndex(y=>y.type==="card"&&y.id===n.targetCardId),o=i===-1?null:s[i];if(!o||o.type!=="card")return null;const a=Fm(r,e.nodeId);if(!a)return null;const l=Fl(a),c=Fl(o),d=yi(l),p=n.position==="above"?[d,c]:[c,d];return s[i]={id:o.id,type:"stack",children:p},s}function Va(t,e){return t.parentStackId?SD(t,e):_D(t,e)}function _D(t,e){const n=t.hitTarget;if(n.type==="reorder"){const r=e[t.sourceIndex];if(!r||r.type!=="card")return[...e];const s=[...e];return s.splice(t.sourceIndex,1),s.splice(n.index,0,yi(r)),s}if(n.type==="stack"){const r=bD(t,e);return r?wD(r,t,n,e)??[...e]:[...e]}return[...e]}function SD(t,e){const n=t.hitTarget;switch(n.type){case"stack-child-reorder":return kD(t,e,n.position);case"stack-child-extract":return ED(t,e,n.toIndex);case"stack-child-noop":return $D(t,e);default:return[...e]}}function kD(t,e,n){const r=e.findIndex(y=>y.type==="stack"&&y.id===t.parentStackId);if(r===-1)return[...e];const s=e[r];if(!s||s.type!=="stack")return[...e];if(!s.children.every(y=>y.type==="card"))return[...e];const i=s.children,o=i.findIndex(y=>y.id===t.nodeId);if(o===-1)return[...e];const a=i[o],l=i.filter(y=>y.id!==t.nodeId),c=yi(a),d=n==="above"?[c,...l]:[...l,c],p=[...e];return p[r]={...s,children:d},p}function ED(t,e,n){if(!t.parentStackId)return[...e];const r=dD(e,t.parentStackId,t.nodeId,n);if(r===e)return[...e];const s=r.findIndex(a=>a.type==="card"&&a.id===t.nodeId);if(s===-1)return[...e];const i=r[s];if(!i||i.type!=="card")return[...e];const o=[...r];return o[s]=yi(i),o}function $D(t,e){const n=e.findIndex(l=>l.type==="stack"&&l.id===t.parentStackId);if(n===-1)return[...e];const r=e[n];if(!r||r.type!=="stack")return[...e];const s=r.children.findIndex(l=>l.type==="card"&&l.id===t.nodeId);if(s===-1)return[...e];const i=r.children[s];if(!i||i.type!=="card")return[...e];const o=[...e],a=[...r.children];return a[s]=yi(i),o[n]={...r,children:a},o}function AD(t,e){return e.find(r=>r.type==="stack"&&r.id===t.id)?t.id:$c()}function xD(t,e,n){if(t.type==="drop-target"){const r=jc(e,n);if(!r)throw new Error(`finalize: missing dragged card ${n}`);return Fl(r)}return t}function TD(t,e,n){const r=t.children.map(i=>xD(i,e,n));return{id:AD(t,e),type:"stack",children:r}}function CD(t,e,n){if(t.type==="drop-target"){const r=jc(e,n);if(!r)throw new Error(`finalize: missing dragged card ${n}`);return Fm(e,n)!==null?r:Zl(r)}return t.type==="card"||t.type==="row"?t:TD(t,e,n)}function ID(t,e,n){return t.map(r=>CD(r,e,n))}function PD(t,e){return JSON.stringify(t)===JSON.stringify(e)}const RD=Hr(kt);class DD extends RD{constructor(n={}){super();v(this,"pending",null);v(this,"active",null)}start(n){if(this.pending||this.active)return;const r=n.pointer.x??0,s=n.pointer.y??0;this.pending={startX:r,startY:s,grabOffsetX:n.grabOffset.x??0,grabOffsetY:n.grabOffset.y??0,nodeId:n.nodeId,sourceIndex:n.source.index,parentStackId:n.source.parentId,width:n.size.x??0,height:n.size.y??0,baseLayout:n.layout}}update(n){const r=n.pointer.x??0,s=n.pointer.y??0,i=this.pending;if(i){const c=r-i.startX,d=s-i.startY;Math.hypot(c,d)>=fE&&(this.pending=null,this.active={...i,pointerX:r,pointerY:s,hitTarget:{type:"reorder",index:i.sourceIndex},lastReorderIndex:i.sourceIndex},this.emitDrag(),this.dispatchEvent(new te("change")));return}if(!this.active)return;const o=Va(this.active,this.active.baseLayout),a=this.getHitTargetForPointer(r,s,n,o),l=a.type==="reorder"?a.index:this.active.lastReorderIndex;this.active.pointerX===r&&this.active.pointerY===s&&mD(this.active.hitTarget,a)&&this.active.lastReorderIndex===l||(this.active={...this.active,pointerX:r,pointerY:s,hitTarget:a,lastReorderIndex:l},this.emitDrag(),this.dispatchEvent(new te("change")))}drop(){if(this.pending){this.cancel();return}if(!this.active)return;const n=this.active.baseLayout;let r=null;try{const s=Va(this.active,n),i=ID(s,n,this.active.nodeId);PD(i,n)||(r=i)}catch{r=null}this.reset(),r&&this.dispatchEvent(new fD("drop",{layout:r})),this.dispatchEvent(new te("change"))}cancel(){!this.pending&&!this.active||(this.reset(),this.dispatchEvent(new te("change")))}dispose(){this.reset()}get status(){return this.active?"active":this.pending?"pending":"idle"}reset(){this.pending=null,this.active=null}emitDrag(){if(!this.active)return;const n=Va(this.active,this.active.baseLayout);this.dispatchEvent(new pD("drag",{nodeId:this.active.nodeId,source:{index:this.active.sourceIndex,parentId:this.active.parentStackId},grabOffset:Se({x:this.active.grabOffsetX,y:this.active.grabOffsetY}),pointer:Se({x:this.active.pointerX,y:this.active.pointerY}),size:Se({x:this.active.width,y:this.active.height}),projectedLayout:n}))}getHitTargetForPointer(n,r,s,i){return this.active?this.isPointerInsideDragBounds(n,r,s.viewport)?this.active.parentStackId?this.getStackChildHitTarget(n,r,s,i):this.getTopLevelCardHitTarget(n,r,s,i):{type:"reorder",index:this.active.sourceIndex}:{type:"reorder",index:0}}getStackChildHitTarget(n,r,s,i){var c;if(!((c=this.active)!=null&&c.parentStackId))return{type:"stack-child-noop"};const o=this.getSourceStackInteractionRect(s.geometry);if(o&&bn(n,r,o)){const d=o.top+o.height/2;return{type:"stack-child-reorder",position:r<d?"above":"below"}}const a=this.getSourceRemainingSiblingRect(s.geometry);if(a&&bn(n,r,a)){const d=a.top+a.height/2;return{type:"stack-child-reorder",position:r<d?"above":"below"}}return{type:"stack-child-extract",toIndex:this.getTopLevelReorderIndexForPointer(n,r,s,i)}}getSourceRemainingSiblingRect(n){var i,o;if(!((i=this.active)!=null&&i.parentStackId))return;const r=Ld(this.active.baseLayout,this.active.parentStackId);if(!r)return;const s=r.children.find(a=>{var l;return a.type==="card"&&a.id!==((l=this.active)==null?void 0:l.nodeId)});if(s)return(o=n.find(a=>a.id===s.id))==null?void 0:o.rect}getSourceStackInteractionRect(n){var o;if(!((o=this.active)!=null&&o.parentStackId))return;const r=n.find(a=>{var l;return a.id===((l=this.active)==null?void 0:l.parentStackId)});if(r)return this.active.sourceStackRect=r.rect,r.rect;const s=Ld(this.active.baseLayout,this.active.parentStackId);if(!s)return this.active.sourceStackRect;const i=s.children.find(a=>{var l;return a.type==="card"&&a.id!==((l=this.active)==null?void 0:l.nodeId)});if(i){const a=n.find(l=>l.id===i.id);if(a)return a.rect}return this.active.sourceStackRect}getTopLevelCardHitTarget(n,r,s,i){var m,E,k;const o=this.getTopLevelZoneNodes(s.geometry,i);if(o.length===0)return{type:"reorder",index:((m=this.active)==null?void 0:m.sourceIndex)??0};const l=(s.effectiveVelocity??0)<=gD;for(const I of o){const G=I.rect;if(!bn(n,r,G))continue;const N=this.resolveTopLevelTargetForCard(n,r,I,I.logicalIndex,l);if(N)return N;if(!l&&((E=this.active)!=null&&E.hitTarget))return this.active.hitTarget}const c=this.getNearestTargetableZone(n,o);if(!c)return{type:"reorder",index:((k=this.active)==null?void 0:k.sourceIndex)??0};const d=Math.max(c.rect.left,Math.min(c.rect.left+c.rect.width,n)),p=this.resolveTopLevelTargetForCard(d,r,c,c.logicalIndex,l);if(p)return p;const y=c.rect.left+c.rect.width/2;return{type:"reorder",index:n<y?c.logicalIndex:c.logicalIndex+1}}getTopLevelReorderIndexForPointer(n,r,s,i){var c,d;const o=this.getTopLevelZoneNodes(s.geometry,i);if(o.length===0)return((c=this.active)==null?void 0:c.sourceIndex)??0;for(const p of o){if(!bn(n,r,p.rect))continue;const y=Ga(p.rect,Ba["reorder-before"]);if(bn(n,r,y))return p.logicalIndex;const m=Ga(p.rect,Ba["reorder-after"]);if(bn(n,r,m))return p.logicalIndex+1}const a=this.getNearestTargetableZone(n,o);if(!a)return((d=this.active)==null?void 0:d.sourceIndex)??0;const l=a.rect.left+a.rect.width/2;return n<l?a.logicalIndex:a.logicalIndex+1}getTopLevelZoneNodes(n,r){const s=new Map(r.map(a=>[a.id,a])),i=[];let o=0;for(const a of n){const l=s.get(a.id);l&&l.type!=="drop-target"&&(l.type==="card"||l.type==="stack")&&(i.push({id:l.id,rect:a.rect,logicalIndex:o}),o+=1)}return i}resolveTopLevelTargetForCard(n,r,s,i,o){const a=s.rect;for(const l of hD){if(!o&&(l==="stack-above"||l==="stack-below"))continue;const c=Ba[l],d=Ga(a,c);if(bn(n,r,d))return l==="stack-above"?{type:"stack",targetCardId:s.id,position:"above"}:l==="stack-below"?{type:"stack",targetCardId:s.id,position:"below"}:l==="reorder-before"?{type:"reorder",index:i}:{type:"reorder",index:i+1}}return null}getNearestTargetableZone(n,r){let s=null,i=Number.POSITIVE_INFINITY;for(const o of r){const a=o.rect.left,l=o.rect.left+o.rect.width,c=n<a?a-n:n>l?n-l:0;c<i&&(i=c,s=o)}return s}isPointerInsideDragBounds(n,r,s){return n>=s.left&&n<=s.left+s.width&&r>=s.top&&r<=s.top+s.height}}const Md=60,OD=80,Nd=.5,Ud=10;class zD{constructor(){v(this,"awaitingFreshWheelGesture",!1);v(this,"lastWheelEventAt",Number.NEGATIVE_INFINITY);v(this,"lastWheelDeltaX",0);v(this,"activeGestureType","none");v(this,"lastWheelGestureAt",Number.NEGATIVE_INFINITY)}markKeyboardNavigation(e){this.awaitingFreshWheelGesture=!0,this.lastWheelEventAt=e,this.activeGestureType="none"}reset(){this.awaitingFreshWheelGesture=!1,this.lastWheelEventAt=Number.NEGATIVE_INFINITY,this.lastWheelDeltaX=0,this.activeGestureType="none",this.lastWheelGestureAt=Number.NEGATIVE_INFINITY}decide(e){const{now:n,shiftKey:r,deltaX:s,deltaY:i,overArtifactContent:o}=e;n-this.lastWheelGestureAt>=Md&&(this.activeGestureType="none");const l=r&&i!==0,c=l?i:s,d=Math.abs(c),p=Math.abs(i);return this.activeGestureType==="vertical-artifact"&&o?d>=Nd&&d>=p*Ud?this.classifyHorizontal(n,c):(this.lastWheelGestureAt=n,{type:"scroll-native"}):this.activeGestureType==="horizontal-filmstrip"?!l&&o&&p>0&&p>=d*Ud?(this.activeGestureType="vertical-artifact",this.lastWheelGestureAt=n,{type:"scroll-native"}):this.classifyHorizontal(n,c):d<Nd?(o&&(this.activeGestureType="vertical-artifact"),this.lastWheelGestureAt=n,{type:"scroll-native"}):l||d>p?this.classifyHorizontal(n,c):p>d?(o&&(this.activeGestureType="vertical-artifact"),this.lastWheelGestureAt=n,{type:"scroll-native"}):o?(this.activeGestureType="vertical-artifact",this.lastWheelGestureAt=n,{type:"scroll-native"}):this.classifyHorizontal(n,c)}classifyHorizontal(e,n){const r=e-this.lastWheelEventAt,s=Math.sign(this.lastWheelDeltaX),i=Math.sign(n),o=s!==0&&i!==0&&s!==i,a=s!==0&&Math.abs(n)>=Math.abs(this.lastWheelDeltaX)+OD;return this.awaitingFreshWheelGesture&&r<Md&&!o&&!a?{type:"ignore"}:(this.lastWheelEventAt=e,this.lastWheelDeltaX=n,this.lastWheelGestureAt=e,this.awaitingFreshWheelGesture=!1,this.activeGestureType="horizontal-filmstrip",{type:"scroll-horizontal",horizontalDelta:n})}}const LD=2,Fd=1e3,ji=1e-4;function Zd(t,e,n){if(t===0)return 0;const r=e.toPixels(xe({y:He})).y??0;return(n-r)/LD}class MD extends Event{constructor(n){super("scroll",{bubbles:!0,composed:!0});v(this,"scrollPosition");this.scrollPosition=n}}class Zm extends Event{constructor(n){super("layout-change",{bubbles:!0,composed:!0});v(this,"layout");this.layout=n}}class ND extends HTMLElement{constructor(){super();v(this,"_layout",[]);v(this,"_scrollPosition",0);v(this,"layoutGrid",null);v(this,"layoutScroll",new uD(xe({x:0})));v(this,"scrollModelKey","");v(this,"resizeObserver",null);v(this,"renderPending",!1);v(this,"animateNextRender",!0);v(this,"wheelGesture",new zD);v(this,"dragController",new DD);v(this,"dragState",null);v(this,"activeDragPointerId",null);v(this,"dragListenersAttached",!1);v(this,"dragFrame",0);v(this,"lastDragFrameTime",0);v(this,"lastPointerX",0);v(this,"lastPointerY",0);v(this,"pointerVelocityPxPerSec",0);v(this,"scrollVelocityPxPerSec",0);v(this,"motionSampleTime",0);v(this,"motionSampleX",0);v(this,"motionSampleY",0);v(this,"dragTrackOffsetXPx",0);v(this,"previousProjectedLayoutForOffset",null);v(this,"renderContent",()=>M``);v(this,"onDragControllerChange",()=>{this.dragController.status==="idle"&&(this.dragState=null,this.dragTrackOffsetXPx=0,this.previousProjectedLayoutForOffset=null),this.scheduleRender()});v(this,"onDragControllerDrag",n=>{const r=zd(n.projectedLayout),s=this.shouldApplyTrackOffset(n.projectedLayout,n.source.parentId),i=n.source.parentId?this.getStackChildAnchorCardId(n.source.parentId,n.nodeId):null;this.dragTrackOffsetXPx=s?this.computeDragTrackOffset(this.previousProjectedLayoutForOffset,r,n.nodeId,n.source.parentId,i,this.dragTrackOffsetXPx):0,this.previousProjectedLayoutForOffset=r,this.dragState={nodeId:n.nodeId,source:n.source,grabOffset:n.grabOffset,pointer:n.pointer,size:n.size,projectedLayout:n.projectedLayout},this.scheduleRender()});v(this,"onDragControllerDrop",n=>{this.dragState=null,this.dragTrackOffsetXPx=0,this.previousProjectedLayoutForOffset=null,this.commitLayout(n.layout)});v(this,"onLayoutScrollInternal",n=>{const s=n.scroll.x??0;Math.abs(s-this._scrollPosition)<ji||(this._scrollPosition=s,this.emitScrollPositionChanged(s),this.scheduleRender())});v(this,"handleKeyDown",n=>{if(n.key==="Escape"&&this.dragController.status!=="idle"){n.preventDefault(),this.stopDragFrameLoop(),this.releaseActiveDragPointerCapture(),this.dragController.cancel(),this.detachDragListeners();return}this.dragController.status==="idle"&&(n.key==="ArrowRight"?(n.preventDefault(),this.wheelGesture.markKeyboardNavigation(Date.now()),this.shiftWindow(1)):n.key==="ArrowLeft"&&(n.preventDefault(),this.wheelGesture.markKeyboardNavigation(Date.now()),this.shiftWindow(-1)))});v(this,"handleWheel",n=>{if(this._layout.length===0)return;const r=this.wheelGesture.decide({now:Date.now(),shiftKey:n.shiftKey,deltaX:n.deltaX,deltaY:n.deltaY,overArtifactContent:!1});r.type==="scroll-horizontal"&&(n.preventDefault(),this.applyHorizontalWheel(r.horizontalDelta))});v(this,"handleWindowMessage",n=>{var o;if(this._layout.length===0)return;const r=this.findManagedArtifactFrame(n.source);if(!r||!this.isTrustedArtifactFrameMessage(n,r)||!EC(n.data))return;const s=this.wheelGesture.decide({now:Date.now(),shiftKey:n.data.shiftKey,deltaX:n.data.deltaX,deltaY:n.data.deltaY,overArtifactContent:!0});if(s.type==="scroll-horizontal"){this.applyHorizontalWheel(s.horizontalDelta);return}if(s.type!=="scroll-native")return;const i={type:"scroll",deltaX:0,deltaY:n.data.deltaY};(o=r.contentWindow)==null||o.postMessage(i,this.getArtifactFrameTargetOrigin(r))});v(this,"handlePointerDown",n=>{if(n.button!==0||this.dragController.status!=="idle")return;const r=n.target;if(!(r instanceof Element)||!r.closest("[drag-handle]")||r.closest("button, input, textarea, select, a, [role='button']"))return;const s=r.closest(".card-slot");if(!s)return;const i=s.getAttribute("data-layout-node-id");if(!i)return;const o=FD(this._layout,i);if(!o)return;const a=s.getBoundingClientRect();this.lastPointerX=n.clientX,this.lastPointerY=n.clientY,this.resetMotionTracking(n.clientX,n.clientY),this.focus(),this.dragController.start({nodeId:i,source:{index:o.topLevelIndex,parentId:o.sourceStackId},pointer:Se({x:n.clientX,y:n.clientY}),grabOffset:Se({x:n.clientX-a.left,y:n.clientY-a.top}),size:Se({x:a.width,y:a.height}),layout:this._layout}),this.attachDragListeners(),this.activeDragPointerId=n.pointerId;try{this.setPointerCapture(n.pointerId)}catch{}n.preventDefault()});v(this,"handleWindowPointerMove",n=>{this.lastPointerX=n.clientX,this.lastPointerY=n.clientY,this.updatePointerVelocity(n.clientX,n.clientY),this.syncDragTargetForLatestPointer(),this.ensureDragFrameLoop()});v(this,"handleWindowPointerUp",n=>{this.stopDragFrameLoop(),this.releasePointerCaptureForEvent(n.pointerId),this.dragController.drop(),this.clearMotionTracking(),this.detachDragListeners()});v(this,"handleWindowPointerCancel",n=>{this.stopDragFrameLoop(),this.releasePointerCaptureForEvent(n.pointerId),this.dragController.cancel(),this.clearMotionTracking(),this.detachDragListeners()});v(this,"handleWindowBlur",()=>{this.releaseActiveDragPointerCapture(),this.stopDragFrameLoop(),this.dragController.cancel(),this.clearMotionTracking(),this.detachDragListeners()});v(this,"runDragFrame",n=>{if(this.dragController.status==="idle"){this.dragFrame=0;return}const r=Math.max(0,n-this.lastDragFrameTime)/Fd;this.lastDragFrameTime=n,this.samplePointerVelocityAt(n,this.lastPointerX,this.lastPointerY);const s=this.getBoundingClientRect(),i=this.clampPointerToViewport(this.lastPointerX,this.lastPointerY,s),o=this.getDragEdgeScrollDeltaPixels(i.x,s,r);this.scrollVelocityPxPerSec=r>ji?Math.abs(o)/r:0,Math.abs(o)>ji&&(this.animateNextRender=!1,this.layoutScroll.wheelPixels(Se({x:o}))),this.dragController.status==="active"&&this.syncDragTarget(i.x,i.y,s),this.dragFrame=requestAnimationFrame(this.runDragFrame)});this.dragController.addEventListener("change",this.onDragControllerChange),this.dragController.addEventListener("drag",this.onDragControllerDrag),this.dragController.addEventListener("drop",this.onDragControllerDrop),this.layoutScroll.addEventListener("layout-scroll",this.onLayoutScrollInternal)}set layout(n){this._layout=[...n],this.stopDragFrameLoop(),this.dragController.cancel(),this.scrollModelKey="",this.syncScrollModel(),this.layoutScroll.scroll=xe({x:this._scrollPosition}),this.scheduleRender()}get layout(){return this._layout}commitLayout(n){this.layout=n,this.emitLayoutChanged()}set scrollPosition(n){Math.abs(n-this._scrollPosition)<ji||(this.animateNextRender=!1,this.syncScrollModel(),this.layoutScroll.scroll=xe({x:n}))}get scrollPosition(){return this._scrollPosition}connectedCallback(){this.hasAttribute("tabindex")||(this.tabIndex=0),this.focus(),this.addEventListener("keydown",this.handleKeyDown),this.addEventListener("wheel",this.handleWheel,{passive:!1}),this.addEventListener("pointerdown",this.handlePointerDown),window.addEventListener("message",this.handleWindowMessage),typeof ResizeObserver<"u"&&(this.resizeObserver=new ResizeObserver(()=>this.render()),this.resizeObserver.observe(this)),this.render()}disconnectedCallback(){var n;this.removeEventListener("keydown",this.handleKeyDown),this.removeEventListener("wheel",this.handleWheel),this.removeEventListener("pointerdown",this.handlePointerDown),window.removeEventListener("message",this.handleWindowMessage),(n=this.resizeObserver)==null||n.disconnect(),this.resizeObserver=null,this.wheelGesture.reset(),this.detachDragListeners(),this.dragController.removeEventListener("change",this.onDragControllerChange),this.dragController.removeEventListener("drag",this.onDragControllerDrag),this.dragController.removeEventListener("drop",this.onDragControllerDrop),this.layoutScroll.removeEventListener("layout-scroll",this.onLayoutScrollInternal),this.dragController.dispose(),this.stopDragFrameLoop()}scheduleRender(){this.renderPending||(this.renderPending=!0,queueMicrotask(()=>{this.renderPending=!1,this.render()}))}createGrid(n,r){return new QR({basis:Se({x:kn,y:kn}),min:Se({x:Jh,y:Jh}),viewport:Se({x:n,y:r}),gap:Se({x:de,y:de})})}syncScrollModel(){const n=this.clientWidth>0?this.clientWidth:tn,r=this.clientHeight>0?this.clientHeight:vr,i=$s(this._layout).nodes.map(a=>a.width),o=`${n}x${r}:${i.join(",")}`;o===this.scrollModelKey&&this.layoutGrid||(this.scrollModelKey=o,this.layoutGrid=this.createGrid(n,r),this.layoutScroll.rebuild({grid:this.layoutGrid,nodeWidths:i.map(a=>xe({x:a}))}))}emitScrollPositionChanged(n){this.dispatchEvent(new MD(n))}emitLayoutChanged(){this.dispatchEvent(new Zm([...this._layout]))}shiftWindow(n){this.syncScrollModel(),this.animateNextRender=!0,this.layoutScroll.step(n)}applyHorizontalWheel(n){this.syncScrollModel();const r=this.layoutGrid;if(!r)return;this.animateNextRender=!1;const s=r.toUnits(Se({x:n}));this.layoutScroll.wheel(xe({x:s.x??0}))}findManagedArtifactFrame(n){if(!n)return null;const r=this.querySelectorAll("iframe.artifact-frame");for(const s of r)if(s.contentWindow===n)return s;return null}isTrustedArtifactFrameMessage(n,r){if(n.origin==="null")return!0;const s=this.getArtifactFrameOrigin(r);return s===null||n.origin===s}getArtifactFrameTargetOrigin(n){const r=n.getAttribute("sandbox")??"";return new Set(r.split(/\s+/).filter(Boolean)).has("allow-same-origin")?this.getArtifactFrameOrigin(n)??"*":"*"}getArtifactFrameOrigin(n){const r=n.getAttribute("src")??n.src;if(!r)return null;try{return new URL(r,window.location.href).origin}catch{return null}}releaseActiveDragPointerCapture(){this.activeDragPointerId!==null&&this.releasePointerCaptureForEvent(this.activeDragPointerId)}releasePointerCaptureForEvent(n){try{this.hasPointerCapture(n)&&this.releasePointerCapture(n)}catch{}}attachDragListeners(){this.dragListenersAttached||(window.addEventListener("pointermove",this.handleWindowPointerMove),window.addEventListener("pointerup",this.handleWindowPointerUp),window.addEventListener("pointercancel",this.handleWindowPointerCancel),this.addEventListener("pointermove",this.handleWindowPointerMove),this.addEventListener("pointerup",this.handleWindowPointerUp),this.addEventListener("pointercancel",this.handleWindowPointerCancel),window.addEventListener("blur",this.handleWindowBlur),this.dragListenersAttached=!0)}detachDragListeners(){this.dragListenersAttached&&(window.removeEventListener("pointermove",this.handleWindowPointerMove),window.removeEventListener("pointerup",this.handleWindowPointerUp),window.removeEventListener("pointercancel",this.handleWindowPointerCancel),this.removeEventListener("pointermove",this.handleWindowPointerMove),this.removeEventListener("pointerup",this.handleWindowPointerUp),this.removeEventListener("pointercancel",this.handleWindowPointerCancel),window.removeEventListener("blur",this.handleWindowBlur),this.dragListenersAttached=!1,this.activeDragPointerId=null)}getDisplayModel(){if(this.dragController.status!=="active"||!this.dragState)return{layout:this._layout,activePlaceholderId:null,placeholdersById:new Map};const n=new Map;return n.set(this.dragState.nodeId,{id:this.dragState.nodeId,sourceCardId:this.dragState.nodeId}),{layout:zd(this.dragState.projectedLayout),activePlaceholderId:this.dragState.nodeId,placeholdersById:n}}render(){const n=this.clientWidth>0?this.clientWidth:tn,r=this.clientHeight>0?this.clientHeight:vr,s=this.createGrid(n,r);this.layoutGrid=s;const i=this.getDisplayModel(),o=i.layout,a=this.dragController.status==="active",l=$s(o),c=l.nodes.map(L=>L.width),d=`${n}x${r}:${c.join(",")}`;!a&&d!==this.scrollModelKey&&(this.scrollModelKey=d,this.layoutScroll.rebuild({grid:s,nodeWidths:c.map(L=>xe({x:L}))}),this._scrollPosition=this.layoutScroll.scroll.x??this._scrollPosition);const p=UD(o),y=s.unit.x??kn,m=s.unit.y??kn,E=a?this.dragTrackOffsetXPx:0,k=(this.layoutScroll.translate.x??0)+E,I=Zd(l.nodes.length,s,r),G=this.animateNextRender&&!a,N=[`transform: translate(${k}px, ${I}px);`,`transition-duration: ${G?pE:0}ms;`,`pointer-events: ${a?"none":"auto"};`].join(" ");this.animateNextRender=!0,this.style.setProperty("--layout-unit-x",`${y}px`),this.style.setProperty("--layout-unit-y",`${m}px`),this.style.setProperty("--layout-gap",`${de}px`);const j=this.dragState,F={width:(j==null?void 0:j.size.x)??0,height:(j==null?void 0:j.size.y)??0};be(M`
|
|
153
153
|
<div class="track" style=${N}>
|
|
154
154
|
${l.nodes.map((L,J)=>M`
|
|
155
155
|
<div
|
|
@@ -192,7 +192,7 @@ ${r.documentElement.outerHTML}`],{type:"text/html"});return URL.createObjectURL(
|
|
|
192
192
|
${this.renderDraggedPreview(j.nodeId)}
|
|
193
193
|
</div>
|
|
194
194
|
`})():null}
|
|
195
|
-
`,this)}ensureDragFrameLoop(){this.dragFrame!==0||this.dragController.status==="idle"||(this.lastDragFrameTime=performance.now(),this.dragFrame=requestAnimationFrame(this.runDragFrame))}stopDragFrameLoop(){this.dragFrame!==0&&(cancelAnimationFrame(this.dragFrame),this.dragFrame=0,this.scrollVelocityPxPerSec=0)}syncDragTargetForLatestPointer(){if(this.dragController.status==="idle")return;const n=this.getBoundingClientRect();if(this.dragController.status==="active"){const s=this.clampPointerToViewport(this.lastPointerX,this.lastPointerY,n);this.syncDragTarget(s.x,s.y,n);return}if(this.syncDragTarget(this.lastPointerX,this.lastPointerY,n),this.dragController.status==="pending")return;const r=this.clampPointerToViewport(this.lastPointerX,this.lastPointerY,n);(r.x!==this.lastPointerX||r.y!==this.lastPointerY)&&this.syncDragTarget(r.x,r.y,n)}syncDragTarget(n,r,s=this.getBoundingClientRect()){if(this.dragController.status==="idle")return;const i=this.getDisplayModel(),o=new Set(i.placeholdersById.keys()),a=this.dragController.status==="active"?this.dragTrackOffsetXPx:0,l=this.measureLayoutGeometry(i.layout,o,a);this.dragController.update({pointer:Se({x:n,y:r}),viewport:{left:s.left,top:s.top,width:s.width,height:s.height},geometry:l,effectiveVelocity:Math.max(this.pointerVelocityPxPerSec,this.scrollVelocityPxPerSec)})}resetMotionTracking(n,r){this.pointerVelocityPxPerSec=0,this.scrollVelocityPxPerSec=0,this.motionSampleTime=performance.now(),this.motionSampleX=n,this.motionSampleY=r}clearMotionTracking(){this.pointerVelocityPxPerSec=0,this.scrollVelocityPxPerSec=0,this.motionSampleTime=0}updatePointerVelocity(n,r){this.samplePointerVelocityAt(performance.now(),n,r)}samplePointerVelocityAt(n,r,s){if(this.motionSampleTime===0){this.motionSampleTime=n,this.motionSampleX=r,this.motionSampleY=s,this.pointerVelocityPxPerSec=0;return}const i=n-this.motionSampleTime;if(i<100)return;const o=r-this.motionSampleX;this.pointerVelocityPxPerSec=Math.abs(o)/i*Fd,this.motionSampleTime=n,this.motionSampleX=r,this.motionSampleY=s}clampPointerToViewport(n,r,s){return{x:Math.max(s.left,Math.min(s.left+s.width,n)),y:Math.max(s.top,Math.min(s.top+s.height,r))}}isPointerOutsideViewport(n,r,s){return n<s.left||n>s.left+s.width||r<s.top||r>s.top+s.height}getDragEdgeScrollDeltaPixels(n,r,s){var c;const i=r.left+Li,o=r.left+r.width-Li,a=((c=this.layoutGrid)==null?void 0:c.unit.x)??kn,l=
|
|
195
|
+
`,this)}ensureDragFrameLoop(){this.dragFrame!==0||this.dragController.status==="idle"||(this.lastDragFrameTime=performance.now(),this.dragFrame=requestAnimationFrame(this.runDragFrame))}stopDragFrameLoop(){this.dragFrame!==0&&(cancelAnimationFrame(this.dragFrame),this.dragFrame=0,this.scrollVelocityPxPerSec=0)}syncDragTargetForLatestPointer(){if(this.dragController.status==="idle")return;const n=this.getBoundingClientRect();if(this.dragController.status==="active"){const s=this.clampPointerToViewport(this.lastPointerX,this.lastPointerY,n);this.syncDragTarget(s.x,s.y,n);return}if(this.syncDragTarget(this.lastPointerX,this.lastPointerY,n),this.dragController.status==="pending")return;const r=this.clampPointerToViewport(this.lastPointerX,this.lastPointerY,n);(r.x!==this.lastPointerX||r.y!==this.lastPointerY)&&this.syncDragTarget(r.x,r.y,n)}syncDragTarget(n,r,s=this.getBoundingClientRect()){if(this.dragController.status==="idle")return;const i=this.getDisplayModel(),o=new Set(i.placeholdersById.keys()),a=this.dragController.status==="active"?this.dragTrackOffsetXPx:0,l=this.measureLayoutGeometry(i.layout,o,a);this.dragController.update({pointer:Se({x:n,y:r}),viewport:{left:s.left,top:s.top,width:s.width,height:s.height},geometry:l,effectiveVelocity:Math.max(this.pointerVelocityPxPerSec,this.scrollVelocityPxPerSec)})}resetMotionTracking(n,r){this.pointerVelocityPxPerSec=0,this.scrollVelocityPxPerSec=0,this.motionSampleTime=performance.now(),this.motionSampleX=n,this.motionSampleY=r}clearMotionTracking(){this.pointerVelocityPxPerSec=0,this.scrollVelocityPxPerSec=0,this.motionSampleTime=0}updatePointerVelocity(n,r){this.samplePointerVelocityAt(performance.now(),n,r)}samplePointerVelocityAt(n,r,s){if(this.motionSampleTime===0){this.motionSampleTime=n,this.motionSampleX=r,this.motionSampleY=s,this.pointerVelocityPxPerSec=0;return}const i=n-this.motionSampleTime;if(i<100)return;const o=r-this.motionSampleX;this.pointerVelocityPxPerSec=Math.abs(o)/i*Fd,this.motionSampleTime=n,this.motionSampleX=r,this.motionSampleY=s}clampPointerToViewport(n,r,s){return{x:Math.max(s.left,Math.min(s.left+s.width,n)),y:Math.max(s.top,Math.min(s.top+s.height,r))}}isPointerOutsideViewport(n,r,s){return n<s.left||n>s.left+s.width||r<s.top||r>s.top+s.height}getDragEdgeScrollDeltaPixels(n,r,s){var c;const i=r.left+Li,o=r.left+r.width-Li,a=((c=this.layoutGrid)==null?void 0:c.unit.x)??kn,l=gE*a;if(n<i){const d=Math.max(0,Math.min(1,(i-n)/Li));return-(l*d**Xh)*s}if(n>o){const d=Math.max(0,Math.min(1,(n-o)/Li));return l*d**Xh*s}return 0}measureLayoutGeometry(n,r,s=0){const i=this.layoutGrid;if(!i)return[];const o=$s(n),a=new Map(o.nodes.map(E=>[E.id,E.width])),l=i.toPixels(xe({y:He})).y??vr,c=this.clientHeight>0?this.clientHeight:vr,d=(this.layoutScroll.translate.x??0)+s,p=Zd(o.nodes.length,i,c),y=[];let m=d;for(const E of n){const k=a.get(E.id)??St,I=i.toPixels(xe({x:k})).x??tn,G={left:m,top:p,width:I,height:l};y.push({id:E.id,rect:G}),m+=I+de}return y}getPlaceholderPixelSize(n,r,s,i){if(!r)return i;for(const o of n.nodes)for(const a of o.cards)if(a.id===r)return{width:s.toPixels(xe({x:a.width})).x??i.width,height:s.toPixels(xe({y:a.height})).y??i.height};return i}renderDraggedPreview(n){const r=jc(this._layout,n);return r?this.renderContent(r,{isDragging:!0}):M``}shouldApplyTrackOffset(n,r){if(r)return!0;for(const s of n){if(s.type!=="stack")continue;if(s.children.some(o=>o.type==="drop-target")&&r!==s.id)return!0}return!1}computeDragTrackOffset(n,r,s,i,o,a){if(!n)return a;const l=i?o??this.getStableAnchorCardId(n,r,s):this.getStableAnchorNodeId(n,r,s);if(!l)return a;const c=i?Wd(n,l,this.layoutGrid):Bd(n,l,this.layoutGrid),d=i?Wd(r,l,this.layoutGrid):Bd(r,l,this.layoutGrid);return c===null||d===null?a:a+(c-d)}getStableAnchorCardId(n,r,s){const i=jd(n),o=new Set(jd(r));for(const a of i)if(a!==s&&o.has(a))return a;return null}getStableAnchorNodeId(n,r,s){const i=new Set(r.map(o=>o.id));for(const o of n)if(o.id!==s&&i.has(o.id))return o.id;return null}getStackChildAnchorCardId(n,r){const s=this._layout.find(o=>o.type==="stack"&&o.id===n);if(!s||s.type!=="stack")return null;const i=s.children.find(o=>o.type==="card"&&o.id!==r);return(i==null?void 0:i.id)??null}}function UD(t){const e=new Map;for(const n of t){if(n.type==="card"){e.set(n.id,n);continue}for(const r of n.children)if(r.type==="card")e.set(r.id,r);else for(const s of r.children)e.set(s.id,s)}return e}function FD(t,e){const n=t.findIndex(r=>r.type==="card"&&r.id===e);if(n!==-1)return{topLevelIndex:n};for(let r=0;r<t.length;r+=1){const s=t[r];if(!(!s||s.type!=="stack")&&s.children.some(i=>i.type==="card"&&i.id===e))return{topLevelIndex:r,sourceStackId:s.id}}return null}function jd(t){const e=[];for(const n of t){if(n.type==="card"){e.push(n.id);continue}if(n.type==="stack"){const r=n.children.find(s=>s.type==="card");r&&e.push(r.id)}}return e}function Wd(t,e,n){if(!n)return null;const r=$s(t),s=new Map(r.nodes.map(o=>[o.id,o.width]));let i=0;for(const o of t){if(o.type==="card"&&o.id===e||o.type==="stack"&&o.children.some(c=>c.type==="card"&&c.id===e))return i;const a=s.get(o.id)??St,l=n.toPixels(xe({x:a})).x??tn;i+=l+de}return null}function Bd(t,e,n){if(!n)return null;const r=$s(t),s=new Map(r.nodes.map(o=>[o.id,o.width]));let i=0;for(const o of t){if(o.id===e)return i;const a=s.get(o.id)??St,l=n.toPixels(xe({x:a})).x??tn;i+=l+de}return null}customElements.get("layout-view")||customElements.define("layout-view",ND);class ZD extends HTMLElement{constructor(){super(...arguments);v(this,"screenManager",Ve.resolve("ScreenManager"));v(this,"boundModel",null);v(this,"handleActiveScreenChanged",()=>{this.rebindModel(),this.render()});v(this,"handleModelChange",()=>{this.render()});v(this,"handleCloseArtifact",n=>{n instanceof zm&&this.screenManager.activeScreen&&this.screenManager.activeScreen.removeArtifact(n.artifactID)});v(this,"handleScrollPositionChanged",n=>{const r=n;typeof r.scrollPosition=="number"&&Number.isFinite(r.scrollPosition)&&this.screenManager.activeScreen&&this.screenManager.activeScreen.setScrollPosition(r.scrollPosition)});v(this,"handleLayoutChanged",n=>{n instanceof Zm&&this.screenManager.activeScreen&&this.screenManager.activeScreen.setLayout(n.layout)})}connectedCallback(){this.screenManager.addEventListener("active-screen-changed",this.handleActiveScreenChanged),this.rebindModel(),this.render()}disconnectedCallback(){this.screenManager.removeEventListener("active-screen-changed",this.handleActiveScreenChanged),this.unbindModel()}rebindModel(){const n=this.screenManager.activeScreen;this.boundModel!==n&&(this.unbindModel(),this.boundModel=n,n&&n.addEventListener("change",this.handleModelChange))}unbindModel(){this.boundModel&&(this.boundModel.removeEventListener("change",this.handleModelChange),this.boundModel=null)}buildArtifactMap(){const n=this.screenManager.activeScreen;return n?new Map(n.artifacts):new Map}render(){const n=this.screenManager.activeScreen,r=(n==null?void 0:n.layout)??[],s=this.buildArtifactMap();if(r.length===0){be(M`<p data-testid="empty-screen">No artifacts yet.</p>`,this);return}be(M`
|
|
196
196
|
<layout-view
|
|
197
197
|
.layout=${r}
|
|
198
198
|
.renderContent=${(o,a)=>{const l=s.get(o.artifactID);return!l||!n?M``:M`<artifact-view
|
|
@@ -207,12 +207,12 @@ ${r.documentElement.outerHTML}`],{type:"text/html"});return URL.createObjectURL(
|
|
|
207
207
|
@layout-change=${this.handleLayoutChanged}
|
|
208
208
|
@close-artifact=${this.handleCloseArtifact}
|
|
209
209
|
></layout-view>
|
|
210
|
-
`,this)}}customElements.define("screen-view",FD);const Ya=new WeakMap,Gd=Object.prototype.hasOwnProperty,ZD=(()=>{const t=new Set;let e=HTMLElement.prototype;for(;e;){for(const n of Object.getOwnPropertyNames(e))t.add(n);if(e===Node.prototype)break;e=Object.getPrototypeOf(e)}return t})();function jD(t,e){if(t===Boolean)return e!==null;if(e!==null)return t===Number?Number(e):e}var ni,Bl,Fn,Ye,wt,Ir,Zn,Pr,Ce,ws,jm,Wm,Bm,so;const An=class An extends HTMLElement{constructor(){var s;super();$(this,Ce);$(this,Fn,new Map);$(this,Ye,new Map);$(this,wt,new Map);$(this,Ir,!1);$(this,Zn,!1);$(this,Pr,!1);const n=b(s=An,ni,Bl).call(s,this.constructor),r=this;for(const i of n.properties)Gd.call(r,i)&&(u(this,wt).set(i,r[i]),delete r[i])}static get observedAttributes(){var n;return b(n=An,ni,Bl).call(n,this).observedAttributes}connected(){}disconnected(){}changed(n){}connectedCallback(){if(b(this,Ce,Bm).call(this),!u(this,Zn))for(const n of b(this,Ce,ws).call(this).properties)u(this,Ye).has(n)||u(this,Ye).set(n,void 0);this.dispatchEvent(new Event("reactive:connect")),this.connected(),b(this,Ce,so).call(this)}disconnectedCallback(){this.dispatchEvent(new Event("reactive:disconnect")),this.disconnected()}attributeChangedCallback(n,r,s){if(r===s)return;const i=b(this,Ce,ws).call(this).byAttr.get(n);i&&(u(this,wt).has(i.property)||(this[i.property]=jD(i.type,s)))}};ni=new WeakSet,Bl=function(n){const r=Ya.get(n);if(r)return r;const s=[...n.properties??[]],i=n.attributes??{},o=new Map,a=new Map;for(const c of s)if(ZD.has(c))throw new Error(`Reactive property "${c}" collides with a built-in DOM property. Rename it to avoid shadowing the platform API.`);for(const[c,d]of Object.entries(i)){if(c.includes("-")&&d.property===void 0)throw new Error(`Attribute "${c}" must declare a "property" name because kebab-case cannot be a property.`);const p=d.property??c;if(!s.includes(p))throw new Error(`Attribute '${c}' references property '${p}', which isn't declared in \`static properties\`. Add it to \`properties\` to make it reactive.`);const y={attribute:c,property:p,type:d.type};o.set(c,y),a.set(p,y)}for(const c of s){const d=Object.getOwnPropertyDescriptor(n.prototype,c);if((d==null?void 0:d.get)!==void 0||(d==null?void 0:d.set)!==void 0)throw new Error(`Observed property "${c}" cannot define a custom getter/setter. Use changed() for side effects instead.`);d===void 0&&Object.defineProperty(n.prototype,c,{configurable:!0,enumerable:!0,get(){return u(this,Fn).get(c)},set(p){b(this,Ce,jm).call(this,c,p)}})}const l={properties:s,observedAttributes:Object.keys(i),byAttr:o,byProp:a};return Ya.set(n,l),l},Fn=new WeakMap,Ye=new WeakMap,wt=new WeakMap,Ir=new WeakMap,Zn=new WeakMap,Pr=new WeakMap,Ce=new WeakSet,ws=function(){return Ya.get(this.constructor)},jm=function(n,r){if(!u(this,Pr)&&u(this,wt).has(n))return;const s=u(this,Fn).get(n);Object.is(s,r)||(u(this,Ye).has(n)||u(this,Ye).set(n,s),u(this,Fn).set(n,r),u(this,wt).delete(n),b(this,Ce,Wm).call(this,n,r),this.isConnected&&b(this,Ce,so).call(this))},Wm=function(n,r){const s=b(this,Ce,ws).call(this).byProp.get(n);if(!s)return;const{attribute:i,type:o}=s;if(o===Boolean){const l=this.hasAttribute(i);r&&!l?this.setAttribute(i,""):!r&&l&&this.removeAttribute(i);return}if(r==null){this.hasAttribute(i)&&this.removeAttribute(i);return}const a=String(r);this.getAttribute(i)!==a&&this.setAttribute(i,a)},Bm=function(){const n=this,r=b(this,Ce,ws).call(this);for(const s of r.properties){if(!Gd.call(n,s))continue;const i=n[s];delete n[s],!(u(this,wt).has(s)||u(this,Fn).has(s))&&(n[s]=i)}x(this,Pr,!0);try{for(const[s,i]of u(this,wt))n[s]=i;u(this,wt).clear()}finally{x(this,Pr,!1)}},so=function(){u(this,Ir)||!this.isConnected||u(this,Zn)&&u(this,Ye).size===0||(x(this,Ir,!0),queueMicrotask(()=>{if(x(this,Ir,!1),!this.isConnected||u(this,Zn)&&u(this,Ye).size===0)return;const n=new Map(u(this,Ye));u(this,Ye).clear(),x(this,Zn,!0);try{this.changed(n)}catch(r){console.error(r)}this.isConnected&&u(this,Ye).size>0&&b(this,Ce,so).call(this)}))},$(An,ni),v(An,"properties"),v(An,"attributes");let Rs=An;function WD(t,e){let n=null;const r=()=>e((n==null?void 0:n.messages)??[]),s=()=>{const o=t.getActiveClient();o!==n&&(n==null||n.removeEventListener("change",r),n=o,n&&(n.addEventListener("change",r),n.connect().catch(a=>{console.error("ACPClient.connect() failed",a)})),r())};t.addEventListener("change",s),s();const i=()=>{t.removeEventListener("change",s),n==null||n.removeEventListener("change",r),n=null};return{dispose:i,[Symbol.dispose](){i()}}}/*! @license DOMPurify 3.3.3 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.3.3/LICENSE */const{entries:Gm,setPrototypeOf:Vd,isFrozen:BD,getPrototypeOf:GD,getOwnPropertyDescriptor:VD}=Object;let{freeze:ze,seal:Xe,create:io}=Object,{apply:Gl,construct:Vl}=typeof Reflect<"u"&&Reflect;ze||(ze=function(e){return e});Xe||(Xe=function(e){return e});Gl||(Gl=function(e,n){for(var r=arguments.length,s=new Array(r>2?r-2:0),i=2;i<r;i++)s[i-2]=arguments[i];return e.apply(n,s)});Vl||(Vl=function(e){for(var n=arguments.length,r=new Array(n>1?n-1:0),s=1;s<n;s++)r[s-1]=arguments[s];return new e(...r)});const Wi=Le(Array.prototype.forEach),HD=Le(Array.prototype.lastIndexOf),Hd=Le(Array.prototype.pop),as=Le(Array.prototype.push),qD=Le(Array.prototype.splice),oo=Le(String.prototype.toLowerCase),Ka=Le(String.prototype.toString),Ja=Le(String.prototype.match),ls=Le(String.prototype.replace),YD=Le(String.prototype.indexOf),KD=Le(String.prototype.trim),Ge=Le(Object.prototype.hasOwnProperty),Pe=Le(RegExp.prototype.test),cs=JD(TypeError);function Le(t){return function(e){e instanceof RegExp&&(e.lastIndex=0);for(var n=arguments.length,r=new Array(n>1?n-1:0),s=1;s<n;s++)r[s-1]=arguments[s];return Gl(t,e,r)}}function JD(t){return function(){for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];return Vl(t,n)}}function W(t,e){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:oo;Vd&&Vd(t,null);let r=e.length;for(;r--;){let s=e[r];if(typeof s=="string"){const i=n(s);i!==s&&(BD(e)||(e[r]=i),s=i)}t[s]=!0}return t}function XD(t){for(let e=0;e<t.length;e++)Ge(t,e)||(t[e]=null);return t}function ft(t){const e=io(null);for(const[n,r]of Gm(t))Ge(t,n)&&(Array.isArray(r)?e[n]=XD(r):r&&typeof r=="object"&&r.constructor===Object?e[n]=ft(r):e[n]=r);return e}function us(t,e){for(;t!==null;){const r=VD(t,e);if(r){if(r.get)return Le(r.get);if(typeof r.value=="function")return Le(r.value)}t=GD(t)}function n(){return null}return n}const qd=ze(["a","abbr","acronym","address","area","article","aside","audio","b","bdi","bdo","big","blink","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","content","data","datalist","dd","decorator","del","details","dfn","dialog","dir","div","dl","dt","element","em","fieldset","figcaption","figure","font","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","img","input","ins","kbd","label","legend","li","main","map","mark","marquee","menu","menuitem","meter","nav","nobr","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","search","section","select","shadow","slot","small","source","spacer","span","strike","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","tr","track","tt","u","ul","var","video","wbr"]),Xa=ze(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","enterkeyhint","exportparts","filter","font","g","glyph","glyphref","hkern","image","inputmode","line","lineargradient","marker","mask","metadata","mpath","part","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),Qa=ze(["feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence"]),QD=ze(["animate","color-profile","cursor","discard","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignobject","hatch","hatchpath","mesh","meshgradient","meshpatch","meshrow","missing-glyph","script","set","solidcolor","unknown","use"]),el=ze(["math","menclose","merror","mfenced","mfrac","mglyph","mi","mlabeledtr","mmultiscripts","mn","mo","mover","mpadded","mphantom","mroot","mrow","ms","mspace","msqrt","mstyle","msub","msup","msubsup","mtable","mtd","mtext","mtr","munder","munderover","mprescripts"]),eO=ze(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),Yd=ze(["#text"]),Kd=ze(["accept","action","align","alt","autocapitalize","autocomplete","autopictureinpicture","autoplay","background","bgcolor","border","capture","cellpadding","cellspacing","checked","cite","class","clear","color","cols","colspan","controls","controlslist","coords","crossorigin","datetime","decoding","default","dir","disabled","disablepictureinpicture","disableremoteplayback","download","draggable","enctype","enterkeyhint","exportparts","face","for","headers","height","hidden","high","href","hreflang","id","inert","inputmode","integrity","ismap","kind","label","lang","list","loading","loop","low","max","maxlength","media","method","min","minlength","multiple","muted","name","nonce","noshade","novalidate","nowrap","open","optimum","part","pattern","placeholder","playsinline","popover","popovertarget","popovertargetaction","poster","preload","pubdate","radiogroup","readonly","rel","required","rev","reversed","role","rows","rowspan","spellcheck","scope","selected","shape","size","sizes","slot","span","srclang","start","src","srcset","step","style","summary","tabindex","title","translate","type","usemap","valign","value","width","wrap","xmlns","slot"]),tl=ze(["accent-height","accumulate","additive","alignment-baseline","amplitude","ascent","attributename","attributetype","azimuth","basefrequency","baseline-shift","begin","bias","by","class","clip","clippathunits","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","cx","cy","d","dx","dy","diffuseconstant","direction","display","divisor","dur","edgemode","elevation","end","exponent","fill","fill-opacity","fill-rule","filter","filterunits","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","fx","fy","g1","g2","glyph-name","glyphref","gradientunits","gradienttransform","height","href","id","image-rendering","in","in2","intercept","k","k1","k2","k3","k4","kerning","keypoints","keysplines","keytimes","lang","lengthadjust","letter-spacing","kernelmatrix","kernelunitlength","lighting-color","local","marker-end","marker-mid","marker-start","markerheight","markerunits","markerwidth","maskcontentunits","maskunits","max","mask","mask-type","media","method","mode","min","name","numoctaves","offset","operator","opacity","order","orient","orientation","origin","overflow","paint-order","path","pathlength","patterncontentunits","patterntransform","patternunits","points","preservealpha","preserveaspectratio","primitiveunits","r","rx","ry","radius","refx","refy","repeatcount","repeatdur","restart","result","rotate","scale","seed","shape-rendering","slope","specularconstant","specularexponent","spreadmethod","startoffset","stddeviation","stitchtiles","stop-color","stop-opacity","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke","stroke-width","style","surfacescale","systemlanguage","tabindex","tablevalues","targetx","targety","transform","transform-origin","text-anchor","text-decoration","text-rendering","textlength","type","u1","u2","unicode","values","viewbox","visibility","version","vert-adv-y","vert-origin-x","vert-origin-y","width","word-spacing","wrap","writing-mode","xchannelselector","ychannelselector","x","x1","x2","xmlns","y","y1","y2","z","zoomandpan"]),Jd=ze(["accent","accentunder","align","bevelled","close","columnsalign","columnlines","columnspan","denomalign","depth","dir","display","displaystyle","encoding","fence","frame","height","href","id","largeop","length","linethickness","lspace","lquote","mathbackground","mathcolor","mathsize","mathvariant","maxsize","minsize","movablelimits","notation","numalign","open","rowalign","rowlines","rowspacing","rowspan","rspace","rquote","scriptlevel","scriptminsize","scriptsizemultiplier","selection","separator","separators","stretchy","subscriptshift","supscriptshift","symmetric","voffset","width","xmlns"]),Bi=ze(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),tO=Xe(/\{\{[\w\W]*|[\w\W]*\}\}/gm),nO=Xe(/<%[\w\W]*|[\w\W]*%>/gm),rO=Xe(/\$\{[\w\W]*/gm),sO=Xe(/^data-[\-\w.\u00B7-\uFFFF]+$/),iO=Xe(/^aria-[\-\w]+$/),Vm=Xe(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),oO=Xe(/^(?:\w+script|data):/i),aO=Xe(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),Hm=Xe(/^html$/i),lO=Xe(/^[a-z][.\w]*(-[.\w]+)+$/i);var Xd=Object.freeze({__proto__:null,ARIA_ATTR:iO,ATTR_WHITESPACE:aO,CUSTOM_ELEMENT:lO,DATA_ATTR:sO,DOCTYPE_NAME:Hm,ERB_EXPR:nO,IS_ALLOWED_URI:Vm,IS_SCRIPT_OR_DATA:oO,MUSTACHE_EXPR:tO,TMPLIT_EXPR:rO});const hs={element:1,text:3,progressingInstruction:7,comment:8,document:9},cO=function(){return typeof window>"u"?null:window},uO=function(e,n){if(typeof e!="object"||typeof e.createPolicy!="function")return null;let r=null;const s="data-tt-policy-suffix";n&&n.hasAttribute(s)&&(r=n.getAttribute(s));const i="dompurify"+(r?"#"+r:"");try{return e.createPolicy(i,{createHTML(o){return o},createScriptURL(o){return o}})}catch{return console.warn("TrustedTypes policy "+i+" could not be created."),null}},Qd=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}};function qm(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:cO();const e=z=>qm(z);if(e.version="3.3.3",e.removed=[],!t||!t.document||t.document.nodeType!==hs.document||!t.Element)return e.isSupported=!1,e;let{document:n}=t;const r=n,s=r.currentScript,{DocumentFragment:i,HTMLTemplateElement:o,Node:a,Element:l,NodeFilter:c,NamedNodeMap:d=t.NamedNodeMap||t.MozNamedAttrMap,HTMLFormElement:p,DOMParser:y,trustedTypes:m}=t,E=l.prototype,k=us(E,"cloneNode"),I=us(E,"remove"),G=us(E,"nextSibling"),N=us(E,"childNodes"),j=us(E,"parentNode");if(typeof o=="function"){const z=n.createElement("template");z.content&&z.content.ownerDocument&&(n=z.content.ownerDocument)}let F,L="";const{implementation:J,createNodeIterator:H,createDocumentFragment:he,getElementsByTagName:lt}=n,{importNode:wi}=r;let Ee=Qd();e.isSupported=typeof Gm=="function"&&typeof j=="function"&&J&&J.createHTMLDocument!==void 0;const{MUSTACHE_EXPR:gn,ERB_EXPR:ct,TMPLIT_EXPR:Wt,DATA_ATTR:ea,ARIA_ATTR:_i,IS_SCRIPT_OR_DATA:mv,ATTR_WHITESPACE:nu,CUSTOM_ELEMENT:vv}=Xd;let{IS_ALLOWED_URI:ru}=Xd,we=null;const su=W({},[...qd,...Xa,...Qa,...el,...Yd]);let $e=null;const iu=W({},[...Kd,...tl,...Jd,...Bi]);let pe=Object.seal(io(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),Xr=null,Si=null;const Bt=Object.seal(io(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let ou=!0,ta=!0,au=!1,lu=!0,Qn=!1,ki=!0,mn=!1,na=!1,ra=!1,er=!1,Ei=!1,$i=!1,cu=!0,uu=!1;const yv="user-content-";let sa=!0,Qr=!1,tr={},ut=null;const ia=W({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","style","svg","template","thead","title","video","xmp"]);let hu=null;const du=W({},["audio","video","img","source","image","track"]);let oa=null;const pu=W({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),Ai="http://www.w3.org/1998/Math/MathML",xi="http://www.w3.org/2000/svg",Et="http://www.w3.org/1999/xhtml";let nr=Et,aa=!1,la=null;const bv=W({},[Ai,xi,Et],Ka);let Ti=W({},["mi","mo","mn","ms","mtext"]),Ci=W({},["annotation-xml"]);const wv=W({},["title","style","font","a","script"]);let es=null;const _v=["application/xhtml+xml","text/html"],Sv="text/html";let ve=null,rr=null;const kv=n.createElement("form"),fu=function(g){return g instanceof RegExp||g instanceof Function},ca=function(){let g=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(!(rr&&rr===g)){if((!g||typeof g!="object")&&(g={}),g=ft(g),es=_v.indexOf(g.PARSER_MEDIA_TYPE)===-1?Sv:g.PARSER_MEDIA_TYPE,ve=es==="application/xhtml+xml"?Ka:oo,we=Ge(g,"ALLOWED_TAGS")?W({},g.ALLOWED_TAGS,ve):su,$e=Ge(g,"ALLOWED_ATTR")?W({},g.ALLOWED_ATTR,ve):iu,la=Ge(g,"ALLOWED_NAMESPACES")?W({},g.ALLOWED_NAMESPACES,Ka):bv,oa=Ge(g,"ADD_URI_SAFE_ATTR")?W(ft(pu),g.ADD_URI_SAFE_ATTR,ve):pu,hu=Ge(g,"ADD_DATA_URI_TAGS")?W(ft(du),g.ADD_DATA_URI_TAGS,ve):du,ut=Ge(g,"FORBID_CONTENTS")?W({},g.FORBID_CONTENTS,ve):ia,Xr=Ge(g,"FORBID_TAGS")?W({},g.FORBID_TAGS,ve):ft({}),Si=Ge(g,"FORBID_ATTR")?W({},g.FORBID_ATTR,ve):ft({}),tr=Ge(g,"USE_PROFILES")?g.USE_PROFILES:!1,ou=g.ALLOW_ARIA_ATTR!==!1,ta=g.ALLOW_DATA_ATTR!==!1,au=g.ALLOW_UNKNOWN_PROTOCOLS||!1,lu=g.ALLOW_SELF_CLOSE_IN_ATTR!==!1,Qn=g.SAFE_FOR_TEMPLATES||!1,ki=g.SAFE_FOR_XML!==!1,mn=g.WHOLE_DOCUMENT||!1,er=g.RETURN_DOM||!1,Ei=g.RETURN_DOM_FRAGMENT||!1,$i=g.RETURN_TRUSTED_TYPE||!1,ra=g.FORCE_BODY||!1,cu=g.SANITIZE_DOM!==!1,uu=g.SANITIZE_NAMED_PROPS||!1,sa=g.KEEP_CONTENT!==!1,Qr=g.IN_PLACE||!1,ru=g.ALLOWED_URI_REGEXP||Vm,nr=g.NAMESPACE||Et,Ti=g.MATHML_TEXT_INTEGRATION_POINTS||Ti,Ci=g.HTML_INTEGRATION_POINTS||Ci,pe=g.CUSTOM_ELEMENT_HANDLING||{},g.CUSTOM_ELEMENT_HANDLING&&fu(g.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(pe.tagNameCheck=g.CUSTOM_ELEMENT_HANDLING.tagNameCheck),g.CUSTOM_ELEMENT_HANDLING&&fu(g.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(pe.attributeNameCheck=g.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),g.CUSTOM_ELEMENT_HANDLING&&typeof g.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements=="boolean"&&(pe.allowCustomizedBuiltInElements=g.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),Qn&&(ta=!1),Ei&&(er=!0),tr&&(we=W({},Yd),$e=io(null),tr.html===!0&&(W(we,qd),W($e,Kd)),tr.svg===!0&&(W(we,Xa),W($e,tl),W($e,Bi)),tr.svgFilters===!0&&(W(we,Qa),W($e,tl),W($e,Bi)),tr.mathMl===!0&&(W(we,el),W($e,Jd),W($e,Bi))),Ge(g,"ADD_TAGS")||(Bt.tagCheck=null),Ge(g,"ADD_ATTR")||(Bt.attributeCheck=null),g.ADD_TAGS&&(typeof g.ADD_TAGS=="function"?Bt.tagCheck=g.ADD_TAGS:(we===su&&(we=ft(we)),W(we,g.ADD_TAGS,ve))),g.ADD_ATTR&&(typeof g.ADD_ATTR=="function"?Bt.attributeCheck=g.ADD_ATTR:($e===iu&&($e=ft($e)),W($e,g.ADD_ATTR,ve))),g.ADD_URI_SAFE_ATTR&&W(oa,g.ADD_URI_SAFE_ATTR,ve),g.FORBID_CONTENTS&&(ut===ia&&(ut=ft(ut)),W(ut,g.FORBID_CONTENTS,ve)),g.ADD_FORBID_CONTENTS&&(ut===ia&&(ut=ft(ut)),W(ut,g.ADD_FORBID_CONTENTS,ve)),sa&&(we["#text"]=!0),mn&&W(we,["html","head","body"]),we.table&&(W(we,["tbody"]),delete Xr.tbody),g.TRUSTED_TYPES_POLICY){if(typeof g.TRUSTED_TYPES_POLICY.createHTML!="function")throw cs('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof g.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw cs('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');F=g.TRUSTED_TYPES_POLICY,L=F.createHTML("")}else F===void 0&&(F=uO(m,s)),F!==null&&typeof L=="string"&&(L=F.createHTML(""));ze&&ze(g),rr=g}},gu=W({},[...Xa,...Qa,...QD]),mu=W({},[...el,...eO]),Ev=function(g){let T=j(g);(!T||!T.tagName)&&(T={namespaceURI:nr,tagName:"template"});const P=oo(g.tagName),se=oo(T.tagName);return la[g.namespaceURI]?g.namespaceURI===xi?T.namespaceURI===Et?P==="svg":T.namespaceURI===Ai?P==="svg"&&(se==="annotation-xml"||Ti[se]):!!gu[P]:g.namespaceURI===Ai?T.namespaceURI===Et?P==="math":T.namespaceURI===xi?P==="math"&&Ci[se]:!!mu[P]:g.namespaceURI===Et?T.namespaceURI===xi&&!Ci[se]||T.namespaceURI===Ai&&!Ti[se]?!1:!mu[P]&&(wv[P]||!gu[P]):!!(es==="application/xhtml+xml"&&la[g.namespaceURI]):!1},ht=function(g){as(e.removed,{element:g});try{j(g).removeChild(g)}catch{I(g)}},vn=function(g,T){try{as(e.removed,{attribute:T.getAttributeNode(g),from:T})}catch{as(e.removed,{attribute:null,from:T})}if(T.removeAttribute(g),g==="is")if(er||Ei)try{ht(T)}catch{}else try{T.setAttribute(g,"")}catch{}},vu=function(g){let T=null,P=null;if(ra)g="<remove></remove>"+g;else{const fe=Ja(g,/^[\r\n\t ]+/);P=fe&&fe[0]}es==="application/xhtml+xml"&&nr===Et&&(g='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+g+"</body></html>");const se=F?F.createHTML(g):g;if(nr===Et)try{T=new y().parseFromString(se,es)}catch{}if(!T||!T.documentElement){T=J.createDocument(nr,"template",null);try{T.documentElement.innerHTML=aa?L:se}catch{}}const Ie=T.body||T.documentElement;return g&&P&&Ie.insertBefore(n.createTextNode(P),Ie.childNodes[0]||null),nr===Et?lt.call(T,mn?"html":"body")[0]:mn?T.documentElement:Ie},yu=function(g){return H.call(g.ownerDocument||g,g,c.SHOW_ELEMENT|c.SHOW_COMMENT|c.SHOW_TEXT|c.SHOW_PROCESSING_INSTRUCTION|c.SHOW_CDATA_SECTION,null)},ua=function(g){return g instanceof p&&(typeof g.nodeName!="string"||typeof g.textContent!="string"||typeof g.removeChild!="function"||!(g.attributes instanceof d)||typeof g.removeAttribute!="function"||typeof g.setAttribute!="function"||typeof g.namespaceURI!="string"||typeof g.insertBefore!="function"||typeof g.hasChildNodes!="function")},bu=function(g){return typeof a=="function"&&g instanceof a};function $t(z,g,T){Wi(z,P=>{P.call(e,g,T,rr)})}const wu=function(g){let T=null;if($t(Ee.beforeSanitizeElements,g,null),ua(g))return ht(g),!0;const P=ve(g.nodeName);if($t(Ee.uponSanitizeElement,g,{tagName:P,allowedTags:we}),ki&&g.hasChildNodes()&&!bu(g.firstElementChild)&&Pe(/<[/\w!]/g,g.innerHTML)&&Pe(/<[/\w!]/g,g.textContent)||g.nodeType===hs.progressingInstruction||ki&&g.nodeType===hs.comment&&Pe(/<[/\w]/g,g.data))return ht(g),!0;if(!(Bt.tagCheck instanceof Function&&Bt.tagCheck(P))&&(!we[P]||Xr[P])){if(!Xr[P]&&Su(P)&&(pe.tagNameCheck instanceof RegExp&&Pe(pe.tagNameCheck,P)||pe.tagNameCheck instanceof Function&&pe.tagNameCheck(P)))return!1;if(sa&&!ut[P]){const se=j(g)||g.parentNode,Ie=N(g)||g.childNodes;if(Ie&&se){const fe=Ie.length;for(let Me=fe-1;Me>=0;--Me){const At=k(Ie[Me],!0);At.__removalCount=(g.__removalCount||0)+1,se.insertBefore(At,G(g))}}}return ht(g),!0}return g instanceof l&&!Ev(g)||(P==="noscript"||P==="noembed"||P==="noframes")&&Pe(/<\/no(script|embed|frames)/i,g.innerHTML)?(ht(g),!0):(Qn&&g.nodeType===hs.text&&(T=g.textContent,Wi([gn,ct,Wt],se=>{T=ls(T,se," ")}),g.textContent!==T&&(as(e.removed,{element:g.cloneNode()}),g.textContent=T)),$t(Ee.afterSanitizeElements,g,null),!1)},_u=function(g,T,P){if(Si[T]||cu&&(T==="id"||T==="name")&&(P in n||P in kv))return!1;if(!(ta&&!Si[T]&&Pe(ea,T))){if(!(ou&&Pe(_i,T))){if(!(Bt.attributeCheck instanceof Function&&Bt.attributeCheck(T,g))){if(!$e[T]||Si[T]){if(!(Su(g)&&(pe.tagNameCheck instanceof RegExp&&Pe(pe.tagNameCheck,g)||pe.tagNameCheck instanceof Function&&pe.tagNameCheck(g))&&(pe.attributeNameCheck instanceof RegExp&&Pe(pe.attributeNameCheck,T)||pe.attributeNameCheck instanceof Function&&pe.attributeNameCheck(T,g))||T==="is"&&pe.allowCustomizedBuiltInElements&&(pe.tagNameCheck instanceof RegExp&&Pe(pe.tagNameCheck,P)||pe.tagNameCheck instanceof Function&&pe.tagNameCheck(P))))return!1}else if(!oa[T]){if(!Pe(ru,ls(P,nu,""))){if(!((T==="src"||T==="xlink:href"||T==="href")&&g!=="script"&&YD(P,"data:")===0&&hu[g])){if(!(au&&!Pe(mv,ls(P,nu,"")))){if(P)return!1}}}}}}}return!0},Su=function(g){return g!=="annotation-xml"&&Ja(g,vv)},ku=function(g){$t(Ee.beforeSanitizeAttributes,g,null);const{attributes:T}=g;if(!T||ua(g))return;const P={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:$e,forceKeepAttr:void 0};let se=T.length;for(;se--;){const Ie=T[se],{name:fe,namespaceURI:Me,value:At}=Ie,sr=ve(fe),ha=At;let Ae=fe==="value"?ha:KD(ha);if(P.attrName=sr,P.attrValue=Ae,P.keepAttr=!0,P.forceKeepAttr=void 0,$t(Ee.uponSanitizeAttribute,g,P),Ae=P.attrValue,uu&&(sr==="id"||sr==="name")&&(vn(fe,g),Ae=yv+Ae),ki&&Pe(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,Ae)){vn(fe,g);continue}if(sr==="attributename"&&Ja(Ae,"href")){vn(fe,g);continue}if(P.forceKeepAttr)continue;if(!P.keepAttr){vn(fe,g);continue}if(!lu&&Pe(/\/>/i,Ae)){vn(fe,g);continue}Qn&&Wi([gn,ct,Wt],$u=>{Ae=ls(Ae,$u," ")});const Eu=ve(g.nodeName);if(!_u(Eu,sr,Ae)){vn(fe,g);continue}if(F&&typeof m=="object"&&typeof m.getAttributeType=="function"&&!Me)switch(m.getAttributeType(Eu,sr)){case"TrustedHTML":{Ae=F.createHTML(Ae);break}case"TrustedScriptURL":{Ae=F.createScriptURL(Ae);break}}if(Ae!==ha)try{Me?g.setAttributeNS(Me,fe,Ae):g.setAttribute(fe,Ae),ua(g)?ht(g):Hd(e.removed)}catch{vn(fe,g)}}$t(Ee.afterSanitizeAttributes,g,null)},$v=function z(g){let T=null;const P=yu(g);for($t(Ee.beforeSanitizeShadowDOM,g,null);T=P.nextNode();)$t(Ee.uponSanitizeShadowNode,T,null),wu(T),ku(T),T.content instanceof i&&z(T.content);$t(Ee.afterSanitizeShadowDOM,g,null)};return e.sanitize=function(z){let g=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},T=null,P=null,se=null,Ie=null;if(aa=!z,aa&&(z="<!-->"),typeof z!="string"&&!bu(z))if(typeof z.toString=="function"){if(z=z.toString(),typeof z!="string")throw cs("dirty is not a string, aborting")}else throw cs("toString is not a function");if(!e.isSupported)return z;if(na||ca(g),e.removed=[],typeof z=="string"&&(Qr=!1),Qr){if(z.nodeName){const At=ve(z.nodeName);if(!we[At]||Xr[At])throw cs("root node is forbidden and cannot be sanitized in-place")}}else if(z instanceof a)T=vu("<!---->"),P=T.ownerDocument.importNode(z,!0),P.nodeType===hs.element&&P.nodeName==="BODY"||P.nodeName==="HTML"?T=P:T.appendChild(P);else{if(!er&&!Qn&&!mn&&z.indexOf("<")===-1)return F&&$i?F.createHTML(z):z;if(T=vu(z),!T)return er?null:$i?L:""}T&&ra&&ht(T.firstChild);const fe=yu(Qr?z:T);for(;se=fe.nextNode();)wu(se),ku(se),se.content instanceof i&&$v(se.content);if(Qr)return z;if(er){if(Ei)for(Ie=he.call(T.ownerDocument);T.firstChild;)Ie.appendChild(T.firstChild);else Ie=T;return($e.shadowroot||$e.shadowrootmode)&&(Ie=wi.call(r,Ie,!0)),Ie}let Me=mn?T.outerHTML:T.innerHTML;return mn&&we["!doctype"]&&T.ownerDocument&&T.ownerDocument.doctype&&T.ownerDocument.doctype.name&&Pe(Hm,T.ownerDocument.doctype.name)&&(Me="<!DOCTYPE "+T.ownerDocument.doctype.name+`>
|
|
211
|
-
`+Me),Qn&&Wi([gn,ct,Wt],At=>{Me=ls(Me,At," ")}),F&&$i?F.createHTML(Me):Me},e.setConfig=function(){let z=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};ca(z),na=!0},e.clearConfig=function(){rr=null,na=!1},e.isValidAttribute=function(z,g,T){rr||ca({});const P=ve(z),se=ve(g);return
|
|
212
|
-
]`).replace("lheading",Xm).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()}
|
|
210
|
+
`,this)}}customElements.define("screen-view",ZD);const Ha=new WeakMap,Gd=Object.prototype.hasOwnProperty,jD=(()=>{const t=new Set;let e=HTMLElement.prototype;for(;e;){for(const n of Object.getOwnPropertyNames(e))t.add(n);if(e===Node.prototype)break;e=Object.getPrototypeOf(e)}return t})();function WD(t,e){if(t===Boolean)return e!==null;if(e!==null)return t===Number?Number(e):e}var ni,jl,Fn,Ye,wt,Ir,Zn,Pr,Ce,ws,jm,Wm,Bm,so;const An=class An extends HTMLElement{constructor(){var s;super();$(this,Ce);$(this,Fn,new Map);$(this,Ye,new Map);$(this,wt,new Map);$(this,Ir,!1);$(this,Zn,!1);$(this,Pr,!1);const n=b(s=An,ni,jl).call(s,this.constructor),r=this;for(const i of n.properties)Gd.call(r,i)&&(u(this,wt).set(i,r[i]),delete r[i])}static get observedAttributes(){var n;return b(n=An,ni,jl).call(n,this).observedAttributes}connected(){}disconnected(){}changed(n){}connectedCallback(){if(b(this,Ce,Bm).call(this),!u(this,Zn))for(const n of b(this,Ce,ws).call(this).properties)u(this,Ye).has(n)||u(this,Ye).set(n,void 0);this.dispatchEvent(new Event("reactive:connect")),this.connected(),b(this,Ce,so).call(this)}disconnectedCallback(){this.dispatchEvent(new Event("reactive:disconnect")),this.disconnected()}attributeChangedCallback(n,r,s){if(r===s)return;const i=b(this,Ce,ws).call(this).byAttr.get(n);i&&(u(this,wt).has(i.property)||(this[i.property]=WD(i.type,s)))}};ni=new WeakSet,jl=function(n){const r=Ha.get(n);if(r)return r;const s=[...n.properties??[]],i=n.attributes??{},o=new Map,a=new Map;for(const c of s)if(jD.has(c))throw new Error(`Reactive property "${c}" collides with a built-in DOM property. Rename it to avoid shadowing the platform API.`);for(const[c,d]of Object.entries(i)){if(c.includes("-")&&d.property===void 0)throw new Error(`Attribute "${c}" must declare a "property" name because kebab-case cannot be a property.`);const p=d.property??c;if(!s.includes(p))throw new Error(`Attribute '${c}' references property '${p}', which isn't declared in \`static properties\`. Add it to \`properties\` to make it reactive.`);const y={attribute:c,property:p,type:d.type};o.set(c,y),a.set(p,y)}for(const c of s){const d=Object.getOwnPropertyDescriptor(n.prototype,c);if((d==null?void 0:d.get)!==void 0||(d==null?void 0:d.set)!==void 0)throw new Error(`Observed property "${c}" cannot define a custom getter/setter. Use changed() for side effects instead.`);d===void 0&&Object.defineProperty(n.prototype,c,{configurable:!0,enumerable:!0,get(){return u(this,Fn).get(c)},set(p){b(this,Ce,jm).call(this,c,p)}})}const l={properties:s,observedAttributes:Object.keys(i),byAttr:o,byProp:a};return Ha.set(n,l),l},Fn=new WeakMap,Ye=new WeakMap,wt=new WeakMap,Ir=new WeakMap,Zn=new WeakMap,Pr=new WeakMap,Ce=new WeakSet,ws=function(){return Ha.get(this.constructor)},jm=function(n,r){if(!u(this,Pr)&&u(this,wt).has(n))return;const s=u(this,Fn).get(n);Object.is(s,r)||(u(this,Ye).has(n)||u(this,Ye).set(n,s),u(this,Fn).set(n,r),u(this,wt).delete(n),b(this,Ce,Wm).call(this,n,r),this.isConnected&&b(this,Ce,so).call(this))},Wm=function(n,r){const s=b(this,Ce,ws).call(this).byProp.get(n);if(!s)return;const{attribute:i,type:o}=s;if(o===Boolean){const l=this.hasAttribute(i);r&&!l?this.setAttribute(i,""):!r&&l&&this.removeAttribute(i);return}if(r==null){this.hasAttribute(i)&&this.removeAttribute(i);return}const a=String(r);this.getAttribute(i)!==a&&this.setAttribute(i,a)},Bm=function(){const n=this,r=b(this,Ce,ws).call(this);for(const s of r.properties){if(!Gd.call(n,s))continue;const i=n[s];delete n[s],!(u(this,wt).has(s)||u(this,Fn).has(s))&&(n[s]=i)}x(this,Pr,!0);try{for(const[s,i]of u(this,wt))n[s]=i;u(this,wt).clear()}finally{x(this,Pr,!1)}},so=function(){u(this,Ir)||!this.isConnected||u(this,Zn)&&u(this,Ye).size===0||(x(this,Ir,!0),queueMicrotask(()=>{if(x(this,Ir,!1),!this.isConnected||u(this,Zn)&&u(this,Ye).size===0)return;const n=new Map(u(this,Ye));u(this,Ye).clear(),x(this,Zn,!0);try{this.changed(n)}catch(r){console.error(r)}this.isConnected&&u(this,Ye).size>0&&b(this,Ce,so).call(this)}))},$(An,ni),v(An,"properties"),v(An,"attributes");let Rs=An;function BD(t,e){let n=null;const r=()=>e((n==null?void 0:n.messages)??[]),s=()=>{const o=t.getActiveClient();o!==n&&(n==null||n.removeEventListener("change",r),n=o,n&&(n.addEventListener("change",r),n.connect().catch(a=>{console.error("ACPClient.connect() failed",a)})),r())};t.addEventListener("change",s),s();const i=()=>{t.removeEventListener("change",s),n==null||n.removeEventListener("change",r),n=null};return{dispose:i,[Symbol.dispose](){i()}}}/*! @license DOMPurify 3.3.3 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.3.3/LICENSE */const{entries:Gm,setPrototypeOf:Vd,isFrozen:GD,getPrototypeOf:VD,getOwnPropertyDescriptor:HD}=Object;let{freeze:ze,seal:Xe,create:io}=Object,{apply:Wl,construct:Bl}=typeof Reflect<"u"&&Reflect;ze||(ze=function(e){return e});Xe||(Xe=function(e){return e});Wl||(Wl=function(e,n){for(var r=arguments.length,s=new Array(r>2?r-2:0),i=2;i<r;i++)s[i-2]=arguments[i];return e.apply(n,s)});Bl||(Bl=function(e){for(var n=arguments.length,r=new Array(n>1?n-1:0),s=1;s<n;s++)r[s-1]=arguments[s];return new e(...r)});const Wi=Le(Array.prototype.forEach),qD=Le(Array.prototype.lastIndexOf),Hd=Le(Array.prototype.pop),as=Le(Array.prototype.push),YD=Le(Array.prototype.splice),oo=Le(String.prototype.toLowerCase),qa=Le(String.prototype.toString),Ya=Le(String.prototype.match),ls=Le(String.prototype.replace),KD=Le(String.prototype.indexOf),JD=Le(String.prototype.trim),Ge=Le(Object.prototype.hasOwnProperty),Pe=Le(RegExp.prototype.test),cs=XD(TypeError);function Le(t){return function(e){e instanceof RegExp&&(e.lastIndex=0);for(var n=arguments.length,r=new Array(n>1?n-1:0),s=1;s<n;s++)r[s-1]=arguments[s];return Wl(t,e,r)}}function XD(t){return function(){for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];return Bl(t,n)}}function W(t,e){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:oo;Vd&&Vd(t,null);let r=e.length;for(;r--;){let s=e[r];if(typeof s=="string"){const i=n(s);i!==s&&(GD(e)||(e[r]=i),s=i)}t[s]=!0}return t}function QD(t){for(let e=0;e<t.length;e++)Ge(t,e)||(t[e]=null);return t}function ft(t){const e=io(null);for(const[n,r]of Gm(t))Ge(t,n)&&(Array.isArray(r)?e[n]=QD(r):r&&typeof r=="object"&&r.constructor===Object?e[n]=ft(r):e[n]=r);return e}function us(t,e){for(;t!==null;){const r=HD(t,e);if(r){if(r.get)return Le(r.get);if(typeof r.value=="function")return Le(r.value)}t=VD(t)}function n(){return null}return n}const qd=ze(["a","abbr","acronym","address","area","article","aside","audio","b","bdi","bdo","big","blink","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","content","data","datalist","dd","decorator","del","details","dfn","dialog","dir","div","dl","dt","element","em","fieldset","figcaption","figure","font","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","img","input","ins","kbd","label","legend","li","main","map","mark","marquee","menu","menuitem","meter","nav","nobr","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","search","section","select","shadow","slot","small","source","spacer","span","strike","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","tr","track","tt","u","ul","var","video","wbr"]),Ka=ze(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","enterkeyhint","exportparts","filter","font","g","glyph","glyphref","hkern","image","inputmode","line","lineargradient","marker","mask","metadata","mpath","part","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),Ja=ze(["feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence"]),eO=ze(["animate","color-profile","cursor","discard","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignobject","hatch","hatchpath","mesh","meshgradient","meshpatch","meshrow","missing-glyph","script","set","solidcolor","unknown","use"]),Xa=ze(["math","menclose","merror","mfenced","mfrac","mglyph","mi","mlabeledtr","mmultiscripts","mn","mo","mover","mpadded","mphantom","mroot","mrow","ms","mspace","msqrt","mstyle","msub","msup","msubsup","mtable","mtd","mtext","mtr","munder","munderover","mprescripts"]),tO=ze(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),Yd=ze(["#text"]),Kd=ze(["accept","action","align","alt","autocapitalize","autocomplete","autopictureinpicture","autoplay","background","bgcolor","border","capture","cellpadding","cellspacing","checked","cite","class","clear","color","cols","colspan","controls","controlslist","coords","crossorigin","datetime","decoding","default","dir","disabled","disablepictureinpicture","disableremoteplayback","download","draggable","enctype","enterkeyhint","exportparts","face","for","headers","height","hidden","high","href","hreflang","id","inert","inputmode","integrity","ismap","kind","label","lang","list","loading","loop","low","max","maxlength","media","method","min","minlength","multiple","muted","name","nonce","noshade","novalidate","nowrap","open","optimum","part","pattern","placeholder","playsinline","popover","popovertarget","popovertargetaction","poster","preload","pubdate","radiogroup","readonly","rel","required","rev","reversed","role","rows","rowspan","spellcheck","scope","selected","shape","size","sizes","slot","span","srclang","start","src","srcset","step","style","summary","tabindex","title","translate","type","usemap","valign","value","width","wrap","xmlns","slot"]),Qa=ze(["accent-height","accumulate","additive","alignment-baseline","amplitude","ascent","attributename","attributetype","azimuth","basefrequency","baseline-shift","begin","bias","by","class","clip","clippathunits","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","cx","cy","d","dx","dy","diffuseconstant","direction","display","divisor","dur","edgemode","elevation","end","exponent","fill","fill-opacity","fill-rule","filter","filterunits","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","fx","fy","g1","g2","glyph-name","glyphref","gradientunits","gradienttransform","height","href","id","image-rendering","in","in2","intercept","k","k1","k2","k3","k4","kerning","keypoints","keysplines","keytimes","lang","lengthadjust","letter-spacing","kernelmatrix","kernelunitlength","lighting-color","local","marker-end","marker-mid","marker-start","markerheight","markerunits","markerwidth","maskcontentunits","maskunits","max","mask","mask-type","media","method","mode","min","name","numoctaves","offset","operator","opacity","order","orient","orientation","origin","overflow","paint-order","path","pathlength","patterncontentunits","patterntransform","patternunits","points","preservealpha","preserveaspectratio","primitiveunits","r","rx","ry","radius","refx","refy","repeatcount","repeatdur","restart","result","rotate","scale","seed","shape-rendering","slope","specularconstant","specularexponent","spreadmethod","startoffset","stddeviation","stitchtiles","stop-color","stop-opacity","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke","stroke-width","style","surfacescale","systemlanguage","tabindex","tablevalues","targetx","targety","transform","transform-origin","text-anchor","text-decoration","text-rendering","textlength","type","u1","u2","unicode","values","viewbox","visibility","version","vert-adv-y","vert-origin-x","vert-origin-y","width","word-spacing","wrap","writing-mode","xchannelselector","ychannelselector","x","x1","x2","xmlns","y","y1","y2","z","zoomandpan"]),Jd=ze(["accent","accentunder","align","bevelled","close","columnsalign","columnlines","columnspan","denomalign","depth","dir","display","displaystyle","encoding","fence","frame","height","href","id","largeop","length","linethickness","lspace","lquote","mathbackground","mathcolor","mathsize","mathvariant","maxsize","minsize","movablelimits","notation","numalign","open","rowalign","rowlines","rowspacing","rowspan","rspace","rquote","scriptlevel","scriptminsize","scriptsizemultiplier","selection","separator","separators","stretchy","subscriptshift","supscriptshift","symmetric","voffset","width","xmlns"]),Bi=ze(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),nO=Xe(/\{\{[\w\W]*|[\w\W]*\}\}/gm),rO=Xe(/<%[\w\W]*|[\w\W]*%>/gm),sO=Xe(/\$\{[\w\W]*/gm),iO=Xe(/^data-[\-\w.\u00B7-\uFFFF]+$/),oO=Xe(/^aria-[\-\w]+$/),Vm=Xe(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),aO=Xe(/^(?:\w+script|data):/i),lO=Xe(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),Hm=Xe(/^html$/i),cO=Xe(/^[a-z][.\w]*(-[.\w]+)+$/i);var Xd=Object.freeze({__proto__:null,ARIA_ATTR:oO,ATTR_WHITESPACE:lO,CUSTOM_ELEMENT:cO,DATA_ATTR:iO,DOCTYPE_NAME:Hm,ERB_EXPR:rO,IS_ALLOWED_URI:Vm,IS_SCRIPT_OR_DATA:aO,MUSTACHE_EXPR:nO,TMPLIT_EXPR:sO});const hs={element:1,text:3,progressingInstruction:7,comment:8,document:9},uO=function(){return typeof window>"u"?null:window},hO=function(e,n){if(typeof e!="object"||typeof e.createPolicy!="function")return null;let r=null;const s="data-tt-policy-suffix";n&&n.hasAttribute(s)&&(r=n.getAttribute(s));const i="dompurify"+(r?"#"+r:"");try{return e.createPolicy(i,{createHTML(o){return o},createScriptURL(o){return o}})}catch{return console.warn("TrustedTypes policy "+i+" could not be created."),null}},Qd=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}};function qm(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:uO();const e=z=>qm(z);if(e.version="3.3.3",e.removed=[],!t||!t.document||t.document.nodeType!==hs.document||!t.Element)return e.isSupported=!1,e;let{document:n}=t;const r=n,s=r.currentScript,{DocumentFragment:i,HTMLTemplateElement:o,Node:a,Element:l,NodeFilter:c,NamedNodeMap:d=t.NamedNodeMap||t.MozNamedAttrMap,HTMLFormElement:p,DOMParser:y,trustedTypes:m}=t,E=l.prototype,k=us(E,"cloneNode"),I=us(E,"remove"),G=us(E,"nextSibling"),N=us(E,"childNodes"),j=us(E,"parentNode");if(typeof o=="function"){const z=n.createElement("template");z.content&&z.content.ownerDocument&&(n=z.content.ownerDocument)}let F,L="";const{implementation:J,createNodeIterator:H,createDocumentFragment:he,getElementsByTagName:lt}=n,{importNode:wi}=r;let Ee=Qd();e.isSupported=typeof Gm=="function"&&typeof j=="function"&&J&&J.createHTMLDocument!==void 0;const{MUSTACHE_EXPR:gn,ERB_EXPR:ct,TMPLIT_EXPR:Wt,DATA_ATTR:ea,ARIA_ATTR:_i,IS_SCRIPT_OR_DATA:mv,ATTR_WHITESPACE:eu,CUSTOM_ELEMENT:vv}=Xd;let{IS_ALLOWED_URI:tu}=Xd,we=null;const nu=W({},[...qd,...Ka,...Ja,...Xa,...Yd]);let $e=null;const ru=W({},[...Kd,...Qa,...Jd,...Bi]);let pe=Object.seal(io(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),Xr=null,Si=null;const Bt=Object.seal(io(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let su=!0,ta=!0,iu=!1,ou=!0,Qn=!1,ki=!0,mn=!1,na=!1,ra=!1,er=!1,Ei=!1,$i=!1,au=!0,lu=!1;const yv="user-content-";let sa=!0,Qr=!1,tr={},ut=null;const ia=W({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","style","svg","template","thead","title","video","xmp"]);let cu=null;const uu=W({},["audio","video","img","source","image","track"]);let oa=null;const hu=W({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),Ai="http://www.w3.org/1998/Math/MathML",xi="http://www.w3.org/2000/svg",Et="http://www.w3.org/1999/xhtml";let nr=Et,aa=!1,la=null;const bv=W({},[Ai,xi,Et],qa);let Ti=W({},["mi","mo","mn","ms","mtext"]),Ci=W({},["annotation-xml"]);const wv=W({},["title","style","font","a","script"]);let es=null;const _v=["application/xhtml+xml","text/html"],Sv="text/html";let ve=null,rr=null;const kv=n.createElement("form"),du=function(g){return g instanceof RegExp||g instanceof Function},ca=function(){let g=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(!(rr&&rr===g)){if((!g||typeof g!="object")&&(g={}),g=ft(g),es=_v.indexOf(g.PARSER_MEDIA_TYPE)===-1?Sv:g.PARSER_MEDIA_TYPE,ve=es==="application/xhtml+xml"?qa:oo,we=Ge(g,"ALLOWED_TAGS")?W({},g.ALLOWED_TAGS,ve):nu,$e=Ge(g,"ALLOWED_ATTR")?W({},g.ALLOWED_ATTR,ve):ru,la=Ge(g,"ALLOWED_NAMESPACES")?W({},g.ALLOWED_NAMESPACES,qa):bv,oa=Ge(g,"ADD_URI_SAFE_ATTR")?W(ft(hu),g.ADD_URI_SAFE_ATTR,ve):hu,cu=Ge(g,"ADD_DATA_URI_TAGS")?W(ft(uu),g.ADD_DATA_URI_TAGS,ve):uu,ut=Ge(g,"FORBID_CONTENTS")?W({},g.FORBID_CONTENTS,ve):ia,Xr=Ge(g,"FORBID_TAGS")?W({},g.FORBID_TAGS,ve):ft({}),Si=Ge(g,"FORBID_ATTR")?W({},g.FORBID_ATTR,ve):ft({}),tr=Ge(g,"USE_PROFILES")?g.USE_PROFILES:!1,su=g.ALLOW_ARIA_ATTR!==!1,ta=g.ALLOW_DATA_ATTR!==!1,iu=g.ALLOW_UNKNOWN_PROTOCOLS||!1,ou=g.ALLOW_SELF_CLOSE_IN_ATTR!==!1,Qn=g.SAFE_FOR_TEMPLATES||!1,ki=g.SAFE_FOR_XML!==!1,mn=g.WHOLE_DOCUMENT||!1,er=g.RETURN_DOM||!1,Ei=g.RETURN_DOM_FRAGMENT||!1,$i=g.RETURN_TRUSTED_TYPE||!1,ra=g.FORCE_BODY||!1,au=g.SANITIZE_DOM!==!1,lu=g.SANITIZE_NAMED_PROPS||!1,sa=g.KEEP_CONTENT!==!1,Qr=g.IN_PLACE||!1,tu=g.ALLOWED_URI_REGEXP||Vm,nr=g.NAMESPACE||Et,Ti=g.MATHML_TEXT_INTEGRATION_POINTS||Ti,Ci=g.HTML_INTEGRATION_POINTS||Ci,pe=g.CUSTOM_ELEMENT_HANDLING||{},g.CUSTOM_ELEMENT_HANDLING&&du(g.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(pe.tagNameCheck=g.CUSTOM_ELEMENT_HANDLING.tagNameCheck),g.CUSTOM_ELEMENT_HANDLING&&du(g.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(pe.attributeNameCheck=g.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),g.CUSTOM_ELEMENT_HANDLING&&typeof g.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements=="boolean"&&(pe.allowCustomizedBuiltInElements=g.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),Qn&&(ta=!1),Ei&&(er=!0),tr&&(we=W({},Yd),$e=io(null),tr.html===!0&&(W(we,qd),W($e,Kd)),tr.svg===!0&&(W(we,Ka),W($e,Qa),W($e,Bi)),tr.svgFilters===!0&&(W(we,Ja),W($e,Qa),W($e,Bi)),tr.mathMl===!0&&(W(we,Xa),W($e,Jd),W($e,Bi))),Ge(g,"ADD_TAGS")||(Bt.tagCheck=null),Ge(g,"ADD_ATTR")||(Bt.attributeCheck=null),g.ADD_TAGS&&(typeof g.ADD_TAGS=="function"?Bt.tagCheck=g.ADD_TAGS:(we===nu&&(we=ft(we)),W(we,g.ADD_TAGS,ve))),g.ADD_ATTR&&(typeof g.ADD_ATTR=="function"?Bt.attributeCheck=g.ADD_ATTR:($e===ru&&($e=ft($e)),W($e,g.ADD_ATTR,ve))),g.ADD_URI_SAFE_ATTR&&W(oa,g.ADD_URI_SAFE_ATTR,ve),g.FORBID_CONTENTS&&(ut===ia&&(ut=ft(ut)),W(ut,g.FORBID_CONTENTS,ve)),g.ADD_FORBID_CONTENTS&&(ut===ia&&(ut=ft(ut)),W(ut,g.ADD_FORBID_CONTENTS,ve)),sa&&(we["#text"]=!0),mn&&W(we,["html","head","body"]),we.table&&(W(we,["tbody"]),delete Xr.tbody),g.TRUSTED_TYPES_POLICY){if(typeof g.TRUSTED_TYPES_POLICY.createHTML!="function")throw cs('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof g.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw cs('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');F=g.TRUSTED_TYPES_POLICY,L=F.createHTML("")}else F===void 0&&(F=hO(m,s)),F!==null&&typeof L=="string"&&(L=F.createHTML(""));ze&&ze(g),rr=g}},pu=W({},[...Ka,...Ja,...eO]),fu=W({},[...Xa,...tO]),Ev=function(g){let T=j(g);(!T||!T.tagName)&&(T={namespaceURI:nr,tagName:"template"});const P=oo(g.tagName),se=oo(T.tagName);return la[g.namespaceURI]?g.namespaceURI===xi?T.namespaceURI===Et?P==="svg":T.namespaceURI===Ai?P==="svg"&&(se==="annotation-xml"||Ti[se]):!!pu[P]:g.namespaceURI===Ai?T.namespaceURI===Et?P==="math":T.namespaceURI===xi?P==="math"&&Ci[se]:!!fu[P]:g.namespaceURI===Et?T.namespaceURI===xi&&!Ci[se]||T.namespaceURI===Ai&&!Ti[se]?!1:!fu[P]&&(wv[P]||!pu[P]):!!(es==="application/xhtml+xml"&&la[g.namespaceURI]):!1},ht=function(g){as(e.removed,{element:g});try{j(g).removeChild(g)}catch{I(g)}},vn=function(g,T){try{as(e.removed,{attribute:T.getAttributeNode(g),from:T})}catch{as(e.removed,{attribute:null,from:T})}if(T.removeAttribute(g),g==="is")if(er||Ei)try{ht(T)}catch{}else try{T.setAttribute(g,"")}catch{}},gu=function(g){let T=null,P=null;if(ra)g="<remove></remove>"+g;else{const fe=Ya(g,/^[\r\n\t ]+/);P=fe&&fe[0]}es==="application/xhtml+xml"&&nr===Et&&(g='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+g+"</body></html>");const se=F?F.createHTML(g):g;if(nr===Et)try{T=new y().parseFromString(se,es)}catch{}if(!T||!T.documentElement){T=J.createDocument(nr,"template",null);try{T.documentElement.innerHTML=aa?L:se}catch{}}const Ie=T.body||T.documentElement;return g&&P&&Ie.insertBefore(n.createTextNode(P),Ie.childNodes[0]||null),nr===Et?lt.call(T,mn?"html":"body")[0]:mn?T.documentElement:Ie},mu=function(g){return H.call(g.ownerDocument||g,g,c.SHOW_ELEMENT|c.SHOW_COMMENT|c.SHOW_TEXT|c.SHOW_PROCESSING_INSTRUCTION|c.SHOW_CDATA_SECTION,null)},ua=function(g){return g instanceof p&&(typeof g.nodeName!="string"||typeof g.textContent!="string"||typeof g.removeChild!="function"||!(g.attributes instanceof d)||typeof g.removeAttribute!="function"||typeof g.setAttribute!="function"||typeof g.namespaceURI!="string"||typeof g.insertBefore!="function"||typeof g.hasChildNodes!="function")},vu=function(g){return typeof a=="function"&&g instanceof a};function $t(z,g,T){Wi(z,P=>{P.call(e,g,T,rr)})}const yu=function(g){let T=null;if($t(Ee.beforeSanitizeElements,g,null),ua(g))return ht(g),!0;const P=ve(g.nodeName);if($t(Ee.uponSanitizeElement,g,{tagName:P,allowedTags:we}),ki&&g.hasChildNodes()&&!vu(g.firstElementChild)&&Pe(/<[/\w!]/g,g.innerHTML)&&Pe(/<[/\w!]/g,g.textContent)||g.nodeType===hs.progressingInstruction||ki&&g.nodeType===hs.comment&&Pe(/<[/\w]/g,g.data))return ht(g),!0;if(!(Bt.tagCheck instanceof Function&&Bt.tagCheck(P))&&(!we[P]||Xr[P])){if(!Xr[P]&&wu(P)&&(pe.tagNameCheck instanceof RegExp&&Pe(pe.tagNameCheck,P)||pe.tagNameCheck instanceof Function&&pe.tagNameCheck(P)))return!1;if(sa&&!ut[P]){const se=j(g)||g.parentNode,Ie=N(g)||g.childNodes;if(Ie&&se){const fe=Ie.length;for(let Me=fe-1;Me>=0;--Me){const At=k(Ie[Me],!0);At.__removalCount=(g.__removalCount||0)+1,se.insertBefore(At,G(g))}}}return ht(g),!0}return g instanceof l&&!Ev(g)||(P==="noscript"||P==="noembed"||P==="noframes")&&Pe(/<\/no(script|embed|frames)/i,g.innerHTML)?(ht(g),!0):(Qn&&g.nodeType===hs.text&&(T=g.textContent,Wi([gn,ct,Wt],se=>{T=ls(T,se," ")}),g.textContent!==T&&(as(e.removed,{element:g.cloneNode()}),g.textContent=T)),$t(Ee.afterSanitizeElements,g,null),!1)},bu=function(g,T,P){if(Si[T]||au&&(T==="id"||T==="name")&&(P in n||P in kv))return!1;if(!(ta&&!Si[T]&&Pe(ea,T))){if(!(su&&Pe(_i,T))){if(!(Bt.attributeCheck instanceof Function&&Bt.attributeCheck(T,g))){if(!$e[T]||Si[T]){if(!(wu(g)&&(pe.tagNameCheck instanceof RegExp&&Pe(pe.tagNameCheck,g)||pe.tagNameCheck instanceof Function&&pe.tagNameCheck(g))&&(pe.attributeNameCheck instanceof RegExp&&Pe(pe.attributeNameCheck,T)||pe.attributeNameCheck instanceof Function&&pe.attributeNameCheck(T,g))||T==="is"&&pe.allowCustomizedBuiltInElements&&(pe.tagNameCheck instanceof RegExp&&Pe(pe.tagNameCheck,P)||pe.tagNameCheck instanceof Function&&pe.tagNameCheck(P))))return!1}else if(!oa[T]){if(!Pe(tu,ls(P,eu,""))){if(!((T==="src"||T==="xlink:href"||T==="href")&&g!=="script"&&KD(P,"data:")===0&&cu[g])){if(!(iu&&!Pe(mv,ls(P,eu,"")))){if(P)return!1}}}}}}}return!0},wu=function(g){return g!=="annotation-xml"&&Ya(g,vv)},_u=function(g){$t(Ee.beforeSanitizeAttributes,g,null);const{attributes:T}=g;if(!T||ua(g))return;const P={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:$e,forceKeepAttr:void 0};let se=T.length;for(;se--;){const Ie=T[se],{name:fe,namespaceURI:Me,value:At}=Ie,sr=ve(fe),ha=At;let Ae=fe==="value"?ha:JD(ha);if(P.attrName=sr,P.attrValue=Ae,P.keepAttr=!0,P.forceKeepAttr=void 0,$t(Ee.uponSanitizeAttribute,g,P),Ae=P.attrValue,lu&&(sr==="id"||sr==="name")&&(vn(fe,g),Ae=yv+Ae),ki&&Pe(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,Ae)){vn(fe,g);continue}if(sr==="attributename"&&Ya(Ae,"href")){vn(fe,g);continue}if(P.forceKeepAttr)continue;if(!P.keepAttr){vn(fe,g);continue}if(!ou&&Pe(/\/>/i,Ae)){vn(fe,g);continue}Qn&&Wi([gn,ct,Wt],ku=>{Ae=ls(Ae,ku," ")});const Su=ve(g.nodeName);if(!bu(Su,sr,Ae)){vn(fe,g);continue}if(F&&typeof m=="object"&&typeof m.getAttributeType=="function"&&!Me)switch(m.getAttributeType(Su,sr)){case"TrustedHTML":{Ae=F.createHTML(Ae);break}case"TrustedScriptURL":{Ae=F.createScriptURL(Ae);break}}if(Ae!==ha)try{Me?g.setAttributeNS(Me,fe,Ae):g.setAttribute(fe,Ae),ua(g)?ht(g):Hd(e.removed)}catch{vn(fe,g)}}$t(Ee.afterSanitizeAttributes,g,null)},$v=function z(g){let T=null;const P=mu(g);for($t(Ee.beforeSanitizeShadowDOM,g,null);T=P.nextNode();)$t(Ee.uponSanitizeShadowNode,T,null),yu(T),_u(T),T.content instanceof i&&z(T.content);$t(Ee.afterSanitizeShadowDOM,g,null)};return e.sanitize=function(z){let g=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},T=null,P=null,se=null,Ie=null;if(aa=!z,aa&&(z="<!-->"),typeof z!="string"&&!vu(z))if(typeof z.toString=="function"){if(z=z.toString(),typeof z!="string")throw cs("dirty is not a string, aborting")}else throw cs("toString is not a function");if(!e.isSupported)return z;if(na||ca(g),e.removed=[],typeof z=="string"&&(Qr=!1),Qr){if(z.nodeName){const At=ve(z.nodeName);if(!we[At]||Xr[At])throw cs("root node is forbidden and cannot be sanitized in-place")}}else if(z instanceof a)T=gu("<!---->"),P=T.ownerDocument.importNode(z,!0),P.nodeType===hs.element&&P.nodeName==="BODY"||P.nodeName==="HTML"?T=P:T.appendChild(P);else{if(!er&&!Qn&&!mn&&z.indexOf("<")===-1)return F&&$i?F.createHTML(z):z;if(T=gu(z),!T)return er?null:$i?L:""}T&&ra&&ht(T.firstChild);const fe=mu(Qr?z:T);for(;se=fe.nextNode();)yu(se),_u(se),se.content instanceof i&&$v(se.content);if(Qr)return z;if(er){if(Ei)for(Ie=he.call(T.ownerDocument);T.firstChild;)Ie.appendChild(T.firstChild);else Ie=T;return($e.shadowroot||$e.shadowrootmode)&&(Ie=wi.call(r,Ie,!0)),Ie}let Me=mn?T.outerHTML:T.innerHTML;return mn&&we["!doctype"]&&T.ownerDocument&&T.ownerDocument.doctype&&T.ownerDocument.doctype.name&&Pe(Hm,T.ownerDocument.doctype.name)&&(Me="<!DOCTYPE "+T.ownerDocument.doctype.name+`>
|
|
211
|
+
`+Me),Qn&&Wi([gn,ct,Wt],At=>{Me=ls(Me,At," ")}),F&&$i?F.createHTML(Me):Me},e.setConfig=function(){let z=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};ca(z),na=!0},e.clearConfig=function(){rr=null,na=!1},e.isValidAttribute=function(z,g,T){rr||ca({});const P=ve(z),se=ve(g);return bu(P,se,T)},e.addHook=function(z,g){typeof g=="function"&&as(Ee[z],g)},e.removeHook=function(z,g){if(g!==void 0){const T=qD(Ee[z],g);return T===-1?void 0:YD(Ee[z],T,1)[0]}return Hd(Ee[z])},e.removeHooks=function(z){Ee[z]=[]},e.removeAllHooks=function(){Ee=Qd()},e}var Ym=qm();function Wc(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var Xn=Wc();function Km(t){Xn=t}var $n={exec:()=>null};function q(t,e=""){let n=typeof t=="string"?t:t.source,r={replace:(s,i)=>{let o=typeof i=="string"?i:i.source;return o=o.replace(Oe.caret,"$1"),n=n.replace(s,o),r},getRegex:()=>new RegExp(n,e)};return r}var dO=(()=>{try{return!!new RegExp("(?<=1)(?<!1)")}catch{return!1}})(),Oe={codeRemoveIndent:/^(?: {1,4}| {0,3}\t)/gm,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,multipleSpaceGlobal:/\s+/g,blankLine:/^[ \t]*$/,doubleBlankLine:/\n[ \t]*\n[ \t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] +\S/,listReplaceTask:/^\[[ xX]\] +/,listTaskCheckbox:/\[[ xX]\]/,anyLine:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\||\| *$/g,tableRowBlankLine:/\n[ \t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^<a /i,endATag:/^<\/a>/i,startPreScriptTag:/^<(pre|code|kbd|script)(\s|>)/i,endPreScriptTag:/^<\/(pre|code|kbd|script)(\s|>)/i,startAngleBracket:/^</,endAngleBracket:/>$/,pedanticHrefTitle:/^([^'"]*[^\s])\s+(['"])(.*)\2/,unicodeAlphaNumeric:/[\p{L}\p{N}]/u,escapeTest:/[&<>"']/,escapeReplace:/[&<>"']/g,escapeTestNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeReplaceNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:t=>new RegExp(`^( {0,3}${t})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),hrRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),fencesBeginRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}(?:\`\`\`|~~~)`),headingBeginRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}#`),htmlBeginRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}<(?:[a-z].*>|!--)`,"i"),blockquoteBeginRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}>`)},pO=/^(?:[ \t]*(?:\n|$))+/,fO=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,gO=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,bi=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,mO=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,Bc=/ {0,3}(?:[*+-]|\d{1,9}[.)])/,Jm=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,Xm=q(Jm).replace(/bull/g,Bc).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/\|table/g,"").getRegex(),vO=q(Jm).replace(/bull/g,Bc).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/table/g,/ {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(),Gc=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,yO=/^[^\n]+/,Vc=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,bO=q(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",Vc).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),wO=q(/^(bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,Bc).getRegex(),Jo="address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul",Hc=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,_O=q("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))","i").replace("comment",Hc).replace("tag",Jo).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),Qm=q(Gc).replace("hr",bi).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("|table","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",Jo).getRegex(),SO=q(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",Qm).getRegex(),qc={blockquote:SO,code:fO,def:bO,fences:gO,heading:mO,hr:bi,html:_O,lheading:Xm,list:wO,newline:pO,paragraph:Qm,table:$n,text:yO},ep=q("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",bi).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("blockquote"," {0,3}>").replace("code","(?: {4}| {0,3} )[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",Jo).getRegex(),kO={...qc,lheading:vO,table:ep,paragraph:q(Gc).replace("hr",bi).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",ep).replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",Jo).getRegex()},EO={...qc,html:q(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",Hc).replace(/tag/g,"(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:$n,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:q(Gc).replace("hr",bi).replace("heading",` *#{1,6} *[^
|
|
212
|
+
]`).replace("lheading",Xm).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},$O=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,AO=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,ev=/^( {2,}|\\)\n(?!\s*$)/,xO=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,Jr=/[\p{P}\p{S}]/u,Xo=/[\s\p{P}\p{S}]/u,Yc=/[^\s\p{P}\p{S}]/u,TO=q(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,Xo).getRegex(),tv=/(?!~)[\p{P}\p{S}]/u,CO=/(?!~)[\s\p{P}\p{S}]/u,IO=/(?:[^\s\p{P}\p{S}]|~)/u,PO=q(/link|precode-code|html/,"g").replace("link",/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-",dO?"(?<!`)()":"(^^|[^`])").replace("code",/(?<b>`+)[^`]+\k<b>(?!`)/).replace("html",/<(?! )[^<>]*?>/).getRegex(),nv=/^(?:\*+(?:((?!\*)punct)|([^\s*]))?)|^_+(?:((?!_)punct)|([^\s_]))?/,RO=q(nv,"u").replace(/punct/g,Jr).getRegex(),DO=q(nv,"u").replace(/punct/g,tv).getRegex(),rv="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",OO=q(rv,"gu").replace(/notPunctSpace/g,Yc).replace(/punctSpace/g,Xo).replace(/punct/g,Jr).getRegex(),zO=q(rv,"gu").replace(/notPunctSpace/g,IO).replace(/punctSpace/g,CO).replace(/punct/g,tv).getRegex(),LO=q("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,Yc).replace(/punctSpace/g,Xo).replace(/punct/g,Jr).getRegex(),MO=q(/^~~?(?:((?!~)punct)|[^\s~])/,"u").replace(/punct/g,Jr).getRegex(),NO="^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)",UO=q(NO,"gu").replace(/notPunctSpace/g,Yc).replace(/punctSpace/g,Xo).replace(/punct/g,Jr).getRegex(),FO=q(/\\(punct)/,"gu").replace(/punct/g,Jr).getRegex(),ZO=q(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace("scheme",/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace("email",/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(),jO=q(Hc).replace("(?:-->|$)","-->").getRegex(),WO=q("^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>").replace("comment",jO).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),_o=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\])|[^\[\]\\`])*?/,BO=q(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?\s*\)/).replace("label",_o).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),sv=q(/^!?\[(label)\]\[(ref)\]/).replace("label",_o).replace("ref",Vc).getRegex(),iv=q(/^!?\[(ref)\](?:\[\])?/).replace("ref",Vc).getRegex(),GO=q("reflink|nolink(?!\\()","g").replace("reflink",sv).replace("nolink",iv).getRegex(),tp=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,Kc={_backpedal:$n,anyPunctuation:FO,autolink:ZO,blockSkip:PO,br:ev,code:AO,del:$n,delLDelim:$n,delRDelim:$n,emStrongLDelim:RO,emStrongRDelimAst:OO,emStrongRDelimUnd:LO,escape:$O,link:BO,nolink:iv,punctuation:TO,reflink:sv,reflinkSearch:GO,tag:WO,text:xO,url:$n},VO={...Kc,link:q(/^!?\[(label)\]\((.*?)\)/).replace("label",_o).getRegex(),reflink:q(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",_o).getRegex()},Gl={...Kc,emStrongRDelimAst:zO,emStrongLDelim:DO,delLDelim:MO,delRDelim:UO,url:q(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol",tp).replace("email",/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])((?:\\[\s\S]|[^\\])*?(?:\\[\s\S]|[^\s~\\]))\1(?=[^~]|$)/,text:q(/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace("protocol",tp).getRegex()},HO={...Gl,br:q(ev).replace("{2,}","*").getRegex(),text:q(Gl.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},Gi={normal:qc,gfm:kO,pedantic:EO},ds={normal:Kc,gfm:Gl,breaks:HO,pedantic:VO},qO={"&":"&","<":"<",">":">",'"':""","'":"'"},np=t=>qO[t];function gt(t,e){if(e){if(Oe.escapeTest.test(t))return t.replace(Oe.escapeReplace,np)}else if(Oe.escapeTestNoEncode.test(t))return t.replace(Oe.escapeReplaceNoEncode,np);return t}function rp(t){try{t=encodeURI(t).replace(Oe.percentDecode,"%")}catch{return null}return t}function sp(t,e){var i;let n=t.replace(Oe.findPipe,(o,a,l)=>{let c=!1,d=a;for(;--d>=0&&l[d]==="\\";)c=!c;return c?"|":" |"}),r=n.split(Oe.splitPipe),s=0;if(r[0].trim()||r.shift(),r.length>0&&!((i=r.at(-1))!=null&&i.trim())&&r.pop(),e)if(r.length>e)r.splice(e);else for(;r.length<e;)r.push("");for(;s<r.length;s++)r[s]=r[s].trim().replace(Oe.slashPipe,"|");return r}function ps(t,e,n){let r=t.length;if(r===0)return"";let s=0;for(;s<r&&t.charAt(r-s-1)===e;)s++;return t.slice(0,r-s)}function YO(t,e){if(t.indexOf(e[1])===-1)return-1;let n=0;for(let r=0;r<t.length;r++)if(t[r]==="\\")r++;else if(t[r]===e[0])n++;else if(t[r]===e[1]&&(n--,n<0))return r;return n>0?-2:-1}function KO(t,e=0){let n=e,r="";for(let s of t)if(s===" "){let i=4-n%4;r+=" ".repeat(i),n+=i}else r+=s,n++;return r}function ip(t,e,n,r,s){let i=e.href,o=e.title||null,a=t[1].replace(s.other.outputLinkReplace,"$1");r.state.inLink=!0;let l={type:t[0].charAt(0)==="!"?"image":"link",raw:n,href:i,title:o,text:a,tokens:r.inlineTokens(a)};return r.state.inLink=!1,l}function JO(t,e,n){let r=t.match(n.other.indentCodeCompensation);if(r===null)return e;let s=r[1];return e.split(`
|
|
213
213
|
`).map(i=>{let o=i.match(n.other.beginningSpace);if(o===null)return i;let[a]=o;return a.length>=s.length?i.slice(s.length):i}).join(`
|
|
214
214
|
`)}var So=class{constructor(t){v(this,"options");v(this,"rules");v(this,"lexer");this.options=t||Xn}space(t){let e=this.rules.block.newline.exec(t);if(e&&e[0].length>0)return{type:"space",raw:e[0]}}code(t){let e=this.rules.block.code.exec(t);if(e){let n=e[0].replace(this.rules.other.codeRemoveIndent,"");return{type:"code",raw:e[0],codeBlockStyle:"indented",text:this.options.pedantic?n:ps(n,`
|
|
215
|
-
`)}}}fences(t){let e=this.rules.block.fences.exec(t);if(e){let n=e[0],r=
|
|
215
|
+
`)}}}fences(t){let e=this.rules.block.fences.exec(t);if(e){let n=e[0],r=JO(n,e[3]||"",this.rules);return{type:"code",raw:n,lang:e[2]?e[2].trim().replace(this.rules.inline.anyPunctuation,"$1"):e[2],text:r}}}heading(t){let e=this.rules.block.heading.exec(t);if(e){let n=e[2].trim();if(this.rules.other.endingHash.test(n)){let r=ps(n,"#");(this.options.pedantic||!r||this.rules.other.endingSpaceChar.test(r))&&(n=r.trim())}return{type:"heading",raw:e[0],depth:e[1].length,text:n,tokens:this.lexer.inline(n)}}}hr(t){let e=this.rules.block.hr.exec(t);if(e)return{type:"hr",raw:ps(e[0],`
|
|
216
216
|
`)}}blockquote(t){let e=this.rules.block.blockquote.exec(t);if(e){let n=ps(e[0],`
|
|
217
217
|
`).split(`
|
|
218
218
|
`),r="",s="",i=[];for(;n.length>0;){let o=!1,a=[],l;for(l=0;l<n.length;l++)if(this.rules.other.blockquoteStart.test(n[l]))a.push(n[l]),o=!0;else if(!o)a.push(n[l]);else break;n=n.slice(l);let c=a.join(`
|
|
@@ -224,7 +224,7 @@ ${d}`:d;let p=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTo
|
|
|
224
224
|
`),k=this.blockquote(E);i[i.length-1]=k,r=r.substring(0,r.length-m.raw.length)+k.raw,s=s.substring(0,s.length-m.text.length)+k.text;break}else if((y==null?void 0:y.type)==="list"){let m=y,E=m.raw+`
|
|
225
225
|
`+n.join(`
|
|
226
226
|
`),k=this.list(E);i[i.length-1]=k,r=r.substring(0,r.length-y.raw.length)+k.raw,s=s.substring(0,s.length-m.raw.length)+k.raw,n=E.substring(i.at(-1).raw.length).split(`
|
|
227
|
-
`);continue}}return{type:"blockquote",raw:r,tokens:i,text:s}}}list(t){var n,r;let e=this.rules.block.list.exec(t);if(e){let s=e[1].trim(),i=s.length>1,o={type:"list",raw:"",ordered:i,start:i?+s.slice(0,-1):"",loose:!1,items:[]};s=i?`\\d{1,9}\\${s.slice(-1)}`:`\\${s}`,this.options.pedantic&&(s=i?s:"[*+-]");let a=this.rules.other.listItemRegex(s),l=!1;for(;t;){let d=!1,p="",y="";if(!(e=a.exec(t))||this.rules.block.hr.test(t))break;p=e[0],t=t.substring(p.length);let m=
|
|
227
|
+
`);continue}}return{type:"blockquote",raw:r,tokens:i,text:s}}}list(t){var n,r;let e=this.rules.block.list.exec(t);if(e){let s=e[1].trim(),i=s.length>1,o={type:"list",raw:"",ordered:i,start:i?+s.slice(0,-1):"",loose:!1,items:[]};s=i?`\\d{1,9}\\${s.slice(-1)}`:`\\${s}`,this.options.pedantic&&(s=i?s:"[*+-]");let a=this.rules.other.listItemRegex(s),l=!1;for(;t;){let d=!1,p="",y="";if(!(e=a.exec(t))||this.rules.block.hr.test(t))break;p=e[0],t=t.substring(p.length);let m=KO(e[2].split(`
|
|
228
228
|
`,1)[0],e[1].length),E=t.split(`
|
|
229
229
|
`,1)[0],k=!m.trim(),I=0;if(this.options.pedantic?(I=2,y=m.trimStart()):k?I=e[1].length+1:(I=m.search(this.rules.other.nonSpaceChar),I=I>4?1:I,y=m.slice(I),I+=e[1].length),k&&this.rules.other.blankLine.test(E)&&(p+=E+`
|
|
230
230
|
`,t=t.substring(E.length+1),d=!0),!d){let G=this.rules.other.nextBulletRegex(I),N=this.rules.other.hrRegex(I),j=this.rules.other.fencesBeginRegex(I),F=this.rules.other.headingBeginRegex(I),L=this.rules.other.htmlBeginRegex(I),J=this.rules.other.blockquoteBeginRegex(I);for(;t;){let H=t.split(`
|
|
@@ -233,7 +233,7 @@ ${d}`:d;let p=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTo
|
|
|
233
233
|
`+E}k=!E.trim(),p+=H+`
|
|
234
234
|
`,t=t.substring(H.length+1),m=he.slice(I)}}o.loose||(l?o.loose=!0:this.rules.other.doubleBlankLine.test(p)&&(l=!0)),o.items.push({type:"list_item",raw:p,task:!!this.options.gfm&&this.rules.other.listIsTask.test(y),loose:!1,text:y,tokens:[]}),o.raw+=p}let c=o.items.at(-1);if(c)c.raw=c.raw.trimEnd(),c.text=c.text.trimEnd();else return;o.raw=o.raw.trimEnd();for(let d of o.items){if(this.lexer.state.top=!1,d.tokens=this.lexer.blockTokens(d.text,[]),d.task){if(d.text=d.text.replace(this.rules.other.listReplaceTask,""),((n=d.tokens[0])==null?void 0:n.type)==="text"||((r=d.tokens[0])==null?void 0:r.type)==="paragraph"){d.tokens[0].raw=d.tokens[0].raw.replace(this.rules.other.listReplaceTask,""),d.tokens[0].text=d.tokens[0].text.replace(this.rules.other.listReplaceTask,"");for(let y=this.lexer.inlineQueue.length-1;y>=0;y--)if(this.rules.other.listIsTask.test(this.lexer.inlineQueue[y].src)){this.lexer.inlineQueue[y].src=this.lexer.inlineQueue[y].src.replace(this.rules.other.listReplaceTask,"");break}}let p=this.rules.other.listTaskCheckbox.exec(d.raw);if(p){let y={type:"checkbox",raw:p[0]+" ",checked:p[0]!=="[ ]"};d.checked=y.checked,o.loose?d.tokens[0]&&["paragraph","text"].includes(d.tokens[0].type)&&"tokens"in d.tokens[0]&&d.tokens[0].tokens?(d.tokens[0].raw=y.raw+d.tokens[0].raw,d.tokens[0].text=y.raw+d.tokens[0].text,d.tokens[0].tokens.unshift(y)):d.tokens.unshift({type:"paragraph",raw:y.raw,text:y.raw,tokens:[y]}):d.tokens.unshift(y)}}if(!o.loose){let p=d.tokens.filter(m=>m.type==="space"),y=p.length>0&&p.some(m=>this.rules.other.anyLine.test(m.raw));o.loose=y}}if(o.loose)for(let d of o.items){d.loose=!0;for(let p of d.tokens)p.type==="text"&&(p.type="paragraph")}return o}}html(t){let e=this.rules.block.html.exec(t);if(e)return{type:"html",block:!0,raw:e[0],pre:e[1]==="pre"||e[1]==="script"||e[1]==="style",text:e[0]}}def(t){let e=this.rules.block.def.exec(t);if(e){let n=e[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal," "),r=e[2]?e[2].replace(this.rules.other.hrefBrackets,"$1").replace(this.rules.inline.anyPunctuation,"$1"):"",s=e[3]?e[3].substring(1,e[3].length-1).replace(this.rules.inline.anyPunctuation,"$1"):e[3];return{type:"def",tag:n,raw:e[0],href:r,title:s}}}table(t){var o;let e=this.rules.block.table.exec(t);if(!e||!this.rules.other.tableDelimiter.test(e[2]))return;let n=sp(e[1]),r=e[2].replace(this.rules.other.tableAlignChars,"").split("|"),s=(o=e[3])!=null&&o.trim()?e[3].replace(this.rules.other.tableRowBlankLine,"").split(`
|
|
235
235
|
`):[],i={type:"table",raw:e[0],header:[],align:[],rows:[]};if(n.length===r.length){for(let a of r)this.rules.other.tableAlignRight.test(a)?i.align.push("right"):this.rules.other.tableAlignCenter.test(a)?i.align.push("center"):this.rules.other.tableAlignLeft.test(a)?i.align.push("left"):i.align.push(null);for(let a=0;a<n.length;a++)i.header.push({text:n[a],tokens:this.lexer.inline(n[a]),header:!0,align:i.align[a]});for(let a of s)i.rows.push(sp(a,i.header.length).map((l,c)=>({text:l,tokens:this.lexer.inline(l),header:!1,align:i.align[c]})));return i}}lheading(t){let e=this.rules.block.lheading.exec(t);if(e){let n=e[1].trim();return{type:"heading",raw:e[0],depth:e[2].charAt(0)==="="?1:2,text:n,tokens:this.lexer.inline(n)}}}paragraph(t){let e=this.rules.block.paragraph.exec(t);if(e){let n=e[1].charAt(e[1].length-1)===`
|
|
236
|
-
`?e[1].slice(0,-1):e[1];return{type:"paragraph",raw:e[0],text:n,tokens:this.lexer.inline(n)}}}text(t){let e=this.rules.block.text.exec(t);if(e)return{type:"text",raw:e[0],text:e[0],tokens:this.lexer.inline(e[0])}}escape(t){let e=this.rules.inline.escape.exec(t);if(e)return{type:"escape",raw:e[0],text:e[1]}}tag(t){let e=this.rules.inline.tag.exec(t);if(e)return!this.lexer.state.inLink&&this.rules.other.startATag.test(e[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&this.rules.other.endATag.test(e[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&this.rules.other.startPreScriptTag.test(e[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&this.rules.other.endPreScriptTag.test(e[0])&&(this.lexer.state.inRawBlock=!1),{type:"html",raw:e[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:e[0]}}link(t){let e=this.rules.inline.link.exec(t);if(e){let n=e[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(n)){if(!this.rules.other.endAngleBracket.test(n))return;let i=ps(n.slice(0,-1),"\\");if((n.length-i.length)%2===0)return}else{let i=
|
|
236
|
+
`?e[1].slice(0,-1):e[1];return{type:"paragraph",raw:e[0],text:n,tokens:this.lexer.inline(n)}}}text(t){let e=this.rules.block.text.exec(t);if(e)return{type:"text",raw:e[0],text:e[0],tokens:this.lexer.inline(e[0])}}escape(t){let e=this.rules.inline.escape.exec(t);if(e)return{type:"escape",raw:e[0],text:e[1]}}tag(t){let e=this.rules.inline.tag.exec(t);if(e)return!this.lexer.state.inLink&&this.rules.other.startATag.test(e[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&this.rules.other.endATag.test(e[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&this.rules.other.startPreScriptTag.test(e[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&this.rules.other.endPreScriptTag.test(e[0])&&(this.lexer.state.inRawBlock=!1),{type:"html",raw:e[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:e[0]}}link(t){let e=this.rules.inline.link.exec(t);if(e){let n=e[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(n)){if(!this.rules.other.endAngleBracket.test(n))return;let i=ps(n.slice(0,-1),"\\");if((n.length-i.length)%2===0)return}else{let i=YO(e[2],"()");if(i===-2)return;if(i>-1){let o=(e[0].indexOf("!")===0?5:4)+e[1].length+i;e[2]=e[2].substring(0,i),e[0]=e[0].substring(0,o).trim(),e[3]=""}}let r=e[2],s="";if(this.options.pedantic){let i=this.rules.other.pedanticHrefTitle.exec(r);i&&(r=i[1],s=i[3])}else s=e[3]?e[3].slice(1,-1):"";return r=r.trim(),this.rules.other.startAngleBracket.test(r)&&(this.options.pedantic&&!this.rules.other.endAngleBracket.test(n)?r=r.slice(1):r=r.slice(1,-1)),ip(e,{href:r&&r.replace(this.rules.inline.anyPunctuation,"$1"),title:s&&s.replace(this.rules.inline.anyPunctuation,"$1")},e[0],this.lexer,this.rules)}}reflink(t,e){let n;if((n=this.rules.inline.reflink.exec(t))||(n=this.rules.inline.nolink.exec(t))){let r=(n[2]||n[1]).replace(this.rules.other.multipleSpaceGlobal," "),s=e[r.toLowerCase()];if(!s){let i=n[0].charAt(0);return{type:"text",raw:i,text:i}}return ip(n,s,n[0],this.lexer,this.rules)}}emStrong(t,e,n=""){let r=this.rules.inline.emStrongLDelim.exec(t);if(!(!r||!r[1]&&!r[2]&&!r[3]&&!r[4]||r[4]&&n.match(this.rules.other.unicodeAlphaNumeric))&&(!(r[1]||r[3])||!n||this.rules.inline.punctuation.exec(n))){let s=[...r[0]].length-1,i,o,a=s,l=0,c=r[0][0]==="*"?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(c.lastIndex=0,e=e.slice(-1*t.length+s);(r=c.exec(e))!=null;){if(i=r[1]||r[2]||r[3]||r[4]||r[5]||r[6],!i)continue;if(o=[...i].length,r[3]||r[4]){a+=o;continue}else if((r[5]||r[6])&&s%3&&!((s+o)%3)){l+=o;continue}if(a-=o,a>0)continue;o=Math.min(o,o+a+l);let d=[...r[0]][0].length,p=t.slice(0,s+r.index+d+o);if(Math.min(s,o)%2){let m=p.slice(1,-1);return{type:"em",raw:p,text:m,tokens:this.lexer.inlineTokens(m)}}let y=p.slice(2,-2);return{type:"strong",raw:p,text:y,tokens:this.lexer.inlineTokens(y)}}}}codespan(t){let e=this.rules.inline.code.exec(t);if(e){let n=e[2].replace(this.rules.other.newLineCharGlobal," "),r=this.rules.other.nonSpaceChar.test(n),s=this.rules.other.startingSpaceChar.test(n)&&this.rules.other.endingSpaceChar.test(n);return r&&s&&(n=n.substring(1,n.length-1)),{type:"codespan",raw:e[0],text:n}}}br(t){let e=this.rules.inline.br.exec(t);if(e)return{type:"br",raw:e[0]}}del(t,e,n=""){let r=this.rules.inline.delLDelim.exec(t);if(r&&(!r[1]||!n||this.rules.inline.punctuation.exec(n))){let s=[...r[0]].length-1,i,o,a=s,l=this.rules.inline.delRDelim;for(l.lastIndex=0,e=e.slice(-1*t.length+s);(r=l.exec(e))!=null;){if(i=r[1]||r[2]||r[3]||r[4]||r[5]||r[6],!i||(o=[...i].length,o!==s))continue;if(r[3]||r[4]){a+=o;continue}if(a-=o,a>0)continue;o=Math.min(o,o+a);let c=[...r[0]][0].length,d=t.slice(0,s+r.index+c+o),p=d.slice(s,-s);return{type:"del",raw:d,text:p,tokens:this.lexer.inlineTokens(p)}}}}autolink(t){let e=this.rules.inline.autolink.exec(t);if(e){let n,r;return e[2]==="@"?(n=e[1],r="mailto:"+n):(n=e[1],r=n),{type:"link",raw:e[0],text:n,href:r,tokens:[{type:"text",raw:n,text:n}]}}}url(t){var n;let e;if(e=this.rules.inline.url.exec(t)){let r,s;if(e[2]==="@")r=e[0],s="mailto:"+r;else{let i;do i=e[0],e[0]=((n=this.rules.inline._backpedal.exec(e[0]))==null?void 0:n[0])??"";while(i!==e[0]);r=e[0],e[1]==="www."?s="http://"+e[0]:s=e[0]}return{type:"link",raw:e[0],text:r,href:s,tokens:[{type:"text",raw:r,text:r}]}}}inlineText(t){let e=this.rules.inline.text.exec(t);if(e){let n=this.lexer.state.inRawBlock;return{type:"text",raw:e[0],text:e[0],escaped:n}}}},ot=class Vl{constructor(e){v(this,"tokens");v(this,"options");v(this,"state");v(this,"inlineQueue");v(this,"tokenizer");this.tokens=[],this.tokens.links=Object.create(null),this.options=e||Xn,this.options.tokenizer=this.options.tokenizer||new So,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,top:!0};let n={other:Oe,block:Gi.normal,inline:ds.normal};this.options.pedantic?(n.block=Gi.pedantic,n.inline=ds.pedantic):this.options.gfm&&(n.block=Gi.gfm,this.options.breaks?n.inline=ds.breaks:n.inline=ds.gfm),this.tokenizer.rules=n}static get rules(){return{block:Gi,inline:ds}}static lex(e,n){return new Vl(n).lex(e)}static lexInline(e,n){return new Vl(n).inlineTokens(e)}lex(e){e=e.replace(Oe.carriageReturn,`
|
|
237
237
|
`),this.blockTokens(e,this.tokens);for(let n=0;n<this.inlineQueue.length;n++){let r=this.inlineQueue[n];this.inlineTokens(r.src,r.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(e,n=[],r=!1){var s,i,o;for(this.tokenizer.lexer=this,this.options.pedantic&&(e=e.replace(Oe.tabCharGlobal," ").replace(Oe.spaceLine,""));e;){let a;if((i=(s=this.options.extensions)==null?void 0:s.block)!=null&&i.some(c=>(a=c.call({lexer:this},e,n))?(e=e.substring(a.raw.length),n.push(a),!0):!1))continue;if(a=this.tokenizer.space(e)){e=e.substring(a.raw.length);let c=n.at(-1);a.raw.length===1&&c!==void 0?c.raw+=`
|
|
238
238
|
`:n.push(a);continue}if(a=this.tokenizer.code(e)){e=e.substring(a.raw.length);let c=n.at(-1);(c==null?void 0:c.type)==="paragraph"||(c==null?void 0:c.type)==="text"?(c.raw+=(c.raw.endsWith(`
|
|
239
239
|
`)?"":`
|
|
@@ -265,10 +265,10 @@ ${this.parser.parse(t)}</blockquote>
|
|
|
265
265
|
`}tablerow({text:t}){return`<tr>
|
|
266
266
|
${t}</tr>
|
|
267
267
|
`}tablecell(t){let e=this.parser.parseInline(t.tokens),n=t.header?"th":"td";return(t.align?`<${n} align="${t.align}">`:`<${n}>`)+e+`</${n}>
|
|
268
|
-
`}strong({tokens:t}){return`<strong>${this.parser.parseInline(t)}</strong>`}em({tokens:t}){return`<em>${this.parser.parseInline(t)}</em>`}codespan({text:t}){return`<code>${gt(t,!0)}</code>`}br(t){return"<br>"}del({tokens:t}){return`<del>${this.parser.parseInline(t)}</del>`}link({href:t,title:e,tokens:n}){let r=this.parser.parseInline(n),s=rp(t);if(s===null)return r;t=s;let i='<a href="'+t+'"';return e&&(i+=' title="'+gt(e)+'"'),i+=">"+r+"</a>",i}image({href:t,title:e,text:n,tokens:r}){r&&(n=this.parser.parseInline(r,this.parser.textRenderer));let s=rp(t);if(s===null)return gt(n);t=s;let i=`<img src="${t}" alt="${gt(n)}"`;return e&&(i+=` title="${gt(e)}"`),i+=">",i}text(t){return"tokens"in t&&t.tokens?this.parser.parseInline(t.tokens):"escaped"in t&&t.escaped?t.text:gt(t.text)}},
|
|
269
|
-
Please report this to https://github.com/markedjs/marked.`,t){let r="<p>An error occurred:</p><pre>"+gt(n.message+"",!0)+"</pre>";return e?Promise.resolve(r):r}if(e)return Promise.reject(n);throw n}}},Hn=new
|
|
268
|
+
`}strong({tokens:t}){return`<strong>${this.parser.parseInline(t)}</strong>`}em({tokens:t}){return`<em>${this.parser.parseInline(t)}</em>`}codespan({text:t}){return`<code>${gt(t,!0)}</code>`}br(t){return"<br>"}del({tokens:t}){return`<del>${this.parser.parseInline(t)}</del>`}link({href:t,title:e,tokens:n}){let r=this.parser.parseInline(n),s=rp(t);if(s===null)return r;t=s;let i='<a href="'+t+'"';return e&&(i+=' title="'+gt(e)+'"'),i+=">"+r+"</a>",i}image({href:t,title:e,text:n,tokens:r}){r&&(n=this.parser.parseInline(r,this.parser.textRenderer));let s=rp(t);if(s===null)return gt(n);t=s;let i=`<img src="${t}" alt="${gt(n)}"`;return e&&(i+=` title="${gt(e)}"`),i+=">",i}text(t){return"tokens"in t&&t.tokens?this.parser.parseInline(t.tokens):"escaped"in t&&t.escaped?t.text:gt(t.text)}},Jc=class{strong({text:t}){return t}em({text:t}){return t}codespan({text:t}){return t}del({text:t}){return t}html({text:t}){return t}text({text:t}){return t}link({text:t}){return""+t}image({text:t}){return""+t}br(){return""}checkbox({raw:t}){return t}},at=class Hl{constructor(e){v(this,"options");v(this,"renderer");v(this,"textRenderer");this.options=e||Xn,this.options.renderer=this.options.renderer||new ko,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new Jc}static parse(e,n){return new Hl(n).parse(e)}static parseInline(e,n){return new Hl(n).parseInline(e)}parse(e){var r,s;this.renderer.parser=this;let n="";for(let i=0;i<e.length;i++){let o=e[i];if((s=(r=this.options.extensions)==null?void 0:r.renderers)!=null&&s[o.type]){let l=o,c=this.options.extensions.renderers[l.type].call({parser:this},l);if(c!==!1||!["space","hr","heading","code","table","blockquote","list","html","def","paragraph","text"].includes(l.type)){n+=c||"";continue}}let a=o;switch(a.type){case"space":{n+=this.renderer.space(a);break}case"hr":{n+=this.renderer.hr(a);break}case"heading":{n+=this.renderer.heading(a);break}case"code":{n+=this.renderer.code(a);break}case"table":{n+=this.renderer.table(a);break}case"blockquote":{n+=this.renderer.blockquote(a);break}case"list":{n+=this.renderer.list(a);break}case"checkbox":{n+=this.renderer.checkbox(a);break}case"html":{n+=this.renderer.html(a);break}case"def":{n+=this.renderer.def(a);break}case"paragraph":{n+=this.renderer.paragraph(a);break}case"text":{n+=this.renderer.text(a);break}default:{let l='Token with "'+a.type+'" type was not found.';if(this.options.silent)return console.error(l),"";throw new Error(l)}}}return n}parseInline(e,n=this.renderer){var s,i;this.renderer.parser=this;let r="";for(let o=0;o<e.length;o++){let a=e[o];if((i=(s=this.options.extensions)==null?void 0:s.renderers)!=null&&i[a.type]){let c=this.options.extensions.renderers[a.type].call({parser:this},a);if(c!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(a.type)){r+=c||"";continue}}let l=a;switch(l.type){case"escape":{r+=n.text(l);break}case"html":{r+=n.html(l);break}case"link":{r+=n.link(l);break}case"image":{r+=n.image(l);break}case"checkbox":{r+=n.checkbox(l);break}case"strong":{r+=n.strong(l);break}case"em":{r+=n.em(l);break}case"codespan":{r+=n.codespan(l);break}case"br":{r+=n.br(l);break}case"del":{r+=n.del(l);break}case"text":{r+=n.text(l);break}default:{let c='Token with "'+l.type+'" type was not found.';if(this.options.silent)return console.error(c),"";throw new Error(c)}}}return r}},Vi,_s=(Vi=class{constructor(t){v(this,"options");v(this,"block");this.options=t||Xn}preprocess(t){return t}postprocess(t){return t}processAllTokens(t){return t}emStrongMask(t){return t}provideLexer(){return this.block?ot.lex:ot.lexInline}provideParser(){return this.block?at.parse:at.parseInline}},v(Vi,"passThroughHooks",new Set(["preprocess","postprocess","processAllTokens","emStrongMask"])),v(Vi,"passThroughHooksRespectAsync",new Set(["preprocess","postprocess","processAllTokens"])),Vi),XO=class{constructor(...t){v(this,"defaults",Wc());v(this,"options",this.setOptions);v(this,"parse",this.parseMarkdown(!0));v(this,"parseInline",this.parseMarkdown(!1));v(this,"Parser",at);v(this,"Renderer",ko);v(this,"TextRenderer",Jc);v(this,"Lexer",ot);v(this,"Tokenizer",So);v(this,"Hooks",_s);this.use(...t)}walkTokens(t,e){var r,s;let n=[];for(let i of t)switch(n=n.concat(e.call(this,i)),i.type){case"table":{let o=i;for(let a of o.header)n=n.concat(this.walkTokens(a.tokens,e));for(let a of o.rows)for(let l of a)n=n.concat(this.walkTokens(l.tokens,e));break}case"list":{let o=i;n=n.concat(this.walkTokens(o.items,e));break}default:{let o=i;(s=(r=this.defaults.extensions)==null?void 0:r.childTokens)!=null&&s[o.type]?this.defaults.extensions.childTokens[o.type].forEach(a=>{let l=o[a].flat(1/0);n=n.concat(this.walkTokens(l,e))}):o.tokens&&(n=n.concat(this.walkTokens(o.tokens,e)))}}return n}use(...t){let e=this.defaults.extensions||{renderers:{},childTokens:{}};return t.forEach(n=>{let r={...n};if(r.async=this.defaults.async||r.async||!1,n.extensions&&(n.extensions.forEach(s=>{if(!s.name)throw new Error("extension name required");if("renderer"in s){let i=e.renderers[s.name];i?e.renderers[s.name]=function(...o){let a=s.renderer.apply(this,o);return a===!1&&(a=i.apply(this,o)),a}:e.renderers[s.name]=s.renderer}if("tokenizer"in s){if(!s.level||s.level!=="block"&&s.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");let i=e[s.level];i?i.unshift(s.tokenizer):e[s.level]=[s.tokenizer],s.start&&(s.level==="block"?e.startBlock?e.startBlock.push(s.start):e.startBlock=[s.start]:s.level==="inline"&&(e.startInline?e.startInline.push(s.start):e.startInline=[s.start]))}"childTokens"in s&&s.childTokens&&(e.childTokens[s.name]=s.childTokens)}),r.extensions=e),n.renderer){let s=this.defaults.renderer||new ko(this.defaults);for(let i in n.renderer){if(!(i in s))throw new Error(`renderer '${i}' does not exist`);if(["options","parser"].includes(i))continue;let o=i,a=n.renderer[o],l=s[o];s[o]=(...c)=>{let d=a.apply(s,c);return d===!1&&(d=l.apply(s,c)),d||""}}r.renderer=s}if(n.tokenizer){let s=this.defaults.tokenizer||new So(this.defaults);for(let i in n.tokenizer){if(!(i in s))throw new Error(`tokenizer '${i}' does not exist`);if(["options","rules","lexer"].includes(i))continue;let o=i,a=n.tokenizer[o],l=s[o];s[o]=(...c)=>{let d=a.apply(s,c);return d===!1&&(d=l.apply(s,c)),d}}r.tokenizer=s}if(n.hooks){let s=this.defaults.hooks||new _s;for(let i in n.hooks){if(!(i in s))throw new Error(`hook '${i}' does not exist`);if(["options","block"].includes(i))continue;let o=i,a=n.hooks[o],l=s[o];_s.passThroughHooks.has(i)?s[o]=c=>{if(this.defaults.async&&_s.passThroughHooksRespectAsync.has(i))return(async()=>{let p=await a.call(s,c);return l.call(s,p)})();let d=a.call(s,c);return l.call(s,d)}:s[o]=(...c)=>{if(this.defaults.async)return(async()=>{let p=await a.apply(s,c);return p===!1&&(p=await l.apply(s,c)),p})();let d=a.apply(s,c);return d===!1&&(d=l.apply(s,c)),d}}r.hooks=s}if(n.walkTokens){let s=this.defaults.walkTokens,i=n.walkTokens;r.walkTokens=function(o){let a=[];return a.push(i.call(this,o)),s&&(a=a.concat(s.call(this,o))),a}}this.defaults={...this.defaults,...r}}),this}setOptions(t){return this.defaults={...this.defaults,...t},this}lexer(t,e){return ot.lex(t,e??this.defaults)}parser(t,e){return at.parse(t,e??this.defaults)}parseMarkdown(t){return(e,n)=>{let r={...n},s={...this.defaults,...r},i=this.onError(!!s.silent,!!s.async);if(this.defaults.async===!0&&r.async===!1)return i(new Error("marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise."));if(typeof e>"u"||e===null)return i(new Error("marked(): input parameter is undefined or null"));if(typeof e!="string")return i(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(e)+", string expected"));if(s.hooks&&(s.hooks.options=s,s.hooks.block=t),s.async)return(async()=>{let o=s.hooks?await s.hooks.preprocess(e):e,a=await(s.hooks?await s.hooks.provideLexer():t?ot.lex:ot.lexInline)(o,s),l=s.hooks?await s.hooks.processAllTokens(a):a;s.walkTokens&&await Promise.all(this.walkTokens(l,s.walkTokens));let c=await(s.hooks?await s.hooks.provideParser():t?at.parse:at.parseInline)(l,s);return s.hooks?await s.hooks.postprocess(c):c})().catch(i);try{s.hooks&&(e=s.hooks.preprocess(e));let o=(s.hooks?s.hooks.provideLexer():t?ot.lex:ot.lexInline)(e,s);s.hooks&&(o=s.hooks.processAllTokens(o)),s.walkTokens&&this.walkTokens(o,s.walkTokens);let a=(s.hooks?s.hooks.provideParser():t?at.parse:at.parseInline)(o,s);return s.hooks&&(a=s.hooks.postprocess(a)),a}catch(o){return i(o)}}}onError(t,e){return n=>{if(n.message+=`
|
|
269
|
+
Please report this to https://github.com/markedjs/marked.`,t){let r="<p>An error occurred:</p><pre>"+gt(n.message+"",!0)+"</pre>";return e?Promise.resolve(r):r}if(e)return Promise.reject(n);throw n}}},Hn=new XO;function X(t,e){return Hn.parse(t,e)}X.options=X.setOptions=function(t){return Hn.setOptions(t),X.defaults=Hn.defaults,Km(X.defaults),X};X.getDefaults=Wc;X.defaults=Xn;X.use=function(...t){return Hn.use(...t),X.defaults=Hn.defaults,Km(X.defaults),X};X.walkTokens=function(t,e){return Hn.walkTokens(t,e)};X.parseInline=Hn.parseInline;X.Parser=at;X.parser=at.parse;X.Renderer=ko;X.TextRenderer=Jc;X.Lexer=ot;X.lexer=ot.lex;X.Tokenizer=So;X.Hooks=_s;X.parse=X;X.options;X.setOptions;X.use;X.walkTokens;X.parseInline;at.parse;ot.lex;Ym.addHook("afterSanitizeAttributes",t=>{t.tagName==="A"&&(t.setAttribute("target","_blank"),t.setAttribute("rel","noopener noreferrer"))});function QO(t){const e=X.parse(t,{async:!1});return Ym.sanitize(e,{USE_PROFILES:{html:!0}})}const ez=8,op=new WeakMap;function tz(t){const e=op.get(t);if(e&&e.text===t.text)return e.html;const n=QO(t.text);return op.set(t,{text:t.text,html:n}),n}function ap(t){for(let e=t.length-1;e>=0;e-=1){const n=t[e];if(n&&n.kind==="user")return n.id}return null}var Mt,jn,Io,Po,ri,ql;class ov extends Rs{constructor(){super(...arguments);$(this,ri);v(this,"messages",[]);$(this,Mt,!0);$(this,jn,null);$(this,Io,()=>{const n=u(this,jn);if(!n)return;const s=n.scrollHeight-n.clientHeight-n.scrollTop<=ez;s!==u(this,Mt)&&(x(this,Mt,s),this.toggleAttribute("data-pinned",s))});$(this,Po,()=>{x(this,Mt,!0),this.toggleAttribute("data-pinned",!0),b(this,ri,ql).call(this,!0)})}changed(n){let r=!1;if(n.has("messages")){const s=n.get("messages")??[],i=ap(this.messages);r=i!==null&&i!==ap(s),r&&x(this,Mt,!0)}be(this.template(),this),u(this,jn)||x(this,jn,this.querySelector(".history-scroll")),this.toggleAttribute("data-pinned",u(this,Mt)),b(this,ri,ql).call(this,r)}template(){const n=this.messages.filter(r=>r.kind==="user"||r.kind==="assistant");return M`
|
|
270
270
|
<div class="history-scroll" @scroll=${u(this,Io)}>
|
|
271
|
-
${n.map(r=>{const s=r.kind==="assistant"?
|
|
271
|
+
${n.map(r=>{const s=r.kind==="assistant"?IR(tz(r)):r.text;return M`<div
|
|
272
272
|
class="message message-${r.kind}"
|
|
273
273
|
data-message-id=${r.id}
|
|
274
274
|
>${s}</div>`})}
|
|
@@ -281,7 +281,7 @@ Please report this to https://github.com/markedjs/marked.`,t){let r="<p>An error
|
|
|
281
281
|
>
|
|
282
282
|
${wm({size:16})}
|
|
283
283
|
</button>
|
|
284
|
-
`}}Mt=new WeakMap,jn=new WeakMap,Io=new WeakMap,Po=new WeakMap,ri=new WeakSet,
|
|
284
|
+
`}}Mt=new WeakMap,jn=new WeakMap,Io=new WeakMap,Po=new WeakMap,ri=new WeakSet,ql=function(n){requestAnimationFrame(()=>{const r=u(this,jn);r&&(!u(this,Mt)&&!n||(r.scrollTop=r.scrollHeight-r.clientHeight))})},v(ov,"properties",["messages"]);customElements.define("message-history",ov);const nz=et();var un,Kl,Jl,si,ii;class Yl extends Rs{constructor(){super(...arguments);$(this,un);v(this,"placeholder","What do you want to do?");v(this,"open",!1);v(this,"messages",[]);v(this,"handleTriggerActivate",()=>{this.open=!0});v(this,"handleKeydown",n=>{if(n.key!=="Enter"||n.shiftKey)return;const r=n.currentTarget,s=r.value.trim();n.preventDefault(),s&&(r.value="",this.dispatchEvent(new nz("command-submit",{value:s,bubbles:!0,composed:!0})))});$(this,si,n=>{n.target instanceof Node&&(this.contains(n.target)||(this.open=!1))});$(this,ii,n=>{n.key==="Escape"&&(this.open=!1)})}connected(){this.open&&b(this,un,Kl).call(this)}disconnected(){b(this,un,Jl).call(this)}changed(n){if(be(this.template(),this),n.has("open"))if(this.open){b(this,un,Kl).call(this);const r=this.querySelector("textarea");r==null||r.focus()}else b(this,un,Jl).call(this)}template(){return this.open?M`
|
|
285
285
|
<message-history .messages=${this.messages}></message-history>
|
|
286
286
|
<textarea
|
|
287
287
|
class="input"
|
|
@@ -298,7 +298,7 @@ Please report this to https://github.com/markedjs/marked.`,t){let r="<p>An error
|
|
|
298
298
|
>
|
|
299
299
|
${this.placeholder}
|
|
300
300
|
</button>
|
|
301
|
-
`}}un=new WeakSet,
|
|
301
|
+
`}}un=new WeakSet,Kl=function(){document.addEventListener("mousedown",u(this,si)),document.addEventListener("keydown",u(this,ii))},Jl=function(){document.removeEventListener("mousedown",u(this,si)),document.removeEventListener("keydown",u(this,ii))},si=new WeakMap,ii=new WeakMap,v(Yl,"properties",["placeholder","open","messages"]),v(Yl,"attributes",{placeholder:{type:String},open:{type:Boolean}});customElements.define("command-panel",Yl);const el=et();class rz extends HTMLElement{constructor(){super(...arguments);v(this,"screenManager",Ve.resolve("ScreenManager"));v(this,"serverManager",Ve.resolve("ServerManager"));v(this,"handleChange",()=>{this.render()})}connectedCallback(){this.render(),this.screenManager.addEventListener("active-screen-changed",this.handleChange),this.serverManager.addEventListener("change",this.handleChange),this.serverManager.addEventListener("screens-changed",this.handleChange)}disconnectedCallback(){this.screenManager.removeEventListener("active-screen-changed",this.handleChange),this.serverManager.removeEventListener("change",this.handleChange),this.serverManager.removeEventListener("screens-changed",this.handleChange)}handleSelect(n){const r=n.value;for(const[s,i]of this.serverManager.servers)if(i.screens.has(r)){this.screenManager.setActive(s,r);return}}closeDropdown(){var n;(n=this.querySelector("dropdown-menu"))==null||n.close()}handleEditScreen(){this.screenManager.activeScreen&&(this.closeDropdown(),this.dispatchEvent(new el("edit-screen",{bubbles:!0,composed:!0})))}handleCreateScreen(n){this.closeDropdown(),this.dispatchEvent(new el("create-screen",{serverURL:n,bubbles:!0,composed:!0}))}handleDeleteScreen(){this.screenManager.activeScreen&&(this.closeDropdown(),this.dispatchEvent(new el("delete-screen",{bubbles:!0,composed:!0})))}render(){var l;const n=this.screenManager.activeScreen,r=(n==null?void 0:n.name)??"No screens",s=(n==null?void 0:n.id)??null,i=[...this.serverManager.servers.values()],o=i.flatMap(c=>[...c.screens.values()]).sort((c,d)=>c.name.localeCompare(d.name,void 0,{sensitivity:"base"})),a=((l=i[0])==null?void 0:l.url)??null;be(M`
|
|
302
302
|
<dropdown-menu
|
|
303
303
|
title=${r}
|
|
304
304
|
placement="top"
|
|
@@ -345,7 +345,7 @@ Please report this to https://github.com/markedjs/marked.`,t){let r="<p>An error
|
|
|
345
345
|
<dropdown-item value=${n.id} ?selected=${i}>
|
|
346
346
|
${o}
|
|
347
347
|
</dropdown-item>
|
|
348
|
-
`}}customElements.define("screen-picker",
|
|
348
|
+
`}}customElements.define("screen-picker",rz);var oi,Rr,Ro,Do,lv;class av extends Rs{constructor(){super(...arguments);$(this,Do);v(this,"messages",[]);$(this,oi,Ve.resolve("ACPClientManager"));$(this,Rr);$(this,Ro,n=>{const r=u(this,oi).getActiveClient();if(!r)return;const s=n.value;r.sendMessage({text:s}).catch(i=>{console.error("ACPClient.sendMessage() failed",i)})})}connected(){x(this,Rr,BD(u(this,oi),n=>{this.messages=n}))}disconnected(){var n;(n=u(this,Rr))==null||n.dispose(),x(this,Rr,void 0)}changed(){be(b(this,Do,lv).call(this),this)}}oi=new WeakMap,Rr=new WeakMap,Ro=new WeakMap,Do=new WeakSet,lv=function(){return M`
|
|
349
349
|
<screen-picker></screen-picker>
|
|
350
350
|
<command-panel
|
|
351
351
|
.messages=${this.messages}
|
|
@@ -466,7 +466,7 @@ Please report this to https://github.com/markedjs/marked.`,t){let r="<p>An error
|
|
|
466
466
|
</panel-view>
|
|
467
467
|
</section>
|
|
468
468
|
</modal-overlay>
|
|
469
|
-
`,this)}}v(hv,"observedAttributes",["open"]);customElements.define("settings-modal",hv);class dv extends Event{constructor(n){super("auth-submit",{bubbles:!0,composed:!0});v(this,"token");this.token=n}}class
|
|
469
|
+
`,this)}}v(hv,"observedAttributes",["open"]);customElements.define("settings-modal",hv);class dv extends Event{constructor(n){super("auth-submit",{bubbles:!0,composed:!0});v(this,"token");this.token=n}}class sz extends HTMLElement{constructor(){super(...arguments);v(this,"_invalid",!1);v(this,"_tokenValue","")}set invalid(n){this._invalid=n,this.render()}get invalid(){return this._invalid}set tokenValue(n){this._tokenValue=n,this.render()}get tokenValue(){return this._tokenValue}connectedCallback(){this.render()}handleInput(n){const r=n.currentTarget;this._tokenValue=r.value}handleSubmit(n){n.preventDefault();const r=this._tokenValue.trim();r&&this.dispatchEvent(new dv(r))}render(){be(M`
|
|
470
470
|
<modal-overlay open>
|
|
471
471
|
<section class="auth-modal">
|
|
472
472
|
<form class="auth-form" @submit=${n=>this.handleSubmit(n)}>
|
|
@@ -487,7 +487,7 @@ Please report this to https://github.com/markedjs/marked.`,t){let r="<p>An error
|
|
|
487
487
|
</form>
|
|
488
488
|
</section>
|
|
489
489
|
</modal-overlay>
|
|
490
|
-
`,this)}}customElements.get("auth-modal")||customElements.define("auth-modal",
|
|
490
|
+
`,this)}}customElements.get("auth-modal")||customElements.define("auth-modal",sz);class iz extends HTMLElement{constructor(){super(...arguments);v(this,"runtimeServerURL",um());v(this,"electronMode",dm());v(this,"serverManager",Ve.resolve("ServerManager"));v(this,"modals",{screenForm:{open:!1,mode:"edit"},deleteScreen:{open:!1},settings:{open:!1}});v(this,"connectError",null);v(this,"handleServerManagerChange",()=>{this.render()})}connectedCallback(){this.serverManager.addEventListener("change",this.handleServerManagerChange),this.addEventListener("auth-submit",n=>{var s;const r=n instanceof dv?n.token:n instanceof CustomEvent&&typeof((s=n.detail)==null?void 0:s.token)=="string"?n.detail.token:null;r&&this.handleAuthSubmit(r)}),this.addEventListener("edit-screen",()=>{this.modals.screenForm={open:!0,mode:"edit"},this.render()}),this.addEventListener("create-screen",n=>{const r=n.serverURL;this.modals.screenForm={open:!0,mode:"create",targetServerURL:r},this.render()}),this.addEventListener("delete-screen",()=>{this.modals.deleteScreen={open:!0},this.render()}),this.initializeConnection(),this.render()}disconnectedCallback(){this.serverManager.removeEventListener("change",this.handleServerManagerChange)}async initializeConnection(){if(this.electronMode){this.serverManager.connectConfiguredServers(this.runtimeServerURL);return}if(this.serverManager.activeServer)return;const n=new wl({url:this.runtimeServerURL,name:"Server",token:hm()});this.serverManager.add(n),this.serverManager.setActive(n);try{await n.connect(),this.connectError=null}catch(r){this.connectError=r instanceof Error&&!(r instanceof bl)?r.message:null}this.render()}async handleAuthSubmit(n){const r=this.serverManager.activeServer;if(r){this.connectError=null,r.token=n,this.updateTokenQueryParam(n);try{await r.connect()}catch(s){s instanceof bl||(this.connectError=s instanceof Error?s.message:String(s))}this.render()}}updateTokenQueryParam(n){const r=new URL(window.location.href);r.searchParams.set("token",n),window.history.replaceState({},"",`${r.pathname}${r.search}${r.hash}`)}render(){const n=this.serverManager.activeServer,r=(n==null?void 0:n.status)??null;if(r==="connecting"){be(M`
|
|
491
491
|
<main class="auth-gate"><p>Connecting...</p></main>
|
|
492
492
|
`,this);return}if(r==="disconnected"){const i=n;if(!i)return;be(M`
|
|
493
493
|
<main class="auth-gate">
|
|
@@ -517,4 +517,4 @@ Please report this to https://github.com/markedjs/marked.`,t){let r="<p>An error
|
|
|
517
517
|
?open=${this.modals.settings.open}
|
|
518
518
|
@close=${()=>{this.modals.settings={open:!1},this.render()}}
|
|
519
519
|
></settings-modal>
|
|
520
|
-
`;be(s,this)}}customElements.get("television-app")||customElements.define("television-app",
|
|
520
|
+
`;be(s,this)}}customElements.get("television-app")||customElements.define("television-app",iz);const Xc=dm(),Qo=um(),pv=new FE(Xc?"television-electron":"television-browser",UE(Qo)),fv=new RC({localStore:pv,localServerURL:Qo}),gv=new LE({localStore:pv,serverManager:fv}),oz=new pR({serverURL:Qo,token:hm()??"",screenManager:gv});Ve.register("ServerManager",()=>fv);Ve.register("ScreenManager",()=>gv);Ve.register("ACPClientManager",()=>oz);const Qc=document.createElement("television-app");Qc.runtimeServerURL=Qo;Qc.electronMode=Xc;Xc&&document.body.classList.add("electron");document.body.appendChild(Qc);
|