@telepath-computer/television 0.1.39 → 0.1.40

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 Ov=Object.defineProperty;var Sh=n=>{throw TypeError(n)};var zv=(n,e,t)=>e in n?Ov(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var b=(n,e,t)=>zv(n,typeof e!="symbol"?e+"":e,t),rl=(n,e,t)=>e.has(n)||Sh("Cannot "+t);var c=(n,e,t)=>(rl(n,e,"read from private field"),t?t.call(n):e.get(n)),S=(n,e,t)=>e.has(n)?Sh("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(n):e.set(n,t),E=(n,e,t,r)=>(rl(n,e,"write to private field"),r?r.call(n,t):e.set(n,t),t),m=(n,e,t)=>(rl(n,e,"access private method"),t);var kh=(n,e,t,r)=>({set _(i){E(n,e,i,t)},get _(){return c(n,e,r)}});(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const i of document.querySelectorAll('link[rel="modulepreload"]'))r(i);new MutationObserver(i=>{for(const s of i)if(s.type==="childList")for(const o of s.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&r(o)}).observe(document,{childList:!0,subtree:!0});function t(i){const s={};return i.integrity&&(s.integrity=i.integrity),i.referrerPolicy&&(s.referrerPolicy=i.referrerPolicy),i.crossOrigin==="use-credentials"?s.credentials="include":i.crossOrigin==="anonymous"?s.credentials="omit":s.credentials="same-origin",s}function r(i){if(i.ep)return;i.ep=!0;const s=t(i);fetch(i.href,s)}})();var In=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Lv(n){if(n.__esModule)return n;var e=n.default;if(typeof e=="function"){var t=function r(){return this instanceof r?Reflect.construct(e,arguments,this.constructor):e.apply(this,arguments)};t.prototype=e.prototype}else t={};return Object.defineProperty(t,"__esModule",{value:!0}),Object.keys(n).forEach(function(r){var i=Object.getOwnPropertyDescriptor(n,r);Object.defineProperty(t,r,i.get?i:{enumerable:!0,get:function(){return n[r]}})}),t}var Eh=Object.prototype.toString,up=function(e){var t=Eh.call(e),r=t==="[object Arguments]";return r||(r=t!=="[object Array]"&&e!==null&&typeof e=="object"&&typeof e.length=="number"&&e.length>=0&&Eh.call(e.callee)==="[object Function]"),r},il,$h;function Mv(){if($h)return il;$h=1;var n;if(!Object.keys){var e=Object.prototype.hasOwnProperty,t=Object.prototype.toString,r=up,i=Object.prototype.propertyIsEnumerable,s=!i.call({toString:null},"toString"),o=i.call(function(){},"prototype"),a=["toString","toLocaleString","valueOf","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","constructor"],l=function(v){var y=v.constructor;return y&&y.prototype===v},u={$applicationCache:!0,$console:!0,$external:!0,$frame:!0,$frameElement:!0,$frames:!0,$innerHeight:!0,$innerWidth:!0,$onmozfullscreenchange:!0,$onmozfullscreenerror:!0,$outerHeight:!0,$outerWidth:!0,$pageXOffset:!0,$pageYOffset:!0,$parent:!0,$scrollLeft:!0,$scrollTop:!0,$scrollX:!0,$scrollY:!0,$self:!0,$webkitIndexedDB:!0,$webkitStorageInfo:!0,$window:!0},d=function(){if(typeof window>"u")return!1;for(var v in window)try{if(!u["$"+v]&&e.call(window,v)&&window[v]!==null&&typeof window[v]=="object")try{l(window[v])}catch{return!0}}catch{return!0}return!1}(),f=function(v){if(typeof window>"u"||!d)return l(v);try{return l(v)}catch{return!1}};n=function(y){var A=y!==null&&typeof y=="object",k=t.call(y)==="[object Function]",I=r(y),B=A&&t.call(y)==="[object String]",P=[];if(!A&&!k&&!I)throw new TypeError("Object.keys called on a non-object");var le=o&&k;if(B&&y.length>0&&!e.call(y,0))for(var M=0;M<y.length;++M)P.push(String(M));if(I&&y.length>0)for(var Z=0;Z<y.length;++Z)P.push(String(Z));else for(var U in y)!(le&&U==="prototype")&&e.call(y,U)&&P.push(String(U));if(s)for(var ge=f(y),ce=0;ce<a.length;++ce)!(ge&&a[ce]==="constructor")&&e.call(y,a[ce])&&P.push(a[ce]);return P}}return il=n,il}var Nv=Array.prototype.slice,Uv=up,Ah=Object.keys,To=Ah?function(e){return Ah(e)}:Mv(),xh=Object.keys;To.shim=function(){if(Object.keys){var e=function(){var t=Object.keys(arguments);return t&&t.length===arguments.length}(1,2);e||(Object.keys=function(r){return Uv(r)?xh(Nv.call(r)):xh(r)})}else Object.keys=To;return Object.keys||To};var Fv=To,Co=Object.defineProperty||!1;if(Co)try{Co({},"a",{value:1})}catch{Co=!1}var Us=Co,qt=SyntaxError,G=TypeError,Zv=Object.getOwnPropertyDescriptor,Io=Zv;if(Io)try{Io([],"length")}catch{Io=null}var ii=Io,Th=Us,Hv=qt,yr=G,Ch=ii,hp=function(e,t,r){if(!e||typeof e!="object"&&typeof e!="function")throw new yr("`obj` must be an object or a function`");if(typeof t!="string"&&typeof t!="symbol")throw new yr("`property` must be a string or a symbol`");if(arguments.length>3&&typeof arguments[3]!="boolean"&&arguments[3]!==null)throw new yr("`nonEnumerable`, if provided, must be a boolean or null");if(arguments.length>4&&typeof arguments[4]!="boolean"&&arguments[4]!==null)throw new yr("`nonWritable`, if provided, must be a boolean or null");if(arguments.length>5&&typeof arguments[5]!="boolean"&&arguments[5]!==null)throw new yr("`nonConfigurable`, if provided, must be a boolean or null");if(arguments.length>6&&typeof arguments[6]!="boolean")throw new yr("`loose`, if provided, must be a boolean");var i=arguments.length>3?arguments[3]:null,s=arguments.length>4?arguments[4]:null,o=arguments.length>5?arguments[5]:null,a=arguments.length>6?arguments[6]:!1,l=!!Ch&&Ch(e,t);if(Th)Th(e,t,{configurable:o===null&&l?l.configurable:!o,enumerable:i===null&&l?l.enumerable:!i,value:r,writable:s===null&&l?l.writable:!s});else if(a||!i&&!s&&!o)e[t]=r;else throw new Hv("This environment does not support defining a property as non-configurable, non-writable, or non-enumerable.")},Yl=Us,dp=function(){return!!Yl};dp.hasArrayLengthDefineBug=function(){if(!Yl)return null;try{return Yl([],"length",{value:1}).length!==1}catch{return!0}};var Aa=dp,Vv=Fv,jv=typeof Symbol=="function"&&typeof Symbol("foo")=="symbol",Bv=Object.prototype.toString,Gv=Array.prototype.concat,Ih=hp,Wv=function(n){return typeof n=="function"&&Bv.call(n)==="[object Function]"},fp=Aa(),qv=function(n,e,t,r){if(e in n){if(r===!0){if(n[e]===t)return}else if(!Wv(r)||!r())return}fp?Ih(n,e,t,!0):Ih(n,e,t)},pp=function(n,e){var t=arguments.length>2?arguments[2]:{},r=Vv(e);jv&&(r=Gv.call(r,Object.getOwnPropertySymbols(e)));for(var i=0;i<r.length;i+=1)qv(n,r[i],e[r[i]],t[r[i]])};pp.supportsDescriptors=!!fp;var ar=pp,Po={exports:{}};typeof self<"u"?Po.exports=self:typeof window<"u"?Po.exports=window:Po.exports=Function("return this")();var gp=Po.exports,Yv=gp,mp=function(){return typeof In!="object"||!In||In.Math!==Math||In.Array!==Array?Yv:In},Kv=ar,Jv=ii,Xv=mp,Qv=function(){var e=Xv();if(Kv.supportsDescriptors){var t=Jv(e,"globalThis");(!t||t.configurable&&(t.enumerable||!t.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},eb=ar,tb=gp,yp=mp,nb=Qv,rb=yp(),vp=function(){return rb};eb(vp,{getPolyfill:yp,implementation:tb,shim:nb});var Yc=vp,Yt=function(e){return!!e&&(typeof e=="function"||typeof e=="object")},Kc=Object,bp=Error,ib=EvalError,sb=RangeError,Jc=ReferenceError,ob=URIError,ab=Math.abs,lb=Math.floor,cb=Math.max,ub=Math.min,hb=Math.pow,db=Math.round,Xc=Number.isNaN||function(e){return e!==e},fb=Xc,pb=function(e){return fb(e)||e===0?e:e<0?-1:1},si=function(){if(typeof Symbol!="function"||typeof Object.getOwnPropertySymbols!="function")return!1;if(typeof Symbol.iterator=="symbol")return!0;var e={},t=Symbol("test"),r=Object(t);if(typeof t=="string"||Object.prototype.toString.call(t)!=="[object Symbol]"||Object.prototype.toString.call(r)!=="[object Symbol]")return!1;var i=42;e[t]=i;for(var s 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]!==t||!Object.prototype.propertyIsEnumerable.call(e,t))return!1;if(typeof Object.getOwnPropertyDescriptor=="function"){var a=Object.getOwnPropertyDescriptor(e,t);if(a.value!==i||a.enumerable!==!0)return!1}return!0},Ph=typeof Symbol<"u"&&Symbol,gb=si,Qc=function(){return typeof Ph!="function"||typeof Symbol!="function"||typeof Ph("foo")!="symbol"||typeof Symbol("bar")!="symbol"?!1:gb()},wp=typeof Reflect<"u"&&Reflect.getPrototypeOf||null,mb=Kc,_p=mb.getPrototypeOf||null,yb="Function.prototype.bind called on incompatible ",vb=Object.prototype.toString,bb=Math.max,wb="[object Function]",Rh=function(e,t){for(var r=[],i=0;i<e.length;i+=1)r[i]=e[i];for(var s=0;s<t.length;s+=1)r[s+e.length]=t[s];return r},_b=function(e,t){for(var r=[],i=t,s=0;i<e.length;i+=1,s+=1)r[s]=e[i];return r},Sb=function(n,e){for(var t="",r=0;r<n.length;r+=1)t+=n[r],r+1<n.length&&(t+=e);return t},kb=function(e){var t=this;if(typeof t!="function"||vb.apply(t)!==wb)throw new TypeError(yb+t);for(var r=_b(arguments,1),i,s=function(){if(this instanceof i){var d=t.apply(this,Rh(r,arguments));return Object(d)===d?d:this}return t.apply(e,Rh(r,arguments))},o=bb(0,t.length-r.length),a=[],l=0;l<o;l++)a[l]="$"+l;if(i=Function("binder","return function ("+Sb(a,",")+"){ return binder.apply(this,arguments); }")(s),t.prototype){var u=function(){};u.prototype=t.prototype,i.prototype=new u,u.prototype=null}return i},Eb=kb,Fs=Function.prototype.bind||Eb,eu=Function.prototype.call,sl,Dh;function tu(){return Dh||(Dh=1,sl=Function.prototype.apply),sl}var $b=typeof Reflect<"u"&&Reflect&&Reflect.apply,Ab=Fs,xb=tu(),Tb=eu,Cb=$b,Sp=Cb||Ab.call(Tb,xb),Ib=Fs,Pb=G,Rb=eu,Db=Sp,xa=function(e){if(e.length<1||typeof e[0]!="function")throw new Pb("a function is required");return Db(Ib,Rb,e)},Ob=xa,Oh=ii,kp;try{kp=[].__proto__===Array.prototype}catch(n){if(!n||typeof n!="object"||!("code"in n)||n.code!=="ERR_PROTO_ACCESS")throw n}var ol=!!kp&&Oh&&Oh(Object.prototype,"__proto__"),Ep=Object,zh=Ep.getPrototypeOf,zb=ol&&typeof ol.get=="function"?Ob([ol.get]):typeof zh=="function"?function(e){return zh(e==null?e:Ep(e))}:!1,Lh=wp,Mh=_p,Nh=zb,$p=Lh?function(e){return Lh(e)}:Mh?function(e){if(!e||typeof e!="object"&&typeof e!="function")throw new TypeError("getProto: not an object");return Mh(e)}:Nh?function(e){return Nh(e)}:null,Lb=Function.prototype.call,Mb=Object.prototype.hasOwnProperty,Nb=Fs,Kt=Nb.call(Lb,Mb),j,Ub=Kc,Fb=bp,Zb=ib,Hb=sb,Vb=Jc,Jr=qt,Pr=G,jb=ob,Bb=ab,Gb=lb,Wb=cb,qb=ub,Yb=hb,Kb=db,Jb=pb,Ap=Function,al=function(n){try{return Ap('"use strict"; return ('+n+").constructor;")()}catch{}},Ki=ii,Xb=Us,ll=function(){throw new Pr},Qb=Ki?function(){try{return arguments.callee,ll}catch{try{return Ki(arguments,"callee").get}catch{return ll}}}():ll,vr=Qc(),Se=$p,ew=_p,tw=wp,xp=tu(),Zs=eu,_r={},nw=typeof Uint8Array>"u"||!Se?j:Se(Uint8Array),er={__proto__:null,"%AggregateError%":typeof AggregateError>"u"?j:AggregateError,"%Array%":Array,"%ArrayBuffer%":typeof ArrayBuffer>"u"?j:ArrayBuffer,"%ArrayIteratorPrototype%":vr&&Se?Se([][Symbol.iterator]()):j,"%AsyncFromSyncIteratorPrototype%":j,"%AsyncFunction%":_r,"%AsyncGenerator%":_r,"%AsyncGeneratorFunction%":_r,"%AsyncIteratorPrototype%":_r,"%Atomics%":typeof Atomics>"u"?j:Atomics,"%BigInt%":typeof BigInt>"u"?j:BigInt,"%BigInt64Array%":typeof BigInt64Array>"u"?j:BigInt64Array,"%BigUint64Array%":typeof BigUint64Array>"u"?j:BigUint64Array,"%Boolean%":Boolean,"%DataView%":typeof DataView>"u"?j:DataView,"%Date%":Date,"%decodeURI%":decodeURI,"%decodeURIComponent%":decodeURIComponent,"%encodeURI%":encodeURI,"%encodeURIComponent%":encodeURIComponent,"%Error%":Fb,"%eval%":eval,"%EvalError%":Zb,"%Float16Array%":typeof Float16Array>"u"?j:Float16Array,"%Float32Array%":typeof Float32Array>"u"?j:Float32Array,"%Float64Array%":typeof Float64Array>"u"?j:Float64Array,"%FinalizationRegistry%":typeof FinalizationRegistry>"u"?j:FinalizationRegistry,"%Function%":Ap,"%GeneratorFunction%":_r,"%Int8Array%":typeof Int8Array>"u"?j:Int8Array,"%Int16Array%":typeof Int16Array>"u"?j:Int16Array,"%Int32Array%":typeof Int32Array>"u"?j:Int32Array,"%isFinite%":isFinite,"%isNaN%":isNaN,"%IteratorPrototype%":vr&&Se?Se(Se([][Symbol.iterator]())):j,"%JSON%":typeof JSON=="object"?JSON:j,"%Map%":typeof Map>"u"?j:Map,"%MapIteratorPrototype%":typeof Map>"u"||!vr||!Se?j:Se(new Map()[Symbol.iterator]()),"%Math%":Math,"%Number%":Number,"%Object%":Ub,"%Object.getOwnPropertyDescriptor%":Ki,"%parseFloat%":parseFloat,"%parseInt%":parseInt,"%Promise%":typeof Promise>"u"?j:Promise,"%Proxy%":typeof Proxy>"u"?j:Proxy,"%RangeError%":Hb,"%ReferenceError%":Vb,"%Reflect%":typeof Reflect>"u"?j:Reflect,"%RegExp%":RegExp,"%Set%":typeof Set>"u"?j:Set,"%SetIteratorPrototype%":typeof Set>"u"||!vr||!Se?j:Se(new Set()[Symbol.iterator]()),"%SharedArrayBuffer%":typeof SharedArrayBuffer>"u"?j:SharedArrayBuffer,"%String%":String,"%StringIteratorPrototype%":vr&&Se?Se(""[Symbol.iterator]()):j,"%Symbol%":vr?Symbol:j,"%SyntaxError%":Jr,"%ThrowTypeError%":Qb,"%TypedArray%":nw,"%TypeError%":Pr,"%Uint8Array%":typeof Uint8Array>"u"?j:Uint8Array,"%Uint8ClampedArray%":typeof Uint8ClampedArray>"u"?j:Uint8ClampedArray,"%Uint16Array%":typeof Uint16Array>"u"?j:Uint16Array,"%Uint32Array%":typeof Uint32Array>"u"?j:Uint32Array,"%URIError%":jb,"%WeakMap%":typeof WeakMap>"u"?j:WeakMap,"%WeakRef%":typeof WeakRef>"u"?j:WeakRef,"%WeakSet%":typeof WeakSet>"u"?j:WeakSet,"%Function.prototype.call%":Zs,"%Function.prototype.apply%":xp,"%Object.defineProperty%":Xb,"%Object.getPrototypeOf%":ew,"%Math.abs%":Bb,"%Math.floor%":Gb,"%Math.max%":Wb,"%Math.min%":qb,"%Math.pow%":Yb,"%Math.round%":Kb,"%Math.sign%":Jb,"%Reflect.getPrototypeOf%":tw};if(Se)try{null.error}catch(n){var rw=Se(Se(n));er["%Error.prototype%"]=rw}var iw=function n(e){var t;if(e==="%AsyncFunction%")t=al("async function () {}");else if(e==="%GeneratorFunction%")t=al("function* () {}");else if(e==="%AsyncGeneratorFunction%")t=al("async function* () {}");else if(e==="%AsyncGenerator%"){var r=n("%AsyncGeneratorFunction%");r&&(t=r.prototype)}else if(e==="%AsyncIteratorPrototype%"){var i=n("%AsyncGenerator%");i&&Se&&(t=Se(i.prototype))}return er[e]=t,t},Uh={__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"]},Hs=Fs,Vo=Kt,sw=Hs.call(Zs,Array.prototype.concat),ow=Hs.call(xp,Array.prototype.splice),Fh=Hs.call(Zs,String.prototype.replace),jo=Hs.call(Zs,String.prototype.slice),aw=Hs.call(Zs,RegExp.prototype.exec),lw=/[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g,cw=/\\(\\)?/g,uw=function(e){var t=jo(e,0,1),r=jo(e,-1);if(t==="%"&&r!=="%")throw new Jr("invalid intrinsic syntax, expected closing `%`");if(r==="%"&&t!=="%")throw new Jr("invalid intrinsic syntax, expected opening `%`");var i=[];return Fh(e,lw,function(s,o,a,l){i[i.length]=a?Fh(l,cw,"$1"):o||s}),i},hw=function(e,t){var r=e,i;if(Vo(Uh,r)&&(i=Uh[r],r="%"+i[0]+"%"),Vo(er,r)){var s=er[r];if(s===_r&&(s=iw(r)),typeof s>"u"&&!t)throw new Pr("intrinsic "+e+" exists, but is not available. Please file an issue!");return{alias:i,name:r,value:s}}throw new Jr("intrinsic "+e+" does not exist!")},st=function(e,t){if(typeof e!="string"||e.length===0)throw new Pr("intrinsic name must be a non-empty string");if(arguments.length>1&&typeof t!="boolean")throw new Pr('"allowMissing" argument must be a boolean');if(aw(/^%?[^%]*%?$/,e)===null)throw new Jr("`%` may not be present anywhere but at the beginning and end of the intrinsic name");var r=uw(e),i=r.length>0?r[0]:"",s=hw("%"+i+"%",t),o=s.name,a=s.value,l=!1,u=s.alias;u&&(i=u[0],ow(r,sw([0,1],u)));for(var d=1,f=!0;d<r.length;d+=1){var v=r[d],y=jo(v,0,1),A=jo(v,-1);if((y==='"'||y==="'"||y==="`"||A==='"'||A==="'"||A==="`")&&y!==A)throw new Jr("property names with quotes must have matching quotes");if((v==="constructor"||!f)&&(l=!0),i+="."+v,o="%"+i+"%",Vo(er,o))a=er[o];else if(a!=null){if(!(v in a)){if(!t)throw new Pr("base intrinsic for "+e+" exists, but the property is not available.");return}if(Ki&&d+1>=r.length){var k=Ki(a,v);f=!!k,f&&"get"in k&&!("originalValue"in k.get)?a=k.get:a=a[v]}else f=Vo(a,v),a=a[v];f&&!l&&(er[o]=a)}}return a},cl,Zh;function bn(){if(Zh)return cl;Zh=1;var n=st,e=xa,t=e([n("%String.prototype.indexOf%")]);return cl=function(i,s){var o=n(i,!!s);return typeof o=="function"&&t(i,".prototype.")>-1?e([o]):o},cl}var ul,Hh;function nu(){if(Hh)return ul;Hh=1;var n=st,e=n("%Array%"),t=!e.isArray&&bn()("Object.prototype.toString");return ul=e.isArray||function(i){return t(i)==="[object Array]"},ul}var dw=Aa,Vh=Us,Tp=dw.hasArrayLengthDefineBug(),fw=Tp&&nu(),pw=bn(),gw=pw("Object.prototype.propertyIsEnumerable"),ru=function(e,t,r,i,s,o){if(!Vh){if(!e(o)||!o["[[Configurable]]"]||!o["[[Writable]]"]||s in i&&gw(i,s)!==!!o["[[Enumerable]]"])return!1;var a=o["[[Value]]"];return i[s]=a,t(i[s],a)}return Tp&&s==="length"&&"[[Value]]"in o&&fw(i)&&i.length!==o["[[Value]]"]?(i.length=o["[[Value]]"],i.length===o["[[Value]]"]):(Vh(i,s,r(o)),!0)},mw=G,_i=Kt,yw={__proto__:null,"[[Configurable]]":!0,"[[Enumerable]]":!0,"[[Get]]":!0,"[[Set]]":!0,"[[Value]]":!0,"[[Writable]]":!0},oi=function(e){if(!e||typeof e!="object")return!1;for(var t in e)if(_i(e,t)&&!yw[t])return!1;var r=_i(e,"[[Value]]")||_i(e,"[[Writable]]"),i=_i(e,"[[Get]]")||_i(e,"[[Set]]");if(r&&i)throw new mw("Property Descriptors may not be both accessor and data descriptors");return!0},Cp=function(e){if(typeof e>"u")return e;var t={};return"[[Value]]"in e&&(t.value=e["[[Value]]"]),"[[Writable]]"in e&&(t.writable=!!e["[[Writable]]"]),"[[Get]]"in e&&(t.get=e["[[Get]]"]),"[[Set]]"in e&&(t.set=e["[[Set]]"]),"[[Enumerable]]"in e&&(t.enumerable=!!e["[[Enumerable]]"]),"[[Configurable]]"in e&&(t.configurable=!!e["[[Configurable]]"]),t},vw=G,bw=oi,ww=Cp,Ip=function(e){if(typeof e<"u"&&!bw(e))throw new vw("Assertion failed: `Desc` must be a Property Descriptor");return ww(e)},_w=G,jh=Kt,Sw=oi,Pp=function(e){if(typeof e>"u")return!1;if(!Sw(e))throw new _w("Assertion failed: `Desc` must be a Property Descriptor");return!(!jh(e,"[[Value]]")&&!jh(e,"[[Writable]]"))},ai=function(e){return typeof e=="string"||typeof e=="symbol"},Bh=Xc,Rp=function(e,t){return e===t?e===0?1/e===1/t:!0:Bh(e)&&Bh(t)},Gh=G,kw=Yt,Ew=ru,$w=Ip,Aw=Pp,xw=ai,Tw=Rp,iu=function(e,t,r){if(!kw(e))throw new Gh("Assertion failed: Type(O) is not Object");if(!xw(t))throw new Gh("Assertion failed: P is not a Property Key");var i={"[[Configurable]]":!0,"[[Enumerable]]":!1,"[[Value]]":r,"[[Writable]]":!0};return Ew(Aw,Tw,$w,e,t,i)},Dp=Function.prototype.toString,Tr=typeof Reflect=="object"&&Reflect!==null&&Reflect.apply,Kl,Ro;if(typeof Tr=="function"&&typeof Object.defineProperty=="function")try{Kl=Object.defineProperty({},"length",{get:function(){throw Ro}}),Ro={},Tr(function(){throw 42},null,Kl)}catch(n){n!==Ro&&(Tr=null)}else Tr=null;var Cw=/^\s*class\b/,Jl=function(e){try{var t=Dp.call(e);return Cw.test(t)}catch{return!1}},hl=function(e){try{return Jl(e)?!1:(Dp.call(e),!0)}catch{return!1}},Do=Object.prototype.toString,Iw="[object Object]",Pw="[object Function]",Rw="[object GeneratorFunction]",Dw="[object HTMLAllCollection]",Ow="[object HTML document.all class]",zw="[object HTMLCollection]",Lw=typeof Symbol=="function"&&!!Symbol.toStringTag,Mw=!(0 in[,]),Xl=function(){return!1};if(typeof document=="object"){var Nw=document.all;Do.call(Nw)===Do.call(document.all)&&(Xl=function(e){if((Mw||!e)&&(typeof e>"u"||typeof e=="object"))try{var t=Do.call(e);return(t===Dw||t===Ow||t===zw||t===Iw)&&e("")==null}catch{}return!1})}var Op=Tr?function(e){if(Xl(e))return!0;if(!e||typeof e!="function"&&typeof e!="object")return!1;try{Tr(e,null,Kl)}catch(t){if(t!==Ro)return!1}return!Jl(e)&&hl(e)}:function(e){if(Xl(e))return!0;if(!e||typeof e!="function"&&typeof e!="object")return!1;if(Lw)return hl(e);if(Jl(e))return!1;var t=Do.call(e);return t!==Pw&&t!==Rw&&!/^\[object HTML/.test(t)?!1:hl(e)},Uw=Op,Fw=function(e){return!!e},yt=Kt,lo=G,Zw=Yt,Wh=Uw,dl=Fw,Hw=function(e){if(!Zw(e))throw new lo("ToPropertyDescriptor requires an object");var t={};if(yt(e,"enumerable")&&(t["[[Enumerable]]"]=dl(e.enumerable)),yt(e,"configurable")&&(t["[[Configurable]]"]=dl(e.configurable)),yt(e,"value")&&(t["[[Value]]"]=e.value),yt(e,"writable")&&(t["[[Writable]]"]=dl(e.writable)),yt(e,"get")){var r=e.get;if(typeof r<"u"&&!Wh(r))throw new lo("getter must be a function");t["[[Get]]"]=r}if(yt(e,"set")){var i=e.set;if(typeof i<"u"&&!Wh(i))throw new lo("setter must be a function");t["[[Set]]"]=i}if((yt(t,"[[Get]]")||yt(t,"[[Set]]"))&&(yt(t,"[[Value]]")||yt(t,"[[Writable]]")))throw new lo("Invalid property descriptor. Cannot both specify accessors and a value or writable attribute");return t},fl=G,Vw=Yt,qh=oi,jw=ru,Bw=Ip,Gw=Pp,Ww=ai,qw=Rp,Yw=Hw,Kw=function(e,t,r){if(!Vw(e))throw new fl("Assertion failed: Type(O) is not Object");if(!Ww(t))throw new fl("Assertion failed: P is not a Property Key");var i=qh(r)?r:Yw(r);if(!qh(i))throw new fl("Assertion failed: Desc is not a valid Property Descriptor");return jw(Gw,qw,Bw,e,t,i)},Yh=G,Jw=Yt,Xw=Kw,Qw=ai,e_=function(e,t,r){if(!Jw(e))throw new Yh("Assertion failed: Type(O) is not Object");if(!Qw(t))throw new Yh("Assertion failed: P is not a Property Key");var i={"[[Configurable]]":!0,"[[Enumerable]]":!1,"[[Value]]":r,"[[Writable]]":!0};return Xw(e,t,i)},t_=typeof Reflect<"u"&&Reflect.setPrototypeOf||null,n_=Kc,r_=n_.setPrototypeOf||null,i_=xa,Kh=ii,s_=G,zp={};try{zp.__proto__=null}catch(n){if(!n||typeof n!="object"||!("code"in n)||n.code!=="ERR_PROTO_ACCESS")throw n}var o_=!("toString"in zp),pl=Kh&&Kh(Object.prototype,"__proto__"),a_=o_&&(!!pl&&typeof pl.set=="function"&&i_([pl.set])||function(e,t){if(e==null)throw new s_("set Object.prototype.__proto__ called on null or undefined");return e.__proto__=t,t}),Jh=t_,l_=r_,Xh=a_,c_=G,u_=Jh?function(e,t){if(Jh(e,t))return e;throw new c_("Reflect.setPrototypeOf: failed to set [[Prototype]]")}:l_||(Xh?function(e,t){return Xh(e,t),e}:null),Qh=G,h_=Yt,ed=$p,d_=function(e){if(!h_(e))throw new Qh("Assertion failed: O must be an Object");if(!ed)throw new Qh("This environment does not support fetching prototypes.");return ed(e)},f_=G,p_=u_,g_=Yt,m_=d_,y_=function(e,t){if(t!==null&&!g_(t))throw new f_("Assertion failed: V must be Object or Null");try{p_(e,t)}catch{return!1}return m_(e)===t},gl=iu,td=e_,Lp=y_,v_=Aa(),su=bp;function Vs(n,e,t){var r=new su(t);return Lp(r,Oo),delete r.constructor,td(r,"error",n),td(r,"suppressed",e),r}v_&&Object.defineProperty(Vs,"prototype",{writable:!1});var Oo=Vs.prototype;if(!gl(Oo,"constructor",Vs)||!gl(Oo,"message","")||!gl(Oo,"name","SuppressedError"))throw new su("unable to install SuppressedError.prototype properties; please report this!");Lp(Vs.prototype,su.prototype);var b_=Vs,w_=b_,Mp=function(){return typeof SuppressedError=="function"?SuppressedError:w_},__=ar,nd=Yc(),S_=Mp,k_=function(){var e=S_();return __(nd,{SuppressedError:e},{SuppressedError:function(){return nd.SuppressedError!==e}}),e};k_();var E_=G,$_=oi,A_=Cp,x_=function(e){if(typeof e<"u"&&!$_(e))throw new E_("Assertion failed: `Desc` must be a Property Descriptor");return A_(e)},T_=G,rd=Kt,C_=oi,I_=function(e){if(typeof e>"u")return!1;if(!C_(e))throw new T_("Assertion failed: `Desc` must be a Property Descriptor");return!(!rd(e,"[[Value]]")&&!rd(e,"[[Writable]]"))},id=Xc,P_=function(e,t){return e===t?e===0?1/e===1/t:!0:id(e)&&id(t)},li=Op,R_=function(e){return!!e},vt=Kt,co=G,D_=Yt,sd=li,ml=R_,O_=function(e){if(!D_(e))throw new co("ToPropertyDescriptor requires an object");var t={};if(vt(e,"enumerable")&&(t["[[Enumerable]]"]=ml(e.enumerable)),vt(e,"configurable")&&(t["[[Configurable]]"]=ml(e.configurable)),vt(e,"value")&&(t["[[Value]]"]=e.value),vt(e,"writable")&&(t["[[Writable]]"]=ml(e.writable)),vt(e,"get")){var r=e.get;if(typeof r<"u"&&!sd(r))throw new co("getter must be a function");t["[[Get]]"]=r}if(vt(e,"set")){var i=e.set;if(typeof i<"u"&&!sd(i))throw new co("setter must be a function");t["[[Set]]"]=i}if((vt(t,"[[Get]]")||vt(t,"[[Set]]"))&&(vt(t,"[[Value]]")||vt(t,"[[Writable]]")))throw new co("Invalid property descriptor. Cannot both specify accessors and a value or writable attribute");return t},yl=G,z_=Yt,od=oi,L_=ru,M_=x_,N_=I_,U_=ai,F_=P_,Z_=O_,js=function(e,t,r){if(!z_(e))throw new yl("Assertion failed: Type(O) is not Object");if(!U_(t))throw new yl("Assertion failed: P is not a Property Key");var i=od(r)?r:Z_(r);if(!od(i))throw new yl("Assertion failed: Desc is not a valid Property Descriptor");return L_(N_,F_,M_,e,t,i)},H_=si(),V_=H_?Symbol.dispose||Symbol("Symbol.dispose"):null,j_=si,B_=V_,ou=function(){return j_()&&Symbol.dispose||B_},G_=Qc,W_=js,q_=ou,Y_=function(){var e=q_();return G_()&&W_(Symbol,"dispose",{"[[Configurable]]":!1,"[[Enumerable]]":!1,"[[Writable]]":!1,"[[Value]]":e}),e},K_=si(),J_=K_?Symbol.asyncDispose||Symbol("Symbol.asyncDispose"):null,X_=si,Q_=J_,au=function(){return X_()&&Symbol.asyncDispose||Q_},eS=Qc,tS=js,nS=au,rS=function(){var e=nS();return eS()&&tS(Symbol,"asyncDispose",{"[[Configurable]]":!1,"[[Enumerable]]":!1,"[[Writable]]":!1,"[[Value]]":e}),e},iS=nu(),sS=st,oS=bn(),aS=G,lS=iS,cS=sS("%Reflect.apply%",!0)||oS("Function.prototype.apply"),Ta=function(e,t){var r=arguments.length>2?arguments[2]:[];if(!lS(r))throw new aS("Assertion failed: optional `argumentsList`, if provided, must be a List");return cS(e,t,r)};const uS={},hS=Object.freeze(Object.defineProperty({__proto__:null,default:uS},Symbol.toStringTag,{value:"Module"})),dS=Lv(hS);var lu=typeof Map=="function"&&Map.prototype,vl=Object.getOwnPropertyDescriptor&&lu?Object.getOwnPropertyDescriptor(Map.prototype,"size"):null,Bo=lu&&vl&&typeof vl.get=="function"?vl.get:null,ad=lu&&Map.prototype.forEach,cu=typeof Set=="function"&&Set.prototype,bl=Object.getOwnPropertyDescriptor&&cu?Object.getOwnPropertyDescriptor(Set.prototype,"size"):null,Go=cu&&bl&&typeof bl.get=="function"?bl.get:null,ld=cu&&Set.prototype.forEach,fS=typeof WeakMap=="function"&&WeakMap.prototype,ji=fS?WeakMap.prototype.has:null,pS=typeof WeakSet=="function"&&WeakSet.prototype,Bi=pS?WeakSet.prototype.has:null,gS=typeof WeakRef=="function"&&WeakRef.prototype,cd=gS?WeakRef.prototype.deref:null,mS=Boolean.prototype.valueOf,yS=Object.prototype.toString,vS=Function.prototype.toString,bS=String.prototype.match,uu=String.prototype.slice,hn=String.prototype.replace,wS=String.prototype.toUpperCase,ud=String.prototype.toLowerCase,Np=RegExp.prototype.test,hd=Array.prototype.concat,$t=Array.prototype.join,_S=Array.prototype.slice,dd=Math.floor,Ql=typeof BigInt=="function"?BigInt.prototype.valueOf:null,wl=Object.getOwnPropertySymbols,ec=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?Symbol.prototype.toString:null,Xr=typeof Symbol=="function"&&typeof Symbol.iterator=="object",Gi=typeof Symbol=="function"&&Symbol.toStringTag&&(typeof Symbol.toStringTag===Xr||!0)?Symbol.toStringTag:null,Up=Object.prototype.propertyIsEnumerable,fd=(typeof Reflect=="function"?Reflect.getPrototypeOf:Object.getPrototypeOf)||([].__proto__===Array.prototype?function(n){return n.__proto__}:null);function pd(n,e){if(n===1/0||n===-1/0||n!==n||n&&n>-1e3&&n<1e3||Np.call(/e/,e))return e;var t=/[0-9](?=(?:[0-9]{3})+(?![0-9]))/g;if(typeof n=="number"){var r=n<0?-dd(-n):dd(n);if(r!==n){var i=String(r),s=uu.call(e,i.length+1);return hn.call(i,t,"$&_")+"."+hn.call(hn.call(s,/([0-9]{3})/g,"$&_"),/_$/,"")}}return hn.call(e,t,"$&_")}var tc=dS,gd=tc.custom,md=Hp(gd)?gd:null,Fp={__proto__:null,double:'"',single:"'"},SS={__proto__:null,double:/(["\\])/g,single:/(['\\])/g},ci=function n(e,t,r,i){var s=t||{};if(zt(s,"quoteStyle")&&!zt(Fp,s.quoteStyle))throw new TypeError('option "quoteStyle" must be "single" or "double"');if(zt(s,"maxStringLength")&&(typeof s.maxStringLength=="number"?s.maxStringLength<0&&s.maxStringLength!==1/0:s.maxStringLength!==null))throw new TypeError('option "maxStringLength", if provided, must be a positive integer, Infinity, or `null`');var o=zt(s,"customInspect")?s.customInspect:!0;if(typeof o!="boolean"&&o!=="symbol")throw new TypeError("option \"customInspect\", if provided, must be `true`, `false`, or `'symbol'`");if(zt(s,"indent")&&s.indent!==null&&s.indent!==" "&&!(parseInt(s.indent,10)===s.indent&&s.indent>0))throw new TypeError('option "indent" must be "\\t", an integer > 0, or `null`');if(zt(s,"numericSeparator")&&typeof s.numericSeparator!="boolean")throw new TypeError('option "numericSeparator", if provided, must be `true` or `false`');var a=s.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 jp(e,s);if(typeof e=="number"){if(e===0)return 1/0/e>0?"0":"-0";var l=String(e);return a?pd(e,l):l}if(typeof e=="bigint"){var u=String(e)+"n";return a?pd(e,u):u}var d=typeof s.depth>"u"?5:s.depth;if(typeof r>"u"&&(r=0),r>=d&&d>0&&typeof e=="object")return nc(e)?"[Array]":"[Object]";var f=FS(s,r);if(typeof i>"u")i=[];else if(Vp(i,e)>=0)return"[Circular]";function v(pt,Xt,Ba){if(Xt&&(i=_S.call(i),i.push(Xt)),Ba){var Qs={depth:s.depth};return zt(s,"quoteStyle")&&(Qs.quoteStyle=s.quoteStyle),n(pt,Qs,r+1,i)}return n(pt,s,r+1,i)}if(typeof e=="function"&&!yd(e)){var y=PS(e),A=uo(e,v);return"[Function"+(y?": "+y:" (anonymous)")+"]"+(A.length>0?" { "+$t.call(A,", ")+" }":"")}if(Hp(e)){var k=Xr?hn.call(String(e),/^(Symbol\(.*\))_[^)]*$/,"$1"):ec.call(e);return typeof e=="object"&&!Xr?Si(k):k}if(MS(e)){for(var I="<"+ud.call(String(e.nodeName)),B=e.attributes||[],P=0;P<B.length;P++)I+=" "+B[P].name+"="+Zp(kS(B[P].value),"double",s);return I+=">",e.childNodes&&e.childNodes.length&&(I+="..."),I+="</"+ud.call(String(e.nodeName))+">",I}if(nc(e)){if(e.length===0)return"[]";var le=uo(e,v);return f&&!US(le)?"["+rc(le,f)+"]":"[ "+$t.call(le,", ")+" ]"}if($S(e)){var M=uo(e,v);return!("cause"in Error.prototype)&&"cause"in e&&!Up.call(e,"cause")?"{ ["+String(e)+"] "+$t.call(hd.call("[cause]: "+v(e.cause),M),", ")+" }":M.length===0?"["+String(e)+"]":"{ ["+String(e)+"] "+$t.call(M,", ")+" }"}if(typeof e=="object"&&o){if(md&&typeof e[md]=="function"&&tc)return tc(e,{depth:d-r});if(o!=="symbol"&&typeof e.inspect=="function")return e.inspect()}if(RS(e)){var Z=[];return ad&&ad.call(e,function(pt,Xt){Z.push(v(Xt,e,!0)+" => "+v(pt,e))}),vd("Map",Bo.call(e),Z,f)}if(zS(e)){var U=[];return ld&&ld.call(e,function(pt){U.push(v(pt,e))}),vd("Set",Go.call(e),U,f)}if(DS(e))return _l("WeakMap");if(LS(e))return _l("WeakSet");if(OS(e))return _l("WeakRef");if(xS(e))return Si(v(Number(e)));if(CS(e))return Si(v(Ql.call(e)));if(TS(e))return Si(mS.call(e));if(AS(e))return Si(v(String(e)));if(typeof window<"u"&&e===window)return"{ [object Window] }";if(typeof globalThis<"u"&&e===globalThis||typeof In<"u"&&e===In)return"{ [object globalThis] }";if(!ES(e)&&!yd(e)){var ge=uo(e,v),ce=fd?fd(e)===Object.prototype:e instanceof Object||e.constructor===Object,yi=e instanceof Object?"":"null prototype",Xs=!ce&&Gi&&Object(e)===e&&Gi in e?uu.call(wn(e),8,-1):yi?"Object":"",$e=ce||typeof e.constructor!="function"?"":e.constructor.name?e.constructor.name+" ":"",kn=$e+(Xs||yi?"["+$t.call(hd.call([],Xs||[],yi||[]),": ")+"] ":"");return ge.length===0?kn+"{}":f?kn+"{"+rc(ge,f)+"}":kn+"{ "+$t.call(ge,", ")+" }"}return String(e)};function Zp(n,e,t){var r=t.quoteStyle||e,i=Fp[r];return i+n+i}function kS(n){return hn.call(String(n),/"/g,"&quot;")}function lr(n){return!Gi||!(typeof n=="object"&&(Gi in n||typeof n[Gi]<"u"))}function nc(n){return wn(n)==="[object Array]"&&lr(n)}function ES(n){return wn(n)==="[object Date]"&&lr(n)}function yd(n){return wn(n)==="[object RegExp]"&&lr(n)}function $S(n){return wn(n)==="[object Error]"&&lr(n)}function AS(n){return wn(n)==="[object String]"&&lr(n)}function xS(n){return wn(n)==="[object Number]"&&lr(n)}function TS(n){return wn(n)==="[object Boolean]"&&lr(n)}function Hp(n){if(Xr)return n&&typeof n=="object"&&n instanceof Symbol;if(typeof n=="symbol")return!0;if(!n||typeof n!="object"||!ec)return!1;try{return ec.call(n),!0}catch{}return!1}function CS(n){if(!n||typeof n!="object"||!Ql)return!1;try{return Ql.call(n),!0}catch{}return!1}var IS=Object.prototype.hasOwnProperty||function(n){return n in this};function zt(n,e){return IS.call(n,e)}function wn(n){return yS.call(n)}function PS(n){if(n.name)return n.name;var e=bS.call(vS.call(n),/^function\s*([\w$]+)/);return e?e[1]:null}function Vp(n,e){if(n.indexOf)return n.indexOf(e);for(var t=0,r=n.length;t<r;t++)if(n[t]===e)return t;return-1}function RS(n){if(!Bo||!n||typeof n!="object")return!1;try{Bo.call(n);try{Go.call(n)}catch{return!0}return n instanceof Map}catch{}return!1}function DS(n){if(!ji||!n||typeof n!="object")return!1;try{ji.call(n,ji);try{Bi.call(n,Bi)}catch{return!0}return n instanceof WeakMap}catch{}return!1}function OS(n){if(!cd||!n||typeof n!="object")return!1;try{return cd.call(n),!0}catch{}return!1}function zS(n){if(!Go||!n||typeof n!="object")return!1;try{Go.call(n);try{Bo.call(n)}catch{return!0}return n instanceof Set}catch{}return!1}function LS(n){if(!Bi||!n||typeof n!="object")return!1;try{Bi.call(n,Bi);try{ji.call(n,ji)}catch{return!0}return n instanceof WeakSet}catch{}return!1}function MS(n){return!n||typeof n!="object"?!1:typeof HTMLElement<"u"&&n instanceof HTMLElement?!0:typeof n.nodeName=="string"&&typeof n.getAttribute=="function"}function jp(n,e){if(n.length>e.maxStringLength){var t=n.length-e.maxStringLength,r="... "+t+" more character"+(t>1?"s":"");return jp(uu.call(n,0,e.maxStringLength),e)+r}var i=SS[e.quoteStyle||"single"];i.lastIndex=0;var s=hn.call(hn.call(n,i,"\\$1"),/[\x00-\x1f]/g,NS);return Zp(s,"single",e)}function NS(n){var e=n.charCodeAt(0),t={8:"b",9:"t",10:"n",12:"f",13:"r"}[e];return t?"\\"+t:"\\x"+(e<16?"0":"")+wS.call(e.toString(16))}function Si(n){return"Object("+n+")"}function _l(n){return n+" { ? }"}function vd(n,e,t,r){var i=r?rc(t,r):$t.call(t,", ");return n+" ("+e+") {"+i+"}"}function US(n){for(var e=0;e<n.length;e++)if(Vp(n[e],`
2
- `)>=0)return!1;return!0}function FS(n,e){var t;if(n.indent===" ")t=" ";else if(typeof n.indent=="number"&&n.indent>0)t=$t.call(Array(n.indent+1)," ");else return null;return{base:t,prev:$t.call(Array(e+1),t)}}function rc(n,e){if(n.length===0)return"";var t=`
1
+ var Rv=Object.defineProperty;var Eh=n=>{throw TypeError(n)};var Dv=(n,e,t)=>e in n?Rv(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var b=(n,e,t)=>Dv(n,typeof e!="symbol"?e+"":e,t),rl=(n,e,t)=>e.has(n)||Eh("Cannot "+t);var c=(n,e,t)=>(rl(n,e,"read from private field"),t?t.call(n):e.get(n)),S=(n,e,t)=>e.has(n)?Eh("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(n):e.set(n,t),E=(n,e,t,r)=>(rl(n,e,"write to private field"),r?r.call(n,t):e.set(n,t),t),m=(n,e,t)=>(rl(n,e,"access private method"),t);var $h=(n,e,t,r)=>({set _(i){E(n,e,i,t)},get _(){return c(n,e,r)}});(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const i of document.querySelectorAll('link[rel="modulepreload"]'))r(i);new MutationObserver(i=>{for(const s of i)if(s.type==="childList")for(const o of s.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&r(o)}).observe(document,{childList:!0,subtree:!0});function t(i){const s={};return i.integrity&&(s.integrity=i.integrity),i.referrerPolicy&&(s.referrerPolicy=i.referrerPolicy),i.crossOrigin==="use-credentials"?s.credentials="include":i.crossOrigin==="anonymous"?s.credentials="omit":s.credentials="same-origin",s}function r(i){if(i.ep)return;i.ep=!0;const s=t(i);fetch(i.href,s)}})();var In=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Ov(n){if(n.__esModule)return n;var e=n.default;if(typeof e=="function"){var t=function r(){return this instanceof r?Reflect.construct(e,arguments,this.constructor):e.apply(this,arguments)};t.prototype=e.prototype}else t={};return Object.defineProperty(t,"__esModule",{value:!0}),Object.keys(n).forEach(function(r){var i=Object.getOwnPropertyDescriptor(n,r);Object.defineProperty(t,r,i.get?i:{enumerable:!0,get:function(){return n[r]}})}),t}var Ah=Object.prototype.toString,up=function(e){var t=Ah.call(e),r=t==="[object Arguments]";return r||(r=t!=="[object Array]"&&e!==null&&typeof e=="object"&&typeof e.length=="number"&&e.length>=0&&Ah.call(e.callee)==="[object Function]"),r},il,xh;function zv(){if(xh)return il;xh=1;var n;if(!Object.keys){var e=Object.prototype.hasOwnProperty,t=Object.prototype.toString,r=up,i=Object.prototype.propertyIsEnumerable,s=!i.call({toString:null},"toString"),o=i.call(function(){},"prototype"),a=["toString","toLocaleString","valueOf","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","constructor"],l=function(v){var y=v.constructor;return y&&y.prototype===v},u={$applicationCache:!0,$console:!0,$external:!0,$frame:!0,$frameElement:!0,$frames:!0,$innerHeight:!0,$innerWidth:!0,$onmozfullscreenchange:!0,$onmozfullscreenerror:!0,$outerHeight:!0,$outerWidth:!0,$pageXOffset:!0,$pageYOffset:!0,$parent:!0,$scrollLeft:!0,$scrollTop:!0,$scrollX:!0,$scrollY:!0,$self:!0,$webkitIndexedDB:!0,$webkitStorageInfo:!0,$window:!0},d=function(){if(typeof window>"u")return!1;for(var v in window)try{if(!u["$"+v]&&e.call(window,v)&&window[v]!==null&&typeof window[v]=="object")try{l(window[v])}catch{return!0}}catch{return!0}return!1}(),f=function(v){if(typeof window>"u"||!d)return l(v);try{return l(v)}catch{return!1}};n=function(y){var A=y!==null&&typeof y=="object",k=t.call(y)==="[object Function]",I=r(y),G=A&&t.call(y)==="[object String]",P=[];if(!A&&!k&&!I)throw new TypeError("Object.keys called on a non-object");var le=o&&k;if(G&&y.length>0&&!e.call(y,0))for(var M=0;M<y.length;++M)P.push(String(M));if(I&&y.length>0)for(var Z=0;Z<y.length;++Z)P.push(String(Z));else for(var U in y)!(le&&U==="prototype")&&e.call(y,U)&&P.push(String(U));if(s)for(var ge=f(y),ce=0;ce<a.length;++ce)!(ge&&a[ce]==="constructor")&&e.call(y,a[ce])&&P.push(a[ce]);return P}}return il=n,il}var Lv=Array.prototype.slice,Mv=up,Th=Object.keys,To=Th?function(e){return Th(e)}:zv(),Ch=Object.keys;To.shim=function(){if(Object.keys){var e=function(){var t=Object.keys(arguments);return t&&t.length===arguments.length}(1,2);e||(Object.keys=function(r){return Mv(r)?Ch(Lv.call(r)):Ch(r)})}else Object.keys=To;return Object.keys||To};var Nv=To,Co=Object.defineProperty||!1;if(Co)try{Co({},"a",{value:1})}catch{Co=!1}var Us=Co,qt=SyntaxError,B=TypeError,Uv=Object.getOwnPropertyDescriptor,Io=Uv;if(Io)try{Io([],"length")}catch{Io=null}var ii=Io,Ih=Us,Fv=qt,yr=B,Ph=ii,hp=function(e,t,r){if(!e||typeof e!="object"&&typeof e!="function")throw new yr("`obj` must be an object or a function`");if(typeof t!="string"&&typeof t!="symbol")throw new yr("`property` must be a string or a symbol`");if(arguments.length>3&&typeof arguments[3]!="boolean"&&arguments[3]!==null)throw new yr("`nonEnumerable`, if provided, must be a boolean or null");if(arguments.length>4&&typeof arguments[4]!="boolean"&&arguments[4]!==null)throw new yr("`nonWritable`, if provided, must be a boolean or null");if(arguments.length>5&&typeof arguments[5]!="boolean"&&arguments[5]!==null)throw new yr("`nonConfigurable`, if provided, must be a boolean or null");if(arguments.length>6&&typeof arguments[6]!="boolean")throw new yr("`loose`, if provided, must be a boolean");var i=arguments.length>3?arguments[3]:null,s=arguments.length>4?arguments[4]:null,o=arguments.length>5?arguments[5]:null,a=arguments.length>6?arguments[6]:!1,l=!!Ph&&Ph(e,t);if(Ih)Ih(e,t,{configurable:o===null&&l?l.configurable:!o,enumerable:i===null&&l?l.enumerable:!i,value:r,writable:s===null&&l?l.writable:!s});else if(a||!i&&!s&&!o)e[t]=r;else throw new Fv("This environment does not support defining a property as non-configurable, non-writable, or non-enumerable.")},Jl=Us,dp=function(){return!!Jl};dp.hasArrayLengthDefineBug=function(){if(!Jl)return null;try{return Jl([],"length",{value:1}).length!==1}catch{return!0}};var Aa=dp,Zv=Nv,Hv=typeof Symbol=="function"&&typeof Symbol("foo")=="symbol",Vv=Object.prototype.toString,jv=Array.prototype.concat,Rh=hp,Gv=function(n){return typeof n=="function"&&Vv.call(n)==="[object Function]"},fp=Aa(),Bv=function(n,e,t,r){if(e in n){if(r===!0){if(n[e]===t)return}else if(!Gv(r)||!r())return}fp?Rh(n,e,t,!0):Rh(n,e,t)},pp=function(n,e){var t=arguments.length>2?arguments[2]:{},r=Zv(e);Hv&&(r=jv.call(r,Object.getOwnPropertySymbols(e)));for(var i=0;i<r.length;i+=1)Bv(n,r[i],e[r[i]],t[r[i]])};pp.supportsDescriptors=!!fp;var ar=pp,Po={exports:{}};typeof self<"u"?Po.exports=self:typeof window<"u"?Po.exports=window:Po.exports=Function("return this")();var gp=Po.exports,Wv=gp,mp=function(){return typeof In!="object"||!In||In.Math!==Math||In.Array!==Array?Wv:In},qv=ar,Yv=ii,Kv=mp,Jv=function(){var e=Kv();if(qv.supportsDescriptors){var t=Yv(e,"globalThis");(!t||t.configurable&&(t.enumerable||!t.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},Xv=ar,Qv=gp,yp=mp,eb=Jv,tb=yp(),vp=function(){return tb};Xv(vp,{getPolyfill:yp,implementation:Qv,shim:eb});var Jc=vp,Yt=function(e){return!!e&&(typeof e=="function"||typeof e=="object")},Xc=Object,bp=Error,nb=EvalError,rb=RangeError,Qc=ReferenceError,ib=URIError,sb=Math.abs,ob=Math.floor,ab=Math.max,lb=Math.min,cb=Math.pow,ub=Math.round,eu=Number.isNaN||function(e){return e!==e},hb=eu,db=function(e){return hb(e)||e===0?e:e<0?-1:1},si=function(){if(typeof Symbol!="function"||typeof Object.getOwnPropertySymbols!="function")return!1;if(typeof Symbol.iterator=="symbol")return!0;var e={},t=Symbol("test"),r=Object(t);if(typeof t=="string"||Object.prototype.toString.call(t)!=="[object Symbol]"||Object.prototype.toString.call(r)!=="[object Symbol]")return!1;var i=42;e[t]=i;for(var s 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]!==t||!Object.prototype.propertyIsEnumerable.call(e,t))return!1;if(typeof Object.getOwnPropertyDescriptor=="function"){var a=Object.getOwnPropertyDescriptor(e,t);if(a.value!==i||a.enumerable!==!0)return!1}return!0},Dh=typeof Symbol<"u"&&Symbol,fb=si,tu=function(){return typeof Dh!="function"||typeof Symbol!="function"||typeof Dh("foo")!="symbol"||typeof Symbol("bar")!="symbol"?!1:fb()},sl,Oh;function wp(){return Oh||(Oh=1,sl=typeof Reflect<"u"&&Reflect.getPrototypeOf||null),sl}var ol,zh;function _p(){if(zh)return ol;zh=1;var n=Xc;return ol=n.getPrototypeOf||null,ol}var pb="Function.prototype.bind called on incompatible ",gb=Object.prototype.toString,mb=Math.max,yb="[object Function]",Lh=function(e,t){for(var r=[],i=0;i<e.length;i+=1)r[i]=e[i];for(var s=0;s<t.length;s+=1)r[s+e.length]=t[s];return r},vb=function(e,t){for(var r=[],i=t,s=0;i<e.length;i+=1,s+=1)r[s]=e[i];return r},bb=function(n,e){for(var t="",r=0;r<n.length;r+=1)t+=n[r],r+1<n.length&&(t+=e);return t},wb=function(e){var t=this;if(typeof t!="function"||gb.apply(t)!==yb)throw new TypeError(pb+t);for(var r=vb(arguments,1),i,s=function(){if(this instanceof i){var d=t.apply(this,Lh(r,arguments));return Object(d)===d?d:this}return t.apply(e,Lh(r,arguments))},o=mb(0,t.length-r.length),a=[],l=0;l<o;l++)a[l]="$"+l;if(i=Function("binder","return function ("+bb(a,",")+"){ return binder.apply(this,arguments); }")(s),t.prototype){var u=function(){};u.prototype=t.prototype,i.prototype=new u,u.prototype=null}return i},_b=wb,Fs=Function.prototype.bind||_b,nu=Function.prototype.call,ru=Function.prototype.apply,Sb=typeof Reflect<"u"&&Reflect&&Reflect.apply,kb=Fs,Eb=ru,$b=nu,Ab=Sb,Sp=Ab||kb.call($b,Eb),xb=Fs,Tb=B,Cb=nu,Ib=Sp,xa=function(e){if(e.length<1||typeof e[0]!="function")throw new Tb("a function is required");return Ib(xb,Cb,e)},al,Mh;function Pb(){if(Mh)return al;Mh=1;var n=xa,e=ii,t;try{t=[].__proto__===Array.prototype}catch(o){if(!o||typeof o!="object"||!("code"in o)||o.code!=="ERR_PROTO_ACCESS")throw o}var r=!!t&&e&&e(Object.prototype,"__proto__"),i=Object,s=i.getPrototypeOf;return al=r&&typeof r.get=="function"?n([r.get]):typeof s=="function"?function(a){return s(a==null?a:i(a))}:!1,al}var ll,Nh;function kp(){if(Nh)return ll;Nh=1;var n=wp(),e=_p(),t=Pb();return ll=n?function(i){return n(i)}:e?function(i){if(!i||typeof i!="object"&&typeof i!="function")throw new TypeError("getProto: not an object");return e(i)}:t?function(i){return t(i)}:null,ll}var Rb=Function.prototype.call,Db=Object.prototype.hasOwnProperty,Ob=Fs,Kt=Ob.call(Rb,Db),j,zb=Xc,Lb=bp,Mb=nb,Nb=rb,Ub=Qc,Jr=qt,Pr=B,Fb=ib,Zb=sb,Hb=ob,Vb=ab,jb=lb,Gb=cb,Bb=ub,Wb=db,Ep=Function,cl=function(n){try{return Ep('"use strict"; return ('+n+").constructor;")()}catch{}},Ki=ii,qb=Us,ul=function(){throw new Pr},Yb=Ki?function(){try{return arguments.callee,ul}catch{try{return Ki(arguments,"callee").get}catch{return ul}}}():ul,vr=tu(),Se=kp(),Kb=_p(),Jb=wp(),$p=ru,Zs=nu,_r={},Xb=typeof Uint8Array>"u"||!Se?j:Se(Uint8Array),er={__proto__:null,"%AggregateError%":typeof AggregateError>"u"?j:AggregateError,"%Array%":Array,"%ArrayBuffer%":typeof ArrayBuffer>"u"?j:ArrayBuffer,"%ArrayIteratorPrototype%":vr&&Se?Se([][Symbol.iterator]()):j,"%AsyncFromSyncIteratorPrototype%":j,"%AsyncFunction%":_r,"%AsyncGenerator%":_r,"%AsyncGeneratorFunction%":_r,"%AsyncIteratorPrototype%":_r,"%Atomics%":typeof Atomics>"u"?j:Atomics,"%BigInt%":typeof BigInt>"u"?j:BigInt,"%BigInt64Array%":typeof BigInt64Array>"u"?j:BigInt64Array,"%BigUint64Array%":typeof BigUint64Array>"u"?j:BigUint64Array,"%Boolean%":Boolean,"%DataView%":typeof DataView>"u"?j:DataView,"%Date%":Date,"%decodeURI%":decodeURI,"%decodeURIComponent%":decodeURIComponent,"%encodeURI%":encodeURI,"%encodeURIComponent%":encodeURIComponent,"%Error%":Lb,"%eval%":eval,"%EvalError%":Mb,"%Float16Array%":typeof Float16Array>"u"?j:Float16Array,"%Float32Array%":typeof Float32Array>"u"?j:Float32Array,"%Float64Array%":typeof Float64Array>"u"?j:Float64Array,"%FinalizationRegistry%":typeof FinalizationRegistry>"u"?j:FinalizationRegistry,"%Function%":Ep,"%GeneratorFunction%":_r,"%Int8Array%":typeof Int8Array>"u"?j:Int8Array,"%Int16Array%":typeof Int16Array>"u"?j:Int16Array,"%Int32Array%":typeof Int32Array>"u"?j:Int32Array,"%isFinite%":isFinite,"%isNaN%":isNaN,"%IteratorPrototype%":vr&&Se?Se(Se([][Symbol.iterator]())):j,"%JSON%":typeof JSON=="object"?JSON:j,"%Map%":typeof Map>"u"?j:Map,"%MapIteratorPrototype%":typeof Map>"u"||!vr||!Se?j:Se(new Map()[Symbol.iterator]()),"%Math%":Math,"%Number%":Number,"%Object%":zb,"%Object.getOwnPropertyDescriptor%":Ki,"%parseFloat%":parseFloat,"%parseInt%":parseInt,"%Promise%":typeof Promise>"u"?j:Promise,"%Proxy%":typeof Proxy>"u"?j:Proxy,"%RangeError%":Nb,"%ReferenceError%":Ub,"%Reflect%":typeof Reflect>"u"?j:Reflect,"%RegExp%":RegExp,"%Set%":typeof Set>"u"?j:Set,"%SetIteratorPrototype%":typeof Set>"u"||!vr||!Se?j:Se(new Set()[Symbol.iterator]()),"%SharedArrayBuffer%":typeof SharedArrayBuffer>"u"?j:SharedArrayBuffer,"%String%":String,"%StringIteratorPrototype%":vr&&Se?Se(""[Symbol.iterator]()):j,"%Symbol%":vr?Symbol:j,"%SyntaxError%":Jr,"%ThrowTypeError%":Yb,"%TypedArray%":Xb,"%TypeError%":Pr,"%Uint8Array%":typeof Uint8Array>"u"?j:Uint8Array,"%Uint8ClampedArray%":typeof Uint8ClampedArray>"u"?j:Uint8ClampedArray,"%Uint16Array%":typeof Uint16Array>"u"?j:Uint16Array,"%Uint32Array%":typeof Uint32Array>"u"?j:Uint32Array,"%URIError%":Fb,"%WeakMap%":typeof WeakMap>"u"?j:WeakMap,"%WeakRef%":typeof WeakRef>"u"?j:WeakRef,"%WeakSet%":typeof WeakSet>"u"?j:WeakSet,"%Function.prototype.call%":Zs,"%Function.prototype.apply%":$p,"%Object.defineProperty%":qb,"%Object.getPrototypeOf%":Kb,"%Math.abs%":Zb,"%Math.floor%":Hb,"%Math.max%":Vb,"%Math.min%":jb,"%Math.pow%":Gb,"%Math.round%":Bb,"%Math.sign%":Wb,"%Reflect.getPrototypeOf%":Jb};if(Se)try{null.error}catch(n){var Qb=Se(Se(n));er["%Error.prototype%"]=Qb}var ew=function n(e){var t;if(e==="%AsyncFunction%")t=cl("async function () {}");else if(e==="%GeneratorFunction%")t=cl("function* () {}");else if(e==="%AsyncGeneratorFunction%")t=cl("async function* () {}");else if(e==="%AsyncGenerator%"){var r=n("%AsyncGeneratorFunction%");r&&(t=r.prototype)}else if(e==="%AsyncIteratorPrototype%"){var i=n("%AsyncGenerator%");i&&Se&&(t=Se(i.prototype))}return er[e]=t,t},Uh={__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"]},Hs=Fs,Vo=Kt,tw=Hs.call(Zs,Array.prototype.concat),nw=Hs.call($p,Array.prototype.splice),Fh=Hs.call(Zs,String.prototype.replace),jo=Hs.call(Zs,String.prototype.slice),rw=Hs.call(Zs,RegExp.prototype.exec),iw=/[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g,sw=/\\(\\)?/g,ow=function(e){var t=jo(e,0,1),r=jo(e,-1);if(t==="%"&&r!=="%")throw new Jr("invalid intrinsic syntax, expected closing `%`");if(r==="%"&&t!=="%")throw new Jr("invalid intrinsic syntax, expected opening `%`");var i=[];return Fh(e,iw,function(s,o,a,l){i[i.length]=a?Fh(l,sw,"$1"):o||s}),i},aw=function(e,t){var r=e,i;if(Vo(Uh,r)&&(i=Uh[r],r="%"+i[0]+"%"),Vo(er,r)){var s=er[r];if(s===_r&&(s=ew(r)),typeof s>"u"&&!t)throw new Pr("intrinsic "+e+" exists, but is not available. Please file an issue!");return{alias:i,name:r,value:s}}throw new Jr("intrinsic "+e+" does not exist!")},st=function(e,t){if(typeof e!="string"||e.length===0)throw new Pr("intrinsic name must be a non-empty string");if(arguments.length>1&&typeof t!="boolean")throw new Pr('"allowMissing" argument must be a boolean');if(rw(/^%?[^%]*%?$/,e)===null)throw new Jr("`%` may not be present anywhere but at the beginning and end of the intrinsic name");var r=ow(e),i=r.length>0?r[0]:"",s=aw("%"+i+"%",t),o=s.name,a=s.value,l=!1,u=s.alias;u&&(i=u[0],nw(r,tw([0,1],u)));for(var d=1,f=!0;d<r.length;d+=1){var v=r[d],y=jo(v,0,1),A=jo(v,-1);if((y==='"'||y==="'"||y==="`"||A==='"'||A==="'"||A==="`")&&y!==A)throw new Jr("property names with quotes must have matching quotes");if((v==="constructor"||!f)&&(l=!0),i+="."+v,o="%"+i+"%",Vo(er,o))a=er[o];else if(a!=null){if(!(v in a)){if(!t)throw new Pr("base intrinsic for "+e+" exists, but the property is not available.");return}if(Ki&&d+1>=r.length){var k=Ki(a,v);f=!!k,f&&"get"in k&&!("originalValue"in k.get)?a=k.get:a=a[v]}else f=Vo(a,v),a=a[v];f&&!l&&(er[o]=a)}}return a},hl,Zh;function bn(){if(Zh)return hl;Zh=1;var n=st,e=xa,t=e([n("%String.prototype.indexOf%")]);return hl=function(i,s){var o=n(i,!!s);return typeof o=="function"&&t(i,".prototype.")>-1?e([o]):o},hl}var dl,Hh;function iu(){if(Hh)return dl;Hh=1;var n=st,e=n("%Array%"),t=!e.isArray&&bn()("Object.prototype.toString");return dl=e.isArray||function(i){return t(i)==="[object Array]"},dl}var lw=Aa,Vh=Us,Ap=lw.hasArrayLengthDefineBug(),cw=Ap&&iu(),uw=bn(),hw=uw("Object.prototype.propertyIsEnumerable"),su=function(e,t,r,i,s,o){if(!Vh){if(!e(o)||!o["[[Configurable]]"]||!o["[[Writable]]"]||s in i&&hw(i,s)!==!!o["[[Enumerable]]"])return!1;var a=o["[[Value]]"];return i[s]=a,t(i[s],a)}return Ap&&s==="length"&&"[[Value]]"in o&&cw(i)&&i.length!==o["[[Value]]"]?(i.length=o["[[Value]]"],i.length===o["[[Value]]"]):(Vh(i,s,r(o)),!0)},dw=B,_i=Kt,fw={__proto__:null,"[[Configurable]]":!0,"[[Enumerable]]":!0,"[[Get]]":!0,"[[Set]]":!0,"[[Value]]":!0,"[[Writable]]":!0},oi=function(e){if(!e||typeof e!="object")return!1;for(var t in e)if(_i(e,t)&&!fw[t])return!1;var r=_i(e,"[[Value]]")||_i(e,"[[Writable]]"),i=_i(e,"[[Get]]")||_i(e,"[[Set]]");if(r&&i)throw new dw("Property Descriptors may not be both accessor and data descriptors");return!0},xp=function(e){if(typeof e>"u")return e;var t={};return"[[Value]]"in e&&(t.value=e["[[Value]]"]),"[[Writable]]"in e&&(t.writable=!!e["[[Writable]]"]),"[[Get]]"in e&&(t.get=e["[[Get]]"]),"[[Set]]"in e&&(t.set=e["[[Set]]"]),"[[Enumerable]]"in e&&(t.enumerable=!!e["[[Enumerable]]"]),"[[Configurable]]"in e&&(t.configurable=!!e["[[Configurable]]"]),t},pw=B,gw=oi,mw=xp,Tp=function(e){if(typeof e<"u"&&!gw(e))throw new pw("Assertion failed: `Desc` must be a Property Descriptor");return mw(e)},yw=B,jh=Kt,vw=oi,Cp=function(e){if(typeof e>"u")return!1;if(!vw(e))throw new yw("Assertion failed: `Desc` must be a Property Descriptor");return!(!jh(e,"[[Value]]")&&!jh(e,"[[Writable]]"))},ai=function(e){return typeof e=="string"||typeof e=="symbol"},Gh=eu,Ip=function(e,t){return e===t?e===0?1/e===1/t:!0:Gh(e)&&Gh(t)},Bh=B,bw=Yt,ww=su,_w=Tp,Sw=Cp,kw=ai,Ew=Ip,ou=function(e,t,r){if(!bw(e))throw new Bh("Assertion failed: Type(O) is not Object");if(!kw(t))throw new Bh("Assertion failed: P is not a Property Key");var i={"[[Configurable]]":!0,"[[Enumerable]]":!1,"[[Value]]":r,"[[Writable]]":!0};return ww(Sw,Ew,_w,e,t,i)},Pp=Function.prototype.toString,Tr=typeof Reflect=="object"&&Reflect!==null&&Reflect.apply,Xl,Ro;if(typeof Tr=="function"&&typeof Object.defineProperty=="function")try{Xl=Object.defineProperty({},"length",{get:function(){throw Ro}}),Ro={},Tr(function(){throw 42},null,Xl)}catch(n){n!==Ro&&(Tr=null)}else Tr=null;var $w=/^\s*class\b/,Ql=function(e){try{var t=Pp.call(e);return $w.test(t)}catch{return!1}},fl=function(e){try{return Ql(e)?!1:(Pp.call(e),!0)}catch{return!1}},Do=Object.prototype.toString,Aw="[object Object]",xw="[object Function]",Tw="[object GeneratorFunction]",Cw="[object HTMLAllCollection]",Iw="[object HTML document.all class]",Pw="[object HTMLCollection]",Rw=typeof Symbol=="function"&&!!Symbol.toStringTag,Dw=!(0 in[,]),ec=function(){return!1};if(typeof document=="object"){var Ow=document.all;Do.call(Ow)===Do.call(document.all)&&(ec=function(e){if((Dw||!e)&&(typeof e>"u"||typeof e=="object"))try{var t=Do.call(e);return(t===Cw||t===Iw||t===Pw||t===Aw)&&e("")==null}catch{}return!1})}var Rp=Tr?function(e){if(ec(e))return!0;if(!e||typeof e!="function"&&typeof e!="object")return!1;try{Tr(e,null,Xl)}catch(t){if(t!==Ro)return!1}return!Ql(e)&&fl(e)}:function(e){if(ec(e))return!0;if(!e||typeof e!="function"&&typeof e!="object")return!1;if(Rw)return fl(e);if(Ql(e))return!1;var t=Do.call(e);return t!==xw&&t!==Tw&&!/^\[object HTML/.test(t)?!1:fl(e)},zw=Rp,Lw=function(e){return!!e},yt=Kt,lo=B,Mw=Yt,Wh=zw,pl=Lw,Nw=function(e){if(!Mw(e))throw new lo("ToPropertyDescriptor requires an object");var t={};if(yt(e,"enumerable")&&(t["[[Enumerable]]"]=pl(e.enumerable)),yt(e,"configurable")&&(t["[[Configurable]]"]=pl(e.configurable)),yt(e,"value")&&(t["[[Value]]"]=e.value),yt(e,"writable")&&(t["[[Writable]]"]=pl(e.writable)),yt(e,"get")){var r=e.get;if(typeof r<"u"&&!Wh(r))throw new lo("getter must be a function");t["[[Get]]"]=r}if(yt(e,"set")){var i=e.set;if(typeof i<"u"&&!Wh(i))throw new lo("setter must be a function");t["[[Set]]"]=i}if((yt(t,"[[Get]]")||yt(t,"[[Set]]"))&&(yt(t,"[[Value]]")||yt(t,"[[Writable]]")))throw new lo("Invalid property descriptor. Cannot both specify accessors and a value or writable attribute");return t},gl=B,Uw=Yt,qh=oi,Fw=su,Zw=Tp,Hw=Cp,Vw=ai,jw=Ip,Gw=Nw,Bw=function(e,t,r){if(!Uw(e))throw new gl("Assertion failed: Type(O) is not Object");if(!Vw(t))throw new gl("Assertion failed: P is not a Property Key");var i=qh(r)?r:Gw(r);if(!qh(i))throw new gl("Assertion failed: Desc is not a valid Property Descriptor");return Fw(Hw,jw,Zw,e,t,i)},Yh=B,Ww=Yt,qw=Bw,Yw=ai,Kw=function(e,t,r){if(!Ww(e))throw new Yh("Assertion failed: Type(O) is not Object");if(!Yw(t))throw new Yh("Assertion failed: P is not a Property Key");var i={"[[Configurable]]":!0,"[[Enumerable]]":!1,"[[Value]]":r,"[[Writable]]":!0};return qw(e,t,i)},Jw=typeof Reflect<"u"&&Reflect.setPrototypeOf||null,Xw=Xc,Qw=Xw.setPrototypeOf||null,e_=xa,Kh=ii,t_=B,Dp={};try{Dp.__proto__=null}catch(n){if(!n||typeof n!="object"||!("code"in n)||n.code!=="ERR_PROTO_ACCESS")throw n}var n_=!("toString"in Dp),ml=Kh&&Kh(Object.prototype,"__proto__"),r_=n_&&(!!ml&&typeof ml.set=="function"&&e_([ml.set])||function(e,t){if(e==null)throw new t_("set Object.prototype.__proto__ called on null or undefined");return e.__proto__=t,t}),Jh=Jw,i_=Qw,Xh=r_,s_=B,o_=Jh?function(e,t){if(Jh(e,t))return e;throw new s_("Reflect.setPrototypeOf: failed to set [[Prototype]]")}:i_||(Xh?function(e,t){return Xh(e,t),e}:null),Qh=B,a_=Yt,ed=kp(),l_=function(e){if(!a_(e))throw new Qh("Assertion failed: O must be an Object");if(!ed)throw new Qh("This environment does not support fetching prototypes.");return ed(e)},c_=B,u_=o_,h_=Yt,d_=l_,f_=function(e,t){if(t!==null&&!h_(t))throw new c_("Assertion failed: V must be Object or Null");try{u_(e,t)}catch{return!1}return d_(e)===t},yl=ou,td=Kw,Op=f_,p_=Aa(),au=bp;function Vs(n,e,t){var r=new au(t);return Op(r,Oo),delete r.constructor,td(r,"error",n),td(r,"suppressed",e),r}p_&&Object.defineProperty(Vs,"prototype",{writable:!1});var Oo=Vs.prototype;if(!yl(Oo,"constructor",Vs)||!yl(Oo,"message","")||!yl(Oo,"name","SuppressedError"))throw new au("unable to install SuppressedError.prototype properties; please report this!");Op(Vs.prototype,au.prototype);var g_=Vs,m_=g_,zp=function(){return typeof SuppressedError=="function"?SuppressedError:m_},y_=ar,nd=Jc(),v_=zp,b_=function(){var e=v_();return y_(nd,{SuppressedError:e},{SuppressedError:function(){return nd.SuppressedError!==e}}),e};b_();var w_=B,__=oi,S_=xp,k_=function(e){if(typeof e<"u"&&!__(e))throw new w_("Assertion failed: `Desc` must be a Property Descriptor");return S_(e)},E_=B,rd=Kt,$_=oi,A_=function(e){if(typeof e>"u")return!1;if(!$_(e))throw new E_("Assertion failed: `Desc` must be a Property Descriptor");return!(!rd(e,"[[Value]]")&&!rd(e,"[[Writable]]"))},id=eu,x_=function(e,t){return e===t?e===0?1/e===1/t:!0:id(e)&&id(t)},li=Rp,T_=function(e){return!!e},vt=Kt,co=B,C_=Yt,sd=li,vl=T_,I_=function(e){if(!C_(e))throw new co("ToPropertyDescriptor requires an object");var t={};if(vt(e,"enumerable")&&(t["[[Enumerable]]"]=vl(e.enumerable)),vt(e,"configurable")&&(t["[[Configurable]]"]=vl(e.configurable)),vt(e,"value")&&(t["[[Value]]"]=e.value),vt(e,"writable")&&(t["[[Writable]]"]=vl(e.writable)),vt(e,"get")){var r=e.get;if(typeof r<"u"&&!sd(r))throw new co("getter must be a function");t["[[Get]]"]=r}if(vt(e,"set")){var i=e.set;if(typeof i<"u"&&!sd(i))throw new co("setter must be a function");t["[[Set]]"]=i}if((vt(t,"[[Get]]")||vt(t,"[[Set]]"))&&(vt(t,"[[Value]]")||vt(t,"[[Writable]]")))throw new co("Invalid property descriptor. Cannot both specify accessors and a value or writable attribute");return t},bl=B,P_=Yt,od=oi,R_=su,D_=k_,O_=A_,z_=ai,L_=x_,M_=I_,js=function(e,t,r){if(!P_(e))throw new bl("Assertion failed: Type(O) is not Object");if(!z_(t))throw new bl("Assertion failed: P is not a Property Key");var i=od(r)?r:M_(r);if(!od(i))throw new bl("Assertion failed: Desc is not a valid Property Descriptor");return R_(O_,L_,D_,e,t,i)},N_=si(),U_=N_?Symbol.dispose||Symbol("Symbol.dispose"):null,F_=si,Z_=U_,lu=function(){return F_()&&Symbol.dispose||Z_},H_=tu,V_=js,j_=lu,G_=function(){var e=j_();return H_()&&V_(Symbol,"dispose",{"[[Configurable]]":!1,"[[Enumerable]]":!1,"[[Writable]]":!1,"[[Value]]":e}),e},B_=si(),W_=B_?Symbol.asyncDispose||Symbol("Symbol.asyncDispose"):null,q_=si,Y_=W_,cu=function(){return q_()&&Symbol.asyncDispose||Y_},K_=tu,J_=js,X_=cu,Q_=function(){var e=X_();return K_()&&J_(Symbol,"asyncDispose",{"[[Configurable]]":!1,"[[Enumerable]]":!1,"[[Writable]]":!1,"[[Value]]":e}),e},eS=iu(),tS=st,nS=bn(),rS=B,iS=eS,sS=tS("%Reflect.apply%",!0)||nS("Function.prototype.apply"),Ta=function(e,t){var r=arguments.length>2?arguments[2]:[];if(!iS(r))throw new rS("Assertion failed: optional `argumentsList`, if provided, must be a List");return sS(e,t,r)};const oS={},aS=Object.freeze(Object.defineProperty({__proto__:null,default:oS},Symbol.toStringTag,{value:"Module"})),lS=Ov(aS);var uu=typeof Map=="function"&&Map.prototype,wl=Object.getOwnPropertyDescriptor&&uu?Object.getOwnPropertyDescriptor(Map.prototype,"size"):null,Go=uu&&wl&&typeof wl.get=="function"?wl.get:null,ad=uu&&Map.prototype.forEach,hu=typeof Set=="function"&&Set.prototype,_l=Object.getOwnPropertyDescriptor&&hu?Object.getOwnPropertyDescriptor(Set.prototype,"size"):null,Bo=hu&&_l&&typeof _l.get=="function"?_l.get:null,ld=hu&&Set.prototype.forEach,cS=typeof WeakMap=="function"&&WeakMap.prototype,ji=cS?WeakMap.prototype.has:null,uS=typeof WeakSet=="function"&&WeakSet.prototype,Gi=uS?WeakSet.prototype.has:null,hS=typeof WeakRef=="function"&&WeakRef.prototype,cd=hS?WeakRef.prototype.deref:null,dS=Boolean.prototype.valueOf,fS=Object.prototype.toString,pS=Function.prototype.toString,gS=String.prototype.match,du=String.prototype.slice,hn=String.prototype.replace,mS=String.prototype.toUpperCase,ud=String.prototype.toLowerCase,Lp=RegExp.prototype.test,hd=Array.prototype.concat,$t=Array.prototype.join,yS=Array.prototype.slice,dd=Math.floor,tc=typeof BigInt=="function"?BigInt.prototype.valueOf:null,Sl=Object.getOwnPropertySymbols,nc=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?Symbol.prototype.toString:null,Xr=typeof Symbol=="function"&&typeof Symbol.iterator=="object",Bi=typeof Symbol=="function"&&Symbol.toStringTag&&(typeof Symbol.toStringTag===Xr||!0)?Symbol.toStringTag:null,Mp=Object.prototype.propertyIsEnumerable,fd=(typeof Reflect=="function"?Reflect.getPrototypeOf:Object.getPrototypeOf)||([].__proto__===Array.prototype?function(n){return n.__proto__}:null);function pd(n,e){if(n===1/0||n===-1/0||n!==n||n&&n>-1e3&&n<1e3||Lp.call(/e/,e))return e;var t=/[0-9](?=(?:[0-9]{3})+(?![0-9]))/g;if(typeof n=="number"){var r=n<0?-dd(-n):dd(n);if(r!==n){var i=String(r),s=du.call(e,i.length+1);return hn.call(i,t,"$&_")+"."+hn.call(hn.call(s,/([0-9]{3})/g,"$&_"),/_$/,"")}}return hn.call(e,t,"$&_")}var rc=lS,gd=rc.custom,md=Fp(gd)?gd:null,Np={__proto__:null,double:'"',single:"'"},vS={__proto__:null,double:/(["\\])/g,single:/(['\\])/g},ci=function n(e,t,r,i){var s=t||{};if(zt(s,"quoteStyle")&&!zt(Np,s.quoteStyle))throw new TypeError('option "quoteStyle" must be "single" or "double"');if(zt(s,"maxStringLength")&&(typeof s.maxStringLength=="number"?s.maxStringLength<0&&s.maxStringLength!==1/0:s.maxStringLength!==null))throw new TypeError('option "maxStringLength", if provided, must be a positive integer, Infinity, or `null`');var o=zt(s,"customInspect")?s.customInspect:!0;if(typeof o!="boolean"&&o!=="symbol")throw new TypeError("option \"customInspect\", if provided, must be `true`, `false`, or `'symbol'`");if(zt(s,"indent")&&s.indent!==null&&s.indent!==" "&&!(parseInt(s.indent,10)===s.indent&&s.indent>0))throw new TypeError('option "indent" must be "\\t", an integer > 0, or `null`');if(zt(s,"numericSeparator")&&typeof s.numericSeparator!="boolean")throw new TypeError('option "numericSeparator", if provided, must be `true` or `false`');var a=s.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 Hp(e,s);if(typeof e=="number"){if(e===0)return 1/0/e>0?"0":"-0";var l=String(e);return a?pd(e,l):l}if(typeof e=="bigint"){var u=String(e)+"n";return a?pd(e,u):u}var d=typeof s.depth>"u"?5:s.depth;if(typeof r>"u"&&(r=0),r>=d&&d>0&&typeof e=="object")return ic(e)?"[Array]":"[Object]";var f=LS(s,r);if(typeof i>"u")i=[];else if(Zp(i,e)>=0)return"[Circular]";function v(pt,Xt,Ga){if(Xt&&(i=yS.call(i),i.push(Xt)),Ga){var Qs={depth:s.depth};return zt(s,"quoteStyle")&&(Qs.quoteStyle=s.quoteStyle),n(pt,Qs,r+1,i)}return n(pt,s,r+1,i)}if(typeof e=="function"&&!yd(e)){var y=xS(e),A=uo(e,v);return"[Function"+(y?": "+y:" (anonymous)")+"]"+(A.length>0?" { "+$t.call(A,", ")+" }":"")}if(Fp(e)){var k=Xr?hn.call(String(e),/^(Symbol\(.*\))_[^)]*$/,"$1"):nc.call(e);return typeof e=="object"&&!Xr?Si(k):k}if(DS(e)){for(var I="<"+ud.call(String(e.nodeName)),G=e.attributes||[],P=0;P<G.length;P++)I+=" "+G[P].name+"="+Up(bS(G[P].value),"double",s);return I+=">",e.childNodes&&e.childNodes.length&&(I+="..."),I+="</"+ud.call(String(e.nodeName))+">",I}if(ic(e)){if(e.length===0)return"[]";var le=uo(e,v);return f&&!zS(le)?"["+sc(le,f)+"]":"[ "+$t.call(le,", ")+" ]"}if(_S(e)){var M=uo(e,v);return!("cause"in Error.prototype)&&"cause"in e&&!Mp.call(e,"cause")?"{ ["+String(e)+"] "+$t.call(hd.call("[cause]: "+v(e.cause),M),", ")+" }":M.length===0?"["+String(e)+"]":"{ ["+String(e)+"] "+$t.call(M,", ")+" }"}if(typeof e=="object"&&o){if(md&&typeof e[md]=="function"&&rc)return rc(e,{depth:d-r});if(o!=="symbol"&&typeof e.inspect=="function")return e.inspect()}if(TS(e)){var Z=[];return ad&&ad.call(e,function(pt,Xt){Z.push(v(Xt,e,!0)+" => "+v(pt,e))}),vd("Map",Go.call(e),Z,f)}if(PS(e)){var U=[];return ld&&ld.call(e,function(pt){U.push(v(pt,e))}),vd("Set",Bo.call(e),U,f)}if(CS(e))return kl("WeakMap");if(RS(e))return kl("WeakSet");if(IS(e))return kl("WeakRef");if(kS(e))return Si(v(Number(e)));if($S(e))return Si(v(tc.call(e)));if(ES(e))return Si(dS.call(e));if(SS(e))return Si(v(String(e)));if(typeof window<"u"&&e===window)return"{ [object Window] }";if(typeof globalThis<"u"&&e===globalThis||typeof In<"u"&&e===In)return"{ [object globalThis] }";if(!wS(e)&&!yd(e)){var ge=uo(e,v),ce=fd?fd(e)===Object.prototype:e instanceof Object||e.constructor===Object,yi=e instanceof Object?"":"null prototype",Xs=!ce&&Bi&&Object(e)===e&&Bi in e?du.call(wn(e),8,-1):yi?"Object":"",$e=ce||typeof e.constructor!="function"?"":e.constructor.name?e.constructor.name+" ":"",kn=$e+(Xs||yi?"["+$t.call(hd.call([],Xs||[],yi||[]),": ")+"] ":"");return ge.length===0?kn+"{}":f?kn+"{"+sc(ge,f)+"}":kn+"{ "+$t.call(ge,", ")+" }"}return String(e)};function Up(n,e,t){var r=t.quoteStyle||e,i=Np[r];return i+n+i}function bS(n){return hn.call(String(n),/"/g,"&quot;")}function lr(n){return!Bi||!(typeof n=="object"&&(Bi in n||typeof n[Bi]<"u"))}function ic(n){return wn(n)==="[object Array]"&&lr(n)}function wS(n){return wn(n)==="[object Date]"&&lr(n)}function yd(n){return wn(n)==="[object RegExp]"&&lr(n)}function _S(n){return wn(n)==="[object Error]"&&lr(n)}function SS(n){return wn(n)==="[object String]"&&lr(n)}function kS(n){return wn(n)==="[object Number]"&&lr(n)}function ES(n){return wn(n)==="[object Boolean]"&&lr(n)}function Fp(n){if(Xr)return n&&typeof n=="object"&&n instanceof Symbol;if(typeof n=="symbol")return!0;if(!n||typeof n!="object"||!nc)return!1;try{return nc.call(n),!0}catch{}return!1}function $S(n){if(!n||typeof n!="object"||!tc)return!1;try{return tc.call(n),!0}catch{}return!1}var AS=Object.prototype.hasOwnProperty||function(n){return n in this};function zt(n,e){return AS.call(n,e)}function wn(n){return fS.call(n)}function xS(n){if(n.name)return n.name;var e=gS.call(pS.call(n),/^function\s*([\w$]+)/);return e?e[1]:null}function Zp(n,e){if(n.indexOf)return n.indexOf(e);for(var t=0,r=n.length;t<r;t++)if(n[t]===e)return t;return-1}function TS(n){if(!Go||!n||typeof n!="object")return!1;try{Go.call(n);try{Bo.call(n)}catch{return!0}return n instanceof Map}catch{}return!1}function CS(n){if(!ji||!n||typeof n!="object")return!1;try{ji.call(n,ji);try{Gi.call(n,Gi)}catch{return!0}return n instanceof WeakMap}catch{}return!1}function IS(n){if(!cd||!n||typeof n!="object")return!1;try{return cd.call(n),!0}catch{}return!1}function PS(n){if(!Bo||!n||typeof n!="object")return!1;try{Bo.call(n);try{Go.call(n)}catch{return!0}return n instanceof Set}catch{}return!1}function RS(n){if(!Gi||!n||typeof n!="object")return!1;try{Gi.call(n,Gi);try{ji.call(n,ji)}catch{return!0}return n instanceof WeakSet}catch{}return!1}function DS(n){return!n||typeof n!="object"?!1:typeof HTMLElement<"u"&&n instanceof HTMLElement?!0:typeof n.nodeName=="string"&&typeof n.getAttribute=="function"}function Hp(n,e){if(n.length>e.maxStringLength){var t=n.length-e.maxStringLength,r="... "+t+" more character"+(t>1?"s":"");return Hp(du.call(n,0,e.maxStringLength),e)+r}var i=vS[e.quoteStyle||"single"];i.lastIndex=0;var s=hn.call(hn.call(n,i,"\\$1"),/[\x00-\x1f]/g,OS);return Up(s,"single",e)}function OS(n){var e=n.charCodeAt(0),t={8:"b",9:"t",10:"n",12:"f",13:"r"}[e];return t?"\\"+t:"\\x"+(e<16?"0":"")+mS.call(e.toString(16))}function Si(n){return"Object("+n+")"}function kl(n){return n+" { ? }"}function vd(n,e,t,r){var i=r?sc(t,r):$t.call(t,", ");return n+" ("+e+") {"+i+"}"}function zS(n){for(var e=0;e<n.length;e++)if(Zp(n[e],`
2
+ `)>=0)return!1;return!0}function LS(n,e){var t;if(n.indent===" ")t=" ";else if(typeof n.indent=="number"&&n.indent>0)t=$t.call(Array(n.indent+1)," ");else return null;return{base:t,prev:$t.call(Array(e+1),t)}}function sc(n,e){if(n.length===0)return"";var t=`
3
3
  `+e.prev+e.base;return t+$t.call(n,","+t)+`
4
- `+e.prev}function uo(n,e){var t=nc(n),r=[];if(t){r.length=n.length;for(var i=0;i<n.length;i++)r[i]=zt(n,i)?e(n[i],n):""}var s=typeof wl=="function"?wl(n):[],o;if(Xr){o={};for(var a=0;a<s.length;a++)o["$"+s[a]]=s[a]}for(var l in n)zt(n,l)&&(t&&String(Number(l))===l&&l<n.length||Xr&&o["$"+l]instanceof Symbol||(Np.call(/[^\w$]/,l)?r.push(e(l,n)+": "+e(n[l],n)):r.push(l+": "+e(n[l],n))));if(typeof wl=="function")for(var u=0;u<s.length;u++)Up.call(n,s[u])&&r.push("["+e(s[u])+"]: "+e(n[s[u]],n));return r}var ZS=ci,HS=G,Ca=function(n,e,t){for(var r=n,i;(i=r.next)!=null;r=i)if(i.key===e)return r.next=i.next,t||(i.next=n.next,n.next=i),i},VS=function(n,e){if(n){var t=Ca(n,e);return t&&t.value}},jS=function(n,e,t){var r=Ca(n,e);r?r.value=t:n.next={key:e,next:n.next,value:t}},BS=function(n,e){return n?!!Ca(n,e):!1},GS=function(n,e){if(n)return Ca(n,e,!0)},WS=function(){var e,t={assert:function(r){if(!t.has(r))throw new HS("Side channel does not contain "+ZS(r))},delete:function(r){var i=e&&e.next,s=GS(e,r);return s&&i&&i===s&&(e=void 0),!!s},get:function(r){return VS(e,r)},has:function(r){return BS(e,r)},set:function(r,i){e||(e={next:void 0}),jS(e,r,i)}};return t},qS=st,Bs=bn(),YS=ci,KS=G,bd=qS("%Map%",!0),JS=Bs("Map.prototype.get",!0),XS=Bs("Map.prototype.set",!0),QS=Bs("Map.prototype.has",!0),ek=Bs("Map.prototype.delete",!0),tk=Bs("Map.prototype.size",!0),Bp=!!bd&&function(){var e,t={assert:function(r){if(!t.has(r))throw new KS("Side channel does not contain "+YS(r))},delete:function(r){if(e){var i=ek(e,r);return tk(e)===0&&(e=void 0),i}return!1},get:function(r){if(e)return JS(e,r)},has:function(r){return e?QS(e,r):!1},set:function(r,i){e||(e=new bd),XS(e,r,i)}};return t},nk=st,Ia=bn(),rk=ci,ho=Bp,ik=G,br=nk("%WeakMap%",!0),sk=Ia("WeakMap.prototype.get",!0),ok=Ia("WeakMap.prototype.set",!0),ak=Ia("WeakMap.prototype.has",!0),lk=Ia("WeakMap.prototype.delete",!0),ck=br?function(){var e,t,r={assert:function(i){if(!r.has(i))throw new ik("Side channel does not contain "+rk(i))},delete:function(i){if(br&&i&&(typeof i=="object"||typeof i=="function")){if(e)return lk(e,i)}else if(ho&&t)return t.delete(i);return!1},get:function(i){return br&&i&&(typeof i=="object"||typeof i=="function")&&e?sk(e,i):t&&t.get(i)},has:function(i){return br&&i&&(typeof i=="object"||typeof i=="function")&&e?ak(e,i):!!t&&t.has(i)},set:function(i,s){br&&i&&(typeof i=="object"||typeof i=="function")?(e||(e=new br),ok(e,i,s)):ho&&(t||(t=ho()),t.set(i,s))}};return r}:ho,uk=G,hk=ci,dk=WS,fk=Bp,pk=ck,gk=pk||fk||dk,mk=function(){var e,t={assert:function(r){if(!t.has(r))throw new uk("Side channel does not contain "+hk(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,i){e||(e=gk()),e.set(r,i)}};return t},yk=Kt,ki=mk(),Rt=G,hu={assert:function(n,e){if(!n||typeof n!="object"&&typeof n!="function")throw new Rt("`O` is not an object");if(typeof e!="string")throw new Rt("`slot` must be a string");if(ki.assert(n),!hu.has(n,e))throw new Rt("`"+e+"` is not present on `O`")},get:function(n,e){if(!n||typeof n!="object"&&typeof n!="function")throw new Rt("`O` is not an object");if(typeof e!="string")throw new Rt("`slot` must be a string");var t=ki.get(n);return t&&t["$"+e]},has:function(n,e){if(!n||typeof n!="object"&&typeof n!="function")throw new Rt("`O` is not an object");if(typeof e!="string")throw new Rt("`slot` must be a string");var t=ki.get(n);return!!t&&yk(t,"$"+e)},set:function(n,e,t){if(!n||typeof n!="object"&&typeof n!="function")throw new Rt("`O` is not an object");if(typeof e!="string")throw new Rt("`slot` must be a string");var r=ki.get(n);r||(r={},ki.set(n,r)),r["$"+e]=t}};Object.freeze&&Object.freeze(hu);var du=hu,Gp=qt,dn=du,Gs=function n(e,t){if(!(this instanceof n))return new n(e,t);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"');dn.set(this,"[[Type]]",e),dn.set(this,"[[Value]]",t)};Gs.prototype.type=function(){return dn.get(this,"[[Type]]")};Gs.prototype.value=function(){return dn.get(this,"[[Value]]")};Gs.prototype["?"]=function(){var e=dn.get(this,"[[Type]]"),t=dn.get(this,"[[Value]]");if(e==="throw")throw t;return t};Gs.prototype["!"]=function(){var e=dn.get(this,"[[Type]]");if(e!=="normal")throw new Gp('Assertion failed: Completion Record is not of type "normal"');return dn.get(this,"[[Value]]")};var fu=Gs,vk=fu,pu=function(e){return new vk("normal",e)},Sl,wd;function bk(){if(wd)return Sl;wd=1;var n=si;return Sl=function(){return n()&&!!Symbol.toStringTag},Sl}var wk=st,_d=wk("%Object.defineProperty%",!0),_k=bk()(),Sk=Kt,kk=G,fo=_k?Symbol.toStringTag:null,Wp=function(e,t){var r=arguments.length>2&&!!arguments[2]&&arguments[2].force,i=arguments.length>2&&!!arguments[2]&&arguments[2].nonConfigurable;if(typeof r<"u"&&typeof r!="boolean"||typeof i<"u"&&typeof i!="boolean")throw new kk("if provided, the `overrideIfSet` and `nonConfigurable` options must be booleans");fo&&(r||!Sk(e,fo))&&(_d?_d(e,fo,{configurable:!i,enumerable:!1,value:t,writable:!1}):e[fo]=t)},qp={exports:{}},Ek=st,Sd=hp,$k=Aa(),kd=ii,Ed=G,Ak=Ek("%Math.floor%"),xk=function(e,t){if(typeof e!="function")throw new Ed("`fn` is not a function");if(typeof t!="number"||t<0||t>4294967295||Ak(t)!==t)throw new Ed("`length` must be a positive 32-bit integer");var r=arguments.length>2&&!!arguments[2],i=!0,s=!0;if("length"in e&&kd){var o=kd(e,"length");o&&!o.configurable&&(i=!1),o&&!o.writable&&(s=!1)}return(i||s||!r)&&($k?Sd(e,"length",t,!0,!0):Sd(e,"length",t)),e},Tk=Fs,Ck=tu(),Ik=Sp,Pk=function(){return Ik(Tk,Ck,arguments)};(function(n){var e=xk,t=Us,r=xa,i=Pk;n.exports=function(o){var a=r(arguments),l=1+o.length-(arguments.length-1);return e(a,l>0?l:0,!0)},t?t(n.exports,"apply",{value:i}):n.exports.apply=i})(qp);var gu=qp.exports,Rk=function(e,t){for(var r=0;r<e.length;r+=1)if(!t(e[r],r,e))return!1;return!0},Dk=Object,Ok=function(e){return e&&typeof e=="object"&&(typeof e["[[ResourceValue]]"]>"u"||Dk(e["[[ResourceValue]]"])===e["[[ResourceValue]]"])&&(e["[[Hint]]"]==="SYNC-DISPOSE"||e["[[Hint]]"]==="ASYNC-DISPOSE")&&(typeof e["[[DisposeMethod]]"]=="function"||typeof e["[[DisposeMethod]]"]>"u")},zk=Kt,Lk=nu(),Mk=Rk,Nk=Ok,Uk=function(e){return e&&typeof e=="object"&&zk(e,"[[DisposableResourceStack]]")&&Lk(e["[[DisposableResourceStack]]"])&&(e["[[DisposableResourceStack]]"].length===0||Mk(e["[[DisposableResourceStack]]"],Nk))},Fk=Yt,Zk=function(e){if(e===null)return"Null";if(typeof e>"u")return"Undefined";if(Fk(e))return"Object";if(typeof e=="number")return"Number";if(typeof e=="boolean")return"Boolean";if(typeof e=="string")return"String"},Hk=Zk,mu=function(e){return typeof e=="symbol"?"Symbol":typeof e=="bigint"?"BigInt":Hk(e)},Vk=G,jk=ci,Bk=ai,Gk=function(e,t){if(!Bk(t))throw new Vk("Assertion failed: P is not a Property Key, got "+jk(t));return e[t]},$d=G,Wk=Gk,qk=li,Yk=ai,Ad=ci,Kk=function(e,t){if(!Yk(t))throw new $d("Assertion failed: P is not a Property Key");var r=Wk(e,t);if(r!=null){if(!qk(r))throw new $d(Ad(t)+" is not a function: "+Ad(r));return r}},ic={exports:{}},Jk=st,Xk=Jk,xd=Xk("%Reflect.construct%",!0),Wo=js;try{Wo({},"",{"[[Get]]":function(){}})}catch{Wo=null}if(Wo&&xd){var Td={},Cd={};Wo(Cd,"length",{"[[Get]]":function(){throw Td},"[[Enumerable]]":!0}),ic.exports=function(e){try{xd(e,Cd)}catch(t){return t===Td}}}else ic.exports=function(e){return typeof e=="function"&&!!e.prototype};var Qk=ic.exports,kl=G,Id=li,eE=Qk,tE=function(e){if(!eE(e))throw new kl("C must be a constructor");var t={"[[Resolve]]":void 0,"[[Reject]]":void 0},r=new e(function(i,s){if(typeof t["[[Resolve]]"]<"u"||typeof t["[[Reject]]"]<"u")throw new kl("executor has already been called");t["[[Resolve]]"]=i,t["[[Reject]]"]=s});if(!Id(t["[[Resolve]]"])||!Id(t["[[Reject]]"]))throw new kl("executor must provide valid resolve and reject functions");return{"[[Promise]]":r,"[[Resolve]]":t["[[Resolve]]"],"[[Reject]]":t["[[Reject]]"]}},Pd=qt,nE=G,El=Ta,Rd=Kk,rE=tE,iE=mu,Dd=ou(),Od=au(),sE=function(e,t){if(iE(e)!=="Object")throw new nE("`V` must be an Object");if(t!=="SYNC-DISPOSE"&&t!=="ASYNC-DISPOSE")throw new Pd("Assertion failed: `hint` must be `~SYNC-DISPOSE~` or `~ASYNC-DISPOSE~`");var r;if(t==="ASYNC-DISPOSE"&&Od&&(r=Rd(e,Od)),!r){if(!Dd)throw new Pd("`Symbol.dispose` is not supported");if(r=Rd(e,Dd),typeof r<"u")return function(){var i=this;if(t==="ASYNC-DISPOSE"){var s=rE(Promise);try{El(r,i),El(s["[[Resolve]]"],void 0,[void 0])}catch(o){s["[[Reject]]"](o)}return s["[[Promise]]"]}El(r,i)}}return r},oE=qt,$l=G,aE=li,lE=mu,cE=sE,uE=function(e,t){if(t!=="SYNC-DISPOSE"&&t!=="ASYNC-DISPOSE")throw new oE("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"&&lE(e)!=="Object")throw new $l("`V` must be an Object, or `null` or `undefined`");if(r=cE(e,t),typeof r>"u")throw new $l("dispose method must not be `undefined` on `V` when an object `V` is provided")}else if(r=arguments[2],!aE(r))throw new $l("`method`, when provided, must be a function");return{"[[ResourceValue]]":e,"[[Hint]]":t,"[[DisposeMethod]]":r}},hE=qt,po=G,dE=Uk,zd=uE,fE=bn(),pE=fE("Array.prototype.push"),Yp=function(e,t,r){if(!dE(e))throw new po("Assertion failed: `disposeCapability` must be a DisposeCapability Record");if(r!=="SYNC-DISPOSE"&&r!=="ASYNC-DISPOSE")throw new hE("Assertion failed: `hint` must be `~SYNC-DISPOSE~` or `~ASYNC-DISPOSE~`");var i=arguments.length>3?arguments[3]:void 0;if(arguments.length>3&&typeof i!="function")throw new po("Assertion failed: `method`, when present, must be a function");if(!e["[[DisposableResourceStack]]"])throw new po("Assertion failed: `disposeCapability.[[DisposableResourceStack]]` must not be ~EMPTY~");var s;if(arguments.length<4){if(t==null&&r==="SYNC_DISPOSE")return"UNUSED";s=zd(t,r)}else{if(typeof t<"u")throw new po("Assertion failed: `V` must be undefined when `method` is present");s=zd(void 0,r,i)}return pE(e["[[DisposableResourceStack]]"],s),"UNUSED"},Al,Ld;function yu(){if(Ld)return Al;Ld=1;var n=st,e=gu,t=qt,r=n("%Promise.resolve%",!0),i=r&&e(r);return Al=function(o,a){if(!i)throw new t("This environment does not support Promises.");return i(o,a)},Al}var xl,Md;function gE(){if(Md)return xl;Md=1;var n=st,e=qt,t=n("%Promise%",!0),r=Ta,i=yu(),s=mu;return xl=function(a,l,u){if(typeof a<"u"&&s(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 u<"u"&&typeof u!="function")throw new e("Assertion failed: `method` must be `undefined` or a function");var d=typeof u>"u"?u:r(u,a);if(l==="ASYNC-DISPOSE")return i(t,d)},xl}var Tl,Nd;function mE(){if(Nd)return Tl;Nd=1;var n=fu;return Tl=function(t){return new n("throw",t)},Tl}var yE=st,Cl=qt,Ud=G,vE=yE("%Promise%",!0),bE=bn(),Fd=bE("Promise.prototype.then",!0),wE=fu,Zd=gE(),_E=pu,SE=yu(),Hd=mE(),kE=Mp(),Kp=function(e,t){if(!(t instanceof wE))throw new Ud("`completion` must be a Completion Record");var r=e["[[DisposableResourceStack]]"];if(!r)throw new Ud("Assertion failed: `disposeCapability.[[DisposableResourceStack]]` must not be ~EMPTY~");for(var i,s=r.length-1;s>=0;s-=1)if(!i)i=r[s]["[[Hint]]"];else if(i!==r[s]["[[Hint]]"])throw new Cl("mixed hint stacks are not supported");for(var o=i==="ASYNC-DISPOSE"&&SE(vE,t),a=function(v){if(t.type()==="throw"){var y=t.value(),A=new kE(v,y);t=Hd(A)}else t=Hd(v)},l=i==="ASYNC-DISPOSE"&&function(y){return Fd(o,function(){var A=Zd(y["[[ResourceValue]]"],y["[[Hint]]"],y["[[DisposeMethod]]"]);if(!A)throw new Cl("Assertion failed: non-`~ASYNC-DISPOSE~` resource returned a promise from Dispose");return Fd(A,_E)},a)},u=r.length-1;u>=0;u-=1)if(i==="ASYNC-DISPOSE")o=l(r[u]);else{var d=r[u];try{var f=Zd(d["[[ResourceValue]]"],d["[[Hint]]"],d["[[DisposeMethod]]"]);if(f)throw new Cl("Assertion failed: `~SYNC-DISPOSE~` resource returned something from Dispose")}catch(v){a(v)}}return e["[[DisposableResourceStack]]"]=null,i==="ASYNC-DISPOSE"?o:t},Jp=function(){var e=[];return{"[[DisposableResourceStack]]":e}},Pa=Jc,vu=G,EE=Ta,ui=iu,$E=js,Xp=li,AE=pu,je=du,xE=Wp,Qp=ar.supportsDescriptors,TE=gu,bu=Yp,CE=Kp,eg=Jp,Vd=ou(),tt=function n(){if(!(this instanceof n)||je.has(this,"[[DisposableState]]")||je.has(this,"[[DisposeCapability]]"))throw new vu("can only be used with new");je.set(this,"[[DisposableState]]","PENDING"),je.set(this,"[[DisposeCapability]]",eg())},tg=function(){var e=this;return je.assert(e,"[[DisposableState]]"),je.get(e,"[[DisposableState]]")==="DISPOSED"},Ws=TE(tg);Qp?$E(tt.prototype,"disposed",{"[[Configurable]]":!0,"[[Enumerable]]":!1,"[[Get]]":tg}):tt.prototype.disposed=!1;var ng=function(e){je.set(e,"[[DisposableState]]","DISPOSED"),Qp||(e.disposed=!0)};ui(tt.prototype,"dispose",function(){var e=this;if(!Ws(e))return ng(e),CE(je.get(e,"[[DisposeCapability]]"),AE())["?"]()});ui(tt.prototype,"use",function(e){var t=this;if(Ws(t))throw new Pa("a disposed stack can not use anything new");return bu(je.get(t,"[[DisposeCapability]]"),e,"SYNC-DISPOSE"),e});ui(tt.prototype,"adopt",function(e,t){var r=this;if(Ws(r))throw new Pa("a disposed stack can not use anything new");if(!Xp(t))throw new vu("`onDispose` must be a function");var i=function(){return EE(t,void 0,[e])};return bu(je.get(r,"[[DisposeCapability]]"),void 0,"SYNC-DISPOSE",i),e});ui(tt.prototype,"defer",function(e){var t=this;if(Ws(t))throw new Pa("a disposed stack can not defer anything new");if(!Xp(e))throw new vu("`onDispose` must be a function");bu(je.get(t,"[[DisposeCapability]]"),void 0,"SYNC-DISPOSE",e)});ui(tt.prototype,"move",function(){var e=this;if(Ws(e))throw new Pa("a disposed stack can not use anything new");var t=new tt;return je.set(t,"[[DisposeCapability]]",je.get(e,"[[DisposeCapability]]")),je.set(e,"[[DisposeCapability]]",eg()),ng(e),t});Vd&&ui(tt.prototype,Vd,tt.prototype.dispose);xE(tt.prototype,"DisposableStack");var IE=tt,PE=IE,RE=function(){return typeof DisposableStack=="function"?DisposableStack:PE},DE=ar,OE=Yc(),zE=RE,LE=function(){var e=zE();return DE(OE,{DisposableStack:e},{DisposableStack:!0}),e},ME=st,Ra=Jc,wu=G,jd=ME("%Promise%",!0),_u=Yp,NE=Ta,hi=iu,UE=js,FE=Kp,rg=li,ig=Jp,ZE=pu,Bd=yu(),Be=du,HE=Wp,sg=ar.supportsDescriptors,VE=gu,jE=bn(),BE=jE("Promise.prototype.then",!0),Gd=au(),nt=function n(){if(!(this instanceof n)||Be.has(this,"[[AsyncDisposableState]]")||Be.has(this,"[[DisposeCapability]]"))throw new wu("can only be used with new");Be.set(this,"[[AsyncDisposableState]]","pending"),Be.set(this,"[[DisposeCapability]]",ig())},og=function(){var e=this;return Be.assert(e,"[[AsyncDisposableState]]"),Be.get(e,"[[AsyncDisposableState]]")==="disposed"},qs=VE(og);sg?UE(nt.prototype,"disposed",{"[[Configurable]]":!0,"[[Enumerable]]":!1,"[[Get]]":og}):nt.prototype.disposed=!1;var ag=function(e){Be.set(e,"[[AsyncDisposableState]]","disposed"),sg||(e.disposed=!0)};hi(nt.prototype,"disposeAsync",function(){var e=this;return qs(e)?Bd(jd):(ag(e),BE(Bd(jd,FE(Be.get(e,"[[DisposeCapability]]"),ZE())),function(t){return t["?"]()}))});hi(nt.prototype,"use",function(e){var t=this;if(qs(t))throw new Ra("a disposed stack can not use anything new");return _u(Be.get(t,"[[DisposeCapability]]"),e,"ASYNC-DISPOSE"),e});hi(nt.prototype,"adopt",function(e,t){var r=this;if(qs(r))throw new Ra("a disposed stack can not use anything new");if(!rg(t))throw new wu("`onDisposeAsync` must be a function");var i=function(){return NE(t,void 0,[e])};return i.value=e,_u(Be.get(r,"[[DisposeCapability]]"),void 0,"ASYNC-DISPOSE",i),e});hi(nt.prototype,"defer",function(e){var t=this;if(qs(t))throw new Ra("a disposed stack can not defer anything new");if(!rg(e))throw new wu("`onDispose` must be a function");_u(Be.get(t,"[[DisposeCapability]]"),void 0,"ASYNC-DISPOSE",e)});hi(nt.prototype,"move",function(){var e=this;if(qs(e))throw new Ra("a disposed stack can not use anything new");var t=new nt;return Be.set(t,"[[DisposeCapability]]",Be.get(e,"[[DisposeCapability]]")),Be.set(e,"[[DisposeCapability]]",ig()),ag(e),t});Gd&&hi(nt.prototype,Gd,nt.prototype.disposeAsync);HE(nt.prototype,"AsyncDisposableStack");var GE=nt,WE=GE,qE=function(){return typeof AsyncDisposableStack=="function"?AsyncDisposableStack:WE},YE=ar,KE=Yc(),JE=qE,XE=function(){var e=JE();return YE(KE,{AsyncDisposableStack:e},{AsyncDisposableStack:!0}),e},QE=Y_,e0=rS,t0=LE,n0=XE,r0=function(){QE(),e0(),t0(),n0()};r0();const Wd=new WeakMap;function i0(n){return(typeof n=="object"||typeof n=="function")&&n!==null&&"then"in n&&typeof n.then=="function"}function wr(n){return typeof n=="string"?n:typeof n=="symbol"?n.description??n.toString():n.name||"(anonymous class)"}function qd(){return new Error("register(Key, factory) requires a factory function. Wrap existing instances as () => instance.")}function s0(){return new Error("register(Key, factory) does not accept async factories. Await setup before registering.")}class o0{constructor(){b(this,"entries",new Map);b(this,"constructionStack",[])}register(e,t){if(t===void 0){if(typeof e!="function")throw qd();this.validateClassRegistration(e),this.storeFactory(e,()=>this.instantiateClass(e));return}if(typeof t!="function")throw qd();if(t.constructor.name==="AsyncFunction")throw s0();this.storeFactory(e,t)}has(e){var t;return((t=this.entries.get(e))==null?void 0:t.factory)!==void 0}resolve(e){return this.resolveAny(e)}storeFactory(e,t){const r=this.getOrCreateEntry(e);r.factory=t,r.instance=void 0,r.error=void 0}validateClassRegistration(e){const t=Wd.get(e);if(t){if(e.length!==t.length)throw new Error(`${wr(e)} cannot be registered with register(Class). @injectable(...) declared ${t.length} dependencies but constructor arity is ${e.length}. Use register(Key, () => value) instead.`);return}if(e.length!==0)throw new Error(`${wr(e)} cannot be registered with register(Class). Undecorated classes must have zero required constructor parameters. Use register(Key, () => value) instead.`)}instantiateClass(e){const t=Wd.get(e);if(!t)return new e;const r=t.map(i=>this.resolveAny(i));return new e(...r)}resolveAny(e){return this.getOrCreateEntry(e).proxy}getOrCreateEntry(e){let t=this.entries.get(e);return t||(t={key:e},t.proxy=this.createProxy(t),this.entries.set(e,t),t)}createProxy(e){return new Proxy({},{get:(t,r)=>{if(r==="then")return;const i=this.getInstance(e),s=Reflect.get(i,r,i);return typeof s=="function"?s.bind(i):s},set:(t,r,i)=>{const s=this.getInstance(e);return Reflect.set(s,r,i,s)},has:(t,r)=>{const i=this.getInstance(e);return r in i}})}getInstance(e){if(e.instance)return e.instance;if(e.error)throw e.error;if(!e.factory)throw new Error(`${wr(e.key)} was resolved but never registered`);const t=this.constructionStack.indexOf(e.key);if(t!==-1){const r=[...this.constructionStack.slice(t),e.key].map(i=>wr(i)).join(" -> ");throw new Error(`Circular dependency detected: ${r}`)}this.constructionStack.push(e.key);try{const r=e.factory();if(i0(r))throw new Error(`Factory for ${wr(e.key)} returned a Promise. Await setup before registering.`);if(typeof r!="object"||r===null)throw new Error(`Factory for ${wr(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 rt=new o0,a0=new Set(["target","currentTarget","eventPhase","defaultPrevented","isTrusted","timeStamp","srcElement","returnValue","cancelBubble","NONE","CAPTURING_PHASE","AT_TARGET","BUBBLING_PHASE","composedPath","stopPropagation","stopImmediatePropagation","preventDefault","initEvent"]);function l0(n){for(const e of Object.keys(n))if(a0.has(e))throw new Error(`Event payload key "${e}" is reserved; choose a different property name`)}function c0(n,e){l0(e);for(const t of Object.keys(e))Object.defineProperty(n,t,{value:e[t],writable:!0,enumerable:!0,configurable:!0})}function xt(){class n extends Event{constructor(t,r){const{type:i,bubbles:s,cancelable:o,composed:a,...l}=r??{};if(i!==void 0)throw new Error('Do not pass "type" in init; use the constructor argument instead');super(t,{bubbles:s,cancelable:o,composed:a}),c0(this,l)}}return n}class Tt extends globalThis.EventTarget{}function u0(n,e,t){const r=n.dispose.bind(n);n.dispose=()=>{if(!e())return t(),r()}}function di(n){var t;class e extends n{constructor(...s){super(...s);S(this,t,!1);u0(this,()=>c(this,t),()=>{E(this,t,!0)})}[Symbol.dispose](){this.dispose()}get disposed(){return c(this,t)}}return t=new WeakMap,e}const h0=xt(),zo=xt(),lg="0123456789ABCDEFGHJKMNPQRSTVWXYZ",qo=32,d0=16,cg=10,Yd=0xffffffffffff;var zn;(function(n){n.Base32IncorrectEncoding="B32_ENC_INVALID",n.DecodeTimeInvalidCharacter="DEC_TIME_CHAR",n.DecodeTimeValueMalformed="DEC_TIME_MALFORMED",n.EncodeTimeNegative="ENC_TIME_NEG",n.EncodeTimeSizeExceeded="ENC_TIME_SIZE_EXCEED",n.EncodeTimeValueMalformed="ENC_TIME_MALFORMED",n.PRNGDetectFailure="PRNG_DETECT",n.ULIDInvalid="ULID_INVALID",n.Unexpected="UNEXPECTED",n.UUIDInvalid="UUID_INVALID"})(zn||(zn={}));class Oi extends Error{constructor(e,t){super(`${t} (${e})`),this.name="ULIDError",this.code=e}}function f0(n){const e=Math.floor(n()*qo)%qo;return lg.charAt(e)}function p0(n){const e=g0(),t=e&&(e.crypto||e.msCrypto)||null;if(typeof(t==null?void 0:t.getRandomValues)=="function")return()=>{const r=new Uint8Array(1);return t.getRandomValues(r),r[0]/256};if(typeof(t==null?void 0:t.randomBytes)=="function")return()=>t.randomBytes(1).readUInt8()/256;throw new Oi(zn.PRNGDetectFailure,"Failed to find a reliable PRNG")}function g0(){return v0()?self:typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:null}function m0(n,e){let t="";for(;n>0;n--)t=f0(e)+t;return t}function y0(n,e=cg){if(isNaN(n))throw new Oi(zn.EncodeTimeValueMalformed,`Time must be a number: ${n}`);if(n>Yd)throw new Oi(zn.EncodeTimeSizeExceeded,`Cannot encode a time larger than ${Yd}: ${n}`);if(n<0)throw new Oi(zn.EncodeTimeNegative,`Time must be positive: ${n}`);if(Number.isInteger(n)===!1)throw new Oi(zn.EncodeTimeValueMalformed,`Time must be an integer: ${n}`);let t,r="";for(let i=e;i>0;i--)t=n%qo,r=lg.charAt(t)+r,n=(n-t)/qo;return r}function v0(){return typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope}function Su(n,e){const t=p0(),r=Date.now();return y0(r,cg)+m0(d0,t)}const At=4,Je=6,ug=2,sc=2,b0=At,w0=Je,ku="auto",fn="auto",Pn=120,Kd=75,pe=16,tr=Pn*At+pe*(At-1),Yo=Pn*Je+pe*(Je-1),_0=200,S0=4,go=150,k0=10,Jd=2,E0=4;function hg(n){return pg(n)}function dg(n,e){return pg(n.flatMap(t=>mg(t,e)))}function fg(n){const e=[],t=new Set;for(const r of n){if(r.type==="row"){e.push(`Top-level rows are invalid: ${r.id}`);continue}yg(r,"strip",e,t)}return{valid:e.length===0,errors:e}}function Wi(n){const e=hg(n),t=fg(e);if(!t.valid)throw new Error(`Invalid layout: ${t.errors.join("; ")}`);return{totalNodes:e.length,nodes:e.filter(r=>r.type!=="row").map(T0)}}function pg(n){const e=[];for(const t of n){const r=gg(t);for(const i of r){if(i.type==="row"){e.push(...i.children.map(Gt));continue}e.push(i)}}return e}function gg(n){switch(n.type){case"card":return[Gt(n)];case"row":{const e=n.children.map(Gt);return e.length===0?[]:e.length===1?[e[0]]:[{...n,children:e}]}case"stack":{const e=[];for(const t of n.children){const r=gg(t);for(const i of r){if(i.type==="stack"){e.push(...i.children.map(oc));continue}if(i.type==="row"){e.push({...i,children:i.children.map(Gt)});continue}e.push(Gt(i))}}return e.length===0?[]:e.length===1?[oc(e[0])]:[{...n,children:e}]}}}function mg(n,e){switch(n.type){case"card":return n.artifactID===e?[]:[Gt(n)];case"row":{const t=n.children.filter(r=>r.artifactID!==e).map(Gt);return t.length===0?[]:t.length===1?[t[0]]:[{...n,children:t}]}case"stack":{const t=n.children.flatMap(r=>mg(r,e).filter(s=>s.type!=="stack"));return t.length===0?[]:t.length===1?[oc(t[0])]:[{...n,children:t}]}}}function yg(n,e,t,r){switch(n.type){case"card":vg(n,e,t,r);return;case"row":$0(n,e,t,r);return;case"stack":A0(n,e,t,r);return}}function vg(n,e,t,r){Eu(n.id,t),typeof n.artifactID!="string"||n.artifactID.length===0?t.push(`Card ${n.id} is missing artifactID`):r.has(n.artifactID)?t.push(`Duplicate artifactID in layout: ${n.artifactID}`):r.add(n.artifactID),x0(n.width)||t.push(`Card ${n.id} width must be an integer in the range 2-4`),bg(n.height)||t.push(`Card ${n.id} height must be an integer in the range 2-6 or "auto"`);const i=Rn(n.width);e==="row"&&i<ug&&t.push(`Row child ${n.id} must be at least 2 columns wide`)}function $0(n,e,t,r){if(Eu(n.id,t),e!=="stack"&&t.push(`Row ${n.id} may only appear inside a stack`),bg(n.height,E0)||t.push(`Row ${n.id} height must be an integer in the range 2-4 or "auto"`),!Array.isArray(n.children)||n.children.length===0){t.push(`Row ${n.id} must contain card nodes`);return}let i=0;for(const s of n.children){if(s.type!=="card"){t.push(`Row ${n.id} must contain only card nodes`);continue}vg(s,"row",t,r),i+=Rn(s.width)}i!==At&&t.push(`Row ${n.id} children must sum to 4 columns`)}function A0(n,e,t,r){if(Eu(n.id,t),e!=="strip"&&t.push(`Invalid nested stack at ${n.id}; stack children cannot contain another nested stack`),!Array.isArray(n.children)||n.children.length===0){t.push(`Stack ${n.id} must contain at least one child`);return}let i=0,s=0;for(const a of n.children){if(a.type==="stack"){t.push(`Stack ${n.id} cannot contain another nested stack`);continue}if(yg(a,"stack",t,r),a.height===fn){s+=1;continue}i+=a.height}if(i>Je&&t.push(`Stack ${n.id} exceeds the 6-row budget`),s===0)return;const o=Je-i;if(o<s*sc||o%s!==0){t.push(`Stack ${n.id} has auto-height children that cannot resolve to whole height >= 2`);return}o/s<sc&&t.push(`Stack ${n.id} has auto-height children below the minimum row size`)}function Eu(n,e){(typeof n!="string"||n.length===0)&&e.push(`Node id must be a non-empty string: ${String(n)}`)}function x0(n){return n===ku||Number.isInteger(n)&&n>=ug&&n<=b0}function bg(n,e=w0){return n===fn||Number.isInteger(n)&&n>=sc&&n<=e}function Rn(n){return n===ku?At:n}function T0(n){if(n.type==="card")return{id:n.id,type:"card",width:Rn(n.width),cards:[{id:n.id,artifactID:n.artifactID,col:1,row:1,width:Rn(n.width),height:wg(n.height,Je)}]};const e=C0(n.children),t=[];let r=1;for(let i=0;i<n.children.length;i+=1){const s=n.children[i],o=e[i];if(s.type==="card")t.push({id:s.id,artifactID:s.artifactID,col:1,row:r,width:Rn(s.width),height:o});else{let a=1;for(const l of s.children)t.push({id:l.id,artifactID:l.artifactID,col:a,row:r,width:Rn(l.width),height:o}),a+=Rn(l.width)}r+=o}return{id:n.id,type:"stack",width:t.reduce((i,s)=>Math.max(i,s.col+s.width-1),1),cards:t}}function C0(n){let e=0,t=0;for(const i of n)i.height===fn?t+=1:e+=i.height;const r=t>0?(Je-e)/t:0;return n.map(i=>wg(i.height,r))}function wg(n,e){return n===fn?e:n}function Gt(n){return{...n}}function oc(n){return n.type==="card"?Gt(n):{...n,children:n.children.map(Gt)}}function _g(n,e={}){return{id:e.id??Su(),type:"card",artifactID:n,width:e.width??ku,height:e.height??fn}}function Sg(n,e){return n.some(t=>kg(t,e))}function kg(n,e){switch(n.type){case"card":return n.artifactID===e;case"row":return n.children.some(t=>t.artifactID===e);case"stack":return n.children.some(t=>kg(t,e))}}function Xd(n){return n.layout.flatMap(Eg)}function Eg(n){switch(n.type){case"card":return[n.artifactID];case"row":return n.children.map(e=>e.artifactID);case"stack":return n.children.flatMap(Eg)}}const Q=xt(),$g=xt(),Ei=xt(),I0=xt();function P0(n){class e extends Error{constructor(r,i){super(r),this.name=n,i&&Object.assign(this,i)}}return e}const R0=P0("RequestError"),D0=200,O0=300;class z0{constructor(e,t){b(this,"serverURL");b(this,"token");this.serverURL=e.replace(/\/$/,""),this.token=t.token}async requestJSON(e,t,r){const i=await this.request(e,t,r!==void 0?JSON.stringify(r):void 0,r!==void 0?{"content-type":"application/json"}:void 0),s=await L0(i);if(!i.ok||i.status<D0||i.status>=O0)throw this.createError(typeof s.error=="string"?s.error:i.statusText,i.status);return s}async requestVoid(e,t){const r=await this.request(e,t);if(!r.ok)throw this.createError(await Il(r,r.statusText),r.status)}async requestText(e,t){const r=await this.request(e,t);if(!r.ok)throw this.createError(await Il(r,r.statusText),r.status);return r.text()}async requestRawVoid(e,t,r){const i=await this.request(e,t,r,{"content-type":"text/plain"});if(!i.ok)throw this.createError(await Il(i,i.statusText),i.status)}createError(e,t){const r={serverURL:this.serverURL};return t!==void 0&&(r.status=t),new R0(e,r)}async request(e,t,r,i){const s=`${this.serverURL}${t}`;try{return await fetch(s,{method:e,headers:this.buildHeaders(i),body:r})}catch(o){throw this.createError(o instanceof Error?o.message:"Failed to reach server")}}buildHeaders(e){const t={...e??{}};return this.token&&(t.Authorization=`Bearer ${this.token}`),Object.keys(t).length>0?t:void 0}}async function L0(n){try{return await n.json()}catch{const e=await n.text().catch(()=>"");return e?{message:e}:{}}}async function Il(n,e){try{const t=await n.json();if(typeof t.error=="string")return t.error;if(typeof t.message=="string")return t.message}catch{}return e}function Ag(n){return n.map(e=>`${e.name} (${e.id})`).join(", ")}var _t,aa,xg;class M0{constructor(e){S(this,aa);S(this,_t);E(this,_t,e)}list(){return c(this,_t).requestJSON("GET","/screens")}async get(e={}){const t=await m(this,aa,xg).call(this,e.screenID);return c(this,_t).requestJSON("GET",`/screens/${encodeURIComponent(t)}`)}create(e){const t={name:e.name};return e.id!==void 0&&(t.id=e.id),c(this,_t).requestJSON("POST","/screens",t)}update(e){const t={};return e.name!==void 0&&(t.name=e.name),e.layout!==void 0&&(t.layout=e.layout),c(this,_t).requestJSON("PATCH",`/screens/${encodeURIComponent(e.screenID)}`,t)}remove(e){return c(this,_t).requestJSON("DELETE",`/screens/${encodeURIComponent(e.screenID)}`)}}_t=new WeakMap,aa=new WeakSet,xg=async function(e){if(e!==void 0)return e;const{screens:t}=await this.list();if(t.length===1)return t[0].id;throw c(this,_t).createError(`screenID is required when multiple screens exist. Available screens: ${Ag(t)}`)};var Ze,ns,la,Tg;class N0{constructor(e,t){S(this,la);S(this,Ze);S(this,ns);E(this,Ze,e),E(this,ns,t)}async create(e){const t=await m(this,la,Tg).call(this,e.screenID);return c(this,Ze).requestJSON("POST",`/screens/${encodeURIComponent(t)}/artifact`,{type:e.type,title:e.title,externalFilePath:e.externalFilePath})}get(e){return c(this,Ze).requestJSON("GET",`/artifacts/${encodeURIComponent(e.artifactID)}`)}update(e){const t={};return e.title!==void 0&&(t.title=e.title),c(this,Ze).requestJSON("PATCH",`/artifacts/${encodeURIComponent(e.artifactID)}`,t)}edit(e){return c(this,Ze).requestJSON("POST",`/artifacts/${encodeURIComponent(e.artifactID)}/edit`)}commitPending(e){return c(this,Ze).requestJSON("POST",`/artifacts/${encodeURIComponent(e.artifactID)}/commit`)}abandonPending(e){return c(this,Ze).requestVoid("POST",`/artifacts/${encodeURIComponent(e.artifactID)}/abandon`)}remove(e){return c(this,Ze).requestJSON("DELETE",`/screens/${encodeURIComponent(e.screenID)}/artifacts/${encodeURIComponent(e.artifactID)}`)}getContent(e){return c(this,Ze).requestText("GET",`/artifacts/${encodeURIComponent(e.artifactID)}/content`)}putContent(e){return c(this,Ze).requestRawVoid("PUT",`/artifacts/${encodeURIComponent(e.artifactID)}/content`,e.content)}}Ze=new WeakMap,ns=new WeakMap,la=new WeakSet,Tg=async function(e){if(e!==void 0)return e;const{screens:t}=await c(this,ns).list();if(t.length===1)return t[0].id;throw c(this,Ze).createError(`screenID is required when multiple screens exist. Available screens: ${Ag(t)}`)};var rs;class U0{constructor(e){S(this,rs);E(this,rs,e)}async list(){const{views:e}=await c(this,rs).requestJSON("GET","/views");return e}}rs=new WeakMap;var tn;class F0{constructor(e,t={}){b(this,"screens");b(this,"artifacts");b(this,"views");S(this,tn);E(this,tn,new z0(e,t)),this.screens=new M0(c(this,tn)),this.artifacts=new N0(c(this,tn),this.screens),this.views=new U0(c(this,tn))}health(){return c(this,tn).requestJSON("GET","/health")}}tn=new WeakMap;const Z0=di(Tt);var Mn,He,Nn,ze,nn,rn,J,Sr,Cg,is,Ig,Pg,Rg,Dg,ac,lc,cc,Og;class H0 extends Z0{constructor(t){var i;super();S(this,J);b(this,"id");b(this,"server");S(this,Mn);S(this,He,new Map);S(this,Nn);S(this,ze);S(this,nn);S(this,rn,null);S(this,is,t=>{if(this.disposed)return;const r=t.event;switch(r.type){case"screen-updated":r.screen.id===this.id&&m(this,J,Ig).call(this,r.screen);break;case"artifact-created":r.screenID===this.id&&m(this,J,Pg).call(this,r.artifact);break;case"artifact-updated":m(this,J,Rg).call(this,r.artifact);break;case"artifact-removed":r.screenID===this.id&&m(this,J,Dg).call(this,r.artifactID);break;case"artifact-content-changed":c(this,He).has(r.artifactID)&&this.dispatchEvent(new I0("artifact-content-changed",{artifactID:r.artifactID}));break}});this.id=t.screen.id,this.server=t.server,E(this,Mn,t.localStore),E(this,Nn,t.screen.name),E(this,ze,structuredClone(t.screen.layout));const r=((i=c(this,Mn).get().screens[this.id])==null?void 0:i.scrollPosition)??0;E(this,nn,Math.max(0,r)),this.server.addEventListener("server-event",c(this,is)),m(this,J,Cg).call(this)}get name(){return c(this,Nn)}get layout(){return c(this,ze)}get scrollPosition(){return c(this,nn)}get artifacts(){return c(this,He)}setScrollPosition(t){m(this,J,Sr).call(this);const r=Math.max(0,t);r!==c(this,nn)&&(E(this,nn,r),m(this,J,Og).call(this),this.dispatchEvent(new Q("change")))}setLayout(t){m(this,J,Sr).call(this);const r=hg(t);if(!fg(r).valid)return;const s=m(this,J,lc).call(this);E(this,ze,r),E(this,rn,{layout:r,snapshot:s}),this.dispatchEvent(new Q("change")),this.server.client.screens.update({screenID:this.id,layout:r.map(o=>structuredClone(o))}).catch(()=>{var o;this.disposed||((o=c(this,rn))==null?void 0:o.layout)===r&&(E(this,rn,null),m(this,J,cc).call(this,s),this.dispatchEvent(new Q("change")))})}rename(t){m(this,J,Sr).call(this),E(this,Nn,t),this.dispatchEvent(new Q("change")),this.server.client.screens.update({screenID:this.id,name:t}).catch(()=>{})}async remove(){m(this,J,Sr).call(this),await this.server.client.screens.remove({screenID:this.id})}removeArtifact(t){if(m(this,J,Sr).call(this),!c(this,He).has(t))return;const r=m(this,J,lc).call(this);m(this,J,ac).call(this,t),this.dispatchEvent(new Q("change")),this.server.client.artifacts.remove({artifactID:t,screenID:this.id}).catch(()=>{this.disposed||(m(this,J,cc).call(this,r),this.dispatchEvent(new Q("change")))})}dispose(){this.server.removeEventListener("server-event",c(this,is))}}Mn=new WeakMap,He=new WeakMap,Nn=new WeakMap,ze=new WeakMap,nn=new WeakMap,rn=new WeakMap,J=new WeakSet,Sr=function(){if(this.disposed)throw new Error("ScreenModel is disposed")},Cg=async function(){try{const t=await this.server.client.screens.get({screenID:this.id});if(this.disposed)return;for(const r of t.artifacts)c(this,He).set(r.id,r);this.dispatchEvent(new Q("change"))}catch{}},is=new WeakMap,Ig=function(t){c(this,rn)&&E(this,rn,null),E(this,Nn,t.name),E(this,ze,structuredClone(t.layout)),this.dispatchEvent(new Q("change"))},Pg=function(t){Sg(c(this,ze),t.id)||E(this,ze,[...c(this,ze),_g(t.id)]),c(this,He).set(t.id,t),this.dispatchEvent(new Q("change"))},Rg=function(t){const r=c(this,He).get(t.id);r&&(c(this,He).set(t.id,{...r,...t}),this.dispatchEvent(new Q("change")))},Dg=function(t){m(this,J,ac).call(this,t)&&this.dispatchEvent(new Q("change"))},ac=function(t){const r=c(this,He).delete(t),i=Xd({layout:c(this,ze)}).length,s=dg(c(this,ze),t),o=Xd({layout:s}).length;return E(this,ze,s),r||i!==o},lc=function(){return{layout:structuredClone(c(this,ze)),artifacts:new Map([...c(this,He).entries()].map(([t,r])=>[t,structuredClone(r)]))}},cc=function(t){E(this,ze,structuredClone(t.layout)),c(this,He).clear();for(const[r,i]of t.artifacts)c(this,He).set(r,structuredClone(i))},Og=function(){const t=c(this,Mn).get();c(this,Mn).set({...t,screens:{...t.screens,[this.id]:{scrollPosition:c(this,nn)}}})};const V0=di(Tt);var Xe,Mt,at,ss,os,as,Dr,Lo;class j0 extends V0{constructor(t){super();S(this,Dr);S(this,Xe);S(this,Mt);S(this,at,null);S(this,ss,()=>{this.disposed||m(this,Dr,Lo).call(this)});S(this,os,()=>{this.disposed||m(this,Dr,Lo).call(this)});S(this,as,t=>{var i;if(this.disposed)return;const r=t.event;r.type==="screen-removed"&&((i=c(this,at))==null?void 0:i.id)===r.screenID&&this.clearActive()});E(this,Xe,t.localStore),E(this,Mt,t.serverManager),c(this,Xe).addEventListener("change",c(this,ss)),c(this,Mt).addEventListener("change",c(this,os)),c(this,Mt).addEventListener("server-event",c(this,as)),m(this,Dr,Lo).call(this)}get activeScreen(){return c(this,at)}setActive(t,r){const i=c(this,Xe).get();i.activeServerURL===t&&i.activeScreenID===r||c(this,Xe).set({...i,activeServerURL:t,activeScreenID:r})}clearActive(){const t=c(this,Xe).get();t.activeScreenID!==null&&c(this,Xe).set({...t,activeScreenID:null})}dispose(){var t;c(this,Xe).removeEventListener("change",c(this,ss)),c(this,Mt).removeEventListener("change",c(this,os)),c(this,Mt).removeEventListener("server-event",c(this,as)),(t=c(this,at))==null||t.dispose(),E(this,at,null)}}Xe=new WeakMap,Mt=new WeakMap,at=new WeakMap,ss=new WeakMap,os=new WeakMap,as=new WeakMap,Dr=new WeakSet,Lo=function(){var l,u,d;const{activeServerURL:t,activeScreenID:r}=c(this,Xe).get(),i=t?c(this,Mt).servers.get(t)??null:null,s=i&&r?i.screens.get(r)??null:null,o=((l=c(this,at))==null?void 0:l.id)??null,a=(s==null?void 0:s.id)??null;o===a&&((u=c(this,at))==null?void 0:u.server)===i||((d=c(this,at))==null||d.dispose(),E(this,at,i&&s?new H0({screen:s,server:i,localStore:c(this,Xe)}):null),this.dispatchEvent(new h0("active-screen-changed")))};const B0="Local",G0="store-";function Lt(n){return new URL(n).origin}function W0(n){return{servers:[{url:Lt(n),name:B0}],activeServerURL:null,activeScreenID:null,screens:{}}}var Un,Fn,Zn;class q0 extends Tt{constructor(t,r,i={}){super();S(this,Un);S(this,Fn);S(this,Zn);E(this,Un,`${G0}${t}`),E(this,Fn,i.storage??Y0());const s=c(this,Fn).getItem(c(this,Un));s===null?(E(this,Zn,r),c(this,Fn).setItem(c(this,Un),JSON.stringify(r))):E(this,Zn,JSON.parse(s))}get(){return c(this,Zn)}set(t){E(this,Zn,t),c(this,Fn).setItem(c(this,Un),JSON.stringify(t)),this.dispatchEvent(new Q("change"))}}Un=new WeakMap,Fn=new WeakMap,Zn=new WeakMap;function Y0(){const n=globalThis.localStorage;if(!n)throw new Error("LocalStore: no storage adapter supplied and window.localStorage is unavailable");return n}function $(n,e,t){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(n))return;a._zod.traits.add(n),e(a,l);const u=o.prototype,d=Object.keys(u);for(let f=0;f<d.length;f++){const v=d[f];v in a||(a[v]=u[v].bind(a))}}const i=(t==null?void 0:t.Parent)??Object;class s extends i{}Object.defineProperty(s,"name",{value:n});function o(a){var l;const u=t!=null&&t.Parent?new s:this;r(u,a),(l=u._zod).deferred??(l.deferred=[]);for(const d of u._zod.deferred)d();return u}return Object.defineProperty(o,"init",{value:r}),Object.defineProperty(o,Symbol.hasInstance,{value:a=>{var l,u;return t!=null&&t.Parent&&a instanceof t.Parent?!0:(u=(l=a==null?void 0:a._zod)==null?void 0:l.traits)==null?void 0:u.has(n)}}),Object.defineProperty(o,"name",{value:n}),o}class Rr extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class zg extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name="ZodEncodeError"}}const Lg={};function pn(n){return Lg}function Mg(n){const e=Object.values(n).filter(r=>typeof r=="number");return Object.entries(n).filter(([r,i])=>e.indexOf(+r)===-1).map(([r,i])=>i)}function uc(n,e){return typeof e=="bigint"?e.toString():e}function $u(n){return{get value(){{const e=n();return Object.defineProperty(this,"value",{value:e}),e}}}}function Au(n){return n==null}function xu(n){const e=n.startsWith("^")?1:0,t=n.endsWith("$")?n.length-1:n.length;return n.slice(e,t)}function K0(n,e){const t=(n.toString().split(".")[1]||"").length,r=e.toString();let i=(r.split(".")[1]||"").length;if(i===0&&/\d?e-\d?/.test(r)){const l=r.match(/\d?e-(\d?)/);l!=null&&l[1]&&(i=Number.parseInt(l[1]))}const s=t>i?t:i,o=Number.parseInt(n.toFixed(s).replace(".","")),a=Number.parseInt(e.toFixed(s).replace(".",""));return o%a/10**s}const Qd=Symbol("evaluating");function X(n,e,t){let r;Object.defineProperty(n,e,{get(){if(r!==Qd)return r===void 0&&(r=Qd,r=t()),r},set(i){Object.defineProperty(n,e,{value:i})},configurable:!0})}function cr(n,e,t){Object.defineProperty(n,e,{value:t,writable:!0,enumerable:!0,configurable:!0})}function _n(...n){const e={};for(const t of n){const r=Object.getOwnPropertyDescriptors(t);Object.assign(e,r)}return Object.defineProperties({},e)}function ef(n){return JSON.stringify(n)}function J0(n){return n.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}const Ng="captureStackTrace"in Error?Error.captureStackTrace:(...n)=>{};function Ko(n){return typeof n=="object"&&n!==null&&!Array.isArray(n)}const X0=$u(()=>{var n;if(typeof navigator<"u"&&((n=navigator==null?void 0:navigator.userAgent)!=null&&n.includes("Cloudflare")))return!1;try{const e=Function;return new e(""),!0}catch{return!1}});function Qr(n){if(Ko(n)===!1)return!1;const e=n.constructor;if(e===void 0||typeof e!="function")return!0;const t=e.prototype;return!(Ko(t)===!1||Object.prototype.hasOwnProperty.call(t,"isPrototypeOf")===!1)}function Ug(n){return Qr(n)?{...n}:Array.isArray(n)?[...n]:n}const Q0=new Set(["string","number","symbol"]);function ei(n){return n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Sn(n,e,t){const r=new n._zod.constr(e??n._zod.def);return(!e||t!=null&&t.parent)&&(r._zod.parent=n),r}function O(n){const e=n;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 e$(n){return Object.keys(n).filter(e=>n[e]._zod.optin==="optional"&&n[e]._zod.optout==="optional")}const t$={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 n$(n,e){const t=n._zod.def,r=t.checks;if(r&&r.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");const s=_n(n._zod.def,{get shape(){const o={};for(const a in e){if(!(a in t.shape))throw new Error(`Unrecognized key: "${a}"`);e[a]&&(o[a]=t.shape[a])}return cr(this,"shape",o),o},checks:[]});return Sn(n,s)}function r$(n,e){const t=n._zod.def,r=t.checks;if(r&&r.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");const s=_n(n._zod.def,{get shape(){const o={...n._zod.def.shape};for(const a in e){if(!(a in t.shape))throw new Error(`Unrecognized key: "${a}"`);e[a]&&delete o[a]}return cr(this,"shape",o),o},checks:[]});return Sn(n,s)}function i$(n,e){if(!Qr(e))throw new Error("Invalid input to extend: expected a plain object");const t=n._zod.def.checks;if(t&&t.length>0){const s=n._zod.def.shape;for(const o in e)if(Object.getOwnPropertyDescriptor(s,o)!==void 0)throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}const i=_n(n._zod.def,{get shape(){const s={...n._zod.def.shape,...e};return cr(this,"shape",s),s}});return Sn(n,i)}function s$(n,e){if(!Qr(e))throw new Error("Invalid input to safeExtend: expected a plain object");const t=_n(n._zod.def,{get shape(){const r={...n._zod.def.shape,...e};return cr(this,"shape",r),r}});return Sn(n,t)}function o$(n,e){const t=_n(n._zod.def,{get shape(){const r={...n._zod.def.shape,...e._zod.def.shape};return cr(this,"shape",r),r},get catchall(){return e._zod.def.catchall},checks:[]});return Sn(n,t)}function a$(n,e,t){const i=e._zod.def.checks;if(i&&i.length>0)throw new Error(".partial() cannot be used on object schemas containing refinements");const o=_n(e._zod.def,{get shape(){const a=e._zod.def.shape,l={...a};if(t)for(const u in t){if(!(u in a))throw new Error(`Unrecognized key: "${u}"`);t[u]&&(l[u]=n?new n({type:"optional",innerType:a[u]}):a[u])}else for(const u in a)l[u]=n?new n({type:"optional",innerType:a[u]}):a[u];return cr(this,"shape",l),l},checks:[]});return Sn(e,o)}function l$(n,e,t){const r=_n(e._zod.def,{get shape(){const i=e._zod.def.shape,s={...i};if(t)for(const o in t){if(!(o in s))throw new Error(`Unrecognized key: "${o}"`);t[o]&&(s[o]=new n({type:"nonoptional",innerType:i[o]}))}else for(const o in i)s[o]=new n({type:"nonoptional",innerType:i[o]});return cr(this,"shape",s),s}});return Sn(e,r)}function Cr(n,e=0){var t;if(n.aborted===!0)return!0;for(let r=e;r<n.issues.length;r++)if(((t=n.issues[r])==null?void 0:t.continue)!==!0)return!0;return!1}function Ir(n,e){return e.map(t=>{var r;return(r=t).path??(r.path=[]),t.path.unshift(n),t})}function mo(n){return typeof n=="string"?n:n==null?void 0:n.message}function gn(n,e,t){var i,s,o,a,l,u;const r={...n,path:n.path??[]};if(!n.message){const d=mo((o=(s=(i=n.inst)==null?void 0:i._zod.def)==null?void 0:s.error)==null?void 0:o.call(s,n))??mo((a=e==null?void 0:e.error)==null?void 0:a.call(e,n))??mo((l=t.customError)==null?void 0:l.call(t,n))??mo((u=t.localeError)==null?void 0:u.call(t,n))??"Invalid input";r.message=d}return delete r.inst,delete r.continue,e!=null&&e.reportInput||delete r.input,r}function Tu(n){return Array.isArray(n)?"array":typeof n=="string"?"string":"unknown"}function Ji(...n){const[e,t,r]=n;return typeof e=="string"?{message:e,code:"custom",input:t,inst:r}:{...e}}const Fg=(n,e)=>{n.name="$ZodError",Object.defineProperty(n,"_zod",{value:n._zod,enumerable:!1}),Object.defineProperty(n,"issues",{value:e,enumerable:!1}),n.message=JSON.stringify(e,uc,2),Object.defineProperty(n,"toString",{value:()=>n.message,enumerable:!1})},Zg=$("$ZodError",Fg),Hg=$("$ZodError",Fg,{Parent:Error});function c$(n,e=t=>t.message){const t={},r=[];for(const i of n.issues)i.path.length>0?(t[i.path[0]]=t[i.path[0]]||[],t[i.path[0]].push(e(i))):r.push(e(i));return{formErrors:r,fieldErrors:t}}function u$(n,e=t=>t.message){const t={_errors:[]},r=i=>{for(const s of i.issues)if(s.code==="invalid_union"&&s.errors.length)s.errors.map(o=>r({issues:o}));else if(s.code==="invalid_key")r({issues:s.issues});else if(s.code==="invalid_element")r({issues:s.issues});else if(s.path.length===0)t._errors.push(e(s));else{let o=t,a=0;for(;a<s.path.length;){const l=s.path[a];a===s.path.length-1?(o[l]=o[l]||{_errors:[]},o[l]._errors.push(e(s))):o[l]=o[l]||{_errors:[]},o=o[l],a++}}};return r(n),t}const Cu=n=>(e,t,r,i)=>{const s=r?Object.assign(r,{async:!1}):{async:!1},o=e._zod.run({value:t,issues:[]},s);if(o instanceof Promise)throw new Rr;if(o.issues.length){const a=new((i==null?void 0:i.Err)??n)(o.issues.map(l=>gn(l,s,pn())));throw Ng(a,i==null?void 0:i.callee),a}return o.value},Iu=n=>async(e,t,r,i)=>{const s=r?Object.assign(r,{async:!0}):{async:!0};let o=e._zod.run({value:t,issues:[]},s);if(o instanceof Promise&&(o=await o),o.issues.length){const a=new((i==null?void 0:i.Err)??n)(o.issues.map(l=>gn(l,s,pn())));throw Ng(a,i==null?void 0:i.callee),a}return o.value},Da=n=>(e,t,r)=>{const i=r?{...r,async:!1}:{async:!1},s=e._zod.run({value:t,issues:[]},i);if(s instanceof Promise)throw new Rr;return s.issues.length?{success:!1,error:new(n??Zg)(s.issues.map(o=>gn(o,i,pn())))}:{success:!0,data:s.value}},h$=Da(Hg),Oa=n=>async(e,t,r)=>{const i=r?Object.assign(r,{async:!0}):{async:!0};let s=e._zod.run({value:t,issues:[]},i);return s instanceof Promise&&(s=await s),s.issues.length?{success:!1,error:new n(s.issues.map(o=>gn(o,i,pn())))}:{success:!0,data:s.value}},d$=Oa(Hg),f$=n=>(e,t,r)=>{const i=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return Cu(n)(e,t,i)},p$=n=>(e,t,r)=>Cu(n)(e,t,r),g$=n=>async(e,t,r)=>{const i=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return Iu(n)(e,t,i)},m$=n=>async(e,t,r)=>Iu(n)(e,t,r),y$=n=>(e,t,r)=>{const i=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return Da(n)(e,t,i)},v$=n=>(e,t,r)=>Da(n)(e,t,r),b$=n=>async(e,t,r)=>{const i=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return Oa(n)(e,t,i)},w$=n=>async(e,t,r)=>Oa(n)(e,t,r),_$=/^[cC][^\s-]{8,}$/,S$=/^[0-9a-z]+$/,k$=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,E$=/^[0-9a-vA-V]{20}$/,$$=/^[A-Za-z0-9]{27}$/,A$=/^[a-zA-Z0-9_-]{21}$/,x$=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,T$=/^([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})$/,tf=n=>n?new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${n}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,C$=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,I$="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function P$(){return new RegExp(I$,"u")}const R$=/^(?:(?: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])$/,D$=/^(([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}|:))$/,O$=/^((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])$/,z$=/^(([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])$/,L$=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Vg=/^[A-Za-z0-9_-]*$/,M$=/^\+[1-9]\d{6,14}$/,jg="(?:(?:\\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])))",N$=new RegExp(`^${jg}$`);function Bg(n){const e="(?:[01]\\d|2[0-3]):[0-5]\\d";return typeof n.precision=="number"?n.precision===-1?`${e}`:n.precision===0?`${e}:[0-5]\\d`:`${e}:[0-5]\\d\\.\\d{${n.precision}}`:`${e}(?::[0-5]\\d(?:\\.\\d+)?)?`}function U$(n){return new RegExp(`^${Bg(n)}$`)}function F$(n){const e=Bg({precision:n.precision}),t=["Z"];n.local&&t.push(""),n.offset&&t.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");const r=`${e}(?:${t.join("|")})`;return new RegExp(`^${jg}T(?:${r})$`)}const Z$=n=>{const e=n?`[\\s\\S]{${(n==null?void 0:n.minimum)??0},${(n==null?void 0:n.maximum)??""}}`:"[\\s\\S]*";return new RegExp(`^${e}$`)},H$=/^-?\d+$/,Gg=/^-?\d+(?:\.\d+)?$/,V$=/^(?:true|false)$/i,j$=/^[^A-Z]*$/,B$=/^[^a-z]*$/,Ge=$("$ZodCheck",(n,e)=>{var t;n._zod??(n._zod={}),n._zod.def=e,(t=n._zod).onattach??(t.onattach=[])}),Wg={number:"number",bigint:"bigint",object:"date"},qg=$("$ZodCheckLessThan",(n,e)=>{Ge.init(n,e);const t=Wg[typeof e.value];n._zod.onattach.push(r=>{const i=r._zod.bag,s=(e.inclusive?i.maximum:i.exclusiveMaximum)??Number.POSITIVE_INFINITY;e.value<s&&(e.inclusive?i.maximum=e.value:i.exclusiveMaximum=e.value)}),n._zod.check=r=>{(e.inclusive?r.value<=e.value:r.value<e.value)||r.issues.push({origin:t,code:"too_big",maximum:typeof e.value=="object"?e.value.getTime():e.value,input:r.value,inclusive:e.inclusive,inst:n,continue:!e.abort})}}),Yg=$("$ZodCheckGreaterThan",(n,e)=>{Ge.init(n,e);const t=Wg[typeof e.value];n._zod.onattach.push(r=>{const i=r._zod.bag,s=(e.inclusive?i.minimum:i.exclusiveMinimum)??Number.NEGATIVE_INFINITY;e.value>s&&(e.inclusive?i.minimum=e.value:i.exclusiveMinimum=e.value)}),n._zod.check=r=>{(e.inclusive?r.value>=e.value:r.value>e.value)||r.issues.push({origin:t,code:"too_small",minimum:typeof e.value=="object"?e.value.getTime():e.value,input:r.value,inclusive:e.inclusive,inst:n,continue:!e.abort})}}),G$=$("$ZodCheckMultipleOf",(n,e)=>{Ge.init(n,e),n._zod.onattach.push(t=>{var r;(r=t._zod.bag).multipleOf??(r.multipleOf=e.value)}),n._zod.check=t=>{if(typeof t.value!=typeof e.value)throw new Error("Cannot mix number and bigint in multiple_of check.");(typeof t.value=="bigint"?t.value%e.value===BigInt(0):K0(t.value,e.value)===0)||t.issues.push({origin:typeof t.value,code:"not_multiple_of",divisor:e.value,input:t.value,inst:n,continue:!e.abort})}}),W$=$("$ZodCheckNumberFormat",(n,e)=>{var o;Ge.init(n,e),e.format=e.format||"float64";const t=(o=e.format)==null?void 0:o.includes("int"),r=t?"int":"number",[i,s]=t$[e.format];n._zod.onattach.push(a=>{const l=a._zod.bag;l.format=e.format,l.minimum=i,l.maximum=s,t&&(l.pattern=H$)}),n._zod.check=a=>{const l=a.value;if(t){if(!Number.isInteger(l)){a.issues.push({expected:r,format:e.format,code:"invalid_type",continue:!1,input:l,inst:n});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:n,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:n,origin:r,inclusive:!0,continue:!e.abort});return}}l<i&&a.issues.push({origin:"number",input:l,code:"too_small",minimum:i,inclusive:!0,inst:n,continue:!e.abort}),l>s&&a.issues.push({origin:"number",input:l,code:"too_big",maximum:s,inclusive:!0,inst:n,continue:!e.abort})}}),q$=$("$ZodCheckMaxLength",(n,e)=>{var t;Ge.init(n,e),(t=n._zod.def).when??(t.when=r=>{const i=r.value;return!Au(i)&&i.length!==void 0}),n._zod.onattach.push(r=>{const i=r._zod.bag.maximum??Number.POSITIVE_INFINITY;e.maximum<i&&(r._zod.bag.maximum=e.maximum)}),n._zod.check=r=>{const i=r.value;if(i.length<=e.maximum)return;const o=Tu(i);r.issues.push({origin:o,code:"too_big",maximum:e.maximum,inclusive:!0,input:i,inst:n,continue:!e.abort})}}),Y$=$("$ZodCheckMinLength",(n,e)=>{var t;Ge.init(n,e),(t=n._zod.def).when??(t.when=r=>{const i=r.value;return!Au(i)&&i.length!==void 0}),n._zod.onattach.push(r=>{const i=r._zod.bag.minimum??Number.NEGATIVE_INFINITY;e.minimum>i&&(r._zod.bag.minimum=e.minimum)}),n._zod.check=r=>{const i=r.value;if(i.length>=e.minimum)return;const o=Tu(i);r.issues.push({origin:o,code:"too_small",minimum:e.minimum,inclusive:!0,input:i,inst:n,continue:!e.abort})}}),K$=$("$ZodCheckLengthEquals",(n,e)=>{var t;Ge.init(n,e),(t=n._zod.def).when??(t.when=r=>{const i=r.value;return!Au(i)&&i.length!==void 0}),n._zod.onattach.push(r=>{const i=r._zod.bag;i.minimum=e.length,i.maximum=e.length,i.length=e.length}),n._zod.check=r=>{const i=r.value,s=i.length;if(s===e.length)return;const o=Tu(i),a=s>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:n,continue:!e.abort})}}),za=$("$ZodCheckStringFormat",(n,e)=>{var t,r;Ge.init(n,e),n._zod.onattach.push(i=>{const s=i._zod.bag;s.format=e.format,e.pattern&&(s.patterns??(s.patterns=new Set),s.patterns.add(e.pattern))}),e.pattern?(t=n._zod).check??(t.check=i=>{e.pattern.lastIndex=0,!e.pattern.test(i.value)&&i.issues.push({origin:"string",code:"invalid_format",format:e.format,input:i.value,...e.pattern?{pattern:e.pattern.toString()}:{},inst:n,continue:!e.abort})}):(r=n._zod).check??(r.check=()=>{})}),J$=$("$ZodCheckRegex",(n,e)=>{za.init(n,e),n._zod.check=t=>{e.pattern.lastIndex=0,!e.pattern.test(t.value)&&t.issues.push({origin:"string",code:"invalid_format",format:"regex",input:t.value,pattern:e.pattern.toString(),inst:n,continue:!e.abort})}}),X$=$("$ZodCheckLowerCase",(n,e)=>{e.pattern??(e.pattern=j$),za.init(n,e)}),Q$=$("$ZodCheckUpperCase",(n,e)=>{e.pattern??(e.pattern=B$),za.init(n,e)}),eA=$("$ZodCheckIncludes",(n,e)=>{Ge.init(n,e);const t=ei(e.includes),r=new RegExp(typeof e.position=="number"?`^.{${e.position}}${t}`:t);e.pattern=r,n._zod.onattach.push(i=>{const s=i._zod.bag;s.patterns??(s.patterns=new Set),s.patterns.add(r)}),n._zod.check=i=>{i.value.includes(e.includes,e.position)||i.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:e.includes,input:i.value,inst:n,continue:!e.abort})}}),tA=$("$ZodCheckStartsWith",(n,e)=>{Ge.init(n,e);const t=new RegExp(`^${ei(e.prefix)}.*`);e.pattern??(e.pattern=t),n._zod.onattach.push(r=>{const i=r._zod.bag;i.patterns??(i.patterns=new Set),i.patterns.add(t)}),n._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:n,continue:!e.abort})}}),nA=$("$ZodCheckEndsWith",(n,e)=>{Ge.init(n,e);const t=new RegExp(`.*${ei(e.suffix)}$`);e.pattern??(e.pattern=t),n._zod.onattach.push(r=>{const i=r._zod.bag;i.patterns??(i.patterns=new Set),i.patterns.add(t)}),n._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:n,continue:!e.abort})}}),rA=$("$ZodCheckOverwrite",(n,e)=>{Ge.init(n,e),n._zod.check=t=>{t.value=e.tx(t.value)}});class iA{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 uo(n,e){var t=ic(n),r=[];if(t){r.length=n.length;for(var i=0;i<n.length;i++)r[i]=zt(n,i)?e(n[i],n):""}var s=typeof Sl=="function"?Sl(n):[],o;if(Xr){o={};for(var a=0;a<s.length;a++)o["$"+s[a]]=s[a]}for(var l in n)zt(n,l)&&(t&&String(Number(l))===l&&l<n.length||Xr&&o["$"+l]instanceof Symbol||(Lp.call(/[^\w$]/,l)?r.push(e(l,n)+": "+e(n[l],n)):r.push(l+": "+e(n[l],n))));if(typeof Sl=="function")for(var u=0;u<s.length;u++)Mp.call(n,s[u])&&r.push("["+e(s[u])+"]: "+e(n[s[u]],n));return r}var MS=ci,NS=B,Ca=function(n,e,t){for(var r=n,i;(i=r.next)!=null;r=i)if(i.key===e)return r.next=i.next,t||(i.next=n.next,n.next=i),i},US=function(n,e){if(n){var t=Ca(n,e);return t&&t.value}},FS=function(n,e,t){var r=Ca(n,e);r?r.value=t:n.next={key:e,next:n.next,value:t}},ZS=function(n,e){return n?!!Ca(n,e):!1},HS=function(n,e){if(n)return Ca(n,e,!0)},VS=function(){var e,t={assert:function(r){if(!t.has(r))throw new NS("Side channel does not contain "+MS(r))},delete:function(r){var i=e&&e.next,s=HS(e,r);return s&&i&&i===s&&(e=void 0),!!s},get:function(r){return US(e,r)},has:function(r){return ZS(e,r)},set:function(r,i){e||(e={next:void 0}),FS(e,r,i)}};return t},jS=st,Gs=bn(),GS=ci,BS=B,bd=jS("%Map%",!0),WS=Gs("Map.prototype.get",!0),qS=Gs("Map.prototype.set",!0),YS=Gs("Map.prototype.has",!0),KS=Gs("Map.prototype.delete",!0),JS=Gs("Map.prototype.size",!0),Vp=!!bd&&function(){var e,t={assert:function(r){if(!t.has(r))throw new BS("Side channel does not contain "+GS(r))},delete:function(r){if(e){var i=KS(e,r);return JS(e)===0&&(e=void 0),i}return!1},get:function(r){if(e)return WS(e,r)},has:function(r){return e?YS(e,r):!1},set:function(r,i){e||(e=new bd),qS(e,r,i)}};return t},XS=st,Ia=bn(),QS=ci,ho=Vp,ek=B,br=XS("%WeakMap%",!0),tk=Ia("WeakMap.prototype.get",!0),nk=Ia("WeakMap.prototype.set",!0),rk=Ia("WeakMap.prototype.has",!0),ik=Ia("WeakMap.prototype.delete",!0),sk=br?function(){var e,t,r={assert:function(i){if(!r.has(i))throw new ek("Side channel does not contain "+QS(i))},delete:function(i){if(br&&i&&(typeof i=="object"||typeof i=="function")){if(e)return ik(e,i)}else if(ho&&t)return t.delete(i);return!1},get:function(i){return br&&i&&(typeof i=="object"||typeof i=="function")&&e?tk(e,i):t&&t.get(i)},has:function(i){return br&&i&&(typeof i=="object"||typeof i=="function")&&e?rk(e,i):!!t&&t.has(i)},set:function(i,s){br&&i&&(typeof i=="object"||typeof i=="function")?(e||(e=new br),nk(e,i,s)):ho&&(t||(t=ho()),t.set(i,s))}};return r}:ho,ok=B,ak=ci,lk=VS,ck=Vp,uk=sk,hk=uk||ck||lk,dk=function(){var e,t={assert:function(r){if(!t.has(r))throw new ok("Side channel does not contain "+ak(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,i){e||(e=hk()),e.set(r,i)}};return t},fk=Kt,ki=dk(),Rt=B,fu={assert:function(n,e){if(!n||typeof n!="object"&&typeof n!="function")throw new Rt("`O` is not an object");if(typeof e!="string")throw new Rt("`slot` must be a string");if(ki.assert(n),!fu.has(n,e))throw new Rt("`"+e+"` is not present on `O`")},get:function(n,e){if(!n||typeof n!="object"&&typeof n!="function")throw new Rt("`O` is not an object");if(typeof e!="string")throw new Rt("`slot` must be a string");var t=ki.get(n);return t&&t["$"+e]},has:function(n,e){if(!n||typeof n!="object"&&typeof n!="function")throw new Rt("`O` is not an object");if(typeof e!="string")throw new Rt("`slot` must be a string");var t=ki.get(n);return!!t&&fk(t,"$"+e)},set:function(n,e,t){if(!n||typeof n!="object"&&typeof n!="function")throw new Rt("`O` is not an object");if(typeof e!="string")throw new Rt("`slot` must be a string");var r=ki.get(n);r||(r={},ki.set(n,r)),r["$"+e]=t}};Object.freeze&&Object.freeze(fu);var pu=fu,jp=qt,dn=pu,Bs=function n(e,t){if(!(this instanceof n))return new n(e,t);if(e!=="normal"&&e!=="break"&&e!=="continue"&&e!=="return"&&e!=="throw")throw new jp('Assertion failed: `type` must be one of "normal", "break", "continue", "return", or "throw"');dn.set(this,"[[Type]]",e),dn.set(this,"[[Value]]",t)};Bs.prototype.type=function(){return dn.get(this,"[[Type]]")};Bs.prototype.value=function(){return dn.get(this,"[[Value]]")};Bs.prototype["?"]=function(){var e=dn.get(this,"[[Type]]"),t=dn.get(this,"[[Value]]");if(e==="throw")throw t;return t};Bs.prototype["!"]=function(){var e=dn.get(this,"[[Type]]");if(e!=="normal")throw new jp('Assertion failed: Completion Record is not of type "normal"');return dn.get(this,"[[Value]]")};var gu=Bs,pk=gu,mu=function(e){return new pk("normal",e)},El,wd;function gk(){if(wd)return El;wd=1;var n=si;return El=function(){return n()&&!!Symbol.toStringTag},El}var mk=st,_d=mk("%Object.defineProperty%",!0),yk=gk()(),vk=Kt,bk=B,fo=yk?Symbol.toStringTag:null,Gp=function(e,t){var r=arguments.length>2&&!!arguments[2]&&arguments[2].force,i=arguments.length>2&&!!arguments[2]&&arguments[2].nonConfigurable;if(typeof r<"u"&&typeof r!="boolean"||typeof i<"u"&&typeof i!="boolean")throw new bk("if provided, the `overrideIfSet` and `nonConfigurable` options must be booleans");fo&&(r||!vk(e,fo))&&(_d?_d(e,fo,{configurable:!i,enumerable:!1,value:t,writable:!1}):e[fo]=t)},Bp={exports:{}},wk=st,Sd=hp,_k=Aa(),kd=ii,Ed=B,Sk=wk("%Math.floor%"),kk=function(e,t){if(typeof e!="function")throw new Ed("`fn` is not a function");if(typeof t!="number"||t<0||t>4294967295||Sk(t)!==t)throw new Ed("`length` must be a positive 32-bit integer");var r=arguments.length>2&&!!arguments[2],i=!0,s=!0;if("length"in e&&kd){var o=kd(e,"length");o&&!o.configurable&&(i=!1),o&&!o.writable&&(s=!1)}return(i||s||!r)&&(_k?Sd(e,"length",t,!0,!0):Sd(e,"length",t)),e},Ek=Fs,$k=ru,Ak=Sp,xk=function(){return Ak(Ek,$k,arguments)};(function(n){var e=kk,t=Us,r=xa,i=xk;n.exports=function(o){var a=r(arguments),l=1+o.length-(arguments.length-1);return e(a,l>0?l:0,!0)},t?t(n.exports,"apply",{value:i}):n.exports.apply=i})(Bp);var yu=Bp.exports,Tk=function(e,t){for(var r=0;r<e.length;r+=1)if(!t(e[r],r,e))return!1;return!0},Ck=Object,Ik=function(e){return e&&typeof e=="object"&&(typeof e["[[ResourceValue]]"]>"u"||Ck(e["[[ResourceValue]]"])===e["[[ResourceValue]]"])&&(e["[[Hint]]"]==="SYNC-DISPOSE"||e["[[Hint]]"]==="ASYNC-DISPOSE")&&(typeof e["[[DisposeMethod]]"]=="function"||typeof e["[[DisposeMethod]]"]>"u")},Pk=Kt,Rk=iu(),Dk=Tk,Ok=Ik,zk=function(e){return e&&typeof e=="object"&&Pk(e,"[[DisposableResourceStack]]")&&Rk(e["[[DisposableResourceStack]]"])&&(e["[[DisposableResourceStack]]"].length===0||Dk(e["[[DisposableResourceStack]]"],Ok))},Lk=Yt,Mk=function(e){if(e===null)return"Null";if(typeof e>"u")return"Undefined";if(Lk(e))return"Object";if(typeof e=="number")return"Number";if(typeof e=="boolean")return"Boolean";if(typeof e=="string")return"String"},Nk=Mk,vu=function(e){return typeof e=="symbol"?"Symbol":typeof e=="bigint"?"BigInt":Nk(e)},Uk=B,Fk=ci,Zk=ai,Hk=function(e,t){if(!Zk(t))throw new Uk("Assertion failed: P is not a Property Key, got "+Fk(t));return e[t]},$d=B,Vk=Hk,jk=li,Gk=ai,Ad=ci,Bk=function(e,t){if(!Gk(t))throw new $d("Assertion failed: P is not a Property Key");var r=Vk(e,t);if(r!=null){if(!jk(r))throw new $d(Ad(t)+" is not a function: "+Ad(r));return r}},oc={exports:{}},Wk=st,qk=Wk,xd=qk("%Reflect.construct%",!0),Wo=js;try{Wo({},"",{"[[Get]]":function(){}})}catch{Wo=null}if(Wo&&xd){var Td={},Cd={};Wo(Cd,"length",{"[[Get]]":function(){throw Td},"[[Enumerable]]":!0}),oc.exports=function(e){try{xd(e,Cd)}catch(t){return t===Td}}}else oc.exports=function(e){return typeof e=="function"&&!!e.prototype};var Yk=oc.exports,$l=B,Id=li,Kk=Yk,Jk=function(e){if(!Kk(e))throw new $l("C must be a constructor");var t={"[[Resolve]]":void 0,"[[Reject]]":void 0},r=new e(function(i,s){if(typeof t["[[Resolve]]"]<"u"||typeof t["[[Reject]]"]<"u")throw new $l("executor has already been called");t["[[Resolve]]"]=i,t["[[Reject]]"]=s});if(!Id(t["[[Resolve]]"])||!Id(t["[[Reject]]"]))throw new $l("executor must provide valid resolve and reject functions");return{"[[Promise]]":r,"[[Resolve]]":t["[[Resolve]]"],"[[Reject]]":t["[[Reject]]"]}},Pd=qt,Xk=B,Al=Ta,Rd=Bk,Qk=Jk,eE=vu,Dd=lu(),Od=cu(),tE=function(e,t){if(eE(e)!=="Object")throw new Xk("`V` must be an Object");if(t!=="SYNC-DISPOSE"&&t!=="ASYNC-DISPOSE")throw new Pd("Assertion failed: `hint` must be `~SYNC-DISPOSE~` or `~ASYNC-DISPOSE~`");var r;if(t==="ASYNC-DISPOSE"&&Od&&(r=Rd(e,Od)),!r){if(!Dd)throw new Pd("`Symbol.dispose` is not supported");if(r=Rd(e,Dd),typeof r<"u")return function(){var i=this;if(t==="ASYNC-DISPOSE"){var s=Qk(Promise);try{Al(r,i),Al(s["[[Resolve]]"],void 0,[void 0])}catch(o){s["[[Reject]]"](o)}return s["[[Promise]]"]}Al(r,i)}}return r},nE=qt,xl=B,rE=li,iE=vu,sE=tE,oE=function(e,t){if(t!=="SYNC-DISPOSE"&&t!=="ASYNC-DISPOSE")throw new nE("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"&&iE(e)!=="Object")throw new xl("`V` must be an Object, or `null` or `undefined`");if(r=sE(e,t),typeof r>"u")throw new xl("dispose method must not be `undefined` on `V` when an object `V` is provided")}else if(r=arguments[2],!rE(r))throw new xl("`method`, when provided, must be a function");return{"[[ResourceValue]]":e,"[[Hint]]":t,"[[DisposeMethod]]":r}},aE=qt,po=B,lE=zk,zd=oE,cE=bn(),uE=cE("Array.prototype.push"),Wp=function(e,t,r){if(!lE(e))throw new po("Assertion failed: `disposeCapability` must be a DisposeCapability Record");if(r!=="SYNC-DISPOSE"&&r!=="ASYNC-DISPOSE")throw new aE("Assertion failed: `hint` must be `~SYNC-DISPOSE~` or `~ASYNC-DISPOSE~`");var i=arguments.length>3?arguments[3]:void 0;if(arguments.length>3&&typeof i!="function")throw new po("Assertion failed: `method`, when present, must be a function");if(!e["[[DisposableResourceStack]]"])throw new po("Assertion failed: `disposeCapability.[[DisposableResourceStack]]` must not be ~EMPTY~");var s;if(arguments.length<4){if(t==null&&r==="SYNC_DISPOSE")return"UNUSED";s=zd(t,r)}else{if(typeof t<"u")throw new po("Assertion failed: `V` must be undefined when `method` is present");s=zd(void 0,r,i)}return uE(e["[[DisposableResourceStack]]"],s),"UNUSED"},Tl,Ld;function bu(){if(Ld)return Tl;Ld=1;var n=st,e=yu,t=qt,r=n("%Promise.resolve%",!0),i=r&&e(r);return Tl=function(o,a){if(!i)throw new t("This environment does not support Promises.");return i(o,a)},Tl}var Cl,Md;function hE(){if(Md)return Cl;Md=1;var n=st,e=qt,t=n("%Promise%",!0),r=Ta,i=bu(),s=vu;return Cl=function(a,l,u){if(typeof a<"u"&&s(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 u<"u"&&typeof u!="function")throw new e("Assertion failed: `method` must be `undefined` or a function");var d=typeof u>"u"?u:r(u,a);if(l==="ASYNC-DISPOSE")return i(t,d)},Cl}var Il,Nd;function dE(){if(Nd)return Il;Nd=1;var n=gu;return Il=function(t){return new n("throw",t)},Il}var fE=st,Pl=qt,Ud=B,pE=fE("%Promise%",!0),gE=bn(),Fd=gE("Promise.prototype.then",!0),mE=gu,Zd=hE(),yE=mu,vE=bu(),Hd=dE(),bE=zp(),qp=function(e,t){if(!(t instanceof mE))throw new Ud("`completion` must be a Completion Record");var r=e["[[DisposableResourceStack]]"];if(!r)throw new Ud("Assertion failed: `disposeCapability.[[DisposableResourceStack]]` must not be ~EMPTY~");for(var i,s=r.length-1;s>=0;s-=1)if(!i)i=r[s]["[[Hint]]"];else if(i!==r[s]["[[Hint]]"])throw new Pl("mixed hint stacks are not supported");for(var o=i==="ASYNC-DISPOSE"&&vE(pE,t),a=function(v){if(t.type()==="throw"){var y=t.value(),A=new bE(v,y);t=Hd(A)}else t=Hd(v)},l=i==="ASYNC-DISPOSE"&&function(y){return Fd(o,function(){var A=Zd(y["[[ResourceValue]]"],y["[[Hint]]"],y["[[DisposeMethod]]"]);if(!A)throw new Pl("Assertion failed: non-`~ASYNC-DISPOSE~` resource returned a promise from Dispose");return Fd(A,yE)},a)},u=r.length-1;u>=0;u-=1)if(i==="ASYNC-DISPOSE")o=l(r[u]);else{var d=r[u];try{var f=Zd(d["[[ResourceValue]]"],d["[[Hint]]"],d["[[DisposeMethod]]"]);if(f)throw new Pl("Assertion failed: `~SYNC-DISPOSE~` resource returned something from Dispose")}catch(v){a(v)}}return e["[[DisposableResourceStack]]"]=null,i==="ASYNC-DISPOSE"?o:t},Yp=function(){var e=[];return{"[[DisposableResourceStack]]":e}},Pa=Qc,wu=B,wE=Ta,ui=ou,_E=js,Kp=li,SE=mu,je=pu,kE=Gp,Jp=ar.supportsDescriptors,EE=yu,_u=Wp,$E=qp,Xp=Yp,Vd=lu(),tt=function n(){if(!(this instanceof n)||je.has(this,"[[DisposableState]]")||je.has(this,"[[DisposeCapability]]"))throw new wu("can only be used with new");je.set(this,"[[DisposableState]]","PENDING"),je.set(this,"[[DisposeCapability]]",Xp())},Qp=function(){var e=this;return je.assert(e,"[[DisposableState]]"),je.get(e,"[[DisposableState]]")==="DISPOSED"},Ws=EE(Qp);Jp?_E(tt.prototype,"disposed",{"[[Configurable]]":!0,"[[Enumerable]]":!1,"[[Get]]":Qp}):tt.prototype.disposed=!1;var eg=function(e){je.set(e,"[[DisposableState]]","DISPOSED"),Jp||(e.disposed=!0)};ui(tt.prototype,"dispose",function(){var e=this;if(!Ws(e))return eg(e),$E(je.get(e,"[[DisposeCapability]]"),SE())["?"]()});ui(tt.prototype,"use",function(e){var t=this;if(Ws(t))throw new Pa("a disposed stack can not use anything new");return _u(je.get(t,"[[DisposeCapability]]"),e,"SYNC-DISPOSE"),e});ui(tt.prototype,"adopt",function(e,t){var r=this;if(Ws(r))throw new Pa("a disposed stack can not use anything new");if(!Kp(t))throw new wu("`onDispose` must be a function");var i=function(){return wE(t,void 0,[e])};return _u(je.get(r,"[[DisposeCapability]]"),void 0,"SYNC-DISPOSE",i),e});ui(tt.prototype,"defer",function(e){var t=this;if(Ws(t))throw new Pa("a disposed stack can not defer anything new");if(!Kp(e))throw new wu("`onDispose` must be a function");_u(je.get(t,"[[DisposeCapability]]"),void 0,"SYNC-DISPOSE",e)});ui(tt.prototype,"move",function(){var e=this;if(Ws(e))throw new Pa("a disposed stack can not use anything new");var t=new tt;return je.set(t,"[[DisposeCapability]]",je.get(e,"[[DisposeCapability]]")),je.set(e,"[[DisposeCapability]]",Xp()),eg(e),t});Vd&&ui(tt.prototype,Vd,tt.prototype.dispose);kE(tt.prototype,"DisposableStack");var AE=tt,xE=AE,TE=function(){return typeof DisposableStack=="function"?DisposableStack:xE},CE=ar,IE=Jc(),PE=TE,RE=function(){var e=PE();return CE(IE,{DisposableStack:e},{DisposableStack:!0}),e},DE=st,Ra=Qc,Su=B,jd=DE("%Promise%",!0),ku=Wp,OE=Ta,hi=ou,zE=js,LE=qp,tg=li,ng=Yp,ME=mu,Gd=bu(),Ge=pu,NE=Gp,rg=ar.supportsDescriptors,UE=yu,FE=bn(),ZE=FE("Promise.prototype.then",!0),Bd=cu(),nt=function n(){if(!(this instanceof n)||Ge.has(this,"[[AsyncDisposableState]]")||Ge.has(this,"[[DisposeCapability]]"))throw new Su("can only be used with new");Ge.set(this,"[[AsyncDisposableState]]","pending"),Ge.set(this,"[[DisposeCapability]]",ng())},ig=function(){var e=this;return Ge.assert(e,"[[AsyncDisposableState]]"),Ge.get(e,"[[AsyncDisposableState]]")==="disposed"},qs=UE(ig);rg?zE(nt.prototype,"disposed",{"[[Configurable]]":!0,"[[Enumerable]]":!1,"[[Get]]":ig}):nt.prototype.disposed=!1;var sg=function(e){Ge.set(e,"[[AsyncDisposableState]]","disposed"),rg||(e.disposed=!0)};hi(nt.prototype,"disposeAsync",function(){var e=this;return qs(e)?Gd(jd):(sg(e),ZE(Gd(jd,LE(Ge.get(e,"[[DisposeCapability]]"),ME())),function(t){return t["?"]()}))});hi(nt.prototype,"use",function(e){var t=this;if(qs(t))throw new Ra("a disposed stack can not use anything new");return ku(Ge.get(t,"[[DisposeCapability]]"),e,"ASYNC-DISPOSE"),e});hi(nt.prototype,"adopt",function(e,t){var r=this;if(qs(r))throw new Ra("a disposed stack can not use anything new");if(!tg(t))throw new Su("`onDisposeAsync` must be a function");var i=function(){return OE(t,void 0,[e])};return i.value=e,ku(Ge.get(r,"[[DisposeCapability]]"),void 0,"ASYNC-DISPOSE",i),e});hi(nt.prototype,"defer",function(e){var t=this;if(qs(t))throw new Ra("a disposed stack can not defer anything new");if(!tg(e))throw new Su("`onDispose` must be a function");ku(Ge.get(t,"[[DisposeCapability]]"),void 0,"ASYNC-DISPOSE",e)});hi(nt.prototype,"move",function(){var e=this;if(qs(e))throw new Ra("a disposed stack can not use anything new");var t=new nt;return Ge.set(t,"[[DisposeCapability]]",Ge.get(e,"[[DisposeCapability]]")),Ge.set(e,"[[DisposeCapability]]",ng()),sg(e),t});Bd&&hi(nt.prototype,Bd,nt.prototype.disposeAsync);NE(nt.prototype,"AsyncDisposableStack");var HE=nt,VE=HE,jE=function(){return typeof AsyncDisposableStack=="function"?AsyncDisposableStack:VE},GE=ar,BE=Jc(),WE=jE,qE=function(){var e=WE();return GE(BE,{AsyncDisposableStack:e},{AsyncDisposableStack:!0}),e},YE=G_,KE=Q_,JE=RE,XE=qE,QE=function(){YE(),KE(),JE(),XE()};QE();const Wd=new WeakMap;function e0(n){return(typeof n=="object"||typeof n=="function")&&n!==null&&"then"in n&&typeof n.then=="function"}function wr(n){return typeof n=="string"?n:typeof n=="symbol"?n.description??n.toString():n.name||"(anonymous class)"}function qd(){return new Error("register(Key, factory) requires a factory function. Wrap existing instances as () => instance.")}function t0(){return new Error("register(Key, factory) does not accept async factories. Await setup before registering.")}class n0{constructor(){b(this,"entries",new Map);b(this,"constructionStack",[])}register(e,t){if(t===void 0){if(typeof e!="function")throw qd();this.validateClassRegistration(e),this.storeFactory(e,()=>this.instantiateClass(e));return}if(typeof t!="function")throw qd();if(t.constructor.name==="AsyncFunction")throw t0();this.storeFactory(e,t)}has(e){var t;return((t=this.entries.get(e))==null?void 0:t.factory)!==void 0}resolve(e){return this.resolveAny(e)}storeFactory(e,t){const r=this.getOrCreateEntry(e);r.factory=t,r.instance=void 0,r.error=void 0}validateClassRegistration(e){const t=Wd.get(e);if(t){if(e.length!==t.length)throw new Error(`${wr(e)} cannot be registered with register(Class). @injectable(...) declared ${t.length} dependencies but constructor arity is ${e.length}. Use register(Key, () => value) instead.`);return}if(e.length!==0)throw new Error(`${wr(e)} cannot be registered with register(Class). Undecorated classes must have zero required constructor parameters. Use register(Key, () => value) instead.`)}instantiateClass(e){const t=Wd.get(e);if(!t)return new e;const r=t.map(i=>this.resolveAny(i));return new e(...r)}resolveAny(e){return this.getOrCreateEntry(e).proxy}getOrCreateEntry(e){let t=this.entries.get(e);return t||(t={key:e},t.proxy=this.createProxy(t),this.entries.set(e,t),t)}createProxy(e){return new Proxy({},{get:(t,r)=>{if(r==="then")return;const i=this.getInstance(e),s=Reflect.get(i,r,i);return typeof s=="function"?s.bind(i):s},set:(t,r,i)=>{const s=this.getInstance(e);return Reflect.set(s,r,i,s)},has:(t,r)=>{const i=this.getInstance(e);return r in i}})}getInstance(e){if(e.instance)return e.instance;if(e.error)throw e.error;if(!e.factory)throw new Error(`${wr(e.key)} was resolved but never registered`);const t=this.constructionStack.indexOf(e.key);if(t!==-1){const r=[...this.constructionStack.slice(t),e.key].map(i=>wr(i)).join(" -> ");throw new Error(`Circular dependency detected: ${r}`)}this.constructionStack.push(e.key);try{const r=e.factory();if(e0(r))throw new Error(`Factory for ${wr(e.key)} returned a Promise. Await setup before registering.`);if(typeof r!="object"||r===null)throw new Error(`Factory for ${wr(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 rt=new n0,r0=new Set(["target","currentTarget","eventPhase","defaultPrevented","isTrusted","timeStamp","srcElement","returnValue","cancelBubble","NONE","CAPTURING_PHASE","AT_TARGET","BUBBLING_PHASE","composedPath","stopPropagation","stopImmediatePropagation","preventDefault","initEvent"]);function i0(n){for(const e of Object.keys(n))if(r0.has(e))throw new Error(`Event payload key "${e}" is reserved; choose a different property name`)}function s0(n,e){i0(e);for(const t of Object.keys(e))Object.defineProperty(n,t,{value:e[t],writable:!0,enumerable:!0,configurable:!0})}function xt(){class n extends Event{constructor(t,r){const{type:i,bubbles:s,cancelable:o,composed:a,...l}=r??{};if(i!==void 0)throw new Error('Do not pass "type" in init; use the constructor argument instead');super(t,{bubbles:s,cancelable:o,composed:a}),s0(this,l)}}return n}class Tt extends globalThis.EventTarget{}function o0(n,e,t){const r=n.dispose.bind(n);n.dispose=()=>{if(!e())return t(),r()}}function di(n){var t;class e extends n{constructor(...s){super(...s);S(this,t,!1);o0(this,()=>c(this,t),()=>{E(this,t,!0)})}[Symbol.dispose](){this.dispose()}get disposed(){return c(this,t)}}return t=new WeakMap,e}const a0=xt(),zo=xt(),og="0123456789ABCDEFGHJKMNPQRSTVWXYZ",qo=32,l0=16,ag=10,Yd=0xffffffffffff;var zn;(function(n){n.Base32IncorrectEncoding="B32_ENC_INVALID",n.DecodeTimeInvalidCharacter="DEC_TIME_CHAR",n.DecodeTimeValueMalformed="DEC_TIME_MALFORMED",n.EncodeTimeNegative="ENC_TIME_NEG",n.EncodeTimeSizeExceeded="ENC_TIME_SIZE_EXCEED",n.EncodeTimeValueMalformed="ENC_TIME_MALFORMED",n.PRNGDetectFailure="PRNG_DETECT",n.ULIDInvalid="ULID_INVALID",n.Unexpected="UNEXPECTED",n.UUIDInvalid="UUID_INVALID"})(zn||(zn={}));class Oi extends Error{constructor(e,t){super(`${t} (${e})`),this.name="ULIDError",this.code=e}}function c0(n){const e=Math.floor(n()*qo)%qo;return og.charAt(e)}function u0(n){const e=h0(),t=e&&(e.crypto||e.msCrypto)||null;if(typeof(t==null?void 0:t.getRandomValues)=="function")return()=>{const r=new Uint8Array(1);return t.getRandomValues(r),r[0]/256};if(typeof(t==null?void 0:t.randomBytes)=="function")return()=>t.randomBytes(1).readUInt8()/256;throw new Oi(zn.PRNGDetectFailure,"Failed to find a reliable PRNG")}function h0(){return p0()?self:typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:null}function d0(n,e){let t="";for(;n>0;n--)t=c0(e)+t;return t}function f0(n,e=ag){if(isNaN(n))throw new Oi(zn.EncodeTimeValueMalformed,`Time must be a number: ${n}`);if(n>Yd)throw new Oi(zn.EncodeTimeSizeExceeded,`Cannot encode a time larger than ${Yd}: ${n}`);if(n<0)throw new Oi(zn.EncodeTimeNegative,`Time must be positive: ${n}`);if(Number.isInteger(n)===!1)throw new Oi(zn.EncodeTimeValueMalformed,`Time must be an integer: ${n}`);let t,r="";for(let i=e;i>0;i--)t=n%qo,r=og.charAt(t)+r,n=(n-t)/qo;return r}function p0(){return typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope}function Eu(n,e){const t=u0(),r=Date.now();return f0(r,ag)+d0(l0,t)}const At=4,Je=6,lg=2,ac=2,g0=At,m0=Je,$u="auto",fn="auto",Pn=120,Kd=75,pe=16,tr=Pn*At+pe*(At-1),Yo=Pn*Je+pe*(Je-1),y0=200,v0=4,go=150,b0=10,Jd=2,w0=4;function cg(n){return dg(n)}function ug(n,e){return dg(n.flatMap(t=>pg(t,e)))}function hg(n){const e=[],t=new Set;for(const r of n){if(r.type==="row"){e.push(`Top-level rows are invalid: ${r.id}`);continue}gg(r,"strip",e,t)}return{valid:e.length===0,errors:e}}function Wi(n){const e=cg(n),t=hg(e);if(!t.valid)throw new Error(`Invalid layout: ${t.errors.join("; ")}`);return{totalNodes:e.length,nodes:e.filter(r=>r.type!=="row").map(E0)}}function dg(n){const e=[];for(const t of n){const r=fg(t);for(const i of r){if(i.type==="row"){e.push(...i.children.map(Bt));continue}e.push(i)}}return e}function fg(n){switch(n.type){case"card":return[Bt(n)];case"row":{const e=n.children.map(Bt);return e.length===0?[]:e.length===1?[e[0]]:[{...n,children:e}]}case"stack":{const e=[];for(const t of n.children){const r=fg(t);for(const i of r){if(i.type==="stack"){e.push(...i.children.map(lc));continue}if(i.type==="row"){e.push({...i,children:i.children.map(Bt)});continue}e.push(Bt(i))}}return e.length===0?[]:e.length===1?[lc(e[0])]:[{...n,children:e}]}}}function pg(n,e){switch(n.type){case"card":return n.artifactID===e?[]:[Bt(n)];case"row":{const t=n.children.filter(r=>r.artifactID!==e).map(Bt);return t.length===0?[]:t.length===1?[t[0]]:[{...n,children:t}]}case"stack":{const t=n.children.flatMap(r=>pg(r,e).filter(s=>s.type!=="stack"));return t.length===0?[]:t.length===1?[lc(t[0])]:[{...n,children:t}]}}}function gg(n,e,t,r){switch(n.type){case"card":mg(n,e,t,r);return;case"row":_0(n,e,t,r);return;case"stack":S0(n,e,t,r);return}}function mg(n,e,t,r){Au(n.id,t),typeof n.artifactID!="string"||n.artifactID.length===0?t.push(`Card ${n.id} is missing artifactID`):r.has(n.artifactID)?t.push(`Duplicate artifactID in layout: ${n.artifactID}`):r.add(n.artifactID),k0(n.width)||t.push(`Card ${n.id} width must be an integer in the range 2-4`),yg(n.height)||t.push(`Card ${n.id} height must be an integer in the range 2-6 or "auto"`);const i=Rn(n.width);e==="row"&&i<lg&&t.push(`Row child ${n.id} must be at least 2 columns wide`)}function _0(n,e,t,r){if(Au(n.id,t),e!=="stack"&&t.push(`Row ${n.id} may only appear inside a stack`),yg(n.height,w0)||t.push(`Row ${n.id} height must be an integer in the range 2-4 or "auto"`),!Array.isArray(n.children)||n.children.length===0){t.push(`Row ${n.id} must contain card nodes`);return}let i=0;for(const s of n.children){if(s.type!=="card"){t.push(`Row ${n.id} must contain only card nodes`);continue}mg(s,"row",t,r),i+=Rn(s.width)}i!==At&&t.push(`Row ${n.id} children must sum to 4 columns`)}function S0(n,e,t,r){if(Au(n.id,t),e!=="strip"&&t.push(`Invalid nested stack at ${n.id}; stack children cannot contain another nested stack`),!Array.isArray(n.children)||n.children.length===0){t.push(`Stack ${n.id} must contain at least one child`);return}let i=0,s=0;for(const a of n.children){if(a.type==="stack"){t.push(`Stack ${n.id} cannot contain another nested stack`);continue}if(gg(a,"stack",t,r),a.height===fn){s+=1;continue}i+=a.height}if(i>Je&&t.push(`Stack ${n.id} exceeds the 6-row budget`),s===0)return;const o=Je-i;if(o<s*ac||o%s!==0){t.push(`Stack ${n.id} has auto-height children that cannot resolve to whole height >= 2`);return}o/s<ac&&t.push(`Stack ${n.id} has auto-height children below the minimum row size`)}function Au(n,e){(typeof n!="string"||n.length===0)&&e.push(`Node id must be a non-empty string: ${String(n)}`)}function k0(n){return n===$u||Number.isInteger(n)&&n>=lg&&n<=g0}function yg(n,e=m0){return n===fn||Number.isInteger(n)&&n>=ac&&n<=e}function Rn(n){return n===$u?At:n}function E0(n){if(n.type==="card")return{id:n.id,type:"card",width:Rn(n.width),cards:[{id:n.id,artifactID:n.artifactID,col:1,row:1,width:Rn(n.width),height:vg(n.height,Je)}]};const e=$0(n.children),t=[];let r=1;for(let i=0;i<n.children.length;i+=1){const s=n.children[i],o=e[i];if(s.type==="card")t.push({id:s.id,artifactID:s.artifactID,col:1,row:r,width:Rn(s.width),height:o});else{let a=1;for(const l of s.children)t.push({id:l.id,artifactID:l.artifactID,col:a,row:r,width:Rn(l.width),height:o}),a+=Rn(l.width)}r+=o}return{id:n.id,type:"stack",width:t.reduce((i,s)=>Math.max(i,s.col+s.width-1),1),cards:t}}function $0(n){let e=0,t=0;for(const i of n)i.height===fn?t+=1:e+=i.height;const r=t>0?(Je-e)/t:0;return n.map(i=>vg(i.height,r))}function vg(n,e){return n===fn?e:n}function Bt(n){return{...n}}function lc(n){return n.type==="card"?Bt(n):{...n,children:n.children.map(Bt)}}function bg(n,e={}){return{id:e.id??Eu(),type:"card",artifactID:n,width:e.width??$u,height:e.height??fn}}function wg(n,e){return n.some(t=>_g(t,e))}function _g(n,e){switch(n.type){case"card":return n.artifactID===e;case"row":return n.children.some(t=>t.artifactID===e);case"stack":return n.children.some(t=>_g(t,e))}}function Xd(n){return n.layout.flatMap(Sg)}function Sg(n){switch(n.type){case"card":return[n.artifactID];case"row":return n.children.map(e=>e.artifactID);case"stack":return n.children.flatMap(Sg)}}const Q=xt(),kg=xt(),Ei=xt(),A0=xt();function x0(n){class e extends Error{constructor(r,i){super(r),this.name=n,i&&Object.assign(this,i)}}return e}const T0=x0("RequestError"),C0=200,I0=300;class P0{constructor(e,t){b(this,"serverURL");b(this,"token");this.serverURL=e.replace(/\/$/,""),this.token=t.token}async requestJSON(e,t,r){const i=await this.request(e,t,r!==void 0?JSON.stringify(r):void 0,r!==void 0?{"content-type":"application/json"}:void 0),s=await R0(i);if(!i.ok||i.status<C0||i.status>=I0)throw this.createError(typeof s.error=="string"?s.error:i.statusText,i.status);return s}async requestVoid(e,t){const r=await this.request(e,t);if(!r.ok)throw this.createError(await Rl(r,r.statusText),r.status)}async requestText(e,t){const r=await this.request(e,t);if(!r.ok)throw this.createError(await Rl(r,r.statusText),r.status);return r.text()}async requestRawVoid(e,t,r){const i=await this.request(e,t,r,{"content-type":"text/plain"});if(!i.ok)throw this.createError(await Rl(i,i.statusText),i.status)}createError(e,t){const r={serverURL:this.serverURL};return t!==void 0&&(r.status=t),new T0(e,r)}async request(e,t,r,i){const s=`${this.serverURL}${t}`;try{return await fetch(s,{method:e,headers:this.buildHeaders(i),body:r})}catch(o){throw this.createError(o instanceof Error?o.message:"Failed to reach server")}}buildHeaders(e){const t={...e??{}};return this.token&&(t.Authorization=`Bearer ${this.token}`),Object.keys(t).length>0?t:void 0}}async function R0(n){try{return await n.json()}catch{const e=await n.text().catch(()=>"");return e?{message:e}:{}}}async function Rl(n,e){try{const t=await n.json();if(typeof t.error=="string")return t.error;if(typeof t.message=="string")return t.message}catch{}return e}function Eg(n){return n.map(e=>`${e.name} (${e.id})`).join(", ")}var _t,aa,$g;class D0{constructor(e){S(this,aa);S(this,_t);E(this,_t,e)}list(){return c(this,_t).requestJSON("GET","/screens")}async get(e={}){const t=await m(this,aa,$g).call(this,e.screenID);return c(this,_t).requestJSON("GET",`/screens/${encodeURIComponent(t)}`)}create(e){const t={name:e.name};return e.id!==void 0&&(t.id=e.id),c(this,_t).requestJSON("POST","/screens",t)}update(e){const t={};return e.name!==void 0&&(t.name=e.name),e.layout!==void 0&&(t.layout=e.layout),c(this,_t).requestJSON("PATCH",`/screens/${encodeURIComponent(e.screenID)}`,t)}remove(e){return c(this,_t).requestJSON("DELETE",`/screens/${encodeURIComponent(e.screenID)}`)}}_t=new WeakMap,aa=new WeakSet,$g=async function(e){if(e!==void 0)return e;const{screens:t}=await this.list();if(t.length===1)return t[0].id;throw c(this,_t).createError(`screenID is required when multiple screens exist. Available screens: ${Eg(t)}`)};var Ze,ns,la,Ag;class O0{constructor(e,t){S(this,la);S(this,Ze);S(this,ns);E(this,Ze,e),E(this,ns,t)}async create(e){const t=await m(this,la,Ag).call(this,e.screenID);return c(this,Ze).requestJSON("POST",`/screens/${encodeURIComponent(t)}/artifact`,{type:e.type,title:e.title,externalFilePath:e.externalFilePath})}get(e){return c(this,Ze).requestJSON("GET",`/artifacts/${encodeURIComponent(e.artifactID)}`)}update(e){const t={};return e.title!==void 0&&(t.title=e.title),c(this,Ze).requestJSON("PATCH",`/artifacts/${encodeURIComponent(e.artifactID)}`,t)}edit(e){return c(this,Ze).requestJSON("POST",`/artifacts/${encodeURIComponent(e.artifactID)}/edit`)}commitPending(e){return c(this,Ze).requestJSON("POST",`/artifacts/${encodeURIComponent(e.artifactID)}/commit`)}abandonPending(e){return c(this,Ze).requestVoid("POST",`/artifacts/${encodeURIComponent(e.artifactID)}/abandon`)}remove(e){return c(this,Ze).requestJSON("DELETE",`/screens/${encodeURIComponent(e.screenID)}/artifacts/${encodeURIComponent(e.artifactID)}`)}getContent(e){return c(this,Ze).requestText("GET",`/artifacts/${encodeURIComponent(e.artifactID)}/content`)}putContent(e){return c(this,Ze).requestRawVoid("PUT",`/artifacts/${encodeURIComponent(e.artifactID)}/content`,e.content)}}Ze=new WeakMap,ns=new WeakMap,la=new WeakSet,Ag=async function(e){if(e!==void 0)return e;const{screens:t}=await c(this,ns).list();if(t.length===1)return t[0].id;throw c(this,Ze).createError(`screenID is required when multiple screens exist. Available screens: ${Eg(t)}`)};var rs;class z0{constructor(e){S(this,rs);E(this,rs,e)}async list(){const{views:e}=await c(this,rs).requestJSON("GET","/views");return e}}rs=new WeakMap;var tn;class L0{constructor(e,t={}){b(this,"screens");b(this,"artifacts");b(this,"views");S(this,tn);E(this,tn,new P0(e,t)),this.screens=new D0(c(this,tn)),this.artifacts=new O0(c(this,tn),this.screens),this.views=new z0(c(this,tn))}health(){return c(this,tn).requestJSON("GET","/health")}}tn=new WeakMap;const M0=di(Tt);var Mn,He,Nn,ze,nn,rn,J,Sr,xg,is,Tg,Cg,Ig,Pg,cc,uc,hc,Rg;class N0 extends M0{constructor(t){var i;super();S(this,J);b(this,"id");b(this,"server");S(this,Mn);S(this,He,new Map);S(this,Nn);S(this,ze);S(this,nn);S(this,rn,null);S(this,is,t=>{if(this.disposed)return;const r=t.event;switch(r.type){case"screen-updated":r.screen.id===this.id&&m(this,J,Tg).call(this,r.screen);break;case"artifact-created":r.screenID===this.id&&m(this,J,Cg).call(this,r.artifact);break;case"artifact-updated":m(this,J,Ig).call(this,r.artifact);break;case"artifact-removed":r.screenID===this.id&&m(this,J,Pg).call(this,r.artifactID);break;case"artifact-content-changed":c(this,He).has(r.artifactID)&&this.dispatchEvent(new A0("artifact-content-changed",{artifactID:r.artifactID}));break}});this.id=t.screen.id,this.server=t.server,E(this,Mn,t.localStore),E(this,Nn,t.screen.name),E(this,ze,structuredClone(t.screen.layout));const r=((i=c(this,Mn).get().screens[this.id])==null?void 0:i.scrollPosition)??0;E(this,nn,Math.max(0,r)),this.server.addEventListener("server-event",c(this,is)),m(this,J,xg).call(this)}get name(){return c(this,Nn)}get layout(){return c(this,ze)}get scrollPosition(){return c(this,nn)}get artifacts(){return c(this,He)}setScrollPosition(t){m(this,J,Sr).call(this);const r=Math.max(0,t);r!==c(this,nn)&&(E(this,nn,r),m(this,J,Rg).call(this),this.dispatchEvent(new Q("change")))}setLayout(t){m(this,J,Sr).call(this);const r=cg(t);if(!hg(r).valid)return;const s=m(this,J,uc).call(this);E(this,ze,r),E(this,rn,{layout:r,snapshot:s}),this.dispatchEvent(new Q("change")),this.server.client.screens.update({screenID:this.id,layout:r.map(o=>structuredClone(o))}).catch(()=>{var o;this.disposed||((o=c(this,rn))==null?void 0:o.layout)===r&&(E(this,rn,null),m(this,J,hc).call(this,s),this.dispatchEvent(new Q("change")))})}rename(t){m(this,J,Sr).call(this),E(this,Nn,t),this.dispatchEvent(new Q("change")),this.server.client.screens.update({screenID:this.id,name:t}).catch(()=>{})}async remove(){m(this,J,Sr).call(this),await this.server.client.screens.remove({screenID:this.id})}removeArtifact(t){if(m(this,J,Sr).call(this),!c(this,He).has(t))return;const r=m(this,J,uc).call(this);m(this,J,cc).call(this,t),this.dispatchEvent(new Q("change")),this.server.client.artifacts.remove({artifactID:t,screenID:this.id}).catch(()=>{this.disposed||(m(this,J,hc).call(this,r),this.dispatchEvent(new Q("change")))})}dispose(){this.server.removeEventListener("server-event",c(this,is))}}Mn=new WeakMap,He=new WeakMap,Nn=new WeakMap,ze=new WeakMap,nn=new WeakMap,rn=new WeakMap,J=new WeakSet,Sr=function(){if(this.disposed)throw new Error("ScreenModel is disposed")},xg=async function(){try{const t=await this.server.client.screens.get({screenID:this.id});if(this.disposed)return;for(const r of t.artifacts)c(this,He).set(r.id,r);this.dispatchEvent(new Q("change"))}catch{}},is=new WeakMap,Tg=function(t){c(this,rn)&&E(this,rn,null),E(this,Nn,t.name),E(this,ze,structuredClone(t.layout)),this.dispatchEvent(new Q("change"))},Cg=function(t){wg(c(this,ze),t.id)||E(this,ze,[...c(this,ze),bg(t.id)]),c(this,He).set(t.id,t),this.dispatchEvent(new Q("change"))},Ig=function(t){const r=c(this,He).get(t.id);r&&(c(this,He).set(t.id,{...r,...t}),this.dispatchEvent(new Q("change")))},Pg=function(t){m(this,J,cc).call(this,t)&&this.dispatchEvent(new Q("change"))},cc=function(t){const r=c(this,He).delete(t),i=Xd({layout:c(this,ze)}).length,s=ug(c(this,ze),t),o=Xd({layout:s}).length;return E(this,ze,s),r||i!==o},uc=function(){return{layout:structuredClone(c(this,ze)),artifacts:new Map([...c(this,He).entries()].map(([t,r])=>[t,structuredClone(r)]))}},hc=function(t){E(this,ze,structuredClone(t.layout)),c(this,He).clear();for(const[r,i]of t.artifacts)c(this,He).set(r,structuredClone(i))},Rg=function(){const t=c(this,Mn).get();c(this,Mn).set({...t,screens:{...t.screens,[this.id]:{scrollPosition:c(this,nn)}}})};const U0=di(Tt);var Xe,Mt,at,ss,os,as,Dr,Lo;class F0 extends U0{constructor(t){super();S(this,Dr);S(this,Xe);S(this,Mt);S(this,at,null);S(this,ss,()=>{this.disposed||m(this,Dr,Lo).call(this)});S(this,os,()=>{this.disposed||m(this,Dr,Lo).call(this)});S(this,as,t=>{var i;if(this.disposed)return;const r=t.event;r.type==="screen-removed"&&((i=c(this,at))==null?void 0:i.id)===r.screenID&&this.clearActive()});E(this,Xe,t.localStore),E(this,Mt,t.serverManager),c(this,Xe).addEventListener("change",c(this,ss)),c(this,Mt).addEventListener("change",c(this,os)),c(this,Mt).addEventListener("server-event",c(this,as)),m(this,Dr,Lo).call(this)}get activeScreen(){return c(this,at)}setActive(t,r){const i=c(this,Xe).get();i.activeServerURL===t&&i.activeScreenID===r||c(this,Xe).set({...i,activeServerURL:t,activeScreenID:r})}clearActive(){const t=c(this,Xe).get();t.activeScreenID!==null&&c(this,Xe).set({...t,activeScreenID:null})}dispose(){var t;c(this,Xe).removeEventListener("change",c(this,ss)),c(this,Mt).removeEventListener("change",c(this,os)),c(this,Mt).removeEventListener("server-event",c(this,as)),(t=c(this,at))==null||t.dispose(),E(this,at,null)}}Xe=new WeakMap,Mt=new WeakMap,at=new WeakMap,ss=new WeakMap,os=new WeakMap,as=new WeakMap,Dr=new WeakSet,Lo=function(){var l,u,d;const{activeServerURL:t,activeScreenID:r}=c(this,Xe).get(),i=t?c(this,Mt).servers.get(t)??null:null,s=i&&r?i.screens.get(r)??null:null,o=((l=c(this,at))==null?void 0:l.id)??null,a=(s==null?void 0:s.id)??null;o===a&&((u=c(this,at))==null?void 0:u.server)===i||((d=c(this,at))==null||d.dispose(),E(this,at,i&&s?new N0({screen:s,server:i,localStore:c(this,Xe)}):null),this.dispatchEvent(new a0("active-screen-changed")))};const Z0="Local",H0="store-";function Lt(n){return new URL(n).origin}function V0(n){return{servers:[{url:Lt(n),name:Z0}],activeServerURL:null,activeScreenID:null,screens:{}}}var Un,Fn,Zn;class j0 extends Tt{constructor(t,r,i={}){super();S(this,Un);S(this,Fn);S(this,Zn);E(this,Un,`${H0}${t}`),E(this,Fn,i.storage??G0());const s=c(this,Fn).getItem(c(this,Un));s===null?(E(this,Zn,r),c(this,Fn).setItem(c(this,Un),JSON.stringify(r))):E(this,Zn,JSON.parse(s))}get(){return c(this,Zn)}set(t){E(this,Zn,t),c(this,Fn).setItem(c(this,Un),JSON.stringify(t)),this.dispatchEvent(new Q("change"))}}Un=new WeakMap,Fn=new WeakMap,Zn=new WeakMap;function G0(){const n=globalThis.localStorage;if(!n)throw new Error("LocalStore: no storage adapter supplied and window.localStorage is unavailable");return n}function $(n,e,t){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(n))return;a._zod.traits.add(n),e(a,l);const u=o.prototype,d=Object.keys(u);for(let f=0;f<d.length;f++){const v=d[f];v in a||(a[v]=u[v].bind(a))}}const i=(t==null?void 0:t.Parent)??Object;class s extends i{}Object.defineProperty(s,"name",{value:n});function o(a){var l;const u=t!=null&&t.Parent?new s:this;r(u,a),(l=u._zod).deferred??(l.deferred=[]);for(const d of u._zod.deferred)d();return u}return Object.defineProperty(o,"init",{value:r}),Object.defineProperty(o,Symbol.hasInstance,{value:a=>{var l,u;return t!=null&&t.Parent&&a instanceof t.Parent?!0:(u=(l=a==null?void 0:a._zod)==null?void 0:l.traits)==null?void 0:u.has(n)}}),Object.defineProperty(o,"name",{value:n}),o}class Rr extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class Dg extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name="ZodEncodeError"}}const Og={};function pn(n){return Og}function zg(n){const e=Object.values(n).filter(r=>typeof r=="number");return Object.entries(n).filter(([r,i])=>e.indexOf(+r)===-1).map(([r,i])=>i)}function dc(n,e){return typeof e=="bigint"?e.toString():e}function xu(n){return{get value(){{const e=n();return Object.defineProperty(this,"value",{value:e}),e}}}}function Tu(n){return n==null}function Cu(n){const e=n.startsWith("^")?1:0,t=n.endsWith("$")?n.length-1:n.length;return n.slice(e,t)}function B0(n,e){const t=(n.toString().split(".")[1]||"").length,r=e.toString();let i=(r.split(".")[1]||"").length;if(i===0&&/\d?e-\d?/.test(r)){const l=r.match(/\d?e-(\d?)/);l!=null&&l[1]&&(i=Number.parseInt(l[1]))}const s=t>i?t:i,o=Number.parseInt(n.toFixed(s).replace(".","")),a=Number.parseInt(e.toFixed(s).replace(".",""));return o%a/10**s}const Qd=Symbol("evaluating");function X(n,e,t){let r;Object.defineProperty(n,e,{get(){if(r!==Qd)return r===void 0&&(r=Qd,r=t()),r},set(i){Object.defineProperty(n,e,{value:i})},configurable:!0})}function cr(n,e,t){Object.defineProperty(n,e,{value:t,writable:!0,enumerable:!0,configurable:!0})}function _n(...n){const e={};for(const t of n){const r=Object.getOwnPropertyDescriptors(t);Object.assign(e,r)}return Object.defineProperties({},e)}function ef(n){return JSON.stringify(n)}function W0(n){return n.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}const Lg="captureStackTrace"in Error?Error.captureStackTrace:(...n)=>{};function Ko(n){return typeof n=="object"&&n!==null&&!Array.isArray(n)}const q0=xu(()=>{var n;if(typeof navigator<"u"&&((n=navigator==null?void 0:navigator.userAgent)!=null&&n.includes("Cloudflare")))return!1;try{const e=Function;return new e(""),!0}catch{return!1}});function Qr(n){if(Ko(n)===!1)return!1;const e=n.constructor;if(e===void 0||typeof e!="function")return!0;const t=e.prototype;return!(Ko(t)===!1||Object.prototype.hasOwnProperty.call(t,"isPrototypeOf")===!1)}function Mg(n){return Qr(n)?{...n}:Array.isArray(n)?[...n]:n}const Y0=new Set(["string","number","symbol"]);function ei(n){return n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Sn(n,e,t){const r=new n._zod.constr(e??n._zod.def);return(!e||t!=null&&t.parent)&&(r._zod.parent=n),r}function O(n){const e=n;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 K0(n){return Object.keys(n).filter(e=>n[e]._zod.optin==="optional"&&n[e]._zod.optout==="optional")}const J0={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 X0(n,e){const t=n._zod.def,r=t.checks;if(r&&r.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");const s=_n(n._zod.def,{get shape(){const o={};for(const a in e){if(!(a in t.shape))throw new Error(`Unrecognized key: "${a}"`);e[a]&&(o[a]=t.shape[a])}return cr(this,"shape",o),o},checks:[]});return Sn(n,s)}function Q0(n,e){const t=n._zod.def,r=t.checks;if(r&&r.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");const s=_n(n._zod.def,{get shape(){const o={...n._zod.def.shape};for(const a in e){if(!(a in t.shape))throw new Error(`Unrecognized key: "${a}"`);e[a]&&delete o[a]}return cr(this,"shape",o),o},checks:[]});return Sn(n,s)}function e$(n,e){if(!Qr(e))throw new Error("Invalid input to extend: expected a plain object");const t=n._zod.def.checks;if(t&&t.length>0){const s=n._zod.def.shape;for(const o in e)if(Object.getOwnPropertyDescriptor(s,o)!==void 0)throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}const i=_n(n._zod.def,{get shape(){const s={...n._zod.def.shape,...e};return cr(this,"shape",s),s}});return Sn(n,i)}function t$(n,e){if(!Qr(e))throw new Error("Invalid input to safeExtend: expected a plain object");const t=_n(n._zod.def,{get shape(){const r={...n._zod.def.shape,...e};return cr(this,"shape",r),r}});return Sn(n,t)}function n$(n,e){const t=_n(n._zod.def,{get shape(){const r={...n._zod.def.shape,...e._zod.def.shape};return cr(this,"shape",r),r},get catchall(){return e._zod.def.catchall},checks:[]});return Sn(n,t)}function r$(n,e,t){const i=e._zod.def.checks;if(i&&i.length>0)throw new Error(".partial() cannot be used on object schemas containing refinements");const o=_n(e._zod.def,{get shape(){const a=e._zod.def.shape,l={...a};if(t)for(const u in t){if(!(u in a))throw new Error(`Unrecognized key: "${u}"`);t[u]&&(l[u]=n?new n({type:"optional",innerType:a[u]}):a[u])}else for(const u in a)l[u]=n?new n({type:"optional",innerType:a[u]}):a[u];return cr(this,"shape",l),l},checks:[]});return Sn(e,o)}function i$(n,e,t){const r=_n(e._zod.def,{get shape(){const i=e._zod.def.shape,s={...i};if(t)for(const o in t){if(!(o in s))throw new Error(`Unrecognized key: "${o}"`);t[o]&&(s[o]=new n({type:"nonoptional",innerType:i[o]}))}else for(const o in i)s[o]=new n({type:"nonoptional",innerType:i[o]});return cr(this,"shape",s),s}});return Sn(e,r)}function Cr(n,e=0){var t;if(n.aborted===!0)return!0;for(let r=e;r<n.issues.length;r++)if(((t=n.issues[r])==null?void 0:t.continue)!==!0)return!0;return!1}function Ir(n,e){return e.map(t=>{var r;return(r=t).path??(r.path=[]),t.path.unshift(n),t})}function mo(n){return typeof n=="string"?n:n==null?void 0:n.message}function gn(n,e,t){var i,s,o,a,l,u;const r={...n,path:n.path??[]};if(!n.message){const d=mo((o=(s=(i=n.inst)==null?void 0:i._zod.def)==null?void 0:s.error)==null?void 0:o.call(s,n))??mo((a=e==null?void 0:e.error)==null?void 0:a.call(e,n))??mo((l=t.customError)==null?void 0:l.call(t,n))??mo((u=t.localeError)==null?void 0:u.call(t,n))??"Invalid input";r.message=d}return delete r.inst,delete r.continue,e!=null&&e.reportInput||delete r.input,r}function Iu(n){return Array.isArray(n)?"array":typeof n=="string"?"string":"unknown"}function Ji(...n){const[e,t,r]=n;return typeof e=="string"?{message:e,code:"custom",input:t,inst:r}:{...e}}const Ng=(n,e)=>{n.name="$ZodError",Object.defineProperty(n,"_zod",{value:n._zod,enumerable:!1}),Object.defineProperty(n,"issues",{value:e,enumerable:!1}),n.message=JSON.stringify(e,dc,2),Object.defineProperty(n,"toString",{value:()=>n.message,enumerable:!1})},Ug=$("$ZodError",Ng),Fg=$("$ZodError",Ng,{Parent:Error});function s$(n,e=t=>t.message){const t={},r=[];for(const i of n.issues)i.path.length>0?(t[i.path[0]]=t[i.path[0]]||[],t[i.path[0]].push(e(i))):r.push(e(i));return{formErrors:r,fieldErrors:t}}function o$(n,e=t=>t.message){const t={_errors:[]},r=i=>{for(const s of i.issues)if(s.code==="invalid_union"&&s.errors.length)s.errors.map(o=>r({issues:o}));else if(s.code==="invalid_key")r({issues:s.issues});else if(s.code==="invalid_element")r({issues:s.issues});else if(s.path.length===0)t._errors.push(e(s));else{let o=t,a=0;for(;a<s.path.length;){const l=s.path[a];a===s.path.length-1?(o[l]=o[l]||{_errors:[]},o[l]._errors.push(e(s))):o[l]=o[l]||{_errors:[]},o=o[l],a++}}};return r(n),t}const Pu=n=>(e,t,r,i)=>{const s=r?Object.assign(r,{async:!1}):{async:!1},o=e._zod.run({value:t,issues:[]},s);if(o instanceof Promise)throw new Rr;if(o.issues.length){const a=new((i==null?void 0:i.Err)??n)(o.issues.map(l=>gn(l,s,pn())));throw Lg(a,i==null?void 0:i.callee),a}return o.value},Ru=n=>async(e,t,r,i)=>{const s=r?Object.assign(r,{async:!0}):{async:!0};let o=e._zod.run({value:t,issues:[]},s);if(o instanceof Promise&&(o=await o),o.issues.length){const a=new((i==null?void 0:i.Err)??n)(o.issues.map(l=>gn(l,s,pn())));throw Lg(a,i==null?void 0:i.callee),a}return o.value},Da=n=>(e,t,r)=>{const i=r?{...r,async:!1}:{async:!1},s=e._zod.run({value:t,issues:[]},i);if(s instanceof Promise)throw new Rr;return s.issues.length?{success:!1,error:new(n??Ug)(s.issues.map(o=>gn(o,i,pn())))}:{success:!0,data:s.value}},a$=Da(Fg),Oa=n=>async(e,t,r)=>{const i=r?Object.assign(r,{async:!0}):{async:!0};let s=e._zod.run({value:t,issues:[]},i);return s instanceof Promise&&(s=await s),s.issues.length?{success:!1,error:new n(s.issues.map(o=>gn(o,i,pn())))}:{success:!0,data:s.value}},l$=Oa(Fg),c$=n=>(e,t,r)=>{const i=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return Pu(n)(e,t,i)},u$=n=>(e,t,r)=>Pu(n)(e,t,r),h$=n=>async(e,t,r)=>{const i=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return Ru(n)(e,t,i)},d$=n=>async(e,t,r)=>Ru(n)(e,t,r),f$=n=>(e,t,r)=>{const i=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return Da(n)(e,t,i)},p$=n=>(e,t,r)=>Da(n)(e,t,r),g$=n=>async(e,t,r)=>{const i=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return Oa(n)(e,t,i)},m$=n=>async(e,t,r)=>Oa(n)(e,t,r),y$=/^[cC][^\s-]{8,}$/,v$=/^[0-9a-z]+$/,b$=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,w$=/^[0-9a-vA-V]{20}$/,_$=/^[A-Za-z0-9]{27}$/,S$=/^[a-zA-Z0-9_-]{21}$/,k$=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,E$=/^([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})$/,tf=n=>n?new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${n}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,$$=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,A$="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function x$(){return new RegExp(A$,"u")}const T$=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,C$=/^(([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}|:))$/,I$=/^((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])$/,P$=/^(([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])$/,R$=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Zg=/^[A-Za-z0-9_-]*$/,D$=/^\+[1-9]\d{6,14}$/,Hg="(?:(?:\\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])))",O$=new RegExp(`^${Hg}$`);function Vg(n){const e="(?:[01]\\d|2[0-3]):[0-5]\\d";return typeof n.precision=="number"?n.precision===-1?`${e}`:n.precision===0?`${e}:[0-5]\\d`:`${e}:[0-5]\\d\\.\\d{${n.precision}}`:`${e}(?::[0-5]\\d(?:\\.\\d+)?)?`}function z$(n){return new RegExp(`^${Vg(n)}$`)}function L$(n){const e=Vg({precision:n.precision}),t=["Z"];n.local&&t.push(""),n.offset&&t.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");const r=`${e}(?:${t.join("|")})`;return new RegExp(`^${Hg}T(?:${r})$`)}const M$=n=>{const e=n?`[\\s\\S]{${(n==null?void 0:n.minimum)??0},${(n==null?void 0:n.maximum)??""}}`:"[\\s\\S]*";return new RegExp(`^${e}$`)},N$=/^-?\d+$/,jg=/^-?\d+(?:\.\d+)?$/,U$=/^(?:true|false)$/i,F$=/^[^A-Z]*$/,Z$=/^[^a-z]*$/,Be=$("$ZodCheck",(n,e)=>{var t;n._zod??(n._zod={}),n._zod.def=e,(t=n._zod).onattach??(t.onattach=[])}),Gg={number:"number",bigint:"bigint",object:"date"},Bg=$("$ZodCheckLessThan",(n,e)=>{Be.init(n,e);const t=Gg[typeof e.value];n._zod.onattach.push(r=>{const i=r._zod.bag,s=(e.inclusive?i.maximum:i.exclusiveMaximum)??Number.POSITIVE_INFINITY;e.value<s&&(e.inclusive?i.maximum=e.value:i.exclusiveMaximum=e.value)}),n._zod.check=r=>{(e.inclusive?r.value<=e.value:r.value<e.value)||r.issues.push({origin:t,code:"too_big",maximum:typeof e.value=="object"?e.value.getTime():e.value,input:r.value,inclusive:e.inclusive,inst:n,continue:!e.abort})}}),Wg=$("$ZodCheckGreaterThan",(n,e)=>{Be.init(n,e);const t=Gg[typeof e.value];n._zod.onattach.push(r=>{const i=r._zod.bag,s=(e.inclusive?i.minimum:i.exclusiveMinimum)??Number.NEGATIVE_INFINITY;e.value>s&&(e.inclusive?i.minimum=e.value:i.exclusiveMinimum=e.value)}),n._zod.check=r=>{(e.inclusive?r.value>=e.value:r.value>e.value)||r.issues.push({origin:t,code:"too_small",minimum:typeof e.value=="object"?e.value.getTime():e.value,input:r.value,inclusive:e.inclusive,inst:n,continue:!e.abort})}}),H$=$("$ZodCheckMultipleOf",(n,e)=>{Be.init(n,e),n._zod.onattach.push(t=>{var r;(r=t._zod.bag).multipleOf??(r.multipleOf=e.value)}),n._zod.check=t=>{if(typeof t.value!=typeof e.value)throw new Error("Cannot mix number and bigint in multiple_of check.");(typeof t.value=="bigint"?t.value%e.value===BigInt(0):B0(t.value,e.value)===0)||t.issues.push({origin:typeof t.value,code:"not_multiple_of",divisor:e.value,input:t.value,inst:n,continue:!e.abort})}}),V$=$("$ZodCheckNumberFormat",(n,e)=>{var o;Be.init(n,e),e.format=e.format||"float64";const t=(o=e.format)==null?void 0:o.includes("int"),r=t?"int":"number",[i,s]=J0[e.format];n._zod.onattach.push(a=>{const l=a._zod.bag;l.format=e.format,l.minimum=i,l.maximum=s,t&&(l.pattern=N$)}),n._zod.check=a=>{const l=a.value;if(t){if(!Number.isInteger(l)){a.issues.push({expected:r,format:e.format,code:"invalid_type",continue:!1,input:l,inst:n});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:n,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:n,origin:r,inclusive:!0,continue:!e.abort});return}}l<i&&a.issues.push({origin:"number",input:l,code:"too_small",minimum:i,inclusive:!0,inst:n,continue:!e.abort}),l>s&&a.issues.push({origin:"number",input:l,code:"too_big",maximum:s,inclusive:!0,inst:n,continue:!e.abort})}}),j$=$("$ZodCheckMaxLength",(n,e)=>{var t;Be.init(n,e),(t=n._zod.def).when??(t.when=r=>{const i=r.value;return!Tu(i)&&i.length!==void 0}),n._zod.onattach.push(r=>{const i=r._zod.bag.maximum??Number.POSITIVE_INFINITY;e.maximum<i&&(r._zod.bag.maximum=e.maximum)}),n._zod.check=r=>{const i=r.value;if(i.length<=e.maximum)return;const o=Iu(i);r.issues.push({origin:o,code:"too_big",maximum:e.maximum,inclusive:!0,input:i,inst:n,continue:!e.abort})}}),G$=$("$ZodCheckMinLength",(n,e)=>{var t;Be.init(n,e),(t=n._zod.def).when??(t.when=r=>{const i=r.value;return!Tu(i)&&i.length!==void 0}),n._zod.onattach.push(r=>{const i=r._zod.bag.minimum??Number.NEGATIVE_INFINITY;e.minimum>i&&(r._zod.bag.minimum=e.minimum)}),n._zod.check=r=>{const i=r.value;if(i.length>=e.minimum)return;const o=Iu(i);r.issues.push({origin:o,code:"too_small",minimum:e.minimum,inclusive:!0,input:i,inst:n,continue:!e.abort})}}),B$=$("$ZodCheckLengthEquals",(n,e)=>{var t;Be.init(n,e),(t=n._zod.def).when??(t.when=r=>{const i=r.value;return!Tu(i)&&i.length!==void 0}),n._zod.onattach.push(r=>{const i=r._zod.bag;i.minimum=e.length,i.maximum=e.length,i.length=e.length}),n._zod.check=r=>{const i=r.value,s=i.length;if(s===e.length)return;const o=Iu(i),a=s>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:n,continue:!e.abort})}}),za=$("$ZodCheckStringFormat",(n,e)=>{var t,r;Be.init(n,e),n._zod.onattach.push(i=>{const s=i._zod.bag;s.format=e.format,e.pattern&&(s.patterns??(s.patterns=new Set),s.patterns.add(e.pattern))}),e.pattern?(t=n._zod).check??(t.check=i=>{e.pattern.lastIndex=0,!e.pattern.test(i.value)&&i.issues.push({origin:"string",code:"invalid_format",format:e.format,input:i.value,...e.pattern?{pattern:e.pattern.toString()}:{},inst:n,continue:!e.abort})}):(r=n._zod).check??(r.check=()=>{})}),W$=$("$ZodCheckRegex",(n,e)=>{za.init(n,e),n._zod.check=t=>{e.pattern.lastIndex=0,!e.pattern.test(t.value)&&t.issues.push({origin:"string",code:"invalid_format",format:"regex",input:t.value,pattern:e.pattern.toString(),inst:n,continue:!e.abort})}}),q$=$("$ZodCheckLowerCase",(n,e)=>{e.pattern??(e.pattern=F$),za.init(n,e)}),Y$=$("$ZodCheckUpperCase",(n,e)=>{e.pattern??(e.pattern=Z$),za.init(n,e)}),K$=$("$ZodCheckIncludes",(n,e)=>{Be.init(n,e);const t=ei(e.includes),r=new RegExp(typeof e.position=="number"?`^.{${e.position}}${t}`:t);e.pattern=r,n._zod.onattach.push(i=>{const s=i._zod.bag;s.patterns??(s.patterns=new Set),s.patterns.add(r)}),n._zod.check=i=>{i.value.includes(e.includes,e.position)||i.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:e.includes,input:i.value,inst:n,continue:!e.abort})}}),J$=$("$ZodCheckStartsWith",(n,e)=>{Be.init(n,e);const t=new RegExp(`^${ei(e.prefix)}.*`);e.pattern??(e.pattern=t),n._zod.onattach.push(r=>{const i=r._zod.bag;i.patterns??(i.patterns=new Set),i.patterns.add(t)}),n._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:n,continue:!e.abort})}}),X$=$("$ZodCheckEndsWith",(n,e)=>{Be.init(n,e);const t=new RegExp(`.*${ei(e.suffix)}$`);e.pattern??(e.pattern=t),n._zod.onattach.push(r=>{const i=r._zod.bag;i.patterns??(i.patterns=new Set),i.patterns.add(t)}),n._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:n,continue:!e.abort})}}),Q$=$("$ZodCheckOverwrite",(n,e)=>{Be.init(n,e),n._zod.check=t=>{t.value=e.tx(t.value)}});class eA{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),i=Math.min(...r.map(o=>o.length-o.trimStart().length)),s=r.map(o=>o.slice(i)).map(o=>" ".repeat(this.indent*2)+o);for(const o of s)this.content.push(o)}compile(){const e=Function,t=this==null?void 0:this.args,i=[...((this==null?void 0:this.content)??[""]).map(s=>` ${s}`)];return new e(...t,i.join(`
6
- `))}}const sA={major:4,minor:3,patch:6},he=$("$ZodType",(n,e)=>{var i;var t;n??(n={}),n._zod.def=e,n._zod.bag=n._zod.bag||{},n._zod.version=sA;const r=[...n._zod.def.checks??[]];n._zod.traits.has("$ZodCheck")&&r.unshift(n);for(const s of r)for(const o of s._zod.onattach)o(n);if(r.length===0)(t=n._zod).deferred??(t.deferred=[]),(i=n._zod.deferred)==null||i.push(()=>{n._zod.run=n._zod.parse});else{const s=(a,l,u)=>{let d=Cr(a),f;for(const v of l){if(v._zod.def.when){if(!v._zod.def.when(a))continue}else if(d)continue;const y=a.issues.length,A=v._zod.check(a);if(A instanceof Promise&&(u==null?void 0:u.async)===!1)throw new Rr;if(f||A instanceof Promise)f=(f??Promise.resolve()).then(async()=>{await A,a.issues.length!==y&&(d||(d=Cr(a,y)))});else{if(a.issues.length===y)continue;d||(d=Cr(a,y))}}return f?f.then(()=>a):a},o=(a,l,u)=>{if(Cr(a))return a.aborted=!0,a;const d=s(l,r,u);if(d instanceof Promise){if(u.async===!1)throw new Rr;return d.then(f=>n._zod.parse(f,u))}return n._zod.parse(d,u)};n._zod.run=(a,l)=>{if(l.skipChecks)return n._zod.parse(a,l);if(l.direction==="backward"){const d=n._zod.parse({value:a.value,issues:[]},{...l,skipChecks:!0});return d instanceof Promise?d.then(f=>o(f,a,l)):o(d,a,l)}const u=n._zod.parse(a,l);if(u instanceof Promise){if(l.async===!1)throw new Rr;return u.then(d=>s(d,r,l))}return s(u,r,l)}}X(n,"~standard",()=>({validate:s=>{var o;try{const a=h$(n,s);return a.success?{value:a.data}:{issues:(o=a.error)==null?void 0:o.issues}}catch{return d$(n,s).then(l=>{var u;return l.success?{value:l.data}:{issues:(u=l.error)==null?void 0:u.issues}})}},vendor:"zod",version:1}))}),Pu=$("$ZodString",(n,e)=>{var t;he.init(n,e),n._zod.pattern=[...((t=n==null?void 0:n._zod.bag)==null?void 0:t.patterns)??[]].pop()??Z$(n._zod.bag),n._zod.parse=(r,i)=>{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:n}),r}}),ae=$("$ZodStringFormat",(n,e)=>{za.init(n,e),Pu.init(n,e)}),oA=$("$ZodGUID",(n,e)=>{e.pattern??(e.pattern=T$),ae.init(n,e)}),aA=$("$ZodUUID",(n,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=tf(r))}else e.pattern??(e.pattern=tf());ae.init(n,e)}),lA=$("$ZodEmail",(n,e)=>{e.pattern??(e.pattern=C$),ae.init(n,e)}),cA=$("$ZodURL",(n,e)=>{ae.init(n,e),n._zod.check=t=>{try{const r=t.value.trim(),i=new URL(r);e.hostname&&(e.hostname.lastIndex=0,e.hostname.test(i.hostname)||t.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:e.hostname.source,input:t.value,inst:n,continue:!e.abort})),e.protocol&&(e.protocol.lastIndex=0,e.protocol.test(i.protocol.endsWith(":")?i.protocol.slice(0,-1):i.protocol)||t.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:e.protocol.source,input:t.value,inst:n,continue:!e.abort})),e.normalize?t.value=i.href:t.value=r;return}catch{t.issues.push({code:"invalid_format",format:"url",input:t.value,inst:n,continue:!e.abort})}}}),uA=$("$ZodEmoji",(n,e)=>{e.pattern??(e.pattern=P$()),ae.init(n,e)}),hA=$("$ZodNanoID",(n,e)=>{e.pattern??(e.pattern=A$),ae.init(n,e)}),dA=$("$ZodCUID",(n,e)=>{e.pattern??(e.pattern=_$),ae.init(n,e)}),fA=$("$ZodCUID2",(n,e)=>{e.pattern??(e.pattern=S$),ae.init(n,e)}),pA=$("$ZodULID",(n,e)=>{e.pattern??(e.pattern=k$),ae.init(n,e)}),gA=$("$ZodXID",(n,e)=>{e.pattern??(e.pattern=E$),ae.init(n,e)}),mA=$("$ZodKSUID",(n,e)=>{e.pattern??(e.pattern=$$),ae.init(n,e)}),yA=$("$ZodISODateTime",(n,e)=>{e.pattern??(e.pattern=F$(e)),ae.init(n,e)}),vA=$("$ZodISODate",(n,e)=>{e.pattern??(e.pattern=N$),ae.init(n,e)}),bA=$("$ZodISOTime",(n,e)=>{e.pattern??(e.pattern=U$(e)),ae.init(n,e)}),wA=$("$ZodISODuration",(n,e)=>{e.pattern??(e.pattern=x$),ae.init(n,e)}),_A=$("$ZodIPv4",(n,e)=>{e.pattern??(e.pattern=R$),ae.init(n,e),n._zod.bag.format="ipv4"}),SA=$("$ZodIPv6",(n,e)=>{e.pattern??(e.pattern=D$),ae.init(n,e),n._zod.bag.format="ipv6",n._zod.check=t=>{try{new URL(`http://[${t.value}]`)}catch{t.issues.push({code:"invalid_format",format:"ipv6",input:t.value,inst:n,continue:!e.abort})}}}),kA=$("$ZodCIDRv4",(n,e)=>{e.pattern??(e.pattern=O$),ae.init(n,e)}),EA=$("$ZodCIDRv6",(n,e)=>{e.pattern??(e.pattern=z$),ae.init(n,e),n._zod.check=t=>{const r=t.value.split("/");try{if(r.length!==2)throw new Error;const[i,s]=r;if(!s)throw new Error;const o=Number(s);if(`${o}`!==s)throw new Error;if(o<0||o>128)throw new Error;new URL(`http://[${i}]`)}catch{t.issues.push({code:"invalid_format",format:"cidrv6",input:t.value,inst:n,continue:!e.abort})}}});function Kg(n){if(n==="")return!0;if(n.length%4!==0)return!1;try{return atob(n),!0}catch{return!1}}const $A=$("$ZodBase64",(n,e)=>{e.pattern??(e.pattern=L$),ae.init(n,e),n._zod.bag.contentEncoding="base64",n._zod.check=t=>{Kg(t.value)||t.issues.push({code:"invalid_format",format:"base64",input:t.value,inst:n,continue:!e.abort})}});function AA(n){if(!Vg.test(n))return!1;const e=n.replace(/[-_]/g,r=>r==="-"?"+":"/"),t=e.padEnd(Math.ceil(e.length/4)*4,"=");return Kg(t)}const xA=$("$ZodBase64URL",(n,e)=>{e.pattern??(e.pattern=Vg),ae.init(n,e),n._zod.bag.contentEncoding="base64url",n._zod.check=t=>{AA(t.value)||t.issues.push({code:"invalid_format",format:"base64url",input:t.value,inst:n,continue:!e.abort})}}),TA=$("$ZodE164",(n,e)=>{e.pattern??(e.pattern=M$),ae.init(n,e)});function CA(n,e=null){try{const t=n.split(".");if(t.length!==3)return!1;const[r]=t;if(!r)return!1;const i=JSON.parse(atob(r));return!("typ"in i&&(i==null?void 0:i.typ)!=="JWT"||!i.alg||e&&(!("alg"in i)||i.alg!==e))}catch{return!1}}const IA=$("$ZodJWT",(n,e)=>{ae.init(n,e),n._zod.check=t=>{CA(t.value,e.alg)||t.issues.push({code:"invalid_format",format:"jwt",input:t.value,inst:n,continue:!e.abort})}}),Jg=$("$ZodNumber",(n,e)=>{he.init(n,e),n._zod.pattern=n._zod.bag.pattern??Gg,n._zod.parse=(t,r)=>{if(e.coerce)try{t.value=Number(t.value)}catch{}const i=t.value;if(typeof i=="number"&&!Number.isNaN(i)&&Number.isFinite(i))return t;const s=typeof i=="number"?Number.isNaN(i)?"NaN":Number.isFinite(i)?void 0:"Infinity":void 0;return t.issues.push({expected:"number",code:"invalid_type",input:i,inst:n,...s?{received:s}:{}}),t}}),PA=$("$ZodNumberFormat",(n,e)=>{W$.init(n,e),Jg.init(n,e)}),RA=$("$ZodBoolean",(n,e)=>{he.init(n,e),n._zod.pattern=V$,n._zod.parse=(t,r)=>{if(e.coerce)try{t.value=!!t.value}catch{}const i=t.value;return typeof i=="boolean"||t.issues.push({expected:"boolean",code:"invalid_type",input:i,inst:n}),t}}),DA=$("$ZodUnknown",(n,e)=>{he.init(n,e),n._zod.parse=t=>t}),OA=$("$ZodNever",(n,e)=>{he.init(n,e),n._zod.parse=(t,r)=>(t.issues.push({expected:"never",code:"invalid_type",input:t.value,inst:n}),t)});function nf(n,e,t){n.issues.length&&e.issues.push(...Ir(t,n.issues)),e.value[t]=n.value}const zA=$("$ZodArray",(n,e)=>{he.init(n,e),n._zod.parse=(t,r)=>{const i=t.value;if(!Array.isArray(i))return t.issues.push({expected:"array",code:"invalid_type",input:i,inst:n}),t;t.value=Array(i.length);const s=[];for(let o=0;o<i.length;o++){const a=i[o],l=e.element._zod.run({value:a,issues:[]},r);l instanceof Promise?s.push(l.then(u=>nf(u,t,o))):nf(l,t,o)}return s.length?Promise.all(s).then(()=>t):t}});function Jo(n,e,t,r,i){if(n.issues.length){if(i&&!(t in r))return;e.issues.push(...Ir(t,n.issues))}n.value===void 0?t in r&&(e.value[t]=void 0):e.value[t]=n.value}function Xg(n){var r,i,s,o;const e=Object.keys(n.shape);for(const a of e)if(!((o=(s=(i=(r=n.shape)==null?void 0:r[a])==null?void 0:i._zod)==null?void 0:s.traits)!=null&&o.has("$ZodType")))throw new Error(`Invalid element at key "${a}": expected a Zod schema`);const t=e$(n.shape);return{...n,keys:e,keySet:new Set(e),numKeys:e.length,optionalKeys:new Set(t)}}function Qg(n,e,t,r,i,s){const o=[],a=i.keySet,l=i.catchall._zod,u=l.def.type,d=l.optout==="optional";for(const f in e){if(a.has(f))continue;if(u==="never"){o.push(f);continue}const v=l.run({value:e[f],issues:[]},r);v instanceof Promise?n.push(v.then(y=>Jo(y,t,f,e,d))):Jo(v,t,f,e,d)}return o.length&&t.issues.push({code:"unrecognized_keys",keys:o,input:e,inst:s}),n.length?Promise.all(n).then(()=>t):t}const LA=$("$ZodObject",(n,e)=>{he.init(n,e);const t=Object.getOwnPropertyDescriptor(e,"shape");if(!(t!=null&&t.get)){const a=e.shape;Object.defineProperty(e,"shape",{get:()=>{const l={...a};return Object.defineProperty(e,"shape",{value:l}),l}})}const r=$u(()=>Xg(e));X(n._zod,"propValues",()=>{const a=e.shape,l={};for(const u in a){const d=a[u]._zod;if(d.values){l[u]??(l[u]=new Set);for(const f of d.values)l[u].add(f)}}return l});const i=Ko,s=e.catchall;let o;n._zod.parse=(a,l)=>{o??(o=r.value);const u=a.value;if(!i(u))return a.issues.push({expected:"object",code:"invalid_type",input:u,inst:n}),a;a.value={};const d=[],f=o.shape;for(const v of o.keys){const y=f[v],A=y._zod.optout==="optional",k=y._zod.run({value:u[v],issues:[]},l);k instanceof Promise?d.push(k.then(I=>Jo(I,a,v,u,A))):Jo(k,a,v,u,A)}return s?Qg(d,u,a,l,r.value,n):d.length?Promise.all(d).then(()=>a):a}}),MA=$("$ZodObjectJIT",(n,e)=>{LA.init(n,e);const t=n._zod.parse,r=$u(()=>Xg(e)),i=v=>{var le;const y=new iA(["shape","payload","ctx"]),A=r.value,k=M=>{const Z=ef(M);return`shape[${Z}]._zod.run({ value: input[${Z}], issues: [] }, ctx)`};y.write("const input = payload.value;");const I=Object.create(null);let B=0;for(const M of A.keys)I[M]=`key_${B++}`;y.write("const newResult = {};");for(const M of A.keys){const Z=I[M],U=ef(M),ge=v[M],ce=((le=ge==null?void 0:ge._zod)==null?void 0:le.optout)==="optional";y.write(`const ${Z} = ${k(M)};`),ce?y.write(`
6
+ `))}}const tA={major:4,minor:3,patch:6},he=$("$ZodType",(n,e)=>{var i;var t;n??(n={}),n._zod.def=e,n._zod.bag=n._zod.bag||{},n._zod.version=tA;const r=[...n._zod.def.checks??[]];n._zod.traits.has("$ZodCheck")&&r.unshift(n);for(const s of r)for(const o of s._zod.onattach)o(n);if(r.length===0)(t=n._zod).deferred??(t.deferred=[]),(i=n._zod.deferred)==null||i.push(()=>{n._zod.run=n._zod.parse});else{const s=(a,l,u)=>{let d=Cr(a),f;for(const v of l){if(v._zod.def.when){if(!v._zod.def.when(a))continue}else if(d)continue;const y=a.issues.length,A=v._zod.check(a);if(A instanceof Promise&&(u==null?void 0:u.async)===!1)throw new Rr;if(f||A instanceof Promise)f=(f??Promise.resolve()).then(async()=>{await A,a.issues.length!==y&&(d||(d=Cr(a,y)))});else{if(a.issues.length===y)continue;d||(d=Cr(a,y))}}return f?f.then(()=>a):a},o=(a,l,u)=>{if(Cr(a))return a.aborted=!0,a;const d=s(l,r,u);if(d instanceof Promise){if(u.async===!1)throw new Rr;return d.then(f=>n._zod.parse(f,u))}return n._zod.parse(d,u)};n._zod.run=(a,l)=>{if(l.skipChecks)return n._zod.parse(a,l);if(l.direction==="backward"){const d=n._zod.parse({value:a.value,issues:[]},{...l,skipChecks:!0});return d instanceof Promise?d.then(f=>o(f,a,l)):o(d,a,l)}const u=n._zod.parse(a,l);if(u instanceof Promise){if(l.async===!1)throw new Rr;return u.then(d=>s(d,r,l))}return s(u,r,l)}}X(n,"~standard",()=>({validate:s=>{var o;try{const a=a$(n,s);return a.success?{value:a.data}:{issues:(o=a.error)==null?void 0:o.issues}}catch{return l$(n,s).then(l=>{var u;return l.success?{value:l.data}:{issues:(u=l.error)==null?void 0:u.issues}})}},vendor:"zod",version:1}))}),Du=$("$ZodString",(n,e)=>{var t;he.init(n,e),n._zod.pattern=[...((t=n==null?void 0:n._zod.bag)==null?void 0:t.patterns)??[]].pop()??M$(n._zod.bag),n._zod.parse=(r,i)=>{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:n}),r}}),ae=$("$ZodStringFormat",(n,e)=>{za.init(n,e),Du.init(n,e)}),nA=$("$ZodGUID",(n,e)=>{e.pattern??(e.pattern=E$),ae.init(n,e)}),rA=$("$ZodUUID",(n,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=tf(r))}else e.pattern??(e.pattern=tf());ae.init(n,e)}),iA=$("$ZodEmail",(n,e)=>{e.pattern??(e.pattern=$$),ae.init(n,e)}),sA=$("$ZodURL",(n,e)=>{ae.init(n,e),n._zod.check=t=>{try{const r=t.value.trim(),i=new URL(r);e.hostname&&(e.hostname.lastIndex=0,e.hostname.test(i.hostname)||t.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:e.hostname.source,input:t.value,inst:n,continue:!e.abort})),e.protocol&&(e.protocol.lastIndex=0,e.protocol.test(i.protocol.endsWith(":")?i.protocol.slice(0,-1):i.protocol)||t.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:e.protocol.source,input:t.value,inst:n,continue:!e.abort})),e.normalize?t.value=i.href:t.value=r;return}catch{t.issues.push({code:"invalid_format",format:"url",input:t.value,inst:n,continue:!e.abort})}}}),oA=$("$ZodEmoji",(n,e)=>{e.pattern??(e.pattern=x$()),ae.init(n,e)}),aA=$("$ZodNanoID",(n,e)=>{e.pattern??(e.pattern=S$),ae.init(n,e)}),lA=$("$ZodCUID",(n,e)=>{e.pattern??(e.pattern=y$),ae.init(n,e)}),cA=$("$ZodCUID2",(n,e)=>{e.pattern??(e.pattern=v$),ae.init(n,e)}),uA=$("$ZodULID",(n,e)=>{e.pattern??(e.pattern=b$),ae.init(n,e)}),hA=$("$ZodXID",(n,e)=>{e.pattern??(e.pattern=w$),ae.init(n,e)}),dA=$("$ZodKSUID",(n,e)=>{e.pattern??(e.pattern=_$),ae.init(n,e)}),fA=$("$ZodISODateTime",(n,e)=>{e.pattern??(e.pattern=L$(e)),ae.init(n,e)}),pA=$("$ZodISODate",(n,e)=>{e.pattern??(e.pattern=O$),ae.init(n,e)}),gA=$("$ZodISOTime",(n,e)=>{e.pattern??(e.pattern=z$(e)),ae.init(n,e)}),mA=$("$ZodISODuration",(n,e)=>{e.pattern??(e.pattern=k$),ae.init(n,e)}),yA=$("$ZodIPv4",(n,e)=>{e.pattern??(e.pattern=T$),ae.init(n,e),n._zod.bag.format="ipv4"}),vA=$("$ZodIPv6",(n,e)=>{e.pattern??(e.pattern=C$),ae.init(n,e),n._zod.bag.format="ipv6",n._zod.check=t=>{try{new URL(`http://[${t.value}]`)}catch{t.issues.push({code:"invalid_format",format:"ipv6",input:t.value,inst:n,continue:!e.abort})}}}),bA=$("$ZodCIDRv4",(n,e)=>{e.pattern??(e.pattern=I$),ae.init(n,e)}),wA=$("$ZodCIDRv6",(n,e)=>{e.pattern??(e.pattern=P$),ae.init(n,e),n._zod.check=t=>{const r=t.value.split("/");try{if(r.length!==2)throw new Error;const[i,s]=r;if(!s)throw new Error;const o=Number(s);if(`${o}`!==s)throw new Error;if(o<0||o>128)throw new Error;new URL(`http://[${i}]`)}catch{t.issues.push({code:"invalid_format",format:"cidrv6",input:t.value,inst:n,continue:!e.abort})}}});function qg(n){if(n==="")return!0;if(n.length%4!==0)return!1;try{return atob(n),!0}catch{return!1}}const _A=$("$ZodBase64",(n,e)=>{e.pattern??(e.pattern=R$),ae.init(n,e),n._zod.bag.contentEncoding="base64",n._zod.check=t=>{qg(t.value)||t.issues.push({code:"invalid_format",format:"base64",input:t.value,inst:n,continue:!e.abort})}});function SA(n){if(!Zg.test(n))return!1;const e=n.replace(/[-_]/g,r=>r==="-"?"+":"/"),t=e.padEnd(Math.ceil(e.length/4)*4,"=");return qg(t)}const kA=$("$ZodBase64URL",(n,e)=>{e.pattern??(e.pattern=Zg),ae.init(n,e),n._zod.bag.contentEncoding="base64url",n._zod.check=t=>{SA(t.value)||t.issues.push({code:"invalid_format",format:"base64url",input:t.value,inst:n,continue:!e.abort})}}),EA=$("$ZodE164",(n,e)=>{e.pattern??(e.pattern=D$),ae.init(n,e)});function $A(n,e=null){try{const t=n.split(".");if(t.length!==3)return!1;const[r]=t;if(!r)return!1;const i=JSON.parse(atob(r));return!("typ"in i&&(i==null?void 0:i.typ)!=="JWT"||!i.alg||e&&(!("alg"in i)||i.alg!==e))}catch{return!1}}const AA=$("$ZodJWT",(n,e)=>{ae.init(n,e),n._zod.check=t=>{$A(t.value,e.alg)||t.issues.push({code:"invalid_format",format:"jwt",input:t.value,inst:n,continue:!e.abort})}}),Yg=$("$ZodNumber",(n,e)=>{he.init(n,e),n._zod.pattern=n._zod.bag.pattern??jg,n._zod.parse=(t,r)=>{if(e.coerce)try{t.value=Number(t.value)}catch{}const i=t.value;if(typeof i=="number"&&!Number.isNaN(i)&&Number.isFinite(i))return t;const s=typeof i=="number"?Number.isNaN(i)?"NaN":Number.isFinite(i)?void 0:"Infinity":void 0;return t.issues.push({expected:"number",code:"invalid_type",input:i,inst:n,...s?{received:s}:{}}),t}}),xA=$("$ZodNumberFormat",(n,e)=>{V$.init(n,e),Yg.init(n,e)}),TA=$("$ZodBoolean",(n,e)=>{he.init(n,e),n._zod.pattern=U$,n._zod.parse=(t,r)=>{if(e.coerce)try{t.value=!!t.value}catch{}const i=t.value;return typeof i=="boolean"||t.issues.push({expected:"boolean",code:"invalid_type",input:i,inst:n}),t}}),CA=$("$ZodUnknown",(n,e)=>{he.init(n,e),n._zod.parse=t=>t}),IA=$("$ZodNever",(n,e)=>{he.init(n,e),n._zod.parse=(t,r)=>(t.issues.push({expected:"never",code:"invalid_type",input:t.value,inst:n}),t)});function nf(n,e,t){n.issues.length&&e.issues.push(...Ir(t,n.issues)),e.value[t]=n.value}const PA=$("$ZodArray",(n,e)=>{he.init(n,e),n._zod.parse=(t,r)=>{const i=t.value;if(!Array.isArray(i))return t.issues.push({expected:"array",code:"invalid_type",input:i,inst:n}),t;t.value=Array(i.length);const s=[];for(let o=0;o<i.length;o++){const a=i[o],l=e.element._zod.run({value:a,issues:[]},r);l instanceof Promise?s.push(l.then(u=>nf(u,t,o))):nf(l,t,o)}return s.length?Promise.all(s).then(()=>t):t}});function Jo(n,e,t,r,i){if(n.issues.length){if(i&&!(t in r))return;e.issues.push(...Ir(t,n.issues))}n.value===void 0?t in r&&(e.value[t]=void 0):e.value[t]=n.value}function Kg(n){var r,i,s,o;const e=Object.keys(n.shape);for(const a of e)if(!((o=(s=(i=(r=n.shape)==null?void 0:r[a])==null?void 0:i._zod)==null?void 0:s.traits)!=null&&o.has("$ZodType")))throw new Error(`Invalid element at key "${a}": expected a Zod schema`);const t=K0(n.shape);return{...n,keys:e,keySet:new Set(e),numKeys:e.length,optionalKeys:new Set(t)}}function Jg(n,e,t,r,i,s){const o=[],a=i.keySet,l=i.catchall._zod,u=l.def.type,d=l.optout==="optional";for(const f in e){if(a.has(f))continue;if(u==="never"){o.push(f);continue}const v=l.run({value:e[f],issues:[]},r);v instanceof Promise?n.push(v.then(y=>Jo(y,t,f,e,d))):Jo(v,t,f,e,d)}return o.length&&t.issues.push({code:"unrecognized_keys",keys:o,input:e,inst:s}),n.length?Promise.all(n).then(()=>t):t}const RA=$("$ZodObject",(n,e)=>{he.init(n,e);const t=Object.getOwnPropertyDescriptor(e,"shape");if(!(t!=null&&t.get)){const a=e.shape;Object.defineProperty(e,"shape",{get:()=>{const l={...a};return Object.defineProperty(e,"shape",{value:l}),l}})}const r=xu(()=>Kg(e));X(n._zod,"propValues",()=>{const a=e.shape,l={};for(const u in a){const d=a[u]._zod;if(d.values){l[u]??(l[u]=new Set);for(const f of d.values)l[u].add(f)}}return l});const i=Ko,s=e.catchall;let o;n._zod.parse=(a,l)=>{o??(o=r.value);const u=a.value;if(!i(u))return a.issues.push({expected:"object",code:"invalid_type",input:u,inst:n}),a;a.value={};const d=[],f=o.shape;for(const v of o.keys){const y=f[v],A=y._zod.optout==="optional",k=y._zod.run({value:u[v],issues:[]},l);k instanceof Promise?d.push(k.then(I=>Jo(I,a,v,u,A))):Jo(k,a,v,u,A)}return s?Jg(d,u,a,l,r.value,n):d.length?Promise.all(d).then(()=>a):a}}),DA=$("$ZodObjectJIT",(n,e)=>{RA.init(n,e);const t=n._zod.parse,r=xu(()=>Kg(e)),i=v=>{var le;const y=new eA(["shape","payload","ctx"]),A=r.value,k=M=>{const Z=ef(M);return`shape[${Z}]._zod.run({ value: input[${Z}], issues: [] }, ctx)`};y.write("const input = payload.value;");const I=Object.create(null);let G=0;for(const M of A.keys)I[M]=`key_${G++}`;y.write("const newResult = {};");for(const M of A.keys){const Z=I[M],U=ef(M),ge=v[M],ce=((le=ge==null?void 0:ge._zod)==null?void 0:le.optout)==="optional";y.write(`const ${Z} = ${k(M)};`),ce?y.write(`
7
7
  if (${Z}.issues.length) {
8
8
  if (${U} in input) {
9
9
  payload.issues = payload.issues.concat(${Z}.issues.map(iss => ({
@@ -37,35 +37,35 @@ var Ov=Object.defineProperty;var Sh=n=>{throw TypeError(n)};var zv=(n,e,t)=>e in
37
37
  newResult[${U}] = ${Z}.value;
38
38
  }
39
39
 
40
- `)}y.write("payload.value = newResult;"),y.write("return payload;");const P=y.compile();return(M,Z)=>P(v,M,Z)};let s;const o=Ko,a=!Lg.jitless,u=a&&X0.value,d=e.catchall;let f;n._zod.parse=(v,y)=>{f??(f=r.value);const A=v.value;return o(A)?a&&u&&(y==null?void 0:y.async)===!1&&y.jitless!==!0?(s||(s=i(e.shape)),v=s(v,y),d?Qg([],A,v,y,f,n):v):t(v,y):(v.issues.push({expected:"object",code:"invalid_type",input:A,inst:n}),v)}});function rf(n,e,t,r){for(const s of n)if(s.issues.length===0)return e.value=s.value,e;const i=n.filter(s=>!Cr(s));return i.length===1?(e.value=i[0].value,i[0]):(e.issues.push({code:"invalid_union",input:e.value,inst:t,errors:n.map(s=>s.issues.map(o=>gn(o,r,pn())))}),e)}const NA=$("$ZodUnion",(n,e)=>{he.init(n,e),X(n._zod,"optin",()=>e.options.some(i=>i._zod.optin==="optional")?"optional":void 0),X(n._zod,"optout",()=>e.options.some(i=>i._zod.optout==="optional")?"optional":void 0),X(n._zod,"values",()=>{if(e.options.every(i=>i._zod.values))return new Set(e.options.flatMap(i=>Array.from(i._zod.values)))}),X(n._zod,"pattern",()=>{if(e.options.every(i=>i._zod.pattern)){const i=e.options.map(s=>s._zod.pattern);return new RegExp(`^(${i.map(s=>xu(s.source)).join("|")})$`)}});const t=e.options.length===1,r=e.options[0]._zod.run;n._zod.parse=(i,s)=>{if(t)return r(i,s);let o=!1;const a=[];for(const l of e.options){const u=l._zod.run({value:i.value,issues:[]},s);if(u instanceof Promise)a.push(u),o=!0;else{if(u.issues.length===0)return u;a.push(u)}}return o?Promise.all(a).then(l=>rf(l,i,n,s)):rf(a,i,n,s)}}),UA=$("$ZodIntersection",(n,e)=>{he.init(n,e),n._zod.parse=(t,r)=>{const i=t.value,s=e.left._zod.run({value:i,issues:[]},r),o=e.right._zod.run({value:i,issues:[]},r);return s instanceof Promise||o instanceof Promise?Promise.all([s,o]).then(([l,u])=>sf(t,l,u)):sf(t,s,o)}});function hc(n,e){if(n===e)return{valid:!0,data:n};if(n instanceof Date&&e instanceof Date&&+n==+e)return{valid:!0,data:n};if(Qr(n)&&Qr(e)){const t=Object.keys(e),r=Object.keys(n).filter(s=>t.indexOf(s)!==-1),i={...n,...e};for(const s of r){const o=hc(n[s],e[s]);if(!o.valid)return{valid:!1,mergeErrorPath:[s,...o.mergeErrorPath]};i[s]=o.data}return{valid:!0,data:i}}if(Array.isArray(n)&&Array.isArray(e)){if(n.length!==e.length)return{valid:!1,mergeErrorPath:[]};const t=[];for(let r=0;r<n.length;r++){const i=n[r],s=e[r],o=hc(i,s);if(!o.valid)return{valid:!1,mergeErrorPath:[r,...o.mergeErrorPath]};t.push(o.data)}return{valid:!0,data:t}}return{valid:!1,mergeErrorPath:[]}}function sf(n,e,t){const r=new Map;let i;for(const a of e.issues)if(a.code==="unrecognized_keys"){i??(i=a);for(const l of a.keys)r.has(l)||r.set(l,{}),r.get(l).l=!0}else n.issues.push(a);for(const a of t.issues)if(a.code==="unrecognized_keys")for(const l of a.keys)r.has(l)||r.set(l,{}),r.get(l).r=!0;else n.issues.push(a);const s=[...r].filter(([,a])=>a.l&&a.r).map(([a])=>a);if(s.length&&i&&n.issues.push({...i,keys:s}),Cr(n))return n;const o=hc(e.value,t.value);if(!o.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(o.mergeErrorPath)}`);return n.value=o.data,n}const FA=$("$ZodRecord",(n,e)=>{he.init(n,e),n._zod.parse=(t,r)=>{const i=t.value;if(!Qr(i))return t.issues.push({expected:"record",code:"invalid_type",input:i,inst:n}),t;const s=[],o=e.keyType._zod.values;if(o){t.value={};const a=new Set;for(const u of o)if(typeof u=="string"||typeof u=="number"||typeof u=="symbol"){a.add(typeof u=="number"?u.toString():u);const d=e.valueType._zod.run({value:i[u],issues:[]},r);d instanceof Promise?s.push(d.then(f=>{f.issues.length&&t.issues.push(...Ir(u,f.issues)),t.value[u]=f.value})):(d.issues.length&&t.issues.push(...Ir(u,d.issues)),t.value[u]=d.value)}let l;for(const u in i)a.has(u)||(l=l??[],l.push(u));l&&l.length>0&&t.issues.push({code:"unrecognized_keys",input:i,inst:n,keys:l})}else{t.value={};for(const a of Reflect.ownKeys(i)){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"&&Gg.test(a)&&l.issues.length){const f=e.keyType._zod.run({value:Number(a),issues:[]},r);if(f instanceof Promise)throw new Error("Async schemas not supported in object keys currently");f.issues.length===0&&(l=f)}if(l.issues.length){e.mode==="loose"?t.value[a]=i[a]:t.issues.push({code:"invalid_key",origin:"record",issues:l.issues.map(f=>gn(f,r,pn())),input:a,path:[a],inst:n});continue}const d=e.valueType._zod.run({value:i[a],issues:[]},r);d instanceof Promise?s.push(d.then(f=>{f.issues.length&&t.issues.push(...Ir(a,f.issues)),t.value[l.value]=f.value})):(d.issues.length&&t.issues.push(...Ir(a,d.issues)),t.value[l.value]=d.value)}}return s.length?Promise.all(s).then(()=>t):t}}),ZA=$("$ZodEnum",(n,e)=>{he.init(n,e);const t=Mg(e.entries),r=new Set(t);n._zod.values=r,n._zod.pattern=new RegExp(`^(${t.filter(i=>Q0.has(typeof i)).map(i=>typeof i=="string"?ei(i):i.toString()).join("|")})$`),n._zod.parse=(i,s)=>{const o=i.value;return r.has(o)||i.issues.push({code:"invalid_value",values:t,input:o,inst:n}),i}}),HA=$("$ZodLiteral",(n,e)=>{if(he.init(n,e),e.values.length===0)throw new Error("Cannot create literal schema with no valid values");const t=new Set(e.values);n._zod.values=t,n._zod.pattern=new RegExp(`^(${e.values.map(r=>typeof r=="string"?ei(r):r?ei(r.toString()):String(r)).join("|")})$`),n._zod.parse=(r,i)=>{const s=r.value;return t.has(s)||r.issues.push({code:"invalid_value",values:e.values,input:s,inst:n}),r}}),VA=$("$ZodTransform",(n,e)=>{he.init(n,e),n._zod.parse=(t,r)=>{if(r.direction==="backward")throw new zg(n.constructor.name);const i=e.transform(t.value,t);if(r.async)return(i instanceof Promise?i:Promise.resolve(i)).then(o=>(t.value=o,t));if(i instanceof Promise)throw new Rr;return t.value=i,t}});function of(n,e){return n.issues.length&&e===void 0?{issues:[],value:void 0}:n}const em=$("$ZodOptional",(n,e)=>{he.init(n,e),n._zod.optin="optional",n._zod.optout="optional",X(n._zod,"values",()=>e.innerType._zod.values?new Set([...e.innerType._zod.values,void 0]):void 0),X(n._zod,"pattern",()=>{const t=e.innerType._zod.pattern;return t?new RegExp(`^(${xu(t.source)})?$`):void 0}),n._zod.parse=(t,r)=>{if(e.innerType._zod.optin==="optional"){const i=e.innerType._zod.run(t,r);return i instanceof Promise?i.then(s=>of(s,t.value)):of(i,t.value)}return t.value===void 0?t:e.innerType._zod.run(t,r)}}),jA=$("$ZodExactOptional",(n,e)=>{em.init(n,e),X(n._zod,"values",()=>e.innerType._zod.values),X(n._zod,"pattern",()=>e.innerType._zod.pattern),n._zod.parse=(t,r)=>e.innerType._zod.run(t,r)}),BA=$("$ZodNullable",(n,e)=>{he.init(n,e),X(n._zod,"optin",()=>e.innerType._zod.optin),X(n._zod,"optout",()=>e.innerType._zod.optout),X(n._zod,"pattern",()=>{const t=e.innerType._zod.pattern;return t?new RegExp(`^(${xu(t.source)}|null)$`):void 0}),X(n._zod,"values",()=>e.innerType._zod.values?new Set([...e.innerType._zod.values,null]):void 0),n._zod.parse=(t,r)=>t.value===null?t:e.innerType._zod.run(t,r)}),GA=$("$ZodDefault",(n,e)=>{he.init(n,e),n._zod.optin="optional",X(n._zod,"values",()=>e.innerType._zod.values),n._zod.parse=(t,r)=>{if(r.direction==="backward")return e.innerType._zod.run(t,r);if(t.value===void 0)return t.value=e.defaultValue,t;const i=e.innerType._zod.run(t,r);return i instanceof Promise?i.then(s=>af(s,e)):af(i,e)}});function af(n,e){return n.value===void 0&&(n.value=e.defaultValue),n}const WA=$("$ZodPrefault",(n,e)=>{he.init(n,e),n._zod.optin="optional",X(n._zod,"values",()=>e.innerType._zod.values),n._zod.parse=(t,r)=>(r.direction==="backward"||t.value===void 0&&(t.value=e.defaultValue),e.innerType._zod.run(t,r))}),qA=$("$ZodNonOptional",(n,e)=>{he.init(n,e),X(n._zod,"values",()=>{const t=e.innerType._zod.values;return t?new Set([...t].filter(r=>r!==void 0)):void 0}),n._zod.parse=(t,r)=>{const i=e.innerType._zod.run(t,r);return i instanceof Promise?i.then(s=>lf(s,n)):lf(i,n)}});function lf(n,e){return!n.issues.length&&n.value===void 0&&n.issues.push({code:"invalid_type",expected:"nonoptional",input:n.value,inst:e}),n}const YA=$("$ZodCatch",(n,e)=>{he.init(n,e),X(n._zod,"optin",()=>e.innerType._zod.optin),X(n._zod,"optout",()=>e.innerType._zod.optout),X(n._zod,"values",()=>e.innerType._zod.values),n._zod.parse=(t,r)=>{if(r.direction==="backward")return e.innerType._zod.run(t,r);const i=e.innerType._zod.run(t,r);return i instanceof Promise?i.then(s=>(t.value=s.value,s.issues.length&&(t.value=e.catchValue({...t,error:{issues:s.issues.map(o=>gn(o,r,pn()))},input:t.value}),t.issues=[]),t)):(t.value=i.value,i.issues.length&&(t.value=e.catchValue({...t,error:{issues:i.issues.map(s=>gn(s,r,pn()))},input:t.value}),t.issues=[]),t)}}),KA=$("$ZodPipe",(n,e)=>{he.init(n,e),X(n._zod,"values",()=>e.in._zod.values),X(n._zod,"optin",()=>e.in._zod.optin),X(n._zod,"optout",()=>e.out._zod.optout),X(n._zod,"propValues",()=>e.in._zod.propValues),n._zod.parse=(t,r)=>{if(r.direction==="backward"){const s=e.out._zod.run(t,r);return s instanceof Promise?s.then(o=>yo(o,e.in,r)):yo(s,e.in,r)}const i=e.in._zod.run(t,r);return i instanceof Promise?i.then(s=>yo(s,e.out,r)):yo(i,e.out,r)}});function yo(n,e,t){return n.issues.length?(n.aborted=!0,n):e._zod.run({value:n.value,issues:n.issues},t)}const JA=$("$ZodReadonly",(n,e)=>{he.init(n,e),X(n._zod,"propValues",()=>e.innerType._zod.propValues),X(n._zod,"values",()=>e.innerType._zod.values),X(n._zod,"optin",()=>{var t,r;return(r=(t=e.innerType)==null?void 0:t._zod)==null?void 0:r.optin}),X(n._zod,"optout",()=>{var t,r;return(r=(t=e.innerType)==null?void 0:t._zod)==null?void 0:r.optout}),n._zod.parse=(t,r)=>{if(r.direction==="backward")return e.innerType._zod.run(t,r);const i=e.innerType._zod.run(t,r);return i instanceof Promise?i.then(cf):cf(i)}});function cf(n){return n.value=Object.freeze(n.value),n}const XA=$("$ZodCustom",(n,e)=>{Ge.init(n,e),he.init(n,e),n._zod.parse=(t,r)=>t,n._zod.check=t=>{const r=t.value,i=e.fn(r);if(i instanceof Promise)return i.then(s=>uf(s,t,r,n));uf(i,t,r,n)}});function uf(n,e,t,r){if(!n){const i={code:"custom",input:t,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(i.params=r._zod.def.params),e.issues.push(Ji(i))}}var hf;class QA{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...t){const r=t[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 t=this._map.get(e);return t&&typeof t=="object"&&"id"in t&&this._idmap.delete(t.id),this._map.delete(e),this}get(e){const t=e._zod.parent;if(t){const r={...this.get(t)??{}};delete r.id;const i={...r,...this._map.get(e)};return Object.keys(i).length?i:void 0}return this._map.get(e)}has(e){return this._map.has(e)}}function ex(){return new QA}(hf=globalThis).__zod_globalRegistry??(hf.__zod_globalRegistry=ex());const zi=globalThis.__zod_globalRegistry;function tx(n,e){return new n({type:"string",...O(e)})}function nx(n,e){return new n({type:"string",format:"email",check:"string_format",abort:!1,...O(e)})}function df(n,e){return new n({type:"string",format:"guid",check:"string_format",abort:!1,...O(e)})}function rx(n,e){return new n({type:"string",format:"uuid",check:"string_format",abort:!1,...O(e)})}function ix(n,e){return new n({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...O(e)})}function sx(n,e){return new n({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...O(e)})}function ox(n,e){return new n({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...O(e)})}function ax(n,e){return new n({type:"string",format:"url",check:"string_format",abort:!1,...O(e)})}function lx(n,e){return new n({type:"string",format:"emoji",check:"string_format",abort:!1,...O(e)})}function cx(n,e){return new n({type:"string",format:"nanoid",check:"string_format",abort:!1,...O(e)})}function ux(n,e){return new n({type:"string",format:"cuid",check:"string_format",abort:!1,...O(e)})}function hx(n,e){return new n({type:"string",format:"cuid2",check:"string_format",abort:!1,...O(e)})}function dx(n,e){return new n({type:"string",format:"ulid",check:"string_format",abort:!1,...O(e)})}function fx(n,e){return new n({type:"string",format:"xid",check:"string_format",abort:!1,...O(e)})}function px(n,e){return new n({type:"string",format:"ksuid",check:"string_format",abort:!1,...O(e)})}function gx(n,e){return new n({type:"string",format:"ipv4",check:"string_format",abort:!1,...O(e)})}function mx(n,e){return new n({type:"string",format:"ipv6",check:"string_format",abort:!1,...O(e)})}function yx(n,e){return new n({type:"string",format:"cidrv4",check:"string_format",abort:!1,...O(e)})}function vx(n,e){return new n({type:"string",format:"cidrv6",check:"string_format",abort:!1,...O(e)})}function bx(n,e){return new n({type:"string",format:"base64",check:"string_format",abort:!1,...O(e)})}function wx(n,e){return new n({type:"string",format:"base64url",check:"string_format",abort:!1,...O(e)})}function _x(n,e){return new n({type:"string",format:"e164",check:"string_format",abort:!1,...O(e)})}function Sx(n,e){return new n({type:"string",format:"jwt",check:"string_format",abort:!1,...O(e)})}function kx(n,e){return new n({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...O(e)})}function Ex(n,e){return new n({type:"string",format:"date",check:"string_format",...O(e)})}function $x(n,e){return new n({type:"string",format:"time",check:"string_format",precision:null,...O(e)})}function Ax(n,e){return new n({type:"string",format:"duration",check:"string_format",...O(e)})}function xx(n,e){return new n({type:"number",checks:[],...O(e)})}function Tx(n,e){return new n({type:"number",check:"number_format",abort:!1,format:"safeint",...O(e)})}function Cx(n,e){return new n({type:"boolean",...O(e)})}function Ix(n){return new n({type:"unknown"})}function Px(n,e){return new n({type:"never",...O(e)})}function ff(n,e){return new qg({check:"less_than",...O(e),value:n,inclusive:!1})}function Pl(n,e){return new qg({check:"less_than",...O(e),value:n,inclusive:!0})}function pf(n,e){return new Yg({check:"greater_than",...O(e),value:n,inclusive:!1})}function Rl(n,e){return new Yg({check:"greater_than",...O(e),value:n,inclusive:!0})}function gf(n,e){return new G$({check:"multiple_of",...O(e),value:n})}function tm(n,e){return new q$({check:"max_length",...O(e),maximum:n})}function Xo(n,e){return new Y$({check:"min_length",...O(e),minimum:n})}function nm(n,e){return new K$({check:"length_equals",...O(e),length:n})}function Rx(n,e){return new J$({check:"string_format",format:"regex",...O(e),pattern:n})}function Dx(n){return new X$({check:"string_format",format:"lowercase",...O(n)})}function Ox(n){return new Q$({check:"string_format",format:"uppercase",...O(n)})}function zx(n,e){return new eA({check:"string_format",format:"includes",...O(e),includes:n})}function Lx(n,e){return new tA({check:"string_format",format:"starts_with",...O(e),prefix:n})}function Mx(n,e){return new nA({check:"string_format",format:"ends_with",...O(e),suffix:n})}function fi(n){return new rA({check:"overwrite",tx:n})}function Nx(n){return fi(e=>e.normalize(n))}function Ux(){return fi(n=>n.trim())}function Fx(){return fi(n=>n.toLowerCase())}function Zx(){return fi(n=>n.toUpperCase())}function Hx(){return fi(n=>J0(n))}function Vx(n,e,t){return new n({type:"array",element:e,...O(t)})}function jx(n,e,t){return new n({type:"custom",check:"custom",fn:e,...O(t)})}function Bx(n){const e=Gx(t=>(t.addIssue=r=>{if(typeof r=="string")t.issues.push(Ji(r,t.value,e._zod.def));else{const i=r;i.fatal&&(i.continue=!1),i.code??(i.code="custom"),i.input??(i.input=t.value),i.inst??(i.inst=e),i.continue??(i.continue=!e._zod.def.abort),t.issues.push(Ji(i))}},n(t.value,t)));return e}function Gx(n,e){const t=new Ge({check:"custom",...O(e)});return t._zod.check=n,t}function rm(n){let e=(n==null?void 0:n.target)??"draft-2020-12";return e==="draft-4"&&(e="draft-04"),e==="draft-7"&&(e="draft-07"),{processors:n.processors??{},metadataRegistry:(n==null?void 0:n.metadata)??zi,target:e,unrepresentable:(n==null?void 0:n.unrepresentable)??"throw",override:(n==null?void 0:n.override)??(()=>{}),io:(n==null?void 0:n.io)??"output",counter:0,seen:new Map,cycles:(n==null?void 0:n.cycles)??"ref",reused:(n==null?void 0:n.reused)??"inline",external:(n==null?void 0:n.external)??void 0}}function ve(n,e,t={path:[],schemaPath:[]}){var d,f;var r;const i=n._zod.def,s=e.seen.get(n);if(s)return s.count++,t.schemaPath.includes(n)&&(s.cycle=t.path),s.schema;const o={schema:{},count:1,cycle:void 0,path:t.path};e.seen.set(n,o);const a=(f=(d=n._zod).toJSONSchema)==null?void 0:f.call(d);if(a)o.schema=a;else{const v={...t,schemaPath:[...t.schemaPath,n],path:t.path};if(n._zod.processJSONSchema)n._zod.processJSONSchema(e,o.schema,v);else{const A=o.schema,k=e.processors[i.type];if(!k)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${i.type}`);k(n,e,A,v)}const y=n._zod.parent;y&&(o.ref||(o.ref=y),ve(y,e,v),e.seen.get(y).isParent=!0)}const l=e.metadataRegistry.get(n);return l&&Object.assign(o.schema,l),e.io==="input"&&Oe(n)&&(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(n).schema}function im(n,e){var o,a,l,u;const t=n.seen.get(e);if(!t)throw new Error("Unprocessed schema. This is a bug in Zod.");const r=new Map;for(const d of n.seen.entries()){const f=(o=n.metadataRegistry.get(d[0]))==null?void 0:o.id;if(f){const v=r.get(f);if(v&&v!==d[0])throw new Error(`Duplicate schema id "${f}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);r.set(f,d[0])}}const i=d=>{var k;const f=n.target==="draft-2020-12"?"$defs":"definitions";if(n.external){const I=(k=n.external.registry.get(d[0]))==null?void 0:k.id,B=n.external.uri??(le=>le);if(I)return{ref:B(I)};const P=d[1].defId??d[1].schema.id??`schema${n.counter++}`;return d[1].defId=P,{defId:P,ref:`${B("__shared")}#/${f}/${P}`}}if(d[1]===t)return{ref:"#"};const y=`#/${f}/`,A=d[1].schema.id??`__schema${n.counter++}`;return{defId:A,ref:y+A}},s=d=>{if(d[1].schema.$ref)return;const f=d[1],{ref:v,defId:y}=i(d);f.def={...f.schema},y&&(f.defId=y);const A=f.schema;for(const k in A)delete A[k];A.$ref=v};if(n.cycles==="throw")for(const d of n.seen.entries()){const f=d[1];if(f.cycle)throw new Error(`Cycle detected: #/${(a=f.cycle)==null?void 0:a.join("/")}/<root>
40
+ `)}y.write("payload.value = newResult;"),y.write("return payload;");const P=y.compile();return(M,Z)=>P(v,M,Z)};let s;const o=Ko,a=!Og.jitless,u=a&&q0.value,d=e.catchall;let f;n._zod.parse=(v,y)=>{f??(f=r.value);const A=v.value;return o(A)?a&&u&&(y==null?void 0:y.async)===!1&&y.jitless!==!0?(s||(s=i(e.shape)),v=s(v,y),d?Jg([],A,v,y,f,n):v):t(v,y):(v.issues.push({expected:"object",code:"invalid_type",input:A,inst:n}),v)}});function rf(n,e,t,r){for(const s of n)if(s.issues.length===0)return e.value=s.value,e;const i=n.filter(s=>!Cr(s));return i.length===1?(e.value=i[0].value,i[0]):(e.issues.push({code:"invalid_union",input:e.value,inst:t,errors:n.map(s=>s.issues.map(o=>gn(o,r,pn())))}),e)}const OA=$("$ZodUnion",(n,e)=>{he.init(n,e),X(n._zod,"optin",()=>e.options.some(i=>i._zod.optin==="optional")?"optional":void 0),X(n._zod,"optout",()=>e.options.some(i=>i._zod.optout==="optional")?"optional":void 0),X(n._zod,"values",()=>{if(e.options.every(i=>i._zod.values))return new Set(e.options.flatMap(i=>Array.from(i._zod.values)))}),X(n._zod,"pattern",()=>{if(e.options.every(i=>i._zod.pattern)){const i=e.options.map(s=>s._zod.pattern);return new RegExp(`^(${i.map(s=>Cu(s.source)).join("|")})$`)}});const t=e.options.length===1,r=e.options[0]._zod.run;n._zod.parse=(i,s)=>{if(t)return r(i,s);let o=!1;const a=[];for(const l of e.options){const u=l._zod.run({value:i.value,issues:[]},s);if(u instanceof Promise)a.push(u),o=!0;else{if(u.issues.length===0)return u;a.push(u)}}return o?Promise.all(a).then(l=>rf(l,i,n,s)):rf(a,i,n,s)}}),zA=$("$ZodIntersection",(n,e)=>{he.init(n,e),n._zod.parse=(t,r)=>{const i=t.value,s=e.left._zod.run({value:i,issues:[]},r),o=e.right._zod.run({value:i,issues:[]},r);return s instanceof Promise||o instanceof Promise?Promise.all([s,o]).then(([l,u])=>sf(t,l,u)):sf(t,s,o)}});function fc(n,e){if(n===e)return{valid:!0,data:n};if(n instanceof Date&&e instanceof Date&&+n==+e)return{valid:!0,data:n};if(Qr(n)&&Qr(e)){const t=Object.keys(e),r=Object.keys(n).filter(s=>t.indexOf(s)!==-1),i={...n,...e};for(const s of r){const o=fc(n[s],e[s]);if(!o.valid)return{valid:!1,mergeErrorPath:[s,...o.mergeErrorPath]};i[s]=o.data}return{valid:!0,data:i}}if(Array.isArray(n)&&Array.isArray(e)){if(n.length!==e.length)return{valid:!1,mergeErrorPath:[]};const t=[];for(let r=0;r<n.length;r++){const i=n[r],s=e[r],o=fc(i,s);if(!o.valid)return{valid:!1,mergeErrorPath:[r,...o.mergeErrorPath]};t.push(o.data)}return{valid:!0,data:t}}return{valid:!1,mergeErrorPath:[]}}function sf(n,e,t){const r=new Map;let i;for(const a of e.issues)if(a.code==="unrecognized_keys"){i??(i=a);for(const l of a.keys)r.has(l)||r.set(l,{}),r.get(l).l=!0}else n.issues.push(a);for(const a of t.issues)if(a.code==="unrecognized_keys")for(const l of a.keys)r.has(l)||r.set(l,{}),r.get(l).r=!0;else n.issues.push(a);const s=[...r].filter(([,a])=>a.l&&a.r).map(([a])=>a);if(s.length&&i&&n.issues.push({...i,keys:s}),Cr(n))return n;const o=fc(e.value,t.value);if(!o.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(o.mergeErrorPath)}`);return n.value=o.data,n}const LA=$("$ZodRecord",(n,e)=>{he.init(n,e),n._zod.parse=(t,r)=>{const i=t.value;if(!Qr(i))return t.issues.push({expected:"record",code:"invalid_type",input:i,inst:n}),t;const s=[],o=e.keyType._zod.values;if(o){t.value={};const a=new Set;for(const u of o)if(typeof u=="string"||typeof u=="number"||typeof u=="symbol"){a.add(typeof u=="number"?u.toString():u);const d=e.valueType._zod.run({value:i[u],issues:[]},r);d instanceof Promise?s.push(d.then(f=>{f.issues.length&&t.issues.push(...Ir(u,f.issues)),t.value[u]=f.value})):(d.issues.length&&t.issues.push(...Ir(u,d.issues)),t.value[u]=d.value)}let l;for(const u in i)a.has(u)||(l=l??[],l.push(u));l&&l.length>0&&t.issues.push({code:"unrecognized_keys",input:i,inst:n,keys:l})}else{t.value={};for(const a of Reflect.ownKeys(i)){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"&&jg.test(a)&&l.issues.length){const f=e.keyType._zod.run({value:Number(a),issues:[]},r);if(f instanceof Promise)throw new Error("Async schemas not supported in object keys currently");f.issues.length===0&&(l=f)}if(l.issues.length){e.mode==="loose"?t.value[a]=i[a]:t.issues.push({code:"invalid_key",origin:"record",issues:l.issues.map(f=>gn(f,r,pn())),input:a,path:[a],inst:n});continue}const d=e.valueType._zod.run({value:i[a],issues:[]},r);d instanceof Promise?s.push(d.then(f=>{f.issues.length&&t.issues.push(...Ir(a,f.issues)),t.value[l.value]=f.value})):(d.issues.length&&t.issues.push(...Ir(a,d.issues)),t.value[l.value]=d.value)}}return s.length?Promise.all(s).then(()=>t):t}}),MA=$("$ZodEnum",(n,e)=>{he.init(n,e);const t=zg(e.entries),r=new Set(t);n._zod.values=r,n._zod.pattern=new RegExp(`^(${t.filter(i=>Y0.has(typeof i)).map(i=>typeof i=="string"?ei(i):i.toString()).join("|")})$`),n._zod.parse=(i,s)=>{const o=i.value;return r.has(o)||i.issues.push({code:"invalid_value",values:t,input:o,inst:n}),i}}),NA=$("$ZodLiteral",(n,e)=>{if(he.init(n,e),e.values.length===0)throw new Error("Cannot create literal schema with no valid values");const t=new Set(e.values);n._zod.values=t,n._zod.pattern=new RegExp(`^(${e.values.map(r=>typeof r=="string"?ei(r):r?ei(r.toString()):String(r)).join("|")})$`),n._zod.parse=(r,i)=>{const s=r.value;return t.has(s)||r.issues.push({code:"invalid_value",values:e.values,input:s,inst:n}),r}}),UA=$("$ZodTransform",(n,e)=>{he.init(n,e),n._zod.parse=(t,r)=>{if(r.direction==="backward")throw new Dg(n.constructor.name);const i=e.transform(t.value,t);if(r.async)return(i instanceof Promise?i:Promise.resolve(i)).then(o=>(t.value=o,t));if(i instanceof Promise)throw new Rr;return t.value=i,t}});function of(n,e){return n.issues.length&&e===void 0?{issues:[],value:void 0}:n}const Xg=$("$ZodOptional",(n,e)=>{he.init(n,e),n._zod.optin="optional",n._zod.optout="optional",X(n._zod,"values",()=>e.innerType._zod.values?new Set([...e.innerType._zod.values,void 0]):void 0),X(n._zod,"pattern",()=>{const t=e.innerType._zod.pattern;return t?new RegExp(`^(${Cu(t.source)})?$`):void 0}),n._zod.parse=(t,r)=>{if(e.innerType._zod.optin==="optional"){const i=e.innerType._zod.run(t,r);return i instanceof Promise?i.then(s=>of(s,t.value)):of(i,t.value)}return t.value===void 0?t:e.innerType._zod.run(t,r)}}),FA=$("$ZodExactOptional",(n,e)=>{Xg.init(n,e),X(n._zod,"values",()=>e.innerType._zod.values),X(n._zod,"pattern",()=>e.innerType._zod.pattern),n._zod.parse=(t,r)=>e.innerType._zod.run(t,r)}),ZA=$("$ZodNullable",(n,e)=>{he.init(n,e),X(n._zod,"optin",()=>e.innerType._zod.optin),X(n._zod,"optout",()=>e.innerType._zod.optout),X(n._zod,"pattern",()=>{const t=e.innerType._zod.pattern;return t?new RegExp(`^(${Cu(t.source)}|null)$`):void 0}),X(n._zod,"values",()=>e.innerType._zod.values?new Set([...e.innerType._zod.values,null]):void 0),n._zod.parse=(t,r)=>t.value===null?t:e.innerType._zod.run(t,r)}),HA=$("$ZodDefault",(n,e)=>{he.init(n,e),n._zod.optin="optional",X(n._zod,"values",()=>e.innerType._zod.values),n._zod.parse=(t,r)=>{if(r.direction==="backward")return e.innerType._zod.run(t,r);if(t.value===void 0)return t.value=e.defaultValue,t;const i=e.innerType._zod.run(t,r);return i instanceof Promise?i.then(s=>af(s,e)):af(i,e)}});function af(n,e){return n.value===void 0&&(n.value=e.defaultValue),n}const VA=$("$ZodPrefault",(n,e)=>{he.init(n,e),n._zod.optin="optional",X(n._zod,"values",()=>e.innerType._zod.values),n._zod.parse=(t,r)=>(r.direction==="backward"||t.value===void 0&&(t.value=e.defaultValue),e.innerType._zod.run(t,r))}),jA=$("$ZodNonOptional",(n,e)=>{he.init(n,e),X(n._zod,"values",()=>{const t=e.innerType._zod.values;return t?new Set([...t].filter(r=>r!==void 0)):void 0}),n._zod.parse=(t,r)=>{const i=e.innerType._zod.run(t,r);return i instanceof Promise?i.then(s=>lf(s,n)):lf(i,n)}});function lf(n,e){return!n.issues.length&&n.value===void 0&&n.issues.push({code:"invalid_type",expected:"nonoptional",input:n.value,inst:e}),n}const GA=$("$ZodCatch",(n,e)=>{he.init(n,e),X(n._zod,"optin",()=>e.innerType._zod.optin),X(n._zod,"optout",()=>e.innerType._zod.optout),X(n._zod,"values",()=>e.innerType._zod.values),n._zod.parse=(t,r)=>{if(r.direction==="backward")return e.innerType._zod.run(t,r);const i=e.innerType._zod.run(t,r);return i instanceof Promise?i.then(s=>(t.value=s.value,s.issues.length&&(t.value=e.catchValue({...t,error:{issues:s.issues.map(o=>gn(o,r,pn()))},input:t.value}),t.issues=[]),t)):(t.value=i.value,i.issues.length&&(t.value=e.catchValue({...t,error:{issues:i.issues.map(s=>gn(s,r,pn()))},input:t.value}),t.issues=[]),t)}}),BA=$("$ZodPipe",(n,e)=>{he.init(n,e),X(n._zod,"values",()=>e.in._zod.values),X(n._zod,"optin",()=>e.in._zod.optin),X(n._zod,"optout",()=>e.out._zod.optout),X(n._zod,"propValues",()=>e.in._zod.propValues),n._zod.parse=(t,r)=>{if(r.direction==="backward"){const s=e.out._zod.run(t,r);return s instanceof Promise?s.then(o=>yo(o,e.in,r)):yo(s,e.in,r)}const i=e.in._zod.run(t,r);return i instanceof Promise?i.then(s=>yo(s,e.out,r)):yo(i,e.out,r)}});function yo(n,e,t){return n.issues.length?(n.aborted=!0,n):e._zod.run({value:n.value,issues:n.issues},t)}const WA=$("$ZodReadonly",(n,e)=>{he.init(n,e),X(n._zod,"propValues",()=>e.innerType._zod.propValues),X(n._zod,"values",()=>e.innerType._zod.values),X(n._zod,"optin",()=>{var t,r;return(r=(t=e.innerType)==null?void 0:t._zod)==null?void 0:r.optin}),X(n._zod,"optout",()=>{var t,r;return(r=(t=e.innerType)==null?void 0:t._zod)==null?void 0:r.optout}),n._zod.parse=(t,r)=>{if(r.direction==="backward")return e.innerType._zod.run(t,r);const i=e.innerType._zod.run(t,r);return i instanceof Promise?i.then(cf):cf(i)}});function cf(n){return n.value=Object.freeze(n.value),n}const qA=$("$ZodCustom",(n,e)=>{Be.init(n,e),he.init(n,e),n._zod.parse=(t,r)=>t,n._zod.check=t=>{const r=t.value,i=e.fn(r);if(i instanceof Promise)return i.then(s=>uf(s,t,r,n));uf(i,t,r,n)}});function uf(n,e,t,r){if(!n){const i={code:"custom",input:t,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(i.params=r._zod.def.params),e.issues.push(Ji(i))}}var hf;class YA{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...t){const r=t[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 t=this._map.get(e);return t&&typeof t=="object"&&"id"in t&&this._idmap.delete(t.id),this._map.delete(e),this}get(e){const t=e._zod.parent;if(t){const r={...this.get(t)??{}};delete r.id;const i={...r,...this._map.get(e)};return Object.keys(i).length?i:void 0}return this._map.get(e)}has(e){return this._map.has(e)}}function KA(){return new YA}(hf=globalThis).__zod_globalRegistry??(hf.__zod_globalRegistry=KA());const zi=globalThis.__zod_globalRegistry;function JA(n,e){return new n({type:"string",...O(e)})}function XA(n,e){return new n({type:"string",format:"email",check:"string_format",abort:!1,...O(e)})}function df(n,e){return new n({type:"string",format:"guid",check:"string_format",abort:!1,...O(e)})}function QA(n,e){return new n({type:"string",format:"uuid",check:"string_format",abort:!1,...O(e)})}function ex(n,e){return new n({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...O(e)})}function tx(n,e){return new n({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...O(e)})}function nx(n,e){return new n({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...O(e)})}function rx(n,e){return new n({type:"string",format:"url",check:"string_format",abort:!1,...O(e)})}function ix(n,e){return new n({type:"string",format:"emoji",check:"string_format",abort:!1,...O(e)})}function sx(n,e){return new n({type:"string",format:"nanoid",check:"string_format",abort:!1,...O(e)})}function ox(n,e){return new n({type:"string",format:"cuid",check:"string_format",abort:!1,...O(e)})}function ax(n,e){return new n({type:"string",format:"cuid2",check:"string_format",abort:!1,...O(e)})}function lx(n,e){return new n({type:"string",format:"ulid",check:"string_format",abort:!1,...O(e)})}function cx(n,e){return new n({type:"string",format:"xid",check:"string_format",abort:!1,...O(e)})}function ux(n,e){return new n({type:"string",format:"ksuid",check:"string_format",abort:!1,...O(e)})}function hx(n,e){return new n({type:"string",format:"ipv4",check:"string_format",abort:!1,...O(e)})}function dx(n,e){return new n({type:"string",format:"ipv6",check:"string_format",abort:!1,...O(e)})}function fx(n,e){return new n({type:"string",format:"cidrv4",check:"string_format",abort:!1,...O(e)})}function px(n,e){return new n({type:"string",format:"cidrv6",check:"string_format",abort:!1,...O(e)})}function gx(n,e){return new n({type:"string",format:"base64",check:"string_format",abort:!1,...O(e)})}function mx(n,e){return new n({type:"string",format:"base64url",check:"string_format",abort:!1,...O(e)})}function yx(n,e){return new n({type:"string",format:"e164",check:"string_format",abort:!1,...O(e)})}function vx(n,e){return new n({type:"string",format:"jwt",check:"string_format",abort:!1,...O(e)})}function bx(n,e){return new n({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...O(e)})}function wx(n,e){return new n({type:"string",format:"date",check:"string_format",...O(e)})}function _x(n,e){return new n({type:"string",format:"time",check:"string_format",precision:null,...O(e)})}function Sx(n,e){return new n({type:"string",format:"duration",check:"string_format",...O(e)})}function kx(n,e){return new n({type:"number",checks:[],...O(e)})}function Ex(n,e){return new n({type:"number",check:"number_format",abort:!1,format:"safeint",...O(e)})}function $x(n,e){return new n({type:"boolean",...O(e)})}function Ax(n){return new n({type:"unknown"})}function xx(n,e){return new n({type:"never",...O(e)})}function ff(n,e){return new Bg({check:"less_than",...O(e),value:n,inclusive:!1})}function Dl(n,e){return new Bg({check:"less_than",...O(e),value:n,inclusive:!0})}function pf(n,e){return new Wg({check:"greater_than",...O(e),value:n,inclusive:!1})}function Ol(n,e){return new Wg({check:"greater_than",...O(e),value:n,inclusive:!0})}function gf(n,e){return new H$({check:"multiple_of",...O(e),value:n})}function Qg(n,e){return new j$({check:"max_length",...O(e),maximum:n})}function Xo(n,e){return new G$({check:"min_length",...O(e),minimum:n})}function em(n,e){return new B$({check:"length_equals",...O(e),length:n})}function Tx(n,e){return new W$({check:"string_format",format:"regex",...O(e),pattern:n})}function Cx(n){return new q$({check:"string_format",format:"lowercase",...O(n)})}function Ix(n){return new Y$({check:"string_format",format:"uppercase",...O(n)})}function Px(n,e){return new K$({check:"string_format",format:"includes",...O(e),includes:n})}function Rx(n,e){return new J$({check:"string_format",format:"starts_with",...O(e),prefix:n})}function Dx(n,e){return new X$({check:"string_format",format:"ends_with",...O(e),suffix:n})}function fi(n){return new Q$({check:"overwrite",tx:n})}function Ox(n){return fi(e=>e.normalize(n))}function zx(){return fi(n=>n.trim())}function Lx(){return fi(n=>n.toLowerCase())}function Mx(){return fi(n=>n.toUpperCase())}function Nx(){return fi(n=>W0(n))}function Ux(n,e,t){return new n({type:"array",element:e,...O(t)})}function Fx(n,e,t){return new n({type:"custom",check:"custom",fn:e,...O(t)})}function Zx(n){const e=Hx(t=>(t.addIssue=r=>{if(typeof r=="string")t.issues.push(Ji(r,t.value,e._zod.def));else{const i=r;i.fatal&&(i.continue=!1),i.code??(i.code="custom"),i.input??(i.input=t.value),i.inst??(i.inst=e),i.continue??(i.continue=!e._zod.def.abort),t.issues.push(Ji(i))}},n(t.value,t)));return e}function Hx(n,e){const t=new Be({check:"custom",...O(e)});return t._zod.check=n,t}function tm(n){let e=(n==null?void 0:n.target)??"draft-2020-12";return e==="draft-4"&&(e="draft-04"),e==="draft-7"&&(e="draft-07"),{processors:n.processors??{},metadataRegistry:(n==null?void 0:n.metadata)??zi,target:e,unrepresentable:(n==null?void 0:n.unrepresentable)??"throw",override:(n==null?void 0:n.override)??(()=>{}),io:(n==null?void 0:n.io)??"output",counter:0,seen:new Map,cycles:(n==null?void 0:n.cycles)??"ref",reused:(n==null?void 0:n.reused)??"inline",external:(n==null?void 0:n.external)??void 0}}function ve(n,e,t={path:[],schemaPath:[]}){var d,f;var r;const i=n._zod.def,s=e.seen.get(n);if(s)return s.count++,t.schemaPath.includes(n)&&(s.cycle=t.path),s.schema;const o={schema:{},count:1,cycle:void 0,path:t.path};e.seen.set(n,o);const a=(f=(d=n._zod).toJSONSchema)==null?void 0:f.call(d);if(a)o.schema=a;else{const v={...t,schemaPath:[...t.schemaPath,n],path:t.path};if(n._zod.processJSONSchema)n._zod.processJSONSchema(e,o.schema,v);else{const A=o.schema,k=e.processors[i.type];if(!k)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${i.type}`);k(n,e,A,v)}const y=n._zod.parent;y&&(o.ref||(o.ref=y),ve(y,e,v),e.seen.get(y).isParent=!0)}const l=e.metadataRegistry.get(n);return l&&Object.assign(o.schema,l),e.io==="input"&&Oe(n)&&(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(n).schema}function nm(n,e){var o,a,l,u;const t=n.seen.get(e);if(!t)throw new Error("Unprocessed schema. This is a bug in Zod.");const r=new Map;for(const d of n.seen.entries()){const f=(o=n.metadataRegistry.get(d[0]))==null?void 0:o.id;if(f){const v=r.get(f);if(v&&v!==d[0])throw new Error(`Duplicate schema id "${f}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);r.set(f,d[0])}}const i=d=>{var k;const f=n.target==="draft-2020-12"?"$defs":"definitions";if(n.external){const I=(k=n.external.registry.get(d[0]))==null?void 0:k.id,G=n.external.uri??(le=>le);if(I)return{ref:G(I)};const P=d[1].defId??d[1].schema.id??`schema${n.counter++}`;return d[1].defId=P,{defId:P,ref:`${G("__shared")}#/${f}/${P}`}}if(d[1]===t)return{ref:"#"};const y=`#/${f}/`,A=d[1].schema.id??`__schema${n.counter++}`;return{defId:A,ref:y+A}},s=d=>{if(d[1].schema.$ref)return;const f=d[1],{ref:v,defId:y}=i(d);f.def={...f.schema},y&&(f.defId=y);const A=f.schema;for(const k in A)delete A[k];A.$ref=v};if(n.cycles==="throw")for(const d of n.seen.entries()){const f=d[1];if(f.cycle)throw new Error(`Cycle detected: #/${(a=f.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 n.seen.entries()){const f=d[1];if(e===d[0]){s(d);continue}if(n.external){const y=(l=n.external.registry.get(d[0]))==null?void 0:l.id;if(e!==d[0]&&y){s(d);continue}}if((u=n.metadataRegistry.get(d[0]))==null?void 0:u.id){s(d);continue}if(f.cycle){s(d);continue}if(f.count>1&&n.reused==="ref"){s(d);continue}}}function sm(n,e){var o,a,l;const t=n.seen.get(e);if(!t)throw new Error("Unprocessed schema. This is a bug in Zod.");const r=u=>{const d=n.seen.get(u);if(d.ref===null)return;const f=d.def??d.schema,v={...f},y=d.ref;if(d.ref=null,y){r(y);const k=n.seen.get(y),I=k.schema;if(I.$ref&&(n.target==="draft-07"||n.target==="draft-04"||n.target==="openapi-3.0")?(f.allOf=f.allOf??[],f.allOf.push(I)):Object.assign(f,I),Object.assign(f,v),u._zod.parent===y)for(const P in f)P==="$ref"||P==="allOf"||P in v||delete f[P];if(I.$ref&&k.def)for(const P in f)P==="$ref"||P==="allOf"||P in k.def&&JSON.stringify(f[P])===JSON.stringify(k.def[P])&&delete f[P]}const A=u._zod.parent;if(A&&A!==y){r(A);const k=n.seen.get(A);if(k!=null&&k.schema.$ref&&(f.$ref=k.schema.$ref,k.def))for(const I in f)I==="$ref"||I==="allOf"||I in k.def&&JSON.stringify(f[I])===JSON.stringify(k.def[I])&&delete f[I]}n.override({zodSchema:u,jsonSchema:f,path:d.path??[]})};for(const u of[...n.seen.entries()].reverse())r(u[0]);const i={};if(n.target==="draft-2020-12"?i.$schema="https://json-schema.org/draft/2020-12/schema":n.target==="draft-07"?i.$schema="http://json-schema.org/draft-07/schema#":n.target==="draft-04"?i.$schema="http://json-schema.org/draft-04/schema#":n.target,(o=n.external)!=null&&o.uri){const u=(a=n.external.registry.get(e))==null?void 0:a.id;if(!u)throw new Error("Schema is missing an `id` property");i.$id=n.external.uri(u)}Object.assign(i,t.def??t.schema);const s=((l=n.external)==null?void 0:l.defs)??{};for(const u of n.seen.entries()){const d=u[1];d.def&&d.defId&&(s[d.defId]=d.def)}n.external||Object.keys(s).length>0&&(n.target==="draft-2020-12"?i.$defs=s:i.definitions=s);try{const u=JSON.parse(JSON.stringify(i));return Object.defineProperty(u,"~standard",{value:{...e["~standard"],jsonSchema:{input:Qo(e,"input",n.processors),output:Qo(e,"output",n.processors)}},enumerable:!1,writable:!1}),u}catch{throw new Error("Error converting schema to JSON.")}}function Oe(n,e){const t=e??{seen:new Set};if(t.seen.has(n))return!1;t.seen.add(n);const r=n._zod.def;if(r.type==="transform")return!0;if(r.type==="array")return Oe(r.element,t);if(r.type==="set")return Oe(r.valueType,t);if(r.type==="lazy")return Oe(r.getter(),t);if(r.type==="promise"||r.type==="optional"||r.type==="nonoptional"||r.type==="nullable"||r.type==="readonly"||r.type==="default"||r.type==="prefault")return Oe(r.innerType,t);if(r.type==="intersection")return Oe(r.left,t)||Oe(r.right,t);if(r.type==="record"||r.type==="map")return Oe(r.keyType,t)||Oe(r.valueType,t);if(r.type==="pipe")return Oe(r.in,t)||Oe(r.out,t);if(r.type==="object"){for(const i in r.shape)if(Oe(r.shape[i],t))return!0;return!1}if(r.type==="union"){for(const i of r.options)if(Oe(i,t))return!0;return!1}if(r.type==="tuple"){for(const i of r.items)if(Oe(i,t))return!0;return!!(r.rest&&Oe(r.rest,t))}return!1}const Wx=(n,e={})=>t=>{const r=rm({...t,processors:e});return ve(n,r),im(r,n),sm(r,n)},Qo=(n,e,t={})=>r=>{const{libraryOptions:i,target:s}=r??{},o=rm({...i??{},target:s,io:e,processors:t});return ve(n,o),im(o,n),sm(o,n)},qx={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},Yx=(n,e,t,r)=>{const i=t;i.type="string";const{minimum:s,maximum:o,format:a,patterns:l,contentEncoding:u}=n._zod.bag;if(typeof s=="number"&&(i.minLength=s),typeof o=="number"&&(i.maxLength=o),a&&(i.format=qx[a]??a,i.format===""&&delete i.format,a==="time"&&delete i.format),u&&(i.contentEncoding=u),l&&l.size>0){const d=[...l];d.length===1?i.pattern=d[0].source:d.length>1&&(i.allOf=[...d.map(f=>({...e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0"?{type:"string"}:{},pattern:f.source}))])}},Kx=(n,e,t,r)=>{const i=t,{minimum:s,maximum:o,format:a,multipleOf:l,exclusiveMaximum:u,exclusiveMinimum:d}=n._zod.bag;typeof a=="string"&&a.includes("int")?i.type="integer":i.type="number",typeof d=="number"&&(e.target==="draft-04"||e.target==="openapi-3.0"?(i.minimum=d,i.exclusiveMinimum=!0):i.exclusiveMinimum=d),typeof s=="number"&&(i.minimum=s,typeof d=="number"&&e.target!=="draft-04"&&(d>=s?delete i.minimum:delete i.exclusiveMinimum)),typeof u=="number"&&(e.target==="draft-04"||e.target==="openapi-3.0"?(i.maximum=u,i.exclusiveMaximum=!0):i.exclusiveMaximum=u),typeof o=="number"&&(i.maximum=o,typeof u=="number"&&e.target!=="draft-04"&&(u<=o?delete i.maximum:delete i.exclusiveMaximum)),typeof l=="number"&&(i.multipleOf=l)},Jx=(n,e,t,r)=>{t.type="boolean"},Xx=(n,e,t,r)=>{t.not={}},Qx=(n,e,t,r)=>{},eT=(n,e,t,r)=>{const i=n._zod.def,s=Mg(i.entries);s.every(o=>typeof o=="number")&&(t.type="number"),s.every(o=>typeof o=="string")&&(t.type="string"),t.enum=s},tT=(n,e,t,r)=>{const i=n._zod.def,s=[];for(const o of i.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");s.push(Number(o))}else s.push(o);if(s.length!==0)if(s.length===1){const o=s[0];t.type=o===null?"null":typeof o,e.target==="draft-04"||e.target==="openapi-3.0"?t.enum=[o]:t.const=o}else s.every(o=>typeof o=="number")&&(t.type="number"),s.every(o=>typeof o=="string")&&(t.type="string"),s.every(o=>typeof o=="boolean")&&(t.type="boolean"),s.every(o=>o===null)&&(t.type="null"),t.enum=s},nT=(n,e,t,r)=>{if(e.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema")},rT=(n,e,t,r)=>{if(e.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema")},iT=(n,e,t,r)=>{const i=t,s=n._zod.def,{minimum:o,maximum:a}=n._zod.bag;typeof o=="number"&&(i.minItems=o),typeof a=="number"&&(i.maxItems=a),i.type="array",i.items=ve(s.element,e,{...r,path:[...r.path,"items"]})},sT=(n,e,t,r)=>{var u;const i=t,s=n._zod.def;i.type="object",i.properties={};const o=s.shape;for(const d in o)i.properties[d]=ve(o[d],e,{...r,path:[...r.path,"properties",d]});const a=new Set(Object.keys(o)),l=new Set([...a].filter(d=>{const f=s.shape[d]._zod;return e.io==="input"?f.optin===void 0:f.optout===void 0}));l.size>0&&(i.required=Array.from(l)),((u=s.catchall)==null?void 0:u._zod.def.type)==="never"?i.additionalProperties=!1:s.catchall?s.catchall&&(i.additionalProperties=ve(s.catchall,e,{...r,path:[...r.path,"additionalProperties"]})):e.io==="output"&&(i.additionalProperties=!1)},oT=(n,e,t,r)=>{const i=n._zod.def,s=i.inclusive===!1,o=i.options.map((a,l)=>ve(a,e,{...r,path:[...r.path,s?"oneOf":"anyOf",l]}));s?t.oneOf=o:t.anyOf=o},aT=(n,e,t,r)=>{const i=n._zod.def,s=ve(i.left,e,{...r,path:[...r.path,"allOf",0]}),o=ve(i.right,e,{...r,path:[...r.path,"allOf",1]}),a=u=>"allOf"in u&&Object.keys(u).length===1,l=[...a(s)?s.allOf:[s],...a(o)?o.allOf:[o]];t.allOf=l},lT=(n,e,t,r)=>{const i=t,s=n._zod.def;i.type="object";const o=s.keyType,a=o._zod.bag,l=a==null?void 0:a.patterns;if(s.mode==="loose"&&l&&l.size>0){const d=ve(s.valueType,e,{...r,path:[...r.path,"patternProperties","*"]});i.patternProperties={};for(const f of l)i.patternProperties[f.source]=d}else(e.target==="draft-07"||e.target==="draft-2020-12")&&(i.propertyNames=ve(s.keyType,e,{...r,path:[...r.path,"propertyNames"]})),i.additionalProperties=ve(s.valueType,e,{...r,path:[...r.path,"additionalProperties"]});const u=o._zod.values;if(u){const d=[...u].filter(f=>typeof f=="string"||typeof f=="number");d.length>0&&(i.required=d)}},cT=(n,e,t,r)=>{const i=n._zod.def,s=ve(i.innerType,e,r),o=e.seen.get(n);e.target==="openapi-3.0"?(o.ref=i.innerType,t.nullable=!0):t.anyOf=[s,{type:"null"}]},uT=(n,e,t,r)=>{const i=n._zod.def;ve(i.innerType,e,r);const s=e.seen.get(n);s.ref=i.innerType},hT=(n,e,t,r)=>{const i=n._zod.def;ve(i.innerType,e,r);const s=e.seen.get(n);s.ref=i.innerType,t.default=JSON.parse(JSON.stringify(i.defaultValue))},dT=(n,e,t,r)=>{const i=n._zod.def;ve(i.innerType,e,r);const s=e.seen.get(n);s.ref=i.innerType,e.io==="input"&&(t._prefault=JSON.parse(JSON.stringify(i.defaultValue)))},fT=(n,e,t,r)=>{const i=n._zod.def;ve(i.innerType,e,r);const s=e.seen.get(n);s.ref=i.innerType;let o;try{o=i.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}t.default=o},pT=(n,e,t,r)=>{const i=n._zod.def,s=e.io==="input"?i.in._zod.def.type==="transform"?i.out:i.in:i.out;ve(s,e,r);const o=e.seen.get(n);o.ref=s},gT=(n,e,t,r)=>{const i=n._zod.def;ve(i.innerType,e,r);const s=e.seen.get(n);s.ref=i.innerType,t.readOnly=!0},om=(n,e,t,r)=>{const i=n._zod.def;ve(i.innerType,e,r);const s=e.seen.get(n);s.ref=i.innerType},mT=$("ZodISODateTime",(n,e)=>{yA.init(n,e),fe.init(n,e)});function yT(n){return kx(mT,n)}const vT=$("ZodISODate",(n,e)=>{vA.init(n,e),fe.init(n,e)});function bT(n){return Ex(vT,n)}const wT=$("ZodISOTime",(n,e)=>{bA.init(n,e),fe.init(n,e)});function _T(n){return $x(wT,n)}const ST=$("ZodISODuration",(n,e)=>{wA.init(n,e),fe.init(n,e)});function kT(n){return Ax(ST,n)}const am=(n,e)=>{Zg.init(n,e),n.name="ZodError",Object.defineProperties(n,{format:{value:t=>u$(n,t)},flatten:{value:t=>c$(n,t)},addIssue:{value:t=>{n.issues.push(t),n.message=JSON.stringify(n.issues,uc,2)}},addIssues:{value:t=>{n.issues.push(...t),n.message=JSON.stringify(n.issues,uc,2)}},isEmpty:{get(){return n.issues.length===0}}})},mf=$("ZodError",am),ot=$("ZodError",am,{Parent:Error}),ET=Cu(ot),$T=Iu(ot),AT=Da(ot),xT=Oa(ot),TT=f$(ot),CT=p$(ot),IT=g$(ot),PT=m$(ot),RT=y$(ot),DT=v$(ot),OT=b$(ot),zT=w$(ot),de=$("ZodType",(n,e)=>(he.init(n,e),Object.assign(n["~standard"],{jsonSchema:{input:Qo(n,"input"),output:Qo(n,"output")}}),n.toJSONSchema=Wx(n,{}),n.def=e,n.type=e.type,Object.defineProperty(n,"_def",{value:e}),n.check=(...t)=>n.clone(_n(e,{checks:[...e.checks??[],...t.map(r=>typeof r=="function"?{_zod:{check:r,def:{check:"custom"},onattach:[]}}:r)]}),{parent:!0}),n.with=n.check,n.clone=(t,r)=>Sn(n,t,r),n.brand=()=>n,n.register=(t,r)=>(t.add(n,r),n),n.parse=(t,r)=>ET(n,t,r,{callee:n.parse}),n.safeParse=(t,r)=>AT(n,t,r),n.parseAsync=async(t,r)=>$T(n,t,r,{callee:n.parseAsync}),n.safeParseAsync=async(t,r)=>xT(n,t,r),n.spa=n.safeParseAsync,n.encode=(t,r)=>TT(n,t,r),n.decode=(t,r)=>CT(n,t,r),n.encodeAsync=async(t,r)=>IT(n,t,r),n.decodeAsync=async(t,r)=>PT(n,t,r),n.safeEncode=(t,r)=>RT(n,t,r),n.safeDecode=(t,r)=>DT(n,t,r),n.safeEncodeAsync=async(t,r)=>OT(n,t,r),n.safeDecodeAsync=async(t,r)=>zT(n,t,r),n.refine=(t,r)=>n.check(AC(t,r)),n.superRefine=t=>n.check(xC(t)),n.overwrite=t=>n.check(fi(t)),n.optional=()=>bf(n),n.exactOptional=()=>fC(n),n.nullable=()=>wf(n),n.nullish=()=>bf(wf(n)),n.nonoptional=t=>bC(n,t),n.array=()=>D(n),n.or=t=>H([n,t]),n.and=t=>La(n,t),n.transform=t=>_f(n,hC(t)),n.default=t=>mC(n,t),n.prefault=t=>vC(n,t),n.catch=t=>_C(n,t),n.pipe=t=>_f(n,t),n.readonly=()=>EC(n),n.describe=t=>{const r=n.clone();return zi.add(r,{description:t}),r},Object.defineProperty(n,"description",{get(){var t;return(t=zi.get(n))==null?void 0:t.description},configurable:!0}),n.meta=(...t)=>{if(t.length===0)return zi.get(n);const r=n.clone();return zi.add(r,t[0]),r},n.isOptional=()=>n.safeParse(void 0).success,n.isNullable=()=>n.safeParse(null).success,n.apply=t=>t(n),n)),lm=$("_ZodString",(n,e)=>{Pu.init(n,e),de.init(n,e),n._zod.processJSONSchema=(r,i,s)=>Yx(n,r,i);const t=n._zod.bag;n.format=t.format??null,n.minLength=t.minimum??null,n.maxLength=t.maximum??null,n.regex=(...r)=>n.check(Rx(...r)),n.includes=(...r)=>n.check(zx(...r)),n.startsWith=(...r)=>n.check(Lx(...r)),n.endsWith=(...r)=>n.check(Mx(...r)),n.min=(...r)=>n.check(Xo(...r)),n.max=(...r)=>n.check(tm(...r)),n.length=(...r)=>n.check(nm(...r)),n.nonempty=(...r)=>n.check(Xo(1,...r)),n.lowercase=r=>n.check(Dx(r)),n.uppercase=r=>n.check(Ox(r)),n.trim=()=>n.check(Ux()),n.normalize=(...r)=>n.check(Nx(...r)),n.toLowerCase=()=>n.check(Fx()),n.toUpperCase=()=>n.check(Zx()),n.slugify=()=>n.check(Hx())}),LT=$("ZodString",(n,e)=>{Pu.init(n,e),lm.init(n,e),n.email=t=>n.check(nx(MT,t)),n.url=t=>n.check(ax(NT,t)),n.jwt=t=>n.check(Sx(QT,t)),n.emoji=t=>n.check(lx(UT,t)),n.guid=t=>n.check(df(yf,t)),n.uuid=t=>n.check(rx(vo,t)),n.uuidv4=t=>n.check(ix(vo,t)),n.uuidv6=t=>n.check(sx(vo,t)),n.uuidv7=t=>n.check(ox(vo,t)),n.nanoid=t=>n.check(cx(FT,t)),n.guid=t=>n.check(df(yf,t)),n.cuid=t=>n.check(ux(ZT,t)),n.cuid2=t=>n.check(hx(HT,t)),n.ulid=t=>n.check(dx(VT,t)),n.base64=t=>n.check(bx(KT,t)),n.base64url=t=>n.check(wx(JT,t)),n.xid=t=>n.check(fx(jT,t)),n.ksuid=t=>n.check(px(BT,t)),n.ipv4=t=>n.check(gx(GT,t)),n.ipv6=t=>n.check(mx(WT,t)),n.cidrv4=t=>n.check(yx(qT,t)),n.cidrv6=t=>n.check(vx(YT,t)),n.e164=t=>n.check(_x(XT,t)),n.datetime=t=>n.check(yT(t)),n.date=t=>n.check(bT(t)),n.time=t=>n.check(_T(t)),n.duration=t=>n.check(kT(t))});function h(n){return tx(LT,n)}const fe=$("ZodStringFormat",(n,e)=>{ae.init(n,e),lm.init(n,e)}),MT=$("ZodEmail",(n,e)=>{lA.init(n,e),fe.init(n,e)}),yf=$("ZodGUID",(n,e)=>{oA.init(n,e),fe.init(n,e)}),vo=$("ZodUUID",(n,e)=>{aA.init(n,e),fe.init(n,e)}),NT=$("ZodURL",(n,e)=>{cA.init(n,e),fe.init(n,e)}),UT=$("ZodEmoji",(n,e)=>{uA.init(n,e),fe.init(n,e)}),FT=$("ZodNanoID",(n,e)=>{hA.init(n,e),fe.init(n,e)}),ZT=$("ZodCUID",(n,e)=>{dA.init(n,e),fe.init(n,e)}),HT=$("ZodCUID2",(n,e)=>{fA.init(n,e),fe.init(n,e)}),VT=$("ZodULID",(n,e)=>{pA.init(n,e),fe.init(n,e)}),jT=$("ZodXID",(n,e)=>{gA.init(n,e),fe.init(n,e)}),BT=$("ZodKSUID",(n,e)=>{mA.init(n,e),fe.init(n,e)}),GT=$("ZodIPv4",(n,e)=>{_A.init(n,e),fe.init(n,e)}),WT=$("ZodIPv6",(n,e)=>{SA.init(n,e),fe.init(n,e)}),qT=$("ZodCIDRv4",(n,e)=>{kA.init(n,e),fe.init(n,e)}),YT=$("ZodCIDRv6",(n,e)=>{EA.init(n,e),fe.init(n,e)}),KT=$("ZodBase64",(n,e)=>{$A.init(n,e),fe.init(n,e)}),JT=$("ZodBase64URL",(n,e)=>{xA.init(n,e),fe.init(n,e)}),XT=$("ZodE164",(n,e)=>{TA.init(n,e),fe.init(n,e)}),QT=$("ZodJWT",(n,e)=>{IA.init(n,e),fe.init(n,e)}),cm=$("ZodNumber",(n,e)=>{Jg.init(n,e),de.init(n,e),n._zod.processJSONSchema=(r,i,s)=>Kx(n,r,i),n.gt=(r,i)=>n.check(pf(r,i)),n.gte=(r,i)=>n.check(Rl(r,i)),n.min=(r,i)=>n.check(Rl(r,i)),n.lt=(r,i)=>n.check(ff(r,i)),n.lte=(r,i)=>n.check(Pl(r,i)),n.max=(r,i)=>n.check(Pl(r,i)),n.int=r=>n.check(vf(r)),n.safe=r=>n.check(vf(r)),n.positive=r=>n.check(pf(0,r)),n.nonnegative=r=>n.check(Rl(0,r)),n.negative=r=>n.check(ff(0,r)),n.nonpositive=r=>n.check(Pl(0,r)),n.multipleOf=(r,i)=>n.check(gf(r,i)),n.step=(r,i)=>n.check(gf(r,i)),n.finite=()=>n;const t=n._zod.bag;n.minValue=Math.max(t.minimum??Number.NEGATIVE_INFINITY,t.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,n.maxValue=Math.min(t.maximum??Number.POSITIVE_INFINITY,t.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,n.isInt=(t.format??"").includes("int")||Number.isSafeInteger(t.multipleOf??.5),n.isFinite=!0,n.format=t.format??null});function N(n){return xx(cm,n)}const eC=$("ZodNumberFormat",(n,e)=>{PA.init(n,e),cm.init(n,e)});function vf(n){return Tx(eC,n)}const tC=$("ZodBoolean",(n,e)=>{RA.init(n,e),de.init(n,e),n._zod.processJSONSchema=(t,r,i)=>Jx(n,t,r)});function Ee(n){return Cx(tC,n)}const nC=$("ZodUnknown",(n,e)=>{DA.init(n,e),de.init(n,e),n._zod.processJSONSchema=(t,r,i)=>Qx()});function w(){return Ix(nC)}const rC=$("ZodNever",(n,e)=>{OA.init(n,e),de.init(n,e),n._zod.processJSONSchema=(t,r,i)=>Xx(n,t,r)});function iC(n){return Px(rC,n)}const sC=$("ZodArray",(n,e)=>{zA.init(n,e),de.init(n,e),n._zod.processJSONSchema=(t,r,i)=>iT(n,t,r,i),n.element=e.element,n.min=(t,r)=>n.check(Xo(t,r)),n.nonempty=t=>n.check(Xo(1,t)),n.max=(t,r)=>n.check(tm(t,r)),n.length=(t,r)=>n.check(nm(t,r)),n.unwrap=()=>n.element});function D(n,e){return Vx(sC,n,e)}const um=$("ZodObject",(n,e)=>{MA.init(n,e),de.init(n,e),n._zod.processJSONSchema=(t,r,i)=>sT(n,t,r,i),X(n,"shape",()=>e.shape),n.keyof=()=>ea(Object.keys(n._zod.def.shape)),n.catchall=t=>n.clone({...n._zod.def,catchall:t}),n.passthrough=()=>n.clone({...n._zod.def,catchall:w()}),n.loose=()=>n.clone({...n._zod.def,catchall:w()}),n.strict=()=>n.clone({...n._zod.def,catchall:iC()}),n.strip=()=>n.clone({...n._zod.def,catchall:void 0}),n.extend=t=>i$(n,t),n.safeExtend=t=>s$(n,t),n.merge=t=>o$(n,t),n.pick=t=>n$(n,t),n.omit=t=>r$(n,t),n.partial=(...t)=>a$(dm,n,t[0]),n.required=(...t)=>l$(fm,n,t[0])});function hm(n,e){const t={type:"object",shape:n??{},...O(e)};return new um(t)}function p(n,e){return new um({type:"object",shape:n,catchall:w(),...O(e)})}const oC=$("ZodUnion",(n,e)=>{NA.init(n,e),de.init(n,e),n._zod.processJSONSchema=(t,r,i)=>oT(n,t,r,i),n.options=e.options});function H(n,e){return new oC({type:"union",options:n,...O(e)})}const aC=$("ZodIntersection",(n,e)=>{UA.init(n,e),de.init(n,e),n._zod.processJSONSchema=(t,r,i)=>aT(n,t,r,i)});function La(n,e){return new aC({type:"intersection",left:n,right:e})}const lC=$("ZodRecord",(n,e)=>{FA.init(n,e),de.init(n,e),n._zod.processJSONSchema=(t,r,i)=>lT(n,t,r,i),n.keyType=e.keyType,n.valueType=e.valueType});function _(n,e,t){return new lC({type:"record",keyType:n,valueType:e,...O(t)})}const dc=$("ZodEnum",(n,e)=>{ZA.init(n,e),de.init(n,e),n._zod.processJSONSchema=(r,i,s)=>eT(n,r,i),n.enum=e.entries,n.options=Object.values(e.entries);const t=new Set(Object.keys(e.entries));n.extract=(r,i)=>{const s={};for(const o of r)if(t.has(o))s[o]=e.entries[o];else throw new Error(`Key ${o} not found in enum`);return new dc({...e,checks:[],...O(i),entries:s})},n.exclude=(r,i)=>{const s={...e.entries};for(const o of r)if(t.has(o))delete s[o];else throw new Error(`Key ${o} not found in enum`);return new dc({...e,checks:[],...O(i),entries:s})}});function ea(n,e){const t=Array.isArray(n)?Object.fromEntries(n.map(r=>[r,r])):n;return new dc({type:"enum",entries:t,...O(e)})}const cC=$("ZodLiteral",(n,e)=>{HA.init(n,e),de.init(n,e),n._zod.processJSONSchema=(t,r,i)=>tT(n,t,r),n.values=new Set(e.values),Object.defineProperty(n,"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 x(n,e){return new cC({type:"literal",values:Array.isArray(n)?n:[n],...O(e)})}const uC=$("ZodTransform",(n,e)=>{VA.init(n,e),de.init(n,e),n._zod.processJSONSchema=(t,r,i)=>rT(n,t),n._zod.parse=(t,r)=>{if(r.direction==="backward")throw new zg(n.constructor.name);t.addIssue=s=>{if(typeof s=="string")t.issues.push(Ji(s,t.value,e));else{const o=s;o.fatal&&(o.continue=!1),o.code??(o.code="custom"),o.input??(o.input=t.value),o.inst??(o.inst=n),t.issues.push(Ji(o))}};const i=e.transform(t.value,t);return i instanceof Promise?i.then(s=>(t.value=s,t)):(t.value=i,t)}});function hC(n){return new uC({type:"transform",transform:n})}const dm=$("ZodOptional",(n,e)=>{em.init(n,e),de.init(n,e),n._zod.processJSONSchema=(t,r,i)=>om(n,t,r,i),n.unwrap=()=>n._zod.def.innerType});function bf(n){return new dm({type:"optional",innerType:n})}const dC=$("ZodExactOptional",(n,e)=>{jA.init(n,e),de.init(n,e),n._zod.processJSONSchema=(t,r,i)=>om(n,t,r,i),n.unwrap=()=>n._zod.def.innerType});function fC(n){return new dC({type:"optional",innerType:n})}const pC=$("ZodNullable",(n,e)=>{BA.init(n,e),de.init(n,e),n._zod.processJSONSchema=(t,r,i)=>cT(n,t,r,i),n.unwrap=()=>n._zod.def.innerType});function wf(n){return new pC({type:"nullable",innerType:n})}const gC=$("ZodDefault",(n,e)=>{GA.init(n,e),de.init(n,e),n._zod.processJSONSchema=(t,r,i)=>hT(n,t,r,i),n.unwrap=()=>n._zod.def.innerType,n.removeDefault=n.unwrap});function mC(n,e){return new gC({type:"default",innerType:n,get defaultValue(){return typeof e=="function"?e():Ug(e)}})}const yC=$("ZodPrefault",(n,e)=>{WA.init(n,e),de.init(n,e),n._zod.processJSONSchema=(t,r,i)=>dT(n,t,r,i),n.unwrap=()=>n._zod.def.innerType});function vC(n,e){return new yC({type:"prefault",innerType:n,get defaultValue(){return typeof e=="function"?e():Ug(e)}})}const fm=$("ZodNonOptional",(n,e)=>{qA.init(n,e),de.init(n,e),n._zod.processJSONSchema=(t,r,i)=>uT(n,t,r,i),n.unwrap=()=>n._zod.def.innerType});function bC(n,e){return new fm({type:"nonoptional",innerType:n,...O(e)})}const wC=$("ZodCatch",(n,e)=>{YA.init(n,e),de.init(n,e),n._zod.processJSONSchema=(t,r,i)=>fT(n,t,r,i),n.unwrap=()=>n._zod.def.innerType,n.removeCatch=n.unwrap});function _C(n,e){return new wC({type:"catch",innerType:n,catchValue:typeof e=="function"?e:()=>e})}const SC=$("ZodPipe",(n,e)=>{KA.init(n,e),de.init(n,e),n._zod.processJSONSchema=(t,r,i)=>pT(n,t,r,i),n.in=e.in,n.out=e.out});function _f(n,e){return new SC({type:"pipe",in:n,out:e})}const kC=$("ZodReadonly",(n,e)=>{JA.init(n,e),de.init(n,e),n._zod.processJSONSchema=(t,r,i)=>gT(n,t,r,i),n.unwrap=()=>n._zod.def.innerType});function EC(n){return new kC({type:"readonly",innerType:n})}const $C=$("ZodCustom",(n,e)=>{XA.init(n,e),de.init(n,e),n._zod.processJSONSchema=(t,r,i)=>nT(n,t)});function AC(n,e={}){return jx($C,n,e)}function xC(n){return Bx(n)}const TC=["text/markdown","text/html"],CC=["committed","pending"];hm({id:h().min(1),type:ea(TC),title:h(),status:ea(CC),externalFilePath:h().optional()});hm({name:h().min(1),description:h(),accepts:D(h().min(1)).min(1)});function Ru(n){return typeof n=="object"&&n!==null}function IC(n){return!Ru(n)||n.type!=="ready"?!1:!("id"in n)}function PC(n){return!(!Ru(n)||n.type!=="update-content"||typeof n.id!="string"||typeof n.content!="string")}function RC(n){return!Ru(n)||n.type!=="wheel"||typeof n.deltaX!="number"||typeof n.deltaY!="number"||typeof n.shiftKey!="boolean"?!1:!("id"in n)}function DC(n,e){if(n===e)return 2;if(n==="*/*")return 0;const t=n.indexOf("/");if(t>0&&n.slice(t+1)==="*"){const r=n.slice(0,t),i=e.indexOf("/");if(i>0&&e.slice(0,i)===r)return 1}return null}function OC(n,e){let t=null;for(const r of n.accepts){const i=DC(r,e);i!==null&&(t===null||i>t)&&(t=i)}return t}function zC(n,e){let t=-1,r=null;for(const i of e){const s=OC(i,n);s!==null&&(s>t||s===t&&r!==null&&i.id<r.id)&&(t=s,r=i)}return r}const LC=4401;class fc extends Error{constructor(e="Authentication required"){super(e),this.name="AuthError"}}class pc extends Tt{constructor(t){super();b(this,"url");b(this,"name");b(this,"token");b(this,"status","disconnected");b(this,"screens",new Map);b(this,"views",[]);b(this,"client");b(this,"createSocket");b(this,"createClient");b(this,"socket",null);b(this,"connectAttempt",0);this.url=Lt(t.url),this.name=t.name,this.token=t.token??null,this.createSocket=t.createSocket??(r=>new WebSocket(r)),this.createClient=t.createClient??((r,i)=>new F0(r,{token:i??void 0})),this.client=this.createClient(this.url,this.token)}async connect(){var i;this.connectAttempt+=1;const t=this.connectAttempt;(i=this.socket)==null||i.close(),this.client=this.createClient(this.url,this.token),this.status="connecting",this.dispatchEvent(new Q("change"));const r=this.createSocket(MC(this.url,this.token));return this.socket=r,await new Promise((s,o)=>{let a=!1;const l=()=>{a||this.connectAttempt!==t||(a=!0,this.status="connected",this.dispatchEvent(new Q("change")),s())},u=f=>{a||this.connectAttempt!==t||(a=!0,this.status="disconnected",this.dispatchEvent(new Q("change")),o(f))},d=async()=>{try{const[{screens:f},v]=await Promise.all([this.client.screens.list(),this.client.views.list()]);this.screens=new Map(f.map(y=>[y.id,structuredClone(y)])),this.views=v,this.dispatchEvent(new Q("change")),l()}catch(f){u(f instanceof Error?f:new Error(String(f)))}};r.addEventListener("open",()=>{d()}),r.addEventListener("message",f=>{const v=UC(f);v&&(this.applyServerEvent(v),this.dispatchEvent(new $g("server-event",{serverURL:this.url,event:v})))}),r.addEventListener("close",f=>{if(this.connectAttempt===t){if(this.socket=null,NC(f)===LC){u(new fc);return}if(!a){u(new Error("Connection closed before initialization"));return}this.status="disconnected",this.dispatchEvent(new Q("change"))}}),r.addEventListener("error",()=>{u(new Error("WebSocket connection failed"))})})}disconnect(){var t;this.connectAttempt+=1,(t=this.socket)==null||t.close(),this.socket=null,this.status="disconnected",this.dispatchEvent(new Q("change"))}getViewURL(t){const r=zC(t.type,this.views);if(!r)return null;const i=`${this.url}/views/${encodeURIComponent(r.id)}/`;return this.token===null?i:`${i}?token=${encodeURIComponent(this.token)}`}getContentURL(t){const r=`${this.url}/artifacts/${encodeURIComponent(t)}/content`;return this.token===null?r:`${r}?token=${encodeURIComponent(this.token)}`}async createScreen(t){const{screen:r}=await this.client.screens.create({name:t});return this.screens.set(r.id,structuredClone(r)),r}applyServerEvent(t){switch(t.type){case"screen-created":this.screens.set(t.screen.id,structuredClone(t.screen)),this.dispatchEvent(new zo("screens-changed"));break;case"screen-updated":this.screens.set(t.screen.id,structuredClone(t.screen)),this.dispatchEvent(new zo("screens-changed"));break;case"screen-removed":this.screens.delete(t.screenID),this.dispatchEvent(new zo("screens-changed"));break;case"artifact-created":{const r=this.screens.get(t.screenID);r&&!Sg(r.layout,t.artifact.id)&&(r.layout=[...r.layout,_g(t.artifact.id)]);break}case"artifact-removed":{const r=this.screens.get(t.screenID);r&&(r.layout=dg(r.layout,t.artifactID));break}}}}function MC(n,e){const t=new URL(n);return t.protocol=t.protocol==="https:"?"wss:":"ws:",t.pathname="/events",t.search="",e&&t.searchParams.set("token",e),t.hash="",t.toString()}function NC(n){return typeof n=="object"&&n!==null&&"code"in n&&typeof n.code=="number"?n.code:null}function UC(n){const e=typeof n=="string"?n:typeof n=="object"&&n!==null&&"data"in n&&typeof n.data=="string"?n.data:"";if(!e)return null;try{return JSON.parse(e)}catch{return null}}class FC extends Tt{constructor(t){super();b(this,"servers",new Map);b(this,"localServerURL");b(this,"localStore");b(this,"createSocket");b(this,"lastActiveServerURL");b(this,"serverListeners",new Map);b(this,"handleLocalStoreChange",()=>{const t=this.localStore.get().activeServerURL;t!==this.lastActiveServerURL&&(this.lastActiveServerURL=t,this.dispatchEvent(new Q("change")))});this.localStore=t.localStore,this.localServerURL=t.localServerURL?Lt(t.localServerURL):null,this.createSocket=t.createSocket??(r=>new WebSocket(r)),this.lastActiveServerURL=this.localStore.get().activeServerURL,this.localStore.addEventListener("change",this.handleLocalStoreChange)}get activeServer(){const t=this.localStore.get().activeServerURL;return t===null?null:this.servers.get(t)??null}add(t){const r=Lt(t.url);this.servers.get(r)&&this.remove(r),this.servers.set(r,t);const s=()=>{this.dispatchEvent(new Q("change"))},o=l=>{this.dispatchEvent(new $g("server-event",{serverURL:l.serverURL,event:l.event}))},a=()=>{this.dispatchEvent(new zo("screens-changed"))};t.addEventListener("change",s),t.addEventListener("server-event",o),t.addEventListener("screens-changed",a),this.serverListeners.set(r,{onServerChange:s,onServerEvent:o,onScreensChanged:a}),this.dispatchEvent(new Q("change"))}remove(t){const r=Lt(t);if(this.localServerURL&&r===this.localServerURL)return;const i=this.servers.get(r);if(!i)return;const s=this.serverListeners.get(r);s&&(i.removeEventListener("change",s.onServerChange),i.removeEventListener("server-event",s.onServerEvent),i.removeEventListener("screens-changed",s.onScreensChanged),this.serverListeners.delete(r)),i.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 Q("change"))}setActive(t){const r=this.localStore.get(),i=t?Lt(t.url):null;r.activeServerURL!==i&&this.localStore.set({...r,activeServerURL:i})}connectConfiguredServers(t){const r=this.localStore.get().servers;for(const s of r){const o=new pc({url:s.url,name:s.name,createSocket:this.createSocket});this.add(o),o.connect().catch(()=>{})}const i=t?this.servers.get(Lt(t))??null:null;this.setActive(i??this.servers.values().next().value??null)}addServer(t,r){const i=Lt(t);this.remove(i);const s=this.localStore.get();this.localStore.set({...s,servers:[...s.servers.filter(a=>Lt(a.url)!==i),{url:i,name:r}]});const o=new pc({url:i,name:r,createSocket:this.createSocket});this.add(o),this.setActive(o),o.connect().catch(()=>{})}removeServer(t){this.remove(t)}}const se={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"},Dt={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"},ZC=1,HC=p({_meta:_(h(),w()).nullish(),terminal:Ee().optional().default(!1)}),VC=p({_meta:_(h(),w()).nullish(),label:h().nullish(),name:h(),optional:Ee().optional().default(!1),secret:Ee().optional().default(!0)}),jC=p({_meta:_(h(),w()).nullish(),description:h().nullish(),id:h(),name:h()}),BC=p({_meta:_(h(),w()).nullish(),description:h().nullish(),id:h(),link:h().nullish(),name:h(),vars:D(VC)}),GC=p({_meta:_(h(),w()).nullish(),args:D(h()).optional(),description:h().nullish(),env:_(h(),h()).optional(),id:h(),name:h()}),WC=H([BC.and(p({type:x("env_var")})),GC.and(p({type:x("terminal")})),jC]),qC=p({_meta:_(h(),w()).nullish(),methodId:h()}),YC=p({_meta:_(h(),w()).nullish()}),KC=p({_meta:_(h(),w()).nullish(),blob:h(),mimeType:h().nullish(),uri:h()}),JC=p({default:Ee().nullish(),description:h().nullish(),title:h().nullish()}),XC=p({_meta:_(h(),w()).nullish()}),QC=p({_meta:_(h(),w()).nullish()}),eI=p({amount:N(),currency:h()}),tI=p({_meta:_(h(),w()).nullish(),terminalId:h()}),nI=p({_meta:_(h(),w()).nullish(),newText:h(),oldText:h().nullish(),path:h()}),rI=H([h(),N(),N(),Ee(),D(h())]),iI=p({content:_(h(),rI).nullish()}),sI=H([iI.and(p({action:x("accept")})),p({action:x("decline")}),p({action:x("cancel")})]),oI=p({_meta:_(h(),w()).nullish()}),pm=h(),aI=p({_meta:_(h(),w()).nullish(),elicitationId:pm}),lI=p({_meta:_(h(),w()).nullish(),action:sI}),cI=x("object"),uI=x("string"),hI=p({_meta:_(h(),w()).nullish()}),dI=p({_meta:_(h(),w()).nullish(),form:oI.nullish(),url:hI.nullish()}),fI=p({elicitationId:pm,url:h().url()}),gm=p({const:h(),title:h()}),mm=p({_meta:_(h(),w()).nullish(),name:h(),value:h()}),pI=H([x(-32700),x(-32600),x(-32601),x(-32602),x(-32603),x(-32800),x(-32e3),x(-32002),x(-32042),N().int().min(-2147483648,{message:"Invalid value: Expected int32 to be >= -2147483648"}).max(2147483647,{message:"Invalid value: Expected int32 to be <= 2147483647"})]),ym=p({code:pI,data:w().optional(),message:h()}),vm=w(),bm=w(),wm=w(),gI=p({_meta:_(h(),w()).nullish(),readTextFile:Ee().optional().default(!1),writeTextFile:Ee().optional().default(!1)}),_m=p({_meta:_(h(),w()).nullish(),name:h(),value:h()}),Sm=p({_meta:_(h(),w()).nullish(),name:h(),title:h().nullish(),version:h()}),mI=p({default:N().nullish(),description:h().nullish(),maximum:N().nullish(),minimum:N().nullish(),title:h().nullish()}),yI=p({_meta:_(h(),w()).nullish()}),vI=p({_meta:_(h(),w()).nullish(),additionalDirectories:D(h()).optional(),cursor:h().nullish(),cwd:h().nullish()}),bI=p({_meta:_(h(),w()).nullish()}),wI=p({_meta:_(h(),w()).nullish(),logout:bI.nullish()}),_I=p({_meta:_(h(),w()).nullish()}),SI=p({_meta:_(h(),w()).nullish()}),kI=p({_meta:_(h(),w()).nullish(),http:Ee().optional().default(!1),sse:Ee().optional().default(!1)}),EI=p({_meta:_(h(),w()).nullish(),headers:D(_m),name:h(),url:h()}),$I=p({_meta:_(h(),w()).nullish(),headers:D(_m),name:h(),url:h()}),AI=p({_meta:_(h(),w()).nullish(),args:D(h()),command:h(),env:D(mm),name:h()}),Ma=H([EI.and(p({type:x("http")})),$I.and(p({type:x("sse")})),AI]),Du=h(),xI=p({_meta:_(h(),w()).nullish(),description:h().nullish(),modelId:Du,name:h()}),TI=H([x("error"),x("warning"),x("information"),x("hint")]),CI=p({_meta:_(h(),w()).nullish()}),II=p({_meta:_(h(),w()).nullish()}),PI=p({_meta:_(h(),w()).nullish()}),RI=p({_meta:_(h(),w()).nullish()}),DI=p({_meta:_(h(),w()).nullish()}),OI=p({_meta:_(h(),w()).nullish(),maxCount:N().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish()}),zI=p({diff:h(),uri:h()}),LI=p({endLine:N().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}),startLine:N().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}),text:h()}),MI=p({_meta:_(h(),w()).nullish()}),NI=p({_meta:_(h(),w()).nullish()}),UI=p({languageId:h(),text:h(),uri:h()}),FI=p({_meta:_(h(),w()).nullish(),maxCount:N().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish()}),ZI=H([x("rejected"),x("ignored"),x("replaced"),x("cancelled")]),HI=p({excerpts:D(LI),uri:h()}),VI=p({_meta:_(h(),w()).nullish()}),jI=p({_meta:_(h(),w()).nullish()}),BI=p({name:h(),owner:h(),remoteUrl:h()}),GI=p({_meta:_(h(),w()).nullish()}),WI=p({_meta:_(h(),w()).nullish(),jump:MI.nullish(),rename:jI.nullish(),searchAndReplace:GI.nullish()}),qI=p({id:h(),isRegex:Ee().nullish(),replace:h(),search:h(),uri:h()}),YI=H([x("automatic"),x("diagnostic"),x("manual")]),KI=p({_meta:_(h(),w()).nullish(),maxCount:N().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish()}),JI=p({_meta:_(h(),w()).nullish(),diagnostics:CI.nullish(),editHistory:OI.nullish(),openFiles:NI.nullish(),recentFiles:FI.nullish(),relatedSnippets:VI.nullish(),userActions:KI.nullish()}),XI=p({_meta:_(h(),w()).nullish(),additionalDirectories:D(h()).optional(),cwd:h(),mcpServers:D(Ma)}),QI=p({default:N().nullish(),description:h().nullish(),maximum:N().nullish(),minimum:N().nullish(),title:h().nullish()}),km=h(),e1=H([x("allow_once"),x("allow_always"),x("reject_once"),x("reject_always")]),t1=p({_meta:_(h(),w()).nullish(),kind:e1,name:h(),optionId:km}),n1=H([x("high"),x("medium"),x("low")]),r1=H([x("pending"),x("in_progress"),x("completed")]),i1=p({_meta:_(h(),w()).nullish(),content:h(),priority:n1,status:r1}),s1=p({_meta:_(h(),w()).nullish(),entries:D(i1)}),mn=p({character:N().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}),line:N().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"})}),o1=p({id:h(),position:mn,uri:h()}),a1=p({id:h(),newName:h(),position:mn,uri:h()}),l1=p({action:h(),position:mn,timestampMs:N(),uri:h()}),Em=H([x("utf-16"),x("utf-32"),x("utf-8")]),c1=p({_meta:_(h(),w()).nullish(),auth:HC.optional().default({terminal:!1}),elicitation:dI.nullish(),fs:gI.optional().default({readTextFile:!1,writeTextFile:!1}),nes:WI.nullish(),positionEncodings:D(Em).optional(),terminal:Ee().optional().default(!1)}),u1=p({_meta:_(h(),w()).nullish(),audio:Ee().optional().default(!1),embeddedContext:Ee().optional().default(!1),image:Ee().optional().default(!1)}),$m=N().int().gte(0).lte(65535),h1=p({_meta:_(h(),w()).nullish(),clientCapabilities:c1.optional().default({auth:{terminal:!1},fs:{readTextFile:!1,writeTextFile:!1},terminal:!1}),clientInfo:Sm.nullish(),protocolVersion:$m}),pi=p({end:mn,start:mn}),d1=p({message:h(),range:pi,severity:TI,uri:h()}),f1=p({languageId:h(),lastFocusedMs:N().nullish(),uri:h(),visibleRange:pi.nullish()}),p1=p({_meta:_(h(),w()).nullish(),diagnostics:D(d1).nullish(),editHistory:D(zI).nullish(),openFiles:D(f1).nullish(),recentFiles:D(UI).nullish(),relatedSnippets:D(HI).nullish(),userActions:D(l1).nullish()}),g1=p({newText:h(),range:pi}),m1=p({cursorPosition:mn.nullish(),edits:D(g1),id:h(),uri:h()}),y1=H([m1.and(p({kind:x("edit")})),o1.and(p({kind:x("jump")})),a1.and(p({kind:x("rename")})),qI.and(p({kind:x("searchAndReplace")}))]),v1=p({_meta:_(h(),w()).nullish(),content:h()}),b1=p({_meta:_(h(),w()).nullish()}),nr=H([N(),h()]).nullable();p({_meta:_(h(),w()).nullish(),requestId:nr});const w1=ea(["assistant","user"]),Ys=p({_meta:_(h(),w()).nullish(),audience:D(w1).nullish(),lastModified:h().nullish(),priority:N().nullish()}),_1=p({_meta:_(h(),w()).nullish(),annotations:Ys.nullish(),data:h(),mimeType:h()}),S1=p({_meta:_(h(),w()).nullish(),annotations:Ys.nullish(),data:h(),mimeType:h(),uri:h().nullish()}),k1=p({_meta:_(h(),w()).nullish(),annotations:Ys.nullish(),description:h().nullish(),mimeType:h().nullish(),name:h(),size:N().nullish(),title:h().nullish(),uri:h()}),E1=p({_meta:_(h(),w()).nullish(),optionId:km}),$1=H([p({outcome:x("cancelled")}),E1.and(p({outcome:x("selected")}))]),A1=p({_meta:_(h(),w()).nullish(),outcome:$1}),x1=p({_meta:_(h(),w()).nullish()}),T1=p({_meta:_(h(),w()).nullish()}),C1=p({currentValue:Ee()}),I1=h(),Am=h(),P1=H([x("mode"),x("model"),x("thought_level"),h()]),Ou=h(),xm=p({_meta:_(h(),w()).nullish(),description:h().nullish(),name:h(),value:Ou}),R1=p({_meta:_(h(),w()).nullish(),group:I1,name:h(),options:D(xm)}),D1=H([D(xm),D(R1)]),O1=p({currentValue:Ou,options:D1}),gi=La(H([O1.and(p({type:x("select")})),C1.and(p({type:x("boolean")}))]),p({_meta:_(h(),w()).nullish(),category:P1.nullish(),description:h().nullish(),id:Am,name:h()})),z1=p({_meta:_(h(),w()).nullish(),configOptions:D(gi)}),L1=p({_meta:_(h(),w()).nullish()}),Y=h(),M1=p({_meta:_(h(),w()).nullish(),id:h(),sessionId:Y}),N1=p({_meta:_(h(),w()).nullish(),sessionId:Y}),U1=p({_meta:_(h(),w()).nullish(),sessionId:Y}),F1=p({_meta:_(h(),w()).nullish(),sessionId:Y}),Tm=p({_meta:_(h(),w()).nullish(),args:D(h()).optional(),command:h(),cwd:h().nullish(),env:D(mm).optional(),outputByteLimit:N().nullish(),sessionId:Y}),Z1=p({_meta:_(h(),w()).nullish(),sessionId:Y,uri:h()}),H1=p({_meta:_(h(),w()).nullish(),position:mn,sessionId:Y,uri:h(),version:N(),visibleRange:pi}),V1=p({_meta:_(h(),w()).nullish(),languageId:h(),sessionId:Y,text:h(),uri:h(),version:N()}),j1=p({_meta:_(h(),w()).nullish(),sessionId:Y,uri:h()}),B1=p({_meta:_(h(),w()).nullish(),additionalDirectories:D(h()).optional(),cwd:h(),mcpServers:D(Ma).optional(),sessionId:Y}),Cm=p({_meta:_(h(),w()).nullish(),sessionId:Y,terminalId:h()}),G1=p({_meta:_(h(),w()).nullish(),additionalDirectories:D(h()).optional(),cwd:h(),mcpServers:D(Ma),sessionId:Y}),Im=p({_meta:_(h(),w()).nullish(),limit:N().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),line:N().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),path:h(),sessionId:Y}),W1=p({_meta:_(h(),w()).nullish(),id:h(),reason:ZI.nullish(),sessionId:Y}),Pm=p({_meta:_(h(),w()).nullish(),sessionId:Y,terminalId:h()}),q1=p({_meta:_(h(),w()).nullish(),additionalDirectories:D(h()).optional(),cwd:h(),mcpServers:D(Ma).optional(),sessionId:Y}),Y1=p({_meta:_(h(),w()).nullish(),additionalDirectories:D(h()).optional(),cwd:h(),sessionId:Y,title:h().nullish(),updatedAt:h().nullish()}),K1=p({_meta:_(h(),w()).nullish(),nextCursor:h().nullish(),sessions:D(Y1)}),J1=p({_meta:_(h(),w()).nullish(),title:h().nullish(),updatedAt:h().nullish()}),X1=p({_meta:_(h(),w()).nullish()}),Na=h(),Q1=p({_meta:_(h(),w()).nullish(),currentModeId:Na}),eP=p({_meta:_(h(),w()).nullish(),description:h().nullish(),id:Na,name:h()}),Ua=p({_meta:_(h(),w()).nullish(),availableModes:D(eP),currentModeId:Na}),Fa=p({_meta:_(h(),w()).nullish(),availableModels:D(xI),currentModelId:Du}),tP=p({_meta:_(h(),w()).nullish(),configOptions:D(gi).nullish(),models:Fa.nullish(),modes:Ua.nullish(),sessionId:Y}),nP=p({_meta:_(h(),w()).nullish(),configOptions:D(gi).nullish(),models:Fa.nullish(),modes:Ua.nullish()}),rP=p({_meta:_(h(),w()).nullish(),configOptions:D(gi).nullish(),models:Fa.nullish(),modes:Ua.nullish(),sessionId:Y}),iP=p({_meta:_(h(),w()).nullish(),configOptions:D(gi).nullish(),models:Fa.nullish(),modes:Ua.nullish()}),sP=p({_meta:_(h(),w()).nullish()}),oP=p({_meta:_(h(),w()).nullish(),additionalDirectories:x1.nullish(),close:T1.nullish(),fork:L1.nullish(),list:X1.nullish(),resume:sP.nullish()}),aP=La(H([p({type:x("boolean"),value:Ee()}),p({value:Ou})]),p({_meta:_(h(),w()).nullish(),configId:Am,sessionId:Y})),lP=p({_meta:_(h(),w()).nullish(),configOptions:D(gi)}),cP=p({_meta:_(h(),w()).nullish(),modeId:Na,sessionId:Y}),uP=p({_meta:_(h(),w()).nullish()}),hP=p({_meta:_(h(),w()).nullish(),modelId:Du,sessionId:Y}),dP=p({_meta:_(h(),w()).nullish()}),fP=p({_meta:_(h(),w()).nullish(),sessionId:Y}),pP=H([x("end_turn"),x("max_tokens"),x("max_turn_requests"),x("refusal"),x("cancelled")]),gP=H([x("email"),x("uri"),x("date"),x("date-time")]),mP=p({default:h().nullish(),description:h().nullish(),enum:D(h()).nullish(),format:gP.nullish(),maxLength:N().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),minLength:N().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),oneOf:D(gm).nullish(),pattern:h().nullish(),title:h().nullish()}),yP=p({_meta:_(h(),w()).nullish(),context:p1.nullish(),position:mn,selection:pi.nullish(),sessionId:Y,triggerKind:YI,uri:h(),version:N()}),vP=p({_meta:_(h(),w()).nullish(),suggestions:D(y1)}),bP=p({_meta:_(h(),w()).nullish(),terminalId:h()}),wP=p({_meta:_(h(),w()).nullish(),exitCode:N().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),signal:h().nullish()}),Rm=p({_meta:_(h(),w()).nullish(),sessionId:Y,terminalId:h()}),_P=p({_meta:_(h(),w()).nullish(),exitStatus:wP.nullish(),output:h(),truncated:Ee()}),SP=p({_meta:_(h(),w()).nullish(),annotations:Ys.nullish(),text:h()}),kP=p({range:pi.nullish(),text:h()}),EP=p({_meta:_(h(),w()).nullish(),contentChanges:D(kP),sessionId:Y,uri:h(),version:N()});p({method:h(),params:H([N1,V1,EP,Z1,j1,H1,M1,W1,vm]).nullish()});const $P=H([x("full"),x("incremental")]),AP=p({_meta:_(h(),w()).nullish(),syncKind:$P}),xP=p({_meta:_(h(),w()).nullish(),didChange:AP.nullish(),didClose:II.nullish(),didFocus:PI.nullish(),didOpen:RI.nullish(),didSave:DI.nullish()}),TP=p({_meta:_(h(),w()).nullish(),document:xP.nullish()}),CP=p({_meta:_(h(),w()).nullish(),context:JI.nullish(),events:TP.nullish()}),IP=p({_meta:_(h(),w()).nullish(),auth:wI.optional().default({}),loadSession:Ee().optional().default(!1),mcpCapabilities:kI.optional().default({http:!1,sse:!1}),nes:CP.nullish(),positionEncoding:Em.nullish(),promptCapabilities:u1.optional().default({audio:!1,embeddedContext:!1,image:!1}),sessionCapabilities:oP.optional().default({})}),PP=p({_meta:_(h(),w()).nullish(),agentCapabilities:IP.optional().default({auth:{},loadSession:!1,mcpCapabilities:{http:!1,sse:!1},promptCapabilities:{audio:!1,embeddedContext:!1,image:!1},sessionCapabilities:{}}),agentInfo:Sm.nullish(),authMethods:D(WC).optional().default([]),protocolVersion:$m}),RP=p({_meta:_(h(),w()).nullish(),mimeType:h().nullish(),text:h(),uri:h()}),DP=H([RP,KC]),OP=p({_meta:_(h(),w()).nullish(),annotations:Ys.nullish(),resource:DP}),zu=H([SP.and(p({type:x("text")})),S1.and(p({type:x("image")})),_1.and(p({type:x("audio")})),k1.and(p({type:x("resource_link")})),OP.and(p({type:x("resource")}))]),zP=p({_meta:_(h(),w()).nullish(),content:zu}),Dl=p({_meta:_(h(),w()).nullish(),content:zu,messageId:h().nullish()}),LP=p({_meta:_(h(),w()).nullish(),messageId:h().nullish(),prompt:D(zu),sessionId:Y}),MP=p({anyOf:D(gm)}),Dm=H([zP.and(p({type:x("content")})),nI.and(p({type:x("diff")})),bP.and(p({type:x("terminal")}))]),Om=h(),zm=p({_meta:_(h(),w()).nullish(),line:N().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),path:h()}),Lm=H([x("pending"),x("in_progress"),x("completed"),x("failed")]),Mm=H([x("read"),x("edit"),x("delete"),x("move"),x("search"),x("execute"),x("think"),x("fetch"),x("switch_mode"),x("other")]),NP=p({_meta:_(h(),w()).nullish(),content:D(Dm).optional(),kind:Mm.optional(),locations:D(zm).optional(),rawInput:w().optional(),rawOutput:w().optional(),status:Lm.optional(),title:h(),toolCallId:Om}),Nm=p({_meta:_(h(),w()).nullish(),content:D(Dm).nullish(),kind:Mm.nullish(),locations:D(zm).nullish(),rawInput:w().optional(),rawOutput:w().optional(),status:Lm.nullish(),title:h().nullish(),toolCallId:Om}),Um=p({_meta:_(h(),w()).nullish(),options:D(t1),sessionId:Y,toolCall:Nm}),UP=p({_meta:_(h(),w()).nullish(),hint:h()}),FP=UP,ZP=p({_meta:_(h(),w()).nullish(),description:h(),input:FP.nullish(),name:h()}),HP=p({_meta:_(h(),w()).nullish(),availableCommands:D(ZP)}),VP=p({enum:D(h()),type:uI}),jP=H([VP,MP]),BP=p({default:D(h()).nullish(),description:h().nullish(),items:jP,maxItems:N().nullish(),minItems:N().nullish(),title:h().nullish()}),GP=H([mP.and(p({type:x("string")})),QI.and(p({type:x("number")})),mI.and(p({type:x("integer")})),JC.and(p({type:x("boolean")})),BP.and(p({type:x("array")}))]),WP=p({description:h().nullish(),properties:_(h(),GP).optional().default({}),required:D(h()).nullish(),title:h().nullish(),type:cI.optional().default("object")}),qP=p({requestedSchema:WP}),YP=La(H([qP.and(p({mode:x("form")})),fI.and(p({mode:x("url")}))]),p({_meta:_(h(),w()).nullish(),message:h(),sessionId:Y})),KP=p({cachedReadTokens:N().nullish(),cachedWriteTokens:N().nullish(),inputTokens:N(),outputTokens:N(),thoughtTokens:N().nullish(),totalTokens:N()}),JP=p({_meta:_(h(),w()).nullish(),stopReason:pP,usage:KP.nullish(),userMessageId:h().nullish()});H([p({id:nr,result:H([PP,YC,SI,rP,nP,K1,tP,iP,QC,uP,lP,JP,dP,fP,vP,XC,wm])}),p({error:ym,id:nr})]);const XP=p({_meta:_(h(),w()).nullish(),cost:eI.nullish(),size:N(),used:N()}),QP=H([Dl.and(p({sessionUpdate:x("user_message_chunk")})),Dl.and(p({sessionUpdate:x("agent_message_chunk")})),Dl.and(p({sessionUpdate:x("agent_thought_chunk")})),NP.and(p({sessionUpdate:x("tool_call")})),Nm.and(p({sessionUpdate:x("tool_call_update")})),s1.and(p({sessionUpdate:x("plan")})),HP.and(p({sessionUpdate:x("available_commands_update")})),Q1.and(p({sessionUpdate:x("current_mode_update")})),z1.and(p({sessionUpdate:x("config_option_update")})),J1.and(p({sessionUpdate:x("session_info_update")})),XP.and(p({sessionUpdate:x("usage_update")}))]),Fm=p({_meta:_(h(),w()).nullish(),sessionId:Y,update:QP});p({method:h(),params:H([Fm,aI,vm]).nullish()});const Zm=p({_meta:_(h(),w()).nullish(),sessionId:Y,terminalId:h()}),eR=p({_meta:_(h(),w()).nullish(),exitCode:N().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),signal:h().nullish()}),tR=p({name:h(),uri:h()}),nR=p({_meta:_(h(),w()).nullish(),repository:BI.nullish(),workspaceFolders:D(tR).nullish(),workspaceUri:h().nullish()});p({id:nr,method:h(),params:H([h1,qC,_I,XI,G1,vI,B1,q1,F1,cP,aP,LP,hP,nR,yP,U1,bm]).nullish()});const Hm=p({_meta:_(h(),w()).nullish(),content:h(),path:h(),sessionId:Y});p({id:nr,method:h(),params:H([Hm,Im,Um,Tm,Rm,Pm,Zm,Cm,YP,bm]).nullish()});const rR=p({_meta:_(h(),w()).nullish()});H([p({id:nr,result:H([rR,v1,A1,tI,_P,b1,eR,yI,lI,wm])}),p({error:ym,id:nr})]);var q;class iR{constructor(e,t){S(this,q);const r=e(this),i=async(o,a)=>{var l,u,d,f,v,y,A;switch(o){case Dt.fs_write_text_file:{const k=Hm.parse(a);return(l=r.writeTextFile)==null?void 0:l.call(r,k)}case Dt.fs_read_text_file:{const k=Im.parse(a);return(u=r.readTextFile)==null?void 0:u.call(r,k)}case Dt.session_request_permission:{const k=Um.parse(a);return r.requestPermission(k)}case Dt.terminal_create:{const k=Tm.parse(a);return(d=r.createTerminal)==null?void 0:d.call(r,k)}case Dt.terminal_output:{const k=Rm.parse(a);return(f=r.terminalOutput)==null?void 0:f.call(r,k)}case Dt.terminal_release:{const k=Pm.parse(a);return await((v=r.releaseTerminal)==null?void 0:v.call(r,k))??{}}case Dt.terminal_wait_for_exit:{const k=Zm.parse(a);return(y=r.waitForTerminalExit)==null?void 0:y.call(r,k)}case Dt.terminal_kill:{const k=Cm.parse(a);return await((A=r.killTerminal)==null?void 0:A.call(r,k))??{}}default:if(r.extMethod)return r.extMethod(o,a);throw we.methodNotFound(o)}},s=async(o,a)=>{switch(o){case Dt.session_update:{const l=Fm.parse(a);return r.sessionUpdate(l)}default:if(r.extNotification)return r.extNotification(o,a);throw we.methodNotFound(o)}};E(this,q,new sR(i,s,t))}async initialize(e){return await c(this,q).sendRequest(se.initialize,e)}async newSession(e){return await c(this,q).sendRequest(se.session_new,e)}async loadSession(e){return await c(this,q).sendRequest(se.session_load,e)??{}}async unstable_forkSession(e){return await c(this,q).sendRequest(se.session_fork,e)}async listSessions(e){return await c(this,q).sendRequest(se.session_list,e)}async unstable_resumeSession(e){return await c(this,q).sendRequest(se.session_resume,e)}async unstable_closeSession(e){return await c(this,q).sendRequest(se.session_close,e)}async setSessionMode(e){return await c(this,q).sendRequest(se.session_set_mode,e)??{}}async unstable_setSessionModel(e){return await c(this,q).sendRequest(se.session_set_model,e)??{}}async setSessionConfigOption(e){return await c(this,q).sendRequest(se.session_set_config_option,e)}async authenticate(e){return await c(this,q).sendRequest(se.authenticate,e)??{}}async unstable_logout(e){return await c(this,q).sendRequest(se.logout,e)??{}}async prompt(e){return await c(this,q).sendRequest(se.session_prompt,e)}async cancel(e){return await c(this,q).sendNotification(se.session_cancel,e)}async unstable_startNes(e){return await c(this,q).sendRequest(se.nes_start,e)}async unstable_suggestNes(e){return await c(this,q).sendRequest(se.nes_suggest,e)}async unstable_closeNes(e){return await c(this,q).sendRequest(se.nes_close,e)??{}}async unstable_didOpenDocument(e){return await c(this,q).sendNotification(se.document_did_open,e)}async unstable_didChangeDocument(e){return await c(this,q).sendNotification(se.document_did_change,e)}async unstable_didCloseDocument(e){return await c(this,q).sendNotification(se.document_did_close,e)}async unstable_didSaveDocument(e){return await c(this,q).sendNotification(se.document_did_save,e)}async unstable_didFocusDocument(e){return await c(this,q).sendNotification(se.document_did_focus,e)}async unstable_acceptNes(e){return await c(this,q).sendNotification(se.nes_accept,e)}async unstable_rejectNes(e){return await c(this,q).sendNotification(se.nes_reject,e)}async extMethod(e,t){return await c(this,q).sendRequest(e,t)}async extNotification(e,t){return await c(this,q).sendNotification(e,t)}get signal(){return c(this,q).signal}get closed(){return c(this,q).closed}}q=new WeakMap;var sn,ca,ls,cs,Or,zr,St,us,ue,Vm,gc,jm,Bm,Gm,Wm,mc,Li;class sR{constructor(e,t,r){S(this,ue);S(this,sn,new Map);S(this,ca,0);S(this,ls);S(this,cs);S(this,Or);S(this,zr,Promise.resolve());S(this,St,new AbortController);S(this,us);E(this,ls,e),E(this,cs,t),E(this,Or,r),E(this,us,new Promise(i=>{c(this,St).signal.addEventListener("abort",()=>i())})),m(this,ue,Vm).call(this)}get signal(){return c(this,St).signal}get closed(){return c(this,us)}async sendRequest(e,t){m(this,ue,mc).call(this);const r=kh(this,ca)._++,i=new Promise((s,o)=>{c(this,sn).set(r,{resolve:s,reject:o})});return await m(this,ue,Li).call(this,{jsonrpc:"2.0",id:r,method:e,params:t}),i}async sendNotification(e,t){m(this,ue,mc).call(this),await m(this,ue,Li).call(this,{jsonrpc:"2.0",method:e,params:t})}}sn=new WeakMap,ca=new WeakMap,ls=new WeakMap,cs=new WeakMap,Or=new WeakMap,zr=new WeakMap,St=new WeakMap,us=new WeakMap,ue=new WeakSet,Vm=async function(){let e;try{const t=c(this,Or).readable.getReader();try{for(;!c(this,St).signal.aborted;){const{value:r,done:i}=await t.read();if(i)break;if(r)try{m(this,ue,jm).call(this,r)}catch(s){console.error("Unexpected error during message processing:",r,s),"id"in r&&r.id!==void 0&&m(this,ue,Li).call(this,{jsonrpc:"2.0",id:r.id,error:{code:-32700,message:"Parse error"}})}}}finally{t.releaseLock()}}catch(t){e=t}finally{m(this,ue,gc).call(this,e)}},gc=function(e){if(c(this,St).signal.aborted)return;const t=e??new Error("ACP connection closed");for(const r of c(this,sn).values())r.reject(t);c(this,sn).clear(),c(this,St).abort(t)},jm=async function(e){if("method"in e&&"id"in e){const t=await m(this,ue,Bm).call(this,e.method,e.params);"error"in t&&console.error("Error handling request",e,t.error),await m(this,ue,Li).call(this,{jsonrpc:"2.0",id:e.id,...t})}else if("method"in e){const t=await m(this,ue,Gm).call(this,e.method,e.params);"error"in t&&console.error("Error handling notification",e,t.error)}else"id"in e?m(this,ue,Wm).call(this,e):console.error("Invalid message",{message:e})},Bm=async function(e,t){try{return{result:await c(this,ls).call(this,e,t)??null}}catch(r){if(r instanceof we)return r.toResult();if(r instanceof mf)return we.invalidParams(r.format()).toResult();let i;(r instanceof Error||typeof r=="object"&&r!=null&&"message"in r&&typeof r.message=="string")&&(i=r.message);try{return we.internalError(i?JSON.parse(i):{}).toResult()}catch{return we.internalError({details:i}).toResult()}}},Gm=async function(e,t){try{return await c(this,cs).call(this,e,t),{result:null}}catch(r){if(r instanceof we)return r.toResult();if(r instanceof mf)return we.invalidParams(r.format()).toResult();let i;(r instanceof Error||typeof r=="object"&&r!=null&&"message"in r&&typeof r.message=="string")&&(i=r.message);try{return we.internalError(i?JSON.parse(i):{}).toResult()}catch{return we.internalError({details:i}).toResult()}}},Wm=function(e){const t=c(this,sn).get(e.id);if(t){if("result"in e)t.resolve(e.result);else if("error"in e){const{code:r,message:i,data:s}=e.error;t.reject(new we(r,i,s))}c(this,sn).delete(e.id)}else console.error("Got response to unknown request",e.id)},mc=function(){if(c(this,St).signal.aborted)throw c(this,St).signal.reason??new Error("ACP connection closed")},Li=async function(e){return E(this,zr,c(this,zr).then(async()=>{const t=c(this,Or).writable.getWriter();try{await t.write(e)}finally{t.releaseLock()}}).catch(t=>{m(this,ue,gc).call(this,t)})),c(this,zr)};class we extends Error{constructor(t,r,i){super(r);b(this,"code");b(this,"data");this.code=t,this.name="RequestError",this.data=i}static parseError(t,r){return new we(-32700,`Parse error${r?`: ${r}`:""}`,t)}static invalidRequest(t,r){return new we(-32600,`Invalid request${r?`: ${r}`:""}`,t)}static methodNotFound(t){return new we(-32601,`"Method not found": ${t}`,{method:t})}static invalidParams(t,r){return new we(-32602,`Invalid params${r?`: ${r}`:""}`,t)}static internalError(t,r){return new we(-32603,`Internal error${r?`: ${r}`:""}`,t)}static authRequired(t,r){return new we(-32e3,`Authentication required${r?`: ${r}`:""}`,t)}static resourceNotFound(t){return new we(-32002,`Resource not found${t?`: ${t}`:""}`,t&&{uri:t})}toResult(){return{error:{code:this.code,message:this.message,data:this.data}}}toErrorResponse(){return{code:this.code,message:this.message,data:this.data}}}const oR=/^Sender \(untrusted metadata\):\n```json\n[\s\S]*?\n```\n\n?/,aR=/^\[[^\n]*Working directory:[^\n]*\]\n\n?/,lR=/\[Television screen context\][\s\S]*?\[\/Television screen context\]\n*/,cR=/\[\[\s*(?:reply_to_current|reply_to\s*:\s*[^\]\n]+|audio_as_voice)\s*\]\]\s*/gi,uR="single_session",hR={name:"television-acp-client",version:"0.0.0"},qm="agent:main:television",dR=di(Tt);var ee,Nt,Lr,Ut,Hn,Vn,on,Mr,kt,lt,an,jn,Ft,ln,hs,Zt,ct,ua,Ht,C,Ym,Km,yc,Jm,Xm,Qm,ey,ty,ny,ry,Tn,kr,Er,We,iy,$r,vc,bc,Mo,sy,ds,fs,wc,Ar,oy,ay;class fR extends dR{constructor(t){super();S(this,C);S(this,ee,pR());S(this,Nt,null);S(this,Lr,null);S(this,Ut,null);S(this,Hn,null);S(this,Vn,null);S(this,on,null);S(this,Mr,1);S(this,kt,null);S(this,lt,null);S(this,an,!1);S(this,jn,!1);S(this,Ft,null);S(this,ln,new Set);S(this,hs);S(this,Zt);S(this,ct);S(this,ua,t=>{m(this,C,Km).call(this,t)});S(this,Ht,null);S(this,ds,()=>{m(this,C,Ar).call(this,"ACP bridge websocket closed")});S(this,fs,()=>{m(this,C,Ar).call(this,"ACP bridge websocket error")});E(this,Zt,t),E(this,ct,t.sessionMode??uR),E(this,hs,t.createSocket??(r=>new WebSocket(r)))}getState(){return c(this,ee)}get messages(){return c(this,ee).messageOrder.map(t=>c(this,ee).messagesById[t]).filter(t=>t!==void 0)}async connect(){if(this.disposed)throw new Error("ACPClient has been disposed");if(c(this,ee).lifecycle.status!=="ready"){m(this,C,We).call(this,{lifecycle:{status:"connecting"}}),c(this,Lr)??E(this,Lr,m(this,C,Ym).call(this));try{await c(this,Lr),await m(this,C,yc).call(this)}catch(t){throw m(this,C,Ar).call(this,bo(t)),t}}}dispose(){m(this,C,wc).call(this),m(this,C,We).call(this,{lifecycle:{status:"disposed"},run:{status:"idle",stopReason:null,canCancel:!1,error:null}})}async sendMessage(t){if(await this.connect(),c(this,ee).lifecycle.status!=="ready"||c(this,ee).run.status==="running"||c(this,ee).run.status==="cancelling")throw new Error("ACPClient is not ready to send a new message");const r=t.text.trim();if(!r)throw new Error("Cannot send an empty message");m(this,C,kr).call(this,{id:m(this,C,$r).call(this,"user"),kind:"user",text:r,status:"final"}),m(this,C,We).call(this,{run:{status:"running",stopReason:null,canCancel:!0,error:null}});try{const i=await m(this,C,Mo).call(this).prompt({sessionId:m(this,C,bc).call(this),prompt:[{type:"text",text:m(this,C,iy).call(this,r)}]});m(this,C,Tn).call(this,i.stopReason==="cancelled"?"cancelled":"final"),m(this,C,We).call(this,{run:{status:i.stopReason==="cancelled"?"cancelled":"completed",stopReason:i.stopReason,canCancel:!1,error:null}})}catch(i){throw m(this,C,ay).call(this)||(m(this,C,Tn).call(this,"error"),m(this,C,We).call(this,{run:{status:"error",stopReason:null,canCancel:!1,error:bo(i)}})),i}}async cancel(){if(await this.connect(),!c(this,ee).run.canCancel||c(this,ee).run.status!=="running")throw new Error("No active cancellable run");m(this,C,We).call(this,{run:{...c(this,ee).run,status:"cancelling"}}),await m(this,C,Mo).call(this).cancel({sessionId:m(this,C,bc).call(this)})}setScreenContext(t){var s,o,a;const r={screenID:t.screenID,screenName:t.screenName};if(((s=c(this,lt))==null?void 0:s.screenID)===r.screenID&&((o=c(this,lt))==null?void 0:o.screenName)===r.screenName)return;const i=((a=c(this,lt))==null?void 0:a.screenID)??null;if(E(this,lt,r),c(this,ct)==="single_session"){(!c(this,on)||i!==r.screenID)&&E(this,an,!0);return}c(this,on)!==Sf(c(this,ct),r.screenID,c(this,Zt).clientGUID??"default-client")&&(E(this,Ut,null),E(this,Hn,null),c(this,Nt)&&c(this,ee).run.status==="idle"&&m(this,C,yc).call(this).catch(l=>{m(this,C,Ar).call(this,bo(l))}))}}ee=new WeakMap,Nt=new WeakMap,Lr=new WeakMap,Ut=new WeakMap,Hn=new WeakMap,Vn=new WeakMap,on=new WeakMap,Mr=new WeakMap,kt=new WeakMap,lt=new WeakMap,an=new WeakMap,jn=new WeakMap,Ft=new WeakMap,ln=new WeakMap,hs=new WeakMap,Zt=new WeakMap,ct=new WeakMap,ua=new WeakMap,Ht=new WeakMap,C=new WeakSet,Ym=async function(){try{m(this,C,We).call(this,{lifecycle:{status:"connecting"}});const{stream:t,socket:r}=await yR({serverURL:c(this,Zt).serverURL,token:c(this,Zt).token,createSocket:c(this,hs),onDisconnect:c(this,ua)});E(this,Ht,r),r.addEventListener("close",c(this,ds)),r.addEventListener("error",c(this,fs)),E(this,Nt,new iR(i=>({connection:i,sessionUpdate:async s=>{await m(this,C,Xm).call(this,s)},requestPermission:async s=>m(this,C,Qm).call(this,s)}),t)),await c(this,Nt).initialize({protocolVersion:ZC,clientCapabilities:{},clientInfo:hR})}catch(t){throw t}},Km=function(t){m(this,C,Ar).call(this,bo(t))},yc=async function(){const t=m(this,C,sy).call(this);if(c(this,Ut)&&c(this,Hn)===t){await c(this,Ut);return}E(this,Hn,t),E(this,Ut,m(this,C,Jm).call(this,t)),await c(this,Ut)},Jm=async function(t){const r=m(this,C,Mo).call(this);m(this,C,oy).call(this);let i,s=!1;try{E(this,jn,!0),E(this,Ft,null),await r.loadSession({sessionId:t,cwd:"/",mcpServers:[],_meta:{sessionKey:t}}),i=t,s=c(this,ee).messageOrder.length>0}catch{i=(await r.newSession({cwd:"/",mcpServers:[],_meta:{sessionKey:t}})).sessionId,s=!1}finally{E(this,jn,!1),E(this,Ft,null),m(this,C,Tn).call(this,"final")}await r.setSessionConfigOption({sessionId:i,configId:"verbose_level",value:"full"}),E(this,Vn,i),E(this,on,t),s?(c(this,ln).add(t),c(this,ct)==="single_session"&&E(this,an,!1)):(c(this,ln).delete(t),E(this,an,c(this,ct)==="single_session")),m(this,C,We).call(this,{lifecycle:{status:"ready"}})},Xm=async function(t){const r=t.update;switch(r.sessionUpdate){case"user_message_chunk":r.content.type==="text"&&m(this,C,ry).call(this,r.content.text);return;case"agent_message_chunk":r.content.type==="text"&&m(this,C,ey).call(this,r.content.text);return;case"tool_call":m(this,C,ty).call(this,r);return;case"tool_call_update":m(this,C,ny).call(this,r);return;case"agent_thought_chunk":return;default:return}},Qm=async function(t){return{outcome:{outcome:"cancelled"}}},ey=function(t){E(this,Ft,null);const r=gR(t);if(!r)return;if(!c(this,kt)){const s={id:m(this,C,$r).call(this,"assistant"),kind:"assistant",text:r,status:"streaming"};E(this,kt,s.id),m(this,C,kr).call(this,s);return}const i=c(this,ee).messagesById[c(this,kt)];if(!i||i.kind!=="assistant")throw new Error("Open assistant message invariant violated");m(this,C,Er).call(this,{...i,text:`${i.text}${r}`,status:"streaming"})},ty=function(t){m(this,C,Tn).call(this,"final");const r=m(this,C,vc).call(this,t.toolCallId),i={id:(r==null?void 0:r.id)??m(this,C,$r).call(this,"tool"),kind:"tool_call",toolCallId:t.toolCallId,title:t.title,toolKind:t.kind??"other",status:t.status==="failed"?"failed":t.status==="completed"?"completed":"in_progress",text:(r==null?void 0:r.text)??"",locations:t.locations??(r==null?void 0:r.locations)};if(r){m(this,C,Er).call(this,i);return}m(this,C,kr).call(this,i)},ny=function(t){const r=m(this,C,vc).call(this,t.toolCallId),i=(r==null?void 0:r.text)??"",s=mR(t.content),o=s?`${i}${s}`:i,a={id:(r==null?void 0:r.id)??m(this,C,$r).call(this,"tool"),kind:"tool_call",toolCallId:t.toolCallId,title:(r==null?void 0:r.title)??t.toolCallId,toolKind:(r==null?void 0:r.toolKind)??"other",status:t.status==="failed"?"failed":t.status==="completed"?"completed":"in_progress",text:o,locations:t.locations??(r==null?void 0:r.locations)};if(r){m(this,C,Er).call(this,a);return}m(this,C,kr).call(this,a)},ry=function(t){if(m(this,C,Tn).call(this,"final"),!t)return;const r=c(this,jn)?c(this,Ft):null;if(!r){const s=kf(t);if(!s)return;const o={id:m(this,C,$r).call(this,"user"),kind:"user",text:s,status:"final"};m(this,C,kr).call(this,o),c(this,jn)&&E(this,Ft,o.id);return}const i=c(this,ee).messagesById[r];if(!i||i.kind!=="user")throw new Error("Replay user message invariant violated");m(this,C,Er).call(this,{...i,text:kf(`${i.text}${t}`)})},Tn=function(t){if(!c(this,kt))return;const r=c(this,ee).messagesById[c(this,kt)];(r==null?void 0:r.kind)==="assistant"&&m(this,C,Er).call(this,{...r,status:t}),E(this,kt,null)},kr=function(t){m(this,C,We).call(this,{messagesById:{...c(this,ee).messagesById,[t.id]:t},messageOrder:[...c(this,ee).messageOrder,t.id]})},Er=function(t){m(this,C,We).call(this,{messagesById:{...c(this,ee).messagesById,[t.id]:t}})},We=function(t){const r={...c(this,ee),...t};E(this,ee,{...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 Q("change"))},iy=function(t){const r=c(this,on);return!c(this,lt)||!r||!(c(this,ct)==="single_session"?c(this,an)||!c(this,ln).has(r):!c(this,ln).has(r))?t:(E(this,an,!1),c(this,ln).add(r),["[Television screen context]","This chat session is coming from a Television client in the screen below.",`screen_id: ${c(this,lt).screenID}`,`screen_name: ${c(this,lt).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]","",t].join(`
43
- `))},$r=function(t){const r=`${t}-${c(this,Mr)}`;return E(this,Mr,c(this,Mr)+1),r},vc=function(t){for(const r of c(this,ee).messageOrder){const i=c(this,ee).messagesById[r];if((i==null?void 0:i.kind)==="tool_call"&&i.toolCallId===t)return i}return null},bc=function(){if(!c(this,Vn))throw new Error("ACP session is not ready");return c(this,Vn)},Mo=function(){if(!c(this,Nt))throw new Error("ACP connection is not ready");return c(this,Nt)},sy=function(){var r;if(c(this,ct)==="single_session")return`${qm}-${(c(this,Zt).clientGUID??"default-client").toLowerCase()}`;const t=(r=c(this,lt))==null?void 0:r.screenID;if(!t)throw new Error("Screen context is required for per-screen session mode");return Sf(c(this,ct),t,c(this,Zt).clientGUID??"default-client")},ds=new WeakMap,fs=new WeakMap,wc=function(){E(this,Nt,null),E(this,Lr,null),E(this,Ut,null),E(this,Hn,null),E(this,Vn,null),E(this,on,null),c(this,Ht)&&(c(this,Ht).removeEventListener("close",c(this,ds)),c(this,Ht).removeEventListener("error",c(this,fs)),c(this,Ht).close(),E(this,Ht,null))},Ar=function(t){this.disposed||c(this,ee).lifecycle.status==="disconnected"||(m(this,C,Tn).call(this,"error"),m(this,C,wc).call(this),m(this,C,We).call(this,{lifecycle:{status:"disconnected",...t?{error:t}:{}},run:{status:"idle",stopReason:null,canCancel:!1,error:null}}))},oy=function(){E(this,kt,null),E(this,Ft,null),E(this,Mr,1),m(this,C,We).call(this,{run:{status:"idle",stopReason:null,canCancel:!1,error:null},messagesById:{},messageOrder:[]})},ay=function(){return c(this,ee).lifecycle.status==="disconnected"};function pR(){return{lifecycle:{status:"connecting"},run:{status:"idle",stopReason:null,canCancel:!1,error:null},messagesById:{},messageOrder:[],sendDisabled:!0,cancelDisabled:!0}}function Sf(n,e,t){return n==="single_session"?`${qm}-${t.toLowerCase()}`:`agent:main:television-${t.toLowerCase()}-${e.toLowerCase()}`}function ly(n){return n.replace(/^(?:\s*\n)+/,"")}function kf(n){let e=n;return e=e.replace(oR,""),e=e.replace(aR,""),e=e.replace(lR,""),e=ly(e),e}function gR(n){let e=n;return e=e.replace(cR,""),e=ly(e),e}function mR(n){return!n||n.length===0?"":n.flatMap(e=>e.type==="content"&&e.content.type==="text"?[e.content.text]:[]).join("")}async function yR(n){const e=n.createSocket(bR(n.serverURL,n.token));let t=!1,r,i;const s=new Promise((l,u)=>{r=l,i=u}),o=new ReadableStream({start(l){let u=!1;const d=()=>{e.send(JSON.stringify({type:"acp-bridge-connect"}))},f=A=>{const k=vR(A);if(!k)return;let I;try{I=JSON.parse(k)}catch(B){const P=B instanceof Error?B:new Error(String(B));i(P),l.error(P);return}switch(I.type){case"acp-bridge-status":if(I.status==="ready"){t||(t=!0,r());return}if(I.status==="error"||I.status==="exited"){const B=new Error(I.error??`ACP bridge ${I.status}`);t||i(B),l.error(B)}return;case"acp-bridge-message":l.enqueue(I.message);return}},v=()=>{var k;if(u)return;u=!0;const A=new Error("ACP bridge websocket closed");t||i(A),(k=n.onDisconnect)==null||k.call(n,A),l.close()},y=()=>{var k;if(u)return;u=!0;const A=new Error("ACP bridge websocket error");t||i(A),(k=n.onDisconnect)==null||k.call(n,A),l.error(A)};e.addEventListener("open",d),e.addEventListener("message",f),e.addEventListener("close",v),e.addEventListener("error",y)}}),a=new WritableStream({async write(l){await s,e.send(JSON.stringify({type:"acp-bridge-message",message:l}))},close(){e.close()},abort(){e.close()}});return await s,{stream:{readable:o,writable:a},socket:e}}function vR(n){if(typeof n=="string")return n;if(n instanceof Uint8Array)return new TextDecoder().decode(n);if(typeof Buffer<"u"&&n instanceof Buffer)return n.toString("utf8");if(typeof n=="object"&&n!==null&&"data"in n){const e=n.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 bR(n,e){const t=new URL(n);return t.protocol=t.protocol==="https:"?"wss:":"ws:",t.pathname="/acp",t.search="",t.searchParams.set("token",e),t.hash="",t.toString()}function bo(n){return n instanceof Error?n.message:String(n)}const Ef="television.acpClientGUID",wR=di(Tt);class _R extends wR{constructor(t){super();b(this,"screenManager");b(this,"clients",new Map);b(this,"options");b(this,"sessionMode");b(this,"clientGUID");b(this,"activeClient",null);b(this,"handleActiveScreenChanged",()=>{this.syncActiveClient()});this.screenManager=t.screenManager,this.sessionMode=t.sessionMode??"single_session",this.options={serverURL:t.serverURL,token:t.token,...t.createSocket?{createSocket:t.createSocket}:{},...t.sessionMode?{sessionMode:t.sessionMode}:{}},this.clientGUID=t.clientGUID??SR(t.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 t of this.clients.values())t.dispose();this.clients.clear(),this.activeClient=null}syncActiveClient(){const t=this.screenManager.activeScreen,r=t?this.getClientForScreen(t):null;this.activeClient!==r&&(this.activeClient=r,this.dispatchEvent(new Q("change")))}getClientForScreen(t){const r=this.sessionMode==="single_session"?"single_session":t.id;let i=this.clients.get(r);return i||(i=new fR({...this.options,sessionMode:this.sessionMode,clientGUID:this.clientGUID}),this.clients.set(r,i)),i.setScreenContext({screenID:t.id,screenName:t.name}),i}}function SR(n){const e=n.getItem(Ef);if(e)return e;const t=Su().toLowerCase();return n.setItem(Ef,t),t}const kR="serverURL",ER="token",$R="mode",AR="electron";function cy(n=window.location.search,e=window.location.origin){const r=new URLSearchParams(n).get(kR);return r?new URL(r).origin:new URL(e).origin}function uy(n=window.location.search){return new URLSearchParams(n).get(ER)}function hy(n=window.location.search){return new URLSearchParams(n).get($R)===AR}/**
42
+ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(const d of n.seen.entries()){const f=d[1];if(e===d[0]){s(d);continue}if(n.external){const y=(l=n.external.registry.get(d[0]))==null?void 0:l.id;if(e!==d[0]&&y){s(d);continue}}if((u=n.metadataRegistry.get(d[0]))==null?void 0:u.id){s(d);continue}if(f.cycle){s(d);continue}if(f.count>1&&n.reused==="ref"){s(d);continue}}}function rm(n,e){var o,a,l;const t=n.seen.get(e);if(!t)throw new Error("Unprocessed schema. This is a bug in Zod.");const r=u=>{const d=n.seen.get(u);if(d.ref===null)return;const f=d.def??d.schema,v={...f},y=d.ref;if(d.ref=null,y){r(y);const k=n.seen.get(y),I=k.schema;if(I.$ref&&(n.target==="draft-07"||n.target==="draft-04"||n.target==="openapi-3.0")?(f.allOf=f.allOf??[],f.allOf.push(I)):Object.assign(f,I),Object.assign(f,v),u._zod.parent===y)for(const P in f)P==="$ref"||P==="allOf"||P in v||delete f[P];if(I.$ref&&k.def)for(const P in f)P==="$ref"||P==="allOf"||P in k.def&&JSON.stringify(f[P])===JSON.stringify(k.def[P])&&delete f[P]}const A=u._zod.parent;if(A&&A!==y){r(A);const k=n.seen.get(A);if(k!=null&&k.schema.$ref&&(f.$ref=k.schema.$ref,k.def))for(const I in f)I==="$ref"||I==="allOf"||I in k.def&&JSON.stringify(f[I])===JSON.stringify(k.def[I])&&delete f[I]}n.override({zodSchema:u,jsonSchema:f,path:d.path??[]})};for(const u of[...n.seen.entries()].reverse())r(u[0]);const i={};if(n.target==="draft-2020-12"?i.$schema="https://json-schema.org/draft/2020-12/schema":n.target==="draft-07"?i.$schema="http://json-schema.org/draft-07/schema#":n.target==="draft-04"?i.$schema="http://json-schema.org/draft-04/schema#":n.target,(o=n.external)!=null&&o.uri){const u=(a=n.external.registry.get(e))==null?void 0:a.id;if(!u)throw new Error("Schema is missing an `id` property");i.$id=n.external.uri(u)}Object.assign(i,t.def??t.schema);const s=((l=n.external)==null?void 0:l.defs)??{};for(const u of n.seen.entries()){const d=u[1];d.def&&d.defId&&(s[d.defId]=d.def)}n.external||Object.keys(s).length>0&&(n.target==="draft-2020-12"?i.$defs=s:i.definitions=s);try{const u=JSON.parse(JSON.stringify(i));return Object.defineProperty(u,"~standard",{value:{...e["~standard"],jsonSchema:{input:Qo(e,"input",n.processors),output:Qo(e,"output",n.processors)}},enumerable:!1,writable:!1}),u}catch{throw new Error("Error converting schema to JSON.")}}function Oe(n,e){const t=e??{seen:new Set};if(t.seen.has(n))return!1;t.seen.add(n);const r=n._zod.def;if(r.type==="transform")return!0;if(r.type==="array")return Oe(r.element,t);if(r.type==="set")return Oe(r.valueType,t);if(r.type==="lazy")return Oe(r.getter(),t);if(r.type==="promise"||r.type==="optional"||r.type==="nonoptional"||r.type==="nullable"||r.type==="readonly"||r.type==="default"||r.type==="prefault")return Oe(r.innerType,t);if(r.type==="intersection")return Oe(r.left,t)||Oe(r.right,t);if(r.type==="record"||r.type==="map")return Oe(r.keyType,t)||Oe(r.valueType,t);if(r.type==="pipe")return Oe(r.in,t)||Oe(r.out,t);if(r.type==="object"){for(const i in r.shape)if(Oe(r.shape[i],t))return!0;return!1}if(r.type==="union"){for(const i of r.options)if(Oe(i,t))return!0;return!1}if(r.type==="tuple"){for(const i of r.items)if(Oe(i,t))return!0;return!!(r.rest&&Oe(r.rest,t))}return!1}const Vx=(n,e={})=>t=>{const r=tm({...t,processors:e});return ve(n,r),nm(r,n),rm(r,n)},Qo=(n,e,t={})=>r=>{const{libraryOptions:i,target:s}=r??{},o=tm({...i??{},target:s,io:e,processors:t});return ve(n,o),nm(o,n),rm(o,n)},jx={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},Gx=(n,e,t,r)=>{const i=t;i.type="string";const{minimum:s,maximum:o,format:a,patterns:l,contentEncoding:u}=n._zod.bag;if(typeof s=="number"&&(i.minLength=s),typeof o=="number"&&(i.maxLength=o),a&&(i.format=jx[a]??a,i.format===""&&delete i.format,a==="time"&&delete i.format),u&&(i.contentEncoding=u),l&&l.size>0){const d=[...l];d.length===1?i.pattern=d[0].source:d.length>1&&(i.allOf=[...d.map(f=>({...e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0"?{type:"string"}:{},pattern:f.source}))])}},Bx=(n,e,t,r)=>{const i=t,{minimum:s,maximum:o,format:a,multipleOf:l,exclusiveMaximum:u,exclusiveMinimum:d}=n._zod.bag;typeof a=="string"&&a.includes("int")?i.type="integer":i.type="number",typeof d=="number"&&(e.target==="draft-04"||e.target==="openapi-3.0"?(i.minimum=d,i.exclusiveMinimum=!0):i.exclusiveMinimum=d),typeof s=="number"&&(i.minimum=s,typeof d=="number"&&e.target!=="draft-04"&&(d>=s?delete i.minimum:delete i.exclusiveMinimum)),typeof u=="number"&&(e.target==="draft-04"||e.target==="openapi-3.0"?(i.maximum=u,i.exclusiveMaximum=!0):i.exclusiveMaximum=u),typeof o=="number"&&(i.maximum=o,typeof u=="number"&&e.target!=="draft-04"&&(u<=o?delete i.maximum:delete i.exclusiveMaximum)),typeof l=="number"&&(i.multipleOf=l)},Wx=(n,e,t,r)=>{t.type="boolean"},qx=(n,e,t,r)=>{t.not={}},Yx=(n,e,t,r)=>{},Kx=(n,e,t,r)=>{const i=n._zod.def,s=zg(i.entries);s.every(o=>typeof o=="number")&&(t.type="number"),s.every(o=>typeof o=="string")&&(t.type="string"),t.enum=s},Jx=(n,e,t,r)=>{const i=n._zod.def,s=[];for(const o of i.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");s.push(Number(o))}else s.push(o);if(s.length!==0)if(s.length===1){const o=s[0];t.type=o===null?"null":typeof o,e.target==="draft-04"||e.target==="openapi-3.0"?t.enum=[o]:t.const=o}else s.every(o=>typeof o=="number")&&(t.type="number"),s.every(o=>typeof o=="string")&&(t.type="string"),s.every(o=>typeof o=="boolean")&&(t.type="boolean"),s.every(o=>o===null)&&(t.type="null"),t.enum=s},Xx=(n,e,t,r)=>{if(e.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema")},Qx=(n,e,t,r)=>{if(e.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema")},eT=(n,e,t,r)=>{const i=t,s=n._zod.def,{minimum:o,maximum:a}=n._zod.bag;typeof o=="number"&&(i.minItems=o),typeof a=="number"&&(i.maxItems=a),i.type="array",i.items=ve(s.element,e,{...r,path:[...r.path,"items"]})},tT=(n,e,t,r)=>{var u;const i=t,s=n._zod.def;i.type="object",i.properties={};const o=s.shape;for(const d in o)i.properties[d]=ve(o[d],e,{...r,path:[...r.path,"properties",d]});const a=new Set(Object.keys(o)),l=new Set([...a].filter(d=>{const f=s.shape[d]._zod;return e.io==="input"?f.optin===void 0:f.optout===void 0}));l.size>0&&(i.required=Array.from(l)),((u=s.catchall)==null?void 0:u._zod.def.type)==="never"?i.additionalProperties=!1:s.catchall?s.catchall&&(i.additionalProperties=ve(s.catchall,e,{...r,path:[...r.path,"additionalProperties"]})):e.io==="output"&&(i.additionalProperties=!1)},nT=(n,e,t,r)=>{const i=n._zod.def,s=i.inclusive===!1,o=i.options.map((a,l)=>ve(a,e,{...r,path:[...r.path,s?"oneOf":"anyOf",l]}));s?t.oneOf=o:t.anyOf=o},rT=(n,e,t,r)=>{const i=n._zod.def,s=ve(i.left,e,{...r,path:[...r.path,"allOf",0]}),o=ve(i.right,e,{...r,path:[...r.path,"allOf",1]}),a=u=>"allOf"in u&&Object.keys(u).length===1,l=[...a(s)?s.allOf:[s],...a(o)?o.allOf:[o]];t.allOf=l},iT=(n,e,t,r)=>{const i=t,s=n._zod.def;i.type="object";const o=s.keyType,a=o._zod.bag,l=a==null?void 0:a.patterns;if(s.mode==="loose"&&l&&l.size>0){const d=ve(s.valueType,e,{...r,path:[...r.path,"patternProperties","*"]});i.patternProperties={};for(const f of l)i.patternProperties[f.source]=d}else(e.target==="draft-07"||e.target==="draft-2020-12")&&(i.propertyNames=ve(s.keyType,e,{...r,path:[...r.path,"propertyNames"]})),i.additionalProperties=ve(s.valueType,e,{...r,path:[...r.path,"additionalProperties"]});const u=o._zod.values;if(u){const d=[...u].filter(f=>typeof f=="string"||typeof f=="number");d.length>0&&(i.required=d)}},sT=(n,e,t,r)=>{const i=n._zod.def,s=ve(i.innerType,e,r),o=e.seen.get(n);e.target==="openapi-3.0"?(o.ref=i.innerType,t.nullable=!0):t.anyOf=[s,{type:"null"}]},oT=(n,e,t,r)=>{const i=n._zod.def;ve(i.innerType,e,r);const s=e.seen.get(n);s.ref=i.innerType},aT=(n,e,t,r)=>{const i=n._zod.def;ve(i.innerType,e,r);const s=e.seen.get(n);s.ref=i.innerType,t.default=JSON.parse(JSON.stringify(i.defaultValue))},lT=(n,e,t,r)=>{const i=n._zod.def;ve(i.innerType,e,r);const s=e.seen.get(n);s.ref=i.innerType,e.io==="input"&&(t._prefault=JSON.parse(JSON.stringify(i.defaultValue)))},cT=(n,e,t,r)=>{const i=n._zod.def;ve(i.innerType,e,r);const s=e.seen.get(n);s.ref=i.innerType;let o;try{o=i.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}t.default=o},uT=(n,e,t,r)=>{const i=n._zod.def,s=e.io==="input"?i.in._zod.def.type==="transform"?i.out:i.in:i.out;ve(s,e,r);const o=e.seen.get(n);o.ref=s},hT=(n,e,t,r)=>{const i=n._zod.def;ve(i.innerType,e,r);const s=e.seen.get(n);s.ref=i.innerType,t.readOnly=!0},im=(n,e,t,r)=>{const i=n._zod.def;ve(i.innerType,e,r);const s=e.seen.get(n);s.ref=i.innerType},dT=$("ZodISODateTime",(n,e)=>{fA.init(n,e),fe.init(n,e)});function fT(n){return bx(dT,n)}const pT=$("ZodISODate",(n,e)=>{pA.init(n,e),fe.init(n,e)});function gT(n){return wx(pT,n)}const mT=$("ZodISOTime",(n,e)=>{gA.init(n,e),fe.init(n,e)});function yT(n){return _x(mT,n)}const vT=$("ZodISODuration",(n,e)=>{mA.init(n,e),fe.init(n,e)});function bT(n){return Sx(vT,n)}const sm=(n,e)=>{Ug.init(n,e),n.name="ZodError",Object.defineProperties(n,{format:{value:t=>o$(n,t)},flatten:{value:t=>s$(n,t)},addIssue:{value:t=>{n.issues.push(t),n.message=JSON.stringify(n.issues,dc,2)}},addIssues:{value:t=>{n.issues.push(...t),n.message=JSON.stringify(n.issues,dc,2)}},isEmpty:{get(){return n.issues.length===0}}})},mf=$("ZodError",sm),ot=$("ZodError",sm,{Parent:Error}),wT=Pu(ot),_T=Ru(ot),ST=Da(ot),kT=Oa(ot),ET=c$(ot),$T=u$(ot),AT=h$(ot),xT=d$(ot),TT=f$(ot),CT=p$(ot),IT=g$(ot),PT=m$(ot),de=$("ZodType",(n,e)=>(he.init(n,e),Object.assign(n["~standard"],{jsonSchema:{input:Qo(n,"input"),output:Qo(n,"output")}}),n.toJSONSchema=Vx(n,{}),n.def=e,n.type=e.type,Object.defineProperty(n,"_def",{value:e}),n.check=(...t)=>n.clone(_n(e,{checks:[...e.checks??[],...t.map(r=>typeof r=="function"?{_zod:{check:r,def:{check:"custom"},onattach:[]}}:r)]}),{parent:!0}),n.with=n.check,n.clone=(t,r)=>Sn(n,t,r),n.brand=()=>n,n.register=(t,r)=>(t.add(n,r),n),n.parse=(t,r)=>wT(n,t,r,{callee:n.parse}),n.safeParse=(t,r)=>ST(n,t,r),n.parseAsync=async(t,r)=>_T(n,t,r,{callee:n.parseAsync}),n.safeParseAsync=async(t,r)=>kT(n,t,r),n.spa=n.safeParseAsync,n.encode=(t,r)=>ET(n,t,r),n.decode=(t,r)=>$T(n,t,r),n.encodeAsync=async(t,r)=>AT(n,t,r),n.decodeAsync=async(t,r)=>xT(n,t,r),n.safeEncode=(t,r)=>TT(n,t,r),n.safeDecode=(t,r)=>CT(n,t,r),n.safeEncodeAsync=async(t,r)=>IT(n,t,r),n.safeDecodeAsync=async(t,r)=>PT(n,t,r),n.refine=(t,r)=>n.check(SC(t,r)),n.superRefine=t=>n.check(kC(t)),n.overwrite=t=>n.check(fi(t)),n.optional=()=>bf(n),n.exactOptional=()=>cC(n),n.nullable=()=>wf(n),n.nullish=()=>bf(wf(n)),n.nonoptional=t=>gC(n,t),n.array=()=>D(n),n.or=t=>H([n,t]),n.and=t=>La(n,t),n.transform=t=>_f(n,aC(t)),n.default=t=>dC(n,t),n.prefault=t=>pC(n,t),n.catch=t=>yC(n,t),n.pipe=t=>_f(n,t),n.readonly=()=>wC(n),n.describe=t=>{const r=n.clone();return zi.add(r,{description:t}),r},Object.defineProperty(n,"description",{get(){var t;return(t=zi.get(n))==null?void 0:t.description},configurable:!0}),n.meta=(...t)=>{if(t.length===0)return zi.get(n);const r=n.clone();return zi.add(r,t[0]),r},n.isOptional=()=>n.safeParse(void 0).success,n.isNullable=()=>n.safeParse(null).success,n.apply=t=>t(n),n)),om=$("_ZodString",(n,e)=>{Du.init(n,e),de.init(n,e),n._zod.processJSONSchema=(r,i,s)=>Gx(n,r,i);const t=n._zod.bag;n.format=t.format??null,n.minLength=t.minimum??null,n.maxLength=t.maximum??null,n.regex=(...r)=>n.check(Tx(...r)),n.includes=(...r)=>n.check(Px(...r)),n.startsWith=(...r)=>n.check(Rx(...r)),n.endsWith=(...r)=>n.check(Dx(...r)),n.min=(...r)=>n.check(Xo(...r)),n.max=(...r)=>n.check(Qg(...r)),n.length=(...r)=>n.check(em(...r)),n.nonempty=(...r)=>n.check(Xo(1,...r)),n.lowercase=r=>n.check(Cx(r)),n.uppercase=r=>n.check(Ix(r)),n.trim=()=>n.check(zx()),n.normalize=(...r)=>n.check(Ox(...r)),n.toLowerCase=()=>n.check(Lx()),n.toUpperCase=()=>n.check(Mx()),n.slugify=()=>n.check(Nx())}),RT=$("ZodString",(n,e)=>{Du.init(n,e),om.init(n,e),n.email=t=>n.check(XA(DT,t)),n.url=t=>n.check(rx(OT,t)),n.jwt=t=>n.check(vx(YT,t)),n.emoji=t=>n.check(ix(zT,t)),n.guid=t=>n.check(df(yf,t)),n.uuid=t=>n.check(QA(vo,t)),n.uuidv4=t=>n.check(ex(vo,t)),n.uuidv6=t=>n.check(tx(vo,t)),n.uuidv7=t=>n.check(nx(vo,t)),n.nanoid=t=>n.check(sx(LT,t)),n.guid=t=>n.check(df(yf,t)),n.cuid=t=>n.check(ox(MT,t)),n.cuid2=t=>n.check(ax(NT,t)),n.ulid=t=>n.check(lx(UT,t)),n.base64=t=>n.check(gx(BT,t)),n.base64url=t=>n.check(mx(WT,t)),n.xid=t=>n.check(cx(FT,t)),n.ksuid=t=>n.check(ux(ZT,t)),n.ipv4=t=>n.check(hx(HT,t)),n.ipv6=t=>n.check(dx(VT,t)),n.cidrv4=t=>n.check(fx(jT,t)),n.cidrv6=t=>n.check(px(GT,t)),n.e164=t=>n.check(yx(qT,t)),n.datetime=t=>n.check(fT(t)),n.date=t=>n.check(gT(t)),n.time=t=>n.check(yT(t)),n.duration=t=>n.check(bT(t))});function h(n){return JA(RT,n)}const fe=$("ZodStringFormat",(n,e)=>{ae.init(n,e),om.init(n,e)}),DT=$("ZodEmail",(n,e)=>{iA.init(n,e),fe.init(n,e)}),yf=$("ZodGUID",(n,e)=>{nA.init(n,e),fe.init(n,e)}),vo=$("ZodUUID",(n,e)=>{rA.init(n,e),fe.init(n,e)}),OT=$("ZodURL",(n,e)=>{sA.init(n,e),fe.init(n,e)}),zT=$("ZodEmoji",(n,e)=>{oA.init(n,e),fe.init(n,e)}),LT=$("ZodNanoID",(n,e)=>{aA.init(n,e),fe.init(n,e)}),MT=$("ZodCUID",(n,e)=>{lA.init(n,e),fe.init(n,e)}),NT=$("ZodCUID2",(n,e)=>{cA.init(n,e),fe.init(n,e)}),UT=$("ZodULID",(n,e)=>{uA.init(n,e),fe.init(n,e)}),FT=$("ZodXID",(n,e)=>{hA.init(n,e),fe.init(n,e)}),ZT=$("ZodKSUID",(n,e)=>{dA.init(n,e),fe.init(n,e)}),HT=$("ZodIPv4",(n,e)=>{yA.init(n,e),fe.init(n,e)}),VT=$("ZodIPv6",(n,e)=>{vA.init(n,e),fe.init(n,e)}),jT=$("ZodCIDRv4",(n,e)=>{bA.init(n,e),fe.init(n,e)}),GT=$("ZodCIDRv6",(n,e)=>{wA.init(n,e),fe.init(n,e)}),BT=$("ZodBase64",(n,e)=>{_A.init(n,e),fe.init(n,e)}),WT=$("ZodBase64URL",(n,e)=>{kA.init(n,e),fe.init(n,e)}),qT=$("ZodE164",(n,e)=>{EA.init(n,e),fe.init(n,e)}),YT=$("ZodJWT",(n,e)=>{AA.init(n,e),fe.init(n,e)}),am=$("ZodNumber",(n,e)=>{Yg.init(n,e),de.init(n,e),n._zod.processJSONSchema=(r,i,s)=>Bx(n,r,i),n.gt=(r,i)=>n.check(pf(r,i)),n.gte=(r,i)=>n.check(Ol(r,i)),n.min=(r,i)=>n.check(Ol(r,i)),n.lt=(r,i)=>n.check(ff(r,i)),n.lte=(r,i)=>n.check(Dl(r,i)),n.max=(r,i)=>n.check(Dl(r,i)),n.int=r=>n.check(vf(r)),n.safe=r=>n.check(vf(r)),n.positive=r=>n.check(pf(0,r)),n.nonnegative=r=>n.check(Ol(0,r)),n.negative=r=>n.check(ff(0,r)),n.nonpositive=r=>n.check(Dl(0,r)),n.multipleOf=(r,i)=>n.check(gf(r,i)),n.step=(r,i)=>n.check(gf(r,i)),n.finite=()=>n;const t=n._zod.bag;n.minValue=Math.max(t.minimum??Number.NEGATIVE_INFINITY,t.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,n.maxValue=Math.min(t.maximum??Number.POSITIVE_INFINITY,t.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,n.isInt=(t.format??"").includes("int")||Number.isSafeInteger(t.multipleOf??.5),n.isFinite=!0,n.format=t.format??null});function N(n){return kx(am,n)}const KT=$("ZodNumberFormat",(n,e)=>{xA.init(n,e),am.init(n,e)});function vf(n){return Ex(KT,n)}const JT=$("ZodBoolean",(n,e)=>{TA.init(n,e),de.init(n,e),n._zod.processJSONSchema=(t,r,i)=>Wx(n,t,r)});function Ee(n){return $x(JT,n)}const XT=$("ZodUnknown",(n,e)=>{CA.init(n,e),de.init(n,e),n._zod.processJSONSchema=(t,r,i)=>Yx()});function w(){return Ax(XT)}const QT=$("ZodNever",(n,e)=>{IA.init(n,e),de.init(n,e),n._zod.processJSONSchema=(t,r,i)=>qx(n,t,r)});function eC(n){return xx(QT,n)}const tC=$("ZodArray",(n,e)=>{PA.init(n,e),de.init(n,e),n._zod.processJSONSchema=(t,r,i)=>eT(n,t,r,i),n.element=e.element,n.min=(t,r)=>n.check(Xo(t,r)),n.nonempty=t=>n.check(Xo(1,t)),n.max=(t,r)=>n.check(Qg(t,r)),n.length=(t,r)=>n.check(em(t,r)),n.unwrap=()=>n.element});function D(n,e){return Ux(tC,n,e)}const lm=$("ZodObject",(n,e)=>{DA.init(n,e),de.init(n,e),n._zod.processJSONSchema=(t,r,i)=>tT(n,t,r,i),X(n,"shape",()=>e.shape),n.keyof=()=>ea(Object.keys(n._zod.def.shape)),n.catchall=t=>n.clone({...n._zod.def,catchall:t}),n.passthrough=()=>n.clone({...n._zod.def,catchall:w()}),n.loose=()=>n.clone({...n._zod.def,catchall:w()}),n.strict=()=>n.clone({...n._zod.def,catchall:eC()}),n.strip=()=>n.clone({...n._zod.def,catchall:void 0}),n.extend=t=>e$(n,t),n.safeExtend=t=>t$(n,t),n.merge=t=>n$(n,t),n.pick=t=>X0(n,t),n.omit=t=>Q0(n,t),n.partial=(...t)=>r$(um,n,t[0]),n.required=(...t)=>i$(hm,n,t[0])});function cm(n,e){const t={type:"object",shape:n??{},...O(e)};return new lm(t)}function p(n,e){return new lm({type:"object",shape:n,catchall:w(),...O(e)})}const nC=$("ZodUnion",(n,e)=>{OA.init(n,e),de.init(n,e),n._zod.processJSONSchema=(t,r,i)=>nT(n,t,r,i),n.options=e.options});function H(n,e){return new nC({type:"union",options:n,...O(e)})}const rC=$("ZodIntersection",(n,e)=>{zA.init(n,e),de.init(n,e),n._zod.processJSONSchema=(t,r,i)=>rT(n,t,r,i)});function La(n,e){return new rC({type:"intersection",left:n,right:e})}const iC=$("ZodRecord",(n,e)=>{LA.init(n,e),de.init(n,e),n._zod.processJSONSchema=(t,r,i)=>iT(n,t,r,i),n.keyType=e.keyType,n.valueType=e.valueType});function _(n,e,t){return new iC({type:"record",keyType:n,valueType:e,...O(t)})}const pc=$("ZodEnum",(n,e)=>{MA.init(n,e),de.init(n,e),n._zod.processJSONSchema=(r,i,s)=>Kx(n,r,i),n.enum=e.entries,n.options=Object.values(e.entries);const t=new Set(Object.keys(e.entries));n.extract=(r,i)=>{const s={};for(const o of r)if(t.has(o))s[o]=e.entries[o];else throw new Error(`Key ${o} not found in enum`);return new pc({...e,checks:[],...O(i),entries:s})},n.exclude=(r,i)=>{const s={...e.entries};for(const o of r)if(t.has(o))delete s[o];else throw new Error(`Key ${o} not found in enum`);return new pc({...e,checks:[],...O(i),entries:s})}});function ea(n,e){const t=Array.isArray(n)?Object.fromEntries(n.map(r=>[r,r])):n;return new pc({type:"enum",entries:t,...O(e)})}const sC=$("ZodLiteral",(n,e)=>{NA.init(n,e),de.init(n,e),n._zod.processJSONSchema=(t,r,i)=>Jx(n,t,r),n.values=new Set(e.values),Object.defineProperty(n,"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 x(n,e){return new sC({type:"literal",values:Array.isArray(n)?n:[n],...O(e)})}const oC=$("ZodTransform",(n,e)=>{UA.init(n,e),de.init(n,e),n._zod.processJSONSchema=(t,r,i)=>Qx(n,t),n._zod.parse=(t,r)=>{if(r.direction==="backward")throw new Dg(n.constructor.name);t.addIssue=s=>{if(typeof s=="string")t.issues.push(Ji(s,t.value,e));else{const o=s;o.fatal&&(o.continue=!1),o.code??(o.code="custom"),o.input??(o.input=t.value),o.inst??(o.inst=n),t.issues.push(Ji(o))}};const i=e.transform(t.value,t);return i instanceof Promise?i.then(s=>(t.value=s,t)):(t.value=i,t)}});function aC(n){return new oC({type:"transform",transform:n})}const um=$("ZodOptional",(n,e)=>{Xg.init(n,e),de.init(n,e),n._zod.processJSONSchema=(t,r,i)=>im(n,t,r,i),n.unwrap=()=>n._zod.def.innerType});function bf(n){return new um({type:"optional",innerType:n})}const lC=$("ZodExactOptional",(n,e)=>{FA.init(n,e),de.init(n,e),n._zod.processJSONSchema=(t,r,i)=>im(n,t,r,i),n.unwrap=()=>n._zod.def.innerType});function cC(n){return new lC({type:"optional",innerType:n})}const uC=$("ZodNullable",(n,e)=>{ZA.init(n,e),de.init(n,e),n._zod.processJSONSchema=(t,r,i)=>sT(n,t,r,i),n.unwrap=()=>n._zod.def.innerType});function wf(n){return new uC({type:"nullable",innerType:n})}const hC=$("ZodDefault",(n,e)=>{HA.init(n,e),de.init(n,e),n._zod.processJSONSchema=(t,r,i)=>aT(n,t,r,i),n.unwrap=()=>n._zod.def.innerType,n.removeDefault=n.unwrap});function dC(n,e){return new hC({type:"default",innerType:n,get defaultValue(){return typeof e=="function"?e():Mg(e)}})}const fC=$("ZodPrefault",(n,e)=>{VA.init(n,e),de.init(n,e),n._zod.processJSONSchema=(t,r,i)=>lT(n,t,r,i),n.unwrap=()=>n._zod.def.innerType});function pC(n,e){return new fC({type:"prefault",innerType:n,get defaultValue(){return typeof e=="function"?e():Mg(e)}})}const hm=$("ZodNonOptional",(n,e)=>{jA.init(n,e),de.init(n,e),n._zod.processJSONSchema=(t,r,i)=>oT(n,t,r,i),n.unwrap=()=>n._zod.def.innerType});function gC(n,e){return new hm({type:"nonoptional",innerType:n,...O(e)})}const mC=$("ZodCatch",(n,e)=>{GA.init(n,e),de.init(n,e),n._zod.processJSONSchema=(t,r,i)=>cT(n,t,r,i),n.unwrap=()=>n._zod.def.innerType,n.removeCatch=n.unwrap});function yC(n,e){return new mC({type:"catch",innerType:n,catchValue:typeof e=="function"?e:()=>e})}const vC=$("ZodPipe",(n,e)=>{BA.init(n,e),de.init(n,e),n._zod.processJSONSchema=(t,r,i)=>uT(n,t,r,i),n.in=e.in,n.out=e.out});function _f(n,e){return new vC({type:"pipe",in:n,out:e})}const bC=$("ZodReadonly",(n,e)=>{WA.init(n,e),de.init(n,e),n._zod.processJSONSchema=(t,r,i)=>hT(n,t,r,i),n.unwrap=()=>n._zod.def.innerType});function wC(n){return new bC({type:"readonly",innerType:n})}const _C=$("ZodCustom",(n,e)=>{qA.init(n,e),de.init(n,e),n._zod.processJSONSchema=(t,r,i)=>Xx(n,t)});function SC(n,e={}){return Fx(_C,n,e)}function kC(n){return Zx(n)}const EC=["text/markdown","text/html"],$C=["committed","pending"];cm({id:h().min(1),type:ea(EC),title:h(),status:ea($C),externalFilePath:h().optional()});cm({name:h().min(1),description:h(),accepts:D(h().min(1)).min(1)});function Ou(n){return typeof n=="object"&&n!==null}function AC(n){return!Ou(n)||n.type!=="ready"?!1:!("id"in n)}function xC(n){return!(!Ou(n)||n.type!=="update-content"||typeof n.id!="string"||typeof n.content!="string")}function TC(n){return!Ou(n)||n.type!=="wheel"||typeof n.deltaX!="number"||typeof n.deltaY!="number"||typeof n.shiftKey!="boolean"?!1:!("id"in n)}function CC(n,e){if(n===e)return 2;if(n==="*/*")return 0;const t=n.indexOf("/");if(t>0&&n.slice(t+1)==="*"){const r=n.slice(0,t),i=e.indexOf("/");if(i>0&&e.slice(0,i)===r)return 1}return null}function IC(n,e){let t=null;for(const r of n.accepts){const i=CC(r,e);i!==null&&(t===null||i>t)&&(t=i)}return t}function PC(n,e){let t=-1,r=null;for(const i of e){const s=IC(i,n);s!==null&&(s>t||s===t&&r!==null&&i.id<r.id)&&(t=s,r=i)}return r}const RC=4401;class gc extends Error{constructor(e="Authentication required"){super(e),this.name="AuthError"}}class mc extends Tt{constructor(t){super();b(this,"url");b(this,"name");b(this,"token");b(this,"status","disconnected");b(this,"screens",new Map);b(this,"views",[]);b(this,"client");b(this,"createSocket");b(this,"createClient");b(this,"socket",null);b(this,"connectAttempt",0);this.url=Lt(t.url),this.name=t.name,this.token=t.token??null,this.createSocket=t.createSocket??(r=>new WebSocket(r)),this.createClient=t.createClient??((r,i)=>new L0(r,{token:i??void 0})),this.client=this.createClient(this.url,this.token)}async connect(){var i;this.connectAttempt+=1;const t=this.connectAttempt;(i=this.socket)==null||i.close(),this.client=this.createClient(this.url,this.token),this.status="connecting",this.dispatchEvent(new Q("change"));const r=this.createSocket(DC(this.url,this.token));return this.socket=r,await new Promise((s,o)=>{let a=!1;const l=()=>{a||this.connectAttempt!==t||(a=!0,this.status="connected",this.dispatchEvent(new Q("change")),s())},u=f=>{a||this.connectAttempt!==t||(a=!0,this.status="disconnected",this.dispatchEvent(new Q("change")),o(f))},d=async()=>{try{const[{screens:f},v]=await Promise.all([this.client.screens.list(),this.client.views.list()]);this.screens=new Map(f.map(y=>[y.id,structuredClone(y)])),this.views=v,this.dispatchEvent(new Q("change")),l()}catch(f){u(f instanceof Error?f:new Error(String(f)))}};r.addEventListener("open",()=>{d()}),r.addEventListener("message",f=>{const v=zC(f);v&&(this.applyServerEvent(v),this.dispatchEvent(new kg("server-event",{serverURL:this.url,event:v})))}),r.addEventListener("close",f=>{if(this.connectAttempt===t){if(this.socket=null,OC(f)===RC){u(new gc);return}if(!a){u(new Error("Connection closed before initialization"));return}this.status="disconnected",this.dispatchEvent(new Q("change"))}}),r.addEventListener("error",()=>{u(new Error("WebSocket connection failed"))})})}disconnect(){var t;this.connectAttempt+=1,(t=this.socket)==null||t.close(),this.socket=null,this.status="disconnected",this.dispatchEvent(new Q("change"))}getViewURL(t){const r=PC(t.type,this.views);if(!r)return null;const i=`${this.url}/views/${encodeURIComponent(r.id)}/`;return this.token===null?i:`${i}?token=${encodeURIComponent(this.token)}`}getContentURL(t){const r=`${this.url}/artifacts/${encodeURIComponent(t)}/content`;return this.token===null?r:`${r}?token=${encodeURIComponent(this.token)}`}async createScreen(t){const{screen:r}=await this.client.screens.create({name:t});return this.screens.set(r.id,structuredClone(r)),r}applyServerEvent(t){switch(t.type){case"screen-created":this.screens.set(t.screen.id,structuredClone(t.screen)),this.dispatchEvent(new zo("screens-changed"));break;case"screen-updated":this.screens.set(t.screen.id,structuredClone(t.screen)),this.dispatchEvent(new zo("screens-changed"));break;case"screen-removed":this.screens.delete(t.screenID),this.dispatchEvent(new zo("screens-changed"));break;case"artifact-created":{const r=this.screens.get(t.screenID);r&&!wg(r.layout,t.artifact.id)&&(r.layout=[...r.layout,bg(t.artifact.id)]);break}case"artifact-removed":{const r=this.screens.get(t.screenID);r&&(r.layout=ug(r.layout,t.artifactID));break}}}}function DC(n,e){const t=new URL(n);return t.protocol=t.protocol==="https:"?"wss:":"ws:",t.pathname="/events",t.search="",e&&t.searchParams.set("token",e),t.hash="",t.toString()}function OC(n){return typeof n=="object"&&n!==null&&"code"in n&&typeof n.code=="number"?n.code:null}function zC(n){const e=typeof n=="string"?n:typeof n=="object"&&n!==null&&"data"in n&&typeof n.data=="string"?n.data:"";if(!e)return null;try{return JSON.parse(e)}catch{return null}}class LC extends Tt{constructor(t){super();b(this,"servers",new Map);b(this,"localServerURL");b(this,"localStore");b(this,"createSocket");b(this,"lastActiveServerURL");b(this,"serverListeners",new Map);b(this,"handleLocalStoreChange",()=>{const t=this.localStore.get().activeServerURL;t!==this.lastActiveServerURL&&(this.lastActiveServerURL=t,this.dispatchEvent(new Q("change")))});this.localStore=t.localStore,this.localServerURL=t.localServerURL?Lt(t.localServerURL):null,this.createSocket=t.createSocket??(r=>new WebSocket(r)),this.lastActiveServerURL=this.localStore.get().activeServerURL,this.localStore.addEventListener("change",this.handleLocalStoreChange)}get activeServer(){const t=this.localStore.get().activeServerURL;return t===null?null:this.servers.get(t)??null}add(t){const r=Lt(t.url);this.servers.get(r)&&this.remove(r),this.servers.set(r,t);const s=()=>{this.dispatchEvent(new Q("change"))},o=l=>{this.dispatchEvent(new kg("server-event",{serverURL:l.serverURL,event:l.event}))},a=()=>{this.dispatchEvent(new zo("screens-changed"))};t.addEventListener("change",s),t.addEventListener("server-event",o),t.addEventListener("screens-changed",a),this.serverListeners.set(r,{onServerChange:s,onServerEvent:o,onScreensChanged:a}),this.dispatchEvent(new Q("change"))}remove(t){const r=Lt(t);if(this.localServerURL&&r===this.localServerURL)return;const i=this.servers.get(r);if(!i)return;const s=this.serverListeners.get(r);s&&(i.removeEventListener("change",s.onServerChange),i.removeEventListener("server-event",s.onServerEvent),i.removeEventListener("screens-changed",s.onScreensChanged),this.serverListeners.delete(r)),i.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 Q("change"))}setActive(t){const r=this.localStore.get(),i=t?Lt(t.url):null;r.activeServerURL!==i&&this.localStore.set({...r,activeServerURL:i})}connectConfiguredServers(t){const r=this.localStore.get().servers;for(const s of r){const o=new mc({url:s.url,name:s.name,createSocket:this.createSocket});this.add(o),o.connect().catch(()=>{})}const i=t?this.servers.get(Lt(t))??null:null;this.setActive(i??this.servers.values().next().value??null)}addServer(t,r){const i=Lt(t);this.remove(i);const s=this.localStore.get();this.localStore.set({...s,servers:[...s.servers.filter(a=>Lt(a.url)!==i),{url:i,name:r}]});const o=new mc({url:i,name:r,createSocket:this.createSocket});this.add(o),this.setActive(o),o.connect().catch(()=>{})}removeServer(t){this.remove(t)}}const se={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"},Dt={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"},MC=1,NC=p({_meta:_(h(),w()).nullish(),terminal:Ee().optional().default(!1)}),UC=p({_meta:_(h(),w()).nullish(),label:h().nullish(),name:h(),optional:Ee().optional().default(!1),secret:Ee().optional().default(!0)}),FC=p({_meta:_(h(),w()).nullish(),description:h().nullish(),id:h(),name:h()}),ZC=p({_meta:_(h(),w()).nullish(),description:h().nullish(),id:h(),link:h().nullish(),name:h(),vars:D(UC)}),HC=p({_meta:_(h(),w()).nullish(),args:D(h()).optional(),description:h().nullish(),env:_(h(),h()).optional(),id:h(),name:h()}),VC=H([ZC.and(p({type:x("env_var")})),HC.and(p({type:x("terminal")})),FC]),jC=p({_meta:_(h(),w()).nullish(),methodId:h()}),GC=p({_meta:_(h(),w()).nullish()}),BC=p({_meta:_(h(),w()).nullish(),blob:h(),mimeType:h().nullish(),uri:h()}),WC=p({default:Ee().nullish(),description:h().nullish(),title:h().nullish()}),qC=p({_meta:_(h(),w()).nullish()}),YC=p({_meta:_(h(),w()).nullish()}),KC=p({amount:N(),currency:h()}),JC=p({_meta:_(h(),w()).nullish(),terminalId:h()}),XC=p({_meta:_(h(),w()).nullish(),newText:h(),oldText:h().nullish(),path:h()}),QC=H([h(),N(),N(),Ee(),D(h())]),eI=p({content:_(h(),QC).nullish()}),tI=H([eI.and(p({action:x("accept")})),p({action:x("decline")}),p({action:x("cancel")})]),nI=p({_meta:_(h(),w()).nullish()}),dm=h(),rI=p({_meta:_(h(),w()).nullish(),elicitationId:dm}),iI=p({_meta:_(h(),w()).nullish(),action:tI}),sI=x("object"),oI=x("string"),aI=p({_meta:_(h(),w()).nullish()}),lI=p({_meta:_(h(),w()).nullish(),form:nI.nullish(),url:aI.nullish()}),cI=p({elicitationId:dm,url:h().url()}),fm=p({const:h(),title:h()}),pm=p({_meta:_(h(),w()).nullish(),name:h(),value:h()}),uI=H([x(-32700),x(-32600),x(-32601),x(-32602),x(-32603),x(-32800),x(-32e3),x(-32002),x(-32042),N().int().min(-2147483648,{message:"Invalid value: Expected int32 to be >= -2147483648"}).max(2147483647,{message:"Invalid value: Expected int32 to be <= 2147483647"})]),gm=p({code:uI,data:w().optional(),message:h()}),mm=w(),ym=w(),vm=w(),hI=p({_meta:_(h(),w()).nullish(),readTextFile:Ee().optional().default(!1),writeTextFile:Ee().optional().default(!1)}),bm=p({_meta:_(h(),w()).nullish(),name:h(),value:h()}),wm=p({_meta:_(h(),w()).nullish(),name:h(),title:h().nullish(),version:h()}),dI=p({default:N().nullish(),description:h().nullish(),maximum:N().nullish(),minimum:N().nullish(),title:h().nullish()}),fI=p({_meta:_(h(),w()).nullish()}),pI=p({_meta:_(h(),w()).nullish(),additionalDirectories:D(h()).optional(),cursor:h().nullish(),cwd:h().nullish()}),gI=p({_meta:_(h(),w()).nullish()}),mI=p({_meta:_(h(),w()).nullish(),logout:gI.nullish()}),yI=p({_meta:_(h(),w()).nullish()}),vI=p({_meta:_(h(),w()).nullish()}),bI=p({_meta:_(h(),w()).nullish(),http:Ee().optional().default(!1),sse:Ee().optional().default(!1)}),wI=p({_meta:_(h(),w()).nullish(),headers:D(bm),name:h(),url:h()}),_I=p({_meta:_(h(),w()).nullish(),headers:D(bm),name:h(),url:h()}),SI=p({_meta:_(h(),w()).nullish(),args:D(h()),command:h(),env:D(pm),name:h()}),Ma=H([wI.and(p({type:x("http")})),_I.and(p({type:x("sse")})),SI]),zu=h(),kI=p({_meta:_(h(),w()).nullish(),description:h().nullish(),modelId:zu,name:h()}),EI=H([x("error"),x("warning"),x("information"),x("hint")]),$I=p({_meta:_(h(),w()).nullish()}),AI=p({_meta:_(h(),w()).nullish()}),xI=p({_meta:_(h(),w()).nullish()}),TI=p({_meta:_(h(),w()).nullish()}),CI=p({_meta:_(h(),w()).nullish()}),II=p({_meta:_(h(),w()).nullish(),maxCount:N().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish()}),PI=p({diff:h(),uri:h()}),RI=p({endLine:N().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}),startLine:N().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}),text:h()}),DI=p({_meta:_(h(),w()).nullish()}),OI=p({_meta:_(h(),w()).nullish()}),zI=p({languageId:h(),text:h(),uri:h()}),LI=p({_meta:_(h(),w()).nullish(),maxCount:N().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish()}),MI=H([x("rejected"),x("ignored"),x("replaced"),x("cancelled")]),NI=p({excerpts:D(RI),uri:h()}),UI=p({_meta:_(h(),w()).nullish()}),FI=p({_meta:_(h(),w()).nullish()}),ZI=p({name:h(),owner:h(),remoteUrl:h()}),HI=p({_meta:_(h(),w()).nullish()}),VI=p({_meta:_(h(),w()).nullish(),jump:DI.nullish(),rename:FI.nullish(),searchAndReplace:HI.nullish()}),jI=p({id:h(),isRegex:Ee().nullish(),replace:h(),search:h(),uri:h()}),GI=H([x("automatic"),x("diagnostic"),x("manual")]),BI=p({_meta:_(h(),w()).nullish(),maxCount:N().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish()}),WI=p({_meta:_(h(),w()).nullish(),diagnostics:$I.nullish(),editHistory:II.nullish(),openFiles:OI.nullish(),recentFiles:LI.nullish(),relatedSnippets:UI.nullish(),userActions:BI.nullish()}),qI=p({_meta:_(h(),w()).nullish(),additionalDirectories:D(h()).optional(),cwd:h(),mcpServers:D(Ma)}),YI=p({default:N().nullish(),description:h().nullish(),maximum:N().nullish(),minimum:N().nullish(),title:h().nullish()}),_m=h(),KI=H([x("allow_once"),x("allow_always"),x("reject_once"),x("reject_always")]),JI=p({_meta:_(h(),w()).nullish(),kind:KI,name:h(),optionId:_m}),XI=H([x("high"),x("medium"),x("low")]),QI=H([x("pending"),x("in_progress"),x("completed")]),eP=p({_meta:_(h(),w()).nullish(),content:h(),priority:XI,status:QI}),tP=p({_meta:_(h(),w()).nullish(),entries:D(eP)}),mn=p({character:N().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}),line:N().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"})}),nP=p({id:h(),position:mn,uri:h()}),rP=p({id:h(),newName:h(),position:mn,uri:h()}),iP=p({action:h(),position:mn,timestampMs:N(),uri:h()}),Sm=H([x("utf-16"),x("utf-32"),x("utf-8")]),sP=p({_meta:_(h(),w()).nullish(),auth:NC.optional().default({terminal:!1}),elicitation:lI.nullish(),fs:hI.optional().default({readTextFile:!1,writeTextFile:!1}),nes:VI.nullish(),positionEncodings:D(Sm).optional(),terminal:Ee().optional().default(!1)}),oP=p({_meta:_(h(),w()).nullish(),audio:Ee().optional().default(!1),embeddedContext:Ee().optional().default(!1),image:Ee().optional().default(!1)}),km=N().int().gte(0).lte(65535),aP=p({_meta:_(h(),w()).nullish(),clientCapabilities:sP.optional().default({auth:{terminal:!1},fs:{readTextFile:!1,writeTextFile:!1},terminal:!1}),clientInfo:wm.nullish(),protocolVersion:km}),pi=p({end:mn,start:mn}),lP=p({message:h(),range:pi,severity:EI,uri:h()}),cP=p({languageId:h(),lastFocusedMs:N().nullish(),uri:h(),visibleRange:pi.nullish()}),uP=p({_meta:_(h(),w()).nullish(),diagnostics:D(lP).nullish(),editHistory:D(PI).nullish(),openFiles:D(cP).nullish(),recentFiles:D(zI).nullish(),relatedSnippets:D(NI).nullish(),userActions:D(iP).nullish()}),hP=p({newText:h(),range:pi}),dP=p({cursorPosition:mn.nullish(),edits:D(hP),id:h(),uri:h()}),fP=H([dP.and(p({kind:x("edit")})),nP.and(p({kind:x("jump")})),rP.and(p({kind:x("rename")})),jI.and(p({kind:x("searchAndReplace")}))]),pP=p({_meta:_(h(),w()).nullish(),content:h()}),gP=p({_meta:_(h(),w()).nullish()}),nr=H([N(),h()]).nullable();p({_meta:_(h(),w()).nullish(),requestId:nr});const mP=ea(["assistant","user"]),Ys=p({_meta:_(h(),w()).nullish(),audience:D(mP).nullish(),lastModified:h().nullish(),priority:N().nullish()}),yP=p({_meta:_(h(),w()).nullish(),annotations:Ys.nullish(),data:h(),mimeType:h()}),vP=p({_meta:_(h(),w()).nullish(),annotations:Ys.nullish(),data:h(),mimeType:h(),uri:h().nullish()}),bP=p({_meta:_(h(),w()).nullish(),annotations:Ys.nullish(),description:h().nullish(),mimeType:h().nullish(),name:h(),size:N().nullish(),title:h().nullish(),uri:h()}),wP=p({_meta:_(h(),w()).nullish(),optionId:_m}),_P=H([p({outcome:x("cancelled")}),wP.and(p({outcome:x("selected")}))]),SP=p({_meta:_(h(),w()).nullish(),outcome:_P}),kP=p({_meta:_(h(),w()).nullish()}),EP=p({_meta:_(h(),w()).nullish()}),$P=p({currentValue:Ee()}),AP=h(),Em=h(),xP=H([x("mode"),x("model"),x("thought_level"),h()]),Lu=h(),$m=p({_meta:_(h(),w()).nullish(),description:h().nullish(),name:h(),value:Lu}),TP=p({_meta:_(h(),w()).nullish(),group:AP,name:h(),options:D($m)}),CP=H([D($m),D(TP)]),IP=p({currentValue:Lu,options:CP}),gi=La(H([IP.and(p({type:x("select")})),$P.and(p({type:x("boolean")}))]),p({_meta:_(h(),w()).nullish(),category:xP.nullish(),description:h().nullish(),id:Em,name:h()})),PP=p({_meta:_(h(),w()).nullish(),configOptions:D(gi)}),RP=p({_meta:_(h(),w()).nullish()}),Y=h(),DP=p({_meta:_(h(),w()).nullish(),id:h(),sessionId:Y}),OP=p({_meta:_(h(),w()).nullish(),sessionId:Y}),zP=p({_meta:_(h(),w()).nullish(),sessionId:Y}),LP=p({_meta:_(h(),w()).nullish(),sessionId:Y}),Am=p({_meta:_(h(),w()).nullish(),args:D(h()).optional(),command:h(),cwd:h().nullish(),env:D(pm).optional(),outputByteLimit:N().nullish(),sessionId:Y}),MP=p({_meta:_(h(),w()).nullish(),sessionId:Y,uri:h()}),NP=p({_meta:_(h(),w()).nullish(),position:mn,sessionId:Y,uri:h(),version:N(),visibleRange:pi}),UP=p({_meta:_(h(),w()).nullish(),languageId:h(),sessionId:Y,text:h(),uri:h(),version:N()}),FP=p({_meta:_(h(),w()).nullish(),sessionId:Y,uri:h()}),ZP=p({_meta:_(h(),w()).nullish(),additionalDirectories:D(h()).optional(),cwd:h(),mcpServers:D(Ma).optional(),sessionId:Y}),xm=p({_meta:_(h(),w()).nullish(),sessionId:Y,terminalId:h()}),HP=p({_meta:_(h(),w()).nullish(),additionalDirectories:D(h()).optional(),cwd:h(),mcpServers:D(Ma),sessionId:Y}),Tm=p({_meta:_(h(),w()).nullish(),limit:N().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),line:N().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),path:h(),sessionId:Y}),VP=p({_meta:_(h(),w()).nullish(),id:h(),reason:MI.nullish(),sessionId:Y}),Cm=p({_meta:_(h(),w()).nullish(),sessionId:Y,terminalId:h()}),jP=p({_meta:_(h(),w()).nullish(),additionalDirectories:D(h()).optional(),cwd:h(),mcpServers:D(Ma).optional(),sessionId:Y}),GP=p({_meta:_(h(),w()).nullish(),additionalDirectories:D(h()).optional(),cwd:h(),sessionId:Y,title:h().nullish(),updatedAt:h().nullish()}),BP=p({_meta:_(h(),w()).nullish(),nextCursor:h().nullish(),sessions:D(GP)}),WP=p({_meta:_(h(),w()).nullish(),title:h().nullish(),updatedAt:h().nullish()}),qP=p({_meta:_(h(),w()).nullish()}),Na=h(),YP=p({_meta:_(h(),w()).nullish(),currentModeId:Na}),KP=p({_meta:_(h(),w()).nullish(),description:h().nullish(),id:Na,name:h()}),Ua=p({_meta:_(h(),w()).nullish(),availableModes:D(KP),currentModeId:Na}),Fa=p({_meta:_(h(),w()).nullish(),availableModels:D(kI),currentModelId:zu}),JP=p({_meta:_(h(),w()).nullish(),configOptions:D(gi).nullish(),models:Fa.nullish(),modes:Ua.nullish(),sessionId:Y}),XP=p({_meta:_(h(),w()).nullish(),configOptions:D(gi).nullish(),models:Fa.nullish(),modes:Ua.nullish()}),QP=p({_meta:_(h(),w()).nullish(),configOptions:D(gi).nullish(),models:Fa.nullish(),modes:Ua.nullish(),sessionId:Y}),e1=p({_meta:_(h(),w()).nullish(),configOptions:D(gi).nullish(),models:Fa.nullish(),modes:Ua.nullish()}),t1=p({_meta:_(h(),w()).nullish()}),n1=p({_meta:_(h(),w()).nullish(),additionalDirectories:kP.nullish(),close:EP.nullish(),fork:RP.nullish(),list:qP.nullish(),resume:t1.nullish()}),r1=La(H([p({type:x("boolean"),value:Ee()}),p({value:Lu})]),p({_meta:_(h(),w()).nullish(),configId:Em,sessionId:Y})),i1=p({_meta:_(h(),w()).nullish(),configOptions:D(gi)}),s1=p({_meta:_(h(),w()).nullish(),modeId:Na,sessionId:Y}),o1=p({_meta:_(h(),w()).nullish()}),a1=p({_meta:_(h(),w()).nullish(),modelId:zu,sessionId:Y}),l1=p({_meta:_(h(),w()).nullish()}),c1=p({_meta:_(h(),w()).nullish(),sessionId:Y}),u1=H([x("end_turn"),x("max_tokens"),x("max_turn_requests"),x("refusal"),x("cancelled")]),h1=H([x("email"),x("uri"),x("date"),x("date-time")]),d1=p({default:h().nullish(),description:h().nullish(),enum:D(h()).nullish(),format:h1.nullish(),maxLength:N().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),minLength:N().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),oneOf:D(fm).nullish(),pattern:h().nullish(),title:h().nullish()}),f1=p({_meta:_(h(),w()).nullish(),context:uP.nullish(),position:mn,selection:pi.nullish(),sessionId:Y,triggerKind:GI,uri:h(),version:N()}),p1=p({_meta:_(h(),w()).nullish(),suggestions:D(fP)}),g1=p({_meta:_(h(),w()).nullish(),terminalId:h()}),m1=p({_meta:_(h(),w()).nullish(),exitCode:N().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),signal:h().nullish()}),Im=p({_meta:_(h(),w()).nullish(),sessionId:Y,terminalId:h()}),y1=p({_meta:_(h(),w()).nullish(),exitStatus:m1.nullish(),output:h(),truncated:Ee()}),v1=p({_meta:_(h(),w()).nullish(),annotations:Ys.nullish(),text:h()}),b1=p({range:pi.nullish(),text:h()}),w1=p({_meta:_(h(),w()).nullish(),contentChanges:D(b1),sessionId:Y,uri:h(),version:N()});p({method:h(),params:H([OP,UP,w1,MP,FP,NP,DP,VP,mm]).nullish()});const _1=H([x("full"),x("incremental")]),S1=p({_meta:_(h(),w()).nullish(),syncKind:_1}),k1=p({_meta:_(h(),w()).nullish(),didChange:S1.nullish(),didClose:AI.nullish(),didFocus:xI.nullish(),didOpen:TI.nullish(),didSave:CI.nullish()}),E1=p({_meta:_(h(),w()).nullish(),document:k1.nullish()}),$1=p({_meta:_(h(),w()).nullish(),context:WI.nullish(),events:E1.nullish()}),A1=p({_meta:_(h(),w()).nullish(),auth:mI.optional().default({}),loadSession:Ee().optional().default(!1),mcpCapabilities:bI.optional().default({http:!1,sse:!1}),nes:$1.nullish(),positionEncoding:Sm.nullish(),promptCapabilities:oP.optional().default({audio:!1,embeddedContext:!1,image:!1}),sessionCapabilities:n1.optional().default({})}),x1=p({_meta:_(h(),w()).nullish(),agentCapabilities:A1.optional().default({auth:{},loadSession:!1,mcpCapabilities:{http:!1,sse:!1},promptCapabilities:{audio:!1,embeddedContext:!1,image:!1},sessionCapabilities:{}}),agentInfo:wm.nullish(),authMethods:D(VC).optional().default([]),protocolVersion:km}),T1=p({_meta:_(h(),w()).nullish(),mimeType:h().nullish(),text:h(),uri:h()}),C1=H([T1,BC]),I1=p({_meta:_(h(),w()).nullish(),annotations:Ys.nullish(),resource:C1}),Mu=H([v1.and(p({type:x("text")})),vP.and(p({type:x("image")})),yP.and(p({type:x("audio")})),bP.and(p({type:x("resource_link")})),I1.and(p({type:x("resource")}))]),P1=p({_meta:_(h(),w()).nullish(),content:Mu}),zl=p({_meta:_(h(),w()).nullish(),content:Mu,messageId:h().nullish()}),R1=p({_meta:_(h(),w()).nullish(),messageId:h().nullish(),prompt:D(Mu),sessionId:Y}),D1=p({anyOf:D(fm)}),Pm=H([P1.and(p({type:x("content")})),XC.and(p({type:x("diff")})),g1.and(p({type:x("terminal")}))]),Rm=h(),Dm=p({_meta:_(h(),w()).nullish(),line:N().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),path:h()}),Om=H([x("pending"),x("in_progress"),x("completed"),x("failed")]),zm=H([x("read"),x("edit"),x("delete"),x("move"),x("search"),x("execute"),x("think"),x("fetch"),x("switch_mode"),x("other")]),O1=p({_meta:_(h(),w()).nullish(),content:D(Pm).optional(),kind:zm.optional(),locations:D(Dm).optional(),rawInput:w().optional(),rawOutput:w().optional(),status:Om.optional(),title:h(),toolCallId:Rm}),Lm=p({_meta:_(h(),w()).nullish(),content:D(Pm).nullish(),kind:zm.nullish(),locations:D(Dm).nullish(),rawInput:w().optional(),rawOutput:w().optional(),status:Om.nullish(),title:h().nullish(),toolCallId:Rm}),Mm=p({_meta:_(h(),w()).nullish(),options:D(JI),sessionId:Y,toolCall:Lm}),z1=p({_meta:_(h(),w()).nullish(),hint:h()}),L1=z1,M1=p({_meta:_(h(),w()).nullish(),description:h(),input:L1.nullish(),name:h()}),N1=p({_meta:_(h(),w()).nullish(),availableCommands:D(M1)}),U1=p({enum:D(h()),type:oI}),F1=H([U1,D1]),Z1=p({default:D(h()).nullish(),description:h().nullish(),items:F1,maxItems:N().nullish(),minItems:N().nullish(),title:h().nullish()}),H1=H([d1.and(p({type:x("string")})),YI.and(p({type:x("number")})),dI.and(p({type:x("integer")})),WC.and(p({type:x("boolean")})),Z1.and(p({type:x("array")}))]),V1=p({description:h().nullish(),properties:_(h(),H1).optional().default({}),required:D(h()).nullish(),title:h().nullish(),type:sI.optional().default("object")}),j1=p({requestedSchema:V1}),G1=La(H([j1.and(p({mode:x("form")})),cI.and(p({mode:x("url")}))]),p({_meta:_(h(),w()).nullish(),message:h(),sessionId:Y})),B1=p({cachedReadTokens:N().nullish(),cachedWriteTokens:N().nullish(),inputTokens:N(),outputTokens:N(),thoughtTokens:N().nullish(),totalTokens:N()}),W1=p({_meta:_(h(),w()).nullish(),stopReason:u1,usage:B1.nullish(),userMessageId:h().nullish()});H([p({id:nr,result:H([x1,GC,vI,QP,XP,BP,JP,e1,YC,o1,i1,W1,l1,c1,p1,qC,vm])}),p({error:gm,id:nr})]);const q1=p({_meta:_(h(),w()).nullish(),cost:KC.nullish(),size:N(),used:N()}),Y1=H([zl.and(p({sessionUpdate:x("user_message_chunk")})),zl.and(p({sessionUpdate:x("agent_message_chunk")})),zl.and(p({sessionUpdate:x("agent_thought_chunk")})),O1.and(p({sessionUpdate:x("tool_call")})),Lm.and(p({sessionUpdate:x("tool_call_update")})),tP.and(p({sessionUpdate:x("plan")})),N1.and(p({sessionUpdate:x("available_commands_update")})),YP.and(p({sessionUpdate:x("current_mode_update")})),PP.and(p({sessionUpdate:x("config_option_update")})),WP.and(p({sessionUpdate:x("session_info_update")})),q1.and(p({sessionUpdate:x("usage_update")}))]),Nm=p({_meta:_(h(),w()).nullish(),sessionId:Y,update:Y1});p({method:h(),params:H([Nm,rI,mm]).nullish()});const Um=p({_meta:_(h(),w()).nullish(),sessionId:Y,terminalId:h()}),K1=p({_meta:_(h(),w()).nullish(),exitCode:N().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),signal:h().nullish()}),J1=p({name:h(),uri:h()}),X1=p({_meta:_(h(),w()).nullish(),repository:ZI.nullish(),workspaceFolders:D(J1).nullish(),workspaceUri:h().nullish()});p({id:nr,method:h(),params:H([aP,jC,yI,qI,HP,pI,ZP,jP,LP,s1,r1,R1,a1,X1,f1,zP,ym]).nullish()});const Fm=p({_meta:_(h(),w()).nullish(),content:h(),path:h(),sessionId:Y});p({id:nr,method:h(),params:H([Fm,Tm,Mm,Am,Im,Cm,Um,xm,G1,ym]).nullish()});const Q1=p({_meta:_(h(),w()).nullish()});H([p({id:nr,result:H([Q1,pP,SP,JC,y1,gP,K1,fI,iI,vm])}),p({error:gm,id:nr})]);var q;class eR{constructor(e,t){S(this,q);const r=e(this),i=async(o,a)=>{var l,u,d,f,v,y,A;switch(o){case Dt.fs_write_text_file:{const k=Fm.parse(a);return(l=r.writeTextFile)==null?void 0:l.call(r,k)}case Dt.fs_read_text_file:{const k=Tm.parse(a);return(u=r.readTextFile)==null?void 0:u.call(r,k)}case Dt.session_request_permission:{const k=Mm.parse(a);return r.requestPermission(k)}case Dt.terminal_create:{const k=Am.parse(a);return(d=r.createTerminal)==null?void 0:d.call(r,k)}case Dt.terminal_output:{const k=Im.parse(a);return(f=r.terminalOutput)==null?void 0:f.call(r,k)}case Dt.terminal_release:{const k=Cm.parse(a);return await((v=r.releaseTerminal)==null?void 0:v.call(r,k))??{}}case Dt.terminal_wait_for_exit:{const k=Um.parse(a);return(y=r.waitForTerminalExit)==null?void 0:y.call(r,k)}case Dt.terminal_kill:{const k=xm.parse(a);return await((A=r.killTerminal)==null?void 0:A.call(r,k))??{}}default:if(r.extMethod)return r.extMethod(o,a);throw we.methodNotFound(o)}},s=async(o,a)=>{switch(o){case Dt.session_update:{const l=Nm.parse(a);return r.sessionUpdate(l)}default:if(r.extNotification)return r.extNotification(o,a);throw we.methodNotFound(o)}};E(this,q,new tR(i,s,t))}async initialize(e){return await c(this,q).sendRequest(se.initialize,e)}async newSession(e){return await c(this,q).sendRequest(se.session_new,e)}async loadSession(e){return await c(this,q).sendRequest(se.session_load,e)??{}}async unstable_forkSession(e){return await c(this,q).sendRequest(se.session_fork,e)}async listSessions(e){return await c(this,q).sendRequest(se.session_list,e)}async unstable_resumeSession(e){return await c(this,q).sendRequest(se.session_resume,e)}async unstable_closeSession(e){return await c(this,q).sendRequest(se.session_close,e)}async setSessionMode(e){return await c(this,q).sendRequest(se.session_set_mode,e)??{}}async unstable_setSessionModel(e){return await c(this,q).sendRequest(se.session_set_model,e)??{}}async setSessionConfigOption(e){return await c(this,q).sendRequest(se.session_set_config_option,e)}async authenticate(e){return await c(this,q).sendRequest(se.authenticate,e)??{}}async unstable_logout(e){return await c(this,q).sendRequest(se.logout,e)??{}}async prompt(e){return await c(this,q).sendRequest(se.session_prompt,e)}async cancel(e){return await c(this,q).sendNotification(se.session_cancel,e)}async unstable_startNes(e){return await c(this,q).sendRequest(se.nes_start,e)}async unstable_suggestNes(e){return await c(this,q).sendRequest(se.nes_suggest,e)}async unstable_closeNes(e){return await c(this,q).sendRequest(se.nes_close,e)??{}}async unstable_didOpenDocument(e){return await c(this,q).sendNotification(se.document_did_open,e)}async unstable_didChangeDocument(e){return await c(this,q).sendNotification(se.document_did_change,e)}async unstable_didCloseDocument(e){return await c(this,q).sendNotification(se.document_did_close,e)}async unstable_didSaveDocument(e){return await c(this,q).sendNotification(se.document_did_save,e)}async unstable_didFocusDocument(e){return await c(this,q).sendNotification(se.document_did_focus,e)}async unstable_acceptNes(e){return await c(this,q).sendNotification(se.nes_accept,e)}async unstable_rejectNes(e){return await c(this,q).sendNotification(se.nes_reject,e)}async extMethod(e,t){return await c(this,q).sendRequest(e,t)}async extNotification(e,t){return await c(this,q).sendNotification(e,t)}get signal(){return c(this,q).signal}get closed(){return c(this,q).closed}}q=new WeakMap;var sn,ca,ls,cs,Or,zr,St,us,ue,Zm,yc,Hm,Vm,jm,Gm,vc,Li;class tR{constructor(e,t,r){S(this,ue);S(this,sn,new Map);S(this,ca,0);S(this,ls);S(this,cs);S(this,Or);S(this,zr,Promise.resolve());S(this,St,new AbortController);S(this,us);E(this,ls,e),E(this,cs,t),E(this,Or,r),E(this,us,new Promise(i=>{c(this,St).signal.addEventListener("abort",()=>i())})),m(this,ue,Zm).call(this)}get signal(){return c(this,St).signal}get closed(){return c(this,us)}async sendRequest(e,t){m(this,ue,vc).call(this);const r=$h(this,ca)._++,i=new Promise((s,o)=>{c(this,sn).set(r,{resolve:s,reject:o})});return await m(this,ue,Li).call(this,{jsonrpc:"2.0",id:r,method:e,params:t}),i}async sendNotification(e,t){m(this,ue,vc).call(this),await m(this,ue,Li).call(this,{jsonrpc:"2.0",method:e,params:t})}}sn=new WeakMap,ca=new WeakMap,ls=new WeakMap,cs=new WeakMap,Or=new WeakMap,zr=new WeakMap,St=new WeakMap,us=new WeakMap,ue=new WeakSet,Zm=async function(){let e;try{const t=c(this,Or).readable.getReader();try{for(;!c(this,St).signal.aborted;){const{value:r,done:i}=await t.read();if(i)break;if(r)try{m(this,ue,Hm).call(this,r)}catch(s){console.error("Unexpected error during message processing:",r,s),"id"in r&&r.id!==void 0&&m(this,ue,Li).call(this,{jsonrpc:"2.0",id:r.id,error:{code:-32700,message:"Parse error"}})}}}finally{t.releaseLock()}}catch(t){e=t}finally{m(this,ue,yc).call(this,e)}},yc=function(e){if(c(this,St).signal.aborted)return;const t=e??new Error("ACP connection closed");for(const r of c(this,sn).values())r.reject(t);c(this,sn).clear(),c(this,St).abort(t)},Hm=async function(e){if("method"in e&&"id"in e){const t=await m(this,ue,Vm).call(this,e.method,e.params);"error"in t&&console.error("Error handling request",e,t.error),await m(this,ue,Li).call(this,{jsonrpc:"2.0",id:e.id,...t})}else if("method"in e){const t=await m(this,ue,jm).call(this,e.method,e.params);"error"in t&&console.error("Error handling notification",e,t.error)}else"id"in e?m(this,ue,Gm).call(this,e):console.error("Invalid message",{message:e})},Vm=async function(e,t){try{return{result:await c(this,ls).call(this,e,t)??null}}catch(r){if(r instanceof we)return r.toResult();if(r instanceof mf)return we.invalidParams(r.format()).toResult();let i;(r instanceof Error||typeof r=="object"&&r!=null&&"message"in r&&typeof r.message=="string")&&(i=r.message);try{return we.internalError(i?JSON.parse(i):{}).toResult()}catch{return we.internalError({details:i}).toResult()}}},jm=async function(e,t){try{return await c(this,cs).call(this,e,t),{result:null}}catch(r){if(r instanceof we)return r.toResult();if(r instanceof mf)return we.invalidParams(r.format()).toResult();let i;(r instanceof Error||typeof r=="object"&&r!=null&&"message"in r&&typeof r.message=="string")&&(i=r.message);try{return we.internalError(i?JSON.parse(i):{}).toResult()}catch{return we.internalError({details:i}).toResult()}}},Gm=function(e){const t=c(this,sn).get(e.id);if(t){if("result"in e)t.resolve(e.result);else if("error"in e){const{code:r,message:i,data:s}=e.error;t.reject(new we(r,i,s))}c(this,sn).delete(e.id)}else console.error("Got response to unknown request",e.id)},vc=function(){if(c(this,St).signal.aborted)throw c(this,St).signal.reason??new Error("ACP connection closed")},Li=async function(e){return E(this,zr,c(this,zr).then(async()=>{const t=c(this,Or).writable.getWriter();try{await t.write(e)}finally{t.releaseLock()}}).catch(t=>{m(this,ue,yc).call(this,t)})),c(this,zr)};class we extends Error{constructor(t,r,i){super(r);b(this,"code");b(this,"data");this.code=t,this.name="RequestError",this.data=i}static parseError(t,r){return new we(-32700,`Parse error${r?`: ${r}`:""}`,t)}static invalidRequest(t,r){return new we(-32600,`Invalid request${r?`: ${r}`:""}`,t)}static methodNotFound(t){return new we(-32601,`"Method not found": ${t}`,{method:t})}static invalidParams(t,r){return new we(-32602,`Invalid params${r?`: ${r}`:""}`,t)}static internalError(t,r){return new we(-32603,`Internal error${r?`: ${r}`:""}`,t)}static authRequired(t,r){return new we(-32e3,`Authentication required${r?`: ${r}`:""}`,t)}static resourceNotFound(t){return new we(-32002,`Resource not found${t?`: ${t}`:""}`,t&&{uri:t})}toResult(){return{error:{code:this.code,message:this.message,data:this.data}}}toErrorResponse(){return{code:this.code,message:this.message,data:this.data}}}const nR=/^Sender \(untrusted metadata\):\n```json\n[\s\S]*?\n```\n\n?/,rR=/^\[[^\n]*Working directory:[^\n]*\]\n\n?/,iR=/\[Television screen context\][\s\S]*?\[\/Television screen context\]\n*/,sR=/\[\[\s*(?:reply_to_current|reply_to\s*:\s*[^\]\n]+|audio_as_voice)\s*\]\]\s*/gi,oR="single_session",aR={name:"television-acp-client",version:"0.0.0"},Bm="agent:main:television",lR=di(Tt);var ee,Nt,Lr,Ut,Hn,Vn,on,Mr,kt,lt,an,jn,Ft,ln,hs,Zt,ct,ua,Ht,C,Wm,qm,bc,Ym,Km,Jm,Xm,Qm,ey,ty,Tn,kr,Er,We,ny,$r,wc,_c,Mo,ry,ds,fs,Sc,Ar,iy,sy;class cR extends lR{constructor(t){super();S(this,C);S(this,ee,uR());S(this,Nt,null);S(this,Lr,null);S(this,Ut,null);S(this,Hn,null);S(this,Vn,null);S(this,on,null);S(this,Mr,1);S(this,kt,null);S(this,lt,null);S(this,an,!1);S(this,jn,!1);S(this,Ft,null);S(this,ln,new Set);S(this,hs);S(this,Zt);S(this,ct);S(this,ua,t=>{m(this,C,qm).call(this,t)});S(this,Ht,null);S(this,ds,()=>{m(this,C,Ar).call(this,"ACP bridge websocket closed")});S(this,fs,()=>{m(this,C,Ar).call(this,"ACP bridge websocket error")});E(this,Zt,t),E(this,ct,t.sessionMode??oR),E(this,hs,t.createSocket??(r=>new WebSocket(r)))}getState(){return c(this,ee)}get messages(){return c(this,ee).messageOrder.map(t=>c(this,ee).messagesById[t]).filter(t=>t!==void 0)}async connect(){if(this.disposed)throw new Error("ACPClient has been disposed");if(c(this,ee).lifecycle.status!=="ready"){m(this,C,We).call(this,{lifecycle:{status:"connecting"}}),c(this,Lr)??E(this,Lr,m(this,C,Wm).call(this));try{await c(this,Lr),await m(this,C,bc).call(this)}catch(t){throw m(this,C,Ar).call(this,bo(t)),t}}}dispose(){m(this,C,Sc).call(this),m(this,C,We).call(this,{lifecycle:{status:"disposed"},run:{status:"idle",stopReason:null,canCancel:!1,error:null}})}async sendMessage(t){if(await this.connect(),c(this,ee).lifecycle.status!=="ready"||c(this,ee).run.status==="running"||c(this,ee).run.status==="cancelling")throw new Error("ACPClient is not ready to send a new message");const r=t.text.trim();if(!r)throw new Error("Cannot send an empty message");m(this,C,kr).call(this,{id:m(this,C,$r).call(this,"user"),kind:"user",text:r,status:"final"}),m(this,C,We).call(this,{run:{status:"running",stopReason:null,canCancel:!0,error:null}});try{const i=await m(this,C,Mo).call(this).prompt({sessionId:m(this,C,_c).call(this),prompt:[{type:"text",text:m(this,C,ny).call(this,r)}]});m(this,C,Tn).call(this,i.stopReason==="cancelled"?"cancelled":"final"),m(this,C,We).call(this,{run:{status:i.stopReason==="cancelled"?"cancelled":"completed",stopReason:i.stopReason,canCancel:!1,error:null}})}catch(i){throw m(this,C,sy).call(this)||(m(this,C,Tn).call(this,"error"),m(this,C,We).call(this,{run:{status:"error",stopReason:null,canCancel:!1,error:bo(i)}})),i}}async cancel(){if(await this.connect(),!c(this,ee).run.canCancel||c(this,ee).run.status!=="running")throw new Error("No active cancellable run");m(this,C,We).call(this,{run:{...c(this,ee).run,status:"cancelling"}}),await m(this,C,Mo).call(this).cancel({sessionId:m(this,C,_c).call(this)})}setScreenContext(t){var s,o,a;const r={screenID:t.screenID,screenName:t.screenName};if(((s=c(this,lt))==null?void 0:s.screenID)===r.screenID&&((o=c(this,lt))==null?void 0:o.screenName)===r.screenName)return;const i=((a=c(this,lt))==null?void 0:a.screenID)??null;if(E(this,lt,r),c(this,ct)==="single_session"){(!c(this,on)||i!==r.screenID)&&E(this,an,!0);return}c(this,on)!==Sf(c(this,ct),r.screenID,c(this,Zt).clientGUID??"default-client")&&(E(this,Ut,null),E(this,Hn,null),c(this,Nt)&&c(this,ee).run.status==="idle"&&m(this,C,bc).call(this).catch(l=>{m(this,C,Ar).call(this,bo(l))}))}}ee=new WeakMap,Nt=new WeakMap,Lr=new WeakMap,Ut=new WeakMap,Hn=new WeakMap,Vn=new WeakMap,on=new WeakMap,Mr=new WeakMap,kt=new WeakMap,lt=new WeakMap,an=new WeakMap,jn=new WeakMap,Ft=new WeakMap,ln=new WeakMap,hs=new WeakMap,Zt=new WeakMap,ct=new WeakMap,ua=new WeakMap,Ht=new WeakMap,C=new WeakSet,Wm=async function(){try{m(this,C,We).call(this,{lifecycle:{status:"connecting"}});const{stream:t,socket:r}=await fR({serverURL:c(this,Zt).serverURL,token:c(this,Zt).token,createSocket:c(this,hs),onDisconnect:c(this,ua)});E(this,Ht,r),r.addEventListener("close",c(this,ds)),r.addEventListener("error",c(this,fs)),E(this,Nt,new eR(i=>({connection:i,sessionUpdate:async s=>{await m(this,C,Km).call(this,s)},requestPermission:async s=>m(this,C,Jm).call(this,s)}),t)),await c(this,Nt).initialize({protocolVersion:MC,clientCapabilities:{},clientInfo:aR})}catch(t){throw t}},qm=function(t){m(this,C,Ar).call(this,bo(t))},bc=async function(){const t=m(this,C,ry).call(this);if(c(this,Ut)&&c(this,Hn)===t){await c(this,Ut);return}E(this,Hn,t),E(this,Ut,m(this,C,Ym).call(this,t)),await c(this,Ut)},Ym=async function(t){const r=m(this,C,Mo).call(this);m(this,C,iy).call(this);let i,s=!1;try{E(this,jn,!0),E(this,Ft,null),await r.loadSession({sessionId:t,cwd:"/",mcpServers:[],_meta:{sessionKey:t}}),i=t,s=c(this,ee).messageOrder.length>0}catch{i=(await r.newSession({cwd:"/",mcpServers:[],_meta:{sessionKey:t}})).sessionId,s=!1}finally{E(this,jn,!1),E(this,Ft,null),m(this,C,Tn).call(this,"final")}await r.setSessionConfigOption({sessionId:i,configId:"verbose_level",value:"full"}),E(this,Vn,i),E(this,on,t),s?(c(this,ln).add(t),c(this,ct)==="single_session"&&E(this,an,!1)):(c(this,ln).delete(t),E(this,an,c(this,ct)==="single_session")),m(this,C,We).call(this,{lifecycle:{status:"ready"}})},Km=async function(t){const r=t.update;switch(r.sessionUpdate){case"user_message_chunk":r.content.type==="text"&&m(this,C,ty).call(this,r.content.text);return;case"agent_message_chunk":r.content.type==="text"&&m(this,C,Xm).call(this,r.content.text);return;case"tool_call":m(this,C,Qm).call(this,r);return;case"tool_call_update":m(this,C,ey).call(this,r);return;case"agent_thought_chunk":return;default:return}},Jm=async function(t){return{outcome:{outcome:"cancelled"}}},Xm=function(t){E(this,Ft,null);const r=hR(t);if(!r)return;if(!c(this,kt)){const s={id:m(this,C,$r).call(this,"assistant"),kind:"assistant",text:r,status:"streaming"};E(this,kt,s.id),m(this,C,kr).call(this,s);return}const i=c(this,ee).messagesById[c(this,kt)];if(!i||i.kind!=="assistant")throw new Error("Open assistant message invariant violated");m(this,C,Er).call(this,{...i,text:`${i.text}${r}`,status:"streaming"})},Qm=function(t){m(this,C,Tn).call(this,"final");const r=m(this,C,wc).call(this,t.toolCallId),i={id:(r==null?void 0:r.id)??m(this,C,$r).call(this,"tool"),kind:"tool_call",toolCallId:t.toolCallId,title:t.title,toolKind:t.kind??"other",status:t.status==="failed"?"failed":t.status==="completed"?"completed":"in_progress",text:(r==null?void 0:r.text)??"",locations:t.locations??(r==null?void 0:r.locations)};if(r){m(this,C,Er).call(this,i);return}m(this,C,kr).call(this,i)},ey=function(t){const r=m(this,C,wc).call(this,t.toolCallId),i=(r==null?void 0:r.text)??"",s=dR(t.content),o=s?`${i}${s}`:i,a={id:(r==null?void 0:r.id)??m(this,C,$r).call(this,"tool"),kind:"tool_call",toolCallId:t.toolCallId,title:(r==null?void 0:r.title)??t.toolCallId,toolKind:(r==null?void 0:r.toolKind)??"other",status:t.status==="failed"?"failed":t.status==="completed"?"completed":"in_progress",text:o,locations:t.locations??(r==null?void 0:r.locations)};if(r){m(this,C,Er).call(this,a);return}m(this,C,kr).call(this,a)},ty=function(t){if(m(this,C,Tn).call(this,"final"),!t)return;const r=c(this,jn)?c(this,Ft):null;if(!r){const s=kf(t);if(!s)return;const o={id:m(this,C,$r).call(this,"user"),kind:"user",text:s,status:"final"};m(this,C,kr).call(this,o),c(this,jn)&&E(this,Ft,o.id);return}const i=c(this,ee).messagesById[r];if(!i||i.kind!=="user")throw new Error("Replay user message invariant violated");m(this,C,Er).call(this,{...i,text:kf(`${i.text}${t}`)})},Tn=function(t){if(!c(this,kt))return;const r=c(this,ee).messagesById[c(this,kt)];(r==null?void 0:r.kind)==="assistant"&&m(this,C,Er).call(this,{...r,status:t}),E(this,kt,null)},kr=function(t){m(this,C,We).call(this,{messagesById:{...c(this,ee).messagesById,[t.id]:t},messageOrder:[...c(this,ee).messageOrder,t.id]})},Er=function(t){m(this,C,We).call(this,{messagesById:{...c(this,ee).messagesById,[t.id]:t}})},We=function(t){const r={...c(this,ee),...t};E(this,ee,{...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 Q("change"))},ny=function(t){const r=c(this,on);return!c(this,lt)||!r||!(c(this,ct)==="single_session"?c(this,an)||!c(this,ln).has(r):!c(this,ln).has(r))?t:(E(this,an,!1),c(this,ln).add(r),["[Television screen context]","This chat session is coming from a Television client in the screen below.",`screen_id: ${c(this,lt).screenID}`,`screen_name: ${c(this,lt).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]","",t].join(`
43
+ `))},$r=function(t){const r=`${t}-${c(this,Mr)}`;return E(this,Mr,c(this,Mr)+1),r},wc=function(t){for(const r of c(this,ee).messageOrder){const i=c(this,ee).messagesById[r];if((i==null?void 0:i.kind)==="tool_call"&&i.toolCallId===t)return i}return null},_c=function(){if(!c(this,Vn))throw new Error("ACP session is not ready");return c(this,Vn)},Mo=function(){if(!c(this,Nt))throw new Error("ACP connection is not ready");return c(this,Nt)},ry=function(){var r;if(c(this,ct)==="single_session")return`${Bm}-${(c(this,Zt).clientGUID??"default-client").toLowerCase()}`;const t=(r=c(this,lt))==null?void 0:r.screenID;if(!t)throw new Error("Screen context is required for per-screen session mode");return Sf(c(this,ct),t,c(this,Zt).clientGUID??"default-client")},ds=new WeakMap,fs=new WeakMap,Sc=function(){E(this,Nt,null),E(this,Lr,null),E(this,Ut,null),E(this,Hn,null),E(this,Vn,null),E(this,on,null),c(this,Ht)&&(c(this,Ht).removeEventListener("close",c(this,ds)),c(this,Ht).removeEventListener("error",c(this,fs)),c(this,Ht).close(),E(this,Ht,null))},Ar=function(t){this.disposed||c(this,ee).lifecycle.status==="disconnected"||(m(this,C,Tn).call(this,"error"),m(this,C,Sc).call(this),m(this,C,We).call(this,{lifecycle:{status:"disconnected",...t?{error:t}:{}},run:{status:"idle",stopReason:null,canCancel:!1,error:null}}))},iy=function(){E(this,kt,null),E(this,Ft,null),E(this,Mr,1),m(this,C,We).call(this,{run:{status:"idle",stopReason:null,canCancel:!1,error:null},messagesById:{},messageOrder:[]})},sy=function(){return c(this,ee).lifecycle.status==="disconnected"};function uR(){return{lifecycle:{status:"connecting"},run:{status:"idle",stopReason:null,canCancel:!1,error:null},messagesById:{},messageOrder:[],sendDisabled:!0,cancelDisabled:!0}}function Sf(n,e,t){return n==="single_session"?`${Bm}-${t.toLowerCase()}`:`agent:main:television-${t.toLowerCase()}-${e.toLowerCase()}`}function oy(n){return n.replace(/^(?:\s*\n)+/,"")}function kf(n){let e=n;return e=e.replace(nR,""),e=e.replace(rR,""),e=e.replace(iR,""),e=oy(e),e}function hR(n){let e=n;return e=e.replace(sR,""),e=oy(e),e}function dR(n){return!n||n.length===0?"":n.flatMap(e=>e.type==="content"&&e.content.type==="text"?[e.content.text]:[]).join("")}async function fR(n){const e=n.createSocket(gR(n.serverURL,n.token));let t=!1,r,i;const s=new Promise((l,u)=>{r=l,i=u}),o=new ReadableStream({start(l){let u=!1;const d=()=>{e.send(JSON.stringify({type:"acp-bridge-connect"}))},f=A=>{const k=pR(A);if(!k)return;let I;try{I=JSON.parse(k)}catch(G){const P=G instanceof Error?G:new Error(String(G));i(P),l.error(P);return}switch(I.type){case"acp-bridge-status":if(I.status==="ready"){t||(t=!0,r());return}if(I.status==="error"||I.status==="exited"){const G=new Error(I.error??`ACP bridge ${I.status}`);t||i(G),l.error(G)}return;case"acp-bridge-message":l.enqueue(I.message);return}},v=()=>{var k;if(u)return;u=!0;const A=new Error("ACP bridge websocket closed");t||i(A),(k=n.onDisconnect)==null||k.call(n,A),l.close()},y=()=>{var k;if(u)return;u=!0;const A=new Error("ACP bridge websocket error");t||i(A),(k=n.onDisconnect)==null||k.call(n,A),l.error(A)};e.addEventListener("open",d),e.addEventListener("message",f),e.addEventListener("close",v),e.addEventListener("error",y)}}),a=new WritableStream({async write(l){await s,e.send(JSON.stringify({type:"acp-bridge-message",message:l}))},close(){e.close()},abort(){e.close()}});return await s,{stream:{readable:o,writable:a},socket:e}}function pR(n){if(typeof n=="string")return n;if(n instanceof Uint8Array)return new TextDecoder().decode(n);if(typeof Buffer<"u"&&n instanceof Buffer)return n.toString("utf8");if(typeof n=="object"&&n!==null&&"data"in n){const e=n.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 gR(n,e){const t=new URL(n);return t.protocol=t.protocol==="https:"?"wss:":"ws:",t.pathname="/acp",t.search="",t.searchParams.set("token",e),t.hash="",t.toString()}function bo(n){return n instanceof Error?n.message:String(n)}const Ef="television.acpClientGUID",mR=di(Tt);class yR extends mR{constructor(t){super();b(this,"screenManager");b(this,"clients",new Map);b(this,"options");b(this,"sessionMode");b(this,"clientGUID");b(this,"activeClient",null);b(this,"handleActiveScreenChanged",()=>{this.syncActiveClient()});this.screenManager=t.screenManager,this.sessionMode=t.sessionMode??"single_session",this.options={serverURL:t.serverURL,token:t.token,...t.createSocket?{createSocket:t.createSocket}:{},...t.sessionMode?{sessionMode:t.sessionMode}:{}},this.clientGUID=t.clientGUID??vR(t.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 t of this.clients.values())t.dispose();this.clients.clear(),this.activeClient=null}syncActiveClient(){const t=this.screenManager.activeScreen,r=t?this.getClientForScreen(t):null;this.activeClient!==r&&(this.activeClient=r,this.dispatchEvent(new Q("change")))}getClientForScreen(t){const r=this.sessionMode==="single_session"?"single_session":t.id;let i=this.clients.get(r);return i||(i=new cR({...this.options,sessionMode:this.sessionMode,clientGUID:this.clientGUID}),this.clients.set(r,i)),i.setScreenContext({screenID:t.id,screenName:t.name}),i}}function vR(n){const e=n.getItem(Ef);if(e)return e;const t=Eu().toLowerCase();return n.setItem(Ef,t),t}const bR="serverURL",wR="token",_R="mode",SR="electron";function ay(n=window.location.search,e=window.location.origin){const r=new URLSearchParams(n).get(bR);return r?new URL(r).origin:new URL(e).origin}function ly(n=window.location.search){return new URLSearchParams(n).get(wR)}function cy(n=window.location.search){return new URLSearchParams(n).get(_R)===SR}/**
44
44
  * @license
45
45
  * Copyright 2017 Google LLC
46
46
  * SPDX-License-Identifier: BSD-3-Clause
47
- */const qi=globalThis,$f=n=>n,ta=qi.trustedTypes,Af=ta?ta.createPolicy("lit-html",{createHTML:n=>n}):void 0,dy="$lit$",en=`lit$${Math.random().toFixed(9).slice(2)}$`,fy="?"+en,xR=`<${fy}>`,rr=document,Xi=()=>rr.createComment(""),Qi=n=>n===null||typeof n!="object"&&typeof n!="function",Lu=Array.isArray,TR=n=>Lu(n)||typeof(n==null?void 0:n[Symbol.iterator])=="function",Ol=`[
48
- \f\r]`,$i=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,xf=/-->/g,Tf=/>/g,An=RegExp(`>|${Ol}(?:([^\\s"'>=/]+)(${Ol}*=${Ol}*(?:[^
49
- \f\r"'\`<>=]|("|')|))|$)`,"g"),Cf=/'/g,If=/"/g,py=/^(?:script|style|textarea|title)$/i,CR=n=>(e,...t)=>({_$litType$:n,strings:e,values:t}),F=CR(1),ti=Symbol.for("lit-noChange"),oe=Symbol.for("lit-nothing"),Pf=new WeakMap,Ln=rr.createTreeWalker(rr,129);function gy(n,e){if(!Lu(n)||!n.hasOwnProperty("raw"))throw Error("invalid template strings array");return Af!==void 0?Af.createHTML(e):e}const IR=(n,e)=>{const t=n.length-1,r=[];let i,s=e===2?"<svg>":e===3?"<math>":"",o=$i;for(let a=0;a<t;a++){const l=n[a];let u,d,f=-1,v=0;for(;v<l.length&&(o.lastIndex=v,d=o.exec(l),d!==null);)v=o.lastIndex,o===$i?d[1]==="!--"?o=xf:d[1]!==void 0?o=Tf:d[2]!==void 0?(py.test(d[2])&&(i=RegExp("</"+d[2],"g")),o=An):d[3]!==void 0&&(o=An):o===An?d[0]===">"?(o=i??$i,f=-1):d[1]===void 0?f=-2:(f=o.lastIndex-d[2].length,u=d[1],o=d[3]===void 0?An:d[3]==='"'?If:Cf):o===If||o===Cf?o=An:o===xf||o===Tf?o=$i:(o=An,i=void 0);const y=o===An&&n[a+1].startsWith("/>")?" ":"";s+=o===$i?l+xR:f>=0?(r.push(u),l.slice(0,f)+dy+l.slice(f)+en+y):l+en+(f===-2?a:y)}return[gy(n,s+(n[t]||"<?>")+(e===2?"</svg>":e===3?"</math>":"")),r]};class es{constructor({strings:e,_$litType$:t},r){let i;this.parts=[];let s=0,o=0;const a=e.length-1,l=this.parts,[u,d]=IR(e,t);if(this.el=es.createElement(u,r),Ln.currentNode=this.el.content,t===2||t===3){const f=this.el.content.firstChild;f.replaceWith(...f.childNodes)}for(;(i=Ln.nextNode())!==null&&l.length<a;){if(i.nodeType===1){if(i.hasAttributes())for(const f of i.getAttributeNames())if(f.endsWith(dy)){const v=d[o++],y=i.getAttribute(f).split(en),A=/([.?@])?(.*)/.exec(v);l.push({type:1,index:s,name:A[2],strings:y,ctor:A[1]==="."?RR:A[1]==="?"?DR:A[1]==="@"?OR:Za}),i.removeAttribute(f)}else f.startsWith(en)&&(l.push({type:6,index:s}),i.removeAttribute(f));if(py.test(i.tagName)){const f=i.textContent.split(en),v=f.length-1;if(v>0){i.textContent=ta?ta.emptyScript:"";for(let y=0;y<v;y++)i.append(f[y],Xi()),Ln.nextNode(),l.push({type:2,index:++s});i.append(f[v],Xi())}}}else if(i.nodeType===8)if(i.data===fy)l.push({type:2,index:s});else{let f=-1;for(;(f=i.data.indexOf(en,f+1))!==-1;)l.push({type:7,index:s}),f+=en.length-1}s++}}static createElement(e,t){const r=rr.createElement("template");return r.innerHTML=e,r}}function ni(n,e,t=n,r){var o,a;if(e===ti)return e;let i=r!==void 0?(o=t._$Co)==null?void 0:o[r]:t._$Cl;const s=Qi(e)?void 0:e._$litDirective$;return(i==null?void 0:i.constructor)!==s&&((a=i==null?void 0:i._$AO)==null||a.call(i,!1),s===void 0?i=void 0:(i=new s(n),i._$AT(n,t,r)),r!==void 0?(t._$Co??(t._$Co=[]))[r]=i:t._$Cl=i),i!==void 0&&(e=ni(n,i._$AS(n,e.values),i,r)),e}class PR{constructor(e,t){this._$AV=[],this._$AN=void 0,this._$AD=e,this._$AM=t}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(e){const{el:{content:t},parts:r}=this._$AD,i=((e==null?void 0:e.creationScope)??rr).importNode(t,!0);Ln.currentNode=i;let s=Ln.nextNode(),o=0,a=0,l=r[0];for(;l!==void 0;){if(o===l.index){let u;l.type===2?u=new Mu(s,s.nextSibling,this,e):l.type===1?u=new l.ctor(s,l.name,l.strings,this,e):l.type===6&&(u=new zR(s,this,e)),this._$AV.push(u),l=r[++a]}o!==(l==null?void 0:l.index)&&(s=Ln.nextNode(),o++)}return Ln.currentNode=rr,i}p(e){let t=0;for(const r of this._$AV)r!==void 0&&(r.strings!==void 0?(r._$AI(e,r,t),t+=r.strings.length-2):r._$AI(e[t])),t++}}let Mu=class my{get _$AU(){var e;return((e=this._$AM)==null?void 0:e._$AU)??this._$Cv}constructor(e,t,r,i){this.type=2,this._$AH=oe,this._$AN=void 0,this._$AA=e,this._$AB=t,this._$AM=r,this.options=i,this._$Cv=(i==null?void 0:i.isConnected)??!0}get parentNode(){let e=this._$AA.parentNode;const t=this._$AM;return t!==void 0&&(e==null?void 0:e.nodeType)===11&&(e=t.parentNode),e}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(e,t=this){e=ni(this,e,t),Qi(e)?e===oe||e==null||e===""?(this._$AH!==oe&&this._$AR(),this._$AH=oe):e!==this._$AH&&e!==ti&&this._(e):e._$litType$!==void 0?this.$(e):e.nodeType!==void 0?this.T(e):TR(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!==oe&&Qi(this._$AH)?this._$AA.nextSibling.data=e:this.T(rr.createTextNode(e)),this._$AH=e}$(e){var s;const{values:t,_$litType$:r}=e,i=typeof r=="number"?this._$AC(e):(r.el===void 0&&(r.el=es.createElement(gy(r.h,r.h[0]),this.options)),r);if(((s=this._$AH)==null?void 0:s._$AD)===i)this._$AH.p(t);else{const o=new PR(i,this),a=o.u(this.options);o.p(t),this.T(a),this._$AH=o}}_$AC(e){let t=Pf.get(e.strings);return t===void 0&&Pf.set(e.strings,t=new es(e)),t}k(e){Lu(this._$AH)||(this._$AH=[],this._$AR());const t=this._$AH;let r,i=0;for(const s of e)i===t.length?t.push(r=new my(this.O(Xi()),this.O(Xi()),this,this.options)):r=t[i],r._$AI(s),i++;i<t.length&&(this._$AR(r&&r._$AB.nextSibling,i),t.length=i)}_$AR(e=this._$AA.nextSibling,t){var r;for((r=this._$AP)==null?void 0:r.call(this,!1,!0,t);e!==this._$AB;){const i=$f(e).nextSibling;$f(e).remove(),e=i}}setConnected(e){var t;this._$AM===void 0&&(this._$Cv=e,(t=this._$AP)==null||t.call(this,e))}},Za=class{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(e,t,r,i,s){this.type=1,this._$AH=oe,this._$AN=void 0,this.element=e,this.name=t,this._$AM=i,this.options=s,r.length>2||r[0]!==""||r[1]!==""?(this._$AH=Array(r.length-1).fill(new String),this.strings=r):this._$AH=oe}_$AI(e,t=this,r,i){const s=this.strings;let o=!1;if(s===void 0)e=ni(this,e,t,0),o=!Qi(e)||e!==this._$AH&&e!==ti,o&&(this._$AH=e);else{const a=e;let l,u;for(e=s[0],l=0;l<s.length-1;l++)u=ni(this,a[r+l],t,l),u===ti&&(u=this._$AH[l]),o||(o=!Qi(u)||u!==this._$AH[l]),u===oe?e=oe:e!==oe&&(e+=(u??"")+s[l+1]),this._$AH[l]=u}o&&!i&&this.j(e)}j(e){e===oe?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,e??"")}},RR=class extends Za{constructor(){super(...arguments),this.type=3}j(e){this.element[this.name]=e===oe?void 0:e}},DR=class extends Za{constructor(){super(...arguments),this.type=4}j(e){this.element.toggleAttribute(this.name,!!e&&e!==oe)}},OR=class extends Za{constructor(e,t,r,i,s){super(e,t,r,i,s),this.type=5}_$AI(e,t=this){if((e=ni(this,e,t,0)??oe)===ti)return;const r=this._$AH,i=e===oe&&r!==oe||e.capture!==r.capture||e.once!==r.once||e.passive!==r.passive,s=e!==oe&&(r===oe||i);i&&this.element.removeEventListener(this.name,this,r),s&&this.element.addEventListener(this.name,this,e),this._$AH=e}handleEvent(e){var t;typeof this._$AH=="function"?this._$AH.call(((t=this.options)==null?void 0:t.host)??this.element,e):this._$AH.handleEvent(e)}};class zR{constructor(e,t,r){this.element=e,this.type=6,this._$AN=void 0,this._$AM=t,this.options=r}get _$AU(){return this._$AM._$AU}_$AI(e){ni(this,e)}}const zl=qi.litHtmlPolyfillSupport;zl==null||zl(es,Mu),(qi.litHtmlVersions??(qi.litHtmlVersions=[])).push("3.3.2");const Pe=(n,e,t)=>{const r=e;let i=r._$litPart$;return i===void 0&&(r._$litPart$=i=new Mu(e.insertBefore(Xi(),null),null,void 0,{})),i._$AI(n),i};/**
47
+ */const qi=globalThis,$f=n=>n,ta=qi.trustedTypes,Af=ta?ta.createPolicy("lit-html",{createHTML:n=>n}):void 0,uy="$lit$",en=`lit$${Math.random().toFixed(9).slice(2)}$`,hy="?"+en,kR=`<${hy}>`,rr=document,Xi=()=>rr.createComment(""),Qi=n=>n===null||typeof n!="object"&&typeof n!="function",Nu=Array.isArray,ER=n=>Nu(n)||typeof(n==null?void 0:n[Symbol.iterator])=="function",Ll=`[
48
+ \f\r]`,$i=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,xf=/-->/g,Tf=/>/g,An=RegExp(`>|${Ll}(?:([^\\s"'>=/]+)(${Ll}*=${Ll}*(?:[^
49
+ \f\r"'\`<>=]|("|')|))|$)`,"g"),Cf=/'/g,If=/"/g,dy=/^(?:script|style|textarea|title)$/i,$R=n=>(e,...t)=>({_$litType$:n,strings:e,values:t}),F=$R(1),ti=Symbol.for("lit-noChange"),oe=Symbol.for("lit-nothing"),Pf=new WeakMap,Ln=rr.createTreeWalker(rr,129);function fy(n,e){if(!Nu(n)||!n.hasOwnProperty("raw"))throw Error("invalid template strings array");return Af!==void 0?Af.createHTML(e):e}const AR=(n,e)=>{const t=n.length-1,r=[];let i,s=e===2?"<svg>":e===3?"<math>":"",o=$i;for(let a=0;a<t;a++){const l=n[a];let u,d,f=-1,v=0;for(;v<l.length&&(o.lastIndex=v,d=o.exec(l),d!==null);)v=o.lastIndex,o===$i?d[1]==="!--"?o=xf:d[1]!==void 0?o=Tf:d[2]!==void 0?(dy.test(d[2])&&(i=RegExp("</"+d[2],"g")),o=An):d[3]!==void 0&&(o=An):o===An?d[0]===">"?(o=i??$i,f=-1):d[1]===void 0?f=-2:(f=o.lastIndex-d[2].length,u=d[1],o=d[3]===void 0?An:d[3]==='"'?If:Cf):o===If||o===Cf?o=An:o===xf||o===Tf?o=$i:(o=An,i=void 0);const y=o===An&&n[a+1].startsWith("/>")?" ":"";s+=o===$i?l+kR:f>=0?(r.push(u),l.slice(0,f)+uy+l.slice(f)+en+y):l+en+(f===-2?a:y)}return[fy(n,s+(n[t]||"<?>")+(e===2?"</svg>":e===3?"</math>":"")),r]};class es{constructor({strings:e,_$litType$:t},r){let i;this.parts=[];let s=0,o=0;const a=e.length-1,l=this.parts,[u,d]=AR(e,t);if(this.el=es.createElement(u,r),Ln.currentNode=this.el.content,t===2||t===3){const f=this.el.content.firstChild;f.replaceWith(...f.childNodes)}for(;(i=Ln.nextNode())!==null&&l.length<a;){if(i.nodeType===1){if(i.hasAttributes())for(const f of i.getAttributeNames())if(f.endsWith(uy)){const v=d[o++],y=i.getAttribute(f).split(en),A=/([.?@])?(.*)/.exec(v);l.push({type:1,index:s,name:A[2],strings:y,ctor:A[1]==="."?TR:A[1]==="?"?CR:A[1]==="@"?IR:Za}),i.removeAttribute(f)}else f.startsWith(en)&&(l.push({type:6,index:s}),i.removeAttribute(f));if(dy.test(i.tagName)){const f=i.textContent.split(en),v=f.length-1;if(v>0){i.textContent=ta?ta.emptyScript:"";for(let y=0;y<v;y++)i.append(f[y],Xi()),Ln.nextNode(),l.push({type:2,index:++s});i.append(f[v],Xi())}}}else if(i.nodeType===8)if(i.data===hy)l.push({type:2,index:s});else{let f=-1;for(;(f=i.data.indexOf(en,f+1))!==-1;)l.push({type:7,index:s}),f+=en.length-1}s++}}static createElement(e,t){const r=rr.createElement("template");return r.innerHTML=e,r}}function ni(n,e,t=n,r){var o,a;if(e===ti)return e;let i=r!==void 0?(o=t._$Co)==null?void 0:o[r]:t._$Cl;const s=Qi(e)?void 0:e._$litDirective$;return(i==null?void 0:i.constructor)!==s&&((a=i==null?void 0:i._$AO)==null||a.call(i,!1),s===void 0?i=void 0:(i=new s(n),i._$AT(n,t,r)),r!==void 0?(t._$Co??(t._$Co=[]))[r]=i:t._$Cl=i),i!==void 0&&(e=ni(n,i._$AS(n,e.values),i,r)),e}class xR{constructor(e,t){this._$AV=[],this._$AN=void 0,this._$AD=e,this._$AM=t}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(e){const{el:{content:t},parts:r}=this._$AD,i=((e==null?void 0:e.creationScope)??rr).importNode(t,!0);Ln.currentNode=i;let s=Ln.nextNode(),o=0,a=0,l=r[0];for(;l!==void 0;){if(o===l.index){let u;l.type===2?u=new Uu(s,s.nextSibling,this,e):l.type===1?u=new l.ctor(s,l.name,l.strings,this,e):l.type===6&&(u=new PR(s,this,e)),this._$AV.push(u),l=r[++a]}o!==(l==null?void 0:l.index)&&(s=Ln.nextNode(),o++)}return Ln.currentNode=rr,i}p(e){let t=0;for(const r of this._$AV)r!==void 0&&(r.strings!==void 0?(r._$AI(e,r,t),t+=r.strings.length-2):r._$AI(e[t])),t++}}let Uu=class py{get _$AU(){var e;return((e=this._$AM)==null?void 0:e._$AU)??this._$Cv}constructor(e,t,r,i){this.type=2,this._$AH=oe,this._$AN=void 0,this._$AA=e,this._$AB=t,this._$AM=r,this.options=i,this._$Cv=(i==null?void 0:i.isConnected)??!0}get parentNode(){let e=this._$AA.parentNode;const t=this._$AM;return t!==void 0&&(e==null?void 0:e.nodeType)===11&&(e=t.parentNode),e}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(e,t=this){e=ni(this,e,t),Qi(e)?e===oe||e==null||e===""?(this._$AH!==oe&&this._$AR(),this._$AH=oe):e!==this._$AH&&e!==ti&&this._(e):e._$litType$!==void 0?this.$(e):e.nodeType!==void 0?this.T(e):ER(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!==oe&&Qi(this._$AH)?this._$AA.nextSibling.data=e:this.T(rr.createTextNode(e)),this._$AH=e}$(e){var s;const{values:t,_$litType$:r}=e,i=typeof r=="number"?this._$AC(e):(r.el===void 0&&(r.el=es.createElement(fy(r.h,r.h[0]),this.options)),r);if(((s=this._$AH)==null?void 0:s._$AD)===i)this._$AH.p(t);else{const o=new xR(i,this),a=o.u(this.options);o.p(t),this.T(a),this._$AH=o}}_$AC(e){let t=Pf.get(e.strings);return t===void 0&&Pf.set(e.strings,t=new es(e)),t}k(e){Nu(this._$AH)||(this._$AH=[],this._$AR());const t=this._$AH;let r,i=0;for(const s of e)i===t.length?t.push(r=new py(this.O(Xi()),this.O(Xi()),this,this.options)):r=t[i],r._$AI(s),i++;i<t.length&&(this._$AR(r&&r._$AB.nextSibling,i),t.length=i)}_$AR(e=this._$AA.nextSibling,t){var r;for((r=this._$AP)==null?void 0:r.call(this,!1,!0,t);e!==this._$AB;){const i=$f(e).nextSibling;$f(e).remove(),e=i}}setConnected(e){var t;this._$AM===void 0&&(this._$Cv=e,(t=this._$AP)==null||t.call(this,e))}},Za=class{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(e,t,r,i,s){this.type=1,this._$AH=oe,this._$AN=void 0,this.element=e,this.name=t,this._$AM=i,this.options=s,r.length>2||r[0]!==""||r[1]!==""?(this._$AH=Array(r.length-1).fill(new String),this.strings=r):this._$AH=oe}_$AI(e,t=this,r,i){const s=this.strings;let o=!1;if(s===void 0)e=ni(this,e,t,0),o=!Qi(e)||e!==this._$AH&&e!==ti,o&&(this._$AH=e);else{const a=e;let l,u;for(e=s[0],l=0;l<s.length-1;l++)u=ni(this,a[r+l],t,l),u===ti&&(u=this._$AH[l]),o||(o=!Qi(u)||u!==this._$AH[l]),u===oe?e=oe:e!==oe&&(e+=(u??"")+s[l+1]),this._$AH[l]=u}o&&!i&&this.j(e)}j(e){e===oe?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,e??"")}},TR=class extends Za{constructor(){super(...arguments),this.type=3}j(e){this.element[this.name]=e===oe?void 0:e}},CR=class extends Za{constructor(){super(...arguments),this.type=4}j(e){this.element.toggleAttribute(this.name,!!e&&e!==oe)}},IR=class extends Za{constructor(e,t,r,i,s){super(e,t,r,i,s),this.type=5}_$AI(e,t=this){if((e=ni(this,e,t,0)??oe)===ti)return;const r=this._$AH,i=e===oe&&r!==oe||e.capture!==r.capture||e.once!==r.once||e.passive!==r.passive,s=e!==oe&&(r===oe||i);i&&this.element.removeEventListener(this.name,this,r),s&&this.element.addEventListener(this.name,this,e),this._$AH=e}handleEvent(e){var t;typeof this._$AH=="function"?this._$AH.call(((t=this.options)==null?void 0:t.host)??this.element,e):this._$AH.handleEvent(e)}};class PR{constructor(e,t,r){this.element=e,this.type=6,this._$AN=void 0,this._$AM=t,this.options=r}get _$AU(){return this._$AM._$AU}_$AI(e){ni(this,e)}}const Ml=qi.litHtmlPolyfillSupport;Ml==null||Ml(es,Uu),(qi.litHtmlVersions??(qi.litHtmlVersions=[])).push("3.3.2");const Pe=(n,e,t)=>{const r=e;let i=r._$litPart$;return i===void 0&&(r._$litPart$=i=new Uu(e.insertBefore(Xi(),null),null,void 0,{})),i._$AI(n),i};/**
50
50
  * @license
51
51
  * Copyright 2017 Google LLC
52
52
  * SPDX-License-Identifier: BSD-3-Clause
53
- */const yy={CHILD:2},Nu=n=>(...e)=>({_$litDirective$:n,values:e});class vy{constructor(e){}get _$AU(){return this._$AM._$AU}_$AT(e,t,r){this._$Ct=e,this._$AM=t,this._$Ci=r}_$AS(e,t){return this.update(e,t)}update(e,t){return this.render(...t)}}/**
53
+ */const gy={CHILD:2},Fu=n=>(...e)=>({_$litDirective$:n,values:e});class my{constructor(e){}get _$AU(){return this._$AM._$AU}_$AT(e,t,r){this._$Ct=e,this._$AM=t,this._$Ci=r}_$AS(e,t){return this.update(e,t)}update(e,t){return this.render(...t)}}/**
54
54
  * @license
55
55
  * Copyright 2017 Google LLC
56
56
  * SPDX-License-Identifier: BSD-3-Clause
57
- */let na=class extends vy{constructor(e){if(super(e),this.it=oe,e.type!==yy.CHILD)throw Error(this.constructor.directiveName+"() can only be used in child bindings")}render(e){if(e===oe||e==null)return this._t=void 0,this.it=e;if(e===ti)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 t=[e];return t.raw=t,this._t={_$litType$:this.constructor.resultType,strings:t,values:[]}}};na.directiveName="unsafeHTML",na.resultType=1;const LR=Nu(na);/**
57
+ */let na=class extends my{constructor(e){if(super(e),this.it=oe,e.type!==gy.CHILD)throw Error(this.constructor.directiveName+"() can only be used in child bindings")}render(e){if(e===oe||e==null)return this._t=void 0,this.it=e;if(e===ti)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 t=[e];return t.raw=t,this._t={_$litType$:this.constructor.resultType,strings:t,values:[]}}};na.directiveName="unsafeHTML",na.resultType=1;const RR=Fu(na);/**
58
58
  * @license
59
59
  * Copyright 2017 Google LLC
60
60
  * SPDX-License-Identifier: BSD-3-Clause
61
- */class _c extends na{}_c.directiveName="unsafeSVG",_c.resultType=2;const MR=Nu(_c),NR={size:16,color:"currentColor",weight:"regular"};function UR(n){return typeof n=="string"?{regular:n}:n}function Jt(n,e="0 0 256 256"){const t=UR(n);return r=>{const{size:i,color:s,weight:o}={...NR,...r},a=t[o]??t.regular;return F`<svg
61
+ */class kc extends na{}kc.directiveName="unsafeSVG",kc.resultType=2;const DR=Fu(kc),OR={size:16,color:"currentColor",weight:"regular"};function zR(n){return typeof n=="string"?{regular:n}:n}function Jt(n,e="0 0 256 256"){const t=zR(n);return r=>{const{size:i,color:s,weight:o}={...OR,...r},a=t[o]??t.regular;return F`<svg
62
62
  xmlns="http://www.w3.org/2000/svg"
63
63
  data-ui-icon=""
64
64
  width="${i}"
65
65
  height="${i}"
66
66
  viewBox="${e}"
67
67
  fill="${s}"
68
- >${MR(a)}</svg>`}}const FR=Jt('<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"/>'),by=Jt('<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"/>'),ZR=Jt('<path d="M181.66,133.66l-80,80a8,8,0,0,1-11.32-11.32L164.69,128,90.34,53.66a8,8,0,0,1,11.32-11.32l80,80A8,8,0,0,1,181.66,133.66Z"/>'),wy=Jt('<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"/>'),HR=Jt('<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"/>'),VR=Jt('<path d="M224,128a8,8,0,0,1-8,8H136v80a8,8,0,0,1-16,0V136H40a8,8,0,0,1,0-16h80V40a8,8,0,0,1,16,0v80h80A8,8,0,0,1,224,128Z"/>'),jR=Jt({regular:'<path d="M219.31,108.68l-80-80a16,16,0,0,0-22.62,0l-80,80A15.87,15.87,0,0,0,32,120v96a8,8,0,0,0,8,8h64a8,8,0,0,0,8-8V160h32v56a8,8,0,0,0,8,8h64a8,8,0,0,0,8-8V120A15.87,15.87,0,0,0,219.31,108.68ZM208,208H160V152a8,8,0,0,0-8-8H104a8,8,0,0,0-8,8v56H48V120l80-80,80,80Z"/>',bold:'<path d="M222.14,105.85l-80-80a20,20,0,0,0-28.28,0l-80,80A19.86,19.86,0,0,0,28,120v96a12,12,0,0,0,12,12h64a12,12,0,0,0,12-12V164h24v52a12,12,0,0,0,12,12h64a12,12,0,0,0,12-12V120A19.86,19.86,0,0,0,222.14,105.85ZM204,204H164V152a12,12,0,0,0-12-12H104a12,12,0,0,0-12,12v52H52V121.65l76-76,76,76Z"/>',fill:'<path d="M224,120v96a8,8,0,0,1-8,8H160a8,8,0,0,1-8-8V164a4,4,0,0,0-4-4H108a4,4,0,0,0-4,4v52a8,8,0,0,1-8,8H40a8,8,0,0,1-8-8V120a16,16,0,0,1,4.69-11.31l80-80a16,16,0,0,1,22.62,0l80,80A16,16,0,0,1,224,120Z"/>'}),BR=Jt({regular:'<path d="M227.31,73.37,182.63,28.68a16,16,0,0,0-22.63,0L36.69,152A15.86,15.86,0,0,0,32,163.31V208a16,16,0,0,0,16,16H92.69A15.86,15.86,0,0,0,104,219.31L227.31,96a16,16,0,0,0,0-22.63ZM51.31,160,136,75.31,152.69,92,68,176.68ZM48,179.31,76.69,208H48Zm48,25.38L79.31,188,164,103.31,180.69,120Zm96-96L147.31,64l24-24L216,84.68Z"/>',bold:'<path d="M230.14,70.54,185.46,25.85a20,20,0,0,0-28.29,0L33.86,149.17A19.85,19.85,0,0,0,28,163.31V208a20,20,0,0,0,20,20H92.69a19.86,19.86,0,0,0,14.14-5.86L230.14,98.82a20,20,0,0,0,0-28.28ZM93,180l71-71,11,11-71,71ZM76,163,65,152l71-71,11,11ZM52,173l15.51,15.51h0L83,204H52ZM192,103,153,64l18.34-18.34,39,39Z"/>'}),GR=Jt({regular:'<path d="M216,48H176V40a24,24,0,0,0-24-24H104A24,24,0,0,0,80,40v8H40a8,8,0,0,0,0,16h8V208a16,16,0,0,0,16,16H192a16,16,0,0,0,16-16V64h8a8,8,0,0,0,0-16ZM96,40a8,8,0,0,1,8-8h48a8,8,0,0,1,8,8v8H96Zm96,168H64V64H192ZM112,104v64a8,8,0,0,1-16,0V104a8,8,0,0,1,16,0Zm48,0v64a8,8,0,0,1-16,0V104a8,8,0,0,1,16,0Z"/>',bold:'<path d="M216,44H176V40a24,24,0,0,0-24-24H104A24,24,0,0,0,80,40v4H40a12,12,0,0,0,0,24h4V208a20,20,0,0,0,20,20H192a20,20,0,0,0,20-20V68h4a12,12,0,0,0,0-24ZM104,40h48v4H104Zm84,164H68V68H188Zm-84-48V120a12,12,0,0,1,24,0v36a12,12,0,0,1-24,0Zm40,0V120a12,12,0,0,1,24,0v36a12,12,0,0,1-24,0Z"/>'});class _y extends Event{constructor(t){super("dropdown-item-select",{bubbles:!0,composed:!0});b(this,"value");this.value=t}}class WR extends Event{constructor(t){super("select",{bubbles:!0,composed:!0});b(this,"value");this.value=t}}var Ye,ut,cn,Nr,te,ps,z,ky,Mi,Ey,$y,Sc,Ay,Ni,Cn,Bn,gs,ms,ys,ha,xy,Ty,kc,Ui,Cy,Ec,Ot;class Sy extends HTMLElement{constructor(){super();S(this,z);S(this,Ye,!1);S(this,ut,null);S(this,cn,null);S(this,Nr);S(this,te,null);S(this,ps,new MutationObserver(t=>m(this,z,xy).call(this,t)));S(this,Bn,()=>{m(this,z,Ni).call(this,!c(this,Ye))});S(this,gs,t=>{t.key!=="Enter"&&t.key!==" "||(t.preventDefault(),c(this,Bn).call(this))});S(this,ms,t=>{c(this,Ye)&&(t.composedPath().includes(this)||m(this,z,Ni).call(this,!1))});S(this,ys,t=>{t instanceof _y&&(t.stopPropagation(),E(this,Ye,!1),m(this,z,Mi).call(this,t.value),m(this,z,Ot).call(this),this.dispatchEvent(new WR(t.value)))});S(this,ha,()=>{m(this,z,kc).call(this)});E(this,Nr,this.attachShadow({mode:"open"}))}connectedCallback(){this.addEventListener("dropdown-item-select",c(this,ys)),document.addEventListener("click",c(this,ms),!0),m(this,z,ky).call(this),c(this,ps).observe(this,{childList:!0,subtree:!0,characterData:!0,attributes:!0,attributeFilter:["selected","value","slot"]}),m(this,z,Ot).call(this)}disconnectedCallback(){this.removeEventListener("dropdown-item-select",c(this,ys)),document.removeEventListener("click",c(this,ms),!0),c(this,ps).disconnect(),m(this,z,Ec).call(this)}attributeChangedCallback(t){if(t==="open"){m(this,z,Ni).call(this,this.hasAttribute("open"));return}m(this,z,Ot).call(this)}get open(){return c(this,Ye)}set open(t){this.toggleAttribute("open",t)}get title(){return this.getAttribute("title")??""}get placement(){return this.getAttribute("placement")==="top"?"top":"bottom"}get value(){return c(this,ut)}set value(t){t===null?(m(this,z,Cn).call(this,null,null),m(this,z,Ey).call(this)):m(this,z,Mi).call(this,t),m(this,z,Ot).call(this)}close(){m(this,z,Ni).call(this,!1)}}Ye=new WeakMap,ut=new WeakMap,cn=new WeakMap,Nr=new WeakMap,te=new WeakMap,ps=new WeakMap,z=new WeakSet,ky=function(){var r;const t=this.querySelector("dropdown-item[selected]");t&&m(this,z,Cn).call(this,t.value,((r=t.textContent)==null?void 0:r.trim())??null)},Mi=function(t){var r;for(const i of c(this,z,Sc))i.value===t?(m(this,z,Cn).call(this,t,((r=i.textContent)==null?void 0:r.trim())??null),i.hasAttribute("selected")||i.setAttribute("selected","")):i.hasAttribute("selected")&&i.removeAttribute("selected")},Ey=function(){const t=this.querySelectorAll("dropdown-item[selected]");for(const r of t)r.removeAttribute("selected")},$y=function(t){for(const r of c(this,z,Sc))if(r.value===t)return r;return null},Sc=function(){return this.querySelectorAll("dropdown-item")},Ay=function(){return c(this,cn)??this.title},Ni=function(t){c(this,Ye)!==t&&(E(this,Ye,t),m(this,z,Ot).call(this))},Cn=function(t,r){E(this,ut,t),E(this,cn,r)},Bn=new WeakMap,gs=new WeakMap,ms=new WeakMap,ys=new WeakMap,ha=new WeakMap,xy=function(t){t.every(i=>i.target instanceof Element?i.target.closest('[slot="trigger"]')!==null:!1)||m(this,z,Ty).call(this)},Ty=function(){var r,i;const t=this.querySelector("dropdown-item[selected]");if(t){const s=t.value,o=((r=t.textContent)==null?void 0:r.trim())??null,a=c(this,ut)!==s||c(this,cn)!==o;m(this,z,Cn).call(this,s,o),m(this,z,Mi).call(this,s),a?m(this,z,Ot).call(this):m(this,z,Ui).call(this);return}if(c(this,ut)!==null){const s=m(this,z,$y).call(this,c(this,ut));if(s){const o=((i=s.textContent)==null?void 0:i.trim())??null,a=c(this,cn)!==o;m(this,z,Cn).call(this,c(this,ut),o),m(this,z,Mi).call(this,c(this,ut)),a?m(this,z,Ot).call(this):m(this,z,Ui).call(this);return}}if(c(this,ut)!==null||c(this,cn)!==null){m(this,z,Cn).call(this,null,null),m(this,z,Ot).call(this);return}m(this,z,Ui).call(this)},kc=function(){const t=c(this,Nr).querySelector('slot[name="trigger"]'),r=t instanceof HTMLSlotElement?t.assignedElements()[0]??null:null;c(this,te)!==r&&(m(this,z,Ec).call(this),E(this,te,r),c(this,te)&&(c(this,te).addEventListener("click",c(this,Bn)),c(this,te)instanceof HTMLButtonElement?c(this,te).hasAttribute("type")||(c(this,te).type="button"):(c(this,te).hasAttribute("role")||c(this,te).setAttribute("role","button"),c(this,te).hasAttribute("tabindex")||(c(this,te).tabIndex=0),c(this,te).addEventListener("keydown",c(this,gs))))),m(this,z,Ui).call(this)},Ui=function(){c(this,te)&&(c(this,te).setAttribute("data-dropdown-trigger",""),c(this,te).setAttribute("aria-haspopup","listbox"),c(this,te).setAttribute("aria-expanded",c(this,Ye)?"true":"false"))},Cy=function(){return this.placement==="top"?HR:wy},Ec=function(){c(this,te)&&(c(this,te).removeEventListener("click",c(this,Bn)),c(this,te).removeEventListener("keydown",c(this,gs)),c(this,te).removeAttribute("data-dropdown-trigger"),c(this,te).removeAttribute("aria-haspopup"),c(this,te).removeAttribute("aria-expanded"),E(this,te,null))},Ot=function(){this.toggleAttribute("open",c(this,Ye)),Pe(F`
68
+ >${DR(a)}</svg>`}}const LR=Jt('<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"/>'),yy=Jt('<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"/>'),MR=Jt('<path d="M181.66,133.66l-80,80a8,8,0,0,1-11.32-11.32L164.69,128,90.34,53.66a8,8,0,0,1,11.32-11.32l80,80A8,8,0,0,1,181.66,133.66Z"/>'),vy=Jt('<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"/>'),NR=Jt('<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"/>'),UR=Jt('<path d="M224,128a8,8,0,0,1-8,8H136v80a8,8,0,0,1-16,0V136H40a8,8,0,0,1,0-16h80V40a8,8,0,0,1,16,0v80h80A8,8,0,0,1,224,128Z"/>'),FR=Jt({regular:'<path d="M219.31,108.68l-80-80a16,16,0,0,0-22.62,0l-80,80A15.87,15.87,0,0,0,32,120v96a8,8,0,0,0,8,8h64a8,8,0,0,0,8-8V160h32v56a8,8,0,0,0,8,8h64a8,8,0,0,0,8-8V120A15.87,15.87,0,0,0,219.31,108.68ZM208,208H160V152a8,8,0,0,0-8-8H104a8,8,0,0,0-8,8v56H48V120l80-80,80,80Z"/>',bold:'<path d="M222.14,105.85l-80-80a20,20,0,0,0-28.28,0l-80,80A19.86,19.86,0,0,0,28,120v96a12,12,0,0,0,12,12h64a12,12,0,0,0,12-12V164h24v52a12,12,0,0,0,12,12h64a12,12,0,0,0,12-12V120A19.86,19.86,0,0,0,222.14,105.85ZM204,204H164V152a12,12,0,0,0-12-12H104a12,12,0,0,0-12,12v52H52V121.65l76-76,76,76Z"/>',fill:'<path d="M224,120v96a8,8,0,0,1-8,8H160a8,8,0,0,1-8-8V164a4,4,0,0,0-4-4H108a4,4,0,0,0-4,4v52a8,8,0,0,1-8,8H40a8,8,0,0,1-8-8V120a16,16,0,0,1,4.69-11.31l80-80a16,16,0,0,1,22.62,0l80,80A16,16,0,0,1,224,120Z"/>'}),ZR=Jt({regular:'<path d="M227.31,73.37,182.63,28.68a16,16,0,0,0-22.63,0L36.69,152A15.86,15.86,0,0,0,32,163.31V208a16,16,0,0,0,16,16H92.69A15.86,15.86,0,0,0,104,219.31L227.31,96a16,16,0,0,0,0-22.63ZM51.31,160,136,75.31,152.69,92,68,176.68ZM48,179.31,76.69,208H48Zm48,25.38L79.31,188,164,103.31,180.69,120Zm96-96L147.31,64l24-24L216,84.68Z"/>',bold:'<path d="M230.14,70.54,185.46,25.85a20,20,0,0,0-28.29,0L33.86,149.17A19.85,19.85,0,0,0,28,163.31V208a20,20,0,0,0,20,20H92.69a19.86,19.86,0,0,0,14.14-5.86L230.14,98.82a20,20,0,0,0,0-28.28ZM93,180l71-71,11,11-71,71ZM76,163,65,152l71-71,11,11ZM52,173l15.51,15.51h0L83,204H52ZM192,103,153,64l18.34-18.34,39,39Z"/>'}),HR=Jt({regular:'<path d="M216,48H176V40a24,24,0,0,0-24-24H104A24,24,0,0,0,80,40v8H40a8,8,0,0,0,0,16h8V208a16,16,0,0,0,16,16H192a16,16,0,0,0,16-16V64h8a8,8,0,0,0,0-16ZM96,40a8,8,0,0,1,8-8h48a8,8,0,0,1,8,8v8H96Zm96,168H64V64H192ZM112,104v64a8,8,0,0,1-16,0V104a8,8,0,0,1,16,0Zm48,0v64a8,8,0,0,1-16,0V104a8,8,0,0,1,16,0Z"/>',bold:'<path d="M216,44H176V40a24,24,0,0,0-24-24H104A24,24,0,0,0,80,40v4H40a12,12,0,0,0,0,24h4V208a20,20,0,0,0,20,20H192a20,20,0,0,0,20-20V68h4a12,12,0,0,0,0-24ZM104,40h48v4H104Zm84,164H68V68H188Zm-84-48V120a12,12,0,0,1,24,0v36a12,12,0,0,1-24,0Zm40,0V120a12,12,0,0,1,24,0v36a12,12,0,0,1-24,0Z"/>'});class by extends Event{constructor(t){super("dropdown-item-select",{bubbles:!0,composed:!0});b(this,"value");this.value=t}}class VR extends Event{constructor(t){super("select",{bubbles:!0,composed:!0});b(this,"value");this.value=t}}var Ye,ut,cn,Nr,te,ps,z,_y,Mi,Sy,ky,Ec,Ey,Ni,Cn,Gn,gs,ms,ys,ha,$y,Ay,$c,Ui,xy,Ac,Ot;class wy extends HTMLElement{constructor(){super();S(this,z);S(this,Ye,!1);S(this,ut,null);S(this,cn,null);S(this,Nr);S(this,te,null);S(this,ps,new MutationObserver(t=>m(this,z,$y).call(this,t)));S(this,Gn,()=>{m(this,z,Ni).call(this,!c(this,Ye))});S(this,gs,t=>{t.key!=="Enter"&&t.key!==" "||(t.preventDefault(),c(this,Gn).call(this))});S(this,ms,t=>{c(this,Ye)&&(t.composedPath().includes(this)||m(this,z,Ni).call(this,!1))});S(this,ys,t=>{t instanceof by&&(t.stopPropagation(),E(this,Ye,!1),m(this,z,Mi).call(this,t.value),m(this,z,Ot).call(this),this.dispatchEvent(new VR(t.value)))});S(this,ha,()=>{m(this,z,$c).call(this)});E(this,Nr,this.attachShadow({mode:"open"}))}connectedCallback(){this.addEventListener("dropdown-item-select",c(this,ys)),document.addEventListener("click",c(this,ms),!0),m(this,z,_y).call(this),c(this,ps).observe(this,{childList:!0,subtree:!0,characterData:!0,attributes:!0,attributeFilter:["selected","value","slot"]}),m(this,z,Ot).call(this)}disconnectedCallback(){this.removeEventListener("dropdown-item-select",c(this,ys)),document.removeEventListener("click",c(this,ms),!0),c(this,ps).disconnect(),m(this,z,Ac).call(this)}attributeChangedCallback(t){if(t==="open"){m(this,z,Ni).call(this,this.hasAttribute("open"));return}m(this,z,Ot).call(this)}get open(){return c(this,Ye)}set open(t){this.toggleAttribute("open",t)}get title(){return this.getAttribute("title")??""}get placement(){return this.getAttribute("placement")==="top"?"top":"bottom"}get value(){return c(this,ut)}set value(t){t===null?(m(this,z,Cn).call(this,null,null),m(this,z,Sy).call(this)):m(this,z,Mi).call(this,t),m(this,z,Ot).call(this)}close(){m(this,z,Ni).call(this,!1)}}Ye=new WeakMap,ut=new WeakMap,cn=new WeakMap,Nr=new WeakMap,te=new WeakMap,ps=new WeakMap,z=new WeakSet,_y=function(){var r;const t=this.querySelector("dropdown-item[selected]");t&&m(this,z,Cn).call(this,t.value,((r=t.textContent)==null?void 0:r.trim())??null)},Mi=function(t){var r;for(const i of c(this,z,Ec))i.value===t?(m(this,z,Cn).call(this,t,((r=i.textContent)==null?void 0:r.trim())??null),i.hasAttribute("selected")||i.setAttribute("selected","")):i.hasAttribute("selected")&&i.removeAttribute("selected")},Sy=function(){const t=this.querySelectorAll("dropdown-item[selected]");for(const r of t)r.removeAttribute("selected")},ky=function(t){for(const r of c(this,z,Ec))if(r.value===t)return r;return null},Ec=function(){return this.querySelectorAll("dropdown-item")},Ey=function(){return c(this,cn)??this.title},Ni=function(t){c(this,Ye)!==t&&(E(this,Ye,t),m(this,z,Ot).call(this))},Cn=function(t,r){E(this,ut,t),E(this,cn,r)},Gn=new WeakMap,gs=new WeakMap,ms=new WeakMap,ys=new WeakMap,ha=new WeakMap,$y=function(t){t.every(i=>i.target instanceof Element?i.target.closest('[slot="trigger"]')!==null:!1)||m(this,z,Ay).call(this)},Ay=function(){var r,i;const t=this.querySelector("dropdown-item[selected]");if(t){const s=t.value,o=((r=t.textContent)==null?void 0:r.trim())??null,a=c(this,ut)!==s||c(this,cn)!==o;m(this,z,Cn).call(this,s,o),m(this,z,Mi).call(this,s),a?m(this,z,Ot).call(this):m(this,z,Ui).call(this);return}if(c(this,ut)!==null){const s=m(this,z,ky).call(this,c(this,ut));if(s){const o=((i=s.textContent)==null?void 0:i.trim())??null,a=c(this,cn)!==o;m(this,z,Cn).call(this,c(this,ut),o),m(this,z,Mi).call(this,c(this,ut)),a?m(this,z,Ot).call(this):m(this,z,Ui).call(this);return}}if(c(this,ut)!==null||c(this,cn)!==null){m(this,z,Cn).call(this,null,null),m(this,z,Ot).call(this);return}m(this,z,Ui).call(this)},$c=function(){const t=c(this,Nr).querySelector('slot[name="trigger"]'),r=t instanceof HTMLSlotElement?t.assignedElements()[0]??null:null;c(this,te)!==r&&(m(this,z,Ac).call(this),E(this,te,r),c(this,te)&&(c(this,te).addEventListener("click",c(this,Gn)),c(this,te)instanceof HTMLButtonElement?c(this,te).hasAttribute("type")||(c(this,te).type="button"):(c(this,te).hasAttribute("role")||c(this,te).setAttribute("role","button"),c(this,te).hasAttribute("tabindex")||(c(this,te).tabIndex=0),c(this,te).addEventListener("keydown",c(this,gs))))),m(this,z,Ui).call(this)},Ui=function(){c(this,te)&&(c(this,te).setAttribute("data-dropdown-trigger",""),c(this,te).setAttribute("aria-haspopup","listbox"),c(this,te).setAttribute("aria-expanded",c(this,Ye)?"true":"false"))},xy=function(){return this.placement==="top"?NR:vy},Ac=function(){c(this,te)&&(c(this,te).removeEventListener("click",c(this,Gn)),c(this,te).removeEventListener("keydown",c(this,gs)),c(this,te).removeAttribute("data-dropdown-trigger"),c(this,te).removeAttribute("aria-haspopup"),c(this,te).removeAttribute("aria-expanded"),E(this,te,null))},Ot=function(){this.toggleAttribute("open",c(this,Ye)),Pe(F`
69
69
  <slot name="trigger" @slotchange=${c(this,ha)}>
70
70
  <button
71
71
  class="fallback-trigger"
@@ -73,11 +73,11 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
73
73
  type="button"
74
74
  aria-haspopup="listbox"
75
75
  aria-expanded=${c(this,Ye)?"true":"false"}
76
- @click=${c(this,Bn)}
76
+ @click=${c(this,Gn)}
77
77
  >
78
- <span class="trigger-label" part="trigger-label">${c(this,z,Ay)}</span>
78
+ <span class="trigger-label" part="trigger-label">${c(this,z,Ey)}</span>
79
79
  <span class="trigger-icon" part="trigger-icon" aria-hidden="true">
80
- ${c(this,z,Cy).call(this,{size:16})}
80
+ ${c(this,z,xy).call(this,{size:16})}
81
81
  </span>
82
82
  </button>
83
83
  </slot>
@@ -90,13 +90,13 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
90
90
  <slot></slot>
91
91
  </div>
92
92
  `:null}
93
- `,c(this,Nr)),queueMicrotask(()=>m(this,z,kc).call(this))},b(Sy,"observedAttributes",["title","placement","open"]);class qR extends HTMLElement{}class YR extends HTMLElement{}class KR extends HTMLElement{}var or,$c,Py,vs,bs;class Iy extends HTMLElement{constructor(){super(...arguments);S(this,or);S(this,vs,()=>{this.action||m(this,or,Py).call(this)});S(this,bs,t=>{t.key!=="Enter"&&t.key!==" "||(t.preventDefault(),this.click())})}connectedCallback(){this.hasAttribute("role")||this.setAttribute("role","option"),this.hasAttribute("tabindex")||(this.tabIndex=0),this.addEventListener("click",c(this,vs)),this.addEventListener("keydown",c(this,bs)),m(this,or,$c).call(this)}disconnectedCallback(){this.removeEventListener("click",c(this,vs)),this.removeEventListener("keydown",c(this,bs))}attributeChangedCallback(){m(this,or,$c).call(this)}get value(){return this.getAttribute("value")??""}get selected(){return this.hasAttribute("selected")}get action(){return this.hasAttribute("action")}}or=new WeakSet,$c=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")},Py=function(){this.dispatchEvent(new _y(this.value))},vs=new WeakMap,bs=new WeakMap,b(Iy,"observedAttributes",["action","selected","value"]);customElements.get("dropdown-menu")||customElements.define("dropdown-menu",Sy);customElements.get("dropdown-group")||customElements.define("dropdown-group",qR);customElements.get("dropdown-label")||customElements.define("dropdown-label",YR);customElements.get("dropdown-divider")||customElements.define("dropdown-divider",KR);customElements.get("dropdown-item")||customElements.define("dropdown-item",Iy);class JR extends Event{constructor(){super("close",{bubbles:!0,composed:!0})}}var ws,yn,Ac,da,_s,xc;class Ry extends HTMLElement{constructor(){super();S(this,yn);S(this,ws);S(this,da,t=>{t.target===t.currentTarget&&m(this,yn,Ac).call(this)});S(this,_s,t=>{this.open&&t.key==="Escape"&&m(this,yn,Ac).call(this)});E(this,ws,this.attachShadow({mode:"open"}))}connectedCallback(){document.addEventListener("keydown",c(this,_s)),m(this,yn,xc).call(this)}disconnectedCallback(){document.removeEventListener("keydown",c(this,_s))}attributeChangedCallback(){m(this,yn,xc).call(this)}get open(){return this.hasAttribute("open")}}ws=new WeakMap,yn=new WeakSet,Ac=function(){this.dispatchEvent(new JR)},da=new WeakMap,_s=new WeakMap,xc=function(){Pe(F`
93
+ `,c(this,Nr)),queueMicrotask(()=>m(this,z,$c).call(this))},b(wy,"observedAttributes",["title","placement","open"]);class jR extends HTMLElement{}class GR extends HTMLElement{}class BR extends HTMLElement{}var or,xc,Cy,vs,bs;class Ty extends HTMLElement{constructor(){super(...arguments);S(this,or);S(this,vs,()=>{this.action||m(this,or,Cy).call(this)});S(this,bs,t=>{t.key!=="Enter"&&t.key!==" "||(t.preventDefault(),this.click())})}connectedCallback(){this.hasAttribute("role")||this.setAttribute("role","option"),this.hasAttribute("tabindex")||(this.tabIndex=0),this.addEventListener("click",c(this,vs)),this.addEventListener("keydown",c(this,bs)),m(this,or,xc).call(this)}disconnectedCallback(){this.removeEventListener("click",c(this,vs)),this.removeEventListener("keydown",c(this,bs))}attributeChangedCallback(){m(this,or,xc).call(this)}get value(){return this.getAttribute("value")??""}get selected(){return this.hasAttribute("selected")}get action(){return this.hasAttribute("action")}}or=new WeakSet,xc=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")},Cy=function(){this.dispatchEvent(new by(this.value))},vs=new WeakMap,bs=new WeakMap,b(Ty,"observedAttributes",["action","selected","value"]);customElements.get("dropdown-menu")||customElements.define("dropdown-menu",wy);customElements.get("dropdown-group")||customElements.define("dropdown-group",jR);customElements.get("dropdown-label")||customElements.define("dropdown-label",GR);customElements.get("dropdown-divider")||customElements.define("dropdown-divider",BR);customElements.get("dropdown-item")||customElements.define("dropdown-item",Ty);class WR extends Event{constructor(){super("close",{bubbles:!0,composed:!0})}}var ws,yn,Tc,da,_s,Cc;class Iy extends HTMLElement{constructor(){super();S(this,yn);S(this,ws);S(this,da,t=>{t.target===t.currentTarget&&m(this,yn,Tc).call(this)});S(this,_s,t=>{this.open&&t.key==="Escape"&&m(this,yn,Tc).call(this)});E(this,ws,this.attachShadow({mode:"open"}))}connectedCallback(){document.addEventListener("keydown",c(this,_s)),m(this,yn,Cc).call(this)}disconnectedCallback(){document.removeEventListener("keydown",c(this,_s))}attributeChangedCallback(){m(this,yn,Cc).call(this)}get open(){return this.hasAttribute("open")}}ws=new WeakMap,yn=new WeakSet,Tc=function(){this.dispatchEvent(new WR)},da=new WeakMap,_s=new WeakMap,Cc=function(){Pe(F`
94
94
  ${this.open?F`
95
95
  <div class="backdrop" part="backdrop" @click=${c(this,da)}>
96
96
  <slot></slot>
97
97
  </div>
98
98
  `:null}
99
- `,c(this,ws))},b(Ry,"observedAttributes",["open"]);customElements.get("modal-overlay")||customElements.define("modal-overlay",Ry);class XR extends Event{constructor(){super("close",{bubbles:!0,composed:!0})}}class QR extends HTMLElement{}var Ss,ks,Tc;class Dy extends HTMLElement{constructor(){super();S(this,ks);S(this,Ss);E(this,Ss,this.attachShadow({mode:"open"}))}connectedCallback(){m(this,ks,Tc).call(this)}attributeChangedCallback(){m(this,ks,Tc).call(this)}get closable(){return this.hasAttribute("closable")}}Ss=new WeakMap,ks=new WeakSet,Tc=function(){const t=this.querySelector("panel-page");Pe(F`
99
+ `,c(this,ws))},b(Iy,"observedAttributes",["open"]);customElements.get("modal-overlay")||customElements.define("modal-overlay",Iy);class qR extends Event{constructor(){super("close",{bubbles:!0,composed:!0})}}class YR extends HTMLElement{}var Ss,ks,Ic;class Py extends HTMLElement{constructor(){super();S(this,ks);S(this,Ss);E(this,Ss,this.attachShadow({mode:"open"}))}connectedCallback(){m(this,ks,Ic).call(this)}attributeChangedCallback(){m(this,ks,Ic).call(this)}get closable(){return this.hasAttribute("closable")}}Ss=new WeakMap,ks=new WeakSet,Ic=function(){const t=this.querySelector("panel-page");Pe(F`
100
100
  <section class="panel" part="panel">
101
101
  <header class="title-bar" part="header">
102
102
  <h2 class="title" part="title">${(t==null?void 0:t.getAttribute("title"))??""}</h2>
@@ -106,15 +106,15 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
106
106
  class="title-button"
107
107
  part="button close-button"
108
108
  aria-label="Close"
109
- @click=${()=>this.dispatchEvent(new XR)}
109
+ @click=${()=>this.dispatchEvent(new qR)}
110
110
  >
111
- <span class="close-icon" part="icon close-icon">${by({size:16})}</span>
111
+ <span class="close-icon" part="icon close-icon">${yy({size:16})}</span>
112
112
  </button>
113
113
  `:null}
114
114
  </header>
115
115
  <slot></slot>
116
116
  </section>
117
- `,c(this,Ss))},b(Dy,"observedAttributes",["closable"]);customElements.get("panel-view")||customElements.define("panel-view",Dy);customElements.get("panel-page")||customElements.define("panel-page",QR);class eD extends Event{constructor(){super("close",{bubbles:!0,composed:!0})}}const Rf='a[href],button:not([disabled]),input:not([disabled]),select:not([disabled]),textarea:not([disabled]),[tabindex]:not([tabindex="-1"])',Ll=4;var Ve,Vt,Ur,Qe,Es,Fr,ne,zy,Ly,Cc,$s,As,Gn,My,Ic,Ny,Uy,No,Uo;class Oy extends HTMLElement{constructor(){super();S(this,ne);S(this,Ve,!1);S(this,Vt,null);S(this,Ur);S(this,Qe,null);S(this,Es,"bottom-start");S(this,Fr,!1);S(this,$s,t=>{c(this,Ve)&&(c(this,Fr)||t.composedPath().includes(this)||(this.open=!1))});S(this,As,t=>{if(c(this,Ve)){if(t.key==="Escape"){t.preventDefault(),this.open=!1;return}t.key==="Tab"&&m(this,ne,My).call(this,t)}});S(this,Gn,()=>{c(this,Ve)&&m(this,ne,No).call(this)});E(this,Ur,this.attachShadow({mode:"open"}))}connectedCallback(){m(this,ne,Uo).call(this)}disconnectedCallback(){m(this,ne,Cc).call(this)}attributeChangedCallback(t){t==="open"&&m(this,ne,zy).call(this,this.hasAttribute("open"))}get open(){return c(this,Ve)}set open(t){this.toggleAttribute("open",t)}get anchor(){return c(this,Vt)}set anchor(t){c(this,Vt)!==t&&(E(this,Vt,t),c(this,Ve)&&m(this,ne,No).call(this))}}Ve=new WeakMap,Vt=new WeakMap,Ur=new WeakMap,Qe=new WeakMap,Es=new WeakMap,Fr=new WeakMap,ne=new WeakSet,zy=function(t){var r;c(this,Ve)!==t&&(E(this,Ve,t),t?(E(this,Fr,!0),setTimeout(()=>{E(this,Fr,!1)},0),m(this,ne,Uo).call(this),m(this,ne,Ly).call(this),queueMicrotask(()=>{c(this,Ve)&&(m(this,ne,No).call(this),m(this,ne,Uy).call(this))})):(m(this,ne,Cc).call(this),m(this,ne,Uo).call(this),(r=c(this,Vt))==null||r.focus(),this.dispatchEvent(new eD)))},Ly=function(){document.addEventListener("click",c(this,$s)),document.addEventListener("keydown",c(this,As),!0),window.addEventListener("resize",c(this,Gn)),window.addEventListener("scroll",c(this,Gn),!0)},Cc=function(){document.removeEventListener("click",c(this,$s)),document.removeEventListener("keydown",c(this,As),!0),window.removeEventListener("resize",c(this,Gn)),window.removeEventListener("scroll",c(this,Gn),!0)},$s=new WeakMap,As=new WeakMap,Gn=new WeakMap,My=function(t){const r=m(this,ne,Ic).call(this);if(r.length===0){t.preventDefault();return}const i=r[0],s=r[r.length-1],o=m(this,ne,Ny).call(this),a=o instanceof HTMLElement&&r.includes(o);t.shiftKey?(!a||o===i)&&(t.preventDefault(),s.focus()):(!a||o===s)&&(t.preventDefault(),i.focus())},Ic=function(){if(!c(this,Qe))return[];const t=c(this,Qe).querySelector("slot");if(!(t instanceof HTMLSlotElement))return[];const r=[];for(const i of t.assignedElements({flatten:!0}))if(i instanceof HTMLElement){i.matches(Rf)&&r.push(i);for(const s of i.querySelectorAll(Rf))r.push(s)}return r},Ny=function(){var r;let t=document.activeElement;for(;t&&((r=t.shadowRoot)!=null&&r.activeElement);)t=t.shadowRoot.activeElement;return t},Uy=function(){var r;const t=m(this,ne,Ic).call(this);t.length>0?t[0].focus():(r=c(this,Qe))==null||r.focus()},No=function(){if(!c(this,Ve)||!c(this,Vt)||!c(this,Qe))return;const t=c(this,Vt).getBoundingClientRect(),r=c(this,Qe).getBoundingClientRect(),s=window.innerHeight-t.bottom,o=r.height+Ll,a=s<o&&t.top>o?"top-start":"bottom-start";E(this,Es,a);const l=a==="bottom-start"?t.bottom+Ll:t.top-r.height-Ll,u=t.left;c(this,Qe).style.top=`${l}px`,c(this,Qe).style.left=`${u}px`,c(this,Qe).setAttribute("data-placement",a)},Uo=function(){this.toggleAttribute("open",c(this,Ve)),Pe(c(this,Ve)?F`<div
117
+ `,c(this,Ss))},b(Py,"observedAttributes",["closable"]);customElements.get("panel-view")||customElements.define("panel-view",Py);customElements.get("panel-page")||customElements.define("panel-page",YR);class KR extends Event{constructor(){super("close",{bubbles:!0,composed:!0})}}const Rf='a[href],button:not([disabled]),input:not([disabled]),select:not([disabled]),textarea:not([disabled]),[tabindex]:not([tabindex="-1"])',Nl=4;var Ve,Vt,Ur,Qe,Es,Fr,ne,Dy,Oy,Pc,$s,As,Bn,zy,Rc,Ly,My,No,Uo;class Ry extends HTMLElement{constructor(){super();S(this,ne);S(this,Ve,!1);S(this,Vt,null);S(this,Ur);S(this,Qe,null);S(this,Es,"bottom-start");S(this,Fr,!1);S(this,$s,t=>{c(this,Ve)&&(c(this,Fr)||t.composedPath().includes(this)||(this.open=!1))});S(this,As,t=>{if(c(this,Ve)){if(t.key==="Escape"){t.preventDefault(),this.open=!1;return}t.key==="Tab"&&m(this,ne,zy).call(this,t)}});S(this,Bn,()=>{c(this,Ve)&&m(this,ne,No).call(this)});E(this,Ur,this.attachShadow({mode:"open"}))}connectedCallback(){m(this,ne,Uo).call(this)}disconnectedCallback(){m(this,ne,Pc).call(this)}attributeChangedCallback(t){t==="open"&&m(this,ne,Dy).call(this,this.hasAttribute("open"))}get open(){return c(this,Ve)}set open(t){this.toggleAttribute("open",t)}get anchor(){return c(this,Vt)}set anchor(t){c(this,Vt)!==t&&(E(this,Vt,t),c(this,Ve)&&m(this,ne,No).call(this))}}Ve=new WeakMap,Vt=new WeakMap,Ur=new WeakMap,Qe=new WeakMap,Es=new WeakMap,Fr=new WeakMap,ne=new WeakSet,Dy=function(t){var r;c(this,Ve)!==t&&(E(this,Ve,t),t?(E(this,Fr,!0),setTimeout(()=>{E(this,Fr,!1)},0),m(this,ne,Uo).call(this),m(this,ne,Oy).call(this),queueMicrotask(()=>{c(this,Ve)&&(m(this,ne,No).call(this),m(this,ne,My).call(this))})):(m(this,ne,Pc).call(this),m(this,ne,Uo).call(this),(r=c(this,Vt))==null||r.focus(),this.dispatchEvent(new KR)))},Oy=function(){document.addEventListener("click",c(this,$s)),document.addEventListener("keydown",c(this,As),!0),window.addEventListener("resize",c(this,Bn)),window.addEventListener("scroll",c(this,Bn),!0)},Pc=function(){document.removeEventListener("click",c(this,$s)),document.removeEventListener("keydown",c(this,As),!0),window.removeEventListener("resize",c(this,Bn)),window.removeEventListener("scroll",c(this,Bn),!0)},$s=new WeakMap,As=new WeakMap,Bn=new WeakMap,zy=function(t){const r=m(this,ne,Rc).call(this);if(r.length===0){t.preventDefault();return}const i=r[0],s=r[r.length-1],o=m(this,ne,Ly).call(this),a=o instanceof HTMLElement&&r.includes(o);t.shiftKey?(!a||o===i)&&(t.preventDefault(),s.focus()):(!a||o===s)&&(t.preventDefault(),i.focus())},Rc=function(){if(!c(this,Qe))return[];const t=c(this,Qe).querySelector("slot");if(!(t instanceof HTMLSlotElement))return[];const r=[];for(const i of t.assignedElements({flatten:!0}))if(i instanceof HTMLElement){i.matches(Rf)&&r.push(i);for(const s of i.querySelectorAll(Rf))r.push(s)}return r},Ly=function(){var r;let t=document.activeElement;for(;t&&((r=t.shadowRoot)!=null&&r.activeElement);)t=t.shadowRoot.activeElement;return t},My=function(){var r;const t=m(this,ne,Rc).call(this);t.length>0?t[0].focus():(r=c(this,Qe))==null||r.focus()},No=function(){if(!c(this,Ve)||!c(this,Vt)||!c(this,Qe))return;const t=c(this,Vt).getBoundingClientRect(),r=c(this,Qe).getBoundingClientRect(),s=window.innerHeight-t.bottom,o=r.height+Nl,a=s<o&&t.top>o?"top-start":"bottom-start";E(this,Es,a);const l=a==="bottom-start"?t.bottom+Nl:t.top-r.height-Nl,u=t.left;c(this,Qe).style.top=`${l}px`,c(this,Qe).style.left=`${u}px`,c(this,Qe).setAttribute("data-placement",a)},Uo=function(){this.toggleAttribute("open",c(this,Ve)),Pe(c(this,Ve)?F`<div
118
118
  class="panel"
119
119
  part="panel"
120
120
  data-placement=${c(this,Es)}
@@ -122,8 +122,8 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
122
122
  role="dialog"
123
123
  >
124
124
  <slot></slot>
125
- </div>`:oe,c(this,Ur)),E(this,Qe,c(this,Ur).querySelector(".panel"))},b(Oy,"observedAttributes",["open"]);customElements.get("ui-popover")||customElements.define("ui-popover",Oy);const tD=xt(),nD="No handler registered for update-content",rD="handleUpdateContent: handler already registered";function iD(n){return n instanceof Error&&typeof n.message=="string"?n.message:String(n)}const sD=di(Tt);var Zr,Hr,Vr,Wn,qn,xs,Ce,Pc,Fy,Zy,Fi,Rc,cp;let oD=(cp=class extends sD{constructor(t){super();S(this,Ce);S(this,Zr);S(this,Hr);S(this,Vr);S(this,Wn,null);S(this,qn,null);S(this,xs,!1);E(this,Zr,t);const r=t.ownerDocument.defaultView;if(!r)throw new Error("ArtifactView: iframe has no owner window");E(this,Hr,r),E(this,Vr,i=>m(this,Ce,Fy).call(this,i)),c(this,Hr).addEventListener("message",c(this,Vr))}get content(){return c(this,qn)}set content(t){m(this,Ce,Rc).call(this),E(this,qn,t),c(this,xs)&&m(this,Ce,Pc).call(this,t)}handleUpdateContent(t){if(m(this,Ce,Rc).call(this),c(this,Wn)!==null)throw new Error(rD);E(this,Wn,t)}dispose(){c(this,Hr).removeEventListener("message",c(this,Vr)),E(this,Wn,null)}},Zr=new WeakMap,Hr=new WeakMap,Vr=new WeakMap,Wn=new WeakMap,qn=new WeakMap,xs=new WeakMap,Ce=new WeakSet,Pc=function(t){const r={type:"content-updated",content:t};m(this,Ce,Fi).call(this,r)},Fy=function(t){if(this.disposed||t.source!==c(this,Zr).contentWindow)return;const r=t.data;if(IC(r)){E(this,xs,!0),this.dispatchEvent(new tD("ready")),c(this,qn)!==null&&m(this,Ce,Pc).call(this,c(this,qn));return}if(PC(r)){m(this,Ce,Zy).call(this,r);return}},Zy=async function(t){const r=c(this,Wn);if(r===null){m(this,Ce,Fi).call(this,{type:"response",id:t.id,error:{message:nD}});return}try{await r(t.content)}catch(i){if(this.disposed)return;m(this,Ce,Fi).call(this,{type:"response",id:t.id,error:{message:iD(i)}});return}this.disposed||m(this,Ce,Fi).call(this,{type:"response",id:t.id,result:{}})},Fi=function(t){const r=c(this,Zr).contentWindow;r&&r.postMessage(t,"*")},Rc=function(){if(this.disposed)throw new Error("ArtifactView is disposed")},cp);function aD(n=window){n.parent!==n&&(n.addEventListener("wheel",e=>{const t=e;n.parent.postMessage({type:"wheel",deltaX:t.deltaX,deltaY:t.deltaY,shiftKey:t.shiftKey},"*"),t.preventDefault()},{passive:!1}),n.addEventListener("message",e=>{const t=e.data;if(t!==null&&typeof t=="object"&&t.type==="scroll"){const r=t,i=typeof r.deltaX=="number"?r.deltaX:0,s=typeof r.deltaY=="number"?r.deltaY:0;n.scrollBy(i,s)}}))}function lD(){return`(${aD.toString()})(window);`}async function cD(n){const e=await fetch(n);if(!e.ok)throw new Error(`Failed to fetch artifact content: ${e.status}`);const t=await e.text(),r=new DOMParser().parseFromString(t,"text/html"),i=r.createElement("base");i.href=n,r.head.insertBefore(i,r.head.firstChild);const s=r.createElement("script");s.textContent=lD(),r.head.appendChild(s);const o=new Blob([`<!DOCTYPE html>
126
- ${r.documentElement.outerHTML}`],{type:"text/html"});return URL.createObjectURL(o)}const Hy=xt();class uD extends HTMLElement{constructor(){super(...arguments);b(this,"_artifact",null);b(this,"_viewURL",null);b(this,"_contentURL",null);b(this,"_screen",null);b(this,"_subscribedScreen",null);b(this,"_activeView",null);b(this,"_contentState",{kind:"idle"});b(this,"_fetchSequence",0);b(this,"_blobSequence",0);b(this,"_mountedViewURL",null);b(this,"_directRender",!1);b(this,"_blobURL",null);b(this,"handleScreenContentChanged",t=>{!this._artifact||t.artifactID!==this._artifact.id||this._activeView!==null&&this.refetchContent()})}set artifact(t){const r=this._artifact;this._artifact=t,this.render(),r!==null&&r!==t&&this.syncView()}get artifact(){return this._artifact}set viewURL(t){this._viewURL!==t&&(this._viewURL=t,this.syncView())}get viewURL(){return this._viewURL}set contentURL(t){this._contentURL!==t&&(this._contentURL=t,this.syncView())}get contentURL(){return this._contentURL}set screen(t){this._screen!==t&&(this._screen=t,this.syncScreenSubscription())}get screen(){return this._screen}set dragging(t){t?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 Hy("close-artifact",{artifactID:this._artifact.id,bubbles:!0,composed:!0}))}syncView(){var t;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 oD(r),this._activeView.handleUpdateContent(async i=>{await this.saveContent(i)}),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(),((t=this._artifact)==null?void 0:t.status)==="committed"&&this.loadBlobFrame(this._contentURL);return}this.teardownView(),this._contentState={kind:"idle"},this.render()}}async saveContent(t){const r=this._screen,i=this._artifact;if(!r||!i)throw new Error("artifact-view: cannot save without a screen and artifact");await r.server.client.artifacts.putContent({artifactID:i.id,content:t})}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 t=this._fetchSequence,r=this._contentURL,i=this._activeView;if(!i||r===null){this._contentState={kind:"error"},this.render();return}this._contentState={kind:"loading"},(async()=>{try{const s=await fetch(r);if(t!==this._fetchSequence)return;if(!s.ok){this._contentState={kind:"error"},this.teardownView(),this.render();return}const o=await s.text();if(t!==this._fetchSequence||this._activeView!==i)return;this._activeView.content=o,this._contentState={kind:"ready"}}catch{if(t!==this._fetchSequence)return;this._contentState={kind:"error"},this.teardownView(),this.render()}})()}refetchContent(){this._fetchSequence+=1;const t=this._fetchSequence,r=this._contentURL,i=this._activeView;!i||r===null||(async()=>{try{const s=await fetch(r);if(t!==this._fetchSequence||!s.ok)return;const o=await s.text();if(t!==this._fetchSequence||this._activeView!==i)return;this._activeView.content=o}catch{}})()}loadBlobFrame(t){this._blobSequence+=1;const r=this._blobSequence;(async()=>{try{const i=await cD(t);if(r!==this._blobSequence){URL.revokeObjectURL(i);return}this._blobURL=i,this.render();const s=this.querySelector("iframe.artifact-frame");s&&(s.src=i)}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"?F`
125
+ </div>`:oe,c(this,Ur)),E(this,Qe,c(this,Ur).querySelector(".panel"))},b(Ry,"observedAttributes",["open"]);customElements.get("ui-popover")||customElements.define("ui-popover",Ry);const JR=xt(),XR="No handler registered for update-content",QR="handleUpdateContent: handler already registered";function eD(n){return n instanceof Error&&typeof n.message=="string"?n.message:String(n)}const tD=di(Tt);var Zr,Hr,Vr,Wn,qn,xs,Ce,Dc,Ny,Uy,Fi,Oc,cp;let nD=(cp=class extends tD{constructor(t){super();S(this,Ce);S(this,Zr);S(this,Hr);S(this,Vr);S(this,Wn,null);S(this,qn,null);S(this,xs,!1);E(this,Zr,t);const r=t.ownerDocument.defaultView;if(!r)throw new Error("ArtifactView: iframe has no owner window");E(this,Hr,r),E(this,Vr,i=>m(this,Ce,Ny).call(this,i)),c(this,Hr).addEventListener("message",c(this,Vr))}get content(){return c(this,qn)}set content(t){m(this,Ce,Oc).call(this),E(this,qn,t),c(this,xs)&&m(this,Ce,Dc).call(this,t)}handleUpdateContent(t){if(m(this,Ce,Oc).call(this),c(this,Wn)!==null)throw new Error(QR);E(this,Wn,t)}dispose(){c(this,Hr).removeEventListener("message",c(this,Vr)),E(this,Wn,null)}},Zr=new WeakMap,Hr=new WeakMap,Vr=new WeakMap,Wn=new WeakMap,qn=new WeakMap,xs=new WeakMap,Ce=new WeakSet,Dc=function(t){const r={type:"content-updated",content:t};m(this,Ce,Fi).call(this,r)},Ny=function(t){if(this.disposed||t.source!==c(this,Zr).contentWindow)return;const r=t.data;if(AC(r)){E(this,xs,!0),this.dispatchEvent(new JR("ready")),c(this,qn)!==null&&m(this,Ce,Dc).call(this,c(this,qn));return}if(xC(r)){m(this,Ce,Uy).call(this,r);return}},Uy=async function(t){const r=c(this,Wn);if(r===null){m(this,Ce,Fi).call(this,{type:"response",id:t.id,error:{message:XR}});return}try{await r(t.content)}catch(i){if(this.disposed)return;m(this,Ce,Fi).call(this,{type:"response",id:t.id,error:{message:eD(i)}});return}this.disposed||m(this,Ce,Fi).call(this,{type:"response",id:t.id,result:{}})},Fi=function(t){const r=c(this,Zr).contentWindow;r&&r.postMessage(t,"*")},Oc=function(){if(this.disposed)throw new Error("ArtifactView is disposed")},cp);function rD(n=window){n.parent!==n&&(n.addEventListener("wheel",e=>{const t=e;n.parent.postMessage({type:"wheel",deltaX:t.deltaX,deltaY:t.deltaY,shiftKey:t.shiftKey},"*"),t.preventDefault()},{passive:!1}),n.addEventListener("message",e=>{const t=e.data;if(t!==null&&typeof t=="object"&&t.type==="scroll"){const r=t,i=typeof r.deltaX=="number"?r.deltaX:0,s=typeof r.deltaY=="number"?r.deltaY:0;n.scrollBy(i,s)}}))}function iD(){return`(${rD.toString()})(window);`}async function sD(n){const e=await fetch(n);if(!e.ok)throw new Error(`Failed to fetch artifact content: ${e.status}`);const t=await e.text(),r=new DOMParser().parseFromString(t,"text/html"),i=r.createElement("base");i.href=n,r.head.insertBefore(i,r.head.firstChild);const s=r.createElement("script");s.textContent=iD(),r.head.appendChild(s);const o=new Blob([`<!DOCTYPE html>
126
+ ${r.documentElement.outerHTML}`],{type:"text/html"});return URL.createObjectURL(o)}const Fy=xt();class oD extends HTMLElement{constructor(){super(...arguments);b(this,"_artifact",null);b(this,"_viewURL",null);b(this,"_contentURL",null);b(this,"_screen",null);b(this,"_subscribedScreen",null);b(this,"_activeView",null);b(this,"_contentState",{kind:"idle"});b(this,"_fetchSequence",0);b(this,"_blobSequence",0);b(this,"_mountedViewURL",null);b(this,"_directRender",!1);b(this,"_blobURL",null);b(this,"handleScreenContentChanged",t=>{!this._artifact||t.artifactID!==this._artifact.id||this._activeView!==null&&this.refetchContent()})}set artifact(t){const r=this._artifact;this._artifact=t,this.render(),r!==null&&r!==t&&this.syncView()}get artifact(){return this._artifact}set viewURL(t){this._viewURL!==t&&(this._viewURL=t,this.syncView())}get viewURL(){return this._viewURL}set contentURL(t){this._contentURL!==t&&(this._contentURL=t,this.syncView())}get contentURL(){return this._contentURL}set screen(t){this._screen!==t&&(this._screen=t,this.syncScreenSubscription())}get screen(){return this._screen}set dragging(t){t?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 Fy("close-artifact",{artifactID:this._artifact.id,bubbles:!0,composed:!0}))}syncView(){var t;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 nD(r),this._activeView.handleUpdateContent(async i=>{await this.saveContent(i)}),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(),((t=this._artifact)==null?void 0:t.status)==="committed"&&this.loadBlobFrame(this._contentURL);return}this.teardownView(),this._contentState={kind:"idle"},this.render()}}async saveContent(t){const r=this._screen,i=this._artifact;if(!r||!i)throw new Error("artifact-view: cannot save without a screen and artifact");await r.server.client.artifacts.putContent({artifactID:i.id,content:t})}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 t=this._fetchSequence,r=this._contentURL,i=this._activeView;if(!i||r===null){this._contentState={kind:"error"},this.render();return}this._contentState={kind:"loading"},(async()=>{try{const s=await fetch(r);if(t!==this._fetchSequence)return;if(!s.ok){this._contentState={kind:"error"},this.teardownView(),this.render();return}const o=await s.text();if(t!==this._fetchSequence||this._activeView!==i)return;this._activeView.content=o,this._contentState={kind:"ready"}}catch{if(t!==this._fetchSequence)return;this._contentState={kind:"error"},this.teardownView(),this.render()}})()}refetchContent(){this._fetchSequence+=1;const t=this._fetchSequence,r=this._contentURL,i=this._activeView;!i||r===null||(async()=>{try{const s=await fetch(r);if(t!==this._fetchSequence||!s.ok)return;const o=await s.text();if(t!==this._fetchSequence||this._activeView!==i)return;this._activeView.content=o}catch{}})()}loadBlobFrame(t){this._blobSequence+=1;const r=this._blobSequence;(async()=>{try{const i=await sD(t);if(r!==this._blobSequence){URL.revokeObjectURL(i);return}this._blobURL=i,this.render();const s=this.querySelector("iframe.artifact-frame");s&&(s.src=i)}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"?F`
127
127
  <div class="artifact-content artifact-placeholder">
128
128
  <em>Failed to load content</em>
129
129
  </div>
@@ -141,7 +141,7 @@ ${r.documentElement.outerHTML}`],{type:"text/html"});return URL.createObjectURL(
141
141
  ${this.contentTemplate()}
142
142
  <footer class="artifact-title-bar" drag-handle>
143
143
  <div class="artifact-title-group">
144
- <span class="artifact-title-icon">${FR({size:16})}</span>
144
+ <span class="artifact-title-icon">${LR({size:16})}</span>
145
145
  <span class="artifact-title">${t.title}</span>
146
146
  </div>
147
147
  <button
@@ -150,11 +150,11 @@ ${r.documentElement.outerHTML}`],{type:"text/html"});return URL.createObjectURL(
150
150
  @click=${()=>this.handleClose()}
151
151
  aria-label="Close"
152
152
  >
153
- ${by({size:16})}
153
+ ${yy({size:16})}
154
154
  </button>
155
155
  </footer>
156
- `}render(){this._artifact&&(this.setAttribute("type",this._artifact.type),Pe(this.template(),this))}}customElements.define("artifact-view",uD);const ke=n=>({type:"px",...n}),Te=n=>({type:"unit",...n}),wo=2,hD=2;class dD{constructor(e){b(this,"basis");b(this,"min");b(this,"_gap");b(this,"_viewport");b(this,"_unit");this.basis=e.basis,this.min=e.min,this._viewport=e.viewport,this._gap=e.gap??ke({x:pe,y:pe});const t=this._viewport.x??tr,r=this._viewport.y??Yo,i=this._gap.x??pe,s=this._gap.y??pe,o=tr+i*hD,a=t<=o,l=a?t-i*wo:Math.min(tr,t-i*wo),u=a?r-s*wo:Math.min(Yo,r-s*wo),d=(l-i*(At-1))/At,f=(u-s*(Je-1))/Je,v=this.basis.x??0,y=this.basis.y??0,A=this.min.x??0,k=this.min.y??0;this._unit=ke(a?{x:Math.max(A,d),y:Math.max(k,f)}:{x:Math.max(A,Math.min(v,d)),y:Math.max(k,Math.min(y,f))})}get unit(){return this._unit}get viewport(){return this._viewport}get gap(){return this._gap}toUnits(e){return Te({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 t=this._unit.x??0,r=this._unit.y??0,i=this._gap.x??pe,s=this._gap.y??pe,o=e.x==null?void 0:e.x*t+Math.max(0,e.x-1)*i,a=e.y==null?void 0:e.y*r+Math.max(0,e.y-1)*s;return ke({x:o,y:a})}}const ir=1e-4,Bt=1e-6,fD=40,pD=24;function Vy(n,e){return Math.max(0,n-e*2)}function jy(n){const e=[0];for(const t of n)e.push((e[e.length-1]??0)+t);return e}function By(n){const e=[0];for(let t=0;t<n.length;t+=1){const r=e[t]??0;e.push(r+n[t]+pe)}return e}function Gy(n,e,t){if(e<0||e>=n.length)return 0;let r=0,i=0;for(let s=e;s<n.length;s+=1){const o=n[s],a=i===0?o:r+pe+o;if(a>t+ir)break;r=a,i+=1}return Math.max(1,i)}function gD(n,e,t){if(e<0||e>=n.length)return 0;let r=0,i=0;for(let s=e;s>=0;s-=1){const o=n[s],a=i===0?o:r+pe+o;if(a>t+ir)break;r=a,i+=1}return Math.max(1,i)}function mD(n,e){if(n.length===0)return 0;let t=0,r=0;for(let i=n.length-1;i>=0;i-=1){const s=n[i],o=r===0?s:t+pe+s;if(o>e+ir)break;t=o,r+=1}return Math.max(1,r)}function Uu(n,e){if(n.length===0)return 0;const t=mD(n,e);return Math.max(0,n.length-t)}function Df(n,e,t){if(n.length===0)return 0;const r=Gy(n,e,t),i=Math.min(n.length,e+r);if(i<=e)return 0;const s=n.slice(e,i);return s.reduce((o,a)=>o+a,0)+Math.max(0,s.length-1)*pe}function Dc(n,e,t){const r=n[e]??0;return t-r}function xr(n,e,t,r,i){if(n.length===0)return 0;const s=Uu(n,i),o=e[s]??0,a=Math.max(0,Math.min(o,t));let l=0;for(let Z=0;Z<s;Z+=1){const U=e[Z]??0,ge=e[Z+1]??U;if(a>=U&&a<=ge+ir){l=Z;break}l=Z+1}const u=Math.min(l+1,s),d=e[l]??0,f=e[u]??d,v=Math.max(f-d,ir),y=u===l?0:(a-d)/v,A=By(n),k=Df(n,l,i),I=Df(n,u,i),B=(r-k)/2,P=(r-I)/2,le=Dc(A,l,B),M=Dc(A,u,P);return le+(M-le)*y}function Of(n,e,t,r,i){const s=Uu(n,r),o=e[s]??0;let a=0,l=o;for(let u=0;u<fD;u+=1){const d=(a+l)/2;xr(n,e,d,t,r)>i?a=d:l=d}return(a+l)/2}function zf(n,e,t){const r=By(n),[i,s]=e,o=n.slice(i,s+1),a=o.reduce((u,d)=>u+d,0)+Math.max(0,o.length-1)*pe,l=(t-a)/2;return Dc(r,i,l)}function yD(n,e,t){const r=Gy(n,e,t);return[e,Math.min(n.length-1,e+r-1)]}function vD(n,e,t){const r=gD(n,e,t);return[Math.max(0,e-r+1),e]}function bD(n){const e=new Set,t=[];for(const r of n){const i=`${r.nodeRange[0]}:${r.nodeRange[1]}`;if(e.has(i))continue;const s=t[t.length-1];s&&Math.abs(s.anchor-r.anchor)<=Bt||(e.add(i),t.push(r))}return t}function wD(n){const{nodeCols:e,nodeWidthsPx:t,viewportWidthPx:r}=n;if(e.length===0||t.length===0)return{viewspans:[],minScroll:0,maxScroll:0};const i=n.gapPx??pe,s=Vy(r,i),o=jy(e),a=Uu(t,s),l=o[a]??0,u=[];for(let d=0;d<=a;d+=1){const f=yD(t,d,s),v=zf(t,f,r),y=Of(t,o,r,s,v);u.push({nodeRange:f,anchor:Math.max(0,Math.min(l,y))})}for(let d=t.length-1;d>=0;d-=1){const f=vD(t,d,s),v=`${f[0]}:${f[1]}`;if(u.some(k=>`${k.nodeRange[0]}:${k.nodeRange[1]}`===v))continue;const y=zf(t,f,r),A=Of(t,o,r,s,y);u.push({nodeRange:f,anchor:Math.max(0,Math.min(l,A))})}return u.sort((d,f)=>Math.abs(d.anchor-f.anchor)>Bt?d.anchor-f.anchor:d.nodeRange[0]!==f.nodeRange[0]?d.nodeRange[0]-f.nodeRange[0]:d.nodeRange[1]-f.nodeRange[1]),{viewspans:bD(u),minScroll:0,maxScroll:l}}function _D(n,e){var i;let t=0,r=Number.POSITIVE_INFINITY;for(let s=0;s<n.length;s+=1){const o=Math.abs((((i=n[s])==null?void 0:i.anchor)??0)-e);if(o+Bt<r){r=o,t=s;continue}Math.abs(o-r)<=Bt&&s<t&&(t=s)}return t}function SD(n,e,t){return t<=0?0:Math.max(0,Math.min(t-1,n+e))}function Ai(n,e,t){return Math.max(e,Math.min(t,n))}class kD extends Tt{constructor(t){super();b(this,"_scroll",0);b(this,"minScroll",0);b(this,"maxScroll",0);b(this,"viewspans",[]);b(this,"activeViewspanIndex",null);b(this,"nodeWidthsPx",[]);b(this,"boundaryCols",[0]);b(this,"viewportWidthPx",0);b(this,"framedViewportWidthPx",0);this._scroll=(t==null?void 0:t.x)??0}get scroll(){return Te({x:this._scroll})}get translate(){return ke({x:xr(this.nodeWidthsPx,this.boundaryCols,this._scroll,this.viewportWidthPx,this.framedViewportWidthPx)})}set scroll(t){const r=Ai(t.x??this._scroll,this.minScroll,this.maxScroll);Math.abs(r-this._scroll)<=Bt||(this._scroll=r,this.activeViewspanIndex=null,this.dispatchEvent(new Ei("layout-scroll",{scroll:this.scroll})))}rebuild(t){const r=t.nodeWidths.map(u=>Math.max(0,u.x??0)),i=r.map(u=>t.grid.toPixels(Te({x:u})).x??0),s=t.grid.viewport.x??0,o=t.grid.gap.x??pe,a=wD({nodeCols:r,nodeWidthsPx:i,viewportWidthPx:s,gapPx:o});this.nodeWidthsPx=i,this.boundaryCols=jy(r),this.viewportWidthPx=s,this.framedViewportWidthPx=Vy(s,o),this.viewspans=a.viewspans,this.minScroll=a.minScroll,this.maxScroll=a.maxScroll,this.activeViewspanIndex=null;const l=Ai(this._scroll,this.minScroll,this.maxScroll);Math.abs(l-this._scroll)>Bt&&(this._scroll=l,this.dispatchEvent(new Ei("layout-scroll",{scroll:this.scroll})))}step(t){var a;if(this.viewspans.length===0)return;const r=this.activeViewspanIndex??_D(this.viewspans,this._scroll),i=SD(r,t,this.viewspans.length),s=((a=this.viewspans[i])==null?void 0:a.anchor)??this._scroll,o=Ai(s,this.minScroll,this.maxScroll);this.activeViewspanIndex=i,!(Math.abs(o-this._scroll)<=Bt)&&(this._scroll=o,this.dispatchEvent(new Ei("layout-scroll",{scroll:this.scroll})))}wheel(t){const r=Ai(this._scroll+(t.x??0),this.minScroll,this.maxScroll);this.activeViewspanIndex=null,!(Math.abs(r-this._scroll)<=Bt)&&(this._scroll=r,this.dispatchEvent(new Ei("layout-scroll",{scroll:this.scroll})))}wheelPixels(t){const r=t.x??0;if(Math.abs(r)<=ir)return;this.activeViewspanIndex=null;const i=xr(this.nodeWidthsPx,this.boundaryCols,this._scroll,this.viewportWidthPx,this.framedViewportWidthPx),s=i-r,o=xr(this.nodeWidthsPx,this.boundaryCols,this.maxScroll,this.viewportWidthPx,this.framedViewportWidthPx),a=xr(this.nodeWidthsPx,this.boundaryCols,this.minScroll,this.viewportWidthPx,this.framedViewportWidthPx),l=Math.max(o,Math.min(a,s));if(Math.abs(l-i)<=ir)return;let u=this.minScroll,d=this.maxScroll;for(let v=0;v<pD;v+=1){const y=(u+d)/2;xr(this.nodeWidthsPx,this.boundaryCols,y,this.viewportWidthPx,this.framedViewportWidthPx)>l?u=y:d=y}const f=Ai((u+d)/2,this.minScroll,this.maxScroll);Math.abs(f-this._scroll)<=Bt||(this._scroll=f,this.dispatchEvent(new Ei("layout-scroll",{scroll:this.scroll})))}}const Ml={"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}},ED=["stack-above","stack-below","reorder-before","reorder-after"];function Nl(n,e){return{left:n.left+n.width*e.left,top:n.top+n.height*e.top,width:n.width*e.width,height:n.height*e.height}}function xn(n,e,t){return n>=t.left&&n<t.left+t.width&&e>=t.top&&e<t.top+t.height}function Fu(n,e){for(const t of n){if(t.type==="card"&&t.id===e)return t;if(t.type==="stack")for(const r of t.children){if(r.type==="card"&&r.id===e)return r;if(r.type==="row"){for(const i of r.children)if(i.id===e)return i}}}return null}function Oc(n){return n.height===Je||n.height===fn?{...n,height:fn}:n}function zc(n){return n.height===fn?{...n,height:Je}:n}function $D(n,e,t,r){const i=n.findIndex(d=>d.type==="stack"&&d.id===e);if(i===-1)return n;const s=n[i];if(!s||s.type!=="stack")return n;const o=s.children.find(d=>d.type==="card"&&d.id===t);if(!o||o.type!=="card")return n;const a=s.children.filter(d=>d.id!==t);if(a.length===s.children.length||a.length<1)return n;const l=[...n];if(a.length===1){const[d]=a;l[i]=d.type==="card"?zc(d):d}else l[i]={...s,children:a};const u=Math.max(0,Math.min(r,l.length));return l.splice(u,0,zc(o)),l}const AD=xt(),xD=xt(),TD=50;function CD(n,e){if(n.type!==e.type)return!1;switch(n.type){case"reorder":return e.index===n.index;case"stack":return e.targetCardId===n.targetCardId&&e.position===n.position;case"stack-child-noop":return!0;case"stack-child-extract":return e.toIndex===n.toIndex;case"stack-child-reorder":return e.position===n.position;default:return!1}}function Ks(n){return{id:n.id,type:"drop-target",width:n.width,height:n.height}}function Lf(n){return n.map(PD)}function ID(n){return n.type==="drop-target"?{id:n.id,type:"card",artifactID:n.id,width:n.width,height:n.height}:n}function PD(n){return n.type==="drop-target"?{id:n.id,type:"card",artifactID:n.id,width:n.width,height:n.height}:n.type==="stack"?{...n,children:n.children.map(ID)}:n}function Wy(n,e){return n.find(r=>r.type==="card"&&r.id===e)??null}function Mf(n,e){return n.find(r=>r.type==="stack"&&r.id===e)??null}function RD(n,e){const t=[...e],r=t.findIndex(a=>a.type==="card"&&a.id===n.nodeId);if(r===-1)return null;const i=t[r];if(!i||i.type!=="card")return null;t.splice(r,1);const s=Math.max(0,Math.min(n.lastReorderIndex,t.length));t.splice(s,0,i);const o=t.findIndex(a=>a.type==="card"&&a.id===n.nodeId);return o===-1?null:{base:t,visualDraggedIndex:o}}function DD(n,e,t,r){const i=[...n.base];i.splice(n.visualDraggedIndex,1);const s=i.findIndex(v=>v.type==="card"&&v.id===t.targetCardId),o=s===-1?null:i[s];if(!o||o.type!=="card")return null;const a=Wy(r,e.nodeId);if(!a)return null;const l=Oc(a),u=Oc(o),d=Ks(l),f=t.position==="above"?[d,u]:[u,d];return i[s]={id:o.id,type:"stack",children:f},i}function Ul(n,e){return n.parentStackId?zD(n,e):OD(n,e)}function OD(n,e){const t=n.hitTarget;if(t.type==="reorder"){const r=e[n.sourceIndex];if(!r||r.type!=="card")return[...e];const i=[...e];return i.splice(n.sourceIndex,1),i.splice(t.index,0,Ks(r)),i}if(t.type==="stack"){const r=RD(n,e);return r?DD(r,n,t,e)??[...e]:[...e]}return[...e]}function zD(n,e){const t=n.hitTarget;switch(t.type){case"stack-child-reorder":return LD(n,e,t.position);case"stack-child-extract":return MD(n,e,t.toIndex);case"stack-child-noop":return ND(n,e);default:return[...e]}}function LD(n,e,t){const r=e.findIndex(v=>v.type==="stack"&&v.id===n.parentStackId);if(r===-1)return[...e];const i=e[r];if(!i||i.type!=="stack")return[...e];if(!i.children.every(v=>v.type==="card"))return[...e];const s=i.children,o=s.findIndex(v=>v.id===n.nodeId);if(o===-1)return[...e];const a=s[o],l=s.filter(v=>v.id!==n.nodeId),u=Ks(a),d=t==="above"?[u,...l]:[...l,u],f=[...e];return f[r]={...i,children:d},f}function MD(n,e,t){if(!n.parentStackId)return[...e];const r=$D(e,n.parentStackId,n.nodeId,t);if(r===e)return[...e];const i=r.findIndex(a=>a.type==="card"&&a.id===n.nodeId);if(i===-1)return[...e];const s=r[i];if(!s||s.type!=="card")return[...e];const o=[...r];return o[i]=Ks(s),o}function ND(n,e){const t=e.findIndex(l=>l.type==="stack"&&l.id===n.parentStackId);if(t===-1)return[...e];const r=e[t];if(!r||r.type!=="stack")return[...e];const i=r.children.findIndex(l=>l.type==="card"&&l.id===n.nodeId);if(i===-1)return[...e];const s=r.children[i];if(!s||s.type!=="card")return[...e];const o=[...e],a=[...r.children];return a[i]=Ks(s),o[t]={...r,children:a},o}function UD(n,e){return e.find(r=>r.type==="stack"&&r.id===n.id)?n.id:Su()}function FD(n,e,t){if(n.type==="drop-target"){const r=Fu(e,t);if(!r)throw new Error(`finalize: missing dragged card ${t}`);return Oc(r)}return n}function ZD(n,e,t){const r=n.children.map(s=>FD(s,e,t));return{id:UD(n,e),type:"stack",children:r}}function HD(n,e,t){if(n.type==="drop-target"){const r=Fu(e,t);if(!r)throw new Error(`finalize: missing dragged card ${t}`);return Wy(e,t)!==null?r:zc(r)}return n.type==="card"||n.type==="row"?n:ZD(n,e,t)}function VD(n,e,t){return n.map(r=>HD(r,e,t))}function jD(n,e){return JSON.stringify(n)===JSON.stringify(e)}const BD=di(Tt);class GD extends BD{constructor(t={}){super();b(this,"pending",null);b(this,"active",null)}start(t){if(this.pending||this.active)return;const r=t.pointer.x??0,i=t.pointer.y??0;this.pending={startX:r,startY:i,grabOffsetX:t.grabOffset.x??0,grabOffsetY:t.grabOffset.y??0,nodeId:t.nodeId,sourceIndex:t.source.index,parentStackId:t.source.parentId,width:t.size.x??0,height:t.size.y??0,baseLayout:t.layout}}update(t){const r=t.pointer.x??0,i=t.pointer.y??0,s=this.pending;if(s){const u=r-s.startX,d=i-s.startY;Math.hypot(u,d)>=S0&&(this.pending=null,this.active={...s,pointerX:r,pointerY:i,hitTarget:{type:"reorder",index:s.sourceIndex},lastReorderIndex:s.sourceIndex},this.emitDrag(),this.dispatchEvent(new Q("change")));return}if(!this.active)return;const o=Ul(this.active,this.active.baseLayout),a=this.getHitTargetForPointer(r,i,t,o),l=a.type==="reorder"?a.index:this.active.lastReorderIndex;this.active.pointerX===r&&this.active.pointerY===i&&CD(this.active.hitTarget,a)&&this.active.lastReorderIndex===l||(this.active={...this.active,pointerX:r,pointerY:i,hitTarget:a,lastReorderIndex:l},this.emitDrag(),this.dispatchEvent(new Q("change")))}drop(){if(this.pending){this.cancel();return}if(!this.active)return;const t=this.active.baseLayout;let r=null;try{const i=Ul(this.active,t),s=VD(i,t,this.active.nodeId);jD(s,t)||(r=s)}catch{r=null}this.reset(),r&&this.dispatchEvent(new xD("drop",{layout:r})),this.dispatchEvent(new Q("change"))}cancel(){!this.pending&&!this.active||(this.reset(),this.dispatchEvent(new Q("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 t=Ul(this.active,this.active.baseLayout);this.dispatchEvent(new AD("drag",{nodeId:this.active.nodeId,source:{index:this.active.sourceIndex,parentId:this.active.parentStackId},grabOffset:ke({x:this.active.grabOffsetX,y:this.active.grabOffsetY}),pointer:ke({x:this.active.pointerX,y:this.active.pointerY}),size:ke({x:this.active.width,y:this.active.height}),projectedLayout:t}))}getHitTargetForPointer(t,r,i,s){return this.active?this.isPointerInsideDragBounds(t,r,i.viewport)?this.active.parentStackId?this.getStackChildHitTarget(t,r,i,s):this.getTopLevelCardHitTarget(t,r,i,s):{type:"reorder",index:this.active.sourceIndex}:{type:"reorder",index:0}}getStackChildHitTarget(t,r,i,s){var u;if(!((u=this.active)!=null&&u.parentStackId))return{type:"stack-child-noop"};const o=this.getSourceStackInteractionRect(i.geometry);if(o&&xn(t,r,o)){const d=o.top+o.height/2;return{type:"stack-child-reorder",position:r<d?"above":"below"}}const a=this.getSourceRemainingSiblingRect(i.geometry);if(a&&xn(t,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(t,r,i,s)}}getSourceRemainingSiblingRect(t){var s,o;if(!((s=this.active)!=null&&s.parentStackId))return;const r=Mf(this.active.baseLayout,this.active.parentStackId);if(!r)return;const i=r.children.find(a=>{var l;return a.type==="card"&&a.id!==((l=this.active)==null?void 0:l.nodeId)});if(i)return(o=t.find(a=>a.id===i.id))==null?void 0:o.rect}getSourceStackInteractionRect(t){var o;if(!((o=this.active)!=null&&o.parentStackId))return;const r=t.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 i=Mf(this.active.baseLayout,this.active.parentStackId);if(!i)return this.active.sourceStackRect;const s=i.children.find(a=>{var l;return a.type==="card"&&a.id!==((l=this.active)==null?void 0:l.nodeId)});if(s){const a=t.find(l=>l.id===s.id);if(a)return a.rect}return this.active.sourceStackRect}getTopLevelCardHitTarget(t,r,i,s){var y,A,k;const o=this.getTopLevelZoneNodes(i.geometry,s);if(o.length===0)return{type:"reorder",index:((y=this.active)==null?void 0:y.sourceIndex)??0};const l=(i.effectiveVelocity??0)<=TD;for(const I of o){const B=I.rect;if(!xn(t,r,B))continue;const P=this.resolveTopLevelTargetForCard(t,r,I,I.logicalIndex,l);if(P)return P;if(!l&&((A=this.active)!=null&&A.hitTarget))return this.active.hitTarget}const u=this.getNearestTargetableZone(t,o);if(!u)return{type:"reorder",index:((k=this.active)==null?void 0:k.sourceIndex)??0};const d=Math.max(u.rect.left,Math.min(u.rect.left+u.rect.width,t)),f=this.resolveTopLevelTargetForCard(d,r,u,u.logicalIndex,l);if(f)return f;const v=u.rect.left+u.rect.width/2;return{type:"reorder",index:t<v?u.logicalIndex:u.logicalIndex+1}}getTopLevelReorderIndexForPointer(t,r,i,s){var u,d;const o=this.getTopLevelZoneNodes(i.geometry,s);if(o.length===0)return((u=this.active)==null?void 0:u.sourceIndex)??0;for(const f of o){if(!xn(t,r,f.rect))continue;const v=Nl(f.rect,Ml["reorder-before"]);if(xn(t,r,v))return f.logicalIndex;const y=Nl(f.rect,Ml["reorder-after"]);if(xn(t,r,y))return f.logicalIndex+1}const a=this.getNearestTargetableZone(t,o);if(!a)return((d=this.active)==null?void 0:d.sourceIndex)??0;const l=a.rect.left+a.rect.width/2;return t<l?a.logicalIndex:a.logicalIndex+1}getTopLevelZoneNodes(t,r){const i=new Map(r.map(a=>[a.id,a])),s=[];let o=0;for(const a of t){const l=i.get(a.id);l&&l.type!=="drop-target"&&(l.type==="card"||l.type==="stack")&&(s.push({id:l.id,rect:a.rect,logicalIndex:o}),o+=1)}return s}resolveTopLevelTargetForCard(t,r,i,s,o){const a=i.rect;for(const l of ED){if(!o&&(l==="stack-above"||l==="stack-below"))continue;const u=Ml[l],d=Nl(a,u);if(xn(t,r,d))return l==="stack-above"?{type:"stack",targetCardId:i.id,position:"above"}:l==="stack-below"?{type:"stack",targetCardId:i.id,position:"below"}:l==="reorder-before"?{type:"reorder",index:s}:{type:"reorder",index:s+1}}return null}getNearestTargetableZone(t,r){let i=null,s=Number.POSITIVE_INFINITY;for(const o of r){const a=o.rect.left,l=o.rect.left+o.rect.width,u=t<a?a-t:t>l?t-l:0;u<s&&(s=u,i=o)}return i}isPointerInsideDragBounds(t,r,i){return t>=i.left&&t<=i.left+i.width&&r>=i.top&&r<=i.top+i.height}}const Nf=60,WD=80,Uf=.5,Ff=10;class qD{constructor(){b(this,"awaitingFreshWheelGesture",!1);b(this,"lastWheelEventAt",Number.NEGATIVE_INFINITY);b(this,"lastWheelDeltaX",0);b(this,"activeGestureType","none");b(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:t,shiftKey:r,deltaX:i,deltaY:s,overArtifactContent:o}=e;t-this.lastWheelGestureAt>=Nf&&(this.activeGestureType="none");const l=r&&s!==0,u=l?s:i,d=Math.abs(u),f=Math.abs(s);return this.activeGestureType==="vertical-artifact"&&o?d>=Uf&&d>=f*Ff?this.classifyHorizontal(t,u):(this.lastWheelGestureAt=t,{type:"scroll-native"}):this.activeGestureType==="horizontal-filmstrip"?!l&&o&&f>0&&f>=d*Ff?(this.activeGestureType="vertical-artifact",this.lastWheelGestureAt=t,{type:"scroll-native"}):this.classifyHorizontal(t,u):d<Uf?(o&&(this.activeGestureType="vertical-artifact"),this.lastWheelGestureAt=t,{type:"scroll-native"}):l||d>f?this.classifyHorizontal(t,u):f>d?(o&&(this.activeGestureType="vertical-artifact"),this.lastWheelGestureAt=t,{type:"scroll-native"}):o?(this.activeGestureType="vertical-artifact",this.lastWheelGestureAt=t,{type:"scroll-native"}):this.classifyHorizontal(t,u)}classifyHorizontal(e,t){const r=e-this.lastWheelEventAt,i=Math.sign(this.lastWheelDeltaX),s=Math.sign(t),o=i!==0&&s!==0&&i!==s,a=i!==0&&Math.abs(t)>=Math.abs(this.lastWheelDeltaX)+WD;return this.awaitingFreshWheelGesture&&r<Nf&&!o&&!a?{type:"ignore"}:(this.lastWheelEventAt=e,this.lastWheelDeltaX=t,this.lastWheelGestureAt=e,this.awaitingFreshWheelGesture=!1,this.activeGestureType="horizontal-filmstrip",{type:"scroll-horizontal",horizontalDelta:t})}}const YD=2,Zf=1e3,_o=1e-4;function Hf(n,e,t){if(n===0)return 0;const r=e.toPixels(Te({y:Je})).y??0;return(t-r)/YD}function Fl(n){const e=n.clientWidth>0?n.clientWidth:tr,t=n.clientHeight>0?n.clientHeight:Yo;let r=0,i=0;if(n.isConnected){const o=getComputedStyle(n);r=parseFloat(o.paddingTop)||0,i=parseFloat(o.paddingBottom)||0}const s=Math.max(1,t-r-i);return{width:e,height:s,offsetY:r}}class KD extends Event{constructor(t){super("scroll",{bubbles:!0,composed:!0});b(this,"scrollPosition");this.scrollPosition=t}}class qy extends Event{constructor(t){super("layout-change",{bubbles:!0,composed:!0});b(this,"layout");this.layout=t}}class JD extends HTMLElement{constructor(){super();b(this,"_layout",[]);b(this,"_scrollPosition",0);b(this,"layoutGrid",null);b(this,"layoutScroll",new kD(Te({x:0})));b(this,"scrollModelKey","");b(this,"resizeObserver",null);b(this,"renderPending",!1);b(this,"animateNextRender",!0);b(this,"wheelGesture",new qD);b(this,"dragController",new GD);b(this,"dragState",null);b(this,"activeDragPointerId",null);b(this,"dragListenersAttached",!1);b(this,"dragFrame",0);b(this,"lastDragFrameTime",0);b(this,"lastPointerX",0);b(this,"lastPointerY",0);b(this,"pointerVelocityPxPerSec",0);b(this,"scrollVelocityPxPerSec",0);b(this,"motionSampleTime",0);b(this,"motionSampleX",0);b(this,"motionSampleY",0);b(this,"dragTrackOffsetXPx",0);b(this,"previousProjectedLayoutForOffset",null);b(this,"renderContent",()=>F``);b(this,"onDragControllerChange",()=>{this.dragController.status==="idle"&&(this.dragState=null,this.dragTrackOffsetXPx=0,this.previousProjectedLayoutForOffset=null),this.scheduleRender()});b(this,"onDragControllerDrag",t=>{const r=Lf(t.projectedLayout),i=this.shouldApplyTrackOffset(t.projectedLayout,t.source.parentId),s=t.source.parentId?this.getStackChildAnchorCardId(t.source.parentId,t.nodeId):null;this.dragTrackOffsetXPx=i?this.computeDragTrackOffset(this.previousProjectedLayoutForOffset,r,t.nodeId,t.source.parentId,s,this.dragTrackOffsetXPx):0,this.previousProjectedLayoutForOffset=r,this.dragState={nodeId:t.nodeId,source:t.source,grabOffset:t.grabOffset,pointer:t.pointer,size:t.size,projectedLayout:t.projectedLayout},this.scheduleRender()});b(this,"onDragControllerDrop",t=>{this.dragState=null,this.dragTrackOffsetXPx=0,this.previousProjectedLayoutForOffset=null,this.commitLayout(t.layout)});b(this,"onLayoutScrollInternal",t=>{const i=t.scroll.x??0;Math.abs(i-this._scrollPosition)<_o||(this._scrollPosition=i,this.emitScrollPositionChanged(i),this.scheduleRender())});b(this,"handleKeyDown",t=>{if(t.key==="Escape"&&this.dragController.status!=="idle"){t.preventDefault(),this.stopDragFrameLoop(),this.releaseActiveDragPointerCapture(),this.dragController.cancel(),this.detachDragListeners();return}this.dragController.status==="idle"&&(t.key==="ArrowRight"?(t.preventDefault(),this.wheelGesture.markKeyboardNavigation(Date.now()),this.shiftWindow(1)):t.key==="ArrowLeft"&&(t.preventDefault(),this.wheelGesture.markKeyboardNavigation(Date.now()),this.shiftWindow(-1)))});b(this,"handleWheel",t=>{if(this._layout.length===0)return;const r=this.wheelGesture.decide({now:Date.now(),shiftKey:t.shiftKey,deltaX:t.deltaX,deltaY:t.deltaY,overArtifactContent:!1});r.type==="scroll-horizontal"&&(t.preventDefault(),this.applyHorizontalWheel(r.horizontalDelta))});b(this,"handleWindowMessage",t=>{var o;if(this._layout.length===0)return;const r=this.findManagedArtifactFrame(t.source);if(!r||!this.isTrustedArtifactFrameMessage(t,r)||!RC(t.data))return;const i=this.wheelGesture.decide({now:Date.now(),shiftKey:t.data.shiftKey,deltaX:t.data.deltaX,deltaY:t.data.deltaY,overArtifactContent:!0});if(i.type==="scroll-horizontal"){this.applyHorizontalWheel(i.horizontalDelta);return}if(i.type!=="scroll-native")return;const s={type:"scroll",deltaX:0,deltaY:t.data.deltaY};(o=r.contentWindow)==null||o.postMessage(s,this.getArtifactFrameTargetOrigin(r))});b(this,"handlePointerDown",t=>{if(t.button!==0||this.dragController.status!=="idle")return;const r=t.target;if(!(r instanceof Element)||!r.closest("[drag-handle]")||r.closest("button, input, textarea, select, a, [role='button']"))return;const i=r.closest(".card-slot");if(!i)return;const s=i.getAttribute("data-layout-node-id");if(!s)return;const o=QD(this._layout,s);if(!o)return;const a=i.getBoundingClientRect();this.lastPointerX=t.clientX,this.lastPointerY=t.clientY,this.resetMotionTracking(t.clientX,t.clientY),this.focus(),this.dragController.start({nodeId:s,source:{index:o.topLevelIndex,parentId:o.sourceStackId},pointer:ke({x:t.clientX,y:t.clientY}),grabOffset:ke({x:t.clientX-a.left,y:t.clientY-a.top}),size:ke({x:a.width,y:a.height}),layout:this._layout}),this.attachDragListeners(),this.activeDragPointerId=t.pointerId;try{this.setPointerCapture(t.pointerId)}catch{}t.preventDefault()});b(this,"handleWindowPointerMove",t=>{this.lastPointerX=t.clientX,this.lastPointerY=t.clientY,this.updatePointerVelocity(t.clientX,t.clientY),this.syncDragTargetForLatestPointer(),this.ensureDragFrameLoop()});b(this,"handleWindowPointerUp",t=>{this.stopDragFrameLoop(),this.releasePointerCaptureForEvent(t.pointerId),this.dragController.drop(),this.clearMotionTracking(),this.detachDragListeners()});b(this,"handleWindowPointerCancel",t=>{this.stopDragFrameLoop(),this.releasePointerCaptureForEvent(t.pointerId),this.dragController.cancel(),this.clearMotionTracking(),this.detachDragListeners()});b(this,"handleWindowBlur",()=>{this.releaseActiveDragPointerCapture(),this.stopDragFrameLoop(),this.dragController.cancel(),this.clearMotionTracking(),this.detachDragListeners()});b(this,"runDragFrame",t=>{if(this.dragController.status==="idle"){this.dragFrame=0;return}const r=Math.max(0,t-this.lastDragFrameTime)/Zf;this.lastDragFrameTime=t,this.samplePointerVelocityAt(t,this.lastPointerX,this.lastPointerY);const i=this.getBoundingClientRect(),s=this.clampPointerToViewport(this.lastPointerX,this.lastPointerY,i),o=this.getDragEdgeScrollDeltaPixels(s.x,i,r);this.scrollVelocityPxPerSec=r>_o?Math.abs(o)/r:0,Math.abs(o)>_o&&(this.animateNextRender=!1,this.layoutScroll.wheelPixels(ke({x:o}))),this.dragController.status==="active"&&this.syncDragTarget(s.x,s.y,i),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(t){this._layout=[...t],this.stopDragFrameLoop(),this.dragController.cancel(),this.scrollModelKey="",this.syncScrollModel(),this.layoutScroll.scroll=Te({x:this._scrollPosition}),this.scheduleRender()}get layout(){return this._layout}commitLayout(t){this.layout=t,this.emitLayoutChanged()}set scrollPosition(t){Math.abs(t-this._scrollPosition)<_o||(this.animateNextRender=!1,this.syncScrollModel(),this.layoutScroll.scroll=Te({x:t}))}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 t;this.removeEventListener("keydown",this.handleKeyDown),this.removeEventListener("wheel",this.handleWheel),this.removeEventListener("pointerdown",this.handlePointerDown),window.removeEventListener("message",this.handleWindowMessage),(t=this.resizeObserver)==null||t.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(t,r){return new dD({basis:ke({x:Pn,y:Pn}),min:ke({x:Kd,y:Kd}),viewport:ke({x:t,y:r}),gap:ke({x:pe,y:pe})})}syncScrollModel(){const t=Fl(this),i=Wi(this._layout).nodes.map(o=>o.width),s=`${t.width}x${t.height}:${i.join(",")}`;s===this.scrollModelKey&&this.layoutGrid||(this.scrollModelKey=s,this.layoutGrid=this.createGrid(t.width,t.height),this.layoutScroll.rebuild({grid:this.layoutGrid,nodeWidths:i.map(o=>Te({x:o}))}))}emitScrollPositionChanged(t){this.dispatchEvent(new KD(t))}emitLayoutChanged(){this.dispatchEvent(new qy([...this._layout]))}shiftWindow(t){this.syncScrollModel(),this.animateNextRender=!0,this.layoutScroll.step(t)}applyHorizontalWheel(t){this.syncScrollModel();const r=this.layoutGrid;if(!r)return;this.animateNextRender=!1;const i=r.toUnits(ke({x:t}));this.layoutScroll.wheel(Te({x:i.x??0}))}findManagedArtifactFrame(t){if(!t)return null;const r=this.querySelectorAll("iframe.artifact-frame");for(const i of r)if(i.contentWindow===t)return i;return null}isTrustedArtifactFrameMessage(t,r){if(t.origin==="null")return!0;const i=this.getArtifactFrameOrigin(r);return i===null||t.origin===i}getArtifactFrameTargetOrigin(t){const r=t.getAttribute("sandbox")??"";return new Set(r.split(/\s+/).filter(Boolean)).has("allow-same-origin")?this.getArtifactFrameOrigin(t)??"*":"*"}getArtifactFrameOrigin(t){const r=t.getAttribute("src")??t.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(t){try{this.hasPointerCapture(t)&&this.releasePointerCapture(t)}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 t=new Map;return t.set(this.dragState.nodeId,{id:this.dragState.nodeId,sourceCardId:this.dragState.nodeId}),{layout:Lf(this.dragState.projectedLayout),activePlaceholderId:this.dragState.nodeId,placeholdersById:t}}render(){const t=Fl(this),r=this.createGrid(t.width,t.height);this.layoutGrid=r;const i=this.getDisplayModel(),s=i.layout,o=this.dragController.status==="active",a=Wi(s),l=a.nodes.map(M=>M.width),u=`${t.width}x${t.height}:${l.join(",")}`;!o&&u!==this.scrollModelKey&&(this.scrollModelKey=u,this.layoutScroll.rebuild({grid:r,nodeWidths:l.map(M=>Te({x:M}))}),this._scrollPosition=this.layoutScroll.scroll.x??this._scrollPosition);const d=XD(s),f=r.unit.x??Pn,v=r.unit.y??Pn,y=o?this.dragTrackOffsetXPx:0,A=(this.layoutScroll.translate.x??0)+y,k=Hf(a.nodes.length,r,t.height),I=this.animateNextRender&&!o,B=[`transform: translate(${A}px, ${k}px);`,`transition-duration: ${I?_0:0}ms;`,`pointer-events: ${o?"none":"auto"};`].join(" ");this.animateNextRender=!0,this.style.setProperty("--layout-unit-x",`${f}px`),this.style.setProperty("--layout-unit-y",`${v}px`),this.style.setProperty("--layout-gap",`${pe}px`);const P=this.dragState,le={width:(P==null?void 0:P.size.x)??0,height:(P==null?void 0:P.size.y)??0};Pe(F`
157
- <div class="track" style=${B}>
156
+ `}render(){this._artifact&&(this.setAttribute("type",this._artifact.type),Pe(this.template(),this))}}customElements.define("artifact-view",oD);const ke=n=>({type:"px",...n}),Te=n=>({type:"unit",...n}),wo=2,aD=2;class lD{constructor(e){b(this,"basis");b(this,"min");b(this,"_gap");b(this,"_viewport");b(this,"_unit");this.basis=e.basis,this.min=e.min,this._viewport=e.viewport,this._gap=e.gap??ke({x:pe,y:pe});const t=this._viewport.x??tr,r=this._viewport.y??Yo,i=this._gap.x??pe,s=this._gap.y??pe,o=tr+i*aD,a=t<=o,l=a?t-i*wo:Math.min(tr,t-i*wo),u=a?r-s*wo:Math.min(Yo,r-s*wo),d=(l-i*(At-1))/At,f=(u-s*(Je-1))/Je,v=this.basis.x??0,y=this.basis.y??0,A=this.min.x??0,k=this.min.y??0;this._unit=ke(a?{x:Math.max(A,d),y:Math.max(k,f)}:{x:Math.max(A,Math.min(v,d)),y:Math.max(k,Math.min(y,f))})}get unit(){return this._unit}get viewport(){return this._viewport}get gap(){return this._gap}toUnits(e){return Te({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 t=this._unit.x??0,r=this._unit.y??0,i=this._gap.x??pe,s=this._gap.y??pe,o=e.x==null?void 0:e.x*t+Math.max(0,e.x-1)*i,a=e.y==null?void 0:e.y*r+Math.max(0,e.y-1)*s;return ke({x:o,y:a})}}const ir=1e-4,Gt=1e-6,cD=40,uD=24;function Zy(n,e){return Math.max(0,n-e*2)}function Hy(n){const e=[0];for(const t of n)e.push((e[e.length-1]??0)+t);return e}function Vy(n){const e=[0];for(let t=0;t<n.length;t+=1){const r=e[t]??0;e.push(r+n[t]+pe)}return e}function jy(n,e,t){if(e<0||e>=n.length)return 0;let r=0,i=0;for(let s=e;s<n.length;s+=1){const o=n[s],a=i===0?o:r+pe+o;if(a>t+ir)break;r=a,i+=1}return Math.max(1,i)}function hD(n,e,t){if(e<0||e>=n.length)return 0;let r=0,i=0;for(let s=e;s>=0;s-=1){const o=n[s],a=i===0?o:r+pe+o;if(a>t+ir)break;r=a,i+=1}return Math.max(1,i)}function dD(n,e){if(n.length===0)return 0;let t=0,r=0;for(let i=n.length-1;i>=0;i-=1){const s=n[i],o=r===0?s:t+pe+s;if(o>e+ir)break;t=o,r+=1}return Math.max(1,r)}function Zu(n,e){if(n.length===0)return 0;const t=dD(n,e);return Math.max(0,n.length-t)}function Df(n,e,t){if(n.length===0)return 0;const r=jy(n,e,t),i=Math.min(n.length,e+r);if(i<=e)return 0;const s=n.slice(e,i);return s.reduce((o,a)=>o+a,0)+Math.max(0,s.length-1)*pe}function zc(n,e,t){const r=n[e]??0;return t-r}function xr(n,e,t,r,i){if(n.length===0)return 0;const s=Zu(n,i),o=e[s]??0,a=Math.max(0,Math.min(o,t));let l=0;for(let Z=0;Z<s;Z+=1){const U=e[Z]??0,ge=e[Z+1]??U;if(a>=U&&a<=ge+ir){l=Z;break}l=Z+1}const u=Math.min(l+1,s),d=e[l]??0,f=e[u]??d,v=Math.max(f-d,ir),y=u===l?0:(a-d)/v,A=Vy(n),k=Df(n,l,i),I=Df(n,u,i),G=(r-k)/2,P=(r-I)/2,le=zc(A,l,G),M=zc(A,u,P);return le+(M-le)*y}function Of(n,e,t,r,i){const s=Zu(n,r),o=e[s]??0;let a=0,l=o;for(let u=0;u<cD;u+=1){const d=(a+l)/2;xr(n,e,d,t,r)>i?a=d:l=d}return(a+l)/2}function zf(n,e,t){const r=Vy(n),[i,s]=e,o=n.slice(i,s+1),a=o.reduce((u,d)=>u+d,0)+Math.max(0,o.length-1)*pe,l=(t-a)/2;return zc(r,i,l)}function fD(n,e,t){const r=jy(n,e,t);return[e,Math.min(n.length-1,e+r-1)]}function pD(n,e,t){const r=hD(n,e,t);return[Math.max(0,e-r+1),e]}function gD(n){const e=new Set,t=[];for(const r of n){const i=`${r.nodeRange[0]}:${r.nodeRange[1]}`;if(e.has(i))continue;const s=t[t.length-1];s&&Math.abs(s.anchor-r.anchor)<=Gt||(e.add(i),t.push(r))}return t}function mD(n){const{nodeCols:e,nodeWidthsPx:t,viewportWidthPx:r}=n;if(e.length===0||t.length===0)return{viewspans:[],minScroll:0,maxScroll:0};const i=n.gapPx??pe,s=Zy(r,i),o=Hy(e),a=Zu(t,s),l=o[a]??0,u=[];for(let d=0;d<=a;d+=1){const f=fD(t,d,s),v=zf(t,f,r),y=Of(t,o,r,s,v);u.push({nodeRange:f,anchor:Math.max(0,Math.min(l,y))})}for(let d=t.length-1;d>=0;d-=1){const f=pD(t,d,s),v=`${f[0]}:${f[1]}`;if(u.some(k=>`${k.nodeRange[0]}:${k.nodeRange[1]}`===v))continue;const y=zf(t,f,r),A=Of(t,o,r,s,y);u.push({nodeRange:f,anchor:Math.max(0,Math.min(l,A))})}return u.sort((d,f)=>Math.abs(d.anchor-f.anchor)>Gt?d.anchor-f.anchor:d.nodeRange[0]!==f.nodeRange[0]?d.nodeRange[0]-f.nodeRange[0]:d.nodeRange[1]-f.nodeRange[1]),{viewspans:gD(u),minScroll:0,maxScroll:l}}function yD(n,e){var i;let t=0,r=Number.POSITIVE_INFINITY;for(let s=0;s<n.length;s+=1){const o=Math.abs((((i=n[s])==null?void 0:i.anchor)??0)-e);if(o+Gt<r){r=o,t=s;continue}Math.abs(o-r)<=Gt&&s<t&&(t=s)}return t}function vD(n,e,t){return t<=0?0:Math.max(0,Math.min(t-1,n+e))}function Ai(n,e,t){return Math.max(e,Math.min(t,n))}class bD extends Tt{constructor(t){super();b(this,"_scroll",0);b(this,"minScroll",0);b(this,"maxScroll",0);b(this,"viewspans",[]);b(this,"activeViewspanIndex",null);b(this,"nodeWidthsPx",[]);b(this,"boundaryCols",[0]);b(this,"viewportWidthPx",0);b(this,"framedViewportWidthPx",0);this._scroll=(t==null?void 0:t.x)??0}get scroll(){return Te({x:this._scroll})}get translate(){return ke({x:xr(this.nodeWidthsPx,this.boundaryCols,this._scroll,this.viewportWidthPx,this.framedViewportWidthPx)})}set scroll(t){const r=Ai(t.x??this._scroll,this.minScroll,this.maxScroll);Math.abs(r-this._scroll)<=Gt||(this._scroll=r,this.activeViewspanIndex=null,this.dispatchEvent(new Ei("layout-scroll",{scroll:this.scroll})))}rebuild(t){const r=t.nodeWidths.map(u=>Math.max(0,u.x??0)),i=r.map(u=>t.grid.toPixels(Te({x:u})).x??0),s=t.grid.viewport.x??0,o=t.grid.gap.x??pe,a=mD({nodeCols:r,nodeWidthsPx:i,viewportWidthPx:s,gapPx:o});this.nodeWidthsPx=i,this.boundaryCols=Hy(r),this.viewportWidthPx=s,this.framedViewportWidthPx=Zy(s,o),this.viewspans=a.viewspans,this.minScroll=a.minScroll,this.maxScroll=a.maxScroll,this.activeViewspanIndex=null;const l=Ai(this._scroll,this.minScroll,this.maxScroll);Math.abs(l-this._scroll)>Gt&&(this._scroll=l,this.dispatchEvent(new Ei("layout-scroll",{scroll:this.scroll})))}step(t){var a;if(this.viewspans.length===0)return;const r=this.activeViewspanIndex??yD(this.viewspans,this._scroll),i=vD(r,t,this.viewspans.length),s=((a=this.viewspans[i])==null?void 0:a.anchor)??this._scroll,o=Ai(s,this.minScroll,this.maxScroll);this.activeViewspanIndex=i,!(Math.abs(o-this._scroll)<=Gt)&&(this._scroll=o,this.dispatchEvent(new Ei("layout-scroll",{scroll:this.scroll})))}wheel(t){const r=Ai(this._scroll+(t.x??0),this.minScroll,this.maxScroll);this.activeViewspanIndex=null,!(Math.abs(r-this._scroll)<=Gt)&&(this._scroll=r,this.dispatchEvent(new Ei("layout-scroll",{scroll:this.scroll})))}wheelPixels(t){const r=t.x??0;if(Math.abs(r)<=ir)return;this.activeViewspanIndex=null;const i=xr(this.nodeWidthsPx,this.boundaryCols,this._scroll,this.viewportWidthPx,this.framedViewportWidthPx),s=i-r,o=xr(this.nodeWidthsPx,this.boundaryCols,this.maxScroll,this.viewportWidthPx,this.framedViewportWidthPx),a=xr(this.nodeWidthsPx,this.boundaryCols,this.minScroll,this.viewportWidthPx,this.framedViewportWidthPx),l=Math.max(o,Math.min(a,s));if(Math.abs(l-i)<=ir)return;let u=this.minScroll,d=this.maxScroll;for(let v=0;v<uD;v+=1){const y=(u+d)/2;xr(this.nodeWidthsPx,this.boundaryCols,y,this.viewportWidthPx,this.framedViewportWidthPx)>l?u=y:d=y}const f=Ai((u+d)/2,this.minScroll,this.maxScroll);Math.abs(f-this._scroll)<=Gt||(this._scroll=f,this.dispatchEvent(new Ei("layout-scroll",{scroll:this.scroll})))}}const Ul={"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}},wD=["stack-above","stack-below","reorder-before","reorder-after"];function Fl(n,e){return{left:n.left+n.width*e.left,top:n.top+n.height*e.top,width:n.width*e.width,height:n.height*e.height}}function xn(n,e,t){return n>=t.left&&n<t.left+t.width&&e>=t.top&&e<t.top+t.height}function Hu(n,e){for(const t of n){if(t.type==="card"&&t.id===e)return t;if(t.type==="stack")for(const r of t.children){if(r.type==="card"&&r.id===e)return r;if(r.type==="row"){for(const i of r.children)if(i.id===e)return i}}}return null}function Lc(n){return n.height===Je||n.height===fn?{...n,height:fn}:n}function Mc(n){return n.height===fn?{...n,height:Je}:n}function _D(n,e,t,r){const i=n.findIndex(d=>d.type==="stack"&&d.id===e);if(i===-1)return n;const s=n[i];if(!s||s.type!=="stack")return n;const o=s.children.find(d=>d.type==="card"&&d.id===t);if(!o||o.type!=="card")return n;const a=s.children.filter(d=>d.id!==t);if(a.length===s.children.length||a.length<1)return n;const l=[...n];if(a.length===1){const[d]=a;l[i]=d.type==="card"?Mc(d):d}else l[i]={...s,children:a};const u=Math.max(0,Math.min(r,l.length));return l.splice(u,0,Mc(o)),l}const SD=xt(),kD=xt(),ED=50;function $D(n,e){if(n.type!==e.type)return!1;switch(n.type){case"reorder":return e.index===n.index;case"stack":return e.targetCardId===n.targetCardId&&e.position===n.position;case"stack-child-noop":return!0;case"stack-child-extract":return e.toIndex===n.toIndex;case"stack-child-reorder":return e.position===n.position;default:return!1}}function Ks(n){return{id:n.id,type:"drop-target",width:n.width,height:n.height}}function Lf(n){return n.map(xD)}function AD(n){return n.type==="drop-target"?{id:n.id,type:"card",artifactID:n.id,width:n.width,height:n.height}:n}function xD(n){return n.type==="drop-target"?{id:n.id,type:"card",artifactID:n.id,width:n.width,height:n.height}:n.type==="stack"?{...n,children:n.children.map(AD)}:n}function Gy(n,e){return n.find(r=>r.type==="card"&&r.id===e)??null}function Mf(n,e){return n.find(r=>r.type==="stack"&&r.id===e)??null}function TD(n,e){const t=[...e],r=t.findIndex(a=>a.type==="card"&&a.id===n.nodeId);if(r===-1)return null;const i=t[r];if(!i||i.type!=="card")return null;t.splice(r,1);const s=Math.max(0,Math.min(n.lastReorderIndex,t.length));t.splice(s,0,i);const o=t.findIndex(a=>a.type==="card"&&a.id===n.nodeId);return o===-1?null:{base:t,visualDraggedIndex:o}}function CD(n,e,t,r){const i=[...n.base];i.splice(n.visualDraggedIndex,1);const s=i.findIndex(v=>v.type==="card"&&v.id===t.targetCardId),o=s===-1?null:i[s];if(!o||o.type!=="card")return null;const a=Gy(r,e.nodeId);if(!a)return null;const l=Lc(a),u=Lc(o),d=Ks(l),f=t.position==="above"?[d,u]:[u,d];return i[s]={id:o.id,type:"stack",children:f},i}function Zl(n,e){return n.parentStackId?PD(n,e):ID(n,e)}function ID(n,e){const t=n.hitTarget;if(t.type==="reorder"){const r=e[n.sourceIndex];if(!r||r.type!=="card")return[...e];const i=[...e];return i.splice(n.sourceIndex,1),i.splice(t.index,0,Ks(r)),i}if(t.type==="stack"){const r=TD(n,e);return r?CD(r,n,t,e)??[...e]:[...e]}return[...e]}function PD(n,e){const t=n.hitTarget;switch(t.type){case"stack-child-reorder":return RD(n,e,t.position);case"stack-child-extract":return DD(n,e,t.toIndex);case"stack-child-noop":return OD(n,e);default:return[...e]}}function RD(n,e,t){const r=e.findIndex(v=>v.type==="stack"&&v.id===n.parentStackId);if(r===-1)return[...e];const i=e[r];if(!i||i.type!=="stack")return[...e];if(!i.children.every(v=>v.type==="card"))return[...e];const s=i.children,o=s.findIndex(v=>v.id===n.nodeId);if(o===-1)return[...e];const a=s[o],l=s.filter(v=>v.id!==n.nodeId),u=Ks(a),d=t==="above"?[u,...l]:[...l,u],f=[...e];return f[r]={...i,children:d},f}function DD(n,e,t){if(!n.parentStackId)return[...e];const r=_D(e,n.parentStackId,n.nodeId,t);if(r===e)return[...e];const i=r.findIndex(a=>a.type==="card"&&a.id===n.nodeId);if(i===-1)return[...e];const s=r[i];if(!s||s.type!=="card")return[...e];const o=[...r];return o[i]=Ks(s),o}function OD(n,e){const t=e.findIndex(l=>l.type==="stack"&&l.id===n.parentStackId);if(t===-1)return[...e];const r=e[t];if(!r||r.type!=="stack")return[...e];const i=r.children.findIndex(l=>l.type==="card"&&l.id===n.nodeId);if(i===-1)return[...e];const s=r.children[i];if(!s||s.type!=="card")return[...e];const o=[...e],a=[...r.children];return a[i]=Ks(s),o[t]={...r,children:a},o}function zD(n,e){return e.find(r=>r.type==="stack"&&r.id===n.id)?n.id:Eu()}function LD(n,e,t){if(n.type==="drop-target"){const r=Hu(e,t);if(!r)throw new Error(`finalize: missing dragged card ${t}`);return Lc(r)}return n}function MD(n,e,t){const r=n.children.map(s=>LD(s,e,t));return{id:zD(n,e),type:"stack",children:r}}function ND(n,e,t){if(n.type==="drop-target"){const r=Hu(e,t);if(!r)throw new Error(`finalize: missing dragged card ${t}`);return Gy(e,t)!==null?r:Mc(r)}return n.type==="card"||n.type==="row"?n:MD(n,e,t)}function UD(n,e,t){return n.map(r=>ND(r,e,t))}function FD(n,e){return JSON.stringify(n)===JSON.stringify(e)}const ZD=di(Tt);class HD extends ZD{constructor(t={}){super();b(this,"pending",null);b(this,"active",null)}start(t){if(this.pending||this.active)return;const r=t.pointer.x??0,i=t.pointer.y??0;this.pending={startX:r,startY:i,grabOffsetX:t.grabOffset.x??0,grabOffsetY:t.grabOffset.y??0,nodeId:t.nodeId,sourceIndex:t.source.index,parentStackId:t.source.parentId,width:t.size.x??0,height:t.size.y??0,baseLayout:t.layout}}update(t){const r=t.pointer.x??0,i=t.pointer.y??0,s=this.pending;if(s){const u=r-s.startX,d=i-s.startY;Math.hypot(u,d)>=v0&&(this.pending=null,this.active={...s,pointerX:r,pointerY:i,hitTarget:{type:"reorder",index:s.sourceIndex},lastReorderIndex:s.sourceIndex},this.emitDrag(),this.dispatchEvent(new Q("change")));return}if(!this.active)return;const o=Zl(this.active,this.active.baseLayout),a=this.getHitTargetForPointer(r,i,t,o),l=a.type==="reorder"?a.index:this.active.lastReorderIndex;this.active.pointerX===r&&this.active.pointerY===i&&$D(this.active.hitTarget,a)&&this.active.lastReorderIndex===l||(this.active={...this.active,pointerX:r,pointerY:i,hitTarget:a,lastReorderIndex:l},this.emitDrag(),this.dispatchEvent(new Q("change")))}drop(){if(this.pending){this.cancel();return}if(!this.active)return;const t=this.active.baseLayout;let r=null;try{const i=Zl(this.active,t),s=UD(i,t,this.active.nodeId);FD(s,t)||(r=s)}catch{r=null}this.reset(),r&&this.dispatchEvent(new kD("drop",{layout:r})),this.dispatchEvent(new Q("change"))}cancel(){!this.pending&&!this.active||(this.reset(),this.dispatchEvent(new Q("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 t=Zl(this.active,this.active.baseLayout);this.dispatchEvent(new SD("drag",{nodeId:this.active.nodeId,source:{index:this.active.sourceIndex,parentId:this.active.parentStackId},grabOffset:ke({x:this.active.grabOffsetX,y:this.active.grabOffsetY}),pointer:ke({x:this.active.pointerX,y:this.active.pointerY}),size:ke({x:this.active.width,y:this.active.height}),projectedLayout:t}))}getHitTargetForPointer(t,r,i,s){return this.active?this.isPointerInsideDragBounds(t,r,i.viewport)?this.active.parentStackId?this.getStackChildHitTarget(t,r,i,s):this.getTopLevelCardHitTarget(t,r,i,s):{type:"reorder",index:this.active.sourceIndex}:{type:"reorder",index:0}}getStackChildHitTarget(t,r,i,s){var u;if(!((u=this.active)!=null&&u.parentStackId))return{type:"stack-child-noop"};const o=this.getSourceStackInteractionRect(i.geometry);if(o&&xn(t,r,o)){const d=o.top+o.height/2;return{type:"stack-child-reorder",position:r<d?"above":"below"}}const a=this.getSourceRemainingSiblingRect(i.geometry);if(a&&xn(t,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(t,r,i,s)}}getSourceRemainingSiblingRect(t){var s,o;if(!((s=this.active)!=null&&s.parentStackId))return;const r=Mf(this.active.baseLayout,this.active.parentStackId);if(!r)return;const i=r.children.find(a=>{var l;return a.type==="card"&&a.id!==((l=this.active)==null?void 0:l.nodeId)});if(i)return(o=t.find(a=>a.id===i.id))==null?void 0:o.rect}getSourceStackInteractionRect(t){var o;if(!((o=this.active)!=null&&o.parentStackId))return;const r=t.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 i=Mf(this.active.baseLayout,this.active.parentStackId);if(!i)return this.active.sourceStackRect;const s=i.children.find(a=>{var l;return a.type==="card"&&a.id!==((l=this.active)==null?void 0:l.nodeId)});if(s){const a=t.find(l=>l.id===s.id);if(a)return a.rect}return this.active.sourceStackRect}getTopLevelCardHitTarget(t,r,i,s){var y,A,k;const o=this.getTopLevelZoneNodes(i.geometry,s);if(o.length===0)return{type:"reorder",index:((y=this.active)==null?void 0:y.sourceIndex)??0};const l=(i.effectiveVelocity??0)<=ED;for(const I of o){const G=I.rect;if(!xn(t,r,G))continue;const P=this.resolveTopLevelTargetForCard(t,r,I,I.logicalIndex,l);if(P)return P;if(!l&&((A=this.active)!=null&&A.hitTarget))return this.active.hitTarget}const u=this.getNearestTargetableZone(t,o);if(!u)return{type:"reorder",index:((k=this.active)==null?void 0:k.sourceIndex)??0};const d=Math.max(u.rect.left,Math.min(u.rect.left+u.rect.width,t)),f=this.resolveTopLevelTargetForCard(d,r,u,u.logicalIndex,l);if(f)return f;const v=u.rect.left+u.rect.width/2;return{type:"reorder",index:t<v?u.logicalIndex:u.logicalIndex+1}}getTopLevelReorderIndexForPointer(t,r,i,s){var u,d;const o=this.getTopLevelZoneNodes(i.geometry,s);if(o.length===0)return((u=this.active)==null?void 0:u.sourceIndex)??0;for(const f of o){if(!xn(t,r,f.rect))continue;const v=Fl(f.rect,Ul["reorder-before"]);if(xn(t,r,v))return f.logicalIndex;const y=Fl(f.rect,Ul["reorder-after"]);if(xn(t,r,y))return f.logicalIndex+1}const a=this.getNearestTargetableZone(t,o);if(!a)return((d=this.active)==null?void 0:d.sourceIndex)??0;const l=a.rect.left+a.rect.width/2;return t<l?a.logicalIndex:a.logicalIndex+1}getTopLevelZoneNodes(t,r){const i=new Map(r.map(a=>[a.id,a])),s=[];let o=0;for(const a of t){const l=i.get(a.id);l&&l.type!=="drop-target"&&(l.type==="card"||l.type==="stack")&&(s.push({id:l.id,rect:a.rect,logicalIndex:o}),o+=1)}return s}resolveTopLevelTargetForCard(t,r,i,s,o){const a=i.rect;for(const l of wD){if(!o&&(l==="stack-above"||l==="stack-below"))continue;const u=Ul[l],d=Fl(a,u);if(xn(t,r,d))return l==="stack-above"?{type:"stack",targetCardId:i.id,position:"above"}:l==="stack-below"?{type:"stack",targetCardId:i.id,position:"below"}:l==="reorder-before"?{type:"reorder",index:s}:{type:"reorder",index:s+1}}return null}getNearestTargetableZone(t,r){let i=null,s=Number.POSITIVE_INFINITY;for(const o of r){const a=o.rect.left,l=o.rect.left+o.rect.width,u=t<a?a-t:t>l?t-l:0;u<s&&(s=u,i=o)}return i}isPointerInsideDragBounds(t,r,i){return t>=i.left&&t<=i.left+i.width&&r>=i.top&&r<=i.top+i.height}}const Nf=60,VD=80,Uf=.5,Ff=10;class jD{constructor(){b(this,"awaitingFreshWheelGesture",!1);b(this,"lastWheelEventAt",Number.NEGATIVE_INFINITY);b(this,"lastWheelDeltaX",0);b(this,"activeGestureType","none");b(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:t,shiftKey:r,deltaX:i,deltaY:s,overArtifactContent:o}=e;t-this.lastWheelGestureAt>=Nf&&(this.activeGestureType="none");const l=r&&s!==0,u=l?s:i,d=Math.abs(u),f=Math.abs(s);return this.activeGestureType==="vertical-artifact"&&o?d>=Uf&&d>=f*Ff?this.classifyHorizontal(t,u):(this.lastWheelGestureAt=t,{type:"scroll-native"}):this.activeGestureType==="horizontal-filmstrip"?!l&&o&&f>0&&f>=d*Ff?(this.activeGestureType="vertical-artifact",this.lastWheelGestureAt=t,{type:"scroll-native"}):this.classifyHorizontal(t,u):d<Uf?(o&&(this.activeGestureType="vertical-artifact"),this.lastWheelGestureAt=t,{type:"scroll-native"}):l||d>f?this.classifyHorizontal(t,u):f>d?(o&&(this.activeGestureType="vertical-artifact"),this.lastWheelGestureAt=t,{type:"scroll-native"}):o?(this.activeGestureType="vertical-artifact",this.lastWheelGestureAt=t,{type:"scroll-native"}):this.classifyHorizontal(t,u)}classifyHorizontal(e,t){const r=e-this.lastWheelEventAt,i=Math.sign(this.lastWheelDeltaX),s=Math.sign(t),o=i!==0&&s!==0&&i!==s,a=i!==0&&Math.abs(t)>=Math.abs(this.lastWheelDeltaX)+VD;return this.awaitingFreshWheelGesture&&r<Nf&&!o&&!a?{type:"ignore"}:(this.lastWheelEventAt=e,this.lastWheelDeltaX=t,this.lastWheelGestureAt=e,this.awaitingFreshWheelGesture=!1,this.activeGestureType="horizontal-filmstrip",{type:"scroll-horizontal",horizontalDelta:t})}}const GD=2,Zf=1e3,_o=1e-4;function Hf(n,e,t){if(n===0)return 0;const r=e.toPixels(Te({y:Je})).y??0;return(t-r)/GD}function Hl(n){const e=n.clientWidth>0?n.clientWidth:tr,t=n.clientHeight>0?n.clientHeight:Yo;let r=0,i=0;if(n.isConnected){const o=getComputedStyle(n);r=parseFloat(o.paddingTop)||0,i=parseFloat(o.paddingBottom)||0}const s=Math.max(1,t-r-i);return{width:e,height:s,offsetY:r}}class BD extends Event{constructor(t){super("scroll",{bubbles:!0,composed:!0});b(this,"scrollPosition");this.scrollPosition=t}}class By extends Event{constructor(t){super("layout-change",{bubbles:!0,composed:!0});b(this,"layout");this.layout=t}}class WD extends HTMLElement{constructor(){super();b(this,"_layout",[]);b(this,"_scrollPosition",0);b(this,"layoutGrid",null);b(this,"layoutScroll",new bD(Te({x:0})));b(this,"scrollModelKey","");b(this,"resizeObserver",null);b(this,"renderPending",!1);b(this,"animateNextRender",!0);b(this,"wheelGesture",new jD);b(this,"dragController",new HD);b(this,"dragState",null);b(this,"activeDragPointerId",null);b(this,"dragListenersAttached",!1);b(this,"dragFrame",0);b(this,"lastDragFrameTime",0);b(this,"lastPointerX",0);b(this,"lastPointerY",0);b(this,"pointerVelocityPxPerSec",0);b(this,"scrollVelocityPxPerSec",0);b(this,"motionSampleTime",0);b(this,"motionSampleX",0);b(this,"motionSampleY",0);b(this,"dragTrackOffsetXPx",0);b(this,"previousProjectedLayoutForOffset",null);b(this,"renderContent",()=>F``);b(this,"onDragControllerChange",()=>{this.dragController.status==="idle"&&(this.dragState=null,this.dragTrackOffsetXPx=0,this.previousProjectedLayoutForOffset=null),this.scheduleRender()});b(this,"onDragControllerDrag",t=>{const r=Lf(t.projectedLayout),i=this.shouldApplyTrackOffset(t.projectedLayout,t.source.parentId),s=t.source.parentId?this.getStackChildAnchorCardId(t.source.parentId,t.nodeId):null;this.dragTrackOffsetXPx=i?this.computeDragTrackOffset(this.previousProjectedLayoutForOffset,r,t.nodeId,t.source.parentId,s,this.dragTrackOffsetXPx):0,this.previousProjectedLayoutForOffset=r,this.dragState={nodeId:t.nodeId,source:t.source,grabOffset:t.grabOffset,pointer:t.pointer,size:t.size,projectedLayout:t.projectedLayout},this.scheduleRender()});b(this,"onDragControllerDrop",t=>{this.dragState=null,this.dragTrackOffsetXPx=0,this.previousProjectedLayoutForOffset=null,this.commitLayout(t.layout)});b(this,"onLayoutScrollInternal",t=>{const i=t.scroll.x??0;Math.abs(i-this._scrollPosition)<_o||(this._scrollPosition=i,this.emitScrollPositionChanged(i),this.scheduleRender())});b(this,"handleKeyDown",t=>{if(t.key==="Escape"&&this.dragController.status!=="idle"){t.preventDefault(),this.stopDragFrameLoop(),this.releaseActiveDragPointerCapture(),this.dragController.cancel(),this.detachDragListeners();return}this.dragController.status==="idle"&&(t.key==="ArrowRight"?(t.preventDefault(),this.wheelGesture.markKeyboardNavigation(Date.now()),this.shiftWindow(1)):t.key==="ArrowLeft"&&(t.preventDefault(),this.wheelGesture.markKeyboardNavigation(Date.now()),this.shiftWindow(-1)))});b(this,"handleWheel",t=>{if(this._layout.length===0)return;const r=this.wheelGesture.decide({now:Date.now(),shiftKey:t.shiftKey,deltaX:t.deltaX,deltaY:t.deltaY,overArtifactContent:!1});r.type==="scroll-horizontal"&&(t.preventDefault(),this.applyHorizontalWheel(r.horizontalDelta))});b(this,"handleWindowMessage",t=>{var o;if(this._layout.length===0)return;const r=this.findManagedArtifactFrame(t.source);if(!r||!this.isTrustedArtifactFrameMessage(t,r)||!TC(t.data))return;const i=this.wheelGesture.decide({now:Date.now(),shiftKey:t.data.shiftKey,deltaX:t.data.deltaX,deltaY:t.data.deltaY,overArtifactContent:!0});if(i.type==="scroll-horizontal"){this.applyHorizontalWheel(i.horizontalDelta);return}if(i.type!=="scroll-native")return;const s={type:"scroll",deltaX:0,deltaY:t.data.deltaY};(o=r.contentWindow)==null||o.postMessage(s,this.getArtifactFrameTargetOrigin(r))});b(this,"handlePointerDown",t=>{if(t.button!==0||this.dragController.status!=="idle")return;const r=t.target;if(!(r instanceof Element)||!r.closest("[drag-handle]")||r.closest("button, input, textarea, select, a, [role='button']"))return;const i=r.closest(".card-slot");if(!i)return;const s=i.getAttribute("data-layout-node-id");if(!s)return;const o=YD(this._layout,s);if(!o)return;const a=i.getBoundingClientRect();this.lastPointerX=t.clientX,this.lastPointerY=t.clientY,this.resetMotionTracking(t.clientX,t.clientY),this.focus(),this.dragController.start({nodeId:s,source:{index:o.topLevelIndex,parentId:o.sourceStackId},pointer:ke({x:t.clientX,y:t.clientY}),grabOffset:ke({x:t.clientX-a.left,y:t.clientY-a.top}),size:ke({x:a.width,y:a.height}),layout:this._layout}),this.attachDragListeners(),this.activeDragPointerId=t.pointerId;try{this.setPointerCapture(t.pointerId)}catch{}t.preventDefault()});b(this,"handleWindowPointerMove",t=>{this.lastPointerX=t.clientX,this.lastPointerY=t.clientY,this.updatePointerVelocity(t.clientX,t.clientY),this.syncDragTargetForLatestPointer(),this.ensureDragFrameLoop()});b(this,"handleWindowPointerUp",t=>{this.stopDragFrameLoop(),this.releasePointerCaptureForEvent(t.pointerId),this.dragController.drop(),this.clearMotionTracking(),this.detachDragListeners()});b(this,"handleWindowPointerCancel",t=>{this.stopDragFrameLoop(),this.releasePointerCaptureForEvent(t.pointerId),this.dragController.cancel(),this.clearMotionTracking(),this.detachDragListeners()});b(this,"handleWindowBlur",()=>{this.releaseActiveDragPointerCapture(),this.stopDragFrameLoop(),this.dragController.cancel(),this.clearMotionTracking(),this.detachDragListeners()});b(this,"runDragFrame",t=>{if(this.dragController.status==="idle"){this.dragFrame=0;return}const r=Math.max(0,t-this.lastDragFrameTime)/Zf;this.lastDragFrameTime=t,this.samplePointerVelocityAt(t,this.lastPointerX,this.lastPointerY);const i=this.getBoundingClientRect(),s=this.clampPointerToViewport(this.lastPointerX,this.lastPointerY,i),o=this.getDragEdgeScrollDeltaPixels(s.x,i,r);this.scrollVelocityPxPerSec=r>_o?Math.abs(o)/r:0,Math.abs(o)>_o&&(this.animateNextRender=!1,this.layoutScroll.wheelPixels(ke({x:o}))),this.dragController.status==="active"&&this.syncDragTarget(s.x,s.y,i),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(t){this._layout=[...t],this.stopDragFrameLoop(),this.dragController.cancel(),this.scrollModelKey="",this.syncScrollModel(),this.layoutScroll.scroll=Te({x:this._scrollPosition}),this.scheduleRender()}get layout(){return this._layout}commitLayout(t){this.layout=t,this.emitLayoutChanged()}set scrollPosition(t){Math.abs(t-this._scrollPosition)<_o||(this.animateNextRender=!1,this.syncScrollModel(),this.layoutScroll.scroll=Te({x:t}))}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 t;this.removeEventListener("keydown",this.handleKeyDown),this.removeEventListener("wheel",this.handleWheel),this.removeEventListener("pointerdown",this.handlePointerDown),window.removeEventListener("message",this.handleWindowMessage),(t=this.resizeObserver)==null||t.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(t,r){return new lD({basis:ke({x:Pn,y:Pn}),min:ke({x:Kd,y:Kd}),viewport:ke({x:t,y:r}),gap:ke({x:pe,y:pe})})}syncScrollModel(){const t=Hl(this),i=Wi(this._layout).nodes.map(o=>o.width),s=`${t.width}x${t.height}:${i.join(",")}`;s===this.scrollModelKey&&this.layoutGrid||(this.scrollModelKey=s,this.layoutGrid=this.createGrid(t.width,t.height),this.layoutScroll.rebuild({grid:this.layoutGrid,nodeWidths:i.map(o=>Te({x:o}))}))}emitScrollPositionChanged(t){this.dispatchEvent(new BD(t))}emitLayoutChanged(){this.dispatchEvent(new By([...this._layout]))}shiftWindow(t){this.syncScrollModel(),this.animateNextRender=!0,this.layoutScroll.step(t)}applyHorizontalWheel(t){this.syncScrollModel();const r=this.layoutGrid;if(!r)return;this.animateNextRender=!1;const i=r.toUnits(ke({x:t}));this.layoutScroll.wheel(Te({x:i.x??0}))}findManagedArtifactFrame(t){if(!t)return null;const r=this.querySelectorAll("iframe.artifact-frame");for(const i of r)if(i.contentWindow===t)return i;return null}isTrustedArtifactFrameMessage(t,r){if(t.origin==="null")return!0;const i=this.getArtifactFrameOrigin(r);return i===null||t.origin===i}getArtifactFrameTargetOrigin(t){const r=t.getAttribute("sandbox")??"";return new Set(r.split(/\s+/).filter(Boolean)).has("allow-same-origin")?this.getArtifactFrameOrigin(t)??"*":"*"}getArtifactFrameOrigin(t){const r=t.getAttribute("src")??t.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(t){try{this.hasPointerCapture(t)&&this.releasePointerCapture(t)}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 t=new Map;return t.set(this.dragState.nodeId,{id:this.dragState.nodeId,sourceCardId:this.dragState.nodeId}),{layout:Lf(this.dragState.projectedLayout),activePlaceholderId:this.dragState.nodeId,placeholdersById:t}}render(){const t=Hl(this),r=this.createGrid(t.width,t.height);this.layoutGrid=r;const i=this.getDisplayModel(),s=i.layout,o=this.dragController.status==="active",a=Wi(s),l=a.nodes.map(M=>M.width),u=`${t.width}x${t.height}:${l.join(",")}`;!o&&u!==this.scrollModelKey&&(this.scrollModelKey=u,this.layoutScroll.rebuild({grid:r,nodeWidths:l.map(M=>Te({x:M}))}),this._scrollPosition=this.layoutScroll.scroll.x??this._scrollPosition);const d=qD(s),f=r.unit.x??Pn,v=r.unit.y??Pn,y=o?this.dragTrackOffsetXPx:0,A=(this.layoutScroll.translate.x??0)+y,k=Hf(a.nodes.length,r,t.height),I=this.animateNextRender&&!o,G=[`transform: translate(${A}px, ${k}px);`,`transition-duration: ${I?y0:0}ms;`,`pointer-events: ${o?"none":"auto"};`].join(" ");this.animateNextRender=!0,this.style.setProperty("--layout-unit-x",`${f}px`),this.style.setProperty("--layout-unit-y",`${v}px`),this.style.setProperty("--layout-gap",`${pe}px`);const P=this.dragState,le={width:(P==null?void 0:P.size.x)??0,height:(P==null?void 0:P.size.y)??0};Pe(F`
157
+ <div class="track" style=${G}>
158
158
  ${a.nodes.map((M,Z)=>F`
159
159
  <div
160
160
  class="node"
@@ -196,7 +196,7 @@ ${r.documentElement.outerHTML}`],{type:"text/html"});return URL.createObjectURL(
196
196
  ${this.renderDraggedPreview(P.nodeId)}
197
197
  </div>
198
198
  `})():null}
199
- `,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 t=this.getBoundingClientRect();if(this.dragController.status==="active"){const i=this.clampPointerToViewport(this.lastPointerX,this.lastPointerY,t);this.syncDragTarget(i.x,i.y,t);return}if(this.syncDragTarget(this.lastPointerX,this.lastPointerY,t),this.dragController.status==="pending")return;const r=this.clampPointerToViewport(this.lastPointerX,this.lastPointerY,t);(r.x!==this.lastPointerX||r.y!==this.lastPointerY)&&this.syncDragTarget(r.x,r.y,t)}syncDragTarget(t,r,i=this.getBoundingClientRect()){if(this.dragController.status==="idle")return;const s=this.getDisplayModel(),o=new Set(s.placeholdersById.keys()),a=this.dragController.status==="active"?this.dragTrackOffsetXPx:0,l=this.measureLayoutGeometry(s.layout,o,a);this.dragController.update({pointer:ke({x:t,y:r}),viewport:{left:i.left,top:i.top,width:i.width,height:i.height},geometry:l,effectiveVelocity:Math.max(this.pointerVelocityPxPerSec,this.scrollVelocityPxPerSec)})}resetMotionTracking(t,r){this.pointerVelocityPxPerSec=0,this.scrollVelocityPxPerSec=0,this.motionSampleTime=performance.now(),this.motionSampleX=t,this.motionSampleY=r}clearMotionTracking(){this.pointerVelocityPxPerSec=0,this.scrollVelocityPxPerSec=0,this.motionSampleTime=0}updatePointerVelocity(t,r){this.samplePointerVelocityAt(performance.now(),t,r)}samplePointerVelocityAt(t,r,i){if(this.motionSampleTime===0){this.motionSampleTime=t,this.motionSampleX=r,this.motionSampleY=i,this.pointerVelocityPxPerSec=0;return}const s=t-this.motionSampleTime;if(s<100)return;const o=r-this.motionSampleX;this.pointerVelocityPxPerSec=Math.abs(o)/s*Zf,this.motionSampleTime=t,this.motionSampleX=r,this.motionSampleY=i}clampPointerToViewport(t,r,i){return{x:Math.max(i.left,Math.min(i.left+i.width,t)),y:Math.max(i.top,Math.min(i.top+i.height,r))}}isPointerOutsideViewport(t,r,i){return t<i.left||t>i.left+i.width||r<i.top||r>i.top+i.height}getDragEdgeScrollDeltaPixels(t,r,i){var u;const s=r.left+go,o=r.left+r.width-go,a=((u=this.layoutGrid)==null?void 0:u.unit.x)??Pn,l=k0*a;if(t<s){const d=Math.max(0,Math.min(1,(s-t)/go));return-(l*d**Jd)*i}if(t>o){const d=Math.max(0,Math.min(1,(t-o)/go));return l*d**Jd*i}return 0}measureLayoutGeometry(t,r,i=0){const s=this.layoutGrid;if(!s)return[];const o=Wi(t),a=new Map(o.nodes.map(k=>[k.id,k.width])),l=s.toPixels(Te({y:Je})).y??Yo,u=Fl(this),d=(this.layoutScroll.translate.x??0)+i,f=Hf(o.nodes.length,s,u.height),v=u.offsetY+f,y=[];let A=d;for(const k of t){const I=a.get(k.id)??At,B=s.toPixels(Te({x:I})).x??tr,P={left:A,top:v,width:B,height:l};y.push({id:k.id,rect:P}),A+=B+pe}return y}getPlaceholderPixelSize(t,r,i,s){if(!r)return s;for(const o of t.nodes)for(const a of o.cards)if(a.id===r)return{width:i.toPixels(Te({x:a.width})).x??s.width,height:i.toPixels(Te({y:a.height})).y??s.height};return s}renderDraggedPreview(t){const r=Fu(this._layout,t);return r?this.renderContent(r,{isDragging:!0}):F``}shouldApplyTrackOffset(t,r){if(r)return!0;for(const i of t){if(i.type!=="stack")continue;if(i.children.some(o=>o.type==="drop-target")&&r!==i.id)return!0}return!1}computeDragTrackOffset(t,r,i,s,o,a){if(!t)return a;const l=s?o??this.getStableAnchorCardId(t,r,i):this.getStableAnchorNodeId(t,r,i);if(!l)return a;const u=s?jf(t,l,this.layoutGrid):Bf(t,l,this.layoutGrid),d=s?jf(r,l,this.layoutGrid):Bf(r,l,this.layoutGrid);return u===null||d===null?a:a+(u-d)}getStableAnchorCardId(t,r,i){const s=Vf(t),o=new Set(Vf(r));for(const a of s)if(a!==i&&o.has(a))return a;return null}getStableAnchorNodeId(t,r,i){const s=new Set(r.map(o=>o.id));for(const o of t)if(o.id!==i&&s.has(o.id))return o.id;return null}getStackChildAnchorCardId(t,r){const i=this._layout.find(o=>o.type==="stack"&&o.id===t);if(!i||i.type!=="stack")return null;const s=i.children.find(o=>o.type==="card"&&o.id!==r);return(s==null?void 0:s.id)??null}}function XD(n){const e=new Map;for(const t of n){if(t.type==="card"){e.set(t.id,t);continue}for(const r of t.children)if(r.type==="card")e.set(r.id,r);else for(const i of r.children)e.set(i.id,i)}return e}function QD(n,e){const t=n.findIndex(r=>r.type==="card"&&r.id===e);if(t!==-1)return{topLevelIndex:t};for(let r=0;r<n.length;r+=1){const i=n[r];if(!(!i||i.type!=="stack")&&i.children.some(s=>s.type==="card"&&s.id===e))return{topLevelIndex:r,sourceStackId:i.id}}return null}function Vf(n){const e=[];for(const t of n){if(t.type==="card"){e.push(t.id);continue}if(t.type==="stack"){const r=t.children.find(i=>i.type==="card");r&&e.push(r.id)}}return e}function jf(n,e,t){if(!t)return null;const r=Wi(n),i=new Map(r.nodes.map(o=>[o.id,o.width]));let s=0;for(const o of n){if(o.type==="card"&&o.id===e||o.type==="stack"&&o.children.some(u=>u.type==="card"&&u.id===e))return s;const a=i.get(o.id)??At,l=t.toPixels(Te({x:a})).x??tr;s+=l+pe}return null}function Bf(n,e,t){if(!t)return null;const r=Wi(n),i=new Map(r.nodes.map(o=>[o.id,o.width]));let s=0;for(const o of n){if(o.id===e)return s;const a=i.get(o.id)??At,l=t.toPixels(Te({x:a})).x??tr;s+=l+pe}return null}customElements.get("layout-view")||customElements.define("layout-view",JD);class eO extends HTMLElement{constructor(){super(...arguments);b(this,"screenManager",rt.resolve("ScreenManager"));b(this,"boundModel",null);b(this,"handleActiveScreenChanged",()=>{this.rebindModel(),this.render()});b(this,"handleModelChange",()=>{this.render()});b(this,"handleCloseArtifact",t=>{t instanceof Hy&&this.screenManager.activeScreen&&this.screenManager.activeScreen.removeArtifact(t.artifactID)});b(this,"handleScrollPositionChanged",t=>{const r=t;typeof r.scrollPosition=="number"&&Number.isFinite(r.scrollPosition)&&this.screenManager.activeScreen&&this.screenManager.activeScreen.setScrollPosition(r.scrollPosition)});b(this,"handleLayoutChanged",t=>{t instanceof qy&&this.screenManager.activeScreen&&this.screenManager.activeScreen.setLayout(t.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 t=this.screenManager.activeScreen;this.boundModel!==t&&(this.unbindModel(),this.boundModel=t,t&&t.addEventListener("change",this.handleModelChange))}unbindModel(){this.boundModel&&(this.boundModel.removeEventListener("change",this.handleModelChange),this.boundModel=null)}buildArtifactMap(){const t=this.screenManager.activeScreen;return t?new Map(t.artifacts):new Map}render(){const t=this.screenManager.activeScreen,r=(t==null?void 0:t.layout)??[],i=this.buildArtifactMap();if(r.length===0){Pe(F`<p data-testid="empty-screen" class="empty">
199
+ `,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 t=this.getBoundingClientRect();if(this.dragController.status==="active"){const i=this.clampPointerToViewport(this.lastPointerX,this.lastPointerY,t);this.syncDragTarget(i.x,i.y,t);return}if(this.syncDragTarget(this.lastPointerX,this.lastPointerY,t),this.dragController.status==="pending")return;const r=this.clampPointerToViewport(this.lastPointerX,this.lastPointerY,t);(r.x!==this.lastPointerX||r.y!==this.lastPointerY)&&this.syncDragTarget(r.x,r.y,t)}syncDragTarget(t,r,i=this.getBoundingClientRect()){if(this.dragController.status==="idle")return;const s=this.getDisplayModel(),o=new Set(s.placeholdersById.keys()),a=this.dragController.status==="active"?this.dragTrackOffsetXPx:0,l=this.measureLayoutGeometry(s.layout,o,a);this.dragController.update({pointer:ke({x:t,y:r}),viewport:{left:i.left,top:i.top,width:i.width,height:i.height},geometry:l,effectiveVelocity:Math.max(this.pointerVelocityPxPerSec,this.scrollVelocityPxPerSec)})}resetMotionTracking(t,r){this.pointerVelocityPxPerSec=0,this.scrollVelocityPxPerSec=0,this.motionSampleTime=performance.now(),this.motionSampleX=t,this.motionSampleY=r}clearMotionTracking(){this.pointerVelocityPxPerSec=0,this.scrollVelocityPxPerSec=0,this.motionSampleTime=0}updatePointerVelocity(t,r){this.samplePointerVelocityAt(performance.now(),t,r)}samplePointerVelocityAt(t,r,i){if(this.motionSampleTime===0){this.motionSampleTime=t,this.motionSampleX=r,this.motionSampleY=i,this.pointerVelocityPxPerSec=0;return}const s=t-this.motionSampleTime;if(s<100)return;const o=r-this.motionSampleX;this.pointerVelocityPxPerSec=Math.abs(o)/s*Zf,this.motionSampleTime=t,this.motionSampleX=r,this.motionSampleY=i}clampPointerToViewport(t,r,i){return{x:Math.max(i.left,Math.min(i.left+i.width,t)),y:Math.max(i.top,Math.min(i.top+i.height,r))}}isPointerOutsideViewport(t,r,i){return t<i.left||t>i.left+i.width||r<i.top||r>i.top+i.height}getDragEdgeScrollDeltaPixels(t,r,i){var u;const s=r.left+go,o=r.left+r.width-go,a=((u=this.layoutGrid)==null?void 0:u.unit.x)??Pn,l=b0*a;if(t<s){const d=Math.max(0,Math.min(1,(s-t)/go));return-(l*d**Jd)*i}if(t>o){const d=Math.max(0,Math.min(1,(t-o)/go));return l*d**Jd*i}return 0}measureLayoutGeometry(t,r,i=0){const s=this.layoutGrid;if(!s)return[];const o=Wi(t),a=new Map(o.nodes.map(k=>[k.id,k.width])),l=s.toPixels(Te({y:Je})).y??Yo,u=Hl(this),d=(this.layoutScroll.translate.x??0)+i,f=Hf(o.nodes.length,s,u.height),v=u.offsetY+f,y=[];let A=d;for(const k of t){const I=a.get(k.id)??At,G=s.toPixels(Te({x:I})).x??tr,P={left:A,top:v,width:G,height:l};y.push({id:k.id,rect:P}),A+=G+pe}return y}getPlaceholderPixelSize(t,r,i,s){if(!r)return s;for(const o of t.nodes)for(const a of o.cards)if(a.id===r)return{width:i.toPixels(Te({x:a.width})).x??s.width,height:i.toPixels(Te({y:a.height})).y??s.height};return s}renderDraggedPreview(t){const r=Hu(this._layout,t);return r?this.renderContent(r,{isDragging:!0}):F``}shouldApplyTrackOffset(t,r){if(r)return!0;for(const i of t){if(i.type!=="stack")continue;if(i.children.some(o=>o.type==="drop-target")&&r!==i.id)return!0}return!1}computeDragTrackOffset(t,r,i,s,o,a){if(!t)return a;const l=s?o??this.getStableAnchorCardId(t,r,i):this.getStableAnchorNodeId(t,r,i);if(!l)return a;const u=s?jf(t,l,this.layoutGrid):Gf(t,l,this.layoutGrid),d=s?jf(r,l,this.layoutGrid):Gf(r,l,this.layoutGrid);return u===null||d===null?a:a+(u-d)}getStableAnchorCardId(t,r,i){const s=Vf(t),o=new Set(Vf(r));for(const a of s)if(a!==i&&o.has(a))return a;return null}getStableAnchorNodeId(t,r,i){const s=new Set(r.map(o=>o.id));for(const o of t)if(o.id!==i&&s.has(o.id))return o.id;return null}getStackChildAnchorCardId(t,r){const i=this._layout.find(o=>o.type==="stack"&&o.id===t);if(!i||i.type!=="stack")return null;const s=i.children.find(o=>o.type==="card"&&o.id!==r);return(s==null?void 0:s.id)??null}}function qD(n){const e=new Map;for(const t of n){if(t.type==="card"){e.set(t.id,t);continue}for(const r of t.children)if(r.type==="card")e.set(r.id,r);else for(const i of r.children)e.set(i.id,i)}return e}function YD(n,e){const t=n.findIndex(r=>r.type==="card"&&r.id===e);if(t!==-1)return{topLevelIndex:t};for(let r=0;r<n.length;r+=1){const i=n[r];if(!(!i||i.type!=="stack")&&i.children.some(s=>s.type==="card"&&s.id===e))return{topLevelIndex:r,sourceStackId:i.id}}return null}function Vf(n){const e=[];for(const t of n){if(t.type==="card"){e.push(t.id);continue}if(t.type==="stack"){const r=t.children.find(i=>i.type==="card");r&&e.push(r.id)}}return e}function jf(n,e,t){if(!t)return null;const r=Wi(n),i=new Map(r.nodes.map(o=>[o.id,o.width]));let s=0;for(const o of n){if(o.type==="card"&&o.id===e||o.type==="stack"&&o.children.some(u=>u.type==="card"&&u.id===e))return s;const a=i.get(o.id)??At,l=t.toPixels(Te({x:a})).x??tr;s+=l+pe}return null}function Gf(n,e,t){if(!t)return null;const r=Wi(n),i=new Map(r.nodes.map(o=>[o.id,o.width]));let s=0;for(const o of n){if(o.id===e)return s;const a=i.get(o.id)??At,l=t.toPixels(Te({x:a})).x??tr;s+=l+pe}return null}customElements.get("layout-view")||customElements.define("layout-view",WD);class KD extends HTMLElement{constructor(){super(...arguments);b(this,"screenManager",rt.resolve("ScreenManager"));b(this,"boundModel",null);b(this,"handleActiveScreenChanged",()=>{this.rebindModel(),this.render()});b(this,"handleModelChange",()=>{this.render()});b(this,"handleCloseArtifact",t=>{t instanceof Fy&&this.screenManager.activeScreen&&this.screenManager.activeScreen.removeArtifact(t.artifactID)});b(this,"handleScrollPositionChanged",t=>{const r=t;typeof r.scrollPosition=="number"&&Number.isFinite(r.scrollPosition)&&this.screenManager.activeScreen&&this.screenManager.activeScreen.setScrollPosition(r.scrollPosition)});b(this,"handleLayoutChanged",t=>{t instanceof By&&this.screenManager.activeScreen&&this.screenManager.activeScreen.setLayout(t.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 t=this.screenManager.activeScreen;this.boundModel!==t&&(this.unbindModel(),this.boundModel=t,t&&t.addEventListener("change",this.handleModelChange))}unbindModel(){this.boundModel&&(this.boundModel.removeEventListener("change",this.handleModelChange),this.boundModel=null)}buildArtifactMap(){const t=this.screenManager.activeScreen;return t?new Map(t.artifacts):new Map}render(){const t=this.screenManager.activeScreen,r=(t==null?void 0:t.layout)??[],i=this.buildArtifactMap();if(r.length===0){Pe(F`<p data-testid="empty-screen" class="empty">
200
200
  No artifacts yet. Create one by asking for something.
201
201
  </p>`,this);return}Pe(F`
202
202
  <layout-view
@@ -213,7 +213,7 @@ ${r.documentElement.outerHTML}`],{type:"text/html"});return URL.createObjectURL(
213
213
  @layout-change=${this.handleLayoutChanged}
214
214
  @close-artifact=${this.handleCloseArtifact}
215
215
  ></layout-view>
216
- `,this)}}customElements.define("screen-view",eO);var fa,jr,Ts,Wt,Yy,Ky,Lc;class tO extends HTMLElement{constructor(){super(...arguments);S(this,Wt);S(this,fa,rt.resolve("ScreenManager"));S(this,jr,rt.resolve("ServerManager"));S(this,Ts,()=>{m(this,Wt,Lc).call(this)})}connectedCallback(){c(this,jr).addEventListener("change",c(this,Ts)),m(this,Wt,Lc).call(this)}disconnectedCallback(){c(this,jr).removeEventListener("change",c(this,Ts))}}fa=new WeakMap,jr=new WeakMap,Ts=new WeakMap,Wt=new WeakSet,Yy=function(t,r){c(this,fa).setActive(t,r)},Ky=function(){for(const t of c(this,jr).servers.values())return t;return null},Lc=function(){const t=m(this,Wt,Ky).call(this),i=(t?[...t.screens.values()]:[]).slice().sort((o,a)=>o.name.localeCompare(a.name,void 0,{sensitivity:"base"})),s=i.length===0?F`<p class="empty">No screens yet. Hit + to create one.</p>`:F`
216
+ `,this)}}customElements.define("screen-view",KD);var fa,jr,Ts,Wt,Wy,qy,Nc;class JD extends HTMLElement{constructor(){super(...arguments);S(this,Wt);S(this,fa,rt.resolve("ScreenManager"));S(this,jr,rt.resolve("ServerManager"));S(this,Ts,()=>{m(this,Wt,Nc).call(this)})}connectedCallback(){c(this,jr).addEventListener("change",c(this,Ts)),m(this,Wt,Nc).call(this)}disconnectedCallback(){c(this,jr).removeEventListener("change",c(this,Ts))}}fa=new WeakMap,jr=new WeakMap,Ts=new WeakMap,Wt=new WeakSet,Wy=function(t,r){c(this,fa).setActive(t,r)},qy=function(){for(const t of c(this,jr).servers.values())return t;return null},Nc=function(){const t=m(this,Wt,qy).call(this),i=(t?[...t.screens.values()]:[]).slice().sort((o,a)=>o.name.localeCompare(a.name,void 0,{sensitivity:"base"})),s=i.length===0?F`<p class="empty">No screens yet. Hit + to create one.</p>`:F`
217
217
  <div class="content">
218
218
  <h2 class="heading">Screens</h2>
219
219
  <ul class="tiles">
@@ -222,7 +222,7 @@ ${r.documentElement.outerHTML}`],{type:"text/html"});return URL.createObjectURL(
222
222
  <button
223
223
  class="tile"
224
224
  type="button"
225
- @click=${()=>t&&m(this,Wt,Yy).call(this,t.url,o.id)}
225
+ @click=${()=>t&&m(this,Wt,Wy).call(this,t.url,o.id)}
226
226
  >
227
227
  ${o.name}
228
228
  </button>
@@ -230,19 +230,19 @@ ${r.documentElement.outerHTML}`],{type:"text/html"});return URL.createObjectURL(
230
230
  `)}
231
231
  </ul>
232
232
  </div>
233
- `;Pe(s,this)};customElements.get("home-screen")||customElements.define("home-screen",tO);const Zl=new WeakMap,Gf=Object.prototype.hasOwnProperty,nO=(()=>{const n=new Set;let e=HTMLElement.prototype;for(;e;){for(const t of Object.getOwnPropertyNames(e))n.add(t);if(e===Node.prototype)break;e=Object.getPrototypeOf(e)}return n})();function rO(n,e){if(n===Boolean)return e!==null;if(e!==null)return n===Number?Number(e):e}var Cs,Mc,Yn,et,Et,Br,Kn,Gr,Ie,Zi,Jy,Xy,Qy,Fo;const On=class On extends HTMLElement{constructor(){var i;super();S(this,Ie);S(this,Yn,new Map);S(this,et,new Map);S(this,Et,new Map);S(this,Br,!1);S(this,Kn,!1);S(this,Gr,!1);const t=m(i=On,Cs,Mc).call(i,this.constructor),r=this;for(const s of t.properties)Gf.call(r,s)&&(c(this,Et).set(s,r[s]),delete r[s])}static get observedAttributes(){var t;return m(t=On,Cs,Mc).call(t,this).observedAttributes}connected(){}disconnected(){}changed(t){}connectedCallback(){if(m(this,Ie,Qy).call(this),!c(this,Kn))for(const t of m(this,Ie,Zi).call(this).properties)c(this,et).has(t)||c(this,et).set(t,void 0);this.dispatchEvent(new Event("reactive:connect")),this.connected(),m(this,Ie,Fo).call(this)}disconnectedCallback(){this.dispatchEvent(new Event("reactive:disconnect")),this.disconnected()}attributeChangedCallback(t,r,i){if(r===i)return;const s=m(this,Ie,Zi).call(this).byAttr.get(t);s&&(c(this,Et).has(s.property)||(this[s.property]=rO(s.type,i)))}};Cs=new WeakSet,Mc=function(t){const r=Zl.get(t);if(r)return r;const i=[...t.properties??[]],s=t.attributes??{},o=new Map,a=new Map;for(const u of i)if(nO.has(u))throw new Error(`Reactive property "${u}" collides with a built-in DOM property. Rename it to avoid shadowing the platform API.`);for(const[u,d]of Object.entries(s)){if(u.includes("-")&&d.property===void 0)throw new Error(`Attribute "${u}" must declare a "property" name because kebab-case cannot be a property.`);const f=d.property??u;if(!i.includes(f))throw new Error(`Attribute '${u}' references property '${f}', which isn't declared in \`static properties\`. Add it to \`properties\` to make it reactive.`);const v={attribute:u,property:f,type:d.type};o.set(u,v),a.set(f,v)}for(const u of i){const d=Object.getOwnPropertyDescriptor(t.prototype,u);if((d==null?void 0:d.get)!==void 0||(d==null?void 0:d.set)!==void 0)throw new Error(`Observed property "${u}" cannot define a custom getter/setter. Use changed() for side effects instead.`);d===void 0&&Object.defineProperty(t.prototype,u,{configurable:!0,enumerable:!0,get(){return c(this,Yn).get(u)},set(f){m(this,Ie,Jy).call(this,u,f)}})}const l={properties:i,observedAttributes:Object.keys(s),byAttr:o,byProp:a};return Zl.set(t,l),l},Yn=new WeakMap,et=new WeakMap,Et=new WeakMap,Br=new WeakMap,Kn=new WeakMap,Gr=new WeakMap,Ie=new WeakSet,Zi=function(){return Zl.get(this.constructor)},Jy=function(t,r){if(!c(this,Gr)&&c(this,Et).has(t))return;const i=c(this,Yn).get(t);Object.is(i,r)||(c(this,et).has(t)||c(this,et).set(t,i),c(this,Yn).set(t,r),c(this,Et).delete(t),m(this,Ie,Xy).call(this,t,r),this.isConnected&&m(this,Ie,Fo).call(this))},Xy=function(t,r){const i=m(this,Ie,Zi).call(this).byProp.get(t);if(!i)return;const{attribute:s,type:o}=i;if(o===Boolean){const l=this.hasAttribute(s);r&&!l?this.setAttribute(s,""):!r&&l&&this.removeAttribute(s);return}if(r==null){this.hasAttribute(s)&&this.removeAttribute(s);return}const a=String(r);this.getAttribute(s)!==a&&this.setAttribute(s,a)},Qy=function(){const t=this,r=m(this,Ie,Zi).call(this);for(const i of r.properties){if(!Gf.call(t,i))continue;const s=t[i];delete t[i],!(c(this,Et).has(i)||c(this,Yn).has(i))&&(t[i]=s)}E(this,Gr,!0);try{for(const[i,s]of c(this,Et))t[i]=s;c(this,Et).clear()}finally{E(this,Gr,!1)}},Fo=function(){c(this,Br)||!this.isConnected||c(this,Kn)&&c(this,et).size===0||(E(this,Br,!0),queueMicrotask(()=>{if(E(this,Br,!1),!this.isConnected||c(this,Kn)&&c(this,et).size===0)return;const t=new Map(c(this,et));c(this,et).clear(),E(this,Kn,!0);try{this.changed(t)}catch(r){console.error(r)}this.isConnected&&c(this,et).size>0&&m(this,Ie,Fo).call(this)}))},S(On,Cs),b(On,"properties"),b(On,"attributes");let ts=On;/**
233
+ `;Pe(s,this)};customElements.get("home-screen")||customElements.define("home-screen",JD);const Vl=new WeakMap,Bf=Object.prototype.hasOwnProperty,XD=(()=>{const n=new Set;let e=HTMLElement.prototype;for(;e;){for(const t of Object.getOwnPropertyNames(e))n.add(t);if(e===Node.prototype)break;e=Object.getPrototypeOf(e)}return n})();function QD(n,e){if(n===Boolean)return e!==null;if(e!==null)return n===Number?Number(e):e}var Cs,Uc,Yn,et,Et,Gr,Kn,Br,Ie,Zi,Yy,Ky,Jy,Fo;const On=class On extends HTMLElement{constructor(){var i;super();S(this,Ie);S(this,Yn,new Map);S(this,et,new Map);S(this,Et,new Map);S(this,Gr,!1);S(this,Kn,!1);S(this,Br,!1);const t=m(i=On,Cs,Uc).call(i,this.constructor),r=this;for(const s of t.properties)Bf.call(r,s)&&(c(this,Et).set(s,r[s]),delete r[s])}static get observedAttributes(){var t;return m(t=On,Cs,Uc).call(t,this).observedAttributes}connected(){}disconnected(){}changed(t){}connectedCallback(){if(m(this,Ie,Jy).call(this),!c(this,Kn))for(const t of m(this,Ie,Zi).call(this).properties)c(this,et).has(t)||c(this,et).set(t,void 0);this.dispatchEvent(new Event("reactive:connect")),this.connected(),m(this,Ie,Fo).call(this)}disconnectedCallback(){this.dispatchEvent(new Event("reactive:disconnect")),this.disconnected()}attributeChangedCallback(t,r,i){if(r===i)return;const s=m(this,Ie,Zi).call(this).byAttr.get(t);s&&(c(this,Et).has(s.property)||(this[s.property]=QD(s.type,i)))}};Cs=new WeakSet,Uc=function(t){const r=Vl.get(t);if(r)return r;const i=[...t.properties??[]],s=t.attributes??{},o=new Map,a=new Map;for(const u of i)if(XD.has(u))throw new Error(`Reactive property "${u}" collides with a built-in DOM property. Rename it to avoid shadowing the platform API.`);for(const[u,d]of Object.entries(s)){if(u.includes("-")&&d.property===void 0)throw new Error(`Attribute "${u}" must declare a "property" name because kebab-case cannot be a property.`);const f=d.property??u;if(!i.includes(f))throw new Error(`Attribute '${u}' references property '${f}', which isn't declared in \`static properties\`. Add it to \`properties\` to make it reactive.`);const v={attribute:u,property:f,type:d.type};o.set(u,v),a.set(f,v)}for(const u of i){const d=Object.getOwnPropertyDescriptor(t.prototype,u);if((d==null?void 0:d.get)!==void 0||(d==null?void 0:d.set)!==void 0)throw new Error(`Observed property "${u}" cannot define a custom getter/setter. Use changed() for side effects instead.`);d===void 0&&Object.defineProperty(t.prototype,u,{configurable:!0,enumerable:!0,get(){return c(this,Yn).get(u)},set(f){m(this,Ie,Yy).call(this,u,f)}})}const l={properties:i,observedAttributes:Object.keys(s),byAttr:o,byProp:a};return Vl.set(t,l),l},Yn=new WeakMap,et=new WeakMap,Et=new WeakMap,Gr=new WeakMap,Kn=new WeakMap,Br=new WeakMap,Ie=new WeakSet,Zi=function(){return Vl.get(this.constructor)},Yy=function(t,r){if(!c(this,Br)&&c(this,Et).has(t))return;const i=c(this,Yn).get(t);Object.is(i,r)||(c(this,et).has(t)||c(this,et).set(t,i),c(this,Yn).set(t,r),c(this,Et).delete(t),m(this,Ie,Ky).call(this,t,r),this.isConnected&&m(this,Ie,Fo).call(this))},Ky=function(t,r){const i=m(this,Ie,Zi).call(this).byProp.get(t);if(!i)return;const{attribute:s,type:o}=i;if(o===Boolean){const l=this.hasAttribute(s);r&&!l?this.setAttribute(s,""):!r&&l&&this.removeAttribute(s);return}if(r==null){this.hasAttribute(s)&&this.removeAttribute(s);return}const a=String(r);this.getAttribute(s)!==a&&this.setAttribute(s,a)},Jy=function(){const t=this,r=m(this,Ie,Zi).call(this);for(const i of r.properties){if(!Bf.call(t,i))continue;const s=t[i];delete t[i],!(c(this,Et).has(i)||c(this,Yn).has(i))&&(t[i]=s)}E(this,Br,!0);try{for(const[i,s]of c(this,Et))t[i]=s;c(this,Et).clear()}finally{E(this,Br,!1)}},Fo=function(){c(this,Gr)||!this.isConnected||c(this,Kn)&&c(this,et).size===0||(E(this,Gr,!0),queueMicrotask(()=>{if(E(this,Gr,!1),!this.isConnected||c(this,Kn)&&c(this,et).size===0)return;const t=new Map(c(this,et));c(this,et).clear(),E(this,Kn,!0);try{this.changed(t)}catch(r){console.error(r)}this.isConnected&&c(this,et).size>0&&m(this,Ie,Fo).call(this)}))},S(On,Cs),b(On,"properties"),b(On,"attributes");let ts=On;/**
234
234
  * @license
235
235
  * Copyright 2020 Google LLC
236
236
  * SPDX-License-Identifier: BSD-3-Clause
237
- */const iO=n=>n.strings===void 0;/**
237
+ */const eO=n=>n.strings===void 0;/**
238
238
  * @license
239
239
  * Copyright 2017 Google LLC
240
240
  * SPDX-License-Identifier: BSD-3-Clause
241
- */const Yi=(n,e)=>{var r;const t=n._$AN;if(t===void 0)return!1;for(const i of t)(r=i._$AO)==null||r.call(i,e,!1),Yi(i,e);return!0},ra=n=>{let e,t;do{if((e=n._$AM)===void 0)break;t=e._$AN,t.delete(n),n=e}while((t==null?void 0:t.size)===0)},ev=n=>{for(let e;e=n._$AM;n=e){let t=e._$AN;if(t===void 0)e._$AN=t=new Set;else if(t.has(n))break;t.add(n),aO(e)}};function sO(n){this._$AN!==void 0?(ra(this),this._$AM=n,ev(this)):this._$AM=n}function oO(n,e=!1,t=0){const r=this._$AH,i=this._$AN;if(i!==void 0&&i.size!==0)if(e)if(Array.isArray(r))for(let s=t;s<r.length;s++)Yi(r[s],!1),ra(r[s]);else r!=null&&(Yi(r,!1),ra(r));else Yi(this,n)}const aO=n=>{n.type==yy.CHILD&&(n._$AP??(n._$AP=oO),n._$AQ??(n._$AQ=sO))};class lO extends vy{constructor(){super(...arguments),this._$AN=void 0}_$AT(e,t,r){super._$AT(e,t,r),ev(this),this.isConnected=e._$AU}_$AO(e,t=!0){var r,i;e!==this.isConnected&&(this.isConnected=e,e?(r=this.reconnected)==null||r.call(this):(i=this.disconnected)==null||i.call(this)),t&&(Yi(this,e),ra(this))}setValue(e){if(iO(this._$Ct))this._$Ct._$AI(e,this);else{const t=[...this._$Ct._$AH];t[this._$Ci]=e,this._$Ct._$AI(t,this,0)}}disconnected(){}reconnected(){}}/**
241
+ */const Yi=(n,e)=>{var r;const t=n._$AN;if(t===void 0)return!1;for(const i of t)(r=i._$AO)==null||r.call(i,e,!1),Yi(i,e);return!0},ra=n=>{let e,t;do{if((e=n._$AM)===void 0)break;t=e._$AN,t.delete(n),n=e}while((t==null?void 0:t.size)===0)},Xy=n=>{for(let e;e=n._$AM;n=e){let t=e._$AN;if(t===void 0)e._$AN=t=new Set;else if(t.has(n))break;t.add(n),rO(e)}};function tO(n){this._$AN!==void 0?(ra(this),this._$AM=n,Xy(this)):this._$AM=n}function nO(n,e=!1,t=0){const r=this._$AH,i=this._$AN;if(i!==void 0&&i.size!==0)if(e)if(Array.isArray(r))for(let s=t;s<r.length;s++)Yi(r[s],!1),ra(r[s]);else r!=null&&(Yi(r,!1),ra(r));else Yi(this,n)}const rO=n=>{n.type==gy.CHILD&&(n._$AP??(n._$AP=nO),n._$AQ??(n._$AQ=tO))};class iO extends my{constructor(){super(...arguments),this._$AN=void 0}_$AT(e,t,r){super._$AT(e,t,r),Xy(this),this.isConnected=e._$AU}_$AO(e,t=!0){var r,i;e!==this.isConnected&&(this.isConnected=e,e?(r=this.reconnected)==null||r.call(this):(i=this.disconnected)==null||i.call(this)),t&&(Yi(this,e),ra(this))}setValue(e){if(eO(this._$Ct))this._$Ct._$AI(e,this);else{const t=[...this._$Ct._$AH];t[this._$Ci]=e,this._$Ct._$AI(t,this,0)}}disconnected(){}reconnected(){}}/**
242
242
  * @license
243
243
  * Copyright 2020 Google LLC
244
244
  * SPDX-License-Identifier: BSD-3-Clause
245
- */const So=()=>new cO;class cO{}const Hl=new WeakMap,ko=Nu(class extends lO{render(n){return oe}update(n,[e]){var r;const t=e!==this.G;return t&&this.G!==void 0&&this.rt(void 0),(t||this.lt!==this.ct)&&(this.G=e,this.ht=(r=n.options)==null?void 0:r.host,this.rt(this.ct=n.element)),oe}rt(n){if(this.isConnected||(n=void 0),typeof this.G=="function"){const e=this.ht??globalThis;let t=Hl.get(e);t===void 0&&(t=new WeakMap,Hl.set(e,t)),t.get(this.G)!==void 0&&this.G.call(this.ht,void 0),t.set(this.G,n),n!==void 0&&this.G.call(this.ht,n)}else this.G.value=n}get lt(){var n,e;return typeof this.G=="function"?(n=Hl.get(this.ht??globalThis))==null?void 0:n.get(this.G):(e=this.G)==null?void 0:e.value}disconnected(){this.lt===this.ct&&this.rt(void 0)}reconnected(){this.rt(this.ct)}});var Ke,un,Wr,qr,Is,Jn,Xn,re,Ps,Rs,Me,Nc,Uc,pa,ga,ma,ya,va,ba,wa,Ds,Os,Hi,tv,ht;class uO extends ts{constructor(){super(...arguments);S(this,Me);S(this,Ke,rt.resolve("ScreenManager"));S(this,un,null);S(this,Wr,new DisposableStack);S(this,qr,So());S(this,Is,So());S(this,Jn,So());S(this,Xn,So());S(this,re,{kind:"none"});S(this,Ps,()=>{m(this,Me,Nc).call(this),c(this,ht).call(this)});S(this,Rs,()=>{c(this,ht).call(this)});S(this,pa,()=>{c(this,Ke).clearActive()});S(this,ga,t=>{c(this,re).kind!=="none"&&(t.stopImmediatePropagation(),m(this,Me,Hi).call(this))});S(this,ma,()=>{var r;const t=c(this,Ke).activeScreen;t&&((r=c(this,qr).value)==null||r.close(),E(this,re,{kind:"rename",draft:t.name}),c(this,ht).call(this))});S(this,ya,()=>{var t;c(this,Ke).activeScreen&&((t=c(this,qr).value)==null||t.close(),E(this,re,{kind:"delete",error:null}),c(this,ht).call(this))});S(this,va,t=>{if(c(this,re).kind!=="rename")return;const r=t.target;r instanceof HTMLInputElement&&E(this,re,{kind:"rename",draft:r.value})});S(this,ba,t=>{if(t.preventDefault(),c(this,re).kind!=="rename")return;const r=c(this,Ke).activeScreen;if(!r)return;const i=c(this,re).draft.trim();i.length>0&&i!==r.name&&r.rename(i),m(this,Me,Hi).call(this)});S(this,wa,async()=>{if(c(this,re).kind!=="delete")return;const t=c(this,Ke).activeScreen;if(t){E(this,re,{kind:"delete",error:null});try{await t.remove(),c(this,Ke).clearActive(),m(this,Me,Hi).call(this)}catch(r){E(this,re,{kind:"delete",error:r instanceof Error?r.message:"Failed to delete screen."}),c(this,ht).call(this)}}});S(this,Ds,()=>{m(this,Me,Hi).call(this)});S(this,Os,()=>{c(this,re).kind!=="none"&&(E(this,re,{kind:"none"}),c(this,ht).call(this))});S(this,ht,()=>{const t=F`
245
+ */const So=()=>new sO;class sO{}const jl=new WeakMap,ko=Fu(class extends iO{render(n){return oe}update(n,[e]){var r;const t=e!==this.G;return t&&this.G!==void 0&&this.rt(void 0),(t||this.lt!==this.ct)&&(this.G=e,this.ht=(r=n.options)==null?void 0:r.host,this.rt(this.ct=n.element)),oe}rt(n){if(this.isConnected||(n=void 0),typeof this.G=="function"){const e=this.ht??globalThis;let t=jl.get(e);t===void 0&&(t=new WeakMap,jl.set(e,t)),t.get(this.G)!==void 0&&this.G.call(this.ht,void 0),t.set(this.G,n),n!==void 0&&this.G.call(this.ht,n)}else this.G.value=n}get lt(){var n,e;return typeof this.G=="function"?(n=jl.get(this.ht??globalThis))==null?void 0:n.get(this.G):(e=this.G)==null?void 0:e.value}disconnected(){this.lt===this.ct&&this.rt(void 0)}reconnected(){this.rt(this.ct)}});var Ke,un,Wr,qr,Is,Jn,Xn,re,Ps,Rs,Me,Fc,Zc,pa,ga,ma,ya,va,ba,wa,Ds,Os,Hi,Qy,ht;class oO extends ts{constructor(){super(...arguments);S(this,Me);S(this,Ke,rt.resolve("ScreenManager"));S(this,un,null);S(this,Wr,new DisposableStack);S(this,qr,So());S(this,Is,So());S(this,Jn,So());S(this,Xn,So());S(this,re,{kind:"none"});S(this,Ps,()=>{m(this,Me,Fc).call(this),c(this,ht).call(this)});S(this,Rs,()=>{c(this,ht).call(this)});S(this,pa,()=>{c(this,Ke).clearActive()});S(this,ga,t=>{c(this,re).kind!=="none"&&(t.stopImmediatePropagation(),m(this,Me,Hi).call(this))});S(this,ma,()=>{var r;const t=c(this,Ke).activeScreen;t&&((r=c(this,qr).value)==null||r.close(),E(this,re,{kind:"rename",draft:t.name}),c(this,ht).call(this))});S(this,ya,()=>{var t;c(this,Ke).activeScreen&&((t=c(this,qr).value)==null||t.close(),E(this,re,{kind:"delete",error:null}),c(this,ht).call(this))});S(this,va,t=>{if(c(this,re).kind!=="rename")return;const r=t.target;r instanceof HTMLInputElement&&E(this,re,{kind:"rename",draft:r.value})});S(this,ba,t=>{if(t.preventDefault(),c(this,re).kind!=="rename")return;const r=c(this,Ke).activeScreen;if(!r)return;const i=c(this,re).draft.trim();i.length>0&&i!==r.name&&r.rename(i),m(this,Me,Hi).call(this)});S(this,wa,async()=>{if(c(this,re).kind!=="delete")return;const t=c(this,Ke).activeScreen;if(t){E(this,re,{kind:"delete",error:null});try{await t.remove(),c(this,Ke).clearActive(),m(this,Me,Hi).call(this)}catch(r){E(this,re,{kind:"delete",error:r instanceof Error?r.message:"Failed to delete screen."}),c(this,ht).call(this)}}});S(this,Ds,()=>{m(this,Me,Hi).call(this)});S(this,Os,()=>{c(this,re).kind!=="none"&&(E(this,re,{kind:"none"}),c(this,ht).call(this))});S(this,ht,()=>{const t=F`
246
246
  <button
247
247
  icon-only
248
248
  class="home"
@@ -250,11 +250,11 @@ ${r.documentElement.outerHTML}`],{type:"text/html"});return URL.createObjectURL(
250
250
  aria-label="Home"
251
251
  @click=${c(this,pa)}
252
252
  >
253
- ${jR({weight:"fill"})}
253
+ ${FR({weight:"fill"})}
254
254
  </button>
255
- `;Pe(F`${t}${m(this,Me,tv).call(this)}`,this);const r=c(this,Is).value??null;c(this,Jn).value&&(c(this,Jn).value.anchor=r),c(this,Xn).value&&(c(this,Xn).value.anchor=r)})}connected(){c(this,Ke).addEventListener("active-screen-changed",c(this,Ps)),m(this,Me,Nc).call(this),c(this,ht).call(this),c(this,Wr).defer(()=>{c(this,Ke).removeEventListener("active-screen-changed",c(this,Ps)),m(this,Me,Uc).call(this)})}disconnected(){c(this,Wr).dispose(),E(this,Wr,new DisposableStack)}}Ke=new WeakMap,un=new WeakMap,Wr=new WeakMap,qr=new WeakMap,Is=new WeakMap,Jn=new WeakMap,Xn=new WeakMap,re=new WeakMap,Ps=new WeakMap,Rs=new WeakMap,Me=new WeakSet,Nc=function(){var r;const t=c(this,Ke).activeScreen;c(this,un)!==t&&(m(this,Me,Uc).call(this),E(this,un,t),(r=c(this,un))==null||r.addEventListener("change",c(this,Rs)))},Uc=function(){var t;(t=c(this,un))==null||t.removeEventListener("change",c(this,Rs)),E(this,un,null)},pa=new WeakMap,ga=new WeakMap,ma=new WeakMap,ya=new WeakMap,va=new WeakMap,ba=new WeakMap,wa=new WeakMap,Ds=new WeakMap,Os=new WeakMap,Hi=function(){const t=c(this,re).kind==="rename"?c(this,Jn).value:c(this,re).kind==="delete"?c(this,Xn).value:null;t&&(t.open=!1),E(this,re,{kind:"none"}),c(this,ht).call(this)},tv=function(){const t=c(this,Ke).activeScreen;if(!t)return null;const r=c(this,re).kind==="rename"?c(this,re).draft:"",i=c(this,re).kind==="delete"?c(this,re).error:null;return F`
255
+ `;Pe(F`${t}${m(this,Me,Qy).call(this)}`,this);const r=c(this,Is).value??null;c(this,Jn).value&&(c(this,Jn).value.anchor=r),c(this,Xn).value&&(c(this,Xn).value.anchor=r)})}connected(){c(this,Ke).addEventListener("active-screen-changed",c(this,Ps)),m(this,Me,Fc).call(this),c(this,ht).call(this),c(this,Wr).defer(()=>{c(this,Ke).removeEventListener("active-screen-changed",c(this,Ps)),m(this,Me,Zc).call(this)})}disconnected(){c(this,Wr).dispose(),E(this,Wr,new DisposableStack)}}Ke=new WeakMap,un=new WeakMap,Wr=new WeakMap,qr=new WeakMap,Is=new WeakMap,Jn=new WeakMap,Xn=new WeakMap,re=new WeakMap,Ps=new WeakMap,Rs=new WeakMap,Me=new WeakSet,Fc=function(){var r;const t=c(this,Ke).activeScreen;c(this,un)!==t&&(m(this,Me,Zc).call(this),E(this,un,t),(r=c(this,un))==null||r.addEventListener("change",c(this,Rs)))},Zc=function(){var t;(t=c(this,un))==null||t.removeEventListener("change",c(this,Rs)),E(this,un,null)},pa=new WeakMap,ga=new WeakMap,ma=new WeakMap,ya=new WeakMap,va=new WeakMap,ba=new WeakMap,wa=new WeakMap,Ds=new WeakMap,Os=new WeakMap,Hi=function(){const t=c(this,re).kind==="rename"?c(this,Jn).value:c(this,re).kind==="delete"?c(this,Xn).value:null;t&&(t.open=!1),E(this,re,{kind:"none"}),c(this,ht).call(this)},Qy=function(){const t=c(this,Ke).activeScreen;if(!t)return null;const r=c(this,re).kind==="rename"?c(this,re).draft:"",i=c(this,re).kind==="delete"?c(this,re).error:null;return F`
256
256
  <span class="separator" aria-hidden="true">
257
- ${ZR()}
257
+ ${MR()}
258
258
  </span>
259
259
  <dropdown-menu ${ko(c(this,qr))}>
260
260
  <button
@@ -270,10 +270,10 @@ ${r.documentElement.outerHTML}`],{type:"text/html"});return URL.createObjectURL(
270
270
  </button>
271
271
  <dropdown-group>
272
272
  <dropdown-item action @click=${c(this,ma)}>
273
- ${BR()} Rename
273
+ ${ZR()} Rename
274
274
  </dropdown-item>
275
275
  <dropdown-item action danger @click=${c(this,ya)}>
276
- ${GR()} Delete
276
+ ${HR()} Delete
277
277
  </dropdown-item>
278
278
  </dropdown-group>
279
279
  </dropdown-menu>
@@ -319,7 +319,7 @@ ${r.documentElement.outerHTML}`],{type:"text/html"});return URL.createObjectURL(
319
319
  </div>
320
320
  </div>
321
321
  </ui-popover>
322
- `},ht=new WeakMap;customElements.define("screen-breadcrumb",uO);var _a,Sa,Yr,ri,nv,ka,rv;class hO extends HTMLElement{constructor(){super(...arguments);S(this,ri);S(this,_a,rt.resolve("ServerManager"));S(this,Sa,rt.resolve("ScreenManager"));S(this,Yr,!1);S(this,ka,async()=>{if(c(this,Yr))return;const t=m(this,ri,nv).call(this);if(t){E(this,Yr,!0);try{const r=await t.createScreen(dO(new Date));c(this,Sa).setActive(t.url,r.id)}catch{}finally{E(this,Yr,!1)}}})}connectedCallback(){m(this,ri,rv).call(this)}}_a=new WeakMap,Sa=new WeakMap,Yr=new WeakMap,ri=new WeakSet,nv=function(){for(const t of c(this,_a).servers.values())return t;return null},ka=new WeakMap,rv=function(){Pe(F`
322
+ `},ht=new WeakMap;customElements.define("screen-breadcrumb",oO);var _a,Sa,Yr,ri,ev,ka,tv;class aO extends HTMLElement{constructor(){super(...arguments);S(this,ri);S(this,_a,rt.resolve("ServerManager"));S(this,Sa,rt.resolve("ScreenManager"));S(this,Yr,!1);S(this,ka,async()=>{if(c(this,Yr))return;const t=m(this,ri,ev).call(this);if(t){E(this,Yr,!0);try{const r=await t.createScreen(lO(new Date));c(this,Sa).setActive(t.url,r.id)}catch{}finally{E(this,Yr,!1)}}})}connectedCallback(){m(this,ri,tv).call(this)}}_a=new WeakMap,Sa=new WeakMap,Yr=new WeakMap,ri=new WeakSet,ev=function(){for(const t of c(this,_a).servers.values())return t;return null},ka=new WeakMap,tv=function(){Pe(F`
323
323
  <button
324
324
  icon-only
325
325
  class="new-screen"
@@ -327,14 +327,14 @@ ${r.documentElement.outerHTML}`],{type:"text/html"});return URL.createObjectURL(
327
327
  aria-label="New screen"
328
328
  @click=${c(this,ka)}
329
329
  >
330
- ${VR({size:16,weight:"bold"})}
330
+ ${UR({size:16,weight:"bold"})}
331
331
  </button>
332
- `,this)};function dO(n){const e=n.toLocaleDateString("en-US",{month:"long",day:"numeric",year:"numeric"}),t=n.getHours(),r=t%12===0?12:t%12,i=n.getMinutes().toString().padStart(2,"0"),s=t>=12?"pm":"am";return`${e} at ${r}:${i}${s}`}customElements.define("screen-create-button",hO);function fO(n,e){let t=null;const r=()=>e((t==null?void 0:t.messages)??[]),i=()=>{const o=n.getActiveClient();o!==t&&(t==null||t.removeEventListener("change",r),t=o,t&&(t.addEventListener("change",r),t.connect().catch(a=>{console.error("ACPClient.connect() failed",a)})),r())};n.addEventListener("change",i),i();const s=()=>{n.removeEventListener("change",i),t==null||t.removeEventListener("change",r),t=null};return{dispose:s,[Symbol.dispose](){s()}}}/*! @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:iv,setPrototypeOf:Wf,isFrozen:pO,getPrototypeOf:gO,getOwnPropertyDescriptor:mO}=Object;let{freeze:Ne,seal:it,create:Zo}=Object,{apply:Fc,construct:Zc}=typeof Reflect<"u"&&Reflect;Ne||(Ne=function(e){return e});it||(it=function(e){return e});Fc||(Fc=function(e,t){for(var r=arguments.length,i=new Array(r>2?r-2:0),s=2;s<r;s++)i[s-2]=arguments[s];return e.apply(t,i)});Zc||(Zc=function(e){for(var t=arguments.length,r=new Array(t>1?t-1:0),i=1;i<t;i++)r[i-1]=arguments[i];return new e(...r)});const Eo=Ue(Array.prototype.forEach),yO=Ue(Array.prototype.lastIndexOf),qf=Ue(Array.prototype.pop),xi=Ue(Array.prototype.push),vO=Ue(Array.prototype.splice),Ho=Ue(String.prototype.toLowerCase),Vl=Ue(String.prototype.toString),jl=Ue(String.prototype.match),Ti=Ue(String.prototype.replace),bO=Ue(String.prototype.indexOf),wO=Ue(String.prototype.trim),qe=Ue(Object.prototype.hasOwnProperty),De=Ue(RegExp.prototype.test),Ci=_O(TypeError);function Ue(n){return function(e){e instanceof RegExp&&(e.lastIndex=0);for(var t=arguments.length,r=new Array(t>1?t-1:0),i=1;i<t;i++)r[i-1]=arguments[i];return Fc(n,e,r)}}function _O(n){return function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return Zc(n,t)}}function V(n,e){let t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:Ho;Wf&&Wf(n,null);let r=e.length;for(;r--;){let i=e[r];if(typeof i=="string"){const s=t(i);s!==i&&(pO(e)||(e[r]=s),i=s)}n[i]=!0}return n}function SO(n){for(let e=0;e<n.length;e++)qe(n,e)||(n[e]=null);return n}function bt(n){const e=Zo(null);for(const[t,r]of iv(n))qe(n,t)&&(Array.isArray(r)?e[t]=SO(r):r&&typeof r=="object"&&r.constructor===Object?e[t]=bt(r):e[t]=r);return e}function Ii(n,e){for(;n!==null;){const r=mO(n,e);if(r){if(r.get)return Ue(r.get);if(typeof r.value=="function")return Ue(r.value)}n=gO(n)}function t(){return null}return t}const Yf=Ne(["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"]),Bl=Ne(["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"]),Gl=Ne(["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"]),kO=Ne(["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"]),Wl=Ne(["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=Ne(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),Kf=Ne(["#text"]),Jf=Ne(["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"]),ql=Ne(["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"]),Xf=Ne(["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"]),$o=Ne(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),$O=it(/\{\{[\w\W]*|[\w\W]*\}\}/gm),AO=it(/<%[\w\W]*|[\w\W]*%>/gm),xO=it(/\$\{[\w\W]*/gm),TO=it(/^data-[\-\w.\u00B7-\uFFFF]+$/),CO=it(/^aria-[\-\w]+$/),sv=it(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),IO=it(/^(?:\w+script|data):/i),PO=it(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),ov=it(/^html$/i),RO=it(/^[a-z][.\w]*(-[.\w]+)+$/i);var Qf=Object.freeze({__proto__:null,ARIA_ATTR:CO,ATTR_WHITESPACE:PO,CUSTOM_ELEMENT:RO,DATA_ATTR:TO,DOCTYPE_NAME:ov,ERB_EXPR:AO,IS_ALLOWED_URI:sv,IS_SCRIPT_OR_DATA:IO,MUSTACHE_EXPR:$O,TMPLIT_EXPR:xO});const Pi={element:1,text:3,progressingInstruction:7,comment:8,document:9},DO=function(){return typeof window>"u"?null:window},OO=function(e,t){if(typeof e!="object"||typeof e.createPolicy!="function")return null;let r=null;const i="data-tt-policy-suffix";t&&t.hasAttribute(i)&&(r=t.getAttribute(i));const s="dompurify"+(r?"#"+r:"");try{return e.createPolicy(s,{createHTML(o){return o},createScriptURL(o){return o}})}catch{return console.warn("TrustedTypes policy "+s+" could not be created."),null}},ep=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}};function av(){let n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:DO();const e=L=>av(L);if(e.version="3.3.3",e.removed=[],!n||!n.document||n.document.nodeType!==Pi.document||!n.Element)return e.isSupported=!1,e;let{document:t}=n;const r=t,i=r.currentScript,{DocumentFragment:s,HTMLTemplateElement:o,Node:a,Element:l,NodeFilter:u,NamedNodeMap:d=n.NamedNodeMap||n.MozNamedAttrMap,HTMLFormElement:f,DOMParser:v,trustedTypes:y}=n,A=l.prototype,k=Ii(A,"cloneNode"),I=Ii(A,"remove"),B=Ii(A,"nextSibling"),P=Ii(A,"childNodes"),le=Ii(A,"parentNode");if(typeof o=="function"){const L=t.createElement("template");L.content&&L.content.ownerDocument&&(t=L.content.ownerDocument)}let M,Z="";const{implementation:U,createNodeIterator:ge,createDocumentFragment:ce,getElementsByTagName:yi}=t,{importNode:Xs}=r;let $e=ep();e.isSupported=typeof iv=="function"&&typeof le=="function"&&U&&U.createHTMLDocument!==void 0;const{MUSTACHE_EXPR:kn,ERB_EXPR:pt,TMPLIT_EXPR:Xt,DATA_ATTR:Ba,ARIA_ATTR:Qs,IS_SCRIPT_OR_DATA:Ev,ATTR_WHITESPACE:Xu,CUSTOM_ELEMENT:$v}=Qf;let{IS_ALLOWED_URI:Qu}=Qf,_e=null;const eh=V({},[...Yf,...Bl,...Gl,...Wl,...Kf]);let Ae=null;const th=V({},[...Jf,...ql,...Xf,...$o]);let me=Object.seal(Zo(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}})),vi=null,eo=null;const Qt=Object.seal(Zo(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let nh=!0,Ga=!0,rh=!1,ih=!0,hr=!1,to=!0,En=!1,Wa=!1,qa=!1,dr=!1,no=!1,ro=!1,sh=!0,oh=!1;const Av="user-content-";let Ya=!0,bi=!1,fr={},gt=null;const Ka=V({},["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 ah=null;const lh=V({},["audio","video","img","source","image","track"]);let Ja=null;const ch=V({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),io="http://www.w3.org/1998/Math/MathML",so="http://www.w3.org/2000/svg",Ct="http://www.w3.org/1999/xhtml";let pr=Ct,Xa=!1,Qa=null;const xv=V({},[io,so,Ct],Vl);let oo=V({},["mi","mo","mn","ms","mtext"]),ao=V({},["annotation-xml"]);const Tv=V({},["title","style","font","a","script"]);let wi=null;const Cv=["application/xhtml+xml","text/html"],Iv="text/html";let be=null,gr=null;const Pv=t.createElement("form"),uh=function(g){return g instanceof RegExp||g instanceof Function},el=function(){let g=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(!(gr&&gr===g)){if((!g||typeof g!="object")&&(g={}),g=bt(g),wi=Cv.indexOf(g.PARSER_MEDIA_TYPE)===-1?Iv:g.PARSER_MEDIA_TYPE,be=wi==="application/xhtml+xml"?Vl:Ho,_e=qe(g,"ALLOWED_TAGS")?V({},g.ALLOWED_TAGS,be):eh,Ae=qe(g,"ALLOWED_ATTR")?V({},g.ALLOWED_ATTR,be):th,Qa=qe(g,"ALLOWED_NAMESPACES")?V({},g.ALLOWED_NAMESPACES,Vl):xv,Ja=qe(g,"ADD_URI_SAFE_ATTR")?V(bt(ch),g.ADD_URI_SAFE_ATTR,be):ch,ah=qe(g,"ADD_DATA_URI_TAGS")?V(bt(lh),g.ADD_DATA_URI_TAGS,be):lh,gt=qe(g,"FORBID_CONTENTS")?V({},g.FORBID_CONTENTS,be):Ka,vi=qe(g,"FORBID_TAGS")?V({},g.FORBID_TAGS,be):bt({}),eo=qe(g,"FORBID_ATTR")?V({},g.FORBID_ATTR,be):bt({}),fr=qe(g,"USE_PROFILES")?g.USE_PROFILES:!1,nh=g.ALLOW_ARIA_ATTR!==!1,Ga=g.ALLOW_DATA_ATTR!==!1,rh=g.ALLOW_UNKNOWN_PROTOCOLS||!1,ih=g.ALLOW_SELF_CLOSE_IN_ATTR!==!1,hr=g.SAFE_FOR_TEMPLATES||!1,to=g.SAFE_FOR_XML!==!1,En=g.WHOLE_DOCUMENT||!1,dr=g.RETURN_DOM||!1,no=g.RETURN_DOM_FRAGMENT||!1,ro=g.RETURN_TRUSTED_TYPE||!1,qa=g.FORCE_BODY||!1,sh=g.SANITIZE_DOM!==!1,oh=g.SANITIZE_NAMED_PROPS||!1,Ya=g.KEEP_CONTENT!==!1,bi=g.IN_PLACE||!1,Qu=g.ALLOWED_URI_REGEXP||sv,pr=g.NAMESPACE||Ct,oo=g.MATHML_TEXT_INTEGRATION_POINTS||oo,ao=g.HTML_INTEGRATION_POINTS||ao,me=g.CUSTOM_ELEMENT_HANDLING||{},g.CUSTOM_ELEMENT_HANDLING&&uh(g.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(me.tagNameCheck=g.CUSTOM_ELEMENT_HANDLING.tagNameCheck),g.CUSTOM_ELEMENT_HANDLING&&uh(g.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(me.attributeNameCheck=g.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),g.CUSTOM_ELEMENT_HANDLING&&typeof g.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements=="boolean"&&(me.allowCustomizedBuiltInElements=g.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),hr&&(Ga=!1),no&&(dr=!0),fr&&(_e=V({},Kf),Ae=Zo(null),fr.html===!0&&(V(_e,Yf),V(Ae,Jf)),fr.svg===!0&&(V(_e,Bl),V(Ae,ql),V(Ae,$o)),fr.svgFilters===!0&&(V(_e,Gl),V(Ae,ql),V(Ae,$o)),fr.mathMl===!0&&(V(_e,Wl),V(Ae,Xf),V(Ae,$o))),qe(g,"ADD_TAGS")||(Qt.tagCheck=null),qe(g,"ADD_ATTR")||(Qt.attributeCheck=null),g.ADD_TAGS&&(typeof g.ADD_TAGS=="function"?Qt.tagCheck=g.ADD_TAGS:(_e===eh&&(_e=bt(_e)),V(_e,g.ADD_TAGS,be))),g.ADD_ATTR&&(typeof g.ADD_ATTR=="function"?Qt.attributeCheck=g.ADD_ATTR:(Ae===th&&(Ae=bt(Ae)),V(Ae,g.ADD_ATTR,be))),g.ADD_URI_SAFE_ATTR&&V(Ja,g.ADD_URI_SAFE_ATTR,be),g.FORBID_CONTENTS&&(gt===Ka&&(gt=bt(gt)),V(gt,g.FORBID_CONTENTS,be)),g.ADD_FORBID_CONTENTS&&(gt===Ka&&(gt=bt(gt)),V(gt,g.ADD_FORBID_CONTENTS,be)),Ya&&(_e["#text"]=!0),En&&V(_e,["html","head","body"]),_e.table&&(V(_e,["tbody"]),delete vi.tbody),g.TRUSTED_TYPES_POLICY){if(typeof g.TRUSTED_TYPES_POLICY.createHTML!="function")throw Ci('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof g.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw Ci('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');M=g.TRUSTED_TYPES_POLICY,Z=M.createHTML("")}else M===void 0&&(M=OO(y,i)),M!==null&&typeof Z=="string"&&(Z=M.createHTML(""));Ne&&Ne(g),gr=g}},hh=V({},[...Bl,...Gl,...kO]),dh=V({},[...Wl,...EO]),Rv=function(g){let T=le(g);(!T||!T.tagName)&&(T={namespaceURI:pr,tagName:"template"});const R=Ho(g.tagName),ie=Ho(T.tagName);return Qa[g.namespaceURI]?g.namespaceURI===so?T.namespaceURI===Ct?R==="svg":T.namespaceURI===io?R==="svg"&&(ie==="annotation-xml"||oo[ie]):!!hh[R]:g.namespaceURI===io?T.namespaceURI===Ct?R==="math":T.namespaceURI===so?R==="math"&&ao[ie]:!!dh[R]:g.namespaceURI===Ct?T.namespaceURI===so&&!ao[ie]||T.namespaceURI===io&&!oo[ie]?!1:!dh[R]&&(Tv[R]||!hh[R]):!!(wi==="application/xhtml+xml"&&Qa[g.namespaceURI]):!1},mt=function(g){xi(e.removed,{element:g});try{le(g).removeChild(g)}catch{I(g)}},$n=function(g,T){try{xi(e.removed,{attribute:T.getAttributeNode(g),from:T})}catch{xi(e.removed,{attribute:null,from:T})}if(T.removeAttribute(g),g==="is")if(dr||no)try{mt(T)}catch{}else try{T.setAttribute(g,"")}catch{}},fh=function(g){let T=null,R=null;if(qa)g="<remove></remove>"+g;else{const ye=jl(g,/^[\r\n\t ]+/);R=ye&&ye[0]}wi==="application/xhtml+xml"&&pr===Ct&&(g='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+g+"</body></html>");const ie=M?M.createHTML(g):g;if(pr===Ct)try{T=new v().parseFromString(ie,wi)}catch{}if(!T||!T.documentElement){T=U.createDocument(pr,"template",null);try{T.documentElement.innerHTML=Xa?Z:ie}catch{}}const Re=T.body||T.documentElement;return g&&R&&Re.insertBefore(t.createTextNode(R),Re.childNodes[0]||null),pr===Ct?yi.call(T,En?"html":"body")[0]:En?T.documentElement:Re},ph=function(g){return ge.call(g.ownerDocument||g,g,u.SHOW_ELEMENT|u.SHOW_COMMENT|u.SHOW_TEXT|u.SHOW_PROCESSING_INSTRUCTION|u.SHOW_CDATA_SECTION,null)},tl=function(g){return g instanceof f&&(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")},gh=function(g){return typeof a=="function"&&g instanceof a};function It(L,g,T){Eo(L,R=>{R.call(e,g,T,gr)})}const mh=function(g){let T=null;if(It($e.beforeSanitizeElements,g,null),tl(g))return mt(g),!0;const R=be(g.nodeName);if(It($e.uponSanitizeElement,g,{tagName:R,allowedTags:_e}),to&&g.hasChildNodes()&&!gh(g.firstElementChild)&&De(/<[/\w!]/g,g.innerHTML)&&De(/<[/\w!]/g,g.textContent)||g.nodeType===Pi.progressingInstruction||to&&g.nodeType===Pi.comment&&De(/<[/\w]/g,g.data))return mt(g),!0;if(!(Qt.tagCheck instanceof Function&&Qt.tagCheck(R))&&(!_e[R]||vi[R])){if(!vi[R]&&vh(R)&&(me.tagNameCheck instanceof RegExp&&De(me.tagNameCheck,R)||me.tagNameCheck instanceof Function&&me.tagNameCheck(R)))return!1;if(Ya&&!gt[R]){const ie=le(g)||g.parentNode,Re=P(g)||g.childNodes;if(Re&&ie){const ye=Re.length;for(let Fe=ye-1;Fe>=0;--Fe){const Pt=k(Re[Fe],!0);Pt.__removalCount=(g.__removalCount||0)+1,ie.insertBefore(Pt,B(g))}}}return mt(g),!0}return g instanceof l&&!Rv(g)||(R==="noscript"||R==="noembed"||R==="noframes")&&De(/<\/no(script|embed|frames)/i,g.innerHTML)?(mt(g),!0):(hr&&g.nodeType===Pi.text&&(T=g.textContent,Eo([kn,pt,Xt],ie=>{T=Ti(T,ie," ")}),g.textContent!==T&&(xi(e.removed,{element:g.cloneNode()}),g.textContent=T)),It($e.afterSanitizeElements,g,null),!1)},yh=function(g,T,R){if(eo[T]||sh&&(T==="id"||T==="name")&&(R in t||R in Pv))return!1;if(!(Ga&&!eo[T]&&De(Ba,T))){if(!(nh&&De(Qs,T))){if(!(Qt.attributeCheck instanceof Function&&Qt.attributeCheck(T,g))){if(!Ae[T]||eo[T]){if(!(vh(g)&&(me.tagNameCheck instanceof RegExp&&De(me.tagNameCheck,g)||me.tagNameCheck instanceof Function&&me.tagNameCheck(g))&&(me.attributeNameCheck instanceof RegExp&&De(me.attributeNameCheck,T)||me.attributeNameCheck instanceof Function&&me.attributeNameCheck(T,g))||T==="is"&&me.allowCustomizedBuiltInElements&&(me.tagNameCheck instanceof RegExp&&De(me.tagNameCheck,R)||me.tagNameCheck instanceof Function&&me.tagNameCheck(R))))return!1}else if(!Ja[T]){if(!De(Qu,Ti(R,Xu,""))){if(!((T==="src"||T==="xlink:href"||T==="href")&&g!=="script"&&bO(R,"data:")===0&&ah[g])){if(!(rh&&!De(Ev,Ti(R,Xu,"")))){if(R)return!1}}}}}}}return!0},vh=function(g){return g!=="annotation-xml"&&jl(g,$v)},bh=function(g){It($e.beforeSanitizeAttributes,g,null);const{attributes:T}=g;if(!T||tl(g))return;const R={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:Ae,forceKeepAttr:void 0};let ie=T.length;for(;ie--;){const Re=T[ie],{name:ye,namespaceURI:Fe,value:Pt}=Re,mr=be(ye),nl=Pt;let xe=ye==="value"?nl:wO(nl);if(R.attrName=mr,R.attrValue=xe,R.keepAttr=!0,R.forceKeepAttr=void 0,It($e.uponSanitizeAttribute,g,R),xe=R.attrValue,oh&&(mr==="id"||mr==="name")&&($n(ye,g),xe=Av+xe),to&&De(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,xe)){$n(ye,g);continue}if(mr==="attributename"&&jl(xe,"href")){$n(ye,g);continue}if(R.forceKeepAttr)continue;if(!R.keepAttr){$n(ye,g);continue}if(!ih&&De(/\/>/i,xe)){$n(ye,g);continue}hr&&Eo([kn,pt,Xt],_h=>{xe=Ti(xe,_h," ")});const wh=be(g.nodeName);if(!yh(wh,mr,xe)){$n(ye,g);continue}if(M&&typeof y=="object"&&typeof y.getAttributeType=="function"&&!Fe)switch(y.getAttributeType(wh,mr)){case"TrustedHTML":{xe=M.createHTML(xe);break}case"TrustedScriptURL":{xe=M.createScriptURL(xe);break}}if(xe!==nl)try{Fe?g.setAttributeNS(Fe,ye,xe):g.setAttribute(ye,xe),tl(g)?mt(g):qf(e.removed)}catch{$n(ye,g)}}It($e.afterSanitizeAttributes,g,null)},Dv=function L(g){let T=null;const R=ph(g);for(It($e.beforeSanitizeShadowDOM,g,null);T=R.nextNode();)It($e.uponSanitizeShadowNode,T,null),mh(T),bh(T),T.content instanceof s&&L(T.content);It($e.afterSanitizeShadowDOM,g,null)};return e.sanitize=function(L){let g=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},T=null,R=null,ie=null,Re=null;if(Xa=!L,Xa&&(L="<!-->"),typeof L!="string"&&!gh(L))if(typeof L.toString=="function"){if(L=L.toString(),typeof L!="string")throw Ci("dirty is not a string, aborting")}else throw Ci("toString is not a function");if(!e.isSupported)return L;if(Wa||el(g),e.removed=[],typeof L=="string"&&(bi=!1),bi){if(L.nodeName){const Pt=be(L.nodeName);if(!_e[Pt]||vi[Pt])throw Ci("root node is forbidden and cannot be sanitized in-place")}}else if(L instanceof a)T=fh("<!---->"),R=T.ownerDocument.importNode(L,!0),R.nodeType===Pi.element&&R.nodeName==="BODY"||R.nodeName==="HTML"?T=R:T.appendChild(R);else{if(!dr&&!hr&&!En&&L.indexOf("<")===-1)return M&&ro?M.createHTML(L):L;if(T=fh(L),!T)return dr?null:ro?Z:""}T&&qa&&mt(T.firstChild);const ye=ph(bi?L:T);for(;ie=ye.nextNode();)mh(ie),bh(ie),ie.content instanceof s&&Dv(ie.content);if(bi)return L;if(dr){if(no)for(Re=ce.call(T.ownerDocument);T.firstChild;)Re.appendChild(T.firstChild);else Re=T;return(Ae.shadowroot||Ae.shadowrootmode)&&(Re=Xs.call(r,Re,!0)),Re}let Fe=En?T.outerHTML:T.innerHTML;return En&&_e["!doctype"]&&T.ownerDocument&&T.ownerDocument.doctype&&T.ownerDocument.doctype.name&&De(ov,T.ownerDocument.doctype.name)&&(Fe="<!DOCTYPE "+T.ownerDocument.doctype.name+`>
333
- `+Fe),hr&&Eo([kn,pt,Xt],Pt=>{Fe=Ti(Fe,Pt," ")}),M&&ro?M.createHTML(Fe):Fe},e.setConfig=function(){let L=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};el(L),Wa=!0},e.clearConfig=function(){gr=null,Wa=!1},e.isValidAttribute=function(L,g,T){gr||el({});const R=be(L),ie=be(g);return yh(R,ie,T)},e.addHook=function(L,g){typeof g=="function"&&xi($e[L],g)},e.removeHook=function(L,g){if(g!==void 0){const T=yO($e[L],g);return T===-1?void 0:vO($e[L],T,1)[0]}return qf($e[L])},e.removeHooks=function(L){$e[L]=[]},e.removeAllHooks=function(){$e=ep()},e}var lv=av();function Zu(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var ur=Zu();function cv(n){ur=n}var Dn={exec:()=>null};function W(n,e=""){let t=typeof n=="string"?n:n.source,r={replace:(i,s)=>{let o=typeof s=="string"?s:s.source;return o=o.replace(Le.caret,"$1"),t=t.replace(i,o),r},getRegex:()=>new RegExp(t,e)};return r}var zO=(()=>{try{return!!new RegExp("(?<=1)(?<!1)")}catch{return!1}})(),Le={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:n=>new RegExp(`^( {0,3}${n})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:n=>new RegExp(`^ {0,${Math.min(3,n-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),hrRegex:n=>new RegExp(`^ {0,${Math.min(3,n-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),fencesBeginRegex:n=>new RegExp(`^ {0,${Math.min(3,n-1)}}(?:\`\`\`|~~~)`),headingBeginRegex:n=>new RegExp(`^ {0,${Math.min(3,n-1)}}#`),htmlBeginRegex:n=>new RegExp(`^ {0,${Math.min(3,n-1)}}<(?:[a-z].*>|!--)`,"i"),blockquoteBeginRegex:n=>new RegExp(`^ {0,${Math.min(3,n-1)}}>`)},LO=/^(?:[ \t]*(?:\n|$))+/,MO=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,NO=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,Js=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,UO=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,Hu=/ {0,3}(?:[*+-]|\d{1,9}[.)])/,uv=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,hv=W(uv).replace(/bull/g,Hu).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(),FO=W(uv).replace(/bull/g,Hu).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(),Vu=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,ZO=/^[^\n]+/,ju=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,HO=W(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",ju).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),VO=W(/^(bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,Hu).getRegex(),Ha="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",Bu=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,jO=W("^ {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",Bu).replace("tag",Ha).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),dv=W(Vu).replace("hr",Js).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",Ha).getRegex(),BO=W(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",dv).getRegex(),Gu={blockquote:BO,code:MO,def:HO,fences:NO,heading:UO,hr:Js,html:jO,lheading:hv,list:VO,newline:LO,paragraph:dv,table:Dn,text:ZO},tp=W("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",Js).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",Ha).getRegex(),GO={...Gu,lheading:FO,table:tp,paragraph:W(Vu).replace("hr",Js).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",tp).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",Ha).getRegex()},WO={...Gu,html:W(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",Bu).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:Dn,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:W(Vu).replace("hr",Js).replace("heading",` *#{1,6} *[^
334
- ]`).replace("lheading",hv).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},qO=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,YO=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,fv=/^( {2,}|\\)\n(?!\s*$)/,KO=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,mi=/[\p{P}\p{S}]/u,Va=/[\s\p{P}\p{S}]/u,Wu=/[^\s\p{P}\p{S}]/u,JO=W(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,Va).getRegex(),pv=/(?!~)[\p{P}\p{S}]/u,XO=/(?!~)[\s\p{P}\p{S}]/u,QO=/(?:[^\s\p{P}\p{S}]|~)/u,ez=W(/link|precode-code|html/,"g").replace("link",/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-",zO?"(?<!`)()":"(^^|[^`])").replace("code",/(?<b>`+)[^`]+\k<b>(?!`)/).replace("html",/<(?! )[^<>]*?>/).getRegex(),gv=/^(?:\*+(?:((?!\*)punct)|([^\s*]))?)|^_+(?:((?!_)punct)|([^\s_]))?/,tz=W(gv,"u").replace(/punct/g,mi).getRegex(),nz=W(gv,"u").replace(/punct/g,pv).getRegex(),mv="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",rz=W(mv,"gu").replace(/notPunctSpace/g,Wu).replace(/punctSpace/g,Va).replace(/punct/g,mi).getRegex(),iz=W(mv,"gu").replace(/notPunctSpace/g,QO).replace(/punctSpace/g,XO).replace(/punct/g,pv).getRegex(),sz=W("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,Wu).replace(/punctSpace/g,Va).replace(/punct/g,mi).getRegex(),oz=W(/^~~?(?:((?!~)punct)|[^\s~])/,"u").replace(/punct/g,mi).getRegex(),az="^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)",lz=W(az,"gu").replace(/notPunctSpace/g,Wu).replace(/punctSpace/g,Va).replace(/punct/g,mi).getRegex(),cz=W(/\\(punct)/,"gu").replace(/punct/g,mi).getRegex(),uz=W(/^<(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(),hz=W(Bu).replace("(?:-->|$)","-->").getRegex(),dz=W("^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",hz).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),ia=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\])|[^\[\]\\`])*?/,fz=W(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?\s*\)/).replace("label",ia).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),yv=W(/^!?\[(label)\]\[(ref)\]/).replace("label",ia).replace("ref",ju).getRegex(),vv=W(/^!?\[(ref)\](?:\[\])?/).replace("ref",ju).getRegex(),pz=W("reflink|nolink(?!\\()","g").replace("reflink",yv).replace("nolink",vv).getRegex(),np=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,qu={_backpedal:Dn,anyPunctuation:cz,autolink:uz,blockSkip:ez,br:fv,code:YO,del:Dn,delLDelim:Dn,delRDelim:Dn,emStrongLDelim:tz,emStrongRDelimAst:rz,emStrongRDelimUnd:sz,escape:qO,link:fz,nolink:vv,punctuation:JO,reflink:yv,reflinkSearch:pz,tag:dz,text:KO,url:Dn},gz={...qu,link:W(/^!?\[(label)\]\((.*?)\)/).replace("label",ia).getRegex(),reflink:W(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",ia).getRegex()},Hc={...qu,emStrongRDelimAst:iz,emStrongLDelim:nz,delLDelim:oz,delRDelim:lz,url:W(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol",np).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:W(/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace("protocol",np).getRegex()},mz={...Hc,br:W(fv).replace("{2,}","*").getRegex(),text:W(Hc.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},Ao={normal:Gu,gfm:GO,pedantic:WO},Ri={normal:qu,gfm:Hc,breaks:mz,pedantic:gz},yz={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},rp=n=>yz[n];function wt(n,e){if(e){if(Le.escapeTest.test(n))return n.replace(Le.escapeReplace,rp)}else if(Le.escapeTestNoEncode.test(n))return n.replace(Le.escapeReplaceNoEncode,rp);return n}function ip(n){try{n=encodeURI(n).replace(Le.percentDecode,"%")}catch{return null}return n}function sp(n,e){var s;let t=n.replace(Le.findPipe,(o,a,l)=>{let u=!1,d=a;for(;--d>=0&&l[d]==="\\";)u=!u;return u?"|":" |"}),r=t.split(Le.splitPipe),i=0;if(r[0].trim()||r.shift(),r.length>0&&!((s=r.at(-1))!=null&&s.trim())&&r.pop(),e)if(r.length>e)r.splice(e);else for(;r.length<e;)r.push("");for(;i<r.length;i++)r[i]=r[i].trim().replace(Le.slashPipe,"|");return r}function Di(n,e,t){let r=n.length;if(r===0)return"";let i=0;for(;i<r&&n.charAt(r-i-1)===e;)i++;return n.slice(0,r-i)}function vz(n,e){if(n.indexOf(e[1])===-1)return-1;let t=0;for(let r=0;r<n.length;r++)if(n[r]==="\\")r++;else if(n[r]===e[0])t++;else if(n[r]===e[1]&&(t--,t<0))return r;return t>0?-2:-1}function bz(n,e=0){let t=e,r="";for(let i of n)if(i===" "){let s=4-t%4;r+=" ".repeat(s),t+=s}else r+=i,t++;return r}function op(n,e,t,r,i){let s=e.href,o=e.title||null,a=n[1].replace(i.other.outputLinkReplace,"$1");r.state.inLink=!0;let l={type:n[0].charAt(0)==="!"?"image":"link",raw:t,href:s,title:o,text:a,tokens:r.inlineTokens(a)};return r.state.inLink=!1,l}function wz(n,e,t){let r=n.match(t.other.indentCodeCompensation);if(r===null)return e;let i=r[1];return e.split(`
332
+ `,this)};function lO(n){const e=n.toLocaleDateString("en-US",{month:"long",day:"numeric",year:"numeric"}),t=n.getHours(),r=t%12===0?12:t%12,i=n.getMinutes().toString().padStart(2,"0"),s=t>=12?"pm":"am";return`${e} at ${r}:${i}${s}`}customElements.define("screen-create-button",aO);function cO(n,e){let t=null;const r=()=>e((t==null?void 0:t.messages)??[]),i=()=>{const o=n.getActiveClient();o!==t&&(t==null||t.removeEventListener("change",r),t=o,t&&(t.addEventListener("change",r),t.connect().catch(a=>{console.error("ACPClient.connect() failed",a)})),r())};n.addEventListener("change",i),i();const s=()=>{n.removeEventListener("change",i),t==null||t.removeEventListener("change",r),t=null};return{dispose:s,[Symbol.dispose](){s()}}}/*! @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:nv,setPrototypeOf:Wf,isFrozen:uO,getPrototypeOf:hO,getOwnPropertyDescriptor:dO}=Object;let{freeze:Ne,seal:it,create:Zo}=Object,{apply:Hc,construct:Vc}=typeof Reflect<"u"&&Reflect;Ne||(Ne=function(e){return e});it||(it=function(e){return e});Hc||(Hc=function(e,t){for(var r=arguments.length,i=new Array(r>2?r-2:0),s=2;s<r;s++)i[s-2]=arguments[s];return e.apply(t,i)});Vc||(Vc=function(e){for(var t=arguments.length,r=new Array(t>1?t-1:0),i=1;i<t;i++)r[i-1]=arguments[i];return new e(...r)});const Eo=Ue(Array.prototype.forEach),fO=Ue(Array.prototype.lastIndexOf),qf=Ue(Array.prototype.pop),xi=Ue(Array.prototype.push),pO=Ue(Array.prototype.splice),Ho=Ue(String.prototype.toLowerCase),Gl=Ue(String.prototype.toString),Bl=Ue(String.prototype.match),Ti=Ue(String.prototype.replace),gO=Ue(String.prototype.indexOf),mO=Ue(String.prototype.trim),qe=Ue(Object.prototype.hasOwnProperty),De=Ue(RegExp.prototype.test),Ci=yO(TypeError);function Ue(n){return function(e){e instanceof RegExp&&(e.lastIndex=0);for(var t=arguments.length,r=new Array(t>1?t-1:0),i=1;i<t;i++)r[i-1]=arguments[i];return Hc(n,e,r)}}function yO(n){return function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return Vc(n,t)}}function V(n,e){let t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:Ho;Wf&&Wf(n,null);let r=e.length;for(;r--;){let i=e[r];if(typeof i=="string"){const s=t(i);s!==i&&(uO(e)||(e[r]=s),i=s)}n[i]=!0}return n}function vO(n){for(let e=0;e<n.length;e++)qe(n,e)||(n[e]=null);return n}function bt(n){const e=Zo(null);for(const[t,r]of nv(n))qe(n,t)&&(Array.isArray(r)?e[t]=vO(r):r&&typeof r=="object"&&r.constructor===Object?e[t]=bt(r):e[t]=r);return e}function Ii(n,e){for(;n!==null;){const r=dO(n,e);if(r){if(r.get)return Ue(r.get);if(typeof r.value=="function")return Ue(r.value)}n=hO(n)}function t(){return null}return t}const Yf=Ne(["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"]),Wl=Ne(["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"]),ql=Ne(["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"]),bO=Ne(["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"]),Yl=Ne(["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"]),wO=Ne(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),Kf=Ne(["#text"]),Jf=Ne(["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"]),Kl=Ne(["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"]),Xf=Ne(["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"]),$o=Ne(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),_O=it(/\{\{[\w\W]*|[\w\W]*\}\}/gm),SO=it(/<%[\w\W]*|[\w\W]*%>/gm),kO=it(/\$\{[\w\W]*/gm),EO=it(/^data-[\-\w.\u00B7-\uFFFF]+$/),$O=it(/^aria-[\-\w]+$/),rv=it(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),AO=it(/^(?:\w+script|data):/i),xO=it(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),iv=it(/^html$/i),TO=it(/^[a-z][.\w]*(-[.\w]+)+$/i);var Qf=Object.freeze({__proto__:null,ARIA_ATTR:$O,ATTR_WHITESPACE:xO,CUSTOM_ELEMENT:TO,DATA_ATTR:EO,DOCTYPE_NAME:iv,ERB_EXPR:SO,IS_ALLOWED_URI:rv,IS_SCRIPT_OR_DATA:AO,MUSTACHE_EXPR:_O,TMPLIT_EXPR:kO});const Pi={element:1,text:3,progressingInstruction:7,comment:8,document:9},CO=function(){return typeof window>"u"?null:window},IO=function(e,t){if(typeof e!="object"||typeof e.createPolicy!="function")return null;let r=null;const i="data-tt-policy-suffix";t&&t.hasAttribute(i)&&(r=t.getAttribute(i));const s="dompurify"+(r?"#"+r:"");try{return e.createPolicy(s,{createHTML(o){return o},createScriptURL(o){return o}})}catch{return console.warn("TrustedTypes policy "+s+" could not be created."),null}},ep=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}};function sv(){let n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:CO();const e=L=>sv(L);if(e.version="3.3.3",e.removed=[],!n||!n.document||n.document.nodeType!==Pi.document||!n.Element)return e.isSupported=!1,e;let{document:t}=n;const r=t,i=r.currentScript,{DocumentFragment:s,HTMLTemplateElement:o,Node:a,Element:l,NodeFilter:u,NamedNodeMap:d=n.NamedNodeMap||n.MozNamedAttrMap,HTMLFormElement:f,DOMParser:v,trustedTypes:y}=n,A=l.prototype,k=Ii(A,"cloneNode"),I=Ii(A,"remove"),G=Ii(A,"nextSibling"),P=Ii(A,"childNodes"),le=Ii(A,"parentNode");if(typeof o=="function"){const L=t.createElement("template");L.content&&L.content.ownerDocument&&(t=L.content.ownerDocument)}let M,Z="";const{implementation:U,createNodeIterator:ge,createDocumentFragment:ce,getElementsByTagName:yi}=t,{importNode:Xs}=r;let $e=ep();e.isSupported=typeof nv=="function"&&typeof le=="function"&&U&&U.createHTMLDocument!==void 0;const{MUSTACHE_EXPR:kn,ERB_EXPR:pt,TMPLIT_EXPR:Xt,DATA_ATTR:Ga,ARIA_ATTR:Qs,IS_SCRIPT_OR_DATA:Sv,ATTR_WHITESPACE:eh,CUSTOM_ELEMENT:kv}=Qf;let{IS_ALLOWED_URI:th}=Qf,_e=null;const nh=V({},[...Yf,...Wl,...ql,...Yl,...Kf]);let Ae=null;const rh=V({},[...Jf,...Kl,...Xf,...$o]);let me=Object.seal(Zo(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}})),vi=null,eo=null;const Qt=Object.seal(Zo(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let ih=!0,Ba=!0,sh=!1,oh=!0,hr=!1,to=!0,En=!1,Wa=!1,qa=!1,dr=!1,no=!1,ro=!1,ah=!0,lh=!1;const Ev="user-content-";let Ya=!0,bi=!1,fr={},gt=null;const Ka=V({},["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 ch=null;const uh=V({},["audio","video","img","source","image","track"]);let Ja=null;const hh=V({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),io="http://www.w3.org/1998/Math/MathML",so="http://www.w3.org/2000/svg",Ct="http://www.w3.org/1999/xhtml";let pr=Ct,Xa=!1,Qa=null;const $v=V({},[io,so,Ct],Gl);let oo=V({},["mi","mo","mn","ms","mtext"]),ao=V({},["annotation-xml"]);const Av=V({},["title","style","font","a","script"]);let wi=null;const xv=["application/xhtml+xml","text/html"],Tv="text/html";let be=null,gr=null;const Cv=t.createElement("form"),dh=function(g){return g instanceof RegExp||g instanceof Function},el=function(){let g=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(!(gr&&gr===g)){if((!g||typeof g!="object")&&(g={}),g=bt(g),wi=xv.indexOf(g.PARSER_MEDIA_TYPE)===-1?Tv:g.PARSER_MEDIA_TYPE,be=wi==="application/xhtml+xml"?Gl:Ho,_e=qe(g,"ALLOWED_TAGS")?V({},g.ALLOWED_TAGS,be):nh,Ae=qe(g,"ALLOWED_ATTR")?V({},g.ALLOWED_ATTR,be):rh,Qa=qe(g,"ALLOWED_NAMESPACES")?V({},g.ALLOWED_NAMESPACES,Gl):$v,Ja=qe(g,"ADD_URI_SAFE_ATTR")?V(bt(hh),g.ADD_URI_SAFE_ATTR,be):hh,ch=qe(g,"ADD_DATA_URI_TAGS")?V(bt(uh),g.ADD_DATA_URI_TAGS,be):uh,gt=qe(g,"FORBID_CONTENTS")?V({},g.FORBID_CONTENTS,be):Ka,vi=qe(g,"FORBID_TAGS")?V({},g.FORBID_TAGS,be):bt({}),eo=qe(g,"FORBID_ATTR")?V({},g.FORBID_ATTR,be):bt({}),fr=qe(g,"USE_PROFILES")?g.USE_PROFILES:!1,ih=g.ALLOW_ARIA_ATTR!==!1,Ba=g.ALLOW_DATA_ATTR!==!1,sh=g.ALLOW_UNKNOWN_PROTOCOLS||!1,oh=g.ALLOW_SELF_CLOSE_IN_ATTR!==!1,hr=g.SAFE_FOR_TEMPLATES||!1,to=g.SAFE_FOR_XML!==!1,En=g.WHOLE_DOCUMENT||!1,dr=g.RETURN_DOM||!1,no=g.RETURN_DOM_FRAGMENT||!1,ro=g.RETURN_TRUSTED_TYPE||!1,qa=g.FORCE_BODY||!1,ah=g.SANITIZE_DOM!==!1,lh=g.SANITIZE_NAMED_PROPS||!1,Ya=g.KEEP_CONTENT!==!1,bi=g.IN_PLACE||!1,th=g.ALLOWED_URI_REGEXP||rv,pr=g.NAMESPACE||Ct,oo=g.MATHML_TEXT_INTEGRATION_POINTS||oo,ao=g.HTML_INTEGRATION_POINTS||ao,me=g.CUSTOM_ELEMENT_HANDLING||{},g.CUSTOM_ELEMENT_HANDLING&&dh(g.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(me.tagNameCheck=g.CUSTOM_ELEMENT_HANDLING.tagNameCheck),g.CUSTOM_ELEMENT_HANDLING&&dh(g.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(me.attributeNameCheck=g.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),g.CUSTOM_ELEMENT_HANDLING&&typeof g.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements=="boolean"&&(me.allowCustomizedBuiltInElements=g.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),hr&&(Ba=!1),no&&(dr=!0),fr&&(_e=V({},Kf),Ae=Zo(null),fr.html===!0&&(V(_e,Yf),V(Ae,Jf)),fr.svg===!0&&(V(_e,Wl),V(Ae,Kl),V(Ae,$o)),fr.svgFilters===!0&&(V(_e,ql),V(Ae,Kl),V(Ae,$o)),fr.mathMl===!0&&(V(_e,Yl),V(Ae,Xf),V(Ae,$o))),qe(g,"ADD_TAGS")||(Qt.tagCheck=null),qe(g,"ADD_ATTR")||(Qt.attributeCheck=null),g.ADD_TAGS&&(typeof g.ADD_TAGS=="function"?Qt.tagCheck=g.ADD_TAGS:(_e===nh&&(_e=bt(_e)),V(_e,g.ADD_TAGS,be))),g.ADD_ATTR&&(typeof g.ADD_ATTR=="function"?Qt.attributeCheck=g.ADD_ATTR:(Ae===rh&&(Ae=bt(Ae)),V(Ae,g.ADD_ATTR,be))),g.ADD_URI_SAFE_ATTR&&V(Ja,g.ADD_URI_SAFE_ATTR,be),g.FORBID_CONTENTS&&(gt===Ka&&(gt=bt(gt)),V(gt,g.FORBID_CONTENTS,be)),g.ADD_FORBID_CONTENTS&&(gt===Ka&&(gt=bt(gt)),V(gt,g.ADD_FORBID_CONTENTS,be)),Ya&&(_e["#text"]=!0),En&&V(_e,["html","head","body"]),_e.table&&(V(_e,["tbody"]),delete vi.tbody),g.TRUSTED_TYPES_POLICY){if(typeof g.TRUSTED_TYPES_POLICY.createHTML!="function")throw Ci('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof g.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw Ci('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');M=g.TRUSTED_TYPES_POLICY,Z=M.createHTML("")}else M===void 0&&(M=IO(y,i)),M!==null&&typeof Z=="string"&&(Z=M.createHTML(""));Ne&&Ne(g),gr=g}},fh=V({},[...Wl,...ql,...bO]),ph=V({},[...Yl,...wO]),Iv=function(g){let T=le(g);(!T||!T.tagName)&&(T={namespaceURI:pr,tagName:"template"});const R=Ho(g.tagName),ie=Ho(T.tagName);return Qa[g.namespaceURI]?g.namespaceURI===so?T.namespaceURI===Ct?R==="svg":T.namespaceURI===io?R==="svg"&&(ie==="annotation-xml"||oo[ie]):!!fh[R]:g.namespaceURI===io?T.namespaceURI===Ct?R==="math":T.namespaceURI===so?R==="math"&&ao[ie]:!!ph[R]:g.namespaceURI===Ct?T.namespaceURI===so&&!ao[ie]||T.namespaceURI===io&&!oo[ie]?!1:!ph[R]&&(Av[R]||!fh[R]):!!(wi==="application/xhtml+xml"&&Qa[g.namespaceURI]):!1},mt=function(g){xi(e.removed,{element:g});try{le(g).removeChild(g)}catch{I(g)}},$n=function(g,T){try{xi(e.removed,{attribute:T.getAttributeNode(g),from:T})}catch{xi(e.removed,{attribute:null,from:T})}if(T.removeAttribute(g),g==="is")if(dr||no)try{mt(T)}catch{}else try{T.setAttribute(g,"")}catch{}},gh=function(g){let T=null,R=null;if(qa)g="<remove></remove>"+g;else{const ye=Bl(g,/^[\r\n\t ]+/);R=ye&&ye[0]}wi==="application/xhtml+xml"&&pr===Ct&&(g='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+g+"</body></html>");const ie=M?M.createHTML(g):g;if(pr===Ct)try{T=new v().parseFromString(ie,wi)}catch{}if(!T||!T.documentElement){T=U.createDocument(pr,"template",null);try{T.documentElement.innerHTML=Xa?Z:ie}catch{}}const Re=T.body||T.documentElement;return g&&R&&Re.insertBefore(t.createTextNode(R),Re.childNodes[0]||null),pr===Ct?yi.call(T,En?"html":"body")[0]:En?T.documentElement:Re},mh=function(g){return ge.call(g.ownerDocument||g,g,u.SHOW_ELEMENT|u.SHOW_COMMENT|u.SHOW_TEXT|u.SHOW_PROCESSING_INSTRUCTION|u.SHOW_CDATA_SECTION,null)},tl=function(g){return g instanceof f&&(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")},yh=function(g){return typeof a=="function"&&g instanceof a};function It(L,g,T){Eo(L,R=>{R.call(e,g,T,gr)})}const vh=function(g){let T=null;if(It($e.beforeSanitizeElements,g,null),tl(g))return mt(g),!0;const R=be(g.nodeName);if(It($e.uponSanitizeElement,g,{tagName:R,allowedTags:_e}),to&&g.hasChildNodes()&&!yh(g.firstElementChild)&&De(/<[/\w!]/g,g.innerHTML)&&De(/<[/\w!]/g,g.textContent)||g.nodeType===Pi.progressingInstruction||to&&g.nodeType===Pi.comment&&De(/<[/\w]/g,g.data))return mt(g),!0;if(!(Qt.tagCheck instanceof Function&&Qt.tagCheck(R))&&(!_e[R]||vi[R])){if(!vi[R]&&wh(R)&&(me.tagNameCheck instanceof RegExp&&De(me.tagNameCheck,R)||me.tagNameCheck instanceof Function&&me.tagNameCheck(R)))return!1;if(Ya&&!gt[R]){const ie=le(g)||g.parentNode,Re=P(g)||g.childNodes;if(Re&&ie){const ye=Re.length;for(let Fe=ye-1;Fe>=0;--Fe){const Pt=k(Re[Fe],!0);Pt.__removalCount=(g.__removalCount||0)+1,ie.insertBefore(Pt,G(g))}}}return mt(g),!0}return g instanceof l&&!Iv(g)||(R==="noscript"||R==="noembed"||R==="noframes")&&De(/<\/no(script|embed|frames)/i,g.innerHTML)?(mt(g),!0):(hr&&g.nodeType===Pi.text&&(T=g.textContent,Eo([kn,pt,Xt],ie=>{T=Ti(T,ie," ")}),g.textContent!==T&&(xi(e.removed,{element:g.cloneNode()}),g.textContent=T)),It($e.afterSanitizeElements,g,null),!1)},bh=function(g,T,R){if(eo[T]||ah&&(T==="id"||T==="name")&&(R in t||R in Cv))return!1;if(!(Ba&&!eo[T]&&De(Ga,T))){if(!(ih&&De(Qs,T))){if(!(Qt.attributeCheck instanceof Function&&Qt.attributeCheck(T,g))){if(!Ae[T]||eo[T]){if(!(wh(g)&&(me.tagNameCheck instanceof RegExp&&De(me.tagNameCheck,g)||me.tagNameCheck instanceof Function&&me.tagNameCheck(g))&&(me.attributeNameCheck instanceof RegExp&&De(me.attributeNameCheck,T)||me.attributeNameCheck instanceof Function&&me.attributeNameCheck(T,g))||T==="is"&&me.allowCustomizedBuiltInElements&&(me.tagNameCheck instanceof RegExp&&De(me.tagNameCheck,R)||me.tagNameCheck instanceof Function&&me.tagNameCheck(R))))return!1}else if(!Ja[T]){if(!De(th,Ti(R,eh,""))){if(!((T==="src"||T==="xlink:href"||T==="href")&&g!=="script"&&gO(R,"data:")===0&&ch[g])){if(!(sh&&!De(Sv,Ti(R,eh,"")))){if(R)return!1}}}}}}}return!0},wh=function(g){return g!=="annotation-xml"&&Bl(g,kv)},_h=function(g){It($e.beforeSanitizeAttributes,g,null);const{attributes:T}=g;if(!T||tl(g))return;const R={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:Ae,forceKeepAttr:void 0};let ie=T.length;for(;ie--;){const Re=T[ie],{name:ye,namespaceURI:Fe,value:Pt}=Re,mr=be(ye),nl=Pt;let xe=ye==="value"?nl:mO(nl);if(R.attrName=mr,R.attrValue=xe,R.keepAttr=!0,R.forceKeepAttr=void 0,It($e.uponSanitizeAttribute,g,R),xe=R.attrValue,lh&&(mr==="id"||mr==="name")&&($n(ye,g),xe=Ev+xe),to&&De(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,xe)){$n(ye,g);continue}if(mr==="attributename"&&Bl(xe,"href")){$n(ye,g);continue}if(R.forceKeepAttr)continue;if(!R.keepAttr){$n(ye,g);continue}if(!oh&&De(/\/>/i,xe)){$n(ye,g);continue}hr&&Eo([kn,pt,Xt],kh=>{xe=Ti(xe,kh," ")});const Sh=be(g.nodeName);if(!bh(Sh,mr,xe)){$n(ye,g);continue}if(M&&typeof y=="object"&&typeof y.getAttributeType=="function"&&!Fe)switch(y.getAttributeType(Sh,mr)){case"TrustedHTML":{xe=M.createHTML(xe);break}case"TrustedScriptURL":{xe=M.createScriptURL(xe);break}}if(xe!==nl)try{Fe?g.setAttributeNS(Fe,ye,xe):g.setAttribute(ye,xe),tl(g)?mt(g):qf(e.removed)}catch{$n(ye,g)}}It($e.afterSanitizeAttributes,g,null)},Pv=function L(g){let T=null;const R=mh(g);for(It($e.beforeSanitizeShadowDOM,g,null);T=R.nextNode();)It($e.uponSanitizeShadowNode,T,null),vh(T),_h(T),T.content instanceof s&&L(T.content);It($e.afterSanitizeShadowDOM,g,null)};return e.sanitize=function(L){let g=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},T=null,R=null,ie=null,Re=null;if(Xa=!L,Xa&&(L="<!-->"),typeof L!="string"&&!yh(L))if(typeof L.toString=="function"){if(L=L.toString(),typeof L!="string")throw Ci("dirty is not a string, aborting")}else throw Ci("toString is not a function");if(!e.isSupported)return L;if(Wa||el(g),e.removed=[],typeof L=="string"&&(bi=!1),bi){if(L.nodeName){const Pt=be(L.nodeName);if(!_e[Pt]||vi[Pt])throw Ci("root node is forbidden and cannot be sanitized in-place")}}else if(L instanceof a)T=gh("<!---->"),R=T.ownerDocument.importNode(L,!0),R.nodeType===Pi.element&&R.nodeName==="BODY"||R.nodeName==="HTML"?T=R:T.appendChild(R);else{if(!dr&&!hr&&!En&&L.indexOf("<")===-1)return M&&ro?M.createHTML(L):L;if(T=gh(L),!T)return dr?null:ro?Z:""}T&&qa&&mt(T.firstChild);const ye=mh(bi?L:T);for(;ie=ye.nextNode();)vh(ie),_h(ie),ie.content instanceof s&&Pv(ie.content);if(bi)return L;if(dr){if(no)for(Re=ce.call(T.ownerDocument);T.firstChild;)Re.appendChild(T.firstChild);else Re=T;return(Ae.shadowroot||Ae.shadowrootmode)&&(Re=Xs.call(r,Re,!0)),Re}let Fe=En?T.outerHTML:T.innerHTML;return En&&_e["!doctype"]&&T.ownerDocument&&T.ownerDocument.doctype&&T.ownerDocument.doctype.name&&De(iv,T.ownerDocument.doctype.name)&&(Fe="<!DOCTYPE "+T.ownerDocument.doctype.name+`>
333
+ `+Fe),hr&&Eo([kn,pt,Xt],Pt=>{Fe=Ti(Fe,Pt," ")}),M&&ro?M.createHTML(Fe):Fe},e.setConfig=function(){let L=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};el(L),Wa=!0},e.clearConfig=function(){gr=null,Wa=!1},e.isValidAttribute=function(L,g,T){gr||el({});const R=be(L),ie=be(g);return bh(R,ie,T)},e.addHook=function(L,g){typeof g=="function"&&xi($e[L],g)},e.removeHook=function(L,g){if(g!==void 0){const T=fO($e[L],g);return T===-1?void 0:pO($e[L],T,1)[0]}return qf($e[L])},e.removeHooks=function(L){$e[L]=[]},e.removeAllHooks=function(){$e=ep()},e}var ov=sv();function Vu(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var ur=Vu();function av(n){ur=n}var Dn={exec:()=>null};function W(n,e=""){let t=typeof n=="string"?n:n.source,r={replace:(i,s)=>{let o=typeof s=="string"?s:s.source;return o=o.replace(Le.caret,"$1"),t=t.replace(i,o),r},getRegex:()=>new RegExp(t,e)};return r}var PO=(()=>{try{return!!new RegExp("(?<=1)(?<!1)")}catch{return!1}})(),Le={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:n=>new RegExp(`^( {0,3}${n})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:n=>new RegExp(`^ {0,${Math.min(3,n-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),hrRegex:n=>new RegExp(`^ {0,${Math.min(3,n-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),fencesBeginRegex:n=>new RegExp(`^ {0,${Math.min(3,n-1)}}(?:\`\`\`|~~~)`),headingBeginRegex:n=>new RegExp(`^ {0,${Math.min(3,n-1)}}#`),htmlBeginRegex:n=>new RegExp(`^ {0,${Math.min(3,n-1)}}<(?:[a-z].*>|!--)`,"i"),blockquoteBeginRegex:n=>new RegExp(`^ {0,${Math.min(3,n-1)}}>`)},RO=/^(?:[ \t]*(?:\n|$))+/,DO=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,OO=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,Js=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,zO=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,ju=/ {0,3}(?:[*+-]|\d{1,9}[.)])/,lv=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,cv=W(lv).replace(/bull/g,ju).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(),LO=W(lv).replace(/bull/g,ju).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(),Gu=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,MO=/^[^\n]+/,Bu=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,NO=W(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",Bu).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),UO=W(/^(bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,ju).getRegex(),Ha="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",Wu=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,FO=W("^ {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",Wu).replace("tag",Ha).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),uv=W(Gu).replace("hr",Js).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",Ha).getRegex(),ZO=W(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",uv).getRegex(),qu={blockquote:ZO,code:DO,def:NO,fences:OO,heading:zO,hr:Js,html:FO,lheading:cv,list:UO,newline:RO,paragraph:uv,table:Dn,text:MO},tp=W("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",Js).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",Ha).getRegex(),HO={...qu,lheading:LO,table:tp,paragraph:W(Gu).replace("hr",Js).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",tp).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",Ha).getRegex()},VO={...qu,html:W(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",Wu).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:Dn,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:W(Gu).replace("hr",Js).replace("heading",` *#{1,6} *[^
334
+ ]`).replace("lheading",cv).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},jO=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,GO=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,hv=/^( {2,}|\\)\n(?!\s*$)/,BO=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,mi=/[\p{P}\p{S}]/u,Va=/[\s\p{P}\p{S}]/u,Yu=/[^\s\p{P}\p{S}]/u,WO=W(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,Va).getRegex(),dv=/(?!~)[\p{P}\p{S}]/u,qO=/(?!~)[\s\p{P}\p{S}]/u,YO=/(?:[^\s\p{P}\p{S}]|~)/u,KO=W(/link|precode-code|html/,"g").replace("link",/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-",PO?"(?<!`)()":"(^^|[^`])").replace("code",/(?<b>`+)[^`]+\k<b>(?!`)/).replace("html",/<(?! )[^<>]*?>/).getRegex(),fv=/^(?:\*+(?:((?!\*)punct)|([^\s*]))?)|^_+(?:((?!_)punct)|([^\s_]))?/,JO=W(fv,"u").replace(/punct/g,mi).getRegex(),XO=W(fv,"u").replace(/punct/g,dv).getRegex(),pv="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",QO=W(pv,"gu").replace(/notPunctSpace/g,Yu).replace(/punctSpace/g,Va).replace(/punct/g,mi).getRegex(),ez=W(pv,"gu").replace(/notPunctSpace/g,YO).replace(/punctSpace/g,qO).replace(/punct/g,dv).getRegex(),tz=W("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,Yu).replace(/punctSpace/g,Va).replace(/punct/g,mi).getRegex(),nz=W(/^~~?(?:((?!~)punct)|[^\s~])/,"u").replace(/punct/g,mi).getRegex(),rz="^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)",iz=W(rz,"gu").replace(/notPunctSpace/g,Yu).replace(/punctSpace/g,Va).replace(/punct/g,mi).getRegex(),sz=W(/\\(punct)/,"gu").replace(/punct/g,mi).getRegex(),oz=W(/^<(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(),az=W(Wu).replace("(?:-->|$)","-->").getRegex(),lz=W("^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",az).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),ia=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\])|[^\[\]\\`])*?/,cz=W(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?\s*\)/).replace("label",ia).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),gv=W(/^!?\[(label)\]\[(ref)\]/).replace("label",ia).replace("ref",Bu).getRegex(),mv=W(/^!?\[(ref)\](?:\[\])?/).replace("ref",Bu).getRegex(),uz=W("reflink|nolink(?!\\()","g").replace("reflink",gv).replace("nolink",mv).getRegex(),np=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,Ku={_backpedal:Dn,anyPunctuation:sz,autolink:oz,blockSkip:KO,br:hv,code:GO,del:Dn,delLDelim:Dn,delRDelim:Dn,emStrongLDelim:JO,emStrongRDelimAst:QO,emStrongRDelimUnd:tz,escape:jO,link:cz,nolink:mv,punctuation:WO,reflink:gv,reflinkSearch:uz,tag:lz,text:BO,url:Dn},hz={...Ku,link:W(/^!?\[(label)\]\((.*?)\)/).replace("label",ia).getRegex(),reflink:W(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",ia).getRegex()},jc={...Ku,emStrongRDelimAst:ez,emStrongLDelim:XO,delLDelim:nz,delRDelim:iz,url:W(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol",np).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:W(/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace("protocol",np).getRegex()},dz={...jc,br:W(hv).replace("{2,}","*").getRegex(),text:W(jc.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},Ao={normal:qu,gfm:HO,pedantic:VO},Ri={normal:Ku,gfm:jc,breaks:dz,pedantic:hz},fz={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},rp=n=>fz[n];function wt(n,e){if(e){if(Le.escapeTest.test(n))return n.replace(Le.escapeReplace,rp)}else if(Le.escapeTestNoEncode.test(n))return n.replace(Le.escapeReplaceNoEncode,rp);return n}function ip(n){try{n=encodeURI(n).replace(Le.percentDecode,"%")}catch{return null}return n}function sp(n,e){var s;let t=n.replace(Le.findPipe,(o,a,l)=>{let u=!1,d=a;for(;--d>=0&&l[d]==="\\";)u=!u;return u?"|":" |"}),r=t.split(Le.splitPipe),i=0;if(r[0].trim()||r.shift(),r.length>0&&!((s=r.at(-1))!=null&&s.trim())&&r.pop(),e)if(r.length>e)r.splice(e);else for(;r.length<e;)r.push("");for(;i<r.length;i++)r[i]=r[i].trim().replace(Le.slashPipe,"|");return r}function Di(n,e,t){let r=n.length;if(r===0)return"";let i=0;for(;i<r&&n.charAt(r-i-1)===e;)i++;return n.slice(0,r-i)}function pz(n,e){if(n.indexOf(e[1])===-1)return-1;let t=0;for(let r=0;r<n.length;r++)if(n[r]==="\\")r++;else if(n[r]===e[0])t++;else if(n[r]===e[1]&&(t--,t<0))return r;return t>0?-2:-1}function gz(n,e=0){let t=e,r="";for(let i of n)if(i===" "){let s=4-t%4;r+=" ".repeat(s),t+=s}else r+=i,t++;return r}function op(n,e,t,r,i){let s=e.href,o=e.title||null,a=n[1].replace(i.other.outputLinkReplace,"$1");r.state.inLink=!0;let l={type:n[0].charAt(0)==="!"?"image":"link",raw:t,href:s,title:o,text:a,tokens:r.inlineTokens(a)};return r.state.inLink=!1,l}function mz(n,e,t){let r=n.match(t.other.indentCodeCompensation);if(r===null)return e;let i=r[1];return e.split(`
335
335
  `).map(s=>{let o=s.match(t.other.beginningSpace);if(o===null)return s;let[a]=o;return a.length>=i.length?s.slice(i.length):s}).join(`
336
336
  `)}var sa=class{constructor(n){b(this,"options");b(this,"rules");b(this,"lexer");this.options=n||ur}space(n){let e=this.rules.block.newline.exec(n);if(e&&e[0].length>0)return{type:"space",raw:e[0]}}code(n){let e=this.rules.block.code.exec(n);if(e){let t=e[0].replace(this.rules.other.codeRemoveIndent,"");return{type:"code",raw:e[0],codeBlockStyle:"indented",text:this.options.pedantic?t:Di(t,`
337
- `)}}}fences(n){let e=this.rules.block.fences.exec(n);if(e){let t=e[0],r=wz(t,e[3]||"",this.rules);return{type:"code",raw:t,lang:e[2]?e[2].trim().replace(this.rules.inline.anyPunctuation,"$1"):e[2],text:r}}}heading(n){let e=this.rules.block.heading.exec(n);if(e){let t=e[2].trim();if(this.rules.other.endingHash.test(t)){let r=Di(t,"#");(this.options.pedantic||!r||this.rules.other.endingSpaceChar.test(r))&&(t=r.trim())}return{type:"heading",raw:e[0],depth:e[1].length,text:t,tokens:this.lexer.inline(t)}}}hr(n){let e=this.rules.block.hr.exec(n);if(e)return{type:"hr",raw:Di(e[0],`
337
+ `)}}}fences(n){let e=this.rules.block.fences.exec(n);if(e){let t=e[0],r=mz(t,e[3]||"",this.rules);return{type:"code",raw:t,lang:e[2]?e[2].trim().replace(this.rules.inline.anyPunctuation,"$1"):e[2],text:r}}}heading(n){let e=this.rules.block.heading.exec(n);if(e){let t=e[2].trim();if(this.rules.other.endingHash.test(t)){let r=Di(t,"#");(this.options.pedantic||!r||this.rules.other.endingSpaceChar.test(r))&&(t=r.trim())}return{type:"heading",raw:e[0],depth:e[1].length,text:t,tokens:this.lexer.inline(t)}}}hr(n){let e=this.rules.block.hr.exec(n);if(e)return{type:"hr",raw:Di(e[0],`
338
338
  `)}}blockquote(n){let e=this.rules.block.blockquote.exec(n);if(e){let t=Di(e[0],`
339
339
  `).split(`
340
340
  `),r="",i="",s=[];for(;t.length>0;){let o=!1,a=[],l;for(l=0;l<t.length;l++)if(this.rules.other.blockquoteStart.test(t[l]))a.push(t[l]),o=!0;else if(!o)a.push(t[l]);else break;t=t.slice(l);let u=a.join(`
@@ -346,16 +346,16 @@ ${d}`:d;let f=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTo
346
346
  `),k=this.blockquote(A);s[s.length-1]=k,r=r.substring(0,r.length-y.raw.length)+k.raw,i=i.substring(0,i.length-y.text.length)+k.text;break}else if((v==null?void 0:v.type)==="list"){let y=v,A=y.raw+`
347
347
  `+t.join(`
348
348
  `),k=this.list(A);s[s.length-1]=k,r=r.substring(0,r.length-v.raw.length)+k.raw,i=i.substring(0,i.length-y.raw.length)+k.raw,t=A.substring(s.at(-1).raw.length).split(`
349
- `);continue}}return{type:"blockquote",raw:r,tokens:s,text:i}}}list(n){var t,r;let e=this.rules.block.list.exec(n);if(e){let i=e[1].trim(),s=i.length>1,o={type:"list",raw:"",ordered:s,start:s?+i.slice(0,-1):"",loose:!1,items:[]};i=s?`\\d{1,9}\\${i.slice(-1)}`:`\\${i}`,this.options.pedantic&&(i=s?i:"[*+-]");let a=this.rules.other.listItemRegex(i),l=!1;for(;n;){let d=!1,f="",v="";if(!(e=a.exec(n))||this.rules.block.hr.test(n))break;f=e[0],n=n.substring(f.length);let y=bz(e[2].split(`
349
+ `);continue}}return{type:"blockquote",raw:r,tokens:s,text:i}}}list(n){var t,r;let e=this.rules.block.list.exec(n);if(e){let i=e[1].trim(),s=i.length>1,o={type:"list",raw:"",ordered:s,start:s?+i.slice(0,-1):"",loose:!1,items:[]};i=s?`\\d{1,9}\\${i.slice(-1)}`:`\\${i}`,this.options.pedantic&&(i=s?i:"[*+-]");let a=this.rules.other.listItemRegex(i),l=!1;for(;n;){let d=!1,f="",v="";if(!(e=a.exec(n))||this.rules.block.hr.test(n))break;f=e[0],n=n.substring(f.length);let y=gz(e[2].split(`
350
350
  `,1)[0],e[1].length),A=n.split(`
351
351
  `,1)[0],k=!y.trim(),I=0;if(this.options.pedantic?(I=2,v=y.trimStart()):k?I=e[1].length+1:(I=y.search(this.rules.other.nonSpaceChar),I=I>4?1:I,v=y.slice(I),I+=e[1].length),k&&this.rules.other.blankLine.test(A)&&(f+=A+`
352
- `,n=n.substring(A.length+1),d=!0),!d){let B=this.rules.other.nextBulletRegex(I),P=this.rules.other.hrRegex(I),le=this.rules.other.fencesBeginRegex(I),M=this.rules.other.headingBeginRegex(I),Z=this.rules.other.htmlBeginRegex(I),U=this.rules.other.blockquoteBeginRegex(I);for(;n;){let ge=n.split(`
353
- `,1)[0],ce;if(A=ge,this.options.pedantic?(A=A.replace(this.rules.other.listReplaceNesting," "),ce=A):ce=A.replace(this.rules.other.tabCharGlobal," "),le.test(A)||M.test(A)||Z.test(A)||U.test(A)||B.test(A)||P.test(A))break;if(ce.search(this.rules.other.nonSpaceChar)>=I||!A.trim())v+=`
352
+ `,n=n.substring(A.length+1),d=!0),!d){let G=this.rules.other.nextBulletRegex(I),P=this.rules.other.hrRegex(I),le=this.rules.other.fencesBeginRegex(I),M=this.rules.other.headingBeginRegex(I),Z=this.rules.other.htmlBeginRegex(I),U=this.rules.other.blockquoteBeginRegex(I);for(;n;){let ge=n.split(`
353
+ `,1)[0],ce;if(A=ge,this.options.pedantic?(A=A.replace(this.rules.other.listReplaceNesting," "),ce=A):ce=A.replace(this.rules.other.tabCharGlobal," "),le.test(A)||M.test(A)||Z.test(A)||U.test(A)||G.test(A)||P.test(A))break;if(ce.search(this.rules.other.nonSpaceChar)>=I||!A.trim())v+=`
354
354
  `+ce.slice(I);else{if(k||y.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4||le.test(y)||M.test(y)||P.test(y))break;v+=`
355
355
  `+A}k=!A.trim(),f+=ge+`
356
356
  `,n=n.substring(ge.length+1),y=ce.slice(I)}}o.loose||(l?o.loose=!0:this.rules.other.doubleBlankLine.test(f)&&(l=!0)),o.items.push({type:"list_item",raw:f,task:!!this.options.gfm&&this.rules.other.listIsTask.test(v),loose:!1,text:v,tokens:[]}),o.raw+=f}let u=o.items.at(-1);if(u)u.raw=u.raw.trimEnd(),u.text=u.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,""),((t=d.tokens[0])==null?void 0:t.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 v=this.lexer.inlineQueue.length-1;v>=0;v--)if(this.rules.other.listIsTask.test(this.lexer.inlineQueue[v].src)){this.lexer.inlineQueue[v].src=this.lexer.inlineQueue[v].src.replace(this.rules.other.listReplaceTask,"");break}}let f=this.rules.other.listTaskCheckbox.exec(d.raw);if(f){let v={type:"checkbox",raw:f[0]+" ",checked:f[0]!=="[ ]"};d.checked=v.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=v.raw+d.tokens[0].raw,d.tokens[0].text=v.raw+d.tokens[0].text,d.tokens[0].tokens.unshift(v)):d.tokens.unshift({type:"paragraph",raw:v.raw,text:v.raw,tokens:[v]}):d.tokens.unshift(v)}}if(!o.loose){let f=d.tokens.filter(y=>y.type==="space"),v=f.length>0&&f.some(y=>this.rules.other.anyLine.test(y.raw));o.loose=v}}if(o.loose)for(let d of o.items){d.loose=!0;for(let f of d.tokens)f.type==="text"&&(f.type="paragraph")}return o}}html(n){let e=this.rules.block.html.exec(n);if(e)return{type:"html",block:!0,raw:e[0],pre:e[1]==="pre"||e[1]==="script"||e[1]==="style",text:e[0]}}def(n){let e=this.rules.block.def.exec(n);if(e){let t=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"):"",i=e[3]?e[3].substring(1,e[3].length-1).replace(this.rules.inline.anyPunctuation,"$1"):e[3];return{type:"def",tag:t,raw:e[0],href:r,title:i}}}table(n){var o;let e=this.rules.block.table.exec(n);if(!e||!this.rules.other.tableDelimiter.test(e[2]))return;let t=sp(e[1]),r=e[2].replace(this.rules.other.tableAlignChars,"").split("|"),i=(o=e[3])!=null&&o.trim()?e[3].replace(this.rules.other.tableRowBlankLine,"").split(`
357
357
  `):[],s={type:"table",raw:e[0],header:[],align:[],rows:[]};if(t.length===r.length){for(let a of r)this.rules.other.tableAlignRight.test(a)?s.align.push("right"):this.rules.other.tableAlignCenter.test(a)?s.align.push("center"):this.rules.other.tableAlignLeft.test(a)?s.align.push("left"):s.align.push(null);for(let a=0;a<t.length;a++)s.header.push({text:t[a],tokens:this.lexer.inline(t[a]),header:!0,align:s.align[a]});for(let a of i)s.rows.push(sp(a,s.header.length).map((l,u)=>({text:l,tokens:this.lexer.inline(l),header:!1,align:s.align[u]})));return s}}lheading(n){let e=this.rules.block.lheading.exec(n);if(e){let t=e[1].trim();return{type:"heading",raw:e[0],depth:e[2].charAt(0)==="="?1:2,text:t,tokens:this.lexer.inline(t)}}}paragraph(n){let e=this.rules.block.paragraph.exec(n);if(e){let t=e[1].charAt(e[1].length-1)===`
358
- `?e[1].slice(0,-1):e[1];return{type:"paragraph",raw:e[0],text:t,tokens:this.lexer.inline(t)}}}text(n){let e=this.rules.block.text.exec(n);if(e)return{type:"text",raw:e[0],text:e[0],tokens:this.lexer.inline(e[0])}}escape(n){let e=this.rules.inline.escape.exec(n);if(e)return{type:"escape",raw:e[0],text:e[1]}}tag(n){let e=this.rules.inline.tag.exec(n);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(n){let e=this.rules.inline.link.exec(n);if(e){let t=e[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(t)){if(!this.rules.other.endAngleBracket.test(t))return;let s=Di(t.slice(0,-1),"\\");if((t.length-s.length)%2===0)return}else{let s=vz(e[2],"()");if(s===-2)return;if(s>-1){let o=(e[0].indexOf("!")===0?5:4)+e[1].length+s;e[2]=e[2].substring(0,s),e[0]=e[0].substring(0,o).trim(),e[3]=""}}let r=e[2],i="";if(this.options.pedantic){let s=this.rules.other.pedanticHrefTitle.exec(r);s&&(r=s[1],i=s[3])}else i=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(t)?r=r.slice(1):r=r.slice(1,-1)),op(e,{href:r&&r.replace(this.rules.inline.anyPunctuation,"$1"),title:i&&i.replace(this.rules.inline.anyPunctuation,"$1")},e[0],this.lexer,this.rules)}}reflink(n,e){let t;if((t=this.rules.inline.reflink.exec(n))||(t=this.rules.inline.nolink.exec(n))){let r=(t[2]||t[1]).replace(this.rules.other.multipleSpaceGlobal," "),i=e[r.toLowerCase()];if(!i){let s=t[0].charAt(0);return{type:"text",raw:s,text:s}}return op(t,i,t[0],this.lexer,this.rules)}}emStrong(n,e,t=""){let r=this.rules.inline.emStrongLDelim.exec(n);if(!(!r||!r[1]&&!r[2]&&!r[3]&&!r[4]||r[4]&&t.match(this.rules.other.unicodeAlphaNumeric))&&(!(r[1]||r[3])||!t||this.rules.inline.punctuation.exec(t))){let i=[...r[0]].length-1,s,o,a=i,l=0,u=r[0][0]==="*"?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(u.lastIndex=0,e=e.slice(-1*n.length+i);(r=u.exec(e))!=null;){if(s=r[1]||r[2]||r[3]||r[4]||r[5]||r[6],!s)continue;if(o=[...s].length,r[3]||r[4]){a+=o;continue}else if((r[5]||r[6])&&i%3&&!((i+o)%3)){l+=o;continue}if(a-=o,a>0)continue;o=Math.min(o,o+a+l);let d=[...r[0]][0].length,f=n.slice(0,i+r.index+d+o);if(Math.min(i,o)%2){let y=f.slice(1,-1);return{type:"em",raw:f,text:y,tokens:this.lexer.inlineTokens(y)}}let v=f.slice(2,-2);return{type:"strong",raw:f,text:v,tokens:this.lexer.inlineTokens(v)}}}}codespan(n){let e=this.rules.inline.code.exec(n);if(e){let t=e[2].replace(this.rules.other.newLineCharGlobal," "),r=this.rules.other.nonSpaceChar.test(t),i=this.rules.other.startingSpaceChar.test(t)&&this.rules.other.endingSpaceChar.test(t);return r&&i&&(t=t.substring(1,t.length-1)),{type:"codespan",raw:e[0],text:t}}}br(n){let e=this.rules.inline.br.exec(n);if(e)return{type:"br",raw:e[0]}}del(n,e,t=""){let r=this.rules.inline.delLDelim.exec(n);if(r&&(!r[1]||!t||this.rules.inline.punctuation.exec(t))){let i=[...r[0]].length-1,s,o,a=i,l=this.rules.inline.delRDelim;for(l.lastIndex=0,e=e.slice(-1*n.length+i);(r=l.exec(e))!=null;){if(s=r[1]||r[2]||r[3]||r[4]||r[5]||r[6],!s||(o=[...s].length,o!==i))continue;if(r[3]||r[4]){a+=o;continue}if(a-=o,a>0)continue;o=Math.min(o,o+a);let u=[...r[0]][0].length,d=n.slice(0,i+r.index+u+o),f=d.slice(i,-i);return{type:"del",raw:d,text:f,tokens:this.lexer.inlineTokens(f)}}}}autolink(n){let e=this.rules.inline.autolink.exec(n);if(e){let t,r;return e[2]==="@"?(t=e[1],r="mailto:"+t):(t=e[1],r=t),{type:"link",raw:e[0],text:t,href:r,tokens:[{type:"text",raw:t,text:t}]}}}url(n){var t;let e;if(e=this.rules.inline.url.exec(n)){let r,i;if(e[2]==="@")r=e[0],i="mailto:"+r;else{let s;do s=e[0],e[0]=((t=this.rules.inline._backpedal.exec(e[0]))==null?void 0:t[0])??"";while(s!==e[0]);r=e[0],e[1]==="www."?i="http://"+e[0]:i=e[0]}return{type:"link",raw:e[0],text:r,href:i,tokens:[{type:"text",raw:r,text:r}]}}}inlineText(n){let e=this.rules.inline.text.exec(n);if(e){let t=this.lexer.state.inRawBlock;return{type:"text",raw:e[0],text:e[0],escaped:t}}}},dt=class Vc{constructor(e){b(this,"tokens");b(this,"options");b(this,"state");b(this,"inlineQueue");b(this,"tokenizer");this.tokens=[],this.tokens.links=Object.create(null),this.options=e||ur,this.options.tokenizer=this.options.tokenizer||new sa,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 t={other:Le,block:Ao.normal,inline:Ri.normal};this.options.pedantic?(t.block=Ao.pedantic,t.inline=Ri.pedantic):this.options.gfm&&(t.block=Ao.gfm,this.options.breaks?t.inline=Ri.breaks:t.inline=Ri.gfm),this.tokenizer.rules=t}static get rules(){return{block:Ao,inline:Ri}}static lex(e,t){return new Vc(t).lex(e)}static lexInline(e,t){return new Vc(t).inlineTokens(e)}lex(e){e=e.replace(Le.carriageReturn,`
358
+ `?e[1].slice(0,-1):e[1];return{type:"paragraph",raw:e[0],text:t,tokens:this.lexer.inline(t)}}}text(n){let e=this.rules.block.text.exec(n);if(e)return{type:"text",raw:e[0],text:e[0],tokens:this.lexer.inline(e[0])}}escape(n){let e=this.rules.inline.escape.exec(n);if(e)return{type:"escape",raw:e[0],text:e[1]}}tag(n){let e=this.rules.inline.tag.exec(n);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(n){let e=this.rules.inline.link.exec(n);if(e){let t=e[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(t)){if(!this.rules.other.endAngleBracket.test(t))return;let s=Di(t.slice(0,-1),"\\");if((t.length-s.length)%2===0)return}else{let s=pz(e[2],"()");if(s===-2)return;if(s>-1){let o=(e[0].indexOf("!")===0?5:4)+e[1].length+s;e[2]=e[2].substring(0,s),e[0]=e[0].substring(0,o).trim(),e[3]=""}}let r=e[2],i="";if(this.options.pedantic){let s=this.rules.other.pedanticHrefTitle.exec(r);s&&(r=s[1],i=s[3])}else i=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(t)?r=r.slice(1):r=r.slice(1,-1)),op(e,{href:r&&r.replace(this.rules.inline.anyPunctuation,"$1"),title:i&&i.replace(this.rules.inline.anyPunctuation,"$1")},e[0],this.lexer,this.rules)}}reflink(n,e){let t;if((t=this.rules.inline.reflink.exec(n))||(t=this.rules.inline.nolink.exec(n))){let r=(t[2]||t[1]).replace(this.rules.other.multipleSpaceGlobal," "),i=e[r.toLowerCase()];if(!i){let s=t[0].charAt(0);return{type:"text",raw:s,text:s}}return op(t,i,t[0],this.lexer,this.rules)}}emStrong(n,e,t=""){let r=this.rules.inline.emStrongLDelim.exec(n);if(!(!r||!r[1]&&!r[2]&&!r[3]&&!r[4]||r[4]&&t.match(this.rules.other.unicodeAlphaNumeric))&&(!(r[1]||r[3])||!t||this.rules.inline.punctuation.exec(t))){let i=[...r[0]].length-1,s,o,a=i,l=0,u=r[0][0]==="*"?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(u.lastIndex=0,e=e.slice(-1*n.length+i);(r=u.exec(e))!=null;){if(s=r[1]||r[2]||r[3]||r[4]||r[5]||r[6],!s)continue;if(o=[...s].length,r[3]||r[4]){a+=o;continue}else if((r[5]||r[6])&&i%3&&!((i+o)%3)){l+=o;continue}if(a-=o,a>0)continue;o=Math.min(o,o+a+l);let d=[...r[0]][0].length,f=n.slice(0,i+r.index+d+o);if(Math.min(i,o)%2){let y=f.slice(1,-1);return{type:"em",raw:f,text:y,tokens:this.lexer.inlineTokens(y)}}let v=f.slice(2,-2);return{type:"strong",raw:f,text:v,tokens:this.lexer.inlineTokens(v)}}}}codespan(n){let e=this.rules.inline.code.exec(n);if(e){let t=e[2].replace(this.rules.other.newLineCharGlobal," "),r=this.rules.other.nonSpaceChar.test(t),i=this.rules.other.startingSpaceChar.test(t)&&this.rules.other.endingSpaceChar.test(t);return r&&i&&(t=t.substring(1,t.length-1)),{type:"codespan",raw:e[0],text:t}}}br(n){let e=this.rules.inline.br.exec(n);if(e)return{type:"br",raw:e[0]}}del(n,e,t=""){let r=this.rules.inline.delLDelim.exec(n);if(r&&(!r[1]||!t||this.rules.inline.punctuation.exec(t))){let i=[...r[0]].length-1,s,o,a=i,l=this.rules.inline.delRDelim;for(l.lastIndex=0,e=e.slice(-1*n.length+i);(r=l.exec(e))!=null;){if(s=r[1]||r[2]||r[3]||r[4]||r[5]||r[6],!s||(o=[...s].length,o!==i))continue;if(r[3]||r[4]){a+=o;continue}if(a-=o,a>0)continue;o=Math.min(o,o+a);let u=[...r[0]][0].length,d=n.slice(0,i+r.index+u+o),f=d.slice(i,-i);return{type:"del",raw:d,text:f,tokens:this.lexer.inlineTokens(f)}}}}autolink(n){let e=this.rules.inline.autolink.exec(n);if(e){let t,r;return e[2]==="@"?(t=e[1],r="mailto:"+t):(t=e[1],r=t),{type:"link",raw:e[0],text:t,href:r,tokens:[{type:"text",raw:t,text:t}]}}}url(n){var t;let e;if(e=this.rules.inline.url.exec(n)){let r,i;if(e[2]==="@")r=e[0],i="mailto:"+r;else{let s;do s=e[0],e[0]=((t=this.rules.inline._backpedal.exec(e[0]))==null?void 0:t[0])??"";while(s!==e[0]);r=e[0],e[1]==="www."?i="http://"+e[0]:i=e[0]}return{type:"link",raw:e[0],text:r,href:i,tokens:[{type:"text",raw:r,text:r}]}}}inlineText(n){let e=this.rules.inline.text.exec(n);if(e){let t=this.lexer.state.inRawBlock;return{type:"text",raw:e[0],text:e[0],escaped:t}}}},dt=class Gc{constructor(e){b(this,"tokens");b(this,"options");b(this,"state");b(this,"inlineQueue");b(this,"tokenizer");this.tokens=[],this.tokens.links=Object.create(null),this.options=e||ur,this.options.tokenizer=this.options.tokenizer||new sa,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 t={other:Le,block:Ao.normal,inline:Ri.normal};this.options.pedantic?(t.block=Ao.pedantic,t.inline=Ri.pedantic):this.options.gfm&&(t.block=Ao.gfm,this.options.breaks?t.inline=Ri.breaks:t.inline=Ri.gfm),this.tokenizer.rules=t}static get rules(){return{block:Ao,inline:Ri}}static lex(e,t){return new Gc(t).lex(e)}static lexInline(e,t){return new Gc(t).inlineTokens(e)}lex(e){e=e.replace(Le.carriageReturn,`
359
359
  `),this.blockTokens(e,this.tokens);for(let t=0;t<this.inlineQueue.length;t++){let r=this.inlineQueue[t];this.inlineTokens(r.src,r.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(e,t=[],r=!1){var i,s,o;for(this.tokenizer.lexer=this,this.options.pedantic&&(e=e.replace(Le.tabCharGlobal," ").replace(Le.spaceLine,""));e;){let a;if((s=(i=this.options.extensions)==null?void 0:i.block)!=null&&s.some(u=>(a=u.call({lexer:this},e,t))?(e=e.substring(a.raw.length),t.push(a),!0):!1))continue;if(a=this.tokenizer.space(e)){e=e.substring(a.raw.length);let u=t.at(-1);a.raw.length===1&&u!==void 0?u.raw+=`
360
360
  `:t.push(a);continue}if(a=this.tokenizer.code(e)){e=e.substring(a.raw.length);let u=t.at(-1);(u==null?void 0:u.type)==="paragraph"||(u==null?void 0:u.type)==="text"?(u.raw+=(u.raw.endsWith(`
361
361
  `)?"":`
@@ -369,7 +369,7 @@ ${d}`:d;let f=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTo
369
369
  `+a.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=u.text):t.push(a),r=l.length!==e.length,e=e.substring(a.raw.length);continue}if(a=this.tokenizer.text(e)){e=e.substring(a.raw.length);let u=t.at(-1);(u==null?void 0:u.type)==="text"?(u.raw+=(u.raw.endsWith(`
370
370
  `)?"":`
371
371
  `)+a.raw,u.text+=`
372
- `+a.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=u.text):t.push(a);continue}if(e){let u="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent){console.error(u);break}else throw new Error(u)}}return this.state.top=!0,t}inline(e,t=[]){return this.inlineQueue.push({src:e,tokens:t}),t}inlineTokens(e,t=[]){var l,u,d,f,v;this.tokenizer.lexer=this;let r=e,i=null;if(this.tokens.links){let y=Object.keys(this.tokens.links);if(y.length>0)for(;(i=this.tokenizer.rules.inline.reflinkSearch.exec(r))!=null;)y.includes(i[0].slice(i[0].lastIndexOf("[")+1,-1))&&(r=r.slice(0,i.index)+"["+"a".repeat(i[0].length-2)+"]"+r.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;(i=this.tokenizer.rules.inline.anyPunctuation.exec(r))!=null;)r=r.slice(0,i.index)+"++"+r.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);let s;for(;(i=this.tokenizer.rules.inline.blockSkip.exec(r))!=null;)s=i[2]?i[2].length:0,r=r.slice(0,i.index+s)+"["+"a".repeat(i[0].length-s-2)+"]"+r.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);r=((u=(l=this.options.hooks)==null?void 0:l.emStrongMask)==null?void 0:u.call({lexer:this},r))??r;let o=!1,a="";for(;e;){o||(a=""),o=!1;let y;if((f=(d=this.options.extensions)==null?void 0:d.inline)!=null&&f.some(k=>(y=k.call({lexer:this},e,t))?(e=e.substring(y.raw.length),t.push(y),!0):!1))continue;if(y=this.tokenizer.escape(e)){e=e.substring(y.raw.length),t.push(y);continue}if(y=this.tokenizer.tag(e)){e=e.substring(y.raw.length),t.push(y);continue}if(y=this.tokenizer.link(e)){e=e.substring(y.raw.length),t.push(y);continue}if(y=this.tokenizer.reflink(e,this.tokens.links)){e=e.substring(y.raw.length);let k=t.at(-1);y.type==="text"&&(k==null?void 0:k.type)==="text"?(k.raw+=y.raw,k.text+=y.text):t.push(y);continue}if(y=this.tokenizer.emStrong(e,r,a)){e=e.substring(y.raw.length),t.push(y);continue}if(y=this.tokenizer.codespan(e)){e=e.substring(y.raw.length),t.push(y);continue}if(y=this.tokenizer.br(e)){e=e.substring(y.raw.length),t.push(y);continue}if(y=this.tokenizer.del(e,r,a)){e=e.substring(y.raw.length),t.push(y);continue}if(y=this.tokenizer.autolink(e)){e=e.substring(y.raw.length),t.push(y);continue}if(!this.state.inLink&&(y=this.tokenizer.url(e))){e=e.substring(y.raw.length),t.push(y);continue}let A=e;if((v=this.options.extensions)!=null&&v.startInline){let k=1/0,I=e.slice(1),B;this.options.extensions.startInline.forEach(P=>{B=P.call({lexer:this},I),typeof B=="number"&&B>=0&&(k=Math.min(k,B))}),k<1/0&&k>=0&&(A=e.substring(0,k+1))}if(y=this.tokenizer.inlineText(A)){e=e.substring(y.raw.length),y.raw.slice(-1)!=="_"&&(a=y.raw.slice(-1)),o=!0;let k=t.at(-1);(k==null?void 0:k.type)==="text"?(k.raw+=y.raw,k.text+=y.text):t.push(y);continue}if(e){let k="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent){console.error(k);break}else throw new Error(k)}}return t}},oa=class{constructor(n){b(this,"options");b(this,"parser");this.options=n||ur}space(n){return""}code({text:n,lang:e,escaped:t}){var s;let r=(s=(e||"").match(Le.notSpaceStart))==null?void 0:s[0],i=n.replace(Le.endingNewline,"")+`
372
+ `+a.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=u.text):t.push(a);continue}if(e){let u="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent){console.error(u);break}else throw new Error(u)}}return this.state.top=!0,t}inline(e,t=[]){return this.inlineQueue.push({src:e,tokens:t}),t}inlineTokens(e,t=[]){var l,u,d,f,v;this.tokenizer.lexer=this;let r=e,i=null;if(this.tokens.links){let y=Object.keys(this.tokens.links);if(y.length>0)for(;(i=this.tokenizer.rules.inline.reflinkSearch.exec(r))!=null;)y.includes(i[0].slice(i[0].lastIndexOf("[")+1,-1))&&(r=r.slice(0,i.index)+"["+"a".repeat(i[0].length-2)+"]"+r.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;(i=this.tokenizer.rules.inline.anyPunctuation.exec(r))!=null;)r=r.slice(0,i.index)+"++"+r.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);let s;for(;(i=this.tokenizer.rules.inline.blockSkip.exec(r))!=null;)s=i[2]?i[2].length:0,r=r.slice(0,i.index+s)+"["+"a".repeat(i[0].length-s-2)+"]"+r.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);r=((u=(l=this.options.hooks)==null?void 0:l.emStrongMask)==null?void 0:u.call({lexer:this},r))??r;let o=!1,a="";for(;e;){o||(a=""),o=!1;let y;if((f=(d=this.options.extensions)==null?void 0:d.inline)!=null&&f.some(k=>(y=k.call({lexer:this},e,t))?(e=e.substring(y.raw.length),t.push(y),!0):!1))continue;if(y=this.tokenizer.escape(e)){e=e.substring(y.raw.length),t.push(y);continue}if(y=this.tokenizer.tag(e)){e=e.substring(y.raw.length),t.push(y);continue}if(y=this.tokenizer.link(e)){e=e.substring(y.raw.length),t.push(y);continue}if(y=this.tokenizer.reflink(e,this.tokens.links)){e=e.substring(y.raw.length);let k=t.at(-1);y.type==="text"&&(k==null?void 0:k.type)==="text"?(k.raw+=y.raw,k.text+=y.text):t.push(y);continue}if(y=this.tokenizer.emStrong(e,r,a)){e=e.substring(y.raw.length),t.push(y);continue}if(y=this.tokenizer.codespan(e)){e=e.substring(y.raw.length),t.push(y);continue}if(y=this.tokenizer.br(e)){e=e.substring(y.raw.length),t.push(y);continue}if(y=this.tokenizer.del(e,r,a)){e=e.substring(y.raw.length),t.push(y);continue}if(y=this.tokenizer.autolink(e)){e=e.substring(y.raw.length),t.push(y);continue}if(!this.state.inLink&&(y=this.tokenizer.url(e))){e=e.substring(y.raw.length),t.push(y);continue}let A=e;if((v=this.options.extensions)!=null&&v.startInline){let k=1/0,I=e.slice(1),G;this.options.extensions.startInline.forEach(P=>{G=P.call({lexer:this},I),typeof G=="number"&&G>=0&&(k=Math.min(k,G))}),k<1/0&&k>=0&&(A=e.substring(0,k+1))}if(y=this.tokenizer.inlineText(A)){e=e.substring(y.raw.length),y.raw.slice(-1)!=="_"&&(a=y.raw.slice(-1)),o=!0;let k=t.at(-1);(k==null?void 0:k.type)==="text"?(k.raw+=y.raw,k.text+=y.text):t.push(y);continue}if(e){let k="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent){console.error(k);break}else throw new Error(k)}}return t}},oa=class{constructor(n){b(this,"options");b(this,"parser");this.options=n||ur}space(n){return""}code({text:n,lang:e,escaped:t}){var s;let r=(s=(e||"").match(Le.notSpaceStart))==null?void 0:s[0],i=n.replace(Le.endingNewline,"")+`
373
373
  `;return r?'<pre><code class="language-'+wt(r)+'">'+(t?i:wt(i,!0))+`</code></pre>
374
374
  `:"<pre><code>"+(t?i:wt(i,!0))+`</code></pre>
375
375
  `}blockquote({tokens:n}){return`<blockquote>
@@ -387,10 +387,10 @@ ${this.parser.parse(n)}</blockquote>
387
387
  `}tablerow({text:n}){return`<tr>
388
388
  ${n}</tr>
389
389
  `}tablecell(n){let e=this.parser.parseInline(n.tokens),t=n.header?"th":"td";return(n.align?`<${t} align="${n.align}">`:`<${t}>`)+e+`</${t}>
390
- `}strong({tokens:n}){return`<strong>${this.parser.parseInline(n)}</strong>`}em({tokens:n}){return`<em>${this.parser.parseInline(n)}</em>`}codespan({text:n}){return`<code>${wt(n,!0)}</code>`}br(n){return"<br>"}del({tokens:n}){return`<del>${this.parser.parseInline(n)}</del>`}link({href:n,title:e,tokens:t}){let r=this.parser.parseInline(t),i=ip(n);if(i===null)return r;n=i;let s='<a href="'+n+'"';return e&&(s+=' title="'+wt(e)+'"'),s+=">"+r+"</a>",s}image({href:n,title:e,text:t,tokens:r}){r&&(t=this.parser.parseInline(r,this.parser.textRenderer));let i=ip(n);if(i===null)return wt(t);n=i;let s=`<img src="${n}" alt="${wt(t)}"`;return e&&(s+=` title="${wt(e)}"`),s+=">",s}text(n){return"tokens"in n&&n.tokens?this.parser.parseInline(n.tokens):"escaped"in n&&n.escaped?n.text:wt(n.text)}},Yu=class{strong({text:n}){return n}em({text:n}){return n}codespan({text:n}){return n}del({text:n}){return n}html({text:n}){return n}text({text:n}){return n}link({text:n}){return""+n}image({text:n}){return""+n}br(){return""}checkbox({raw:n}){return n}},ft=class jc{constructor(e){b(this,"options");b(this,"renderer");b(this,"textRenderer");this.options=e||ur,this.options.renderer=this.options.renderer||new oa,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new Yu}static parse(e,t){return new jc(t).parse(e)}static parseInline(e,t){return new jc(t).parseInline(e)}parse(e){var r,i;this.renderer.parser=this;let t="";for(let s=0;s<e.length;s++){let o=e[s];if((i=(r=this.options.extensions)==null?void 0:r.renderers)!=null&&i[o.type]){let l=o,u=this.options.extensions.renderers[l.type].call({parser:this},l);if(u!==!1||!["space","hr","heading","code","table","blockquote","list","html","def","paragraph","text"].includes(l.type)){t+=u||"";continue}}let a=o;switch(a.type){case"space":{t+=this.renderer.space(a);break}case"hr":{t+=this.renderer.hr(a);break}case"heading":{t+=this.renderer.heading(a);break}case"code":{t+=this.renderer.code(a);break}case"table":{t+=this.renderer.table(a);break}case"blockquote":{t+=this.renderer.blockquote(a);break}case"list":{t+=this.renderer.list(a);break}case"checkbox":{t+=this.renderer.checkbox(a);break}case"html":{t+=this.renderer.html(a);break}case"def":{t+=this.renderer.def(a);break}case"paragraph":{t+=this.renderer.paragraph(a);break}case"text":{t+=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 t}parseInline(e,t=this.renderer){var i,s;this.renderer.parser=this;let r="";for(let o=0;o<e.length;o++){let a=e[o];if((s=(i=this.options.extensions)==null?void 0:i.renderers)!=null&&s[a.type]){let u=this.options.extensions.renderers[a.type].call({parser:this},a);if(u!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(a.type)){r+=u||"";continue}}let l=a;switch(l.type){case"escape":{r+=t.text(l);break}case"html":{r+=t.html(l);break}case"link":{r+=t.link(l);break}case"image":{r+=t.image(l);break}case"checkbox":{r+=t.checkbox(l);break}case"strong":{r+=t.strong(l);break}case"em":{r+=t.em(l);break}case"codespan":{r+=t.codespan(l);break}case"br":{r+=t.br(l);break}case"del":{r+=t.del(l);break}case"text":{r+=t.text(l);break}default:{let u='Token with "'+l.type+'" type was not found.';if(this.options.silent)return console.error(u),"";throw new Error(u)}}}return r}},xo,Vi=(xo=class{constructor(n){b(this,"options");b(this,"block");this.options=n||ur}preprocess(n){return n}postprocess(n){return n}processAllTokens(n){return n}emStrongMask(n){return n}provideLexer(){return this.block?dt.lex:dt.lexInline}provideParser(){return this.block?ft.parse:ft.parseInline}},b(xo,"passThroughHooks",new Set(["preprocess","postprocess","processAllTokens","emStrongMask"])),b(xo,"passThroughHooksRespectAsync",new Set(["preprocess","postprocess","processAllTokens"])),xo),_z=class{constructor(...n){b(this,"defaults",Zu());b(this,"options",this.setOptions);b(this,"parse",this.parseMarkdown(!0));b(this,"parseInline",this.parseMarkdown(!1));b(this,"Parser",ft);b(this,"Renderer",oa);b(this,"TextRenderer",Yu);b(this,"Lexer",dt);b(this,"Tokenizer",sa);b(this,"Hooks",Vi);this.use(...n)}walkTokens(n,e){var r,i;let t=[];for(let s of n)switch(t=t.concat(e.call(this,s)),s.type){case"table":{let o=s;for(let a of o.header)t=t.concat(this.walkTokens(a.tokens,e));for(let a of o.rows)for(let l of a)t=t.concat(this.walkTokens(l.tokens,e));break}case"list":{let o=s;t=t.concat(this.walkTokens(o.items,e));break}default:{let o=s;(i=(r=this.defaults.extensions)==null?void 0:r.childTokens)!=null&&i[o.type]?this.defaults.extensions.childTokens[o.type].forEach(a=>{let l=o[a].flat(1/0);t=t.concat(this.walkTokens(l,e))}):o.tokens&&(t=t.concat(this.walkTokens(o.tokens,e)))}}return t}use(...n){let e=this.defaults.extensions||{renderers:{},childTokens:{}};return n.forEach(t=>{let r={...t};if(r.async=this.defaults.async||r.async||!1,t.extensions&&(t.extensions.forEach(i=>{if(!i.name)throw new Error("extension name required");if("renderer"in i){let s=e.renderers[i.name];s?e.renderers[i.name]=function(...o){let a=i.renderer.apply(this,o);return a===!1&&(a=s.apply(this,o)),a}:e.renderers[i.name]=i.renderer}if("tokenizer"in i){if(!i.level||i.level!=="block"&&i.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");let s=e[i.level];s?s.unshift(i.tokenizer):e[i.level]=[i.tokenizer],i.start&&(i.level==="block"?e.startBlock?e.startBlock.push(i.start):e.startBlock=[i.start]:i.level==="inline"&&(e.startInline?e.startInline.push(i.start):e.startInline=[i.start]))}"childTokens"in i&&i.childTokens&&(e.childTokens[i.name]=i.childTokens)}),r.extensions=e),t.renderer){let i=this.defaults.renderer||new oa(this.defaults);for(let s in t.renderer){if(!(s in i))throw new Error(`renderer '${s}' does not exist`);if(["options","parser"].includes(s))continue;let o=s,a=t.renderer[o],l=i[o];i[o]=(...u)=>{let d=a.apply(i,u);return d===!1&&(d=l.apply(i,u)),d||""}}r.renderer=i}if(t.tokenizer){let i=this.defaults.tokenizer||new sa(this.defaults);for(let s in t.tokenizer){if(!(s in i))throw new Error(`tokenizer '${s}' does not exist`);if(["options","rules","lexer"].includes(s))continue;let o=s,a=t.tokenizer[o],l=i[o];i[o]=(...u)=>{let d=a.apply(i,u);return d===!1&&(d=l.apply(i,u)),d}}r.tokenizer=i}if(t.hooks){let i=this.defaults.hooks||new Vi;for(let s in t.hooks){if(!(s in i))throw new Error(`hook '${s}' does not exist`);if(["options","block"].includes(s))continue;let o=s,a=t.hooks[o],l=i[o];Vi.passThroughHooks.has(s)?i[o]=u=>{if(this.defaults.async&&Vi.passThroughHooksRespectAsync.has(s))return(async()=>{let f=await a.call(i,u);return l.call(i,f)})();let d=a.call(i,u);return l.call(i,d)}:i[o]=(...u)=>{if(this.defaults.async)return(async()=>{let f=await a.apply(i,u);return f===!1&&(f=await l.apply(i,u)),f})();let d=a.apply(i,u);return d===!1&&(d=l.apply(i,u)),d}}r.hooks=i}if(t.walkTokens){let i=this.defaults.walkTokens,s=t.walkTokens;r.walkTokens=function(o){let a=[];return a.push(s.call(this,o)),i&&(a=a.concat(i.call(this,o))),a}}this.defaults={...this.defaults,...r}}),this}setOptions(n){return this.defaults={...this.defaults,...n},this}lexer(n,e){return dt.lex(n,e??this.defaults)}parser(n,e){return ft.parse(n,e??this.defaults)}parseMarkdown(n){return(e,t)=>{let r={...t},i={...this.defaults,...r},s=this.onError(!!i.silent,!!i.async);if(this.defaults.async===!0&&r.async===!1)return s(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 s(new Error("marked(): input parameter is undefined or null"));if(typeof e!="string")return s(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(e)+", string expected"));if(i.hooks&&(i.hooks.options=i,i.hooks.block=n),i.async)return(async()=>{let o=i.hooks?await i.hooks.preprocess(e):e,a=await(i.hooks?await i.hooks.provideLexer():n?dt.lex:dt.lexInline)(o,i),l=i.hooks?await i.hooks.processAllTokens(a):a;i.walkTokens&&await Promise.all(this.walkTokens(l,i.walkTokens));let u=await(i.hooks?await i.hooks.provideParser():n?ft.parse:ft.parseInline)(l,i);return i.hooks?await i.hooks.postprocess(u):u})().catch(s);try{i.hooks&&(e=i.hooks.preprocess(e));let o=(i.hooks?i.hooks.provideLexer():n?dt.lex:dt.lexInline)(e,i);i.hooks&&(o=i.hooks.processAllTokens(o)),i.walkTokens&&this.walkTokens(o,i.walkTokens);let a=(i.hooks?i.hooks.provideParser():n?ft.parse:ft.parseInline)(o,i);return i.hooks&&(a=i.hooks.postprocess(a)),a}catch(o){return s(o)}}}onError(n,e){return t=>{if(t.message+=`
391
- Please report this to https://github.com/markedjs/marked.`,n){let r="<p>An error occurred:</p><pre>"+wt(t.message+"",!0)+"</pre>";return e?Promise.resolve(r):r}if(e)return Promise.reject(t);throw t}}},sr=new _z;function K(n,e){return sr.parse(n,e)}K.options=K.setOptions=function(n){return sr.setOptions(n),K.defaults=sr.defaults,cv(K.defaults),K};K.getDefaults=Zu;K.defaults=ur;K.use=function(...n){return sr.use(...n),K.defaults=sr.defaults,cv(K.defaults),K};K.walkTokens=function(n,e){return sr.walkTokens(n,e)};K.parseInline=sr.parseInline;K.Parser=ft;K.parser=ft.parse;K.Renderer=oa;K.TextRenderer=Yu;K.Lexer=dt;K.lexer=dt.lex;K.Tokenizer=sa;K.Hooks=Vi;K.parse=K;K.options;K.setOptions;K.use;K.walkTokens;K.parseInline;ft.parse;dt.lex;lv.addHook("afterSanitizeAttributes",n=>{n.tagName==="A"&&(n.setAttribute("target","_blank"),n.setAttribute("rel","noopener noreferrer"))});function Sz(n){const e=K.parse(n,{async:!1});return lv.sanitize(e,{USE_PROFILES:{html:!0}})}const kz=8,ap=new WeakMap;function Ez(n){const e=ap.get(n);if(e&&e.text===n.text)return e.html;const t=Sz(n.text);return ap.set(n,{text:n.text,html:t}),t}function lp(n){for(let e=n.length-1;e>=0;e-=1){const t=n[e];if(t&&t.kind==="user")return t.id}return null}var jt,Qn,Ea,$a,zs,Bc;class bv extends ts{constructor(){super(...arguments);S(this,zs);b(this,"messages",[]);S(this,jt,!0);S(this,Qn,null);S(this,Ea,()=>{const t=c(this,Qn);if(!t)return;const i=t.scrollHeight-t.clientHeight-t.scrollTop<=kz;i!==c(this,jt)&&(E(this,jt,i),this.toggleAttribute("data-pinned",i))});S(this,$a,()=>{E(this,jt,!0),this.toggleAttribute("data-pinned",!0),m(this,zs,Bc).call(this,!0)})}changed(t){let r=!1;if(t.has("messages")){const i=t.get("messages")??[],s=lp(this.messages);r=s!==null&&s!==lp(i),r&&E(this,jt,!0)}Pe(this.template(),this),c(this,Qn)||E(this,Qn,this.querySelector(".history-scroll")),this.toggleAttribute("data-pinned",c(this,jt)),m(this,zs,Bc).call(this,r)}template(){const t=this.messages.filter(r=>r.kind==="user"||r.kind==="assistant");return F`
390
+ `}strong({tokens:n}){return`<strong>${this.parser.parseInline(n)}</strong>`}em({tokens:n}){return`<em>${this.parser.parseInline(n)}</em>`}codespan({text:n}){return`<code>${wt(n,!0)}</code>`}br(n){return"<br>"}del({tokens:n}){return`<del>${this.parser.parseInline(n)}</del>`}link({href:n,title:e,tokens:t}){let r=this.parser.parseInline(t),i=ip(n);if(i===null)return r;n=i;let s='<a href="'+n+'"';return e&&(s+=' title="'+wt(e)+'"'),s+=">"+r+"</a>",s}image({href:n,title:e,text:t,tokens:r}){r&&(t=this.parser.parseInline(r,this.parser.textRenderer));let i=ip(n);if(i===null)return wt(t);n=i;let s=`<img src="${n}" alt="${wt(t)}"`;return e&&(s+=` title="${wt(e)}"`),s+=">",s}text(n){return"tokens"in n&&n.tokens?this.parser.parseInline(n.tokens):"escaped"in n&&n.escaped?n.text:wt(n.text)}},Ju=class{strong({text:n}){return n}em({text:n}){return n}codespan({text:n}){return n}del({text:n}){return n}html({text:n}){return n}text({text:n}){return n}link({text:n}){return""+n}image({text:n}){return""+n}br(){return""}checkbox({raw:n}){return n}},ft=class Bc{constructor(e){b(this,"options");b(this,"renderer");b(this,"textRenderer");this.options=e||ur,this.options.renderer=this.options.renderer||new oa,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new Ju}static parse(e,t){return new Bc(t).parse(e)}static parseInline(e,t){return new Bc(t).parseInline(e)}parse(e){var r,i;this.renderer.parser=this;let t="";for(let s=0;s<e.length;s++){let o=e[s];if((i=(r=this.options.extensions)==null?void 0:r.renderers)!=null&&i[o.type]){let l=o,u=this.options.extensions.renderers[l.type].call({parser:this},l);if(u!==!1||!["space","hr","heading","code","table","blockquote","list","html","def","paragraph","text"].includes(l.type)){t+=u||"";continue}}let a=o;switch(a.type){case"space":{t+=this.renderer.space(a);break}case"hr":{t+=this.renderer.hr(a);break}case"heading":{t+=this.renderer.heading(a);break}case"code":{t+=this.renderer.code(a);break}case"table":{t+=this.renderer.table(a);break}case"blockquote":{t+=this.renderer.blockquote(a);break}case"list":{t+=this.renderer.list(a);break}case"checkbox":{t+=this.renderer.checkbox(a);break}case"html":{t+=this.renderer.html(a);break}case"def":{t+=this.renderer.def(a);break}case"paragraph":{t+=this.renderer.paragraph(a);break}case"text":{t+=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 t}parseInline(e,t=this.renderer){var i,s;this.renderer.parser=this;let r="";for(let o=0;o<e.length;o++){let a=e[o];if((s=(i=this.options.extensions)==null?void 0:i.renderers)!=null&&s[a.type]){let u=this.options.extensions.renderers[a.type].call({parser:this},a);if(u!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(a.type)){r+=u||"";continue}}let l=a;switch(l.type){case"escape":{r+=t.text(l);break}case"html":{r+=t.html(l);break}case"link":{r+=t.link(l);break}case"image":{r+=t.image(l);break}case"checkbox":{r+=t.checkbox(l);break}case"strong":{r+=t.strong(l);break}case"em":{r+=t.em(l);break}case"codespan":{r+=t.codespan(l);break}case"br":{r+=t.br(l);break}case"del":{r+=t.del(l);break}case"text":{r+=t.text(l);break}default:{let u='Token with "'+l.type+'" type was not found.';if(this.options.silent)return console.error(u),"";throw new Error(u)}}}return r}},xo,Vi=(xo=class{constructor(n){b(this,"options");b(this,"block");this.options=n||ur}preprocess(n){return n}postprocess(n){return n}processAllTokens(n){return n}emStrongMask(n){return n}provideLexer(){return this.block?dt.lex:dt.lexInline}provideParser(){return this.block?ft.parse:ft.parseInline}},b(xo,"passThroughHooks",new Set(["preprocess","postprocess","processAllTokens","emStrongMask"])),b(xo,"passThroughHooksRespectAsync",new Set(["preprocess","postprocess","processAllTokens"])),xo),yz=class{constructor(...n){b(this,"defaults",Vu());b(this,"options",this.setOptions);b(this,"parse",this.parseMarkdown(!0));b(this,"parseInline",this.parseMarkdown(!1));b(this,"Parser",ft);b(this,"Renderer",oa);b(this,"TextRenderer",Ju);b(this,"Lexer",dt);b(this,"Tokenizer",sa);b(this,"Hooks",Vi);this.use(...n)}walkTokens(n,e){var r,i;let t=[];for(let s of n)switch(t=t.concat(e.call(this,s)),s.type){case"table":{let o=s;for(let a of o.header)t=t.concat(this.walkTokens(a.tokens,e));for(let a of o.rows)for(let l of a)t=t.concat(this.walkTokens(l.tokens,e));break}case"list":{let o=s;t=t.concat(this.walkTokens(o.items,e));break}default:{let o=s;(i=(r=this.defaults.extensions)==null?void 0:r.childTokens)!=null&&i[o.type]?this.defaults.extensions.childTokens[o.type].forEach(a=>{let l=o[a].flat(1/0);t=t.concat(this.walkTokens(l,e))}):o.tokens&&(t=t.concat(this.walkTokens(o.tokens,e)))}}return t}use(...n){let e=this.defaults.extensions||{renderers:{},childTokens:{}};return n.forEach(t=>{let r={...t};if(r.async=this.defaults.async||r.async||!1,t.extensions&&(t.extensions.forEach(i=>{if(!i.name)throw new Error("extension name required");if("renderer"in i){let s=e.renderers[i.name];s?e.renderers[i.name]=function(...o){let a=i.renderer.apply(this,o);return a===!1&&(a=s.apply(this,o)),a}:e.renderers[i.name]=i.renderer}if("tokenizer"in i){if(!i.level||i.level!=="block"&&i.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");let s=e[i.level];s?s.unshift(i.tokenizer):e[i.level]=[i.tokenizer],i.start&&(i.level==="block"?e.startBlock?e.startBlock.push(i.start):e.startBlock=[i.start]:i.level==="inline"&&(e.startInline?e.startInline.push(i.start):e.startInline=[i.start]))}"childTokens"in i&&i.childTokens&&(e.childTokens[i.name]=i.childTokens)}),r.extensions=e),t.renderer){let i=this.defaults.renderer||new oa(this.defaults);for(let s in t.renderer){if(!(s in i))throw new Error(`renderer '${s}' does not exist`);if(["options","parser"].includes(s))continue;let o=s,a=t.renderer[o],l=i[o];i[o]=(...u)=>{let d=a.apply(i,u);return d===!1&&(d=l.apply(i,u)),d||""}}r.renderer=i}if(t.tokenizer){let i=this.defaults.tokenizer||new sa(this.defaults);for(let s in t.tokenizer){if(!(s in i))throw new Error(`tokenizer '${s}' does not exist`);if(["options","rules","lexer"].includes(s))continue;let o=s,a=t.tokenizer[o],l=i[o];i[o]=(...u)=>{let d=a.apply(i,u);return d===!1&&(d=l.apply(i,u)),d}}r.tokenizer=i}if(t.hooks){let i=this.defaults.hooks||new Vi;for(let s in t.hooks){if(!(s in i))throw new Error(`hook '${s}' does not exist`);if(["options","block"].includes(s))continue;let o=s,a=t.hooks[o],l=i[o];Vi.passThroughHooks.has(s)?i[o]=u=>{if(this.defaults.async&&Vi.passThroughHooksRespectAsync.has(s))return(async()=>{let f=await a.call(i,u);return l.call(i,f)})();let d=a.call(i,u);return l.call(i,d)}:i[o]=(...u)=>{if(this.defaults.async)return(async()=>{let f=await a.apply(i,u);return f===!1&&(f=await l.apply(i,u)),f})();let d=a.apply(i,u);return d===!1&&(d=l.apply(i,u)),d}}r.hooks=i}if(t.walkTokens){let i=this.defaults.walkTokens,s=t.walkTokens;r.walkTokens=function(o){let a=[];return a.push(s.call(this,o)),i&&(a=a.concat(i.call(this,o))),a}}this.defaults={...this.defaults,...r}}),this}setOptions(n){return this.defaults={...this.defaults,...n},this}lexer(n,e){return dt.lex(n,e??this.defaults)}parser(n,e){return ft.parse(n,e??this.defaults)}parseMarkdown(n){return(e,t)=>{let r={...t},i={...this.defaults,...r},s=this.onError(!!i.silent,!!i.async);if(this.defaults.async===!0&&r.async===!1)return s(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 s(new Error("marked(): input parameter is undefined or null"));if(typeof e!="string")return s(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(e)+", string expected"));if(i.hooks&&(i.hooks.options=i,i.hooks.block=n),i.async)return(async()=>{let o=i.hooks?await i.hooks.preprocess(e):e,a=await(i.hooks?await i.hooks.provideLexer():n?dt.lex:dt.lexInline)(o,i),l=i.hooks?await i.hooks.processAllTokens(a):a;i.walkTokens&&await Promise.all(this.walkTokens(l,i.walkTokens));let u=await(i.hooks?await i.hooks.provideParser():n?ft.parse:ft.parseInline)(l,i);return i.hooks?await i.hooks.postprocess(u):u})().catch(s);try{i.hooks&&(e=i.hooks.preprocess(e));let o=(i.hooks?i.hooks.provideLexer():n?dt.lex:dt.lexInline)(e,i);i.hooks&&(o=i.hooks.processAllTokens(o)),i.walkTokens&&this.walkTokens(o,i.walkTokens);let a=(i.hooks?i.hooks.provideParser():n?ft.parse:ft.parseInline)(o,i);return i.hooks&&(a=i.hooks.postprocess(a)),a}catch(o){return s(o)}}}onError(n,e){return t=>{if(t.message+=`
391
+ Please report this to https://github.com/markedjs/marked.`,n){let r="<p>An error occurred:</p><pre>"+wt(t.message+"",!0)+"</pre>";return e?Promise.resolve(r):r}if(e)return Promise.reject(t);throw t}}},sr=new yz;function K(n,e){return sr.parse(n,e)}K.options=K.setOptions=function(n){return sr.setOptions(n),K.defaults=sr.defaults,av(K.defaults),K};K.getDefaults=Vu;K.defaults=ur;K.use=function(...n){return sr.use(...n),K.defaults=sr.defaults,av(K.defaults),K};K.walkTokens=function(n,e){return sr.walkTokens(n,e)};K.parseInline=sr.parseInline;K.Parser=ft;K.parser=ft.parse;K.Renderer=oa;K.TextRenderer=Ju;K.Lexer=dt;K.lexer=dt.lex;K.Tokenizer=sa;K.Hooks=Vi;K.parse=K;K.options;K.setOptions;K.use;K.walkTokens;K.parseInline;ft.parse;dt.lex;ov.addHook("afterSanitizeAttributes",n=>{n.tagName==="A"&&(n.setAttribute("target","_blank"),n.setAttribute("rel","noopener noreferrer"))});function vz(n){const e=K.parse(n,{async:!1});return ov.sanitize(e,{USE_PROFILES:{html:!0}})}const bz=8,ap=new WeakMap;function wz(n){const e=ap.get(n);if(e&&e.text===n.text)return e.html;const t=vz(n.text);return ap.set(n,{text:n.text,html:t}),t}function lp(n){for(let e=n.length-1;e>=0;e-=1){const t=n[e];if(t&&t.kind==="user")return t.id}return null}var jt,Qn,Ea,$a,zs,Wc;class yv extends ts{constructor(){super(...arguments);S(this,zs);b(this,"messages",[]);S(this,jt,!0);S(this,Qn,null);S(this,Ea,()=>{const t=c(this,Qn);if(!t)return;const i=t.scrollHeight-t.clientHeight-t.scrollTop<=bz;i!==c(this,jt)&&(E(this,jt,i),this.toggleAttribute("data-pinned",i))});S(this,$a,()=>{E(this,jt,!0),this.toggleAttribute("data-pinned",!0),m(this,zs,Wc).call(this,!0)})}changed(t){let r=!1;if(t.has("messages")){const i=t.get("messages")??[],s=lp(this.messages);r=s!==null&&s!==lp(i),r&&E(this,jt,!0)}Pe(this.template(),this),c(this,Qn)||E(this,Qn,this.querySelector(".history-scroll")),this.toggleAttribute("data-pinned",c(this,jt)),m(this,zs,Wc).call(this,r)}template(){const t=this.messages.filter(r=>r.kind==="user"||r.kind==="assistant");return F`
392
392
  <div class="history-scroll" @scroll=${c(this,Ea)}>
393
- ${t.map(r=>{const i=r.kind==="assistant"?LR(Ez(r)):r.text;return F`<div
393
+ ${t.map(r=>{const i=r.kind==="assistant"?RR(wz(r)):r.text;return F`<div
394
394
  class="message message-${r.kind}"
395
395
  data-message-id=${r.id}
396
396
  >${i}</div>`})}
@@ -401,9 +401,9 @@ Please report this to https://github.com/markedjs/marked.`,n){let r="<p>An error
401
401
  aria-label="Jump to latest message"
402
402
  @click=${c(this,$a)}
403
403
  >
404
- ${wy({size:16})}
404
+ ${vy({size:16})}
405
405
  </button>
406
- `}}jt=new WeakMap,Qn=new WeakMap,Ea=new WeakMap,$a=new WeakMap,zs=new WeakSet,Bc=function(t){requestAnimationFrame(()=>{const r=c(this,Qn);r&&(!c(this,jt)&&!t||(r.scrollTop=r.scrollHeight-r.clientHeight))})},b(bv,"properties",["messages"]);customElements.define("message-history",bv);var Ls,Kr,vn,Wc,qc,Ms,Ns;class Gc extends ts{constructor(){super(...arguments);S(this,vn);b(this,"placeholder","What do you want to do?");b(this,"open",!1);b(this,"messages",[]);S(this,Ls,rt.resolve("ACPClientManager"));S(this,Kr);b(this,"handleTriggerActivate",()=>{this.open=!0});b(this,"handleKeydown",t=>{if(t.key!=="Enter"||t.shiftKey)return;const r=t.currentTarget,i=r.value.trim();if(t.preventDefault(),!i)return;r.value="";const s=c(this,Ls).getActiveClient();s&&s.sendMessage({text:i}).catch(o=>{console.error("ACPClient.sendMessage() failed",o)})});S(this,Ms,t=>{t.target instanceof Node&&(this.contains(t.target)||(this.open=!1))});S(this,Ns,t=>{t.key==="Escape"&&(this.open=!1)})}connected(){E(this,Kr,fO(c(this,Ls),t=>{this.messages=t})),this.open&&m(this,vn,Wc).call(this)}disconnected(){var t;(t=c(this,Kr))==null||t.dispose(),E(this,Kr,void 0),m(this,vn,qc).call(this)}changed(t){if(Pe(this.template(),this),t.has("open"))if(this.open){m(this,vn,Wc).call(this);const r=this.querySelector("textarea");r==null||r.focus()}else m(this,vn,qc).call(this)}template(){return this.open?F`
406
+ `}}jt=new WeakMap,Qn=new WeakMap,Ea=new WeakMap,$a=new WeakMap,zs=new WeakSet,Wc=function(t){requestAnimationFrame(()=>{const r=c(this,Qn);r&&(!c(this,jt)&&!t||(r.scrollTop=r.scrollHeight-r.clientHeight))})},b(yv,"properties",["messages"]);customElements.define("message-history",yv);var Ls,Kr,vn,Yc,Kc,Ms,Ns;class qc extends ts{constructor(){super(...arguments);S(this,vn);b(this,"placeholder","What do you want to do?");b(this,"open",!1);b(this,"messages",[]);S(this,Ls,rt.resolve("ACPClientManager"));S(this,Kr);b(this,"handleTriggerActivate",()=>{this.open=!0});b(this,"handleKeydown",t=>{if(t.key!=="Enter"||t.shiftKey)return;const r=t.currentTarget,i=r.value.trim();if(t.preventDefault(),!i)return;r.value="";const s=c(this,Ls).getActiveClient();s&&s.sendMessage({text:i}).catch(o=>{console.error("ACPClient.sendMessage() failed",o)})});S(this,Ms,t=>{t.target instanceof Node&&(this.contains(t.target)||(this.open=!1))});S(this,Ns,t=>{t.key==="Escape"&&(this.open=!1)})}connected(){E(this,Kr,cO(c(this,Ls),t=>{this.messages=t})),this.open&&m(this,vn,Yc).call(this)}disconnected(){var t;(t=c(this,Kr))==null||t.dispose(),E(this,Kr,void 0),m(this,vn,Kc).call(this)}changed(t){if(Pe(this.template(),this),t.has("open"))if(this.open){m(this,vn,Yc).call(this);const r=this.querySelector("textarea");r==null||r.focus()}else m(this,vn,Kc).call(this)}template(){return this.open?F`
407
407
  <message-history .messages=${this.messages}></message-history>
408
408
  <textarea
409
409
  class="input"
@@ -420,7 +420,7 @@ Please report this to https://github.com/markedjs/marked.`,n){let r="<p>An error
420
420
  >
421
421
  ${this.placeholder}
422
422
  </button>
423
- `}}Ls=new WeakMap,Kr=new WeakMap,vn=new WeakSet,Wc=function(){document.addEventListener("mousedown",c(this,Ms)),document.addEventListener("keydown",c(this,Ns))},qc=function(){document.removeEventListener("mousedown",c(this,Ms)),document.removeEventListener("keydown",c(this,Ns))},Ms=new WeakMap,Ns=new WeakMap,b(Gc,"properties",["placeholder","open","messages"]),b(Gc,"attributes",{placeholder:{type:String},open:{type:Boolean}});customElements.define("command-panel",Gc);class wv extends Event{constructor(t){super("auth-submit",{bubbles:!0,composed:!0});b(this,"token");this.token=t}}class $z extends HTMLElement{constructor(){super(...arguments);b(this,"_invalid",!1);b(this,"_tokenValue","")}set invalid(t){this._invalid=t,this.render()}get invalid(){return this._invalid}set tokenValue(t){this._tokenValue=t,this.render()}get tokenValue(){return this._tokenValue}connectedCallback(){this.render()}handleInput(t){const r=t.currentTarget;this._tokenValue=r.value}handleSubmit(t){t.preventDefault();const r=this._tokenValue.trim();r&&this.dispatchEvent(new wv(r))}render(){Pe(F`
423
+ `}}Ls=new WeakMap,Kr=new WeakMap,vn=new WeakSet,Yc=function(){document.addEventListener("mousedown",c(this,Ms)),document.addEventListener("keydown",c(this,Ns))},Kc=function(){document.removeEventListener("mousedown",c(this,Ms)),document.removeEventListener("keydown",c(this,Ns))},Ms=new WeakMap,Ns=new WeakMap,b(qc,"properties",["placeholder","open","messages"]),b(qc,"attributes",{placeholder:{type:String},open:{type:Boolean}});customElements.define("command-panel",qc);class vv extends Event{constructor(t){super("auth-submit",{bubbles:!0,composed:!0});b(this,"token");this.token=t}}class _z extends HTMLElement{constructor(){super(...arguments);b(this,"_invalid",!1);b(this,"_tokenValue","")}set invalid(t){this._invalid=t,this.render()}get invalid(){return this._invalid}set tokenValue(t){this._tokenValue=t,this.render()}get tokenValue(){return this._tokenValue}connectedCallback(){this.render()}handleInput(t){const r=t.currentTarget;this._tokenValue=r.value}handleSubmit(t){t.preventDefault();const r=this._tokenValue.trim();r&&this.dispatchEvent(new vv(r))}render(){Pe(F`
424
424
  <modal-overlay open>
425
425
  <section class="auth-modal">
426
426
  <form class="auth-form" @submit=${t=>this.handleSubmit(t)}>
@@ -441,7 +441,7 @@ Please report this to https://github.com/markedjs/marked.`,n){let r="<p>An error
441
441
  </form>
442
442
  </section>
443
443
  </modal-overlay>
444
- `,this)}}customElements.get("auth-modal")||customElements.define("auth-modal",$z);class Az extends HTMLElement{constructor(){super(...arguments);b(this,"runtimeServerURL",cy());b(this,"electronMode",hy());b(this,"serverManager",rt.resolve("ServerManager"));b(this,"screenManager",rt.resolve("ScreenManager"));b(this,"connectError",null);b(this,"handleServerManagerChange",()=>{this.render()});b(this,"handleActiveScreenChanged",()=>{this.render()})}connectedCallback(){this.serverManager.addEventListener("change",this.handleServerManagerChange),this.screenManager.addEventListener("active-screen-changed",this.handleActiveScreenChanged),this.addEventListener("auth-submit",t=>{var i;const r=t instanceof wv?t.token:t instanceof CustomEvent&&typeof((i=t.detail)==null?void 0:i.token)=="string"?t.detail.token:null;r&&this.handleAuthSubmit(r)}),this.initializeConnection(),this.render()}disconnectedCallback(){this.serverManager.removeEventListener("change",this.handleServerManagerChange),this.screenManager.removeEventListener("active-screen-changed",this.handleActiveScreenChanged)}async initializeConnection(){if(this.electronMode){this.serverManager.connectConfiguredServers(this.runtimeServerURL);return}if(this.serverManager.activeServer)return;const t=new pc({url:this.runtimeServerURL,name:"Server",token:uy()});this.serverManager.add(t),this.serverManager.setActive(t);try{await t.connect(),this.connectError=null}catch(r){this.connectError=r instanceof Error&&!(r instanceof fc)?r.message:null}this.render()}async handleAuthSubmit(t){const r=this.serverManager.activeServer;if(r){this.connectError=null,r.token=t,this.updateTokenQueryParam(t);try{await r.connect()}catch(i){i instanceof fc||(this.connectError=i instanceof Error?i.message:String(i))}this.render()}}updateTokenQueryParam(t){const r=new URL(window.location.href);r.searchParams.set("token",t),window.history.replaceState({},"",`${r.pathname}${r.search}${r.hash}`)}render(){const t=this.serverManager.activeServer,r=(t==null?void 0:t.status)??null;if(r==="connecting"){Pe(F`
444
+ `,this)}}customElements.get("auth-modal")||customElements.define("auth-modal",_z);class Sz extends HTMLElement{constructor(){super(...arguments);b(this,"runtimeServerURL",ay());b(this,"electronMode",cy());b(this,"serverManager",rt.resolve("ServerManager"));b(this,"screenManager",rt.resolve("ScreenManager"));b(this,"connectError",null);b(this,"handleServerManagerChange",()=>{this.render()});b(this,"handleActiveScreenChanged",()=>{this.render()})}connectedCallback(){this.serverManager.addEventListener("change",this.handleServerManagerChange),this.screenManager.addEventListener("active-screen-changed",this.handleActiveScreenChanged),this.addEventListener("auth-submit",t=>{var i;const r=t instanceof vv?t.token:t instanceof CustomEvent&&typeof((i=t.detail)==null?void 0:i.token)=="string"?t.detail.token:null;r&&this.handleAuthSubmit(r)}),this.initializeConnection(),this.render()}disconnectedCallback(){this.serverManager.removeEventListener("change",this.handleServerManagerChange),this.screenManager.removeEventListener("active-screen-changed",this.handleActiveScreenChanged)}async initializeConnection(){if(this.electronMode){this.serverManager.connectConfiguredServers(this.runtimeServerURL);return}if(this.serverManager.activeServer)return;const t=new mc({url:this.runtimeServerURL,name:"Server",token:ly()});this.serverManager.add(t),this.serverManager.setActive(t);try{await t.connect(),this.connectError=null}catch(r){this.connectError=r instanceof Error&&!(r instanceof gc)?r.message:null}this.render()}async handleAuthSubmit(t){const r=this.serverManager.activeServer;if(r){this.connectError=null,r.token=t,this.updateTokenQueryParam(t);try{await r.connect()}catch(i){i instanceof gc||(this.connectError=i instanceof Error?i.message:String(i))}this.render()}}updateTokenQueryParam(t){const r=new URL(window.location.href);r.searchParams.set("token",t),window.history.replaceState({},"",`${r.pathname}${r.search}${r.hash}`)}render(){const t=this.serverManager.activeServer,r=(t==null?void 0:t.status)??null;if(r==="connecting"){Pe(F`
445
445
  <main class="auth-gate"><p>Connecting...</p></main>
446
446
  `,this);return}if(r==="disconnected"){const o=t;if(!o)return;Pe(F`
447
447
  <main class="auth-gate">
@@ -465,4 +465,4 @@ Please report this to https://github.com/markedjs/marked.`,n){let r="<p>An error
465
465
  `:null}
466
466
  `}
467
467
  </main>
468
- `,this)}}customElements.get("television-app")||customElements.define("television-app",Az);const Ku=hy(),ja=cy(),_v=new q0(Ku?"television-electron":"television-browser",W0(ja)),Sv=new FC({localStore:_v,localServerURL:ja}),kv=new j0({localStore:_v,serverManager:Sv}),xz=new _R({serverURL:ja,token:uy()??"",screenManager:kv});rt.register("ServerManager",()=>Sv);rt.register("ScreenManager",()=>kv);rt.register("ACPClientManager",()=>xz);const Ju=document.createElement("television-app");Ju.runtimeServerURL=ja;Ju.electronMode=Ku;Ku&&document.body.classList.add("electron");document.body.appendChild(Ju);
468
+ `,this)}}customElements.get("television-app")||customElements.define("television-app",Sz);const Xu=cy(),ja=ay(),bv=new j0(Xu?"television-electron":"television-browser",V0(ja)),wv=new LC({localStore:bv,localServerURL:ja}),_v=new F0({localStore:bv,serverManager:wv}),kz=new yR({serverURL:ja,token:ly()??"",screenManager:_v});rt.register("ServerManager",()=>wv);rt.register("ScreenManager",()=>_v);rt.register("ACPClientManager",()=>kz);const Qu=document.createElement("television-app");Qu.runtimeServerURL=ja;Qu.electronMode=Xu;Xu&&document.body.classList.add("electron");document.body.appendChild(Qu);