@telepath-computer/television 0.1.43 → 0.1.44

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,468 +0,0 @@
1
- var zv=Object.defineProperty;var Th=n=>{throw TypeError(n)};var Lv=(n,e,t)=>e in n?zv(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var b=(n,e,t)=>Lv(n,typeof e!="symbol"?e+"":e,t),ol=(n,e,t)=>e.has(n)||Th("Cannot "+t);var l=(n,e,t)=>(ol(n,e,"read from private field"),t?t.call(n):e.get(n)),_=(n,e,t)=>e.has(n)?Th("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(n):e.set(n,t),E=(n,e,t,r)=>(ol(n,e,"write to private field"),r?r.call(n,t):e.set(n,t),t),m=(n,e,t)=>(ol(n,e,"access private method"),t);var Ch=(n,e,t,r)=>({set _(i){E(n,e,i,t)},get _(){return l(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 Mv(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 Ih=Object.prototype.toString,pp=function(e){var t=Ih.call(e),r=t==="[object Arguments]";return r||(r=t!=="[object Array]"&&e!==null&&typeof e=="object"&&typeof e.length=="number"&&e.length>=0&&Ih.call(e.callee)==="[object Function]"),r},al,Ph;function Nv(){if(Ph)return al;Ph=1;var n;if(!Object.keys){var e=Object.prototype.hasOwnProperty,t=Object.prototype.toString,r=pp,i=Object.prototype.propertyIsEnumerable,s=!i.call({toString:null},"toString"),o=i.call(function(){},"prototype"),a=["toString","toLocaleString","valueOf","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","constructor"],c=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{c(window[v])}catch{return!0}}catch{return!0}return!1}(),f=function(v){if(typeof window>"u"||!d)return c(v);try{return c(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 al=n,al}var Uv=Array.prototype.slice,Fv=pp,Rh=Object.keys,Po=Rh?function(e){return Rh(e)}:Nv(),Dh=Object.keys;Po.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 Fv(r)?Dh(Uv.call(r)):Dh(r)})}else Object.keys=Po;return Object.keys||Po};var Zv=Po,Ro=Object.defineProperty||!1;if(Ro)try{Ro({},"a",{value:1})}catch{Ro=!1}var Hs=Ro,qt=SyntaxError,G=TypeError,Hv=Object.getOwnPropertyDescriptor,Do=Hv;if(Do)try{Do([],"length")}catch{Do=null}var ii=Do,Oh=Hs,Vv=qt,yr=G,zh=ii,gp=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,c=!!zh&&zh(e,t);if(Oh)Oh(e,t,{configurable:o===null&&c?c.configurable:!o,enumerable:i===null&&c?c.enumerable:!i,value:r,writable:s===null&&c?c.writable:!s});else if(a||!i&&!s&&!o)e[t]=r;else throw new Vv("This environment does not support defining a property as non-configurable, non-writable, or non-enumerable.")},ec=Hs,mp=function(){return!!ec};mp.hasArrayLengthDefineBug=function(){if(!ec)return null;try{return ec([],"length",{value:1}).length!==1}catch{return!0}};var Ca=mp,jv=Zv,Bv=typeof Symbol=="function"&&typeof Symbol("foo")=="symbol",Gv=Object.prototype.toString,Wv=Array.prototype.concat,Lh=gp,qv=function(n){return typeof n=="function"&&Gv.call(n)==="[object Function]"},yp=Ca(),Yv=function(n,e,t,r){if(e in n){if(r===!0){if(n[e]===t)return}else if(!qv(r)||!r())return}yp?Lh(n,e,t,!0):Lh(n,e,t)},vp=function(n,e){var t=arguments.length>2?arguments[2]:{},r=jv(e);Bv&&(r=Wv.call(r,Object.getOwnPropertySymbols(e)));for(var i=0;i<r.length;i+=1)Yv(n,r[i],e[r[i]],t[r[i]])};vp.supportsDescriptors=!!yp;var ar=vp,Oo={exports:{}};typeof self<"u"?Oo.exports=self:typeof window<"u"?Oo.exports=window:Oo.exports=Function("return this")();var bp=Oo.exports,Kv=bp,wp=function(){return typeof In!="object"||!In||In.Math!==Math||In.Array!==Array?Kv:In},Jv=ar,Xv=ii,Qv=wp,eb=function(){var e=Qv();if(Jv.supportsDescriptors){var t=Xv(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},tb=ar,nb=bp,_p=wp,rb=eb,ib=_p(),Sp=function(){return ib};tb(Sp,{getPolyfill:_p,implementation:nb,shim:rb});var tu=Sp,Yt=function(e){return!!e&&(typeof e=="function"||typeof e=="object")},nu=Object,kp=Error,sb=EvalError,ob=RangeError,ru=ReferenceError,ab=URIError,lb=Math.abs,cb=Math.floor,ub=Math.max,hb=Math.min,db=Math.pow,fb=Math.round,iu=Number.isNaN||function(e){return e!==e},pb=iu,gb=function(e){return pb(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},Mh=typeof Symbol<"u"&&Symbol,mb=si,su=function(){return typeof Mh!="function"||typeof Symbol!="function"||typeof Mh("foo")!="symbol"||typeof Symbol("bar")!="symbol"?!1:mb()},ll,Nh;function Ep(){return Nh||(Nh=1,ll=typeof Reflect<"u"&&Reflect.getPrototypeOf||null),ll}var cl,Uh;function $p(){if(Uh)return cl;Uh=1;var n=nu;return cl=n.getPrototypeOf||null,cl}var yb="Function.prototype.bind called on incompatible ",vb=Object.prototype.toString,bb=Math.max,wb="[object Function]",Fh=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,Fh(r,arguments));return Object(d)===d?d:this}return t.apply(e,Fh(r,arguments))},o=bb(0,t.length-r.length),a=[],c=0;c<o;c++)a[c]="$"+c;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,Vs=Function.prototype.bind||Eb,ou=Function.prototype.call,au=Function.prototype.apply,$b=typeof Reflect<"u"&&Reflect&&Reflect.apply,Ab=Vs,xb=au,Tb=ou,Cb=$b,Ap=Cb||Ab.call(Tb,xb),Ib=Vs,Pb=G,Rb=ou,Db=Ap,Ia=function(e){if(e.length<1||typeof e[0]!="function")throw new Pb("a function is required");return Db(Ib,Rb,e)},ul,Zh;function Ob(){if(Zh)return ul;Zh=1;var n=Ia,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 ul=r&&typeof r.get=="function"?n([r.get]):typeof s=="function"?function(a){return s(a==null?a:i(a))}:!1,ul}var hl,Hh;function xp(){if(Hh)return hl;Hh=1;var n=Ep(),e=$p(),t=Ob();return hl=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,hl}var zb=Function.prototype.call,Lb=Object.prototype.hasOwnProperty,Mb=Vs,Kt=Mb.call(zb,Lb),j,Nb=nu,Ub=kp,Fb=sb,Zb=ob,Hb=ru,Jr=qt,Pr=G,Vb=ab,jb=lb,Bb=cb,Gb=ub,Wb=hb,qb=db,Yb=fb,Kb=gb,Tp=Function,dl=function(n){try{return Tp('"use strict"; return ('+n+").constructor;")()}catch{}},Ki=ii,Jb=Hs,fl=function(){throw new Pr},Xb=Ki?function(){try{return arguments.callee,fl}catch{try{return Ki(arguments,"callee").get}catch{return fl}}}():fl,vr=su(),Se=xp(),Qb=$p(),ew=Ep(),Cp=au,js=ou,_r={},tw=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%":Ub,"%eval%":eval,"%EvalError%":Fb,"%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%":Tp,"%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%":Nb,"%Object.getOwnPropertyDescriptor%":Ki,"%parseFloat%":parseFloat,"%parseInt%":parseInt,"%Promise%":typeof Promise>"u"?j:Promise,"%Proxy%":typeof Proxy>"u"?j:Proxy,"%RangeError%":Zb,"%ReferenceError%":Hb,"%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%":Xb,"%TypedArray%":tw,"%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%":Vb,"%WeakMap%":typeof WeakMap>"u"?j:WeakMap,"%WeakRef%":typeof WeakRef>"u"?j:WeakRef,"%WeakSet%":typeof WeakSet>"u"?j:WeakSet,"%Function.prototype.call%":js,"%Function.prototype.apply%":Cp,"%Object.defineProperty%":Jb,"%Object.getPrototypeOf%":Qb,"%Math.abs%":jb,"%Math.floor%":Bb,"%Math.max%":Gb,"%Math.min%":Wb,"%Math.pow%":qb,"%Math.round%":Yb,"%Math.sign%":Kb,"%Reflect.getPrototypeOf%":ew};if(Se)try{null.error}catch(n){var nw=Se(Se(n));er["%Error.prototype%"]=nw}var rw=function n(e){var t;if(e==="%AsyncFunction%")t=dl("async function () {}");else if(e==="%GeneratorFunction%")t=dl("function* () {}");else if(e==="%AsyncGeneratorFunction%")t=dl("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},Vh={__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"]},Bs=Vs,Go=Kt,iw=Bs.call(js,Array.prototype.concat),sw=Bs.call(Cp,Array.prototype.splice),jh=Bs.call(js,String.prototype.replace),Wo=Bs.call(js,String.prototype.slice),ow=Bs.call(js,RegExp.prototype.exec),aw=/[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g,lw=/\\(\\)?/g,cw=function(e){var t=Wo(e,0,1),r=Wo(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 jh(e,aw,function(s,o,a,c){i[i.length]=a?jh(c,lw,"$1"):o||s}),i},uw=function(e,t){var r=e,i;if(Go(Vh,r)&&(i=Vh[r],r="%"+i[0]+"%"),Go(er,r)){var s=er[r];if(s===_r&&(s=rw(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(ow(/^%?[^%]*%?$/,e)===null)throw new Jr("`%` may not be present anywhere but at the beginning and end of the intrinsic name");var r=cw(e),i=r.length>0?r[0]:"",s=uw("%"+i+"%",t),o=s.name,a=s.value,c=!1,u=s.alias;u&&(i=u[0],sw(r,iw([0,1],u)));for(var d=1,f=!0;d<r.length;d+=1){var v=r[d],y=Wo(v,0,1),A=Wo(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)&&(c=!0),i+="."+v,o="%"+i+"%",Go(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=Go(a,v),a=a[v];f&&!c&&(er[o]=a)}}return a},pl,Bh;function bn(){if(Bh)return pl;Bh=1;var n=st,e=Ia,t=e([n("%String.prototype.indexOf%")]);return pl=function(i,s){var o=n(i,!!s);return typeof o=="function"&&t(i,".prototype.")>-1?e([o]):o},pl}var gl,Gh;function lu(){if(Gh)return gl;Gh=1;var n=st,e=n("%Array%"),t=!e.isArray&&bn()("Object.prototype.toString");return gl=e.isArray||function(i){return t(i)==="[object Array]"},gl}var hw=Ca,Wh=Hs,Ip=hw.hasArrayLengthDefineBug(),dw=Ip&&lu(),fw=bn(),pw=fw("Object.prototype.propertyIsEnumerable"),cu=function(e,t,r,i,s,o){if(!Wh){if(!e(o)||!o["[[Configurable]]"]||!o["[[Writable]]"]||s in i&&pw(i,s)!==!!o["[[Enumerable]]"])return!1;var a=o["[[Value]]"];return i[s]=a,t(i[s],a)}return Ip&&s==="length"&&"[[Value]]"in o&&dw(i)&&i.length!==o["[[Value]]"]?(i.length=o["[[Value]]"],i.length===o["[[Value]]"]):(Wh(i,s,r(o)),!0)},gw=G,_i=Kt,mw={__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)&&!mw[t])return!1;var r=_i(e,"[[Value]]")||_i(e,"[[Writable]]"),i=_i(e,"[[Get]]")||_i(e,"[[Set]]");if(r&&i)throw new gw("Property Descriptors may not be both accessor and data descriptors");return!0},Pp=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},yw=G,vw=oi,bw=Pp,Rp=function(e){if(typeof e<"u"&&!vw(e))throw new yw("Assertion failed: `Desc` must be a Property Descriptor");return bw(e)},ww=G,qh=Kt,_w=oi,Dp=function(e){if(typeof e>"u")return!1;if(!_w(e))throw new ww("Assertion failed: `Desc` must be a Property Descriptor");return!(!qh(e,"[[Value]]")&&!qh(e,"[[Writable]]"))},ai=function(e){return typeof e=="string"||typeof e=="symbol"},Yh=iu,Op=function(e,t){return e===t?e===0?1/e===1/t:!0:Yh(e)&&Yh(t)},Kh=G,Sw=Yt,kw=cu,Ew=Rp,$w=Dp,Aw=ai,xw=Op,uu=function(e,t,r){if(!Sw(e))throw new Kh("Assertion failed: Type(O) is not Object");if(!Aw(t))throw new Kh("Assertion failed: P is not a Property Key");var i={"[[Configurable]]":!0,"[[Enumerable]]":!1,"[[Value]]":r,"[[Writable]]":!0};return kw($w,xw,Ew,e,t,i)},zp=Function.prototype.toString,Tr=typeof Reflect=="object"&&Reflect!==null&&Reflect.apply,tc,zo;if(typeof Tr=="function"&&typeof Object.defineProperty=="function")try{tc=Object.defineProperty({},"length",{get:function(){throw zo}}),zo={},Tr(function(){throw 42},null,tc)}catch(n){n!==zo&&(Tr=null)}else Tr=null;var Tw=/^\s*class\b/,nc=function(e){try{var t=zp.call(e);return Tw.test(t)}catch{return!1}},ml=function(e){try{return nc(e)?!1:(zp.call(e),!0)}catch{return!1}},Lo=Object.prototype.toString,Cw="[object Object]",Iw="[object Function]",Pw="[object GeneratorFunction]",Rw="[object HTMLAllCollection]",Dw="[object HTML document.all class]",Ow="[object HTMLCollection]",zw=typeof Symbol=="function"&&!!Symbol.toStringTag,Lw=!(0 in[,]),rc=function(){return!1};if(typeof document=="object"){var Mw=document.all;Lo.call(Mw)===Lo.call(document.all)&&(rc=function(e){if((Lw||!e)&&(typeof e>"u"||typeof e=="object"))try{var t=Lo.call(e);return(t===Rw||t===Dw||t===Ow||t===Cw)&&e("")==null}catch{}return!1})}var Lp=Tr?function(e){if(rc(e))return!0;if(!e||typeof e!="function"&&typeof e!="object")return!1;try{Tr(e,null,tc)}catch(t){if(t!==zo)return!1}return!nc(e)&&ml(e)}:function(e){if(rc(e))return!0;if(!e||typeof e!="function"&&typeof e!="object")return!1;if(zw)return ml(e);if(nc(e))return!1;var t=Lo.call(e);return t!==Iw&&t!==Pw&&!/^\[object HTML/.test(t)?!1:ml(e)},Nw=Lp,Uw=function(e){return!!e},bt=Kt,ho=G,Fw=Yt,Jh=Nw,yl=Uw,Zw=function(e){if(!Fw(e))throw new ho("ToPropertyDescriptor requires an object");var t={};if(bt(e,"enumerable")&&(t["[[Enumerable]]"]=yl(e.enumerable)),bt(e,"configurable")&&(t["[[Configurable]]"]=yl(e.configurable)),bt(e,"value")&&(t["[[Value]]"]=e.value),bt(e,"writable")&&(t["[[Writable]]"]=yl(e.writable)),bt(e,"get")){var r=e.get;if(typeof r<"u"&&!Jh(r))throw new ho("getter must be a function");t["[[Get]]"]=r}if(bt(e,"set")){var i=e.set;if(typeof i<"u"&&!Jh(i))throw new ho("setter must be a function");t["[[Set]]"]=i}if((bt(t,"[[Get]]")||bt(t,"[[Set]]"))&&(bt(t,"[[Value]]")||bt(t,"[[Writable]]")))throw new ho("Invalid property descriptor. Cannot both specify accessors and a value or writable attribute");return t},vl=G,Hw=Yt,Xh=oi,Vw=cu,jw=Rp,Bw=Dp,Gw=ai,Ww=Op,qw=Zw,Yw=function(e,t,r){if(!Hw(e))throw new vl("Assertion failed: Type(O) is not Object");if(!Gw(t))throw new vl("Assertion failed: P is not a Property Key");var i=Xh(r)?r:qw(r);if(!Xh(i))throw new vl("Assertion failed: Desc is not a valid Property Descriptor");return Vw(Bw,Ww,jw,e,t,i)},Qh=G,Kw=Yt,Jw=Yw,Xw=ai,Qw=function(e,t,r){if(!Kw(e))throw new Qh("Assertion failed: Type(O) is not Object");if(!Xw(t))throw new Qh("Assertion failed: P is not a Property Key");var i={"[[Configurable]]":!0,"[[Enumerable]]":!1,"[[Value]]":r,"[[Writable]]":!0};return Jw(e,t,i)},e_=typeof Reflect<"u"&&Reflect.setPrototypeOf||null,t_=nu,n_=t_.setPrototypeOf||null,r_=Ia,ed=ii,i_=G,Mp={};try{Mp.__proto__=null}catch(n){if(!n||typeof n!="object"||!("code"in n)||n.code!=="ERR_PROTO_ACCESS")throw n}var s_=!("toString"in Mp),bl=ed&&ed(Object.prototype,"__proto__"),o_=s_&&(!!bl&&typeof bl.set=="function"&&r_([bl.set])||function(e,t){if(e==null)throw new i_("set Object.prototype.__proto__ called on null or undefined");return e.__proto__=t,t}),td=e_,a_=n_,nd=o_,l_=G,c_=td?function(e,t){if(td(e,t))return e;throw new l_("Reflect.setPrototypeOf: failed to set [[Prototype]]")}:a_||(nd?function(e,t){return nd(e,t),e}:null),rd=G,u_=Yt,id=xp(),h_=function(e){if(!u_(e))throw new rd("Assertion failed: O must be an Object");if(!id)throw new rd("This environment does not support fetching prototypes.");return id(e)},d_=G,f_=c_,p_=Yt,g_=h_,m_=function(e,t){if(t!==null&&!p_(t))throw new d_("Assertion failed: V must be Object or Null");try{f_(e,t)}catch{return!1}return g_(e)===t},wl=uu,sd=Qw,Np=m_,y_=Ca(),hu=kp;function Gs(n,e,t){var r=new hu(t);return Np(r,Mo),delete r.constructor,sd(r,"error",n),sd(r,"suppressed",e),r}y_&&Object.defineProperty(Gs,"prototype",{writable:!1});var Mo=Gs.prototype;if(!wl(Mo,"constructor",Gs)||!wl(Mo,"message","")||!wl(Mo,"name","SuppressedError"))throw new hu("unable to install SuppressedError.prototype properties; please report this!");Np(Gs.prototype,hu.prototype);var v_=Gs,b_=v_,Up=function(){return typeof SuppressedError=="function"?SuppressedError:b_},w_=ar,od=tu(),__=Up,S_=function(){var e=__();return w_(od,{SuppressedError:e},{SuppressedError:function(){return od.SuppressedError!==e}}),e};S_();var k_=G,E_=oi,$_=Pp,A_=function(e){if(typeof e<"u"&&!E_(e))throw new k_("Assertion failed: `Desc` must be a Property Descriptor");return $_(e)},x_=G,ad=Kt,T_=oi,C_=function(e){if(typeof e>"u")return!1;if(!T_(e))throw new x_("Assertion failed: `Desc` must be a Property Descriptor");return!(!ad(e,"[[Value]]")&&!ad(e,"[[Writable]]"))},ld=iu,I_=function(e,t){return e===t?e===0?1/e===1/t:!0:ld(e)&&ld(t)},li=Lp,P_=function(e){return!!e},wt=Kt,fo=G,R_=Yt,cd=li,_l=P_,D_=function(e){if(!R_(e))throw new fo("ToPropertyDescriptor requires an object");var t={};if(wt(e,"enumerable")&&(t["[[Enumerable]]"]=_l(e.enumerable)),wt(e,"configurable")&&(t["[[Configurable]]"]=_l(e.configurable)),wt(e,"value")&&(t["[[Value]]"]=e.value),wt(e,"writable")&&(t["[[Writable]]"]=_l(e.writable)),wt(e,"get")){var r=e.get;if(typeof r<"u"&&!cd(r))throw new fo("getter must be a function");t["[[Get]]"]=r}if(wt(e,"set")){var i=e.set;if(typeof i<"u"&&!cd(i))throw new fo("setter must be a function");t["[[Set]]"]=i}if((wt(t,"[[Get]]")||wt(t,"[[Set]]"))&&(wt(t,"[[Value]]")||wt(t,"[[Writable]]")))throw new fo("Invalid property descriptor. Cannot both specify accessors and a value or writable attribute");return t},Sl=G,O_=Yt,ud=oi,z_=cu,L_=A_,M_=C_,N_=ai,U_=I_,F_=D_,Ws=function(e,t,r){if(!O_(e))throw new Sl("Assertion failed: Type(O) is not Object");if(!N_(t))throw new Sl("Assertion failed: P is not a Property Key");var i=ud(r)?r:F_(r);if(!ud(i))throw new Sl("Assertion failed: Desc is not a valid Property Descriptor");return z_(M_,U_,L_,e,t,i)},Z_=si(),H_=Z_?Symbol.dispose||Symbol("Symbol.dispose"):null,V_=si,j_=H_,du=function(){return V_()&&Symbol.dispose||j_},B_=su,G_=Ws,W_=du,q_=function(){var e=W_();return B_()&&G_(Symbol,"dispose",{"[[Configurable]]":!1,"[[Enumerable]]":!1,"[[Writable]]":!1,"[[Value]]":e}),e},Y_=si(),K_=Y_?Symbol.asyncDispose||Symbol("Symbol.asyncDispose"):null,J_=si,X_=K_,fu=function(){return J_()&&Symbol.asyncDispose||X_},Q_=su,eS=Ws,tS=fu,nS=function(){var e=tS();return Q_()&&eS(Symbol,"asyncDispose",{"[[Configurable]]":!1,"[[Enumerable]]":!1,"[[Writable]]":!1,"[[Value]]":e}),e},rS=lu(),iS=st,sS=bn(),oS=G,aS=rS,lS=iS("%Reflect.apply%",!0)||sS("Function.prototype.apply"),Pa=function(e,t){var r=arguments.length>2?arguments[2]:[];if(!aS(r))throw new oS("Assertion failed: optional `argumentsList`, if provided, must be a List");return lS(e,t,r)};const cS={},uS=Object.freeze(Object.defineProperty({__proto__:null,default:cS},Symbol.toStringTag,{value:"Module"})),hS=Mv(uS);var pu=typeof Map=="function"&&Map.prototype,kl=Object.getOwnPropertyDescriptor&&pu?Object.getOwnPropertyDescriptor(Map.prototype,"size"):null,qo=pu&&kl&&typeof kl.get=="function"?kl.get:null,hd=pu&&Map.prototype.forEach,gu=typeof Set=="function"&&Set.prototype,El=Object.getOwnPropertyDescriptor&&gu?Object.getOwnPropertyDescriptor(Set.prototype,"size"):null,Yo=gu&&El&&typeof El.get=="function"?El.get:null,dd=gu&&Set.prototype.forEach,dS=typeof WeakMap=="function"&&WeakMap.prototype,ji=dS?WeakMap.prototype.has:null,fS=typeof WeakSet=="function"&&WeakSet.prototype,Bi=fS?WeakSet.prototype.has:null,pS=typeof WeakRef=="function"&&WeakRef.prototype,fd=pS?WeakRef.prototype.deref:null,gS=Boolean.prototype.valueOf,mS=Object.prototype.toString,yS=Function.prototype.toString,vS=String.prototype.match,mu=String.prototype.slice,hn=String.prototype.replace,bS=String.prototype.toUpperCase,pd=String.prototype.toLowerCase,Fp=RegExp.prototype.test,gd=Array.prototype.concat,Tt=Array.prototype.join,wS=Array.prototype.slice,md=Math.floor,ic=typeof BigInt=="function"?BigInt.prototype.valueOf:null,$l=Object.getOwnPropertySymbols,sc=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,Zp=Object.prototype.propertyIsEnumerable,yd=(typeof Reflect=="function"?Reflect.getPrototypeOf:Object.getPrototypeOf)||([].__proto__===Array.prototype?function(n){return n.__proto__}:null);function vd(n,e){if(n===1/0||n===-1/0||n!==n||n&&n>-1e3&&n<1e3||Fp.call(/e/,e))return e;var t=/[0-9](?=(?:[0-9]{3})+(?![0-9]))/g;if(typeof n=="number"){var r=n<0?-md(-n):md(n);if(r!==n){var i=String(r),s=mu.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 oc=hS,bd=oc.custom,wd=jp(bd)?bd:null,Hp={__proto__:null,double:'"',single:"'"},_S={__proto__:null,double:/(["\\])/g,single:/(['\\])/g},ci=function n(e,t,r,i){var s=t||{};if(Lt(s,"quoteStyle")&&!Lt(Hp,s.quoteStyle))throw new TypeError('option "quoteStyle" must be "single" or "double"');if(Lt(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=Lt(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(Lt(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(Lt(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 Gp(e,s);if(typeof e=="number"){if(e===0)return 1/0/e>0?"0":"-0";var c=String(e);return a?vd(e,c):c}if(typeof e=="bigint"){var u=String(e)+"n";return a?vd(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 ac(e)?"[Array]":"[Object]";var f=US(s,r);if(typeof i>"u")i=[];else if(Bp(i,e)>=0)return"[Circular]";function v(mt,Xt,qa){if(Xt&&(i=wS.call(i),i.push(Xt)),qa){var no={depth:s.depth};return Lt(s,"quoteStyle")&&(no.quoteStyle=s.quoteStyle),n(mt,no,r+1,i)}return n(mt,s,r+1,i)}if(typeof e=="function"&&!_d(e)){var y=IS(e),A=po(e,v);return"[Function"+(y?": "+y:" (anonymous)")+"]"+(A.length>0?" { "+Tt.call(A,", ")+" }":"")}if(jp(e)){var k=Xr?hn.call(String(e),/^(Symbol\(.*\))_[^)]*$/,"$1"):sc.call(e);return typeof e=="object"&&!Xr?Si(k):k}if(LS(e)){for(var I="<"+pd.call(String(e.nodeName)),B=e.attributes||[],P=0;P<B.length;P++)I+=" "+B[P].name+"="+Vp(SS(B[P].value),"double",s);return I+=">",e.childNodes&&e.childNodes.length&&(I+="..."),I+="</"+pd.call(String(e.nodeName))+">",I}if(ac(e)){if(e.length===0)return"[]";var le=po(e,v);return f&&!NS(le)?"["+lc(le,f)+"]":"[ "+Tt.call(le,", ")+" ]"}if(ES(e)){var M=po(e,v);return!("cause"in Error.prototype)&&"cause"in e&&!Zp.call(e,"cause")?"{ ["+String(e)+"] "+Tt.call(gd.call("[cause]: "+v(e.cause),M),", ")+" }":M.length===0?"["+String(e)+"]":"{ ["+String(e)+"] "+Tt.call(M,", ")+" }"}if(typeof e=="object"&&o){if(wd&&typeof e[wd]=="function"&&oc)return oc(e,{depth:d-r});if(o!=="symbol"&&typeof e.inspect=="function")return e.inspect()}if(PS(e)){var Z=[];return hd&&hd.call(e,function(mt,Xt){Z.push(v(Xt,e,!0)+" => "+v(mt,e))}),Sd("Map",qo.call(e),Z,f)}if(OS(e)){var U=[];return dd&&dd.call(e,function(mt){U.push(v(mt,e))}),Sd("Set",Yo.call(e),U,f)}if(RS(e))return Al("WeakMap");if(zS(e))return Al("WeakSet");if(DS(e))return Al("WeakRef");if(AS(e))return Si(v(Number(e)));if(TS(e))return Si(v(ic.call(e)));if(xS(e))return Si(gS.call(e));if($S(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(!kS(e)&&!_d(e)){var ge=po(e,v),ce=yd?yd(e)===Object.prototype:e instanceof Object||e.constructor===Object,yi=e instanceof Object?"":"null prototype",to=!ce&&Gi&&Object(e)===e&&Gi in e?mu.call(wn(e),8,-1):yi?"Object":"",$e=ce||typeof e.constructor!="function"?"":e.constructor.name?e.constructor.name+" ":"",kn=$e+(to||yi?"["+Tt.call(gd.call([],to||[],yi||[]),": ")+"] ":"");return ge.length===0?kn+"{}":f?kn+"{"+lc(ge,f)+"}":kn+"{ "+Tt.call(ge,", ")+" }"}return String(e)};function Vp(n,e,t){var r=t.quoteStyle||e,i=Hp[r];return i+n+i}function SS(n){return hn.call(String(n),/"/g,"&quot;")}function lr(n){return!Gi||!(typeof n=="object"&&(Gi in n||typeof n[Gi]<"u"))}function ac(n){return wn(n)==="[object Array]"&&lr(n)}function kS(n){return wn(n)==="[object Date]"&&lr(n)}function _d(n){return wn(n)==="[object RegExp]"&&lr(n)}function ES(n){return wn(n)==="[object Error]"&&lr(n)}function $S(n){return wn(n)==="[object String]"&&lr(n)}function AS(n){return wn(n)==="[object Number]"&&lr(n)}function xS(n){return wn(n)==="[object Boolean]"&&lr(n)}function jp(n){if(Xr)return n&&typeof n=="object"&&n instanceof Symbol;if(typeof n=="symbol")return!0;if(!n||typeof n!="object"||!sc)return!1;try{return sc.call(n),!0}catch{}return!1}function TS(n){if(!n||typeof n!="object"||!ic)return!1;try{return ic.call(n),!0}catch{}return!1}var CS=Object.prototype.hasOwnProperty||function(n){return n in this};function Lt(n,e){return CS.call(n,e)}function wn(n){return mS.call(n)}function IS(n){if(n.name)return n.name;var e=vS.call(yS.call(n),/^function\s*([\w$]+)/);return e?e[1]:null}function Bp(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 PS(n){if(!qo||!n||typeof n!="object")return!1;try{qo.call(n);try{Yo.call(n)}catch{return!0}return n instanceof Map}catch{}return!1}function RS(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 DS(n){if(!fd||!n||typeof n!="object")return!1;try{return fd.call(n),!0}catch{}return!1}function OS(n){if(!Yo||!n||typeof n!="object")return!1;try{Yo.call(n);try{qo.call(n)}catch{return!0}return n instanceof Set}catch{}return!1}function zS(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 LS(n){return!n||typeof n!="object"?!1:typeof HTMLElement<"u"&&n instanceof HTMLElement?!0:typeof n.nodeName=="string"&&typeof n.getAttribute=="function"}function Gp(n,e){if(n.length>e.maxStringLength){var t=n.length-e.maxStringLength,r="... "+t+" more character"+(t>1?"s":"");return Gp(mu.call(n,0,e.maxStringLength),e)+r}var i=_S[e.quoteStyle||"single"];i.lastIndex=0;var s=hn.call(hn.call(n,i,"\\$1"),/[\x00-\x1f]/g,MS);return Vp(s,"single",e)}function MS(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":"")+bS.call(e.toString(16))}function Si(n){return"Object("+n+")"}function Al(n){return n+" { ? }"}function Sd(n,e,t,r){var i=r?lc(t,r):Tt.call(t,", ");return n+" ("+e+") {"+i+"}"}function NS(n){for(var e=0;e<n.length;e++)if(Bp(n[e],`
2
- `)>=0)return!1;return!0}function US(n,e){var t;if(n.indent===" ")t=" ";else if(typeof n.indent=="number"&&n.indent>0)t=Tt.call(Array(n.indent+1)," ");else return null;return{base:t,prev:Tt.call(Array(e+1),t)}}function lc(n,e){if(n.length===0)return"";var t=`
3
- `+e.prev+e.base;return t+Tt.call(n,","+t)+`
4
- `+e.prev}function po(n,e){var t=ac(n),r=[];if(t){r.length=n.length;for(var i=0;i<n.length;i++)r[i]=Lt(n,i)?e(n[i],n):""}var s=typeof $l=="function"?$l(n):[],o;if(Xr){o={};for(var a=0;a<s.length;a++)o["$"+s[a]]=s[a]}for(var c in n)Lt(n,c)&&(t&&String(Number(c))===c&&c<n.length||Xr&&o["$"+c]instanceof Symbol||(Fp.call(/[^\w$]/,c)?r.push(e(c,n)+": "+e(n[c],n)):r.push(c+": "+e(n[c],n))));if(typeof $l=="function")for(var u=0;u<s.length;u++)Zp.call(n,s[u])&&r.push("["+e(s[u])+"]: "+e(n[s[u]],n));return r}var FS=ci,ZS=G,Ra=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},HS=function(n,e){if(n){var t=Ra(n,e);return t&&t.value}},VS=function(n,e,t){var r=Ra(n,e);r?r.value=t:n.next={key:e,next:n.next,value:t}},jS=function(n,e){return n?!!Ra(n,e):!1},BS=function(n,e){if(n)return Ra(n,e,!0)},GS=function(){var e,t={assert:function(r){if(!t.has(r))throw new ZS("Side channel does not contain "+FS(r))},delete:function(r){var i=e&&e.next,s=BS(e,r);return s&&i&&i===s&&(e=void 0),!!s},get:function(r){return HS(e,r)},has:function(r){return jS(e,r)},set:function(r,i){e||(e={next:void 0}),VS(e,r,i)}};return t},WS=st,qs=bn(),qS=ci,YS=G,kd=WS("%Map%",!0),KS=qs("Map.prototype.get",!0),JS=qs("Map.prototype.set",!0),XS=qs("Map.prototype.has",!0),QS=qs("Map.prototype.delete",!0),ek=qs("Map.prototype.size",!0),Wp=!!kd&&function(){var e,t={assert:function(r){if(!t.has(r))throw new YS("Side channel does not contain "+qS(r))},delete:function(r){if(e){var i=QS(e,r);return ek(e)===0&&(e=void 0),i}return!1},get:function(r){if(e)return KS(e,r)},has:function(r){return e?XS(e,r):!1},set:function(r,i){e||(e=new kd),JS(e,r,i)}};return t},tk=st,Da=bn(),nk=ci,go=Wp,rk=G,br=tk("%WeakMap%",!0),ik=Da("WeakMap.prototype.get",!0),sk=Da("WeakMap.prototype.set",!0),ok=Da("WeakMap.prototype.has",!0),ak=Da("WeakMap.prototype.delete",!0),lk=br?function(){var e,t,r={assert:function(i){if(!r.has(i))throw new rk("Side channel does not contain "+nk(i))},delete:function(i){if(br&&i&&(typeof i=="object"||typeof i=="function")){if(e)return ak(e,i)}else if(go&&t)return t.delete(i);return!1},get:function(i){return br&&i&&(typeof i=="object"||typeof i=="function")&&e?ik(e,i):t&&t.get(i)},has:function(i){return br&&i&&(typeof i=="object"||typeof i=="function")&&e?ok(e,i):!!t&&t.has(i)},set:function(i,s){br&&i&&(typeof i=="object"||typeof i=="function")?(e||(e=new br),sk(e,i,s)):go&&(t||(t=go()),t.set(i,s))}};return r}:go,ck=G,uk=ci,hk=GS,dk=Wp,fk=lk,pk=fk||dk||hk,gk=function(){var e,t={assert:function(r){if(!t.has(r))throw new ck("Side channel does not contain "+uk(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=pk()),e.set(r,i)}};return t},mk=Kt,ki=gk(),Dt=G,yu={assert:function(n,e){if(!n||typeof n!="object"&&typeof n!="function")throw new Dt("`O` is not an object");if(typeof e!="string")throw new Dt("`slot` must be a string");if(ki.assert(n),!yu.has(n,e))throw new Dt("`"+e+"` is not present on `O`")},get:function(n,e){if(!n||typeof n!="object"&&typeof n!="function")throw new Dt("`O` is not an object");if(typeof e!="string")throw new Dt("`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 Dt("`O` is not an object");if(typeof e!="string")throw new Dt("`slot` must be a string");var t=ki.get(n);return!!t&&mk(t,"$"+e)},set:function(n,e,t){if(!n||typeof n!="object"&&typeof n!="function")throw new Dt("`O` is not an object");if(typeof e!="string")throw new Dt("`slot` must be a string");var r=ki.get(n);r||(r={},ki.set(n,r)),r["$"+e]=t}};Object.freeze&&Object.freeze(yu);var vu=yu,qp=qt,dn=vu,Ys=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 qp('Assertion failed: `type` must be one of "normal", "break", "continue", "return", or "throw"');dn.set(this,"[[Type]]",e),dn.set(this,"[[Value]]",t)};Ys.prototype.type=function(){return dn.get(this,"[[Type]]")};Ys.prototype.value=function(){return dn.get(this,"[[Value]]")};Ys.prototype["?"]=function(){var e=dn.get(this,"[[Type]]"),t=dn.get(this,"[[Value]]");if(e==="throw")throw t;return t};Ys.prototype["!"]=function(){var e=dn.get(this,"[[Type]]");if(e!=="normal")throw new qp('Assertion failed: Completion Record is not of type "normal"');return dn.get(this,"[[Value]]")};var bu=Ys,yk=bu,wu=function(e){return new yk("normal",e)},xl,Ed;function vk(){if(Ed)return xl;Ed=1;var n=si;return xl=function(){return n()&&!!Symbol.toStringTag},xl}var bk=st,$d=bk("%Object.defineProperty%",!0),wk=vk()(),_k=Kt,Sk=G,mo=wk?Symbol.toStringTag:null,Yp=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 Sk("if provided, the `overrideIfSet` and `nonConfigurable` options must be booleans");mo&&(r||!_k(e,mo))&&($d?$d(e,mo,{configurable:!i,enumerable:!1,value:t,writable:!1}):e[mo]=t)},Kp={exports:{}},kk=st,Ad=gp,Ek=Ca(),xd=ii,Td=G,$k=kk("%Math.floor%"),Ak=function(e,t){if(typeof e!="function")throw new Td("`fn` is not a function");if(typeof t!="number"||t<0||t>4294967295||$k(t)!==t)throw new Td("`length` must be a positive 32-bit integer");var r=arguments.length>2&&!!arguments[2],i=!0,s=!0;if("length"in e&&xd){var o=xd(e,"length");o&&!o.configurable&&(i=!1),o&&!o.writable&&(s=!1)}return(i||s||!r)&&(Ek?Ad(e,"length",t,!0,!0):Ad(e,"length",t)),e},xk=Vs,Tk=au,Ck=Ap,Ik=function(){return Ck(xk,Tk,arguments)};(function(n){var e=Ak,t=Hs,r=Ia,i=Ik;n.exports=function(o){var a=r(arguments),c=1+o.length-(arguments.length-1);return e(a,c>0?c:0,!0)},t?t(n.exports,"apply",{value:i}):n.exports.apply=i})(Kp);var _u=Kp.exports,Pk=function(e,t){for(var r=0;r<e.length;r+=1)if(!t(e[r],r,e))return!1;return!0},Rk=Object,Dk=function(e){return e&&typeof e=="object"&&(typeof e["[[ResourceValue]]"]>"u"||Rk(e["[[ResourceValue]]"])===e["[[ResourceValue]]"])&&(e["[[Hint]]"]==="SYNC-DISPOSE"||e["[[Hint]]"]==="ASYNC-DISPOSE")&&(typeof e["[[DisposeMethod]]"]=="function"||typeof e["[[DisposeMethod]]"]>"u")},Ok=Kt,zk=lu(),Lk=Pk,Mk=Dk,Nk=function(e){return e&&typeof e=="object"&&Ok(e,"[[DisposableResourceStack]]")&&zk(e["[[DisposableResourceStack]]"])&&(e["[[DisposableResourceStack]]"].length===0||Lk(e["[[DisposableResourceStack]]"],Mk))},Uk=Yt,Fk=function(e){if(e===null)return"Null";if(typeof e>"u")return"Undefined";if(Uk(e))return"Object";if(typeof e=="number")return"Number";if(typeof e=="boolean")return"Boolean";if(typeof e=="string")return"String"},Zk=Fk,Su=function(e){return typeof e=="symbol"?"Symbol":typeof e=="bigint"?"BigInt":Zk(e)},Hk=G,Vk=ci,jk=ai,Bk=function(e,t){if(!jk(t))throw new Hk("Assertion failed: P is not a Property Key, got "+Vk(t));return e[t]},Cd=G,Gk=Bk,Wk=li,qk=ai,Id=ci,Yk=function(e,t){if(!qk(t))throw new Cd("Assertion failed: P is not a Property Key");var r=Gk(e,t);if(r!=null){if(!Wk(r))throw new Cd(Id(t)+" is not a function: "+Id(r));return r}},cc={exports:{}},Kk=st,Jk=Kk,Pd=Jk("%Reflect.construct%",!0),Ko=Ws;try{Ko({},"",{"[[Get]]":function(){}})}catch{Ko=null}if(Ko&&Pd){var Rd={},Dd={};Ko(Dd,"length",{"[[Get]]":function(){throw Rd},"[[Enumerable]]":!0}),cc.exports=function(e){try{Pd(e,Dd)}catch(t){return t===Rd}}}else cc.exports=function(e){return typeof e=="function"&&!!e.prototype};var Xk=cc.exports,Tl=G,Od=li,Qk=Xk,eE=function(e){if(!Qk(e))throw new Tl("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 Tl("executor has already been called");t["[[Resolve]]"]=i,t["[[Reject]]"]=s});if(!Od(t["[[Resolve]]"])||!Od(t["[[Reject]]"]))throw new Tl("executor must provide valid resolve and reject functions");return{"[[Promise]]":r,"[[Resolve]]":t["[[Resolve]]"],"[[Reject]]":t["[[Reject]]"]}},zd=qt,tE=G,Cl=Pa,Ld=Yk,nE=eE,rE=Su,Md=du(),Nd=fu(),iE=function(e,t){if(rE(e)!=="Object")throw new tE("`V` must be an Object");if(t!=="SYNC-DISPOSE"&&t!=="ASYNC-DISPOSE")throw new zd("Assertion failed: `hint` must be `~SYNC-DISPOSE~` or `~ASYNC-DISPOSE~`");var r;if(t==="ASYNC-DISPOSE"&&Nd&&(r=Ld(e,Nd)),!r){if(!Md)throw new zd("`Symbol.dispose` is not supported");if(r=Ld(e,Md),typeof r<"u")return function(){var i=this;if(t==="ASYNC-DISPOSE"){var s=nE(Promise);try{Cl(r,i),Cl(s["[[Resolve]]"],void 0,[void 0])}catch(o){s["[[Reject]]"](o)}return s["[[Promise]]"]}Cl(r,i)}}return r},sE=qt,Il=G,oE=li,aE=Su,lE=iE,cE=function(e,t){if(t!=="SYNC-DISPOSE"&&t!=="ASYNC-DISPOSE")throw new sE("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"&&aE(e)!=="Object")throw new Il("`V` must be an Object, or `null` or `undefined`");if(r=lE(e,t),typeof r>"u")throw new Il("dispose method must not be `undefined` on `V` when an object `V` is provided")}else if(r=arguments[2],!oE(r))throw new Il("`method`, when provided, must be a function");return{"[[ResourceValue]]":e,"[[Hint]]":t,"[[DisposeMethod]]":r}},uE=qt,yo=G,hE=Nk,Ud=cE,dE=bn(),fE=dE("Array.prototype.push"),Jp=function(e,t,r){if(!hE(e))throw new yo("Assertion failed: `disposeCapability` must be a DisposeCapability Record");if(r!=="SYNC-DISPOSE"&&r!=="ASYNC-DISPOSE")throw new uE("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 yo("Assertion failed: `method`, when present, must be a function");if(!e["[[DisposableResourceStack]]"])throw new yo("Assertion failed: `disposeCapability.[[DisposableResourceStack]]` must not be ~EMPTY~");var s;if(arguments.length<4){if(t==null&&r==="SYNC_DISPOSE")return"UNUSED";s=Ud(t,r)}else{if(typeof t<"u")throw new yo("Assertion failed: `V` must be undefined when `method` is present");s=Ud(void 0,r,i)}return fE(e["[[DisposableResourceStack]]"],s),"UNUSED"},Pl,Fd;function ku(){if(Fd)return Pl;Fd=1;var n=st,e=_u,t=qt,r=n("%Promise.resolve%",!0),i=r&&e(r);return Pl=function(o,a){if(!i)throw new t("This environment does not support Promises.");return i(o,a)},Pl}var Rl,Zd;function pE(){if(Zd)return Rl;Zd=1;var n=st,e=qt,t=n("%Promise%",!0),r=Pa,i=ku(),s=Su;return Rl=function(a,c,u){if(typeof a<"u"&&s(a)!=="Object")throw new e("Assertion failed: `V` must be `undefined` or an Object");if(c!=="SYNC-DISPOSE"&&c!=="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(c==="ASYNC-DISPOSE")return i(t,d)},Rl}var Dl,Hd;function gE(){if(Hd)return Dl;Hd=1;var n=bu;return Dl=function(t){return new n("throw",t)},Dl}var mE=st,Ol=qt,Vd=G,yE=mE("%Promise%",!0),vE=bn(),jd=vE("Promise.prototype.then",!0),bE=bu,Bd=pE(),wE=wu,_E=ku(),Gd=gE(),SE=Up(),Xp=function(e,t){if(!(t instanceof bE))throw new Vd("`completion` must be a Completion Record");var r=e["[[DisposableResourceStack]]"];if(!r)throw new Vd("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 Ol("mixed hint stacks are not supported");for(var o=i==="ASYNC-DISPOSE"&&_E(yE,t),a=function(v){if(t.type()==="throw"){var y=t.value(),A=new SE(v,y);t=Gd(A)}else t=Gd(v)},c=i==="ASYNC-DISPOSE"&&function(y){return jd(o,function(){var A=Bd(y["[[ResourceValue]]"],y["[[Hint]]"],y["[[DisposeMethod]]"]);if(!A)throw new Ol("Assertion failed: non-`~ASYNC-DISPOSE~` resource returned a promise from Dispose");return jd(A,wE)},a)},u=r.length-1;u>=0;u-=1)if(i==="ASYNC-DISPOSE")o=c(r[u]);else{var d=r[u];try{var f=Bd(d["[[ResourceValue]]"],d["[[Hint]]"],d["[[DisposeMethod]]"]);if(f)throw new Ol("Assertion failed: `~SYNC-DISPOSE~` resource returned something from Dispose")}catch(v){a(v)}}return e["[[DisposableResourceStack]]"]=null,i==="ASYNC-DISPOSE"?o:t},Qp=function(){var e=[];return{"[[DisposableResourceStack]]":e}},Oa=ru,Eu=G,kE=Pa,ui=uu,EE=Ws,eg=li,$E=wu,je=vu,AE=Yp,tg=ar.supportsDescriptors,xE=_u,$u=Jp,TE=Xp,ng=Qp,Wd=du(),nt=function n(){if(!(this instanceof n)||je.has(this,"[[DisposableState]]")||je.has(this,"[[DisposeCapability]]"))throw new Eu("can only be used with new");je.set(this,"[[DisposableState]]","PENDING"),je.set(this,"[[DisposeCapability]]",ng())},rg=function(){var e=this;return je.assert(e,"[[DisposableState]]"),je.get(e,"[[DisposableState]]")==="DISPOSED"},Ks=xE(rg);tg?EE(nt.prototype,"disposed",{"[[Configurable]]":!0,"[[Enumerable]]":!1,"[[Get]]":rg}):nt.prototype.disposed=!1;var ig=function(e){je.set(e,"[[DisposableState]]","DISPOSED"),tg||(e.disposed=!0)};ui(nt.prototype,"dispose",function(){var e=this;if(!Ks(e))return ig(e),TE(je.get(e,"[[DisposeCapability]]"),$E())["?"]()});ui(nt.prototype,"use",function(e){var t=this;if(Ks(t))throw new Oa("a disposed stack can not use anything new");return $u(je.get(t,"[[DisposeCapability]]"),e,"SYNC-DISPOSE"),e});ui(nt.prototype,"adopt",function(e,t){var r=this;if(Ks(r))throw new Oa("a disposed stack can not use anything new");if(!eg(t))throw new Eu("`onDispose` must be a function");var i=function(){return kE(t,void 0,[e])};return $u(je.get(r,"[[DisposeCapability]]"),void 0,"SYNC-DISPOSE",i),e});ui(nt.prototype,"defer",function(e){var t=this;if(Ks(t))throw new Oa("a disposed stack can not defer anything new");if(!eg(e))throw new Eu("`onDispose` must be a function");$u(je.get(t,"[[DisposeCapability]]"),void 0,"SYNC-DISPOSE",e)});ui(nt.prototype,"move",function(){var e=this;if(Ks(e))throw new Oa("a disposed stack can not use anything new");var t=new nt;return je.set(t,"[[DisposeCapability]]",je.get(e,"[[DisposeCapability]]")),je.set(e,"[[DisposeCapability]]",ng()),ig(e),t});Wd&&ui(nt.prototype,Wd,nt.prototype.dispose);AE(nt.prototype,"DisposableStack");var CE=nt,IE=CE,PE=function(){return typeof DisposableStack=="function"?DisposableStack:IE},RE=ar,DE=tu(),OE=PE,zE=function(){var e=OE();return RE(DE,{DisposableStack:e},{DisposableStack:!0}),e},LE=st,za=ru,Au=G,qd=LE("%Promise%",!0),xu=Jp,ME=Pa,hi=uu,NE=Ws,UE=Xp,sg=li,og=Qp,FE=wu,Yd=ku(),Be=vu,ZE=Yp,ag=ar.supportsDescriptors,HE=_u,VE=bn(),jE=VE("Promise.prototype.then",!0),Kd=fu(),rt=function n(){if(!(this instanceof n)||Be.has(this,"[[AsyncDisposableState]]")||Be.has(this,"[[DisposeCapability]]"))throw new Au("can only be used with new");Be.set(this,"[[AsyncDisposableState]]","pending"),Be.set(this,"[[DisposeCapability]]",og())},lg=function(){var e=this;return Be.assert(e,"[[AsyncDisposableState]]"),Be.get(e,"[[AsyncDisposableState]]")==="disposed"},Js=HE(lg);ag?NE(rt.prototype,"disposed",{"[[Configurable]]":!0,"[[Enumerable]]":!1,"[[Get]]":lg}):rt.prototype.disposed=!1;var cg=function(e){Be.set(e,"[[AsyncDisposableState]]","disposed"),ag||(e.disposed=!0)};hi(rt.prototype,"disposeAsync",function(){var e=this;return Js(e)?Yd(qd):(cg(e),jE(Yd(qd,UE(Be.get(e,"[[DisposeCapability]]"),FE())),function(t){return t["?"]()}))});hi(rt.prototype,"use",function(e){var t=this;if(Js(t))throw new za("a disposed stack can not use anything new");return xu(Be.get(t,"[[DisposeCapability]]"),e,"ASYNC-DISPOSE"),e});hi(rt.prototype,"adopt",function(e,t){var r=this;if(Js(r))throw new za("a disposed stack can not use anything new");if(!sg(t))throw new Au("`onDisposeAsync` must be a function");var i=function(){return ME(t,void 0,[e])};return i.value=e,xu(Be.get(r,"[[DisposeCapability]]"),void 0,"ASYNC-DISPOSE",i),e});hi(rt.prototype,"defer",function(e){var t=this;if(Js(t))throw new za("a disposed stack can not defer anything new");if(!sg(e))throw new Au("`onDispose` must be a function");xu(Be.get(t,"[[DisposeCapability]]"),void 0,"ASYNC-DISPOSE",e)});hi(rt.prototype,"move",function(){var e=this;if(Js(e))throw new za("a disposed stack can not use anything new");var t=new rt;return Be.set(t,"[[DisposeCapability]]",Be.get(e,"[[DisposeCapability]]")),Be.set(e,"[[DisposeCapability]]",og()),cg(e),t});Kd&&hi(rt.prototype,Kd,rt.prototype.disposeAsync);ZE(rt.prototype,"AsyncDisposableStack");var BE=rt,GE=BE,WE=function(){return typeof AsyncDisposableStack=="function"?AsyncDisposableStack:GE},qE=ar,YE=tu(),KE=WE,JE=function(){var e=KE();return qE(YE,{AsyncDisposableStack:e},{AsyncDisposableStack:!0}),e},XE=q_,QE=nS,e0=zE,t0=JE,n0=function(){XE(),QE(),e0(),t0()};n0();const Jd=new WeakMap;function r0(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 Xd(){return new Error("register(Key, factory) requires a factory function. Wrap existing instances as () => instance.")}function i0(){return new Error("register(Key, factory) does not accept async factories. Await setup before registering.")}class s0{constructor(){b(this,"entries",new Map);b(this,"constructionStack",[])}register(e,t){if(t===void 0){if(typeof e!="function")throw Xd();this.validateClassRegistration(e),this.storeFactory(e,()=>this.instantiateClass(e));return}if(typeof t!="function")throw Xd();if(t.constructor.name==="AsyncFunction")throw i0();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=Jd.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=Jd.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(r0(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 Ge=new s0,o0=new Set(["target","currentTarget","eventPhase","defaultPrevented","isTrusted","timeStamp","srcElement","returnValue","cancelBubble","NONE","CAPTURING_PHASE","AT_TARGET","BUBBLING_PHASE","composedPath","stopPropagation","stopImmediatePropagation","preventDefault","initEvent"]);function a0(n){for(const e of Object.keys(n))if(o0.has(e))throw new Error(`Event payload key "${e}" is reserved; choose a different property name`)}function l0(n,e){a0(e);for(const t of Object.keys(e))Object.defineProperty(n,t,{value:e[t],writable:!0,enumerable:!0,configurable:!0})}function pt(){class n extends Event{constructor(t,r){const{type:i,bubbles:s,cancelable:o,composed:a,...c}=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}),l0(this,c)}}return n}class gt extends globalThis.EventTarget{}function c0(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);_(this,t,!1);c0(this,()=>l(this,t),()=>{E(this,t,!0)})}[Symbol.dispose](){this.dispose()}get disposed(){return l(this,t)}}return t=new WeakMap,e}const u0=pt(),h0=pt(),No=pt(),ug="0123456789ABCDEFGHJKMNPQRSTVWXYZ",Jo=32,d0=16,hg=10,Qd=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()*Jo)%Jo;return ug.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=hg){if(isNaN(n))throw new Oi(zn.EncodeTimeValueMalformed,`Time must be a number: ${n}`);if(n>Qd)throw new Oi(zn.EncodeTimeSizeExceeded,`Cannot encode a time larger than ${Qd}: ${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%Jo,r=ug.charAt(t)+r,n=(n-t)/Jo;return r}function v0(){return typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope}function Tu(n,e){const t=p0(),r=Date.now();return y0(r,hg)+m0(d0,t)}const Ct=4,Xe=6,dg=2,uc=2,b0=Ct,w0=Xe,Cu="auto",fn="auto",Pn=120,ef=75,pe=16,tr=Pn*Ct+pe*(Ct-1),Xo=Pn*Xe+pe*(Xe-1),_0=200,S0=4,vo=150,k0=10,tf=2,E0=4;function fg(n){return mg(n)}function pg(n,e){return mg(n.flatMap(t=>vg(t,e)))}function gg(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}bg(r,"strip",e,t)}return{valid:e.length===0,errors:e}}function Wi(n){const e=fg(n),t=gg(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 mg(n){const e=[];for(const t of n){const r=yg(t);for(const i of r){if(i.type==="row"){e.push(...i.children.map(Gt));continue}e.push(i)}}return e}function yg(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=yg(t);for(const i of r){if(i.type==="stack"){e.push(...i.children.map(hc));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?[hc(e[0])]:[{...n,children:e}]}}}function vg(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=>vg(r,e).filter(s=>s.type!=="stack"));return t.length===0?[]:t.length===1?[hc(t[0])]:[{...n,children:t}]}}}function bg(n,e,t,r){switch(n.type){case"card":wg(n,e,t,r);return;case"row":$0(n,e,t,r);return;case"stack":A0(n,e,t,r);return}}function wg(n,e,t,r){Iu(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`),_g(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<dg&&t.push(`Row child ${n.id} must be at least 2 columns wide`)}function $0(n,e,t,r){if(Iu(n.id,t),e!=="stack"&&t.push(`Row ${n.id} may only appear inside a stack`),_g(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}wg(s,"row",t,r),i+=Rn(s.width)}i!==Ct&&t.push(`Row ${n.id} children must sum to 4 columns`)}function A0(n,e,t,r){if(Iu(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(bg(a,"stack",t,r),a.height===fn){s+=1;continue}i+=a.height}if(i>Xe&&t.push(`Stack ${n.id} exceeds the 6-row budget`),s===0)return;const o=Xe-i;if(o<s*uc||o%s!==0){t.push(`Stack ${n.id} has auto-height children that cannot resolve to whole height >= 2`);return}o/s<uc&&t.push(`Stack ${n.id} has auto-height children below the minimum row size`)}function Iu(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===Cu||Number.isInteger(n)&&n>=dg&&n<=b0}function _g(n,e=w0){return n===fn||Number.isInteger(n)&&n>=uc&&n<=e}function Rn(n){return n===Cu?Ct: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:Sg(n.height,Xe)}]};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 c of s.children)t.push({id:c.id,artifactID:c.artifactID,col:a,row:r,width:Rn(c.width),height:o}),a+=Rn(c.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?(Xe-e)/t:0;return n.map(i=>Sg(i.height,r))}function Sg(n,e){return n===fn?e:n}function Gt(n){return{...n}}function hc(n){return n.type==="card"?Gt(n):{...n,children:n.children.map(Gt)}}function kg(n,e={}){return{id:e.id??Tu(),type:"card",artifactID:n,width:e.width??Cu,height:e.height??fn}}function Eg(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 nf(n){return n.layout.flatMap(Ag)}function Ag(n){switch(n.type){case"card":return[n.artifactID];case"row":return n.children.map(e=>e.artifactID);case"stack":return n.children.flatMap(Ag)}}const Q=pt(),xg=pt(),Ei=pt(),I0=pt();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 zl(r,r.statusText),r.status)}async requestText(e,t){const r=await this.request(e,t);if(!r.ok)throw this.createError(await zl(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 zl(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 zl(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 Tg(n){return n.map(e=>`${e.name} (${e.id})`).join(", ")}var Et,ua,Cg;class M0{constructor(e){_(this,ua);_(this,Et);E(this,Et,e)}list(){return l(this,Et).requestJSON("GET","/screens")}async get(e={}){const t=await m(this,ua,Cg).call(this,e.screenID);return l(this,Et).requestJSON("GET",`/screens/${encodeURIComponent(t)}`)}create(e){const t={name:e.name};return e.id!==void 0&&(t.id=e.id),l(this,Et).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),l(this,Et).requestJSON("PATCH",`/screens/${encodeURIComponent(e.screenID)}`,t)}remove(e){return l(this,Et).requestJSON("DELETE",`/screens/${encodeURIComponent(e.screenID)}`)}}Et=new WeakMap,ua=new WeakSet,Cg=async function(e){if(e!==void 0)return e;const{screens:t}=await this.list();if(t.length===1)return t[0].id;throw l(this,Et).createError(`screenID is required when multiple screens exist. Available screens: ${Tg(t)}`)};var Ze,ns,ha,Ig;class N0{constructor(e,t){_(this,ha);_(this,Ze);_(this,ns);E(this,Ze,e),E(this,ns,t)}async create(e){const t=await m(this,ha,Ig).call(this,e.screenID);return l(this,Ze).requestJSON("POST",`/screens/${encodeURIComponent(t)}/artifact`,{type:e.type,title:e.title,externalFilePath:e.externalFilePath})}get(e){return l(this,Ze).requestJSON("GET",`/artifacts/${encodeURIComponent(e.artifactID)}`)}update(e){const t={};return e.title!==void 0&&(t.title=e.title),l(this,Ze).requestJSON("PATCH",`/artifacts/${encodeURIComponent(e.artifactID)}`,t)}edit(e){return l(this,Ze).requestJSON("POST",`/artifacts/${encodeURIComponent(e.artifactID)}/edit`)}commitPending(e){return l(this,Ze).requestJSON("POST",`/artifacts/${encodeURIComponent(e.artifactID)}/commit`)}abandonPending(e){return l(this,Ze).requestVoid("POST",`/artifacts/${encodeURIComponent(e.artifactID)}/abandon`)}remove(e){return l(this,Ze).requestJSON("DELETE",`/screens/${encodeURIComponent(e.screenID)}/artifacts/${encodeURIComponent(e.artifactID)}`)}getContent(e){return l(this,Ze).requestText("GET",`/artifacts/${encodeURIComponent(e.artifactID)}/content`)}putContent(e){return l(this,Ze).requestRawVoid("PUT",`/artifacts/${encodeURIComponent(e.artifactID)}/content`,e.content)}}Ze=new WeakMap,ns=new WeakMap,ha=new WeakSet,Ig=async function(e){if(e!==void 0)return e;const{screens:t}=await l(this,ns).list();if(t.length===1)return t[0].id;throw l(this,Ze).createError(`screenID is required when multiple screens exist. Available screens: ${Tg(t)}`)};var rs;class U0{constructor(e){_(this,rs);E(this,rs,e)}async list(){const{views:e}=await l(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");_(this,tn);E(this,tn,new z0(e,t)),this.screens=new M0(l(this,tn)),this.artifacts=new N0(l(this,tn),this.screens),this.views=new U0(l(this,tn))}health(){return l(this,tn).requestJSON("GET","/health")}}tn=new WeakMap;const Z0={focusCommandInput:{label:"Focus Command Input",trigger:{key:"k",meta:!0}}},H0=di(gt);var Mn,He,Nn,ze,nn,rn,J,Sr,Pg,is,Rg,Dg,Og,zg,dc,fc,pc,Lg;class V0 extends H0{constructor(t){var i;super();_(this,J);b(this,"id");b(this,"server");_(this,Mn);_(this,He,new Map);_(this,Nn);_(this,ze);_(this,nn);_(this,rn,null);_(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,Rg).call(this,r.screen);break;case"artifact-created":r.screenID===this.id&&m(this,J,Dg).call(this,r.artifact);break;case"artifact-updated":m(this,J,Og).call(this,r.artifact);break;case"artifact-removed":r.screenID===this.id&&m(this,J,zg).call(this,r.artifactID);break;case"artifact-content-changed":l(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=l(this,Mn).get().screens[this.id])==null?void 0:i.scrollPosition)??0;E(this,nn,Math.max(0,r)),this.server.addEventListener("server-event",l(this,is)),m(this,J,Pg).call(this)}get name(){return l(this,Nn)}get layout(){return l(this,ze)}get scrollPosition(){return l(this,nn)}get artifacts(){return l(this,He)}setScrollPosition(t){m(this,J,Sr).call(this);const r=Math.max(0,t);r!==l(this,nn)&&(E(this,nn,r),m(this,J,Lg).call(this),this.dispatchEvent(new Q("change")))}setLayout(t){m(this,J,Sr).call(this);const r=fg(t);if(!gg(r).valid)return;const s=m(this,J,fc).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=l(this,rn))==null?void 0:o.layout)===r&&(E(this,rn,null),m(this,J,pc).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),!l(this,He).has(t))return;const r=m(this,J,fc).call(this);m(this,J,dc).call(this,t),this.dispatchEvent(new Q("change")),this.server.client.artifacts.remove({artifactID:t,screenID:this.id}).catch(()=>{this.disposed||(m(this,J,pc).call(this,r),this.dispatchEvent(new Q("change")))})}dispose(){this.server.removeEventListener("server-event",l(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")},Pg=async function(){try{const t=await this.server.client.screens.get({screenID:this.id});if(this.disposed)return;for(const r of t.artifacts)l(this,He).set(r.id,r);this.dispatchEvent(new Q("change"))}catch{}},is=new WeakMap,Rg=function(t){l(this,rn)&&E(this,rn,null),E(this,Nn,t.name),E(this,ze,structuredClone(t.layout)),this.dispatchEvent(new Q("change"))},Dg=function(t){Eg(l(this,ze),t.id)||E(this,ze,[...l(this,ze),kg(t.id)]),l(this,He).set(t.id,t),this.dispatchEvent(new Q("change"))},Og=function(t){const r=l(this,He).get(t.id);r&&(l(this,He).set(t.id,{...r,...t}),this.dispatchEvent(new Q("change")))},zg=function(t){m(this,J,dc).call(this,t)&&this.dispatchEvent(new Q("change"))},dc=function(t){const r=l(this,He).delete(t),i=nf({layout:l(this,ze)}).length,s=pg(l(this,ze),t),o=nf({layout:s}).length;return E(this,ze,s),r||i!==o},fc=function(){return{layout:structuredClone(l(this,ze)),artifacts:new Map([...l(this,He).entries()].map(([t,r])=>[t,structuredClone(r)]))}},pc=function(t){E(this,ze,structuredClone(t.layout)),l(this,He).clear();for(const[r,i]of t.artifacts)l(this,He).set(r,structuredClone(i))},Lg=function(){const t=l(this,Mn).get();l(this,Mn).set({...t,screens:{...t.screens,[this.id]:{scrollPosition:l(this,nn)}}})};const j0=di(gt);var Qe,Mt,at,ss,os,as,Dr,Uo;class B0 extends j0{constructor(t){super();_(this,Dr);_(this,Qe);_(this,Mt);_(this,at,null);_(this,ss,()=>{this.disposed||m(this,Dr,Uo).call(this)});_(this,os,()=>{this.disposed||m(this,Dr,Uo).call(this)});_(this,as,t=>{var i;if(this.disposed)return;const r=t.event;r.type==="screen-removed"&&((i=l(this,at))==null?void 0:i.id)===r.screenID&&this.clearActive()});E(this,Qe,t.localStore),E(this,Mt,t.serverManager),l(this,Qe).addEventListener("change",l(this,ss)),l(this,Mt).addEventListener("change",l(this,os)),l(this,Mt).addEventListener("server-event",l(this,as)),m(this,Dr,Uo).call(this)}get activeScreen(){return l(this,at)}setActive(t,r){const i=l(this,Qe).get();i.activeServerURL===t&&i.activeScreenID===r||l(this,Qe).set({...i,activeServerURL:t,activeScreenID:r})}clearActive(){const t=l(this,Qe).get();t.activeScreenID!==null&&l(this,Qe).set({...t,activeScreenID:null})}dispose(){var t;l(this,Qe).removeEventListener("change",l(this,ss)),l(this,Mt).removeEventListener("change",l(this,os)),l(this,Mt).removeEventListener("server-event",l(this,as)),(t=l(this,at))==null||t.dispose(),E(this,at,null)}}Qe=new WeakMap,Mt=new WeakMap,at=new WeakMap,ss=new WeakMap,os=new WeakMap,as=new WeakMap,Dr=new WeakSet,Uo=function(){var c,u,d;const{activeServerURL:t,activeScreenID:r}=l(this,Qe).get(),i=t?l(this,Mt).servers.get(t)??null:null,s=i&&r?i.screens.get(r)??null:null,o=((c=l(this,at))==null?void 0:c.id)??null,a=(s==null?void 0:s.id)??null;o===a&&((u=l(this,at))==null?void 0:u.server)===i||((d=l(this,at))==null||d.dispose(),E(this,at,i&&s?new V0({screen:s,server:i,localStore:l(this,Qe)}):null),this.dispatchEvent(new u0("active-screen-changed")))};const G0="Local",W0="store-";function kt(n){return new URL(n).origin}function q0(n){return{servers:[{url:kt(n),name:G0}],activeServerURL:null,activeScreenID:null,screens:{}}}var Un,Fn,Zn;class Y0 extends gt{constructor(t,r,i={}){super();_(this,Un);_(this,Fn);_(this,Zn);E(this,Un,`${W0}${t}`),E(this,Fn,i.storage??K0());const s=l(this,Fn).getItem(l(this,Un));s===null?(E(this,Zn,r),l(this,Fn).setItem(l(this,Un),JSON.stringify(r))):E(this,Zn,JSON.parse(s))}get(){return l(this,Zn)}set(t){E(this,Zn,t),l(this,Fn).setItem(l(this,Un),JSON.stringify(t)),this.dispatchEvent(new Q("change"))}}Un=new WeakMap,Fn=new WeakMap,Zn=new WeakMap;function K0(){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,c){if(a._zod||Object.defineProperty(a,"_zod",{value:{def:c,constr:o,traits:new Set},enumerable:!1}),a._zod.traits.has(n))return;a._zod.traits.add(n),e(a,c);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 c;const u=t!=null&&t.Parent?new s:this;r(u,a),(c=u._zod).deferred??(c.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 c,u;return t!=null&&t.Parent&&a instanceof t.Parent?!0:(u=(c=a==null?void 0:a._zod)==null?void 0:c.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 Mg extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name="ZodEncodeError"}}const Ng={};function pn(n){return Ng}function Ug(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 gc(n,e){return typeof e=="bigint"?e.toString():e}function Pu(n){return{get value(){{const e=n();return Object.defineProperty(this,"value",{value:e}),e}}}}function Ru(n){return n==null}function Du(n){const e=n.startsWith("^")?1:0,t=n.endsWith("$")?n.length-1:n.length;return n.slice(e,t)}function J0(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 c=r.match(/\d?e-(\d?)/);c!=null&&c[1]&&(i=Number.parseInt(c[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 rf=Symbol("evaluating");function X(n,e,t){let r;Object.defineProperty(n,e,{get(){if(r!==rf)return r===void 0&&(r=rf,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 sf(n){return JSON.stringify(n)}function X0(n){return n.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}const Fg="captureStackTrace"in Error?Error.captureStackTrace:(...n)=>{};function Qo(n){return typeof n=="object"&&n!==null&&!Array.isArray(n)}const Q0=Pu(()=>{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(Qo(n)===!1)return!1;const e=n.constructor;if(e===void 0||typeof e!="function")return!0;const t=e.prototype;return!(Qo(t)===!1||Object.prototype.hasOwnProperty.call(t,"isPrototypeOf")===!1)}function Zg(n){return Qr(n)?{...n}:Array.isArray(n)?[...n]:n}const e$=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 t$(n){return Object.keys(n).filter(e=>n[e]._zod.optin==="optional"&&n[e]._zod.optout==="optional")}const n$={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 r$(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 i$(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 s$(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 o$(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 a$(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 l$(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,c={...a};if(t)for(const u in t){if(!(u in a))throw new Error(`Unrecognized key: "${u}"`);t[u]&&(c[u]=n?new n({type:"optional",innerType:a[u]}):a[u])}else for(const u in a)c[u]=n?new n({type:"optional",innerType:a[u]}):a[u];return cr(this,"shape",c),c},checks:[]});return Sn(e,o)}function c$(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 bo(n){return typeof n=="string"?n:n==null?void 0:n.message}function gn(n,e,t){var i,s,o,a,c,u;const r={...n,path:n.path??[]};if(!n.message){const d=bo((o=(s=(i=n.inst)==null?void 0:i._zod.def)==null?void 0:s.error)==null?void 0:o.call(s,n))??bo((a=e==null?void 0:e.error)==null?void 0:a.call(e,n))??bo((c=t.customError)==null?void 0:c.call(t,n))??bo((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 Ou(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 Hg=(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,gc,2),Object.defineProperty(n,"toString",{value:()=>n.message,enumerable:!1})},Vg=$("$ZodError",Hg),jg=$("$ZodError",Hg,{Parent:Error});function u$(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 h$(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 c=s.path[a];a===s.path.length-1?(o[c]=o[c]||{_errors:[]},o[c]._errors.push(e(s))):o[c]=o[c]||{_errors:[]},o=o[c],a++}}};return r(n),t}const zu=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(c=>gn(c,s,pn())));throw Fg(a,i==null?void 0:i.callee),a}return o.value},Lu=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(c=>gn(c,s,pn())));throw Fg(a,i==null?void 0:i.callee),a}return o.value},La=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??Vg)(s.issues.map(o=>gn(o,i,pn())))}:{success:!0,data:s.value}},d$=La(jg),Ma=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}},f$=Ma(jg),p$=n=>(e,t,r)=>{const i=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return zu(n)(e,t,i)},g$=n=>(e,t,r)=>zu(n)(e,t,r),m$=n=>async(e,t,r)=>{const i=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return Lu(n)(e,t,i)},y$=n=>async(e,t,r)=>Lu(n)(e,t,r),v$=n=>(e,t,r)=>{const i=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return La(n)(e,t,i)},b$=n=>(e,t,r)=>La(n)(e,t,r),w$=n=>async(e,t,r)=>{const i=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return Ma(n)(e,t,i)},_$=n=>async(e,t,r)=>Ma(n)(e,t,r),S$=/^[cC][^\s-]{8,}$/,k$=/^[0-9a-z]+$/,E$=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,$$=/^[0-9a-vA-V]{20}$/,A$=/^[A-Za-z0-9]{27}$/,x$=/^[a-zA-Z0-9_-]{21}$/,T$=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,C$=/^([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})$/,of=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)$/,I$=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,P$="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function R$(){return new RegExp(P$,"u")}const D$=/^(?:(?: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])$/,O$=/^(([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}|:))$/,z$=/^((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])$/,L$=/^(([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])$/,M$=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Bg=/^[A-Za-z0-9_-]*$/,N$=/^\+[1-9]\d{6,14}$/,Gg="(?:(?:\\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])))",U$=new RegExp(`^${Gg}$`);function Wg(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 F$(n){return new RegExp(`^${Wg(n)}$`)}function Z$(n){const e=Wg({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(`^${Gg}T(?:${r})$`)}const H$=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}$`)},V$=/^-?\d+$/,qg=/^-?\d+(?:\.\d+)?$/,j$=/^(?:true|false)$/i,B$=/^[^A-Z]*$/,G$=/^[^a-z]*$/,We=$("$ZodCheck",(n,e)=>{var t;n._zod??(n._zod={}),n._zod.def=e,(t=n._zod).onattach??(t.onattach=[])}),Yg={number:"number",bigint:"bigint",object:"date"},Kg=$("$ZodCheckLessThan",(n,e)=>{We.init(n,e);const t=Yg[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})}}),Jg=$("$ZodCheckGreaterThan",(n,e)=>{We.init(n,e);const t=Yg[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})}}),W$=$("$ZodCheckMultipleOf",(n,e)=>{We.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):J0(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})}}),q$=$("$ZodCheckNumberFormat",(n,e)=>{var o;We.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]=n$[e.format];n._zod.onattach.push(a=>{const c=a._zod.bag;c.format=e.format,c.minimum=i,c.maximum=s,t&&(c.pattern=V$)}),n._zod.check=a=>{const c=a.value;if(t){if(!Number.isInteger(c)){a.issues.push({expected:r,format:e.format,code:"invalid_type",continue:!1,input:c,inst:n});return}if(!Number.isSafeInteger(c)){c>0?a.issues.push({input:c,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:n,origin:r,inclusive:!0,continue:!e.abort}):a.issues.push({input:c,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:n,origin:r,inclusive:!0,continue:!e.abort});return}}c<i&&a.issues.push({origin:"number",input:c,code:"too_small",minimum:i,inclusive:!0,inst:n,continue:!e.abort}),c>s&&a.issues.push({origin:"number",input:c,code:"too_big",maximum:s,inclusive:!0,inst:n,continue:!e.abort})}}),Y$=$("$ZodCheckMaxLength",(n,e)=>{var t;We.init(n,e),(t=n._zod.def).when??(t.when=r=>{const i=r.value;return!Ru(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=Ou(i);r.issues.push({origin:o,code:"too_big",maximum:e.maximum,inclusive:!0,input:i,inst:n,continue:!e.abort})}}),K$=$("$ZodCheckMinLength",(n,e)=>{var t;We.init(n,e),(t=n._zod.def).when??(t.when=r=>{const i=r.value;return!Ru(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=Ou(i);r.issues.push({origin:o,code:"too_small",minimum:e.minimum,inclusive:!0,input:i,inst:n,continue:!e.abort})}}),J$=$("$ZodCheckLengthEquals",(n,e)=>{var t;We.init(n,e),(t=n._zod.def).when??(t.when=r=>{const i=r.value;return!Ru(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=Ou(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})}}),Na=$("$ZodCheckStringFormat",(n,e)=>{var t,r;We.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=()=>{})}),X$=$("$ZodCheckRegex",(n,e)=>{Na.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=B$),Na.init(n,e)}),eA=$("$ZodCheckUpperCase",(n,e)=>{e.pattern??(e.pattern=G$),Na.init(n,e)}),tA=$("$ZodCheckIncludes",(n,e)=>{We.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})}}),nA=$("$ZodCheckStartsWith",(n,e)=>{We.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})}}),rA=$("$ZodCheckEndsWith",(n,e)=>{We.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})}}),iA=$("$ZodCheckOverwrite",(n,e)=>{We.init(n,e),n._zod.check=t=>{t.value=e.tx(t.value)}});class sA{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
- `).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 oA={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=oA;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,c,u)=>{let d=Cr(a),f;for(const v of c){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,c,u)=>{if(Cr(a))return a.aborted=!0,a;const d=s(c,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,c)=>{if(c.skipChecks)return n._zod.parse(a,c);if(c.direction==="backward"){const d=n._zod.parse({value:a.value,issues:[]},{...c,skipChecks:!0});return d instanceof Promise?d.then(f=>o(f,a,c)):o(d,a,c)}const u=n._zod.parse(a,c);if(u instanceof Promise){if(c.async===!1)throw new Rr;return u.then(d=>s(d,r,c))}return s(u,r,c)}}X(n,"~standard",()=>({validate:s=>{var o;try{const a=d$(n,s);return a.success?{value:a.data}:{issues:(o=a.error)==null?void 0:o.issues}}catch{return f$(n,s).then(c=>{var u;return c.success?{value:c.data}:{issues:(u=c.error)==null?void 0:u.issues}})}},vendor:"zod",version:1}))}),Mu=$("$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()??H$(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)=>{Na.init(n,e),Mu.init(n,e)}),aA=$("$ZodGUID",(n,e)=>{e.pattern??(e.pattern=C$),ae.init(n,e)}),lA=$("$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=of(r))}else e.pattern??(e.pattern=of());ae.init(n,e)}),cA=$("$ZodEmail",(n,e)=>{e.pattern??(e.pattern=I$),ae.init(n,e)}),uA=$("$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})}}}),hA=$("$ZodEmoji",(n,e)=>{e.pattern??(e.pattern=R$()),ae.init(n,e)}),dA=$("$ZodNanoID",(n,e)=>{e.pattern??(e.pattern=x$),ae.init(n,e)}),fA=$("$ZodCUID",(n,e)=>{e.pattern??(e.pattern=S$),ae.init(n,e)}),pA=$("$ZodCUID2",(n,e)=>{e.pattern??(e.pattern=k$),ae.init(n,e)}),gA=$("$ZodULID",(n,e)=>{e.pattern??(e.pattern=E$),ae.init(n,e)}),mA=$("$ZodXID",(n,e)=>{e.pattern??(e.pattern=$$),ae.init(n,e)}),yA=$("$ZodKSUID",(n,e)=>{e.pattern??(e.pattern=A$),ae.init(n,e)}),vA=$("$ZodISODateTime",(n,e)=>{e.pattern??(e.pattern=Z$(e)),ae.init(n,e)}),bA=$("$ZodISODate",(n,e)=>{e.pattern??(e.pattern=U$),ae.init(n,e)}),wA=$("$ZodISOTime",(n,e)=>{e.pattern??(e.pattern=F$(e)),ae.init(n,e)}),_A=$("$ZodISODuration",(n,e)=>{e.pattern??(e.pattern=T$),ae.init(n,e)}),SA=$("$ZodIPv4",(n,e)=>{e.pattern??(e.pattern=D$),ae.init(n,e),n._zod.bag.format="ipv4"}),kA=$("$ZodIPv6",(n,e)=>{e.pattern??(e.pattern=O$),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})}}}),EA=$("$ZodCIDRv4",(n,e)=>{e.pattern??(e.pattern=z$),ae.init(n,e)}),$A=$("$ZodCIDRv6",(n,e)=>{e.pattern??(e.pattern=L$),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 Xg(n){if(n==="")return!0;if(n.length%4!==0)return!1;try{return atob(n),!0}catch{return!1}}const AA=$("$ZodBase64",(n,e)=>{e.pattern??(e.pattern=M$),ae.init(n,e),n._zod.bag.contentEncoding="base64",n._zod.check=t=>{Xg(t.value)||t.issues.push({code:"invalid_format",format:"base64",input:t.value,inst:n,continue:!e.abort})}});function xA(n){if(!Bg.test(n))return!1;const e=n.replace(/[-_]/g,r=>r==="-"?"+":"/"),t=e.padEnd(Math.ceil(e.length/4)*4,"=");return Xg(t)}const TA=$("$ZodBase64URL",(n,e)=>{e.pattern??(e.pattern=Bg),ae.init(n,e),n._zod.bag.contentEncoding="base64url",n._zod.check=t=>{xA(t.value)||t.issues.push({code:"invalid_format",format:"base64url",input:t.value,inst:n,continue:!e.abort})}}),CA=$("$ZodE164",(n,e)=>{e.pattern??(e.pattern=N$),ae.init(n,e)});function IA(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 PA=$("$ZodJWT",(n,e)=>{ae.init(n,e),n._zod.check=t=>{IA(t.value,e.alg)||t.issues.push({code:"invalid_format",format:"jwt",input:t.value,inst:n,continue:!e.abort})}}),Qg=$("$ZodNumber",(n,e)=>{he.init(n,e),n._zod.pattern=n._zod.bag.pattern??qg,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}}),RA=$("$ZodNumberFormat",(n,e)=>{q$.init(n,e),Qg.init(n,e)}),DA=$("$ZodBoolean",(n,e)=>{he.init(n,e),n._zod.pattern=j$,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}}),OA=$("$ZodUnknown",(n,e)=>{he.init(n,e),n._zod.parse=t=>t}),zA=$("$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 af(n,e,t){n.issues.length&&e.issues.push(...Ir(t,n.issues)),e.value[t]=n.value}const LA=$("$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],c=e.element._zod.run({value:a,issues:[]},r);c instanceof Promise?s.push(c.then(u=>af(u,t,o))):af(c,t,o)}return s.length?Promise.all(s).then(()=>t):t}});function ea(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 em(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=t$(n.shape);return{...n,keys:e,keySet:new Set(e),numKeys:e.length,optionalKeys:new Set(t)}}function tm(n,e,t,r,i,s){const o=[],a=i.keySet,c=i.catchall._zod,u=c.def.type,d=c.optout==="optional";for(const f in e){if(a.has(f))continue;if(u==="never"){o.push(f);continue}const v=c.run({value:e[f],issues:[]},r);v instanceof Promise?n.push(v.then(y=>ea(y,t,f,e,d))):ea(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 MA=$("$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 c={...a};return Object.defineProperty(e,"shape",{value:c}),c}})}const r=Pu(()=>em(e));X(n._zod,"propValues",()=>{const a=e.shape,c={};for(const u in a){const d=a[u]._zod;if(d.values){c[u]??(c[u]=new Set);for(const f of d.values)c[u].add(f)}}return c});const i=Qo,s=e.catchall;let o;n._zod.parse=(a,c)=>{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:[]},c);k instanceof Promise?d.push(k.then(I=>ea(I,a,v,u,A))):ea(k,a,v,u,A)}return s?tm(d,u,a,c,r.value,n):d.length?Promise.all(d).then(()=>a):a}}),NA=$("$ZodObjectJIT",(n,e)=>{MA.init(n,e);const t=n._zod.parse,r=Pu(()=>em(e)),i=v=>{var le;const y=new sA(["shape","payload","ctx"]),A=r.value,k=M=>{const Z=sf(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=sf(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
- if (${Z}.issues.length) {
8
- if (${U} in input) {
9
- payload.issues = payload.issues.concat(${Z}.issues.map(iss => ({
10
- ...iss,
11
- path: iss.path ? [${U}, ...iss.path] : [${U}]
12
- })));
13
- }
14
- }
15
-
16
- if (${Z}.value === undefined) {
17
- if (${U} in input) {
18
- newResult[${U}] = undefined;
19
- }
20
- } else {
21
- newResult[${U}] = ${Z}.value;
22
- }
23
-
24
- `):y.write(`
25
- if (${Z}.issues.length) {
26
- payload.issues = payload.issues.concat(${Z}.issues.map(iss => ({
27
- ...iss,
28
- path: iss.path ? [${U}, ...iss.path] : [${U}]
29
- })));
30
- }
31
-
32
- if (${Z}.value === undefined) {
33
- if (${U} in input) {
34
- newResult[${U}] = undefined;
35
- }
36
- } else {
37
- newResult[${U}] = ${Z}.value;
38
- }
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=Qo,a=!Ng.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?tm([],A,v,y,f,n):v):t(v,y):(v.issues.push({expected:"object",code:"invalid_type",input:A,inst:n}),v)}});function lf(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 UA=$("$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=>Du(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 c of e.options){const u=c._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(c=>lf(c,i,n,s)):lf(a,i,n,s)}}),FA=$("$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(([c,u])=>cf(t,c,u)):cf(t,s,o)}});function mc(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=mc(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=mc(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 cf(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 c of a.keys)r.has(c)||r.set(c,{}),r.get(c).l=!0}else n.issues.push(a);for(const a of t.issues)if(a.code==="unrecognized_keys")for(const c of a.keys)r.has(c)||r.set(c,{}),r.get(c).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=mc(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 ZA=$("$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 c;for(const u in i)a.has(u)||(c=c??[],c.push(u));c&&c.length>0&&t.issues.push({code:"unrecognized_keys",input:i,inst:n,keys:c})}else{t.value={};for(const a of Reflect.ownKeys(i)){if(a==="__proto__")continue;let c=e.keyType._zod.run({value:a,issues:[]},r);if(c instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(typeof a=="string"&&qg.test(a)&&c.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&&(c=f)}if(c.issues.length){e.mode==="loose"?t.value[a]=i[a]:t.issues.push({code:"invalid_key",origin:"record",issues:c.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[c.value]=f.value})):(d.issues.length&&t.issues.push(...Ir(a,d.issues)),t.value[c.value]=d.value)}}return s.length?Promise.all(s).then(()=>t):t}}),HA=$("$ZodEnum",(n,e)=>{he.init(n,e);const t=Ug(e.entries),r=new Set(t);n._zod.values=r,n._zod.pattern=new RegExp(`^(${t.filter(i=>e$.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}}),VA=$("$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}}),jA=$("$ZodTransform",(n,e)=>{he.init(n,e),n._zod.parse=(t,r)=>{if(r.direction==="backward")throw new Mg(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 uf(n,e){return n.issues.length&&e===void 0?{issues:[],value:void 0}:n}const nm=$("$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(`^(${Du(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=>uf(s,t.value)):uf(i,t.value)}return t.value===void 0?t:e.innerType._zod.run(t,r)}}),BA=$("$ZodExactOptional",(n,e)=>{nm.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)}),GA=$("$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(`^(${Du(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)}),WA=$("$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=>hf(s,e)):hf(i,e)}});function hf(n,e){return n.value===void 0&&(n.value=e.defaultValue),n}const qA=$("$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))}),YA=$("$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=>df(s,n)):df(i,n)}});function df(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 KA=$("$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)}}),JA=$("$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=>wo(o,e.in,r)):wo(s,e.in,r)}const i=e.in._zod.run(t,r);return i instanceof Promise?i.then(s=>wo(s,e.out,r)):wo(i,e.out,r)}});function wo(n,e,t){return n.issues.length?(n.aborted=!0,n):e._zod.run({value:n.value,issues:n.issues},t)}const XA=$("$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(ff):ff(i)}});function ff(n){return n.value=Object.freeze(n.value),n}const QA=$("$ZodCustom",(n,e)=>{We.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=>pf(s,t,r,n));pf(i,t,r,n)}});function pf(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 gf;class ex{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 tx(){return new ex}(gf=globalThis).__zod_globalRegistry??(gf.__zod_globalRegistry=tx());const zi=globalThis.__zod_globalRegistry;function nx(n,e){return new n({type:"string",...O(e)})}function rx(n,e){return new n({type:"string",format:"email",check:"string_format",abort:!1,...O(e)})}function mf(n,e){return new n({type:"string",format:"guid",check:"string_format",abort:!1,...O(e)})}function ix(n,e){return new n({type:"string",format:"uuid",check:"string_format",abort:!1,...O(e)})}function sx(n,e){return new n({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...O(e)})}function ox(n,e){return new n({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...O(e)})}function ax(n,e){return new n({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...O(e)})}function lx(n,e){return new n({type:"string",format:"url",check:"string_format",abort:!1,...O(e)})}function cx(n,e){return new n({type:"string",format:"emoji",check:"string_format",abort:!1,...O(e)})}function ux(n,e){return new n({type:"string",format:"nanoid",check:"string_format",abort:!1,...O(e)})}function hx(n,e){return new n({type:"string",format:"cuid",check:"string_format",abort:!1,...O(e)})}function dx(n,e){return new n({type:"string",format:"cuid2",check:"string_format",abort:!1,...O(e)})}function fx(n,e){return new n({type:"string",format:"ulid",check:"string_format",abort:!1,...O(e)})}function px(n,e){return new n({type:"string",format:"xid",check:"string_format",abort:!1,...O(e)})}function gx(n,e){return new n({type:"string",format:"ksuid",check:"string_format",abort:!1,...O(e)})}function mx(n,e){return new n({type:"string",format:"ipv4",check:"string_format",abort:!1,...O(e)})}function yx(n,e){return new n({type:"string",format:"ipv6",check:"string_format",abort:!1,...O(e)})}function vx(n,e){return new n({type:"string",format:"cidrv4",check:"string_format",abort:!1,...O(e)})}function bx(n,e){return new n({type:"string",format:"cidrv6",check:"string_format",abort:!1,...O(e)})}function wx(n,e){return new n({type:"string",format:"base64",check:"string_format",abort:!1,...O(e)})}function _x(n,e){return new n({type:"string",format:"base64url",check:"string_format",abort:!1,...O(e)})}function Sx(n,e){return new n({type:"string",format:"e164",check:"string_format",abort:!1,...O(e)})}function kx(n,e){return new n({type:"string",format:"jwt",check:"string_format",abort:!1,...O(e)})}function Ex(n,e){return new n({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...O(e)})}function $x(n,e){return new n({type:"string",format:"date",check:"string_format",...O(e)})}function Ax(n,e){return new n({type:"string",format:"time",check:"string_format",precision:null,...O(e)})}function xx(n,e){return new n({type:"string",format:"duration",check:"string_format",...O(e)})}function Tx(n,e){return new n({type:"number",checks:[],...O(e)})}function Cx(n,e){return new n({type:"number",check:"number_format",abort:!1,format:"safeint",...O(e)})}function Ix(n,e){return new n({type:"boolean",...O(e)})}function Px(n){return new n({type:"unknown"})}function Rx(n,e){return new n({type:"never",...O(e)})}function yf(n,e){return new Kg({check:"less_than",...O(e),value:n,inclusive:!1})}function Ll(n,e){return new Kg({check:"less_than",...O(e),value:n,inclusive:!0})}function vf(n,e){return new Jg({check:"greater_than",...O(e),value:n,inclusive:!1})}function Ml(n,e){return new Jg({check:"greater_than",...O(e),value:n,inclusive:!0})}function bf(n,e){return new W$({check:"multiple_of",...O(e),value:n})}function rm(n,e){return new Y$({check:"max_length",...O(e),maximum:n})}function ta(n,e){return new K$({check:"min_length",...O(e),minimum:n})}function im(n,e){return new J$({check:"length_equals",...O(e),length:n})}function Dx(n,e){return new X$({check:"string_format",format:"regex",...O(e),pattern:n})}function Ox(n){return new Q$({check:"string_format",format:"lowercase",...O(n)})}function zx(n){return new eA({check:"string_format",format:"uppercase",...O(n)})}function Lx(n,e){return new tA({check:"string_format",format:"includes",...O(e),includes:n})}function Mx(n,e){return new nA({check:"string_format",format:"starts_with",...O(e),prefix:n})}function Nx(n,e){return new rA({check:"string_format",format:"ends_with",...O(e),suffix:n})}function fi(n){return new iA({check:"overwrite",tx:n})}function Ux(n){return fi(e=>e.normalize(n))}function Fx(){return fi(n=>n.trim())}function Zx(){return fi(n=>n.toLowerCase())}function Hx(){return fi(n=>n.toUpperCase())}function Vx(){return fi(n=>X0(n))}function jx(n,e,t){return new n({type:"array",element:e,...O(t)})}function Bx(n,e,t){return new n({type:"custom",check:"custom",fn:e,...O(t)})}function Gx(n){const e=Wx(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 Wx(n,e){const t=new We({check:"custom",...O(e)});return t._zod.check=n,t}function sm(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 c=e.metadataRegistry.get(n);return c&&Object.assign(o.schema,c),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 om(n,e){var o,a,c,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>
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=(c=n.external.registry.get(d[0]))==null?void 0:c.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 am(n,e){var o,a,c;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=((c=n.external)==null?void 0:c.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:na(e,"input",n.processors),output:na(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 qx=(n,e={})=>t=>{const r=sm({...t,processors:e});return ve(n,r),om(r,n),am(r,n)},na=(n,e,t={})=>r=>{const{libraryOptions:i,target:s}=r??{},o=sm({...i??{},target:s,io:e,processors:t});return ve(n,o),om(o,n),am(o,n)},Yx={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},Kx=(n,e,t,r)=>{const i=t;i.type="string";const{minimum:s,maximum:o,format:a,patterns:c,contentEncoding:u}=n._zod.bag;if(typeof s=="number"&&(i.minLength=s),typeof o=="number"&&(i.maxLength=o),a&&(i.format=Yx[a]??a,i.format===""&&delete i.format,a==="time"&&delete i.format),u&&(i.contentEncoding=u),c&&c.size>0){const d=[...c];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}))])}},Jx=(n,e,t,r)=>{const i=t,{minimum:s,maximum:o,format:a,multipleOf:c,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 c=="number"&&(i.multipleOf=c)},Xx=(n,e,t,r)=>{t.type="boolean"},Qx=(n,e,t,r)=>{t.not={}},eT=(n,e,t,r)=>{},tT=(n,e,t,r)=>{const i=n._zod.def,s=Ug(i.entries);s.every(o=>typeof o=="number")&&(t.type="number"),s.every(o=>typeof o=="string")&&(t.type="string"),t.enum=s},nT=(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},rT=(n,e,t,r)=>{if(e.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema")},iT=(n,e,t,r)=>{if(e.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema")},sT=(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"]})},oT=(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)),c=new Set([...a].filter(d=>{const f=s.shape[d]._zod;return e.io==="input"?f.optin===void 0:f.optout===void 0}));c.size>0&&(i.required=Array.from(c)),((u=s.catchall)==null?void 0:u._zod.def.type)==="never"?i.additionalProperties=!1:s.catchall?s.catchall&&(i.additionalProperties=ve(s.catchall,e,{...r,path:[...r.path,"additionalProperties"]})):e.io==="output"&&(i.additionalProperties=!1)},aT=(n,e,t,r)=>{const i=n._zod.def,s=i.inclusive===!1,o=i.options.map((a,c)=>ve(a,e,{...r,path:[...r.path,s?"oneOf":"anyOf",c]}));s?t.oneOf=o:t.anyOf=o},lT=(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,c=[...a(s)?s.allOf:[s],...a(o)?o.allOf:[o]];t.allOf=c},cT=(n,e,t,r)=>{const i=t,s=n._zod.def;i.type="object";const o=s.keyType,a=o._zod.bag,c=a==null?void 0:a.patterns;if(s.mode==="loose"&&c&&c.size>0){const d=ve(s.valueType,e,{...r,path:[...r.path,"patternProperties","*"]});i.patternProperties={};for(const f of c)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)}},uT=(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"}]},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},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,t.default=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,e.io==="input"&&(t._prefault=JSON.parse(JSON.stringify(i.defaultValue)))},pT=(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},gT=(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},mT=(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},lm=(n,e,t,r)=>{const i=n._zod.def;ve(i.innerType,e,r);const s=e.seen.get(n);s.ref=i.innerType},yT=$("ZodISODateTime",(n,e)=>{vA.init(n,e),fe.init(n,e)});function vT(n){return Ex(yT,n)}const bT=$("ZodISODate",(n,e)=>{bA.init(n,e),fe.init(n,e)});function wT(n){return $x(bT,n)}const _T=$("ZodISOTime",(n,e)=>{wA.init(n,e),fe.init(n,e)});function ST(n){return Ax(_T,n)}const kT=$("ZodISODuration",(n,e)=>{_A.init(n,e),fe.init(n,e)});function ET(n){return xx(kT,n)}const cm=(n,e)=>{Vg.init(n,e),n.name="ZodError",Object.defineProperties(n,{format:{value:t=>h$(n,t)},flatten:{value:t=>u$(n,t)},addIssue:{value:t=>{n.issues.push(t),n.message=JSON.stringify(n.issues,gc,2)}},addIssues:{value:t=>{n.issues.push(...t),n.message=JSON.stringify(n.issues,gc,2)}},isEmpty:{get(){return n.issues.length===0}}})},wf=$("ZodError",cm),ot=$("ZodError",cm,{Parent:Error}),$T=zu(ot),AT=Lu(ot),xT=La(ot),TT=Ma(ot),CT=p$(ot),IT=g$(ot),PT=m$(ot),RT=y$(ot),DT=v$(ot),OT=b$(ot),zT=w$(ot),LT=_$(ot),de=$("ZodType",(n,e)=>(he.init(n,e),Object.assign(n["~standard"],{jsonSchema:{input:na(n,"input"),output:na(n,"output")}}),n.toJSONSchema=qx(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)=>$T(n,t,r,{callee:n.parse}),n.safeParse=(t,r)=>xT(n,t,r),n.parseAsync=async(t,r)=>AT(n,t,r,{callee:n.parseAsync}),n.safeParseAsync=async(t,r)=>TT(n,t,r),n.spa=n.safeParseAsync,n.encode=(t,r)=>CT(n,t,r),n.decode=(t,r)=>IT(n,t,r),n.encodeAsync=async(t,r)=>PT(n,t,r),n.decodeAsync=async(t,r)=>RT(n,t,r),n.safeEncode=(t,r)=>DT(n,t,r),n.safeDecode=(t,r)=>OT(n,t,r),n.safeEncodeAsync=async(t,r)=>zT(n,t,r),n.safeDecodeAsync=async(t,r)=>LT(n,t,r),n.refine=(t,r)=>n.check(xC(t,r)),n.superRefine=t=>n.check(TC(t)),n.overwrite=t=>n.check(fi(t)),n.optional=()=>kf(n),n.exactOptional=()=>pC(n),n.nullable=()=>Ef(n),n.nullish=()=>kf(Ef(n)),n.nonoptional=t=>wC(n,t),n.array=()=>D(n),n.or=t=>H([n,t]),n.and=t=>Ua(n,t),n.transform=t=>$f(n,dC(t)),n.default=t=>yC(n,t),n.prefault=t=>bC(n,t),n.catch=t=>SC(n,t),n.pipe=t=>$f(n,t),n.readonly=()=>$C(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)),um=$("_ZodString",(n,e)=>{Mu.init(n,e),de.init(n,e),n._zod.processJSONSchema=(r,i,s)=>Kx(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(Dx(...r)),n.includes=(...r)=>n.check(Lx(...r)),n.startsWith=(...r)=>n.check(Mx(...r)),n.endsWith=(...r)=>n.check(Nx(...r)),n.min=(...r)=>n.check(ta(...r)),n.max=(...r)=>n.check(rm(...r)),n.length=(...r)=>n.check(im(...r)),n.nonempty=(...r)=>n.check(ta(1,...r)),n.lowercase=r=>n.check(Ox(r)),n.uppercase=r=>n.check(zx(r)),n.trim=()=>n.check(Fx()),n.normalize=(...r)=>n.check(Ux(...r)),n.toLowerCase=()=>n.check(Zx()),n.toUpperCase=()=>n.check(Hx()),n.slugify=()=>n.check(Vx())}),MT=$("ZodString",(n,e)=>{Mu.init(n,e),um.init(n,e),n.email=t=>n.check(rx(NT,t)),n.url=t=>n.check(lx(UT,t)),n.jwt=t=>n.check(kx(eC,t)),n.emoji=t=>n.check(cx(FT,t)),n.guid=t=>n.check(mf(_f,t)),n.uuid=t=>n.check(ix(_o,t)),n.uuidv4=t=>n.check(sx(_o,t)),n.uuidv6=t=>n.check(ox(_o,t)),n.uuidv7=t=>n.check(ax(_o,t)),n.nanoid=t=>n.check(ux(ZT,t)),n.guid=t=>n.check(mf(_f,t)),n.cuid=t=>n.check(hx(HT,t)),n.cuid2=t=>n.check(dx(VT,t)),n.ulid=t=>n.check(fx(jT,t)),n.base64=t=>n.check(wx(JT,t)),n.base64url=t=>n.check(_x(XT,t)),n.xid=t=>n.check(px(BT,t)),n.ksuid=t=>n.check(gx(GT,t)),n.ipv4=t=>n.check(mx(WT,t)),n.ipv6=t=>n.check(yx(qT,t)),n.cidrv4=t=>n.check(vx(YT,t)),n.cidrv6=t=>n.check(bx(KT,t)),n.e164=t=>n.check(Sx(QT,t)),n.datetime=t=>n.check(vT(t)),n.date=t=>n.check(wT(t)),n.time=t=>n.check(ST(t)),n.duration=t=>n.check(ET(t))});function h(n){return nx(MT,n)}const fe=$("ZodStringFormat",(n,e)=>{ae.init(n,e),um.init(n,e)}),NT=$("ZodEmail",(n,e)=>{cA.init(n,e),fe.init(n,e)}),_f=$("ZodGUID",(n,e)=>{aA.init(n,e),fe.init(n,e)}),_o=$("ZodUUID",(n,e)=>{lA.init(n,e),fe.init(n,e)}),UT=$("ZodURL",(n,e)=>{uA.init(n,e),fe.init(n,e)}),FT=$("ZodEmoji",(n,e)=>{hA.init(n,e),fe.init(n,e)}),ZT=$("ZodNanoID",(n,e)=>{dA.init(n,e),fe.init(n,e)}),HT=$("ZodCUID",(n,e)=>{fA.init(n,e),fe.init(n,e)}),VT=$("ZodCUID2",(n,e)=>{pA.init(n,e),fe.init(n,e)}),jT=$("ZodULID",(n,e)=>{gA.init(n,e),fe.init(n,e)}),BT=$("ZodXID",(n,e)=>{mA.init(n,e),fe.init(n,e)}),GT=$("ZodKSUID",(n,e)=>{yA.init(n,e),fe.init(n,e)}),WT=$("ZodIPv4",(n,e)=>{SA.init(n,e),fe.init(n,e)}),qT=$("ZodIPv6",(n,e)=>{kA.init(n,e),fe.init(n,e)}),YT=$("ZodCIDRv4",(n,e)=>{EA.init(n,e),fe.init(n,e)}),KT=$("ZodCIDRv6",(n,e)=>{$A.init(n,e),fe.init(n,e)}),JT=$("ZodBase64",(n,e)=>{AA.init(n,e),fe.init(n,e)}),XT=$("ZodBase64URL",(n,e)=>{TA.init(n,e),fe.init(n,e)}),QT=$("ZodE164",(n,e)=>{CA.init(n,e),fe.init(n,e)}),eC=$("ZodJWT",(n,e)=>{PA.init(n,e),fe.init(n,e)}),hm=$("ZodNumber",(n,e)=>{Qg.init(n,e),de.init(n,e),n._zod.processJSONSchema=(r,i,s)=>Jx(n,r,i),n.gt=(r,i)=>n.check(vf(r,i)),n.gte=(r,i)=>n.check(Ml(r,i)),n.min=(r,i)=>n.check(Ml(r,i)),n.lt=(r,i)=>n.check(yf(r,i)),n.lte=(r,i)=>n.check(Ll(r,i)),n.max=(r,i)=>n.check(Ll(r,i)),n.int=r=>n.check(Sf(r)),n.safe=r=>n.check(Sf(r)),n.positive=r=>n.check(vf(0,r)),n.nonnegative=r=>n.check(Ml(0,r)),n.negative=r=>n.check(yf(0,r)),n.nonpositive=r=>n.check(Ll(0,r)),n.multipleOf=(r,i)=>n.check(bf(r,i)),n.step=(r,i)=>n.check(bf(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 Tx(hm,n)}const tC=$("ZodNumberFormat",(n,e)=>{RA.init(n,e),hm.init(n,e)});function Sf(n){return Cx(tC,n)}const nC=$("ZodBoolean",(n,e)=>{DA.init(n,e),de.init(n,e),n._zod.processJSONSchema=(t,r,i)=>Xx(n,t,r)});function Ee(n){return Ix(nC,n)}const rC=$("ZodUnknown",(n,e)=>{OA.init(n,e),de.init(n,e),n._zod.processJSONSchema=(t,r,i)=>eT()});function w(){return Px(rC)}const iC=$("ZodNever",(n,e)=>{zA.init(n,e),de.init(n,e),n._zod.processJSONSchema=(t,r,i)=>Qx(n,t,r)});function sC(n){return Rx(iC,n)}const oC=$("ZodArray",(n,e)=>{LA.init(n,e),de.init(n,e),n._zod.processJSONSchema=(t,r,i)=>sT(n,t,r,i),n.element=e.element,n.min=(t,r)=>n.check(ta(t,r)),n.nonempty=t=>n.check(ta(1,t)),n.max=(t,r)=>n.check(rm(t,r)),n.length=(t,r)=>n.check(im(t,r)),n.unwrap=()=>n.element});function D(n,e){return jx(oC,n,e)}const dm=$("ZodObject",(n,e)=>{NA.init(n,e),de.init(n,e),n._zod.processJSONSchema=(t,r,i)=>oT(n,t,r,i),X(n,"shape",()=>e.shape),n.keyof=()=>ra(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:sC()}),n.strip=()=>n.clone({...n._zod.def,catchall:void 0}),n.extend=t=>s$(n,t),n.safeExtend=t=>o$(n,t),n.merge=t=>a$(n,t),n.pick=t=>r$(n,t),n.omit=t=>i$(n,t),n.partial=(...t)=>l$(pm,n,t[0]),n.required=(...t)=>c$(gm,n,t[0])});function fm(n,e){const t={type:"object",shape:n??{},...O(e)};return new dm(t)}function p(n,e){return new dm({type:"object",shape:n,catchall:w(),...O(e)})}const aC=$("ZodUnion",(n,e)=>{UA.init(n,e),de.init(n,e),n._zod.processJSONSchema=(t,r,i)=>aT(n,t,r,i),n.options=e.options});function H(n,e){return new aC({type:"union",options:n,...O(e)})}const lC=$("ZodIntersection",(n,e)=>{FA.init(n,e),de.init(n,e),n._zod.processJSONSchema=(t,r,i)=>lT(n,t,r,i)});function Ua(n,e){return new lC({type:"intersection",left:n,right:e})}const cC=$("ZodRecord",(n,e)=>{ZA.init(n,e),de.init(n,e),n._zod.processJSONSchema=(t,r,i)=>cT(n,t,r,i),n.keyType=e.keyType,n.valueType=e.valueType});function S(n,e,t){return new cC({type:"record",keyType:n,valueType:e,...O(t)})}const yc=$("ZodEnum",(n,e)=>{HA.init(n,e),de.init(n,e),n._zod.processJSONSchema=(r,i,s)=>tT(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 yc({...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 yc({...e,checks:[],...O(i),entries:s})}});function ra(n,e){const t=Array.isArray(n)?Object.fromEntries(n.map(r=>[r,r])):n;return new yc({type:"enum",entries:t,...O(e)})}const uC=$("ZodLiteral",(n,e)=>{VA.init(n,e),de.init(n,e),n._zod.processJSONSchema=(t,r,i)=>nT(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 uC({type:"literal",values:Array.isArray(n)?n:[n],...O(e)})}const hC=$("ZodTransform",(n,e)=>{jA.init(n,e),de.init(n,e),n._zod.processJSONSchema=(t,r,i)=>iT(n,t),n._zod.parse=(t,r)=>{if(r.direction==="backward")throw new Mg(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 dC(n){return new hC({type:"transform",transform:n})}const pm=$("ZodOptional",(n,e)=>{nm.init(n,e),de.init(n,e),n._zod.processJSONSchema=(t,r,i)=>lm(n,t,r,i),n.unwrap=()=>n._zod.def.innerType});function kf(n){return new pm({type:"optional",innerType:n})}const fC=$("ZodExactOptional",(n,e)=>{BA.init(n,e),de.init(n,e),n._zod.processJSONSchema=(t,r,i)=>lm(n,t,r,i),n.unwrap=()=>n._zod.def.innerType});function pC(n){return new fC({type:"optional",innerType:n})}const gC=$("ZodNullable",(n,e)=>{GA.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 Ef(n){return new gC({type:"nullable",innerType:n})}const mC=$("ZodDefault",(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,n.removeDefault=n.unwrap});function yC(n,e){return new mC({type:"default",innerType:n,get defaultValue(){return typeof e=="function"?e():Zg(e)}})}const vC=$("ZodPrefault",(n,e)=>{qA.init(n,e),de.init(n,e),n._zod.processJSONSchema=(t,r,i)=>fT(n,t,r,i),n.unwrap=()=>n._zod.def.innerType});function bC(n,e){return new vC({type:"prefault",innerType:n,get defaultValue(){return typeof e=="function"?e():Zg(e)}})}const gm=$("ZodNonOptional",(n,e)=>{YA.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,e){return new gm({type:"nonoptional",innerType:n,...O(e)})}const _C=$("ZodCatch",(n,e)=>{KA.init(n,e),de.init(n,e),n._zod.processJSONSchema=(t,r,i)=>pT(n,t,r,i),n.unwrap=()=>n._zod.def.innerType,n.removeCatch=n.unwrap});function SC(n,e){return new _C({type:"catch",innerType:n,catchValue:typeof e=="function"?e:()=>e})}const kC=$("ZodPipe",(n,e)=>{JA.init(n,e),de.init(n,e),n._zod.processJSONSchema=(t,r,i)=>gT(n,t,r,i),n.in=e.in,n.out=e.out});function $f(n,e){return new kC({type:"pipe",in:n,out:e})}const EC=$("ZodReadonly",(n,e)=>{XA.init(n,e),de.init(n,e),n._zod.processJSONSchema=(t,r,i)=>mT(n,t,r,i),n.unwrap=()=>n._zod.def.innerType});function $C(n){return new EC({type:"readonly",innerType:n})}const AC=$("ZodCustom",(n,e)=>{QA.init(n,e),de.init(n,e),n._zod.processJSONSchema=(t,r,i)=>rT(n,t)});function xC(n,e={}){return Bx(AC,n,e)}function TC(n){return Gx(n)}const CC=["text/markdown","text/html"],IC=["committed","pending"];fm({id:h().min(1),type:ra(CC),title:h(),status:ra(IC),externalFilePath:h().optional()});fm({name:h().min(1),description:h(),accepts:D(h().min(1)).min(1)});function Nu(n){return typeof n=="object"&&n!==null}function PC(n){return!Nu(n)||n.type!=="ready"?!1:!("id"in n)}function RC(n){return!(!Nu(n)||n.type!=="update-content"||typeof n.id!="string"||typeof n.content!="string")}function DC(n){return!Nu(n)||n.type!=="wheel"||typeof n.deltaX!="number"||typeof n.deltaY!="number"||typeof n.shiftKey!="boolean"?!1:!("id"in n)}function OC(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 zC(n,e){let t=null;for(const r of n.accepts){const i=OC(r,e);i!==null&&(t===null||i>t)&&(t=i)}return t}function LC(n,e){let t=-1,r=null;for(const i of e){const s=zC(i,n);s!==null&&(s>t||s===t&&r!==null&&i.id<r.id)&&(t=s,r=i)}return r}const MC=4401;class vc extends Error{constructor(e="Authentication required"){super(e),this.name="AuthError"}}class bc extends gt{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=kt(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(NC(this.url,this.token));return this.socket=r,await new Promise((s,o)=>{let a=!1;const c=()=>{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")),c()}catch(f){u(f instanceof Error?f:new Error(String(f)))}};r.addEventListener("open",()=>{d()}),r.addEventListener("message",f=>{const v=FC(f);v&&(this.applyServerEvent(v),this.dispatchEvent(new xg("server-event",{serverURL:this.url,event:v})))}),r.addEventListener("close",f=>{if(this.connectAttempt===t){if(this.socket=null,UC(f)===MC){u(new vc);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=LC(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 No("screens-changed"));break;case"screen-updated":this.screens.set(t.screen.id,structuredClone(t.screen)),this.dispatchEvent(new No("screens-changed"));break;case"screen-removed":this.screens.delete(t.screenID),this.dispatchEvent(new No("screens-changed"));break;case"artifact-created":{const r=this.screens.get(t.screenID);r&&!Eg(r.layout,t.artifact.id)&&(r.layout=[...r.layout,kg(t.artifact.id)]);break}case"artifact-removed":{const r=this.screens.get(t.screenID);r&&(r.layout=pg(r.layout,t.artifactID));break}}}}function NC(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 UC(n){return typeof n=="object"&&n!==null&&"code"in n&&typeof n.code=="number"?n.code:null}function FC(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 ZC extends gt{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?kt(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=kt(t.url);this.servers.get(r)&&this.remove(r),this.servers.set(r,t);const s=()=>{this.dispatchEvent(new Q("change"))},o=c=>{this.dispatchEvent(new xg("server-event",{serverURL:c.serverURL,event:c.event}))},a=()=>{this.dispatchEvent(new No("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=kt(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(c=>c.url!==r),activeServerURL:a?null:o.activeServerURL}),this.dispatchEvent(new Q("change"))}setActive(t){const r=this.localStore.get(),i=t?kt(t.url):null;r.activeServerURL!==i&&this.localStore.set({...r,activeServerURL:i})}connectConfiguredServers(t,r){const i=this.localStore.get().servers,s=t?kt(t):null;for(const a of i){const c=kt(a.url),u=s!==null&&c===s,d=new bc({url:a.url,name:a.name,token:u?r??null:null,createSocket:this.createSocket});this.add(d),d.connect().catch(()=>{})}const o=s?this.servers.get(s)??null:null;this.setActive(o??this.servers.values().next().value??null)}addServer(t,r){const i=kt(t);this.remove(i);const s=this.localStore.get();this.localStore.set({...s,servers:[...s.servers.filter(a=>kt(a.url)!==i),{url:i,name:r}]});const o=new bc({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"},Ot={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"},HC=1,VC=p({_meta:S(h(),w()).nullish(),terminal:Ee().optional().default(!1)}),jC=p({_meta:S(h(),w()).nullish(),label:h().nullish(),name:h(),optional:Ee().optional().default(!1),secret:Ee().optional().default(!0)}),BC=p({_meta:S(h(),w()).nullish(),description:h().nullish(),id:h(),name:h()}),GC=p({_meta:S(h(),w()).nullish(),description:h().nullish(),id:h(),link:h().nullish(),name:h(),vars:D(jC)}),WC=p({_meta:S(h(),w()).nullish(),args:D(h()).optional(),description:h().nullish(),env:S(h(),h()).optional(),id:h(),name:h()}),qC=H([GC.and(p({type:x("env_var")})),WC.and(p({type:x("terminal")})),BC]),YC=p({_meta:S(h(),w()).nullish(),methodId:h()}),KC=p({_meta:S(h(),w()).nullish()}),JC=p({_meta:S(h(),w()).nullish(),blob:h(),mimeType:h().nullish(),uri:h()}),XC=p({default:Ee().nullish(),description:h().nullish(),title:h().nullish()}),QC=p({_meta:S(h(),w()).nullish()}),eI=p({_meta:S(h(),w()).nullish()}),tI=p({amount:N(),currency:h()}),nI=p({_meta:S(h(),w()).nullish(),terminalId:h()}),rI=p({_meta:S(h(),w()).nullish(),newText:h(),oldText:h().nullish(),path:h()}),iI=H([h(),N(),N(),Ee(),D(h())]),sI=p({content:S(h(),iI).nullish()}),oI=H([sI.and(p({action:x("accept")})),p({action:x("decline")}),p({action:x("cancel")})]),aI=p({_meta:S(h(),w()).nullish()}),mm=h(),lI=p({_meta:S(h(),w()).nullish(),elicitationId:mm}),cI=p({_meta:S(h(),w()).nullish(),action:oI}),uI=x("object"),hI=x("string"),dI=p({_meta:S(h(),w()).nullish()}),fI=p({_meta:S(h(),w()).nullish(),form:aI.nullish(),url:dI.nullish()}),pI=p({elicitationId:mm,url:h().url()}),ym=p({const:h(),title:h()}),vm=p({_meta:S(h(),w()).nullish(),name:h(),value:h()}),gI=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"})]),bm=p({code:gI,data:w().optional(),message:h()}),wm=w(),_m=w(),Sm=w(),mI=p({_meta:S(h(),w()).nullish(),readTextFile:Ee().optional().default(!1),writeTextFile:Ee().optional().default(!1)}),km=p({_meta:S(h(),w()).nullish(),name:h(),value:h()}),Em=p({_meta:S(h(),w()).nullish(),name:h(),title:h().nullish(),version:h()}),yI=p({default:N().nullish(),description:h().nullish(),maximum:N().nullish(),minimum:N().nullish(),title:h().nullish()}),vI=p({_meta:S(h(),w()).nullish()}),bI=p({_meta:S(h(),w()).nullish(),additionalDirectories:D(h()).optional(),cursor:h().nullish(),cwd:h().nullish()}),wI=p({_meta:S(h(),w()).nullish()}),_I=p({_meta:S(h(),w()).nullish(),logout:wI.nullish()}),SI=p({_meta:S(h(),w()).nullish()}),kI=p({_meta:S(h(),w()).nullish()}),EI=p({_meta:S(h(),w()).nullish(),http:Ee().optional().default(!1),sse:Ee().optional().default(!1)}),$I=p({_meta:S(h(),w()).nullish(),headers:D(km),name:h(),url:h()}),AI=p({_meta:S(h(),w()).nullish(),headers:D(km),name:h(),url:h()}),xI=p({_meta:S(h(),w()).nullish(),args:D(h()),command:h(),env:D(vm),name:h()}),Fa=H([$I.and(p({type:x("http")})),AI.and(p({type:x("sse")})),xI]),Uu=h(),TI=p({_meta:S(h(),w()).nullish(),description:h().nullish(),modelId:Uu,name:h()}),CI=H([x("error"),x("warning"),x("information"),x("hint")]),II=p({_meta:S(h(),w()).nullish()}),PI=p({_meta:S(h(),w()).nullish()}),RI=p({_meta:S(h(),w()).nullish()}),DI=p({_meta:S(h(),w()).nullish()}),OI=p({_meta:S(h(),w()).nullish()}),zI=p({_meta:S(h(),w()).nullish(),maxCount:N().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish()}),LI=p({diff:h(),uri:h()}),MI=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()}),NI=p({_meta:S(h(),w()).nullish()}),UI=p({_meta:S(h(),w()).nullish()}),FI=p({languageId:h(),text:h(),uri:h()}),ZI=p({_meta:S(h(),w()).nullish(),maxCount:N().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish()}),HI=H([x("rejected"),x("ignored"),x("replaced"),x("cancelled")]),VI=p({excerpts:D(MI),uri:h()}),jI=p({_meta:S(h(),w()).nullish()}),BI=p({_meta:S(h(),w()).nullish()}),GI=p({name:h(),owner:h(),remoteUrl:h()}),WI=p({_meta:S(h(),w()).nullish()}),qI=p({_meta:S(h(),w()).nullish(),jump:NI.nullish(),rename:BI.nullish(),searchAndReplace:WI.nullish()}),YI=p({id:h(),isRegex:Ee().nullish(),replace:h(),search:h(),uri:h()}),KI=H([x("automatic"),x("diagnostic"),x("manual")]),JI=p({_meta:S(h(),w()).nullish(),maxCount:N().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish()}),XI=p({_meta:S(h(),w()).nullish(),diagnostics:II.nullish(),editHistory:zI.nullish(),openFiles:UI.nullish(),recentFiles:ZI.nullish(),relatedSnippets:jI.nullish(),userActions:JI.nullish()}),QI=p({_meta:S(h(),w()).nullish(),additionalDirectories:D(h()).optional(),cwd:h(),mcpServers:D(Fa)}),eP=p({default:N().nullish(),description:h().nullish(),maximum:N().nullish(),minimum:N().nullish(),title:h().nullish()}),$m=h(),tP=H([x("allow_once"),x("allow_always"),x("reject_once"),x("reject_always")]),nP=p({_meta:S(h(),w()).nullish(),kind:tP,name:h(),optionId:$m}),rP=H([x("high"),x("medium"),x("low")]),iP=H([x("pending"),x("in_progress"),x("completed")]),sP=p({_meta:S(h(),w()).nullish(),content:h(),priority:rP,status:iP}),oP=p({_meta:S(h(),w()).nullish(),entries:D(sP)}),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"})}),aP=p({id:h(),position:mn,uri:h()}),lP=p({id:h(),newName:h(),position:mn,uri:h()}),cP=p({action:h(),position:mn,timestampMs:N(),uri:h()}),Am=H([x("utf-16"),x("utf-32"),x("utf-8")]),uP=p({_meta:S(h(),w()).nullish(),auth:VC.optional().default({terminal:!1}),elicitation:fI.nullish(),fs:mI.optional().default({readTextFile:!1,writeTextFile:!1}),nes:qI.nullish(),positionEncodings:D(Am).optional(),terminal:Ee().optional().default(!1)}),hP=p({_meta:S(h(),w()).nullish(),audio:Ee().optional().default(!1),embeddedContext:Ee().optional().default(!1),image:Ee().optional().default(!1)}),xm=N().int().gte(0).lte(65535),dP=p({_meta:S(h(),w()).nullish(),clientCapabilities:uP.optional().default({auth:{terminal:!1},fs:{readTextFile:!1,writeTextFile:!1},terminal:!1}),clientInfo:Em.nullish(),protocolVersion:xm}),pi=p({end:mn,start:mn}),fP=p({message:h(),range:pi,severity:CI,uri:h()}),pP=p({languageId:h(),lastFocusedMs:N().nullish(),uri:h(),visibleRange:pi.nullish()}),gP=p({_meta:S(h(),w()).nullish(),diagnostics:D(fP).nullish(),editHistory:D(LI).nullish(),openFiles:D(pP).nullish(),recentFiles:D(FI).nullish(),relatedSnippets:D(VI).nullish(),userActions:D(cP).nullish()}),mP=p({newText:h(),range:pi}),yP=p({cursorPosition:mn.nullish(),edits:D(mP),id:h(),uri:h()}),vP=H([yP.and(p({kind:x("edit")})),aP.and(p({kind:x("jump")})),lP.and(p({kind:x("rename")})),YI.and(p({kind:x("searchAndReplace")}))]),bP=p({_meta:S(h(),w()).nullish(),content:h()}),wP=p({_meta:S(h(),w()).nullish()}),nr=H([N(),h()]).nullable();p({_meta:S(h(),w()).nullish(),requestId:nr});const _P=ra(["assistant","user"]),Xs=p({_meta:S(h(),w()).nullish(),audience:D(_P).nullish(),lastModified:h().nullish(),priority:N().nullish()}),SP=p({_meta:S(h(),w()).nullish(),annotations:Xs.nullish(),data:h(),mimeType:h()}),kP=p({_meta:S(h(),w()).nullish(),annotations:Xs.nullish(),data:h(),mimeType:h(),uri:h().nullish()}),EP=p({_meta:S(h(),w()).nullish(),annotations:Xs.nullish(),description:h().nullish(),mimeType:h().nullish(),name:h(),size:N().nullish(),title:h().nullish(),uri:h()}),$P=p({_meta:S(h(),w()).nullish(),optionId:$m}),AP=H([p({outcome:x("cancelled")}),$P.and(p({outcome:x("selected")}))]),xP=p({_meta:S(h(),w()).nullish(),outcome:AP}),TP=p({_meta:S(h(),w()).nullish()}),CP=p({_meta:S(h(),w()).nullish()}),IP=p({currentValue:Ee()}),PP=h(),Tm=h(),RP=H([x("mode"),x("model"),x("thought_level"),h()]),Fu=h(),Cm=p({_meta:S(h(),w()).nullish(),description:h().nullish(),name:h(),value:Fu}),DP=p({_meta:S(h(),w()).nullish(),group:PP,name:h(),options:D(Cm)}),OP=H([D(Cm),D(DP)]),zP=p({currentValue:Fu,options:OP}),gi=Ua(H([zP.and(p({type:x("select")})),IP.and(p({type:x("boolean")}))]),p({_meta:S(h(),w()).nullish(),category:RP.nullish(),description:h().nullish(),id:Tm,name:h()})),LP=p({_meta:S(h(),w()).nullish(),configOptions:D(gi)}),MP=p({_meta:S(h(),w()).nullish()}),Y=h(),NP=p({_meta:S(h(),w()).nullish(),id:h(),sessionId:Y}),UP=p({_meta:S(h(),w()).nullish(),sessionId:Y}),FP=p({_meta:S(h(),w()).nullish(),sessionId:Y}),ZP=p({_meta:S(h(),w()).nullish(),sessionId:Y}),Im=p({_meta:S(h(),w()).nullish(),args:D(h()).optional(),command:h(),cwd:h().nullish(),env:D(vm).optional(),outputByteLimit:N().nullish(),sessionId:Y}),HP=p({_meta:S(h(),w()).nullish(),sessionId:Y,uri:h()}),VP=p({_meta:S(h(),w()).nullish(),position:mn,sessionId:Y,uri:h(),version:N(),visibleRange:pi}),jP=p({_meta:S(h(),w()).nullish(),languageId:h(),sessionId:Y,text:h(),uri:h(),version:N()}),BP=p({_meta:S(h(),w()).nullish(),sessionId:Y,uri:h()}),GP=p({_meta:S(h(),w()).nullish(),additionalDirectories:D(h()).optional(),cwd:h(),mcpServers:D(Fa).optional(),sessionId:Y}),Pm=p({_meta:S(h(),w()).nullish(),sessionId:Y,terminalId:h()}),WP=p({_meta:S(h(),w()).nullish(),additionalDirectories:D(h()).optional(),cwd:h(),mcpServers:D(Fa),sessionId:Y}),Rm=p({_meta:S(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}),qP=p({_meta:S(h(),w()).nullish(),id:h(),reason:HI.nullish(),sessionId:Y}),Dm=p({_meta:S(h(),w()).nullish(),sessionId:Y,terminalId:h()}),YP=p({_meta:S(h(),w()).nullish(),additionalDirectories:D(h()).optional(),cwd:h(),mcpServers:D(Fa).optional(),sessionId:Y}),KP=p({_meta:S(h(),w()).nullish(),additionalDirectories:D(h()).optional(),cwd:h(),sessionId:Y,title:h().nullish(),updatedAt:h().nullish()}),JP=p({_meta:S(h(),w()).nullish(),nextCursor:h().nullish(),sessions:D(KP)}),XP=p({_meta:S(h(),w()).nullish(),title:h().nullish(),updatedAt:h().nullish()}),QP=p({_meta:S(h(),w()).nullish()}),Za=h(),e1=p({_meta:S(h(),w()).nullish(),currentModeId:Za}),t1=p({_meta:S(h(),w()).nullish(),description:h().nullish(),id:Za,name:h()}),Ha=p({_meta:S(h(),w()).nullish(),availableModes:D(t1),currentModeId:Za}),Va=p({_meta:S(h(),w()).nullish(),availableModels:D(TI),currentModelId:Uu}),n1=p({_meta:S(h(),w()).nullish(),configOptions:D(gi).nullish(),models:Va.nullish(),modes:Ha.nullish(),sessionId:Y}),r1=p({_meta:S(h(),w()).nullish(),configOptions:D(gi).nullish(),models:Va.nullish(),modes:Ha.nullish()}),i1=p({_meta:S(h(),w()).nullish(),configOptions:D(gi).nullish(),models:Va.nullish(),modes:Ha.nullish(),sessionId:Y}),s1=p({_meta:S(h(),w()).nullish(),configOptions:D(gi).nullish(),models:Va.nullish(),modes:Ha.nullish()}),o1=p({_meta:S(h(),w()).nullish()}),a1=p({_meta:S(h(),w()).nullish(),additionalDirectories:TP.nullish(),close:CP.nullish(),fork:MP.nullish(),list:QP.nullish(),resume:o1.nullish()}),l1=Ua(H([p({type:x("boolean"),value:Ee()}),p({value:Fu})]),p({_meta:S(h(),w()).nullish(),configId:Tm,sessionId:Y})),c1=p({_meta:S(h(),w()).nullish(),configOptions:D(gi)}),u1=p({_meta:S(h(),w()).nullish(),modeId:Za,sessionId:Y}),h1=p({_meta:S(h(),w()).nullish()}),d1=p({_meta:S(h(),w()).nullish(),modelId:Uu,sessionId:Y}),f1=p({_meta:S(h(),w()).nullish()}),p1=p({_meta:S(h(),w()).nullish(),sessionId:Y}),g1=H([x("end_turn"),x("max_tokens"),x("max_turn_requests"),x("refusal"),x("cancelled")]),m1=H([x("email"),x("uri"),x("date"),x("date-time")]),y1=p({default:h().nullish(),description:h().nullish(),enum:D(h()).nullish(),format:m1.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(ym).nullish(),pattern:h().nullish(),title:h().nullish()}),v1=p({_meta:S(h(),w()).nullish(),context:gP.nullish(),position:mn,selection:pi.nullish(),sessionId:Y,triggerKind:KI,uri:h(),version:N()}),b1=p({_meta:S(h(),w()).nullish(),suggestions:D(vP)}),w1=p({_meta:S(h(),w()).nullish(),terminalId:h()}),_1=p({_meta:S(h(),w()).nullish(),exitCode:N().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),signal:h().nullish()}),Om=p({_meta:S(h(),w()).nullish(),sessionId:Y,terminalId:h()}),S1=p({_meta:S(h(),w()).nullish(),exitStatus:_1.nullish(),output:h(),truncated:Ee()}),k1=p({_meta:S(h(),w()).nullish(),annotations:Xs.nullish(),text:h()}),E1=p({range:pi.nullish(),text:h()}),$1=p({_meta:S(h(),w()).nullish(),contentChanges:D(E1),sessionId:Y,uri:h(),version:N()});p({method:h(),params:H([UP,jP,$1,HP,BP,VP,NP,qP,wm]).nullish()});const A1=H([x("full"),x("incremental")]),x1=p({_meta:S(h(),w()).nullish(),syncKind:A1}),T1=p({_meta:S(h(),w()).nullish(),didChange:x1.nullish(),didClose:PI.nullish(),didFocus:RI.nullish(),didOpen:DI.nullish(),didSave:OI.nullish()}),C1=p({_meta:S(h(),w()).nullish(),document:T1.nullish()}),I1=p({_meta:S(h(),w()).nullish(),context:XI.nullish(),events:C1.nullish()}),P1=p({_meta:S(h(),w()).nullish(),auth:_I.optional().default({}),loadSession:Ee().optional().default(!1),mcpCapabilities:EI.optional().default({http:!1,sse:!1}),nes:I1.nullish(),positionEncoding:Am.nullish(),promptCapabilities:hP.optional().default({audio:!1,embeddedContext:!1,image:!1}),sessionCapabilities:a1.optional().default({})}),R1=p({_meta:S(h(),w()).nullish(),agentCapabilities:P1.optional().default({auth:{},loadSession:!1,mcpCapabilities:{http:!1,sse:!1},promptCapabilities:{audio:!1,embeddedContext:!1,image:!1},sessionCapabilities:{}}),agentInfo:Em.nullish(),authMethods:D(qC).optional().default([]),protocolVersion:xm}),D1=p({_meta:S(h(),w()).nullish(),mimeType:h().nullish(),text:h(),uri:h()}),O1=H([D1,JC]),z1=p({_meta:S(h(),w()).nullish(),annotations:Xs.nullish(),resource:O1}),Zu=H([k1.and(p({type:x("text")})),kP.and(p({type:x("image")})),SP.and(p({type:x("audio")})),EP.and(p({type:x("resource_link")})),z1.and(p({type:x("resource")}))]),L1=p({_meta:S(h(),w()).nullish(),content:Zu}),Nl=p({_meta:S(h(),w()).nullish(),content:Zu,messageId:h().nullish()}),M1=p({_meta:S(h(),w()).nullish(),messageId:h().nullish(),prompt:D(Zu),sessionId:Y}),N1=p({anyOf:D(ym)}),zm=H([L1.and(p({type:x("content")})),rI.and(p({type:x("diff")})),w1.and(p({type:x("terminal")}))]),Lm=h(),Mm=p({_meta:S(h(),w()).nullish(),line:N().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),path:h()}),Nm=H([x("pending"),x("in_progress"),x("completed"),x("failed")]),Um=H([x("read"),x("edit"),x("delete"),x("move"),x("search"),x("execute"),x("think"),x("fetch"),x("switch_mode"),x("other")]),U1=p({_meta:S(h(),w()).nullish(),content:D(zm).optional(),kind:Um.optional(),locations:D(Mm).optional(),rawInput:w().optional(),rawOutput:w().optional(),status:Nm.optional(),title:h(),toolCallId:Lm}),Fm=p({_meta:S(h(),w()).nullish(),content:D(zm).nullish(),kind:Um.nullish(),locations:D(Mm).nullish(),rawInput:w().optional(),rawOutput:w().optional(),status:Nm.nullish(),title:h().nullish(),toolCallId:Lm}),Zm=p({_meta:S(h(),w()).nullish(),options:D(nP),sessionId:Y,toolCall:Fm}),F1=p({_meta:S(h(),w()).nullish(),hint:h()}),Z1=F1,H1=p({_meta:S(h(),w()).nullish(),description:h(),input:Z1.nullish(),name:h()}),V1=p({_meta:S(h(),w()).nullish(),availableCommands:D(H1)}),j1=p({enum:D(h()),type:hI}),B1=H([j1,N1]),G1=p({default:D(h()).nullish(),description:h().nullish(),items:B1,maxItems:N().nullish(),minItems:N().nullish(),title:h().nullish()}),W1=H([y1.and(p({type:x("string")})),eP.and(p({type:x("number")})),yI.and(p({type:x("integer")})),XC.and(p({type:x("boolean")})),G1.and(p({type:x("array")}))]),q1=p({description:h().nullish(),properties:S(h(),W1).optional().default({}),required:D(h()).nullish(),title:h().nullish(),type:uI.optional().default("object")}),Y1=p({requestedSchema:q1}),K1=Ua(H([Y1.and(p({mode:x("form")})),pI.and(p({mode:x("url")}))]),p({_meta:S(h(),w()).nullish(),message:h(),sessionId:Y})),J1=p({cachedReadTokens:N().nullish(),cachedWriteTokens:N().nullish(),inputTokens:N(),outputTokens:N(),thoughtTokens:N().nullish(),totalTokens:N()}),X1=p({_meta:S(h(),w()).nullish(),stopReason:g1,usage:J1.nullish(),userMessageId:h().nullish()});H([p({id:nr,result:H([R1,KC,kI,i1,r1,JP,n1,s1,eI,h1,c1,X1,f1,p1,b1,QC,Sm])}),p({error:bm,id:nr})]);const Q1=p({_meta:S(h(),w()).nullish(),cost:tI.nullish(),size:N(),used:N()}),eR=H([Nl.and(p({sessionUpdate:x("user_message_chunk")})),Nl.and(p({sessionUpdate:x("agent_message_chunk")})),Nl.and(p({sessionUpdate:x("agent_thought_chunk")})),U1.and(p({sessionUpdate:x("tool_call")})),Fm.and(p({sessionUpdate:x("tool_call_update")})),oP.and(p({sessionUpdate:x("plan")})),V1.and(p({sessionUpdate:x("available_commands_update")})),e1.and(p({sessionUpdate:x("current_mode_update")})),LP.and(p({sessionUpdate:x("config_option_update")})),XP.and(p({sessionUpdate:x("session_info_update")})),Q1.and(p({sessionUpdate:x("usage_update")}))]),Hm=p({_meta:S(h(),w()).nullish(),sessionId:Y,update:eR});p({method:h(),params:H([Hm,lI,wm]).nullish()});const Vm=p({_meta:S(h(),w()).nullish(),sessionId:Y,terminalId:h()}),tR=p({_meta:S(h(),w()).nullish(),exitCode:N().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),signal:h().nullish()}),nR=p({name:h(),uri:h()}),rR=p({_meta:S(h(),w()).nullish(),repository:GI.nullish(),workspaceFolders:D(nR).nullish(),workspaceUri:h().nullish()});p({id:nr,method:h(),params:H([dP,YC,SI,QI,WP,bI,GP,YP,ZP,u1,l1,M1,d1,rR,v1,FP,_m]).nullish()});const jm=p({_meta:S(h(),w()).nullish(),content:h(),path:h(),sessionId:Y});p({id:nr,method:h(),params:H([jm,Rm,Zm,Im,Om,Dm,Vm,Pm,K1,_m]).nullish()});const iR=p({_meta:S(h(),w()).nullish()});H([p({id:nr,result:H([iR,bP,xP,nI,S1,wP,tR,vI,cI,Sm])}),p({error:bm,id:nr})]);var q;class sR{constructor(e,t){_(this,q);const r=e(this),i=async(o,a)=>{var c,u,d,f,v,y,A;switch(o){case Ot.fs_write_text_file:{const k=jm.parse(a);return(c=r.writeTextFile)==null?void 0:c.call(r,k)}case Ot.fs_read_text_file:{const k=Rm.parse(a);return(u=r.readTextFile)==null?void 0:u.call(r,k)}case Ot.session_request_permission:{const k=Zm.parse(a);return r.requestPermission(k)}case Ot.terminal_create:{const k=Im.parse(a);return(d=r.createTerminal)==null?void 0:d.call(r,k)}case Ot.terminal_output:{const k=Om.parse(a);return(f=r.terminalOutput)==null?void 0:f.call(r,k)}case Ot.terminal_release:{const k=Dm.parse(a);return await((v=r.releaseTerminal)==null?void 0:v.call(r,k))??{}}case Ot.terminal_wait_for_exit:{const k=Vm.parse(a);return(y=r.waitForTerminalExit)==null?void 0:y.call(r,k)}case Ot.terminal_kill:{const k=Pm.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 Ot.session_update:{const c=Hm.parse(a);return r.sessionUpdate(c)}default:if(r.extNotification)return r.extNotification(o,a);throw we.methodNotFound(o)}};E(this,q,new oR(i,s,t))}async initialize(e){return await l(this,q).sendRequest(se.initialize,e)}async newSession(e){return await l(this,q).sendRequest(se.session_new,e)}async loadSession(e){return await l(this,q).sendRequest(se.session_load,e)??{}}async unstable_forkSession(e){return await l(this,q).sendRequest(se.session_fork,e)}async listSessions(e){return await l(this,q).sendRequest(se.session_list,e)}async unstable_resumeSession(e){return await l(this,q).sendRequest(se.session_resume,e)}async unstable_closeSession(e){return await l(this,q).sendRequest(se.session_close,e)}async setSessionMode(e){return await l(this,q).sendRequest(se.session_set_mode,e)??{}}async unstable_setSessionModel(e){return await l(this,q).sendRequest(se.session_set_model,e)??{}}async setSessionConfigOption(e){return await l(this,q).sendRequest(se.session_set_config_option,e)}async authenticate(e){return await l(this,q).sendRequest(se.authenticate,e)??{}}async unstable_logout(e){return await l(this,q).sendRequest(se.logout,e)??{}}async prompt(e){return await l(this,q).sendRequest(se.session_prompt,e)}async cancel(e){return await l(this,q).sendNotification(se.session_cancel,e)}async unstable_startNes(e){return await l(this,q).sendRequest(se.nes_start,e)}async unstable_suggestNes(e){return await l(this,q).sendRequest(se.nes_suggest,e)}async unstable_closeNes(e){return await l(this,q).sendRequest(se.nes_close,e)??{}}async unstable_didOpenDocument(e){return await l(this,q).sendNotification(se.document_did_open,e)}async unstable_didChangeDocument(e){return await l(this,q).sendNotification(se.document_did_change,e)}async unstable_didCloseDocument(e){return await l(this,q).sendNotification(se.document_did_close,e)}async unstable_didSaveDocument(e){return await l(this,q).sendNotification(se.document_did_save,e)}async unstable_didFocusDocument(e){return await l(this,q).sendNotification(se.document_did_focus,e)}async unstable_acceptNes(e){return await l(this,q).sendNotification(se.nes_accept,e)}async unstable_rejectNes(e){return await l(this,q).sendNotification(se.nes_reject,e)}async extMethod(e,t){return await l(this,q).sendRequest(e,t)}async extNotification(e,t){return await l(this,q).sendNotification(e,t)}get signal(){return l(this,q).signal}get closed(){return l(this,q).closed}}q=new WeakMap;var sn,da,ls,cs,Or,zr,$t,us,ue,Bm,wc,Gm,Wm,qm,Ym,_c,Li;class oR{constructor(e,t,r){_(this,ue);_(this,sn,new Map);_(this,da,0);_(this,ls);_(this,cs);_(this,Or);_(this,zr,Promise.resolve());_(this,$t,new AbortController);_(this,us);E(this,ls,e),E(this,cs,t),E(this,Or,r),E(this,us,new Promise(i=>{l(this,$t).signal.addEventListener("abort",()=>i())})),m(this,ue,Bm).call(this)}get signal(){return l(this,$t).signal}get closed(){return l(this,us)}async sendRequest(e,t){m(this,ue,_c).call(this);const r=Ch(this,da)._++,i=new Promise((s,o)=>{l(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,_c).call(this),await m(this,ue,Li).call(this,{jsonrpc:"2.0",method:e,params:t})}}sn=new WeakMap,da=new WeakMap,ls=new WeakMap,cs=new WeakMap,Or=new WeakMap,zr=new WeakMap,$t=new WeakMap,us=new WeakMap,ue=new WeakSet,Bm=async function(){let e;try{const t=l(this,Or).readable.getReader();try{for(;!l(this,$t).signal.aborted;){const{value:r,done:i}=await t.read();if(i)break;if(r)try{m(this,ue,Gm).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,wc).call(this,e)}},wc=function(e){if(l(this,$t).signal.aborted)return;const t=e??new Error("ACP connection closed");for(const r of l(this,sn).values())r.reject(t);l(this,sn).clear(),l(this,$t).abort(t)},Gm=async function(e){if("method"in e&&"id"in e){const t=await m(this,ue,Wm).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,qm).call(this,e.method,e.params);"error"in t&&console.error("Error handling notification",e,t.error)}else"id"in e?m(this,ue,Ym).call(this,e):console.error("Invalid message",{message:e})},Wm=async function(e,t){try{return{result:await l(this,ls).call(this,e,t)??null}}catch(r){if(r instanceof we)return r.toResult();if(r instanceof wf)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()}}},qm=async function(e,t){try{return await l(this,cs).call(this,e,t),{result:null}}catch(r){if(r instanceof we)return r.toResult();if(r instanceof wf)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()}}},Ym=function(e){const t=l(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))}l(this,sn).delete(e.id)}else console.error("Got response to unknown request",e.id)},_c=function(){if(l(this,$t).signal.aborted)throw l(this,$t).signal.reason??new Error("ACP connection closed")},Li=async function(e){return E(this,zr,l(this,zr).then(async()=>{const t=l(this,Or).writable.getWriter();try{await t.write(e)}finally{t.releaseLock()}}).catch(t=>{m(this,ue,wc).call(this,t)})),l(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 aR=/^Sender \(untrusted metadata\):\n```json\n[\s\S]*?\n```\n\n?/,lR=/^\[[^\n]*Working directory:[^\n]*\]\n\n?/,cR=/\[Television screen context\][\s\S]*?\[\/Television screen context\]\n*/,uR=/\[\[\s*(?:reply_to_current|reply_to\s*:\s*[^\]\n]+|audio_as_voice)\s*\]\]\s*/gi,hR="single_session",dR={name:"television-acp-client",version:"0.0.0"},Km="agent:main:television",fR=di(gt);var ee,Nt,Lr,Ut,Hn,Vn,on,Mr,At,lt,an,jn,Ft,ln,hs,Zt,ct,fa,Ht,C,Jm,Xm,Sc,Qm,ey,ty,ny,ry,iy,sy,Tn,kr,Er,qe,oy,$r,kc,Ec,Fo,ay,ds,fs,$c,Ar,ly,cy;class pR extends fR{constructor(t){super();_(this,C);_(this,ee,gR());_(this,Nt,null);_(this,Lr,null);_(this,Ut,null);_(this,Hn,null);_(this,Vn,null);_(this,on,null);_(this,Mr,1);_(this,At,null);_(this,lt,null);_(this,an,!1);_(this,jn,!1);_(this,Ft,null);_(this,ln,new Set);_(this,hs);_(this,Zt);_(this,ct);_(this,fa,t=>{m(this,C,Xm).call(this,t)});_(this,Ht,null);_(this,ds,()=>{m(this,C,Ar).call(this,"ACP bridge websocket closed")});_(this,fs,()=>{m(this,C,Ar).call(this,"ACP bridge websocket error")});E(this,Zt,t),E(this,ct,t.sessionMode??hR),E(this,hs,t.createSocket??(r=>new WebSocket(r)))}getState(){return l(this,ee)}get messages(){return l(this,ee).messageOrder.map(t=>l(this,ee).messagesById[t]).filter(t=>t!==void 0)}async connect(){if(this.disposed)throw new Error("ACPClient has been disposed");if(l(this,ee).lifecycle.status!=="ready"){m(this,C,qe).call(this,{lifecycle:{status:"connecting"}}),l(this,Lr)??E(this,Lr,m(this,C,Jm).call(this));try{await l(this,Lr),await m(this,C,Sc).call(this)}catch(t){throw m(this,C,Ar).call(this,So(t)),t}}}dispose(){m(this,C,$c).call(this),m(this,C,qe).call(this,{lifecycle:{status:"disposed"},run:{status:"idle",stopReason:null,canCancel:!1,error:null}})}async sendMessage(t){if(await this.connect(),l(this,ee).lifecycle.status!=="ready"||l(this,ee).run.status==="running"||l(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,qe).call(this,{run:{status:"running",stopReason:null,canCancel:!0,error:null}});try{const i=await m(this,C,Fo).call(this).prompt({sessionId:m(this,C,Ec).call(this),prompt:[{type:"text",text:m(this,C,oy).call(this,r)}]});m(this,C,Tn).call(this,i.stopReason==="cancelled"?"cancelled":"final"),m(this,C,qe).call(this,{run:{status:i.stopReason==="cancelled"?"cancelled":"completed",stopReason:i.stopReason,canCancel:!1,error:null}})}catch(i){throw m(this,C,cy).call(this)||(m(this,C,Tn).call(this,"error"),m(this,C,qe).call(this,{run:{status:"error",stopReason:null,canCancel:!1,error:So(i)}})),i}}async cancel(){if(await this.connect(),!l(this,ee).run.canCancel||l(this,ee).run.status!=="running")throw new Error("No active cancellable run");m(this,C,qe).call(this,{run:{...l(this,ee).run,status:"cancelling"}}),await m(this,C,Fo).call(this).cancel({sessionId:m(this,C,Ec).call(this)})}setScreenContext(t){var s,o,a;const r={screenID:t.screenID,screenName:t.screenName};if(((s=l(this,lt))==null?void 0:s.screenID)===r.screenID&&((o=l(this,lt))==null?void 0:o.screenName)===r.screenName)return;const i=((a=l(this,lt))==null?void 0:a.screenID)??null;if(E(this,lt,r),l(this,ct)==="single_session"){(!l(this,on)||i!==r.screenID)&&E(this,an,!0);return}l(this,on)!==Af(l(this,ct),r.screenID,l(this,Zt).clientGUID??"default-client")&&(E(this,Ut,null),E(this,Hn,null),l(this,Nt)&&l(this,ee).run.status==="idle"&&m(this,C,Sc).call(this).catch(c=>{m(this,C,Ar).call(this,So(c))}))}}ee=new WeakMap,Nt=new WeakMap,Lr=new WeakMap,Ut=new WeakMap,Hn=new WeakMap,Vn=new WeakMap,on=new WeakMap,Mr=new WeakMap,At=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,fa=new WeakMap,Ht=new WeakMap,C=new WeakSet,Jm=async function(){try{m(this,C,qe).call(this,{lifecycle:{status:"connecting"}});const{stream:t,socket:r}=await vR({serverURL:l(this,Zt).serverURL,token:l(this,Zt).token,createSocket:l(this,hs),onDisconnect:l(this,fa)});E(this,Ht,r),r.addEventListener("close",l(this,ds)),r.addEventListener("error",l(this,fs)),E(this,Nt,new sR(i=>({connection:i,sessionUpdate:async s=>{await m(this,C,ey).call(this,s)},requestPermission:async s=>m(this,C,ty).call(this,s)}),t)),await l(this,Nt).initialize({protocolVersion:HC,clientCapabilities:{},clientInfo:dR})}catch(t){throw t}},Xm=function(t){m(this,C,Ar).call(this,So(t))},Sc=async function(){const t=m(this,C,ay).call(this);if(l(this,Ut)&&l(this,Hn)===t){await l(this,Ut);return}E(this,Hn,t),E(this,Ut,m(this,C,Qm).call(this,t)),await l(this,Ut)},Qm=async function(t){const r=m(this,C,Fo).call(this);m(this,C,ly).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=l(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?(l(this,ln).add(t),l(this,ct)==="single_session"&&E(this,an,!1)):(l(this,ln).delete(t),E(this,an,l(this,ct)==="single_session")),m(this,C,qe).call(this,{lifecycle:{status:"ready"}})},ey=async function(t){const r=t.update;switch(r.sessionUpdate){case"user_message_chunk":r.content.type==="text"&&m(this,C,sy).call(this,r.content.text);return;case"agent_message_chunk":r.content.type==="text"&&m(this,C,ny).call(this,r.content.text);return;case"tool_call":m(this,C,ry).call(this,r);return;case"tool_call_update":m(this,C,iy).call(this,r);return;case"agent_thought_chunk":return;default:return}},ty=async function(t){return{outcome:{outcome:"cancelled"}}},ny=function(t){E(this,Ft,null);const r=mR(t);if(!r)return;if(!l(this,At)){const s={id:m(this,C,$r).call(this,"assistant"),kind:"assistant",text:r,status:"streaming"};E(this,At,s.id),m(this,C,kr).call(this,s);return}const i=l(this,ee).messagesById[l(this,At)];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"})},ry=function(t){m(this,C,Tn).call(this,"final");const r=m(this,C,kc).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)},iy=function(t){const r=m(this,C,kc).call(this,t.toolCallId),i=(r==null?void 0:r.text)??"",s=yR(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)},sy=function(t){if(m(this,C,Tn).call(this,"final"),!t)return;const r=l(this,jn)?l(this,Ft):null;if(!r){const s=xf(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),l(this,jn)&&E(this,Ft,o.id);return}const i=l(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:xf(`${i.text}${t}`)})},Tn=function(t){if(!l(this,At))return;const r=l(this,ee).messagesById[l(this,At)];(r==null?void 0:r.kind)==="assistant"&&m(this,C,Er).call(this,{...r,status:t}),E(this,At,null)},kr=function(t){m(this,C,qe).call(this,{messagesById:{...l(this,ee).messagesById,[t.id]:t},messageOrder:[...l(this,ee).messageOrder,t.id]})},Er=function(t){m(this,C,qe).call(this,{messagesById:{...l(this,ee).messagesById,[t.id]:t}})},qe=function(t){const r={...l(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"))},oy=function(t){const r=l(this,on);return!l(this,lt)||!r||!(l(this,ct)==="single_session"?l(this,an)||!l(this,ln).has(r):!l(this,ln).has(r))?t:(E(this,an,!1),l(this,ln).add(r),["[Television screen context]","This chat session is coming from a Television client in the screen below.",`screen_id: ${l(this,lt).screenID}`,`screen_name: ${l(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}-${l(this,Mr)}`;return E(this,Mr,l(this,Mr)+1),r},kc=function(t){for(const r of l(this,ee).messageOrder){const i=l(this,ee).messagesById[r];if((i==null?void 0:i.kind)==="tool_call"&&i.toolCallId===t)return i}return null},Ec=function(){if(!l(this,Vn))throw new Error("ACP session is not ready");return l(this,Vn)},Fo=function(){if(!l(this,Nt))throw new Error("ACP connection is not ready");return l(this,Nt)},ay=function(){var r;if(l(this,ct)==="single_session")return`${Km}-${(l(this,Zt).clientGUID??"default-client").toLowerCase()}`;const t=(r=l(this,lt))==null?void 0:r.screenID;if(!t)throw new Error("Screen context is required for per-screen session mode");return Af(l(this,ct),t,l(this,Zt).clientGUID??"default-client")},ds=new WeakMap,fs=new WeakMap,$c=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),l(this,Ht)&&(l(this,Ht).removeEventListener("close",l(this,ds)),l(this,Ht).removeEventListener("error",l(this,fs)),l(this,Ht).close(),E(this,Ht,null))},Ar=function(t){this.disposed||l(this,ee).lifecycle.status==="disconnected"||(m(this,C,Tn).call(this,"error"),m(this,C,$c).call(this),m(this,C,qe).call(this,{lifecycle:{status:"disconnected",...t?{error:t}:{}},run:{status:"idle",stopReason:null,canCancel:!1,error:null}}))},ly=function(){E(this,At,null),E(this,Ft,null),E(this,Mr,1),m(this,C,qe).call(this,{run:{status:"idle",stopReason:null,canCancel:!1,error:null},messagesById:{},messageOrder:[]})},cy=function(){return l(this,ee).lifecycle.status==="disconnected"};function gR(){return{lifecycle:{status:"connecting"},run:{status:"idle",stopReason:null,canCancel:!1,error:null},messagesById:{},messageOrder:[],sendDisabled:!0,cancelDisabled:!0}}function Af(n,e,t){return n==="single_session"?`${Km}-${t.toLowerCase()}`:`agent:main:television-${t.toLowerCase()}-${e.toLowerCase()}`}function uy(n){return n.replace(/^(?:\s*\n)+/,"")}function xf(n){let e=n;return e=e.replace(aR,""),e=e.replace(lR,""),e=e.replace(cR,""),e=uy(e),e}function mR(n){let e=n;return e=e.replace(uR,""),e=uy(e),e}function yR(n){return!n||n.length===0?"":n.flatMap(e=>e.type==="content"&&e.content.type==="text"?[e.content.text]:[]).join("")}async function vR(n){const e=n.createSocket(wR(n.serverURL,n.token));let t=!1,r,i;const s=new Promise((c,u)=>{r=c,i=u}),o=new ReadableStream({start(c){let u=!1;const d=()=>{e.send(JSON.stringify({type:"acp-bridge-connect"}))},f=A=>{const k=bR(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),c.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),c.error(B)}return;case"acp-bridge-message":c.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),c.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),c.error(A)};e.addEventListener("open",d),e.addEventListener("message",f),e.addEventListener("close",v),e.addEventListener("error",y)}}),a=new WritableStream({async write(c){await s,e.send(JSON.stringify({type:"acp-bridge-message",message:c}))},close(){e.close()},abort(){e.close()}});return await s,{stream:{readable:o,writable:a},socket:e}}function bR(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 wR(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 So(n){return n instanceof Error?n.message:String(n)}const Tf="television.acpClientGUID",_R=di(gt);class SR extends _R{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??kR(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 pR({...this.options,sessionMode:this.sessionMode,clientGUID:this.clientGUID}),this.clients.set(r,i)),i.setScreenContext({screenID:t.id,screenName:t.name}),i}}function kR(n){const e=n.getItem(Tf);if(e)return e;const t=Tu().toLowerCase();return n.setItem(Tf,t),t}var ps;class ER extends gt{constructor(){super();_(this,ps,t=>{const r=$R(t);r!==null&&(t.preventDefault(),this.dispatchEvent(new h0("shortcut-triggered",{shortcut:r})))});document.addEventListener("keydown",l(this,ps))}dispose(){document.removeEventListener("keydown",l(this,ps))}}ps=new WeakMap;function $R(n){for(const[e,t]of Object.entries(Z0))if(AR(n,t.trigger))return e;return null}function AR(n,e){return!(n.key.toLowerCase()!==e.key.toLowerCase()||n.metaKey!==!!e.meta||n.ctrlKey!==!!e.ctrl||n.shiftKey!==!!e.shift||n.altKey!==!!e.alt)}const xR="serverURL",TR="token",CR="mode",IR="electron";function hy(n=window.location.search,e=window.location.origin){const r=new URLSearchParams(n).get(xR);return r?new URL(r).origin:new URL(e).origin}function Ac(n=window.location.search){return new URLSearchParams(n).get(TR)}function dy(n=window.location.search){return new URLSearchParams(n).get(CR)===IR}/**
44
- * @license
45
- * Copyright 2017 Google LLC
46
- * SPDX-License-Identifier: BSD-3-Clause
47
- */const qi=globalThis,Cf=n=>n,ia=qi.trustedTypes,If=ia?ia.createPolicy("lit-html",{createHTML:n=>n}):void 0,fy="$lit$",en=`lit$${Math.random().toFixed(9).slice(2)}$`,py="?"+en,PR=`<${py}>`,rr=document,Xi=()=>rr.createComment(""),Qi=n=>n===null||typeof n!="object"&&typeof n!="function",Hu=Array.isArray,RR=n=>Hu(n)||typeof(n==null?void 0:n[Symbol.iterator])=="function",Ul=`[
48
- \f\r]`,$i=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,Pf=/-->/g,Rf=/>/g,An=RegExp(`>|${Ul}(?:([^\\s"'>=/]+)(${Ul}*=${Ul}*(?:[^
49
- \f\r"'\`<>=]|("|')|))|$)`,"g"),Df=/'/g,Of=/"/g,gy=/^(?:script|style|textarea|title)$/i,DR=n=>(e,...t)=>({_$litType$:n,strings:e,values:t}),F=DR(1),ti=Symbol.for("lit-noChange"),oe=Symbol.for("lit-nothing"),zf=new WeakMap,Ln=rr.createTreeWalker(rr,129);function my(n,e){if(!Hu(n)||!n.hasOwnProperty("raw"))throw Error("invalid template strings array");return If!==void 0?If.createHTML(e):e}const OR=(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 c=n[a];let u,d,f=-1,v=0;for(;v<c.length&&(o.lastIndex=v,d=o.exec(c),d!==null);)v=o.lastIndex,o===$i?d[1]==="!--"?o=Pf:d[1]!==void 0?o=Rf:d[2]!==void 0?(gy.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]==='"'?Of:Df):o===Of||o===Df?o=An:o===Pf||o===Rf?o=$i:(o=An,i=void 0);const y=o===An&&n[a+1].startsWith("/>")?" ":"";s+=o===$i?c+PR:f>=0?(r.push(u),c.slice(0,f)+fy+c.slice(f)+en+y):c+en+(f===-2?a:y)}return[my(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,c=this.parts,[u,d]=OR(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&&c.length<a;){if(i.nodeType===1){if(i.hasAttributes())for(const f of i.getAttributeNames())if(f.endsWith(fy)){const v=d[o++],y=i.getAttribute(f).split(en),A=/([.?@])?(.*)/.exec(v);c.push({type:1,index:s,name:A[2],strings:y,ctor:A[1]==="."?LR:A[1]==="?"?MR:A[1]==="@"?NR:ja}),i.removeAttribute(f)}else f.startsWith(en)&&(c.push({type:6,index:s}),i.removeAttribute(f));if(gy.test(i.tagName)){const f=i.textContent.split(en),v=f.length-1;if(v>0){i.textContent=ia?ia.emptyScript:"";for(let y=0;y<v;y++)i.append(f[y],Xi()),Ln.nextNode(),c.push({type:2,index:++s});i.append(f[v],Xi())}}}else if(i.nodeType===8)if(i.data===py)c.push({type:2,index:s});else{let f=-1;for(;(f=i.data.indexOf(en,f+1))!==-1;)c.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 zR{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,c=r[0];for(;c!==void 0;){if(o===c.index){let u;c.type===2?u=new Vu(s,s.nextSibling,this,e):c.type===1?u=new c.ctor(s,c.name,c.strings,this,e):c.type===6&&(u=new UR(s,this,e)),this._$AV.push(u),c=r[++a]}o!==(c==null?void 0:c.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 Vu=class yy{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):RR(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(my(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 zR(i,this),a=o.u(this.options);o.p(t),this.T(a),this._$AH=o}}_$AC(e){let t=zf.get(e.strings);return t===void 0&&zf.set(e.strings,t=new es(e)),t}k(e){Hu(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 yy(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=Cf(e).nextSibling;Cf(e).remove(),e=i}}setConnected(e){var t;this._$AM===void 0&&(this._$Cv=e,(t=this._$AP)==null||t.call(this,e))}},ja=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 c,u;for(e=s[0],c=0;c<s.length-1;c++)u=ni(this,a[r+c],t,c),u===ti&&(u=this._$AH[c]),o||(o=!Qi(u)||u!==this._$AH[c]),u===oe?e=oe:e!==oe&&(e+=(u??"")+s[c+1]),this._$AH[c]=u}o&&!i&&this.j(e)}j(e){e===oe?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,e??"")}},LR=class extends ja{constructor(){super(...arguments),this.type=3}j(e){this.element[this.name]=e===oe?void 0:e}},MR=class extends ja{constructor(){super(...arguments),this.type=4}j(e){this.element.toggleAttribute(this.name,!!e&&e!==oe)}},NR=class extends ja{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 UR{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 Fl=qi.litHtmlPolyfillSupport;Fl==null||Fl(es,Vu),(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 Vu(e.insertBefore(Xi(),null),null,void 0,{})),i._$AI(n),i};/**
50
- * @license
51
- * Copyright 2017 Google LLC
52
- * SPDX-License-Identifier: BSD-3-Clause
53
- */const vy={CHILD:2},ju=n=>(...e)=>({_$litDirective$:n,values:e});class by{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
- * @license
55
- * Copyright 2017 Google LLC
56
- * SPDX-License-Identifier: BSD-3-Clause
57
- */let sa=class extends by{constructor(e){if(super(e),this.it=oe,e.type!==vy.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:[]}}};sa.directiveName="unsafeHTML",sa.resultType=1;const FR=ju(sa);/**
58
- * @license
59
- * Copyright 2017 Google LLC
60
- * SPDX-License-Identifier: BSD-3-Clause
61
- */class xc extends sa{}xc.directiveName="unsafeSVG",xc.resultType=2;const ZR=ju(xc),HR={size:16,color:"currentColor",weight:"regular"};function VR(n){return typeof n=="string"?{regular:n}:n}function Jt(n,e="0 0 256 256"){const t=VR(n);return r=>{const{size:i,color:s,weight:o}={...HR,...r},a=t[o]??t.regular;return F`<svg
62
- xmlns="http://www.w3.org/2000/svg"
63
- data-ui-icon=""
64
- width="${i}"
65
- height="${i}"
66
- viewBox="${e}"
67
- fill="${s}"
68
- >${ZR(a)}</svg>`}}const jR=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"/>'),wy=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"/>'),BR=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"/>'),_y=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"/>'),GR=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"/>'),WR=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"/>'),qR=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"/>'}),YR=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"/>'}),KR=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 Sy extends Event{constructor(t){super("dropdown-item-select",{bubbles:!0,composed:!0});b(this,"value");this.value=t}}class JR extends Event{constructor(t){super("select",{bubbles:!0,composed:!0});b(this,"value");this.value=t}}var Ke,ut,cn,Nr,te,gs,z,Ey,Mi,$y,Ay,Tc,xy,Ni,Cn,Bn,ms,ys,vs,pa,Ty,Cy,Cc,Ui,Iy,Ic,zt;class ky extends HTMLElement{constructor(){super();_(this,z);_(this,Ke,!1);_(this,ut,null);_(this,cn,null);_(this,Nr);_(this,te,null);_(this,gs,new MutationObserver(t=>m(this,z,Ty).call(this,t)));_(this,Bn,()=>{m(this,z,Ni).call(this,!l(this,Ke))});_(this,ms,t=>{t.key!=="Enter"&&t.key!==" "||(t.preventDefault(),l(this,Bn).call(this))});_(this,ys,t=>{l(this,Ke)&&(t.composedPath().includes(this)||m(this,z,Ni).call(this,!1))});_(this,vs,t=>{t instanceof Sy&&(t.stopPropagation(),E(this,Ke,!1),m(this,z,Mi).call(this,t.value),m(this,z,zt).call(this),this.dispatchEvent(new JR(t.value)))});_(this,pa,()=>{m(this,z,Cc).call(this)});E(this,Nr,this.attachShadow({mode:"open"}))}connectedCallback(){this.addEventListener("dropdown-item-select",l(this,vs)),document.addEventListener("click",l(this,ys),!0),m(this,z,Ey).call(this),l(this,gs).observe(this,{childList:!0,subtree:!0,characterData:!0,attributes:!0,attributeFilter:["selected","value","slot"]}),m(this,z,zt).call(this)}disconnectedCallback(){this.removeEventListener("dropdown-item-select",l(this,vs)),document.removeEventListener("click",l(this,ys),!0),l(this,gs).disconnect(),m(this,z,Ic).call(this)}attributeChangedCallback(t){if(t==="open"){m(this,z,Ni).call(this,this.hasAttribute("open"));return}m(this,z,zt).call(this)}get open(){return l(this,Ke)}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 l(this,ut)}set value(t){t===null?(m(this,z,Cn).call(this,null,null),m(this,z,$y).call(this)):m(this,z,Mi).call(this,t),m(this,z,zt).call(this)}close(){m(this,z,Ni).call(this,!1)}}Ke=new WeakMap,ut=new WeakMap,cn=new WeakMap,Nr=new WeakMap,te=new WeakMap,gs=new WeakMap,z=new WeakSet,Ey=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 l(this,z,Tc))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")},$y=function(){const t=this.querySelectorAll("dropdown-item[selected]");for(const r of t)r.removeAttribute("selected")},Ay=function(t){for(const r of l(this,z,Tc))if(r.value===t)return r;return null},Tc=function(){return this.querySelectorAll("dropdown-item")},xy=function(){return l(this,cn)??this.title},Ni=function(t){l(this,Ke)!==t&&(E(this,Ke,t),m(this,z,zt).call(this))},Cn=function(t,r){E(this,ut,t),E(this,cn,r)},Bn=new WeakMap,ms=new WeakMap,ys=new WeakMap,vs=new WeakMap,pa=new WeakMap,Ty=function(t){t.every(i=>i.target instanceof Element?i.target.closest('[slot="trigger"]')!==null:!1)||m(this,z,Cy).call(this)},Cy=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=l(this,ut)!==s||l(this,cn)!==o;m(this,z,Cn).call(this,s,o),m(this,z,Mi).call(this,s),a?m(this,z,zt).call(this):m(this,z,Ui).call(this);return}if(l(this,ut)!==null){const s=m(this,z,Ay).call(this,l(this,ut));if(s){const o=((i=s.textContent)==null?void 0:i.trim())??null,a=l(this,cn)!==o;m(this,z,Cn).call(this,l(this,ut),o),m(this,z,Mi).call(this,l(this,ut)),a?m(this,z,zt).call(this):m(this,z,Ui).call(this);return}}if(l(this,ut)!==null||l(this,cn)!==null){m(this,z,Cn).call(this,null,null),m(this,z,zt).call(this);return}m(this,z,Ui).call(this)},Cc=function(){const t=l(this,Nr).querySelector('slot[name="trigger"]'),r=t instanceof HTMLSlotElement?t.assignedElements()[0]??null:null;l(this,te)!==r&&(m(this,z,Ic).call(this),E(this,te,r),l(this,te)&&(l(this,te).addEventListener("click",l(this,Bn)),l(this,te)instanceof HTMLButtonElement?l(this,te).hasAttribute("type")||(l(this,te).type="button"):(l(this,te).hasAttribute("role")||l(this,te).setAttribute("role","button"),l(this,te).hasAttribute("tabindex")||(l(this,te).tabIndex=0),l(this,te).addEventListener("keydown",l(this,ms))))),m(this,z,Ui).call(this)},Ui=function(){l(this,te)&&(l(this,te).setAttribute("data-dropdown-trigger",""),l(this,te).setAttribute("aria-haspopup","listbox"),l(this,te).setAttribute("aria-expanded",l(this,Ke)?"true":"false"))},Iy=function(){return this.placement==="top"?GR:_y},Ic=function(){l(this,te)&&(l(this,te).removeEventListener("click",l(this,Bn)),l(this,te).removeEventListener("keydown",l(this,ms)),l(this,te).removeAttribute("data-dropdown-trigger"),l(this,te).removeAttribute("aria-haspopup"),l(this,te).removeAttribute("aria-expanded"),E(this,te,null))},zt=function(){this.toggleAttribute("open",l(this,Ke)),Pe(F`
69
- <slot name="trigger" @slotchange=${l(this,pa)}>
70
- <button
71
- class="fallback-trigger"
72
- part="trigger"
73
- type="button"
74
- aria-haspopup="listbox"
75
- aria-expanded=${l(this,Ke)?"true":"false"}
76
- @click=${l(this,Bn)}
77
- >
78
- <span class="trigger-label" part="trigger-label">${l(this,z,xy)}</span>
79
- <span class="trigger-icon" part="trigger-icon" aria-hidden="true">
80
- ${l(this,z,Iy).call(this,{size:16})}
81
- </span>
82
- </button>
83
- </slot>
84
- ${l(this,Ke)?F`
85
- <div
86
- class="panel"
87
- part="panel panel-${this.placement}"
88
- role="listbox"
89
- >
90
- <slot></slot>
91
- </div>
92
- `:null}
93
- `,l(this,Nr)),queueMicrotask(()=>m(this,z,Cc).call(this))},b(ky,"observedAttributes",["title","placement","open"]);class XR extends HTMLElement{}class QR extends HTMLElement{}class eD extends HTMLElement{}var or,Pc,Ry,bs,ws;class Py extends HTMLElement{constructor(){super(...arguments);_(this,or);_(this,bs,()=>{this.action||m(this,or,Ry).call(this)});_(this,ws,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",l(this,bs)),this.addEventListener("keydown",l(this,ws)),m(this,or,Pc).call(this)}disconnectedCallback(){this.removeEventListener("click",l(this,bs)),this.removeEventListener("keydown",l(this,ws))}attributeChangedCallback(){m(this,or,Pc).call(this)}get value(){return this.getAttribute("value")??""}get selected(){return this.hasAttribute("selected")}get action(){return this.hasAttribute("action")}}or=new WeakSet,Pc=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")},Ry=function(){this.dispatchEvent(new Sy(this.value))},bs=new WeakMap,ws=new WeakMap,b(Py,"observedAttributes",["action","selected","value"]);customElements.get("dropdown-menu")||customElements.define("dropdown-menu",ky);customElements.get("dropdown-group")||customElements.define("dropdown-group",XR);customElements.get("dropdown-label")||customElements.define("dropdown-label",QR);customElements.get("dropdown-divider")||customElements.define("dropdown-divider",eD);customElements.get("dropdown-item")||customElements.define("dropdown-item",Py);class tD extends Event{constructor(){super("close",{bubbles:!0,composed:!0})}}var _s,yn,Rc,ga,Ss,Dc;class Dy extends HTMLElement{constructor(){super();_(this,yn);_(this,_s);_(this,ga,t=>{t.target===t.currentTarget&&m(this,yn,Rc).call(this)});_(this,Ss,t=>{this.open&&t.key==="Escape"&&m(this,yn,Rc).call(this)});E(this,_s,this.attachShadow({mode:"open"}))}connectedCallback(){document.addEventListener("keydown",l(this,Ss)),m(this,yn,Dc).call(this)}disconnectedCallback(){document.removeEventListener("keydown",l(this,Ss))}attributeChangedCallback(){m(this,yn,Dc).call(this)}get open(){return this.hasAttribute("open")}}_s=new WeakMap,yn=new WeakSet,Rc=function(){this.dispatchEvent(new tD)},ga=new WeakMap,Ss=new WeakMap,Dc=function(){Pe(F`
94
- ${this.open?F`
95
- <div class="backdrop" part="backdrop" @click=${l(this,ga)}>
96
- <slot></slot>
97
- </div>
98
- `:null}
99
- `,l(this,_s))},b(Dy,"observedAttributes",["open"]);customElements.get("modal-overlay")||customElements.define("modal-overlay",Dy);class nD extends Event{constructor(){super("close",{bubbles:!0,composed:!0})}}class rD extends HTMLElement{}var ks,Es,Oc;class Oy extends HTMLElement{constructor(){super();_(this,Es);_(this,ks);E(this,ks,this.attachShadow({mode:"open"}))}connectedCallback(){m(this,Es,Oc).call(this)}attributeChangedCallback(){m(this,Es,Oc).call(this)}get closable(){return this.hasAttribute("closable")}}ks=new WeakMap,Es=new WeakSet,Oc=function(){const t=this.querySelector("panel-page");Pe(F`
100
- <section class="panel" part="panel">
101
- <header class="title-bar" part="header">
102
- <h2 class="title" part="title">${(t==null?void 0:t.getAttribute("title"))??""}</h2>
103
- ${this.closable?F`
104
- <button
105
- type="button"
106
- class="title-button"
107
- part="button close-button"
108
- aria-label="Close"
109
- @click=${()=>this.dispatchEvent(new nD)}
110
- >
111
- <span class="close-icon" part="icon close-icon">${wy({size:16})}</span>
112
- </button>
113
- `:null}
114
- </header>
115
- <slot></slot>
116
- </section>
117
- `,l(this,ks))},b(Oy,"observedAttributes",["closable"]);customElements.get("panel-view")||customElements.define("panel-view",Oy);customElements.get("panel-page")||customElements.define("panel-page",rD);class iD extends Event{constructor(){super("close",{bubbles:!0,composed:!0})}}const Lf='a[href],button:not([disabled]),input:not([disabled]),select:not([disabled]),textarea:not([disabled]),[tabindex]:not([tabindex="-1"])',Zl=4;var Ve,Vt,Ur,et,$s,Fr,ne,Ly,My,zc,As,xs,Gn,Ny,Lc,Uy,Fy,Zo,Ho;class zy extends HTMLElement{constructor(){super();_(this,ne);_(this,Ve,!1);_(this,Vt,null);_(this,Ur);_(this,et,null);_(this,$s,"bottom-start");_(this,Fr,!1);_(this,As,t=>{l(this,Ve)&&(l(this,Fr)||t.composedPath().includes(this)||(this.open=!1))});_(this,xs,t=>{if(l(this,Ve)){if(t.key==="Escape"){t.preventDefault(),this.open=!1;return}t.key==="Tab"&&m(this,ne,Ny).call(this,t)}});_(this,Gn,()=>{l(this,Ve)&&m(this,ne,Zo).call(this)});E(this,Ur,this.attachShadow({mode:"open"}))}connectedCallback(){m(this,ne,Ho).call(this)}disconnectedCallback(){m(this,ne,zc).call(this)}attributeChangedCallback(t){t==="open"&&m(this,ne,Ly).call(this,this.hasAttribute("open"))}get open(){return l(this,Ve)}set open(t){this.toggleAttribute("open",t)}get anchor(){return l(this,Vt)}set anchor(t){l(this,Vt)!==t&&(E(this,Vt,t),l(this,Ve)&&m(this,ne,Zo).call(this))}}Ve=new WeakMap,Vt=new WeakMap,Ur=new WeakMap,et=new WeakMap,$s=new WeakMap,Fr=new WeakMap,ne=new WeakSet,Ly=function(t){var r;l(this,Ve)!==t&&(E(this,Ve,t),t?(E(this,Fr,!0),setTimeout(()=>{E(this,Fr,!1)},0),m(this,ne,Ho).call(this),m(this,ne,My).call(this),queueMicrotask(()=>{l(this,Ve)&&(m(this,ne,Zo).call(this),m(this,ne,Fy).call(this))})):(m(this,ne,zc).call(this),m(this,ne,Ho).call(this),(r=l(this,Vt))==null||r.focus(),this.dispatchEvent(new iD)))},My=function(){document.addEventListener("click",l(this,As)),document.addEventListener("keydown",l(this,xs),!0),window.addEventListener("resize",l(this,Gn)),window.addEventListener("scroll",l(this,Gn),!0)},zc=function(){document.removeEventListener("click",l(this,As)),document.removeEventListener("keydown",l(this,xs),!0),window.removeEventListener("resize",l(this,Gn)),window.removeEventListener("scroll",l(this,Gn),!0)},As=new WeakMap,xs=new WeakMap,Gn=new WeakMap,Ny=function(t){const r=m(this,ne,Lc).call(this);if(r.length===0){t.preventDefault();return}const i=r[0],s=r[r.length-1],o=m(this,ne,Uy).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())},Lc=function(){if(!l(this,et))return[];const t=l(this,et).querySelector("slot");if(!(t instanceof HTMLSlotElement))return[];const r=[];for(const i of t.assignedElements({flatten:!0}))if(i instanceof HTMLElement){i.matches(Lf)&&r.push(i);for(const s of i.querySelectorAll(Lf))r.push(s)}return r},Uy=function(){var r;let t=document.activeElement;for(;t&&((r=t.shadowRoot)!=null&&r.activeElement);)t=t.shadowRoot.activeElement;return t},Fy=function(){var r;const t=m(this,ne,Lc).call(this);t.length>0?t[0].focus():(r=l(this,et))==null||r.focus()},Zo=function(){if(!l(this,Ve)||!l(this,Vt)||!l(this,et))return;const t=l(this,Vt).getBoundingClientRect(),r=l(this,et).getBoundingClientRect(),s=window.innerHeight-t.bottom,o=r.height+Zl,a=s<o&&t.top>o?"top-start":"bottom-start";E(this,$s,a);const c=a==="bottom-start"?t.bottom+Zl:t.top-r.height-Zl,u=t.left;l(this,et).style.top=`${c}px`,l(this,et).style.left=`${u}px`,l(this,et).setAttribute("data-placement",a)},Ho=function(){this.toggleAttribute("open",l(this,Ve)),Pe(l(this,Ve)?F`<div
118
- class="panel"
119
- part="panel"
120
- data-placement=${l(this,$s)}
121
- tabindex="-1"
122
- role="dialog"
123
- >
124
- <slot></slot>
125
- </div>`:oe,l(this,Ur)),E(this,et,l(this,Ur).querySelector(".panel"))},b(zy,"observedAttributes",["open"]);customElements.get("ui-popover")||customElements.define("ui-popover",zy);const sD=pt(),oD="No handler registered for update-content",aD="handleUpdateContent: handler already registered";function lD(n){return n instanceof Error&&typeof n.message=="string"?n.message:String(n)}const cD=di(gt);var Zr,Hr,Vr,Wn,qn,Ts,Ce,Mc,Zy,Hy,Fi,Nc,fp;let uD=(fp=class extends cD{constructor(t){super();_(this,Ce);_(this,Zr);_(this,Hr);_(this,Vr);_(this,Wn,null);_(this,qn,null);_(this,Ts,!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,Zy).call(this,i)),l(this,Hr).addEventListener("message",l(this,Vr))}get content(){return l(this,qn)}set content(t){m(this,Ce,Nc).call(this),E(this,qn,t),l(this,Ts)&&m(this,Ce,Mc).call(this,t)}handleUpdateContent(t){if(m(this,Ce,Nc).call(this),l(this,Wn)!==null)throw new Error(aD);E(this,Wn,t)}dispose(){l(this,Hr).removeEventListener("message",l(this,Vr)),E(this,Wn,null)}},Zr=new WeakMap,Hr=new WeakMap,Vr=new WeakMap,Wn=new WeakMap,qn=new WeakMap,Ts=new WeakMap,Ce=new WeakSet,Mc=function(t){const r={type:"content-updated",content:t};m(this,Ce,Fi).call(this,r)},Zy=function(t){if(this.disposed||t.source!==l(this,Zr).contentWindow)return;const r=t.data;if(PC(r)){E(this,Ts,!0),this.dispatchEvent(new sD("ready")),l(this,qn)!==null&&m(this,Ce,Mc).call(this,l(this,qn));return}if(RC(r)){m(this,Ce,Hy).call(this,r);return}},Hy=async function(t){const r=l(this,Wn);if(r===null){m(this,Ce,Fi).call(this,{type:"response",id:t.id,error:{message:oD}});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:lD(i)}});return}this.disposed||m(this,Ce,Fi).call(this,{type:"response",id:t.id,result:{}})},Fi=function(t){const r=l(this,Zr).contentWindow;r&&r.postMessage(t,"*")},Nc=function(){if(this.disposed)throw new Error("ArtifactView is disposed")},fp);function hD(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 dD(){return`(${hD.toString()})(window);`}async function fD(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=dD(),r.head.appendChild(s);const o=new Blob([`<!DOCTYPE html>
126
- ${r.documentElement.outerHTML}`],{type:"text/html"});return URL.createObjectURL(o)}const Vy=pt();class pD 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 Vy("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 uD(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 fD(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
- <div class="artifact-content artifact-placeholder">
128
- <em>Failed to load content</em>
129
- </div>
130
- `:this._viewURL!==null||this._directRender?F`
131
- <iframe
132
- class="artifact-frame artifact-content"
133
- src=${this._blobURL??"about:blank"}
134
- sandbox="allow-scripts"
135
- ></iframe>
136
- `:F`
137
- <div class="artifact-content artifact-placeholder">
138
- <em>Artifact unavailable</em>
139
- </div>
140
- `}template(){const t=this._artifact;return F`
141
- ${this.contentTemplate()}
142
- <footer class="artifact-title-bar" drag-handle>
143
- <div class="artifact-title-group">
144
- <span class="artifact-title-icon">${jR({size:16})}</span>
145
- <span class="artifact-title">${t.title}</span>
146
- </div>
147
- <button
148
- icon-only
149
- class="artifact-close-btn"
150
- @click=${()=>this.handleClose()}
151
- aria-label="Close"
152
- >
153
- ${wy({size:16})}
154
- </button>
155
- </footer>
156
- `}render(){this._artifact&&(this.setAttribute("type",this._artifact.type),Pe(this.template(),this))}}customElements.define("artifact-view",pD);const ke=n=>({type:"px",...n}),Te=n=>({type:"unit",...n}),ko=2,gD=2;class mD{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??Xo,i=this._gap.x??pe,s=this._gap.y??pe,o=tr+i*gD,a=t<=o,c=a?t-i*ko:Math.min(tr,t-i*ko),u=a?r-s*ko:Math.min(Xo,r-s*ko),d=(c-i*(Ct-1))/Ct,f=(u-s*(Xe-1))/Xe,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,yD=40,vD=24;function jy(n,e){return Math.max(0,n-e*2)}function By(n){const e=[0];for(const t of n)e.push((e[e.length-1]??0)+t);return e}function Gy(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 Wy(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 bD(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 wD(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 Bu(n,e){if(n.length===0)return 0;const t=wD(n,e);return Math.max(0,n.length-t)}function Mf(n,e,t){if(n.length===0)return 0;const r=Wy(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 Uc(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=Bu(n,i),o=e[s]??0,a=Math.max(0,Math.min(o,t));let c=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){c=Z;break}c=Z+1}const u=Math.min(c+1,s),d=e[c]??0,f=e[u]??d,v=Math.max(f-d,ir),y=u===c?0:(a-d)/v,A=Gy(n),k=Mf(n,c,i),I=Mf(n,u,i),B=(r-k)/2,P=(r-I)/2,le=Uc(A,c,B),M=Uc(A,u,P);return le+(M-le)*y}function Nf(n,e,t,r,i){const s=Bu(n,r),o=e[s]??0;let a=0,c=o;for(let u=0;u<yD;u+=1){const d=(a+c)/2;xr(n,e,d,t,r)>i?a=d:c=d}return(a+c)/2}function Uf(n,e,t){const r=Gy(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,c=(t-a)/2;return Uc(r,i,c)}function _D(n,e,t){const r=Wy(n,e,t);return[e,Math.min(n.length-1,e+r-1)]}function SD(n,e,t){const r=bD(n,e,t);return[Math.max(0,e-r+1),e]}function kD(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 ED(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=jy(r,i),o=By(e),a=Bu(t,s),c=o[a]??0,u=[];for(let d=0;d<=a;d+=1){const f=_D(t,d,s),v=Uf(t,f,r),y=Nf(t,o,r,s,v);u.push({nodeRange:f,anchor:Math.max(0,Math.min(c,y))})}for(let d=t.length-1;d>=0;d-=1){const f=SD(t,d,s),v=`${f[0]}:${f[1]}`;if(u.some(k=>`${k.nodeRange[0]}:${k.nodeRange[1]}`===v))continue;const y=Uf(t,f,r),A=Nf(t,o,r,s,y);u.push({nodeRange:f,anchor:Math.max(0,Math.min(c,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:kD(u),minScroll:0,maxScroll:c}}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 AD(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 xD extends gt{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=ED({nodeCols:r,nodeWidthsPx:i,viewportWidthPx:s,gapPx:o});this.nodeWidthsPx=i,this.boundaryCols=By(r),this.viewportWidthPx=s,this.framedViewportWidthPx=jy(s,o),this.viewspans=a.viewspans,this.minScroll=a.minScroll,this.maxScroll=a.maxScroll,this.activeViewspanIndex=null;const c=Ai(this._scroll,this.minScroll,this.maxScroll);Math.abs(c-this._scroll)>Bt&&(this._scroll=c,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=AD(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),c=Math.max(o,Math.min(a,s));if(Math.abs(c-i)<=ir)return;let u=this.minScroll,d=this.maxScroll;for(let v=0;v<vD;v+=1){const y=(u+d)/2;xr(this.nodeWidthsPx,this.boundaryCols,y,this.viewportWidthPx,this.framedViewportWidthPx)>c?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 Hl={"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}},TD=["stack-above","stack-below","reorder-before","reorder-after"];function Vl(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 Gu(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 Fc(n){return n.height===Xe||n.height===fn?{...n,height:fn}:n}function Zc(n){return n.height===fn?{...n,height:Xe}:n}function CD(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 c=[...n];if(a.length===1){const[d]=a;c[i]=d.type==="card"?Zc(d):d}else c[i]={...s,children:a};const u=Math.max(0,Math.min(r,c.length));return c.splice(u,0,Zc(o)),c}const ID=pt(),PD=pt(),RD=50;function DD(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 Qs(n){return{id:n.id,type:"drop-target",width:n.width,height:n.height}}function Ff(n){return n.map(zD)}function OD(n){return n.type==="drop-target"?{id:n.id,type:"card",artifactID:n.id,width:n.width,height:n.height}:n}function zD(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(OD)}:n}function qy(n,e){return n.find(r=>r.type==="card"&&r.id===e)??null}function Zf(n,e){return n.find(r=>r.type==="stack"&&r.id===e)??null}function LD(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 MD(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=qy(r,e.nodeId);if(!a)return null;const c=Fc(a),u=Fc(o),d=Qs(c),f=t.position==="above"?[d,u]:[u,d];return i[s]={id:o.id,type:"stack",children:f},i}function jl(n,e){return n.parentStackId?UD(n,e):ND(n,e)}function ND(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,Qs(r)),i}if(t.type==="stack"){const r=LD(n,e);return r?MD(r,n,t,e)??[...e]:[...e]}return[...e]}function UD(n,e){const t=n.hitTarget;switch(t.type){case"stack-child-reorder":return FD(n,e,t.position);case"stack-child-extract":return ZD(n,e,t.toIndex);case"stack-child-noop":return HD(n,e);default:return[...e]}}function FD(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],c=s.filter(v=>v.id!==n.nodeId),u=Qs(a),d=t==="above"?[u,...c]:[...c,u],f=[...e];return f[r]={...i,children:d},f}function ZD(n,e,t){if(!n.parentStackId)return[...e];const r=CD(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]=Qs(s),o}function HD(n,e){const t=e.findIndex(c=>c.type==="stack"&&c.id===n.parentStackId);if(t===-1)return[...e];const r=e[t];if(!r||r.type!=="stack")return[...e];const i=r.children.findIndex(c=>c.type==="card"&&c.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]=Qs(s),o[t]={...r,children:a},o}function VD(n,e){return e.find(r=>r.type==="stack"&&r.id===n.id)?n.id:Tu()}function jD(n,e,t){if(n.type==="drop-target"){const r=Gu(e,t);if(!r)throw new Error(`finalize: missing dragged card ${t}`);return Fc(r)}return n}function BD(n,e,t){const r=n.children.map(s=>jD(s,e,t));return{id:VD(n,e),type:"stack",children:r}}function GD(n,e,t){if(n.type==="drop-target"){const r=Gu(e,t);if(!r)throw new Error(`finalize: missing dragged card ${t}`);return qy(e,t)!==null?r:Zc(r)}return n.type==="card"||n.type==="row"?n:BD(n,e,t)}function WD(n,e,t){return n.map(r=>GD(r,e,t))}function qD(n,e){return JSON.stringify(n)===JSON.stringify(e)}const YD=di(gt);class KD extends YD{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=jl(this.active,this.active.baseLayout),a=this.getHitTargetForPointer(r,i,t,o),c=a.type==="reorder"?a.index:this.active.lastReorderIndex;this.active.pointerX===r&&this.active.pointerY===i&&DD(this.active.hitTarget,a)&&this.active.lastReorderIndex===c||(this.active={...this.active,pointerX:r,pointerY:i,hitTarget:a,lastReorderIndex:c},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=jl(this.active,t),s=WD(i,t,this.active.nodeId);qD(s,t)||(r=s)}catch{r=null}this.reset(),r&&this.dispatchEvent(new PD("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=jl(this.active,this.active.baseLayout);this.dispatchEvent(new ID("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=Zf(this.active.baseLayout,this.active.parentStackId);if(!r)return;const i=r.children.find(a=>{var c;return a.type==="card"&&a.id!==((c=this.active)==null?void 0:c.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 c;return a.id===((c=this.active)==null?void 0:c.parentStackId)});if(r)return this.active.sourceStackRect=r.rect,r.rect;const i=Zf(this.active.baseLayout,this.active.parentStackId);if(!i)return this.active.sourceStackRect;const s=i.children.find(a=>{var c;return a.type==="card"&&a.id!==((c=this.active)==null?void 0:c.nodeId)});if(s){const a=t.find(c=>c.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 c=(i.effectiveVelocity??0)<=RD;for(const I of o){const B=I.rect;if(!xn(t,r,B))continue;const P=this.resolveTopLevelTargetForCard(t,r,I,I.logicalIndex,c);if(P)return P;if(!c&&((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,c);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=Vl(f.rect,Hl["reorder-before"]);if(xn(t,r,v))return f.logicalIndex;const y=Vl(f.rect,Hl["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 c=a.rect.left+a.rect.width/2;return t<c?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 c=i.get(a.id);c&&c.type!=="drop-target"&&(c.type==="card"||c.type==="stack")&&(s.push({id:c.id,rect:a.rect,logicalIndex:o}),o+=1)}return s}resolveTopLevelTargetForCard(t,r,i,s,o){const a=i.rect;for(const c of TD){if(!o&&(c==="stack-above"||c==="stack-below"))continue;const u=Hl[c],d=Vl(a,u);if(xn(t,r,d))return c==="stack-above"?{type:"stack",targetCardId:i.id,position:"above"}:c==="stack-below"?{type:"stack",targetCardId:i.id,position:"below"}:c==="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,c=o.rect.left+o.rect.width,u=t<a?a-t:t>c?t-c: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 Hf=60,JD=80,Vf=.5,jf=10;class XD{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>=Hf&&(this.activeGestureType="none");const c=r&&s!==0,u=c?s:i,d=Math.abs(u),f=Math.abs(s);return this.activeGestureType==="vertical-artifact"&&o?d>=Vf&&d>=f*jf?this.classifyHorizontal(t,u):(this.lastWheelGestureAt=t,{type:"scroll-native"}):this.activeGestureType==="horizontal-filmstrip"?!c&&o&&f>0&&f>=d*jf?(this.activeGestureType="vertical-artifact",this.lastWheelGestureAt=t,{type:"scroll-native"}):this.classifyHorizontal(t,u):d<Vf?(o&&(this.activeGestureType="vertical-artifact"),this.lastWheelGestureAt=t,{type:"scroll-native"}):c||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)+JD;return this.awaitingFreshWheelGesture&&r<Hf&&!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 QD=2,Bf=1e3,Eo=1e-4;function Gf(n,e,t){if(n===0)return 0;const r=e.toPixels(Te({y:Xe})).y??0;return(t-r)/QD}function Bl(n){const e=n.clientWidth>0?n.clientWidth:tr,t=n.clientHeight>0?n.clientHeight:Xo;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 eO extends Event{constructor(t){super("scroll",{bubbles:!0,composed:!0});b(this,"scrollPosition");this.scrollPosition=t}}class Yy extends Event{constructor(t){super("layout-change",{bubbles:!0,composed:!0});b(this,"layout");this.layout=t}}class tO extends HTMLElement{constructor(){super();b(this,"_layout",[]);b(this,"_scrollPosition",0);b(this,"layoutGrid",null);b(this,"layoutScroll",new xD(Te({x:0})));b(this,"scrollModelKey","");b(this,"resizeObserver",null);b(this,"renderPending",!1);b(this,"animateNextRender",!0);b(this,"wheelGesture",new XD);b(this,"dragController",new KD);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=Ff(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)<Eo||(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)||!DC(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=rO(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)/Bf;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>Eo?Math.abs(o)/r:0,Math.abs(o)>Eo&&(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)<Eo||(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 mD({basis:ke({x:Pn,y:Pn}),min:ke({x:ef,y:ef}),viewport:ke({x:t,y:r}),gap:ke({x:pe,y:pe})})}syncScrollModel(){const t=Bl(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 eO(t))}emitLayoutChanged(){this.dispatchEvent(new Yy([...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:Ff(this.dragState.projectedLayout),activePlaceholderId:this.dragState.nodeId,placeholdersById:t}}render(){const t=Bl(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),c=a.nodes.map(M=>M.width),u=`${t.width}x${t.height}:${c.join(",")}`;!o&&u!==this.scrollModelKey&&(this.scrollModelKey=u,this.layoutScroll.rebuild({grid:r,nodeWidths:c.map(M=>Te({x:M}))}),this._scrollPosition=this.layoutScroll.scroll.x??this._scrollPosition);const d=nO(s),f=r.unit.x??Pn,v=r.unit.y??Pn,y=o?this.dragTrackOffsetXPx:0,A=(this.layoutScroll.translate.x??0)+y,k=Gf(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}>
158
- ${a.nodes.map((M,Z)=>F`
159
- <div
160
- class="node"
161
- layout-node=${String(Z)}
162
- data-layout-node-id=${M.id}
163
- data-layout-placeholder=${String(i.activePlaceholderId===M.id)}
164
- layout-node-cols=${String(M.width)}
165
- style=${`grid-template-columns: repeat(${M.width}, var(--layout-unit-x)); width: ${r.toPixels(Te({x:M.width})).x}px;`}
166
- >
167
- ${M.cards.map(U=>{const ge=i.placeholdersById.get(U.id);if(P&&ge)return F`
168
- <div
169
- class="card-slot card-placeholder"
170
- data-layout-placeholder-for=${P.nodeId}
171
- data-layout-placeholder-ghost="false"
172
- data-layout-source-stack=${P.source.parentId??""}
173
- style=${`grid-column: ${U.col} / span ${U.width}; grid-row: ${U.row} / span ${U.height};`}
174
- ></div>
175
- `;const ce=d.get(U.id);return ce?F`
176
- <div
177
- class="card-slot"
178
- data-layout-card-id=${U.artifactID}
179
- data-layout-node-id=${U.id}
180
- layout-cols=${String(U.width)}
181
- layout-rows=${String(U.height)}
182
- style=${`grid-column: ${U.col} / span ${U.width}; grid-row: ${U.row} / span ${U.height};`}
183
- >
184
- ${this.renderContent(ce,{isDragging:!1})}
185
- </div>
186
- `:null})}
187
- </div>
188
- `)}
189
- </div>
190
- ${P?(()=>{const M=this.getPlaceholderPixelSize(a,i.activePlaceholderId,r,le),Z=P.pointer.x??0,U=P.pointer.y??0,ge=P.grabOffset.x??0,ce=P.grabOffset.y??0;return F`
191
- <div
192
- class="drag-preview"
193
- data-layout-preview-card-id=${P.nodeId}
194
- style=${[`width: ${M.width}px;`,`height: ${M.height}px;`,`left: ${Z-ge}px;`,`top: ${U-ce}px;`].join(" ")}
195
- >
196
- ${this.renderDraggedPreview(P.nodeId)}
197
- </div>
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,c=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:c,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*Bf,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+vo,o=r.left+r.width-vo,a=((u=this.layoutGrid)==null?void 0:u.unit.x)??Pn,c=k0*a;if(t<s){const d=Math.max(0,Math.min(1,(s-t)/vo));return-(c*d**tf)*i}if(t>o){const d=Math.max(0,Math.min(1,(t-o)/vo));return c*d**tf*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])),c=s.toPixels(Te({y:Xe})).y??Xo,u=Bl(this),d=(this.layoutScroll.translate.x??0)+i,f=Gf(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)??Ct,B=s.toPixels(Te({x:I})).x??tr,P={left:A,top:v,width:B,height:c};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=Gu(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 c=s?o??this.getStableAnchorCardId(t,r,i):this.getStableAnchorNodeId(t,r,i);if(!c)return a;const u=s?qf(t,c,this.layoutGrid):Yf(t,c,this.layoutGrid),d=s?qf(r,c,this.layoutGrid):Yf(r,c,this.layoutGrid);return u===null||d===null?a:a+(u-d)}getStableAnchorCardId(t,r,i){const s=Wf(t),o=new Set(Wf(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 nO(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 rO(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 Wf(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 qf(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)??Ct,c=t.toPixels(Te({x:a})).x??tr;s+=c+pe}return null}function Yf(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)??Ct,c=t.toPixels(Te({x:a})).x??tr;s+=c+pe}return null}customElements.get("layout-view")||customElements.define("layout-view",tO);class iO extends HTMLElement{constructor(){super(...arguments);b(this,"screenManager",Ge.resolve("ScreenManager"));b(this,"boundModel",null);b(this,"handleActiveScreenChanged",()=>{this.rebindModel(),this.render()});b(this,"handleModelChange",()=>{this.render()});b(this,"handleCloseArtifact",t=>{t instanceof Vy&&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 Yy&&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
- No artifacts yet. Create one by asking for something.
201
- </p>`,this);return}Pe(F`
202
- <layout-view
203
- .layout=${r}
204
- .renderContent=${(o,a)=>{const c=i.get(o.artifactID);return!c||!t?F``:F`<artifact-view
205
- .artifact=${c}
206
- .screen=${t}
207
- .viewURL=${t.server.getViewURL(c)}
208
- .contentURL=${t.server.getContentURL(c.id)}
209
- .dragging=${a.isDragging}
210
- ></artifact-view>`}}
211
- .scrollPosition=${(t==null?void 0:t.scrollPosition)??0}
212
- @scroll=${this.handleScrollPositionChanged}
213
- @layout-change=${this.handleLayoutChanged}
214
- @close-artifact=${this.handleCloseArtifact}
215
- ></layout-view>
216
- `,this)}}customElements.define("screen-view",iO);var ma,jr,Cs,Wt,Ky,Jy,Hc;class sO extends HTMLElement{constructor(){super(...arguments);_(this,Wt);_(this,ma,Ge.resolve("ScreenManager"));_(this,jr,Ge.resolve("ServerManager"));_(this,Cs,()=>{m(this,Wt,Hc).call(this)})}connectedCallback(){l(this,jr).addEventListener("change",l(this,Cs)),m(this,Wt,Hc).call(this)}disconnectedCallback(){l(this,jr).removeEventListener("change",l(this,Cs))}}ma=new WeakMap,jr=new WeakMap,Cs=new WeakMap,Wt=new WeakSet,Ky=function(t,r){l(this,ma).setActive(t,r)},Jy=function(){for(const t of l(this,jr).servers.values())return t;return null},Hc=function(){const t=m(this,Wt,Jy).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
- <div class="content">
218
- <h2 class="heading">Screens</h2>
219
- <ul class="tiles">
220
- ${i.map(o=>F`
221
- <li>
222
- <button
223
- class="tile"
224
- type="button"
225
- @click=${()=>t&&m(this,Wt,Ky).call(this,t.url,o.id)}
226
- >
227
- ${o.name}
228
- </button>
229
- </li>
230
- `)}
231
- </ul>
232
- </div>
233
- `;Pe(s,this)};customElements.get("home-screen")||customElements.define("home-screen",sO);const Gl=new WeakMap,Kf=Object.prototype.hasOwnProperty,oO=(()=>{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 aO(n,e){if(n===Boolean)return e!==null;if(e!==null)return n===Number?Number(e):e}var Is,Vc,Yn,tt,xt,Br,Kn,Gr,Ie,Zi,Xy,Qy,ev,Vo;const On=class On extends HTMLElement{constructor(){var i;super();_(this,Ie);_(this,Yn,new Map);_(this,tt,new Map);_(this,xt,new Map);_(this,Br,!1);_(this,Kn,!1);_(this,Gr,!1);const t=m(i=On,Is,Vc).call(i,this.constructor),r=this;for(const s of t.properties)Kf.call(r,s)&&(l(this,xt).set(s,r[s]),delete r[s])}static get observedAttributes(){var t;return m(t=On,Is,Vc).call(t,this).observedAttributes}connected(){}disconnected(){}changed(t){}connectedCallback(){if(m(this,Ie,ev).call(this),!l(this,Kn))for(const t of m(this,Ie,Zi).call(this).properties)l(this,tt).has(t)||l(this,tt).set(t,void 0);this.dispatchEvent(new Event("reactive:connect")),this.connected(),m(this,Ie,Vo).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&&(l(this,xt).has(s.property)||(this[s.property]=aO(s.type,i)))}};Is=new WeakSet,Vc=function(t){const r=Gl.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(oO.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 l(this,Yn).get(u)},set(f){m(this,Ie,Xy).call(this,u,f)}})}const c={properties:i,observedAttributes:Object.keys(s),byAttr:o,byProp:a};return Gl.set(t,c),c},Yn=new WeakMap,tt=new WeakMap,xt=new WeakMap,Br=new WeakMap,Kn=new WeakMap,Gr=new WeakMap,Ie=new WeakSet,Zi=function(){return Gl.get(this.constructor)},Xy=function(t,r){if(!l(this,Gr)&&l(this,xt).has(t))return;const i=l(this,Yn).get(t);Object.is(i,r)||(l(this,tt).has(t)||l(this,tt).set(t,i),l(this,Yn).set(t,r),l(this,xt).delete(t),m(this,Ie,Qy).call(this,t,r),this.isConnected&&m(this,Ie,Vo).call(this))},Qy=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 c=this.hasAttribute(s);r&&!c?this.setAttribute(s,""):!r&&c&&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)},ev=function(){const t=this,r=m(this,Ie,Zi).call(this);for(const i of r.properties){if(!Kf.call(t,i))continue;const s=t[i];delete t[i],!(l(this,xt).has(i)||l(this,Yn).has(i))&&(t[i]=s)}E(this,Gr,!0);try{for(const[i,s]of l(this,xt))t[i]=s;l(this,xt).clear()}finally{E(this,Gr,!1)}},Vo=function(){l(this,Br)||!this.isConnected||l(this,Kn)&&l(this,tt).size===0||(E(this,Br,!0),queueMicrotask(()=>{if(E(this,Br,!1),!this.isConnected||l(this,Kn)&&l(this,tt).size===0)return;const t=new Map(l(this,tt));l(this,tt).clear(),E(this,Kn,!0);try{this.changed(t)}catch(r){console.error(r)}this.isConnected&&l(this,tt).size>0&&m(this,Ie,Vo).call(this)}))},_(On,Is),b(On,"properties"),b(On,"attributes");let ts=On;/**
234
- * @license
235
- * Copyright 2020 Google LLC
236
- * SPDX-License-Identifier: BSD-3-Clause
237
- */const lO=n=>n.strings===void 0;/**
238
- * @license
239
- * Copyright 2017 Google LLC
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},oa=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)},tv=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),hO(e)}};function cO(n){this._$AN!==void 0?(oa(this),this._$AM=n,tv(this)):this._$AM=n}function uO(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),oa(r[s]);else r!=null&&(Yi(r,!1),oa(r));else Yi(this,n)}const hO=n=>{n.type==vy.CHILD&&(n._$AP??(n._$AP=uO),n._$AQ??(n._$AQ=cO))};class dO extends by{constructor(){super(...arguments),this._$AN=void 0}_$AT(e,t,r){super._$AT(e,t,r),tv(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),oa(this))}setValue(e){if(lO(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
- * @license
243
- * Copyright 2020 Google LLC
244
- * SPDX-License-Identifier: BSD-3-Clause
245
- */const $o=()=>new fO;class fO{}const Wl=new WeakMap,Ao=ju(class extends dO{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=Wl.get(e);t===void 0&&(t=new WeakMap,Wl.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=Wl.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 Je,un,Wr,qr,Ps,Jn,Xn,re,Rs,Ds,Me,jc,Bc,ya,va,ba,wa,_a,Sa,ka,Os,zs,Hi,nv,ht;class pO extends ts{constructor(){super(...arguments);_(this,Me);_(this,Je,Ge.resolve("ScreenManager"));_(this,un,null);_(this,Wr,new DisposableStack);_(this,qr,$o());_(this,Ps,$o());_(this,Jn,$o());_(this,Xn,$o());_(this,re,{kind:"none"});_(this,Rs,()=>{m(this,Me,jc).call(this),l(this,ht).call(this)});_(this,Ds,()=>{l(this,ht).call(this)});_(this,ya,()=>{l(this,Je).clearActive()});_(this,va,t=>{l(this,re).kind!=="none"&&(t.stopImmediatePropagation(),m(this,Me,Hi).call(this))});_(this,ba,()=>{var r;const t=l(this,Je).activeScreen;t&&((r=l(this,qr).value)==null||r.close(),E(this,re,{kind:"rename",draft:t.name}),l(this,ht).call(this))});_(this,wa,()=>{var t;l(this,Je).activeScreen&&((t=l(this,qr).value)==null||t.close(),E(this,re,{kind:"delete",error:null}),l(this,ht).call(this))});_(this,_a,t=>{if(l(this,re).kind!=="rename")return;const r=t.target;r instanceof HTMLInputElement&&E(this,re,{kind:"rename",draft:r.value})});_(this,Sa,t=>{if(t.preventDefault(),l(this,re).kind!=="rename")return;const r=l(this,Je).activeScreen;if(!r)return;const i=l(this,re).draft.trim();i.length>0&&i!==r.name&&r.rename(i),m(this,Me,Hi).call(this)});_(this,ka,async()=>{if(l(this,re).kind!=="delete")return;const t=l(this,Je).activeScreen;if(t){E(this,re,{kind:"delete",error:null});try{await t.remove(),l(this,Je).clearActive(),m(this,Me,Hi).call(this)}catch(r){E(this,re,{kind:"delete",error:r instanceof Error?r.message:"Failed to delete screen."}),l(this,ht).call(this)}}});_(this,Os,()=>{m(this,Me,Hi).call(this)});_(this,zs,()=>{l(this,re).kind!=="none"&&(E(this,re,{kind:"none"}),l(this,ht).call(this))});_(this,ht,()=>{const t=F`
246
- <button
247
- icon-only
248
- class="home"
249
- type="button"
250
- aria-label="Home"
251
- @click=${l(this,ya)}
252
- >
253
- ${qR({weight:"fill"})}
254
- </button>
255
- `;Pe(F`${t}${m(this,Me,nv).call(this)}`,this);const r=l(this,Ps).value??null;l(this,Jn).value&&(l(this,Jn).value.anchor=r),l(this,Xn).value&&(l(this,Xn).value.anchor=r)})}connected(){l(this,Je).addEventListener("active-screen-changed",l(this,Rs)),m(this,Me,jc).call(this),l(this,ht).call(this),l(this,Wr).defer(()=>{l(this,Je).removeEventListener("active-screen-changed",l(this,Rs)),m(this,Me,Bc).call(this)})}disconnected(){l(this,Wr).dispose(),E(this,Wr,new DisposableStack)}}Je=new WeakMap,un=new WeakMap,Wr=new WeakMap,qr=new WeakMap,Ps=new WeakMap,Jn=new WeakMap,Xn=new WeakMap,re=new WeakMap,Rs=new WeakMap,Ds=new WeakMap,Me=new WeakSet,jc=function(){var r;const t=l(this,Je).activeScreen;l(this,un)!==t&&(m(this,Me,Bc).call(this),E(this,un,t),(r=l(this,un))==null||r.addEventListener("change",l(this,Ds)))},Bc=function(){var t;(t=l(this,un))==null||t.removeEventListener("change",l(this,Ds)),E(this,un,null)},ya=new WeakMap,va=new WeakMap,ba=new WeakMap,wa=new WeakMap,_a=new WeakMap,Sa=new WeakMap,ka=new WeakMap,Os=new WeakMap,zs=new WeakMap,Hi=function(){const t=l(this,re).kind==="rename"?l(this,Jn).value:l(this,re).kind==="delete"?l(this,Xn).value:null;t&&(t.open=!1),E(this,re,{kind:"none"}),l(this,ht).call(this)},nv=function(){const t=l(this,Je).activeScreen;if(!t)return null;const r=l(this,re).kind==="rename"?l(this,re).draft:"",i=l(this,re).kind==="delete"?l(this,re).error:null;return F`
256
- <span class="separator" aria-hidden="true">
257
- ${BR()}
258
- </span>
259
- <dropdown-menu ${Ao(l(this,qr))}>
260
- <button
261
- slot="trigger"
262
- type="button"
263
- variant="ghost"
264
- aria-label=${`Screen actions for ${t.name}`}
265
- ?data-active=${l(this,re).kind!=="none"}
266
- @click=${l(this,va)}
267
- ${Ao(l(this,Ps))}
268
- >
269
- ${t.name}
270
- </button>
271
- <dropdown-group>
272
- <dropdown-item action @click=${l(this,ba)}>
273
- ${YR()} Rename
274
- </dropdown-item>
275
- <dropdown-item action danger @click=${l(this,wa)}>
276
- ${KR()} Delete
277
- </dropdown-item>
278
- </dropdown-group>
279
- </dropdown-menu>
280
- <ui-popover
281
- class="rename-popover"
282
- ?open=${l(this,re).kind==="rename"}
283
- @close=${l(this,zs)}
284
- ${Ao(l(this,Jn))}
285
- >
286
- <form class="screen-form" @submit=${l(this,Sa)}>
287
- <label class="field">
288
- <span>Screen name</span>
289
- <input
290
- type="text"
291
- .value=${r}
292
- @input=${l(this,_a)}
293
- />
294
- </label>
295
- <div class="actions">
296
- <button type="button" @click=${l(this,Os)}>Cancel</button>
297
- <button type="submit" variant="primary">Save</button>
298
- </div>
299
- </form>
300
- </ui-popover>
301
- <ui-popover
302
- class="delete-popover"
303
- ?open=${l(this,re).kind==="delete"}
304
- @close=${l(this,zs)}
305
- ${Ao(l(this,Xn))}
306
- >
307
- <div class="screen-form">
308
- <p class="confirm-text">Delete "${t.name}"?</p>
309
- ${i?F`<p class="error">${i}</p>`:oe}
310
- <div class="actions">
311
- <button type="button" @click=${l(this,Os)}>Cancel</button>
312
- <button
313
- type="button"
314
- variant="danger"
315
- @click=${l(this,ka)}
316
- >
317
- Delete
318
- </button>
319
- </div>
320
- </div>
321
- </ui-popover>
322
- `},ht=new WeakMap;customElements.define("screen-breadcrumb",pO);var Ea,$a,Yr,ri,rv,Aa,iv;class gO extends HTMLElement{constructor(){super(...arguments);_(this,ri);_(this,Ea,Ge.resolve("ServerManager"));_(this,$a,Ge.resolve("ScreenManager"));_(this,Yr,!1);_(this,Aa,async()=>{if(l(this,Yr))return;const t=m(this,ri,rv).call(this);if(t){E(this,Yr,!0);try{const r=await t.createScreen(mO(new Date));l(this,$a).setActive(t.url,r.id)}catch{}finally{E(this,Yr,!1)}}})}connectedCallback(){m(this,ri,iv).call(this)}}Ea=new WeakMap,$a=new WeakMap,Yr=new WeakMap,ri=new WeakSet,rv=function(){for(const t of l(this,Ea).servers.values())return t;return null},Aa=new WeakMap,iv=function(){Pe(F`
323
- <button
324
- icon-only
325
- class="new-screen"
326
- type="button"
327
- aria-label="New screen"
328
- @click=${l(this,Aa)}
329
- >
330
- ${WR({size:16,weight:"bold"})}
331
- </button>
332
- `,this)};function mO(n){const e=n.toLocaleDateString("en-US",{month:"long",day:"numeric",year:"numeric"}),t=12,r=n.getHours(),i=r%t===0?t:r%t,s=n.getMinutes().toString().padStart(2,"0"),o=r>=t?"pm":"am";return`${e} at ${i}:${s}${o}`}customElements.define("screen-create-button",gO);function yO(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:sv,setPrototypeOf:Jf,isFrozen:vO,getPrototypeOf:bO,getOwnPropertyDescriptor:wO}=Object;let{freeze:Ne,seal:it,create:jo}=Object,{apply:Gc,construct:Wc}=typeof Reflect<"u"&&Reflect;Ne||(Ne=function(e){return e});it||(it=function(e){return e});Gc||(Gc=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)});Wc||(Wc=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 xo=Ue(Array.prototype.forEach),_O=Ue(Array.prototype.lastIndexOf),Xf=Ue(Array.prototype.pop),xi=Ue(Array.prototype.push),SO=Ue(Array.prototype.splice),Bo=Ue(String.prototype.toLowerCase),ql=Ue(String.prototype.toString),Yl=Ue(String.prototype.match),Ti=Ue(String.prototype.replace),kO=Ue(String.prototype.indexOf),EO=Ue(String.prototype.trim),Ye=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 Gc(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 Wc(n,t)}}function V(n,e){let t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:Bo;Jf&&Jf(n,null);let r=e.length;for(;r--;){let i=e[r];if(typeof i=="string"){const s=t(i);s!==i&&(vO(e)||(e[r]=s),i=s)}n[i]=!0}return n}function AO(n){for(let e=0;e<n.length;e++)Ye(n,e)||(n[e]=null);return n}function _t(n){const e=jo(null);for(const[t,r]of sv(n))Ye(n,t)&&(Array.isArray(r)?e[t]=AO(r):r&&typeof r=="object"&&r.constructor===Object?e[t]=_t(r):e[t]=r);return e}function Ii(n,e){for(;n!==null;){const r=wO(n,e);if(r){if(r.get)return Ue(r.get);if(typeof r.value=="function")return Ue(r.value)}n=bO(n)}function t(){return null}return t}const Qf=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"]),Kl=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"]),Jl=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"]),xO=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"]),Xl=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"]),TO=Ne(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),ep=Ne(["#text"]),tp=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"]),np=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"]),To=Ne(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),CO=it(/\{\{[\w\W]*|[\w\W]*\}\}/gm),IO=it(/<%[\w\W]*|[\w\W]*%>/gm),PO=it(/\$\{[\w\W]*/gm),RO=it(/^data-[\-\w.\u00B7-\uFFFF]+$/),DO=it(/^aria-[\-\w]+$/),ov=it(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),OO=it(/^(?:\w+script|data):/i),zO=it(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),av=it(/^html$/i),LO=it(/^[a-z][.\w]*(-[.\w]+)+$/i);var rp=Object.freeze({__proto__:null,ARIA_ATTR:DO,ATTR_WHITESPACE:zO,CUSTOM_ELEMENT:LO,DATA_ATTR:RO,DOCTYPE_NAME:av,ERB_EXPR:IO,IS_ALLOWED_URI:ov,IS_SCRIPT_OR_DATA:OO,MUSTACHE_EXPR:CO,TMPLIT_EXPR:PO});const Pi={element:1,text:3,progressingInstruction:7,comment:8,document:9},MO=function(){return typeof window>"u"?null:window},NO=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}},ip=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}};function lv(){let n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:MO();const e=L=>lv(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:c,NodeFilter:u,NamedNodeMap:d=n.NamedNodeMap||n.MozNamedAttrMap,HTMLFormElement:f,DOMParser:v,trustedTypes:y}=n,A=c.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:to}=r;let $e=ip();e.isSupported=typeof sv=="function"&&typeof le=="function"&&U&&U.createHTMLDocument!==void 0;const{MUSTACHE_EXPR:kn,ERB_EXPR:mt,TMPLIT_EXPR:Xt,DATA_ATTR:qa,ARIA_ATTR:no,IS_SCRIPT_OR_DATA:$v,ATTR_WHITESPACE:ih,CUSTOM_ELEMENT:Av}=rp;let{IS_ALLOWED_URI:sh}=rp,_e=null;const oh=V({},[...Qf,...Kl,...Jl,...Xl,...ep]);let Ae=null;const ah=V({},[...tp,...Ql,...np,...To]);let me=Object.seal(jo(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,ro=null;const Qt=Object.seal(jo(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let lh=!0,Ya=!0,ch=!1,uh=!0,hr=!1,io=!0,En=!1,Ka=!1,Ja=!1,dr=!1,so=!1,oo=!1,hh=!0,dh=!1;const xv="user-content-";let Xa=!0,bi=!1,fr={},yt=null;const Qa=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 fh=null;const ph=V({},["audio","video","img","source","image","track"]);let el=null;const gh=V({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),ao="http://www.w3.org/1998/Math/MathML",lo="http://www.w3.org/2000/svg",It="http://www.w3.org/1999/xhtml";let pr=It,tl=!1,nl=null;const Tv=V({},[ao,lo,It],ql);let co=V({},["mi","mo","mn","ms","mtext"]),uo=V({},["annotation-xml"]);const Cv=V({},["title","style","font","a","script"]);let wi=null;const Iv=["application/xhtml+xml","text/html"],Pv="text/html";let be=null,gr=null;const Rv=t.createElement("form"),mh=function(g){return g instanceof RegExp||g instanceof Function},rl=function(){let g=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(!(gr&&gr===g)){if((!g||typeof g!="object")&&(g={}),g=_t(g),wi=Iv.indexOf(g.PARSER_MEDIA_TYPE)===-1?Pv:g.PARSER_MEDIA_TYPE,be=wi==="application/xhtml+xml"?ql:Bo,_e=Ye(g,"ALLOWED_TAGS")?V({},g.ALLOWED_TAGS,be):oh,Ae=Ye(g,"ALLOWED_ATTR")?V({},g.ALLOWED_ATTR,be):ah,nl=Ye(g,"ALLOWED_NAMESPACES")?V({},g.ALLOWED_NAMESPACES,ql):Tv,el=Ye(g,"ADD_URI_SAFE_ATTR")?V(_t(gh),g.ADD_URI_SAFE_ATTR,be):gh,fh=Ye(g,"ADD_DATA_URI_TAGS")?V(_t(ph),g.ADD_DATA_URI_TAGS,be):ph,yt=Ye(g,"FORBID_CONTENTS")?V({},g.FORBID_CONTENTS,be):Qa,vi=Ye(g,"FORBID_TAGS")?V({},g.FORBID_TAGS,be):_t({}),ro=Ye(g,"FORBID_ATTR")?V({},g.FORBID_ATTR,be):_t({}),fr=Ye(g,"USE_PROFILES")?g.USE_PROFILES:!1,lh=g.ALLOW_ARIA_ATTR!==!1,Ya=g.ALLOW_DATA_ATTR!==!1,ch=g.ALLOW_UNKNOWN_PROTOCOLS||!1,uh=g.ALLOW_SELF_CLOSE_IN_ATTR!==!1,hr=g.SAFE_FOR_TEMPLATES||!1,io=g.SAFE_FOR_XML!==!1,En=g.WHOLE_DOCUMENT||!1,dr=g.RETURN_DOM||!1,so=g.RETURN_DOM_FRAGMENT||!1,oo=g.RETURN_TRUSTED_TYPE||!1,Ja=g.FORCE_BODY||!1,hh=g.SANITIZE_DOM!==!1,dh=g.SANITIZE_NAMED_PROPS||!1,Xa=g.KEEP_CONTENT!==!1,bi=g.IN_PLACE||!1,sh=g.ALLOWED_URI_REGEXP||ov,pr=g.NAMESPACE||It,co=g.MATHML_TEXT_INTEGRATION_POINTS||co,uo=g.HTML_INTEGRATION_POINTS||uo,me=g.CUSTOM_ELEMENT_HANDLING||{},g.CUSTOM_ELEMENT_HANDLING&&mh(g.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(me.tagNameCheck=g.CUSTOM_ELEMENT_HANDLING.tagNameCheck),g.CUSTOM_ELEMENT_HANDLING&&mh(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&&(Ya=!1),so&&(dr=!0),fr&&(_e=V({},ep),Ae=jo(null),fr.html===!0&&(V(_e,Qf),V(Ae,tp)),fr.svg===!0&&(V(_e,Kl),V(Ae,Ql),V(Ae,To)),fr.svgFilters===!0&&(V(_e,Jl),V(Ae,Ql),V(Ae,To)),fr.mathMl===!0&&(V(_e,Xl),V(Ae,np),V(Ae,To))),Ye(g,"ADD_TAGS")||(Qt.tagCheck=null),Ye(g,"ADD_ATTR")||(Qt.attributeCheck=null),g.ADD_TAGS&&(typeof g.ADD_TAGS=="function"?Qt.tagCheck=g.ADD_TAGS:(_e===oh&&(_e=_t(_e)),V(_e,g.ADD_TAGS,be))),g.ADD_ATTR&&(typeof g.ADD_ATTR=="function"?Qt.attributeCheck=g.ADD_ATTR:(Ae===ah&&(Ae=_t(Ae)),V(Ae,g.ADD_ATTR,be))),g.ADD_URI_SAFE_ATTR&&V(el,g.ADD_URI_SAFE_ATTR,be),g.FORBID_CONTENTS&&(yt===Qa&&(yt=_t(yt)),V(yt,g.FORBID_CONTENTS,be)),g.ADD_FORBID_CONTENTS&&(yt===Qa&&(yt=_t(yt)),V(yt,g.ADD_FORBID_CONTENTS,be)),Xa&&(_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=NO(y,i)),M!==null&&typeof Z=="string"&&(Z=M.createHTML(""));Ne&&Ne(g),gr=g}},yh=V({},[...Kl,...Jl,...xO]),vh=V({},[...Xl,...TO]),Dv=function(g){let T=le(g);(!T||!T.tagName)&&(T={namespaceURI:pr,tagName:"template"});const R=Bo(g.tagName),ie=Bo(T.tagName);return nl[g.namespaceURI]?g.namespaceURI===lo?T.namespaceURI===It?R==="svg":T.namespaceURI===ao?R==="svg"&&(ie==="annotation-xml"||co[ie]):!!yh[R]:g.namespaceURI===ao?T.namespaceURI===It?R==="math":T.namespaceURI===lo?R==="math"&&uo[ie]:!!vh[R]:g.namespaceURI===It?T.namespaceURI===lo&&!uo[ie]||T.namespaceURI===ao&&!co[ie]?!1:!vh[R]&&(Cv[R]||!yh[R]):!!(wi==="application/xhtml+xml"&&nl[g.namespaceURI]):!1},vt=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||so)try{vt(T)}catch{}else try{T.setAttribute(g,"")}catch{}},bh=function(g){let T=null,R=null;if(Ja)g="<remove></remove>"+g;else{const ye=Yl(g,/^[\r\n\t ]+/);R=ye&&ye[0]}wi==="application/xhtml+xml"&&pr===It&&(g='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+g+"</body></html>");const ie=M?M.createHTML(g):g;if(pr===It)try{T=new v().parseFromString(ie,wi)}catch{}if(!T||!T.documentElement){T=U.createDocument(pr,"template",null);try{T.documentElement.innerHTML=tl?Z:ie}catch{}}const Re=T.body||T.documentElement;return g&&R&&Re.insertBefore(t.createTextNode(R),Re.childNodes[0]||null),pr===It?yi.call(T,En?"html":"body")[0]:En?T.documentElement:Re},wh=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)},il=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")},_h=function(g){return typeof a=="function"&&g instanceof a};function Pt(L,g,T){xo(L,R=>{R.call(e,g,T,gr)})}const Sh=function(g){let T=null;if(Pt($e.beforeSanitizeElements,g,null),il(g))return vt(g),!0;const R=be(g.nodeName);if(Pt($e.uponSanitizeElement,g,{tagName:R,allowedTags:_e}),io&&g.hasChildNodes()&&!_h(g.firstElementChild)&&De(/<[/\w!]/g,g.innerHTML)&&De(/<[/\w!]/g,g.textContent)||g.nodeType===Pi.progressingInstruction||io&&g.nodeType===Pi.comment&&De(/<[/\w]/g,g.data))return vt(g),!0;if(!(Qt.tagCheck instanceof Function&&Qt.tagCheck(R))&&(!_e[R]||vi[R])){if(!vi[R]&&Eh(R)&&(me.tagNameCheck instanceof RegExp&&De(me.tagNameCheck,R)||me.tagNameCheck instanceof Function&&me.tagNameCheck(R)))return!1;if(Xa&&!yt[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 Rt=k(Re[Fe],!0);Rt.__removalCount=(g.__removalCount||0)+1,ie.insertBefore(Rt,B(g))}}}return vt(g),!0}return g instanceof c&&!Dv(g)||(R==="noscript"||R==="noembed"||R==="noframes")&&De(/<\/no(script|embed|frames)/i,g.innerHTML)?(vt(g),!0):(hr&&g.nodeType===Pi.text&&(T=g.textContent,xo([kn,mt,Xt],ie=>{T=Ti(T,ie," ")}),g.textContent!==T&&(xi(e.removed,{element:g.cloneNode()}),g.textContent=T)),Pt($e.afterSanitizeElements,g,null),!1)},kh=function(g,T,R){if(ro[T]||hh&&(T==="id"||T==="name")&&(R in t||R in Rv))return!1;if(!(Ya&&!ro[T]&&De(qa,T))){if(!(lh&&De(no,T))){if(!(Qt.attributeCheck instanceof Function&&Qt.attributeCheck(T,g))){if(!Ae[T]||ro[T]){if(!(Eh(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(!el[T]){if(!De(sh,Ti(R,ih,""))){if(!((T==="src"||T==="xlink:href"||T==="href")&&g!=="script"&&kO(R,"data:")===0&&fh[g])){if(!(ch&&!De($v,Ti(R,ih,"")))){if(R)return!1}}}}}}}return!0},Eh=function(g){return g!=="annotation-xml"&&Yl(g,Av)},$h=function(g){Pt($e.beforeSanitizeAttributes,g,null);const{attributes:T}=g;if(!T||il(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:Rt}=Re,mr=be(ye),sl=Rt;let xe=ye==="value"?sl:EO(sl);if(R.attrName=mr,R.attrValue=xe,R.keepAttr=!0,R.forceKeepAttr=void 0,Pt($e.uponSanitizeAttribute,g,R),xe=R.attrValue,dh&&(mr==="id"||mr==="name")&&($n(ye,g),xe=xv+xe),io&&De(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,xe)){$n(ye,g);continue}if(mr==="attributename"&&Yl(xe,"href")){$n(ye,g);continue}if(R.forceKeepAttr)continue;if(!R.keepAttr){$n(ye,g);continue}if(!uh&&De(/\/>/i,xe)){$n(ye,g);continue}hr&&xo([kn,mt,Xt],xh=>{xe=Ti(xe,xh," ")});const Ah=be(g.nodeName);if(!kh(Ah,mr,xe)){$n(ye,g);continue}if(M&&typeof y=="object"&&typeof y.getAttributeType=="function"&&!Fe)switch(y.getAttributeType(Ah,mr)){case"TrustedHTML":{xe=M.createHTML(xe);break}case"TrustedScriptURL":{xe=M.createScriptURL(xe);break}}if(xe!==sl)try{Fe?g.setAttributeNS(Fe,ye,xe):g.setAttribute(ye,xe),il(g)?vt(g):Xf(e.removed)}catch{$n(ye,g)}}Pt($e.afterSanitizeAttributes,g,null)},Ov=function L(g){let T=null;const R=wh(g);for(Pt($e.beforeSanitizeShadowDOM,g,null);T=R.nextNode();)Pt($e.uponSanitizeShadowNode,T,null),Sh(T),$h(T),T.content instanceof s&&L(T.content);Pt($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(tl=!L,tl&&(L="<!-->"),typeof L!="string"&&!_h(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(Ka||rl(g),e.removed=[],typeof L=="string"&&(bi=!1),bi){if(L.nodeName){const Rt=be(L.nodeName);if(!_e[Rt]||vi[Rt])throw Ci("root node is forbidden and cannot be sanitized in-place")}}else if(L instanceof a)T=bh("<!---->"),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&&oo?M.createHTML(L):L;if(T=bh(L),!T)return dr?null:oo?Z:""}T&&Ja&&vt(T.firstChild);const ye=wh(bi?L:T);for(;ie=ye.nextNode();)Sh(ie),$h(ie),ie.content instanceof s&&Ov(ie.content);if(bi)return L;if(dr){if(so)for(Re=ce.call(T.ownerDocument);T.firstChild;)Re.appendChild(T.firstChild);else Re=T;return(Ae.shadowroot||Ae.shadowrootmode)&&(Re=to.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(av,T.ownerDocument.doctype.name)&&(Fe="<!DOCTYPE "+T.ownerDocument.doctype.name+`>
333
- `+Fe),hr&&xo([kn,mt,Xt],Rt=>{Fe=Ti(Fe,Rt," ")}),M&&oo?M.createHTML(Fe):Fe},e.setConfig=function(){let L=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};rl(L),Ka=!0},e.clearConfig=function(){gr=null,Ka=!1},e.isValidAttribute=function(L,g,T){gr||rl({});const R=be(L),ie=be(g);return kh(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=_O($e[L],g);return T===-1?void 0:SO($e[L],T,1)[0]}return Xf($e[L])},e.removeHooks=function(L){$e[L]=[]},e.removeAllHooks=function(){$e=ip()},e}var cv=lv();function Wu(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var ur=Wu();function uv(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 UO=(()=>{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)}}>`)},FO=/^(?:[ \t]*(?:\n|$))+/,ZO=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,HO=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,eo=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,VO=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,qu=/ {0,3}(?:[*+-]|\d{1,9}[.)])/,hv=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,dv=W(hv).replace(/bull/g,qu).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(),jO=W(hv).replace(/bull/g,qu).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(),Yu=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,BO=/^[^\n]+/,Ku=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,GO=W(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",Ku).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),WO=W(/^(bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,qu).getRegex(),Ba="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",Ju=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,qO=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",Ju).replace("tag",Ba).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),fv=W(Yu).replace("hr",eo).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",Ba).getRegex(),YO=W(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",fv).getRegex(),Xu={blockquote:YO,code:ZO,def:GO,fences:HO,heading:VO,hr:eo,html:qO,lheading:dv,list:WO,newline:FO,paragraph:fv,table:Dn,text:BO},sp=W("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",eo).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",Ba).getRegex(),KO={...Xu,lheading:jO,table:sp,paragraph:W(Yu).replace("hr",eo).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",sp).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",Ba).getRegex()},JO={...Xu,html:W(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",Ju).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(Yu).replace("hr",eo).replace("heading",` *#{1,6} *[^
334
- ]`).replace("lheading",dv).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},XO=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,QO=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,pv=/^( {2,}|\\)\n(?!\s*$)/,ez=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,mi=/[\p{P}\p{S}]/u,Ga=/[\s\p{P}\p{S}]/u,Qu=/[^\s\p{P}\p{S}]/u,tz=W(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,Ga).getRegex(),gv=/(?!~)[\p{P}\p{S}]/u,nz=/(?!~)[\s\p{P}\p{S}]/u,rz=/(?:[^\s\p{P}\p{S}]|~)/u,iz=W(/link|precode-code|html/,"g").replace("link",/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-",UO?"(?<!`)()":"(^^|[^`])").replace("code",/(?<b>`+)[^`]+\k<b>(?!`)/).replace("html",/<(?! )[^<>]*?>/).getRegex(),mv=/^(?:\*+(?:((?!\*)punct)|([^\s*]))?)|^_+(?:((?!_)punct)|([^\s_]))?/,sz=W(mv,"u").replace(/punct/g,mi).getRegex(),oz=W(mv,"u").replace(/punct/g,gv).getRegex(),yv="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",az=W(yv,"gu").replace(/notPunctSpace/g,Qu).replace(/punctSpace/g,Ga).replace(/punct/g,mi).getRegex(),lz=W(yv,"gu").replace(/notPunctSpace/g,rz).replace(/punctSpace/g,nz).replace(/punct/g,gv).getRegex(),cz=W("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,Qu).replace(/punctSpace/g,Ga).replace(/punct/g,mi).getRegex(),uz=W(/^~~?(?:((?!~)punct)|[^\s~])/,"u").replace(/punct/g,mi).getRegex(),hz="^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)",dz=W(hz,"gu").replace(/notPunctSpace/g,Qu).replace(/punctSpace/g,Ga).replace(/punct/g,mi).getRegex(),fz=W(/\\(punct)/,"gu").replace(/punct/g,mi).getRegex(),pz=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(),gz=W(Ju).replace("(?:-->|$)","-->").getRegex(),mz=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",gz).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),aa=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\])|[^\[\]\\`])*?/,yz=W(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?\s*\)/).replace("label",aa).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),vv=W(/^!?\[(label)\]\[(ref)\]/).replace("label",aa).replace("ref",Ku).getRegex(),bv=W(/^!?\[(ref)\](?:\[\])?/).replace("ref",Ku).getRegex(),vz=W("reflink|nolink(?!\\()","g").replace("reflink",vv).replace("nolink",bv).getRegex(),op=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,eh={_backpedal:Dn,anyPunctuation:fz,autolink:pz,blockSkip:iz,br:pv,code:QO,del:Dn,delLDelim:Dn,delRDelim:Dn,emStrongLDelim:sz,emStrongRDelimAst:az,emStrongRDelimUnd:cz,escape:XO,link:yz,nolink:bv,punctuation:tz,reflink:vv,reflinkSearch:vz,tag:mz,text:ez,url:Dn},bz={...eh,link:W(/^!?\[(label)\]\((.*?)\)/).replace("label",aa).getRegex(),reflink:W(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",aa).getRegex()},qc={...eh,emStrongRDelimAst:lz,emStrongLDelim:oz,delLDelim:uz,delRDelim:dz,url:W(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol",op).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",op).getRegex()},wz={...qc,br:W(pv).replace("{2,}","*").getRegex(),text:W(qc.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},Co={normal:Xu,gfm:KO,pedantic:JO},Ri={normal:eh,gfm:qc,breaks:wz,pedantic:bz},_z={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},ap=n=>_z[n];function St(n,e){if(e){if(Le.escapeTest.test(n))return n.replace(Le.escapeReplace,ap)}else if(Le.escapeTestNoEncode.test(n))return n.replace(Le.escapeReplaceNoEncode,ap);return n}function lp(n){try{n=encodeURI(n).replace(Le.percentDecode,"%")}catch{return null}return n}function cp(n,e){var s;let t=n.replace(Le.findPipe,(o,a,c)=>{let u=!1,d=a;for(;--d>=0&&c[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 Sz(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 kz(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 up(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 c={type:n[0].charAt(0)==="!"?"image":"link",raw:t,href:s,title:o,text:a,tokens:r.inlineTokens(a)};return r.state.inLink=!1,c}function Ez(n,e,t){let r=n.match(t.other.indentCodeCompensation);if(r===null)return e;let i=r[1];return e.split(`
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
- `)}var la=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=Ez(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
- `)}}blockquote(n){let e=this.rules.block.blockquote.exec(n);if(e){let t=Di(e[0],`
339
- `).split(`
340
- `),r="",i="",s=[];for(;t.length>0;){let o=!1,a=[],c;for(c=0;c<t.length;c++)if(this.rules.other.blockquoteStart.test(t[c]))a.push(t[c]),o=!0;else if(!o)a.push(t[c]);else break;t=t.slice(c);let u=a.join(`
341
- `),d=u.replace(this.rules.other.blockquoteSetextReplace,`
342
- $1`).replace(this.rules.other.blockquoteSetextReplace2,"");r=r?`${r}
343
- ${u}`:u,i=i?`${i}
344
- ${d}`:d;let f=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(d,s,!0),this.lexer.state.top=f,t.length===0)break;let v=s.at(-1);if((v==null?void 0:v.type)==="code")break;if((v==null?void 0:v.type)==="blockquote"){let y=v,A=y.raw+`
345
- `+t.join(`
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
- `+t.join(`
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),c=!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=kz(e[2].split(`
350
- `,1)[0],e[1].length),A=n.split(`
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+=`
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
- `+A}k=!A.trim(),f+=ge+`
356
- `,n=n.substring(ge.length+1),y=ce.slice(I)}}o.loose||(c?o.loose=!0:this.rules.other.doubleBlankLine.test(f)&&(c=!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=cp(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
- `):[],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(cp(a,s.header.length).map((c,u)=>({text:c,tokens:this.lexer.inline(c),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=Sz(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)),up(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 up(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,c=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)){c+=o;continue}if(a-=o,a>0)continue;o=Math.min(o,o+a+c);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,c=this.rules.inline.delRDelim;for(c.lastIndex=0,e=e.slice(-1*n.length+i);(r=c.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 Yc{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 la,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:Co.normal,inline:Ri.normal};this.options.pedantic?(t.block=Co.pedantic,t.inline=Ri.pedantic):this.options.gfm&&(t.block=Co.gfm,this.options.breaks?t.inline=Ri.breaks:t.inline=Ri.gfm),this.tokenizer.rules=t}static get rules(){return{block:Co,inline:Ri}}static lex(e,t){return new Yc(t).lex(e)}static lexInline(e,t){return new Yc(t).inlineTokens(e)}lex(e){e=e.replace(Le.carriageReturn,`
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
- `: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
- `)?"":`
362
- `)+a.raw,u.text+=`
363
- `+a.text,this.inlineQueue.at(-1).src=u.text):t.push(a);continue}if(a=this.tokenizer.fences(e)){e=e.substring(a.raw.length),t.push(a);continue}if(a=this.tokenizer.heading(e)){e=e.substring(a.raw.length),t.push(a);continue}if(a=this.tokenizer.hr(e)){e=e.substring(a.raw.length),t.push(a);continue}if(a=this.tokenizer.blockquote(e)){e=e.substring(a.raw.length),t.push(a);continue}if(a=this.tokenizer.list(e)){e=e.substring(a.raw.length),t.push(a);continue}if(a=this.tokenizer.html(e)){e=e.substring(a.raw.length),t.push(a);continue}if(a=this.tokenizer.def(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(`
364
- `)?"":`
365
- `)+a.raw,u.text+=`
366
- `+a.raw,this.inlineQueue.at(-1).src=u.text):this.tokens.links[a.tag]||(this.tokens.links[a.tag]={href:a.href,title:a.title},t.push(a));continue}if(a=this.tokenizer.table(e)){e=e.substring(a.raw.length),t.push(a);continue}if(a=this.tokenizer.lheading(e)){e=e.substring(a.raw.length),t.push(a);continue}let c=e;if((o=this.options.extensions)!=null&&o.startBlock){let u=1/0,d=e.slice(1),f;this.options.extensions.startBlock.forEach(v=>{f=v.call({lexer:this},d),typeof f=="number"&&f>=0&&(u=Math.min(u,f))}),u<1/0&&u>=0&&(c=e.substring(0,u+1))}if(this.state.top&&(a=this.tokenizer.paragraph(c))){let u=t.at(-1);r&&(u==null?void 0:u.type)==="paragraph"?(u.raw+=(u.raw.endsWith(`
367
- `)?"":`
368
- `)+a.raw,u.text+=`
369
- `+a.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=u.text):t.push(a),r=c.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
- `)?"":`
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 c,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=(c=this.options.hooks)==null?void 0:c.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}},ca=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
- `;return r?'<pre><code class="language-'+St(r)+'">'+(t?i:St(i,!0))+`</code></pre>
374
- `:"<pre><code>"+(t?i:St(i,!0))+`</code></pre>
375
- `}blockquote({tokens:n}){return`<blockquote>
376
- ${this.parser.parse(n)}</blockquote>
377
- `}html({text:n}){return n}def(n){return""}heading({tokens:n,depth:e}){return`<h${e}>${this.parser.parseInline(n)}</h${e}>
378
- `}hr(n){return`<hr>
379
- `}list(n){let e=n.ordered,t=n.start,r="";for(let o=0;o<n.items.length;o++){let a=n.items[o];r+=this.listitem(a)}let i=e?"ol":"ul",s=e&&t!==1?' start="'+t+'"':"";return"<"+i+s+`>
380
- `+r+"</"+i+`>
381
- `}listitem(n){return`<li>${this.parser.parse(n.tokens)}</li>
382
- `}checkbox({checked:n}){return"<input "+(n?'checked="" ':"")+'disabled="" type="checkbox"> '}paragraph({tokens:n}){return`<p>${this.parser.parseInline(n)}</p>
383
- `}table(n){let e="",t="";for(let i=0;i<n.header.length;i++)t+=this.tablecell(n.header[i]);e+=this.tablerow({text:t});let r="";for(let i=0;i<n.rows.length;i++){let s=n.rows[i];t="";for(let o=0;o<s.length;o++)t+=this.tablecell(s[o]);r+=this.tablerow({text:t})}return r&&(r=`<tbody>${r}</tbody>`),`<table>
384
- <thead>
385
- `+e+`</thead>
386
- `+r+`</table>
387
- `}tablerow({text:n}){return`<tr>
388
- ${n}</tr>
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>${St(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=lp(n);if(i===null)return r;n=i;let s='<a href="'+n+'"';return e&&(s+=' title="'+St(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=lp(n);if(i===null)return St(t);n=i;let s=`<img src="${n}" alt="${St(t)}"`;return e&&(s+=` title="${St(e)}"`),s+=">",s}text(n){return"tokens"in n&&n.tokens?this.parser.parseInline(n.tokens):"escaped"in n&&n.escaped?n.text:St(n.text)}},th=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 Kc{constructor(e){b(this,"options");b(this,"renderer");b(this,"textRenderer");this.options=e||ur,this.options.renderer=this.options.renderer||new ca,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new th}static parse(e,t){return new Kc(t).parse(e)}static parseInline(e,t){return new Kc(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 c=o,u=this.options.extensions.renderers[c.type].call({parser:this},c);if(u!==!1||!["space","hr","heading","code","table","blockquote","list","html","def","paragraph","text"].includes(c.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 c='Token with "'+a.type+'" type was not found.';if(this.options.silent)return console.error(c),"";throw new Error(c)}}}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 c=a;switch(c.type){case"escape":{r+=t.text(c);break}case"html":{r+=t.html(c);break}case"link":{r+=t.link(c);break}case"image":{r+=t.image(c);break}case"checkbox":{r+=t.checkbox(c);break}case"strong":{r+=t.strong(c);break}case"em":{r+=t.em(c);break}case"codespan":{r+=t.codespan(c);break}case"br":{r+=t.br(c);break}case"del":{r+=t.del(c);break}case"text":{r+=t.text(c);break}default:{let u='Token with "'+c.type+'" type was not found.';if(this.options.silent)return console.error(u),"";throw new Error(u)}}}return r}},Io,Vi=(Io=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(Io,"passThroughHooks",new Set(["preprocess","postprocess","processAllTokens","emStrongMask"])),b(Io,"passThroughHooksRespectAsync",new Set(["preprocess","postprocess","processAllTokens"])),Io),$z=class{constructor(...n){b(this,"defaults",Wu());b(this,"options",this.setOptions);b(this,"parse",this.parseMarkdown(!0));b(this,"parseInline",this.parseMarkdown(!1));b(this,"Parser",ft);b(this,"Renderer",ca);b(this,"TextRenderer",th);b(this,"Lexer",dt);b(this,"Tokenizer",la);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 c of a)t=t.concat(this.walkTokens(c.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 c=o[a].flat(1/0);t=t.concat(this.walkTokens(c,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 ca(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],c=i[o];i[o]=(...u)=>{let d=a.apply(i,u);return d===!1&&(d=c.apply(i,u)),d||""}}r.renderer=i}if(t.tokenizer){let i=this.defaults.tokenizer||new la(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],c=i[o];i[o]=(...u)=>{let d=a.apply(i,u);return d===!1&&(d=c.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],c=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 c.call(i,f)})();let d=a.call(i,u);return c.call(i,d)}:i[o]=(...u)=>{if(this.defaults.async)return(async()=>{let f=await a.apply(i,u);return f===!1&&(f=await c.apply(i,u)),f})();let d=a.apply(i,u);return d===!1&&(d=c.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),c=i.hooks?await i.hooks.processAllTokens(a):a;i.walkTokens&&await Promise.all(this.walkTokens(c,i.walkTokens));let u=await(i.hooks?await i.hooks.provideParser():n?ft.parse:ft.parseInline)(c,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>"+St(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,uv(K.defaults),K};K.getDefaults=Wu;K.defaults=ur;K.use=function(...n){return sr.use(...n),K.defaults=sr.defaults,uv(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=ca;K.TextRenderer=th;K.Lexer=dt;K.lexer=dt.lex;K.Tokenizer=la;K.Hooks=Vi;K.parse=K;K.options;K.setOptions;K.use;K.walkTokens;K.parseInline;ft.parse;dt.lex;cv.addHook("afterSanitizeAttributes",n=>{n.tagName==="A"&&(n.setAttribute("target","_blank"),n.setAttribute("rel","noopener noreferrer"))});function Az(n){const e=K.parse(n,{async:!1});return cv.sanitize(e,{USE_PROFILES:{html:!0}})}const xz=8,hp=new WeakMap;function Tz(n){const e=hp.get(n);if(e&&e.text===n.text)return e.html;const t=Az(n.text);return hp.set(n,{text:n.text,html:t}),t}function dp(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,xa,Ta,Ls,Jc;class wv extends ts{constructor(){super(...arguments);_(this,Ls);b(this,"messages",[]);_(this,jt,!0);_(this,Qn,null);_(this,xa,()=>{const t=l(this,Qn);if(!t)return;const i=t.scrollHeight-t.clientHeight-t.scrollTop<=xz;i!==l(this,jt)&&(E(this,jt,i),this.toggleAttribute("data-pinned",i))});_(this,Ta,()=>{E(this,jt,!0),this.toggleAttribute("data-pinned",!0),m(this,Ls,Jc).call(this,!0)})}changed(t){let r=!1;if(t.has("messages")){const i=t.get("messages")??[],s=dp(this.messages);r=s!==null&&s!==dp(i),r&&E(this,jt,!0)}Pe(this.template(),this),l(this,Qn)||E(this,Qn,this.querySelector(".history-scroll")),this.toggleAttribute("data-pinned",l(this,jt)),m(this,Ls,Jc).call(this,r)}template(){const t=this.messages.filter(r=>r.kind==="user"||r.kind==="assistant");return F`
392
- <div class="history-scroll" @scroll=${l(this,xa)}>
393
- ${t.map(r=>{const i=r.kind==="assistant"?FR(Tz(r)):r.text;return F`<div
394
- class="message message-${r.kind}"
395
- data-message-id=${r.id}
396
- >${i}</div>`})}
397
- </div>
398
- <button
399
- type="button"
400
- class="history-jump"
401
- aria-label="Jump to latest message"
402
- @click=${l(this,Ta)}
403
- >
404
- ${_y({size:16})}
405
- </button>
406
- `}}jt=new WeakMap,Qn=new WeakMap,xa=new WeakMap,Ta=new WeakMap,Ls=new WeakSet,Jc=function(t){requestAnimationFrame(()=>{const r=l(this,Qn);r&&(!l(this,jt)&&!t||(r.scrollTop=r.scrollHeight-r.clientHeight))})},b(wv,"properties",["messages"]);customElements.define("message-history",wv);var Ms,Ns,Kr,Us,vn,Qc,eu,Fs,Zs;class Xc extends ts{constructor(){super(...arguments);_(this,vn);b(this,"placeholder","What do you want to do?");b(this,"open",!1);b(this,"messages",[]);_(this,Ms,Ge.resolve("ACPClientManager"));_(this,Ns,Ge.resolve("ShortcutService"));_(this,Kr,null);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=l(this,Ms).getActiveClient();s&&s.sendMessage({text:i}).catch(o=>{console.error("ACPClient.sendMessage() failed",o)})});_(this,Us,t=>{if(t.shortcut!=="focusCommandInput")return;if(!this.open){this.open=!0;return}const r=this.querySelector("textarea");if(r){if(document.activeElement===r){this.open=!1;return}r.focus()}});_(this,Fs,t=>{t.target instanceof Node&&(this.contains(t.target)||(this.open=!1))});_(this,Zs,t=>{t.key==="Escape"&&(this.open=!1)})}connected(){const t=new DisposableStack;E(this,Kr,t);const r=yO(l(this,Ms),i=>{this.messages=i});t.defer(()=>r.dispose()),l(this,Ns).addEventListener("shortcut-triggered",l(this,Us)),t.defer(()=>l(this,Ns).removeEventListener("shortcut-triggered",l(this,Us))),this.open&&m(this,vn,Qc).call(this)}disconnected(){var t;(t=l(this,Kr))==null||t.dispose(),E(this,Kr,null),m(this,vn,eu).call(this)}changed(t){if(Pe(this.template(),this),t.has("open"))if(this.open){m(this,vn,Qc).call(this);const r=this.querySelector("textarea");r==null||r.focus()}else m(this,vn,eu).call(this)}template(){return this.open?F`
407
- <message-history .messages=${this.messages}></message-history>
408
- <textarea
409
- class="input"
410
- rows="1"
411
- @keydown=${this.handleKeydown}
412
- ></textarea>
413
- `:F`
414
- <button
415
- class="trigger"
416
- type="button"
417
- @click=${this.handleTriggerActivate}
418
- @focus=${this.handleTriggerActivate}
419
- >
420
- <span class="label">${this.placeholder}</span>
421
- <span class="kbd" aria-hidden="true">⌘K</span>
422
- </button>
423
- `}}Ms=new WeakMap,Ns=new WeakMap,Kr=new WeakMap,Us=new WeakMap,vn=new WeakSet,Qc=function(){document.addEventListener("mousedown",l(this,Fs)),document.addEventListener("keydown",l(this,Zs))},eu=function(){document.removeEventListener("mousedown",l(this,Fs)),document.removeEventListener("keydown",l(this,Zs))},Fs=new WeakMap,Zs=new WeakMap,b(Xc,"properties",["placeholder","open","messages"]),b(Xc,"attributes",{placeholder:{type:String},open:{type:Boolean}});customElements.define("command-panel",Xc);class _v extends Event{constructor(t){super("auth-submit",{bubbles:!0,composed:!0});b(this,"token");this.token=t}}class Cz 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 _v(r))}render(){Pe(F`
424
- <modal-overlay open>
425
- <section class="auth-modal">
426
- <form class="auth-form" @submit=${t=>this.handleSubmit(t)}>
427
- <h2 class="auth-modal-title">Enter access token</h2>
428
- <p class="auth-modal-copy">This Television server requires a token.</p>
429
- <label class="settings-field">
430
- <span>Token</span>
431
- <input
432
- class=${this.invalid?"auth-token-input-invalid":""}
433
- type="password"
434
- name="token"
435
- .value=${this.tokenValue}
436
- @input=${t=>this.handleInput(t)}
437
- required
438
- />
439
- </label>
440
- <button type="submit" class="settings-submit-button">Connect</button>
441
- </form>
442
- </section>
443
- </modal-overlay>
444
- `,this)}}customElements.get("auth-modal")||customElements.define("auth-modal",Cz);class Iz extends HTMLElement{constructor(){super(...arguments);b(this,"runtimeServerURL",hy());b(this,"electronMode",dy());b(this,"serverManager",Ge.resolve("ServerManager"));b(this,"screenManager",Ge.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 _v?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,Ac());return}if(this.serverManager.activeServer)return;const t=new bc({url:this.runtimeServerURL,name:"Server",token:Ac()});this.serverManager.add(t),this.serverManager.setActive(t);try{await t.connect(),this.connectError=null}catch(r){this.connectError=r instanceof Error&&!(r instanceof vc)?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 vc||(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
- <main class="auth-gate"><p>Connecting...</p></main>
446
- `,this);return}if(r==="disconnected"){const o=t;if(!o)return;Pe(F`
447
- <main class="auth-gate">
448
- <auth-modal
449
- .invalid=${!!o.token}
450
- .tokenValue=${o.token??""}
451
- ></auth-modal>
452
- </main>
453
- `,this);return}const s=this.screenManager.activeScreen?F`<screen-view></screen-view>`:F`<home-screen></home-screen>`;Pe(F`
454
- <main>
455
- ${this.connectError?F`<p data-testid="auth-error">${this.connectError}</p>`:F`
456
- ${s}
457
- ${r==="connected"?F`
458
- <div class="chrome">
459
- <div class="top-row electron-draggable">
460
- <screen-breadcrumb></screen-breadcrumb>
461
- <screen-create-button></screen-create-button>
462
- </div>
463
- <command-panel></command-panel>
464
- </div>
465
- `:null}
466
- `}
467
- </main>
468
- `,this)}}customElements.get("television-app")||customElements.define("television-app",Iz);const nh=dy(),Wa=hy(),Sv=new Y0(nh?"television-electron":"television-browser",q0(Wa)),kv=new ZC({localStore:Sv,localServerURL:Wa}),Ev=new B0({localStore:Sv,serverManager:kv}),Pz=new SR({serverURL:Wa,token:Ac()??"",screenManager:Ev}),Rz=new ER;Ge.register("ServerManager",()=>kv);Ge.register("ScreenManager",()=>Ev);Ge.register("ACPClientManager",()=>Pz);Ge.register("ShortcutService",()=>Rz);const rh=document.createElement("television-app");rh.runtimeServerURL=Wa;rh.electronMode=nh;nh&&document.body.classList.add("electron");document.body.appendChild(rh);