@telepath-computer/television 0.1.31 → 0.1.33
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.
- package/dist/browser/assets/Supreme-Variable-D6OPM70K.woff2 +0 -0
- package/dist/browser/assets/Supreme-VariableItalic-BM_OJs3z.woff2 +0 -0
- package/dist/browser/assets/gradient-j-DX-EI0uV.jpg +0 -0
- package/dist/browser/assets/index-C0YgLV2m.css +1 -0
- package/dist/browser/assets/index-DNHsk-aL.js +552 -0
- package/dist/browser/index.html +2 -2
- package/dist/cli.cjs +2 -2
- package/package.json +1 -1
- package/dist/browser/assets/index-B1x2HF5Y.css +0 -1
- package/dist/browser/assets/index-D2FJcBjd.js +0 -548
|
@@ -1,548 +0,0 @@
|
|
|
1
|
-
var Cv=Object.defineProperty;var ku=t=>{throw TypeError(t)};var Iv=(t,e,n)=>e in t?Cv(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var v=(t,e,n)=>Iv(t,typeof e!="symbol"?e+"":e,n),fa=(t,e,n)=>e.has(t)||ku("Cannot "+n);var h=(t,e,n)=>(fa(t,e,"read from private field"),n?n.call(t):e.get(t)),x=(t,e,n)=>e.has(t)?ku("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,n),$=(t,e,n,r)=>(fa(t,e,"write to private field"),r?r.call(t,n):e.set(t,n),n),b=(t,e,n)=>(fa(t,e,"access private method"),n);var Eu=(t,e,n,r)=>({set _(s){$(t,e,s,n)},get _(){return h(t,e,r)}});(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const s of document.querySelectorAll('link[rel="modulepreload"]'))r(s);new MutationObserver(s=>{for(const i of s)if(i.type==="childList")for(const o of i.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&r(o)}).observe(document,{childList:!0,subtree:!0});function n(s){const i={};return s.integrity&&(i.integrity=s.integrity),s.referrerPolicy&&(i.referrerPolicy=s.referrerPolicy),s.crossOrigin==="use-credentials"?i.credentials="include":s.crossOrigin==="anonymous"?i.credentials="omit":i.credentials="same-origin",i}function r(s){if(s.ep)return;s.ep=!0;const i=n(s);fetch(s.href,i)}})();var Sn=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Pv(t){if(t.__esModule)return t;var e=t.default;if(typeof e=="function"){var n=function r(){return this instanceof r?Reflect.construct(e,arguments,this.constructor):e.apply(this,arguments)};n.prototype=e.prototype}else n={};return Object.defineProperty(n,"__esModule",{value:!0}),Object.keys(t).forEach(function(r){var s=Object.getOwnPropertyDescriptor(t,r);Object.defineProperty(n,r,s.get?s:{enumerable:!0,get:function(){return t[r]}})}),n}var $u=Object.prototype.toString,hf=function(e){var n=$u.call(e),r=n==="[object Arguments]";return r||(r=n!=="[object Array]"&&e!==null&&typeof e=="object"&&typeof e.length=="number"&&e.length>=0&&$u.call(e.callee)==="[object Function]"),r},pa,Au;function Rv(){if(Au)return pa;Au=1;var t;if(!Object.keys){var e=Object.prototype.hasOwnProperty,n=Object.prototype.toString,r=hf,s=Object.prototype.propertyIsEnumerable,i=!s.call({toString:null},"toString"),o=s.call(function(){},"prototype"),a=["toString","toLocaleString","valueOf","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","constructor"],l=function(y){var m=y.constructor;return m&&m.prototype===y},c={$applicationCache:!0,$console:!0,$external:!0,$frame:!0,$frameElement:!0,$frames:!0,$innerHeight:!0,$innerWidth:!0,$onmozfullscreenchange:!0,$onmozfullscreenerror:!0,$outerHeight:!0,$outerWidth:!0,$pageXOffset:!0,$pageYOffset:!0,$parent:!0,$scrollLeft:!0,$scrollTop:!0,$scrollX:!0,$scrollY:!0,$self:!0,$webkitIndexedDB:!0,$webkitStorageInfo:!0,$window:!0},d=function(){if(typeof window>"u")return!1;for(var y in window)try{if(!c["$"+y]&&e.call(window,y)&&window[y]!==null&&typeof window[y]=="object")try{l(window[y])}catch{return!0}}catch{return!0}return!1}(),f=function(y){if(typeof window>"u"||!d)return l(y);try{return l(y)}catch{return!1}};t=function(m){var E=m!==null&&typeof m=="object",k=n.call(m)==="[object Function]",I=r(m),V=E&&n.call(m)==="[object String]",N=[];if(!E&&!k&&!I)throw new TypeError("Object.keys called on a non-object");var j=o&&k;if(V&&m.length>0&&!e.call(m,0))for(var F=0;F<m.length;++F)N.push(String(F));if(I&&m.length>0)for(var L=0;L<m.length;++L)N.push(String(L));else for(var J in m)!(j&&J==="prototype")&&e.call(m,J)&&N.push(String(J));if(i)for(var H=f(m),he=0;he<a.length;++he)!(H&&a[he]==="constructor")&&e.call(m,a[he])&&N.push(a[he]);return N}}return pa=t,pa}var Dv=Array.prototype.slice,Ov=hf,xu=Object.keys,qi=xu?function(e){return xu(e)}:Rv(),Tu=Object.keys;qi.shim=function(){if(Object.keys){var e=function(){var n=Object.keys(arguments);return n&&n.length===arguments.length}(1,2);e||(Object.keys=function(r){return Ov(r)?Tu(Dv.call(r)):Tu(r)})}else Object.keys=qi;return Object.keys||qi};var zv=qi,Yi=Object.defineProperty||!1;if(Yi)try{Yi({},"a",{value:1})}catch{Yi=!1}var oi=Yi,Zt=SyntaxError,G=TypeError,Lv=Object.getOwnPropertyDescriptor,Ki=Lv;if(Ki)try{Ki([],"length")}catch{Ki=null}var Nr=Ki,Cu=oi,Mv=Zt,rr=G,Iu=Nr,df=function(e,n,r){if(!e||typeof e!="object"&&typeof e!="function")throw new rr("`obj` must be an object or a function`");if(typeof n!="string"&&typeof n!="symbol")throw new rr("`property` must be a string or a symbol`");if(arguments.length>3&&typeof arguments[3]!="boolean"&&arguments[3]!==null)throw new rr("`nonEnumerable`, if provided, must be a boolean or null");if(arguments.length>4&&typeof arguments[4]!="boolean"&&arguments[4]!==null)throw new rr("`nonWritable`, if provided, must be a boolean or null");if(arguments.length>5&&typeof arguments[5]!="boolean"&&arguments[5]!==null)throw new rr("`nonConfigurable`, if provided, must be a boolean or null");if(arguments.length>6&&typeof arguments[6]!="boolean")throw new rr("`loose`, if provided, must be a boolean");var s=arguments.length>3?arguments[3]:null,i=arguments.length>4?arguments[4]:null,o=arguments.length>5?arguments[5]:null,a=arguments.length>6?arguments[6]:!1,l=!!Iu&&Iu(e,n);if(Cu)Cu(e,n,{configurable:o===null&&l?l.configurable:!o,enumerable:s===null&&l?l.enumerable:!s,value:r,writable:i===null&&l?l.writable:!i});else if(a||!s&&!i&&!o)e[n]=r;else throw new Mv("This environment does not support defining a property as non-configurable, non-writable, or non-enumerable.")},nl=oi,ff=function(){return!!nl};ff.hasArrayLengthDefineBug=function(){if(!nl)return null;try{return nl([],"length",{value:1}).length!==1}catch{return!0}};var Lo=ff,Nv=zv,Uv=typeof Symbol=="function"&&typeof Symbol("foo")=="symbol",Fv=Object.prototype.toString,Zv=Array.prototype.concat,Pu=df,jv=function(t){return typeof t=="function"&&Fv.call(t)==="[object Function]"},pf=Lo(),Wv=function(t,e,n,r){if(e in t){if(r===!0){if(t[e]===n)return}else if(!jv(r)||!r())return}pf?Pu(t,e,n,!0):Pu(t,e,n)},gf=function(t,e){var n=arguments.length>2?arguments[2]:{},r=Nv(e);Uv&&(r=Zv.call(r,Object.getOwnPropertySymbols(e)));for(var s=0;s<r.length;s+=1)Wv(t,r[s],e[r[s]],n[r[s]])};gf.supportsDescriptors=!!pf;var Hn=gf,Ji={exports:{}};typeof self<"u"?Ji.exports=self:typeof window<"u"?Ji.exports=window:Ji.exports=Function("return this")();var mf=Ji.exports,Bv=mf,vf=function(){return typeof Sn!="object"||!Sn||Sn.Math!==Math||Sn.Array!==Array?Bv:Sn},Vv=Hn,Gv=Nr,Hv=vf,qv=function(){var e=Hv();if(Vv.supportsDescriptors){var n=Gv(e,"globalThis");(!n||n.configurable&&(n.enumerable||!n.writable||globalThis!==e))&&Object.defineProperty(e,"globalThis",{configurable:!0,enumerable:!1,value:e,writable:!0})}else(typeof globalThis!="object"||globalThis!==e)&&(e.globalThis=e);return e},Yv=Hn,Kv=mf,yf=vf,Jv=qv,Xv=yf(),bf=function(){return Xv};Yv(bf,{getPolyfill:yf,implementation:Kv,shim:Jv});var Kl=bf,jt=function(e){return!!e&&(typeof e=="function"||typeof e=="object")},Jl=Object,wf=Error,Qv=EvalError,ey=RangeError,Xl=ReferenceError,ty=URIError,ny=Math.abs,ry=Math.floor,sy=Math.max,iy=Math.min,oy=Math.pow,ay=Math.round,Ql=Number.isNaN||function(e){return e!==e},ly=Ql,cy=function(e){return ly(e)||e===0?e:e<0?-1:1},Ur=function(){if(typeof Symbol!="function"||typeof Object.getOwnPropertySymbols!="function")return!1;if(typeof Symbol.iterator=="symbol")return!0;var e={},n=Symbol("test"),r=Object(n);if(typeof n=="string"||Object.prototype.toString.call(n)!=="[object Symbol]"||Object.prototype.toString.call(r)!=="[object Symbol]")return!1;var s=42;e[n]=s;for(var i in e)return!1;if(typeof Object.keys=="function"&&Object.keys(e).length!==0||typeof Object.getOwnPropertyNames=="function"&&Object.getOwnPropertyNames(e).length!==0)return!1;var o=Object.getOwnPropertySymbols(e);if(o.length!==1||o[0]!==n||!Object.prototype.propertyIsEnumerable.call(e,n))return!1;if(typeof Object.getOwnPropertyDescriptor=="function"){var a=Object.getOwnPropertyDescriptor(e,n);if(a.value!==s||a.enumerable!==!0)return!1}return!0},Ru=typeof Symbol<"u"&&Symbol,uy=Ur,ec=function(){return typeof Ru!="function"||typeof Symbol!="function"||typeof Ru("foo")!="symbol"||typeof Symbol("bar")!="symbol"?!1:uy()},_f=typeof Reflect<"u"&&Reflect.getPrototypeOf||null,hy=Jl,Sf=hy.getPrototypeOf||null,dy="Function.prototype.bind called on incompatible ",fy=Object.prototype.toString,py=Math.max,gy="[object Function]",Du=function(e,n){for(var r=[],s=0;s<e.length;s+=1)r[s]=e[s];for(var i=0;i<n.length;i+=1)r[i+e.length]=n[i];return r},my=function(e,n){for(var r=[],s=n,i=0;s<e.length;s+=1,i+=1)r[i]=e[s];return r},vy=function(t,e){for(var n="",r=0;r<t.length;r+=1)n+=t[r],r+1<t.length&&(n+=e);return n},yy=function(e){var n=this;if(typeof n!="function"||fy.apply(n)!==gy)throw new TypeError(dy+n);for(var r=my(arguments,1),s,i=function(){if(this instanceof s){var d=n.apply(this,Du(r,arguments));return Object(d)===d?d:this}return n.apply(e,Du(r,arguments))},o=py(0,n.length-r.length),a=[],l=0;l<o;l++)a[l]="$"+l;if(s=Function("binder","return function ("+vy(a,",")+"){ return binder.apply(this,arguments); }")(i),n.prototype){var c=function(){};c.prototype=n.prototype,s.prototype=new c,c.prototype=null}return s},by=yy,ai=Function.prototype.bind||by,tc=Function.prototype.call,ga,Ou;function nc(){return Ou||(Ou=1,ga=Function.prototype.apply),ga}var wy=typeof Reflect<"u"&&Reflect&&Reflect.apply,_y=ai,Sy=nc(),ky=tc,Ey=wy,kf=Ey||_y.call(ky,Sy),$y=ai,Ay=G,xy=tc,Ty=kf,Mo=function(e){if(e.length<1||typeof e[0]!="function")throw new Ay("a function is required");return Ty($y,xy,e)},Cy=Mo,zu=Nr,Ef;try{Ef=[].__proto__===Array.prototype}catch(t){if(!t||typeof t!="object"||!("code"in t)||t.code!=="ERR_PROTO_ACCESS")throw t}var ma=!!Ef&&zu&&zu(Object.prototype,"__proto__"),$f=Object,Lu=$f.getPrototypeOf,Iy=ma&&typeof ma.get=="function"?Cy([ma.get]):typeof Lu=="function"?function(e){return Lu(e==null?e:$f(e))}:!1,Mu=_f,Nu=Sf,Uu=Iy,Af=Mu?function(e){return Mu(e)}:Nu?function(e){if(!e||typeof e!="object"&&typeof e!="function")throw new TypeError("getProto: not an object");return Nu(e)}:Uu?function(e){return Uu(e)}:null,Py=Function.prototype.call,Ry=Object.prototype.hasOwnProperty,Dy=ai,Wt=Dy.call(Py,Ry),B,Oy=Jl,zy=wf,Ly=Qv,My=ey,Ny=Xl,Rr=Zt,br=G,Uy=ty,Fy=ny,Zy=ry,jy=sy,Wy=iy,By=oy,Vy=ay,Gy=cy,xf=Function,va=function(t){try{return xf('"use strict"; return ('+t+").constructor;")()}catch{}},As=Nr,Hy=oi,ya=function(){throw new br},qy=As?function(){try{return arguments.callee,ya}catch{try{return As(arguments,"callee").get}catch{return ya}}}():ya,sr=ec(),_e=Af,Yy=Sf,Ky=_f,Tf=nc(),li=tc,ar={},Jy=typeof Uint8Array>"u"||!_e?B:_e(Uint8Array),Zn={__proto__:null,"%AggregateError%":typeof AggregateError>"u"?B:AggregateError,"%Array%":Array,"%ArrayBuffer%":typeof ArrayBuffer>"u"?B:ArrayBuffer,"%ArrayIteratorPrototype%":sr&&_e?_e([][Symbol.iterator]()):B,"%AsyncFromSyncIteratorPrototype%":B,"%AsyncFunction%":ar,"%AsyncGenerator%":ar,"%AsyncGeneratorFunction%":ar,"%AsyncIteratorPrototype%":ar,"%Atomics%":typeof Atomics>"u"?B:Atomics,"%BigInt%":typeof BigInt>"u"?B:BigInt,"%BigInt64Array%":typeof BigInt64Array>"u"?B:BigInt64Array,"%BigUint64Array%":typeof BigUint64Array>"u"?B:BigUint64Array,"%Boolean%":Boolean,"%DataView%":typeof DataView>"u"?B:DataView,"%Date%":Date,"%decodeURI%":decodeURI,"%decodeURIComponent%":decodeURIComponent,"%encodeURI%":encodeURI,"%encodeURIComponent%":encodeURIComponent,"%Error%":zy,"%eval%":eval,"%EvalError%":Ly,"%Float16Array%":typeof Float16Array>"u"?B:Float16Array,"%Float32Array%":typeof Float32Array>"u"?B:Float32Array,"%Float64Array%":typeof Float64Array>"u"?B:Float64Array,"%FinalizationRegistry%":typeof FinalizationRegistry>"u"?B:FinalizationRegistry,"%Function%":xf,"%GeneratorFunction%":ar,"%Int8Array%":typeof Int8Array>"u"?B:Int8Array,"%Int16Array%":typeof Int16Array>"u"?B:Int16Array,"%Int32Array%":typeof Int32Array>"u"?B:Int32Array,"%isFinite%":isFinite,"%isNaN%":isNaN,"%IteratorPrototype%":sr&&_e?_e(_e([][Symbol.iterator]())):B,"%JSON%":typeof JSON=="object"?JSON:B,"%Map%":typeof Map>"u"?B:Map,"%MapIteratorPrototype%":typeof Map>"u"||!sr||!_e?B:_e(new Map()[Symbol.iterator]()),"%Math%":Math,"%Number%":Number,"%Object%":Oy,"%Object.getOwnPropertyDescriptor%":As,"%parseFloat%":parseFloat,"%parseInt%":parseInt,"%Promise%":typeof Promise>"u"?B:Promise,"%Proxy%":typeof Proxy>"u"?B:Proxy,"%RangeError%":My,"%ReferenceError%":Ny,"%Reflect%":typeof Reflect>"u"?B:Reflect,"%RegExp%":RegExp,"%Set%":typeof Set>"u"?B:Set,"%SetIteratorPrototype%":typeof Set>"u"||!sr||!_e?B:_e(new Set()[Symbol.iterator]()),"%SharedArrayBuffer%":typeof SharedArrayBuffer>"u"?B:SharedArrayBuffer,"%String%":String,"%StringIteratorPrototype%":sr&&_e?_e(""[Symbol.iterator]()):B,"%Symbol%":sr?Symbol:B,"%SyntaxError%":Rr,"%ThrowTypeError%":qy,"%TypedArray%":Jy,"%TypeError%":br,"%Uint8Array%":typeof Uint8Array>"u"?B:Uint8Array,"%Uint8ClampedArray%":typeof Uint8ClampedArray>"u"?B:Uint8ClampedArray,"%Uint16Array%":typeof Uint16Array>"u"?B:Uint16Array,"%Uint32Array%":typeof Uint32Array>"u"?B:Uint32Array,"%URIError%":Uy,"%WeakMap%":typeof WeakMap>"u"?B:WeakMap,"%WeakRef%":typeof WeakRef>"u"?B:WeakRef,"%WeakSet%":typeof WeakSet>"u"?B:WeakSet,"%Function.prototype.call%":li,"%Function.prototype.apply%":Tf,"%Object.defineProperty%":Hy,"%Object.getPrototypeOf%":Yy,"%Math.abs%":Fy,"%Math.floor%":Zy,"%Math.max%":jy,"%Math.min%":Wy,"%Math.pow%":By,"%Math.round%":Vy,"%Math.sign%":Gy,"%Reflect.getPrototypeOf%":Ky};if(_e)try{null.error}catch(t){var Xy=_e(_e(t));Zn["%Error.prototype%"]=Xy}var Qy=function t(e){var n;if(e==="%AsyncFunction%")n=va("async function () {}");else if(e==="%GeneratorFunction%")n=va("function* () {}");else if(e==="%AsyncGeneratorFunction%")n=va("async function* () {}");else if(e==="%AsyncGenerator%"){var r=t("%AsyncGeneratorFunction%");r&&(n=r.prototype)}else if(e==="%AsyncIteratorPrototype%"){var s=t("%AsyncGenerator%");s&&_e&&(n=_e(s.prototype))}return Zn[e]=n,n},Fu={__proto__:null,"%ArrayBufferPrototype%":["ArrayBuffer","prototype"],"%ArrayPrototype%":["Array","prototype"],"%ArrayProto_entries%":["Array","prototype","entries"],"%ArrayProto_forEach%":["Array","prototype","forEach"],"%ArrayProto_keys%":["Array","prototype","keys"],"%ArrayProto_values%":["Array","prototype","values"],"%AsyncFunctionPrototype%":["AsyncFunction","prototype"],"%AsyncGenerator%":["AsyncGeneratorFunction","prototype"],"%AsyncGeneratorPrototype%":["AsyncGeneratorFunction","prototype","prototype"],"%BooleanPrototype%":["Boolean","prototype"],"%DataViewPrototype%":["DataView","prototype"],"%DatePrototype%":["Date","prototype"],"%ErrorPrototype%":["Error","prototype"],"%EvalErrorPrototype%":["EvalError","prototype"],"%Float32ArrayPrototype%":["Float32Array","prototype"],"%Float64ArrayPrototype%":["Float64Array","prototype"],"%FunctionPrototype%":["Function","prototype"],"%Generator%":["GeneratorFunction","prototype"],"%GeneratorPrototype%":["GeneratorFunction","prototype","prototype"],"%Int8ArrayPrototype%":["Int8Array","prototype"],"%Int16ArrayPrototype%":["Int16Array","prototype"],"%Int32ArrayPrototype%":["Int32Array","prototype"],"%JSONParse%":["JSON","parse"],"%JSONStringify%":["JSON","stringify"],"%MapPrototype%":["Map","prototype"],"%NumberPrototype%":["Number","prototype"],"%ObjectPrototype%":["Object","prototype"],"%ObjProto_toString%":["Object","prototype","toString"],"%ObjProto_valueOf%":["Object","prototype","valueOf"],"%PromisePrototype%":["Promise","prototype"],"%PromiseProto_then%":["Promise","prototype","then"],"%Promise_all%":["Promise","all"],"%Promise_reject%":["Promise","reject"],"%Promise_resolve%":["Promise","resolve"],"%RangeErrorPrototype%":["RangeError","prototype"],"%ReferenceErrorPrototype%":["ReferenceError","prototype"],"%RegExpPrototype%":["RegExp","prototype"],"%SetPrototype%":["Set","prototype"],"%SharedArrayBufferPrototype%":["SharedArrayBuffer","prototype"],"%StringPrototype%":["String","prototype"],"%SymbolPrototype%":["Symbol","prototype"],"%SyntaxErrorPrototype%":["SyntaxError","prototype"],"%TypedArrayPrototype%":["TypedArray","prototype"],"%TypeErrorPrototype%":["TypeError","prototype"],"%Uint8ArrayPrototype%":["Uint8Array","prototype"],"%Uint8ClampedArrayPrototype%":["Uint8ClampedArray","prototype"],"%Uint16ArrayPrototype%":["Uint16Array","prototype"],"%Uint32ArrayPrototype%":["Uint32Array","prototype"],"%URIErrorPrototype%":["URIError","prototype"],"%WeakMapPrototype%":["WeakMap","prototype"],"%WeakSetPrototype%":["WeakSet","prototype"]},ci=ai,co=Wt,eb=ci.call(li,Array.prototype.concat),tb=ci.call(Tf,Array.prototype.splice),Zu=ci.call(li,String.prototype.replace),uo=ci.call(li,String.prototype.slice),nb=ci.call(li,RegExp.prototype.exec),rb=/[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g,sb=/\\(\\)?/g,ib=function(e){var n=uo(e,0,1),r=uo(e,-1);if(n==="%"&&r!=="%")throw new Rr("invalid intrinsic syntax, expected closing `%`");if(r==="%"&&n!=="%")throw new Rr("invalid intrinsic syntax, expected opening `%`");var s=[];return Zu(e,rb,function(i,o,a,l){s[s.length]=a?Zu(l,sb,"$1"):o||i}),s},ob=function(e,n){var r=e,s;if(co(Fu,r)&&(s=Fu[r],r="%"+s[0]+"%"),co(Zn,r)){var i=Zn[r];if(i===ar&&(i=Qy(r)),typeof i>"u"&&!n)throw new br("intrinsic "+e+" exists, but is not available. Please file an issue!");return{alias:s,name:r,value:i}}throw new Rr("intrinsic "+e+" does not exist!")},tt=function(e,n){if(typeof e!="string"||e.length===0)throw new br("intrinsic name must be a non-empty string");if(arguments.length>1&&typeof n!="boolean")throw new br('"allowMissing" argument must be a boolean');if(nb(/^%?[^%]*%?$/,e)===null)throw new Rr("`%` may not be present anywhere but at the beginning and end of the intrinsic name");var r=ib(e),s=r.length>0?r[0]:"",i=ob("%"+s+"%",n),o=i.name,a=i.value,l=!1,c=i.alias;c&&(s=c[0],tb(r,eb([0,1],c)));for(var d=1,f=!0;d<r.length;d+=1){var y=r[d],m=uo(y,0,1),E=uo(y,-1);if((m==='"'||m==="'"||m==="`"||E==='"'||E==="'"||E==="`")&&m!==E)throw new Rr("property names with quotes must have matching quotes");if((y==="constructor"||!f)&&(l=!0),s+="."+y,o="%"+s+"%",co(Zn,o))a=Zn[o];else if(a!=null){if(!(y in a)){if(!n)throw new br("base intrinsic for "+e+" exists, but the property is not available.");return}if(As&&d+1>=r.length){var k=As(a,y);f=!!k,f&&"get"in k&&!("originalValue"in k.get)?a=k.get:a=a[y]}else f=co(a,y),a=a[y];f&&!l&&(Zn[o]=a)}}return a},ba,ju;function hn(){if(ju)return ba;ju=1;var t=tt,e=Mo,n=e([t("%String.prototype.indexOf%")]);return ba=function(s,i){var o=t(s,!!i);return typeof o=="function"&&n(s,".prototype.")>-1?e([o]):o},ba}var wa,Wu;function rc(){if(Wu)return wa;Wu=1;var t=tt,e=t("%Array%"),n=!e.isArray&&hn()("Object.prototype.toString");return wa=e.isArray||function(s){return n(s)==="[object Array]"},wa}var ab=Lo,Bu=oi,Cf=ab.hasArrayLengthDefineBug(),lb=Cf&&rc(),cb=hn(),ub=cb("Object.prototype.propertyIsEnumerable"),sc=function(e,n,r,s,i,o){if(!Bu){if(!e(o)||!o["[[Configurable]]"]||!o["[[Writable]]"]||i in s&&ub(s,i)!==!!o["[[Enumerable]]"])return!1;var a=o["[[Value]]"];return s[i]=a,n(s[i],a)}return Cf&&i==="length"&&"[[Value]]"in o&&lb(s)&&s.length!==o["[[Value]]"]?(s.length=o["[[Value]]"],s.length===o["[[Value]]"]):(Bu(s,i,r(o)),!0)},hb=G,es=Wt,db={__proto__:null,"[[Configurable]]":!0,"[[Enumerable]]":!0,"[[Get]]":!0,"[[Set]]":!0,"[[Value]]":!0,"[[Writable]]":!0},Fr=function(e){if(!e||typeof e!="object")return!1;for(var n in e)if(es(e,n)&&!db[n])return!1;var r=es(e,"[[Value]]")||es(e,"[[Writable]]"),s=es(e,"[[Get]]")||es(e,"[[Set]]");if(r&&s)throw new hb("Property Descriptors may not be both accessor and data descriptors");return!0},If=function(e){if(typeof e>"u")return e;var n={};return"[[Value]]"in e&&(n.value=e["[[Value]]"]),"[[Writable]]"in e&&(n.writable=!!e["[[Writable]]"]),"[[Get]]"in e&&(n.get=e["[[Get]]"]),"[[Set]]"in e&&(n.set=e["[[Set]]"]),"[[Enumerable]]"in e&&(n.enumerable=!!e["[[Enumerable]]"]),"[[Configurable]]"in e&&(n.configurable=!!e["[[Configurable]]"]),n},fb=G,pb=Fr,gb=If,Pf=function(e){if(typeof e<"u"&&!pb(e))throw new fb("Assertion failed: `Desc` must be a Property Descriptor");return gb(e)},mb=G,Vu=Wt,vb=Fr,Rf=function(e){if(typeof e>"u")return!1;if(!vb(e))throw new mb("Assertion failed: `Desc` must be a Property Descriptor");return!(!Vu(e,"[[Value]]")&&!Vu(e,"[[Writable]]"))},Zr=function(e){return typeof e=="string"||typeof e=="symbol"},Gu=Ql,Df=function(e,n){return e===n?e===0?1/e===1/n:!0:Gu(e)&&Gu(n)},Hu=G,yb=jt,bb=sc,wb=Pf,_b=Rf,Sb=Zr,kb=Df,ic=function(e,n,r){if(!yb(e))throw new Hu("Assertion failed: Type(O) is not Object");if(!Sb(n))throw new Hu("Assertion failed: P is not a Property Key");var s={"[[Configurable]]":!0,"[[Enumerable]]":!1,"[[Value]]":r,"[[Writable]]":!0};return bb(_b,kb,wb,e,n,s)},Of=Function.prototype.toString,gr=typeof Reflect=="object"&&Reflect!==null&&Reflect.apply,rl,Xi;if(typeof gr=="function"&&typeof Object.defineProperty=="function")try{rl=Object.defineProperty({},"length",{get:function(){throw Xi}}),Xi={},gr(function(){throw 42},null,rl)}catch(t){t!==Xi&&(gr=null)}else gr=null;var Eb=/^\s*class\b/,sl=function(e){try{var n=Of.call(e);return Eb.test(n)}catch{return!1}},_a=function(e){try{return sl(e)?!1:(Of.call(e),!0)}catch{return!1}},Qi=Object.prototype.toString,$b="[object Object]",Ab="[object Function]",xb="[object GeneratorFunction]",Tb="[object HTMLAllCollection]",Cb="[object HTML document.all class]",Ib="[object HTMLCollection]",Pb=typeof Symbol=="function"&&!!Symbol.toStringTag,Rb=!(0 in[,]),il=function(){return!1};if(typeof document=="object"){var Db=document.all;Qi.call(Db)===Qi.call(document.all)&&(il=function(e){if((Rb||!e)&&(typeof e>"u"||typeof e=="object"))try{var n=Qi.call(e);return(n===Tb||n===Cb||n===Ib||n===$b)&&e("")==null}catch{}return!1})}var zf=gr?function(e){if(il(e))return!0;if(!e||typeof e!="function"&&typeof e!="object")return!1;try{gr(e,null,rl)}catch(n){if(n!==Xi)return!1}return!sl(e)&&_a(e)}:function(e){if(il(e))return!0;if(!e||typeof e!="function"&&typeof e!="object")return!1;if(Pb)return _a(e);if(sl(e))return!1;var n=Qi.call(e);return n!==Ab&&n!==xb&&!/^\[object HTML/.test(n)?!1:_a(e)},Ob=zf,zb=function(e){return!!e},ft=Wt,Ii=G,Lb=jt,qu=Ob,Sa=zb,Mb=function(e){if(!Lb(e))throw new Ii("ToPropertyDescriptor requires an object");var n={};if(ft(e,"enumerable")&&(n["[[Enumerable]]"]=Sa(e.enumerable)),ft(e,"configurable")&&(n["[[Configurable]]"]=Sa(e.configurable)),ft(e,"value")&&(n["[[Value]]"]=e.value),ft(e,"writable")&&(n["[[Writable]]"]=Sa(e.writable)),ft(e,"get")){var r=e.get;if(typeof r<"u"&&!qu(r))throw new Ii("getter must be a function");n["[[Get]]"]=r}if(ft(e,"set")){var s=e.set;if(typeof s<"u"&&!qu(s))throw new Ii("setter must be a function");n["[[Set]]"]=s}if((ft(n,"[[Get]]")||ft(n,"[[Set]]"))&&(ft(n,"[[Value]]")||ft(n,"[[Writable]]")))throw new Ii("Invalid property descriptor. Cannot both specify accessors and a value or writable attribute");return n},ka=G,Nb=jt,Yu=Fr,Ub=sc,Fb=Pf,Zb=Rf,jb=Zr,Wb=Df,Bb=Mb,Vb=function(e,n,r){if(!Nb(e))throw new ka("Assertion failed: Type(O) is not Object");if(!jb(n))throw new ka("Assertion failed: P is not a Property Key");var s=Yu(r)?r:Bb(r);if(!Yu(s))throw new ka("Assertion failed: Desc is not a valid Property Descriptor");return Ub(Zb,Wb,Fb,e,n,s)},Ku=G,Gb=jt,Hb=Vb,qb=Zr,Yb=function(e,n,r){if(!Gb(e))throw new Ku("Assertion failed: Type(O) is not Object");if(!qb(n))throw new Ku("Assertion failed: P is not a Property Key");var s={"[[Configurable]]":!0,"[[Enumerable]]":!1,"[[Value]]":r,"[[Writable]]":!0};return Hb(e,n,s)},Kb=typeof Reflect<"u"&&Reflect.setPrototypeOf||null,Jb=Jl,Xb=Jb.setPrototypeOf||null,Qb=Mo,Ju=Nr,ew=G,Lf={};try{Lf.__proto__=null}catch(t){if(!t||typeof t!="object"||!("code"in t)||t.code!=="ERR_PROTO_ACCESS")throw t}var tw=!("toString"in Lf),Ea=Ju&&Ju(Object.prototype,"__proto__"),nw=tw&&(!!Ea&&typeof Ea.set=="function"&&Qb([Ea.set])||function(e,n){if(e==null)throw new ew("set Object.prototype.__proto__ called on null or undefined");return e.__proto__=n,n}),Xu=Kb,rw=Xb,Qu=nw,sw=G,iw=Xu?function(e,n){if(Xu(e,n))return e;throw new sw("Reflect.setPrototypeOf: failed to set [[Prototype]]")}:rw||(Qu?function(e,n){return Qu(e,n),e}:null),eh=G,ow=jt,th=Af,aw=function(e){if(!ow(e))throw new eh("Assertion failed: O must be an Object");if(!th)throw new eh("This environment does not support fetching prototypes.");return th(e)},lw=G,cw=iw,uw=jt,hw=aw,dw=function(e,n){if(n!==null&&!uw(n))throw new lw("Assertion failed: V must be Object or Null");try{cw(e,n)}catch{return!1}return hw(e)===n},$a=ic,nh=Yb,Mf=dw,fw=Lo(),oc=wf;function ui(t,e,n){var r=new oc(n);return Mf(r,eo),delete r.constructor,nh(r,"error",t),nh(r,"suppressed",e),r}fw&&Object.defineProperty(ui,"prototype",{writable:!1});var eo=ui.prototype;if(!$a(eo,"constructor",ui)||!$a(eo,"message","")||!$a(eo,"name","SuppressedError"))throw new oc("unable to install SuppressedError.prototype properties; please report this!");Mf(ui.prototype,oc.prototype);var pw=ui,gw=pw,Nf=function(){return typeof SuppressedError=="function"?SuppressedError:gw},mw=Hn,rh=Kl(),vw=Nf,yw=function(){var e=vw();return mw(rh,{SuppressedError:e},{SuppressedError:function(){return rh.SuppressedError!==e}}),e};yw();var bw=G,ww=Fr,_w=If,Sw=function(e){if(typeof e<"u"&&!ww(e))throw new bw("Assertion failed: `Desc` must be a Property Descriptor");return _w(e)},kw=G,sh=Wt,Ew=Fr,$w=function(e){if(typeof e>"u")return!1;if(!Ew(e))throw new kw("Assertion failed: `Desc` must be a Property Descriptor");return!(!sh(e,"[[Value]]")&&!sh(e,"[[Writable]]"))},ih=Ql,Aw=function(e,n){return e===n?e===0?1/e===1/n:!0:ih(e)&&ih(n)},jr=zf,xw=function(e){return!!e},pt=Wt,Pi=G,Tw=jt,oh=jr,Aa=xw,Cw=function(e){if(!Tw(e))throw new Pi("ToPropertyDescriptor requires an object");var n={};if(pt(e,"enumerable")&&(n["[[Enumerable]]"]=Aa(e.enumerable)),pt(e,"configurable")&&(n["[[Configurable]]"]=Aa(e.configurable)),pt(e,"value")&&(n["[[Value]]"]=e.value),pt(e,"writable")&&(n["[[Writable]]"]=Aa(e.writable)),pt(e,"get")){var r=e.get;if(typeof r<"u"&&!oh(r))throw new Pi("getter must be a function");n["[[Get]]"]=r}if(pt(e,"set")){var s=e.set;if(typeof s<"u"&&!oh(s))throw new Pi("setter must be a function");n["[[Set]]"]=s}if((pt(n,"[[Get]]")||pt(n,"[[Set]]"))&&(pt(n,"[[Value]]")||pt(n,"[[Writable]]")))throw new Pi("Invalid property descriptor. Cannot both specify accessors and a value or writable attribute");return n},xa=G,Iw=jt,ah=Fr,Pw=sc,Rw=Sw,Dw=$w,Ow=Zr,zw=Aw,Lw=Cw,hi=function(e,n,r){if(!Iw(e))throw new xa("Assertion failed: Type(O) is not Object");if(!Ow(n))throw new xa("Assertion failed: P is not a Property Key");var s=ah(r)?r:Lw(r);if(!ah(s))throw new xa("Assertion failed: Desc is not a valid Property Descriptor");return Pw(Dw,zw,Rw,e,n,s)},Mw=Ur(),Nw=Mw?Symbol.dispose||Symbol("Symbol.dispose"):null,Uw=Ur,Fw=Nw,ac=function(){return Uw()&&Symbol.dispose||Fw},Zw=ec,jw=hi,Ww=ac,Bw=function(){var e=Ww();return Zw()&&jw(Symbol,"dispose",{"[[Configurable]]":!1,"[[Enumerable]]":!1,"[[Writable]]":!1,"[[Value]]":e}),e},Vw=Ur(),Gw=Vw?Symbol.asyncDispose||Symbol("Symbol.asyncDispose"):null,Hw=Ur,qw=Gw,lc=function(){return Hw()&&Symbol.asyncDispose||qw},Yw=ec,Kw=hi,Jw=lc,Xw=function(){var e=Jw();return Yw()&&Kw(Symbol,"asyncDispose",{"[[Configurable]]":!1,"[[Enumerable]]":!1,"[[Writable]]":!1,"[[Value]]":e}),e},Qw=rc(),e_=tt,t_=hn(),n_=G,r_=Qw,s_=e_("%Reflect.apply%",!0)||t_("Function.prototype.apply"),No=function(e,n){var r=arguments.length>2?arguments[2]:[];if(!r_(r))throw new n_("Assertion failed: optional `argumentsList`, if provided, must be a List");return s_(e,n,r)};const i_={},o_=Object.freeze(Object.defineProperty({__proto__:null,default:i_},Symbol.toStringTag,{value:"Module"})),a_=Pv(o_);var cc=typeof Map=="function"&&Map.prototype,Ta=Object.getOwnPropertyDescriptor&&cc?Object.getOwnPropertyDescriptor(Map.prototype,"size"):null,ho=cc&&Ta&&typeof Ta.get=="function"?Ta.get:null,lh=cc&&Map.prototype.forEach,uc=typeof Set=="function"&&Set.prototype,Ca=Object.getOwnPropertyDescriptor&&uc?Object.getOwnPropertyDescriptor(Set.prototype,"size"):null,fo=uc&&Ca&&typeof Ca.get=="function"?Ca.get:null,ch=uc&&Set.prototype.forEach,l_=typeof WeakMap=="function"&&WeakMap.prototype,_s=l_?WeakMap.prototype.has:null,c_=typeof WeakSet=="function"&&WeakSet.prototype,Ss=c_?WeakSet.prototype.has:null,u_=typeof WeakRef=="function"&&WeakRef.prototype,uh=u_?WeakRef.prototype.deref:null,h_=Boolean.prototype.valueOf,d_=Object.prototype.toString,f_=Function.prototype.toString,p_=String.prototype.match,hc=String.prototype.slice,tn=String.prototype.replace,g_=String.prototype.toUpperCase,hh=String.prototype.toLowerCase,Uf=RegExp.prototype.test,dh=Array.prototype.concat,_t=Array.prototype.join,m_=Array.prototype.slice,fh=Math.floor,ol=typeof BigInt=="function"?BigInt.prototype.valueOf:null,Ia=Object.getOwnPropertySymbols,al=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?Symbol.prototype.toString:null,Dr=typeof Symbol=="function"&&typeof Symbol.iterator=="object",ks=typeof Symbol=="function"&&Symbol.toStringTag&&(typeof Symbol.toStringTag===Dr||!0)?Symbol.toStringTag:null,Ff=Object.prototype.propertyIsEnumerable,ph=(typeof Reflect=="function"?Reflect.getPrototypeOf:Object.getPrototypeOf)||([].__proto__===Array.prototype?function(t){return t.__proto__}:null);function gh(t,e){if(t===1/0||t===-1/0||t!==t||t&&t>-1e3&&t<1e3||Uf.call(/e/,e))return e;var n=/[0-9](?=(?:[0-9]{3})+(?![0-9]))/g;if(typeof t=="number"){var r=t<0?-fh(-t):fh(t);if(r!==t){var s=String(r),i=hc.call(e,s.length+1);return tn.call(s,n,"$&_")+"."+tn.call(tn.call(i,/([0-9]{3})/g,"$&_"),/_$/,"")}}return tn.call(e,n,"$&_")}var ll=a_,mh=ll.custom,vh=Wf(mh)?mh:null,Zf={__proto__:null,double:'"',single:"'"},v_={__proto__:null,double:/(["\\])/g,single:/(['\\])/g},Wr=function t(e,n,r,s){var i=n||{};if(It(i,"quoteStyle")&&!It(Zf,i.quoteStyle))throw new TypeError('option "quoteStyle" must be "single" or "double"');if(It(i,"maxStringLength")&&(typeof i.maxStringLength=="number"?i.maxStringLength<0&&i.maxStringLength!==1/0:i.maxStringLength!==null))throw new TypeError('option "maxStringLength", if provided, must be a positive integer, Infinity, or `null`');var o=It(i,"customInspect")?i.customInspect:!0;if(typeof o!="boolean"&&o!=="symbol")throw new TypeError("option \"customInspect\", if provided, must be `true`, `false`, or `'symbol'`");if(It(i,"indent")&&i.indent!==null&&i.indent!==" "&&!(parseInt(i.indent,10)===i.indent&&i.indent>0))throw new TypeError('option "indent" must be "\\t", an integer > 0, or `null`');if(It(i,"numericSeparator")&&typeof i.numericSeparator!="boolean")throw new TypeError('option "numericSeparator", if provided, must be `true` or `false`');var a=i.numericSeparator;if(typeof e>"u")return"undefined";if(e===null)return"null";if(typeof e=="boolean")return e?"true":"false";if(typeof e=="string")return Vf(e,i);if(typeof e=="number"){if(e===0)return 1/0/e>0?"0":"-0";var l=String(e);return a?gh(e,l):l}if(typeof e=="bigint"){var c=String(e)+"n";return a?gh(e,c):c}var d=typeof i.depth>"u"?5:i.depth;if(typeof r>"u"&&(r=0),r>=d&&d>0&&typeof e=="object")return cl(e)?"[Array]":"[Object]";var f=z_(i,r);if(typeof s>"u")s=[];else if(Bf(s,e)>=0)return"[Circular]";function y(ut,Bt,ta){if(Bt&&(s=m_.call(s),s.push(Bt)),ta){var _i={depth:i.depth};return It(i,"quoteStyle")&&(_i.quoteStyle=i.quoteStyle),t(ut,_i,r+1,s)}return t(ut,i,r+1,s)}if(typeof e=="function"&&!yh(e)){var m=A_(e),E=Ri(e,y);return"[Function"+(m?": "+m:" (anonymous)")+"]"+(E.length>0?" { "+_t.call(E,", ")+" }":"")}if(Wf(e)){var k=Dr?tn.call(String(e),/^(Symbol\(.*\))_[^)]*$/,"$1"):al.call(e);return typeof e=="object"&&!Dr?ts(k):k}if(R_(e)){for(var I="<"+hh.call(String(e.nodeName)),V=e.attributes||[],N=0;N<V.length;N++)I+=" "+V[N].name+"="+jf(y_(V[N].value),"double",i);return I+=">",e.childNodes&&e.childNodes.length&&(I+="..."),I+="</"+hh.call(String(e.nodeName))+">",I}if(cl(e)){if(e.length===0)return"[]";var j=Ri(e,y);return f&&!O_(j)?"["+ul(j,f)+"]":"[ "+_t.call(j,", ")+" ]"}if(w_(e)){var F=Ri(e,y);return!("cause"in Error.prototype)&&"cause"in e&&!Ff.call(e,"cause")?"{ ["+String(e)+"] "+_t.call(dh.call("[cause]: "+y(e.cause),F),", ")+" }":F.length===0?"["+String(e)+"]":"{ ["+String(e)+"] "+_t.call(F,", ")+" }"}if(typeof e=="object"&&o){if(vh&&typeof e[vh]=="function"&&ll)return ll(e,{depth:d-r});if(o!=="symbol"&&typeof e.inspect=="function")return e.inspect()}if(x_(e)){var L=[];return lh&&lh.call(e,function(ut,Bt){L.push(y(Bt,e,!0)+" => "+y(ut,e))}),bh("Map",ho.call(e),L,f)}if(I_(e)){var J=[];return ch&&ch.call(e,function(ut){J.push(y(ut,e))}),bh("Set",fo.call(e),J,f)}if(T_(e))return Pa("WeakMap");if(P_(e))return Pa("WeakSet");if(C_(e))return Pa("WeakRef");if(S_(e))return ts(y(Number(e)));if(E_(e))return ts(y(ol.call(e)));if(k_(e))return ts(h_.call(e));if(__(e))return ts(y(String(e)));if(typeof window<"u"&&e===window)return"{ [object Window] }";if(typeof globalThis<"u"&&e===globalThis||typeof Sn<"u"&&e===Sn)return"{ [object globalThis] }";if(!b_(e)&&!yh(e)){var H=Ri(e,y),he=ph?ph(e)===Object.prototype:e instanceof Object||e.constructor===Object,ct=e instanceof Object?"":"null prototype",wi=!he&&ks&&Object(e)===e&&ks in e?hc.call(dn(e),8,-1):ct?"Object":"",Ee=he||typeof e.constructor!="function"?"":e.constructor.name?e.constructor.name+" ":"",gn=Ee+(wi||ct?"["+_t.call(dh.call([],wi||[],ct||[]),": ")+"] ":"");return H.length===0?gn+"{}":f?gn+"{"+ul(H,f)+"}":gn+"{ "+_t.call(H,", ")+" }"}return String(e)};function jf(t,e,n){var r=n.quoteStyle||e,s=Zf[r];return s+t+s}function y_(t){return tn.call(String(t),/"/g,""")}function qn(t){return!ks||!(typeof t=="object"&&(ks in t||typeof t[ks]<"u"))}function cl(t){return dn(t)==="[object Array]"&&qn(t)}function b_(t){return dn(t)==="[object Date]"&&qn(t)}function yh(t){return dn(t)==="[object RegExp]"&&qn(t)}function w_(t){return dn(t)==="[object Error]"&&qn(t)}function __(t){return dn(t)==="[object String]"&&qn(t)}function S_(t){return dn(t)==="[object Number]"&&qn(t)}function k_(t){return dn(t)==="[object Boolean]"&&qn(t)}function Wf(t){if(Dr)return t&&typeof t=="object"&&t instanceof Symbol;if(typeof t=="symbol")return!0;if(!t||typeof t!="object"||!al)return!1;try{return al.call(t),!0}catch{}return!1}function E_(t){if(!t||typeof t!="object"||!ol)return!1;try{return ol.call(t),!0}catch{}return!1}var $_=Object.prototype.hasOwnProperty||function(t){return t in this};function It(t,e){return $_.call(t,e)}function dn(t){return d_.call(t)}function A_(t){if(t.name)return t.name;var e=p_.call(f_.call(t),/^function\s*([\w$]+)/);return e?e[1]:null}function Bf(t,e){if(t.indexOf)return t.indexOf(e);for(var n=0,r=t.length;n<r;n++)if(t[n]===e)return n;return-1}function x_(t){if(!ho||!t||typeof t!="object")return!1;try{ho.call(t);try{fo.call(t)}catch{return!0}return t instanceof Map}catch{}return!1}function T_(t){if(!_s||!t||typeof t!="object")return!1;try{_s.call(t,_s);try{Ss.call(t,Ss)}catch{return!0}return t instanceof WeakMap}catch{}return!1}function C_(t){if(!uh||!t||typeof t!="object")return!1;try{return uh.call(t),!0}catch{}return!1}function I_(t){if(!fo||!t||typeof t!="object")return!1;try{fo.call(t);try{ho.call(t)}catch{return!0}return t instanceof Set}catch{}return!1}function P_(t){if(!Ss||!t||typeof t!="object")return!1;try{Ss.call(t,Ss);try{_s.call(t,_s)}catch{return!0}return t instanceof WeakSet}catch{}return!1}function R_(t){return!t||typeof t!="object"?!1:typeof HTMLElement<"u"&&t instanceof HTMLElement?!0:typeof t.nodeName=="string"&&typeof t.getAttribute=="function"}function Vf(t,e){if(t.length>e.maxStringLength){var n=t.length-e.maxStringLength,r="... "+n+" more character"+(n>1?"s":"");return Vf(hc.call(t,0,e.maxStringLength),e)+r}var s=v_[e.quoteStyle||"single"];s.lastIndex=0;var i=tn.call(tn.call(t,s,"\\$1"),/[\x00-\x1f]/g,D_);return jf(i,"single",e)}function D_(t){var e=t.charCodeAt(0),n={8:"b",9:"t",10:"n",12:"f",13:"r"}[e];return n?"\\"+n:"\\x"+(e<16?"0":"")+g_.call(e.toString(16))}function ts(t){return"Object("+t+")"}function Pa(t){return t+" { ? }"}function bh(t,e,n,r){var s=r?ul(n,r):_t.call(n,", ");return t+" ("+e+") {"+s+"}"}function O_(t){for(var e=0;e<t.length;e++)if(Bf(t[e],`
|
|
2
|
-
`)>=0)return!1;return!0}function z_(t,e){var n;if(t.indent===" ")n=" ";else if(typeof t.indent=="number"&&t.indent>0)n=_t.call(Array(t.indent+1)," ");else return null;return{base:n,prev:_t.call(Array(e+1),n)}}function ul(t,e){if(t.length===0)return"";var n=`
|
|
3
|
-
`+e.prev+e.base;return n+_t.call(t,","+n)+`
|
|
4
|
-
`+e.prev}function Ri(t,e){var n=cl(t),r=[];if(n){r.length=t.length;for(var s=0;s<t.length;s++)r[s]=It(t,s)?e(t[s],t):""}var i=typeof Ia=="function"?Ia(t):[],o;if(Dr){o={};for(var a=0;a<i.length;a++)o["$"+i[a]]=i[a]}for(var l in t)It(t,l)&&(n&&String(Number(l))===l&&l<t.length||Dr&&o["$"+l]instanceof Symbol||(Uf.call(/[^\w$]/,l)?r.push(e(l,t)+": "+e(t[l],t)):r.push(l+": "+e(t[l],t))));if(typeof Ia=="function")for(var c=0;c<i.length;c++)Ff.call(t,i[c])&&r.push("["+e(i[c])+"]: "+e(t[i[c]],t));return r}var L_=Wr,M_=G,Uo=function(t,e,n){for(var r=t,s;(s=r.next)!=null;r=s)if(s.key===e)return r.next=s.next,n||(s.next=t.next,t.next=s),s},N_=function(t,e){if(t){var n=Uo(t,e);return n&&n.value}},U_=function(t,e,n){var r=Uo(t,e);r?r.value=n:t.next={key:e,next:t.next,value:n}},F_=function(t,e){return t?!!Uo(t,e):!1},Z_=function(t,e){if(t)return Uo(t,e,!0)},j_=function(){var e,n={assert:function(r){if(!n.has(r))throw new M_("Side channel does not contain "+L_(r))},delete:function(r){var s=e&&e.next,i=Z_(e,r);return i&&s&&s===i&&(e=void 0),!!i},get:function(r){return N_(e,r)},has:function(r){return F_(e,r)},set:function(r,s){e||(e={next:void 0}),U_(e,r,s)}};return n},W_=tt,di=hn(),B_=Wr,V_=G,wh=W_("%Map%",!0),G_=di("Map.prototype.get",!0),H_=di("Map.prototype.set",!0),q_=di("Map.prototype.has",!0),Y_=di("Map.prototype.delete",!0),K_=di("Map.prototype.size",!0),Gf=!!wh&&function(){var e,n={assert:function(r){if(!n.has(r))throw new V_("Side channel does not contain "+B_(r))},delete:function(r){if(e){var s=Y_(e,r);return K_(e)===0&&(e=void 0),s}return!1},get:function(r){if(e)return G_(e,r)},has:function(r){return e?q_(e,r):!1},set:function(r,s){e||(e=new wh),H_(e,r,s)}};return n},J_=tt,Fo=hn(),X_=Wr,Di=Gf,Q_=G,ir=J_("%WeakMap%",!0),eS=Fo("WeakMap.prototype.get",!0),tS=Fo("WeakMap.prototype.set",!0),nS=Fo("WeakMap.prototype.has",!0),rS=Fo("WeakMap.prototype.delete",!0),sS=ir?function(){var e,n,r={assert:function(s){if(!r.has(s))throw new Q_("Side channel does not contain "+X_(s))},delete:function(s){if(ir&&s&&(typeof s=="object"||typeof s=="function")){if(e)return rS(e,s)}else if(Di&&n)return n.delete(s);return!1},get:function(s){return ir&&s&&(typeof s=="object"||typeof s=="function")&&e?eS(e,s):n&&n.get(s)},has:function(s){return ir&&s&&(typeof s=="object"||typeof s=="function")&&e?nS(e,s):!!n&&n.has(s)},set:function(s,i){ir&&s&&(typeof s=="object"||typeof s=="function")?(e||(e=new ir),tS(e,s,i)):Di&&(n||(n=Di()),n.set(s,i))}};return r}:Di,iS=G,oS=Wr,aS=j_,lS=Gf,cS=sS,uS=cS||lS||aS,hS=function(){var e,n={assert:function(r){if(!n.has(r))throw new iS("Side channel does not contain "+oS(r))},delete:function(r){return!!e&&e.delete(r)},get:function(r){return e&&e.get(r)},has:function(r){return!!e&&e.has(r)},set:function(r,s){e||(e=uS()),e.set(r,s)}};return n},dS=Wt,ns=hS(),xt=G,dc={assert:function(t,e){if(!t||typeof t!="object"&&typeof t!="function")throw new xt("`O` is not an object");if(typeof e!="string")throw new xt("`slot` must be a string");if(ns.assert(t),!dc.has(t,e))throw new xt("`"+e+"` is not present on `O`")},get:function(t,e){if(!t||typeof t!="object"&&typeof t!="function")throw new xt("`O` is not an object");if(typeof e!="string")throw new xt("`slot` must be a string");var n=ns.get(t);return n&&n["$"+e]},has:function(t,e){if(!t||typeof t!="object"&&typeof t!="function")throw new xt("`O` is not an object");if(typeof e!="string")throw new xt("`slot` must be a string");var n=ns.get(t);return!!n&&dS(n,"$"+e)},set:function(t,e,n){if(!t||typeof t!="object"&&typeof t!="function")throw new xt("`O` is not an object");if(typeof e!="string")throw new xt("`slot` must be a string");var r=ns.get(t);r||(r={},ns.set(t,r)),r["$"+e]=n}};Object.freeze&&Object.freeze(dc);var fc=dc,Hf=Zt,sn=fc,fi=function t(e,n){if(!(this instanceof t))return new t(e,n);if(e!=="normal"&&e!=="break"&&e!=="continue"&&e!=="return"&&e!=="throw")throw new Hf('Assertion failed: `type` must be one of "normal", "break", "continue", "return", or "throw"');sn.set(this,"[[Type]]",e),sn.set(this,"[[Value]]",n)};fi.prototype.type=function(){return sn.get(this,"[[Type]]")};fi.prototype.value=function(){return sn.get(this,"[[Value]]")};fi.prototype["?"]=function(){var e=sn.get(this,"[[Type]]"),n=sn.get(this,"[[Value]]");if(e==="throw")throw n;return n};fi.prototype["!"]=function(){var e=sn.get(this,"[[Type]]");if(e!=="normal")throw new Hf('Assertion failed: Completion Record is not of type "normal"');return sn.get(this,"[[Value]]")};var pc=fi,fS=pc,gc=function(e){return new fS("normal",e)},Ra,_h;function pS(){if(_h)return Ra;_h=1;var t=Ur;return Ra=function(){return t()&&!!Symbol.toStringTag},Ra}var gS=tt,Sh=gS("%Object.defineProperty%",!0),mS=pS()(),vS=Wt,yS=G,Oi=mS?Symbol.toStringTag:null,qf=function(e,n){var r=arguments.length>2&&!!arguments[2]&&arguments[2].force,s=arguments.length>2&&!!arguments[2]&&arguments[2].nonConfigurable;if(typeof r<"u"&&typeof r!="boolean"||typeof s<"u"&&typeof s!="boolean")throw new yS("if provided, the `overrideIfSet` and `nonConfigurable` options must be booleans");Oi&&(r||!vS(e,Oi))&&(Sh?Sh(e,Oi,{configurable:!s,enumerable:!1,value:n,writable:!1}):e[Oi]=n)},Yf={exports:{}},bS=tt,kh=df,wS=Lo(),Eh=Nr,$h=G,_S=bS("%Math.floor%"),SS=function(e,n){if(typeof e!="function")throw new $h("`fn` is not a function");if(typeof n!="number"||n<0||n>4294967295||_S(n)!==n)throw new $h("`length` must be a positive 32-bit integer");var r=arguments.length>2&&!!arguments[2],s=!0,i=!0;if("length"in e&&Eh){var o=Eh(e,"length");o&&!o.configurable&&(s=!1),o&&!o.writable&&(i=!1)}return(s||i||!r)&&(wS?kh(e,"length",n,!0,!0):kh(e,"length",n)),e},kS=ai,ES=nc(),$S=kf,AS=function(){return $S(kS,ES,arguments)};(function(t){var e=SS,n=oi,r=Mo,s=AS;t.exports=function(o){var a=r(arguments),l=1+o.length-(arguments.length-1);return e(a,l>0?l:0,!0)},n?n(t.exports,"apply",{value:s}):t.exports.apply=s})(Yf);var mc=Yf.exports,xS=function(e,n){for(var r=0;r<e.length;r+=1)if(!n(e[r],r,e))return!1;return!0},TS=Object,CS=function(e){return e&&typeof e=="object"&&(typeof e["[[ResourceValue]]"]>"u"||TS(e["[[ResourceValue]]"])===e["[[ResourceValue]]"])&&(e["[[Hint]]"]==="SYNC-DISPOSE"||e["[[Hint]]"]==="ASYNC-DISPOSE")&&(typeof e["[[DisposeMethod]]"]=="function"||typeof e["[[DisposeMethod]]"]>"u")},IS=Wt,PS=rc(),RS=xS,DS=CS,OS=function(e){return e&&typeof e=="object"&&IS(e,"[[DisposableResourceStack]]")&&PS(e["[[DisposableResourceStack]]"])&&(e["[[DisposableResourceStack]]"].length===0||RS(e["[[DisposableResourceStack]]"],DS))},zS=jt,LS=function(e){if(e===null)return"Null";if(typeof e>"u")return"Undefined";if(zS(e))return"Object";if(typeof e=="number")return"Number";if(typeof e=="boolean")return"Boolean";if(typeof e=="string")return"String"},MS=LS,vc=function(e){return typeof e=="symbol"?"Symbol":typeof e=="bigint"?"BigInt":MS(e)},NS=G,US=Wr,FS=Zr,ZS=function(e,n){if(!FS(n))throw new NS("Assertion failed: P is not a Property Key, got "+US(n));return e[n]},Ah=G,jS=ZS,WS=jr,BS=Zr,xh=Wr,VS=function(e,n){if(!BS(n))throw new Ah("Assertion failed: P is not a Property Key");var r=jS(e,n);if(r!=null){if(!WS(r))throw new Ah(xh(n)+" is not a function: "+xh(r));return r}},hl={exports:{}},GS=tt,HS=GS,Th=HS("%Reflect.construct%",!0),po=hi;try{po({},"",{"[[Get]]":function(){}})}catch{po=null}if(po&&Th){var Ch={},Ih={};po(Ih,"length",{"[[Get]]":function(){throw Ch},"[[Enumerable]]":!0}),hl.exports=function(e){try{Th(e,Ih)}catch(n){return n===Ch}}}else hl.exports=function(e){return typeof e=="function"&&!!e.prototype};var qS=hl.exports,Da=G,Ph=jr,YS=qS,KS=function(e){if(!YS(e))throw new Da("C must be a constructor");var n={"[[Resolve]]":void 0,"[[Reject]]":void 0},r=new e(function(s,i){if(typeof n["[[Resolve]]"]<"u"||typeof n["[[Reject]]"]<"u")throw new Da("executor has already been called");n["[[Resolve]]"]=s,n["[[Reject]]"]=i});if(!Ph(n["[[Resolve]]"])||!Ph(n["[[Reject]]"]))throw new Da("executor must provide valid resolve and reject functions");return{"[[Promise]]":r,"[[Resolve]]":n["[[Resolve]]"],"[[Reject]]":n["[[Reject]]"]}},Rh=Zt,JS=G,Oa=No,Dh=VS,XS=KS,QS=vc,Oh=ac(),zh=lc(),ek=function(e,n){if(QS(e)!=="Object")throw new JS("`V` must be an Object");if(n!=="SYNC-DISPOSE"&&n!=="ASYNC-DISPOSE")throw new Rh("Assertion failed: `hint` must be `~SYNC-DISPOSE~` or `~ASYNC-DISPOSE~`");var r;if(n==="ASYNC-DISPOSE"&&zh&&(r=Dh(e,zh)),!r){if(!Oh)throw new Rh("`Symbol.dispose` is not supported");if(r=Dh(e,Oh),typeof r<"u")return function(){var s=this;if(n==="ASYNC-DISPOSE"){var i=XS(Promise);try{Oa(r,s),Oa(i["[[Resolve]]"],void 0,[void 0])}catch(o){i["[[Reject]]"](o)}return i["[[Promise]]"]}Oa(r,s)}}return r},tk=Zt,za=G,nk=jr,rk=vc,sk=ek,ik=function(e,n){if(n!=="SYNC-DISPOSE"&&n!=="ASYNC-DISPOSE")throw new tk("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"&&rk(e)!=="Object")throw new za("`V` must be an Object, or `null` or `undefined`");if(r=sk(e,n),typeof r>"u")throw new za("dispose method must not be `undefined` on `V` when an object `V` is provided")}else if(r=arguments[2],!nk(r))throw new za("`method`, when provided, must be a function");return{"[[ResourceValue]]":e,"[[Hint]]":n,"[[DisposeMethod]]":r}},ok=Zt,zi=G,ak=OS,Lh=ik,lk=hn(),ck=lk("Array.prototype.push"),Kf=function(e,n,r){if(!ak(e))throw new zi("Assertion failed: `disposeCapability` must be a DisposeCapability Record");if(r!=="SYNC-DISPOSE"&&r!=="ASYNC-DISPOSE")throw new ok("Assertion failed: `hint` must be `~SYNC-DISPOSE~` or `~ASYNC-DISPOSE~`");var s=arguments.length>3?arguments[3]:void 0;if(arguments.length>3&&typeof s!="function")throw new zi("Assertion failed: `method`, when present, must be a function");if(!e["[[DisposableResourceStack]]"])throw new zi("Assertion failed: `disposeCapability.[[DisposableResourceStack]]` must not be ~EMPTY~");var i;if(arguments.length<4){if(n==null&&r==="SYNC_DISPOSE")return"UNUSED";i=Lh(n,r)}else{if(typeof n<"u")throw new zi("Assertion failed: `V` must be undefined when `method` is present");i=Lh(void 0,r,s)}return ck(e["[[DisposableResourceStack]]"],i),"UNUSED"},La,Mh;function yc(){if(Mh)return La;Mh=1;var t=tt,e=mc,n=Zt,r=t("%Promise.resolve%",!0),s=r&&e(r);return La=function(o,a){if(!s)throw new n("This environment does not support Promises.");return s(o,a)},La}var Ma,Nh;function uk(){if(Nh)return Ma;Nh=1;var t=tt,e=Zt,n=t("%Promise%",!0),r=No,s=yc(),i=vc;return Ma=function(a,l,c){if(typeof a<"u"&&i(a)!=="Object")throw new e("Assertion failed: `V` must be `undefined` or an Object");if(l!=="SYNC-DISPOSE"&&l!=="ASYNC-DISPOSE")throw new e("Assertion failed: `hint` must be `~SYNC-DISPOSE~` or `~ASYNC-DISPOSE~`");if(typeof c<"u"&&typeof c!="function")throw new e("Assertion failed: `method` must be `undefined` or a function");var d=typeof c>"u"?c:r(c,a);if(l==="ASYNC-DISPOSE")return s(n,d)},Ma}var Na,Uh;function hk(){if(Uh)return Na;Uh=1;var t=pc;return Na=function(n){return new t("throw",n)},Na}var dk=tt,Ua=Zt,Fh=G,fk=dk("%Promise%",!0),pk=hn(),Zh=pk("Promise.prototype.then",!0),gk=pc,jh=uk(),mk=gc,vk=yc(),Wh=hk(),yk=Nf(),Jf=function(e,n){if(!(n instanceof gk))throw new Fh("`completion` must be a Completion Record");var r=e["[[DisposableResourceStack]]"];if(!r)throw new Fh("Assertion failed: `disposeCapability.[[DisposableResourceStack]]` must not be ~EMPTY~");for(var s,i=r.length-1;i>=0;i-=1)if(!s)s=r[i]["[[Hint]]"];else if(s!==r[i]["[[Hint]]"])throw new Ua("mixed hint stacks are not supported");for(var o=s==="ASYNC-DISPOSE"&&vk(fk,n),a=function(y){if(n.type()==="throw"){var m=n.value(),E=new yk(y,m);n=Wh(E)}else n=Wh(y)},l=s==="ASYNC-DISPOSE"&&function(m){return Zh(o,function(){var E=jh(m["[[ResourceValue]]"],m["[[Hint]]"],m["[[DisposeMethod]]"]);if(!E)throw new Ua("Assertion failed: non-`~ASYNC-DISPOSE~` resource returned a promise from Dispose");return Zh(E,mk)},a)},c=r.length-1;c>=0;c-=1)if(s==="ASYNC-DISPOSE")o=l(r[c]);else{var d=r[c];try{var f=jh(d["[[ResourceValue]]"],d["[[Hint]]"],d["[[DisposeMethod]]"]);if(f)throw new Ua("Assertion failed: `~SYNC-DISPOSE~` resource returned something from Dispose")}catch(y){a(y)}}return e["[[DisposableResourceStack]]"]=null,s==="ASYNC-DISPOSE"?o:n},Xf=function(){var e=[];return{"[[DisposableResourceStack]]":e}},Zo=Xl,bc=G,bk=No,Br=ic,wk=hi,Qf=jr,_k=gc,je=fc,Sk=qf,ep=Hn.supportsDescriptors,kk=mc,wc=Kf,Ek=Jf,tp=Xf,Bh=ac(),Xe=function t(){if(!(this instanceof t)||je.has(this,"[[DisposableState]]")||je.has(this,"[[DisposeCapability]]"))throw new bc("can only be used with new");je.set(this,"[[DisposableState]]","PENDING"),je.set(this,"[[DisposeCapability]]",tp())},np=function(){var e=this;return je.assert(e,"[[DisposableState]]"),je.get(e,"[[DisposableState]]")==="DISPOSED"},pi=kk(np);ep?wk(Xe.prototype,"disposed",{"[[Configurable]]":!0,"[[Enumerable]]":!1,"[[Get]]":np}):Xe.prototype.disposed=!1;var rp=function(e){je.set(e,"[[DisposableState]]","DISPOSED"),ep||(e.disposed=!0)};Br(Xe.prototype,"dispose",function(){var e=this;if(!pi(e))return rp(e),Ek(je.get(e,"[[DisposeCapability]]"),_k())["?"]()});Br(Xe.prototype,"use",function(e){var n=this;if(pi(n))throw new Zo("a disposed stack can not use anything new");return wc(je.get(n,"[[DisposeCapability]]"),e,"SYNC-DISPOSE"),e});Br(Xe.prototype,"adopt",function(e,n){var r=this;if(pi(r))throw new Zo("a disposed stack can not use anything new");if(!Qf(n))throw new bc("`onDispose` must be a function");var s=function(){return bk(n,void 0,[e])};return wc(je.get(r,"[[DisposeCapability]]"),void 0,"SYNC-DISPOSE",s),e});Br(Xe.prototype,"defer",function(e){var n=this;if(pi(n))throw new Zo("a disposed stack can not defer anything new");if(!Qf(e))throw new bc("`onDispose` must be a function");wc(je.get(n,"[[DisposeCapability]]"),void 0,"SYNC-DISPOSE",e)});Br(Xe.prototype,"move",function(){var e=this;if(pi(e))throw new Zo("a disposed stack can not use anything new");var n=new Xe;return je.set(n,"[[DisposeCapability]]",je.get(e,"[[DisposeCapability]]")),je.set(e,"[[DisposeCapability]]",tp()),rp(e),n});Bh&&Br(Xe.prototype,Bh,Xe.prototype.dispose);Sk(Xe.prototype,"DisposableStack");var $k=Xe,Ak=$k,xk=function(){return typeof DisposableStack=="function"?DisposableStack:Ak},Tk=Hn,Ck=Kl(),Ik=xk,Pk=function(){var e=Ik();return Tk(Ck,{DisposableStack:e},{DisposableStack:!0}),e},Rk=tt,jo=Xl,_c=G,Vh=Rk("%Promise%",!0),Sc=Kf,Dk=No,Vr=ic,Ok=hi,zk=Jf,sp=jr,ip=Xf,Lk=gc,Gh=yc(),We=fc,Mk=qf,op=Hn.supportsDescriptors,Nk=mc,Uk=hn(),Fk=Uk("Promise.prototype.then",!0),Hh=lc(),Qe=function t(){if(!(this instanceof t)||We.has(this,"[[AsyncDisposableState]]")||We.has(this,"[[DisposeCapability]]"))throw new _c("can only be used with new");We.set(this,"[[AsyncDisposableState]]","pending"),We.set(this,"[[DisposeCapability]]",ip())},ap=function(){var e=this;return We.assert(e,"[[AsyncDisposableState]]"),We.get(e,"[[AsyncDisposableState]]")==="disposed"},gi=Nk(ap);op?Ok(Qe.prototype,"disposed",{"[[Configurable]]":!0,"[[Enumerable]]":!1,"[[Get]]":ap}):Qe.prototype.disposed=!1;var lp=function(e){We.set(e,"[[AsyncDisposableState]]","disposed"),op||(e.disposed=!0)};Vr(Qe.prototype,"disposeAsync",function(){var e=this;return gi(e)?Gh(Vh):(lp(e),Fk(Gh(Vh,zk(We.get(e,"[[DisposeCapability]]"),Lk())),function(n){return n["?"]()}))});Vr(Qe.prototype,"use",function(e){var n=this;if(gi(n))throw new jo("a disposed stack can not use anything new");return Sc(We.get(n,"[[DisposeCapability]]"),e,"ASYNC-DISPOSE"),e});Vr(Qe.prototype,"adopt",function(e,n){var r=this;if(gi(r))throw new jo("a disposed stack can not use anything new");if(!sp(n))throw new _c("`onDisposeAsync` must be a function");var s=function(){return Dk(n,void 0,[e])};return s.value=e,Sc(We.get(r,"[[DisposeCapability]]"),void 0,"ASYNC-DISPOSE",s),e});Vr(Qe.prototype,"defer",function(e){var n=this;if(gi(n))throw new jo("a disposed stack can not defer anything new");if(!sp(e))throw new _c("`onDispose` must be a function");Sc(We.get(n,"[[DisposeCapability]]"),void 0,"ASYNC-DISPOSE",e)});Vr(Qe.prototype,"move",function(){var e=this;if(gi(e))throw new jo("a disposed stack can not use anything new");var n=new Qe;return We.set(n,"[[DisposeCapability]]",We.get(e,"[[DisposeCapability]]")),We.set(e,"[[DisposeCapability]]",ip()),lp(e),n});Hh&&Vr(Qe.prototype,Hh,Qe.prototype.disposeAsync);Mk(Qe.prototype,"AsyncDisposableStack");var Zk=Qe,jk=Zk,Wk=function(){return typeof AsyncDisposableStack=="function"?AsyncDisposableStack:jk},Bk=Hn,Vk=Kl(),Gk=Wk,Hk=function(){var e=Gk();return Bk(Vk,{AsyncDisposableStack:e},{AsyncDisposableStack:!0}),e},qk=Bw,Yk=Xw,Kk=Pk,Jk=Hk,Xk=function(){qk(),Yk(),Kk(),Jk()};Xk();const qh=new WeakMap;function Qk(t){return(typeof t=="object"||typeof t=="function")&&t!==null&&"then"in t&&typeof t.then=="function"}function or(t){return typeof t=="string"?t:typeof t=="symbol"?t.description??t.toString():t.name||"(anonymous class)"}function Yh(){return new Error("register(Key, factory) requires a factory function. Wrap existing instances as () => instance.")}function eE(){return new Error("register(Key, factory) does not accept async factories. Await setup before registering.")}class tE{constructor(){v(this,"entries",new Map);v(this,"constructionStack",[])}register(e,n){if(n===void 0){if(typeof e!="function")throw Yh();this.validateClassRegistration(e),this.storeFactory(e,()=>this.instantiateClass(e));return}if(typeof n!="function")throw Yh();if(n.constructor.name==="AsyncFunction")throw eE();this.storeFactory(e,n)}has(e){var n;return((n=this.entries.get(e))==null?void 0:n.factory)!==void 0}resolve(e){return this.resolveAny(e)}storeFactory(e,n){const r=this.getOrCreateEntry(e);r.factory=n,r.instance=void 0,r.error=void 0}validateClassRegistration(e){const n=qh.get(e);if(n){if(e.length!==n.length)throw new Error(`${or(e)} cannot be registered with register(Class). @injectable(...) declared ${n.length} dependencies but constructor arity is ${e.length}. Use register(Key, () => value) instead.`);return}if(e.length!==0)throw new Error(`${or(e)} cannot be registered with register(Class). Undecorated classes must have zero required constructor parameters. Use register(Key, () => value) instead.`)}instantiateClass(e){const n=qh.get(e);if(!n)return new e;const r=n.map(s=>this.resolveAny(s));return new e(...r)}resolveAny(e){return this.getOrCreateEntry(e).proxy}getOrCreateEntry(e){let n=this.entries.get(e);return n||(n={key:e},n.proxy=this.createProxy(n),this.entries.set(e,n),n)}createProxy(e){return new Proxy({},{get:(n,r)=>{if(r==="then")return;const s=this.getInstance(e),i=Reflect.get(s,r,s);return typeof i=="function"?i.bind(s):i},set:(n,r,s)=>{const i=this.getInstance(e);return Reflect.set(i,r,s,i)},has:(n,r)=>{const s=this.getInstance(e);return r in s}})}getInstance(e){if(e.instance)return e.instance;if(e.error)throw e.error;if(!e.factory)throw new Error(`${or(e.key)} was resolved but never registered`);const n=this.constructionStack.indexOf(e.key);if(n!==-1){const r=[...this.constructionStack.slice(n),e.key].map(s=>or(s)).join(" -> ");throw new Error(`Circular dependency detected: ${r}`)}this.constructionStack.push(e.key);try{const r=e.factory();if(Qk(r))throw new Error(`Factory for ${or(e.key)} returned a Promise. Await setup before registering.`);if(typeof r!="object"||r===null)throw new Error(`Factory for ${or(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 Ye=new tE,nE=new Set(["target","currentTarget","eventPhase","defaultPrevented","isTrusted","timeStamp","srcElement","returnValue","cancelBubble","NONE","CAPTURING_PHASE","AT_TARGET","BUBBLING_PHASE","composedPath","stopPropagation","stopImmediatePropagation","preventDefault","initEvent"]);function rE(t){for(const e of Object.keys(t))if(nE.has(e))throw new Error(`Event payload key "${e}" is reserved; choose a different property name`)}function sE(t,e){rE(e);for(const n of Object.keys(e))Object.defineProperty(t,n,{value:e[n],writable:!0,enumerable:!0,configurable:!0})}function Be(){class t extends Event{constructor(n,r){const{type:s,bubbles:i,cancelable:o,composed:a,...l}=r??{};if(s!==void 0)throw new Error('Do not pass "type" in init; use the constructor argument instead');super(n,{bubbles:i,cancelable:o,composed:a}),sE(this,l)}}return t}class kt extends globalThis.EventTarget{}function iE(t,e,n){const r=t.dispose.bind(t);t.dispose=()=>{if(!e())return n(),r()}}function Gr(t){var n;class e extends t{constructor(...i){super(...i);x(this,n,!1);iE(this,()=>h(this,n),()=>{$(this,n,!0)})}[Symbol.dispose](){this.dispose()}get disposed(){return h(this,n)}}return n=new WeakMap,e}const oE=Be(),to=Be(),cp="0123456789ABCDEFGHJKMNPQRSTVWXYZ",go=32,aE=16,up=10,Kh=0xffffffffffff;var An;(function(t){t.Base32IncorrectEncoding="B32_ENC_INVALID",t.DecodeTimeInvalidCharacter="DEC_TIME_CHAR",t.DecodeTimeValueMalformed="DEC_TIME_MALFORMED",t.EncodeTimeNegative="ENC_TIME_NEG",t.EncodeTimeSizeExceeded="ENC_TIME_SIZE_EXCEED",t.EncodeTimeValueMalformed="ENC_TIME_MALFORMED",t.PRNGDetectFailure="PRNG_DETECT",t.ULIDInvalid="ULID_INVALID",t.Unexpected="UNEXPECTED",t.UUIDInvalid="UUID_INVALID"})(An||(An={}));class fs extends Error{constructor(e,n){super(`${n} (${e})`),this.name="ULIDError",this.code=e}}function lE(t){const e=Math.floor(t()*go)%go;return cp.charAt(e)}function cE(t){const e=uE(),n=e&&(e.crypto||e.msCrypto)||null;if(typeof(n==null?void 0:n.getRandomValues)=="function")return()=>{const r=new Uint8Array(1);return n.getRandomValues(r),r[0]/256};if(typeof(n==null?void 0:n.randomBytes)=="function")return()=>n.randomBytes(1).readUInt8()/256;throw new fs(An.PRNGDetectFailure,"Failed to find a reliable PRNG")}function uE(){return fE()?self:typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:null}function hE(t,e){let n="";for(;t>0;t--)n=lE(e)+n;return n}function dE(t,e=up){if(isNaN(t))throw new fs(An.EncodeTimeValueMalformed,`Time must be a number: ${t}`);if(t>Kh)throw new fs(An.EncodeTimeSizeExceeded,`Cannot encode a time larger than ${Kh}: ${t}`);if(t<0)throw new fs(An.EncodeTimeNegative,`Time must be positive: ${t}`);if(Number.isInteger(t)===!1)throw new fs(An.EncodeTimeValueMalformed,`Time must be an integer: ${t}`);let n,r="";for(let s=e;s>0;s--)n=t%go,r=cp.charAt(n)+r,t=(t-n)/go;return r}function fE(){return typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope}function kc(t,e){const n=cE(),r=Date.now();return dE(r,up)+hE(aE,n)}const St=4,Ke=6,hp=2,dl=2,pE=St,gE=Ke,Ec="auto",on="auto",kn=120,Jh=75,de=16,nn=kn*St+de*(St-1),mr=kn*Ke+de*(Ke-1),mE=200,vE=4,Li=150,yE=10,Xh=2,bE=4,wE=/^[0-9A-HJKMNP-TV-Z]{26}$/;function dp(t){return gp(t)}function fp(t,e){return gp(t.flatMap(n=>vp(n,e)))}function pp(t){const e=[],n=new Set;for(const r of t){if(r.type==="row"){e.push(`Top-level rows are invalid: ${r.id}`);continue}yp(r,"strip",e,n)}return{valid:e.length===0,errors:e}}function Es(t){const e=dp(t),n=pp(e);if(!n.valid)throw new Error(`Invalid layout: ${n.errors.join("; ")}`);return{totalNodes:e.length,nodes:e.filter(r=>r.type!=="row").map(EE)}}function gp(t){const e=[];for(const n of t){const r=mp(n);for(const s of r){if(s.type==="row"){e.push(...s.children.map(Ft));continue}e.push(s)}}return e}function mp(t){switch(t.type){case"card":return[Ft(t)];case"row":{const e=t.children.map(Ft);return e.length===0?[]:e.length===1?[e[0]]:[{...t,children:e}]}case"stack":{const e=[];for(const n of t.children){const r=mp(n);for(const s of r){if(s.type==="stack"){e.push(...s.children.map(fl));continue}if(s.type==="row"){e.push({...s,children:s.children.map(Ft)});continue}e.push(Ft(s))}}return e.length===0?[]:e.length===1?[fl(e[0])]:[{...t,children:e}]}}}function vp(t,e){switch(t.type){case"card":return t.artifactID===e?[]:[Ft(t)];case"row":{const n=t.children.filter(r=>r.artifactID!==e).map(Ft);return n.length===0?[]:n.length===1?[n[0]]:[{...t,children:n}]}case"stack":{const n=t.children.flatMap(r=>vp(r,e).filter(i=>i.type!=="stack"));return n.length===0?[]:n.length===1?[fl(n[0])]:[{...t,children:n}]}}}function yp(t,e,n,r){switch(t.type){case"card":bp(t,e,n,r);return;case"row":_E(t,e,n,r);return;case"stack":SE(t,e,n,r);return}}function bp(t,e,n,r){$c(t.id,n),typeof t.artifactID!="string"||t.artifactID.length===0?n.push(`Card ${t.id} is missing artifactID`):r.has(t.artifactID)?n.push(`Duplicate artifactID in layout: ${t.artifactID}`):r.add(t.artifactID),kE(t.width)||n.push(`Card ${t.id} width must be an integer in the range 2-4`),wp(t.height)||n.push(`Card ${t.id} height must be an integer in the range 2-6 or "auto"`);const s=En(t.width);e==="row"&&s<hp&&n.push(`Row child ${t.id} must be at least 2 columns wide`)}function _E(t,e,n,r){if($c(t.id,n),e!=="stack"&&n.push(`Row ${t.id} may only appear inside a stack`),wp(t.height,bE)||n.push(`Row ${t.id} height must be an integer in the range 2-4 or "auto"`),!Array.isArray(t.children)||t.children.length===0){n.push(`Row ${t.id} must contain card nodes`);return}let s=0;for(const i of t.children){if(i.type!=="card"){n.push(`Row ${t.id} must contain only card nodes`);continue}bp(i,"row",n,r),s+=En(i.width)}s!==St&&n.push(`Row ${t.id} children must sum to 4 columns`)}function SE(t,e,n,r){if($c(t.id,n),e!=="strip"&&n.push(`Invalid nested stack at ${t.id}; stack children cannot contain another nested stack`),!Array.isArray(t.children)||t.children.length===0){n.push(`Stack ${t.id} must contain at least one child`);return}let s=0,i=0;for(const a of t.children){if(a.type==="stack"){n.push(`Stack ${t.id} cannot contain another nested stack`);continue}if(yp(a,"stack",n,r),a.height===on){i+=1;continue}s+=a.height}if(s>Ke&&n.push(`Stack ${t.id} exceeds the 6-row budget`),i===0)return;const o=Ke-s;if(o<i*dl||o%i!==0){n.push(`Stack ${t.id} has auto-height children that cannot resolve to whole height >= 2`);return}o/i<dl&&n.push(`Stack ${t.id} has auto-height children below the minimum row size`)}function $c(t,e){(typeof t!="string"||!wE.test(t))&&e.push(`Node id must be a ULID: ${String(t)}`)}function kE(t){return t===Ec||Number.isInteger(t)&&t>=hp&&t<=pE}function wp(t,e=gE){return t===on||Number.isInteger(t)&&t>=dl&&t<=e}function En(t){return t===Ec?St:t}function EE(t){if(t.type==="card")return{id:t.id,type:"card",width:En(t.width),cards:[{id:t.id,artifactID:t.artifactID,col:1,row:1,width:En(t.width),height:_p(t.height,Ke)}]};const e=$E(t.children),n=[];let r=1;for(let s=0;s<t.children.length;s+=1){const i=t.children[s],o=e[s];if(i.type==="card")n.push({id:i.id,artifactID:i.artifactID,col:1,row:r,width:En(i.width),height:o});else{let a=1;for(const l of i.children)n.push({id:l.id,artifactID:l.artifactID,col:a,row:r,width:En(l.width),height:o}),a+=En(l.width)}r+=o}return{id:t.id,type:"stack",width:n.reduce((s,i)=>Math.max(s,i.col+i.width-1),1),cards:n}}function $E(t){let e=0,n=0;for(const s of t)s.height===on?n+=1:e+=s.height;const r=n>0?(Ke-e)/n:0;return t.map(s=>_p(s.height,r))}function _p(t,e){return t===on?e:t}function Ft(t){return{...t}}function fl(t){return t.type==="card"?Ft(t):{...t,children:t.children.map(Ft)}}function Sp(t,e={}){return{id:e.id??kc(),type:"card",artifactID:t,width:e.width??Ec,height:e.height??on}}function kp(t,e){return t.some(n=>Ep(n,e))}function Ep(t,e){switch(t.type){case"card":return t.artifactID===e;case"row":return t.children.some(n=>n.artifactID===e);case"stack":return t.children.some(n=>Ep(n,e))}}function Qh(t){return t.layout.flatMap($p)}function $p(t){switch(t.type){case"card":return[t.artifactID];case"row":return t.children.map(e=>e.artifactID);case"stack":return t.children.flatMap($p)}}const te=Be(),Ap=Be(),rs=Be(),AE=Be();function xE(t){class e extends Error{constructor(r,s){super(r),this.name=t,s&&Object.assign(this,s)}}return e}const TE=xE("RequestError"),CE=200,IE=300;class PE{constructor(e,n){v(this,"serverURL");v(this,"token");this.serverURL=e.replace(/\/$/,""),this.token=n.token}async requestJSON(e,n,r){const s=await this.request(e,n,r!==void 0?JSON.stringify(r):void 0,r!==void 0?{"content-type":"application/json"}:void 0),i=await RE(s);if(!s.ok||s.status<CE||s.status>=IE)throw this.createError(typeof i.error=="string"?i.error:s.statusText,s.status);return i}async requestVoid(e,n){const r=await this.request(e,n);if(!r.ok)throw this.createError(await Fa(r,r.statusText),r.status)}async requestText(e,n){const r=await this.request(e,n);if(!r.ok)throw this.createError(await Fa(r,r.statusText),r.status);return r.text()}async requestRawVoid(e,n,r){const s=await this.request(e,n,r,{"content-type":"text/plain"});if(!s.ok)throw this.createError(await Fa(s,s.statusText),s.status)}createError(e,n){const r={serverURL:this.serverURL};return n!==void 0&&(r.status=n),new TE(e,r)}async request(e,n,r,s){const i=`${this.serverURL}${n}`;try{return await fetch(i,{method:e,headers:this.buildHeaders(s),body:r})}catch(o){throw this.createError(o instanceof Error?o.message:"Failed to reach server")}}buildHeaders(e){const n={...e??{}};return this.token&&(n.Authorization=`Bearer ${this.token}`),Object.keys(n).length>0?n:void 0}}async function RE(t){try{return await t.json()}catch{const e=await t.text().catch(()=>"");return e?{message:e}:{}}}async function Fa(t,e){try{const n=await t.json();if(typeof n.error=="string")return n.error;if(typeof n.message=="string")return n.message}catch{}return e}function xp(t){return t.map(e=>`${e.name} (${e.id})`).join(", ")}var vt,Ao,Tp;class DE{constructor(e){x(this,Ao);x(this,vt);$(this,vt,e)}list(){return h(this,vt).requestJSON("GET","/screens")}async get(e={}){const n=await b(this,Ao,Tp).call(this,e.screenID);return h(this,vt).requestJSON("GET",`/screens/${encodeURIComponent(n)}`)}create(e){const n={name:e.name};return e.id!==void 0&&(n.id=e.id),h(this,vt).requestJSON("POST","/screens",n)}update(e){const n={};return e.name!==void 0&&(n.name=e.name),e.layout!==void 0&&(n.layout=e.layout),h(this,vt).requestJSON("PATCH",`/screens/${encodeURIComponent(e.screenID)}`,n)}remove(e){return h(this,vt).requestJSON("DELETE",`/screens/${encodeURIComponent(e.screenID)}`)}}vt=new WeakMap,Ao=new WeakSet,Tp=async function(e){if(e!==void 0)return e;const{screens:n}=await this.list();if(n.length===1)return n[0].id;throw h(this,vt).createError(`screenID is required when multiple screens exist. Available screens: ${xp(n)}`)};var Ue,Os,xo,Cp;class OE{constructor(e,n){x(this,xo);x(this,Ue);x(this,Os);$(this,Ue,e),$(this,Os,n)}async create(e){const n=await b(this,xo,Cp).call(this,e.screenID);return h(this,Ue).requestJSON("POST",`/screens/${encodeURIComponent(n)}/artifact`,{type:e.type,title:e.title,externalFilePath:e.externalFilePath})}get(e){return h(this,Ue).requestJSON("GET",`/artifacts/${encodeURIComponent(e.artifactID)}`)}update(e){const n={};return e.title!==void 0&&(n.title=e.title),h(this,Ue).requestJSON("PATCH",`/artifacts/${encodeURIComponent(e.artifactID)}`,n)}edit(e){return h(this,Ue).requestJSON("POST",`/artifacts/${encodeURIComponent(e.artifactID)}/edit`)}commitPending(e){return h(this,Ue).requestJSON("POST",`/artifacts/${encodeURIComponent(e.artifactID)}/commit`)}abandonPending(e){return h(this,Ue).requestVoid("POST",`/artifacts/${encodeURIComponent(e.artifactID)}/abandon`)}remove(e){return h(this,Ue).requestJSON("DELETE",`/screens/${encodeURIComponent(e.screenID)}/artifacts/${encodeURIComponent(e.artifactID)}`)}getContent(e){return h(this,Ue).requestText("GET",`/artifacts/${encodeURIComponent(e.artifactID)}/content`)}putContent(e){return h(this,Ue).requestRawVoid("PUT",`/artifacts/${encodeURIComponent(e.artifactID)}/content`,e.content)}}Ue=new WeakMap,Os=new WeakMap,xo=new WeakSet,Cp=async function(e){if(e!==void 0)return e;const{screens:n}=await h(this,Os).list();if(n.length===1)return n[0].id;throw h(this,Ue).createError(`screenID is required when multiple screens exist. Available screens: ${xp(n)}`)};var zs;class zE{constructor(e){x(this,zs);$(this,zs,e)}async list(){const{views:e}=await h(this,zs).requestJSON("GET","/views");return e}}zs=new WeakMap;var Ht;class LE{constructor(e,n={}){v(this,"screens");v(this,"artifacts");v(this,"views");x(this,Ht);$(this,Ht,new PE(e,n)),this.screens=new DE(h(this,Ht)),this.artifacts=new OE(h(this,Ht),this.screens),this.views=new zE(h(this,Ht))}health(){return h(this,Ht).requestJSON("GET","/health")}}Ht=new WeakMap;const ME=Gr(kt);var Tn,Fe,Cn,Oe,qt,Yt,Q,lr,Ip,Ls,Pp,Rp,Dp,Op,pl,gl,ml,zp;class NE extends ME{constructor(n){var s;super();x(this,Q);v(this,"id");v(this,"server");x(this,Tn);x(this,Fe,new Map);x(this,Cn);x(this,Oe);x(this,qt);x(this,Yt,null);x(this,Ls,n=>{if(this.disposed)return;const r=n.event;switch(r.type){case"screen-updated":r.screen.id===this.id&&b(this,Q,Pp).call(this,r.screen);break;case"artifact-created":r.screenID===this.id&&b(this,Q,Rp).call(this,r.artifact);break;case"artifact-updated":b(this,Q,Dp).call(this,r.artifact);break;case"artifact-removed":r.screenID===this.id&&b(this,Q,Op).call(this,r.artifactID);break;case"artifact-content-changed":h(this,Fe).has(r.artifactID)&&this.dispatchEvent(new AE("artifact-content-changed",{artifactID:r.artifactID}));break}});this.id=n.screen.id,this.server=n.server,$(this,Tn,n.localStore),$(this,Cn,n.screen.name),$(this,Oe,structuredClone(n.screen.layout));const r=((s=h(this,Tn).get().screens[this.id])==null?void 0:s.scrollPosition)??0;$(this,qt,Math.max(0,r)),this.server.addEventListener("server-event",h(this,Ls)),b(this,Q,Ip).call(this)}get name(){return h(this,Cn)}get layout(){return h(this,Oe)}get scrollPosition(){return h(this,qt)}get artifacts(){return h(this,Fe)}setScrollPosition(n){b(this,Q,lr).call(this);const r=Math.max(0,n);r!==h(this,qt)&&($(this,qt,r),b(this,Q,zp).call(this),this.dispatchEvent(new te("change")))}setLayout(n){b(this,Q,lr).call(this);const r=dp(n);if(!pp(r).valid)return;const i=b(this,Q,gl).call(this);$(this,Oe,r),$(this,Yt,{layout:r,snapshot:i}),this.dispatchEvent(new te("change")),this.server.client.screens.update({screenID:this.id,layout:r.map(o=>structuredClone(o))}).catch(()=>{var o;this.disposed||((o=h(this,Yt))==null?void 0:o.layout)===r&&($(this,Yt,null),b(this,Q,ml).call(this,i),this.dispatchEvent(new te("change")))})}rename(n){b(this,Q,lr).call(this),$(this,Cn,n),this.dispatchEvent(new te("change")),this.server.client.screens.update({screenID:this.id,name:n}).catch(()=>{})}async remove(){b(this,Q,lr).call(this),await this.server.client.screens.remove({screenID:this.id})}removeArtifact(n){if(b(this,Q,lr).call(this),!h(this,Fe).has(n))return;const r=b(this,Q,gl).call(this);b(this,Q,pl).call(this,n),this.dispatchEvent(new te("change")),this.server.client.artifacts.remove({artifactID:n,screenID:this.id}).catch(()=>{this.disposed||(b(this,Q,ml).call(this,r),this.dispatchEvent(new te("change")))})}dispose(){this.server.removeEventListener("server-event",h(this,Ls))}}Tn=new WeakMap,Fe=new WeakMap,Cn=new WeakMap,Oe=new WeakMap,qt=new WeakMap,Yt=new WeakMap,Q=new WeakSet,lr=function(){if(this.disposed)throw new Error("ScreenModel is disposed")},Ip=async function(){try{const n=await this.server.client.screens.get({screenID:this.id});if(this.disposed)return;for(const r of n.artifacts)h(this,Fe).set(r.id,r);this.dispatchEvent(new te("change"))}catch{}},Ls=new WeakMap,Pp=function(n){h(this,Yt)&&$(this,Yt,null),$(this,Cn,n.name),$(this,Oe,structuredClone(n.layout)),this.dispatchEvent(new te("change"))},Rp=function(n){kp(h(this,Oe),n.id)||$(this,Oe,[...h(this,Oe),Sp(n.id)]),h(this,Fe).set(n.id,n),this.dispatchEvent(new te("change"))},Dp=function(n){const r=h(this,Fe).get(n.id);r&&(h(this,Fe).set(n.id,{...r,...n}),this.dispatchEvent(new te("change")))},Op=function(n){b(this,Q,pl).call(this,n)&&this.dispatchEvent(new te("change"))},pl=function(n){const r=h(this,Fe).delete(n),s=Qh({layout:h(this,Oe)}).length,i=fp(h(this,Oe),n),o=Qh({layout:i}).length;return $(this,Oe,i),r||s!==o},gl=function(){return{layout:structuredClone(h(this,Oe)),artifacts:new Map([...h(this,Fe).entries()].map(([n,r])=>[n,structuredClone(r)]))}},ml=function(n){$(this,Oe,structuredClone(n.layout)),h(this,Fe).clear();for(const[r,s]of n.artifacts)h(this,Fe).set(r,structuredClone(s))},zp=function(){const n=h(this,Tn).get();h(this,Tn).set({...n,screens:{...n.screens,[this.id]:{scrollPosition:h(this,qt)}}})};const UE=Gr(kt);var Ze,yt,rt,Ms,Ns,Us,rn,no,Lp;class FE extends UE{constructor(n){super();x(this,rn);x(this,Ze);x(this,yt);x(this,rt,null);x(this,Ms,()=>{this.disposed||b(this,rn,no).call(this)});x(this,Ns,()=>{this.disposed||b(this,rn,no).call(this)});x(this,Us,n=>{var s;if(this.disposed)return;const r=n.event;r.type==="screen-removed"&&((s=h(this,rt))==null?void 0:s.id)===r.screenID&&this.clearActive()});$(this,Ze,n.localStore),$(this,yt,n.serverManager),h(this,Ze).addEventListener("change",h(this,Ms)),h(this,yt).addEventListener("change",h(this,Ns)),h(this,yt).addEventListener("server-event",h(this,Us)),b(this,rn,no).call(this)}get activeScreen(){return h(this,rt)}setActive(n,r){const s=h(this,Ze).get();s.activeServerURL===n&&s.activeScreenID===r||h(this,Ze).set({...s,activeServerURL:n,activeScreenID:r})}clearActive(){const n=h(this,Ze).get();n.activeServerURL===null&&n.activeScreenID===null||h(this,Ze).set({...n,activeServerURL:null,activeScreenID:null})}dispose(){var n;h(this,Ze).removeEventListener("change",h(this,Ms)),h(this,yt).removeEventListener("change",h(this,Ns)),h(this,yt).removeEventListener("server-event",h(this,Us)),(n=h(this,rt))==null||n.dispose(),$(this,rt,null)}}Ze=new WeakMap,yt=new WeakMap,rt=new WeakMap,Ms=new WeakMap,Ns=new WeakMap,Us=new WeakMap,rn=new WeakSet,no=function(){var l,c,d;const{activeServerURL:n,activeScreenID:r}=h(this,Ze).get();let s=n?h(this,yt).servers.get(n)??null:null,i=s&&r?s.screens.get(r)??null:null;if(!i){const f=b(this,rn,Lp).call(this);if(f){s=f.server,i=f.screen,h(this,Ze).set({...h(this,Ze).get(),activeServerURL:f.server.url,activeScreenID:f.screen.id});return}}const o=((l=h(this,rt))==null?void 0:l.id)??null,a=(i==null?void 0:i.id)??null;o===a&&((c=h(this,rt))==null?void 0:c.server)===s||((d=h(this,rt))==null||d.dispose(),$(this,rt,s&&i?new NE({screen:i,server:s,localStore:h(this,Ze)}):null),this.dispatchEvent(new oE("active-screen-changed")))},Lp=function(){for(const n of h(this,yt).servers.values()){const r=n.screens.values().next().value;if(r)return{server:n,screen:r}}return null};const ZE="Local",jE="store-";function Pt(t){return new URL(t).origin}function WE(t){return{servers:[{url:Pt(t),name:ZE}],activeServerURL:null,activeScreenID:null,screens:{}}}var In,Pn,Rn;class BE extends kt{constructor(n,r,s={}){super();x(this,In);x(this,Pn);x(this,Rn);$(this,In,`${jE}${n}`),$(this,Pn,s.storage??VE());const i=h(this,Pn).getItem(h(this,In));i===null?($(this,Rn,r),h(this,Pn).setItem(h(this,In),JSON.stringify(r))):$(this,Rn,JSON.parse(i))}get(){return h(this,Rn)}set(n){$(this,Rn,n),h(this,Pn).setItem(h(this,In),JSON.stringify(n)),this.dispatchEvent(new te("change"))}}In=new WeakMap,Pn=new WeakMap,Rn=new WeakMap;function VE(){const t=globalThis.localStorage;if(!t)throw new Error("LocalStore: no storage adapter supplied and window.localStorage is unavailable");return t}function S(t,e,n){function r(a,l){if(a._zod||Object.defineProperty(a,"_zod",{value:{def:l,constr:o,traits:new Set},enumerable:!1}),a._zod.traits.has(t))return;a._zod.traits.add(t),e(a,l);const c=o.prototype,d=Object.keys(c);for(let f=0;f<d.length;f++){const y=d[f];y in a||(a[y]=c[y].bind(a))}}const s=(n==null?void 0:n.Parent)??Object;class i extends s{}Object.defineProperty(i,"name",{value:t});function o(a){var l;const c=n!=null&&n.Parent?new i:this;r(c,a),(l=c._zod).deferred??(l.deferred=[]);for(const d of c._zod.deferred)d();return c}return Object.defineProperty(o,"init",{value:r}),Object.defineProperty(o,Symbol.hasInstance,{value:a=>{var l,c;return n!=null&&n.Parent&&a instanceof n.Parent?!0:(c=(l=a==null?void 0:a._zod)==null?void 0:l.traits)==null?void 0:c.has(t)}}),Object.defineProperty(o,"name",{value:t}),o}class wr extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class Mp extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name="ZodEncodeError"}}const Np={};function an(t){return Np}function Up(t){const e=Object.values(t).filter(r=>typeof r=="number");return Object.entries(t).filter(([r,s])=>e.indexOf(+r)===-1).map(([r,s])=>s)}function vl(t,e){return typeof e=="bigint"?e.toString():e}function Ac(t){return{get value(){{const e=t();return Object.defineProperty(this,"value",{value:e}),e}}}}function xc(t){return t==null}function Tc(t){const e=t.startsWith("^")?1:0,n=t.endsWith("$")?t.length-1:t.length;return t.slice(e,n)}function GE(t,e){const n=(t.toString().split(".")[1]||"").length,r=e.toString();let s=(r.split(".")[1]||"").length;if(s===0&&/\d?e-\d?/.test(r)){const l=r.match(/\d?e-(\d?)/);l!=null&&l[1]&&(s=Number.parseInt(l[1]))}const i=n>s?n:s,o=Number.parseInt(t.toFixed(i).replace(".","")),a=Number.parseInt(e.toFixed(i).replace(".",""));return o%a/10**i}const ed=Symbol("evaluating");function ee(t,e,n){let r;Object.defineProperty(t,e,{get(){if(r!==ed)return r===void 0&&(r=ed,r=n()),r},set(s){Object.defineProperty(t,e,{value:s})},configurable:!0})}function Yn(t,e,n){Object.defineProperty(t,e,{value:n,writable:!0,enumerable:!0,configurable:!0})}function fn(...t){const e={};for(const n of t){const r=Object.getOwnPropertyDescriptors(n);Object.assign(e,r)}return Object.defineProperties({},e)}function td(t){return JSON.stringify(t)}function HE(t){return t.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}const Fp="captureStackTrace"in Error?Error.captureStackTrace:(...t)=>{};function mo(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}const qE=Ac(()=>{var t;if(typeof navigator<"u"&&((t=navigator==null?void 0:navigator.userAgent)!=null&&t.includes("Cloudflare")))return!1;try{const e=Function;return new e(""),!0}catch{return!1}});function Or(t){if(mo(t)===!1)return!1;const e=t.constructor;if(e===void 0||typeof e!="function")return!0;const n=e.prototype;return!(mo(n)===!1||Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")===!1)}function Zp(t){return Or(t)?{...t}:Array.isArray(t)?[...t]:t}const YE=new Set(["string","number","symbol"]);function zr(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function pn(t,e,n){const r=new t._zod.constr(e??t._zod.def);return(!e||n!=null&&n.parent)&&(r._zod.parent=t),r}function D(t){const e=t;if(!e)return{};if(typeof e=="string")return{error:()=>e};if((e==null?void 0:e.message)!==void 0){if((e==null?void 0:e.error)!==void 0)throw new Error("Cannot specify both `message` and `error` params");e.error=e.message}return delete e.message,typeof e.error=="string"?{...e,error:()=>e.error}:e}function KE(t){return Object.keys(t).filter(e=>t[e]._zod.optin==="optional"&&t[e]._zod.optout==="optional")}const JE={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 XE(t,e){const n=t._zod.def,r=n.checks;if(r&&r.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");const i=fn(t._zod.def,{get shape(){const o={};for(const a in e){if(!(a in n.shape))throw new Error(`Unrecognized key: "${a}"`);e[a]&&(o[a]=n.shape[a])}return Yn(this,"shape",o),o},checks:[]});return pn(t,i)}function QE(t,e){const n=t._zod.def,r=n.checks;if(r&&r.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");const i=fn(t._zod.def,{get shape(){const o={...t._zod.def.shape};for(const a in e){if(!(a in n.shape))throw new Error(`Unrecognized key: "${a}"`);e[a]&&delete o[a]}return Yn(this,"shape",o),o},checks:[]});return pn(t,i)}function e$(t,e){if(!Or(e))throw new Error("Invalid input to extend: expected a plain object");const n=t._zod.def.checks;if(n&&n.length>0){const i=t._zod.def.shape;for(const o in e)if(Object.getOwnPropertyDescriptor(i,o)!==void 0)throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}const s=fn(t._zod.def,{get shape(){const i={...t._zod.def.shape,...e};return Yn(this,"shape",i),i}});return pn(t,s)}function t$(t,e){if(!Or(e))throw new Error("Invalid input to safeExtend: expected a plain object");const n=fn(t._zod.def,{get shape(){const r={...t._zod.def.shape,...e};return Yn(this,"shape",r),r}});return pn(t,n)}function n$(t,e){const n=fn(t._zod.def,{get shape(){const r={...t._zod.def.shape,...e._zod.def.shape};return Yn(this,"shape",r),r},get catchall(){return e._zod.def.catchall},checks:[]});return pn(t,n)}function r$(t,e,n){const s=e._zod.def.checks;if(s&&s.length>0)throw new Error(".partial() cannot be used on object schemas containing refinements");const o=fn(e._zod.def,{get shape(){const a=e._zod.def.shape,l={...a};if(n)for(const c in n){if(!(c in a))throw new Error(`Unrecognized key: "${c}"`);n[c]&&(l[c]=t?new t({type:"optional",innerType:a[c]}):a[c])}else for(const c in a)l[c]=t?new t({type:"optional",innerType:a[c]}):a[c];return Yn(this,"shape",l),l},checks:[]});return pn(e,o)}function s$(t,e,n){const r=fn(e._zod.def,{get shape(){const s=e._zod.def.shape,i={...s};if(n)for(const o in n){if(!(o in i))throw new Error(`Unrecognized key: "${o}"`);n[o]&&(i[o]=new t({type:"nonoptional",innerType:s[o]}))}else for(const o in s)i[o]=new t({type:"nonoptional",innerType:s[o]});return Yn(this,"shape",i),i}});return pn(e,r)}function vr(t,e=0){var n;if(t.aborted===!0)return!0;for(let r=e;r<t.issues.length;r++)if(((n=t.issues[r])==null?void 0:n.continue)!==!0)return!0;return!1}function yr(t,e){return e.map(n=>{var r;return(r=n).path??(r.path=[]),n.path.unshift(t),n})}function Mi(t){return typeof t=="string"?t:t==null?void 0:t.message}function ln(t,e,n){var s,i,o,a,l,c;const r={...t,path:t.path??[]};if(!t.message){const d=Mi((o=(i=(s=t.inst)==null?void 0:s._zod.def)==null?void 0:i.error)==null?void 0:o.call(i,t))??Mi((a=e==null?void 0:e.error)==null?void 0:a.call(e,t))??Mi((l=n.customError)==null?void 0:l.call(n,t))??Mi((c=n.localeError)==null?void 0:c.call(n,t))??"Invalid input";r.message=d}return delete r.inst,delete r.continue,e!=null&&e.reportInput||delete r.input,r}function Cc(t){return Array.isArray(t)?"array":typeof t=="string"?"string":"unknown"}function xs(...t){const[e,n,r]=t;return typeof e=="string"?{message:e,code:"custom",input:n,inst:r}:{...e}}const jp=(t,e)=>{t.name="$ZodError",Object.defineProperty(t,"_zod",{value:t._zod,enumerable:!1}),Object.defineProperty(t,"issues",{value:e,enumerable:!1}),t.message=JSON.stringify(e,vl,2),Object.defineProperty(t,"toString",{value:()=>t.message,enumerable:!1})},Wp=S("$ZodError",jp),Bp=S("$ZodError",jp,{Parent:Error});function i$(t,e=n=>n.message){const n={},r=[];for(const s of t.issues)s.path.length>0?(n[s.path[0]]=n[s.path[0]]||[],n[s.path[0]].push(e(s))):r.push(e(s));return{formErrors:r,fieldErrors:n}}function o$(t,e=n=>n.message){const n={_errors:[]},r=s=>{for(const i of s.issues)if(i.code==="invalid_union"&&i.errors.length)i.errors.map(o=>r({issues:o}));else if(i.code==="invalid_key")r({issues:i.issues});else if(i.code==="invalid_element")r({issues:i.issues});else if(i.path.length===0)n._errors.push(e(i));else{let o=n,a=0;for(;a<i.path.length;){const l=i.path[a];a===i.path.length-1?(o[l]=o[l]||{_errors:[]},o[l]._errors.push(e(i))):o[l]=o[l]||{_errors:[]},o=o[l],a++}}};return r(t),n}const Ic=t=>(e,n,r,s)=>{const i=r?Object.assign(r,{async:!1}):{async:!1},o=e._zod.run({value:n,issues:[]},i);if(o instanceof Promise)throw new wr;if(o.issues.length){const a=new((s==null?void 0:s.Err)??t)(o.issues.map(l=>ln(l,i,an())));throw Fp(a,s==null?void 0:s.callee),a}return o.value},Pc=t=>async(e,n,r,s)=>{const i=r?Object.assign(r,{async:!0}):{async:!0};let o=e._zod.run({value:n,issues:[]},i);if(o instanceof Promise&&(o=await o),o.issues.length){const a=new((s==null?void 0:s.Err)??t)(o.issues.map(l=>ln(l,i,an())));throw Fp(a,s==null?void 0:s.callee),a}return o.value},Wo=t=>(e,n,r)=>{const s=r?{...r,async:!1}:{async:!1},i=e._zod.run({value:n,issues:[]},s);if(i instanceof Promise)throw new wr;return i.issues.length?{success:!1,error:new(t??Wp)(i.issues.map(o=>ln(o,s,an())))}:{success:!0,data:i.value}},a$=Wo(Bp),Bo=t=>async(e,n,r)=>{const s=r?Object.assign(r,{async:!0}):{async:!0};let i=e._zod.run({value:n,issues:[]},s);return i instanceof Promise&&(i=await i),i.issues.length?{success:!1,error:new t(i.issues.map(o=>ln(o,s,an())))}:{success:!0,data:i.value}},l$=Bo(Bp),c$=t=>(e,n,r)=>{const s=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return Ic(t)(e,n,s)},u$=t=>(e,n,r)=>Ic(t)(e,n,r),h$=t=>async(e,n,r)=>{const s=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return Pc(t)(e,n,s)},d$=t=>async(e,n,r)=>Pc(t)(e,n,r),f$=t=>(e,n,r)=>{const s=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return Wo(t)(e,n,s)},p$=t=>(e,n,r)=>Wo(t)(e,n,r),g$=t=>async(e,n,r)=>{const s=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return Bo(t)(e,n,s)},m$=t=>async(e,n,r)=>Bo(t)(e,n,r),v$=/^[cC][^\s-]{8,}$/,y$=/^[0-9a-z]+$/,b$=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,w$=/^[0-9a-vA-V]{20}$/,_$=/^[A-Za-z0-9]{27}$/,S$=/^[a-zA-Z0-9_-]{21}$/,k$=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,E$=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,nd=t=>t?new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${t}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,$$=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,A$="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function x$(){return new RegExp(A$,"u")}const T$=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,C$=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/,I$=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,P$=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,R$=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Vp=/^[A-Za-z0-9_-]*$/,D$=/^\+[1-9]\d{6,14}$/,Gp="(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))",O$=new RegExp(`^${Gp}$`);function Hp(t){const e="(?:[01]\\d|2[0-3]):[0-5]\\d";return typeof t.precision=="number"?t.precision===-1?`${e}`:t.precision===0?`${e}:[0-5]\\d`:`${e}:[0-5]\\d\\.\\d{${t.precision}}`:`${e}(?::[0-5]\\d(?:\\.\\d+)?)?`}function z$(t){return new RegExp(`^${Hp(t)}$`)}function L$(t){const e=Hp({precision:t.precision}),n=["Z"];t.local&&n.push(""),t.offset&&n.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");const r=`${e}(?:${n.join("|")})`;return new RegExp(`^${Gp}T(?:${r})$`)}const M$=t=>{const e=t?`[\\s\\S]{${(t==null?void 0:t.minimum)??0},${(t==null?void 0:t.maximum)??""}}`:"[\\s\\S]*";return new RegExp(`^${e}$`)},N$=/^-?\d+$/,qp=/^-?\d+(?:\.\d+)?$/,U$=/^(?:true|false)$/i,F$=/^[^A-Z]*$/,Z$=/^[^a-z]*$/,Ve=S("$ZodCheck",(t,e)=>{var n;t._zod??(t._zod={}),t._zod.def=e,(n=t._zod).onattach??(n.onattach=[])}),Yp={number:"number",bigint:"bigint",object:"date"},Kp=S("$ZodCheckLessThan",(t,e)=>{Ve.init(t,e);const n=Yp[typeof e.value];t._zod.onattach.push(r=>{const s=r._zod.bag,i=(e.inclusive?s.maximum:s.exclusiveMaximum)??Number.POSITIVE_INFINITY;e.value<i&&(e.inclusive?s.maximum=e.value:s.exclusiveMaximum=e.value)}),t._zod.check=r=>{(e.inclusive?r.value<=e.value:r.value<e.value)||r.issues.push({origin:n,code:"too_big",maximum:typeof e.value=="object"?e.value.getTime():e.value,input:r.value,inclusive:e.inclusive,inst:t,continue:!e.abort})}}),Jp=S("$ZodCheckGreaterThan",(t,e)=>{Ve.init(t,e);const n=Yp[typeof e.value];t._zod.onattach.push(r=>{const s=r._zod.bag,i=(e.inclusive?s.minimum:s.exclusiveMinimum)??Number.NEGATIVE_INFINITY;e.value>i&&(e.inclusive?s.minimum=e.value:s.exclusiveMinimum=e.value)}),t._zod.check=r=>{(e.inclusive?r.value>=e.value:r.value>e.value)||r.issues.push({origin:n,code:"too_small",minimum:typeof e.value=="object"?e.value.getTime():e.value,input:r.value,inclusive:e.inclusive,inst:t,continue:!e.abort})}}),j$=S("$ZodCheckMultipleOf",(t,e)=>{Ve.init(t,e),t._zod.onattach.push(n=>{var r;(r=n._zod.bag).multipleOf??(r.multipleOf=e.value)}),t._zod.check=n=>{if(typeof n.value!=typeof e.value)throw new Error("Cannot mix number and bigint in multiple_of check.");(typeof n.value=="bigint"?n.value%e.value===BigInt(0):GE(n.value,e.value)===0)||n.issues.push({origin:typeof n.value,code:"not_multiple_of",divisor:e.value,input:n.value,inst:t,continue:!e.abort})}}),W$=S("$ZodCheckNumberFormat",(t,e)=>{var o;Ve.init(t,e),e.format=e.format||"float64";const n=(o=e.format)==null?void 0:o.includes("int"),r=n?"int":"number",[s,i]=JE[e.format];t._zod.onattach.push(a=>{const l=a._zod.bag;l.format=e.format,l.minimum=s,l.maximum=i,n&&(l.pattern=N$)}),t._zod.check=a=>{const l=a.value;if(n){if(!Number.isInteger(l)){a.issues.push({expected:r,format:e.format,code:"invalid_type",continue:!1,input:l,inst:t});return}if(!Number.isSafeInteger(l)){l>0?a.issues.push({input:l,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:t,origin:r,inclusive:!0,continue:!e.abort}):a.issues.push({input:l,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:t,origin:r,inclusive:!0,continue:!e.abort});return}}l<s&&a.issues.push({origin:"number",input:l,code:"too_small",minimum:s,inclusive:!0,inst:t,continue:!e.abort}),l>i&&a.issues.push({origin:"number",input:l,code:"too_big",maximum:i,inclusive:!0,inst:t,continue:!e.abort})}}),B$=S("$ZodCheckMaxLength",(t,e)=>{var n;Ve.init(t,e),(n=t._zod.def).when??(n.when=r=>{const s=r.value;return!xc(s)&&s.length!==void 0}),t._zod.onattach.push(r=>{const s=r._zod.bag.maximum??Number.POSITIVE_INFINITY;e.maximum<s&&(r._zod.bag.maximum=e.maximum)}),t._zod.check=r=>{const s=r.value;if(s.length<=e.maximum)return;const o=Cc(s);r.issues.push({origin:o,code:"too_big",maximum:e.maximum,inclusive:!0,input:s,inst:t,continue:!e.abort})}}),V$=S("$ZodCheckMinLength",(t,e)=>{var n;Ve.init(t,e),(n=t._zod.def).when??(n.when=r=>{const s=r.value;return!xc(s)&&s.length!==void 0}),t._zod.onattach.push(r=>{const s=r._zod.bag.minimum??Number.NEGATIVE_INFINITY;e.minimum>s&&(r._zod.bag.minimum=e.minimum)}),t._zod.check=r=>{const s=r.value;if(s.length>=e.minimum)return;const o=Cc(s);r.issues.push({origin:o,code:"too_small",minimum:e.minimum,inclusive:!0,input:s,inst:t,continue:!e.abort})}}),G$=S("$ZodCheckLengthEquals",(t,e)=>{var n;Ve.init(t,e),(n=t._zod.def).when??(n.when=r=>{const s=r.value;return!xc(s)&&s.length!==void 0}),t._zod.onattach.push(r=>{const s=r._zod.bag;s.minimum=e.length,s.maximum=e.length,s.length=e.length}),t._zod.check=r=>{const s=r.value,i=s.length;if(i===e.length)return;const o=Cc(s),a=i>e.length;r.issues.push({origin:o,...a?{code:"too_big",maximum:e.length}:{code:"too_small",minimum:e.length},inclusive:!0,exact:!0,input:r.value,inst:t,continue:!e.abort})}}),Vo=S("$ZodCheckStringFormat",(t,e)=>{var n,r;Ve.init(t,e),t._zod.onattach.push(s=>{const i=s._zod.bag;i.format=e.format,e.pattern&&(i.patterns??(i.patterns=new Set),i.patterns.add(e.pattern))}),e.pattern?(n=t._zod).check??(n.check=s=>{e.pattern.lastIndex=0,!e.pattern.test(s.value)&&s.issues.push({origin:"string",code:"invalid_format",format:e.format,input:s.value,...e.pattern?{pattern:e.pattern.toString()}:{},inst:t,continue:!e.abort})}):(r=t._zod).check??(r.check=()=>{})}),H$=S("$ZodCheckRegex",(t,e)=>{Vo.init(t,e),t._zod.check=n=>{e.pattern.lastIndex=0,!e.pattern.test(n.value)&&n.issues.push({origin:"string",code:"invalid_format",format:"regex",input:n.value,pattern:e.pattern.toString(),inst:t,continue:!e.abort})}}),q$=S("$ZodCheckLowerCase",(t,e)=>{e.pattern??(e.pattern=F$),Vo.init(t,e)}),Y$=S("$ZodCheckUpperCase",(t,e)=>{e.pattern??(e.pattern=Z$),Vo.init(t,e)}),K$=S("$ZodCheckIncludes",(t,e)=>{Ve.init(t,e);const n=zr(e.includes),r=new RegExp(typeof e.position=="number"?`^.{${e.position}}${n}`:n);e.pattern=r,t._zod.onattach.push(s=>{const i=s._zod.bag;i.patterns??(i.patterns=new Set),i.patterns.add(r)}),t._zod.check=s=>{s.value.includes(e.includes,e.position)||s.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:e.includes,input:s.value,inst:t,continue:!e.abort})}}),J$=S("$ZodCheckStartsWith",(t,e)=>{Ve.init(t,e);const n=new RegExp(`^${zr(e.prefix)}.*`);e.pattern??(e.pattern=n),t._zod.onattach.push(r=>{const s=r._zod.bag;s.patterns??(s.patterns=new Set),s.patterns.add(n)}),t._zod.check=r=>{r.value.startsWith(e.prefix)||r.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:e.prefix,input:r.value,inst:t,continue:!e.abort})}}),X$=S("$ZodCheckEndsWith",(t,e)=>{Ve.init(t,e);const n=new RegExp(`.*${zr(e.suffix)}$`);e.pattern??(e.pattern=n),t._zod.onattach.push(r=>{const s=r._zod.bag;s.patterns??(s.patterns=new Set),s.patterns.add(n)}),t._zod.check=r=>{r.value.endsWith(e.suffix)||r.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:e.suffix,input:r.value,inst:t,continue:!e.abort})}}),Q$=S("$ZodCheckOverwrite",(t,e)=>{Ve.init(t,e),t._zod.check=n=>{n.value=e.tx(n.value)}});class e0{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),s=Math.min(...r.map(o=>o.length-o.trimStart().length)),i=r.map(o=>o.slice(s)).map(o=>" ".repeat(this.indent*2)+o);for(const o of i)this.content.push(o)}compile(){const e=Function,n=this==null?void 0:this.args,s=[...((this==null?void 0:this.content)??[""]).map(i=>` ${i}`)];return new e(...n,s.join(`
|
|
6
|
-
`))}}const t0={major:4,minor:3,patch:6},le=S("$ZodType",(t,e)=>{var s;var n;t??(t={}),t._zod.def=e,t._zod.bag=t._zod.bag||{},t._zod.version=t0;const r=[...t._zod.def.checks??[]];t._zod.traits.has("$ZodCheck")&&r.unshift(t);for(const i of r)for(const o of i._zod.onattach)o(t);if(r.length===0)(n=t._zod).deferred??(n.deferred=[]),(s=t._zod.deferred)==null||s.push(()=>{t._zod.run=t._zod.parse});else{const i=(a,l,c)=>{let d=vr(a),f;for(const y of l){if(y._zod.def.when){if(!y._zod.def.when(a))continue}else if(d)continue;const m=a.issues.length,E=y._zod.check(a);if(E instanceof Promise&&(c==null?void 0:c.async)===!1)throw new wr;if(f||E instanceof Promise)f=(f??Promise.resolve()).then(async()=>{await E,a.issues.length!==m&&(d||(d=vr(a,m)))});else{if(a.issues.length===m)continue;d||(d=vr(a,m))}}return f?f.then(()=>a):a},o=(a,l,c)=>{if(vr(a))return a.aborted=!0,a;const d=i(l,r,c);if(d instanceof Promise){if(c.async===!1)throw new wr;return d.then(f=>t._zod.parse(f,c))}return t._zod.parse(d,c)};t._zod.run=(a,l)=>{if(l.skipChecks)return t._zod.parse(a,l);if(l.direction==="backward"){const d=t._zod.parse({value:a.value,issues:[]},{...l,skipChecks:!0});return d instanceof Promise?d.then(f=>o(f,a,l)):o(d,a,l)}const c=t._zod.parse(a,l);if(c instanceof Promise){if(l.async===!1)throw new wr;return c.then(d=>i(d,r,l))}return i(c,r,l)}}ee(t,"~standard",()=>({validate:i=>{var o;try{const a=a$(t,i);return a.success?{value:a.data}:{issues:(o=a.error)==null?void 0:o.issues}}catch{return l$(t,i).then(l=>{var c;return l.success?{value:l.data}:{issues:(c=l.error)==null?void 0:c.issues}})}},vendor:"zod",version:1}))}),Rc=S("$ZodString",(t,e)=>{var n;le.init(t,e),t._zod.pattern=[...((n=t==null?void 0:t._zod.bag)==null?void 0:n.patterns)??[]].pop()??M$(t._zod.bag),t._zod.parse=(r,s)=>{if(e.coerce)try{r.value=String(r.value)}catch{}return typeof r.value=="string"||r.issues.push({expected:"string",code:"invalid_type",input:r.value,inst:t}),r}}),oe=S("$ZodStringFormat",(t,e)=>{Vo.init(t,e),Rc.init(t,e)}),n0=S("$ZodGUID",(t,e)=>{e.pattern??(e.pattern=E$),oe.init(t,e)}),r0=S("$ZodUUID",(t,e)=>{if(e.version){const r={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[e.version];if(r===void 0)throw new Error(`Invalid UUID version: "${e.version}"`);e.pattern??(e.pattern=nd(r))}else e.pattern??(e.pattern=nd());oe.init(t,e)}),s0=S("$ZodEmail",(t,e)=>{e.pattern??(e.pattern=$$),oe.init(t,e)}),i0=S("$ZodURL",(t,e)=>{oe.init(t,e),t._zod.check=n=>{try{const r=n.value.trim(),s=new URL(r);e.hostname&&(e.hostname.lastIndex=0,e.hostname.test(s.hostname)||n.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:e.hostname.source,input:n.value,inst:t,continue:!e.abort})),e.protocol&&(e.protocol.lastIndex=0,e.protocol.test(s.protocol.endsWith(":")?s.protocol.slice(0,-1):s.protocol)||n.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:e.protocol.source,input:n.value,inst:t,continue:!e.abort})),e.normalize?n.value=s.href:n.value=r;return}catch{n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:t,continue:!e.abort})}}}),o0=S("$ZodEmoji",(t,e)=>{e.pattern??(e.pattern=x$()),oe.init(t,e)}),a0=S("$ZodNanoID",(t,e)=>{e.pattern??(e.pattern=S$),oe.init(t,e)}),l0=S("$ZodCUID",(t,e)=>{e.pattern??(e.pattern=v$),oe.init(t,e)}),c0=S("$ZodCUID2",(t,e)=>{e.pattern??(e.pattern=y$),oe.init(t,e)}),u0=S("$ZodULID",(t,e)=>{e.pattern??(e.pattern=b$),oe.init(t,e)}),h0=S("$ZodXID",(t,e)=>{e.pattern??(e.pattern=w$),oe.init(t,e)}),d0=S("$ZodKSUID",(t,e)=>{e.pattern??(e.pattern=_$),oe.init(t,e)}),f0=S("$ZodISODateTime",(t,e)=>{e.pattern??(e.pattern=L$(e)),oe.init(t,e)}),p0=S("$ZodISODate",(t,e)=>{e.pattern??(e.pattern=O$),oe.init(t,e)}),g0=S("$ZodISOTime",(t,e)=>{e.pattern??(e.pattern=z$(e)),oe.init(t,e)}),m0=S("$ZodISODuration",(t,e)=>{e.pattern??(e.pattern=k$),oe.init(t,e)}),v0=S("$ZodIPv4",(t,e)=>{e.pattern??(e.pattern=T$),oe.init(t,e),t._zod.bag.format="ipv4"}),y0=S("$ZodIPv6",(t,e)=>{e.pattern??(e.pattern=C$),oe.init(t,e),t._zod.bag.format="ipv6",t._zod.check=n=>{try{new URL(`http://[${n.value}]`)}catch{n.issues.push({code:"invalid_format",format:"ipv6",input:n.value,inst:t,continue:!e.abort})}}}),b0=S("$ZodCIDRv4",(t,e)=>{e.pattern??(e.pattern=I$),oe.init(t,e)}),w0=S("$ZodCIDRv6",(t,e)=>{e.pattern??(e.pattern=P$),oe.init(t,e),t._zod.check=n=>{const r=n.value.split("/");try{if(r.length!==2)throw new Error;const[s,i]=r;if(!i)throw new Error;const o=Number(i);if(`${o}`!==i)throw new Error;if(o<0||o>128)throw new Error;new URL(`http://[${s}]`)}catch{n.issues.push({code:"invalid_format",format:"cidrv6",input:n.value,inst:t,continue:!e.abort})}}});function Xp(t){if(t==="")return!0;if(t.length%4!==0)return!1;try{return atob(t),!0}catch{return!1}}const _0=S("$ZodBase64",(t,e)=>{e.pattern??(e.pattern=R$),oe.init(t,e),t._zod.bag.contentEncoding="base64",t._zod.check=n=>{Xp(n.value)||n.issues.push({code:"invalid_format",format:"base64",input:n.value,inst:t,continue:!e.abort})}});function S0(t){if(!Vp.test(t))return!1;const e=t.replace(/[-_]/g,r=>r==="-"?"+":"/"),n=e.padEnd(Math.ceil(e.length/4)*4,"=");return Xp(n)}const k0=S("$ZodBase64URL",(t,e)=>{e.pattern??(e.pattern=Vp),oe.init(t,e),t._zod.bag.contentEncoding="base64url",t._zod.check=n=>{S0(n.value)||n.issues.push({code:"invalid_format",format:"base64url",input:n.value,inst:t,continue:!e.abort})}}),E0=S("$ZodE164",(t,e)=>{e.pattern??(e.pattern=D$),oe.init(t,e)});function $0(t,e=null){try{const n=t.split(".");if(n.length!==3)return!1;const[r]=n;if(!r)return!1;const s=JSON.parse(atob(r));return!("typ"in s&&(s==null?void 0:s.typ)!=="JWT"||!s.alg||e&&(!("alg"in s)||s.alg!==e))}catch{return!1}}const A0=S("$ZodJWT",(t,e)=>{oe.init(t,e),t._zod.check=n=>{$0(n.value,e.alg)||n.issues.push({code:"invalid_format",format:"jwt",input:n.value,inst:t,continue:!e.abort})}}),Qp=S("$ZodNumber",(t,e)=>{le.init(t,e),t._zod.pattern=t._zod.bag.pattern??qp,t._zod.parse=(n,r)=>{if(e.coerce)try{n.value=Number(n.value)}catch{}const s=n.value;if(typeof s=="number"&&!Number.isNaN(s)&&Number.isFinite(s))return n;const i=typeof s=="number"?Number.isNaN(s)?"NaN":Number.isFinite(s)?void 0:"Infinity":void 0;return n.issues.push({expected:"number",code:"invalid_type",input:s,inst:t,...i?{received:i}:{}}),n}}),x0=S("$ZodNumberFormat",(t,e)=>{W$.init(t,e),Qp.init(t,e)}),T0=S("$ZodBoolean",(t,e)=>{le.init(t,e),t._zod.pattern=U$,t._zod.parse=(n,r)=>{if(e.coerce)try{n.value=!!n.value}catch{}const s=n.value;return typeof s=="boolean"||n.issues.push({expected:"boolean",code:"invalid_type",input:s,inst:t}),n}}),C0=S("$ZodUnknown",(t,e)=>{le.init(t,e),t._zod.parse=n=>n}),I0=S("$ZodNever",(t,e)=>{le.init(t,e),t._zod.parse=(n,r)=>(n.issues.push({expected:"never",code:"invalid_type",input:n.value,inst:t}),n)});function rd(t,e,n){t.issues.length&&e.issues.push(...yr(n,t.issues)),e.value[n]=t.value}const P0=S("$ZodArray",(t,e)=>{le.init(t,e),t._zod.parse=(n,r)=>{const s=n.value;if(!Array.isArray(s))return n.issues.push({expected:"array",code:"invalid_type",input:s,inst:t}),n;n.value=Array(s.length);const i=[];for(let o=0;o<s.length;o++){const a=s[o],l=e.element._zod.run({value:a,issues:[]},r);l instanceof Promise?i.push(l.then(c=>rd(c,n,o))):rd(l,n,o)}return i.length?Promise.all(i).then(()=>n):n}});function vo(t,e,n,r,s){if(t.issues.length){if(s&&!(n in r))return;e.issues.push(...yr(n,t.issues))}t.value===void 0?n in r&&(e.value[n]=void 0):e.value[n]=t.value}function eg(t){var r,s,i,o;const e=Object.keys(t.shape);for(const a of e)if(!((o=(i=(s=(r=t.shape)==null?void 0:r[a])==null?void 0:s._zod)==null?void 0:i.traits)!=null&&o.has("$ZodType")))throw new Error(`Invalid element at key "${a}": expected a Zod schema`);const n=KE(t.shape);return{...t,keys:e,keySet:new Set(e),numKeys:e.length,optionalKeys:new Set(n)}}function tg(t,e,n,r,s,i){const o=[],a=s.keySet,l=s.catchall._zod,c=l.def.type,d=l.optout==="optional";for(const f in e){if(a.has(f))continue;if(c==="never"){o.push(f);continue}const y=l.run({value:e[f],issues:[]},r);y instanceof Promise?t.push(y.then(m=>vo(m,n,f,e,d))):vo(y,n,f,e,d)}return o.length&&n.issues.push({code:"unrecognized_keys",keys:o,input:e,inst:i}),t.length?Promise.all(t).then(()=>n):n}const R0=S("$ZodObject",(t,e)=>{le.init(t,e);const n=Object.getOwnPropertyDescriptor(e,"shape");if(!(n!=null&&n.get)){const a=e.shape;Object.defineProperty(e,"shape",{get:()=>{const l={...a};return Object.defineProperty(e,"shape",{value:l}),l}})}const r=Ac(()=>eg(e));ee(t._zod,"propValues",()=>{const a=e.shape,l={};for(const c in a){const d=a[c]._zod;if(d.values){l[c]??(l[c]=new Set);for(const f of d.values)l[c].add(f)}}return l});const s=mo,i=e.catchall;let o;t._zod.parse=(a,l)=>{o??(o=r.value);const c=a.value;if(!s(c))return a.issues.push({expected:"object",code:"invalid_type",input:c,inst:t}),a;a.value={};const d=[],f=o.shape;for(const y of o.keys){const m=f[y],E=m._zod.optout==="optional",k=m._zod.run({value:c[y],issues:[]},l);k instanceof Promise?d.push(k.then(I=>vo(I,a,y,c,E))):vo(k,a,y,c,E)}return i?tg(d,c,a,l,r.value,t):d.length?Promise.all(d).then(()=>a):a}}),D0=S("$ZodObjectJIT",(t,e)=>{R0.init(t,e);const n=t._zod.parse,r=Ac(()=>eg(e)),s=y=>{var j;const m=new e0(["shape","payload","ctx"]),E=r.value,k=F=>{const L=td(F);return`shape[${L}]._zod.run({ value: input[${L}], issues: [] }, ctx)`};m.write("const input = payload.value;");const I=Object.create(null);let V=0;for(const F of E.keys)I[F]=`key_${V++}`;m.write("const newResult = {};");for(const F of E.keys){const L=I[F],J=td(F),H=y[F],he=((j=H==null?void 0:H._zod)==null?void 0:j.optout)==="optional";m.write(`const ${L} = ${k(F)};`),he?m.write(`
|
|
7
|
-
if (${L}.issues.length) {
|
|
8
|
-
if (${J} in input) {
|
|
9
|
-
payload.issues = payload.issues.concat(${L}.issues.map(iss => ({
|
|
10
|
-
...iss,
|
|
11
|
-
path: iss.path ? [${J}, ...iss.path] : [${J}]
|
|
12
|
-
})));
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
if (${L}.value === undefined) {
|
|
17
|
-
if (${J} in input) {
|
|
18
|
-
newResult[${J}] = undefined;
|
|
19
|
-
}
|
|
20
|
-
} else {
|
|
21
|
-
newResult[${J}] = ${L}.value;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
`):m.write(`
|
|
25
|
-
if (${L}.issues.length) {
|
|
26
|
-
payload.issues = payload.issues.concat(${L}.issues.map(iss => ({
|
|
27
|
-
...iss,
|
|
28
|
-
path: iss.path ? [${J}, ...iss.path] : [${J}]
|
|
29
|
-
})));
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
if (${L}.value === undefined) {
|
|
33
|
-
if (${J} in input) {
|
|
34
|
-
newResult[${J}] = undefined;
|
|
35
|
-
}
|
|
36
|
-
} else {
|
|
37
|
-
newResult[${J}] = ${L}.value;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
`)}m.write("payload.value = newResult;"),m.write("return payload;");const N=m.compile();return(F,L)=>N(y,F,L)};let i;const o=mo,a=!Np.jitless,c=a&&qE.value,d=e.catchall;let f;t._zod.parse=(y,m)=>{f??(f=r.value);const E=y.value;return o(E)?a&&c&&(m==null?void 0:m.async)===!1&&m.jitless!==!0?(i||(i=s(e.shape)),y=i(y,m),d?tg([],E,y,m,f,t):y):n(y,m):(y.issues.push({expected:"object",code:"invalid_type",input:E,inst:t}),y)}});function sd(t,e,n,r){for(const i of t)if(i.issues.length===0)return e.value=i.value,e;const s=t.filter(i=>!vr(i));return s.length===1?(e.value=s[0].value,s[0]):(e.issues.push({code:"invalid_union",input:e.value,inst:n,errors:t.map(i=>i.issues.map(o=>ln(o,r,an())))}),e)}const O0=S("$ZodUnion",(t,e)=>{le.init(t,e),ee(t._zod,"optin",()=>e.options.some(s=>s._zod.optin==="optional")?"optional":void 0),ee(t._zod,"optout",()=>e.options.some(s=>s._zod.optout==="optional")?"optional":void 0),ee(t._zod,"values",()=>{if(e.options.every(s=>s._zod.values))return new Set(e.options.flatMap(s=>Array.from(s._zod.values)))}),ee(t._zod,"pattern",()=>{if(e.options.every(s=>s._zod.pattern)){const s=e.options.map(i=>i._zod.pattern);return new RegExp(`^(${s.map(i=>Tc(i.source)).join("|")})$`)}});const n=e.options.length===1,r=e.options[0]._zod.run;t._zod.parse=(s,i)=>{if(n)return r(s,i);let o=!1;const a=[];for(const l of e.options){const c=l._zod.run({value:s.value,issues:[]},i);if(c instanceof Promise)a.push(c),o=!0;else{if(c.issues.length===0)return c;a.push(c)}}return o?Promise.all(a).then(l=>sd(l,s,t,i)):sd(a,s,t,i)}}),z0=S("$ZodIntersection",(t,e)=>{le.init(t,e),t._zod.parse=(n,r)=>{const s=n.value,i=e.left._zod.run({value:s,issues:[]},r),o=e.right._zod.run({value:s,issues:[]},r);return i instanceof Promise||o instanceof Promise?Promise.all([i,o]).then(([l,c])=>id(n,l,c)):id(n,i,o)}});function yl(t,e){if(t===e)return{valid:!0,data:t};if(t instanceof Date&&e instanceof Date&&+t==+e)return{valid:!0,data:t};if(Or(t)&&Or(e)){const n=Object.keys(e),r=Object.keys(t).filter(i=>n.indexOf(i)!==-1),s={...t,...e};for(const i of r){const o=yl(t[i],e[i]);if(!o.valid)return{valid:!1,mergeErrorPath:[i,...o.mergeErrorPath]};s[i]=o.data}return{valid:!0,data:s}}if(Array.isArray(t)&&Array.isArray(e)){if(t.length!==e.length)return{valid:!1,mergeErrorPath:[]};const n=[];for(let r=0;r<t.length;r++){const s=t[r],i=e[r],o=yl(s,i);if(!o.valid)return{valid:!1,mergeErrorPath:[r,...o.mergeErrorPath]};n.push(o.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function id(t,e,n){const r=new Map;let s;for(const a of e.issues)if(a.code==="unrecognized_keys"){s??(s=a);for(const l of a.keys)r.has(l)||r.set(l,{}),r.get(l).l=!0}else t.issues.push(a);for(const a of n.issues)if(a.code==="unrecognized_keys")for(const l of a.keys)r.has(l)||r.set(l,{}),r.get(l).r=!0;else t.issues.push(a);const i=[...r].filter(([,a])=>a.l&&a.r).map(([a])=>a);if(i.length&&s&&t.issues.push({...s,keys:i}),vr(t))return t;const o=yl(e.value,n.value);if(!o.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(o.mergeErrorPath)}`);return t.value=o.data,t}const L0=S("$ZodRecord",(t,e)=>{le.init(t,e),t._zod.parse=(n,r)=>{const s=n.value;if(!Or(s))return n.issues.push({expected:"record",code:"invalid_type",input:s,inst:t}),n;const i=[],o=e.keyType._zod.values;if(o){n.value={};const a=new Set;for(const c of o)if(typeof c=="string"||typeof c=="number"||typeof c=="symbol"){a.add(typeof c=="number"?c.toString():c);const d=e.valueType._zod.run({value:s[c],issues:[]},r);d instanceof Promise?i.push(d.then(f=>{f.issues.length&&n.issues.push(...yr(c,f.issues)),n.value[c]=f.value})):(d.issues.length&&n.issues.push(...yr(c,d.issues)),n.value[c]=d.value)}let l;for(const c in s)a.has(c)||(l=l??[],l.push(c));l&&l.length>0&&n.issues.push({code:"unrecognized_keys",input:s,inst:t,keys:l})}else{n.value={};for(const a of Reflect.ownKeys(s)){if(a==="__proto__")continue;let l=e.keyType._zod.run({value:a,issues:[]},r);if(l instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(typeof a=="string"&&qp.test(a)&&l.issues.length){const f=e.keyType._zod.run({value:Number(a),issues:[]},r);if(f instanceof Promise)throw new Error("Async schemas not supported in object keys currently");f.issues.length===0&&(l=f)}if(l.issues.length){e.mode==="loose"?n.value[a]=s[a]:n.issues.push({code:"invalid_key",origin:"record",issues:l.issues.map(f=>ln(f,r,an())),input:a,path:[a],inst:t});continue}const d=e.valueType._zod.run({value:s[a],issues:[]},r);d instanceof Promise?i.push(d.then(f=>{f.issues.length&&n.issues.push(...yr(a,f.issues)),n.value[l.value]=f.value})):(d.issues.length&&n.issues.push(...yr(a,d.issues)),n.value[l.value]=d.value)}}return i.length?Promise.all(i).then(()=>n):n}}),M0=S("$ZodEnum",(t,e)=>{le.init(t,e);const n=Up(e.entries),r=new Set(n);t._zod.values=r,t._zod.pattern=new RegExp(`^(${n.filter(s=>YE.has(typeof s)).map(s=>typeof s=="string"?zr(s):s.toString()).join("|")})$`),t._zod.parse=(s,i)=>{const o=s.value;return r.has(o)||s.issues.push({code:"invalid_value",values:n,input:o,inst:t}),s}}),N0=S("$ZodLiteral",(t,e)=>{if(le.init(t,e),e.values.length===0)throw new Error("Cannot create literal schema with no valid values");const n=new Set(e.values);t._zod.values=n,t._zod.pattern=new RegExp(`^(${e.values.map(r=>typeof r=="string"?zr(r):r?zr(r.toString()):String(r)).join("|")})$`),t._zod.parse=(r,s)=>{const i=r.value;return n.has(i)||r.issues.push({code:"invalid_value",values:e.values,input:i,inst:t}),r}}),U0=S("$ZodTransform",(t,e)=>{le.init(t,e),t._zod.parse=(n,r)=>{if(r.direction==="backward")throw new Mp(t.constructor.name);const s=e.transform(n.value,n);if(r.async)return(s instanceof Promise?s:Promise.resolve(s)).then(o=>(n.value=o,n));if(s instanceof Promise)throw new wr;return n.value=s,n}});function od(t,e){return t.issues.length&&e===void 0?{issues:[],value:void 0}:t}const ng=S("$ZodOptional",(t,e)=>{le.init(t,e),t._zod.optin="optional",t._zod.optout="optional",ee(t._zod,"values",()=>e.innerType._zod.values?new Set([...e.innerType._zod.values,void 0]):void 0),ee(t._zod,"pattern",()=>{const n=e.innerType._zod.pattern;return n?new RegExp(`^(${Tc(n.source)})?$`):void 0}),t._zod.parse=(n,r)=>{if(e.innerType._zod.optin==="optional"){const s=e.innerType._zod.run(n,r);return s instanceof Promise?s.then(i=>od(i,n.value)):od(s,n.value)}return n.value===void 0?n:e.innerType._zod.run(n,r)}}),F0=S("$ZodExactOptional",(t,e)=>{ng.init(t,e),ee(t._zod,"values",()=>e.innerType._zod.values),ee(t._zod,"pattern",()=>e.innerType._zod.pattern),t._zod.parse=(n,r)=>e.innerType._zod.run(n,r)}),Z0=S("$ZodNullable",(t,e)=>{le.init(t,e),ee(t._zod,"optin",()=>e.innerType._zod.optin),ee(t._zod,"optout",()=>e.innerType._zod.optout),ee(t._zod,"pattern",()=>{const n=e.innerType._zod.pattern;return n?new RegExp(`^(${Tc(n.source)}|null)$`):void 0}),ee(t._zod,"values",()=>e.innerType._zod.values?new Set([...e.innerType._zod.values,null]):void 0),t._zod.parse=(n,r)=>n.value===null?n:e.innerType._zod.run(n,r)}),j0=S("$ZodDefault",(t,e)=>{le.init(t,e),t._zod.optin="optional",ee(t._zod,"values",()=>e.innerType._zod.values),t._zod.parse=(n,r)=>{if(r.direction==="backward")return e.innerType._zod.run(n,r);if(n.value===void 0)return n.value=e.defaultValue,n;const s=e.innerType._zod.run(n,r);return s instanceof Promise?s.then(i=>ad(i,e)):ad(s,e)}});function ad(t,e){return t.value===void 0&&(t.value=e.defaultValue),t}const W0=S("$ZodPrefault",(t,e)=>{le.init(t,e),t._zod.optin="optional",ee(t._zod,"values",()=>e.innerType._zod.values),t._zod.parse=(n,r)=>(r.direction==="backward"||n.value===void 0&&(n.value=e.defaultValue),e.innerType._zod.run(n,r))}),B0=S("$ZodNonOptional",(t,e)=>{le.init(t,e),ee(t._zod,"values",()=>{const n=e.innerType._zod.values;return n?new Set([...n].filter(r=>r!==void 0)):void 0}),t._zod.parse=(n,r)=>{const s=e.innerType._zod.run(n,r);return s instanceof Promise?s.then(i=>ld(i,t)):ld(s,t)}});function ld(t,e){return!t.issues.length&&t.value===void 0&&t.issues.push({code:"invalid_type",expected:"nonoptional",input:t.value,inst:e}),t}const V0=S("$ZodCatch",(t,e)=>{le.init(t,e),ee(t._zod,"optin",()=>e.innerType._zod.optin),ee(t._zod,"optout",()=>e.innerType._zod.optout),ee(t._zod,"values",()=>e.innerType._zod.values),t._zod.parse=(n,r)=>{if(r.direction==="backward")return e.innerType._zod.run(n,r);const s=e.innerType._zod.run(n,r);return s instanceof Promise?s.then(i=>(n.value=i.value,i.issues.length&&(n.value=e.catchValue({...n,error:{issues:i.issues.map(o=>ln(o,r,an()))},input:n.value}),n.issues=[]),n)):(n.value=s.value,s.issues.length&&(n.value=e.catchValue({...n,error:{issues:s.issues.map(i=>ln(i,r,an()))},input:n.value}),n.issues=[]),n)}}),G0=S("$ZodPipe",(t,e)=>{le.init(t,e),ee(t._zod,"values",()=>e.in._zod.values),ee(t._zod,"optin",()=>e.in._zod.optin),ee(t._zod,"optout",()=>e.out._zod.optout),ee(t._zod,"propValues",()=>e.in._zod.propValues),t._zod.parse=(n,r)=>{if(r.direction==="backward"){const i=e.out._zod.run(n,r);return i instanceof Promise?i.then(o=>Ni(o,e.in,r)):Ni(i,e.in,r)}const s=e.in._zod.run(n,r);return s instanceof Promise?s.then(i=>Ni(i,e.out,r)):Ni(s,e.out,r)}});function Ni(t,e,n){return t.issues.length?(t.aborted=!0,t):e._zod.run({value:t.value,issues:t.issues},n)}const H0=S("$ZodReadonly",(t,e)=>{le.init(t,e),ee(t._zod,"propValues",()=>e.innerType._zod.propValues),ee(t._zod,"values",()=>e.innerType._zod.values),ee(t._zod,"optin",()=>{var n,r;return(r=(n=e.innerType)==null?void 0:n._zod)==null?void 0:r.optin}),ee(t._zod,"optout",()=>{var n,r;return(r=(n=e.innerType)==null?void 0:n._zod)==null?void 0:r.optout}),t._zod.parse=(n,r)=>{if(r.direction==="backward")return e.innerType._zod.run(n,r);const s=e.innerType._zod.run(n,r);return s instanceof Promise?s.then(cd):cd(s)}});function cd(t){return t.value=Object.freeze(t.value),t}const q0=S("$ZodCustom",(t,e)=>{Ve.init(t,e),le.init(t,e),t._zod.parse=(n,r)=>n,t._zod.check=n=>{const r=n.value,s=e.fn(r);if(s instanceof Promise)return s.then(i=>ud(i,n,r,t));ud(s,n,r,t)}});function ud(t,e,n,r){if(!t){const s={code:"custom",input:n,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(s.params=r._zod.def.params),e.issues.push(xs(s))}}var hd;class Y0{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...n){const r=n[0];return this._map.set(e,r),r&&typeof r=="object"&&"id"in r&&this._idmap.set(r.id,e),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(e){const n=this._map.get(e);return n&&typeof n=="object"&&"id"in n&&this._idmap.delete(n.id),this._map.delete(e),this}get(e){const n=e._zod.parent;if(n){const r={...this.get(n)??{}};delete r.id;const s={...r,...this._map.get(e)};return Object.keys(s).length?s:void 0}return this._map.get(e)}has(e){return this._map.has(e)}}function K0(){return new Y0}(hd=globalThis).__zod_globalRegistry??(hd.__zod_globalRegistry=K0());const ps=globalThis.__zod_globalRegistry;function J0(t,e){return new t({type:"string",...D(e)})}function X0(t,e){return new t({type:"string",format:"email",check:"string_format",abort:!1,...D(e)})}function dd(t,e){return new t({type:"string",format:"guid",check:"string_format",abort:!1,...D(e)})}function Q0(t,e){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,...D(e)})}function eA(t,e){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...D(e)})}function tA(t,e){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...D(e)})}function nA(t,e){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...D(e)})}function rA(t,e){return new t({type:"string",format:"url",check:"string_format",abort:!1,...D(e)})}function sA(t,e){return new t({type:"string",format:"emoji",check:"string_format",abort:!1,...D(e)})}function iA(t,e){return new t({type:"string",format:"nanoid",check:"string_format",abort:!1,...D(e)})}function oA(t,e){return new t({type:"string",format:"cuid",check:"string_format",abort:!1,...D(e)})}function aA(t,e){return new t({type:"string",format:"cuid2",check:"string_format",abort:!1,...D(e)})}function lA(t,e){return new t({type:"string",format:"ulid",check:"string_format",abort:!1,...D(e)})}function cA(t,e){return new t({type:"string",format:"xid",check:"string_format",abort:!1,...D(e)})}function uA(t,e){return new t({type:"string",format:"ksuid",check:"string_format",abort:!1,...D(e)})}function hA(t,e){return new t({type:"string",format:"ipv4",check:"string_format",abort:!1,...D(e)})}function dA(t,e){return new t({type:"string",format:"ipv6",check:"string_format",abort:!1,...D(e)})}function fA(t,e){return new t({type:"string",format:"cidrv4",check:"string_format",abort:!1,...D(e)})}function pA(t,e){return new t({type:"string",format:"cidrv6",check:"string_format",abort:!1,...D(e)})}function gA(t,e){return new t({type:"string",format:"base64",check:"string_format",abort:!1,...D(e)})}function mA(t,e){return new t({type:"string",format:"base64url",check:"string_format",abort:!1,...D(e)})}function vA(t,e){return new t({type:"string",format:"e164",check:"string_format",abort:!1,...D(e)})}function yA(t,e){return new t({type:"string",format:"jwt",check:"string_format",abort:!1,...D(e)})}function bA(t,e){return new t({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...D(e)})}function wA(t,e){return new t({type:"string",format:"date",check:"string_format",...D(e)})}function _A(t,e){return new t({type:"string",format:"time",check:"string_format",precision:null,...D(e)})}function SA(t,e){return new t({type:"string",format:"duration",check:"string_format",...D(e)})}function kA(t,e){return new t({type:"number",checks:[],...D(e)})}function EA(t,e){return new t({type:"number",check:"number_format",abort:!1,format:"safeint",...D(e)})}function $A(t,e){return new t({type:"boolean",...D(e)})}function AA(t){return new t({type:"unknown"})}function xA(t,e){return new t({type:"never",...D(e)})}function fd(t,e){return new Kp({check:"less_than",...D(e),value:t,inclusive:!1})}function Za(t,e){return new Kp({check:"less_than",...D(e),value:t,inclusive:!0})}function pd(t,e){return new Jp({check:"greater_than",...D(e),value:t,inclusive:!1})}function ja(t,e){return new Jp({check:"greater_than",...D(e),value:t,inclusive:!0})}function gd(t,e){return new j$({check:"multiple_of",...D(e),value:t})}function rg(t,e){return new B$({check:"max_length",...D(e),maximum:t})}function yo(t,e){return new V$({check:"min_length",...D(e),minimum:t})}function sg(t,e){return new G$({check:"length_equals",...D(e),length:t})}function TA(t,e){return new H$({check:"string_format",format:"regex",...D(e),pattern:t})}function CA(t){return new q$({check:"string_format",format:"lowercase",...D(t)})}function IA(t){return new Y$({check:"string_format",format:"uppercase",...D(t)})}function PA(t,e){return new K$({check:"string_format",format:"includes",...D(e),includes:t})}function RA(t,e){return new J$({check:"string_format",format:"starts_with",...D(e),prefix:t})}function DA(t,e){return new X$({check:"string_format",format:"ends_with",...D(e),suffix:t})}function Hr(t){return new Q$({check:"overwrite",tx:t})}function OA(t){return Hr(e=>e.normalize(t))}function zA(){return Hr(t=>t.trim())}function LA(){return Hr(t=>t.toLowerCase())}function MA(){return Hr(t=>t.toUpperCase())}function NA(){return Hr(t=>HE(t))}function UA(t,e,n){return new t({type:"array",element:e,...D(n)})}function FA(t,e,n){return new t({type:"custom",check:"custom",fn:e,...D(n)})}function ZA(t){const e=jA(n=>(n.addIssue=r=>{if(typeof r=="string")n.issues.push(xs(r,n.value,e._zod.def));else{const s=r;s.fatal&&(s.continue=!1),s.code??(s.code="custom"),s.input??(s.input=n.value),s.inst??(s.inst=e),s.continue??(s.continue=!e._zod.def.abort),n.issues.push(xs(s))}},t(n.value,n)));return e}function jA(t,e){const n=new Ve({check:"custom",...D(e)});return n._zod.check=t,n}function ig(t){let e=(t==null?void 0:t.target)??"draft-2020-12";return e==="draft-4"&&(e="draft-04"),e==="draft-7"&&(e="draft-07"),{processors:t.processors??{},metadataRegistry:(t==null?void 0:t.metadata)??ps,target:e,unrepresentable:(t==null?void 0:t.unrepresentable)??"throw",override:(t==null?void 0:t.override)??(()=>{}),io:(t==null?void 0:t.io)??"output",counter:0,seen:new Map,cycles:(t==null?void 0:t.cycles)??"ref",reused:(t==null?void 0:t.reused)??"inline",external:(t==null?void 0:t.external)??void 0}}function me(t,e,n={path:[],schemaPath:[]}){var d,f;var r;const s=t._zod.def,i=e.seen.get(t);if(i)return i.count++,n.schemaPath.includes(t)&&(i.cycle=n.path),i.schema;const o={schema:{},count:1,cycle:void 0,path:n.path};e.seen.set(t,o);const a=(f=(d=t._zod).toJSONSchema)==null?void 0:f.call(d);if(a)o.schema=a;else{const y={...n,schemaPath:[...n.schemaPath,t],path:n.path};if(t._zod.processJSONSchema)t._zod.processJSONSchema(e,o.schema,y);else{const E=o.schema,k=e.processors[s.type];if(!k)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${s.type}`);k(t,e,E,y)}const m=t._zod.parent;m&&(o.ref||(o.ref=m),me(m,e,y),e.seen.get(m).isParent=!0)}const l=e.metadataRegistry.get(t);return l&&Object.assign(o.schema,l),e.io==="input"&&De(t)&&(delete o.schema.examples,delete o.schema.default),e.io==="input"&&o.schema._prefault&&((r=o.schema).default??(r.default=o.schema._prefault)),delete o.schema._prefault,e.seen.get(t).schema}function og(t,e){var o,a,l,c;const n=t.seen.get(e);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");const r=new Map;for(const d of t.seen.entries()){const f=(o=t.metadataRegistry.get(d[0]))==null?void 0:o.id;if(f){const y=r.get(f);if(y&&y!==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 s=d=>{var k;const f=t.target==="draft-2020-12"?"$defs":"definitions";if(t.external){const I=(k=t.external.registry.get(d[0]))==null?void 0:k.id,V=t.external.uri??(j=>j);if(I)return{ref:V(I)};const N=d[1].defId??d[1].schema.id??`schema${t.counter++}`;return d[1].defId=N,{defId:N,ref:`${V("__shared")}#/${f}/${N}`}}if(d[1]===n)return{ref:"#"};const m=`#/${f}/`,E=d[1].schema.id??`__schema${t.counter++}`;return{defId:E,ref:m+E}},i=d=>{if(d[1].schema.$ref)return;const f=d[1],{ref:y,defId:m}=s(d);f.def={...f.schema},m&&(f.defId=m);const E=f.schema;for(const k in E)delete E[k];E.$ref=y};if(t.cycles==="throw")for(const d of t.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 t.seen.entries()){const f=d[1];if(e===d[0]){i(d);continue}if(t.external){const m=(l=t.external.registry.get(d[0]))==null?void 0:l.id;if(e!==d[0]&&m){i(d);continue}}if((c=t.metadataRegistry.get(d[0]))==null?void 0:c.id){i(d);continue}if(f.cycle){i(d);continue}if(f.count>1&&t.reused==="ref"){i(d);continue}}}function ag(t,e){var o,a,l;const n=t.seen.get(e);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");const r=c=>{const d=t.seen.get(c);if(d.ref===null)return;const f=d.def??d.schema,y={...f},m=d.ref;if(d.ref=null,m){r(m);const k=t.seen.get(m),I=k.schema;if(I.$ref&&(t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0")?(f.allOf=f.allOf??[],f.allOf.push(I)):Object.assign(f,I),Object.assign(f,y),c._zod.parent===m)for(const N in f)N==="$ref"||N==="allOf"||N in y||delete f[N];if(I.$ref&&k.def)for(const N in f)N==="$ref"||N==="allOf"||N in k.def&&JSON.stringify(f[N])===JSON.stringify(k.def[N])&&delete f[N]}const E=c._zod.parent;if(E&&E!==m){r(E);const k=t.seen.get(E);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]}t.override({zodSchema:c,jsonSchema:f,path:d.path??[]})};for(const c of[...t.seen.entries()].reverse())r(c[0]);const s={};if(t.target==="draft-2020-12"?s.$schema="https://json-schema.org/draft/2020-12/schema":t.target==="draft-07"?s.$schema="http://json-schema.org/draft-07/schema#":t.target==="draft-04"?s.$schema="http://json-schema.org/draft-04/schema#":t.target,(o=t.external)!=null&&o.uri){const c=(a=t.external.registry.get(e))==null?void 0:a.id;if(!c)throw new Error("Schema is missing an `id` property");s.$id=t.external.uri(c)}Object.assign(s,n.def??n.schema);const i=((l=t.external)==null?void 0:l.defs)??{};for(const c of t.seen.entries()){const d=c[1];d.def&&d.defId&&(i[d.defId]=d.def)}t.external||Object.keys(i).length>0&&(t.target==="draft-2020-12"?s.$defs=i:s.definitions=i);try{const c=JSON.parse(JSON.stringify(s));return Object.defineProperty(c,"~standard",{value:{...e["~standard"],jsonSchema:{input:bo(e,"input",t.processors),output:bo(e,"output",t.processors)}},enumerable:!1,writable:!1}),c}catch{throw new Error("Error converting schema to JSON.")}}function De(t,e){const n=e??{seen:new Set};if(n.seen.has(t))return!1;n.seen.add(t);const r=t._zod.def;if(r.type==="transform")return!0;if(r.type==="array")return De(r.element,n);if(r.type==="set")return De(r.valueType,n);if(r.type==="lazy")return De(r.getter(),n);if(r.type==="promise"||r.type==="optional"||r.type==="nonoptional"||r.type==="nullable"||r.type==="readonly"||r.type==="default"||r.type==="prefault")return De(r.innerType,n);if(r.type==="intersection")return De(r.left,n)||De(r.right,n);if(r.type==="record"||r.type==="map")return De(r.keyType,n)||De(r.valueType,n);if(r.type==="pipe")return De(r.in,n)||De(r.out,n);if(r.type==="object"){for(const s in r.shape)if(De(r.shape[s],n))return!0;return!1}if(r.type==="union"){for(const s of r.options)if(De(s,n))return!0;return!1}if(r.type==="tuple"){for(const s of r.items)if(De(s,n))return!0;return!!(r.rest&&De(r.rest,n))}return!1}const WA=(t,e={})=>n=>{const r=ig({...n,processors:e});return me(t,r),og(r,t),ag(r,t)},bo=(t,e,n={})=>r=>{const{libraryOptions:s,target:i}=r??{},o=ig({...s??{},target:i,io:e,processors:n});return me(t,o),og(o,t),ag(o,t)},BA={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},VA=(t,e,n,r)=>{const s=n;s.type="string";const{minimum:i,maximum:o,format:a,patterns:l,contentEncoding:c}=t._zod.bag;if(typeof i=="number"&&(s.minLength=i),typeof o=="number"&&(s.maxLength=o),a&&(s.format=BA[a]??a,s.format===""&&delete s.format,a==="time"&&delete s.format),c&&(s.contentEncoding=c),l&&l.size>0){const d=[...l];d.length===1?s.pattern=d[0].source:d.length>1&&(s.allOf=[...d.map(f=>({...e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0"?{type:"string"}:{},pattern:f.source}))])}},GA=(t,e,n,r)=>{const s=n,{minimum:i,maximum:o,format:a,multipleOf:l,exclusiveMaximum:c,exclusiveMinimum:d}=t._zod.bag;typeof a=="string"&&a.includes("int")?s.type="integer":s.type="number",typeof d=="number"&&(e.target==="draft-04"||e.target==="openapi-3.0"?(s.minimum=d,s.exclusiveMinimum=!0):s.exclusiveMinimum=d),typeof i=="number"&&(s.minimum=i,typeof d=="number"&&e.target!=="draft-04"&&(d>=i?delete s.minimum:delete s.exclusiveMinimum)),typeof c=="number"&&(e.target==="draft-04"||e.target==="openapi-3.0"?(s.maximum=c,s.exclusiveMaximum=!0):s.exclusiveMaximum=c),typeof o=="number"&&(s.maximum=o,typeof c=="number"&&e.target!=="draft-04"&&(c<=o?delete s.maximum:delete s.exclusiveMaximum)),typeof l=="number"&&(s.multipleOf=l)},HA=(t,e,n,r)=>{n.type="boolean"},qA=(t,e,n,r)=>{n.not={}},YA=(t,e,n,r)=>{},KA=(t,e,n,r)=>{const s=t._zod.def,i=Up(s.entries);i.every(o=>typeof o=="number")&&(n.type="number"),i.every(o=>typeof o=="string")&&(n.type="string"),n.enum=i},JA=(t,e,n,r)=>{const s=t._zod.def,i=[];for(const o of s.values)if(o===void 0){if(e.unrepresentable==="throw")throw new Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof o=="bigint"){if(e.unrepresentable==="throw")throw new Error("BigInt literals cannot be represented in JSON Schema");i.push(Number(o))}else i.push(o);if(i.length!==0)if(i.length===1){const o=i[0];n.type=o===null?"null":typeof o,e.target==="draft-04"||e.target==="openapi-3.0"?n.enum=[o]:n.const=o}else i.every(o=>typeof o=="number")&&(n.type="number"),i.every(o=>typeof o=="string")&&(n.type="string"),i.every(o=>typeof o=="boolean")&&(n.type="boolean"),i.every(o=>o===null)&&(n.type="null"),n.enum=i},XA=(t,e,n,r)=>{if(e.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema")},QA=(t,e,n,r)=>{if(e.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema")},ex=(t,e,n,r)=>{const s=n,i=t._zod.def,{minimum:o,maximum:a}=t._zod.bag;typeof o=="number"&&(s.minItems=o),typeof a=="number"&&(s.maxItems=a),s.type="array",s.items=me(i.element,e,{...r,path:[...r.path,"items"]})},tx=(t,e,n,r)=>{var c;const s=n,i=t._zod.def;s.type="object",s.properties={};const o=i.shape;for(const d in o)s.properties[d]=me(o[d],e,{...r,path:[...r.path,"properties",d]});const a=new Set(Object.keys(o)),l=new Set([...a].filter(d=>{const f=i.shape[d]._zod;return e.io==="input"?f.optin===void 0:f.optout===void 0}));l.size>0&&(s.required=Array.from(l)),((c=i.catchall)==null?void 0:c._zod.def.type)==="never"?s.additionalProperties=!1:i.catchall?i.catchall&&(s.additionalProperties=me(i.catchall,e,{...r,path:[...r.path,"additionalProperties"]})):e.io==="output"&&(s.additionalProperties=!1)},nx=(t,e,n,r)=>{const s=t._zod.def,i=s.inclusive===!1,o=s.options.map((a,l)=>me(a,e,{...r,path:[...r.path,i?"oneOf":"anyOf",l]}));i?n.oneOf=o:n.anyOf=o},rx=(t,e,n,r)=>{const s=t._zod.def,i=me(s.left,e,{...r,path:[...r.path,"allOf",0]}),o=me(s.right,e,{...r,path:[...r.path,"allOf",1]}),a=c=>"allOf"in c&&Object.keys(c).length===1,l=[...a(i)?i.allOf:[i],...a(o)?o.allOf:[o]];n.allOf=l},sx=(t,e,n,r)=>{const s=n,i=t._zod.def;s.type="object";const o=i.keyType,a=o._zod.bag,l=a==null?void 0:a.patterns;if(i.mode==="loose"&&l&&l.size>0){const d=me(i.valueType,e,{...r,path:[...r.path,"patternProperties","*"]});s.patternProperties={};for(const f of l)s.patternProperties[f.source]=d}else(e.target==="draft-07"||e.target==="draft-2020-12")&&(s.propertyNames=me(i.keyType,e,{...r,path:[...r.path,"propertyNames"]})),s.additionalProperties=me(i.valueType,e,{...r,path:[...r.path,"additionalProperties"]});const c=o._zod.values;if(c){const d=[...c].filter(f=>typeof f=="string"||typeof f=="number");d.length>0&&(s.required=d)}},ix=(t,e,n,r)=>{const s=t._zod.def,i=me(s.innerType,e,r),o=e.seen.get(t);e.target==="openapi-3.0"?(o.ref=s.innerType,n.nullable=!0):n.anyOf=[i,{type:"null"}]},ox=(t,e,n,r)=>{const s=t._zod.def;me(s.innerType,e,r);const i=e.seen.get(t);i.ref=s.innerType},ax=(t,e,n,r)=>{const s=t._zod.def;me(s.innerType,e,r);const i=e.seen.get(t);i.ref=s.innerType,n.default=JSON.parse(JSON.stringify(s.defaultValue))},lx=(t,e,n,r)=>{const s=t._zod.def;me(s.innerType,e,r);const i=e.seen.get(t);i.ref=s.innerType,e.io==="input"&&(n._prefault=JSON.parse(JSON.stringify(s.defaultValue)))},cx=(t,e,n,r)=>{const s=t._zod.def;me(s.innerType,e,r);const i=e.seen.get(t);i.ref=s.innerType;let o;try{o=s.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}n.default=o},ux=(t,e,n,r)=>{const s=t._zod.def,i=e.io==="input"?s.in._zod.def.type==="transform"?s.out:s.in:s.out;me(i,e,r);const o=e.seen.get(t);o.ref=i},hx=(t,e,n,r)=>{const s=t._zod.def;me(s.innerType,e,r);const i=e.seen.get(t);i.ref=s.innerType,n.readOnly=!0},lg=(t,e,n,r)=>{const s=t._zod.def;me(s.innerType,e,r);const i=e.seen.get(t);i.ref=s.innerType},dx=S("ZodISODateTime",(t,e)=>{f0.init(t,e),ue.init(t,e)});function fx(t){return bA(dx,t)}const px=S("ZodISODate",(t,e)=>{p0.init(t,e),ue.init(t,e)});function gx(t){return wA(px,t)}const mx=S("ZodISOTime",(t,e)=>{g0.init(t,e),ue.init(t,e)});function vx(t){return _A(mx,t)}const yx=S("ZodISODuration",(t,e)=>{m0.init(t,e),ue.init(t,e)});function bx(t){return SA(yx,t)}const cg=(t,e)=>{Wp.init(t,e),t.name="ZodError",Object.defineProperties(t,{format:{value:n=>o$(t,n)},flatten:{value:n=>i$(t,n)},addIssue:{value:n=>{t.issues.push(n),t.message=JSON.stringify(t.issues,vl,2)}},addIssues:{value:n=>{t.issues.push(...n),t.message=JSON.stringify(t.issues,vl,2)}},isEmpty:{get(){return t.issues.length===0}}})},md=S("ZodError",cg),nt=S("ZodError",cg,{Parent:Error}),wx=Ic(nt),_x=Pc(nt),Sx=Wo(nt),kx=Bo(nt),Ex=c$(nt),$x=u$(nt),Ax=h$(nt),xx=d$(nt),Tx=f$(nt),Cx=p$(nt),Ix=g$(nt),Px=m$(nt),ce=S("ZodType",(t,e)=>(le.init(t,e),Object.assign(t["~standard"],{jsonSchema:{input:bo(t,"input"),output:bo(t,"output")}}),t.toJSONSchema=WA(t,{}),t.def=e,t.type=e.type,Object.defineProperty(t,"_def",{value:e}),t.check=(...n)=>t.clone(fn(e,{checks:[...e.checks??[],...n.map(r=>typeof r=="function"?{_zod:{check:r,def:{check:"custom"},onattach:[]}}:r)]}),{parent:!0}),t.with=t.check,t.clone=(n,r)=>pn(t,n,r),t.brand=()=>t,t.register=(n,r)=>(n.add(t,r),t),t.parse=(n,r)=>wx(t,n,r,{callee:t.parse}),t.safeParse=(n,r)=>Sx(t,n,r),t.parseAsync=async(n,r)=>_x(t,n,r,{callee:t.parseAsync}),t.safeParseAsync=async(n,r)=>kx(t,n,r),t.spa=t.safeParseAsync,t.encode=(n,r)=>Ex(t,n,r),t.decode=(n,r)=>$x(t,n,r),t.encodeAsync=async(n,r)=>Ax(t,n,r),t.decodeAsync=async(n,r)=>xx(t,n,r),t.safeEncode=(n,r)=>Tx(t,n,r),t.safeDecode=(n,r)=>Cx(t,n,r),t.safeEncodeAsync=async(n,r)=>Ix(t,n,r),t.safeDecodeAsync=async(n,r)=>Px(t,n,r),t.refine=(n,r)=>t.check(ST(n,r)),t.superRefine=n=>t.check(kT(n)),t.overwrite=n=>t.check(Hr(n)),t.optional=()=>bd(t),t.exactOptional=()=>cT(t),t.nullable=()=>wd(t),t.nullish=()=>bd(wd(t)),t.nonoptional=n=>gT(t,n),t.array=()=>R(t),t.or=n=>Z([t,n]),t.and=n=>Go(t,n),t.transform=n=>_d(t,aT(n)),t.default=n=>dT(t,n),t.prefault=n=>pT(t,n),t.catch=n=>vT(t,n),t.pipe=n=>_d(t,n),t.readonly=()=>wT(t),t.describe=n=>{const r=t.clone();return ps.add(r,{description:n}),r},Object.defineProperty(t,"description",{get(){var n;return(n=ps.get(t))==null?void 0:n.description},configurable:!0}),t.meta=(...n)=>{if(n.length===0)return ps.get(t);const r=t.clone();return ps.add(r,n[0]),r},t.isOptional=()=>t.safeParse(void 0).success,t.isNullable=()=>t.safeParse(null).success,t.apply=n=>n(t),t)),ug=S("_ZodString",(t,e)=>{Rc.init(t,e),ce.init(t,e),t._zod.processJSONSchema=(r,s,i)=>VA(t,r,s);const n=t._zod.bag;t.format=n.format??null,t.minLength=n.minimum??null,t.maxLength=n.maximum??null,t.regex=(...r)=>t.check(TA(...r)),t.includes=(...r)=>t.check(PA(...r)),t.startsWith=(...r)=>t.check(RA(...r)),t.endsWith=(...r)=>t.check(DA(...r)),t.min=(...r)=>t.check(yo(...r)),t.max=(...r)=>t.check(rg(...r)),t.length=(...r)=>t.check(sg(...r)),t.nonempty=(...r)=>t.check(yo(1,...r)),t.lowercase=r=>t.check(CA(r)),t.uppercase=r=>t.check(IA(r)),t.trim=()=>t.check(zA()),t.normalize=(...r)=>t.check(OA(...r)),t.toLowerCase=()=>t.check(LA()),t.toUpperCase=()=>t.check(MA()),t.slugify=()=>t.check(NA())}),Rx=S("ZodString",(t,e)=>{Rc.init(t,e),ug.init(t,e),t.email=n=>t.check(X0(Dx,n)),t.url=n=>t.check(rA(Ox,n)),t.jwt=n=>t.check(yA(Yx,n)),t.emoji=n=>t.check(sA(zx,n)),t.guid=n=>t.check(dd(vd,n)),t.uuid=n=>t.check(Q0(Ui,n)),t.uuidv4=n=>t.check(eA(Ui,n)),t.uuidv6=n=>t.check(tA(Ui,n)),t.uuidv7=n=>t.check(nA(Ui,n)),t.nanoid=n=>t.check(iA(Lx,n)),t.guid=n=>t.check(dd(vd,n)),t.cuid=n=>t.check(oA(Mx,n)),t.cuid2=n=>t.check(aA(Nx,n)),t.ulid=n=>t.check(lA(Ux,n)),t.base64=n=>t.check(gA(Gx,n)),t.base64url=n=>t.check(mA(Hx,n)),t.xid=n=>t.check(cA(Fx,n)),t.ksuid=n=>t.check(uA(Zx,n)),t.ipv4=n=>t.check(hA(jx,n)),t.ipv6=n=>t.check(dA(Wx,n)),t.cidrv4=n=>t.check(fA(Bx,n)),t.cidrv6=n=>t.check(pA(Vx,n)),t.e164=n=>t.check(vA(qx,n)),t.datetime=n=>t.check(fx(n)),t.date=n=>t.check(gx(n)),t.time=n=>t.check(vx(n)),t.duration=n=>t.check(bx(n))});function u(t){return J0(Rx,t)}const ue=S("ZodStringFormat",(t,e)=>{oe.init(t,e),ug.init(t,e)}),Dx=S("ZodEmail",(t,e)=>{s0.init(t,e),ue.init(t,e)}),vd=S("ZodGUID",(t,e)=>{n0.init(t,e),ue.init(t,e)}),Ui=S("ZodUUID",(t,e)=>{r0.init(t,e),ue.init(t,e)}),Ox=S("ZodURL",(t,e)=>{i0.init(t,e),ue.init(t,e)}),zx=S("ZodEmoji",(t,e)=>{o0.init(t,e),ue.init(t,e)}),Lx=S("ZodNanoID",(t,e)=>{a0.init(t,e),ue.init(t,e)}),Mx=S("ZodCUID",(t,e)=>{l0.init(t,e),ue.init(t,e)}),Nx=S("ZodCUID2",(t,e)=>{c0.init(t,e),ue.init(t,e)}),Ux=S("ZodULID",(t,e)=>{u0.init(t,e),ue.init(t,e)}),Fx=S("ZodXID",(t,e)=>{h0.init(t,e),ue.init(t,e)}),Zx=S("ZodKSUID",(t,e)=>{d0.init(t,e),ue.init(t,e)}),jx=S("ZodIPv4",(t,e)=>{v0.init(t,e),ue.init(t,e)}),Wx=S("ZodIPv6",(t,e)=>{y0.init(t,e),ue.init(t,e)}),Bx=S("ZodCIDRv4",(t,e)=>{b0.init(t,e),ue.init(t,e)}),Vx=S("ZodCIDRv6",(t,e)=>{w0.init(t,e),ue.init(t,e)}),Gx=S("ZodBase64",(t,e)=>{_0.init(t,e),ue.init(t,e)}),Hx=S("ZodBase64URL",(t,e)=>{k0.init(t,e),ue.init(t,e)}),qx=S("ZodE164",(t,e)=>{E0.init(t,e),ue.init(t,e)}),Yx=S("ZodJWT",(t,e)=>{A0.init(t,e),ue.init(t,e)}),hg=S("ZodNumber",(t,e)=>{Qp.init(t,e),ce.init(t,e),t._zod.processJSONSchema=(r,s,i)=>GA(t,r,s),t.gt=(r,s)=>t.check(pd(r,s)),t.gte=(r,s)=>t.check(ja(r,s)),t.min=(r,s)=>t.check(ja(r,s)),t.lt=(r,s)=>t.check(fd(r,s)),t.lte=(r,s)=>t.check(Za(r,s)),t.max=(r,s)=>t.check(Za(r,s)),t.int=r=>t.check(yd(r)),t.safe=r=>t.check(yd(r)),t.positive=r=>t.check(pd(0,r)),t.nonnegative=r=>t.check(ja(0,r)),t.negative=r=>t.check(fd(0,r)),t.nonpositive=r=>t.check(Za(0,r)),t.multipleOf=(r,s)=>t.check(gd(r,s)),t.step=(r,s)=>t.check(gd(r,s)),t.finite=()=>t;const n=t._zod.bag;t.minValue=Math.max(n.minimum??Number.NEGATIVE_INFINITY,n.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,t.maxValue=Math.min(n.maximum??Number.POSITIVE_INFINITY,n.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,t.isInt=(n.format??"").includes("int")||Number.isSafeInteger(n.multipleOf??.5),t.isFinite=!0,t.format=n.format??null});function U(t){return kA(hg,t)}const Kx=S("ZodNumberFormat",(t,e)=>{x0.init(t,e),hg.init(t,e)});function yd(t){return EA(Kx,t)}const Jx=S("ZodBoolean",(t,e)=>{T0.init(t,e),ce.init(t,e),t._zod.processJSONSchema=(n,r,s)=>HA(t,n,r)});function ke(t){return $A(Jx,t)}const Xx=S("ZodUnknown",(t,e)=>{C0.init(t,e),ce.init(t,e),t._zod.processJSONSchema=(n,r,s)=>YA()});function w(){return AA(Xx)}const Qx=S("ZodNever",(t,e)=>{I0.init(t,e),ce.init(t,e),t._zod.processJSONSchema=(n,r,s)=>qA(t,n,r)});function eT(t){return xA(Qx,t)}const tT=S("ZodArray",(t,e)=>{P0.init(t,e),ce.init(t,e),t._zod.processJSONSchema=(n,r,s)=>ex(t,n,r,s),t.element=e.element,t.min=(n,r)=>t.check(yo(n,r)),t.nonempty=n=>t.check(yo(1,n)),t.max=(n,r)=>t.check(rg(n,r)),t.length=(n,r)=>t.check(sg(n,r)),t.unwrap=()=>t.element});function R(t,e){return UA(tT,t,e)}const dg=S("ZodObject",(t,e)=>{D0.init(t,e),ce.init(t,e),t._zod.processJSONSchema=(n,r,s)=>tx(t,n,r,s),ee(t,"shape",()=>e.shape),t.keyof=()=>wo(Object.keys(t._zod.def.shape)),t.catchall=n=>t.clone({...t._zod.def,catchall:n}),t.passthrough=()=>t.clone({...t._zod.def,catchall:w()}),t.loose=()=>t.clone({...t._zod.def,catchall:w()}),t.strict=()=>t.clone({...t._zod.def,catchall:eT()}),t.strip=()=>t.clone({...t._zod.def,catchall:void 0}),t.extend=n=>e$(t,n),t.safeExtend=n=>t$(t,n),t.merge=n=>n$(t,n),t.pick=n=>XE(t,n),t.omit=n=>QE(t,n),t.partial=(...n)=>r$(pg,t,n[0]),t.required=(...n)=>s$(gg,t,n[0])});function fg(t,e){const n={type:"object",shape:t??{},...D(e)};return new dg(n)}function p(t,e){return new dg({type:"object",shape:t,catchall:w(),...D(e)})}const nT=S("ZodUnion",(t,e)=>{O0.init(t,e),ce.init(t,e),t._zod.processJSONSchema=(n,r,s)=>nx(t,n,r,s),t.options=e.options});function Z(t,e){return new nT({type:"union",options:t,...D(e)})}const rT=S("ZodIntersection",(t,e)=>{z0.init(t,e),ce.init(t,e),t._zod.processJSONSchema=(n,r,s)=>rx(t,n,r,s)});function Go(t,e){return new rT({type:"intersection",left:t,right:e})}const sT=S("ZodRecord",(t,e)=>{L0.init(t,e),ce.init(t,e),t._zod.processJSONSchema=(n,r,s)=>sx(t,n,r,s),t.keyType=e.keyType,t.valueType=e.valueType});function _(t,e,n){return new sT({type:"record",keyType:t,valueType:e,...D(n)})}const bl=S("ZodEnum",(t,e)=>{M0.init(t,e),ce.init(t,e),t._zod.processJSONSchema=(r,s,i)=>KA(t,r,s),t.enum=e.entries,t.options=Object.values(e.entries);const n=new Set(Object.keys(e.entries));t.extract=(r,s)=>{const i={};for(const o of r)if(n.has(o))i[o]=e.entries[o];else throw new Error(`Key ${o} not found in enum`);return new bl({...e,checks:[],...D(s),entries:i})},t.exclude=(r,s)=>{const i={...e.entries};for(const o of r)if(n.has(o))delete i[o];else throw new Error(`Key ${o} not found in enum`);return new bl({...e,checks:[],...D(s),entries:i})}});function wo(t,e){const n=Array.isArray(t)?Object.fromEntries(t.map(r=>[r,r])):t;return new bl({type:"enum",entries:n,...D(e)})}const iT=S("ZodLiteral",(t,e)=>{N0.init(t,e),ce.init(t,e),t._zod.processJSONSchema=(n,r,s)=>JA(t,n,r),t.values=new Set(e.values),Object.defineProperty(t,"value",{get(){if(e.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return e.values[0]}})});function A(t,e){return new iT({type:"literal",values:Array.isArray(t)?t:[t],...D(e)})}const oT=S("ZodTransform",(t,e)=>{U0.init(t,e),ce.init(t,e),t._zod.processJSONSchema=(n,r,s)=>QA(t,n),t._zod.parse=(n,r)=>{if(r.direction==="backward")throw new Mp(t.constructor.name);n.addIssue=i=>{if(typeof i=="string")n.issues.push(xs(i,n.value,e));else{const o=i;o.fatal&&(o.continue=!1),o.code??(o.code="custom"),o.input??(o.input=n.value),o.inst??(o.inst=t),n.issues.push(xs(o))}};const s=e.transform(n.value,n);return s instanceof Promise?s.then(i=>(n.value=i,n)):(n.value=s,n)}});function aT(t){return new oT({type:"transform",transform:t})}const pg=S("ZodOptional",(t,e)=>{ng.init(t,e),ce.init(t,e),t._zod.processJSONSchema=(n,r,s)=>lg(t,n,r,s),t.unwrap=()=>t._zod.def.innerType});function bd(t){return new pg({type:"optional",innerType:t})}const lT=S("ZodExactOptional",(t,e)=>{F0.init(t,e),ce.init(t,e),t._zod.processJSONSchema=(n,r,s)=>lg(t,n,r,s),t.unwrap=()=>t._zod.def.innerType});function cT(t){return new lT({type:"optional",innerType:t})}const uT=S("ZodNullable",(t,e)=>{Z0.init(t,e),ce.init(t,e),t._zod.processJSONSchema=(n,r,s)=>ix(t,n,r,s),t.unwrap=()=>t._zod.def.innerType});function wd(t){return new uT({type:"nullable",innerType:t})}const hT=S("ZodDefault",(t,e)=>{j0.init(t,e),ce.init(t,e),t._zod.processJSONSchema=(n,r,s)=>ax(t,n,r,s),t.unwrap=()=>t._zod.def.innerType,t.removeDefault=t.unwrap});function dT(t,e){return new hT({type:"default",innerType:t,get defaultValue(){return typeof e=="function"?e():Zp(e)}})}const fT=S("ZodPrefault",(t,e)=>{W0.init(t,e),ce.init(t,e),t._zod.processJSONSchema=(n,r,s)=>lx(t,n,r,s),t.unwrap=()=>t._zod.def.innerType});function pT(t,e){return new fT({type:"prefault",innerType:t,get defaultValue(){return typeof e=="function"?e():Zp(e)}})}const gg=S("ZodNonOptional",(t,e)=>{B0.init(t,e),ce.init(t,e),t._zod.processJSONSchema=(n,r,s)=>ox(t,n,r,s),t.unwrap=()=>t._zod.def.innerType});function gT(t,e){return new gg({type:"nonoptional",innerType:t,...D(e)})}const mT=S("ZodCatch",(t,e)=>{V0.init(t,e),ce.init(t,e),t._zod.processJSONSchema=(n,r,s)=>cx(t,n,r,s),t.unwrap=()=>t._zod.def.innerType,t.removeCatch=t.unwrap});function vT(t,e){return new mT({type:"catch",innerType:t,catchValue:typeof e=="function"?e:()=>e})}const yT=S("ZodPipe",(t,e)=>{G0.init(t,e),ce.init(t,e),t._zod.processJSONSchema=(n,r,s)=>ux(t,n,r,s),t.in=e.in,t.out=e.out});function _d(t,e){return new yT({type:"pipe",in:t,out:e})}const bT=S("ZodReadonly",(t,e)=>{H0.init(t,e),ce.init(t,e),t._zod.processJSONSchema=(n,r,s)=>hx(t,n,r,s),t.unwrap=()=>t._zod.def.innerType});function wT(t){return new bT({type:"readonly",innerType:t})}const _T=S("ZodCustom",(t,e)=>{q0.init(t,e),ce.init(t,e),t._zod.processJSONSchema=(n,r,s)=>XA(t,n)});function ST(t,e={}){return FA(_T,t,e)}function kT(t){return ZA(t)}const ET=["text/markdown","text/html"],$T=["committed","pending"];fg({id:u().min(1),type:wo(ET),title:u(),status:wo($T),externalFilePath:u().optional()});fg({name:u().min(1),description:u(),accepts:R(u().min(1)).min(1)});function Dc(t){return typeof t=="object"&&t!==null}function AT(t){return!Dc(t)||t.type!=="ready"?!1:!("id"in t)}function xT(t){return!(!Dc(t)||t.type!=="update-content"||typeof t.id!="string"||typeof t.content!="string")}function TT(t){return!Dc(t)||t.type!=="wheel"||typeof t.deltaX!="number"||typeof t.deltaY!="number"||typeof t.shiftKey!="boolean"?!1:!("id"in t)}function CT(t,e){if(t===e)return 2;if(t==="*/*")return 0;const n=t.indexOf("/");if(n>0&&t.slice(n+1)==="*"){const r=t.slice(0,n),s=e.indexOf("/");if(s>0&&e.slice(0,s)===r)return 1}return null}function IT(t,e){let n=null;for(const r of t.accepts){const s=CT(r,e);s!==null&&(n===null||s>n)&&(n=s)}return n}function PT(t,e){let n=-1,r=null;for(const s of e){const i=IT(s,t);i!==null&&(i>n||i===n&&r!==null&&s.id<r.id)&&(n=i,r=s)}return r}const RT=4401;class wl extends Error{constructor(e="Authentication required"){super(e),this.name="AuthError"}}class _l extends kt{constructor(n){super();v(this,"url");v(this,"name");v(this,"token");v(this,"status","disconnected");v(this,"screens",new Map);v(this,"views",[]);v(this,"client");v(this,"createSocket");v(this,"createClient");v(this,"socket",null);v(this,"connectAttempt",0);this.url=Pt(n.url),this.name=n.name,this.token=n.token??null,this.createSocket=n.createSocket??(r=>new WebSocket(r)),this.createClient=n.createClient??((r,s)=>new LE(r,{token:s??void 0})),this.client=this.createClient(this.url,this.token)}async connect(){var s;this.connectAttempt+=1;const n=this.connectAttempt;(s=this.socket)==null||s.close(),this.client=this.createClient(this.url,this.token),this.status="connecting",this.dispatchEvent(new te("change"));const r=this.createSocket(DT(this.url,this.token));return this.socket=r,await new Promise((i,o)=>{let a=!1;const l=()=>{a||this.connectAttempt!==n||(a=!0,this.status="connected",this.dispatchEvent(new te("change")),i())},c=f=>{a||this.connectAttempt!==n||(a=!0,this.status="disconnected",this.dispatchEvent(new te("change")),o(f))},d=async()=>{try{const[{screens:f},y]=await Promise.all([this.client.screens.list(),this.client.views.list()]);this.screens=new Map(f.map(m=>[m.id,structuredClone(m)])),this.views=y,this.dispatchEvent(new te("change")),l()}catch(f){c(f instanceof Error?f:new Error(String(f)))}};r.addEventListener("open",()=>{d()}),r.addEventListener("message",f=>{const y=zT(f);y&&(this.applyServerEvent(y),this.dispatchEvent(new Ap("server-event",{serverURL:this.url,event:y})))}),r.addEventListener("close",f=>{if(this.connectAttempt===n){if(this.socket=null,OT(f)===RT){c(new wl);return}if(!a){c(new Error("Connection closed before initialization"));return}this.status="disconnected",this.dispatchEvent(new te("change"))}}),r.addEventListener("error",()=>{c(new Error("WebSocket connection failed"))})})}disconnect(){var n;this.connectAttempt+=1,(n=this.socket)==null||n.close(),this.socket=null,this.status="disconnected",this.dispatchEvent(new te("change"))}getViewURL(n){const r=PT(n.type,this.views);if(!r)return null;const s=`${this.url}/views/${encodeURIComponent(r.id)}/`;return this.token===null?s:`${s}?token=${encodeURIComponent(this.token)}`}getContentURL(n){const r=`${this.url}/artifacts/${encodeURIComponent(n)}/content`;return this.token===null?r:`${r}?token=${encodeURIComponent(this.token)}`}async createScreen(n){const{screen:r}=await this.client.screens.create({name:n});return this.screens.set(r.id,structuredClone(r)),r}applyServerEvent(n){switch(n.type){case"screen-created":this.screens.set(n.screen.id,structuredClone(n.screen)),this.dispatchEvent(new to("screens-changed"));break;case"screen-updated":this.screens.set(n.screen.id,structuredClone(n.screen)),this.dispatchEvent(new to("screens-changed"));break;case"screen-removed":this.screens.delete(n.screenID),this.dispatchEvent(new to("screens-changed"));break;case"artifact-created":{const r=this.screens.get(n.screenID);r&&!kp(r.layout,n.artifact.id)&&(r.layout=[...r.layout,Sp(n.artifact.id)]);break}case"artifact-removed":{const r=this.screens.get(n.screenID);r&&(r.layout=fp(r.layout,n.artifactID));break}}}}function DT(t,e){const n=new URL(t);return n.protocol=n.protocol==="https:"?"wss:":"ws:",n.pathname="/events",n.search="",e&&n.searchParams.set("token",e),n.hash="",n.toString()}function OT(t){return typeof t=="object"&&t!==null&&"code"in t&&typeof t.code=="number"?t.code:null}function zT(t){const e=typeof t=="string"?t:typeof t=="object"&&t!==null&&"data"in t&&typeof t.data=="string"?t.data:"";if(!e)return null;try{return JSON.parse(e)}catch{return null}}class LT extends kt{constructor(n){super();v(this,"servers",new Map);v(this,"localServerURL");v(this,"localStore");v(this,"createSocket");v(this,"lastActiveServerURL");v(this,"serverListeners",new Map);v(this,"handleLocalStoreChange",()=>{const n=this.localStore.get().activeServerURL;n!==this.lastActiveServerURL&&(this.lastActiveServerURL=n,this.dispatchEvent(new te("change")))});this.localStore=n.localStore,this.localServerURL=n.localServerURL?Pt(n.localServerURL):null,this.createSocket=n.createSocket??(r=>new WebSocket(r)),this.lastActiveServerURL=this.localStore.get().activeServerURL,this.localStore.addEventListener("change",this.handleLocalStoreChange)}get activeServer(){const n=this.localStore.get().activeServerURL;return n===null?null:this.servers.get(n)??null}add(n){const r=Pt(n.url);this.servers.get(r)&&this.remove(r),this.servers.set(r,n);const i=()=>{this.dispatchEvent(new te("change"))},o=l=>{this.dispatchEvent(new Ap("server-event",{serverURL:l.serverURL,event:l.event}))},a=()=>{this.dispatchEvent(new to("screens-changed"))};n.addEventListener("change",i),n.addEventListener("server-event",o),n.addEventListener("screens-changed",a),this.serverListeners.set(r,{onServerChange:i,onServerEvent:o,onScreensChanged:a}),this.dispatchEvent(new te("change"))}remove(n){const r=Pt(n);if(this.localServerURL&&r===this.localServerURL)return;const s=this.servers.get(r);if(!s)return;const i=this.serverListeners.get(r);i&&(s.removeEventListener("change",i.onServerChange),s.removeEventListener("server-event",i.onServerEvent),s.removeEventListener("screens-changed",i.onScreensChanged),this.serverListeners.delete(r)),s.disconnect(),this.servers.delete(r);const o=this.localStore.get(),a=o.activeServerURL===r;this.localStore.set({...o,servers:o.servers.filter(l=>l.url!==r),activeServerURL:a?null:o.activeServerURL}),this.dispatchEvent(new te("change"))}setActive(n){const r=this.localStore.get(),s=n?Pt(n.url):null;r.activeServerURL!==s&&this.localStore.set({...r,activeServerURL:s})}connectConfiguredServers(n){const r=this.localStore.get().servers;for(const i of r){const o=new _l({url:i.url,name:i.name,createSocket:this.createSocket});this.add(o),o.connect().catch(()=>{})}const s=n?this.servers.get(Pt(n))??null:null;this.setActive(s??this.servers.values().next().value??null)}addServer(n,r){const s=Pt(n);this.remove(s);const i=this.localStore.get();this.localStore.set({...i,servers:[...i.servers.filter(a=>Pt(a.url)!==s),{url:s,name:r}]});const o=new _l({url:s,name:r,createSocket:this.createSocket});this.add(o),this.setActive(o),o.connect().catch(()=>{})}removeServer(n){this.remove(n)}}const ie={authenticate:"authenticate",document_did_change:"document/didChange",document_did_close:"document/didClose",document_did_focus:"document/didFocus",document_did_open:"document/didOpen",document_did_save:"document/didSave",initialize:"initialize",logout:"logout",nes_accept:"nes/accept",nes_close:"nes/close",nes_reject:"nes/reject",nes_start:"nes/start",nes_suggest:"nes/suggest",session_cancel:"session/cancel",session_close:"session/close",session_fork:"session/fork",session_list:"session/list",session_load:"session/load",session_new:"session/new",session_prompt:"session/prompt",session_resume:"session/resume",session_set_config_option:"session/set_config_option",session_set_mode:"session/set_mode",session_set_model:"session/set_model"},Tt={fs_read_text_file:"fs/read_text_file",fs_write_text_file:"fs/write_text_file",session_request_permission:"session/request_permission",session_update:"session/update",terminal_create:"terminal/create",terminal_kill:"terminal/kill",terminal_output:"terminal/output",terminal_release:"terminal/release",terminal_wait_for_exit:"terminal/wait_for_exit"},MT=1,NT=p({_meta:_(u(),w()).nullish(),terminal:ke().optional().default(!1)}),UT=p({_meta:_(u(),w()).nullish(),label:u().nullish(),name:u(),optional:ke().optional().default(!1),secret:ke().optional().default(!0)}),FT=p({_meta:_(u(),w()).nullish(),description:u().nullish(),id:u(),name:u()}),ZT=p({_meta:_(u(),w()).nullish(),description:u().nullish(),id:u(),link:u().nullish(),name:u(),vars:R(UT)}),jT=p({_meta:_(u(),w()).nullish(),args:R(u()).optional(),description:u().nullish(),env:_(u(),u()).optional(),id:u(),name:u()}),WT=Z([ZT.and(p({type:A("env_var")})),jT.and(p({type:A("terminal")})),FT]),BT=p({_meta:_(u(),w()).nullish(),methodId:u()}),VT=p({_meta:_(u(),w()).nullish()}),GT=p({_meta:_(u(),w()).nullish(),blob:u(),mimeType:u().nullish(),uri:u()}),HT=p({default:ke().nullish(),description:u().nullish(),title:u().nullish()}),qT=p({_meta:_(u(),w()).nullish()}),YT=p({_meta:_(u(),w()).nullish()}),KT=p({amount:U(),currency:u()}),JT=p({_meta:_(u(),w()).nullish(),terminalId:u()}),XT=p({_meta:_(u(),w()).nullish(),newText:u(),oldText:u().nullish(),path:u()}),QT=Z([u(),U(),U(),ke(),R(u())]),eC=p({content:_(u(),QT).nullish()}),tC=Z([eC.and(p({action:A("accept")})),p({action:A("decline")}),p({action:A("cancel")})]),nC=p({_meta:_(u(),w()).nullish()}),mg=u(),rC=p({_meta:_(u(),w()).nullish(),elicitationId:mg}),sC=p({_meta:_(u(),w()).nullish(),action:tC}),iC=A("object"),oC=A("string"),aC=p({_meta:_(u(),w()).nullish()}),lC=p({_meta:_(u(),w()).nullish(),form:nC.nullish(),url:aC.nullish()}),cC=p({elicitationId:mg,url:u().url()}),vg=p({const:u(),title:u()}),yg=p({_meta:_(u(),w()).nullish(),name:u(),value:u()}),uC=Z([A(-32700),A(-32600),A(-32601),A(-32602),A(-32603),A(-32800),A(-32e3),A(-32002),A(-32042),U().int().min(-2147483648,{message:"Invalid value: Expected int32 to be >= -2147483648"}).max(2147483647,{message:"Invalid value: Expected int32 to be <= 2147483647"})]),bg=p({code:uC,data:w().optional(),message:u()}),wg=w(),_g=w(),Sg=w(),hC=p({_meta:_(u(),w()).nullish(),readTextFile:ke().optional().default(!1),writeTextFile:ke().optional().default(!1)}),kg=p({_meta:_(u(),w()).nullish(),name:u(),value:u()}),Eg=p({_meta:_(u(),w()).nullish(),name:u(),title:u().nullish(),version:u()}),dC=p({default:U().nullish(),description:u().nullish(),maximum:U().nullish(),minimum:U().nullish(),title:u().nullish()}),fC=p({_meta:_(u(),w()).nullish()}),pC=p({_meta:_(u(),w()).nullish(),additionalDirectories:R(u()).optional(),cursor:u().nullish(),cwd:u().nullish()}),gC=p({_meta:_(u(),w()).nullish()}),mC=p({_meta:_(u(),w()).nullish(),logout:gC.nullish()}),vC=p({_meta:_(u(),w()).nullish()}),yC=p({_meta:_(u(),w()).nullish()}),bC=p({_meta:_(u(),w()).nullish(),http:ke().optional().default(!1),sse:ke().optional().default(!1)}),wC=p({_meta:_(u(),w()).nullish(),headers:R(kg),name:u(),url:u()}),_C=p({_meta:_(u(),w()).nullish(),headers:R(kg),name:u(),url:u()}),SC=p({_meta:_(u(),w()).nullish(),args:R(u()),command:u(),env:R(yg),name:u()}),Ho=Z([wC.and(p({type:A("http")})),_C.and(p({type:A("sse")})),SC]),Oc=u(),kC=p({_meta:_(u(),w()).nullish(),description:u().nullish(),modelId:Oc,name:u()}),EC=Z([A("error"),A("warning"),A("information"),A("hint")]),$C=p({_meta:_(u(),w()).nullish()}),AC=p({_meta:_(u(),w()).nullish()}),xC=p({_meta:_(u(),w()).nullish()}),TC=p({_meta:_(u(),w()).nullish()}),CC=p({_meta:_(u(),w()).nullish()}),IC=p({_meta:_(u(),w()).nullish(),maxCount:U().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish()}),PC=p({diff:u(),uri:u()}),RC=p({endLine:U().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}),startLine:U().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}),text:u()}),DC=p({_meta:_(u(),w()).nullish()}),OC=p({_meta:_(u(),w()).nullish()}),zC=p({languageId:u(),text:u(),uri:u()}),LC=p({_meta:_(u(),w()).nullish(),maxCount:U().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish()}),MC=Z([A("rejected"),A("ignored"),A("replaced"),A("cancelled")]),NC=p({excerpts:R(RC),uri:u()}),UC=p({_meta:_(u(),w()).nullish()}),FC=p({_meta:_(u(),w()).nullish()}),ZC=p({name:u(),owner:u(),remoteUrl:u()}),jC=p({_meta:_(u(),w()).nullish()}),WC=p({_meta:_(u(),w()).nullish(),jump:DC.nullish(),rename:FC.nullish(),searchAndReplace:jC.nullish()}),BC=p({id:u(),isRegex:ke().nullish(),replace:u(),search:u(),uri:u()}),VC=Z([A("automatic"),A("diagnostic"),A("manual")]),GC=p({_meta:_(u(),w()).nullish(),maxCount:U().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish()}),HC=p({_meta:_(u(),w()).nullish(),diagnostics:$C.nullish(),editHistory:IC.nullish(),openFiles:OC.nullish(),recentFiles:LC.nullish(),relatedSnippets:UC.nullish(),userActions:GC.nullish()}),qC=p({_meta:_(u(),w()).nullish(),additionalDirectories:R(u()).optional(),cwd:u(),mcpServers:R(Ho)}),YC=p({default:U().nullish(),description:u().nullish(),maximum:U().nullish(),minimum:U().nullish(),title:u().nullish()}),$g=u(),KC=Z([A("allow_once"),A("allow_always"),A("reject_once"),A("reject_always")]),JC=p({_meta:_(u(),w()).nullish(),kind:KC,name:u(),optionId:$g}),XC=Z([A("high"),A("medium"),A("low")]),QC=Z([A("pending"),A("in_progress"),A("completed")]),eI=p({_meta:_(u(),w()).nullish(),content:u(),priority:XC,status:QC}),tI=p({_meta:_(u(),w()).nullish(),entries:R(eI)}),cn=p({character:U().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}),line:U().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"})}),nI=p({id:u(),position:cn,uri:u()}),rI=p({id:u(),newName:u(),position:cn,uri:u()}),sI=p({action:u(),position:cn,timestampMs:U(),uri:u()}),Ag=Z([A("utf-16"),A("utf-32"),A("utf-8")]),iI=p({_meta:_(u(),w()).nullish(),auth:NT.optional().default({terminal:!1}),elicitation:lC.nullish(),fs:hC.optional().default({readTextFile:!1,writeTextFile:!1}),nes:WC.nullish(),positionEncodings:R(Ag).optional(),terminal:ke().optional().default(!1)}),oI=p({_meta:_(u(),w()).nullish(),audio:ke().optional().default(!1),embeddedContext:ke().optional().default(!1),image:ke().optional().default(!1)}),xg=U().int().gte(0).lte(65535),aI=p({_meta:_(u(),w()).nullish(),clientCapabilities:iI.optional().default({auth:{terminal:!1},fs:{readTextFile:!1,writeTextFile:!1},terminal:!1}),clientInfo:Eg.nullish(),protocolVersion:xg}),qr=p({end:cn,start:cn}),lI=p({message:u(),range:qr,severity:EC,uri:u()}),cI=p({languageId:u(),lastFocusedMs:U().nullish(),uri:u(),visibleRange:qr.nullish()}),uI=p({_meta:_(u(),w()).nullish(),diagnostics:R(lI).nullish(),editHistory:R(PC).nullish(),openFiles:R(cI).nullish(),recentFiles:R(zC).nullish(),relatedSnippets:R(NC).nullish(),userActions:R(sI).nullish()}),hI=p({newText:u(),range:qr}),dI=p({cursorPosition:cn.nullish(),edits:R(hI),id:u(),uri:u()}),fI=Z([dI.and(p({kind:A("edit")})),nI.and(p({kind:A("jump")})),rI.and(p({kind:A("rename")})),BC.and(p({kind:A("searchAndReplace")}))]),pI=p({_meta:_(u(),w()).nullish(),content:u()}),gI=p({_meta:_(u(),w()).nullish()}),jn=Z([U(),u()]).nullable();p({_meta:_(u(),w()).nullish(),requestId:jn});const mI=wo(["assistant","user"]),mi=p({_meta:_(u(),w()).nullish(),audience:R(mI).nullish(),lastModified:u().nullish(),priority:U().nullish()}),vI=p({_meta:_(u(),w()).nullish(),annotations:mi.nullish(),data:u(),mimeType:u()}),yI=p({_meta:_(u(),w()).nullish(),annotations:mi.nullish(),data:u(),mimeType:u(),uri:u().nullish()}),bI=p({_meta:_(u(),w()).nullish(),annotations:mi.nullish(),description:u().nullish(),mimeType:u().nullish(),name:u(),size:U().nullish(),title:u().nullish(),uri:u()}),wI=p({_meta:_(u(),w()).nullish(),optionId:$g}),_I=Z([p({outcome:A("cancelled")}),wI.and(p({outcome:A("selected")}))]),SI=p({_meta:_(u(),w()).nullish(),outcome:_I}),kI=p({_meta:_(u(),w()).nullish()}),EI=p({_meta:_(u(),w()).nullish()}),$I=p({currentValue:ke()}),AI=u(),Tg=u(),xI=Z([A("mode"),A("model"),A("thought_level"),u()]),zc=u(),Cg=p({_meta:_(u(),w()).nullish(),description:u().nullish(),name:u(),value:zc}),TI=p({_meta:_(u(),w()).nullish(),group:AI,name:u(),options:R(Cg)}),CI=Z([R(Cg),R(TI)]),II=p({currentValue:zc,options:CI}),Yr=Go(Z([II.and(p({type:A("select")})),$I.and(p({type:A("boolean")}))]),p({_meta:_(u(),w()).nullish(),category:xI.nullish(),description:u().nullish(),id:Tg,name:u()})),PI=p({_meta:_(u(),w()).nullish(),configOptions:R(Yr)}),RI=p({_meta:_(u(),w()).nullish()}),K=u(),DI=p({_meta:_(u(),w()).nullish(),id:u(),sessionId:K}),OI=p({_meta:_(u(),w()).nullish(),sessionId:K}),zI=p({_meta:_(u(),w()).nullish(),sessionId:K}),LI=p({_meta:_(u(),w()).nullish(),sessionId:K}),Ig=p({_meta:_(u(),w()).nullish(),args:R(u()).optional(),command:u(),cwd:u().nullish(),env:R(yg).optional(),outputByteLimit:U().nullish(),sessionId:K}),MI=p({_meta:_(u(),w()).nullish(),sessionId:K,uri:u()}),NI=p({_meta:_(u(),w()).nullish(),position:cn,sessionId:K,uri:u(),version:U(),visibleRange:qr}),UI=p({_meta:_(u(),w()).nullish(),languageId:u(),sessionId:K,text:u(),uri:u(),version:U()}),FI=p({_meta:_(u(),w()).nullish(),sessionId:K,uri:u()}),ZI=p({_meta:_(u(),w()).nullish(),additionalDirectories:R(u()).optional(),cwd:u(),mcpServers:R(Ho).optional(),sessionId:K}),Pg=p({_meta:_(u(),w()).nullish(),sessionId:K,terminalId:u()}),jI=p({_meta:_(u(),w()).nullish(),additionalDirectories:R(u()).optional(),cwd:u(),mcpServers:R(Ho),sessionId:K}),Rg=p({_meta:_(u(),w()).nullish(),limit:U().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),line:U().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),path:u(),sessionId:K}),WI=p({_meta:_(u(),w()).nullish(),id:u(),reason:MC.nullish(),sessionId:K}),Dg=p({_meta:_(u(),w()).nullish(),sessionId:K,terminalId:u()}),BI=p({_meta:_(u(),w()).nullish(),additionalDirectories:R(u()).optional(),cwd:u(),mcpServers:R(Ho).optional(),sessionId:K}),VI=p({_meta:_(u(),w()).nullish(),additionalDirectories:R(u()).optional(),cwd:u(),sessionId:K,title:u().nullish(),updatedAt:u().nullish()}),GI=p({_meta:_(u(),w()).nullish(),nextCursor:u().nullish(),sessions:R(VI)}),HI=p({_meta:_(u(),w()).nullish(),title:u().nullish(),updatedAt:u().nullish()}),qI=p({_meta:_(u(),w()).nullish()}),qo=u(),YI=p({_meta:_(u(),w()).nullish(),currentModeId:qo}),KI=p({_meta:_(u(),w()).nullish(),description:u().nullish(),id:qo,name:u()}),Yo=p({_meta:_(u(),w()).nullish(),availableModes:R(KI),currentModeId:qo}),Ko=p({_meta:_(u(),w()).nullish(),availableModels:R(kC),currentModelId:Oc}),JI=p({_meta:_(u(),w()).nullish(),configOptions:R(Yr).nullish(),models:Ko.nullish(),modes:Yo.nullish(),sessionId:K}),XI=p({_meta:_(u(),w()).nullish(),configOptions:R(Yr).nullish(),models:Ko.nullish(),modes:Yo.nullish()}),QI=p({_meta:_(u(),w()).nullish(),configOptions:R(Yr).nullish(),models:Ko.nullish(),modes:Yo.nullish(),sessionId:K}),eP=p({_meta:_(u(),w()).nullish(),configOptions:R(Yr).nullish(),models:Ko.nullish(),modes:Yo.nullish()}),tP=p({_meta:_(u(),w()).nullish()}),nP=p({_meta:_(u(),w()).nullish(),additionalDirectories:kI.nullish(),close:EI.nullish(),fork:RI.nullish(),list:qI.nullish(),resume:tP.nullish()}),rP=Go(Z([p({type:A("boolean"),value:ke()}),p({value:zc})]),p({_meta:_(u(),w()).nullish(),configId:Tg,sessionId:K})),sP=p({_meta:_(u(),w()).nullish(),configOptions:R(Yr)}),iP=p({_meta:_(u(),w()).nullish(),modeId:qo,sessionId:K}),oP=p({_meta:_(u(),w()).nullish()}),aP=p({_meta:_(u(),w()).nullish(),modelId:Oc,sessionId:K}),lP=p({_meta:_(u(),w()).nullish()}),cP=p({_meta:_(u(),w()).nullish(),sessionId:K}),uP=Z([A("end_turn"),A("max_tokens"),A("max_turn_requests"),A("refusal"),A("cancelled")]),hP=Z([A("email"),A("uri"),A("date"),A("date-time")]),dP=p({default:u().nullish(),description:u().nullish(),enum:R(u()).nullish(),format:hP.nullish(),maxLength:U().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),minLength:U().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),oneOf:R(vg).nullish(),pattern:u().nullish(),title:u().nullish()}),fP=p({_meta:_(u(),w()).nullish(),context:uI.nullish(),position:cn,selection:qr.nullish(),sessionId:K,triggerKind:VC,uri:u(),version:U()}),pP=p({_meta:_(u(),w()).nullish(),suggestions:R(fI)}),gP=p({_meta:_(u(),w()).nullish(),terminalId:u()}),mP=p({_meta:_(u(),w()).nullish(),exitCode:U().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),signal:u().nullish()}),Og=p({_meta:_(u(),w()).nullish(),sessionId:K,terminalId:u()}),vP=p({_meta:_(u(),w()).nullish(),exitStatus:mP.nullish(),output:u(),truncated:ke()}),yP=p({_meta:_(u(),w()).nullish(),annotations:mi.nullish(),text:u()}),bP=p({range:qr.nullish(),text:u()}),wP=p({_meta:_(u(),w()).nullish(),contentChanges:R(bP),sessionId:K,uri:u(),version:U()});p({method:u(),params:Z([OI,UI,wP,MI,FI,NI,DI,WI,wg]).nullish()});const _P=Z([A("full"),A("incremental")]),SP=p({_meta:_(u(),w()).nullish(),syncKind:_P}),kP=p({_meta:_(u(),w()).nullish(),didChange:SP.nullish(),didClose:AC.nullish(),didFocus:xC.nullish(),didOpen:TC.nullish(),didSave:CC.nullish()}),EP=p({_meta:_(u(),w()).nullish(),document:kP.nullish()}),$P=p({_meta:_(u(),w()).nullish(),context:HC.nullish(),events:EP.nullish()}),AP=p({_meta:_(u(),w()).nullish(),auth:mC.optional().default({}),loadSession:ke().optional().default(!1),mcpCapabilities:bC.optional().default({http:!1,sse:!1}),nes:$P.nullish(),positionEncoding:Ag.nullish(),promptCapabilities:oI.optional().default({audio:!1,embeddedContext:!1,image:!1}),sessionCapabilities:nP.optional().default({})}),xP=p({_meta:_(u(),w()).nullish(),agentCapabilities:AP.optional().default({auth:{},loadSession:!1,mcpCapabilities:{http:!1,sse:!1},promptCapabilities:{audio:!1,embeddedContext:!1,image:!1},sessionCapabilities:{}}),agentInfo:Eg.nullish(),authMethods:R(WT).optional().default([]),protocolVersion:xg}),TP=p({_meta:_(u(),w()).nullish(),mimeType:u().nullish(),text:u(),uri:u()}),CP=Z([TP,GT]),IP=p({_meta:_(u(),w()).nullish(),annotations:mi.nullish(),resource:CP}),Lc=Z([yP.and(p({type:A("text")})),yI.and(p({type:A("image")})),vI.and(p({type:A("audio")})),bI.and(p({type:A("resource_link")})),IP.and(p({type:A("resource")}))]),PP=p({_meta:_(u(),w()).nullish(),content:Lc}),Wa=p({_meta:_(u(),w()).nullish(),content:Lc,messageId:u().nullish()}),RP=p({_meta:_(u(),w()).nullish(),messageId:u().nullish(),prompt:R(Lc),sessionId:K}),DP=p({anyOf:R(vg)}),zg=Z([PP.and(p({type:A("content")})),XT.and(p({type:A("diff")})),gP.and(p({type:A("terminal")}))]),Lg=u(),Mg=p({_meta:_(u(),w()).nullish(),line:U().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),path:u()}),Ng=Z([A("pending"),A("in_progress"),A("completed"),A("failed")]),Ug=Z([A("read"),A("edit"),A("delete"),A("move"),A("search"),A("execute"),A("think"),A("fetch"),A("switch_mode"),A("other")]),OP=p({_meta:_(u(),w()).nullish(),content:R(zg).optional(),kind:Ug.optional(),locations:R(Mg).optional(),rawInput:w().optional(),rawOutput:w().optional(),status:Ng.optional(),title:u(),toolCallId:Lg}),Fg=p({_meta:_(u(),w()).nullish(),content:R(zg).nullish(),kind:Ug.nullish(),locations:R(Mg).nullish(),rawInput:w().optional(),rawOutput:w().optional(),status:Ng.nullish(),title:u().nullish(),toolCallId:Lg}),Zg=p({_meta:_(u(),w()).nullish(),options:R(JC),sessionId:K,toolCall:Fg}),zP=p({_meta:_(u(),w()).nullish(),hint:u()}),LP=zP,MP=p({_meta:_(u(),w()).nullish(),description:u(),input:LP.nullish(),name:u()}),NP=p({_meta:_(u(),w()).nullish(),availableCommands:R(MP)}),UP=p({enum:R(u()),type:oC}),FP=Z([UP,DP]),ZP=p({default:R(u()).nullish(),description:u().nullish(),items:FP,maxItems:U().nullish(),minItems:U().nullish(),title:u().nullish()}),jP=Z([dP.and(p({type:A("string")})),YC.and(p({type:A("number")})),dC.and(p({type:A("integer")})),HT.and(p({type:A("boolean")})),ZP.and(p({type:A("array")}))]),WP=p({description:u().nullish(),properties:_(u(),jP).optional().default({}),required:R(u()).nullish(),title:u().nullish(),type:iC.optional().default("object")}),BP=p({requestedSchema:WP}),VP=Go(Z([BP.and(p({mode:A("form")})),cC.and(p({mode:A("url")}))]),p({_meta:_(u(),w()).nullish(),message:u(),sessionId:K})),GP=p({cachedReadTokens:U().nullish(),cachedWriteTokens:U().nullish(),inputTokens:U(),outputTokens:U(),thoughtTokens:U().nullish(),totalTokens:U()}),HP=p({_meta:_(u(),w()).nullish(),stopReason:uP,usage:GP.nullish(),userMessageId:u().nullish()});Z([p({id:jn,result:Z([xP,VT,yC,QI,XI,GI,JI,eP,YT,oP,sP,HP,lP,cP,pP,qT,Sg])}),p({error:bg,id:jn})]);const qP=p({_meta:_(u(),w()).nullish(),cost:KT.nullish(),size:U(),used:U()}),YP=Z([Wa.and(p({sessionUpdate:A("user_message_chunk")})),Wa.and(p({sessionUpdate:A("agent_message_chunk")})),Wa.and(p({sessionUpdate:A("agent_thought_chunk")})),OP.and(p({sessionUpdate:A("tool_call")})),Fg.and(p({sessionUpdate:A("tool_call_update")})),tI.and(p({sessionUpdate:A("plan")})),NP.and(p({sessionUpdate:A("available_commands_update")})),YI.and(p({sessionUpdate:A("current_mode_update")})),PI.and(p({sessionUpdate:A("config_option_update")})),HI.and(p({sessionUpdate:A("session_info_update")})),qP.and(p({sessionUpdate:A("usage_update")}))]),jg=p({_meta:_(u(),w()).nullish(),sessionId:K,update:YP});p({method:u(),params:Z([jg,rC,wg]).nullish()});const Wg=p({_meta:_(u(),w()).nullish(),sessionId:K,terminalId:u()}),KP=p({_meta:_(u(),w()).nullish(),exitCode:U().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),signal:u().nullish()}),JP=p({name:u(),uri:u()}),XP=p({_meta:_(u(),w()).nullish(),repository:ZC.nullish(),workspaceFolders:R(JP).nullish(),workspaceUri:u().nullish()});p({id:jn,method:u(),params:Z([aI,BT,vC,qC,jI,pC,ZI,BI,LI,iP,rP,RP,aP,XP,fP,zI,_g]).nullish()});const Bg=p({_meta:_(u(),w()).nullish(),content:u(),path:u(),sessionId:K});p({id:jn,method:u(),params:Z([Bg,Rg,Zg,Ig,Og,Dg,Wg,Pg,VP,_g]).nullish()});const QP=p({_meta:_(u(),w()).nullish()});Z([p({id:jn,result:Z([QP,pI,SI,JT,vP,gI,KP,fC,sC,Sg])}),p({error:bg,id:jn})]);var Y;class eR{constructor(e,n){x(this,Y);const r=e(this),s=async(o,a)=>{var l,c,d,f,y,m,E;switch(o){case Tt.fs_write_text_file:{const k=Bg.parse(a);return(l=r.writeTextFile)==null?void 0:l.call(r,k)}case Tt.fs_read_text_file:{const k=Rg.parse(a);return(c=r.readTextFile)==null?void 0:c.call(r,k)}case Tt.session_request_permission:{const k=Zg.parse(a);return r.requestPermission(k)}case Tt.terminal_create:{const k=Ig.parse(a);return(d=r.createTerminal)==null?void 0:d.call(r,k)}case Tt.terminal_output:{const k=Og.parse(a);return(f=r.terminalOutput)==null?void 0:f.call(r,k)}case Tt.terminal_release:{const k=Dg.parse(a);return await((y=r.releaseTerminal)==null?void 0:y.call(r,k))??{}}case Tt.terminal_wait_for_exit:{const k=Wg.parse(a);return(m=r.waitForTerminalExit)==null?void 0:m.call(r,k)}case Tt.terminal_kill:{const k=Pg.parse(a);return await((E=r.killTerminal)==null?void 0:E.call(r,k))??{}}default:if(r.extMethod)return r.extMethod(o,a);throw ye.methodNotFound(o)}},i=async(o,a)=>{switch(o){case Tt.session_update:{const l=jg.parse(a);return r.sessionUpdate(l)}default:if(r.extNotification)return r.extNotification(o,a);throw ye.methodNotFound(o)}};$(this,Y,new tR(s,i,n))}async initialize(e){return await h(this,Y).sendRequest(ie.initialize,e)}async newSession(e){return await h(this,Y).sendRequest(ie.session_new,e)}async loadSession(e){return await h(this,Y).sendRequest(ie.session_load,e)??{}}async unstable_forkSession(e){return await h(this,Y).sendRequest(ie.session_fork,e)}async listSessions(e){return await h(this,Y).sendRequest(ie.session_list,e)}async unstable_resumeSession(e){return await h(this,Y).sendRequest(ie.session_resume,e)}async unstable_closeSession(e){return await h(this,Y).sendRequest(ie.session_close,e)}async setSessionMode(e){return await h(this,Y).sendRequest(ie.session_set_mode,e)??{}}async unstable_setSessionModel(e){return await h(this,Y).sendRequest(ie.session_set_model,e)??{}}async setSessionConfigOption(e){return await h(this,Y).sendRequest(ie.session_set_config_option,e)}async authenticate(e){return await h(this,Y).sendRequest(ie.authenticate,e)??{}}async unstable_logout(e){return await h(this,Y).sendRequest(ie.logout,e)??{}}async prompt(e){return await h(this,Y).sendRequest(ie.session_prompt,e)}async cancel(e){return await h(this,Y).sendNotification(ie.session_cancel,e)}async unstable_startNes(e){return await h(this,Y).sendRequest(ie.nes_start,e)}async unstable_suggestNes(e){return await h(this,Y).sendRequest(ie.nes_suggest,e)}async unstable_closeNes(e){return await h(this,Y).sendRequest(ie.nes_close,e)??{}}async unstable_didOpenDocument(e){return await h(this,Y).sendNotification(ie.document_did_open,e)}async unstable_didChangeDocument(e){return await h(this,Y).sendNotification(ie.document_did_change,e)}async unstable_didCloseDocument(e){return await h(this,Y).sendNotification(ie.document_did_close,e)}async unstable_didSaveDocument(e){return await h(this,Y).sendNotification(ie.document_did_save,e)}async unstable_didFocusDocument(e){return await h(this,Y).sendNotification(ie.document_did_focus,e)}async unstable_acceptNes(e){return await h(this,Y).sendNotification(ie.nes_accept,e)}async unstable_rejectNes(e){return await h(this,Y).sendNotification(ie.nes_reject,e)}async extMethod(e,n){return await h(this,Y).sendRequest(e,n)}async extNotification(e,n){return await h(this,Y).sendNotification(e,n)}get signal(){return h(this,Y).signal}get closed(){return h(this,Y).closed}}Y=new WeakMap;var Kt,To,Fs,Zs,_r,Sr,bt,js,ae,Vg,Sl,Gg,Hg,qg,Yg,kl,gs;class tR{constructor(e,n,r){x(this,ae);x(this,Kt,new Map);x(this,To,0);x(this,Fs);x(this,Zs);x(this,_r);x(this,Sr,Promise.resolve());x(this,bt,new AbortController);x(this,js);$(this,Fs,e),$(this,Zs,n),$(this,_r,r),$(this,js,new Promise(s=>{h(this,bt).signal.addEventListener("abort",()=>s())})),b(this,ae,Vg).call(this)}get signal(){return h(this,bt).signal}get closed(){return h(this,js)}async sendRequest(e,n){b(this,ae,kl).call(this);const r=Eu(this,To)._++,s=new Promise((i,o)=>{h(this,Kt).set(r,{resolve:i,reject:o})});return await b(this,ae,gs).call(this,{jsonrpc:"2.0",id:r,method:e,params:n}),s}async sendNotification(e,n){b(this,ae,kl).call(this),await b(this,ae,gs).call(this,{jsonrpc:"2.0",method:e,params:n})}}Kt=new WeakMap,To=new WeakMap,Fs=new WeakMap,Zs=new WeakMap,_r=new WeakMap,Sr=new WeakMap,bt=new WeakMap,js=new WeakMap,ae=new WeakSet,Vg=async function(){let e;try{const n=h(this,_r).readable.getReader();try{for(;!h(this,bt).signal.aborted;){const{value:r,done:s}=await n.read();if(s)break;if(r)try{b(this,ae,Gg).call(this,r)}catch(i){console.error("Unexpected error during message processing:",r,i),"id"in r&&r.id!==void 0&&b(this,ae,gs).call(this,{jsonrpc:"2.0",id:r.id,error:{code:-32700,message:"Parse error"}})}}}finally{n.releaseLock()}}catch(n){e=n}finally{b(this,ae,Sl).call(this,e)}},Sl=function(e){if(h(this,bt).signal.aborted)return;const n=e??new Error("ACP connection closed");for(const r of h(this,Kt).values())r.reject(n);h(this,Kt).clear(),h(this,bt).abort(n)},Gg=async function(e){if("method"in e&&"id"in e){const n=await b(this,ae,Hg).call(this,e.method,e.params);"error"in n&&console.error("Error handling request",e,n.error),await b(this,ae,gs).call(this,{jsonrpc:"2.0",id:e.id,...n})}else if("method"in e){const n=await b(this,ae,qg).call(this,e.method,e.params);"error"in n&&console.error("Error handling notification",e,n.error)}else"id"in e?b(this,ae,Yg).call(this,e):console.error("Invalid message",{message:e})},Hg=async function(e,n){try{return{result:await h(this,Fs).call(this,e,n)??null}}catch(r){if(r instanceof ye)return r.toResult();if(r instanceof md)return ye.invalidParams(r.format()).toResult();let s;(r instanceof Error||typeof r=="object"&&r!=null&&"message"in r&&typeof r.message=="string")&&(s=r.message);try{return ye.internalError(s?JSON.parse(s):{}).toResult()}catch{return ye.internalError({details:s}).toResult()}}},qg=async function(e,n){try{return await h(this,Zs).call(this,e,n),{result:null}}catch(r){if(r instanceof ye)return r.toResult();if(r instanceof md)return ye.invalidParams(r.format()).toResult();let s;(r instanceof Error||typeof r=="object"&&r!=null&&"message"in r&&typeof r.message=="string")&&(s=r.message);try{return ye.internalError(s?JSON.parse(s):{}).toResult()}catch{return ye.internalError({details:s}).toResult()}}},Yg=function(e){const n=h(this,Kt).get(e.id);if(n){if("result"in e)n.resolve(e.result);else if("error"in e){const{code:r,message:s,data:i}=e.error;n.reject(new ye(r,s,i))}h(this,Kt).delete(e.id)}else console.error("Got response to unknown request",e.id)},kl=function(){if(h(this,bt).signal.aborted)throw h(this,bt).signal.reason??new Error("ACP connection closed")},gs=async function(e){return $(this,Sr,h(this,Sr).then(async()=>{const n=h(this,_r).writable.getWriter();try{await n.write(e)}finally{n.releaseLock()}}).catch(n=>{b(this,ae,Sl).call(this,n)})),h(this,Sr)};class ye extends Error{constructor(n,r,s){super(r);v(this,"code");v(this,"data");this.code=n,this.name="RequestError",this.data=s}static parseError(n,r){return new ye(-32700,`Parse error${r?`: ${r}`:""}`,n)}static invalidRequest(n,r){return new ye(-32600,`Invalid request${r?`: ${r}`:""}`,n)}static methodNotFound(n){return new ye(-32601,`"Method not found": ${n}`,{method:n})}static invalidParams(n,r){return new ye(-32602,`Invalid params${r?`: ${r}`:""}`,n)}static internalError(n,r){return new ye(-32603,`Internal error${r?`: ${r}`:""}`,n)}static authRequired(n,r){return new ye(-32e3,`Authentication required${r?`: ${r}`:""}`,n)}static resourceNotFound(n){return new ye(-32002,`Resource not found${n?`: ${n}`:""}`,n&&{uri:n})}toResult(){return{error:{code:this.code,message:this.message,data:this.data}}}toErrorResponse(){return{code:this.code,message:this.message,data:this.data}}}const nR=/^Sender \(untrusted metadata\):\n```json\n[\s\S]*?\n```\n\n?/,rR=/^\[[^\n]*Working directory:[^\n]*\]\n\n?/,sR=/\[Television screen context\][\s\S]*?\[\/Television screen context\]\n*/,iR=/\[\[\s*(?:reply_to_current|reply_to\s*:\s*[^\]\n]+|audio_as_voice)\s*\]\]\s*/gi,oR="single_session",aR={name:"television-acp-client",version:"0.0.0"},Kg="agent:main:television",lR=Gr(kt);var re,Rt,kr,Dt,Dn,On,Jt,Er,wt,st,Xt,zn,Ot,Qt,Ws,zt,it,Co,Lt,C,Jg,Xg,El,Qg,em,tm,nm,rm,sm,im,wn,cr,ur,Ge,om,hr,$l,Al,ro,am,Bs,Vs,xl,dr,lm,cm;class cR extends lR{constructor(n){super();x(this,C);x(this,re,uR());x(this,Rt,null);x(this,kr,null);x(this,Dt,null);x(this,Dn,null);x(this,On,null);x(this,Jt,null);x(this,Er,1);x(this,wt,null);x(this,st,null);x(this,Xt,!1);x(this,zn,!1);x(this,Ot,null);x(this,Qt,new Set);x(this,Ws);x(this,zt);x(this,it);x(this,Co,n=>{b(this,C,Xg).call(this,n)});x(this,Lt,null);x(this,Bs,()=>{b(this,C,dr).call(this,"ACP bridge websocket closed")});x(this,Vs,()=>{b(this,C,dr).call(this,"ACP bridge websocket error")});$(this,zt,n),$(this,it,n.sessionMode??oR),$(this,Ws,n.createSocket??(r=>new WebSocket(r)))}getState(){return h(this,re)}async connect(){if(this.disposed)throw new Error("ACPClient has been disposed");if(h(this,re).lifecycle.status!=="ready"){b(this,C,Ge).call(this,{lifecycle:{status:"connecting"}}),h(this,kr)??$(this,kr,b(this,C,Jg).call(this));try{await h(this,kr),await b(this,C,El).call(this)}catch(n){throw b(this,C,dr).call(this,Fi(n)),n}}}dispose(){b(this,C,xl).call(this),b(this,C,Ge).call(this,{lifecycle:{status:"disposed"},run:{status:"idle",stopReason:null,canCancel:!1,error:null}})}async sendMessage(n){if(await this.connect(),h(this,re).lifecycle.status!=="ready"||h(this,re).run.status==="running"||h(this,re).run.status==="cancelling")throw new Error("ACPClient is not ready to send a new message");const r=n.text.trim();if(!r)throw new Error("Cannot send an empty message");b(this,C,cr).call(this,{id:b(this,C,hr).call(this,"user"),kind:"user",text:r,status:"final"}),b(this,C,Ge).call(this,{run:{status:"running",stopReason:null,canCancel:!0,error:null}});try{const s=await b(this,C,ro).call(this).prompt({sessionId:b(this,C,Al).call(this),prompt:[{type:"text",text:b(this,C,om).call(this,r)}]});b(this,C,wn).call(this,s.stopReason==="cancelled"?"cancelled":"final"),b(this,C,Ge).call(this,{run:{status:s.stopReason==="cancelled"?"cancelled":"completed",stopReason:s.stopReason,canCancel:!1,error:null}})}catch(s){throw b(this,C,cm).call(this)||(b(this,C,wn).call(this,"error"),b(this,C,Ge).call(this,{run:{status:"error",stopReason:null,canCancel:!1,error:Fi(s)}})),s}}async cancel(){if(await this.connect(),!h(this,re).run.canCancel||h(this,re).run.status!=="running")throw new Error("No active cancellable run");b(this,C,Ge).call(this,{run:{...h(this,re).run,status:"cancelling"}}),await b(this,C,ro).call(this).cancel({sessionId:b(this,C,Al).call(this)})}setScreenContext(n){var i,o,a;const r={screenID:n.screenID,screenName:n.screenName};if(((i=h(this,st))==null?void 0:i.screenID)===r.screenID&&((o=h(this,st))==null?void 0:o.screenName)===r.screenName)return;const s=((a=h(this,st))==null?void 0:a.screenID)??null;if($(this,st,r),h(this,it)==="single_session"){(!h(this,Jt)||s!==r.screenID)&&$(this,Xt,!0);return}h(this,Jt)!==Sd(h(this,it),r.screenID,h(this,zt).clientGUID??"default-client")&&($(this,Dt,null),$(this,Dn,null),h(this,Rt)&&h(this,re).run.status==="idle"&&b(this,C,El).call(this).catch(l=>{b(this,C,dr).call(this,Fi(l))}))}}re=new WeakMap,Rt=new WeakMap,kr=new WeakMap,Dt=new WeakMap,Dn=new WeakMap,On=new WeakMap,Jt=new WeakMap,Er=new WeakMap,wt=new WeakMap,st=new WeakMap,Xt=new WeakMap,zn=new WeakMap,Ot=new WeakMap,Qt=new WeakMap,Ws=new WeakMap,zt=new WeakMap,it=new WeakMap,Co=new WeakMap,Lt=new WeakMap,C=new WeakSet,Jg=async function(){try{b(this,C,Ge).call(this,{lifecycle:{status:"connecting"}});const{stream:n,socket:r}=await fR({serverURL:h(this,zt).serverURL,token:h(this,zt).token,createSocket:h(this,Ws),onDisconnect:h(this,Co)});$(this,Lt,r),r.addEventListener("close",h(this,Bs)),r.addEventListener("error",h(this,Vs)),$(this,Rt,new eR(s=>({connection:s,sessionUpdate:async i=>{await b(this,C,em).call(this,i)},requestPermission:async i=>b(this,C,tm).call(this,i)}),n)),await h(this,Rt).initialize({protocolVersion:MT,clientCapabilities:{},clientInfo:aR})}catch(n){throw n}},Xg=function(n){b(this,C,dr).call(this,Fi(n))},El=async function(){const n=b(this,C,am).call(this);if(h(this,Dt)&&h(this,Dn)===n){await h(this,Dt);return}$(this,Dn,n),$(this,Dt,b(this,C,Qg).call(this,n)),await h(this,Dt)},Qg=async function(n){const r=b(this,C,ro).call(this);b(this,C,lm).call(this);let s,i=!1;try{$(this,zn,!0),$(this,Ot,null),await r.loadSession({sessionId:n,cwd:"/",mcpServers:[],_meta:{sessionKey:n}}),s=n,i=h(this,re).messageOrder.length>0}catch{s=(await r.newSession({cwd:"/",mcpServers:[],_meta:{sessionKey:n}})).sessionId,i=!1}finally{$(this,zn,!1),$(this,Ot,null),b(this,C,wn).call(this,"final")}await r.setSessionConfigOption({sessionId:s,configId:"verbose_level",value:"full"}),$(this,On,s),$(this,Jt,n),i?(h(this,Qt).add(n),h(this,it)==="single_session"&&$(this,Xt,!1)):(h(this,Qt).delete(n),$(this,Xt,h(this,it)==="single_session")),b(this,C,Ge).call(this,{lifecycle:{status:"ready"}})},em=async function(n){const r=n.update;switch(r.sessionUpdate){case"user_message_chunk":r.content.type==="text"&&b(this,C,im).call(this,r.content.text);return;case"agent_message_chunk":r.content.type==="text"&&b(this,C,nm).call(this,r.content.text);return;case"tool_call":b(this,C,rm).call(this,r);return;case"tool_call_update":b(this,C,sm).call(this,r);return;case"agent_thought_chunk":return;default:return}},tm=async function(n){return{outcome:{outcome:"cancelled"}}},nm=function(n){$(this,Ot,null);const r=hR(n);if(!r)return;if(!h(this,wt)){const i={id:b(this,C,hr).call(this,"assistant"),kind:"assistant",text:r,status:"streaming"};$(this,wt,i.id),b(this,C,cr).call(this,i);return}const s=h(this,re).messagesById[h(this,wt)];if(!s||s.kind!=="assistant")throw new Error("Open assistant message invariant violated");b(this,C,ur).call(this,{...s,text:`${s.text}${r}`,status:"streaming"})},rm=function(n){b(this,C,wn).call(this,"final");const r=b(this,C,$l).call(this,n.toolCallId),s={id:(r==null?void 0:r.id)??b(this,C,hr).call(this,"tool"),kind:"tool_call",toolCallId:n.toolCallId,title:n.title,toolKind:n.kind??"other",status:n.status==="failed"?"failed":n.status==="completed"?"completed":"in_progress",text:(r==null?void 0:r.text)??"",locations:n.locations??(r==null?void 0:r.locations)};if(r){b(this,C,ur).call(this,s);return}b(this,C,cr).call(this,s)},sm=function(n){const r=b(this,C,$l).call(this,n.toolCallId),s=(r==null?void 0:r.text)??"",i=dR(n.content),o=i?`${s}${i}`:s,a={id:(r==null?void 0:r.id)??b(this,C,hr).call(this,"tool"),kind:"tool_call",toolCallId:n.toolCallId,title:(r==null?void 0:r.title)??n.toolCallId,toolKind:(r==null?void 0:r.toolKind)??"other",status:n.status==="failed"?"failed":n.status==="completed"?"completed":"in_progress",text:o,locations:n.locations??(r==null?void 0:r.locations)};if(r){b(this,C,ur).call(this,a);return}b(this,C,cr).call(this,a)},im=function(n){if(b(this,C,wn).call(this,"final"),!n)return;const r=h(this,zn)?h(this,Ot):null;if(!r){const i=kd(n);if(!i)return;const o={id:b(this,C,hr).call(this,"user"),kind:"user",text:i,status:"final"};b(this,C,cr).call(this,o),h(this,zn)&&$(this,Ot,o.id);return}const s=h(this,re).messagesById[r];if(!s||s.kind!=="user")throw new Error("Replay user message invariant violated");b(this,C,ur).call(this,{...s,text:kd(`${s.text}${n}`)})},wn=function(n){if(!h(this,wt))return;const r=h(this,re).messagesById[h(this,wt)];(r==null?void 0:r.kind)==="assistant"&&b(this,C,ur).call(this,{...r,status:n}),$(this,wt,null)},cr=function(n){b(this,C,Ge).call(this,{messagesById:{...h(this,re).messagesById,[n.id]:n},messageOrder:[...h(this,re).messageOrder,n.id]})},ur=function(n){b(this,C,Ge).call(this,{messagesById:{...h(this,re).messagesById,[n.id]:n}})},Ge=function(n){const r={...h(this,re),...n};$(this,re,{...r,sendDisabled:r.lifecycle.status!=="ready"||r.run.status==="running"||r.run.status==="cancelling",cancelDisabled:!(r.run.status==="running"||r.run.status==="cancelling")||!r.run.canCancel}),this.dispatchEvent(new te("change"))},om=function(n){const r=h(this,Jt);return!h(this,st)||!r||!(h(this,it)==="single_session"?h(this,Xt)||!h(this,Qt).has(r):!h(this,Qt).has(r))?n:($(this,Xt,!1),h(this,Qt).add(r),["[Television screen context]","This chat session is coming from a Television client in the screen below.",`screen_id: ${h(this,st).screenID}`,`screen_name: ${h(this,st).screenName??""}`,"When the user asks to inspect or change Television state with the tv CLI, use this screen ID with the --screen argument.","[/Television screen context]","",n].join(`
|
|
43
|
-
`))},hr=function(n){const r=`${n}-${h(this,Er)}`;return $(this,Er,h(this,Er)+1),r},$l=function(n){for(const r of h(this,re).messageOrder){const s=h(this,re).messagesById[r];if((s==null?void 0:s.kind)==="tool_call"&&s.toolCallId===n)return s}return null},Al=function(){if(!h(this,On))throw new Error("ACP session is not ready");return h(this,On)},ro=function(){if(!h(this,Rt))throw new Error("ACP connection is not ready");return h(this,Rt)},am=function(){var r;if(h(this,it)==="single_session")return`${Kg}-${(h(this,zt).clientGUID??"default-client").toLowerCase()}`;const n=(r=h(this,st))==null?void 0:r.screenID;if(!n)throw new Error("Screen context is required for per-screen session mode");return Sd(h(this,it),n,h(this,zt).clientGUID??"default-client")},Bs=new WeakMap,Vs=new WeakMap,xl=function(){$(this,Rt,null),$(this,kr,null),$(this,Dt,null),$(this,Dn,null),$(this,On,null),$(this,Jt,null),h(this,Lt)&&(h(this,Lt).removeEventListener("close",h(this,Bs)),h(this,Lt).removeEventListener("error",h(this,Vs)),h(this,Lt).close(),$(this,Lt,null))},dr=function(n){this.disposed||h(this,re).lifecycle.status==="disconnected"||(b(this,C,wn).call(this,"error"),b(this,C,xl).call(this),b(this,C,Ge).call(this,{lifecycle:{status:"disconnected",...n?{error:n}:{}},run:{status:"idle",stopReason:null,canCancel:!1,error:null}}))},lm=function(){$(this,wt,null),$(this,Ot,null),$(this,Er,1),b(this,C,Ge).call(this,{run:{status:"idle",stopReason:null,canCancel:!1,error:null},messagesById:{},messageOrder:[]})},cm=function(){return h(this,re).lifecycle.status==="disconnected"};function uR(){return{lifecycle:{status:"connecting"},run:{status:"idle",stopReason:null,canCancel:!1,error:null},messagesById:{},messageOrder:[],sendDisabled:!0,cancelDisabled:!0}}function Sd(t,e,n){return t==="single_session"?`${Kg}-${n.toLowerCase()}`:`agent:main:television-${n.toLowerCase()}-${e.toLowerCase()}`}function um(t){return t.replace(/^(?:\s*\n)+/,"")}function kd(t){let e=t;return e=e.replace(nR,""),e=e.replace(rR,""),e=e.replace(sR,""),e=um(e),e}function hR(t){let e=t;return e=e.replace(iR,""),e=um(e),e}function dR(t){return!t||t.length===0?"":t.flatMap(e=>e.type==="content"&&e.content.type==="text"?[e.content.text]:[]).join("")}async function fR(t){const e=t.createSocket(gR(t.serverURL,t.token));let n=!1,r,s;const i=new Promise((l,c)=>{r=l,s=c}),o=new ReadableStream({start(l){let c=!1;const d=()=>{e.send(JSON.stringify({type:"acp-bridge-connect"}))},f=E=>{const k=pR(E);if(!k)return;let I;try{I=JSON.parse(k)}catch(V){const N=V instanceof Error?V:new Error(String(V));s(N),l.error(N);return}switch(I.type){case"acp-bridge-status":if(I.status==="ready"){n||(n=!0,r());return}if(I.status==="error"||I.status==="exited"){const V=new Error(I.error??`ACP bridge ${I.status}`);n||s(V),l.error(V)}return;case"acp-bridge-message":l.enqueue(I.message);return}},y=()=>{var k;if(c)return;c=!0;const E=new Error("ACP bridge websocket closed");n||s(E),(k=t.onDisconnect)==null||k.call(t,E),l.close()},m=()=>{var k;if(c)return;c=!0;const E=new Error("ACP bridge websocket error");n||s(E),(k=t.onDisconnect)==null||k.call(t,E),l.error(E)};e.addEventListener("open",d),e.addEventListener("message",f),e.addEventListener("close",y),e.addEventListener("error",m)}}),a=new WritableStream({async write(l){await i,e.send(JSON.stringify({type:"acp-bridge-message",message:l}))},close(){e.close()},abort(){e.close()}});return await i,{stream:{readable:o,writable:a},socket:e}}function pR(t){if(typeof t=="string")return t;if(t instanceof Uint8Array)return new TextDecoder().decode(t);if(typeof Buffer<"u"&&t instanceof Buffer)return t.toString("utf8");if(typeof t=="object"&&t!==null&&"data"in t){const e=t.data;if(typeof e=="string")return e;if(e instanceof Uint8Array)return new TextDecoder().decode(e);if(Array.isArray(e))return Buffer.concat(e).toString("utf8")}return null}function gR(t,e){const n=new URL(t);return n.protocol=n.protocol==="https:"?"wss:":"ws:",n.pathname="/acp",n.search="",n.searchParams.set("token",e),n.hash="",n.toString()}function Fi(t){return t instanceof Error?t.message:String(t)}const Ed="television.acpClientGUID",mR=Gr(kt);class vR extends mR{constructor(n){super();v(this,"screenManager");v(this,"clients",new Map);v(this,"options");v(this,"sessionMode");v(this,"clientGUID");v(this,"activeClient",null);v(this,"handleActiveScreenChanged",()=>{this.syncActiveClient()});this.screenManager=n.screenManager,this.sessionMode=n.sessionMode??"single_session",this.options={serverURL:n.serverURL,token:n.token,...n.createSocket?{createSocket:n.createSocket}:{},...n.sessionMode?{sessionMode:n.sessionMode}:{}},this.clientGUID=n.clientGUID??yR(n.storage??window.localStorage),this.screenManager.addEventListener("active-screen-changed",this.handleActiveScreenChanged),this.syncActiveClient()}getActiveClient(){return this.activeClient}dispose(){this.screenManager.removeEventListener("active-screen-changed",this.handleActiveScreenChanged);for(const n of this.clients.values())n.dispose();this.clients.clear(),this.activeClient=null}syncActiveClient(){const n=this.screenManager.activeScreen,r=n?this.getClientForScreen(n):null;this.activeClient!==r&&(this.activeClient=r,this.dispatchEvent(new te("change")))}getClientForScreen(n){const r=this.sessionMode==="single_session"?"single_session":n.id;let s=this.clients.get(r);return s||(s=new cR({...this.options,sessionMode:this.sessionMode,clientGUID:this.clientGUID}),this.clients.set(r,s)),s.setScreenContext({screenID:n.id,screenName:n.name}),s}}function yR(t){const e=t.getItem(Ed);if(e)return e;const n=kc().toLowerCase();return t.setItem(Ed,n),n}const bR="serverURL",wR="token",_R="mode",SR="electron";function hm(t=window.location.search,e=window.location.origin){const r=new URLSearchParams(t).get(bR);return r?new URL(r).origin:new URL(e).origin}function dm(t=window.location.search){return new URLSearchParams(t).get(wR)}function fm(t=window.location.search){return new URLSearchParams(t).get(_R)===SR}/**
|
|
44
|
-
* @license
|
|
45
|
-
* Copyright 2017 Google LLC
|
|
46
|
-
* SPDX-License-Identifier: BSD-3-Clause
|
|
47
|
-
*/const $s=globalThis,$d=t=>t,_o=$s.trustedTypes,Ad=_o?_o.createPolicy("lit-html",{createHTML:t=>t}):void 0,pm="$lit$",Gt=`lit$${Math.random().toFixed(9).slice(2)}$`,gm="?"+Gt,kR=`<${gm}>`,Wn=document,Ts=()=>Wn.createComment(""),Cs=t=>t===null||typeof t!="object"&&typeof t!="function",Mc=Array.isArray,ER=t=>Mc(t)||typeof(t==null?void 0:t[Symbol.iterator])=="function",Ba=`[
|
|
48
|
-
\f\r]`,ss=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,xd=/-->/g,Td=/>/g,yn=RegExp(`>|${Ba}(?:([^\\s"'>=/]+)(${Ba}*=${Ba}*(?:[^
|
|
49
|
-
\f\r"'\`<>=]|("|')|))|$)`,"g"),Cd=/'/g,Id=/"/g,mm=/^(?:script|style|textarea|title)$/i,$R=t=>(e,...n)=>({_$litType$:t,strings:e,values:n}),M=$R(1),Lr=Symbol.for("lit-noChange"),ge=Symbol.for("lit-nothing"),Pd=new WeakMap,xn=Wn.createTreeWalker(Wn,129);function vm(t,e){if(!Mc(t)||!t.hasOwnProperty("raw"))throw Error("invalid template strings array");return Ad!==void 0?Ad.createHTML(e):e}const AR=(t,e)=>{const n=t.length-1,r=[];let s,i=e===2?"<svg>":e===3?"<math>":"",o=ss;for(let a=0;a<n;a++){const l=t[a];let c,d,f=-1,y=0;for(;y<l.length&&(o.lastIndex=y,d=o.exec(l),d!==null);)y=o.lastIndex,o===ss?d[1]==="!--"?o=xd:d[1]!==void 0?o=Td:d[2]!==void 0?(mm.test(d[2])&&(s=RegExp("</"+d[2],"g")),o=yn):d[3]!==void 0&&(o=yn):o===yn?d[0]===">"?(o=s??ss,f=-1):d[1]===void 0?f=-2:(f=o.lastIndex-d[2].length,c=d[1],o=d[3]===void 0?yn:d[3]==='"'?Id:Cd):o===Id||o===Cd?o=yn:o===xd||o===Td?o=ss:(o=yn,s=void 0);const m=o===yn&&t[a+1].startsWith("/>")?" ":"";i+=o===ss?l+kR:f>=0?(r.push(c),l.slice(0,f)+pm+l.slice(f)+Gt+m):l+Gt+(f===-2?a:m)}return[vm(t,i+(t[n]||"<?>")+(e===2?"</svg>":e===3?"</math>":"")),r]};class Is{constructor({strings:e,_$litType$:n},r){let s;this.parts=[];let i=0,o=0;const a=e.length-1,l=this.parts,[c,d]=AR(e,n);if(this.el=Is.createElement(c,r),xn.currentNode=this.el.content,n===2||n===3){const f=this.el.content.firstChild;f.replaceWith(...f.childNodes)}for(;(s=xn.nextNode())!==null&&l.length<a;){if(s.nodeType===1){if(s.hasAttributes())for(const f of s.getAttributeNames())if(f.endsWith(pm)){const y=d[o++],m=s.getAttribute(f).split(Gt),E=/([.?@])?(.*)/.exec(y);l.push({type:1,index:i,name:E[2],strings:m,ctor:E[1]==="."?TR:E[1]==="?"?CR:E[1]==="@"?IR:Jo}),s.removeAttribute(f)}else f.startsWith(Gt)&&(l.push({type:6,index:i}),s.removeAttribute(f));if(mm.test(s.tagName)){const f=s.textContent.split(Gt),y=f.length-1;if(y>0){s.textContent=_o?_o.emptyScript:"";for(let m=0;m<y;m++)s.append(f[m],Ts()),xn.nextNode(),l.push({type:2,index:++i});s.append(f[y],Ts())}}}else if(s.nodeType===8)if(s.data===gm)l.push({type:2,index:i});else{let f=-1;for(;(f=s.data.indexOf(Gt,f+1))!==-1;)l.push({type:7,index:i}),f+=Gt.length-1}i++}}static createElement(e,n){const r=Wn.createElement("template");return r.innerHTML=e,r}}function Mr(t,e,n=t,r){var o,a;if(e===Lr)return e;let s=r!==void 0?(o=n._$Co)==null?void 0:o[r]:n._$Cl;const i=Cs(e)?void 0:e._$litDirective$;return(s==null?void 0:s.constructor)!==i&&((a=s==null?void 0:s._$AO)==null||a.call(s,!1),i===void 0?s=void 0:(s=new i(t),s._$AT(t,n,r)),r!==void 0?(n._$Co??(n._$Co=[]))[r]=s:n._$Cl=s),s!==void 0&&(e=Mr(t,s._$AS(t,e.values),s,r)),e}class xR{constructor(e,n){this._$AV=[],this._$AN=void 0,this._$AD=e,this._$AM=n}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(e){const{el:{content:n},parts:r}=this._$AD,s=((e==null?void 0:e.creationScope)??Wn).importNode(n,!0);xn.currentNode=s;let i=xn.nextNode(),o=0,a=0,l=r[0];for(;l!==void 0;){if(o===l.index){let c;l.type===2?c=new Nc(i,i.nextSibling,this,e):l.type===1?c=new l.ctor(i,l.name,l.strings,this,e):l.type===6&&(c=new PR(i,this,e)),this._$AV.push(c),l=r[++a]}o!==(l==null?void 0:l.index)&&(i=xn.nextNode(),o++)}return xn.currentNode=Wn,s}p(e){let n=0;for(const r of this._$AV)r!==void 0&&(r.strings!==void 0?(r._$AI(e,r,n),n+=r.strings.length-2):r._$AI(e[n])),n++}}let Nc=class ym{get _$AU(){var e;return((e=this._$AM)==null?void 0:e._$AU)??this._$Cv}constructor(e,n,r,s){this.type=2,this._$AH=ge,this._$AN=void 0,this._$AA=e,this._$AB=n,this._$AM=r,this.options=s,this._$Cv=(s==null?void 0:s.isConnected)??!0}get parentNode(){let e=this._$AA.parentNode;const n=this._$AM;return n!==void 0&&(e==null?void 0:e.nodeType)===11&&(e=n.parentNode),e}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(e,n=this){e=Mr(this,e,n),Cs(e)?e===ge||e==null||e===""?(this._$AH!==ge&&this._$AR(),this._$AH=ge):e!==this._$AH&&e!==Lr&&this._(e):e._$litType$!==void 0?this.$(e):e.nodeType!==void 0?this.T(e):ER(e)?this.k(e):this._(e)}O(e){return this._$AA.parentNode.insertBefore(e,this._$AB)}T(e){this._$AH!==e&&(this._$AR(),this._$AH=this.O(e))}_(e){this._$AH!==ge&&Cs(this._$AH)?this._$AA.nextSibling.data=e:this.T(Wn.createTextNode(e)),this._$AH=e}$(e){var i;const{values:n,_$litType$:r}=e,s=typeof r=="number"?this._$AC(e):(r.el===void 0&&(r.el=Is.createElement(vm(r.h,r.h[0]),this.options)),r);if(((i=this._$AH)==null?void 0:i._$AD)===s)this._$AH.p(n);else{const o=new xR(s,this),a=o.u(this.options);o.p(n),this.T(a),this._$AH=o}}_$AC(e){let n=Pd.get(e.strings);return n===void 0&&Pd.set(e.strings,n=new Is(e)),n}k(e){Mc(this._$AH)||(this._$AH=[],this._$AR());const n=this._$AH;let r,s=0;for(const i of e)s===n.length?n.push(r=new ym(this.O(Ts()),this.O(Ts()),this,this.options)):r=n[s],r._$AI(i),s++;s<n.length&&(this._$AR(r&&r._$AB.nextSibling,s),n.length=s)}_$AR(e=this._$AA.nextSibling,n){var r;for((r=this._$AP)==null?void 0:r.call(this,!1,!0,n);e!==this._$AB;){const s=$d(e).nextSibling;$d(e).remove(),e=s}}setConnected(e){var n;this._$AM===void 0&&(this._$Cv=e,(n=this._$AP)==null||n.call(this,e))}},Jo=class{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(e,n,r,s,i){this.type=1,this._$AH=ge,this._$AN=void 0,this.element=e,this.name=n,this._$AM=s,this.options=i,r.length>2||r[0]!==""||r[1]!==""?(this._$AH=Array(r.length-1).fill(new String),this.strings=r):this._$AH=ge}_$AI(e,n=this,r,s){const i=this.strings;let o=!1;if(i===void 0)e=Mr(this,e,n,0),o=!Cs(e)||e!==this._$AH&&e!==Lr,o&&(this._$AH=e);else{const a=e;let l,c;for(e=i[0],l=0;l<i.length-1;l++)c=Mr(this,a[r+l],n,l),c===Lr&&(c=this._$AH[l]),o||(o=!Cs(c)||c!==this._$AH[l]),c===ge?e=ge:e!==ge&&(e+=(c??"")+i[l+1]),this._$AH[l]=c}o&&!s&&this.j(e)}j(e){e===ge?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,e??"")}},TR=class extends Jo{constructor(){super(...arguments),this.type=3}j(e){this.element[this.name]=e===ge?void 0:e}},CR=class extends Jo{constructor(){super(...arguments),this.type=4}j(e){this.element.toggleAttribute(this.name,!!e&&e!==ge)}},IR=class extends Jo{constructor(e,n,r,s,i){super(e,n,r,s,i),this.type=5}_$AI(e,n=this){if((e=Mr(this,e,n,0)??ge)===Lr)return;const r=this._$AH,s=e===ge&&r!==ge||e.capture!==r.capture||e.once!==r.once||e.passive!==r.passive,i=e!==ge&&(r===ge||s);s&&this.element.removeEventListener(this.name,this,r),i&&this.element.addEventListener(this.name,this,e),this._$AH=e}handleEvent(e){var n;typeof this._$AH=="function"?this._$AH.call(((n=this.options)==null?void 0:n.host)??this.element,e):this._$AH.handleEvent(e)}};class PR{constructor(e,n,r){this.element=e,this.type=6,this._$AN=void 0,this._$AM=n,this.options=r}get _$AU(){return this._$AM._$AU}_$AI(e){Mr(this,e)}}const Va=$s.litHtmlPolyfillSupport;Va==null||Va(Is,Nc),($s.litHtmlVersions??($s.litHtmlVersions=[])).push("3.3.2");const be=(t,e,n)=>{const r=e;let s=r._$litPart$;return s===void 0&&(r._$litPart$=s=new Nc(e.insertBefore(Ts(),null),null,void 0,{})),s._$AI(t),s};/**
|
|
50
|
-
* @license
|
|
51
|
-
* Copyright 2017 Google LLC
|
|
52
|
-
* SPDX-License-Identifier: BSD-3-Clause
|
|
53
|
-
*/const RR={CHILD:2},bm=t=>(...e)=>({_$litDirective$:t,values:e});class DR{constructor(e){}get _$AU(){return this._$AM._$AU}_$AT(e,n,r){this._$Ct=e,this._$AM=n,this._$Ci=r}_$AS(e,n){return this.update(e,n)}update(e,n){return this.render(...n)}}/**
|
|
54
|
-
* @license
|
|
55
|
-
* Copyright 2017 Google LLC
|
|
56
|
-
* SPDX-License-Identifier: BSD-3-Clause
|
|
57
|
-
*/class So extends DR{constructor(e){if(super(e),this.it=ge,e.type!==RR.CHILD)throw Error(this.constructor.directiveName+"() can only be used in child bindings")}render(e){if(e===ge||e==null)return this._t=void 0,this.it=e;if(e===Lr)return e;if(typeof e!="string")throw Error(this.constructor.directiveName+"() called with a non-string value");if(e===this.it)return this._t;this.it=e;const n=[e];return n.raw=n,this._t={_$litType$:this.constructor.resultType,strings:n,values:[]}}}So.directiveName="unsafeHTML",So.resultType=1;const OR=bm(So);/**
|
|
58
|
-
* @license
|
|
59
|
-
* Copyright 2017 Google LLC
|
|
60
|
-
* SPDX-License-Identifier: BSD-3-Clause
|
|
61
|
-
*/class Tl extends So{}Tl.directiveName="unsafeSVG",Tl.resultType=2;const zR=bm(Tl),LR={size:16,color:"currentColor",weight:"regular"};function MR(t){return typeof t=="string"?{regular:t}:t}function vi(t,e="0 0 256 256"){const n=MR(t);return r=>{const{size:s,color:i,weight:o}={...LR,...r},a=n[o]??n.regular;return M`<svg
|
|
62
|
-
xmlns="http://www.w3.org/2000/svg"
|
|
63
|
-
data-ui-icon=""
|
|
64
|
-
width="${s}"
|
|
65
|
-
height="${s}"
|
|
66
|
-
viewBox="${e}"
|
|
67
|
-
fill="${i}"
|
|
68
|
-
>${zR(a)}</svg>`}}const wm=vi('<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"/>'),NR=vi('<path d="M216,56V200a16,16,0,0,1-16,16H56a16,16,0,0,1-16-16V56A16,16,0,0,1,56,40H200A16,16,0,0,1,216,56Z"/>'),UR=vi({regular:'<path d="M231.87,114l-168-95.89A16,16,0,0,0,40.92,37.34L71.55,128,40.92,218.67A16,16,0,0,0,56,240a16.15,16.15,0,0,0,7.93-2.1l167.92-96.05a16,16,0,0,0,.05-27.89ZM56,224a.56.56,0,0,0,0-.12L85.74,136H144a8,8,0,0,0,0-16H85.74L56.06,32.16A.46.46,0,0,0,56,32l168,95.83Z"/>',bold:'<path d="M233.86,110.48,65.8,14.58A20,20,0,0,0,37.15,38.64L67.33,128,37.15,217.36A20,20,0,0,0,56,244a20.1,20.1,0,0,0,9.81-2.58l.09-.06,168-96.07a20,20,0,0,0,0-34.81ZM63.19,215.26,88.61,140H144a12,12,0,0,0,0-24H88.61L63.18,40.72l152.76,87.17Z"/>'}),Cl=vi('<path d="M213.66,101.66l-80,80a8,8,0,0,1-11.32,0l-80-80A8,8,0,0,1,53.66,90.34L128,164.69l74.34-74.35a8,8,0,0,1,11.32,11.32Z"/>'),FR=vi('<path d="M128,80a48,48,0,1,0,48,48A48.05,48.05,0,0,0,128,80Zm0,80a32,32,0,1,1,32-32A32,32,0,0,1,128,160Zm88-29.84q.06-2.16,0-4.32l14.92-18.64a8,8,0,0,0,1.48-7.06,107.21,107.21,0,0,0-10.88-26.25,8,8,0,0,0-6-3.93l-23.72-2.64q-1.48-1.56-3-3L186,40.54a8,8,0,0,0-3.94-6,107.71,107.71,0,0,0-26.25-10.87,8,8,0,0,0-7.06,1.49L130.16,40Q128,40,125.84,40L107.2,25.11a8,8,0,0,0-7.06-1.48A107.6,107.6,0,0,0,73.89,34.51a8,8,0,0,0-3.93,6L67.32,64.27q-1.56,1.49-3,3L40.54,70a8,8,0,0,0-6,3.94,107.71,107.71,0,0,0-10.87,26.25,8,8,0,0,0,1.49,7.06L40,125.84Q40,128,40,130.16L25.11,148.8a8,8,0,0,0-1.48,7.06,107.21,107.21,0,0,0,10.88,26.25,8,8,0,0,0,6,3.93l23.72,2.64q1.49,1.56,3,3L70,215.46a8,8,0,0,0,3.94,6,107.71,107.71,0,0,0,26.25,10.87,8,8,0,0,0,7.06-1.49L125.84,216q2.16.06,4.32,0l18.64,14.92a8,8,0,0,0,7.06,1.48,107.21,107.21,0,0,0,26.25-10.88,8,8,0,0,0,3.93-6l2.64-23.72q1.56-1.48,3-3L215.46,186a8,8,0,0,0,6-3.94,107.71,107.71,0,0,0,10.87-26.25,8,8,0,0,0-1.49-7.06Zm-16.1-6.5a73.93,73.93,0,0,1,0,8.68,8,8,0,0,0,1.74,5.48l14.19,17.73a91.57,91.57,0,0,1-6.23,15L187,173.11a8,8,0,0,0-5.1,2.64,74.11,74.11,0,0,1-6.14,6.14,8,8,0,0,0-2.64,5.1l-2.51,22.58a91.32,91.32,0,0,1-15,6.23l-17.74-14.19a8,8,0,0,0-5-1.75h-.48a73.93,73.93,0,0,1-8.68,0,8,8,0,0,0-5.48,1.74L100.45,215.8a91.57,91.57,0,0,1-15-6.23L82.89,187a8,8,0,0,0-2.64-5.1,74.11,74.11,0,0,1-6.14-6.14,8,8,0,0,0-5.1-2.64L46.43,170.6a91.32,91.32,0,0,1-6.23-15l14.19-17.74a8,8,0,0,0,1.74-5.48,73.93,73.93,0,0,1,0-8.68,8,8,0,0,0-1.74-5.48L40.2,100.45a91.57,91.57,0,0,1,6.23-15L69,82.89a8,8,0,0,0,5.1-2.64,74.11,74.11,0,0,1,6.14-6.14A8,8,0,0,0,82.89,69L85.4,46.43a91.32,91.32,0,0,1,15-6.23l17.74,14.19a8,8,0,0,0,5.48,1.74,73.93,73.93,0,0,1,8.68,0,8,8,0,0,0,5.48-1.74L155.55,40.2a91.57,91.57,0,0,1,15,6.23L173.11,69a8,8,0,0,0,2.64,5.1,74.11,74.11,0,0,1,6.14,6.14,8,8,0,0,0,5.1,2.64l22.58,2.51a91.32,91.32,0,0,1,6.23,15l-14.19,17.74A8,8,0,0,0,199.87,123.66Z"/>');class _m extends Event{constructor(n){super("dropdown-item-select",{bubbles:!0,composed:!0});v(this,"value");this.value=n}}class ZR extends Event{constructor(n){super("select",{bubbles:!0,composed:!0});v(this,"value");this.value=n}}var Je,ot,en,$r,ne,Gs,z,km,ms,Em,$m,Il,Pl,so,_n,Ln,Hs,qs,Ys,Io,Am,xm,Rl,vs,Dl,Ct;class Sm extends HTMLElement{constructor(){super();x(this,z);x(this,Je,!1);x(this,ot,null);x(this,en,null);x(this,$r);x(this,ne,null);x(this,Gs,new MutationObserver(n=>b(this,z,Am).call(this,n)));x(this,Ln,()=>{b(this,z,so).call(this,!h(this,Je))});x(this,Hs,n=>{n.key!=="Enter"&&n.key!==" "||(n.preventDefault(),h(this,Ln).call(this))});x(this,qs,n=>{h(this,Je)&&(n.composedPath().includes(this)||b(this,z,so).call(this,!1))});x(this,Ys,n=>{n instanceof _m&&(n.stopPropagation(),$(this,Je,!1),b(this,z,ms).call(this,n.value),b(this,z,Ct).call(this),this.dispatchEvent(new ZR(n.value)))});x(this,Io,()=>{b(this,z,Rl).call(this)});$(this,$r,this.attachShadow({mode:"open"}))}connectedCallback(){this.addEventListener("dropdown-item-select",h(this,Ys)),document.addEventListener("click",h(this,qs),!0),b(this,z,km).call(this),h(this,Gs).observe(this,{childList:!0,subtree:!0,characterData:!0,attributes:!0,attributeFilter:["selected","value","slot"]}),b(this,z,Ct).call(this)}disconnectedCallback(){this.removeEventListener("dropdown-item-select",h(this,Ys)),document.removeEventListener("click",h(this,qs),!0),h(this,Gs).disconnect(),b(this,z,Dl).call(this)}attributeChangedCallback(){b(this,z,Ct).call(this)}get title(){return this.getAttribute("title")??""}get value(){return h(this,ot)}set value(n){n===null?(b(this,z,_n).call(this,null,null),b(this,z,Em).call(this)):b(this,z,ms).call(this,n),b(this,z,Ct).call(this)}close(){b(this,z,so).call(this,!1)}}Je=new WeakMap,ot=new WeakMap,en=new WeakMap,$r=new WeakMap,ne=new WeakMap,Gs=new WeakMap,z=new WeakSet,km=function(){var r;const n=this.querySelector("dropdown-item[selected]");n&&b(this,z,_n).call(this,n.value,((r=n.textContent)==null?void 0:r.trim())??null)},ms=function(n){var r;for(const s of h(this,z,Il))s.value===n?(b(this,z,_n).call(this,n,((r=s.textContent)==null?void 0:r.trim())??null),s.hasAttribute("selected")||s.setAttribute("selected","")):s.hasAttribute("selected")&&s.removeAttribute("selected")},Em=function(){const n=this.querySelectorAll("dropdown-item[selected]");for(const r of n)r.removeAttribute("selected")},$m=function(n){for(const r of h(this,z,Il))if(r.value===n)return r;return null},Il=function(){return this.querySelectorAll("dropdown-item")},Pl=function(){return h(this,en)??this.title},so=function(n){h(this,Je)!==n&&($(this,Je,n),b(this,z,Ct).call(this))},_n=function(n,r){$(this,ot,n),$(this,en,r)},Ln=new WeakMap,Hs=new WeakMap,qs=new WeakMap,Ys=new WeakMap,Io=new WeakMap,Am=function(n){n.every(s=>s.target instanceof Element?s.target.closest('[slot="trigger"]')!==null:!1)||b(this,z,xm).call(this)},xm=function(){var r,s;const n=this.querySelector("dropdown-item[selected]");if(n){const i=n.value,o=((r=n.textContent)==null?void 0:r.trim())??null,a=h(this,ot)!==i||h(this,en)!==o;b(this,z,_n).call(this,i,o),b(this,z,ms).call(this,i),a?b(this,z,Ct).call(this):b(this,z,vs).call(this);return}if(h(this,ot)!==null){const i=b(this,z,$m).call(this,h(this,ot));if(i){const o=((s=i.textContent)==null?void 0:s.trim())??null,a=h(this,en)!==o;b(this,z,_n).call(this,h(this,ot),o),b(this,z,ms).call(this,h(this,ot)),a?b(this,z,Ct).call(this):b(this,z,vs).call(this);return}}if(h(this,ot)!==null||h(this,en)!==null){b(this,z,_n).call(this,null,null),b(this,z,Ct).call(this);return}b(this,z,vs).call(this)},Rl=function(){const n=h(this,$r).querySelector('slot[name="trigger"]'),r=n instanceof HTMLSlotElement?n.assignedElements()[0]??null:null;h(this,ne)!==r&&(b(this,z,Dl).call(this),$(this,ne,r),h(this,ne)&&(h(this,ne).addEventListener("click",h(this,Ln)),h(this,ne)instanceof HTMLButtonElement?h(this,ne).hasAttribute("type")||(h(this,ne).type="button"):(h(this,ne).hasAttribute("role")||h(this,ne).setAttribute("role","button"),h(this,ne).hasAttribute("tabindex")||(h(this,ne).tabIndex=0),h(this,ne).addEventListener("keydown",h(this,Hs))))),b(this,z,vs).call(this)},vs=function(){h(this,ne)&&(h(this,ne).setAttribute("data-dropdown-trigger",""),h(this,ne).setAttribute("aria-haspopup","listbox"),h(this,ne).setAttribute("aria-expanded",h(this,Je)?"true":"false"),be(M`
|
|
69
|
-
<span class="trigger-label" data-dropdown-trigger-label>${h(this,z,Pl)}</span>
|
|
70
|
-
<span class="trigger-icon" data-dropdown-trigger-icon aria-hidden="true">
|
|
71
|
-
${Cl({size:14})}
|
|
72
|
-
</span>
|
|
73
|
-
`,h(this,ne)))},Dl=function(){h(this,ne)&&(h(this,ne).removeEventListener("click",h(this,Ln)),h(this,ne).removeEventListener("keydown",h(this,Hs)),h(this,ne).removeAttribute("data-dropdown-trigger"),h(this,ne).removeAttribute("aria-haspopup"),h(this,ne).removeAttribute("aria-expanded"),$(this,ne,null))},Ct=function(){this.toggleAttribute("open",h(this,Je)),be(M`
|
|
74
|
-
<slot name="trigger" @slotchange=${h(this,Io)}>
|
|
75
|
-
<button
|
|
76
|
-
class="fallback-trigger"
|
|
77
|
-
part="trigger"
|
|
78
|
-
type="button"
|
|
79
|
-
aria-haspopup="listbox"
|
|
80
|
-
aria-expanded=${h(this,Je)?"true":"false"}
|
|
81
|
-
@click=${h(this,Ln)}
|
|
82
|
-
>
|
|
83
|
-
<span class="trigger-label" part="trigger-label">${h(this,z,Pl)}</span>
|
|
84
|
-
<span class="trigger-icon" part="trigger-icon" aria-hidden="true">
|
|
85
|
-
${Cl({size:14})}
|
|
86
|
-
</span>
|
|
87
|
-
</button>
|
|
88
|
-
</slot>
|
|
89
|
-
${h(this,Je)?M`
|
|
90
|
-
<div class="panel" part="panel" role="listbox">
|
|
91
|
-
<slot></slot>
|
|
92
|
-
</div>
|
|
93
|
-
`:null}
|
|
94
|
-
`,h(this,$r)),queueMicrotask(()=>b(this,z,Rl).call(this))},v(Sm,"observedAttributes",["title"]);class jR extends HTMLElement{}class WR extends HTMLElement{}class BR extends HTMLElement{}var Gn,Ol,Cm,Ks,Js;class Tm extends HTMLElement{constructor(){super(...arguments);x(this,Gn);x(this,Ks,()=>{this.action||b(this,Gn,Cm).call(this)});x(this,Js,n=>{n.key!=="Enter"&&n.key!==" "||(n.preventDefault(),this.click())})}connectedCallback(){this.hasAttribute("role")||this.setAttribute("role","option"),this.hasAttribute("tabindex")||(this.tabIndex=0),this.addEventListener("click",h(this,Ks)),this.addEventListener("keydown",h(this,Js)),b(this,Gn,Ol).call(this)}disconnectedCallback(){this.removeEventListener("click",h(this,Ks)),this.removeEventListener("keydown",h(this,Js))}attributeChangedCallback(){b(this,Gn,Ol).call(this)}get value(){return this.getAttribute("value")??""}get selected(){return this.hasAttribute("selected")}get action(){return this.hasAttribute("action")}}Gn=new WeakSet,Ol=function(){if(this.action){this.setAttribute("role","button"),this.removeAttribute("aria-selected");return}this.setAttribute("role","option"),this.setAttribute("aria-selected",this.selected?"true":"false")},Cm=function(){this.dispatchEvent(new _m(this.value))},Ks=new WeakMap,Js=new WeakMap,v(Tm,"observedAttributes",["action","selected","value"]);customElements.get("dropdown-menu")||customElements.define("dropdown-menu",Sm);customElements.get("dropdown-group")||customElements.define("dropdown-group",jR);customElements.get("dropdown-label")||customElements.define("dropdown-label",WR);customElements.get("dropdown-divider")||customElements.define("dropdown-divider",BR);customElements.get("dropdown-item")||customElements.define("dropdown-item",Tm);class VR extends Event{constructor(){super("close",{bubbles:!0,composed:!0})}}var Xs,un,zl,Po,Qs,Ll;class Im extends HTMLElement{constructor(){super();x(this,un);x(this,Xs);x(this,Po,n=>{n.target===n.currentTarget&&b(this,un,zl).call(this)});x(this,Qs,n=>{this.open&&n.key==="Escape"&&b(this,un,zl).call(this)});$(this,Xs,this.attachShadow({mode:"open"}))}connectedCallback(){document.addEventListener("keydown",h(this,Qs)),b(this,un,Ll).call(this)}disconnectedCallback(){document.removeEventListener("keydown",h(this,Qs))}attributeChangedCallback(){b(this,un,Ll).call(this)}get open(){return this.hasAttribute("open")}}Xs=new WeakMap,un=new WeakSet,zl=function(){this.dispatchEvent(new VR)},Po=new WeakMap,Qs=new WeakMap,Ll=function(){be(M`
|
|
95
|
-
${this.open?M`
|
|
96
|
-
<div class="backdrop" part="backdrop" @click=${h(this,Po)}>
|
|
97
|
-
<slot></slot>
|
|
98
|
-
</div>
|
|
99
|
-
`:null}
|
|
100
|
-
`,h(this,Xs))},v(Im,"observedAttributes",["open"]);customElements.get("modal-overlay")||customElements.define("modal-overlay",Im);class Pm extends Event{constructor(){super("close",{bubbles:!0,composed:!0})}}class GR extends HTMLElement{}var ei,ti,Ml;class Rm extends HTMLElement{constructor(){super();x(this,ti);x(this,ei);$(this,ei,this.attachShadow({mode:"open"}))}connectedCallback(){b(this,ti,Ml).call(this)}attributeChangedCallback(){b(this,ti,Ml).call(this)}get closable(){return this.hasAttribute("closable")}}ei=new WeakMap,ti=new WeakSet,Ml=function(){const n=this.querySelector("panel-page");be(M`
|
|
101
|
-
<section class="panel" part="panel">
|
|
102
|
-
<header class="title-bar" part="header">
|
|
103
|
-
<h2 class="title" part="title">${(n==null?void 0:n.getAttribute("title"))??""}</h2>
|
|
104
|
-
${this.closable?M`
|
|
105
|
-
<button
|
|
106
|
-
type="button"
|
|
107
|
-
class="title-button"
|
|
108
|
-
part="button close-button"
|
|
109
|
-
aria-label="Close"
|
|
110
|
-
@click=${()=>this.dispatchEvent(new Pm)}
|
|
111
|
-
>
|
|
112
|
-
<span class="close-icon" part="icon close-icon">${wm({size:14})}</span>
|
|
113
|
-
</button>
|
|
114
|
-
`:null}
|
|
115
|
-
</header>
|
|
116
|
-
<slot></slot>
|
|
117
|
-
</section>
|
|
118
|
-
`,h(this,ei))},v(Rm,"observedAttributes",["closable"]);customElements.get("panel-view")||customElements.define("panel-view",Rm);customElements.get("panel-page")||customElements.define("panel-page",GR);const HR=Be(),qR="No handler registered for update-content",YR="handleUpdateContent: handler already registered";function KR(t){return t instanceof Error&&typeof t.message=="string"?t.message:String(t)}const JR=Gr(kt);var Ar,xr,Tr,Mn,Nn,ni,Ce,Nl,Dm,Om,ys,Ul,uf;let XR=(uf=class extends JR{constructor(n){super();x(this,Ce);x(this,Ar);x(this,xr);x(this,Tr);x(this,Mn,null);x(this,Nn,null);x(this,ni,!1);$(this,Ar,n);const r=n.ownerDocument.defaultView;if(!r)throw new Error("ArtifactView: iframe has no owner window");$(this,xr,r),$(this,Tr,s=>b(this,Ce,Dm).call(this,s)),h(this,xr).addEventListener("message",h(this,Tr))}get content(){return h(this,Nn)}set content(n){b(this,Ce,Ul).call(this),$(this,Nn,n),h(this,ni)&&b(this,Ce,Nl).call(this,n)}handleUpdateContent(n){if(b(this,Ce,Ul).call(this),h(this,Mn)!==null)throw new Error(YR);$(this,Mn,n)}dispose(){h(this,xr).removeEventListener("message",h(this,Tr)),$(this,Mn,null)}},Ar=new WeakMap,xr=new WeakMap,Tr=new WeakMap,Mn=new WeakMap,Nn=new WeakMap,ni=new WeakMap,Ce=new WeakSet,Nl=function(n){const r={type:"content-updated",content:n};b(this,Ce,ys).call(this,r)},Dm=function(n){if(this.disposed||n.source!==h(this,Ar).contentWindow)return;const r=n.data;if(AT(r)){$(this,ni,!0),this.dispatchEvent(new HR("ready")),h(this,Nn)!==null&&b(this,Ce,Nl).call(this,h(this,Nn));return}if(xT(r)){b(this,Ce,Om).call(this,r);return}},Om=async function(n){const r=h(this,Mn);if(r===null){b(this,Ce,ys).call(this,{type:"response",id:n.id,error:{message:qR}});return}try{await r(n.content)}catch(s){if(this.disposed)return;b(this,Ce,ys).call(this,{type:"response",id:n.id,error:{message:KR(s)}});return}this.disposed||b(this,Ce,ys).call(this,{type:"response",id:n.id,result:{}})},ys=function(n){const r=h(this,Ar).contentWindow;r&&r.postMessage(n,"*")},Ul=function(){if(this.disposed)throw new Error("ArtifactView is disposed")},uf);function QR(t=window){t.parent!==t&&(t.addEventListener("wheel",e=>{const n=e;t.parent.postMessage({type:"wheel",deltaX:n.deltaX,deltaY:n.deltaY,shiftKey:n.shiftKey},"*"),n.preventDefault()},{passive:!1}),t.addEventListener("message",e=>{const n=e.data;if(n!==null&&typeof n=="object"&&n.type==="scroll"){const r=n,s=typeof r.deltaX=="number"?r.deltaX:0,i=typeof r.deltaY=="number"?r.deltaY:0;t.scrollBy(s,i)}}))}function e1(){return`(${QR.toString()})(window);`}async function t1(t){const e=await fetch(t);if(!e.ok)throw new Error(`Failed to fetch artifact content: ${e.status}`);const n=await e.text(),r=new DOMParser().parseFromString(n,"text/html"),s=r.createElement("base");s.href=t,r.head.insertBefore(s,r.head.firstChild);const i=r.createElement("script");i.textContent=e1(),r.head.appendChild(i);const o=new Blob([`<!DOCTYPE html>
|
|
119
|
-
${r.documentElement.outerHTML}`],{type:"text/html"});return URL.createObjectURL(o)}const zm=Be();class n1 extends HTMLElement{constructor(){super(...arguments);v(this,"_artifact",null);v(this,"_viewURL",null);v(this,"_contentURL",null);v(this,"_screen",null);v(this,"_subscribedScreen",null);v(this,"_activeView",null);v(this,"_contentState",{kind:"idle"});v(this,"_fetchSequence",0);v(this,"_blobSequence",0);v(this,"_mountedViewURL",null);v(this,"_directRender",!1);v(this,"_blobURL",null);v(this,"handleScreenContentChanged",n=>{!this._artifact||n.artifactID!==this._artifact.id||this._activeView!==null&&this.refetchContent()})}set artifact(n){const r=this._artifact;this._artifact=n,this.render(),r!==null&&r!==n&&this.syncView()}get artifact(){return this._artifact}set viewURL(n){this._viewURL!==n&&(this._viewURL=n,this.syncView())}get viewURL(){return this._viewURL}set contentURL(n){this._contentURL!==n&&(this._contentURL=n,this.syncView())}get contentURL(){return this._contentURL}set screen(n){this._screen!==n&&(this._screen=n,this.syncScreenSubscription())}get screen(){return this._screen}get activeView(){return this._activeView}connectedCallback(){this.render(),this.syncView(),this.syncScreenSubscription()}disconnectedCallback(){this.teardownView(),this.unsubscribeFromScreen()}handleClose(){this._artifact&&this.dispatchEvent(new zm("close-artifact",{artifactID:this._artifact.id,bubbles:!0,composed:!0}))}syncView(){var n;if(this.isConnected){if(this._viewURL!==null){if(this._directRender&&this.teardownView(),this._mountedViewURL!==this._viewURL){this.teardownView(),this._contentState={kind:"loading"},this._mountedViewURL=this._viewURL,this.render();const r=this.querySelector("iframe.artifact-frame");if(!r){this._contentState={kind:"error"},this.render();return}this._activeView=new XR(r),this._activeView.handleUpdateContent(async s=>{await this.saveContent(s)}),this.loadBlobFrame(this._viewURL),this.startContentFetch();return}this._activeView!==null&&this.startContentFetch();return}if(this._contentURL!==null){this.teardownView(),this._directRender=!0,this._contentState={kind:"idle"},this.render(),((n=this._artifact)==null?void 0:n.status)==="committed"&&this.loadBlobFrame(this._contentURL);return}this.teardownView(),this._contentState={kind:"idle"},this.render()}}async saveContent(n){const r=this._screen,s=this._artifact;if(!r||!s)throw new Error("artifact-view: cannot save without a screen and artifact");await r.server.client.artifacts.putContent({artifactID:s.id,content:n})}syncScreenSubscription(){if(!this.isConnected){this.unsubscribeFromScreen();return}this._subscribedScreen!==this._screen&&(this.unsubscribeFromScreen(),this._screen!==null&&(this._screen.addEventListener("artifact-content-changed",this.handleScreenContentChanged),this._subscribedScreen=this._screen))}unsubscribeFromScreen(){this._subscribedScreen!==null&&(this._subscribedScreen.removeEventListener("artifact-content-changed",this.handleScreenContentChanged),this._subscribedScreen=null)}startContentFetch(){this._fetchSequence+=1;const n=this._fetchSequence,r=this._contentURL,s=this._activeView;if(!s||r===null){this._contentState={kind:"error"},this.render();return}this._contentState={kind:"loading"},(async()=>{try{const i=await fetch(r);if(n!==this._fetchSequence)return;if(!i.ok){this._contentState={kind:"error"},this.teardownView(),this.render();return}const o=await i.text();if(n!==this._fetchSequence||this._activeView!==s)return;this._activeView.content=o,this._contentState={kind:"ready"}}catch{if(n!==this._fetchSequence)return;this._contentState={kind:"error"},this.teardownView(),this.render()}})()}refetchContent(){this._fetchSequence+=1;const n=this._fetchSequence,r=this._contentURL,s=this._activeView;!s||r===null||(async()=>{try{const i=await fetch(r);if(n!==this._fetchSequence||!i.ok)return;const o=await i.text();if(n!==this._fetchSequence||this._activeView!==s)return;this._activeView.content=o}catch{}})()}loadBlobFrame(n){this._blobSequence+=1;const r=this._blobSequence;(async()=>{try{const s=await t1(n);if(r!==this._blobSequence){URL.revokeObjectURL(s);return}this._blobURL=s,this.render();const i=this.querySelector("iframe.artifact-frame");i&&(i.src=s)}catch{if(r!==this._blobSequence)return;this._contentState={kind:"error"},this.teardownView(),this.render()}})()}teardownView(){this._activeView!==null&&(this._activeView.dispose(),this._activeView=null),this._blobURL!==null&&(URL.revokeObjectURL(this._blobURL),this._blobURL=null),this._mountedViewURL=null,this._directRender=!1,this._fetchSequence+=1,this._blobSequence+=1}contentTemplate(){return this._contentState.kind==="error"?M`
|
|
120
|
-
<div class="artifact-content artifact-placeholder">
|
|
121
|
-
<em>Failed to load content</em>
|
|
122
|
-
</div>
|
|
123
|
-
`:this._viewURL!==null||this._directRender?M`
|
|
124
|
-
<iframe
|
|
125
|
-
class="artifact-frame artifact-content"
|
|
126
|
-
src=${this._blobURL??"about:blank"}
|
|
127
|
-
sandbox="allow-scripts"
|
|
128
|
-
></iframe>
|
|
129
|
-
`:M`
|
|
130
|
-
<div class="artifact-content artifact-placeholder">
|
|
131
|
-
<em>Artifact unavailable</em>
|
|
132
|
-
</div>
|
|
133
|
-
`}template(){const n=this._artifact;return M`
|
|
134
|
-
<header class="artifact-title-bar" drag-handle>
|
|
135
|
-
<span class="artifact-title">${n.title}</span>
|
|
136
|
-
<button
|
|
137
|
-
class="artifact-close-btn"
|
|
138
|
-
@click=${()=>this.handleClose()}
|
|
139
|
-
aria-label="Close"
|
|
140
|
-
>
|
|
141
|
-
${wm({size:14})}
|
|
142
|
-
</button>
|
|
143
|
-
</header>
|
|
144
|
-
${this.contentTemplate()}
|
|
145
|
-
`}render(){this._artifact&&(this.setAttribute("type",this._artifact.type),be(this.template(),this))}}customElements.define("artifact-view",n1);const Se=t=>({type:"px",...t}),Te=t=>({type:"unit",...t}),Zi=2,r1=2;class s1{constructor(e){v(this,"basis");v(this,"min");v(this,"_gap");v(this,"_viewport");v(this,"_unit");this.basis=e.basis,this.min=e.min,this._viewport=e.viewport,this._gap=e.gap??Se({x:de,y:de});const n=this._viewport.x??nn,r=this._viewport.y??mr,s=this._gap.x??de,i=this._gap.y??de,o=nn+s*r1,a=n<=o,l=a?n-s*Zi:Math.min(nn,n-s*Zi),c=a?r-i*Zi:Math.min(mr,r-i*Zi),d=(l-s*(St-1))/St,f=(c-i*(Ke-1))/Ke,y=this.basis.x??0,m=this.basis.y??0,E=this.min.x??0,k=this.min.y??0;this._unit=Se(a?{x:Math.max(E,d),y:Math.max(k,f)}:{x:Math.max(E,Math.min(y,d)),y:Math.max(k,Math.min(m,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 n=this._unit.x??0,r=this._unit.y??0,s=this._gap.x??de,i=this._gap.y??de,o=e.x==null?void 0:e.x*n+Math.max(0,e.x-1)*s,a=e.y==null?void 0:e.y*r+Math.max(0,e.y-1)*i;return Se({x:o,y:a})}}const Bn=1e-4,Ut=1e-6,i1=40,o1=24;function Lm(t,e){return Math.max(0,t-e*2)}function Mm(t){const e=[0];for(const n of t)e.push((e[e.length-1]??0)+n);return e}function Nm(t){const e=[0];for(let n=0;n<t.length;n+=1){const r=e[n]??0;e.push(r+t[n]+de)}return e}function Um(t,e,n){if(e<0||e>=t.length)return 0;let r=0,s=0;for(let i=e;i<t.length;i+=1){const o=t[i],a=s===0?o:r+de+o;if(a>n+Bn)break;r=a,s+=1}return Math.max(1,s)}function a1(t,e,n){if(e<0||e>=t.length)return 0;let r=0,s=0;for(let i=e;i>=0;i-=1){const o=t[i],a=s===0?o:r+de+o;if(a>n+Bn)break;r=a,s+=1}return Math.max(1,s)}function l1(t,e){if(t.length===0)return 0;let n=0,r=0;for(let s=t.length-1;s>=0;s-=1){const i=t[s],o=r===0?i:n+de+i;if(o>e+Bn)break;n=o,r+=1}return Math.max(1,r)}function Uc(t,e){if(t.length===0)return 0;const n=l1(t,e);return Math.max(0,t.length-n)}function Rd(t,e,n){if(t.length===0)return 0;const r=Um(t,e,n),s=Math.min(t.length,e+r);if(s<=e)return 0;const i=t.slice(e,s);return i.reduce((o,a)=>o+a,0)+Math.max(0,i.length-1)*de}function Fl(t,e,n){const r=t[e]??0;return n-r}function fr(t,e,n,r,s){if(t.length===0)return 0;const i=Uc(t,s),o=e[i]??0,a=Math.max(0,Math.min(o,n));let l=0;for(let L=0;L<i;L+=1){const J=e[L]??0,H=e[L+1]??J;if(a>=J&&a<=H+Bn){l=L;break}l=L+1}const c=Math.min(l+1,i),d=e[l]??0,f=e[c]??d,y=Math.max(f-d,Bn),m=c===l?0:(a-d)/y,E=Nm(t),k=Rd(t,l,s),I=Rd(t,c,s),V=(r-k)/2,N=(r-I)/2,j=Fl(E,l,V),F=Fl(E,c,N);return j+(F-j)*m}function Dd(t,e,n,r,s){const i=Uc(t,r),o=e[i]??0;let a=0,l=o;for(let c=0;c<i1;c+=1){const d=(a+l)/2;fr(t,e,d,n,r)>s?a=d:l=d}return(a+l)/2}function Od(t,e,n){const r=Nm(t),[s,i]=e,o=t.slice(s,i+1),a=o.reduce((c,d)=>c+d,0)+Math.max(0,o.length-1)*de,l=(n-a)/2;return Fl(r,s,l)}function c1(t,e,n){const r=Um(t,e,n);return[e,Math.min(t.length-1,e+r-1)]}function u1(t,e,n){const r=a1(t,e,n);return[Math.max(0,e-r+1),e]}function h1(t){const e=new Set,n=[];for(const r of t){const s=`${r.nodeRange[0]}:${r.nodeRange[1]}`;if(e.has(s))continue;const i=n[n.length-1];i&&Math.abs(i.anchor-r.anchor)<=Ut||(e.add(s),n.push(r))}return n}function d1(t){const{nodeCols:e,nodeWidthsPx:n,viewportWidthPx:r}=t;if(e.length===0||n.length===0)return{viewspans:[],minScroll:0,maxScroll:0};const s=t.gapPx??de,i=Lm(r,s),o=Mm(e),a=Uc(n,i),l=o[a]??0,c=[];for(let d=0;d<=a;d+=1){const f=c1(n,d,i),y=Od(n,f,r),m=Dd(n,o,r,i,y);c.push({nodeRange:f,anchor:Math.max(0,Math.min(l,m))})}for(let d=n.length-1;d>=0;d-=1){const f=u1(n,d,i),y=`${f[0]}:${f[1]}`;if(c.some(k=>`${k.nodeRange[0]}:${k.nodeRange[1]}`===y))continue;const m=Od(n,f,r),E=Dd(n,o,r,i,m);c.push({nodeRange:f,anchor:Math.max(0,Math.min(l,E))})}return c.sort((d,f)=>Math.abs(d.anchor-f.anchor)>Ut?d.anchor-f.anchor:d.nodeRange[0]!==f.nodeRange[0]?d.nodeRange[0]-f.nodeRange[0]:d.nodeRange[1]-f.nodeRange[1]),{viewspans:h1(c),minScroll:0,maxScroll:l}}function f1(t,e){var s;let n=0,r=Number.POSITIVE_INFINITY;for(let i=0;i<t.length;i+=1){const o=Math.abs((((s=t[i])==null?void 0:s.anchor)??0)-e);if(o+Ut<r){r=o,n=i;continue}Math.abs(o-r)<=Ut&&i<n&&(n=i)}return n}function p1(t,e,n){return n<=0?0:Math.max(0,Math.min(n-1,t+e))}function is(t,e,n){return Math.max(e,Math.min(n,t))}class g1 extends kt{constructor(n){super();v(this,"_scroll",0);v(this,"minScroll",0);v(this,"maxScroll",0);v(this,"viewspans",[]);v(this,"activeViewspanIndex",null);v(this,"nodeWidthsPx",[]);v(this,"boundaryCols",[0]);v(this,"viewportWidthPx",0);v(this,"framedViewportWidthPx",0);this._scroll=(n==null?void 0:n.x)??0}get scroll(){return Te({x:this._scroll})}get translate(){return Se({x:fr(this.nodeWidthsPx,this.boundaryCols,this._scroll,this.viewportWidthPx,this.framedViewportWidthPx)})}set scroll(n){const r=is(n.x??this._scroll,this.minScroll,this.maxScroll);Math.abs(r-this._scroll)<=Ut||(this._scroll=r,this.activeViewspanIndex=null,this.dispatchEvent(new rs("layout-scroll",{scroll:this.scroll})))}rebuild(n){const r=n.nodeWidths.map(c=>Math.max(0,c.x??0)),s=r.map(c=>n.grid.toPixels(Te({x:c})).x??0),i=n.grid.viewport.x??0,o=n.grid.gap.x??de,a=d1({nodeCols:r,nodeWidthsPx:s,viewportWidthPx:i,gapPx:o});this.nodeWidthsPx=s,this.boundaryCols=Mm(r),this.viewportWidthPx=i,this.framedViewportWidthPx=Lm(i,o),this.viewspans=a.viewspans,this.minScroll=a.minScroll,this.maxScroll=a.maxScroll,this.activeViewspanIndex=null;const l=is(this._scroll,this.minScroll,this.maxScroll);Math.abs(l-this._scroll)>Ut&&(this._scroll=l,this.dispatchEvent(new rs("layout-scroll",{scroll:this.scroll})))}step(n){var a;if(this.viewspans.length===0)return;const r=this.activeViewspanIndex??f1(this.viewspans,this._scroll),s=p1(r,n,this.viewspans.length),i=((a=this.viewspans[s])==null?void 0:a.anchor)??this._scroll,o=is(i,this.minScroll,this.maxScroll);this.activeViewspanIndex=s,!(Math.abs(o-this._scroll)<=Ut)&&(this._scroll=o,this.dispatchEvent(new rs("layout-scroll",{scroll:this.scroll})))}wheel(n){const r=is(this._scroll+(n.x??0),this.minScroll,this.maxScroll);this.activeViewspanIndex=null,!(Math.abs(r-this._scroll)<=Ut)&&(this._scroll=r,this.dispatchEvent(new rs("layout-scroll",{scroll:this.scroll})))}wheelPixels(n){const r=n.x??0;if(Math.abs(r)<=Bn)return;this.activeViewspanIndex=null;const s=fr(this.nodeWidthsPx,this.boundaryCols,this._scroll,this.viewportWidthPx,this.framedViewportWidthPx),i=s-r,o=fr(this.nodeWidthsPx,this.boundaryCols,this.maxScroll,this.viewportWidthPx,this.framedViewportWidthPx),a=fr(this.nodeWidthsPx,this.boundaryCols,this.minScroll,this.viewportWidthPx,this.framedViewportWidthPx),l=Math.max(o,Math.min(a,i));if(Math.abs(l-s)<=Bn)return;let c=this.minScroll,d=this.maxScroll;for(let y=0;y<o1;y+=1){const m=(c+d)/2;fr(this.nodeWidthsPx,this.boundaryCols,m,this.viewportWidthPx,this.framedViewportWidthPx)>l?c=m:d=m}const f=is((c+d)/2,this.minScroll,this.maxScroll);Math.abs(f-this._scroll)<=Ut||(this._scroll=f,this.dispatchEvent(new rs("layout-scroll",{scroll:this.scroll})))}}const Ga={"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}},m1=["stack-above","stack-below","reorder-before","reorder-after"];function Ha(t,e){return{left:t.left+t.width*e.left,top:t.top+t.height*e.top,width:t.width*e.width,height:t.height*e.height}}function bn(t,e,n){return t>=n.left&&t<n.left+n.width&&e>=n.top&&e<n.top+n.height}function Fc(t,e){for(const n of t){if(n.type==="card"&&n.id===e)return n;if(n.type==="stack")for(const r of n.children){if(r.type==="card"&&r.id===e)return r;if(r.type==="row"){for(const s of r.children)if(s.id===e)return s}}}return null}function Zl(t){return t.height===Ke||t.height===on?{...t,height:on}:t}function jl(t){return t.height===on?{...t,height:Ke}:t}function v1(t,e,n,r){const s=t.findIndex(d=>d.type==="stack"&&d.id===e);if(s===-1)return t;const i=t[s];if(!i||i.type!=="stack")return t;const o=i.children.find(d=>d.type==="card"&&d.id===n);if(!o||o.type!=="card")return t;const a=i.children.filter(d=>d.id!==n);if(a.length===i.children.length||a.length<1)return t;const l=[...t];if(a.length===1){const[d]=a;l[s]=d.type==="card"?jl(d):d}else l[s]={...i,children:a};const c=Math.max(0,Math.min(r,l.length));return l.splice(c,0,jl(o)),l}const y1=Be(),b1=Be(),w1=50;function _1(t,e){if(t.type!==e.type)return!1;switch(t.type){case"reorder":return e.index===t.index;case"stack":return e.targetCardId===t.targetCardId&&e.position===t.position;case"stack-child-noop":return!0;case"stack-child-extract":return e.toIndex===t.toIndex;case"stack-child-reorder":return e.position===t.position;default:return!1}}function yi(t){return{id:t.id,type:"drop-target",width:t.width,height:t.height}}function zd(t){return t.map(k1)}function S1(t){return t.type==="drop-target"?{id:t.id,type:"card",artifactID:t.id,width:t.width,height:t.height}:t}function k1(t){return t.type==="drop-target"?{id:t.id,type:"card",artifactID:t.id,width:t.width,height:t.height}:t.type==="stack"?{...t,children:t.children.map(S1)}:t}function Fm(t,e){return t.find(r=>r.type==="card"&&r.id===e)??null}function Ld(t,e){return t.find(r=>r.type==="stack"&&r.id===e)??null}function E1(t,e){const n=[...e],r=n.findIndex(a=>a.type==="card"&&a.id===t.nodeId);if(r===-1)return null;const s=n[r];if(!s||s.type!=="card")return null;n.splice(r,1);const i=Math.max(0,Math.min(t.lastReorderIndex,n.length));n.splice(i,0,s);const o=n.findIndex(a=>a.type==="card"&&a.id===t.nodeId);return o===-1?null:{base:n,visualDraggedIndex:o}}function $1(t,e,n,r){const s=[...t.base];s.splice(t.visualDraggedIndex,1);const i=s.findIndex(y=>y.type==="card"&&y.id===n.targetCardId),o=i===-1?null:s[i];if(!o||o.type!=="card")return null;const a=Fm(r,e.nodeId);if(!a)return null;const l=Zl(a),c=Zl(o),d=yi(l),f=n.position==="above"?[d,c]:[c,d];return s[i]={id:o.id,type:"stack",children:f},s}function qa(t,e){return t.parentStackId?x1(t,e):A1(t,e)}function A1(t,e){const n=t.hitTarget;if(n.type==="reorder"){const r=e[t.sourceIndex];if(!r||r.type!=="card")return[...e];const s=[...e];return s.splice(t.sourceIndex,1),s.splice(n.index,0,yi(r)),s}if(n.type==="stack"){const r=E1(t,e);return r?$1(r,t,n,e)??[...e]:[...e]}return[...e]}function x1(t,e){const n=t.hitTarget;switch(n.type){case"stack-child-reorder":return T1(t,e,n.position);case"stack-child-extract":return C1(t,e,n.toIndex);case"stack-child-noop":return I1(t,e);default:return[...e]}}function T1(t,e,n){const r=e.findIndex(y=>y.type==="stack"&&y.id===t.parentStackId);if(r===-1)return[...e];const s=e[r];if(!s||s.type!=="stack")return[...e];if(!s.children.every(y=>y.type==="card"))return[...e];const i=s.children,o=i.findIndex(y=>y.id===t.nodeId);if(o===-1)return[...e];const a=i[o],l=i.filter(y=>y.id!==t.nodeId),c=yi(a),d=n==="above"?[c,...l]:[...l,c],f=[...e];return f[r]={...s,children:d},f}function C1(t,e,n){if(!t.parentStackId)return[...e];const r=v1(e,t.parentStackId,t.nodeId,n);if(r===e)return[...e];const s=r.findIndex(a=>a.type==="card"&&a.id===t.nodeId);if(s===-1)return[...e];const i=r[s];if(!i||i.type!=="card")return[...e];const o=[...r];return o[s]=yi(i),o}function I1(t,e){const n=e.findIndex(l=>l.type==="stack"&&l.id===t.parentStackId);if(n===-1)return[...e];const r=e[n];if(!r||r.type!=="stack")return[...e];const s=r.children.findIndex(l=>l.type==="card"&&l.id===t.nodeId);if(s===-1)return[...e];const i=r.children[s];if(!i||i.type!=="card")return[...e];const o=[...e],a=[...r.children];return a[s]=yi(i),o[n]={...r,children:a},o}function P1(t,e){return e.find(r=>r.type==="stack"&&r.id===t.id)?t.id:kc()}function R1(t,e,n){if(t.type==="drop-target"){const r=Fc(e,n);if(!r)throw new Error(`finalize: missing dragged card ${n}`);return Zl(r)}return t}function D1(t,e,n){const r=t.children.map(i=>R1(i,e,n));return{id:P1(t,e),type:"stack",children:r}}function O1(t,e,n){if(t.type==="drop-target"){const r=Fc(e,n);if(!r)throw new Error(`finalize: missing dragged card ${n}`);return Fm(e,n)!==null?r:jl(r)}return t.type==="card"||t.type==="row"?t:D1(t,e,n)}function z1(t,e,n){return t.map(r=>O1(r,e,n))}function L1(t,e){return JSON.stringify(t)===JSON.stringify(e)}const M1=Gr(kt);class N1 extends M1{constructor(n={}){super();v(this,"pending",null);v(this,"active",null)}start(n){if(this.pending||this.active)return;const r=n.pointer.x??0,s=n.pointer.y??0;this.pending={startX:r,startY:s,grabOffsetX:n.grabOffset.x??0,grabOffsetY:n.grabOffset.y??0,nodeId:n.nodeId,sourceIndex:n.source.index,parentStackId:n.source.parentId,width:n.size.x??0,height:n.size.y??0,baseLayout:n.layout}}update(n){const r=n.pointer.x??0,s=n.pointer.y??0,i=this.pending;if(i){const c=r-i.startX,d=s-i.startY;Math.hypot(c,d)>=vE&&(this.pending=null,this.active={...i,pointerX:r,pointerY:s,hitTarget:{type:"reorder",index:i.sourceIndex},lastReorderIndex:i.sourceIndex},this.emitDrag(),this.dispatchEvent(new te("change")));return}if(!this.active)return;const o=qa(this.active,this.active.baseLayout),a=this.getHitTargetForPointer(r,s,n,o),l=a.type==="reorder"?a.index:this.active.lastReorderIndex;this.active.pointerX===r&&this.active.pointerY===s&&_1(this.active.hitTarget,a)&&this.active.lastReorderIndex===l||(this.active={...this.active,pointerX:r,pointerY:s,hitTarget:a,lastReorderIndex:l},this.emitDrag(),this.dispatchEvent(new te("change")))}drop(){if(this.pending){this.cancel();return}if(!this.active)return;const n=this.active.baseLayout;let r=null;try{const s=qa(this.active,n),i=z1(s,n,this.active.nodeId);L1(i,n)||(r=i)}catch{r=null}this.reset(),r&&this.dispatchEvent(new b1("drop",{layout:r})),this.dispatchEvent(new te("change"))}cancel(){!this.pending&&!this.active||(this.reset(),this.dispatchEvent(new te("change")))}dispose(){this.reset()}get status(){return this.active?"active":this.pending?"pending":"idle"}reset(){this.pending=null,this.active=null}emitDrag(){if(!this.active)return;const n=qa(this.active,this.active.baseLayout);this.dispatchEvent(new y1("drag",{nodeId:this.active.nodeId,source:{index:this.active.sourceIndex,parentId:this.active.parentStackId},grabOffset:Se({x:this.active.grabOffsetX,y:this.active.grabOffsetY}),pointer:Se({x:this.active.pointerX,y:this.active.pointerY}),size:Se({x:this.active.width,y:this.active.height}),projectedLayout:n}))}getHitTargetForPointer(n,r,s,i){return this.active?this.isPointerInsideDragBounds(n,r,s.viewport)?this.active.parentStackId?this.getStackChildHitTarget(n,r,s,i):this.getTopLevelCardHitTarget(n,r,s,i):{type:"reorder",index:this.active.sourceIndex}:{type:"reorder",index:0}}getStackChildHitTarget(n,r,s,i){var c;if(!((c=this.active)!=null&&c.parentStackId))return{type:"stack-child-noop"};const o=this.getSourceStackInteractionRect(s.geometry);if(o&&bn(n,r,o)){const d=o.top+o.height/2;return{type:"stack-child-reorder",position:r<d?"above":"below"}}const a=this.getSourceRemainingSiblingRect(s.geometry);if(a&&bn(n,r,a)){const d=a.top+a.height/2;return{type:"stack-child-reorder",position:r<d?"above":"below"}}return{type:"stack-child-extract",toIndex:this.getTopLevelReorderIndexForPointer(n,r,s,i)}}getSourceRemainingSiblingRect(n){var i,o;if(!((i=this.active)!=null&&i.parentStackId))return;const r=Ld(this.active.baseLayout,this.active.parentStackId);if(!r)return;const s=r.children.find(a=>{var l;return a.type==="card"&&a.id!==((l=this.active)==null?void 0:l.nodeId)});if(s)return(o=n.find(a=>a.id===s.id))==null?void 0:o.rect}getSourceStackInteractionRect(n){var o;if(!((o=this.active)!=null&&o.parentStackId))return;const r=n.find(a=>{var l;return a.id===((l=this.active)==null?void 0:l.parentStackId)});if(r)return this.active.sourceStackRect=r.rect,r.rect;const s=Ld(this.active.baseLayout,this.active.parentStackId);if(!s)return this.active.sourceStackRect;const i=s.children.find(a=>{var l;return a.type==="card"&&a.id!==((l=this.active)==null?void 0:l.nodeId)});if(i){const a=n.find(l=>l.id===i.id);if(a)return a.rect}return this.active.sourceStackRect}getTopLevelCardHitTarget(n,r,s,i){var m,E,k;const o=this.getTopLevelZoneNodes(s.geometry,i);if(o.length===0)return{type:"reorder",index:((m=this.active)==null?void 0:m.sourceIndex)??0};const l=(s.effectiveVelocity??0)<=w1;for(const I of o){const V=I.rect;if(!bn(n,r,V))continue;const N=this.resolveTopLevelTargetForCard(n,r,I,I.logicalIndex,l);if(N)return N;if(!l&&((E=this.active)!=null&&E.hitTarget))return this.active.hitTarget}const c=this.getNearestTargetableZone(n,o);if(!c)return{type:"reorder",index:((k=this.active)==null?void 0:k.sourceIndex)??0};const d=Math.max(c.rect.left,Math.min(c.rect.left+c.rect.width,n)),f=this.resolveTopLevelTargetForCard(d,r,c,c.logicalIndex,l);if(f)return f;const y=c.rect.left+c.rect.width/2;return{type:"reorder",index:n<y?c.logicalIndex:c.logicalIndex+1}}getTopLevelReorderIndexForPointer(n,r,s,i){var c,d;const o=this.getTopLevelZoneNodes(s.geometry,i);if(o.length===0)return((c=this.active)==null?void 0:c.sourceIndex)??0;for(const f of o){if(!bn(n,r,f.rect))continue;const y=Ha(f.rect,Ga["reorder-before"]);if(bn(n,r,y))return f.logicalIndex;const m=Ha(f.rect,Ga["reorder-after"]);if(bn(n,r,m))return f.logicalIndex+1}const a=this.getNearestTargetableZone(n,o);if(!a)return((d=this.active)==null?void 0:d.sourceIndex)??0;const l=a.rect.left+a.rect.width/2;return n<l?a.logicalIndex:a.logicalIndex+1}getTopLevelZoneNodes(n,r){const s=new Map(r.map(a=>[a.id,a])),i=[];let o=0;for(const a of n){const l=s.get(a.id);l&&l.type!=="drop-target"&&(l.type==="card"||l.type==="stack")&&(i.push({id:l.id,rect:a.rect,logicalIndex:o}),o+=1)}return i}resolveTopLevelTargetForCard(n,r,s,i,o){const a=s.rect;for(const l of m1){if(!o&&(l==="stack-above"||l==="stack-below"))continue;const c=Ga[l],d=Ha(a,c);if(bn(n,r,d))return l==="stack-above"?{type:"stack",targetCardId:s.id,position:"above"}:l==="stack-below"?{type:"stack",targetCardId:s.id,position:"below"}:l==="reorder-before"?{type:"reorder",index:i}:{type:"reorder",index:i+1}}return null}getNearestTargetableZone(n,r){let s=null,i=Number.POSITIVE_INFINITY;for(const o of r){const a=o.rect.left,l=o.rect.left+o.rect.width,c=n<a?a-n:n>l?n-l:0;c<i&&(i=c,s=o)}return s}isPointerInsideDragBounds(n,r,s){return n>=s.left&&n<=s.left+s.width&&r>=s.top&&r<=s.top+s.height}}const Md=60,U1=80,Nd=.5,Ud=10;class F1{constructor(){v(this,"awaitingFreshWheelGesture",!1);v(this,"lastWheelEventAt",Number.NEGATIVE_INFINITY);v(this,"lastWheelDeltaX",0);v(this,"activeGestureType","none");v(this,"lastWheelGestureAt",Number.NEGATIVE_INFINITY)}markKeyboardNavigation(e){this.awaitingFreshWheelGesture=!0,this.lastWheelEventAt=e,this.activeGestureType="none"}reset(){this.awaitingFreshWheelGesture=!1,this.lastWheelEventAt=Number.NEGATIVE_INFINITY,this.lastWheelDeltaX=0,this.activeGestureType="none",this.lastWheelGestureAt=Number.NEGATIVE_INFINITY}decide(e){const{now:n,shiftKey:r,deltaX:s,deltaY:i,overArtifactContent:o}=e;n-this.lastWheelGestureAt>=Md&&(this.activeGestureType="none");const l=r&&i!==0,c=l?i:s,d=Math.abs(c),f=Math.abs(i);return this.activeGestureType==="vertical-artifact"&&o?d>=Nd&&d>=f*Ud?this.classifyHorizontal(n,c):(this.lastWheelGestureAt=n,{type:"scroll-native"}):this.activeGestureType==="horizontal-filmstrip"?!l&&o&&f>0&&f>=d*Ud?(this.activeGestureType="vertical-artifact",this.lastWheelGestureAt=n,{type:"scroll-native"}):this.classifyHorizontal(n,c):d<Nd?(o&&(this.activeGestureType="vertical-artifact"),this.lastWheelGestureAt=n,{type:"scroll-native"}):l||d>f?this.classifyHorizontal(n,c):f>d?(o&&(this.activeGestureType="vertical-artifact"),this.lastWheelGestureAt=n,{type:"scroll-native"}):o?(this.activeGestureType="vertical-artifact",this.lastWheelGestureAt=n,{type:"scroll-native"}):this.classifyHorizontal(n,c)}classifyHorizontal(e,n){const r=e-this.lastWheelEventAt,s=Math.sign(this.lastWheelDeltaX),i=Math.sign(n),o=s!==0&&i!==0&&s!==i,a=s!==0&&Math.abs(n)>=Math.abs(this.lastWheelDeltaX)+U1;return this.awaitingFreshWheelGesture&&r<Md&&!o&&!a?{type:"ignore"}:(this.lastWheelEventAt=e,this.lastWheelDeltaX=n,this.lastWheelGestureAt=e,this.awaitingFreshWheelGesture=!1,this.activeGestureType="horizontal-filmstrip",{type:"scroll-horizontal",horizontalDelta:n})}}const Z1=2,Fd=1e3,ji=1e-4;function Zd(t,e,n){if(t===0)return 0;const r=e.toPixels(Te({y:Ke})).y??0;return(n-r)/Z1}class j1 extends Event{constructor(n){super("scroll",{bubbles:!0,composed:!0});v(this,"scrollPosition");this.scrollPosition=n}}class Zm extends Event{constructor(n){super("layout-change",{bubbles:!0,composed:!0});v(this,"layout");this.layout=n}}class W1 extends HTMLElement{constructor(){super();v(this,"_layout",[]);v(this,"_scrollPosition",0);v(this,"layoutGrid",null);v(this,"layoutScroll",new g1(Te({x:0})));v(this,"scrollModelKey","");v(this,"resizeObserver",null);v(this,"renderPending",!1);v(this,"animateNextRender",!0);v(this,"wheelGesture",new F1);v(this,"dragController",new N1);v(this,"dragState",null);v(this,"activeDragPointerId",null);v(this,"dragListenersAttached",!1);v(this,"dragFrame",0);v(this,"lastDragFrameTime",0);v(this,"lastPointerX",0);v(this,"lastPointerY",0);v(this,"pointerVelocityPxPerSec",0);v(this,"scrollVelocityPxPerSec",0);v(this,"motionSampleTime",0);v(this,"motionSampleX",0);v(this,"motionSampleY",0);v(this,"dragTrackOffsetXPx",0);v(this,"previousProjectedLayoutForOffset",null);v(this,"renderContent",()=>M``);v(this,"onDragControllerChange",()=>{this.dragController.status==="idle"&&(this.dragState=null,this.dragTrackOffsetXPx=0,this.previousProjectedLayoutForOffset=null),this.scheduleRender()});v(this,"onDragControllerDrag",n=>{const r=zd(n.projectedLayout),s=this.shouldApplyTrackOffset(n.projectedLayout,n.source.parentId),i=n.source.parentId?this.getStackChildAnchorCardId(n.source.parentId,n.nodeId):null;this.dragTrackOffsetXPx=s?this.computeDragTrackOffset(this.previousProjectedLayoutForOffset,r,n.nodeId,n.source.parentId,i,this.dragTrackOffsetXPx):0,this.previousProjectedLayoutForOffset=r,this.dragState={nodeId:n.nodeId,source:n.source,grabOffset:n.grabOffset,pointer:n.pointer,size:n.size,projectedLayout:n.projectedLayout},this.scheduleRender()});v(this,"onDragControllerDrop",n=>{this.dragState=null,this.dragTrackOffsetXPx=0,this.previousProjectedLayoutForOffset=null,this.commitLayout(n.layout)});v(this,"onLayoutScrollInternal",n=>{const s=n.scroll.x??0;Math.abs(s-this._scrollPosition)<ji||(this._scrollPosition=s,this.emitScrollPositionChanged(s),this.scheduleRender())});v(this,"handleKeyDown",n=>{if(n.key==="Escape"&&this.dragController.status!=="idle"){n.preventDefault(),this.stopDragFrameLoop(),this.releaseActiveDragPointerCapture(),this.dragController.cancel(),this.detachDragListeners();return}this.dragController.status==="idle"&&(n.key==="ArrowRight"?(n.preventDefault(),this.wheelGesture.markKeyboardNavigation(Date.now()),this.shiftWindow(1)):n.key==="ArrowLeft"&&(n.preventDefault(),this.wheelGesture.markKeyboardNavigation(Date.now()),this.shiftWindow(-1)))});v(this,"handleWheel",n=>{if(this._layout.length===0)return;const r=this.wheelGesture.decide({now:Date.now(),shiftKey:n.shiftKey,deltaX:n.deltaX,deltaY:n.deltaY,overArtifactContent:!1});r.type==="scroll-horizontal"&&(n.preventDefault(),this.applyHorizontalWheel(r.horizontalDelta))});v(this,"handleWindowMessage",n=>{var o;if(this._layout.length===0)return;const r=this.findManagedArtifactFrame(n.source);if(!r||!this.isTrustedArtifactFrameMessage(n,r)||!TT(n.data))return;const s=this.wheelGesture.decide({now:Date.now(),shiftKey:n.data.shiftKey,deltaX:n.data.deltaX,deltaY:n.data.deltaY,overArtifactContent:!0});if(s.type==="scroll-horizontal"){this.applyHorizontalWheel(s.horizontalDelta);return}if(s.type!=="scroll-native")return;const i={type:"scroll",deltaX:0,deltaY:n.data.deltaY};(o=r.contentWindow)==null||o.postMessage(i,this.getArtifactFrameTargetOrigin(r))});v(this,"handlePointerDown",n=>{if(n.button!==0||this.dragController.status!=="idle")return;const r=n.target;if(!(r instanceof Element)||!r.closest("[drag-handle]")||r.closest("button, input, textarea, select, a, [role='button']"))return;const s=r.closest(".card-slot");if(!s)return;const i=s.getAttribute("data-layout-node-id");if(!i)return;const o=V1(this._layout,i);if(!o)return;const a=s.getBoundingClientRect();this.lastPointerX=n.clientX,this.lastPointerY=n.clientY,this.resetMotionTracking(n.clientX,n.clientY),this.focus(),this.dragController.start({nodeId:i,source:{index:o.topLevelIndex,parentId:o.sourceStackId},pointer:Se({x:n.clientX,y:n.clientY}),grabOffset:Se({x:n.clientX-a.left,y:n.clientY-a.top}),size:Se({x:a.width,y:a.height}),layout:this._layout}),this.attachDragListeners(),this.activeDragPointerId=n.pointerId;try{this.setPointerCapture(n.pointerId)}catch{}n.preventDefault()});v(this,"handleWindowPointerMove",n=>{this.lastPointerX=n.clientX,this.lastPointerY=n.clientY,this.updatePointerVelocity(n.clientX,n.clientY),this.syncDragTargetForLatestPointer(),this.ensureDragFrameLoop()});v(this,"handleWindowPointerUp",n=>{this.stopDragFrameLoop(),this.releasePointerCaptureForEvent(n.pointerId),this.dragController.drop(),this.clearMotionTracking(),this.detachDragListeners()});v(this,"handleWindowPointerCancel",n=>{this.stopDragFrameLoop(),this.releasePointerCaptureForEvent(n.pointerId),this.dragController.cancel(),this.clearMotionTracking(),this.detachDragListeners()});v(this,"handleWindowBlur",()=>{this.releaseActiveDragPointerCapture(),this.stopDragFrameLoop(),this.dragController.cancel(),this.clearMotionTracking(),this.detachDragListeners()});v(this,"runDragFrame",n=>{if(this.dragController.status==="idle"){this.dragFrame=0;return}const r=Math.max(0,n-this.lastDragFrameTime)/Fd;this.lastDragFrameTime=n,this.samplePointerVelocityAt(n,this.lastPointerX,this.lastPointerY);const s=this.getBoundingClientRect(),i=this.clampPointerToViewport(this.lastPointerX,this.lastPointerY,s),o=this.getDragEdgeScrollDeltaPixels(i.x,s,r);this.scrollVelocityPxPerSec=r>ji?Math.abs(o)/r:0,Math.abs(o)>ji&&(this.animateNextRender=!1,this.layoutScroll.wheelPixels(Se({x:o}))),this.dragController.status==="active"&&this.syncDragTarget(i.x,i.y,s),this.dragFrame=requestAnimationFrame(this.runDragFrame)});this.dragController.addEventListener("change",this.onDragControllerChange),this.dragController.addEventListener("drag",this.onDragControllerDrag),this.dragController.addEventListener("drop",this.onDragControllerDrop),this.layoutScroll.addEventListener("layout-scroll",this.onLayoutScrollInternal)}set layout(n){this._layout=[...n],this.stopDragFrameLoop(),this.dragController.cancel(),this.scrollModelKey="",this.syncScrollModel(),this.layoutScroll.scroll=Te({x:this._scrollPosition}),this.scheduleRender()}get layout(){return this._layout}commitLayout(n){this.layout=n,this.emitLayoutChanged()}set scrollPosition(n){Math.abs(n-this._scrollPosition)<ji||(this.animateNextRender=!1,this.syncScrollModel(),this.layoutScroll.scroll=Te({x:n}))}get scrollPosition(){return this._scrollPosition}connectedCallback(){this.hasAttribute("tabindex")||(this.tabIndex=0),this.focus(),this.addEventListener("keydown",this.handleKeyDown),this.addEventListener("wheel",this.handleWheel,{passive:!1}),this.addEventListener("pointerdown",this.handlePointerDown),window.addEventListener("message",this.handleWindowMessage),typeof ResizeObserver<"u"&&(this.resizeObserver=new ResizeObserver(()=>this.render()),this.resizeObserver.observe(this)),this.render()}disconnectedCallback(){var n;this.removeEventListener("keydown",this.handleKeyDown),this.removeEventListener("wheel",this.handleWheel),this.removeEventListener("pointerdown",this.handlePointerDown),window.removeEventListener("message",this.handleWindowMessage),(n=this.resizeObserver)==null||n.disconnect(),this.resizeObserver=null,this.wheelGesture.reset(),this.detachDragListeners(),this.dragController.removeEventListener("change",this.onDragControllerChange),this.dragController.removeEventListener("drag",this.onDragControllerDrag),this.dragController.removeEventListener("drop",this.onDragControllerDrop),this.layoutScroll.removeEventListener("layout-scroll",this.onLayoutScrollInternal),this.dragController.dispose(),this.stopDragFrameLoop()}scheduleRender(){this.renderPending||(this.renderPending=!0,queueMicrotask(()=>{this.renderPending=!1,this.render()}))}createGrid(n,r){return new s1({basis:Se({x:kn,y:kn}),min:Se({x:Jh,y:Jh}),viewport:Se({x:n,y:r}),gap:Se({x:de,y:de})})}syncScrollModel(){const n=this.clientWidth>0?this.clientWidth:nn,r=this.clientHeight>0?this.clientHeight:mr,i=Es(this._layout).nodes.map(a=>a.width),o=`${n}x${r}:${i.join(",")}`;o===this.scrollModelKey&&this.layoutGrid||(this.scrollModelKey=o,this.layoutGrid=this.createGrid(n,r),this.layoutScroll.rebuild({grid:this.layoutGrid,nodeWidths:i.map(a=>Te({x:a}))}))}emitScrollPositionChanged(n){this.dispatchEvent(new j1(n))}emitLayoutChanged(){this.dispatchEvent(new Zm([...this._layout]))}shiftWindow(n){this.syncScrollModel(),this.animateNextRender=!0,this.layoutScroll.step(n)}applyHorizontalWheel(n){this.syncScrollModel();const r=this.layoutGrid;if(!r)return;this.animateNextRender=!1;const s=r.toUnits(Se({x:n}));this.layoutScroll.wheel(Te({x:s.x??0}))}findManagedArtifactFrame(n){if(!n)return null;const r=this.querySelectorAll("iframe.artifact-frame");for(const s of r)if(s.contentWindow===n)return s;return null}isTrustedArtifactFrameMessage(n,r){if(n.origin==="null")return!0;const s=this.getArtifactFrameOrigin(r);return s===null||n.origin===s}getArtifactFrameTargetOrigin(n){const r=n.getAttribute("sandbox")??"";return new Set(r.split(/\s+/).filter(Boolean)).has("allow-same-origin")?this.getArtifactFrameOrigin(n)??"*":"*"}getArtifactFrameOrigin(n){const r=n.getAttribute("src")??n.src;if(!r)return null;try{return new URL(r,window.location.href).origin}catch{return null}}releaseActiveDragPointerCapture(){this.activeDragPointerId!==null&&this.releasePointerCaptureForEvent(this.activeDragPointerId)}releasePointerCaptureForEvent(n){try{this.hasPointerCapture(n)&&this.releasePointerCapture(n)}catch{}}attachDragListeners(){this.dragListenersAttached||(window.addEventListener("pointermove",this.handleWindowPointerMove),window.addEventListener("pointerup",this.handleWindowPointerUp),window.addEventListener("pointercancel",this.handleWindowPointerCancel),this.addEventListener("pointermove",this.handleWindowPointerMove),this.addEventListener("pointerup",this.handleWindowPointerUp),this.addEventListener("pointercancel",this.handleWindowPointerCancel),window.addEventListener("blur",this.handleWindowBlur),this.dragListenersAttached=!0)}detachDragListeners(){this.dragListenersAttached&&(window.removeEventListener("pointermove",this.handleWindowPointerMove),window.removeEventListener("pointerup",this.handleWindowPointerUp),window.removeEventListener("pointercancel",this.handleWindowPointerCancel),this.removeEventListener("pointermove",this.handleWindowPointerMove),this.removeEventListener("pointerup",this.handleWindowPointerUp),this.removeEventListener("pointercancel",this.handleWindowPointerCancel),window.removeEventListener("blur",this.handleWindowBlur),this.dragListenersAttached=!1,this.activeDragPointerId=null)}getDisplayModel(){if(this.dragController.status!=="active"||!this.dragState)return{layout:this._layout,activePlaceholderId:null,placeholdersById:new Map};const n=new Map;return n.set(this.dragState.nodeId,{id:this.dragState.nodeId,sourceCardId:this.dragState.nodeId}),{layout:zd(this.dragState.projectedLayout),activePlaceholderId:this.dragState.nodeId,placeholdersById:n}}render(){const n=this.clientWidth>0?this.clientWidth:nn,r=this.clientHeight>0?this.clientHeight:mr,s=this.createGrid(n,r);this.layoutGrid=s;const i=this.getDisplayModel(),o=i.layout,a=this.dragController.status==="active",l=Es(o),c=l.nodes.map(L=>L.width),d=`${n}x${r}:${c.join(",")}`;!a&&d!==this.scrollModelKey&&(this.scrollModelKey=d,this.layoutScroll.rebuild({grid:s,nodeWidths:c.map(L=>Te({x:L}))}),this._scrollPosition=this.layoutScroll.scroll.x??this._scrollPosition);const f=B1(o),y=s.unit.x??kn,m=s.unit.y??kn,E=a?this.dragTrackOffsetXPx:0,k=(this.layoutScroll.translate.x??0)+E,I=Zd(l.nodes.length,s,r),V=this.animateNextRender&&!a,N=[`transform: translate(${k}px, ${I}px);`,`transition-duration: ${V?mE:0}ms;`,`pointer-events: ${a?"none":"auto"};`].join(" ");this.animateNextRender=!0,this.style.setProperty("--layout-unit-x",`${y}px`),this.style.setProperty("--layout-unit-y",`${m}px`),this.style.setProperty("--layout-gap",`${de}px`);const j=this.dragState,F={width:(j==null?void 0:j.size.x)??0,height:(j==null?void 0:j.size.y)??0};be(M`
|
|
146
|
-
<div class="track" style=${N}>
|
|
147
|
-
${l.nodes.map((L,J)=>M`
|
|
148
|
-
<div
|
|
149
|
-
class="node"
|
|
150
|
-
layout-node=${String(J)}
|
|
151
|
-
data-layout-node-id=${L.id}
|
|
152
|
-
data-layout-placeholder=${String(i.activePlaceholderId===L.id)}
|
|
153
|
-
layout-node-cols=${String(L.width)}
|
|
154
|
-
style=${`grid-template-columns: repeat(${L.width}, var(--layout-unit-x)); width: ${s.toPixels(Te({x:L.width})).x}px;`}
|
|
155
|
-
>
|
|
156
|
-
${L.cards.map(H=>{const he=i.placeholdersById.get(H.id);if(j&&he)return M`
|
|
157
|
-
<div
|
|
158
|
-
class="card-slot card-placeholder"
|
|
159
|
-
data-layout-placeholder-for=${j.nodeId}
|
|
160
|
-
data-layout-placeholder-ghost="false"
|
|
161
|
-
data-layout-source-stack=${j.source.parentId??""}
|
|
162
|
-
style=${`grid-column: ${H.col} / span ${H.width}; grid-row: ${H.row} / span ${H.height};`}
|
|
163
|
-
></div>
|
|
164
|
-
`;const ct=f.get(H.id);return ct?M`
|
|
165
|
-
<div
|
|
166
|
-
class="card-slot"
|
|
167
|
-
data-layout-card-id=${H.artifactID}
|
|
168
|
-
data-layout-node-id=${H.id}
|
|
169
|
-
layout-cols=${String(H.width)}
|
|
170
|
-
layout-rows=${String(H.height)}
|
|
171
|
-
style=${`grid-column: ${H.col} / span ${H.width}; grid-row: ${H.row} / span ${H.height};`}
|
|
172
|
-
>
|
|
173
|
-
${this.renderContent(ct)}
|
|
174
|
-
</div>
|
|
175
|
-
`:null})}
|
|
176
|
-
</div>
|
|
177
|
-
`)}
|
|
178
|
-
</div>
|
|
179
|
-
${j?(()=>{const L=this.getPlaceholderPixelSize(l,i.activePlaceholderId,s,F),J=j.pointer.x??0,H=j.pointer.y??0,he=j.grabOffset.x??0,ct=j.grabOffset.y??0;return M`
|
|
180
|
-
<div
|
|
181
|
-
class="drag-preview"
|
|
182
|
-
data-layout-preview-card-id=${j.nodeId}
|
|
183
|
-
style=${[`width: ${L.width}px;`,`height: ${L.height}px;`,`left: ${J-he}px;`,`top: ${H-ct}px;`].join(" ")}
|
|
184
|
-
>
|
|
185
|
-
${this.renderDraggedPreview(j.nodeId)}
|
|
186
|
-
</div>
|
|
187
|
-
`})():null}
|
|
188
|
-
`,this)}ensureDragFrameLoop(){this.dragFrame!==0||this.dragController.status==="idle"||(this.lastDragFrameTime=performance.now(),this.dragFrame=requestAnimationFrame(this.runDragFrame))}stopDragFrameLoop(){this.dragFrame!==0&&(cancelAnimationFrame(this.dragFrame),this.dragFrame=0,this.scrollVelocityPxPerSec=0)}syncDragTargetForLatestPointer(){if(this.dragController.status==="idle")return;const n=this.getBoundingClientRect();if(this.dragController.status==="active"){const s=this.clampPointerToViewport(this.lastPointerX,this.lastPointerY,n);this.syncDragTarget(s.x,s.y,n);return}if(this.syncDragTarget(this.lastPointerX,this.lastPointerY,n),this.dragController.status==="pending")return;const r=this.clampPointerToViewport(this.lastPointerX,this.lastPointerY,n);(r.x!==this.lastPointerX||r.y!==this.lastPointerY)&&this.syncDragTarget(r.x,r.y,n)}syncDragTarget(n,r,s=this.getBoundingClientRect()){if(this.dragController.status==="idle")return;const i=this.getDisplayModel(),o=new Set(i.placeholdersById.keys()),a=this.dragController.status==="active"?this.dragTrackOffsetXPx:0,l=this.measureLayoutGeometry(i.layout,o,a);this.dragController.update({pointer:Se({x:n,y:r}),viewport:{left:s.left,top:s.top,width:s.width,height:s.height},geometry:l,effectiveVelocity:Math.max(this.pointerVelocityPxPerSec,this.scrollVelocityPxPerSec)})}resetMotionTracking(n,r){this.pointerVelocityPxPerSec=0,this.scrollVelocityPxPerSec=0,this.motionSampleTime=performance.now(),this.motionSampleX=n,this.motionSampleY=r}clearMotionTracking(){this.pointerVelocityPxPerSec=0,this.scrollVelocityPxPerSec=0,this.motionSampleTime=0}updatePointerVelocity(n,r){this.samplePointerVelocityAt(performance.now(),n,r)}samplePointerVelocityAt(n,r,s){if(this.motionSampleTime===0){this.motionSampleTime=n,this.motionSampleX=r,this.motionSampleY=s,this.pointerVelocityPxPerSec=0;return}const i=n-this.motionSampleTime;if(i<100)return;const o=r-this.motionSampleX;this.pointerVelocityPxPerSec=Math.abs(o)/i*Fd,this.motionSampleTime=n,this.motionSampleX=r,this.motionSampleY=s}clampPointerToViewport(n,r,s){return{x:Math.max(s.left,Math.min(s.left+s.width,n)),y:Math.max(s.top,Math.min(s.top+s.height,r))}}isPointerOutsideViewport(n,r,s){return n<s.left||n>s.left+s.width||r<s.top||r>s.top+s.height}getDragEdgeScrollDeltaPixels(n,r,s){var c;const i=r.left+Li,o=r.left+r.width-Li,a=((c=this.layoutGrid)==null?void 0:c.unit.x)??kn,l=yE*a;if(n<i){const d=Math.max(0,Math.min(1,(i-n)/Li));return-(l*d**Xh)*s}if(n>o){const d=Math.max(0,Math.min(1,(n-o)/Li));return l*d**Xh*s}return 0}measureLayoutGeometry(n,r,s=0){const i=this.layoutGrid;if(!i)return[];const o=Es(n),a=new Map(o.nodes.map(E=>[E.id,E.width])),l=i.toPixels(Te({y:Ke})).y??mr,c=this.clientHeight>0?this.clientHeight:mr,d=(this.layoutScroll.translate.x??0)+s,f=Zd(o.nodes.length,i,c),y=[];let m=d;for(const E of n){const k=a.get(E.id)??St,I=i.toPixels(Te({x:k})).x??nn,V={left:m,top:f,width:I,height:l};y.push({id:E.id,rect:V}),m+=I+de}return y}getPlaceholderPixelSize(n,r,s,i){if(!r)return i;for(const o of n.nodes)for(const a of o.cards)if(a.id===r)return{width:s.toPixels(Te({x:a.width})).x??i.width,height:s.toPixels(Te({y:a.height})).y??i.height};return i}renderDraggedPreview(n){const r=Fc(this._layout,n);return r?this.renderContent(r):M``}shouldApplyTrackOffset(n,r){if(r)return!0;for(const s of n){if(s.type!=="stack")continue;if(s.children.some(o=>o.type==="drop-target")&&r!==s.id)return!0}return!1}computeDragTrackOffset(n,r,s,i,o,a){if(!n)return a;const l=i?o??this.getStableAnchorCardId(n,r,s):this.getStableAnchorNodeId(n,r,s);if(!l)return a;const c=i?Wd(n,l,this.layoutGrid):Bd(n,l,this.layoutGrid),d=i?Wd(r,l,this.layoutGrid):Bd(r,l,this.layoutGrid);return c===null||d===null?a:a+(c-d)}getStableAnchorCardId(n,r,s){const i=jd(n),o=new Set(jd(r));for(const a of i)if(a!==s&&o.has(a))return a;return null}getStableAnchorNodeId(n,r,s){const i=new Set(r.map(o=>o.id));for(const o of n)if(o.id!==s&&i.has(o.id))return o.id;return null}getStackChildAnchorCardId(n,r){const s=this._layout.find(o=>o.type==="stack"&&o.id===n);if(!s||s.type!=="stack")return null;const i=s.children.find(o=>o.type==="card"&&o.id!==r);return(i==null?void 0:i.id)??null}}function B1(t){const e=new Map;for(const n of t){if(n.type==="card"){e.set(n.id,n);continue}for(const r of n.children)if(r.type==="card")e.set(r.id,r);else for(const s of r.children)e.set(s.id,s)}return e}function V1(t,e){const n=t.findIndex(r=>r.type==="card"&&r.id===e);if(n!==-1)return{topLevelIndex:n};for(let r=0;r<t.length;r+=1){const s=t[r];if(!(!s||s.type!=="stack")&&s.children.some(i=>i.type==="card"&&i.id===e))return{topLevelIndex:r,sourceStackId:s.id}}return null}function jd(t){const e=[];for(const n of t){if(n.type==="card"){e.push(n.id);continue}if(n.type==="stack"){const r=n.children.find(s=>s.type==="card");r&&e.push(r.id)}}return e}function Wd(t,e,n){if(!n)return null;const r=Es(t),s=new Map(r.nodes.map(o=>[o.id,o.width]));let i=0;for(const o of t){if(o.type==="card"&&o.id===e||o.type==="stack"&&o.children.some(c=>c.type==="card"&&c.id===e))return i;const a=s.get(o.id)??St,l=n.toPixels(Te({x:a})).x??nn;i+=l+de}return null}function Bd(t,e,n){if(!n)return null;const r=Es(t),s=new Map(r.nodes.map(o=>[o.id,o.width]));let i=0;for(const o of t){if(o.id===e)return i;const a=s.get(o.id)??St,l=n.toPixels(Te({x:a})).x??nn;i+=l+de}return null}customElements.get("layout-view")||customElements.define("layout-view",W1);class G1 extends HTMLElement{constructor(){super(...arguments);v(this,"screenManager",Ye.resolve("ScreenManager"));v(this,"boundModel",null);v(this,"handleActiveScreenChanged",()=>{this.rebindModel(),this.render()});v(this,"handleModelChange",()=>{this.render()});v(this,"handleCloseArtifact",n=>{n instanceof zm&&this.screenManager.activeScreen&&this.screenManager.activeScreen.removeArtifact(n.artifactID)});v(this,"handleScrollPositionChanged",n=>{const r=n;typeof r.scrollPosition=="number"&&Number.isFinite(r.scrollPosition)&&this.screenManager.activeScreen&&this.screenManager.activeScreen.setScrollPosition(r.scrollPosition)});v(this,"handleLayoutChanged",n=>{n instanceof Zm&&this.screenManager.activeScreen&&this.screenManager.activeScreen.setLayout(n.layout)})}connectedCallback(){this.screenManager.addEventListener("active-screen-changed",this.handleActiveScreenChanged),this.rebindModel(),this.render()}disconnectedCallback(){this.screenManager.removeEventListener("active-screen-changed",this.handleActiveScreenChanged),this.unbindModel()}rebindModel(){const n=this.screenManager.activeScreen;this.boundModel!==n&&(this.unbindModel(),this.boundModel=n,n&&n.addEventListener("change",this.handleModelChange))}unbindModel(){this.boundModel&&(this.boundModel.removeEventListener("change",this.handleModelChange),this.boundModel=null)}buildArtifactMap(){const n=this.screenManager.activeScreen;return n?new Map(n.artifacts):new Map}render(){const n=this.screenManager.activeScreen,r=(n==null?void 0:n.layout)??[],s=this.buildArtifactMap();if(r.length===0){be(M`<p data-testid="empty-screen">No artifacts yet.</p>`,this);return}be(M`
|
|
189
|
-
<layout-view
|
|
190
|
-
.layout=${r}
|
|
191
|
-
.renderContent=${o=>{const a=s.get(o.artifactID);return!a||!n?M``:M`<artifact-view
|
|
192
|
-
.artifact=${a}
|
|
193
|
-
.screen=${n}
|
|
194
|
-
.viewURL=${n.server.getViewURL(a)}
|
|
195
|
-
.contentURL=${n.server.getContentURL(a.id)}
|
|
196
|
-
></artifact-view>`}}
|
|
197
|
-
.scrollPosition=${(n==null?void 0:n.scrollPosition)??0}
|
|
198
|
-
@scroll=${this.handleScrollPositionChanged}
|
|
199
|
-
@layout-change=${this.handleLayoutChanged}
|
|
200
|
-
@close-artifact=${this.handleCloseArtifact}
|
|
201
|
-
></layout-view>
|
|
202
|
-
`,this)}}customElements.define("screen-view",G1);const Ya=Be();class H1 extends HTMLElement{constructor(){super(...arguments);v(this,"screenManager",Ye.resolve("ScreenManager"));v(this,"serverManager",Ye.resolve("ServerManager"));v(this,"handleChange",()=>{this.render()})}connectedCallback(){this.render(),this.screenManager.addEventListener("active-screen-changed",this.handleChange),this.serverManager.addEventListener("change",this.handleChange),this.serverManager.addEventListener("screens-changed",this.handleChange)}disconnectedCallback(){this.screenManager.removeEventListener("active-screen-changed",this.handleChange),this.serverManager.removeEventListener("change",this.handleChange),this.serverManager.removeEventListener("screens-changed",this.handleChange)}handleSelect(n){const r=n.value;for(const[s,i]of this.serverManager.servers)if(i.screens.has(r)){this.screenManager.setActive(s,r);return}}closeDropdown(){var n;(n=this.querySelector("dropdown-menu"))==null||n.close()}handleEditScreen(){this.screenManager.activeScreen&&(this.closeDropdown(),this.dispatchEvent(new Ya("edit-screen",{bubbles:!0,composed:!0})))}handleCreateScreen(n){this.closeDropdown(),this.dispatchEvent(new Ya("create-screen",{serverURL:n,bubbles:!0,composed:!0}))}handleDeleteScreen(){this.screenManager.activeScreen&&(this.closeDropdown(),this.dispatchEvent(new Ya("delete-screen",{bubbles:!0,composed:!0})))}render(){const n=this.screenManager.activeScreen,r=(n==null?void 0:n.name)??"No screens",s=(n==null?void 0:n.id)??null,i=[...this.serverManager.servers.values()].map(o=>({url:o.url,name:o.name,sortedScreens:[...o.screens.values()].sort((a,l)=>a.name.localeCompare(l.name,void 0,{sensitivity:"base"}))}));be(M`
|
|
203
|
-
<dropdown-menu
|
|
204
|
-
title=${r}
|
|
205
|
-
@select=${o=>this.handleSelect(o)}
|
|
206
|
-
>
|
|
207
|
-
<button
|
|
208
|
-
slot="trigger"
|
|
209
|
-
trigger
|
|
210
|
-
type="button"
|
|
211
|
-
aria-label="Choose screen"
|
|
212
|
-
></button>
|
|
213
|
-
${i.map(o=>M`
|
|
214
|
-
<dropdown-group>
|
|
215
|
-
<dropdown-label>${o.name}</dropdown-label>
|
|
216
|
-
${o.sortedScreens.map(a=>this.renderScreenItem(a,s,(n==null?void 0:n.name)??null))}
|
|
217
|
-
<dropdown-item
|
|
218
|
-
action
|
|
219
|
-
@click=${()=>this.handleCreateScreen(o.url)}
|
|
220
|
-
>
|
|
221
|
-
+ New screen
|
|
222
|
-
</dropdown-item>
|
|
223
|
-
</dropdown-group>
|
|
224
|
-
`)}
|
|
225
|
-
${n?M`
|
|
226
|
-
<dropdown-divider></dropdown-divider>
|
|
227
|
-
<dropdown-group>
|
|
228
|
-
<dropdown-item
|
|
229
|
-
action
|
|
230
|
-
@click=${()=>this.handleEditScreen()}
|
|
231
|
-
>
|
|
232
|
-
Edit screen...
|
|
233
|
-
</dropdown-item>
|
|
234
|
-
<dropdown-item
|
|
235
|
-
action
|
|
236
|
-
danger
|
|
237
|
-
@click=${()=>this.handleDeleteScreen()}
|
|
238
|
-
>
|
|
239
|
-
Delete screen...
|
|
240
|
-
</dropdown-item>
|
|
241
|
-
</dropdown-group>
|
|
242
|
-
`:null}
|
|
243
|
-
</dropdown-menu>
|
|
244
|
-
`,this)}renderScreenItem(n,r,s){const i=n.id===r,o=i?s??n.name:n.name;return M`
|
|
245
|
-
<dropdown-item value=${n.id} ?selected=${i}>
|
|
246
|
-
${o}
|
|
247
|
-
</dropdown-item>
|
|
248
|
-
`}}customElements.define("screen-picker",H1);const Vd=new WeakMap,Gd=new WeakSet,jm=new WeakMap,Wm=new WeakMap,Wi=new WeakSet,Bm=t=>t;function Vm(t,e){return t===Boolean?e===null?!1:e!=="false":e===null?null:t===Number?Number(e):t===Object?JSON.parse(e):e}function q1(t,e){return e==null?null:t===Boolean?e?"":"false":t===Object?JSON.stringify(e):String(e)}function Y1(t){const e=new Map;if(!t)return e;if(Array.isArray(t)){for(const n of t)e.set(n,{attribute:!1});return e}for(const[n,r]of Object.entries(t))e.set(n,{type:r.type,attribute:r.attribute??!1});return e}function Ps(t){let e=Vd.get(t);return e||(e={constructing:!0,syncingFromAttribute:null,syncingToAttribute:null,values:new Map},Vd.set(t,e)),e}function Zc(t){return Wm.get(t)??new Map}function Gm(t,e){var n;return((n=jm.get(t))==null?void 0:n.has(e))??!1}function Rs(t){return typeof t.attribute=="string"?t.attribute:null}function K1(t,e){for(const[n,r]of Zc(t))if(Rs(r)===e)return{prop:n,config:r};return null}function io(t){if(Gd.has(t))return;const e=Y1(t.observedProperties);Wm.set(t,e);const n=new Set;jm.set(t,n);for(const[r,s]of e){if(Rs(s)&&!s.type)throw new Error(`Observed property "${r}" requires a "type" when "attribute" is set.`);const o=Object.getOwnPropertyDescriptor(t.prototype,r);if(o!=null&&o.get||o!=null&&o.set)throw new Error(`Observed property "${r}" cannot define a custom getter/setter. Use propertyChangedCallback for side effects instead.`);o||(n.add(r),Object.defineProperty(t.prototype,r,{enumerable:!0,configurable:!0,get(){return Ps(this).values.get(r)},set(a){const l=Ps(this),c=l.values.get(r);if(Object.is(c,a))return;l.values.set(r,a);const d=Rs(s);if(d&&l.syncingFromAttribute!==d&&l.syncingToAttribute!==d){const f=q1(s.type,a);l.syncingToAttribute=d;try{const y=this;f===null?y.removeAttribute(d):y.setAttribute(d,f)}finally{l.syncingToAttribute=null}}(!l.constructing||l.syncingFromAttribute!==null||c!==void 0)&&this.propertyChangedCallback(r,c,a)}}))}Gd.add(t)}function J1(t,e){io(e);const n=Ps(t),r=Bm(t),s=Zc(e);for(const[i,o]of s){if(!Gm(e,i))continue;const a=Object.prototype.hasOwnProperty.call(t,i),l=a?r[i]:void 0;a&&delete r[i];const c=Rs(o);if(c&&t.hasAttribute(c)){const d=Vm(o.type,t.getAttribute(c));n.syncingFromAttribute=c;try{r[i]=d}finally{n.syncingFromAttribute=null}continue}a&&(r[i]=l)}n.constructing=!1}class Ds extends globalThis.HTMLElement{static get observedAttributes(){const e=this;return io(e),X1(e),[...Zc(e).values()].map(n=>Rs(n)).filter(n=>!!n)}constructor(){super();const e=this.constructor;io(e),Ps(this),queueMicrotask(()=>J1(this,e))}attributeChangedCallback(e,n,r){const s=this.constructor;io(s);const i=K1(s,e);if(!i||!Gm(s,i.prop))return;const o=Ps(this);if(o.syncingToAttribute===e)return;const a=Bm(this);Object.prototype.hasOwnProperty.call(this,i.prop)&&delete a[i.prop],o.syncingFromAttribute=e;try{a[i.prop]=Vm(i.config.type,r)}finally{o.syncingFromAttribute=null}}propertyChangedCallback(e,n,r){}}v(Ds,"observedProperties");function X1(t){if(Wi.has(t))return;const e=Object.getOwnPropertyDescriptor(t.prototype,"attributeChangedCallback");if(!e||typeof e.value!="function"){Wi.add(t);return}const n=e.value;if(n===Ds.prototype.attributeChangedCallback){Wi.add(t);return}Object.defineProperty(t.prototype,"attributeChangedCallback",{configurable:!0,writable:!0,value(r,s,i){Ds.prototype.attributeChangedCallback.call(this,r,s,i),n.call(this,r,s,i)}}),Wi.add(t)}/*! @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:Hm,setPrototypeOf:Hd,isFrozen:Q1,getPrototypeOf:eD,getOwnPropertyDescriptor:tD}=Object;let{freeze:Le,seal:et,create:oo}=Object,{apply:Wl,construct:Bl}=typeof Reflect<"u"&&Reflect;Le||(Le=function(e){return e});et||(et=function(e){return e});Wl||(Wl=function(e,n){for(var r=arguments.length,s=new Array(r>2?r-2:0),i=2;i<r;i++)s[i-2]=arguments[i];return e.apply(n,s)});Bl||(Bl=function(e){for(var n=arguments.length,r=new Array(n>1?n-1:0),s=1;s<n;s++)r[s-1]=arguments[s];return new e(...r)});const Bi=Me(Array.prototype.forEach),nD=Me(Array.prototype.lastIndexOf),qd=Me(Array.prototype.pop),os=Me(Array.prototype.push),rD=Me(Array.prototype.splice),ao=Me(String.prototype.toLowerCase),Ka=Me(String.prototype.toString),Ja=Me(String.prototype.match),as=Me(String.prototype.replace),sD=Me(String.prototype.indexOf),iD=Me(String.prototype.trim),He=Me(Object.prototype.hasOwnProperty),Re=Me(RegExp.prototype.test),ls=oD(TypeError);function Me(t){return function(e){e instanceof RegExp&&(e.lastIndex=0);for(var n=arguments.length,r=new Array(n>1?n-1:0),s=1;s<n;s++)r[s-1]=arguments[s];return Wl(t,e,r)}}function oD(t){return function(){for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];return Bl(t,n)}}function W(t,e){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:ao;Hd&&Hd(t,null);let r=e.length;for(;r--;){let s=e[r];if(typeof s=="string"){const i=n(s);i!==s&&(Q1(e)||(e[r]=i),s=i)}t[s]=!0}return t}function aD(t){for(let e=0;e<t.length;e++)He(t,e)||(t[e]=null);return t}function gt(t){const e=oo(null);for(const[n,r]of Hm(t))He(t,n)&&(Array.isArray(r)?e[n]=aD(r):r&&typeof r=="object"&&r.constructor===Object?e[n]=gt(r):e[n]=r);return e}function cs(t,e){for(;t!==null;){const r=tD(t,e);if(r){if(r.get)return Me(r.get);if(typeof r.value=="function")return Me(r.value)}t=eD(t)}function n(){return null}return n}const Yd=Le(["a","abbr","acronym","address","area","article","aside","audio","b","bdi","bdo","big","blink","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","content","data","datalist","dd","decorator","del","details","dfn","dialog","dir","div","dl","dt","element","em","fieldset","figcaption","figure","font","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","img","input","ins","kbd","label","legend","li","main","map","mark","marquee","menu","menuitem","meter","nav","nobr","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","search","section","select","shadow","slot","small","source","spacer","span","strike","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","tr","track","tt","u","ul","var","video","wbr"]),Xa=Le(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","enterkeyhint","exportparts","filter","font","g","glyph","glyphref","hkern","image","inputmode","line","lineargradient","marker","mask","metadata","mpath","part","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),Qa=Le(["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"]),lD=Le(["animate","color-profile","cursor","discard","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignobject","hatch","hatchpath","mesh","meshgradient","meshpatch","meshrow","missing-glyph","script","set","solidcolor","unknown","use"]),el=Le(["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"]),cD=Le(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),Kd=Le(["#text"]),Jd=Le(["accept","action","align","alt","autocapitalize","autocomplete","autopictureinpicture","autoplay","background","bgcolor","border","capture","cellpadding","cellspacing","checked","cite","class","clear","color","cols","colspan","controls","controlslist","coords","crossorigin","datetime","decoding","default","dir","disabled","disablepictureinpicture","disableremoteplayback","download","draggable","enctype","enterkeyhint","exportparts","face","for","headers","height","hidden","high","href","hreflang","id","inert","inputmode","integrity","ismap","kind","label","lang","list","loading","loop","low","max","maxlength","media","method","min","minlength","multiple","muted","name","nonce","noshade","novalidate","nowrap","open","optimum","part","pattern","placeholder","playsinline","popover","popovertarget","popovertargetaction","poster","preload","pubdate","radiogroup","readonly","rel","required","rev","reversed","role","rows","rowspan","spellcheck","scope","selected","shape","size","sizes","slot","span","srclang","start","src","srcset","step","style","summary","tabindex","title","translate","type","usemap","valign","value","width","wrap","xmlns","slot"]),tl=Le(["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"]),Xd=Le(["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"]),Vi=Le(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),uD=et(/\{\{[\w\W]*|[\w\W]*\}\}/gm),hD=et(/<%[\w\W]*|[\w\W]*%>/gm),dD=et(/\$\{[\w\W]*/gm),fD=et(/^data-[\-\w.\u00B7-\uFFFF]+$/),pD=et(/^aria-[\-\w]+$/),qm=et(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),gD=et(/^(?:\w+script|data):/i),mD=et(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),Ym=et(/^html$/i),vD=et(/^[a-z][.\w]*(-[.\w]+)+$/i);var Qd=Object.freeze({__proto__:null,ARIA_ATTR:pD,ATTR_WHITESPACE:mD,CUSTOM_ELEMENT:vD,DATA_ATTR:fD,DOCTYPE_NAME:Ym,ERB_EXPR:hD,IS_ALLOWED_URI:qm,IS_SCRIPT_OR_DATA:gD,MUSTACHE_EXPR:uD,TMPLIT_EXPR:dD});const us={element:1,text:3,progressingInstruction:7,comment:8,document:9},yD=function(){return typeof window>"u"?null:window},bD=function(e,n){if(typeof e!="object"||typeof e.createPolicy!="function")return null;let r=null;const s="data-tt-policy-suffix";n&&n.hasAttribute(s)&&(r=n.getAttribute(s));const i="dompurify"+(r?"#"+r:"");try{return e.createPolicy(i,{createHTML(o){return o},createScriptURL(o){return o}})}catch{return console.warn("TrustedTypes policy "+i+" could not be created."),null}},ef=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}};function Km(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:yD();const e=O=>Km(O);if(e.version="3.3.3",e.removed=[],!t||!t.document||t.document.nodeType!==us.document||!t.Element)return e.isSupported=!1,e;let{document:n}=t;const r=n,s=r.currentScript,{DocumentFragment:i,HTMLTemplateElement:o,Node:a,Element:l,NodeFilter:c,NamedNodeMap:d=t.NamedNodeMap||t.MozNamedAttrMap,HTMLFormElement:f,DOMParser:y,trustedTypes:m}=t,E=l.prototype,k=cs(E,"cloneNode"),I=cs(E,"remove"),V=cs(E,"nextSibling"),N=cs(E,"childNodes"),j=cs(E,"parentNode");if(typeof o=="function"){const O=n.createElement("template");O.content&&O.content.ownerDocument&&(n=O.content.ownerDocument)}let F,L="";const{implementation:J,createNodeIterator:H,createDocumentFragment:he,getElementsByTagName:ct}=n,{importNode:wi}=r;let Ee=ef();e.isSupported=typeof Hm=="function"&&typeof j=="function"&&J&&J.createHTMLDocument!==void 0;const{MUSTACHE_EXPR:gn,ERB_EXPR:ut,TMPLIT_EXPR:Bt,DATA_ATTR:ta,ARIA_ATTR:_i,IS_SCRIPT_OR_DATA:bv,ATTR_WHITESPACE:Qc,CUSTOM_ELEMENT:wv}=Qd;let{IS_ALLOWED_URI:eu}=Qd,we=null;const tu=W({},[...Yd,...Xa,...Qa,...el,...Kd]);let $e=null;const nu=W({},[...Jd,...tl,...Xd,...Vi]);let fe=Object.seal(oo(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}})),Jr=null,Si=null;const Vt=Object.seal(oo(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let ru=!0,na=!0,su=!1,iu=!0,Jn=!1,ki=!0,mn=!1,ra=!1,sa=!1,Xn=!1,Ei=!1,$i=!1,ou=!0,au=!1;const _v="user-content-";let ia=!0,Xr=!1,Qn={},ht=null;const oa=W({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","style","svg","template","thead","title","video","xmp"]);let lu=null;const cu=W({},["audio","video","img","source","image","track"]);let aa=null;const uu=W({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),Ai="http://www.w3.org/1998/Math/MathML",xi="http://www.w3.org/2000/svg",Et="http://www.w3.org/1999/xhtml";let er=Et,la=!1,ca=null;const Sv=W({},[Ai,xi,Et],Ka);let Ti=W({},["mi","mo","mn","ms","mtext"]),Ci=W({},["annotation-xml"]);const kv=W({},["title","style","font","a","script"]);let Qr=null;const Ev=["application/xhtml+xml","text/html"],$v="text/html";let ve=null,tr=null;const Av=n.createElement("form"),hu=function(g){return g instanceof RegExp||g instanceof Function},ua=function(){let g=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(!(tr&&tr===g)){if((!g||typeof g!="object")&&(g={}),g=gt(g),Qr=Ev.indexOf(g.PARSER_MEDIA_TYPE)===-1?$v:g.PARSER_MEDIA_TYPE,ve=Qr==="application/xhtml+xml"?Ka:ao,we=He(g,"ALLOWED_TAGS")?W({},g.ALLOWED_TAGS,ve):tu,$e=He(g,"ALLOWED_ATTR")?W({},g.ALLOWED_ATTR,ve):nu,ca=He(g,"ALLOWED_NAMESPACES")?W({},g.ALLOWED_NAMESPACES,Ka):Sv,aa=He(g,"ADD_URI_SAFE_ATTR")?W(gt(uu),g.ADD_URI_SAFE_ATTR,ve):uu,lu=He(g,"ADD_DATA_URI_TAGS")?W(gt(cu),g.ADD_DATA_URI_TAGS,ve):cu,ht=He(g,"FORBID_CONTENTS")?W({},g.FORBID_CONTENTS,ve):oa,Jr=He(g,"FORBID_TAGS")?W({},g.FORBID_TAGS,ve):gt({}),Si=He(g,"FORBID_ATTR")?W({},g.FORBID_ATTR,ve):gt({}),Qn=He(g,"USE_PROFILES")?g.USE_PROFILES:!1,ru=g.ALLOW_ARIA_ATTR!==!1,na=g.ALLOW_DATA_ATTR!==!1,su=g.ALLOW_UNKNOWN_PROTOCOLS||!1,iu=g.ALLOW_SELF_CLOSE_IN_ATTR!==!1,Jn=g.SAFE_FOR_TEMPLATES||!1,ki=g.SAFE_FOR_XML!==!1,mn=g.WHOLE_DOCUMENT||!1,Xn=g.RETURN_DOM||!1,Ei=g.RETURN_DOM_FRAGMENT||!1,$i=g.RETURN_TRUSTED_TYPE||!1,sa=g.FORCE_BODY||!1,ou=g.SANITIZE_DOM!==!1,au=g.SANITIZE_NAMED_PROPS||!1,ia=g.KEEP_CONTENT!==!1,Xr=g.IN_PLACE||!1,eu=g.ALLOWED_URI_REGEXP||qm,er=g.NAMESPACE||Et,Ti=g.MATHML_TEXT_INTEGRATION_POINTS||Ti,Ci=g.HTML_INTEGRATION_POINTS||Ci,fe=g.CUSTOM_ELEMENT_HANDLING||{},g.CUSTOM_ELEMENT_HANDLING&&hu(g.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(fe.tagNameCheck=g.CUSTOM_ELEMENT_HANDLING.tagNameCheck),g.CUSTOM_ELEMENT_HANDLING&&hu(g.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(fe.attributeNameCheck=g.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),g.CUSTOM_ELEMENT_HANDLING&&typeof g.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements=="boolean"&&(fe.allowCustomizedBuiltInElements=g.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),Jn&&(na=!1),Ei&&(Xn=!0),Qn&&(we=W({},Kd),$e=oo(null),Qn.html===!0&&(W(we,Yd),W($e,Jd)),Qn.svg===!0&&(W(we,Xa),W($e,tl),W($e,Vi)),Qn.svgFilters===!0&&(W(we,Qa),W($e,tl),W($e,Vi)),Qn.mathMl===!0&&(W(we,el),W($e,Xd),W($e,Vi))),He(g,"ADD_TAGS")||(Vt.tagCheck=null),He(g,"ADD_ATTR")||(Vt.attributeCheck=null),g.ADD_TAGS&&(typeof g.ADD_TAGS=="function"?Vt.tagCheck=g.ADD_TAGS:(we===tu&&(we=gt(we)),W(we,g.ADD_TAGS,ve))),g.ADD_ATTR&&(typeof g.ADD_ATTR=="function"?Vt.attributeCheck=g.ADD_ATTR:($e===nu&&($e=gt($e)),W($e,g.ADD_ATTR,ve))),g.ADD_URI_SAFE_ATTR&&W(aa,g.ADD_URI_SAFE_ATTR,ve),g.FORBID_CONTENTS&&(ht===oa&&(ht=gt(ht)),W(ht,g.FORBID_CONTENTS,ve)),g.ADD_FORBID_CONTENTS&&(ht===oa&&(ht=gt(ht)),W(ht,g.ADD_FORBID_CONTENTS,ve)),ia&&(we["#text"]=!0),mn&&W(we,["html","head","body"]),we.table&&(W(we,["tbody"]),delete Jr.tbody),g.TRUSTED_TYPES_POLICY){if(typeof g.TRUSTED_TYPES_POLICY.createHTML!="function")throw ls('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof g.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw ls('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');F=g.TRUSTED_TYPES_POLICY,L=F.createHTML("")}else F===void 0&&(F=bD(m,s)),F!==null&&typeof L=="string"&&(L=F.createHTML(""));Le&&Le(g),tr=g}},du=W({},[...Xa,...Qa,...lD]),fu=W({},[...el,...cD]),xv=function(g){let T=j(g);(!T||!T.tagName)&&(T={namespaceURI:er,tagName:"template"});const P=ao(g.tagName),se=ao(T.tagName);return ca[g.namespaceURI]?g.namespaceURI===xi?T.namespaceURI===Et?P==="svg":T.namespaceURI===Ai?P==="svg"&&(se==="annotation-xml"||Ti[se]):!!du[P]:g.namespaceURI===Ai?T.namespaceURI===Et?P==="math":T.namespaceURI===xi?P==="math"&&Ci[se]:!!fu[P]:g.namespaceURI===Et?T.namespaceURI===xi&&!Ci[se]||T.namespaceURI===Ai&&!Ti[se]?!1:!fu[P]&&(kv[P]||!du[P]):!!(Qr==="application/xhtml+xml"&&ca[g.namespaceURI]):!1},dt=function(g){os(e.removed,{element:g});try{j(g).removeChild(g)}catch{I(g)}},vn=function(g,T){try{os(e.removed,{attribute:T.getAttributeNode(g),from:T})}catch{os(e.removed,{attribute:null,from:T})}if(T.removeAttribute(g),g==="is")if(Xn||Ei)try{dt(T)}catch{}else try{T.setAttribute(g,"")}catch{}},pu=function(g){let T=null,P=null;if(sa)g="<remove></remove>"+g;else{const pe=Ja(g,/^[\r\n\t ]+/);P=pe&&pe[0]}Qr==="application/xhtml+xml"&&er===Et&&(g='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+g+"</body></html>");const se=F?F.createHTML(g):g;if(er===Et)try{T=new y().parseFromString(se,Qr)}catch{}if(!T||!T.documentElement){T=J.createDocument(er,"template",null);try{T.documentElement.innerHTML=la?L:se}catch{}}const Ie=T.body||T.documentElement;return g&&P&&Ie.insertBefore(n.createTextNode(P),Ie.childNodes[0]||null),er===Et?ct.call(T,mn?"html":"body")[0]:mn?T.documentElement:Ie},gu=function(g){return H.call(g.ownerDocument||g,g,c.SHOW_ELEMENT|c.SHOW_COMMENT|c.SHOW_TEXT|c.SHOW_PROCESSING_INSTRUCTION|c.SHOW_CDATA_SECTION,null)},ha=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")},mu=function(g){return typeof a=="function"&&g instanceof a};function $t(O,g,T){Bi(O,P=>{P.call(e,g,T,tr)})}const vu=function(g){let T=null;if($t(Ee.beforeSanitizeElements,g,null),ha(g))return dt(g),!0;const P=ve(g.nodeName);if($t(Ee.uponSanitizeElement,g,{tagName:P,allowedTags:we}),ki&&g.hasChildNodes()&&!mu(g.firstElementChild)&&Re(/<[/\w!]/g,g.innerHTML)&&Re(/<[/\w!]/g,g.textContent)||g.nodeType===us.progressingInstruction||ki&&g.nodeType===us.comment&&Re(/<[/\w]/g,g.data))return dt(g),!0;if(!(Vt.tagCheck instanceof Function&&Vt.tagCheck(P))&&(!we[P]||Jr[P])){if(!Jr[P]&&bu(P)&&(fe.tagNameCheck instanceof RegExp&&Re(fe.tagNameCheck,P)||fe.tagNameCheck instanceof Function&&fe.tagNameCheck(P)))return!1;if(ia&&!ht[P]){const se=j(g)||g.parentNode,Ie=N(g)||g.childNodes;if(Ie&&se){const pe=Ie.length;for(let Ne=pe-1;Ne>=0;--Ne){const At=k(Ie[Ne],!0);At.__removalCount=(g.__removalCount||0)+1,se.insertBefore(At,V(g))}}}return dt(g),!0}return g instanceof l&&!xv(g)||(P==="noscript"||P==="noembed"||P==="noframes")&&Re(/<\/no(script|embed|frames)/i,g.innerHTML)?(dt(g),!0):(Jn&&g.nodeType===us.text&&(T=g.textContent,Bi([gn,ut,Bt],se=>{T=as(T,se," ")}),g.textContent!==T&&(os(e.removed,{element:g.cloneNode()}),g.textContent=T)),$t(Ee.afterSanitizeElements,g,null),!1)},yu=function(g,T,P){if(Si[T]||ou&&(T==="id"||T==="name")&&(P in n||P in Av))return!1;if(!(na&&!Si[T]&&Re(ta,T))){if(!(ru&&Re(_i,T))){if(!(Vt.attributeCheck instanceof Function&&Vt.attributeCheck(T,g))){if(!$e[T]||Si[T]){if(!(bu(g)&&(fe.tagNameCheck instanceof RegExp&&Re(fe.tagNameCheck,g)||fe.tagNameCheck instanceof Function&&fe.tagNameCheck(g))&&(fe.attributeNameCheck instanceof RegExp&&Re(fe.attributeNameCheck,T)||fe.attributeNameCheck instanceof Function&&fe.attributeNameCheck(T,g))||T==="is"&&fe.allowCustomizedBuiltInElements&&(fe.tagNameCheck instanceof RegExp&&Re(fe.tagNameCheck,P)||fe.tagNameCheck instanceof Function&&fe.tagNameCheck(P))))return!1}else if(!aa[T]){if(!Re(eu,as(P,Qc,""))){if(!((T==="src"||T==="xlink:href"||T==="href")&&g!=="script"&&sD(P,"data:")===0&&lu[g])){if(!(su&&!Re(bv,as(P,Qc,"")))){if(P)return!1}}}}}}}return!0},bu=function(g){return g!=="annotation-xml"&&Ja(g,wv)},wu=function(g){$t(Ee.beforeSanitizeAttributes,g,null);const{attributes:T}=g;if(!T||ha(g))return;const P={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:$e,forceKeepAttr:void 0};let se=T.length;for(;se--;){const Ie=T[se],{name:pe,namespaceURI:Ne,value:At}=Ie,nr=ve(pe),da=At;let Ae=pe==="value"?da:iD(da);if(P.attrName=nr,P.attrValue=Ae,P.keepAttr=!0,P.forceKeepAttr=void 0,$t(Ee.uponSanitizeAttribute,g,P),Ae=P.attrValue,au&&(nr==="id"||nr==="name")&&(vn(pe,g),Ae=_v+Ae),ki&&Re(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,Ae)){vn(pe,g);continue}if(nr==="attributename"&&Ja(Ae,"href")){vn(pe,g);continue}if(P.forceKeepAttr)continue;if(!P.keepAttr){vn(pe,g);continue}if(!iu&&Re(/\/>/i,Ae)){vn(pe,g);continue}Jn&&Bi([gn,ut,Bt],Su=>{Ae=as(Ae,Su," ")});const _u=ve(g.nodeName);if(!yu(_u,nr,Ae)){vn(pe,g);continue}if(F&&typeof m=="object"&&typeof m.getAttributeType=="function"&&!Ne)switch(m.getAttributeType(_u,nr)){case"TrustedHTML":{Ae=F.createHTML(Ae);break}case"TrustedScriptURL":{Ae=F.createScriptURL(Ae);break}}if(Ae!==da)try{Ne?g.setAttributeNS(Ne,pe,Ae):g.setAttribute(pe,Ae),ha(g)?dt(g):qd(e.removed)}catch{vn(pe,g)}}$t(Ee.afterSanitizeAttributes,g,null)},Tv=function O(g){let T=null;const P=gu(g);for($t(Ee.beforeSanitizeShadowDOM,g,null);T=P.nextNode();)$t(Ee.uponSanitizeShadowNode,T,null),vu(T),wu(T),T.content instanceof i&&O(T.content);$t(Ee.afterSanitizeShadowDOM,g,null)};return e.sanitize=function(O){let g=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},T=null,P=null,se=null,Ie=null;if(la=!O,la&&(O="<!-->"),typeof O!="string"&&!mu(O))if(typeof O.toString=="function"){if(O=O.toString(),typeof O!="string")throw ls("dirty is not a string, aborting")}else throw ls("toString is not a function");if(!e.isSupported)return O;if(ra||ua(g),e.removed=[],typeof O=="string"&&(Xr=!1),Xr){if(O.nodeName){const At=ve(O.nodeName);if(!we[At]||Jr[At])throw ls("root node is forbidden and cannot be sanitized in-place")}}else if(O instanceof a)T=pu("<!---->"),P=T.ownerDocument.importNode(O,!0),P.nodeType===us.element&&P.nodeName==="BODY"||P.nodeName==="HTML"?T=P:T.appendChild(P);else{if(!Xn&&!Jn&&!mn&&O.indexOf("<")===-1)return F&&$i?F.createHTML(O):O;if(T=pu(O),!T)return Xn?null:$i?L:""}T&&sa&&dt(T.firstChild);const pe=gu(Xr?O:T);for(;se=pe.nextNode();)vu(se),wu(se),se.content instanceof i&&Tv(se.content);if(Xr)return O;if(Xn){if(Ei)for(Ie=he.call(T.ownerDocument);T.firstChild;)Ie.appendChild(T.firstChild);else Ie=T;return($e.shadowroot||$e.shadowrootmode)&&(Ie=wi.call(r,Ie,!0)),Ie}let Ne=mn?T.outerHTML:T.innerHTML;return mn&&we["!doctype"]&&T.ownerDocument&&T.ownerDocument.doctype&&T.ownerDocument.doctype.name&&Re(Ym,T.ownerDocument.doctype.name)&&(Ne="<!DOCTYPE "+T.ownerDocument.doctype.name+`>
|
|
249
|
-
`+Ne),Jn&&Bi([gn,ut,Bt],At=>{Ne=as(Ne,At," ")}),F&&$i?F.createHTML(Ne):Ne},e.setConfig=function(){let O=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};ua(O),ra=!0},e.clearConfig=function(){tr=null,ra=!1},e.isValidAttribute=function(O,g,T){tr||ua({});const P=ve(O),se=ve(g);return yu(P,se,T)},e.addHook=function(O,g){typeof g=="function"&&os(Ee[O],g)},e.removeHook=function(O,g){if(g!==void 0){const T=nD(Ee[O],g);return T===-1?void 0:rD(Ee[O],T,1)[0]}return qd(Ee[O])},e.removeHooks=function(O){Ee[O]=[]},e.removeAllHooks=function(){Ee=ef()},e}var Jm=Km();function jc(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var Kn=jc();function Xm(t){Kn=t}var $n={exec:()=>null};function q(t,e=""){let n=typeof t=="string"?t:t.source,r={replace:(s,i)=>{let o=typeof i=="string"?i:i.source;return o=o.replace(ze.caret,"$1"),n=n.replace(s,o),r},getRegex:()=>new RegExp(n,e)};return r}var wD=(()=>{try{return!!new RegExp("(?<=1)(?<!1)")}catch{return!1}})(),ze={codeRemoveIndent:/^(?: {1,4}| {0,3}\t)/gm,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,multipleSpaceGlobal:/\s+/g,blankLine:/^[ \t]*$/,doubleBlankLine:/\n[ \t]*\n[ \t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] +\S/,listReplaceTask:/^\[[ xX]\] +/,listTaskCheckbox:/\[[ xX]\]/,anyLine:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\||\| *$/g,tableRowBlankLine:/\n[ \t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^<a /i,endATag:/^<\/a>/i,startPreScriptTag:/^<(pre|code|kbd|script)(\s|>)/i,endPreScriptTag:/^<\/(pre|code|kbd|script)(\s|>)/i,startAngleBracket:/^</,endAngleBracket:/>$/,pedanticHrefTitle:/^([^'"]*[^\s])\s+(['"])(.*)\2/,unicodeAlphaNumeric:/[\p{L}\p{N}]/u,escapeTest:/[&<>"']/,escapeReplace:/[&<>"']/g,escapeTestNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeReplaceNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:t=>new RegExp(`^( {0,3}${t})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),hrRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),fencesBeginRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}(?:\`\`\`|~~~)`),headingBeginRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}#`),htmlBeginRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}<(?:[a-z].*>|!--)`,"i"),blockquoteBeginRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}>`)},_D=/^(?:[ \t]*(?:\n|$))+/,SD=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,kD=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,bi=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,ED=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,Wc=/ {0,3}(?:[*+-]|\d{1,9}[.)])/,Qm=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,ev=q(Qm).replace(/bull/g,Wc).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(),$D=q(Qm).replace(/bull/g,Wc).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(),Bc=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,AD=/^[^\n]+/,Vc=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,xD=q(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",Vc).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),TD=q(/^(bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,Wc).getRegex(),Xo="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",Gc=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,CD=q("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))","i").replace("comment",Gc).replace("tag",Xo).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),tv=q(Bc).replace("hr",bi).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("|table","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",Xo).getRegex(),ID=q(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",tv).getRegex(),Hc={blockquote:ID,code:SD,def:xD,fences:kD,heading:ED,hr:bi,html:CD,lheading:ev,list:TD,newline:_D,paragraph:tv,table:$n,text:AD},tf=q("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",bi).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("blockquote"," {0,3}>").replace("code","(?: {4}| {0,3} )[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",Xo).getRegex(),PD={...Hc,lheading:$D,table:tf,paragraph:q(Bc).replace("hr",bi).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",tf).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",Xo).getRegex()},RD={...Hc,html:q(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",Gc).replace(/tag/g,"(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:$n,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:q(Bc).replace("hr",bi).replace("heading",` *#{1,6} *[^
|
|
250
|
-
]`).replace("lheading",ev).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},DD=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,OD=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,nv=/^( {2,}|\\)\n(?!\s*$)/,zD=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,Kr=/[\p{P}\p{S}]/u,Qo=/[\s\p{P}\p{S}]/u,qc=/[^\s\p{P}\p{S}]/u,LD=q(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,Qo).getRegex(),rv=/(?!~)[\p{P}\p{S}]/u,MD=/(?!~)[\s\p{P}\p{S}]/u,ND=/(?:[^\s\p{P}\p{S}]|~)/u,UD=q(/link|precode-code|html/,"g").replace("link",/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-",wD?"(?<!`)()":"(^^|[^`])").replace("code",/(?<b>`+)[^`]+\k<b>(?!`)/).replace("html",/<(?! )[^<>]*?>/).getRegex(),sv=/^(?:\*+(?:((?!\*)punct)|([^\s*]))?)|^_+(?:((?!_)punct)|([^\s_]))?/,FD=q(sv,"u").replace(/punct/g,Kr).getRegex(),ZD=q(sv,"u").replace(/punct/g,rv).getRegex(),iv="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",jD=q(iv,"gu").replace(/notPunctSpace/g,qc).replace(/punctSpace/g,Qo).replace(/punct/g,Kr).getRegex(),WD=q(iv,"gu").replace(/notPunctSpace/g,ND).replace(/punctSpace/g,MD).replace(/punct/g,rv).getRegex(),BD=q("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,qc).replace(/punctSpace/g,Qo).replace(/punct/g,Kr).getRegex(),VD=q(/^~~?(?:((?!~)punct)|[^\s~])/,"u").replace(/punct/g,Kr).getRegex(),GD="^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)",HD=q(GD,"gu").replace(/notPunctSpace/g,qc).replace(/punctSpace/g,Qo).replace(/punct/g,Kr).getRegex(),qD=q(/\\(punct)/,"gu").replace(/punct/g,Kr).getRegex(),YD=q(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace("scheme",/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace("email",/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(),KD=q(Gc).replace("(?:-->|$)","-->").getRegex(),JD=q("^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>").replace("comment",KD).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),ko=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\])|[^\[\]\\`])*?/,XD=q(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?\s*\)/).replace("label",ko).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),ov=q(/^!?\[(label)\]\[(ref)\]/).replace("label",ko).replace("ref",Vc).getRegex(),av=q(/^!?\[(ref)\](?:\[\])?/).replace("ref",Vc).getRegex(),QD=q("reflink|nolink(?!\\()","g").replace("reflink",ov).replace("nolink",av).getRegex(),nf=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,Yc={_backpedal:$n,anyPunctuation:qD,autolink:YD,blockSkip:UD,br:nv,code:OD,del:$n,delLDelim:$n,delRDelim:$n,emStrongLDelim:FD,emStrongRDelimAst:jD,emStrongRDelimUnd:BD,escape:DD,link:XD,nolink:av,punctuation:LD,reflink:ov,reflinkSearch:QD,tag:JD,text:zD,url:$n},eO={...Yc,link:q(/^!?\[(label)\]\((.*?)\)/).replace("label",ko).getRegex(),reflink:q(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",ko).getRegex()},Vl={...Yc,emStrongRDelimAst:WD,emStrongLDelim:ZD,delLDelim:VD,delRDelim:HD,url:q(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol",nf).replace("email",/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])((?:\\[\s\S]|[^\\])*?(?:\\[\s\S]|[^\s~\\]))\1(?=[^~]|$)/,text:q(/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace("protocol",nf).getRegex()},tO={...Vl,br:q(nv).replace("{2,}","*").getRegex(),text:q(Vl.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},Gi={normal:Hc,gfm:PD,pedantic:RD},hs={normal:Yc,gfm:Vl,breaks:tO,pedantic:eO},nO={"&":"&","<":"<",">":">",'"':""","'":"'"},rf=t=>nO[t];function mt(t,e){if(e){if(ze.escapeTest.test(t))return t.replace(ze.escapeReplace,rf)}else if(ze.escapeTestNoEncode.test(t))return t.replace(ze.escapeReplaceNoEncode,rf);return t}function sf(t){try{t=encodeURI(t).replace(ze.percentDecode,"%")}catch{return null}return t}function of(t,e){var i;let n=t.replace(ze.findPipe,(o,a,l)=>{let c=!1,d=a;for(;--d>=0&&l[d]==="\\";)c=!c;return c?"|":" |"}),r=n.split(ze.splitPipe),s=0;if(r[0].trim()||r.shift(),r.length>0&&!((i=r.at(-1))!=null&&i.trim())&&r.pop(),e)if(r.length>e)r.splice(e);else for(;r.length<e;)r.push("");for(;s<r.length;s++)r[s]=r[s].trim().replace(ze.slashPipe,"|");return r}function ds(t,e,n){let r=t.length;if(r===0)return"";let s=0;for(;s<r&&t.charAt(r-s-1)===e;)s++;return t.slice(0,r-s)}function rO(t,e){if(t.indexOf(e[1])===-1)return-1;let n=0;for(let r=0;r<t.length;r++)if(t[r]==="\\")r++;else if(t[r]===e[0])n++;else if(t[r]===e[1]&&(n--,n<0))return r;return n>0?-2:-1}function sO(t,e=0){let n=e,r="";for(let s of t)if(s===" "){let i=4-n%4;r+=" ".repeat(i),n+=i}else r+=s,n++;return r}function af(t,e,n,r,s){let i=e.href,o=e.title||null,a=t[1].replace(s.other.outputLinkReplace,"$1");r.state.inLink=!0;let l={type:t[0].charAt(0)==="!"?"image":"link",raw:n,href:i,title:o,text:a,tokens:r.inlineTokens(a)};return r.state.inLink=!1,l}function iO(t,e,n){let r=t.match(n.other.indentCodeCompensation);if(r===null)return e;let s=r[1];return e.split(`
|
|
251
|
-
`).map(i=>{let o=i.match(n.other.beginningSpace);if(o===null)return i;let[a]=o;return a.length>=s.length?i.slice(s.length):i}).join(`
|
|
252
|
-
`)}var Eo=class{constructor(t){v(this,"options");v(this,"rules");v(this,"lexer");this.options=t||Kn}space(t){let e=this.rules.block.newline.exec(t);if(e&&e[0].length>0)return{type:"space",raw:e[0]}}code(t){let e=this.rules.block.code.exec(t);if(e){let n=e[0].replace(this.rules.other.codeRemoveIndent,"");return{type:"code",raw:e[0],codeBlockStyle:"indented",text:this.options.pedantic?n:ds(n,`
|
|
253
|
-
`)}}}fences(t){let e=this.rules.block.fences.exec(t);if(e){let n=e[0],r=iO(n,e[3]||"",this.rules);return{type:"code",raw:n,lang:e[2]?e[2].trim().replace(this.rules.inline.anyPunctuation,"$1"):e[2],text:r}}}heading(t){let e=this.rules.block.heading.exec(t);if(e){let n=e[2].trim();if(this.rules.other.endingHash.test(n)){let r=ds(n,"#");(this.options.pedantic||!r||this.rules.other.endingSpaceChar.test(r))&&(n=r.trim())}return{type:"heading",raw:e[0],depth:e[1].length,text:n,tokens:this.lexer.inline(n)}}}hr(t){let e=this.rules.block.hr.exec(t);if(e)return{type:"hr",raw:ds(e[0],`
|
|
254
|
-
`)}}blockquote(t){let e=this.rules.block.blockquote.exec(t);if(e){let n=ds(e[0],`
|
|
255
|
-
`).split(`
|
|
256
|
-
`),r="",s="",i=[];for(;n.length>0;){let o=!1,a=[],l;for(l=0;l<n.length;l++)if(this.rules.other.blockquoteStart.test(n[l]))a.push(n[l]),o=!0;else if(!o)a.push(n[l]);else break;n=n.slice(l);let c=a.join(`
|
|
257
|
-
`),d=c.replace(this.rules.other.blockquoteSetextReplace,`
|
|
258
|
-
$1`).replace(this.rules.other.blockquoteSetextReplace2,"");r=r?`${r}
|
|
259
|
-
${c}`:c,s=s?`${s}
|
|
260
|
-
${d}`:d;let f=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(d,i,!0),this.lexer.state.top=f,n.length===0)break;let y=i.at(-1);if((y==null?void 0:y.type)==="code")break;if((y==null?void 0:y.type)==="blockquote"){let m=y,E=m.raw+`
|
|
261
|
-
`+n.join(`
|
|
262
|
-
`),k=this.blockquote(E);i[i.length-1]=k,r=r.substring(0,r.length-m.raw.length)+k.raw,s=s.substring(0,s.length-m.text.length)+k.text;break}else if((y==null?void 0:y.type)==="list"){let m=y,E=m.raw+`
|
|
263
|
-
`+n.join(`
|
|
264
|
-
`),k=this.list(E);i[i.length-1]=k,r=r.substring(0,r.length-y.raw.length)+k.raw,s=s.substring(0,s.length-m.raw.length)+k.raw,n=E.substring(i.at(-1).raw.length).split(`
|
|
265
|
-
`);continue}}return{type:"blockquote",raw:r,tokens:i,text:s}}}list(t){var n,r;let e=this.rules.block.list.exec(t);if(e){let s=e[1].trim(),i=s.length>1,o={type:"list",raw:"",ordered:i,start:i?+s.slice(0,-1):"",loose:!1,items:[]};s=i?`\\d{1,9}\\${s.slice(-1)}`:`\\${s}`,this.options.pedantic&&(s=i?s:"[*+-]");let a=this.rules.other.listItemRegex(s),l=!1;for(;t;){let d=!1,f="",y="";if(!(e=a.exec(t))||this.rules.block.hr.test(t))break;f=e[0],t=t.substring(f.length);let m=sO(e[2].split(`
|
|
266
|
-
`,1)[0],e[1].length),E=t.split(`
|
|
267
|
-
`,1)[0],k=!m.trim(),I=0;if(this.options.pedantic?(I=2,y=m.trimStart()):k?I=e[1].length+1:(I=m.search(this.rules.other.nonSpaceChar),I=I>4?1:I,y=m.slice(I),I+=e[1].length),k&&this.rules.other.blankLine.test(E)&&(f+=E+`
|
|
268
|
-
`,t=t.substring(E.length+1),d=!0),!d){let V=this.rules.other.nextBulletRegex(I),N=this.rules.other.hrRegex(I),j=this.rules.other.fencesBeginRegex(I),F=this.rules.other.headingBeginRegex(I),L=this.rules.other.htmlBeginRegex(I),J=this.rules.other.blockquoteBeginRegex(I);for(;t;){let H=t.split(`
|
|
269
|
-
`,1)[0],he;if(E=H,this.options.pedantic?(E=E.replace(this.rules.other.listReplaceNesting," "),he=E):he=E.replace(this.rules.other.tabCharGlobal," "),j.test(E)||F.test(E)||L.test(E)||J.test(E)||V.test(E)||N.test(E))break;if(he.search(this.rules.other.nonSpaceChar)>=I||!E.trim())y+=`
|
|
270
|
-
`+he.slice(I);else{if(k||m.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4||j.test(m)||F.test(m)||N.test(m))break;y+=`
|
|
271
|
-
`+E}k=!E.trim(),f+=H+`
|
|
272
|
-
`,t=t.substring(H.length+1),m=he.slice(I)}}o.loose||(l?o.loose=!0:this.rules.other.doubleBlankLine.test(f)&&(l=!0)),o.items.push({type:"list_item",raw:f,task:!!this.options.gfm&&this.rules.other.listIsTask.test(y),loose:!1,text:y,tokens:[]}),o.raw+=f}let c=o.items.at(-1);if(c)c.raw=c.raw.trimEnd(),c.text=c.text.trimEnd();else return;o.raw=o.raw.trimEnd();for(let d of o.items){if(this.lexer.state.top=!1,d.tokens=this.lexer.blockTokens(d.text,[]),d.task){if(d.text=d.text.replace(this.rules.other.listReplaceTask,""),((n=d.tokens[0])==null?void 0:n.type)==="text"||((r=d.tokens[0])==null?void 0:r.type)==="paragraph"){d.tokens[0].raw=d.tokens[0].raw.replace(this.rules.other.listReplaceTask,""),d.tokens[0].text=d.tokens[0].text.replace(this.rules.other.listReplaceTask,"");for(let y=this.lexer.inlineQueue.length-1;y>=0;y--)if(this.rules.other.listIsTask.test(this.lexer.inlineQueue[y].src)){this.lexer.inlineQueue[y].src=this.lexer.inlineQueue[y].src.replace(this.rules.other.listReplaceTask,"");break}}let f=this.rules.other.listTaskCheckbox.exec(d.raw);if(f){let y={type:"checkbox",raw:f[0]+" ",checked:f[0]!=="[ ]"};d.checked=y.checked,o.loose?d.tokens[0]&&["paragraph","text"].includes(d.tokens[0].type)&&"tokens"in d.tokens[0]&&d.tokens[0].tokens?(d.tokens[0].raw=y.raw+d.tokens[0].raw,d.tokens[0].text=y.raw+d.tokens[0].text,d.tokens[0].tokens.unshift(y)):d.tokens.unshift({type:"paragraph",raw:y.raw,text:y.raw,tokens:[y]}):d.tokens.unshift(y)}}if(!o.loose){let f=d.tokens.filter(m=>m.type==="space"),y=f.length>0&&f.some(m=>this.rules.other.anyLine.test(m.raw));o.loose=y}}if(o.loose)for(let d of o.items){d.loose=!0;for(let f of d.tokens)f.type==="text"&&(f.type="paragraph")}return o}}html(t){let e=this.rules.block.html.exec(t);if(e)return{type:"html",block:!0,raw:e[0],pre:e[1]==="pre"||e[1]==="script"||e[1]==="style",text:e[0]}}def(t){let e=this.rules.block.def.exec(t);if(e){let n=e[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal," "),r=e[2]?e[2].replace(this.rules.other.hrefBrackets,"$1").replace(this.rules.inline.anyPunctuation,"$1"):"",s=e[3]?e[3].substring(1,e[3].length-1).replace(this.rules.inline.anyPunctuation,"$1"):e[3];return{type:"def",tag:n,raw:e[0],href:r,title:s}}}table(t){var o;let e=this.rules.block.table.exec(t);if(!e||!this.rules.other.tableDelimiter.test(e[2]))return;let n=of(e[1]),r=e[2].replace(this.rules.other.tableAlignChars,"").split("|"),s=(o=e[3])!=null&&o.trim()?e[3].replace(this.rules.other.tableRowBlankLine,"").split(`
|
|
273
|
-
`):[],i={type:"table",raw:e[0],header:[],align:[],rows:[]};if(n.length===r.length){for(let a of r)this.rules.other.tableAlignRight.test(a)?i.align.push("right"):this.rules.other.tableAlignCenter.test(a)?i.align.push("center"):this.rules.other.tableAlignLeft.test(a)?i.align.push("left"):i.align.push(null);for(let a=0;a<n.length;a++)i.header.push({text:n[a],tokens:this.lexer.inline(n[a]),header:!0,align:i.align[a]});for(let a of s)i.rows.push(of(a,i.header.length).map((l,c)=>({text:l,tokens:this.lexer.inline(l),header:!1,align:i.align[c]})));return i}}lheading(t){let e=this.rules.block.lheading.exec(t);if(e){let n=e[1].trim();return{type:"heading",raw:e[0],depth:e[2].charAt(0)==="="?1:2,text:n,tokens:this.lexer.inline(n)}}}paragraph(t){let e=this.rules.block.paragraph.exec(t);if(e){let n=e[1].charAt(e[1].length-1)===`
|
|
274
|
-
`?e[1].slice(0,-1):e[1];return{type:"paragraph",raw:e[0],text:n,tokens:this.lexer.inline(n)}}}text(t){let e=this.rules.block.text.exec(t);if(e)return{type:"text",raw:e[0],text:e[0],tokens:this.lexer.inline(e[0])}}escape(t){let e=this.rules.inline.escape.exec(t);if(e)return{type:"escape",raw:e[0],text:e[1]}}tag(t){let e=this.rules.inline.tag.exec(t);if(e)return!this.lexer.state.inLink&&this.rules.other.startATag.test(e[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&this.rules.other.endATag.test(e[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&this.rules.other.startPreScriptTag.test(e[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&this.rules.other.endPreScriptTag.test(e[0])&&(this.lexer.state.inRawBlock=!1),{type:"html",raw:e[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:e[0]}}link(t){let e=this.rules.inline.link.exec(t);if(e){let n=e[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(n)){if(!this.rules.other.endAngleBracket.test(n))return;let i=ds(n.slice(0,-1),"\\");if((n.length-i.length)%2===0)return}else{let i=rO(e[2],"()");if(i===-2)return;if(i>-1){let o=(e[0].indexOf("!")===0?5:4)+e[1].length+i;e[2]=e[2].substring(0,i),e[0]=e[0].substring(0,o).trim(),e[3]=""}}let r=e[2],s="";if(this.options.pedantic){let i=this.rules.other.pedanticHrefTitle.exec(r);i&&(r=i[1],s=i[3])}else s=e[3]?e[3].slice(1,-1):"";return r=r.trim(),this.rules.other.startAngleBracket.test(r)&&(this.options.pedantic&&!this.rules.other.endAngleBracket.test(n)?r=r.slice(1):r=r.slice(1,-1)),af(e,{href:r&&r.replace(this.rules.inline.anyPunctuation,"$1"),title:s&&s.replace(this.rules.inline.anyPunctuation,"$1")},e[0],this.lexer,this.rules)}}reflink(t,e){let n;if((n=this.rules.inline.reflink.exec(t))||(n=this.rules.inline.nolink.exec(t))){let r=(n[2]||n[1]).replace(this.rules.other.multipleSpaceGlobal," "),s=e[r.toLowerCase()];if(!s){let i=n[0].charAt(0);return{type:"text",raw:i,text:i}}return af(n,s,n[0],this.lexer,this.rules)}}emStrong(t,e,n=""){let r=this.rules.inline.emStrongLDelim.exec(t);if(!(!r||!r[1]&&!r[2]&&!r[3]&&!r[4]||r[4]&&n.match(this.rules.other.unicodeAlphaNumeric))&&(!(r[1]||r[3])||!n||this.rules.inline.punctuation.exec(n))){let s=[...r[0]].length-1,i,o,a=s,l=0,c=r[0][0]==="*"?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(c.lastIndex=0,e=e.slice(-1*t.length+s);(r=c.exec(e))!=null;){if(i=r[1]||r[2]||r[3]||r[4]||r[5]||r[6],!i)continue;if(o=[...i].length,r[3]||r[4]){a+=o;continue}else if((r[5]||r[6])&&s%3&&!((s+o)%3)){l+=o;continue}if(a-=o,a>0)continue;o=Math.min(o,o+a+l);let d=[...r[0]][0].length,f=t.slice(0,s+r.index+d+o);if(Math.min(s,o)%2){let m=f.slice(1,-1);return{type:"em",raw:f,text:m,tokens:this.lexer.inlineTokens(m)}}let y=f.slice(2,-2);return{type:"strong",raw:f,text:y,tokens:this.lexer.inlineTokens(y)}}}}codespan(t){let e=this.rules.inline.code.exec(t);if(e){let n=e[2].replace(this.rules.other.newLineCharGlobal," "),r=this.rules.other.nonSpaceChar.test(n),s=this.rules.other.startingSpaceChar.test(n)&&this.rules.other.endingSpaceChar.test(n);return r&&s&&(n=n.substring(1,n.length-1)),{type:"codespan",raw:e[0],text:n}}}br(t){let e=this.rules.inline.br.exec(t);if(e)return{type:"br",raw:e[0]}}del(t,e,n=""){let r=this.rules.inline.delLDelim.exec(t);if(r&&(!r[1]||!n||this.rules.inline.punctuation.exec(n))){let s=[...r[0]].length-1,i,o,a=s,l=this.rules.inline.delRDelim;for(l.lastIndex=0,e=e.slice(-1*t.length+s);(r=l.exec(e))!=null;){if(i=r[1]||r[2]||r[3]||r[4]||r[5]||r[6],!i||(o=[...i].length,o!==s))continue;if(r[3]||r[4]){a+=o;continue}if(a-=o,a>0)continue;o=Math.min(o,o+a);let c=[...r[0]][0].length,d=t.slice(0,s+r.index+c+o),f=d.slice(s,-s);return{type:"del",raw:d,text:f,tokens:this.lexer.inlineTokens(f)}}}}autolink(t){let e=this.rules.inline.autolink.exec(t);if(e){let n,r;return e[2]==="@"?(n=e[1],r="mailto:"+n):(n=e[1],r=n),{type:"link",raw:e[0],text:n,href:r,tokens:[{type:"text",raw:n,text:n}]}}}url(t){var n;let e;if(e=this.rules.inline.url.exec(t)){let r,s;if(e[2]==="@")r=e[0],s="mailto:"+r;else{let i;do i=e[0],e[0]=((n=this.rules.inline._backpedal.exec(e[0]))==null?void 0:n[0])??"";while(i!==e[0]);r=e[0],e[1]==="www."?s="http://"+e[0]:s=e[0]}return{type:"link",raw:e[0],text:r,href:s,tokens:[{type:"text",raw:r,text:r}]}}}inlineText(t){let e=this.rules.inline.text.exec(t);if(e){let n=this.lexer.state.inRawBlock;return{type:"text",raw:e[0],text:e[0],escaped:n}}}},at=class Gl{constructor(e){v(this,"tokens");v(this,"options");v(this,"state");v(this,"inlineQueue");v(this,"tokenizer");this.tokens=[],this.tokens.links=Object.create(null),this.options=e||Kn,this.options.tokenizer=this.options.tokenizer||new Eo,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,top:!0};let n={other:ze,block:Gi.normal,inline:hs.normal};this.options.pedantic?(n.block=Gi.pedantic,n.inline=hs.pedantic):this.options.gfm&&(n.block=Gi.gfm,this.options.breaks?n.inline=hs.breaks:n.inline=hs.gfm),this.tokenizer.rules=n}static get rules(){return{block:Gi,inline:hs}}static lex(e,n){return new Gl(n).lex(e)}static lexInline(e,n){return new Gl(n).inlineTokens(e)}lex(e){e=e.replace(ze.carriageReturn,`
|
|
275
|
-
`),this.blockTokens(e,this.tokens);for(let n=0;n<this.inlineQueue.length;n++){let r=this.inlineQueue[n];this.inlineTokens(r.src,r.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(e,n=[],r=!1){var s,i,o;for(this.tokenizer.lexer=this,this.options.pedantic&&(e=e.replace(ze.tabCharGlobal," ").replace(ze.spaceLine,""));e;){let a;if((i=(s=this.options.extensions)==null?void 0:s.block)!=null&&i.some(c=>(a=c.call({lexer:this},e,n))?(e=e.substring(a.raw.length),n.push(a),!0):!1))continue;if(a=this.tokenizer.space(e)){e=e.substring(a.raw.length);let c=n.at(-1);a.raw.length===1&&c!==void 0?c.raw+=`
|
|
276
|
-
`:n.push(a);continue}if(a=this.tokenizer.code(e)){e=e.substring(a.raw.length);let c=n.at(-1);(c==null?void 0:c.type)==="paragraph"||(c==null?void 0:c.type)==="text"?(c.raw+=(c.raw.endsWith(`
|
|
277
|
-
`)?"":`
|
|
278
|
-
`)+a.raw,c.text+=`
|
|
279
|
-
`+a.text,this.inlineQueue.at(-1).src=c.text):n.push(a);continue}if(a=this.tokenizer.fences(e)){e=e.substring(a.raw.length),n.push(a);continue}if(a=this.tokenizer.heading(e)){e=e.substring(a.raw.length),n.push(a);continue}if(a=this.tokenizer.hr(e)){e=e.substring(a.raw.length),n.push(a);continue}if(a=this.tokenizer.blockquote(e)){e=e.substring(a.raw.length),n.push(a);continue}if(a=this.tokenizer.list(e)){e=e.substring(a.raw.length),n.push(a);continue}if(a=this.tokenizer.html(e)){e=e.substring(a.raw.length),n.push(a);continue}if(a=this.tokenizer.def(e)){e=e.substring(a.raw.length);let c=n.at(-1);(c==null?void 0:c.type)==="paragraph"||(c==null?void 0:c.type)==="text"?(c.raw+=(c.raw.endsWith(`
|
|
280
|
-
`)?"":`
|
|
281
|
-
`)+a.raw,c.text+=`
|
|
282
|
-
`+a.raw,this.inlineQueue.at(-1).src=c.text):this.tokens.links[a.tag]||(this.tokens.links[a.tag]={href:a.href,title:a.title},n.push(a));continue}if(a=this.tokenizer.table(e)){e=e.substring(a.raw.length),n.push(a);continue}if(a=this.tokenizer.lheading(e)){e=e.substring(a.raw.length),n.push(a);continue}let l=e;if((o=this.options.extensions)!=null&&o.startBlock){let c=1/0,d=e.slice(1),f;this.options.extensions.startBlock.forEach(y=>{f=y.call({lexer:this},d),typeof f=="number"&&f>=0&&(c=Math.min(c,f))}),c<1/0&&c>=0&&(l=e.substring(0,c+1))}if(this.state.top&&(a=this.tokenizer.paragraph(l))){let c=n.at(-1);r&&(c==null?void 0:c.type)==="paragraph"?(c.raw+=(c.raw.endsWith(`
|
|
283
|
-
`)?"":`
|
|
284
|
-
`)+a.raw,c.text+=`
|
|
285
|
-
`+a.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=c.text):n.push(a),r=l.length!==e.length,e=e.substring(a.raw.length);continue}if(a=this.tokenizer.text(e)){e=e.substring(a.raw.length);let c=n.at(-1);(c==null?void 0:c.type)==="text"?(c.raw+=(c.raw.endsWith(`
|
|
286
|
-
`)?"":`
|
|
287
|
-
`)+a.raw,c.text+=`
|
|
288
|
-
`+a.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=c.text):n.push(a);continue}if(e){let c="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent){console.error(c);break}else throw new Error(c)}}return this.state.top=!0,n}inline(e,n=[]){return this.inlineQueue.push({src:e,tokens:n}),n}inlineTokens(e,n=[]){var l,c,d,f,y;this.tokenizer.lexer=this;let r=e,s=null;if(this.tokens.links){let m=Object.keys(this.tokens.links);if(m.length>0)for(;(s=this.tokenizer.rules.inline.reflinkSearch.exec(r))!=null;)m.includes(s[0].slice(s[0].lastIndexOf("[")+1,-1))&&(r=r.slice(0,s.index)+"["+"a".repeat(s[0].length-2)+"]"+r.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;(s=this.tokenizer.rules.inline.anyPunctuation.exec(r))!=null;)r=r.slice(0,s.index)+"++"+r.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);let i;for(;(s=this.tokenizer.rules.inline.blockSkip.exec(r))!=null;)i=s[2]?s[2].length:0,r=r.slice(0,s.index+i)+"["+"a".repeat(s[0].length-i-2)+"]"+r.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);r=((c=(l=this.options.hooks)==null?void 0:l.emStrongMask)==null?void 0:c.call({lexer:this},r))??r;let o=!1,a="";for(;e;){o||(a=""),o=!1;let m;if((f=(d=this.options.extensions)==null?void 0:d.inline)!=null&&f.some(k=>(m=k.call({lexer:this},e,n))?(e=e.substring(m.raw.length),n.push(m),!0):!1))continue;if(m=this.tokenizer.escape(e)){e=e.substring(m.raw.length),n.push(m);continue}if(m=this.tokenizer.tag(e)){e=e.substring(m.raw.length),n.push(m);continue}if(m=this.tokenizer.link(e)){e=e.substring(m.raw.length),n.push(m);continue}if(m=this.tokenizer.reflink(e,this.tokens.links)){e=e.substring(m.raw.length);let k=n.at(-1);m.type==="text"&&(k==null?void 0:k.type)==="text"?(k.raw+=m.raw,k.text+=m.text):n.push(m);continue}if(m=this.tokenizer.emStrong(e,r,a)){e=e.substring(m.raw.length),n.push(m);continue}if(m=this.tokenizer.codespan(e)){e=e.substring(m.raw.length),n.push(m);continue}if(m=this.tokenizer.br(e)){e=e.substring(m.raw.length),n.push(m);continue}if(m=this.tokenizer.del(e,r,a)){e=e.substring(m.raw.length),n.push(m);continue}if(m=this.tokenizer.autolink(e)){e=e.substring(m.raw.length),n.push(m);continue}if(!this.state.inLink&&(m=this.tokenizer.url(e))){e=e.substring(m.raw.length),n.push(m);continue}let E=e;if((y=this.options.extensions)!=null&&y.startInline){let k=1/0,I=e.slice(1),V;this.options.extensions.startInline.forEach(N=>{V=N.call({lexer:this},I),typeof V=="number"&&V>=0&&(k=Math.min(k,V))}),k<1/0&&k>=0&&(E=e.substring(0,k+1))}if(m=this.tokenizer.inlineText(E)){e=e.substring(m.raw.length),m.raw.slice(-1)!=="_"&&(a=m.raw.slice(-1)),o=!0;let k=n.at(-1);(k==null?void 0:k.type)==="text"?(k.raw+=m.raw,k.text+=m.text):n.push(m);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 n}},$o=class{constructor(t){v(this,"options");v(this,"parser");this.options=t||Kn}space(t){return""}code({text:t,lang:e,escaped:n}){var i;let r=(i=(e||"").match(ze.notSpaceStart))==null?void 0:i[0],s=t.replace(ze.endingNewline,"")+`
|
|
289
|
-
`;return r?'<pre><code class="language-'+mt(r)+'">'+(n?s:mt(s,!0))+`</code></pre>
|
|
290
|
-
`:"<pre><code>"+(n?s:mt(s,!0))+`</code></pre>
|
|
291
|
-
`}blockquote({tokens:t}){return`<blockquote>
|
|
292
|
-
${this.parser.parse(t)}</blockquote>
|
|
293
|
-
`}html({text:t}){return t}def(t){return""}heading({tokens:t,depth:e}){return`<h${e}>${this.parser.parseInline(t)}</h${e}>
|
|
294
|
-
`}hr(t){return`<hr>
|
|
295
|
-
`}list(t){let e=t.ordered,n=t.start,r="";for(let o=0;o<t.items.length;o++){let a=t.items[o];r+=this.listitem(a)}let s=e?"ol":"ul",i=e&&n!==1?' start="'+n+'"':"";return"<"+s+i+`>
|
|
296
|
-
`+r+"</"+s+`>
|
|
297
|
-
`}listitem(t){return`<li>${this.parser.parse(t.tokens)}</li>
|
|
298
|
-
`}checkbox({checked:t}){return"<input "+(t?'checked="" ':"")+'disabled="" type="checkbox"> '}paragraph({tokens:t}){return`<p>${this.parser.parseInline(t)}</p>
|
|
299
|
-
`}table(t){let e="",n="";for(let s=0;s<t.header.length;s++)n+=this.tablecell(t.header[s]);e+=this.tablerow({text:n});let r="";for(let s=0;s<t.rows.length;s++){let i=t.rows[s];n="";for(let o=0;o<i.length;o++)n+=this.tablecell(i[o]);r+=this.tablerow({text:n})}return r&&(r=`<tbody>${r}</tbody>`),`<table>
|
|
300
|
-
<thead>
|
|
301
|
-
`+e+`</thead>
|
|
302
|
-
`+r+`</table>
|
|
303
|
-
`}tablerow({text:t}){return`<tr>
|
|
304
|
-
${t}</tr>
|
|
305
|
-
`}tablecell(t){let e=this.parser.parseInline(t.tokens),n=t.header?"th":"td";return(t.align?`<${n} align="${t.align}">`:`<${n}>`)+e+`</${n}>
|
|
306
|
-
`}strong({tokens:t}){return`<strong>${this.parser.parseInline(t)}</strong>`}em({tokens:t}){return`<em>${this.parser.parseInline(t)}</em>`}codespan({text:t}){return`<code>${mt(t,!0)}</code>`}br(t){return"<br>"}del({tokens:t}){return`<del>${this.parser.parseInline(t)}</del>`}link({href:t,title:e,tokens:n}){let r=this.parser.parseInline(n),s=sf(t);if(s===null)return r;t=s;let i='<a href="'+t+'"';return e&&(i+=' title="'+mt(e)+'"'),i+=">"+r+"</a>",i}image({href:t,title:e,text:n,tokens:r}){r&&(n=this.parser.parseInline(r,this.parser.textRenderer));let s=sf(t);if(s===null)return mt(n);t=s;let i=`<img src="${t}" alt="${mt(n)}"`;return e&&(i+=` title="${mt(e)}"`),i+=">",i}text(t){return"tokens"in t&&t.tokens?this.parser.parseInline(t.tokens):"escaped"in t&&t.escaped?t.text:mt(t.text)}},Kc=class{strong({text:t}){return t}em({text:t}){return t}codespan({text:t}){return t}del({text:t}){return t}html({text:t}){return t}text({text:t}){return t}link({text:t}){return""+t}image({text:t}){return""+t}br(){return""}checkbox({raw:t}){return t}},lt=class Hl{constructor(e){v(this,"options");v(this,"renderer");v(this,"textRenderer");this.options=e||Kn,this.options.renderer=this.options.renderer||new $o,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new Kc}static parse(e,n){return new Hl(n).parse(e)}static parseInline(e,n){return new Hl(n).parseInline(e)}parse(e){var r,s;this.renderer.parser=this;let n="";for(let i=0;i<e.length;i++){let o=e[i];if((s=(r=this.options.extensions)==null?void 0:r.renderers)!=null&&s[o.type]){let l=o,c=this.options.extensions.renderers[l.type].call({parser:this},l);if(c!==!1||!["space","hr","heading","code","table","blockquote","list","html","def","paragraph","text"].includes(l.type)){n+=c||"";continue}}let a=o;switch(a.type){case"space":{n+=this.renderer.space(a);break}case"hr":{n+=this.renderer.hr(a);break}case"heading":{n+=this.renderer.heading(a);break}case"code":{n+=this.renderer.code(a);break}case"table":{n+=this.renderer.table(a);break}case"blockquote":{n+=this.renderer.blockquote(a);break}case"list":{n+=this.renderer.list(a);break}case"checkbox":{n+=this.renderer.checkbox(a);break}case"html":{n+=this.renderer.html(a);break}case"def":{n+=this.renderer.def(a);break}case"paragraph":{n+=this.renderer.paragraph(a);break}case"text":{n+=this.renderer.text(a);break}default:{let l='Token with "'+a.type+'" type was not found.';if(this.options.silent)return console.error(l),"";throw new Error(l)}}}return n}parseInline(e,n=this.renderer){var s,i;this.renderer.parser=this;let r="";for(let o=0;o<e.length;o++){let a=e[o];if((i=(s=this.options.extensions)==null?void 0:s.renderers)!=null&&i[a.type]){let c=this.options.extensions.renderers[a.type].call({parser:this},a);if(c!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(a.type)){r+=c||"";continue}}let l=a;switch(l.type){case"escape":{r+=n.text(l);break}case"html":{r+=n.html(l);break}case"link":{r+=n.link(l);break}case"image":{r+=n.image(l);break}case"checkbox":{r+=n.checkbox(l);break}case"strong":{r+=n.strong(l);break}case"em":{r+=n.em(l);break}case"codespan":{r+=n.codespan(l);break}case"br":{r+=n.br(l);break}case"del":{r+=n.del(l);break}case"text":{r+=n.text(l);break}default:{let c='Token with "'+l.type+'" type was not found.';if(this.options.silent)return console.error(c),"";throw new Error(c)}}}return r}},Hi,bs=(Hi=class{constructor(t){v(this,"options");v(this,"block");this.options=t||Kn}preprocess(t){return t}postprocess(t){return t}processAllTokens(t){return t}emStrongMask(t){return t}provideLexer(){return this.block?at.lex:at.lexInline}provideParser(){return this.block?lt.parse:lt.parseInline}},v(Hi,"passThroughHooks",new Set(["preprocess","postprocess","processAllTokens","emStrongMask"])),v(Hi,"passThroughHooksRespectAsync",new Set(["preprocess","postprocess","processAllTokens"])),Hi),oO=class{constructor(...t){v(this,"defaults",jc());v(this,"options",this.setOptions);v(this,"parse",this.parseMarkdown(!0));v(this,"parseInline",this.parseMarkdown(!1));v(this,"Parser",lt);v(this,"Renderer",$o);v(this,"TextRenderer",Kc);v(this,"Lexer",at);v(this,"Tokenizer",Eo);v(this,"Hooks",bs);this.use(...t)}walkTokens(t,e){var r,s;let n=[];for(let i of t)switch(n=n.concat(e.call(this,i)),i.type){case"table":{let o=i;for(let a of o.header)n=n.concat(this.walkTokens(a.tokens,e));for(let a of o.rows)for(let l of a)n=n.concat(this.walkTokens(l.tokens,e));break}case"list":{let o=i;n=n.concat(this.walkTokens(o.items,e));break}default:{let o=i;(s=(r=this.defaults.extensions)==null?void 0:r.childTokens)!=null&&s[o.type]?this.defaults.extensions.childTokens[o.type].forEach(a=>{let l=o[a].flat(1/0);n=n.concat(this.walkTokens(l,e))}):o.tokens&&(n=n.concat(this.walkTokens(o.tokens,e)))}}return n}use(...t){let e=this.defaults.extensions||{renderers:{},childTokens:{}};return t.forEach(n=>{let r={...n};if(r.async=this.defaults.async||r.async||!1,n.extensions&&(n.extensions.forEach(s=>{if(!s.name)throw new Error("extension name required");if("renderer"in s){let i=e.renderers[s.name];i?e.renderers[s.name]=function(...o){let a=s.renderer.apply(this,o);return a===!1&&(a=i.apply(this,o)),a}:e.renderers[s.name]=s.renderer}if("tokenizer"in s){if(!s.level||s.level!=="block"&&s.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");let i=e[s.level];i?i.unshift(s.tokenizer):e[s.level]=[s.tokenizer],s.start&&(s.level==="block"?e.startBlock?e.startBlock.push(s.start):e.startBlock=[s.start]:s.level==="inline"&&(e.startInline?e.startInline.push(s.start):e.startInline=[s.start]))}"childTokens"in s&&s.childTokens&&(e.childTokens[s.name]=s.childTokens)}),r.extensions=e),n.renderer){let s=this.defaults.renderer||new $o(this.defaults);for(let i in n.renderer){if(!(i in s))throw new Error(`renderer '${i}' does not exist`);if(["options","parser"].includes(i))continue;let o=i,a=n.renderer[o],l=s[o];s[o]=(...c)=>{let d=a.apply(s,c);return d===!1&&(d=l.apply(s,c)),d||""}}r.renderer=s}if(n.tokenizer){let s=this.defaults.tokenizer||new Eo(this.defaults);for(let i in n.tokenizer){if(!(i in s))throw new Error(`tokenizer '${i}' does not exist`);if(["options","rules","lexer"].includes(i))continue;let o=i,a=n.tokenizer[o],l=s[o];s[o]=(...c)=>{let d=a.apply(s,c);return d===!1&&(d=l.apply(s,c)),d}}r.tokenizer=s}if(n.hooks){let s=this.defaults.hooks||new bs;for(let i in n.hooks){if(!(i in s))throw new Error(`hook '${i}' does not exist`);if(["options","block"].includes(i))continue;let o=i,a=n.hooks[o],l=s[o];bs.passThroughHooks.has(i)?s[o]=c=>{if(this.defaults.async&&bs.passThroughHooksRespectAsync.has(i))return(async()=>{let f=await a.call(s,c);return l.call(s,f)})();let d=a.call(s,c);return l.call(s,d)}:s[o]=(...c)=>{if(this.defaults.async)return(async()=>{let f=await a.apply(s,c);return f===!1&&(f=await l.apply(s,c)),f})();let d=a.apply(s,c);return d===!1&&(d=l.apply(s,c)),d}}r.hooks=s}if(n.walkTokens){let s=this.defaults.walkTokens,i=n.walkTokens;r.walkTokens=function(o){let a=[];return a.push(i.call(this,o)),s&&(a=a.concat(s.call(this,o))),a}}this.defaults={...this.defaults,...r}}),this}setOptions(t){return this.defaults={...this.defaults,...t},this}lexer(t,e){return at.lex(t,e??this.defaults)}parser(t,e){return lt.parse(t,e??this.defaults)}parseMarkdown(t){return(e,n)=>{let r={...n},s={...this.defaults,...r},i=this.onError(!!s.silent,!!s.async);if(this.defaults.async===!0&&r.async===!1)return i(new Error("marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise."));if(typeof e>"u"||e===null)return i(new Error("marked(): input parameter is undefined or null"));if(typeof e!="string")return i(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(e)+", string expected"));if(s.hooks&&(s.hooks.options=s,s.hooks.block=t),s.async)return(async()=>{let o=s.hooks?await s.hooks.preprocess(e):e,a=await(s.hooks?await s.hooks.provideLexer():t?at.lex:at.lexInline)(o,s),l=s.hooks?await s.hooks.processAllTokens(a):a;s.walkTokens&&await Promise.all(this.walkTokens(l,s.walkTokens));let c=await(s.hooks?await s.hooks.provideParser():t?lt.parse:lt.parseInline)(l,s);return s.hooks?await s.hooks.postprocess(c):c})().catch(i);try{s.hooks&&(e=s.hooks.preprocess(e));let o=(s.hooks?s.hooks.provideLexer():t?at.lex:at.lexInline)(e,s);s.hooks&&(o=s.hooks.processAllTokens(o)),s.walkTokens&&this.walkTokens(o,s.walkTokens);let a=(s.hooks?s.hooks.provideParser():t?lt.parse:lt.parseInline)(o,s);return s.hooks&&(a=s.hooks.postprocess(a)),a}catch(o){return i(o)}}}onError(t,e){return n=>{if(n.message+=`
|
|
307
|
-
Please report this to https://github.com/markedjs/marked.`,t){let r="<p>An error occurred:</p><pre>"+mt(n.message+"",!0)+"</pre>";return e?Promise.resolve(r):r}if(e)return Promise.reject(n);throw n}}},Vn=new oO;function X(t,e){return Vn.parse(t,e)}X.options=X.setOptions=function(t){return Vn.setOptions(t),X.defaults=Vn.defaults,Xm(X.defaults),X};X.getDefaults=jc;X.defaults=Kn;X.use=function(...t){return Vn.use(...t),X.defaults=Vn.defaults,Xm(X.defaults),X};X.walkTokens=function(t,e){return Vn.walkTokens(t,e)};X.parseInline=Vn.parseInline;X.Parser=lt;X.parser=lt.parse;X.Renderer=$o;X.TextRenderer=Kc;X.Lexer=at;X.lexer=at.lex;X.Tokenizer=Eo;X.Hooks=bs;X.parse=X;X.options;X.setOptions;X.use;X.walkTokens;X.parseInline;lt.parse;at.lex;const aO=8;let lf=!1;function lO(){lf||(lf=!0,Jm.addHook("afterSanitizeAttributes",t=>{t.tagName==="A"&&(t.setAttribute("target","_blank"),t.setAttribute("rel","noopener noreferrer"))}))}function cO(t){lO();const e=X.parse(t,{async:!1});return Jm.sanitize(e,{USE_PROFILES:{html:!0}})}function uO(t){return t.kind==="user"||t.kind==="assistant"}function cf(t,e){for(let n=t.length-1;n>=0;n-=1){const r=t[n];if(r&&r.kind===e)return r.id}return null}var Mt,Cr,Nt,Ir,qe,ws,cv,ri,Ro,lo;class lv extends Ds{constructor(){super(...arguments);x(this,qe);v(this,"messages",[]);x(this,Mt,!0);x(this,Cr,null);x(this,Nt,null);x(this,Ir,!1);x(this,ri,()=>{const n=h(this,Nt);if(!n)return;const s=n.scrollHeight-n.clientHeight-n.scrollTop<=aO;s!==h(this,Mt)&&($(this,Mt,s),b(this,qe,ws).call(this))});x(this,Ro,()=>{$(this,Mt,!0),b(this,qe,ws).call(this),b(this,qe,lo).call(this,{force:!0})})}connectedCallback(){$(this,Ir,!0),$(this,Cr,cf(this.messages??[],"user")),b(this,qe,ws).call(this),b(this,qe,lo).call(this,{force:!0})}disconnectedCallback(){$(this,Ir,!1),$(this,Nt,null)}propertyChangedCallback(n,r,s){if(n!=="messages"||!h(this,Ir))return;const i=this.messages??[],o=cf(i,"user"),a=o!==null&&o!==h(this,Cr);$(this,Cr,o),a&&$(this,Mt,!0),b(this,qe,ws).call(this),b(this,qe,lo).call(this,{force:a})}}Mt=new WeakMap,Cr=new WeakMap,Nt=new WeakMap,Ir=new WeakMap,qe=new WeakSet,ws=function(){var i;const n=(this.messages??[]).filter(uO),r=h(this,Mt);be(M`
|
|
308
|
-
<div
|
|
309
|
-
class="chat-history-scroll"
|
|
310
|
-
role="log"
|
|
311
|
-
aria-live="polite"
|
|
312
|
-
@scroll=${h(this,ri)}
|
|
313
|
-
>
|
|
314
|
-
${n.map(o=>b(this,qe,cv).call(this,o))}
|
|
315
|
-
</div>
|
|
316
|
-
<button
|
|
317
|
-
type="button"
|
|
318
|
-
class="chat-history-jump"
|
|
319
|
-
aria-label="Jump to latest message"
|
|
320
|
-
?hidden=${r}
|
|
321
|
-
@click=${h(this,Ro)}
|
|
322
|
-
>
|
|
323
|
-
${Cl({size:14})}
|
|
324
|
-
<span>Jump to latest</span>
|
|
325
|
-
</button>
|
|
326
|
-
`,this);const s=this.querySelector(".chat-history-scroll");s&&s!==h(this,Nt)&&((i=h(this,Nt))==null||i.removeEventListener("scroll",h(this,ri)),$(this,Nt,s))},cv=function(n){const r=OR(cO(n.text));if(n.kind==="user")return M`
|
|
327
|
-
<div class="chat-message chat-message-user">
|
|
328
|
-
<div class="chat-message-body">${r}</div>
|
|
329
|
-
</div>
|
|
330
|
-
`;const s=n.status==="cancelled"?M`<span class="chat-message-badge">[cancelled]</span>`:n.status==="error"?M`<span class="chat-message-badge">[error]</span>`:null;return M`
|
|
331
|
-
<div class="chat-message chat-message-assistant">
|
|
332
|
-
<div class="chat-message-body">${r}${s}</div>
|
|
333
|
-
</div>
|
|
334
|
-
`},ri=new WeakMap,Ro=new WeakMap,lo=function(n){requestAnimationFrame(()=>{const r=h(this,Nt);r&&(!h(this,Mt)&&!n.force||(r.scrollTop=r.scrollHeight-r.clientHeight))})},v(lv,"observedProperties",{messages:{type:Object}});customElements.define("chat-history",lv);const hO=Be(),dO=Be(),fO=Be(),pO=3;class uv extends Ds{constructor(){super(...arguments);v(this,"value","");v(this,"disabled",!1);v(this,"disabledPlaceholder","");v(this,"action","send");v(this,"handleInput",n=>{const s=n.currentTarget.value??"";this.value=s,this.dispatchEvent(new hO("change",{value:s,bubbles:!0,composed:!0}))});v(this,"handleKeyDown",n=>{n.key==="Enter"&&(n.shiftKey||n.isComposing||(n.preventDefault(),!this.disabled&&this.action==="send"&&this.submitMessage()))});v(this,"handleButtonClick",()=>{this.disabled||(this.action==="send"?this.submitMessage():this.dispatchEvent(new fO("cancel",{bubbles:!0,composed:!0})))})}connectedCallback(){this.render()}propertyChangedCallback(){this.render()}get textareaEl(){return this.querySelector("textarea")}submitMessage(){var r;const n=(this.value??"").trim();n.length!==0&&(this.dispatchEvent(new dO("submit",{text:n,bubbles:!0,composed:!0})),(r=this.textareaEl)==null||r.focus())}computeRows(){const n=(this.value??"").split(/\r?\n/).length;return Math.min(pO,Math.max(1,n))}render(){const n=this.action==="send",r=n?"Send message":"Cancel",s=n?UR({size:16}):NR({size:16}),i=this.computeRows(),o=this.value??"",a=this.disabled?"":o,l=this.disabled?this.disabledPlaceholder:"";be(M`
|
|
335
|
-
<textarea
|
|
336
|
-
.value=${a}
|
|
337
|
-
placeholder=${l}
|
|
338
|
-
rows=${i}
|
|
339
|
-
?disabled=${this.disabled}
|
|
340
|
-
@input=${this.handleInput}
|
|
341
|
-
@keydown=${this.handleKeyDown}
|
|
342
|
-
></textarea>
|
|
343
|
-
<button
|
|
344
|
-
type="button"
|
|
345
|
-
aria-label=${r}
|
|
346
|
-
?disabled=${this.disabled}
|
|
347
|
-
@click=${this.handleButtonClick}
|
|
348
|
-
>
|
|
349
|
-
${s}
|
|
350
|
-
</button>
|
|
351
|
-
`,this)}}v(uv,"observedProperties",{value:{type:String},disabled:{type:Boolean},disabledPlaceholder:{type:String},action:{type:String}});customElements.define("chat-input",uv);var Un,xe,Pr,Fn,si,Pe,ql,Yl,ii,Do,Oo,zo,hv,pr;class gO extends HTMLElement{constructor(){super(...arguments);x(this,Pe);x(this,Un,Ye.resolve("ACPClientManager"));x(this,xe,null);x(this,Pr,"");x(this,Fn,!1);x(this,si,()=>{if(!h(this,Fn))return;const n=h(this,Un).getActiveClient();n!==h(this,xe)&&(b(this,Pe,Yl).call(this),b(this,Pe,ql).call(this,n)),b(this,Pe,pr).call(this)});x(this,ii,()=>{h(this,Fn)&&b(this,Pe,pr).call(this)});x(this,Do,n=>{const r=n.value;$(this,Pr,r),b(this,Pe,pr).call(this)});x(this,Oo,n=>{if(!h(this,xe))return;const r=n.text;$(this,Pr,""),b(this,Pe,pr).call(this),h(this,xe).sendMessage({text:r}).catch(s=>{console.error("ACPClient.sendMessage() failed",s)})});x(this,zo,n=>{h(this,xe)&&h(this,xe).cancel().catch(r=>{console.error("ACPClient.cancel() failed",r)})})}connectedCallback(){$(this,Fn,!0),h(this,Un).addEventListener("change",h(this,si)),b(this,Pe,ql).call(this,h(this,Un).getActiveClient()),b(this,Pe,pr).call(this)}disconnectedCallback(){$(this,Fn,!1),h(this,Un).removeEventListener("change",h(this,si)),b(this,Pe,Yl).call(this)}}Un=new WeakMap,xe=new WeakMap,Pr=new WeakMap,Fn=new WeakMap,si=new WeakMap,Pe=new WeakSet,ql=function(n){$(this,xe,n),h(this,xe)&&(h(this,xe).addEventListener("change",h(this,ii)),h(this,xe).connect().catch(r=>{console.error("ACPClient.connect() failed",r)}))},Yl=function(){h(this,xe)&&(h(this,xe).removeEventListener("change",h(this,ii)),$(this,xe,null))},ii=new WeakMap,Do=new WeakMap,Oo=new WeakMap,zo=new WeakMap,hv=function(n){return n.lifecycle.status==="connecting"?"Connecting to agent…":n.lifecycle.status==="disconnected"?n.lifecycle.error?"Agent unavailable":"Agent disconnected":n.lifecycle.status==="disposed"?"Agent unavailable":n.run.status==="cancelling"?"Cancelling…":""},pr=function(){if(!h(this,xe)){this.hidden=!0;return}const n=h(this,xe).getState();this.hidden=n.lifecycle.status!=="ready";const r=n.messageOrder.map(a=>n.messagesById[a]).filter(a=>a!==void 0),s=n.run.canCancel&&n.run.status==="running"?"cancel":"send",i=n.lifecycle.status!=="ready"||n.run.status==="cancelling",o=b(this,Pe,hv).call(this,n);be(M`
|
|
352
|
-
<chat-history .messages=${r}></chat-history>
|
|
353
|
-
<div class="chat-panel-input">
|
|
354
|
-
<chat-input
|
|
355
|
-
.value=${h(this,Pr)}
|
|
356
|
-
.action=${s}
|
|
357
|
-
.disabled=${i}
|
|
358
|
-
.disabledPlaceholder=${o}
|
|
359
|
-
@change=${h(this,Do)}
|
|
360
|
-
@submit=${h(this,Oo)}
|
|
361
|
-
@cancel=${h(this,zo)}
|
|
362
|
-
></chat-input>
|
|
363
|
-
</div>
|
|
364
|
-
`,this)};customElements.get("chat-panel")||customElements.define("chat-panel",gO);class dv extends HTMLElement{constructor(){super(...arguments);v(this,"screenManager",Ye.resolve("ScreenManager"));v(this,"serverManager",Ye.resolve("ServerManager"));v(this,"handleActiveChange",()=>{this.render()});v(this,"_mode","edit");v(this,"_targetServerURL");v(this,"createPending",!1)}get open(){return this.hasAttribute("open")}set mode(n){this._mode=n,this.render()}get mode(){return this._mode}set targetServerURL(n){this._targetServerURL=n,this.render()}get targetServerURL(){return this._targetServerURL}attributeChangedCallback(n){n==="open"&&(this.open||(this.createPending=!1),this.render())}connectedCallback(){this.render(),this.screenManager.addEventListener("active-screen-changed",this.handleActiveChange)}disconnectedCallback(){this.screenManager.removeEventListener("active-screen-changed",this.handleActiveChange)}emitClose(){this.dispatchEvent(new Event("close",{bubbles:!0}))}async handleSubmit(n){var a;n.preventDefault();const r=n.currentTarget,s=new FormData(r),i=String(s.get("name")??"").trim();if(!i)return;if(this._mode==="edit"){(a=this.screenManager.activeScreen)==null||a.rename(i),this.emitClose();return}if(!this._targetServerURL)return;const o=this.serverManager.servers.get(this._targetServerURL);if(o){this.createPending=!0,this.render();try{const l=await o.createScreen(i);this.screenManager.setActive(this._targetServerURL,l.id),this.emitClose()}catch{this.createPending=!1,this.render()}}}render(){var i;const n=this._mode==="edit"?"Edit screen":"New screen",r=this._mode==="edit"?"Save":this.createPending?"Creating...":"Create",s=this._mode==="edit"?((i=this.screenManager.activeScreen)==null?void 0:i.name)??"":"";be(M`
|
|
365
|
-
<modal-overlay ?open=${this.open}>
|
|
366
|
-
<section class="screen-modal">
|
|
367
|
-
<form class="screen-form" @submit=${o=>void this.handleSubmit(o)}>
|
|
368
|
-
<h2 class="screen-modal-title">${n}</h2>
|
|
369
|
-
<label class="settings-field">
|
|
370
|
-
<span>Name</span>
|
|
371
|
-
<input type="text" name="name" .value=${s} required />
|
|
372
|
-
</label>
|
|
373
|
-
<div class="screen-form-actions">
|
|
374
|
-
<button type="submit" class="settings-submit-button" ?disabled=${this.createPending}>
|
|
375
|
-
${r}
|
|
376
|
-
</button>
|
|
377
|
-
<button type="button" class="settings-cancel-button" @click=${()=>this.emitClose()}>
|
|
378
|
-
Cancel
|
|
379
|
-
</button>
|
|
380
|
-
</div>
|
|
381
|
-
</form>
|
|
382
|
-
</section>
|
|
383
|
-
</modal-overlay>
|
|
384
|
-
`,this)}}v(dv,"observedAttributes",["open"]);customElements.define("screen-form-modal",dv);class fv extends HTMLElement{constructor(){super(...arguments);v(this,"screenManager",Ye.resolve("ScreenManager"));v(this,"serverManager",Ye.resolve("ServerManager"));v(this,"handleChange",()=>{this.render()});v(this,"deletePending",!1);v(this,"deleteError",null)}get open(){return this.hasAttribute("open")}attributeChangedCallback(n,r,s){n==="open"&&(s!==null&&r===null&&(this.deletePending=!1,this.deleteError=null),this.render())}connectedCallback(){this.render(),this.screenManager.addEventListener("active-screen-changed",this.handleChange),this.serverManager.addEventListener("change",this.handleChange)}disconnectedCallback(){this.screenManager.removeEventListener("active-screen-changed",this.handleChange),this.serverManager.removeEventListener("change",this.handleChange)}emitClose(){this.dispatchEvent(new Event("close",{bubbles:!0}))}async handleDeleteScreen(){const n=this.screenManager.activeScreen;if(n){this.deletePending=!0,this.deleteError=null,this.render();try{await n.remove(),this.emitClose()}catch(r){this.deletePending=!1,this.deleteError=r instanceof Error?r.message:String(r),this.render()}}}render(){const n=this.screenManager.activeScreen,r=(n==null?void 0:n.server.url)??null,s=r!==null&&r!==this.serverManager.localServerURL;be(M`
|
|
385
|
-
<modal-overlay ?open=${this.open}>
|
|
386
|
-
<section class="screen-modal screen-delete-modal">
|
|
387
|
-
<div class="screen-form">
|
|
388
|
-
<h2 class="screen-modal-title">Delete screen</h2>
|
|
389
|
-
<p class="screen-delete-copy">
|
|
390
|
-
Delete <strong>${(n==null?void 0:n.name)??""}</strong>?
|
|
391
|
-
</p>
|
|
392
|
-
${s?M`<p class="screen-delete-warning">This will delete it for everyone.</p>`:null}
|
|
393
|
-
${this.deleteError?M`<p class="screen-delete-error">${this.deleteError}</p>`:null}
|
|
394
|
-
<div class="screen-form-actions">
|
|
395
|
-
<button
|
|
396
|
-
type="button"
|
|
397
|
-
class="settings-server-remove-button"
|
|
398
|
-
?disabled=${this.deletePending}
|
|
399
|
-
@click=${()=>void this.handleDeleteScreen()}
|
|
400
|
-
>
|
|
401
|
-
${this.deletePending?"Deleting...":"Delete"}
|
|
402
|
-
</button>
|
|
403
|
-
<button
|
|
404
|
-
type="button"
|
|
405
|
-
class="settings-cancel-button"
|
|
406
|
-
?disabled=${this.deletePending}
|
|
407
|
-
@click=${()=>this.emitClose()}
|
|
408
|
-
>
|
|
409
|
-
Cancel
|
|
410
|
-
</button>
|
|
411
|
-
</div>
|
|
412
|
-
</div>
|
|
413
|
-
</section>
|
|
414
|
-
</modal-overlay>
|
|
415
|
-
`,this)}}v(fv,"observedAttributes",["open"]);customElements.define("screen-delete-modal",fv);class pv extends HTMLElement{constructor(){super(...arguments);v(this,"serverManager",Ye.resolve("ServerManager"));v(this,"handleChange",()=>{this.render()});v(this,"addServerFormOpen",!1)}get open(){return this.hasAttribute("open")}attributeChangedCallback(n){n==="open"&&(this.open||(this.addServerFormOpen=!1),this.render())}connectedCallback(){this.render(),this.serverManager.addEventListener("change",this.handleChange)}disconnectedCallback(){this.serverManager.removeEventListener("change",this.handleChange)}emitClose(){this.dispatchEvent(new Event("close",{bubbles:!0}))}openAddServerForm(){this.addServerFormOpen=!0,this.render()}closeAddServerForm(){this.addServerFormOpen&&(this.addServerFormOpen=!1,this.render())}handleAddServer(n){n.preventDefault();const r=n.currentTarget,s=new FormData(r),i=String(s.get("name")??"").trim(),o=String(s.get("url")??"").trim();!i||!o||(this.serverManager.addServer(o,i),this.addServerFormOpen=!1,r.reset(),this.render())}render(){const n=[...this.serverManager.servers.values()];be(M`
|
|
416
|
-
<modal-overlay ?open=${this.open}>
|
|
417
|
-
<section class="settings-panel">
|
|
418
|
-
<panel-view closable @close=${r=>r instanceof Pm&&this.emitClose()}>
|
|
419
|
-
<panel-page id="main" title="Settings">
|
|
420
|
-
<div class="settings-section">
|
|
421
|
-
<h3 class="settings-section-title">Servers</h3>
|
|
422
|
-
<div class="settings-server-list">
|
|
423
|
-
${n.map(r=>M`
|
|
424
|
-
<div class="settings-card settings-server">
|
|
425
|
-
<div class="settings-server-details">
|
|
426
|
-
<div class="settings-server-name">${r.name}</div>
|
|
427
|
-
<div class="settings-server-url">${r.url}</div>
|
|
428
|
-
</div>
|
|
429
|
-
${r.url!==this.serverManager.localServerURL?M`
|
|
430
|
-
<button
|
|
431
|
-
type="button"
|
|
432
|
-
class="settings-server-remove-button"
|
|
433
|
-
aria-label=${`Remove ${r.name}`}
|
|
434
|
-
@click=${()=>this.serverManager.removeServer(r.url)}
|
|
435
|
-
>
|
|
436
|
-
Remove
|
|
437
|
-
</button>
|
|
438
|
-
`:null}
|
|
439
|
-
</div>
|
|
440
|
-
`)}
|
|
441
|
-
</div>
|
|
442
|
-
${this.addServerFormOpen?M`
|
|
443
|
-
<form class="settings-card settings-add-server-form" @submit=${r=>this.handleAddServer(r)}>
|
|
444
|
-
<label class="settings-field">
|
|
445
|
-
<span>Name</span>
|
|
446
|
-
<input type="text" name="name" required />
|
|
447
|
-
</label>
|
|
448
|
-
<label class="settings-field">
|
|
449
|
-
<span>URL</span>
|
|
450
|
-
<input type="url" name="url" required />
|
|
451
|
-
</label>
|
|
452
|
-
<div class="settings-form-actions">
|
|
453
|
-
<button type="submit" class="settings-submit-button">Connect</button>
|
|
454
|
-
<button
|
|
455
|
-
type="button"
|
|
456
|
-
class="settings-cancel-button"
|
|
457
|
-
data-action="cancel-connect-form"
|
|
458
|
-
@click=${()=>this.closeAddServerForm()}
|
|
459
|
-
>
|
|
460
|
-
Cancel
|
|
461
|
-
</button>
|
|
462
|
-
</div>
|
|
463
|
-
</form>
|
|
464
|
-
`:M`
|
|
465
|
-
<button
|
|
466
|
-
type="button"
|
|
467
|
-
class="settings-submit-button settings-connect-button"
|
|
468
|
-
data-action="show-connect-form"
|
|
469
|
-
@click=${()=>this.openAddServerForm()}
|
|
470
|
-
>
|
|
471
|
-
+ Connect to server
|
|
472
|
-
</button>
|
|
473
|
-
`}
|
|
474
|
-
</div>
|
|
475
|
-
</panel-page>
|
|
476
|
-
</panel-view>
|
|
477
|
-
</section>
|
|
478
|
-
</modal-overlay>
|
|
479
|
-
`,this)}}v(pv,"observedAttributes",["open"]);customElements.define("settings-modal",pv);class gv extends Event{constructor(n){super("auth-submit",{bubbles:!0,composed:!0});v(this,"token");this.token=n}}class mO extends HTMLElement{constructor(){super(...arguments);v(this,"_invalid",!1);v(this,"_tokenValue","")}set invalid(n){this._invalid=n,this.render()}get invalid(){return this._invalid}set tokenValue(n){this._tokenValue=n,this.render()}get tokenValue(){return this._tokenValue}connectedCallback(){this.render()}handleInput(n){const r=n.currentTarget;this._tokenValue=r.value}handleSubmit(n){n.preventDefault();const r=this._tokenValue.trim();r&&this.dispatchEvent(new gv(r))}render(){be(M`
|
|
480
|
-
<modal-overlay open>
|
|
481
|
-
<section class="auth-modal">
|
|
482
|
-
<form class="auth-form" @submit=${n=>this.handleSubmit(n)}>
|
|
483
|
-
<h2 class="auth-modal-title">Enter access token</h2>
|
|
484
|
-
<p class="auth-modal-copy">This Television server requires a token.</p>
|
|
485
|
-
<label class="settings-field">
|
|
486
|
-
<span>Token</span>
|
|
487
|
-
<input
|
|
488
|
-
class=${this.invalid?"auth-token-input-invalid":""}
|
|
489
|
-
type="password"
|
|
490
|
-
name="token"
|
|
491
|
-
.value=${this.tokenValue}
|
|
492
|
-
@input=${n=>this.handleInput(n)}
|
|
493
|
-
required
|
|
494
|
-
/>
|
|
495
|
-
</label>
|
|
496
|
-
<button type="submit" class="settings-submit-button">Connect</button>
|
|
497
|
-
</form>
|
|
498
|
-
</section>
|
|
499
|
-
</modal-overlay>
|
|
500
|
-
`,this)}}customElements.get("auth-modal")||customElements.define("auth-modal",mO);class vO extends HTMLElement{constructor(){super(...arguments);v(this,"runtimeServerURL",hm());v(this,"electronMode",fm());v(this,"serverManager",Ye.resolve("ServerManager"));v(this,"modals",{screenForm:{open:!1,mode:"edit"},deleteScreen:{open:!1},settings:{open:!1}});v(this,"connectError",null);v(this,"handleServerManagerChange",()=>{this.render()})}connectedCallback(){this.serverManager.addEventListener("change",this.handleServerManagerChange),this.addEventListener("auth-submit",n=>{var s;const r=n instanceof gv?n.token:n instanceof CustomEvent&&typeof((s=n.detail)==null?void 0:s.token)=="string"?n.detail.token:null;r&&this.handleAuthSubmit(r)}),this.initializeConnection(),this.render()}disconnectedCallback(){this.serverManager.removeEventListener("change",this.handleServerManagerChange)}async initializeConnection(){if(this.electronMode){this.serverManager.connectConfiguredServers(this.runtimeServerURL);return}if(this.serverManager.activeServer)return;const n=new _l({url:this.runtimeServerURL,name:"Server",token:dm()});this.serverManager.add(n),this.serverManager.setActive(n);try{await n.connect(),this.connectError=null}catch(r){this.connectError=r instanceof Error&&!(r instanceof wl)?r.message:null}this.render()}async handleAuthSubmit(n){const r=this.serverManager.activeServer;if(r){this.connectError=null,r.token=n,this.updateTokenQueryParam(n);try{await r.connect()}catch(s){s instanceof wl||(this.connectError=s instanceof Error?s.message:String(s))}this.render()}}updateTokenQueryParam(n){const r=new URL(window.location.href);r.searchParams.set("token",n),window.history.replaceState({},"",`${r.pathname}${r.search}${r.hash}`)}render(){const n=this.serverManager.activeServer,r=(n==null?void 0:n.status)??null;if(r==="connecting"){be(M`
|
|
501
|
-
<main class="auth-gate"><p>Connecting...</p></main>
|
|
502
|
-
`,this);return}if(r==="disconnected"){const i=n;if(!i)return;be(M`
|
|
503
|
-
<main class="auth-gate">
|
|
504
|
-
<auth-modal
|
|
505
|
-
.invalid=${!!i.token}
|
|
506
|
-
.tokenValue=${i.token??""}
|
|
507
|
-
></auth-modal>
|
|
508
|
-
</main>
|
|
509
|
-
`,this);return}const s=M`
|
|
510
|
-
<header>
|
|
511
|
-
<nav>
|
|
512
|
-
<screen-picker
|
|
513
|
-
@edit-screen=${()=>{this.modals.screenForm={open:!0,mode:"edit"},this.render()}}
|
|
514
|
-
@create-screen=${i=>{this.modals.screenForm={open:!0,mode:"create",targetServerURL:i.serverURL},this.render()}}
|
|
515
|
-
@delete-screen=${()=>{this.modals.deleteScreen={open:!0},this.render()}}
|
|
516
|
-
></screen-picker>
|
|
517
|
-
</nav>
|
|
518
|
-
<button
|
|
519
|
-
type="button"
|
|
520
|
-
variant="toolbar"
|
|
521
|
-
size="sm"
|
|
522
|
-
aria-label="Settings"
|
|
523
|
-
@click=${()=>{this.modals.settings={open:!this.modals.settings.open},this.render()}}
|
|
524
|
-
>
|
|
525
|
-
${FR({size:16,weight:"bold"})}
|
|
526
|
-
</button>
|
|
527
|
-
</header>
|
|
528
|
-
<main>
|
|
529
|
-
${this.connectError?M`<p data-testid="auth-error">${this.connectError}</p>`:M`
|
|
530
|
-
<screen-view></screen-view>
|
|
531
|
-
${r==="connected"?M`<chat-panel></chat-panel>`:null}
|
|
532
|
-
`}
|
|
533
|
-
</main>
|
|
534
|
-
<screen-form-modal
|
|
535
|
-
?open=${this.modals.screenForm.open}
|
|
536
|
-
.mode=${this.modals.screenForm.mode}
|
|
537
|
-
.targetServerURL=${this.modals.screenForm.targetServerURL}
|
|
538
|
-
@close=${()=>{this.modals.screenForm={open:!1,mode:"edit"},this.render()}}
|
|
539
|
-
></screen-form-modal>
|
|
540
|
-
<screen-delete-modal
|
|
541
|
-
?open=${this.modals.deleteScreen.open}
|
|
542
|
-
@close=${()=>{this.modals.deleteScreen={open:!1},this.render()}}
|
|
543
|
-
></screen-delete-modal>
|
|
544
|
-
<settings-modal
|
|
545
|
-
?open=${this.modals.settings.open}
|
|
546
|
-
@close=${()=>{this.modals.settings={open:!1},this.render()}}
|
|
547
|
-
></settings-modal>
|
|
548
|
-
`;be(s,this)}}customElements.get("television-app")||customElements.define("television-app",vO);const Jc=fm(),ea=hm(),mv=new BE(Jc?"television-electron":"television-browser",WE(ea)),vv=new LT({localStore:mv,localServerURL:ea}),yv=new FE({localStore:mv,serverManager:vv}),yO=new vR({serverURL:ea,token:dm()??"",screenManager:yv});Ye.register("ServerManager",()=>vv);Ye.register("ScreenManager",()=>yv);Ye.register("ACPClientManager",()=>yO);const Xc=document.createElement("television-app");Xc.runtimeServerURL=ea;Xc.electronMode=Jc;Jc&&document.body.classList.add("electron");document.body.appendChild(Xc);
|