@telepath-computer/television 0.1.106 → 0.1.107
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/canonical/v1/styles.css +16 -6
- package/dist/cli.cjs +2 -2
- package/dist/views/markdown/index.html +1 -1
- package/dist/web/assets/{index-BbSTSxZQ.css → index-B-es86cH.css} +1 -1
- package/dist/web/assets/index-itK0QT_V.js +587 -0
- package/dist/web/index.html +2 -2
- package/package.json +1 -1
- package/dist/web/assets/index-dt9xJolN.js +0 -559
|
@@ -0,0 +1,587 @@
|
|
|
1
|
+
var Mw=Object.defineProperty;var Vd=n=>{throw TypeError(n)};var Nw=(n,t,e)=>t in n?Mw(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e;var m=(n,t,e)=>Nw(n,typeof t!="symbol"?t+"":t,e),sc=(n,t,e)=>t.has(n)||Vd("Cannot "+e);var l=(n,t,e)=>(sc(n,t,"read from private field"),e?e.call(n):t.get(n)),w=(n,t,e)=>t.has(n)?Vd("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(n):t.set(n,e),S=(n,t,e,r)=>(sc(n,t,"write to private field"),r?r.call(n,e):t.set(n,e),e),f=(n,t,e)=>(sc(n,t,"access private method"),e);var jd=(n,t,e,r)=>({set _(i){S(n,t,i,e)},get _(){return l(n,t,r)}});(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const i of document.querySelectorAll('link[rel="modulepreload"]'))r(i);new MutationObserver(i=>{for(const s of i)if(s.type==="childList")for(const o of s.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&r(o)}).observe(document,{childList:!0,subtree:!0});function e(i){const s={};return i.integrity&&(s.integrity=i.integrity),i.referrerPolicy&&(s.referrerPolicy=i.referrerPolicy),i.crossOrigin==="use-credentials"?s.credentials="include":i.crossOrigin==="anonymous"?s.credentials="omit":s.credentials="same-origin",s}function r(i){if(i.ep)return;i.ep=!0;const s=e(i);fetch(i.href,s)}})();var ir=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Uw(n){if(n.__esModule)return n;var t=n.default;if(typeof t=="function"){var e=function r(){return this instanceof r?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};e.prototype=t.prototype}else e={};return Object.defineProperty(e,"__esModule",{value:!0}),Object.keys(n).forEach(function(r){var i=Object.getOwnPropertyDescriptor(n,r);Object.defineProperty(e,r,i.get?i:{enumerable:!0,get:function(){return n[r]}})}),e}var Gd=Object.prototype.toString,qg=function(t){var e=Gd.call(t),r=e==="[object Arguments]";return r||(r=e!=="[object Array]"&&t!==null&&typeof t=="object"&&typeof t.length=="number"&&t.length>=0&&Gd.call(t.callee)==="[object Function]"),r},oc,qd;function Fw(){if(qd)return oc;qd=1;var n;if(!Object.keys){var t=Object.prototype.hasOwnProperty,e=Object.prototype.toString,r=qg,i=Object.prototype.propertyIsEnumerable,s=!i.call({toString:null},"toString"),o=i.call(function(){},"prototype"),a=["toString","toLocaleString","valueOf","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","constructor"],c=function(v){var g=v.constructor;return g&&g.prototype===v},u={$applicationCache:!0,$console:!0,$external:!0,$frame:!0,$frameElement:!0,$frames:!0,$innerHeight:!0,$innerWidth:!0,$onmozfullscreenchange:!0,$onmozfullscreenerror:!0,$outerHeight:!0,$outerWidth:!0,$pageXOffset:!0,$pageYOffset:!0,$parent:!0,$scrollLeft:!0,$scrollTop:!0,$scrollX:!0,$scrollY:!0,$self:!0,$webkitIndexedDB:!0,$webkitStorageInfo:!0,$window:!0},h=function(){if(typeof window>"u")return!1;for(var v in window)try{if(!u["$"+v]&&t.call(window,v)&&window[v]!==null&&typeof window[v]=="object")try{c(window[v])}catch{return!0}}catch{return!0}return!1}(),p=function(v){if(typeof window>"u"||!h)return c(v);try{return c(v)}catch{return!1}};n=function(g){var _=g!==null&&typeof g=="object",k=e.call(g)==="[object Function]",T=r(g),P=_&&e.call(g)==="[object String]",R=[];if(!_&&!k&&!T)throw new TypeError("Object.keys called on a non-object");var W=o&&k;if(P&&g.length>0&&!t.call(g,0))for(var N=0;N<g.length;++N)R.push(String(N));if(T&&g.length>0)for(var F=0;F<g.length;++F)R.push(String(F));else for(var Y in g)!(W&&Y==="prototype")&&t.call(g,Y)&&R.push(String(Y));if(s)for(var j=p(g),le=0;le<a.length;++le)!(j&&a[le]==="constructor")&&t.call(g,a[le])&&R.push(a[le]);return R}}return oc=n,oc}var Hw=Array.prototype.slice,Ww=qg,Yd=Object.keys,va=Yd?function(t){return Yd(t)}:Fw(),Xd=Object.keys;va.shim=function(){if(Object.keys){var t=function(){var e=Object.keys(arguments);return e&&e.length===arguments.length}(1,2);t||(Object.keys=function(r){return Ww(r)?Xd(Hw.call(r)):Xd(r)})}else Object.keys=va;return Object.keys||va};var Zw=va,ya=Object.defineProperty||!1;if(ya)try{ya({},"a",{value:1})}catch{ya=!1}var To=ya,fn=SyntaxError,X=TypeError,Bw=Object.getOwnPropertyDescriptor,ba=Bw;if(ba)try{ba([],"length")}catch{ba=null}var Wi=ba,Kd=To,Vw=fn,Xr=X,Jd=Wi,Yg=function(t,e,r){if(!t||typeof t!="object"&&typeof t!="function")throw new Xr("`obj` must be an object or a function`");if(typeof e!="string"&&typeof e!="symbol")throw new Xr("`property` must be a string or a symbol`");if(arguments.length>3&&typeof arguments[3]!="boolean"&&arguments[3]!==null)throw new Xr("`nonEnumerable`, if provided, must be a boolean or null");if(arguments.length>4&&typeof arguments[4]!="boolean"&&arguments[4]!==null)throw new Xr("`nonWritable`, if provided, must be a boolean or null");if(arguments.length>5&&typeof arguments[5]!="boolean"&&arguments[5]!==null)throw new Xr("`nonConfigurable`, if provided, must be a boolean or null");if(arguments.length>6&&typeof arguments[6]!="boolean")throw new Xr("`loose`, if provided, must be a boolean");var i=arguments.length>3?arguments[3]:null,s=arguments.length>4?arguments[4]:null,o=arguments.length>5?arguments[5]:null,a=arguments.length>6?arguments[6]:!1,c=!!Jd&&Jd(t,e);if(Kd)Kd(t,e,{configurable:o===null&&c?c.configurable:!o,enumerable:i===null&&c?c.enumerable:!i,value:r,writable:s===null&&c?c.writable:!s});else if(a||!i&&!s&&!o)t[e]=r;else throw new Vw("This environment does not support defining a property as non-configurable, non-writable, or non-enumerable.")},ru=To,Xg=function(){return!!ru};Xg.hasArrayLengthDefineBug=function(){if(!ru)return null;try{return ru([],"length",{value:1}).length!==1}catch{return!0}};var El=Xg,jw=Zw,Gw=typeof Symbol=="function"&&typeof Symbol("foo")=="symbol",qw=Object.prototype.toString,Yw=Array.prototype.concat,Qd=Yg,Xw=function(n){return typeof n=="function"&&qw.call(n)==="[object Function]"},Kg=El(),Kw=function(n,t,e,r){if(t in n){if(r===!0){if(n[t]===e)return}else if(!Xw(r)||!r())return}Kg?Qd(n,t,e,!0):Qd(n,t,e)},Jg=function(n,t){var e=arguments.length>2?arguments[2]:{},r=jw(t);Gw&&(r=Yw.call(r,Object.getOwnPropertySymbols(t)));for(var i=0;i<r.length;i+=1)Kw(n,r[i],t[r[i]],e[r[i]])};Jg.supportsDescriptors=!!Kg;var Fr=Jg,wa={exports:{}};typeof self<"u"?wa.exports=self:typeof window<"u"?wa.exports=window:wa.exports=Function("return this")();var Qg=wa.exports,Jw=Qg,em=function(){return typeof ir!="object"||!ir||ir.Math!==Math||ir.Array!==Array?Jw:ir},Qw=Fr,e0=Wi,t0=em,n0=function(){var t=t0();if(Qw.supportsDescriptors){var e=e0(t,"globalThis");(!e||e.configurable&&(e.enumerable||!e.writable||globalThis!==t))&&Object.defineProperty(t,"globalThis",{configurable:!0,enumerable:!1,value:t,writable:!0})}else(typeof globalThis!="object"||globalThis!==t)&&(t.globalThis=t);return t},r0=Fr,i0=Qg,tm=em,s0=n0,o0=tm(),nm=function(){return o0};r0(nm,{getPolyfill:tm,implementation:i0,shim:s0});var fh=nm,gn=function(t){return!!t&&(typeof t=="function"||typeof t=="object")},gh=Object,rm=Error,a0=EvalError,l0=RangeError,mh=ReferenceError,c0=URIError,u0=Math.abs,h0=Math.floor,d0=Math.max,p0=Math.min,f0=Math.pow,g0=Math.round,vh=Number.isNaN||function(t){return t!==t},m0=vh,v0=function(t){return m0(t)||t===0?t:t<0?-1:1},Zi=function(){if(typeof Symbol!="function"||typeof Object.getOwnPropertySymbols!="function")return!1;if(typeof Symbol.iterator=="symbol")return!0;var t={},e=Symbol("test"),r=Object(e);if(typeof e=="string"||Object.prototype.toString.call(e)!=="[object Symbol]"||Object.prototype.toString.call(r)!=="[object Symbol]")return!1;var i=42;t[e]=i;for(var s in t)return!1;if(typeof Object.keys=="function"&&Object.keys(t).length!==0||typeof Object.getOwnPropertyNames=="function"&&Object.getOwnPropertyNames(t).length!==0)return!1;var o=Object.getOwnPropertySymbols(t);if(o.length!==1||o[0]!==e||!Object.prototype.propertyIsEnumerable.call(t,e))return!1;if(typeof Object.getOwnPropertyDescriptor=="function"){var a=Object.getOwnPropertyDescriptor(t,e);if(a.value!==i||a.enumerable!==!0)return!1}return!0},ep=typeof Symbol<"u"&&Symbol,y0=Zi,yh=function(){return typeof ep!="function"||typeof Symbol!="function"||typeof ep("foo")!="symbol"||typeof Symbol("bar")!="symbol"?!1:y0()},ac,tp;function im(){return tp||(tp=1,ac=typeof Reflect<"u"&&Reflect.getPrototypeOf||null),ac}var lc,np;function sm(){if(np)return lc;np=1;var n=gh;return lc=n.getPrototypeOf||null,lc}var b0="Function.prototype.bind called on incompatible ",w0=Object.prototype.toString,S0=Math.max,_0="[object Function]",rp=function(t,e){for(var r=[],i=0;i<t.length;i+=1)r[i]=t[i];for(var s=0;s<e.length;s+=1)r[s+t.length]=e[s];return r},k0=function(t,e){for(var r=[],i=e,s=0;i<t.length;i+=1,s+=1)r[s]=t[i];return r},x0=function(n,t){for(var e="",r=0;r<n.length;r+=1)e+=n[r],r+1<n.length&&(e+=t);return e},E0=function(t){var e=this;if(typeof e!="function"||w0.apply(e)!==_0)throw new TypeError(b0+e);for(var r=k0(arguments,1),i,s=function(){if(this instanceof i){var h=e.apply(this,rp(r,arguments));return Object(h)===h?h:this}return e.apply(t,rp(r,arguments))},o=S0(0,e.length-r.length),a=[],c=0;c<o;c++)a[c]="$"+c;if(i=Function("binder","return function ("+x0(a,",")+"){ return binder.apply(this,arguments); }")(s),e.prototype){var u=function(){};u.prototype=e.prototype,i.prototype=new u,u.prototype=null}return i},A0=E0,Io=Function.prototype.bind||A0,bh=Function.prototype.call,wh=Function.prototype.apply,$0=typeof Reflect<"u"&&Reflect&&Reflect.apply,T0=Io,I0=wh,C0=bh,R0=$0,om=R0||T0.call(C0,I0),P0=Io,D0=X,L0=bh,z0=om,Al=function(t){if(t.length<1||typeof t[0]!="function")throw new D0("a function is required");return z0(P0,L0,t)},cc,ip;function O0(){if(ip)return cc;ip=1;var n=Al,t=Wi,e;try{e=[].__proto__===Array.prototype}catch(o){if(!o||typeof o!="object"||!("code"in o)||o.code!=="ERR_PROTO_ACCESS")throw o}var r=!!e&&t&&t(Object.prototype,"__proto__"),i=Object,s=i.getPrototypeOf;return cc=r&&typeof r.get=="function"?n([r.get]):typeof s=="function"?function(a){return s(a==null?a:i(a))}:!1,cc}var uc,sp;function am(){if(sp)return uc;sp=1;var n=im(),t=sm(),e=O0();return uc=n?function(i){return n(i)}:t?function(i){if(!i||typeof i!="object"&&typeof i!="function")throw new TypeError("getProto: not an object");return t(i)}:e?function(i){return e(i)}:null,uc}var M0=Function.prototype.call,N0=Object.prototype.hasOwnProperty,U0=Io,mn=U0.call(M0,N0),q,F0=gh,H0=rm,W0=a0,Z0=l0,B0=mh,Oi=fn,gi=X,V0=c0,j0=u0,G0=h0,q0=d0,Y0=p0,X0=f0,K0=g0,J0=v0,lm=Function,hc=function(n){try{return lm('"use strict"; return ('+n+").constructor;")()}catch{}},Cs=Wi,Q0=To,dc=function(){throw new gi},eS=Cs?function(){try{return arguments.callee,dc}catch{try{return Cs(arguments,"callee").get}catch{return dc}}}():dc,Kr=yh(),Ie=am(),tS=sm(),nS=im(),cm=wh,Co=bh,ni={},rS=typeof Uint8Array>"u"||!Ie?q:Ie(Uint8Array),Pr={__proto__:null,"%AggregateError%":typeof AggregateError>"u"?q:AggregateError,"%Array%":Array,"%ArrayBuffer%":typeof ArrayBuffer>"u"?q:ArrayBuffer,"%ArrayIteratorPrototype%":Kr&&Ie?Ie([][Symbol.iterator]()):q,"%AsyncFromSyncIteratorPrototype%":q,"%AsyncFunction%":ni,"%AsyncGenerator%":ni,"%AsyncGeneratorFunction%":ni,"%AsyncIteratorPrototype%":ni,"%Atomics%":typeof Atomics>"u"?q:Atomics,"%BigInt%":typeof BigInt>"u"?q:BigInt,"%BigInt64Array%":typeof BigInt64Array>"u"?q:BigInt64Array,"%BigUint64Array%":typeof BigUint64Array>"u"?q:BigUint64Array,"%Boolean%":Boolean,"%DataView%":typeof DataView>"u"?q:DataView,"%Date%":Date,"%decodeURI%":decodeURI,"%decodeURIComponent%":decodeURIComponent,"%encodeURI%":encodeURI,"%encodeURIComponent%":encodeURIComponent,"%Error%":H0,"%eval%":eval,"%EvalError%":W0,"%Float16Array%":typeof Float16Array>"u"?q:Float16Array,"%Float32Array%":typeof Float32Array>"u"?q:Float32Array,"%Float64Array%":typeof Float64Array>"u"?q:Float64Array,"%FinalizationRegistry%":typeof FinalizationRegistry>"u"?q:FinalizationRegistry,"%Function%":lm,"%GeneratorFunction%":ni,"%Int8Array%":typeof Int8Array>"u"?q:Int8Array,"%Int16Array%":typeof Int16Array>"u"?q:Int16Array,"%Int32Array%":typeof Int32Array>"u"?q:Int32Array,"%isFinite%":isFinite,"%isNaN%":isNaN,"%IteratorPrototype%":Kr&&Ie?Ie(Ie([][Symbol.iterator]())):q,"%JSON%":typeof JSON=="object"?JSON:q,"%Map%":typeof Map>"u"?q:Map,"%MapIteratorPrototype%":typeof Map>"u"||!Kr||!Ie?q:Ie(new Map()[Symbol.iterator]()),"%Math%":Math,"%Number%":Number,"%Object%":F0,"%Object.getOwnPropertyDescriptor%":Cs,"%parseFloat%":parseFloat,"%parseInt%":parseInt,"%Promise%":typeof Promise>"u"?q:Promise,"%Proxy%":typeof Proxy>"u"?q:Proxy,"%RangeError%":Z0,"%ReferenceError%":B0,"%Reflect%":typeof Reflect>"u"?q:Reflect,"%RegExp%":RegExp,"%Set%":typeof Set>"u"?q:Set,"%SetIteratorPrototype%":typeof Set>"u"||!Kr||!Ie?q:Ie(new Set()[Symbol.iterator]()),"%SharedArrayBuffer%":typeof SharedArrayBuffer>"u"?q:SharedArrayBuffer,"%String%":String,"%StringIteratorPrototype%":Kr&&Ie?Ie(""[Symbol.iterator]()):q,"%Symbol%":Kr?Symbol:q,"%SyntaxError%":Oi,"%ThrowTypeError%":eS,"%TypedArray%":rS,"%TypeError%":gi,"%Uint8Array%":typeof Uint8Array>"u"?q:Uint8Array,"%Uint8ClampedArray%":typeof Uint8ClampedArray>"u"?q:Uint8ClampedArray,"%Uint16Array%":typeof Uint16Array>"u"?q:Uint16Array,"%Uint32Array%":typeof Uint32Array>"u"?q:Uint32Array,"%URIError%":V0,"%WeakMap%":typeof WeakMap>"u"?q:WeakMap,"%WeakRef%":typeof WeakRef>"u"?q:WeakRef,"%WeakSet%":typeof WeakSet>"u"?q:WeakSet,"%Function.prototype.call%":Co,"%Function.prototype.apply%":cm,"%Object.defineProperty%":Q0,"%Object.getPrototypeOf%":tS,"%Math.abs%":j0,"%Math.floor%":G0,"%Math.max%":q0,"%Math.min%":Y0,"%Math.pow%":X0,"%Math.round%":K0,"%Math.sign%":J0,"%Reflect.getPrototypeOf%":nS};if(Ie)try{null.error}catch(n){var iS=Ie(Ie(n));Pr["%Error.prototype%"]=iS}var sS=function n(t){var e;if(t==="%AsyncFunction%")e=hc("async function () {}");else if(t==="%GeneratorFunction%")e=hc("function* () {}");else if(t==="%AsyncGeneratorFunction%")e=hc("async function* () {}");else if(t==="%AsyncGenerator%"){var r=n("%AsyncGeneratorFunction%");r&&(e=r.prototype)}else if(t==="%AsyncIteratorPrototype%"){var i=n("%AsyncGenerator%");i&&Ie&&(e=Ie(i.prototype))}return Pr[t]=e,e},op={__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"]},Ro=Io,Za=mn,oS=Ro.call(Co,Array.prototype.concat),aS=Ro.call(cm,Array.prototype.splice),ap=Ro.call(Co,String.prototype.replace),Ba=Ro.call(Co,String.prototype.slice),lS=Ro.call(Co,RegExp.prototype.exec),cS=/[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g,uS=/\\(\\)?/g,hS=function(t){var e=Ba(t,0,1),r=Ba(t,-1);if(e==="%"&&r!=="%")throw new Oi("invalid intrinsic syntax, expected closing `%`");if(r==="%"&&e!=="%")throw new Oi("invalid intrinsic syntax, expected opening `%`");var i=[];return ap(t,cS,function(s,o,a,c){i[i.length]=a?ap(c,uS,"$1"):o||s}),i},dS=function(t,e){var r=t,i;if(Za(op,r)&&(i=op[r],r="%"+i[0]+"%"),Za(Pr,r)){var s=Pr[r];if(s===ni&&(s=sS(r)),typeof s>"u"&&!e)throw new gi("intrinsic "+t+" exists, but is not available. Please file an issue!");return{alias:i,name:r,value:s}}throw new Oi("intrinsic "+t+" does not exist!")},bt=function(t,e){if(typeof t!="string"||t.length===0)throw new gi("intrinsic name must be a non-empty string");if(arguments.length>1&&typeof e!="boolean")throw new gi('"allowMissing" argument must be a boolean');if(lS(/^%?[^%]*%?$/,t)===null)throw new Oi("`%` may not be present anywhere but at the beginning and end of the intrinsic name");var r=hS(t),i=r.length>0?r[0]:"",s=dS("%"+i+"%",e),o=s.name,a=s.value,c=!1,u=s.alias;u&&(i=u[0],aS(r,oS([0,1],u)));for(var h=1,p=!0;h<r.length;h+=1){var v=r[h],g=Ba(v,0,1),_=Ba(v,-1);if((g==='"'||g==="'"||g==="`"||_==='"'||_==="'"||_==="`")&&g!==_)throw new Oi("property names with quotes must have matching quotes");if((v==="constructor"||!p)&&(c=!0),i+="."+v,o="%"+i+"%",Za(Pr,o))a=Pr[o];else if(a!=null){if(!(v in a)){if(!e)throw new gi("base intrinsic for "+t+" exists, but the property is not available.");return}if(Cs&&h+1>=r.length){var k=Cs(a,v);p=!!k,p&&"get"in k&&!("originalValue"in k.get)?a=k.get:a=a[v]}else p=Za(a,v),a=a[v];p&&!c&&(Pr[o]=a)}}return a},pc,lp;function Bn(){if(lp)return pc;lp=1;var n=bt,t=Al,e=t([n("%String.prototype.indexOf%")]);return pc=function(i,s){var o=n(i,!!s);return typeof o=="function"&&e(i,".prototype.")>-1?t([o]):o},pc}var fc,cp;function Sh(){if(cp)return fc;cp=1;var n=bt,t=n("%Array%"),e=!t.isArray&&Bn()("Object.prototype.toString");return fc=t.isArray||function(i){return e(i)==="[object Array]"},fc}var pS=El,up=To,um=pS.hasArrayLengthDefineBug(),fS=um&&Sh(),gS=Bn(),mS=gS("Object.prototype.propertyIsEnumerable"),_h=function(t,e,r,i,s,o){if(!up){if(!t(o)||!o["[[Configurable]]"]||!o["[[Writable]]"]||s in i&&mS(i,s)!==!!o["[[Enumerable]]"])return!1;var a=o["[[Value]]"];return i[s]=a,e(i[s],a)}return um&&s==="length"&&"[[Value]]"in o&&fS(i)&&i.length!==o["[[Value]]"]?(i.length=o["[[Value]]"],i.length===o["[[Value]]"]):(up(i,s,r(o)),!0)},vS=X,rs=mn,yS={__proto__:null,"[[Configurable]]":!0,"[[Enumerable]]":!0,"[[Get]]":!0,"[[Set]]":!0,"[[Value]]":!0,"[[Writable]]":!0},Bi=function(t){if(!t||typeof t!="object")return!1;for(var e in t)if(rs(t,e)&&!yS[e])return!1;var r=rs(t,"[[Value]]")||rs(t,"[[Writable]]"),i=rs(t,"[[Get]]")||rs(t,"[[Set]]");if(r&&i)throw new vS("Property Descriptors may not be both accessor and data descriptors");return!0},hm=function(t){if(typeof t>"u")return t;var e={};return"[[Value]]"in t&&(e.value=t["[[Value]]"]),"[[Writable]]"in t&&(e.writable=!!t["[[Writable]]"]),"[[Get]]"in t&&(e.get=t["[[Get]]"]),"[[Set]]"in t&&(e.set=t["[[Set]]"]),"[[Enumerable]]"in t&&(e.enumerable=!!t["[[Enumerable]]"]),"[[Configurable]]"in t&&(e.configurable=!!t["[[Configurable]]"]),e},bS=X,wS=Bi,SS=hm,dm=function(t){if(typeof t<"u"&&!wS(t))throw new bS("Assertion failed: `Desc` must be a Property Descriptor");return SS(t)},_S=X,hp=mn,kS=Bi,pm=function(t){if(typeof t>"u")return!1;if(!kS(t))throw new _S("Assertion failed: `Desc` must be a Property Descriptor");return!(!hp(t,"[[Value]]")&&!hp(t,"[[Writable]]"))},Vi=function(t){return typeof t=="string"||typeof t=="symbol"},dp=vh,fm=function(t,e){return t===e?t===0?1/t===1/e:!0:dp(t)&&dp(e)},pp=X,xS=gn,ES=_h,AS=dm,$S=pm,TS=Vi,IS=fm,kh=function(t,e,r){if(!xS(t))throw new pp("Assertion failed: Type(O) is not Object");if(!TS(e))throw new pp("Assertion failed: P is not a Property Key");var i={"[[Configurable]]":!0,"[[Enumerable]]":!1,"[[Value]]":r,"[[Writable]]":!0};return ES($S,IS,AS,t,e,i)},gm=Function.prototype.toString,di=typeof Reflect=="object"&&Reflect!==null&&Reflect.apply,iu,Sa;if(typeof di=="function"&&typeof Object.defineProperty=="function")try{iu=Object.defineProperty({},"length",{get:function(){throw Sa}}),Sa={},di(function(){throw 42},null,iu)}catch(n){n!==Sa&&(di=null)}else di=null;var CS=/^\s*class\b/,su=function(t){try{var e=gm.call(t);return CS.test(e)}catch{return!1}},gc=function(t){try{return su(t)?!1:(gm.call(t),!0)}catch{return!1}},_a=Object.prototype.toString,RS="[object Object]",PS="[object Function]",DS="[object GeneratorFunction]",LS="[object HTMLAllCollection]",zS="[object HTML document.all class]",OS="[object HTMLCollection]",MS=typeof Symbol=="function"&&!!Symbol.toStringTag,NS=!(0 in[,]),ou=function(){return!1};if(typeof document=="object"){var US=document.all;_a.call(US)===_a.call(document.all)&&(ou=function(t){if((NS||!t)&&(typeof t>"u"||typeof t=="object"))try{var e=_a.call(t);return(e===LS||e===zS||e===OS||e===RS)&&t("")==null}catch{}return!1})}var mm=di?function(t){if(ou(t))return!0;if(!t||typeof t!="function"&&typeof t!="object")return!1;try{di(t,null,iu)}catch(e){if(e!==Sa)return!1}return!su(t)&&gc(t)}:function(t){if(ou(t))return!0;if(!t||typeof t!="function"&&typeof t!="object")return!1;if(MS)return gc(t);if(su(t))return!1;var e=_a.call(t);return e!==PS&&e!==DS&&!/^\[object HTML/.test(e)?!1:gc(t)},FS=mm,HS=function(t){return!!t},Pt=mn,Ko=X,WS=gn,fp=FS,mc=HS,ZS=function(t){if(!WS(t))throw new Ko("ToPropertyDescriptor requires an object");var e={};if(Pt(t,"enumerable")&&(e["[[Enumerable]]"]=mc(t.enumerable)),Pt(t,"configurable")&&(e["[[Configurable]]"]=mc(t.configurable)),Pt(t,"value")&&(e["[[Value]]"]=t.value),Pt(t,"writable")&&(e["[[Writable]]"]=mc(t.writable)),Pt(t,"get")){var r=t.get;if(typeof r<"u"&&!fp(r))throw new Ko("getter must be a function");e["[[Get]]"]=r}if(Pt(t,"set")){var i=t.set;if(typeof i<"u"&&!fp(i))throw new Ko("setter must be a function");e["[[Set]]"]=i}if((Pt(e,"[[Get]]")||Pt(e,"[[Set]]"))&&(Pt(e,"[[Value]]")||Pt(e,"[[Writable]]")))throw new Ko("Invalid property descriptor. Cannot both specify accessors and a value or writable attribute");return e},vc=X,BS=gn,gp=Bi,VS=_h,jS=dm,GS=pm,qS=Vi,YS=fm,XS=ZS,KS=function(t,e,r){if(!BS(t))throw new vc("Assertion failed: Type(O) is not Object");if(!qS(e))throw new vc("Assertion failed: P is not a Property Key");var i=gp(r)?r:XS(r);if(!gp(i))throw new vc("Assertion failed: Desc is not a valid Property Descriptor");return VS(GS,YS,jS,t,e,i)},mp=X,JS=gn,QS=KS,e_=Vi,t_=function(t,e,r){if(!JS(t))throw new mp("Assertion failed: Type(O) is not Object");if(!e_(e))throw new mp("Assertion failed: P is not a Property Key");var i={"[[Configurable]]":!0,"[[Enumerable]]":!1,"[[Value]]":r,"[[Writable]]":!0};return QS(t,e,i)},n_=typeof Reflect<"u"&&Reflect.setPrototypeOf||null,r_=gh,i_=r_.setPrototypeOf||null,s_=Al,vp=Wi,o_=X,vm={};try{vm.__proto__=null}catch(n){if(!n||typeof n!="object"||!("code"in n)||n.code!=="ERR_PROTO_ACCESS")throw n}var a_=!("toString"in vm),yc=vp&&vp(Object.prototype,"__proto__"),l_=a_&&(!!yc&&typeof yc.set=="function"&&s_([yc.set])||function(t,e){if(t==null)throw new o_("set Object.prototype.__proto__ called on null or undefined");return t.__proto__=e,e}),yp=n_,c_=i_,bp=l_,u_=X,h_=yp?function(t,e){if(yp(t,e))return t;throw new u_("Reflect.setPrototypeOf: failed to set [[Prototype]]")}:c_||(bp?function(t,e){return bp(t,e),t}:null),wp=X,d_=gn,Sp=am(),p_=function(t){if(!d_(t))throw new wp("Assertion failed: O must be an Object");if(!Sp)throw new wp("This environment does not support fetching prototypes.");return Sp(t)},f_=X,g_=h_,m_=gn,v_=p_,y_=function(t,e){if(e!==null&&!m_(e))throw new f_("Assertion failed: V must be Object or Null");try{g_(t,e)}catch{return!1}return v_(t)===e},bc=kh,_p=t_,ym=y_,b_=El(),xh=rm;function Po(n,t,e){var r=new xh(e);return ym(r,ka),delete r.constructor,_p(r,"error",n),_p(r,"suppressed",t),r}b_&&Object.defineProperty(Po,"prototype",{writable:!1});var ka=Po.prototype;if(!bc(ka,"constructor",Po)||!bc(ka,"message","")||!bc(ka,"name","SuppressedError"))throw new xh("unable to install SuppressedError.prototype properties; please report this!");ym(Po.prototype,xh.prototype);var w_=Po,S_=w_,bm=function(){return typeof SuppressedError=="function"?SuppressedError:S_},__=Fr,kp=fh(),k_=bm,x_=function(){var t=k_();return __(kp,{SuppressedError:t},{SuppressedError:function(){return kp.SuppressedError!==t}}),t};x_();var E_=X,A_=Bi,$_=hm,T_=function(t){if(typeof t<"u"&&!A_(t))throw new E_("Assertion failed: `Desc` must be a Property Descriptor");return $_(t)},I_=X,xp=mn,C_=Bi,R_=function(t){if(typeof t>"u")return!1;if(!C_(t))throw new I_("Assertion failed: `Desc` must be a Property Descriptor");return!(!xp(t,"[[Value]]")&&!xp(t,"[[Writable]]"))},Ep=vh,P_=function(t,e){return t===e?t===0?1/t===1/e:!0:Ep(t)&&Ep(e)},ji=mm,D_=function(t){return!!t},Dt=mn,Jo=X,L_=gn,Ap=ji,wc=D_,z_=function(t){if(!L_(t))throw new Jo("ToPropertyDescriptor requires an object");var e={};if(Dt(t,"enumerable")&&(e["[[Enumerable]]"]=wc(t.enumerable)),Dt(t,"configurable")&&(e["[[Configurable]]"]=wc(t.configurable)),Dt(t,"value")&&(e["[[Value]]"]=t.value),Dt(t,"writable")&&(e["[[Writable]]"]=wc(t.writable)),Dt(t,"get")){var r=t.get;if(typeof r<"u"&&!Ap(r))throw new Jo("getter must be a function");e["[[Get]]"]=r}if(Dt(t,"set")){var i=t.set;if(typeof i<"u"&&!Ap(i))throw new Jo("setter must be a function");e["[[Set]]"]=i}if((Dt(e,"[[Get]]")||Dt(e,"[[Set]]"))&&(Dt(e,"[[Value]]")||Dt(e,"[[Writable]]")))throw new Jo("Invalid property descriptor. Cannot both specify accessors and a value or writable attribute");return e},Sc=X,O_=gn,$p=Bi,M_=_h,N_=T_,U_=R_,F_=Vi,H_=P_,W_=z_,Do=function(t,e,r){if(!O_(t))throw new Sc("Assertion failed: Type(O) is not Object");if(!F_(e))throw new Sc("Assertion failed: P is not a Property Key");var i=$p(r)?r:W_(r);if(!$p(i))throw new Sc("Assertion failed: Desc is not a valid Property Descriptor");return M_(U_,H_,N_,t,e,i)},Z_=Zi(),B_=Z_?Symbol.dispose||Symbol("Symbol.dispose"):null,V_=Zi,j_=B_,Eh=function(){return V_()&&Symbol.dispose||j_},G_=yh,q_=Do,Y_=Eh,X_=function(){var t=Y_();return G_()&&q_(Symbol,"dispose",{"[[Configurable]]":!1,"[[Enumerable]]":!1,"[[Writable]]":!1,"[[Value]]":t}),t},K_=Zi(),J_=K_?Symbol.asyncDispose||Symbol("Symbol.asyncDispose"):null,Q_=Zi,ek=J_,Ah=function(){return Q_()&&Symbol.asyncDispose||ek},tk=yh,nk=Do,rk=Ah,ik=function(){var t=rk();return tk()&&nk(Symbol,"asyncDispose",{"[[Configurable]]":!1,"[[Enumerable]]":!1,"[[Writable]]":!1,"[[Value]]":t}),t},sk=Sh(),ok=bt,ak=Bn(),lk=X,ck=sk,uk=ok("%Reflect.apply%",!0)||ak("Function.prototype.apply"),$l=function(t,e){var r=arguments.length>2?arguments[2]:[];if(!ck(r))throw new lk("Assertion failed: optional `argumentsList`, if provided, must be a List");return uk(t,e,r)};const hk={},dk=Object.freeze(Object.defineProperty({__proto__:null,default:hk},Symbol.toStringTag,{value:"Module"})),pk=Uw(dk);var $h=typeof Map=="function"&&Map.prototype,_c=Object.getOwnPropertyDescriptor&&$h?Object.getOwnPropertyDescriptor(Map.prototype,"size"):null,Va=$h&&_c&&typeof _c.get=="function"?_c.get:null,Tp=$h&&Map.prototype.forEach,Th=typeof Set=="function"&&Set.prototype,kc=Object.getOwnPropertyDescriptor&&Th?Object.getOwnPropertyDescriptor(Set.prototype,"size"):null,ja=Th&&kc&&typeof kc.get=="function"?kc.get:null,Ip=Th&&Set.prototype.forEach,fk=typeof WeakMap=="function"&&WeakMap.prototype,xs=fk?WeakMap.prototype.has:null,gk=typeof WeakSet=="function"&&WeakSet.prototype,Es=gk?WeakSet.prototype.has:null,mk=typeof WeakRef=="function"&&WeakRef.prototype,Cp=mk?WeakRef.prototype.deref:null,vk=Boolean.prototype.valueOf,yk=Object.prototype.toString,bk=Function.prototype.toString,wk=String.prototype.match,Ih=String.prototype.slice,On=String.prototype.replace,Sk=String.prototype.toUpperCase,Rp=String.prototype.toLowerCase,wm=RegExp.prototype.test,Pp=Array.prototype.concat,jt=Array.prototype.join,_k=Array.prototype.slice,Dp=Math.floor,au=typeof BigInt=="function"?BigInt.prototype.valueOf:null,xc=Object.getOwnPropertySymbols,lu=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?Symbol.prototype.toString:null,Mi=typeof Symbol=="function"&&typeof Symbol.iterator=="object",As=typeof Symbol=="function"&&Symbol.toStringTag&&(typeof Symbol.toStringTag===Mi||!0)?Symbol.toStringTag:null,Sm=Object.prototype.propertyIsEnumerable,Lp=(typeof Reflect=="function"?Reflect.getPrototypeOf:Object.getPrototypeOf)||([].__proto__===Array.prototype?function(n){return n.__proto__}:null);function zp(n,t){if(n===1/0||n===-1/0||n!==n||n&&n>-1e3&&n<1e3||wm.call(/e/,t))return t;var e=/[0-9](?=(?:[0-9]{3})+(?![0-9]))/g;if(typeof n=="number"){var r=n<0?-Dp(-n):Dp(n);if(r!==n){var i=String(r),s=Ih.call(t,i.length+1);return On.call(i,e,"$&_")+"."+On.call(On.call(s,/([0-9]{3})/g,"$&_"),/_$/,"")}}return On.call(t,e,"$&_")}var cu=pk,Op=cu.custom,Mp=xm(Op)?Op:null,_m={__proto__:null,double:'"',single:"'"},kk={__proto__:null,double:/(["\\])/g,single:/(['\\])/g},Gi=function n(t,e,r,i){var s=e||{};if(nn(s,"quoteStyle")&&!nn(_m,s.quoteStyle))throw new TypeError('option "quoteStyle" must be "single" or "double"');if(nn(s,"maxStringLength")&&(typeof s.maxStringLength=="number"?s.maxStringLength<0&&s.maxStringLength!==1/0:s.maxStringLength!==null))throw new TypeError('option "maxStringLength", if provided, must be a positive integer, Infinity, or `null`');var o=nn(s,"customInspect")?s.customInspect:!0;if(typeof o!="boolean"&&o!=="symbol")throw new TypeError("option \"customInspect\", if provided, must be `true`, `false`, or `'symbol'`");if(nn(s,"indent")&&s.indent!==null&&s.indent!==" "&&!(parseInt(s.indent,10)===s.indent&&s.indent>0))throw new TypeError('option "indent" must be "\\t", an integer > 0, or `null`');if(nn(s,"numericSeparator")&&typeof s.numericSeparator!="boolean")throw new TypeError('option "numericSeparator", if provided, must be `true` or `false`');var a=s.numericSeparator;if(typeof t>"u")return"undefined";if(t===null)return"null";if(typeof t=="boolean")return t?"true":"false";if(typeof t=="string")return Am(t,s);if(typeof t=="number"){if(t===0)return 1/0/t>0?"0":"-0";var c=String(t);return a?zp(t,c):c}if(typeof t=="bigint"){var u=String(t)+"n";return a?zp(t,u):u}var h=typeof s.depth>"u"?5:s.depth;if(typeof r>"u"&&(r=0),r>=h&&h>0&&typeof t=="object")return uu(t)?"[Array]":"[Object]";var p=Hk(s,r);if(typeof i>"u")i=[];else if(Em(i,t)>=0)return"[Circular]";function v(It,yn,Gl){if(yn&&(i=_k.call(i),i.push(yn)),Gl){var Wo={depth:s.depth};return nn(s,"quoteStyle")&&(Wo.quoteStyle=s.quoteStyle),n(It,Wo,r+1,i)}return n(It,s,r+1,i)}if(typeof t=="function"&&!Np(t)){var g=Pk(t),_=Qo(t,v);return"[Function"+(g?": "+g:" (anonymous)")+"]"+(_.length>0?" { "+jt.call(_,", ")+" }":"")}if(xm(t)){var k=Mi?On.call(String(t),/^(Symbol\(.*\))_[^)]*$/,"$1"):lu.call(t);return typeof t=="object"&&!Mi?is(k):k}if(Nk(t)){for(var T="<"+Rp.call(String(t.nodeName)),P=t.attributes||[],R=0;R<P.length;R++)T+=" "+P[R].name+"="+km(xk(P[R].value),"double",s);return T+=">",t.childNodes&&t.childNodes.length&&(T+="..."),T+="</"+Rp.call(String(t.nodeName))+">",T}if(uu(t)){if(t.length===0)return"[]";var W=Qo(t,v);return p&&!Fk(W)?"["+hu(W,p)+"]":"[ "+jt.call(W,", ")+" ]"}if(Ak(t)){var N=Qo(t,v);return!("cause"in Error.prototype)&&"cause"in t&&!Sm.call(t,"cause")?"{ ["+String(t)+"] "+jt.call(Pp.call("[cause]: "+v(t.cause),N),", ")+" }":N.length===0?"["+String(t)+"]":"{ ["+String(t)+"] "+jt.call(N,", ")+" }"}if(typeof t=="object"&&o){if(Mp&&typeof t[Mp]=="function"&&cu)return cu(t,{depth:h-r});if(o!=="symbol"&&typeof t.inspect=="function")return t.inspect()}if(Dk(t)){var F=[];return Tp&&Tp.call(t,function(It,yn){F.push(v(yn,t,!0)+" => "+v(It,t))}),Up("Map",Va.call(t),F,p)}if(Ok(t)){var Y=[];return Ip&&Ip.call(t,function(It){Y.push(v(It,t))}),Up("Set",ja.call(t),Y,p)}if(Lk(t))return Ec("WeakMap");if(Mk(t))return Ec("WeakSet");if(zk(t))return Ec("WeakRef");if(Tk(t))return is(v(Number(t)));if(Ck(t))return is(v(au.call(t)));if(Ik(t))return is(vk.call(t));if($k(t))return is(v(String(t)));if(typeof window<"u"&&t===window)return"{ [object Window] }";if(typeof globalThis<"u"&&t===globalThis||typeof ir<"u"&&t===ir)return"{ [object globalThis] }";if(!Ek(t)&&!Np(t)){var j=Qo(t,v),le=Lp?Lp(t)===Object.prototype:t instanceof Object||t.constructor===Object,St=t instanceof Object?"":"null prototype",qn=!le&&As&&Object(t)===t&&As in t?Ih.call(Vn(t),8,-1):St?"Object":"",Pe=le||typeof t.constructor!="function"?"":t.constructor.name?t.constructor.name+" ":"",Yn=Pe+(qn||St?"["+jt.call(Pp.call([],qn||[],St||[]),": ")+"] ":"");return j.length===0?Yn+"{}":p?Yn+"{"+hu(j,p)+"}":Yn+"{ "+jt.call(j,", ")+" }"}return String(t)};function km(n,t,e){var r=e.quoteStyle||t,i=_m[r];return i+n+i}function xk(n){return On.call(String(n),/"/g,""")}function Hr(n){return!As||!(typeof n=="object"&&(As in n||typeof n[As]<"u"))}function uu(n){return Vn(n)==="[object Array]"&&Hr(n)}function Ek(n){return Vn(n)==="[object Date]"&&Hr(n)}function Np(n){return Vn(n)==="[object RegExp]"&&Hr(n)}function Ak(n){return Vn(n)==="[object Error]"&&Hr(n)}function $k(n){return Vn(n)==="[object String]"&&Hr(n)}function Tk(n){return Vn(n)==="[object Number]"&&Hr(n)}function Ik(n){return Vn(n)==="[object Boolean]"&&Hr(n)}function xm(n){if(Mi)return n&&typeof n=="object"&&n instanceof Symbol;if(typeof n=="symbol")return!0;if(!n||typeof n!="object"||!lu)return!1;try{return lu.call(n),!0}catch{}return!1}function Ck(n){if(!n||typeof n!="object"||!au)return!1;try{return au.call(n),!0}catch{}return!1}var Rk=Object.prototype.hasOwnProperty||function(n){return n in this};function nn(n,t){return Rk.call(n,t)}function Vn(n){return yk.call(n)}function Pk(n){if(n.name)return n.name;var t=wk.call(bk.call(n),/^function\s*([\w$]+)/);return t?t[1]:null}function Em(n,t){if(n.indexOf)return n.indexOf(t);for(var e=0,r=n.length;e<r;e++)if(n[e]===t)return e;return-1}function Dk(n){if(!Va||!n||typeof n!="object")return!1;try{Va.call(n);try{ja.call(n)}catch{return!0}return n instanceof Map}catch{}return!1}function Lk(n){if(!xs||!n||typeof n!="object")return!1;try{xs.call(n,xs);try{Es.call(n,Es)}catch{return!0}return n instanceof WeakMap}catch{}return!1}function zk(n){if(!Cp||!n||typeof n!="object")return!1;try{return Cp.call(n),!0}catch{}return!1}function Ok(n){if(!ja||!n||typeof n!="object")return!1;try{ja.call(n);try{Va.call(n)}catch{return!0}return n instanceof Set}catch{}return!1}function Mk(n){if(!Es||!n||typeof n!="object")return!1;try{Es.call(n,Es);try{xs.call(n,xs)}catch{return!0}return n instanceof WeakSet}catch{}return!1}function Nk(n){return!n||typeof n!="object"?!1:typeof HTMLElement<"u"&&n instanceof HTMLElement?!0:typeof n.nodeName=="string"&&typeof n.getAttribute=="function"}function Am(n,t){if(n.length>t.maxStringLength){var e=n.length-t.maxStringLength,r="... "+e+" more character"+(e>1?"s":"");return Am(Ih.call(n,0,t.maxStringLength),t)+r}var i=kk[t.quoteStyle||"single"];i.lastIndex=0;var s=On.call(On.call(n,i,"\\$1"),/[\x00-\x1f]/g,Uk);return km(s,"single",t)}function Uk(n){var t=n.charCodeAt(0),e={8:"b",9:"t",10:"n",12:"f",13:"r"}[t];return e?"\\"+e:"\\x"+(t<16?"0":"")+Sk.call(t.toString(16))}function is(n){return"Object("+n+")"}function Ec(n){return n+" { ? }"}function Up(n,t,e,r){var i=r?hu(e,r):jt.call(e,", ");return n+" ("+t+") {"+i+"}"}function Fk(n){for(var t=0;t<n.length;t++)if(Em(n[t],`
|
|
2
|
+
`)>=0)return!1;return!0}function Hk(n,t){var e;if(n.indent===" ")e=" ";else if(typeof n.indent=="number"&&n.indent>0)e=jt.call(Array(n.indent+1)," ");else return null;return{base:e,prev:jt.call(Array(t+1),e)}}function hu(n,t){if(n.length===0)return"";var e=`
|
|
3
|
+
`+t.prev+t.base;return e+jt.call(n,","+e)+`
|
|
4
|
+
`+t.prev}function Qo(n,t){var e=uu(n),r=[];if(e){r.length=n.length;for(var i=0;i<n.length;i++)r[i]=nn(n,i)?t(n[i],n):""}var s=typeof xc=="function"?xc(n):[],o;if(Mi){o={};for(var a=0;a<s.length;a++)o["$"+s[a]]=s[a]}for(var c in n)nn(n,c)&&(e&&String(Number(c))===c&&c<n.length||Mi&&o["$"+c]instanceof Symbol||(wm.call(/[^\w$]/,c)?r.push(t(c,n)+": "+t(n[c],n)):r.push(c+": "+t(n[c],n))));if(typeof xc=="function")for(var u=0;u<s.length;u++)Sm.call(n,s[u])&&r.push("["+t(s[u])+"]: "+t(n[s[u]],n));return r}var Wk=Gi,Zk=X,Tl=function(n,t,e){for(var r=n,i;(i=r.next)!=null;r=i)if(i.key===t)return r.next=i.next,e||(i.next=n.next,n.next=i),i},Bk=function(n,t){if(n){var e=Tl(n,t);return e&&e.value}},Vk=function(n,t,e){var r=Tl(n,t);r?r.value=e:n.next={key:t,next:n.next,value:e}},jk=function(n,t){return n?!!Tl(n,t):!1},Gk=function(n,t){if(n)return Tl(n,t,!0)},qk=function(){var t,e={assert:function(r){if(!e.has(r))throw new Zk("Side channel does not contain "+Wk(r))},delete:function(r){var i=Gk(t,r);return i&&t&&!t.next&&(t=void 0),!!i},get:function(r){return Bk(t,r)},has:function(r){return jk(t,r)},set:function(r,i){t||(t={next:void 0}),Vk(t,r,i)}};return e},Yk=bt,Lo=Bn(),Xk=Gi,Kk=X,Fp=Yk("%Map%",!0),Jk=Lo("Map.prototype.get",!0),Qk=Lo("Map.prototype.set",!0),ex=Lo("Map.prototype.has",!0),tx=Lo("Map.prototype.delete",!0),nx=Lo("Map.prototype.size",!0),$m=!!Fp&&function(){var t,e={assert:function(r){if(!e.has(r))throw new Kk("Side channel does not contain "+Xk(r))},delete:function(r){if(t){var i=tx(t,r);return nx(t)===0&&(t=void 0),i}return!1},get:function(r){if(t)return Jk(t,r)},has:function(r){return t?ex(t,r):!1},set:function(r,i){t||(t=new Fp),Qk(t,r,i)}};return e},rx=bt,Il=Bn(),ix=Gi,ea=$m,sx=X,Jr=rx("%WeakMap%",!0),ox=Il("WeakMap.prototype.get",!0),ax=Il("WeakMap.prototype.set",!0),lx=Il("WeakMap.prototype.has",!0),cx=Il("WeakMap.prototype.delete",!0),ux=Jr?function(){var t,e,r={assert:function(i){if(!r.has(i))throw new sx("Side channel does not contain "+ix(i))},delete:function(i){if(Jr&&i&&(typeof i=="object"||typeof i=="function")){if(t)return cx(t,i)}else if(ea&&e)return e.delete(i);return!1},get:function(i){return Jr&&i&&(typeof i=="object"||typeof i=="function")&&t?ox(t,i):e&&e.get(i)},has:function(i){return Jr&&i&&(typeof i=="object"||typeof i=="function")&&t?lx(t,i):!!e&&e.has(i)},set:function(i,s){Jr&&i&&(typeof i=="object"||typeof i=="function")?(t||(t=new Jr),ax(t,i,s)):ea&&(e||(e=ea()),e.set(i,s))}};return r}:ea,hx=X,dx=Gi,px=qk,fx=$m,gx=ux,mx=gx||fx||px,vx=function(){var t,e={assert:function(r){if(!e.has(r))throw new hx("Side channel does not contain "+dx(r))},delete:function(r){return!!t&&t.delete(r)},get:function(r){return t&&t.get(r)},has:function(r){return!!t&&t.has(r)},set:function(r,i){t||(t=mx()),t.set(r,i)}};return e},yx=mn,ss=vx(),Jt=X,Ch={assert:function(n,t){if(!n||typeof n!="object"&&typeof n!="function")throw new Jt("`O` is not an object");if(typeof t!="string")throw new Jt("`slot` must be a string");if(ss.assert(n),!Ch.has(n,t))throw new Jt("`"+t+"` is not present on `O`")},get:function(n,t){if(!n||typeof n!="object"&&typeof n!="function")throw new Jt("`O` is not an object");if(typeof t!="string")throw new Jt("`slot` must be a string");var e=ss.get(n);return e&&e["$"+t]},has:function(n,t){if(!n||typeof n!="object"&&typeof n!="function")throw new Jt("`O` is not an object");if(typeof t!="string")throw new Jt("`slot` must be a string");var e=ss.get(n);return!!e&&yx(e,"$"+t)},set:function(n,t,e){if(!n||typeof n!="object"&&typeof n!="function")throw new Jt("`O` is not an object");if(typeof t!="string")throw new Jt("`slot` must be a string");var r=ss.get(n);r||(r={},ss.set(n,r)),r["$"+t]=e}};Object.freeze&&Object.freeze(Ch);var Rh=Ch,Tm=fn,Nn=Rh,zo=function n(t,e){if(!(this instanceof n))return new n(t,e);if(t!=="normal"&&t!=="break"&&t!=="continue"&&t!=="return"&&t!=="throw")throw new Tm('Assertion failed: `type` must be one of "normal", "break", "continue", "return", or "throw"');Nn.set(this,"[[Type]]",t),Nn.set(this,"[[Value]]",e)};zo.prototype.type=function(){return Nn.get(this,"[[Type]]")};zo.prototype.value=function(){return Nn.get(this,"[[Value]]")};zo.prototype["?"]=function(){var t=Nn.get(this,"[[Type]]"),e=Nn.get(this,"[[Value]]");if(t==="throw")throw e;return e};zo.prototype["!"]=function(){var t=Nn.get(this,"[[Type]]");if(t!=="normal")throw new Tm('Assertion failed: Completion Record is not of type "normal"');return Nn.get(this,"[[Value]]")};var Ph=zo,bx=Ph,Dh=function(t){return new bx("normal",t)},Ac,Hp;function wx(){if(Hp)return Ac;Hp=1;var n=Zi;return Ac=function(){return n()&&!!Symbol.toStringTag},Ac}var Sx=bt,Wp=Sx("%Object.defineProperty%",!0),_x=wx()(),kx=mn,xx=X,ta=_x?Symbol.toStringTag:null,Im=function(t,e){var r=arguments.length>2&&!!arguments[2]&&arguments[2].force,i=arguments.length>2&&!!arguments[2]&&arguments[2].nonConfigurable;if(typeof r<"u"&&typeof r!="boolean"||typeof i<"u"&&typeof i!="boolean")throw new xx("if provided, the `overrideIfSet` and `nonConfigurable` options must be booleans");ta&&(r||!kx(t,ta))&&(Wp?Wp(t,ta,{configurable:!i,enumerable:!1,value:e,writable:!1}):t[ta]=e)},Cm={exports:{}},Ex=bt,Zp=Yg,Ax=El(),Bp=Wi,Vp=X,$x=Ex("%Math.floor%"),Tx=function(t,e){if(typeof t!="function")throw new Vp("`fn` is not a function");if(typeof e!="number"||e<0||e>4294967295||$x(e)!==e)throw new Vp("`length` must be a positive 32-bit integer");var r=arguments.length>2&&!!arguments[2],i=!0,s=!0;if("length"in t&&Bp){var o=Bp(t,"length");o&&!o.configurable&&(i=!1),o&&!o.writable&&(s=!1)}return(i||s||!r)&&(Ax?Zp(t,"length",e,!0,!0):Zp(t,"length",e)),t},Ix=Io,Cx=wh,Rx=om,Px=function(){return Rx(Ix,Cx,arguments)};(function(n){var t=Tx,e=To,r=Al,i=Px;n.exports=function(o){var a=r(arguments),c=1+o.length-(arguments.length-1);return t(a,c>0?c:0,!0)},e?e(n.exports,"apply",{value:i}):n.exports.apply=i})(Cm);var Lh=Cm.exports,Dx=function(t,e){for(var r=0;r<t.length;r+=1)if(!e(t[r],r,t))return!1;return!0},Lx=Object,zx=function(t){return t&&typeof t=="object"&&(typeof t["[[ResourceValue]]"]>"u"||Lx(t["[[ResourceValue]]"])===t["[[ResourceValue]]"])&&(t["[[Hint]]"]==="SYNC-DISPOSE"||t["[[Hint]]"]==="ASYNC-DISPOSE")&&(typeof t["[[DisposeMethod]]"]=="function"||typeof t["[[DisposeMethod]]"]>"u")},Ox=mn,Mx=Sh(),Nx=Dx,Ux=zx,Fx=function(t){return t&&typeof t=="object"&&Ox(t,"[[DisposableResourceStack]]")&&Mx(t["[[DisposableResourceStack]]"])&&(t["[[DisposableResourceStack]]"].length===0||Nx(t["[[DisposableResourceStack]]"],Ux))},Hx=gn,Wx=function(t){if(t===null)return"Null";if(typeof t>"u")return"Undefined";if(Hx(t))return"Object";if(typeof t=="number")return"Number";if(typeof t=="boolean")return"Boolean";if(typeof t=="string")return"String"},Zx=Wx,zh=function(t){return typeof t=="symbol"?"Symbol":typeof t=="bigint"?"BigInt":Zx(t)},Bx=X,Vx=Gi,jx=Vi,Gx=function(t,e){if(!jx(e))throw new Bx("Assertion failed: P is not a Property Key, got "+Vx(e));return t[e]},jp=X,qx=Gx,Yx=ji,Xx=Vi,Gp=Gi,Kx=function(t,e){if(!Xx(e))throw new jp("Assertion failed: P is not a Property Key");var r=qx(t,e);if(r!=null){if(!Yx(r))throw new jp(Gp(e)+" is not a function: "+Gp(r));return r}},du={exports:{}},Jx=bt,Qx=Jx,qp=Qx("%Reflect.construct%",!0),Ga=Do;try{Ga({},"",{"[[Get]]":function(){}})}catch{Ga=null}if(Ga&&qp){var Yp={},Xp={};Ga(Xp,"length",{"[[Get]]":function(){throw Yp},"[[Enumerable]]":!0}),du.exports=function(t){try{qp(t,Xp)}catch(e){return e===Yp}}}else du.exports=function(t){return typeof t=="function"&&!!t.prototype};var eE=du.exports,$c=X,Kp=ji,tE=eE,nE=function(t){if(!tE(t))throw new $c("C must be a constructor");var e={"[[Resolve]]":void 0,"[[Reject]]":void 0},r=new t(function(i,s){if(typeof e["[[Resolve]]"]<"u"||typeof e["[[Reject]]"]<"u")throw new $c("executor has already been called");e["[[Resolve]]"]=i,e["[[Reject]]"]=s});if(!Kp(e["[[Resolve]]"])||!Kp(e["[[Reject]]"]))throw new $c("executor must provide valid resolve and reject functions");return{"[[Promise]]":r,"[[Resolve]]":e["[[Resolve]]"],"[[Reject]]":e["[[Reject]]"]}},Jp=fn,rE=X,Tc=$l,Qp=Kx,iE=nE,sE=zh,ef=Eh(),tf=Ah(),oE=function(t,e){if(sE(t)!=="Object")throw new rE("`V` must be an Object");if(e!=="SYNC-DISPOSE"&&e!=="ASYNC-DISPOSE")throw new Jp("Assertion failed: `hint` must be `~SYNC-DISPOSE~` or `~ASYNC-DISPOSE~`");var r;if(e==="ASYNC-DISPOSE"&&tf&&(r=Qp(t,tf)),!r){if(!ef)throw new Jp("`Symbol.dispose` is not supported");if(r=Qp(t,ef),typeof r<"u")return function(){var i=this;if(e==="ASYNC-DISPOSE"){var s=iE(Promise);try{Tc(r,i),Tc(s["[[Resolve]]"],void 0,[void 0])}catch(o){s["[[Reject]]"](o)}return s["[[Promise]]"]}Tc(r,i)}}return r},aE=fn,Ic=X,lE=ji,cE=zh,uE=oE,hE=function(t,e){if(e!=="SYNC-DISPOSE"&&e!=="ASYNC-DISPOSE")throw new aE("Assertion failed: `hint` must be `~SYNC-DISPOSE~` or `~ASYNC-DISPOSE~`");var r;if(arguments.length<3)if(t==null)t=void 0,r=void 0;else{if(typeof t<"u"&&cE(t)!=="Object")throw new Ic("`V` must be an Object, or `null` or `undefined`");if(r=uE(t,e),typeof r>"u")throw new Ic("dispose method must not be `undefined` on `V` when an object `V` is provided")}else if(r=arguments[2],!lE(r))throw new Ic("`method`, when provided, must be a function");return{"[[ResourceValue]]":t,"[[Hint]]":e,"[[DisposeMethod]]":r}},dE=fn,na=X,pE=Fx,nf=hE,fE=Bn(),gE=fE("Array.prototype.push"),Rm=function(t,e,r){if(!pE(t))throw new na("Assertion failed: `disposeCapability` must be a DisposeCapability Record");if(r!=="SYNC-DISPOSE"&&r!=="ASYNC-DISPOSE")throw new dE("Assertion failed: `hint` must be `~SYNC-DISPOSE~` or `~ASYNC-DISPOSE~`");var i=arguments.length>3?arguments[3]:void 0;if(arguments.length>3&&typeof i!="function")throw new na("Assertion failed: `method`, when present, must be a function");if(!t["[[DisposableResourceStack]]"])throw new na("Assertion failed: `disposeCapability.[[DisposableResourceStack]]` must not be ~EMPTY~");var s;if(arguments.length<4){if(e==null&&r==="SYNC_DISPOSE")return"UNUSED";s=nf(e,r)}else{if(typeof e<"u")throw new na("Assertion failed: `V` must be undefined when `method` is present");s=nf(void 0,r,i)}return gE(t["[[DisposableResourceStack]]"],s),"UNUSED"},Cc,rf;function Oh(){if(rf)return Cc;rf=1;var n=bt,t=Lh,e=fn,r=n("%Promise.resolve%",!0),i=r&&t(r);return Cc=function(o,a){if(!i)throw new e("This environment does not support Promises.");return i(o,a)},Cc}var Rc,sf;function mE(){if(sf)return Rc;sf=1;var n=bt,t=fn,e=n("%Promise%",!0),r=$l,i=Oh(),s=zh;return Rc=function(a,c,u){if(typeof a<"u"&&s(a)!=="Object")throw new t("Assertion failed: `V` must be `undefined` or an Object");if(c!=="SYNC-DISPOSE"&&c!=="ASYNC-DISPOSE")throw new t("Assertion failed: `hint` must be `~SYNC-DISPOSE~` or `~ASYNC-DISPOSE~`");if(typeof u<"u"&&typeof u!="function")throw new t("Assertion failed: `method` must be `undefined` or a function");var h=typeof u>"u"?u:r(u,a);if(c==="ASYNC-DISPOSE")return i(e,h)},Rc}var Pc,of;function vE(){if(of)return Pc;of=1;var n=Ph;return Pc=function(e){return new n("throw",e)},Pc}var yE=bt,Dc=fn,af=X,bE=yE("%Promise%",!0),wE=Bn(),lf=wE("Promise.prototype.then",!0),SE=Ph,cf=mE(),_E=Dh,kE=Oh(),uf=vE(),xE=bm(),Pm=function(t,e){if(!(e instanceof SE))throw new af("`completion` must be a Completion Record");var r=t["[[DisposableResourceStack]]"];if(!r)throw new af("Assertion failed: `disposeCapability.[[DisposableResourceStack]]` must not be ~EMPTY~");for(var i,s=r.length-1;s>=0;s-=1)if(!i)i=r[s]["[[Hint]]"];else if(i!==r[s]["[[Hint]]"])throw new Dc("mixed hint stacks are not supported");for(var o=i==="ASYNC-DISPOSE"&&kE(bE,e),a=function(v){if(e.type()==="throw"){var g=e.value(),_=new xE(v,g);e=uf(_)}else e=uf(v)},c=i==="ASYNC-DISPOSE"&&function(g){return lf(o,function(){var _=cf(g["[[ResourceValue]]"],g["[[Hint]]"],g["[[DisposeMethod]]"]);if(!_)throw new Dc("Assertion failed: non-`~ASYNC-DISPOSE~` resource returned a promise from Dispose");return lf(_,_E)},a)},u=r.length-1;u>=0;u-=1)if(i==="ASYNC-DISPOSE")o=c(r[u]);else{var h=r[u];try{var p=cf(h["[[ResourceValue]]"],h["[[Hint]]"],h["[[DisposeMethod]]"]);if(p)throw new Dc("Assertion failed: `~SYNC-DISPOSE~` resource returned something from Dispose")}catch(v){a(v)}}return t["[[DisposableResourceStack]]"]=null,i==="ASYNC-DISPOSE"?o:e},Dm=function(){var t=[];return{"[[DisposableResourceStack]]":t}},Cl=mh,Mh=X,EE=$l,qi=kh,AE=Do,Lm=ji,$E=Dh,nt=Rh,TE=Im,zm=Fr.supportsDescriptors,IE=Lh,Nh=Rm,CE=Pm,Om=Dm,hf=Eh(),ft=function n(){if(!(this instanceof n)||nt.has(this,"[[DisposableState]]")||nt.has(this,"[[DisposeCapability]]"))throw new Mh("can only be used with new");nt.set(this,"[[DisposableState]]","PENDING"),nt.set(this,"[[DisposeCapability]]",Om())},Mm=function(){var t=this;return nt.assert(t,"[[DisposableState]]"),nt.get(t,"[[DisposableState]]")==="DISPOSED"},Oo=IE(Mm);zm?AE(ft.prototype,"disposed",{"[[Configurable]]":!0,"[[Enumerable]]":!1,"[[Get]]":Mm}):ft.prototype.disposed=!1;var Nm=function(t){nt.set(t,"[[DisposableState]]","DISPOSED"),zm||(t.disposed=!0)};qi(ft.prototype,"dispose",function(){var t=this;if(!Oo(t))return Nm(t),CE(nt.get(t,"[[DisposeCapability]]"),$E())["?"]()});qi(ft.prototype,"use",function(t){var e=this;if(Oo(e))throw new Cl("a disposed stack can not use anything new");return Nh(nt.get(e,"[[DisposeCapability]]"),t,"SYNC-DISPOSE"),t});qi(ft.prototype,"adopt",function(t,e){var r=this;if(Oo(r))throw new Cl("a disposed stack can not use anything new");if(!Lm(e))throw new Mh("`onDispose` must be a function");var i=function(){return EE(e,void 0,[t])};return Nh(nt.get(r,"[[DisposeCapability]]"),void 0,"SYNC-DISPOSE",i),t});qi(ft.prototype,"defer",function(t){var e=this;if(Oo(e))throw new Cl("a disposed stack can not defer anything new");if(!Lm(t))throw new Mh("`onDispose` must be a function");Nh(nt.get(e,"[[DisposeCapability]]"),void 0,"SYNC-DISPOSE",t)});qi(ft.prototype,"move",function(){var t=this;if(Oo(t))throw new Cl("a disposed stack can not use anything new");var e=new ft;return nt.set(e,"[[DisposeCapability]]",nt.get(t,"[[DisposeCapability]]")),nt.set(t,"[[DisposeCapability]]",Om()),Nm(t),e});hf&&qi(ft.prototype,hf,ft.prototype.dispose);TE(ft.prototype,"DisposableStack");var RE=ft,PE=RE,DE=function(){return typeof DisposableStack=="function"?DisposableStack:PE},LE=Fr,zE=fh(),OE=DE,ME=function(){var t=OE();return LE(zE,{DisposableStack:t},{DisposableStack:!0}),t},NE=bt,Rl=mh,Uh=X,df=NE("%Promise%",!0),Fh=Rm,UE=$l,Yi=kh,FE=Do,HE=Pm,Um=ji,Fm=Dm,WE=Dh,pf=Oh(),rt=Rh,ZE=Im,Hm=Fr.supportsDescriptors,BE=Lh,VE=Bn(),jE=VE("Promise.prototype.then",!0),ff=Ah(),gt=function n(){if(!(this instanceof n)||rt.has(this,"[[AsyncDisposableState]]")||rt.has(this,"[[DisposeCapability]]"))throw new Uh("can only be used with new");rt.set(this,"[[AsyncDisposableState]]","pending"),rt.set(this,"[[DisposeCapability]]",Fm())},Wm=function(){var t=this;return rt.assert(t,"[[AsyncDisposableState]]"),rt.get(t,"[[AsyncDisposableState]]")==="disposed"},Mo=BE(Wm);Hm?FE(gt.prototype,"disposed",{"[[Configurable]]":!0,"[[Enumerable]]":!1,"[[Get]]":Wm}):gt.prototype.disposed=!1;var Zm=function(t){rt.set(t,"[[AsyncDisposableState]]","disposed"),Hm||(t.disposed=!0)};Yi(gt.prototype,"disposeAsync",function(){var t=this;return Mo(t)?pf(df):(Zm(t),jE(pf(df,HE(rt.get(t,"[[DisposeCapability]]"),WE())),function(e){return e["?"]()}))});Yi(gt.prototype,"use",function(t){var e=this;if(Mo(e))throw new Rl("a disposed stack can not use anything new");return Fh(rt.get(e,"[[DisposeCapability]]"),t,"ASYNC-DISPOSE"),t});Yi(gt.prototype,"adopt",function(t,e){var r=this;if(Mo(r))throw new Rl("a disposed stack can not use anything new");if(!Um(e))throw new Uh("`onDisposeAsync` must be a function");var i=function(){return UE(e,void 0,[t])};return i.value=t,Fh(rt.get(r,"[[DisposeCapability]]"),void 0,"ASYNC-DISPOSE",i),t});Yi(gt.prototype,"defer",function(t){var e=this;if(Mo(e))throw new Rl("a disposed stack can not defer anything new");if(!Um(t))throw new Uh("`onDispose` must be a function");Fh(rt.get(e,"[[DisposeCapability]]"),void 0,"ASYNC-DISPOSE",t)});Yi(gt.prototype,"move",function(){var t=this;if(Mo(t))throw new Rl("a disposed stack can not use anything new");var e=new gt;return rt.set(e,"[[DisposeCapability]]",rt.get(t,"[[DisposeCapability]]")),rt.set(t,"[[DisposeCapability]]",Fm()),Zm(t),e});ff&&Yi(gt.prototype,ff,gt.prototype.disposeAsync);ZE(gt.prototype,"AsyncDisposableStack");var GE=gt,qE=GE,YE=function(){return typeof AsyncDisposableStack=="function"?AsyncDisposableStack:qE},XE=Fr,KE=fh(),JE=YE,QE=function(){var t=JE();return XE(KE,{AsyncDisposableStack:t},{AsyncDisposableStack:!0}),t},eA=X_,tA=ik,nA=ME,rA=QE,iA=function(){eA(),tA(),nA(),rA()};iA();const gf=new WeakMap;function sA(n){return(typeof n=="object"||typeof n=="function")&&n!==null&&"then"in n&&typeof n.then=="function"}function Qr(n){return typeof n=="string"?n:typeof n=="symbol"?n.description??n.toString():n.name||"(anonymous class)"}function mf(){return new Error("register(Key, factory) requires a factory function. Wrap existing instances as () => instance.")}function oA(){return new Error("register(Key, factory) does not accept async factories. Await setup before registering.")}class aA{constructor(){m(this,"entries",new Map);m(this,"constructionStack",[])}register(t,e){if(e===void 0){if(typeof t!="function")throw mf();this.validateClassRegistration(t),this.storeFactory(t,()=>this.instantiateClass(t));return}if(typeof e!="function")throw mf();if(e.constructor.name==="AsyncFunction")throw oA();this.storeFactory(t,e)}has(t){var e;return((e=this.entries.get(t))==null?void 0:e.factory)!==void 0}resolve(t){return this.resolveAny(t)}storeFactory(t,e){const r=this.getOrCreateEntry(t);r.factory=e,r.instance=void 0,r.error=void 0}validateClassRegistration(t){const e=gf.get(t);if(e){if(t.length!==e.length)throw new Error(`${Qr(t)} cannot be registered with register(Class). @injectable(...) declared ${e.length} dependencies but constructor arity is ${t.length}. Use register(Key, () => value) instead.`);return}if(t.length!==0)throw new Error(`${Qr(t)} cannot be registered with register(Class). Undecorated classes must have zero required constructor parameters. Use register(Key, () => value) instead.`)}instantiateClass(t){const e=gf.get(t);if(!e)return new t;const r=e.map(i=>this.resolveAny(i));return new t(...r)}resolveAny(t){return this.getOrCreateEntry(t).proxy}getOrCreateEntry(t){let e=this.entries.get(t);return e||(e={key:t},e.proxy=this.createProxy(e),this.entries.set(t,e),e)}createProxy(t){return new Proxy({},{get:(e,r)=>{if(r==="then")return;const i=this.getInstance(t),s=Reflect.get(i,r,i);return typeof s=="function"?s.bind(i):s},set:(e,r,i)=>{const s=this.getInstance(t);return Reflect.set(s,r,i,s)},has:(e,r)=>{const i=this.getInstance(t);return r in i}})}getInstance(t){if(t.instance)return t.instance;if(t.error)throw t.error;if(!t.factory)throw new Error(`${Qr(t.key)} was resolved but never registered`);const e=this.constructionStack.indexOf(t.key);if(e!==-1){const r=[...this.constructionStack.slice(e),t.key].map(i=>Qr(i)).join(" -> ");throw new Error(`Circular dependency detected: ${r}`)}this.constructionStack.push(t.key);try{const r=t.factory();if(sA(r))throw new Error(`Factory for ${Qr(t.key)} returned a Promise. Await setup before registering.`);if(typeof r!="object"||r===null)throw new Error(`Factory for ${Qr(t.key)} returned a non-object value. Wrap primitives in an object.`);return t.instance=r,r}catch(r){throw t.error=r,r}finally{this.constructionStack.pop()}}}const Gt=new aA,lA=.5,vf=.1,yf=8,cA=4,Bm=3,Vm=3,uA=4,lr=255,jm=.2126,Gm=.7152,qm=.0722;async function Ym(n){const t=hA(n);if(!t)return"light";try{return await fA(n,t)>=lA?"light":"dark"}catch{return"light"}}function hA(n){if(typeof document.elementsFromPoint!="function")return null;const t=n.getBoundingClientRect(),e=t.left+t.width/2,r=t.top+t.height/2,i=document.elementsFromPoint(e,r);for(const s of i){if(!(s instanceof HTMLElement)||s===n||n.contains(s))continue;const o=window.getComputedStyle(s);if(dA(o))return s}return null}function dA(n){return n.backgroundImage&&n.backgroundImage!=="none"?!0:pA(n.backgroundColor)>0}function pA(n){if(!n)return 0;const t=n.match(/rgba?\(([^)]+)\)/);if(!t)return 0;const e=t[1].split(/[\s,/]+/).filter(Boolean);return e.length===uA?parseFloat(e[Bm]):e.length===Vm?1:0}async function fA(n,t){const e=n.getBoundingClientRect(),r=t.getBoundingClientRect(),i={x:ra((e.left-r.left)/r.width),y:ra((e.top-r.top)/r.height),width:ra(e.width/r.width),height:ra(e.height/r.height)},s=window.getComputedStyle(t),o=gA(s.backgroundImage);return o?vA({url:o,surfaceWidth:r.width,surfaceHeight:r.height,region:i}):yA(s.backgroundColor)}function gA(n){const t=n.match(/url\(\s*["']?([^"')]+)["']?\s*\)/);return t?t[1]:null}const bf=new Map;function mA(n){let t=bf.get(n);return t||(t=new Promise((e,r)=>{const i=new Image;i.crossOrigin="anonymous",i.onload=()=>e(i),i.onerror=()=>r(new Error(`Failed to load ${n}`)),i.src=n}),bf.set(n,t),t)}async function vA(n){const t=await mA(n.url),e=Math.max(yf,Math.ceil(n.surfaceWidth*vf)),r=Math.max(yf,Math.ceil(n.surfaceHeight*vf)),i=document.createElement("canvas");i.width=e,i.height=r;const s=i.getContext("2d",{willReadFrequently:!0});if(!s)return 1;const o=n.surfaceWidth/n.surfaceHeight,a=t.naturalWidth/t.naturalHeight;let c,u;a>o?(u=r,c=r*a):(c=e,u=e/a);const h=(e-c)/2,p=(r-u)/2;s.drawImage(t,h,p,c,u);const v=Math.max(0,Math.floor(n.region.x*e)),g=Math.max(0,Math.floor(n.region.y*r)),_=Math.max(1,Math.min(e-v,Math.floor(n.region.width*e))),k=Math.max(1,Math.min(r-g,Math.floor(n.region.height*r))),T=s.getImageData(v,g,_,k).data;let P=0,R=0;for(let W=0;W<T.length;W+=cA){const N=T[W]/lr,F=T[W+1]/lr,Y=T[W+2]/lr,j=T[W+Bm]/lr;P+=j*(jm*N+Gm*F+qm*Y),R+=1}return R>0?P/R:1}function yA(n){const t=n.match(/rgba?\(([^)]+)\)/);if(!t)return 1;const e=t[1].split(/[\s,/]+/).filter(Boolean).map(parseFloat);if(e.length<Vm)return 1;const r=e[0]/lr,i=e[1]/lr,s=e[2]/lr;return jm*r+Gm*i+qm*s}function ra(n){return n<0?0:n>1?1:n}const bA=["ghost","glass"],Rs=[...bA.flatMap(n=>[`button[variant="${n}"]`,`segmented-control[variant="${n}"]`]),'[material="glass"]'].join(", "),ia=new WeakSet,wf=new WeakSet;function Xm(n){if(wf.has(n))return;wf.add(n);for(const e of n.querySelectorAll(Rs))Lc(e);if(typeof MutationObserver!="function")return;new MutationObserver(e=>{for(const r of e)if(r.type==="childList")for(const i of r.addedNodes)wA(i,Lc);else r.type==="attributes"&&r.target instanceof HTMLElement&&r.target.matches(Rs)&&Lc(r.target)}).observe(n,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["variant","material"]})}function wA(n,t){if(n instanceof Element){n instanceof HTMLElement&&n.matches(Rs)&&t(n);for(const e of n.querySelectorAll(Rs))t(e)}}async function Lc(n){if(ia.has(n)||n.hasAttribute("tone"))return;ia.add(n);const t=await Ym(n);if(!n.matches(Rs)){ia.delete(n);return}if(n.hasAttribute("tone")){ia.delete(n);return}n.setAttribute("tone",t)}const SA="*,*:before,*:after{box-sizing:border-box}html,body{margin:0;padding:0;width:100%;height:100%}h1,h2,h3,h4,h5,h6,p,ul,ol,blockquote,pre,hr{margin:0}button,input,textarea,select{font:inherit;color:inherit}@font-face{font-family:Hind;src:url("+new URL("Hind-Variable-C47b_dt9.woff2",import.meta.url).href+') format("woff2-variations");font-weight:300 700;font-style:normal;font-display:swap}:root{--font-sans: "Hind", -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;--font-brand: var(--font-sans);--font-mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, monospace;--font-weight-body: 500;--text-base: 13.5px;--text-scale: 1.125;--text-sm: round(calc(var(--text-base) / var(--text-scale)), 1px);--text-lg: round(calc(var(--text-base) * var(--text-scale)), 1px);--text-xl: round(calc(var(--text-lg) * var(--text-scale)), 1px);--leading-base: 1.5;--control-height-xs: 18px;--control-height-sm: 24px;--control-height-md: 28px;--control-height-lg: 32px;--space-2: 2px;--space-4: 4px;--space-6: 6px;--space-8: 8px;--space-12: 12px;--space-16: 16px;--space-20: 20px;--space-24: 24px;--space-32: 32px;--space-48: 48px;--space-64: 64px;--radius-4: 4px;--radius-8: 8px;--radius-12: 12px;--radius-16: 16px;--radius-24: 24px;--radius-full: 9999px;--layer-chrome: 100;--layer-panel: 500;--layer-overlay: 2000;--shadow-hairline: 0 0 0 .5px var(--color-border);--shadow-control: 0 1px 1px rgb(0 0 0 / .04), 0 2px 6px rgb(0 0 0 / .06);--alpha-50: 4%;--alpha-100: 8%;--alpha-150: 11%;--alpha-200: 15%;--alpha-300: 22%;--alpha-400: 30%;--alpha-500: 40%;--alpha-600: 50%;--alpha-700: 65%;--alpha-800: 80%;--alpha-900: 90%;--alpha-950: 95%;--tint-50: color-mix(in srgb, currentColor var(--alpha-50), transparent);--tint-100: color-mix(in srgb, currentColor var(--alpha-100), transparent);--tint-150: color-mix(in srgb, currentColor var(--alpha-150), transparent);--tint-200: color-mix(in srgb, currentColor var(--alpha-200), transparent);--tint-300: color-mix(in srgb, currentColor var(--alpha-300), transparent);--tint-400: color-mix(in srgb, currentColor var(--alpha-400), transparent);--tint-500: color-mix(in srgb, currentColor var(--alpha-500), transparent);--tint-600: color-mix(in srgb, currentColor var(--alpha-600), transparent);--tint-700: color-mix(in srgb, currentColor var(--alpha-700), transparent);--tint-800: color-mix(in srgb, currentColor var(--alpha-800), transparent);--tint-900: color-mix(in srgb, currentColor var(--alpha-900), transparent);--tint-950: color-mix(in srgb, currentColor var(--alpha-950), transparent);--color-overlay-hover: color-mix(in srgb, var(--black) var(--alpha-100), transparent);--color-overlay-active: color-mix(in srgb, var(--black) var(--alpha-300), transparent);--backdrop-blur-glass: blur(20px) saturate(1.4);--black: #000000;--white: #ffffff;--neutral-50: oklch(.985 0 0);--neutral-100: oklch(.97 0 0);--neutral-200: oklch(.923 0 0);--neutral-300: oklch(.869 0 0);--neutral-350: oklch(.79 0 0);--neutral-400: oklch(.709 0 0);--neutral-500: oklch(.553 0 0);--neutral-600: oklch(.444 0 0);--neutral-700: oklch(.374 0 0);--neutral-800: oklch(.268 0 0);--neutral-900: oklch(.216 0 0);--neutral-950: oklch(.147 0 0);--red-50: oklch(.969 .015 12.422);--red-100: oklch(.941 .03 12.58);--red-200: oklch(.892 .058 10.001);--red-300: oklch(.81 .117 11.638);--red-400: oklch(.712 .194 13.428);--red-500: oklch(.645 .246 16.439);--red-600: oklch(.586 .253 17.585);--red-700: oklch(.514 .222 16.935);--red-800: oklch(.455 .188 13.697);--red-900: oklch(.41 .159 10.272);--red-950: oklch(.271 .105 12.094);--orange-50: oklch(.98 .016 73.684);--orange-100: oklch(.954 .038 75.164);--orange-200: oklch(.901 .076 70.697);--orange-300: oklch(.837 .128 66.29);--orange-400: oklch(.75 .183 55.934);--orange-500: oklch(.705 .213 47.604);--orange-600: oklch(.646 .222 41.116);--orange-700: oklch(.553 .195 38.402);--orange-800: oklch(.47 .157 37.304);--orange-900: oklch(.408 .123 38.172);--orange-950: oklch(.266 .079 36.259);--yellow-50: oklch(.987 .026 102.212);--yellow-100: oklch(.973 .071 103.193);--yellow-200: oklch(.945 .129 101.54);--yellow-300: oklch(.905 .182 98.111);--yellow-400: oklch(.852 .199 91.936);--yellow-500: oklch(.795 .184 86.047);--yellow-600: oklch(.681 .162 75.834);--yellow-700: oklch(.554 .135 66.442);--yellow-800: oklch(.476 .114 61.907);--yellow-900: oklch(.421 .095 57.708);--yellow-950: oklch(.286 .066 53.813);--green-50: oklch(.979 .021 166.113);--green-100: oklch(.95 .052 163.051);--green-200: oklch(.905 .093 164.15);--green-300: oklch(.845 .143 164.978);--green-400: oklch(.765 .177 163.223);--green-500: oklch(.696 .17 162.48);--green-600: oklch(.596 .145 163.225);--green-700: oklch(.508 .118 165.612);--green-800: oklch(.432 .095 166.913);--green-900: oklch(.378 .077 168.94);--green-950: oklch(.262 .051 172.552);--blue-50: oklch(.97 .014 254.604);--blue-100: oklch(.932 .032 255.585);--blue-200: oklch(.882 .059 254.128);--blue-300: oklch(.809 .105 251.813);--blue-400: oklch(.707 .165 254.624);--blue-500: oklch(.623 .214 259.815);--blue-600: oklch(.546 .245 262.881);--blue-700: oklch(.488 .243 264.376);--blue-800: oklch(.424 .199 265.638);--blue-900: oklch(.379 .146 265.522);--blue-950: oklch(.282 .091 267.935);--purple-50: oklch(.969 .016 293.756);--purple-100: oklch(.943 .029 294.588);--purple-200: oklch(.894 .057 293.283);--purple-300: oklch(.811 .111 293.571);--purple-400: oklch(.702 .183 293.541);--purple-500: oklch(.606 .25 292.717);--purple-600: oklch(.541 .281 293.009);--purple-700: oklch(.491 .27 292.581);--purple-800: oklch(.432 .232 292.759);--purple-900: oklch(.38 .189 293.745);--purple-950: oklch(.283 .141 291.089)}@supports (corner-shape: squircle){:root{--radius-8: 10px;--radius-12: 15px;--radius-16: 20px;--radius-24: 30px}}:root[data-font=system]{--font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif}:root{--color-bg: var(--neutral-50);--color-bg-muted: var(--neutral-100);--color-surface: var(--white);--color-surface-muted: var(--neutral-100);--color-interactive: var(--neutral-200);--color-interactive-hover: var(--neutral-300);--color-border: rgba(0, 0, 0, .1);--color-border-muted: rgba(0, 0, 0, .06);--color-text: var(--neutral-900);--color-text-muted: var(--neutral-500);--color-link: inherit;--color-focus-ring: var(--neutral-500);--color-overlay-backdrop: rgb(0 0 0 / .5);--color-highlight: rgb(255 255 255 / .5);--color-primary: var(--blue-500);--color-danger: var(--red-600);color-scheme:light}body{font-family:var(--font-sans);font-size:var(--text-base);font-weight:var(--font-weight-body);line-height:var(--leading-base);letter-spacing:.015em;color:var(--color-text);background:var(--color-bg);-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}a{color:var(--color-link);text-underline-offset:.15em;text-decoration-thickness:.08em}h1,h2,h3,h4,h5,h6{font-weight:600;color:inherit}code{font-family:var(--font-mono);font-size:.9em;background:var(--color-bg-muted);padding:var(--space-2) var(--space-4);border-radius:var(--radius-4)}pre{font-family:var(--font-mono);background:var(--color-bg-muted);padding:var(--space-12);border-radius:var(--radius-8);overflow-x:auto}pre code{background:none;padding:0}blockquote{padding-left:var(--space-16);border-left:3px solid var(--color-border);color:var(--color-text-muted)}hr{border:none;border-top:1px solid var(--color-border)}table{border-collapse:collapse}th,td{padding:var(--space-8) var(--space-12);border:1px solid var(--color-border);text-align:left}th{background:var(--color-bg-muted);font-weight:600}input,textarea{border:.5px solid var(--tint-300);border-radius:var(--radius-12);background:var(--tint-100);color:inherit;font:inherit;box-sizing:border-box;transition:background .12s ease,border-color .12s ease,box-shadow .12s ease}input{height:var(--control-height-lg);padding:0 12px}textarea{padding:6px 10px;resize:none}input::placeholder,textarea::placeholder{color:var(--tint-500)}input:focus,textarea:focus{background:color-mix(in srgb,var(--white) var(--alpha-300),transparent);border-color:var(--color-primary);outline:none;box-shadow:0 0 0 1.5px var(--color-primary)}label.field{display:grid;gap:4px;font-size:13px}label.field>span{font-size:11.5px;font-weight:450;color:var(--tint-800)}@supports (corner-shape: squircle){*{corner-shape:squircle}}button{display:inline-flex;align-items:center;justify-content:center;gap:var(--space-6);box-sizing:border-box;height:var(--control-height-md);padding:0 14px 2px;font:inherit;cursor:default}button,segmented-control{background:var(--color-surface);border:.5px solid var(--tint-200);border-radius:var(--radius-12);box-shadow:var(--shadow-control);color:inherit}button:not([material]):hover:not(:disabled){background:color-mix(in srgb,var(--color-surface) 96%,black)}button:not([material]):active:not(:disabled){background:color-mix(in srgb,var(--color-surface) 88%,black);box-shadow:inset 0 1px 2px #00000014}button:focus-visible{outline:2px solid var(--color-focus-ring);outline-offset:2px}button[variant=primary]{background:var(--color-primary);border-color:#0000002e;color:var(--white)}button[variant=primary]:hover:not(:disabled){background:color-mix(in srgb,var(--color-primary) 92%,black)}button[variant=primary]:active:not(:disabled){background:color-mix(in srgb,var(--color-primary) 82%,black);box-shadow:inset 0 1px 2px #0000002e}button[variant=danger]{background:var(--color-danger);border-color:#0000002e;color:var(--white)}button[variant=danger]:hover:not(:disabled){background:color-mix(in srgb,var(--color-danger) 92%,black)}button[variant=danger]:active:not(:disabled){background:color-mix(in srgb,var(--color-danger) 82%,black);box-shadow:inset 0 1px 2px #0000002e}button[variant=ghost]{background:transparent;border-color:transparent;color:inherit;box-shadow:none}button[variant=ghost]:hover:not(:disabled){background:var(--color-overlay-hover);backdrop-filter:saturate(1.2);-webkit-backdrop-filter:saturate(1.2)}button[variant=ghost]:active:not(:disabled){background:var(--color-overlay-active);backdrop-filter:saturate(1.4);-webkit-backdrop-filter:saturate(1.4);box-shadow:none}button[variant=ghost][data-active]:not(:disabled),button[variant=ghost][data-active]:hover:not(:disabled),button[variant=ghost][aria-pressed=true]:not(:disabled),button[variant=ghost][aria-pressed=true]:hover:not(:disabled),button[variant=ghost][aria-expanded=true]:not(:disabled),button[variant=ghost][aria-expanded=true]:hover:not(:disabled){background:var(--color-overlay-active);backdrop-filter:saturate(1.3);-webkit-backdrop-filter:saturate(1.3);box-shadow:none}button[variant=glass],segmented-control[variant=glass]{background:transparent;border:.5px solid color-mix(in srgb,var(--black) var(--alpha-100),transparent);box-shadow:none}button[variant=glass]{backdrop-filter:blur(20px) brightness(.95) saturate(1.5);-webkit-backdrop-filter:blur(20px) brightness(.95) saturate(1.5)}button[variant=glass]:hover:not(:disabled){background:linear-gradient(var(--color-overlay-hover),var(--color-overlay-hover));backdrop-filter:blur(20px) brightness(.95) saturate(1.8);-webkit-backdrop-filter:blur(20px) brightness(.95) saturate(1.8)}button[variant=glass]:active:not(:disabled){background:linear-gradient(var(--color-overlay-active),var(--color-overlay-active));backdrop-filter:blur(20px) brightness(.95) saturate(2.2);-webkit-backdrop-filter:blur(20px) brightness(.95) saturate(2.2)}button[variant=glass][aria-pressed=true]:not(:disabled),button[variant=glass][aria-pressed=true]:hover:not(:disabled),button[variant=glass][aria-expanded=true]:not(:disabled),button[variant=glass][aria-expanded=true]:hover:not(:disabled){background:linear-gradient(var(--color-overlay-active),var(--color-overlay-active));backdrop-filter:blur(20px) brightness(.95) saturate(2);-webkit-backdrop-filter:blur(20px) brightness(.95) saturate(2)}[tone=dark] button[variant=glass],[tone=dark] segmented-control[variant=glass]{border-color:var(--tint-400)}button[material],segmented-control[material]{color:inherit;box-shadow:none}button[material]:hover:not(:disabled){background-image:linear-gradient(var(--color-overlay-hover),var(--color-overlay-hover))}button[material]:active:not(:disabled){background-image:linear-gradient(var(--color-overlay-active),var(--color-overlay-active))}[tone=dark] button[material],[tone=dark] segmented-control[material]{border-color:var(--tint-400)}button:disabled{background:var(--tint-300);border-color:transparent;color:var(--tint-700);box-shadow:none}:where([tone=dark]) button:not([variant]):not([material]):not(:disabled),:where([tone=dark]) button[variant=default]:not([material]):not(:disabled),:where([tone=dark]) segmented-control:not([variant]):not([material]),:where([tone=dark]) segmented-control[variant=default]:not([material]){background:var(--tint-200);border-color:var(--tint-300);box-shadow:inset 0 .5px 0 var(--tint-300)}:where([tone=dark]) button:not([variant]):hover:not(:disabled),:where([tone=dark]) button[variant=default]:hover:not(:disabled){background:var(--tint-300)}:where([tone=dark]) button:not([variant]):active:not(:disabled),:where([tone=dark]) button[variant=default]:active:not(:disabled){background:var(--tint-400);box-shadow:inset 0 1px 2px #0003}:where([tone=light]) button:not([variant]):not([material]):not(:disabled),:where([tone=light]) button[variant=default]:not([material]):not(:disabled),:where([tone=light]) segmented-control:not([variant]):not([material]),:where([tone=light]) segmented-control[variant=default]:not([material]){background:var(--color-surface);border-color:var(--tint-200);box-shadow:var(--shadow-control)}:where([tone=light]) button:not([variant]):hover:not(:disabled){background:color-mix(in srgb,var(--color-surface) 96%,black)}:where([tone=light]) button:not([variant]):active:not(:disabled){background:color-mix(in srgb,var(--color-surface) 88%,black);box-shadow:inset 0 1px 2px #00000014}button[size=sm],segmented-control[size=sm]{height:var(--control-height-sm)}button[size=sm][icon-only]{width:var(--control-height-sm)}button[size=xs]{height:var(--control-height-xs);padding:0 var(--space-6) 1px;border-radius:var(--radius-8)}button[size=xs][icon-only]{width:var(--control-height-xs);padding:0}button[icon-only]{width:var(--control-height-md);padding:0}[data-ui-icon]{display:inline-block;vertical-align:middle}[selectable],[selectable] *{user-select:text;-webkit-user-select:text}[unselectable],[unselectable] *{user-select:none;-webkit-user-select:none}.prose{line-height:var(--leading-base)}.prose h1{font-size:var(--text-xl);margin-bottom:var(--space-8)}.prose h2{font-size:var(--text-lg);margin-top:var(--space-24);margin-bottom:var(--space-8)}.prose h3,.prose h4,.prose h5,.prose h6{font-size:var(--text-base);margin-top:var(--space-24);margin-bottom:var(--space-8)}.prose p{margin:var(--space-12) 0}.prose ul,.prose ol{padding-left:var(--space-24);margin:var(--space-12) 0}.prose blockquote,.prose pre{margin:var(--space-12) 0}.prose hr{margin:var(--space-24) 0}.prose table{width:100%;margin:var(--space-12) 0}.prose img{max-width:100%;height:auto}.prose>:first-child{margin-top:0}.prose>:last-child{margin-bottom:0}[material=paper]{background:var(--white);border:.5px solid color-mix(in srgb,var(--black) var(--alpha-100),transparent);color:var(--color-text)}[material=glass]{background:transparent;border:.5px solid color-mix(in srgb,var(--black) var(--alpha-100),transparent);backdrop-filter:blur(20px) brightness(.95) saturate(1.5);-webkit-backdrop-filter:blur(20px) brightness(.95) saturate(1.5)}[material=glass-frosted]{background:color-mix(in srgb,var(--white) var(--alpha-800),transparent);border:.5px solid color-mix(in srgb,var(--black) var(--alpha-100),transparent);color:var(--color-text);backdrop-filter:var(--backdrop-blur-glass);-webkit-backdrop-filter:var(--backdrop-blur-glass)}[tone=dark]{color:color-mix(in srgb,var(--white) var(--alpha-950),transparent);border-color:color-mix(in srgb,var(--white) var(--alpha-200),transparent);--color-overlay-hover: color-mix(in srgb, var(--white) var(--alpha-100), transparent);--color-overlay-active: color-mix(in srgb, var(--white) var(--alpha-200), transparent)}[tone=dark][material=paper]{background:#000}[tone=dark][material=glass-frosted]{background:color-mix(in srgb,var(--black) 70%,transparent)}[tone=light]{color:var(--color-text);border-color:color-mix(in srgb,var(--black) var(--alpha-100),transparent);--color-overlay-hover: color-mix(in srgb, var(--black) var(--alpha-50), transparent);--color-overlay-active: color-mix(in srgb, var(--black) var(--alpha-100), transparent)}[level="1"]{box-shadow:0 12px 32px #00000024}[level="2"]{box-shadow:0 4px 6px -2px #0000001f,0 40px 60px -16px #00000038}dropdown-menu{position:relative;display:inline-block;color:inherit}dropdown-group{display:grid;gap:var(--space-4)}dropdown-label{display:block;padding:var(--space-4) var(--space-8);color:var(--color-text-muted);font:inherit;font-size:var(--text-sm);font-weight:600;letter-spacing:.04em;text-transform:uppercase}dropdown-divider{display:block;height:1px;margin:2px 0;background:var(--color-border)}[data-dropdown-trigger][aria-expanded=true],[data-dropdown-trigger][aria-expanded=true]:hover,dropdown-menu[open]::part(trigger),dropdown-menu[open]::part(trigger):hover{background:color-mix(in srgb,var(--color-surface) 88%,black);box-shadow:inset 0 1px 2px #00000014}[data-dropdown-trigger-label],dropdown-menu::part(trigger-label){min-width:0}[data-dropdown-trigger-icon],dropdown-menu::part(trigger-icon){display:inline-flex;align-items:center;justify-content:center;flex:none;color:var(--color-text-muted);transform:translateY(1px)}dropdown-item:focus-visible{outline:2px solid var(--color-focus-ring);outline-offset:2px}ui-popover.dropdown-popover::part(panel){min-width:192px;padding:var(--space-4)}.dropdown-list{display:flex;flex-direction:column;gap:2px}dropdown-item{display:flex;align-items:center;gap:var(--space-8);margin:0;padding:6px 12px;border-radius:var(--radius-8);font:inherit;line-height:1.2;color:inherit;font-weight:var(--font-weight-body);-webkit-user-select:none;user-select:none}dropdown-item>[data-ui-icon]{flex:none}dropdown-item[selected]{background:var(--color-overlay-active)}dropdown-item:hover,dropdown-item[action]:hover{background:var(--color-primary);color:var(--white)}dropdown-item[action]{color:inherit}dropdown-item[danger]{color:var(--color-danger)}dropdown-item[danger]:hover{background:var(--color-danger);color:var(--white)}editable-text{display:inline-block;max-width:100%;vertical-align:top}editable-text>.editable-text-span{display:inline-block;max-width:100%;outline:none;overflow:hidden;white-space:nowrap;cursor:inherit;vertical-align:top}editable-text:not([data-editing])>.editable-text-span{text-overflow:ellipsis}editable-text[data-editing]>.editable-text-span{cursor:text}modal-overlay{color:inherit}modal-overlay::part(backdrop){position:fixed;top:0;right:0;bottom:0;left:0;z-index:var(--layer-overlay);display:flex;align-items:center;justify-content:center;padding:var(--space-16);background:linear-gradient(to bottom,color-mix(in srgb,var(--black) var(--alpha-50),transparent),color-mix(in srgb,var(--black) var(--alpha-400),transparent));backdrop-filter:blur(1px);-webkit-backdrop-filter:blur(1px)}panel-view{display:block}panel-view::part(panel){display:flex;flex-direction:column;gap:var(--space-16);color:var(--color-text)}panel-view::part(header){display:flex;align-items:center;justify-content:space-between;gap:var(--space-12)}panel-view::part(title){margin:0;font:inherit;font-size:var(--text-lg);font-weight:600;color:var(--color-text)}panel-view::part(button){display:inline-flex;align-items:center;justify-content:center;width:28px;height:28px;margin:0;border:1px solid var(--color-border);border-radius:var(--radius-4);background:var(--color-surface);color:var(--color-text);box-shadow:none}panel-view::part(button):hover{background:var(--color-interactive-hover)}panel-view::part(button):focus-visible{outline:2px solid var(--color-focus-ring);outline-offset:2px}panel-view::part(icon){display:inline-flex;align-items:center;justify-content:center;flex:none}ui-popover{display:contents}ui-popover::part(panel){position:fixed;inset:0 auto auto 0;margin:0;min-width:192px;max-width:384px;padding:var(--space-16) var(--space-20);border-radius:var(--radius-12);outline:none;z-index:2000}segmented-control{display:inline-flex;align-items:stretch;box-sizing:border-box;height:var(--control-height-md)}segmented-control>button{height:auto}segmented-control[variant=ghost]{background:transparent;box-shadow:none}[tone=dark] segmented-control[variant=ghost]{border-color:var(--tint-400)}segmented-control>button{position:relative}segmented-control>button[icon-only]{width:auto;height:auto;padding:0 var(--space-6)}segmented-control>button:not([variant]):not(:disabled),[tone] segmented-control>button:not([variant]):not(:disabled){background:transparent;border:0;box-shadow:none}segmented-control>button:first-child{border-top-right-radius:0;border-bottom-right-radius:0}segmented-control>button:last-child{border-top-left-radius:0;border-bottom-left-radius:0}segmented-control>button:not(:first-child):not(:last-child){border-radius:0}segmented-control>button:not([variant]):hover:not(:disabled),[tone] segmented-control>button:not([variant]):hover:not(:disabled){background:var(--color-overlay-hover)}segmented-control>button:not([variant]):active:not(:disabled),[tone] segmented-control>button:not([variant]):active:not(:disabled){background:var(--color-overlay-active);box-shadow:none}segmented-control>button:not([variant])[aria-pressed=true]:not(:disabled),segmented-control>button:not([variant])[aria-current]:not([aria-current=false]):not(:disabled),segmented-control>button:not([variant])[aria-expanded=true]:not(:disabled),[tone] segmented-control>button:not([variant])[aria-pressed=true]:not(:disabled),[tone] segmented-control>button:not([variant])[aria-current]:not([aria-current=false]):not(:disabled),[tone] segmented-control>button:not([variant])[aria-expanded=true]:not(:disabled){background:linear-gradient(var(--color-overlay-active),var(--color-overlay-active))}segmented-control>button:not(:last-child):after{content:"";position:absolute;top:0;bottom:0;right:0;width:.5px;background:var(--tint-200);pointer-events:none}[tone=dark] segmented-control>button:not(:last-child):after{background:var(--tint-400)}segmented-control>dropdown-menu{display:inline-flex;align-items:stretch;height:auto}segmented-control>dropdown-menu>[slot=trigger]{height:auto;position:relative}segmented-control>dropdown-menu>[slot=trigger]:not([variant]):not(:disabled),[tone] segmented-control>dropdown-menu>[slot=trigger]:not([variant]):not(:disabled){background:transparent;border:0;box-shadow:none}segmented-control>dropdown-menu:first-child>[slot=trigger]{border-top-right-radius:0;border-bottom-right-radius:0}segmented-control>dropdown-menu:last-child>[slot=trigger]{border-top-left-radius:0;border-bottom-left-radius:0}segmented-control>dropdown-menu:not(:first-child):not(:last-child)>[slot=trigger]{border-radius:0}segmented-control>dropdown-menu>[slot=trigger]:not([variant]):hover:not(:disabled),[tone] segmented-control>dropdown-menu>[slot=trigger]:not([variant]):hover:not(:disabled){background:var(--color-overlay-hover)}segmented-control>dropdown-menu>[slot=trigger]:not([variant]):active:not(:disabled),[tone] segmented-control>dropdown-menu>[slot=trigger]:not([variant]):active:not(:disabled){background:var(--color-overlay-active);box-shadow:none}segmented-control>dropdown-menu>[slot=trigger]:not([variant])[aria-pressed=true]:not(:disabled),segmented-control>dropdown-menu>[slot=trigger]:not([variant])[aria-current]:not([aria-current=false]):not(:disabled),segmented-control>dropdown-menu>[slot=trigger]:not([variant])[aria-expanded=true]:not(:disabled),[tone] segmented-control>dropdown-menu>[slot=trigger]:not([variant])[aria-pressed=true]:not(:disabled),[tone] segmented-control>dropdown-menu>[slot=trigger]:not([variant])[aria-current]:not([aria-current=false]):not(:disabled),[tone] segmented-control>dropdown-menu>[slot=trigger]:not([variant])[aria-expanded=true]:not(:disabled){background:linear-gradient(var(--color-overlay-active),var(--color-overlay-active))}segmented-control[variant=glass]>button,segmented-control[variant=glass]>dropdown-menu{backdrop-filter:blur(20px) brightness(.95) saturate(1.5);-webkit-backdrop-filter:blur(20px) brightness(.95) saturate(1.5)}segmented-control[variant=glass]>button:not(:disabled):hover,segmented-control[variant=glass]>dropdown-menu:has(>[slot=trigger]:not(:disabled):hover){backdrop-filter:blur(20px) brightness(.95) saturate(1.8);-webkit-backdrop-filter:blur(20px) brightness(.95) saturate(1.8)}segmented-control[variant=glass]>button:not(:disabled):active,segmented-control[variant=glass]>dropdown-menu:has(>[slot=trigger]:not(:disabled):active){backdrop-filter:blur(20px) brightness(.95) saturate(2.2);-webkit-backdrop-filter:blur(20px) brightness(.95) saturate(2.2)}segmented-control[variant=glass]>button:not(:disabled)[aria-pressed=true],segmented-control[variant=glass]>button:not(:disabled)[aria-current]:not([aria-current=false]),segmented-control[variant=glass]>dropdown-menu:has(>[slot=trigger]:not(:disabled)[aria-pressed=true]),segmented-control[variant=glass]>dropdown-menu:has(>[slot=trigger]:not(:disabled)[aria-current]:not([aria-current=false])){backdrop-filter:blur(20px) brightness(.95) saturate(1.8);-webkit-backdrop-filter:blur(20px) brightness(.95) saturate(1.8)}segmented-control[variant=glass]>button:not(:disabled)[aria-expanded=true],segmented-control[variant=glass]>dropdown-menu:has(>[slot=trigger]:not(:disabled)[aria-expanded=true]){backdrop-filter:blur(20px) brightness(.95) saturate(2);-webkit-backdrop-filter:blur(20px) brightness(.95) saturate(2)}segmented-control>dropdown-menu:not(:last-child):after{content:"";position:absolute;top:0;bottom:0;right:0;width:.5px;background:var(--tint-200);pointer-events:none}[tone=dark] segmented-control>dropdown-menu:not(:last-child):after{background:var(--tint-400)}ui-spinner{display:inline-flex;align-items:center;justify-content:center;line-height:0;color:inherit}ui-spinner .spin,.spin{display:inline-flex;animation:ui-spinner-spin 1s steps(8,end) infinite}@keyframes ui-spinner-spin{to{transform:rotate(360deg)}}@media (prefers-reduced-motion: reduce){.spin{animation:none}}system-modal{display:flex;flex-direction:column;width:min(400px,100%);box-sizing:border-box;padding:var(--space-32) var(--space-24);border-radius:var(--radius-12)}system-modal header{display:flex;flex-direction:column;align-items:center;gap:var(--space-16);text-align:center}system-modal header>hgroup{display:flex;flex-direction:column;align-items:center;gap:var(--space-4);max-width:100%}system-modal header h2{margin:0;font-size:var(--text-lg);font-weight:600;letter-spacing:.01em;max-width:100%;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}system-modal header p{margin:0;font-size:var(--text-base);opacity:.7;max-width:100%;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}ui-pill{display:inline-block;vertical-align:baseline;margin:2px 0;padding:0 var(--space-8);font-size:var(--text-sm);font-weight:500;line-height:1.7;border-radius:var(--radius-full);border:1px solid var(--neutral-300);background:var(--neutral-200);color:var(--neutral-900);white-space:nowrap}ui-pill[color=gray]{border-color:var(--neutral-300);background:var(--neutral-200);color:var(--neutral-900)}ui-pill[color=red]{border-color:var(--red-200);background:var(--red-100);color:var(--red-950)}ui-pill[color=orange]{border-color:var(--orange-200);background:var(--orange-100);color:var(--orange-950)}ui-pill[color=yellow]{border-color:var(--yellow-200);background:var(--yellow-100);color:var(--yellow-950)}ui-pill[color=green]{border-color:var(--green-200);background:var(--green-100);color:var(--green-950)}ui-pill[color=blue]{border-color:var(--blue-200);background:var(--blue-100);color:var(--blue-950)}ui-pill[color=purple]{border-color:var(--purple-200);background:var(--purple-100);color:var(--purple-950)}',Hh=new CSSStyleSheet;Hh.replaceSync(SA);const Wh=new CSSStyleSheet;try{document.adoptedStyleSheets=[...document.adoptedStyleSheets,Hh,Wh]}catch{}Xm(document);function Km(n){Wh.replaceSync(n)}function qa(){Km("")}function Zh(n){try{n.adoptedStyleSheets=[...n.adoptedStyleSheets,Hh,Wh]}catch{}Xm(n)}const _A=new Set(["target","currentTarget","eventPhase","defaultPrevented","isTrusted","timeStamp","srcElement","returnValue","cancelBubble","NONE","CAPTURING_PHASE","AT_TARGET","BUBBLING_PHASE","composedPath","stopPropagation","stopImmediatePropagation","preventDefault","initEvent"]);function kA(n){for(const t of Object.keys(n))if(_A.has(t))throw new Error(`Event payload key "${t}" is reserved; choose a different property name`)}function xA(n,t){kA(t);for(const e of Object.keys(t))Object.defineProperty(n,e,{value:t[e],writable:!0,enumerable:!0,configurable:!0})}function it(){class n extends Event{constructor(e,r){const{type:i,bubbles:s,cancelable:o,composed:a,...c}=r??{};if(i!==void 0)throw new Error('Do not pass "type" in init; use the constructor argument instead');super(e,{bubbles:s,cancelable:o,composed:a}),xA(this,c)}}return n}class qt extends globalThis.EventTarget{}function EA(n,t,e){const r=n.dispose.bind(n);n.dispose=()=>{if(!t())return e(),r()}}function No(n){var e;class t extends n{constructor(...s){super(...s);w(this,e,!1);EA(this,()=>l(this,e),()=>{S(this,e,!0)})}[Symbol.dispose](){this.dispose()}get disposed(){return l(this,e)}}return e=new WeakMap,t}const AA=it(),$A=it(),TA=it(),xa=it(),Jm="0123456789ABCDEFGHJKMNPQRSTVWXYZ",Ya=32,IA=16,Qm=10,Sf=0xffffffffffff;var cr;(function(n){n.Base32IncorrectEncoding="B32_ENC_INVALID",n.DecodeTimeInvalidCharacter="DEC_TIME_CHAR",n.DecodeTimeValueMalformed="DEC_TIME_MALFORMED",n.EncodeTimeNegative="ENC_TIME_NEG",n.EncodeTimeSizeExceeded="ENC_TIME_SIZE_EXCEED",n.EncodeTimeValueMalformed="ENC_TIME_MALFORMED",n.PRNGDetectFailure="PRNG_DETECT",n.ULIDInvalid="ULID_INVALID",n.Unexpected="UNEXPECTED",n.UUIDInvalid="UUID_INVALID"})(cr||(cr={}));class gs extends Error{constructor(t,e){super(`${e} (${t})`),this.name="ULIDError",this.code=t}}function CA(n){const t=Math.floor(n()*Ya)%Ya;return Jm.charAt(t)}function RA(n){const t=PA(),e=t&&(t.crypto||t.msCrypto)||null;if(typeof(e==null?void 0:e.getRandomValues)=="function")return()=>{const r=new Uint8Array(1);return e.getRandomValues(r),r[0]/256};if(typeof(e==null?void 0:e.randomBytes)=="function")return()=>e.randomBytes(1).readUInt8()/256;throw new gs(cr.PRNGDetectFailure,"Failed to find a reliable PRNG")}function PA(){return zA()?self:typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:null}function DA(n,t){let e="";for(;n>0;n--)e=CA(t)+e;return e}function LA(n,t=Qm){if(isNaN(n))throw new gs(cr.EncodeTimeValueMalformed,`Time must be a number: ${n}`);if(n>Sf)throw new gs(cr.EncodeTimeSizeExceeded,`Cannot encode a time larger than ${Sf}: ${n}`);if(n<0)throw new gs(cr.EncodeTimeNegative,`Time must be positive: ${n}`);if(Number.isInteger(n)===!1)throw new gs(cr.EncodeTimeValueMalformed,`Time must be an integer: ${n}`);let e,r="";for(let i=t;i>0;i--)e=n%Ya,r=Jm.charAt(e)+r,n=(n-e)/Ya;return r}function zA(){return typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope}function Pl(n,t){const e=RA(),r=Date.now();return LA(r,Qm)+DA(IA,e)}const mt=4,ct=6,Ps=2,pu=2,Bh=8,OA=ct,Vh="auto",Un="auto",Sn=120,_f=50,ce=16,Dr=Sn*mt+ce*(mt-1),Xa=Sn*ct+ce*(ct-1),MA=Dr+ce*2,NA=200,UA=4,sa=150,FA=10,kf=2,xf=8,HA=300,WA=4;function ev(n){return rv(n)}function tv(n,t){return rv(n.flatMap(e=>sv(e,t)))}function nv(n){const t=[],e=new Set;for(const r of n){if(r.type==="row"){t.push(`Top-level rows are invalid: ${r.id}`);continue}ov(r,"strip",t,e)}return{valid:t.length===0,errors:t}}function ur(n){const t=ev(n),e=nv(t);if(!e.valid)throw new Error(`Invalid layout: ${e.errors.join("; ")}`);return{totalNodes:t.length,nodes:t.filter(r=>r.type!=="row").map(jA)}}function rv(n){const t=[];for(const e of n){const r=iv(e);for(const i of r){if(i.type==="row"){t.push(...i.children.map(dn));continue}t.push(i)}}return t}function iv(n){switch(n.type){case"card":return[dn(n)];case"row":{const t=n.children.map(dn);return t.length===0?[]:t.length===1?[t[0]]:[{...n,children:t}]}case"stack":{const t=[];for(const e of n.children){const r=iv(e);for(const i of r){if(i.type==="stack"){t.push(...i.children.map(fu));continue}if(i.type==="row"){t.push({...i,children:i.children.map(dn)});continue}t.push(dn(i))}}return t.length===0?[]:t.length===1?[fu(t[0])]:[{...n,children:t}]}}}function sv(n,t){switch(n.type){case"card":return n.artifactID===t?[]:[dn(n)];case"row":{const e=n.children.filter(r=>r.artifactID!==t).map(dn);return e.length===0?[]:e.length===1?[e[0]]:[{...n,children:e}]}case"stack":{const e=n.children.flatMap(r=>sv(r,t).filter(s=>s.type!=="stack"));return e.length===0?[]:e.length===1?[fu(e[0])]:[{...n,children:e}]}}}function ov(n,t,e,r){switch(n.type){case"card":av(n,t,e,r);return;case"row":ZA(n,t,e,r);return;case"stack":BA(n,t,e,r);return}}function av(n,t,e,r){jh(n.id,e),typeof n.artifactID!="string"||n.artifactID.length===0?e.push(`Card ${n.id} is missing artifactID`):r.has(n.artifactID)?e.push(`Duplicate artifactID in layout: ${n.artifactID}`):r.add(n.artifactID),VA(n.width)||e.push(`Card ${n.id} width must be an integer in the range ${Ps}-${Bh}`),lv(n.height)||e.push(`Card ${n.id} height must be an integer in the range 2-6 or "auto"`);const i=sr(n.width);t==="row"&&i<Ps&&e.push(`Row child ${n.id} must be at least 2 columns wide`)}function ZA(n,t,e,r){if(jh(n.id,e),t!=="stack"&&e.push(`Row ${n.id} may only appear inside a stack`),lv(n.height,WA)||e.push(`Row ${n.id} height must be an integer in the range 2-4 or "auto"`),!Array.isArray(n.children)||n.children.length===0){e.push(`Row ${n.id} must contain card nodes`);return}let i=0;for(const s of n.children){if(s.type!=="card"){e.push(`Row ${n.id} must contain only card nodes`);continue}av(s,"row",e,r),i+=sr(s.width)}i!==mt&&e.push(`Row ${n.id} children must sum to 4 columns`)}function BA(n,t,e,r){if(jh(n.id,e),t!=="strip"&&e.push(`Invalid nested stack at ${n.id}; stack children cannot contain another nested stack`),!Array.isArray(n.children)||n.children.length===0){e.push(`Stack ${n.id} must contain at least one child`);return}let i=0,s=0;for(const a of n.children){if(a.type==="stack"){e.push(`Stack ${n.id} cannot contain another nested stack`);continue}if(ov(a,"stack",e,r),a.height===Un){s+=1;continue}i+=a.height}if(i>ct&&e.push(`Stack ${n.id} exceeds the 6-row budget`),s===0)return;const o=ct-i;if(o<s*pu||o%s!==0){e.push(`Stack ${n.id} has auto-height children that cannot resolve to whole height >= 2`);return}o/s<pu&&e.push(`Stack ${n.id} has auto-height children below the minimum row size`)}function jh(n,t){(typeof n!="string"||n.length===0)&&t.push(`Node id must be a non-empty string: ${String(n)}`)}function VA(n){return n===Vh||Number.isInteger(n)&&n>=Ps&&n<=Bh}function lv(n,t=OA){return n===Un||Number.isInteger(n)&&n>=pu&&n<=t}function sr(n){return n===Vh?mt:n}function jA(n){if(n.type==="card")return{id:n.id,type:"card",width:sr(n.width),cards:[{id:n.id,artifactID:n.artifactID,col:1,row:1,width:sr(n.width),height:cv(n.height,ct)}]};const t=GA(n.children),e=[];let r=1;for(let i=0;i<n.children.length;i+=1){const s=n.children[i],o=t[i];if(s.type==="card")e.push({id:s.id,artifactID:s.artifactID,col:1,row:r,width:Math.min(mt,sr(s.width)),height:o});else{let a=1;for(const c of s.children)e.push({id:c.id,artifactID:c.artifactID,col:a,row:r,width:sr(c.width),height:o}),a+=sr(c.width)}r+=o}return{id:n.id,type:"stack",width:e.reduce((i,s)=>Math.max(i,s.col+s.width-1),1),cards:e}}function GA(n){let t=0,e=0;for(const i of n)i.height===Un?e+=1:t+=i.height;const r=e>0?(ct-t)/e:0;return n.map(i=>cv(i.height,r))}function cv(n,t){return n===Un?t:n}function dn(n){return{...n}}function fu(n){return n.type==="card"?dn(n):{...n,children:n.children.map(dn)}}function uv(n,t={}){return{id:t.id??Pl(),type:"card",artifactID:n,width:t.width??Vh,height:t.height??Un}}function hv(n,t){return n.some(e=>dv(e,t))}function dv(n,t){switch(n.type){case"card":return n.artifactID===t;case"row":return n.children.some(e=>e.artifactID===t);case"stack":return n.children.some(e=>dv(e,t))}}function Ef(n){return n.layout.flatMap(pv)}function pv(n){switch(n.type){case"card":return[n.artifactID];case"row":return n.children.map(t=>t.artifactID);case"stack":return n.children.flatMap(pv)}}const oe=it(),gu=it(),ei=it(),qA=it();function YA(n){class t extends Error{constructor(r,i){super(r),this.name=n,i&&Object.assign(this,i)}}return t}const fv=YA("RequestError"),XA=200,KA=300;class JA{constructor(t,e){m(this,"serverURL");m(this,"token");this.serverURL=t.replace(/\/$/,""),this.token=e.token}async requestJSON(t,e,r){const i=await this.request(t,e,r!==void 0?JSON.stringify(r):void 0,r!==void 0?{"content-type":"application/json"}:void 0),s=await QA(i);if(!i.ok||i.status<XA||i.status>=KA)throw this.createError(typeof s.error=="string"?s.error:i.statusText,i.status);return s}async requestVoid(t,e,r){const i=await this.request(t,e,r!==void 0?JSON.stringify(r):void 0,r!==void 0?{"content-type":"application/json"}:void 0);if(!i.ok)throw this.createError(await zc(i,i.statusText),i.status)}async requestText(t,e){const r=await this.request(t,e);if(!r.ok)throw this.createError(await zc(r,r.statusText),r.status);return r.text()}async requestRawVoid(t,e,r){const i=await this.request(t,e,r,{"content-type":"text/plain"});if(!i.ok)throw this.createError(await zc(i,i.statusText),i.status)}createError(t,e){const r={serverURL:this.serverURL};return e!==void 0&&(r.status=e),new fv(t,r)}async request(t,e,r,i){const s=`${this.serverURL}${e}`;try{return await fetch(s,{method:t,headers:this.buildHeaders(i),body:r})}catch(o){throw this.createError(o instanceof Error?o.message:"Failed to reach server")}}buildHeaders(t){const e={...t??{}};return this.token&&(e.Authorization=`Bearer ${this.token}`),Object.keys(e).length>0?e:void 0}}async function QA(n){try{return await n.json()}catch{const t=await n.text().catch(()=>"");return t?{message:t}:{}}}async function zc(n,t){try{const e=await n.json();if(typeof e.error=="string")return e.error;if(typeof e.message=="string")return e.message}catch{}return t}function e$(n){return n.map(t=>`${t.name} (${t.id})`).join(", ")}var Ot,cl,gv;class t${constructor(t){w(this,cl);w(this,Ot);S(this,Ot,t)}list(){return l(this,Ot).requestJSON("GET","/screens")}async get(t={}){const e=await f(this,cl,gv).call(this,t.screenID);return l(this,Ot).requestJSON("GET",`/screens/${encodeURIComponent(e)}`)}create(t){const e={name:t.name};return t.id!==void 0&&(e.id=t.id),l(this,Ot).requestJSON("POST","/screens",e)}update(t){const{screenID:e,...r}=t;return l(this,Ot).requestJSON("PATCH",`/screens/${encodeURIComponent(e)}`,r)}remove(t){return l(this,Ot).requestJSON("DELETE",`/screens/${encodeURIComponent(t.screenID)}`)}}Ot=new WeakMap,cl=new WeakSet,gv=async function(t){if(t!==void 0)return t;const{screens:e}=await this.list();if(e.length===1)return e[0].id;throw l(this,Ot).createError(`screenID is required when multiple screens exist. Available screens: ${e$(e)}`)};var Fe;class n${constructor(t){w(this,Fe);S(this,Fe,t)}create(t){const e={kind:t.kind,title:t.title};switch(t.kind){case"markdown":e.externalFilePath=t.externalFilePath;break;case"url":e.externalURL=t.externalURL;break;case"web-bundle":t.skipPending!==void 0&&(e.skipPending=t.skipPending);break}return t.screenID!==void 0&&(e.screenID=t.screenID),l(this,Fe).requestJSON("POST","/artifacts",e)}list(t={}){const e=new URLSearchParams;t.screenID!==void 0&&e.set("screenID",t.screenID),t.unplaced&&e.set("unplaced","true");const r=e.toString();return l(this,Fe).requestJSON("GET",r?`/artifacts?${r}`:"/artifacts")}get(t){return l(this,Fe).requestJSON("GET",`/artifacts/${encodeURIComponent(t.artifactID)}`)}update(t){const e={};return t.title!==void 0&&(e.title=t.title),l(this,Fe).requestJSON("PATCH",`/artifacts/${encodeURIComponent(t.artifactID)}`,e)}edit(t){return l(this,Fe).requestJSON("POST",`/artifacts/${encodeURIComponent(t.artifactID)}/edit`)}commitPending(t){return l(this,Fe).requestJSON("POST",`/artifacts/${encodeURIComponent(t.artifactID)}/commit`)}abandonPending(t){return l(this,Fe).requestVoid("POST",`/artifacts/${encodeURIComponent(t.artifactID)}/abandon`)}attach(t){return l(this,Fe).requestJSON("POST",`/screens/${encodeURIComponent(t.screenID)}/artifacts/${encodeURIComponent(t.artifactID)}`)}detach(t){return l(this,Fe).requestJSON("DELETE",`/screens/${encodeURIComponent(t.screenID)}/artifacts/${encodeURIComponent(t.artifactID)}`)}delete(t){return l(this,Fe).requestJSON("DELETE",`/artifacts/${encodeURIComponent(t.artifactID)}`)}getContent(t){return l(this,Fe).requestText("GET",`/artifacts/${encodeURIComponent(t.artifactID)}/content`)}putContent(t){return l(this,Fe).requestRawVoid("PUT",`/artifacts/${encodeURIComponent(t.artifactID)}/content`,t.content)}}Fe=new WeakMap;var dr;class r${constructor(t){w(this,dr);S(this,dr,t)}get(){return l(this,dr).requestJSON("GET","/display")}patch(t){const e={};return t.activeScreenID!==void 0&&(e.activeScreenID=t.activeScreenID),t.activeThemeName!==void 0&&(e.activeThemeName=t.activeThemeName),l(this,dr).requestVoid("PATCH","/display",e)}focus(t){const e={artifactID:t.artifactID};return t.screenID!==void 0&&(e.screenID=t.screenID),l(this,dr).requestJSON("POST","/display/focus",e)}}dr=new WeakMap;var Ns;class i${constructor(t){w(this,Ns);S(this,Ns,t)}async list(){const{views:t}=await l(this,Ns).requestJSON("GET","/views");return t}}Ns=new WeakMap;var rn;class s${constructor(t,e={}){m(this,"screens");m(this,"artifacts");m(this,"display");m(this,"views");w(this,rn);S(this,rn,new JA(t,e)),this.screens=new t$(l(this,rn)),this.artifacts=new n$(l(this,rn)),this.display=new r$(l(this,rn)),this.views=new i$(l(this,rn))}health(){return l(this,rn).requestJSON("GET","/health")}}rn=new WeakMap;const o$={focusCommandInput:{label:"Focus Command Input",trigger:{key:"k",meta:!0}}},a$="Local",l$="store-";function we(n){return new URL(n).origin}function c$(n){return{servers:[{url:we(n),name:a$}],activeServerURL:null,activeScreenID:null,tabs:{},screens:{}}}function u$(n,t){return[...n.tabs[we(t)]??[]]}function h$(n,t,e){const r=we(t),i=n.tabs[r]??[];return i.includes(e)?n:{...n,tabs:{...n.tabs,[r]:[...i,e]}}}function d$(n,t,e){const r=we(t),i=n.tabs[r]??[],s=i.filter(a=>a!==e);if(s.length===i.length)return n;const o={...n.tabs};return s.length===0?delete o[r]:o[r]=s,{...n,tabs:o}}var pr,fr,gr;class p$ extends qt{constructor(e,r,i={}){super();w(this,pr);w(this,fr);w(this,gr);S(this,pr,`${l$}${e}`),S(this,fr,i.storage??f$());const s=l(this,fr).getItem(l(this,pr));s===null?(S(this,gr,r),l(this,fr).setItem(l(this,pr),JSON.stringify(r))):S(this,gr,g$(JSON.parse(s),r))}get(){return l(this,gr)}set(e){S(this,gr,e),l(this,fr).setItem(l(this,pr),JSON.stringify(e)),this.dispatchEvent(new oe("change"))}}pr=new WeakMap,fr=new WeakMap,gr=new WeakMap;function f$(){const n=globalThis.localStorage;if(!n)throw new Error("LocalStore: no storage adapter supplied and window.localStorage is unavailable");return n}function g$(n,t){return{servers:Array.isArray(n.servers)?n.servers:t.servers,activeServerURL:typeof n.activeServerURL=="string"||n.activeServerURL===null?n.activeServerURL:t.activeServerURL,activeScreenID:typeof n.activeScreenID=="string"||n.activeScreenID===null?n.activeScreenID:t.activeScreenID,tabs:n.tabs&&typeof n.tabs=="object"?n.tabs:t.tabs,screens:n.screens&&typeof n.screens=="object"?n.screens:t.screens}}const m$=No(qt);var mr,Ke,vr,Be,kn,xn,te,ri,mv,Us,vv,yv,bv,wv,mu,vu,yu,Sv;class v$ extends m${constructor(e){var i;super();w(this,te);m(this,"id");m(this,"server");w(this,mr);w(this,Ke,new Map);w(this,vr);w(this,Be);w(this,kn);w(this,xn,null);w(this,Us,e=>{if(this.disposed)return;const r=e.event;switch(r.type){case"screen-updated":r.screen.id===this.id&&f(this,te,vv).call(this,r.screen);break;case"artifact-created":break;case"artifact-attached":r.screenID===this.id&&f(this,te,yv).call(this,r.cardID,r.artifact);break;case"artifact-updated":f(this,te,bv).call(this,r.artifact);break;case"artifact-removed":r.screenID===this.id&&f(this,te,wv).call(this,r.artifactID);break;case"artifact-content-changed":l(this,Ke).has(r.artifactID)&&this.dispatchEvent(new qA("artifact-content-changed",{artifactID:r.artifactID}));break}});this.id=e.screen.id,this.server=e.server,S(this,mr,e.localStore),S(this,vr,e.screen.name),S(this,Be,structuredClone(e.screen.layout));const r=((i=l(this,mr).get().screens[this.id])==null?void 0:i.scrollPosition)??0;S(this,kn,Math.max(0,r)),this.server.addEventListener("server-event",l(this,Us)),f(this,te,mv).call(this)}get name(){return l(this,vr)}get layout(){return l(this,Be)}get scrollPosition(){return l(this,kn)}get artifacts(){return l(this,Ke)}setScrollPosition(e){f(this,te,ri).call(this);const r=Math.max(0,e);r!==l(this,kn)&&(S(this,kn,r),f(this,te,Sv).call(this),this.dispatchEvent(new oe("change")))}setLayout(e){f(this,te,ri).call(this);const r=ev(e);if(!nv(r).valid)return;const s=f(this,te,vu).call(this);S(this,Be,r),S(this,xn,{layout:r,snapshot:s}),this.dispatchEvent(new oe("change")),this.server.client.screens.update({screenID:this.id,layout:r.map(o=>structuredClone(o))}).catch(()=>{var o;this.disposed||((o=l(this,xn))==null?void 0:o.layout)===r&&(S(this,xn,null),f(this,te,yu).call(this,s),this.dispatchEvent(new oe("change")))})}rename(e){f(this,te,ri).call(this),S(this,vr,e),this.dispatchEvent(new oe("change")),this.server.client.screens.update({screenID:this.id,name:e}).catch(()=>{})}async remove(){f(this,te,ri).call(this),await this.server.client.screens.remove({screenID:this.id})}removeArtifact(e){if(f(this,te,ri).call(this),!l(this,Ke).has(e))return;const r=f(this,te,vu).call(this);f(this,te,mu).call(this,e),this.dispatchEvent(new oe("change")),this.server.client.artifacts.detach({artifactID:e,screenID:this.id}).catch(()=>{this.disposed||(f(this,te,yu).call(this,r),this.dispatchEvent(new oe("change")))})}dispose(){this.server.removeEventListener("server-event",l(this,Us))}}mr=new WeakMap,Ke=new WeakMap,vr=new WeakMap,Be=new WeakMap,kn=new WeakMap,xn=new WeakMap,te=new WeakSet,ri=function(){if(this.disposed)throw new Error("ScreenModel is disposed")},mv=async function(){try{const e=await this.server.client.screens.get({screenID:this.id});if(this.disposed)return;for(const r of e.artifacts)l(this,Ke).set(r.id,r);this.dispatchEvent(new oe("change"))}catch{}},Us=new WeakMap,vv=function(e){l(this,xn)&&S(this,xn,null),S(this,vr,e.name),S(this,Be,structuredClone(e.layout)),this.dispatchEvent(new oe("change"))},yv=function(e,r){hv(l(this,Be),r.id)||S(this,Be,[...l(this,Be),uv(r.id,{id:e})]),l(this,Ke).set(r.id,r),this.dispatchEvent(new oe("change"))},bv=function(e){const r=l(this,Ke).get(e.id);r&&(l(this,Ke).set(e.id,{...r,...e}),this.dispatchEvent(new oe("change")))},wv=function(e){f(this,te,mu).call(this,e)&&this.dispatchEvent(new oe("change"))},mu=function(e){const r=l(this,Ke).delete(e),i=Ef({layout:l(this,Be)}).length,s=tv(l(this,Be),e),o=Ef({layout:s}).length;return S(this,Be,s),r||i!==o},vu=function(){return{layout:structuredClone(l(this,Be)),artifacts:new Map([...l(this,Ke).entries()].map(([e,r])=>[e,structuredClone(r)]))}},yu=function(e){S(this,Be,structuredClone(e.layout)),l(this,Ke).clear();for(const[r,i]of e.artifacts)l(this,Ke).set(r,structuredClone(i))},Sv=function(){const e=l(this,mr).get();l(this,mr).set({...e,screens:{...e.screens,[this.id]:{scrollPosition:l(this,kn)}}})};const y$=No(qt);var ze,Je,Mt,Fs,Hs,Ws,je,Ea,bu,ii;class b$ extends y${constructor(e){super();w(this,je);w(this,ze);w(this,Je);w(this,Mt,null);w(this,Fs,()=>{this.disposed||f(this,je,Ea).call(this)});w(this,Hs,()=>{this.disposed||f(this,je,Ea).call(this)});w(this,Ws,e=>{if(this.disposed)return;const r=e.event;if(r.type==="screen-removed"){this.removeTab(e.serverURL,r.screenID);const i=l(this,ze).get();i.activeServerURL===we(e.serverURL)&&i.activeScreenID===r.screenID&&f(this,je,ii).call(this,e.serverURL,null);return}if(r.type==="screen-changed"){if(r.screenID===null){f(this,je,ii).call(this,e.serverURL,null);return}const i=l(this,Je).servers.get(we(e.serverURL));if(!i||!i.screens.has(r.screenID))return;this.addTab(e.serverURL,r.screenID),f(this,je,ii).call(this,e.serverURL,r.screenID)}});S(this,ze,e.localStore),S(this,Je,e.serverManager),l(this,ze).addEventListener("change",l(this,Fs)),l(this,Je).addEventListener("change",l(this,Hs)),l(this,Je).addEventListener("server-event",l(this,Ws)),f(this,je,Ea).call(this)}get activeScreen(){return l(this,Mt)}getTabs(e){const r=we(e),i=u$(l(this,ze).get(),r),s=l(this,Je).servers.get(r);return s?i.filter(o=>s.screens.has(o)):i}hasTab(e,r){return this.getTabs(e).includes(r)}addTab(e,r){const i=we(e),s=l(this,Je).servers.get(i);s&&!s.screens.has(r)||f(this,je,bu).call(this,h$(l(this,ze).get(),i,r))}removeTab(e,r){f(this,je,bu).call(this,d$(l(this,ze).get(),e,r))}setActive(e,r){const i=we(e),s=l(this,Je).servers.get(i);!s||!s.screens.has(r)||f(this,je,ii).call(this,i,r)&&s.client.display.patch({activeScreenID:r}).catch(()=>{})}clearActive(){const e=l(this,ze).get().activeServerURL;if(!e||!f(this,je,ii).call(this,e,null))return;const r=l(this,Je).servers.get(e);r==null||r.client.display.patch({activeScreenID:null}).catch(()=>{})}dispose(){var e;l(this,ze).removeEventListener("change",l(this,Fs)),l(this,Je).removeEventListener("change",l(this,Hs)),l(this,Je).removeEventListener("server-event",l(this,Ws)),(e=l(this,Mt))==null||e.dispose(),S(this,Mt,null)}}ze=new WeakMap,Je=new WeakMap,Mt=new WeakMap,Fs=new WeakMap,Hs=new WeakMap,Ws=new WeakMap,je=new WeakSet,Ea=function(){var c,u,h;const{activeServerURL:e,activeScreenID:r}=l(this,ze).get(),i=e?l(this,Je).servers.get(e)??null:null,s=i&&r?i.screens.get(r)??null:null,o=((c=l(this,Mt))==null?void 0:c.id)??null,a=(s==null?void 0:s.id)??null;o===a&&((u=l(this,Mt))==null?void 0:u.server)===i||((h=l(this,Mt))==null||h.dispose(),S(this,Mt,i&&s?new v$({screen:s,server:i,localStore:l(this,ze)}):null),i&&i.acpClient.setScreenContext(s?{screenID:s.id,screenName:s.name}:null),this.dispatchEvent(new AA("active-screen-changed")))},bu=function(e){e!==l(this,ze).get()&&(l(this,ze).set(e),this.dispatchEvent(new $A("tabs-changed")))},ii=function(e,r){const i=we(e),s=l(this,ze).get();return s.activeServerURL===i&&s.activeScreenID===r?!1:(l(this,ze).set({...s,activeServerURL:i,activeScreenID:r}),!0)};function A(n,t,e){function r(a,c){if(a._zod||Object.defineProperty(a,"_zod",{value:{def:c,constr:o,traits:new Set},enumerable:!1}),a._zod.traits.has(n))return;a._zod.traits.add(n),t(a,c);const u=o.prototype,h=Object.keys(u);for(let p=0;p<h.length;p++){const v=h[p];v in a||(a[v]=u[v].bind(a))}}const i=(e==null?void 0:e.Parent)??Object;class s extends i{}Object.defineProperty(s,"name",{value:n});function o(a){var c;const u=e!=null&&e.Parent?new s:this;r(u,a),(c=u._zod).deferred??(c.deferred=[]);for(const h of u._zod.deferred)h();return u}return Object.defineProperty(o,"init",{value:r}),Object.defineProperty(o,Symbol.hasInstance,{value:a=>{var c,u;return e!=null&&e.Parent&&a instanceof e.Parent?!0:(u=(c=a==null?void 0:a._zod)==null?void 0:c.traits)==null?void 0:u.has(n)}}),Object.defineProperty(o,"name",{value:n}),o}class mi extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class _v extends Error{constructor(t){super(`Encountered unidirectional transform during encode: ${t}`),this.name="ZodEncodeError"}}const kv={};function Fn(n){return kv}function xv(n){const t=Object.values(n).filter(r=>typeof r=="number");return Object.entries(n).filter(([r,i])=>t.indexOf(+r)===-1).map(([r,i])=>i)}function wu(n,t){return typeof t=="bigint"?t.toString():t}function Gh(n){return{get value(){{const t=n();return Object.defineProperty(this,"value",{value:t}),t}}}}function qh(n){return n==null}function Yh(n){const t=n.startsWith("^")?1:0,e=n.endsWith("$")?n.length-1:n.length;return n.slice(t,e)}function w$(n,t){const e=(n.toString().split(".")[1]||"").length,r=t.toString();let i=(r.split(".")[1]||"").length;if(i===0&&/\d?e-\d?/.test(r)){const c=r.match(/\d?e-(\d?)/);c!=null&&c[1]&&(i=Number.parseInt(c[1]))}const s=e>i?e:i,o=Number.parseInt(n.toFixed(s).replace(".","")),a=Number.parseInt(t.toFixed(s).replace(".",""));return o%a/10**s}const Af=Symbol("evaluating");function ne(n,t,e){let r;Object.defineProperty(n,t,{get(){if(r!==Af)return r===void 0&&(r=Af,r=e()),r},set(i){Object.defineProperty(n,t,{value:i})},configurable:!0})}function Wr(n,t,e){Object.defineProperty(n,t,{value:e,writable:!0,enumerable:!0,configurable:!0})}function jn(...n){const t={};for(const e of n){const r=Object.getOwnPropertyDescriptors(e);Object.assign(t,r)}return Object.defineProperties({},t)}function $f(n){return JSON.stringify(n)}function S$(n){return n.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}const Ev="captureStackTrace"in Error?Error.captureStackTrace:(...n)=>{};function Ka(n){return typeof n=="object"&&n!==null&&!Array.isArray(n)}const _$=Gh(()=>{var n;if(typeof navigator<"u"&&((n=navigator==null?void 0:navigator.userAgent)!=null&&n.includes("Cloudflare")))return!1;try{const t=Function;return new t(""),!0}catch{return!1}});function Ni(n){if(Ka(n)===!1)return!1;const t=n.constructor;if(t===void 0||typeof t!="function")return!0;const e=t.prototype;return!(Ka(e)===!1||Object.prototype.hasOwnProperty.call(e,"isPrototypeOf")===!1)}function Av(n){return Ni(n)?{...n}:Array.isArray(n)?[...n]:n}const k$=new Set(["string","number","symbol"]);function Ui(n){return n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Gn(n,t,e){const r=new n._zod.constr(t??n._zod.def);return(!t||e!=null&&e.parent)&&(r._zod.parent=n),r}function M(n){const t=n;if(!t)return{};if(typeof t=="string")return{error:()=>t};if((t==null?void 0:t.message)!==void 0){if((t==null?void 0:t.error)!==void 0)throw new Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error=="string"?{...t,error:()=>t.error}:t}function x$(n){return Object.keys(n).filter(t=>n[t]._zod.optin==="optional"&&n[t]._zod.optout==="optional")}const E$={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 A$(n,t){const e=n._zod.def,r=e.checks;if(r&&r.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");const s=jn(n._zod.def,{get shape(){const o={};for(const a in t){if(!(a in e.shape))throw new Error(`Unrecognized key: "${a}"`);t[a]&&(o[a]=e.shape[a])}return Wr(this,"shape",o),o},checks:[]});return Gn(n,s)}function $$(n,t){const e=n._zod.def,r=e.checks;if(r&&r.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");const s=jn(n._zod.def,{get shape(){const o={...n._zod.def.shape};for(const a in t){if(!(a in e.shape))throw new Error(`Unrecognized key: "${a}"`);t[a]&&delete o[a]}return Wr(this,"shape",o),o},checks:[]});return Gn(n,s)}function T$(n,t){if(!Ni(t))throw new Error("Invalid input to extend: expected a plain object");const e=n._zod.def.checks;if(e&&e.length>0){const s=n._zod.def.shape;for(const o in t)if(Object.getOwnPropertyDescriptor(s,o)!==void 0)throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}const i=jn(n._zod.def,{get shape(){const s={...n._zod.def.shape,...t};return Wr(this,"shape",s),s}});return Gn(n,i)}function I$(n,t){if(!Ni(t))throw new Error("Invalid input to safeExtend: expected a plain object");const e=jn(n._zod.def,{get shape(){const r={...n._zod.def.shape,...t};return Wr(this,"shape",r),r}});return Gn(n,e)}function C$(n,t){const e=jn(n._zod.def,{get shape(){const r={...n._zod.def.shape,...t._zod.def.shape};return Wr(this,"shape",r),r},get catchall(){return t._zod.def.catchall},checks:[]});return Gn(n,e)}function R$(n,t,e){const i=t._zod.def.checks;if(i&&i.length>0)throw new Error(".partial() cannot be used on object schemas containing refinements");const o=jn(t._zod.def,{get shape(){const a=t._zod.def.shape,c={...a};if(e)for(const u in e){if(!(u in a))throw new Error(`Unrecognized key: "${u}"`);e[u]&&(c[u]=n?new n({type:"optional",innerType:a[u]}):a[u])}else for(const u in a)c[u]=n?new n({type:"optional",innerType:a[u]}):a[u];return Wr(this,"shape",c),c},checks:[]});return Gn(t,o)}function P$(n,t,e){const r=jn(t._zod.def,{get shape(){const i=t._zod.def.shape,s={...i};if(e)for(const o in e){if(!(o in s))throw new Error(`Unrecognized key: "${o}"`);e[o]&&(s[o]=new n({type:"nonoptional",innerType:i[o]}))}else for(const o in i)s[o]=new n({type:"nonoptional",innerType:i[o]});return Wr(this,"shape",s),s}});return Gn(t,r)}function pi(n,t=0){var e;if(n.aborted===!0)return!0;for(let r=t;r<n.issues.length;r++)if(((e=n.issues[r])==null?void 0:e.continue)!==!0)return!0;return!1}function fi(n,t){return t.map(e=>{var r;return(r=e).path??(r.path=[]),e.path.unshift(n),e})}function oa(n){return typeof n=="string"?n:n==null?void 0:n.message}function Hn(n,t,e){var i,s,o,a,c,u;const r={...n,path:n.path??[]};if(!n.message){const h=oa((o=(s=(i=n.inst)==null?void 0:i._zod.def)==null?void 0:s.error)==null?void 0:o.call(s,n))??oa((a=t==null?void 0:t.error)==null?void 0:a.call(t,n))??oa((c=e.customError)==null?void 0:c.call(e,n))??oa((u=e.localeError)==null?void 0:u.call(e,n))??"Invalid input";r.message=h}return delete r.inst,delete r.continue,t!=null&&t.reportInput||delete r.input,r}function Xh(n){return Array.isArray(n)?"array":typeof n=="string"?"string":"unknown"}function Ds(...n){const[t,e,r]=n;return typeof t=="string"?{message:t,code:"custom",input:e,inst:r}:{...t}}const $v=(n,t)=>{n.name="$ZodError",Object.defineProperty(n,"_zod",{value:n._zod,enumerable:!1}),Object.defineProperty(n,"issues",{value:t,enumerable:!1}),n.message=JSON.stringify(t,wu,2),Object.defineProperty(n,"toString",{value:()=>n.message,enumerable:!1})},Tv=A("$ZodError",$v),Iv=A("$ZodError",$v,{Parent:Error});function D$(n,t=e=>e.message){const e={},r=[];for(const i of n.issues)i.path.length>0?(e[i.path[0]]=e[i.path[0]]||[],e[i.path[0]].push(t(i))):r.push(t(i));return{formErrors:r,fieldErrors:e}}function L$(n,t=e=>e.message){const e={_errors:[]},r=i=>{for(const s of i.issues)if(s.code==="invalid_union"&&s.errors.length)s.errors.map(o=>r({issues:o}));else if(s.code==="invalid_key")r({issues:s.issues});else if(s.code==="invalid_element")r({issues:s.issues});else if(s.path.length===0)e._errors.push(t(s));else{let o=e,a=0;for(;a<s.path.length;){const c=s.path[a];a===s.path.length-1?(o[c]=o[c]||{_errors:[]},o[c]._errors.push(t(s))):o[c]=o[c]||{_errors:[]},o=o[c],a++}}};return r(n),e}const Kh=n=>(t,e,r,i)=>{const s=r?Object.assign(r,{async:!1}):{async:!1},o=t._zod.run({value:e,issues:[]},s);if(o instanceof Promise)throw new mi;if(o.issues.length){const a=new((i==null?void 0:i.Err)??n)(o.issues.map(c=>Hn(c,s,Fn())));throw Ev(a,i==null?void 0:i.callee),a}return o.value},Jh=n=>async(t,e,r,i)=>{const s=r?Object.assign(r,{async:!0}):{async:!0};let o=t._zod.run({value:e,issues:[]},s);if(o instanceof Promise&&(o=await o),o.issues.length){const a=new((i==null?void 0:i.Err)??n)(o.issues.map(c=>Hn(c,s,Fn())));throw Ev(a,i==null?void 0:i.callee),a}return o.value},Dl=n=>(t,e,r)=>{const i=r?{...r,async:!1}:{async:!1},s=t._zod.run({value:e,issues:[]},i);if(s instanceof Promise)throw new mi;return s.issues.length?{success:!1,error:new(n??Tv)(s.issues.map(o=>Hn(o,i,Fn())))}:{success:!0,data:s.value}},z$=Dl(Iv),Ll=n=>async(t,e,r)=>{const i=r?Object.assign(r,{async:!0}):{async:!0};let s=t._zod.run({value:e,issues:[]},i);return s instanceof Promise&&(s=await s),s.issues.length?{success:!1,error:new n(s.issues.map(o=>Hn(o,i,Fn())))}:{success:!0,data:s.value}},O$=Ll(Iv),M$=n=>(t,e,r)=>{const i=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return Kh(n)(t,e,i)},N$=n=>(t,e,r)=>Kh(n)(t,e,r),U$=n=>async(t,e,r)=>{const i=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return Jh(n)(t,e,i)},F$=n=>async(t,e,r)=>Jh(n)(t,e,r),H$=n=>(t,e,r)=>{const i=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return Dl(n)(t,e,i)},W$=n=>(t,e,r)=>Dl(n)(t,e,r),Z$=n=>async(t,e,r)=>{const i=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return Ll(n)(t,e,i)},B$=n=>async(t,e,r)=>Ll(n)(t,e,r),V$=/^[cC][^\s-]{8,}$/,j$=/^[0-9a-z]+$/,G$=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,q$=/^[0-9a-vA-V]{20}$/,Y$=/^[A-Za-z0-9]{27}$/,X$=/^[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)?)?)$/,J$=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,Tf=n=>n?new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${n}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,Q$=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,eT="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function tT(){return new RegExp(eT,"u")}const nT=/^(?:(?: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])$/,rT=/^(([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}|:))$/,iT=/^((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])$/,sT=/^(([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])$/,oT=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Cv=/^[A-Za-z0-9_-]*$/,aT=/^\+[1-9]\d{6,14}$/,Rv="(?:(?:\\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])))",lT=new RegExp(`^${Rv}$`);function Pv(n){const t="(?:[01]\\d|2[0-3]):[0-5]\\d";return typeof n.precision=="number"?n.precision===-1?`${t}`:n.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${n.precision}}`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function cT(n){return new RegExp(`^${Pv(n)}$`)}function uT(n){const t=Pv({precision:n.precision}),e=["Z"];n.local&&e.push(""),n.offset&&e.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");const r=`${t}(?:${e.join("|")})`;return new RegExp(`^${Rv}T(?:${r})$`)}const hT=n=>{const t=n?`[\\s\\S]{${(n==null?void 0:n.minimum)??0},${(n==null?void 0:n.maximum)??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)},dT=/^-?\d+$/,Dv=/^-?\d+(?:\.\d+)?$/,pT=/^(?:true|false)$/i,fT=/^[^A-Z]*$/,gT=/^[^a-z]*$/,st=A("$ZodCheck",(n,t)=>{var e;n._zod??(n._zod={}),n._zod.def=t,(e=n._zod).onattach??(e.onattach=[])}),Lv={number:"number",bigint:"bigint",object:"date"},zv=A("$ZodCheckLessThan",(n,t)=>{st.init(n,t);const e=Lv[typeof t.value];n._zod.onattach.push(r=>{const i=r._zod.bag,s=(t.inclusive?i.maximum:i.exclusiveMaximum)??Number.POSITIVE_INFINITY;t.value<s&&(t.inclusive?i.maximum=t.value:i.exclusiveMaximum=t.value)}),n._zod.check=r=>{(t.inclusive?r.value<=t.value:r.value<t.value)||r.issues.push({origin:e,code:"too_big",maximum:typeof t.value=="object"?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:n,continue:!t.abort})}}),Ov=A("$ZodCheckGreaterThan",(n,t)=>{st.init(n,t);const e=Lv[typeof t.value];n._zod.onattach.push(r=>{const i=r._zod.bag,s=(t.inclusive?i.minimum:i.exclusiveMinimum)??Number.NEGATIVE_INFINITY;t.value>s&&(t.inclusive?i.minimum=t.value:i.exclusiveMinimum=t.value)}),n._zod.check=r=>{(t.inclusive?r.value>=t.value:r.value>t.value)||r.issues.push({origin:e,code:"too_small",minimum:typeof t.value=="object"?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:n,continue:!t.abort})}}),mT=A("$ZodCheckMultipleOf",(n,t)=>{st.init(n,t),n._zod.onattach.push(e=>{var r;(r=e._zod.bag).multipleOf??(r.multipleOf=t.value)}),n._zod.check=e=>{if(typeof e.value!=typeof t.value)throw new Error("Cannot mix number and bigint in multiple_of check.");(typeof e.value=="bigint"?e.value%t.value===BigInt(0):w$(e.value,t.value)===0)||e.issues.push({origin:typeof e.value,code:"not_multiple_of",divisor:t.value,input:e.value,inst:n,continue:!t.abort})}}),vT=A("$ZodCheckNumberFormat",(n,t)=>{var o;st.init(n,t),t.format=t.format||"float64";const e=(o=t.format)==null?void 0:o.includes("int"),r=e?"int":"number",[i,s]=E$[t.format];n._zod.onattach.push(a=>{const c=a._zod.bag;c.format=t.format,c.minimum=i,c.maximum=s,e&&(c.pattern=dT)}),n._zod.check=a=>{const c=a.value;if(e){if(!Number.isInteger(c)){a.issues.push({expected:r,format:t.format,code:"invalid_type",continue:!1,input:c,inst:n});return}if(!Number.isSafeInteger(c)){c>0?a.issues.push({input:c,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:n,origin:r,inclusive:!0,continue:!t.abort}):a.issues.push({input:c,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:n,origin:r,inclusive:!0,continue:!t.abort});return}}c<i&&a.issues.push({origin:"number",input:c,code:"too_small",minimum:i,inclusive:!0,inst:n,continue:!t.abort}),c>s&&a.issues.push({origin:"number",input:c,code:"too_big",maximum:s,inclusive:!0,inst:n,continue:!t.abort})}}),yT=A("$ZodCheckMaxLength",(n,t)=>{var e;st.init(n,t),(e=n._zod.def).when??(e.when=r=>{const i=r.value;return!qh(i)&&i.length!==void 0}),n._zod.onattach.push(r=>{const i=r._zod.bag.maximum??Number.POSITIVE_INFINITY;t.maximum<i&&(r._zod.bag.maximum=t.maximum)}),n._zod.check=r=>{const i=r.value;if(i.length<=t.maximum)return;const o=Xh(i);r.issues.push({origin:o,code:"too_big",maximum:t.maximum,inclusive:!0,input:i,inst:n,continue:!t.abort})}}),bT=A("$ZodCheckMinLength",(n,t)=>{var e;st.init(n,t),(e=n._zod.def).when??(e.when=r=>{const i=r.value;return!qh(i)&&i.length!==void 0}),n._zod.onattach.push(r=>{const i=r._zod.bag.minimum??Number.NEGATIVE_INFINITY;t.minimum>i&&(r._zod.bag.minimum=t.minimum)}),n._zod.check=r=>{const i=r.value;if(i.length>=t.minimum)return;const o=Xh(i);r.issues.push({origin:o,code:"too_small",minimum:t.minimum,inclusive:!0,input:i,inst:n,continue:!t.abort})}}),wT=A("$ZodCheckLengthEquals",(n,t)=>{var e;st.init(n,t),(e=n._zod.def).when??(e.when=r=>{const i=r.value;return!qh(i)&&i.length!==void 0}),n._zod.onattach.push(r=>{const i=r._zod.bag;i.minimum=t.length,i.maximum=t.length,i.length=t.length}),n._zod.check=r=>{const i=r.value,s=i.length;if(s===t.length)return;const o=Xh(i),a=s>t.length;r.issues.push({origin:o,...a?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:r.value,inst:n,continue:!t.abort})}}),zl=A("$ZodCheckStringFormat",(n,t)=>{var e,r;st.init(n,t),n._zod.onattach.push(i=>{const s=i._zod.bag;s.format=t.format,t.pattern&&(s.patterns??(s.patterns=new Set),s.patterns.add(t.pattern))}),t.pattern?(e=n._zod).check??(e.check=i=>{t.pattern.lastIndex=0,!t.pattern.test(i.value)&&i.issues.push({origin:"string",code:"invalid_format",format:t.format,input:i.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:n,continue:!t.abort})}):(r=n._zod).check??(r.check=()=>{})}),ST=A("$ZodCheckRegex",(n,t)=>{zl.init(n,t),n._zod.check=e=>{t.pattern.lastIndex=0,!t.pattern.test(e.value)&&e.issues.push({origin:"string",code:"invalid_format",format:"regex",input:e.value,pattern:t.pattern.toString(),inst:n,continue:!t.abort})}}),_T=A("$ZodCheckLowerCase",(n,t)=>{t.pattern??(t.pattern=fT),zl.init(n,t)}),kT=A("$ZodCheckUpperCase",(n,t)=>{t.pattern??(t.pattern=gT),zl.init(n,t)}),xT=A("$ZodCheckIncludes",(n,t)=>{st.init(n,t);const e=Ui(t.includes),r=new RegExp(typeof t.position=="number"?`^.{${t.position}}${e}`:e);t.pattern=r,n._zod.onattach.push(i=>{const s=i._zod.bag;s.patterns??(s.patterns=new Set),s.patterns.add(r)}),n._zod.check=i=>{i.value.includes(t.includes,t.position)||i.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:i.value,inst:n,continue:!t.abort})}}),ET=A("$ZodCheckStartsWith",(n,t)=>{st.init(n,t);const e=new RegExp(`^${Ui(t.prefix)}.*`);t.pattern??(t.pattern=e),n._zod.onattach.push(r=>{const i=r._zod.bag;i.patterns??(i.patterns=new Set),i.patterns.add(e)}),n._zod.check=r=>{r.value.startsWith(t.prefix)||r.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:r.value,inst:n,continue:!t.abort})}}),AT=A("$ZodCheckEndsWith",(n,t)=>{st.init(n,t);const e=new RegExp(`.*${Ui(t.suffix)}$`);t.pattern??(t.pattern=e),n._zod.onattach.push(r=>{const i=r._zod.bag;i.patterns??(i.patterns=new Set),i.patterns.add(e)}),n._zod.check=r=>{r.value.endsWith(t.suffix)||r.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:r.value,inst:n,continue:!t.abort})}}),$T=A("$ZodCheckOverwrite",(n,t)=>{st.init(n,t),n._zod.check=e=>{e.value=t.tx(e.value)}});class TT{constructor(t=[]){this.content=[],this.indent=0,this&&(this.args=t)}indented(t){this.indent+=1,t(this),this.indent-=1}write(t){if(typeof t=="function"){t(this,{execution:"sync"}),t(this,{execution:"async"});return}const r=t.split(`
|
|
5
|
+
`).filter(o=>o),i=Math.min(...r.map(o=>o.length-o.trimStart().length)),s=r.map(o=>o.slice(i)).map(o=>" ".repeat(this.indent*2)+o);for(const o of s)this.content.push(o)}compile(){const t=Function,e=this==null?void 0:this.args,i=[...((this==null?void 0:this.content)??[""]).map(s=>` ${s}`)];return new t(...e,i.join(`
|
|
6
|
+
`))}}const IT={major:4,minor:3,patch:6},ge=A("$ZodType",(n,t)=>{var i;var e;n??(n={}),n._zod.def=t,n._zod.bag=n._zod.bag||{},n._zod.version=IT;const r=[...n._zod.def.checks??[]];n._zod.traits.has("$ZodCheck")&&r.unshift(n);for(const s of r)for(const o of s._zod.onattach)o(n);if(r.length===0)(e=n._zod).deferred??(e.deferred=[]),(i=n._zod.deferred)==null||i.push(()=>{n._zod.run=n._zod.parse});else{const s=(a,c,u)=>{let h=pi(a),p;for(const v of c){if(v._zod.def.when){if(!v._zod.def.when(a))continue}else if(h)continue;const g=a.issues.length,_=v._zod.check(a);if(_ instanceof Promise&&(u==null?void 0:u.async)===!1)throw new mi;if(p||_ instanceof Promise)p=(p??Promise.resolve()).then(async()=>{await _,a.issues.length!==g&&(h||(h=pi(a,g)))});else{if(a.issues.length===g)continue;h||(h=pi(a,g))}}return p?p.then(()=>a):a},o=(a,c,u)=>{if(pi(a))return a.aborted=!0,a;const h=s(c,r,u);if(h instanceof Promise){if(u.async===!1)throw new mi;return h.then(p=>n._zod.parse(p,u))}return n._zod.parse(h,u)};n._zod.run=(a,c)=>{if(c.skipChecks)return n._zod.parse(a,c);if(c.direction==="backward"){const h=n._zod.parse({value:a.value,issues:[]},{...c,skipChecks:!0});return h instanceof Promise?h.then(p=>o(p,a,c)):o(h,a,c)}const u=n._zod.parse(a,c);if(u instanceof Promise){if(c.async===!1)throw new mi;return u.then(h=>s(h,r,c))}return s(u,r,c)}}ne(n,"~standard",()=>({validate:s=>{var o;try{const a=z$(n,s);return a.success?{value:a.data}:{issues:(o=a.error)==null?void 0:o.issues}}catch{return O$(n,s).then(c=>{var u;return c.success?{value:c.data}:{issues:(u=c.error)==null?void 0:u.issues}})}},vendor:"zod",version:1}))}),Qh=A("$ZodString",(n,t)=>{var e;ge.init(n,t),n._zod.pattern=[...((e=n==null?void 0:n._zod.bag)==null?void 0:e.patterns)??[]].pop()??hT(n._zod.bag),n._zod.parse=(r,i)=>{if(t.coerce)try{r.value=String(r.value)}catch{}return typeof r.value=="string"||r.issues.push({expected:"string",code:"invalid_type",input:r.value,inst:n}),r}}),de=A("$ZodStringFormat",(n,t)=>{zl.init(n,t),Qh.init(n,t)}),CT=A("$ZodGUID",(n,t)=>{t.pattern??(t.pattern=J$),de.init(n,t)}),RT=A("$ZodUUID",(n,t)=>{if(t.version){const r={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(r===void 0)throw new Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=Tf(r))}else t.pattern??(t.pattern=Tf());de.init(n,t)}),PT=A("$ZodEmail",(n,t)=>{t.pattern??(t.pattern=Q$),de.init(n,t)}),DT=A("$ZodURL",(n,t)=>{de.init(n,t),n._zod.check=e=>{try{const r=e.value.trim(),i=new URL(r);t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(i.hostname)||e.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:t.hostname.source,input:e.value,inst:n,continue:!t.abort})),t.protocol&&(t.protocol.lastIndex=0,t.protocol.test(i.protocol.endsWith(":")?i.protocol.slice(0,-1):i.protocol)||e.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:e.value,inst:n,continue:!t.abort})),t.normalize?e.value=i.href:e.value=r;return}catch{e.issues.push({code:"invalid_format",format:"url",input:e.value,inst:n,continue:!t.abort})}}}),LT=A("$ZodEmoji",(n,t)=>{t.pattern??(t.pattern=tT()),de.init(n,t)}),zT=A("$ZodNanoID",(n,t)=>{t.pattern??(t.pattern=X$),de.init(n,t)}),OT=A("$ZodCUID",(n,t)=>{t.pattern??(t.pattern=V$),de.init(n,t)}),MT=A("$ZodCUID2",(n,t)=>{t.pattern??(t.pattern=j$),de.init(n,t)}),NT=A("$ZodULID",(n,t)=>{t.pattern??(t.pattern=G$),de.init(n,t)}),UT=A("$ZodXID",(n,t)=>{t.pattern??(t.pattern=q$),de.init(n,t)}),FT=A("$ZodKSUID",(n,t)=>{t.pattern??(t.pattern=Y$),de.init(n,t)}),HT=A("$ZodISODateTime",(n,t)=>{t.pattern??(t.pattern=uT(t)),de.init(n,t)}),WT=A("$ZodISODate",(n,t)=>{t.pattern??(t.pattern=lT),de.init(n,t)}),ZT=A("$ZodISOTime",(n,t)=>{t.pattern??(t.pattern=cT(t)),de.init(n,t)}),BT=A("$ZodISODuration",(n,t)=>{t.pattern??(t.pattern=K$),de.init(n,t)}),VT=A("$ZodIPv4",(n,t)=>{t.pattern??(t.pattern=nT),de.init(n,t),n._zod.bag.format="ipv4"}),jT=A("$ZodIPv6",(n,t)=>{t.pattern??(t.pattern=rT),de.init(n,t),n._zod.bag.format="ipv6",n._zod.check=e=>{try{new URL(`http://[${e.value}]`)}catch{e.issues.push({code:"invalid_format",format:"ipv6",input:e.value,inst:n,continue:!t.abort})}}}),GT=A("$ZodCIDRv4",(n,t)=>{t.pattern??(t.pattern=iT),de.init(n,t)}),qT=A("$ZodCIDRv6",(n,t)=>{t.pattern??(t.pattern=sT),de.init(n,t),n._zod.check=e=>{const r=e.value.split("/");try{if(r.length!==2)throw new Error;const[i,s]=r;if(!s)throw new Error;const o=Number(s);if(`${o}`!==s)throw new Error;if(o<0||o>128)throw new Error;new URL(`http://[${i}]`)}catch{e.issues.push({code:"invalid_format",format:"cidrv6",input:e.value,inst:n,continue:!t.abort})}}});function Mv(n){if(n==="")return!0;if(n.length%4!==0)return!1;try{return atob(n),!0}catch{return!1}}const YT=A("$ZodBase64",(n,t)=>{t.pattern??(t.pattern=oT),de.init(n,t),n._zod.bag.contentEncoding="base64",n._zod.check=e=>{Mv(e.value)||e.issues.push({code:"invalid_format",format:"base64",input:e.value,inst:n,continue:!t.abort})}});function XT(n){if(!Cv.test(n))return!1;const t=n.replace(/[-_]/g,r=>r==="-"?"+":"/"),e=t.padEnd(Math.ceil(t.length/4)*4,"=");return Mv(e)}const KT=A("$ZodBase64URL",(n,t)=>{t.pattern??(t.pattern=Cv),de.init(n,t),n._zod.bag.contentEncoding="base64url",n._zod.check=e=>{XT(e.value)||e.issues.push({code:"invalid_format",format:"base64url",input:e.value,inst:n,continue:!t.abort})}}),JT=A("$ZodE164",(n,t)=>{t.pattern??(t.pattern=aT),de.init(n,t)});function QT(n,t=null){try{const e=n.split(".");if(e.length!==3)return!1;const[r]=e;if(!r)return!1;const i=JSON.parse(atob(r));return!("typ"in i&&(i==null?void 0:i.typ)!=="JWT"||!i.alg||t&&(!("alg"in i)||i.alg!==t))}catch{return!1}}const eI=A("$ZodJWT",(n,t)=>{de.init(n,t),n._zod.check=e=>{QT(e.value,t.alg)||e.issues.push({code:"invalid_format",format:"jwt",input:e.value,inst:n,continue:!t.abort})}}),Nv=A("$ZodNumber",(n,t)=>{ge.init(n,t),n._zod.pattern=n._zod.bag.pattern??Dv,n._zod.parse=(e,r)=>{if(t.coerce)try{e.value=Number(e.value)}catch{}const i=e.value;if(typeof i=="number"&&!Number.isNaN(i)&&Number.isFinite(i))return e;const s=typeof i=="number"?Number.isNaN(i)?"NaN":Number.isFinite(i)?void 0:"Infinity":void 0;return e.issues.push({expected:"number",code:"invalid_type",input:i,inst:n,...s?{received:s}:{}}),e}}),tI=A("$ZodNumberFormat",(n,t)=>{vT.init(n,t),Nv.init(n,t)}),nI=A("$ZodBoolean",(n,t)=>{ge.init(n,t),n._zod.pattern=pT,n._zod.parse=(e,r)=>{if(t.coerce)try{e.value=!!e.value}catch{}const i=e.value;return typeof i=="boolean"||e.issues.push({expected:"boolean",code:"invalid_type",input:i,inst:n}),e}}),rI=A("$ZodUnknown",(n,t)=>{ge.init(n,t),n._zod.parse=e=>e}),iI=A("$ZodNever",(n,t)=>{ge.init(n,t),n._zod.parse=(e,r)=>(e.issues.push({expected:"never",code:"invalid_type",input:e.value,inst:n}),e)});function If(n,t,e){n.issues.length&&t.issues.push(...fi(e,n.issues)),t.value[e]=n.value}const sI=A("$ZodArray",(n,t)=>{ge.init(n,t),n._zod.parse=(e,r)=>{const i=e.value;if(!Array.isArray(i))return e.issues.push({expected:"array",code:"invalid_type",input:i,inst:n}),e;e.value=Array(i.length);const s=[];for(let o=0;o<i.length;o++){const a=i[o],c=t.element._zod.run({value:a,issues:[]},r);c instanceof Promise?s.push(c.then(u=>If(u,e,o))):If(c,e,o)}return s.length?Promise.all(s).then(()=>e):e}});function Ja(n,t,e,r,i){if(n.issues.length){if(i&&!(e in r))return;t.issues.push(...fi(e,n.issues))}n.value===void 0?e in r&&(t.value[e]=void 0):t.value[e]=n.value}function Uv(n){var r,i,s,o;const t=Object.keys(n.shape);for(const a of t)if(!((o=(s=(i=(r=n.shape)==null?void 0:r[a])==null?void 0:i._zod)==null?void 0:s.traits)!=null&&o.has("$ZodType")))throw new Error(`Invalid element at key "${a}": expected a Zod schema`);const e=x$(n.shape);return{...n,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(e)}}function Fv(n,t,e,r,i,s){const o=[],a=i.keySet,c=i.catchall._zod,u=c.def.type,h=c.optout==="optional";for(const p in t){if(a.has(p))continue;if(u==="never"){o.push(p);continue}const v=c.run({value:t[p],issues:[]},r);v instanceof Promise?n.push(v.then(g=>Ja(g,e,p,t,h))):Ja(v,e,p,t,h)}return o.length&&e.issues.push({code:"unrecognized_keys",keys:o,input:t,inst:s}),n.length?Promise.all(n).then(()=>e):e}const oI=A("$ZodObject",(n,t)=>{ge.init(n,t);const e=Object.getOwnPropertyDescriptor(t,"shape");if(!(e!=null&&e.get)){const a=t.shape;Object.defineProperty(t,"shape",{get:()=>{const c={...a};return Object.defineProperty(t,"shape",{value:c}),c}})}const r=Gh(()=>Uv(t));ne(n._zod,"propValues",()=>{const a=t.shape,c={};for(const u in a){const h=a[u]._zod;if(h.values){c[u]??(c[u]=new Set);for(const p of h.values)c[u].add(p)}}return c});const i=Ka,s=t.catchall;let o;n._zod.parse=(a,c)=>{o??(o=r.value);const u=a.value;if(!i(u))return a.issues.push({expected:"object",code:"invalid_type",input:u,inst:n}),a;a.value={};const h=[],p=o.shape;for(const v of o.keys){const g=p[v],_=g._zod.optout==="optional",k=g._zod.run({value:u[v],issues:[]},c);k instanceof Promise?h.push(k.then(T=>Ja(T,a,v,u,_))):Ja(k,a,v,u,_)}return s?Fv(h,u,a,c,r.value,n):h.length?Promise.all(h).then(()=>a):a}}),aI=A("$ZodObjectJIT",(n,t)=>{oI.init(n,t);const e=n._zod.parse,r=Gh(()=>Uv(t)),i=v=>{var W;const g=new TT(["shape","payload","ctx"]),_=r.value,k=N=>{const F=$f(N);return`shape[${F}]._zod.run({ value: input[${F}], issues: [] }, ctx)`};g.write("const input = payload.value;");const T=Object.create(null);let P=0;for(const N of _.keys)T[N]=`key_${P++}`;g.write("const newResult = {};");for(const N of _.keys){const F=T[N],Y=$f(N),j=v[N],le=((W=j==null?void 0:j._zod)==null?void 0:W.optout)==="optional";g.write(`const ${F} = ${k(N)};`),le?g.write(`
|
|
7
|
+
if (${F}.issues.length) {
|
|
8
|
+
if (${Y} in input) {
|
|
9
|
+
payload.issues = payload.issues.concat(${F}.issues.map(iss => ({
|
|
10
|
+
...iss,
|
|
11
|
+
path: iss.path ? [${Y}, ...iss.path] : [${Y}]
|
|
12
|
+
})));
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
if (${F}.value === undefined) {
|
|
17
|
+
if (${Y} in input) {
|
|
18
|
+
newResult[${Y}] = undefined;
|
|
19
|
+
}
|
|
20
|
+
} else {
|
|
21
|
+
newResult[${Y}] = ${F}.value;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
`):g.write(`
|
|
25
|
+
if (${F}.issues.length) {
|
|
26
|
+
payload.issues = payload.issues.concat(${F}.issues.map(iss => ({
|
|
27
|
+
...iss,
|
|
28
|
+
path: iss.path ? [${Y}, ...iss.path] : [${Y}]
|
|
29
|
+
})));
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
if (${F}.value === undefined) {
|
|
33
|
+
if (${Y} in input) {
|
|
34
|
+
newResult[${Y}] = undefined;
|
|
35
|
+
}
|
|
36
|
+
} else {
|
|
37
|
+
newResult[${Y}] = ${F}.value;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
`)}g.write("payload.value = newResult;"),g.write("return payload;");const R=g.compile();return(N,F)=>R(v,N,F)};let s;const o=Ka,a=!kv.jitless,u=a&&_$.value,h=t.catchall;let p;n._zod.parse=(v,g)=>{p??(p=r.value);const _=v.value;return o(_)?a&&u&&(g==null?void 0:g.async)===!1&&g.jitless!==!0?(s||(s=i(t.shape)),v=s(v,g),h?Fv([],_,v,g,p,n):v):e(v,g):(v.issues.push({expected:"object",code:"invalid_type",input:_,inst:n}),v)}});function Cf(n,t,e,r){for(const s of n)if(s.issues.length===0)return t.value=s.value,t;const i=n.filter(s=>!pi(s));return i.length===1?(t.value=i[0].value,i[0]):(t.issues.push({code:"invalid_union",input:t.value,inst:e,errors:n.map(s=>s.issues.map(o=>Hn(o,r,Fn())))}),t)}const lI=A("$ZodUnion",(n,t)=>{ge.init(n,t),ne(n._zod,"optin",()=>t.options.some(i=>i._zod.optin==="optional")?"optional":void 0),ne(n._zod,"optout",()=>t.options.some(i=>i._zod.optout==="optional")?"optional":void 0),ne(n._zod,"values",()=>{if(t.options.every(i=>i._zod.values))return new Set(t.options.flatMap(i=>Array.from(i._zod.values)))}),ne(n._zod,"pattern",()=>{if(t.options.every(i=>i._zod.pattern)){const i=t.options.map(s=>s._zod.pattern);return new RegExp(`^(${i.map(s=>Yh(s.source)).join("|")})$`)}});const e=t.options.length===1,r=t.options[0]._zod.run;n._zod.parse=(i,s)=>{if(e)return r(i,s);let o=!1;const a=[];for(const c of t.options){const u=c._zod.run({value:i.value,issues:[]},s);if(u instanceof Promise)a.push(u),o=!0;else{if(u.issues.length===0)return u;a.push(u)}}return o?Promise.all(a).then(c=>Cf(c,i,n,s)):Cf(a,i,n,s)}}),cI=A("$ZodIntersection",(n,t)=>{ge.init(n,t),n._zod.parse=(e,r)=>{const i=e.value,s=t.left._zod.run({value:i,issues:[]},r),o=t.right._zod.run({value:i,issues:[]},r);return s instanceof Promise||o instanceof Promise?Promise.all([s,o]).then(([c,u])=>Rf(e,c,u)):Rf(e,s,o)}});function Su(n,t){if(n===t)return{valid:!0,data:n};if(n instanceof Date&&t instanceof Date&&+n==+t)return{valid:!0,data:n};if(Ni(n)&&Ni(t)){const e=Object.keys(t),r=Object.keys(n).filter(s=>e.indexOf(s)!==-1),i={...n,...t};for(const s of r){const o=Su(n[s],t[s]);if(!o.valid)return{valid:!1,mergeErrorPath:[s,...o.mergeErrorPath]};i[s]=o.data}return{valid:!0,data:i}}if(Array.isArray(n)&&Array.isArray(t)){if(n.length!==t.length)return{valid:!1,mergeErrorPath:[]};const e=[];for(let r=0;r<n.length;r++){const i=n[r],s=t[r],o=Su(i,s);if(!o.valid)return{valid:!1,mergeErrorPath:[r,...o.mergeErrorPath]};e.push(o.data)}return{valid:!0,data:e}}return{valid:!1,mergeErrorPath:[]}}function Rf(n,t,e){const r=new Map;let i;for(const a of t.issues)if(a.code==="unrecognized_keys"){i??(i=a);for(const c of a.keys)r.has(c)||r.set(c,{}),r.get(c).l=!0}else n.issues.push(a);for(const a of e.issues)if(a.code==="unrecognized_keys")for(const c of a.keys)r.has(c)||r.set(c,{}),r.get(c).r=!0;else n.issues.push(a);const s=[...r].filter(([,a])=>a.l&&a.r).map(([a])=>a);if(s.length&&i&&n.issues.push({...i,keys:s}),pi(n))return n;const o=Su(t.value,e.value);if(!o.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(o.mergeErrorPath)}`);return n.value=o.data,n}const uI=A("$ZodRecord",(n,t)=>{ge.init(n,t),n._zod.parse=(e,r)=>{const i=e.value;if(!Ni(i))return e.issues.push({expected:"record",code:"invalid_type",input:i,inst:n}),e;const s=[],o=t.keyType._zod.values;if(o){e.value={};const a=new Set;for(const u of o)if(typeof u=="string"||typeof u=="number"||typeof u=="symbol"){a.add(typeof u=="number"?u.toString():u);const h=t.valueType._zod.run({value:i[u],issues:[]},r);h instanceof Promise?s.push(h.then(p=>{p.issues.length&&e.issues.push(...fi(u,p.issues)),e.value[u]=p.value})):(h.issues.length&&e.issues.push(...fi(u,h.issues)),e.value[u]=h.value)}let c;for(const u in i)a.has(u)||(c=c??[],c.push(u));c&&c.length>0&&e.issues.push({code:"unrecognized_keys",input:i,inst:n,keys:c})}else{e.value={};for(const a of Reflect.ownKeys(i)){if(a==="__proto__")continue;let c=t.keyType._zod.run({value:a,issues:[]},r);if(c instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(typeof a=="string"&&Dv.test(a)&&c.issues.length){const p=t.keyType._zod.run({value:Number(a),issues:[]},r);if(p instanceof Promise)throw new Error("Async schemas not supported in object keys currently");p.issues.length===0&&(c=p)}if(c.issues.length){t.mode==="loose"?e.value[a]=i[a]:e.issues.push({code:"invalid_key",origin:"record",issues:c.issues.map(p=>Hn(p,r,Fn())),input:a,path:[a],inst:n});continue}const h=t.valueType._zod.run({value:i[a],issues:[]},r);h instanceof Promise?s.push(h.then(p=>{p.issues.length&&e.issues.push(...fi(a,p.issues)),e.value[c.value]=p.value})):(h.issues.length&&e.issues.push(...fi(a,h.issues)),e.value[c.value]=h.value)}}return s.length?Promise.all(s).then(()=>e):e}}),hI=A("$ZodEnum",(n,t)=>{ge.init(n,t);const e=xv(t.entries),r=new Set(e);n._zod.values=r,n._zod.pattern=new RegExp(`^(${e.filter(i=>k$.has(typeof i)).map(i=>typeof i=="string"?Ui(i):i.toString()).join("|")})$`),n._zod.parse=(i,s)=>{const o=i.value;return r.has(o)||i.issues.push({code:"invalid_value",values:e,input:o,inst:n}),i}}),dI=A("$ZodLiteral",(n,t)=>{if(ge.init(n,t),t.values.length===0)throw new Error("Cannot create literal schema with no valid values");const e=new Set(t.values);n._zod.values=e,n._zod.pattern=new RegExp(`^(${t.values.map(r=>typeof r=="string"?Ui(r):r?Ui(r.toString()):String(r)).join("|")})$`),n._zod.parse=(r,i)=>{const s=r.value;return e.has(s)||r.issues.push({code:"invalid_value",values:t.values,input:s,inst:n}),r}}),pI=A("$ZodTransform",(n,t)=>{ge.init(n,t),n._zod.parse=(e,r)=>{if(r.direction==="backward")throw new _v(n.constructor.name);const i=t.transform(e.value,e);if(r.async)return(i instanceof Promise?i:Promise.resolve(i)).then(o=>(e.value=o,e));if(i instanceof Promise)throw new mi;return e.value=i,e}});function Pf(n,t){return n.issues.length&&t===void 0?{issues:[],value:void 0}:n}const Hv=A("$ZodOptional",(n,t)=>{ge.init(n,t),n._zod.optin="optional",n._zod.optout="optional",ne(n._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),ne(n._zod,"pattern",()=>{const e=t.innerType._zod.pattern;return e?new RegExp(`^(${Yh(e.source)})?$`):void 0}),n._zod.parse=(e,r)=>{if(t.innerType._zod.optin==="optional"){const i=t.innerType._zod.run(e,r);return i instanceof Promise?i.then(s=>Pf(s,e.value)):Pf(i,e.value)}return e.value===void 0?e:t.innerType._zod.run(e,r)}}),fI=A("$ZodExactOptional",(n,t)=>{Hv.init(n,t),ne(n._zod,"values",()=>t.innerType._zod.values),ne(n._zod,"pattern",()=>t.innerType._zod.pattern),n._zod.parse=(e,r)=>t.innerType._zod.run(e,r)}),gI=A("$ZodNullable",(n,t)=>{ge.init(n,t),ne(n._zod,"optin",()=>t.innerType._zod.optin),ne(n._zod,"optout",()=>t.innerType._zod.optout),ne(n._zod,"pattern",()=>{const e=t.innerType._zod.pattern;return e?new RegExp(`^(${Yh(e.source)}|null)$`):void 0}),ne(n._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),n._zod.parse=(e,r)=>e.value===null?e:t.innerType._zod.run(e,r)}),mI=A("$ZodDefault",(n,t)=>{ge.init(n,t),n._zod.optin="optional",ne(n._zod,"values",()=>t.innerType._zod.values),n._zod.parse=(e,r)=>{if(r.direction==="backward")return t.innerType._zod.run(e,r);if(e.value===void 0)return e.value=t.defaultValue,e;const i=t.innerType._zod.run(e,r);return i instanceof Promise?i.then(s=>Df(s,t)):Df(i,t)}});function Df(n,t){return n.value===void 0&&(n.value=t.defaultValue),n}const vI=A("$ZodPrefault",(n,t)=>{ge.init(n,t),n._zod.optin="optional",ne(n._zod,"values",()=>t.innerType._zod.values),n._zod.parse=(e,r)=>(r.direction==="backward"||e.value===void 0&&(e.value=t.defaultValue),t.innerType._zod.run(e,r))}),yI=A("$ZodNonOptional",(n,t)=>{ge.init(n,t),ne(n._zod,"values",()=>{const e=t.innerType._zod.values;return e?new Set([...e].filter(r=>r!==void 0)):void 0}),n._zod.parse=(e,r)=>{const i=t.innerType._zod.run(e,r);return i instanceof Promise?i.then(s=>Lf(s,n)):Lf(i,n)}});function Lf(n,t){return!n.issues.length&&n.value===void 0&&n.issues.push({code:"invalid_type",expected:"nonoptional",input:n.value,inst:t}),n}const bI=A("$ZodCatch",(n,t)=>{ge.init(n,t),ne(n._zod,"optin",()=>t.innerType._zod.optin),ne(n._zod,"optout",()=>t.innerType._zod.optout),ne(n._zod,"values",()=>t.innerType._zod.values),n._zod.parse=(e,r)=>{if(r.direction==="backward")return t.innerType._zod.run(e,r);const i=t.innerType._zod.run(e,r);return i instanceof Promise?i.then(s=>(e.value=s.value,s.issues.length&&(e.value=t.catchValue({...e,error:{issues:s.issues.map(o=>Hn(o,r,Fn()))},input:e.value}),e.issues=[]),e)):(e.value=i.value,i.issues.length&&(e.value=t.catchValue({...e,error:{issues:i.issues.map(s=>Hn(s,r,Fn()))},input:e.value}),e.issues=[]),e)}}),wI=A("$ZodPipe",(n,t)=>{ge.init(n,t),ne(n._zod,"values",()=>t.in._zod.values),ne(n._zod,"optin",()=>t.in._zod.optin),ne(n._zod,"optout",()=>t.out._zod.optout),ne(n._zod,"propValues",()=>t.in._zod.propValues),n._zod.parse=(e,r)=>{if(r.direction==="backward"){const s=t.out._zod.run(e,r);return s instanceof Promise?s.then(o=>aa(o,t.in,r)):aa(s,t.in,r)}const i=t.in._zod.run(e,r);return i instanceof Promise?i.then(s=>aa(s,t.out,r)):aa(i,t.out,r)}});function aa(n,t,e){return n.issues.length?(n.aborted=!0,n):t._zod.run({value:n.value,issues:n.issues},e)}const SI=A("$ZodReadonly",(n,t)=>{ge.init(n,t),ne(n._zod,"propValues",()=>t.innerType._zod.propValues),ne(n._zod,"values",()=>t.innerType._zod.values),ne(n._zod,"optin",()=>{var e,r;return(r=(e=t.innerType)==null?void 0:e._zod)==null?void 0:r.optin}),ne(n._zod,"optout",()=>{var e,r;return(r=(e=t.innerType)==null?void 0:e._zod)==null?void 0:r.optout}),n._zod.parse=(e,r)=>{if(r.direction==="backward")return t.innerType._zod.run(e,r);const i=t.innerType._zod.run(e,r);return i instanceof Promise?i.then(zf):zf(i)}});function zf(n){return n.value=Object.freeze(n.value),n}const _I=A("$ZodCustom",(n,t)=>{st.init(n,t),ge.init(n,t),n._zod.parse=(e,r)=>e,n._zod.check=e=>{const r=e.value,i=t.fn(r);if(i instanceof Promise)return i.then(s=>Of(s,e,r,n));Of(i,e,r,n)}});function Of(n,t,e,r){if(!n){const i={code:"custom",input:e,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(i.params=r._zod.def.params),t.issues.push(Ds(i))}}var Mf;class kI{constructor(){this._map=new WeakMap,this._idmap=new Map}add(t,...e){const r=e[0];return this._map.set(t,r),r&&typeof r=="object"&&"id"in r&&this._idmap.set(r.id,t),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(t){const e=this._map.get(t);return e&&typeof e=="object"&&"id"in e&&this._idmap.delete(e.id),this._map.delete(t),this}get(t){const e=t._zod.parent;if(e){const r={...this.get(e)??{}};delete r.id;const i={...r,...this._map.get(t)};return Object.keys(i).length?i:void 0}return this._map.get(t)}has(t){return this._map.has(t)}}function xI(){return new kI}(Mf=globalThis).__zod_globalRegistry??(Mf.__zod_globalRegistry=xI());const ms=globalThis.__zod_globalRegistry;function EI(n,t){return new n({type:"string",...M(t)})}function AI(n,t){return new n({type:"string",format:"email",check:"string_format",abort:!1,...M(t)})}function Nf(n,t){return new n({type:"string",format:"guid",check:"string_format",abort:!1,...M(t)})}function $I(n,t){return new n({type:"string",format:"uuid",check:"string_format",abort:!1,...M(t)})}function TI(n,t){return new n({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...M(t)})}function II(n,t){return new n({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...M(t)})}function CI(n,t){return new n({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...M(t)})}function RI(n,t){return new n({type:"string",format:"url",check:"string_format",abort:!1,...M(t)})}function PI(n,t){return new n({type:"string",format:"emoji",check:"string_format",abort:!1,...M(t)})}function DI(n,t){return new n({type:"string",format:"nanoid",check:"string_format",abort:!1,...M(t)})}function LI(n,t){return new n({type:"string",format:"cuid",check:"string_format",abort:!1,...M(t)})}function zI(n,t){return new n({type:"string",format:"cuid2",check:"string_format",abort:!1,...M(t)})}function OI(n,t){return new n({type:"string",format:"ulid",check:"string_format",abort:!1,...M(t)})}function MI(n,t){return new n({type:"string",format:"xid",check:"string_format",abort:!1,...M(t)})}function NI(n,t){return new n({type:"string",format:"ksuid",check:"string_format",abort:!1,...M(t)})}function UI(n,t){return new n({type:"string",format:"ipv4",check:"string_format",abort:!1,...M(t)})}function FI(n,t){return new n({type:"string",format:"ipv6",check:"string_format",abort:!1,...M(t)})}function HI(n,t){return new n({type:"string",format:"cidrv4",check:"string_format",abort:!1,...M(t)})}function WI(n,t){return new n({type:"string",format:"cidrv6",check:"string_format",abort:!1,...M(t)})}function ZI(n,t){return new n({type:"string",format:"base64",check:"string_format",abort:!1,...M(t)})}function BI(n,t){return new n({type:"string",format:"base64url",check:"string_format",abort:!1,...M(t)})}function VI(n,t){return new n({type:"string",format:"e164",check:"string_format",abort:!1,...M(t)})}function jI(n,t){return new n({type:"string",format:"jwt",check:"string_format",abort:!1,...M(t)})}function GI(n,t){return new n({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...M(t)})}function qI(n,t){return new n({type:"string",format:"date",check:"string_format",...M(t)})}function YI(n,t){return new n({type:"string",format:"time",check:"string_format",precision:null,...M(t)})}function XI(n,t){return new n({type:"string",format:"duration",check:"string_format",...M(t)})}function KI(n,t){return new n({type:"number",checks:[],...M(t)})}function JI(n,t){return new n({type:"number",check:"number_format",abort:!1,format:"safeint",...M(t)})}function QI(n,t){return new n({type:"boolean",...M(t)})}function e1(n){return new n({type:"unknown"})}function t1(n,t){return new n({type:"never",...M(t)})}function Uf(n,t){return new zv({check:"less_than",...M(t),value:n,inclusive:!1})}function Oc(n,t){return new zv({check:"less_than",...M(t),value:n,inclusive:!0})}function Ff(n,t){return new Ov({check:"greater_than",...M(t),value:n,inclusive:!1})}function Mc(n,t){return new Ov({check:"greater_than",...M(t),value:n,inclusive:!0})}function Hf(n,t){return new mT({check:"multiple_of",...M(t),value:n})}function Wv(n,t){return new yT({check:"max_length",...M(t),maximum:n})}function Qa(n,t){return new bT({check:"min_length",...M(t),minimum:n})}function Zv(n,t){return new wT({check:"length_equals",...M(t),length:n})}function n1(n,t){return new ST({check:"string_format",format:"regex",...M(t),pattern:n})}function r1(n){return new _T({check:"string_format",format:"lowercase",...M(n)})}function i1(n){return new kT({check:"string_format",format:"uppercase",...M(n)})}function s1(n,t){return new xT({check:"string_format",format:"includes",...M(t),includes:n})}function o1(n,t){return new ET({check:"string_format",format:"starts_with",...M(t),prefix:n})}function a1(n,t){return new AT({check:"string_format",format:"ends_with",...M(t),suffix:n})}function Xi(n){return new $T({check:"overwrite",tx:n})}function l1(n){return Xi(t=>t.normalize(n))}function c1(){return Xi(n=>n.trim())}function u1(){return Xi(n=>n.toLowerCase())}function h1(){return Xi(n=>n.toUpperCase())}function d1(){return Xi(n=>S$(n))}function p1(n,t,e){return new n({type:"array",element:t,...M(e)})}function f1(n,t,e){return new n({type:"custom",check:"custom",fn:t,...M(e)})}function g1(n){const t=m1(e=>(e.addIssue=r=>{if(typeof r=="string")e.issues.push(Ds(r,e.value,t._zod.def));else{const i=r;i.fatal&&(i.continue=!1),i.code??(i.code="custom"),i.input??(i.input=e.value),i.inst??(i.inst=t),i.continue??(i.continue=!t._zod.def.abort),e.issues.push(Ds(i))}},n(e.value,e)));return t}function m1(n,t){const e=new st({check:"custom",...M(t)});return e._zod.check=n,e}function Bv(n){let t=(n==null?void 0:n.target)??"draft-2020-12";return t==="draft-4"&&(t="draft-04"),t==="draft-7"&&(t="draft-07"),{processors:n.processors??{},metadataRegistry:(n==null?void 0:n.metadata)??ms,target:t,unrepresentable:(n==null?void 0:n.unrepresentable)??"throw",override:(n==null?void 0:n.override)??(()=>{}),io:(n==null?void 0:n.io)??"output",counter:0,seen:new Map,cycles:(n==null?void 0:n.cycles)??"ref",reused:(n==null?void 0:n.reused)??"inline",external:(n==null?void 0:n.external)??void 0}}function _e(n,t,e={path:[],schemaPath:[]}){var h,p;var r;const i=n._zod.def,s=t.seen.get(n);if(s)return s.count++,e.schemaPath.includes(n)&&(s.cycle=e.path),s.schema;const o={schema:{},count:1,cycle:void 0,path:e.path};t.seen.set(n,o);const a=(p=(h=n._zod).toJSONSchema)==null?void 0:p.call(h);if(a)o.schema=a;else{const v={...e,schemaPath:[...e.schemaPath,n],path:e.path};if(n._zod.processJSONSchema)n._zod.processJSONSchema(t,o.schema,v);else{const _=o.schema,k=t.processors[i.type];if(!k)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${i.type}`);k(n,t,_,v)}const g=n._zod.parent;g&&(o.ref||(o.ref=g),_e(g,t,v),t.seen.get(g).isParent=!0)}const c=t.metadataRegistry.get(n);return c&&Object.assign(o.schema,c),t.io==="input"&&We(n)&&(delete o.schema.examples,delete o.schema.default),t.io==="input"&&o.schema._prefault&&((r=o.schema).default??(r.default=o.schema._prefault)),delete o.schema._prefault,t.seen.get(n).schema}function Vv(n,t){var o,a,c,u;const e=n.seen.get(t);if(!e)throw new Error("Unprocessed schema. This is a bug in Zod.");const r=new Map;for(const h of n.seen.entries()){const p=(o=n.metadataRegistry.get(h[0]))==null?void 0:o.id;if(p){const v=r.get(p);if(v&&v!==h[0])throw new Error(`Duplicate schema id "${p}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);r.set(p,h[0])}}const i=h=>{var k;const p=n.target==="draft-2020-12"?"$defs":"definitions";if(n.external){const T=(k=n.external.registry.get(h[0]))==null?void 0:k.id,P=n.external.uri??(W=>W);if(T)return{ref:P(T)};const R=h[1].defId??h[1].schema.id??`schema${n.counter++}`;return h[1].defId=R,{defId:R,ref:`${P("__shared")}#/${p}/${R}`}}if(h[1]===e)return{ref:"#"};const g=`#/${p}/`,_=h[1].schema.id??`__schema${n.counter++}`;return{defId:_,ref:g+_}},s=h=>{if(h[1].schema.$ref)return;const p=h[1],{ref:v,defId:g}=i(h);p.def={...p.schema},g&&(p.defId=g);const _=p.schema;for(const k in _)delete _[k];_.$ref=v};if(n.cycles==="throw")for(const h of n.seen.entries()){const p=h[1];if(p.cycle)throw new Error(`Cycle detected: #/${(a=p.cycle)==null?void 0:a.join("/")}/<root>
|
|
41
|
+
|
|
42
|
+
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(const h of n.seen.entries()){const p=h[1];if(t===h[0]){s(h);continue}if(n.external){const g=(c=n.external.registry.get(h[0]))==null?void 0:c.id;if(t!==h[0]&&g){s(h);continue}}if((u=n.metadataRegistry.get(h[0]))==null?void 0:u.id){s(h);continue}if(p.cycle){s(h);continue}if(p.count>1&&n.reused==="ref"){s(h);continue}}}function jv(n,t){var o,a,c;const e=n.seen.get(t);if(!e)throw new Error("Unprocessed schema. This is a bug in Zod.");const r=u=>{const h=n.seen.get(u);if(h.ref===null)return;const p=h.def??h.schema,v={...p},g=h.ref;if(h.ref=null,g){r(g);const k=n.seen.get(g),T=k.schema;if(T.$ref&&(n.target==="draft-07"||n.target==="draft-04"||n.target==="openapi-3.0")?(p.allOf=p.allOf??[],p.allOf.push(T)):Object.assign(p,T),Object.assign(p,v),u._zod.parent===g)for(const R in p)R==="$ref"||R==="allOf"||R in v||delete p[R];if(T.$ref&&k.def)for(const R in p)R==="$ref"||R==="allOf"||R in k.def&&JSON.stringify(p[R])===JSON.stringify(k.def[R])&&delete p[R]}const _=u._zod.parent;if(_&&_!==g){r(_);const k=n.seen.get(_);if(k!=null&&k.schema.$ref&&(p.$ref=k.schema.$ref,k.def))for(const T in p)T==="$ref"||T==="allOf"||T in k.def&&JSON.stringify(p[T])===JSON.stringify(k.def[T])&&delete p[T]}n.override({zodSchema:u,jsonSchema:p,path:h.path??[]})};for(const u of[...n.seen.entries()].reverse())r(u[0]);const i={};if(n.target==="draft-2020-12"?i.$schema="https://json-schema.org/draft/2020-12/schema":n.target==="draft-07"?i.$schema="http://json-schema.org/draft-07/schema#":n.target==="draft-04"?i.$schema="http://json-schema.org/draft-04/schema#":n.target,(o=n.external)!=null&&o.uri){const u=(a=n.external.registry.get(t))==null?void 0:a.id;if(!u)throw new Error("Schema is missing an `id` property");i.$id=n.external.uri(u)}Object.assign(i,e.def??e.schema);const s=((c=n.external)==null?void 0:c.defs)??{};for(const u of n.seen.entries()){const h=u[1];h.def&&h.defId&&(s[h.defId]=h.def)}n.external||Object.keys(s).length>0&&(n.target==="draft-2020-12"?i.$defs=s:i.definitions=s);try{const u=JSON.parse(JSON.stringify(i));return Object.defineProperty(u,"~standard",{value:{...t["~standard"],jsonSchema:{input:el(t,"input",n.processors),output:el(t,"output",n.processors)}},enumerable:!1,writable:!1}),u}catch{throw new Error("Error converting schema to JSON.")}}function We(n,t){const e=t??{seen:new Set};if(e.seen.has(n))return!1;e.seen.add(n);const r=n._zod.def;if(r.type==="transform")return!0;if(r.type==="array")return We(r.element,e);if(r.type==="set")return We(r.valueType,e);if(r.type==="lazy")return We(r.getter(),e);if(r.type==="promise"||r.type==="optional"||r.type==="nonoptional"||r.type==="nullable"||r.type==="readonly"||r.type==="default"||r.type==="prefault")return We(r.innerType,e);if(r.type==="intersection")return We(r.left,e)||We(r.right,e);if(r.type==="record"||r.type==="map")return We(r.keyType,e)||We(r.valueType,e);if(r.type==="pipe")return We(r.in,e)||We(r.out,e);if(r.type==="object"){for(const i in r.shape)if(We(r.shape[i],e))return!0;return!1}if(r.type==="union"){for(const i of r.options)if(We(i,e))return!0;return!1}if(r.type==="tuple"){for(const i of r.items)if(We(i,e))return!0;return!!(r.rest&&We(r.rest,e))}return!1}const v1=(n,t={})=>e=>{const r=Bv({...e,processors:t});return _e(n,r),Vv(r,n),jv(r,n)},el=(n,t,e={})=>r=>{const{libraryOptions:i,target:s}=r??{},o=Bv({...i??{},target:s,io:t,processors:e});return _e(n,o),Vv(o,n),jv(o,n)},y1={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},b1=(n,t,e,r)=>{const i=e;i.type="string";const{minimum:s,maximum:o,format:a,patterns:c,contentEncoding:u}=n._zod.bag;if(typeof s=="number"&&(i.minLength=s),typeof o=="number"&&(i.maxLength=o),a&&(i.format=y1[a]??a,i.format===""&&delete i.format,a==="time"&&delete i.format),u&&(i.contentEncoding=u),c&&c.size>0){const h=[...c];h.length===1?i.pattern=h[0].source:h.length>1&&(i.allOf=[...h.map(p=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:p.source}))])}},w1=(n,t,e,r)=>{const i=e,{minimum:s,maximum:o,format:a,multipleOf:c,exclusiveMaximum:u,exclusiveMinimum:h}=n._zod.bag;typeof a=="string"&&a.includes("int")?i.type="integer":i.type="number",typeof h=="number"&&(t.target==="draft-04"||t.target==="openapi-3.0"?(i.minimum=h,i.exclusiveMinimum=!0):i.exclusiveMinimum=h),typeof s=="number"&&(i.minimum=s,typeof h=="number"&&t.target!=="draft-04"&&(h>=s?delete i.minimum:delete i.exclusiveMinimum)),typeof u=="number"&&(t.target==="draft-04"||t.target==="openapi-3.0"?(i.maximum=u,i.exclusiveMaximum=!0):i.exclusiveMaximum=u),typeof o=="number"&&(i.maximum=o,typeof u=="number"&&t.target!=="draft-04"&&(u<=o?delete i.maximum:delete i.exclusiveMaximum)),typeof c=="number"&&(i.multipleOf=c)},S1=(n,t,e,r)=>{e.type="boolean"},_1=(n,t,e,r)=>{e.not={}},k1=(n,t,e,r)=>{},x1=(n,t,e,r)=>{const i=n._zod.def,s=xv(i.entries);s.every(o=>typeof o=="number")&&(e.type="number"),s.every(o=>typeof o=="string")&&(e.type="string"),e.enum=s},E1=(n,t,e,r)=>{const i=n._zod.def,s=[];for(const o of i.values)if(o===void 0){if(t.unrepresentable==="throw")throw new Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof o=="bigint"){if(t.unrepresentable==="throw")throw new Error("BigInt literals cannot be represented in JSON Schema");s.push(Number(o))}else s.push(o);if(s.length!==0)if(s.length===1){const o=s[0];e.type=o===null?"null":typeof o,t.target==="draft-04"||t.target==="openapi-3.0"?e.enum=[o]:e.const=o}else s.every(o=>typeof o=="number")&&(e.type="number"),s.every(o=>typeof o=="string")&&(e.type="string"),s.every(o=>typeof o=="boolean")&&(e.type="boolean"),s.every(o=>o===null)&&(e.type="null"),e.enum=s},A1=(n,t,e,r)=>{if(t.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema")},$1=(n,t,e,r)=>{if(t.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema")},T1=(n,t,e,r)=>{const i=e,s=n._zod.def,{minimum:o,maximum:a}=n._zod.bag;typeof o=="number"&&(i.minItems=o),typeof a=="number"&&(i.maxItems=a),i.type="array",i.items=_e(s.element,t,{...r,path:[...r.path,"items"]})},I1=(n,t,e,r)=>{var u;const i=e,s=n._zod.def;i.type="object",i.properties={};const o=s.shape;for(const h in o)i.properties[h]=_e(o[h],t,{...r,path:[...r.path,"properties",h]});const a=new Set(Object.keys(o)),c=new Set([...a].filter(h=>{const p=s.shape[h]._zod;return t.io==="input"?p.optin===void 0:p.optout===void 0}));c.size>0&&(i.required=Array.from(c)),((u=s.catchall)==null?void 0:u._zod.def.type)==="never"?i.additionalProperties=!1:s.catchall?s.catchall&&(i.additionalProperties=_e(s.catchall,t,{...r,path:[...r.path,"additionalProperties"]})):t.io==="output"&&(i.additionalProperties=!1)},C1=(n,t,e,r)=>{const i=n._zod.def,s=i.inclusive===!1,o=i.options.map((a,c)=>_e(a,t,{...r,path:[...r.path,s?"oneOf":"anyOf",c]}));s?e.oneOf=o:e.anyOf=o},R1=(n,t,e,r)=>{const i=n._zod.def,s=_e(i.left,t,{...r,path:[...r.path,"allOf",0]}),o=_e(i.right,t,{...r,path:[...r.path,"allOf",1]}),a=u=>"allOf"in u&&Object.keys(u).length===1,c=[...a(s)?s.allOf:[s],...a(o)?o.allOf:[o]];e.allOf=c},P1=(n,t,e,r)=>{const i=e,s=n._zod.def;i.type="object";const o=s.keyType,a=o._zod.bag,c=a==null?void 0:a.patterns;if(s.mode==="loose"&&c&&c.size>0){const h=_e(s.valueType,t,{...r,path:[...r.path,"patternProperties","*"]});i.patternProperties={};for(const p of c)i.patternProperties[p.source]=h}else(t.target==="draft-07"||t.target==="draft-2020-12")&&(i.propertyNames=_e(s.keyType,t,{...r,path:[...r.path,"propertyNames"]})),i.additionalProperties=_e(s.valueType,t,{...r,path:[...r.path,"additionalProperties"]});const u=o._zod.values;if(u){const h=[...u].filter(p=>typeof p=="string"||typeof p=="number");h.length>0&&(i.required=h)}},D1=(n,t,e,r)=>{const i=n._zod.def,s=_e(i.innerType,t,r),o=t.seen.get(n);t.target==="openapi-3.0"?(o.ref=i.innerType,e.nullable=!0):e.anyOf=[s,{type:"null"}]},L1=(n,t,e,r)=>{const i=n._zod.def;_e(i.innerType,t,r);const s=t.seen.get(n);s.ref=i.innerType},z1=(n,t,e,r)=>{const i=n._zod.def;_e(i.innerType,t,r);const s=t.seen.get(n);s.ref=i.innerType,e.default=JSON.parse(JSON.stringify(i.defaultValue))},O1=(n,t,e,r)=>{const i=n._zod.def;_e(i.innerType,t,r);const s=t.seen.get(n);s.ref=i.innerType,t.io==="input"&&(e._prefault=JSON.parse(JSON.stringify(i.defaultValue)))},M1=(n,t,e,r)=>{const i=n._zod.def;_e(i.innerType,t,r);const s=t.seen.get(n);s.ref=i.innerType;let o;try{o=i.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}e.default=o},N1=(n,t,e,r)=>{const i=n._zod.def,s=t.io==="input"?i.in._zod.def.type==="transform"?i.out:i.in:i.out;_e(s,t,r);const o=t.seen.get(n);o.ref=s},U1=(n,t,e,r)=>{const i=n._zod.def;_e(i.innerType,t,r);const s=t.seen.get(n);s.ref=i.innerType,e.readOnly=!0},Gv=(n,t,e,r)=>{const i=n._zod.def;_e(i.innerType,t,r);const s=t.seen.get(n);s.ref=i.innerType},F1=A("ZodISODateTime",(n,t)=>{HT.init(n,t),ve.init(n,t)});function H1(n){return GI(F1,n)}const W1=A("ZodISODate",(n,t)=>{WT.init(n,t),ve.init(n,t)});function Z1(n){return qI(W1,n)}const B1=A("ZodISOTime",(n,t)=>{ZT.init(n,t),ve.init(n,t)});function V1(n){return YI(B1,n)}const j1=A("ZodISODuration",(n,t)=>{BT.init(n,t),ve.init(n,t)});function G1(n){return XI(j1,n)}const qv=(n,t)=>{Tv.init(n,t),n.name="ZodError",Object.defineProperties(n,{format:{value:e=>L$(n,e)},flatten:{value:e=>D$(n,e)},addIssue:{value:e=>{n.issues.push(e),n.message=JSON.stringify(n.issues,wu,2)}},addIssues:{value:e=>{n.issues.push(...e),n.message=JSON.stringify(n.issues,wu,2)}},isEmpty:{get(){return n.issues.length===0}}})},Wf=A("ZodError",qv),wt=A("ZodError",qv,{Parent:Error}),q1=Kh(wt),Y1=Jh(wt),X1=Dl(wt),K1=Ll(wt),J1=M$(wt),Q1=N$(wt),eC=U$(wt),tC=F$(wt),nC=H$(wt),rC=W$(wt),iC=Z$(wt),sC=B$(wt),me=A("ZodType",(n,t)=>(ge.init(n,t),Object.assign(n["~standard"],{jsonSchema:{input:el(n,"input"),output:el(n,"output")}}),n.toJSONSchema=v1(n,{}),n.def=t,n.type=t.type,Object.defineProperty(n,"_def",{value:t}),n.check=(...e)=>n.clone(jn(t,{checks:[...t.checks??[],...e.map(r=>typeof r=="function"?{_zod:{check:r,def:{check:"custom"},onattach:[]}}:r)]}),{parent:!0}),n.with=n.check,n.clone=(e,r)=>Gn(n,e,r),n.brand=()=>n,n.register=(e,r)=>(e.add(n,r),n),n.parse=(e,r)=>q1(n,e,r,{callee:n.parse}),n.safeParse=(e,r)=>X1(n,e,r),n.parseAsync=async(e,r)=>Y1(n,e,r,{callee:n.parseAsync}),n.safeParseAsync=async(e,r)=>K1(n,e,r),n.spa=n.safeParseAsync,n.encode=(e,r)=>J1(n,e,r),n.decode=(e,r)=>Q1(n,e,r),n.encodeAsync=async(e,r)=>eC(n,e,r),n.decodeAsync=async(e,r)=>tC(n,e,r),n.safeEncode=(e,r)=>nC(n,e,r),n.safeDecode=(e,r)=>rC(n,e,r),n.safeEncodeAsync=async(e,r)=>iC(n,e,r),n.safeDecodeAsync=async(e,r)=>sC(n,e,r),n.refine=(e,r)=>n.check(XC(e,r)),n.superRefine=e=>n.check(KC(e)),n.overwrite=e=>n.check(Xi(e)),n.optional=()=>Vf(n),n.exactOptional=()=>MC(n),n.nullable=()=>jf(n),n.nullish=()=>Vf(jf(n)),n.nonoptional=e=>ZC(n,e),n.array=()=>L(n),n.or=e=>V([n,e]),n.and=e=>Ol(n,e),n.transform=e=>Gf(n,zC(e)),n.default=e=>FC(n,e),n.prefault=e=>WC(n,e),n.catch=e=>VC(n,e),n.pipe=e=>Gf(n,e),n.readonly=()=>qC(n),n.describe=e=>{const r=n.clone();return ms.add(r,{description:e}),r},Object.defineProperty(n,"description",{get(){var e;return(e=ms.get(n))==null?void 0:e.description},configurable:!0}),n.meta=(...e)=>{if(e.length===0)return ms.get(n);const r=n.clone();return ms.add(r,e[0]),r},n.isOptional=()=>n.safeParse(void 0).success,n.isNullable=()=>n.safeParse(null).success,n.apply=e=>e(n),n)),Yv=A("_ZodString",(n,t)=>{Qh.init(n,t),me.init(n,t),n._zod.processJSONSchema=(r,i,s)=>b1(n,r,i);const e=n._zod.bag;n.format=e.format??null,n.minLength=e.minimum??null,n.maxLength=e.maximum??null,n.regex=(...r)=>n.check(n1(...r)),n.includes=(...r)=>n.check(s1(...r)),n.startsWith=(...r)=>n.check(o1(...r)),n.endsWith=(...r)=>n.check(a1(...r)),n.min=(...r)=>n.check(Qa(...r)),n.max=(...r)=>n.check(Wv(...r)),n.length=(...r)=>n.check(Zv(...r)),n.nonempty=(...r)=>n.check(Qa(1,...r)),n.lowercase=r=>n.check(r1(r)),n.uppercase=r=>n.check(i1(r)),n.trim=()=>n.check(c1()),n.normalize=(...r)=>n.check(l1(...r)),n.toLowerCase=()=>n.check(u1()),n.toUpperCase=()=>n.check(h1()),n.slugify=()=>n.check(d1())}),oC=A("ZodString",(n,t)=>{Qh.init(n,t),Yv.init(n,t),n.email=e=>n.check(AI(aC,e)),n.url=e=>n.check(RI(lC,e)),n.jwt=e=>n.check(jI(kC,e)),n.emoji=e=>n.check(PI(cC,e)),n.guid=e=>n.check(Nf(Zf,e)),n.uuid=e=>n.check($I(la,e)),n.uuidv4=e=>n.check(TI(la,e)),n.uuidv6=e=>n.check(II(la,e)),n.uuidv7=e=>n.check(CI(la,e)),n.nanoid=e=>n.check(DI(uC,e)),n.guid=e=>n.check(Nf(Zf,e)),n.cuid=e=>n.check(LI(hC,e)),n.cuid2=e=>n.check(zI(dC,e)),n.ulid=e=>n.check(OI(pC,e)),n.base64=e=>n.check(ZI(wC,e)),n.base64url=e=>n.check(BI(SC,e)),n.xid=e=>n.check(MI(fC,e)),n.ksuid=e=>n.check(NI(gC,e)),n.ipv4=e=>n.check(UI(mC,e)),n.ipv6=e=>n.check(FI(vC,e)),n.cidrv4=e=>n.check(HI(yC,e)),n.cidrv6=e=>n.check(WI(bC,e)),n.e164=e=>n.check(VI(_C,e)),n.datetime=e=>n.check(H1(e)),n.date=e=>n.check(Z1(e)),n.time=e=>n.check(V1(e)),n.duration=e=>n.check(G1(e))});function d(n){return EI(oC,n)}const ve=A("ZodStringFormat",(n,t)=>{de.init(n,t),Yv.init(n,t)}),aC=A("ZodEmail",(n,t)=>{PT.init(n,t),ve.init(n,t)}),Zf=A("ZodGUID",(n,t)=>{CT.init(n,t),ve.init(n,t)}),la=A("ZodUUID",(n,t)=>{RT.init(n,t),ve.init(n,t)}),lC=A("ZodURL",(n,t)=>{DT.init(n,t),ve.init(n,t)}),cC=A("ZodEmoji",(n,t)=>{LT.init(n,t),ve.init(n,t)}),uC=A("ZodNanoID",(n,t)=>{zT.init(n,t),ve.init(n,t)}),hC=A("ZodCUID",(n,t)=>{OT.init(n,t),ve.init(n,t)}),dC=A("ZodCUID2",(n,t)=>{MT.init(n,t),ve.init(n,t)}),pC=A("ZodULID",(n,t)=>{NT.init(n,t),ve.init(n,t)}),fC=A("ZodXID",(n,t)=>{UT.init(n,t),ve.init(n,t)}),gC=A("ZodKSUID",(n,t)=>{FT.init(n,t),ve.init(n,t)}),mC=A("ZodIPv4",(n,t)=>{VT.init(n,t),ve.init(n,t)}),vC=A("ZodIPv6",(n,t)=>{jT.init(n,t),ve.init(n,t)}),yC=A("ZodCIDRv4",(n,t)=>{GT.init(n,t),ve.init(n,t)}),bC=A("ZodCIDRv6",(n,t)=>{qT.init(n,t),ve.init(n,t)}),wC=A("ZodBase64",(n,t)=>{YT.init(n,t),ve.init(n,t)}),SC=A("ZodBase64URL",(n,t)=>{KT.init(n,t),ve.init(n,t)}),_C=A("ZodE164",(n,t)=>{JT.init(n,t),ve.init(n,t)}),kC=A("ZodJWT",(n,t)=>{eI.init(n,t),ve.init(n,t)}),Xv=A("ZodNumber",(n,t)=>{Nv.init(n,t),me.init(n,t),n._zod.processJSONSchema=(r,i,s)=>w1(n,r,i),n.gt=(r,i)=>n.check(Ff(r,i)),n.gte=(r,i)=>n.check(Mc(r,i)),n.min=(r,i)=>n.check(Mc(r,i)),n.lt=(r,i)=>n.check(Uf(r,i)),n.lte=(r,i)=>n.check(Oc(r,i)),n.max=(r,i)=>n.check(Oc(r,i)),n.int=r=>n.check(Bf(r)),n.safe=r=>n.check(Bf(r)),n.positive=r=>n.check(Ff(0,r)),n.nonnegative=r=>n.check(Mc(0,r)),n.negative=r=>n.check(Uf(0,r)),n.nonpositive=r=>n.check(Oc(0,r)),n.multipleOf=(r,i)=>n.check(Hf(r,i)),n.step=(r,i)=>n.check(Hf(r,i)),n.finite=()=>n;const e=n._zod.bag;n.minValue=Math.max(e.minimum??Number.NEGATIVE_INFINITY,e.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,n.maxValue=Math.min(e.maximum??Number.POSITIVE_INFINITY,e.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,n.isInt=(e.format??"").includes("int")||Number.isSafeInteger(e.multipleOf??.5),n.isFinite=!0,n.format=e.format??null});function H(n){return KI(Xv,n)}const xC=A("ZodNumberFormat",(n,t)=>{tI.init(n,t),Xv.init(n,t)});function Bf(n){return JI(xC,n)}const EC=A("ZodBoolean",(n,t)=>{nI.init(n,t),me.init(n,t),n._zod.processJSONSchema=(e,r,i)=>S1(n,e,r)});function Ce(n){return QI(EC,n)}const AC=A("ZodUnknown",(n,t)=>{rI.init(n,t),me.init(n,t),n._zod.processJSONSchema=(e,r,i)=>k1()});function x(){return e1(AC)}const $C=A("ZodNever",(n,t)=>{iI.init(n,t),me.init(n,t),n._zod.processJSONSchema=(e,r,i)=>_1(n,e,r)});function TC(n){return t1($C,n)}const IC=A("ZodArray",(n,t)=>{sI.init(n,t),me.init(n,t),n._zod.processJSONSchema=(e,r,i)=>T1(n,e,r,i),n.element=t.element,n.min=(e,r)=>n.check(Qa(e,r)),n.nonempty=e=>n.check(Qa(1,e)),n.max=(e,r)=>n.check(Wv(e,r)),n.length=(e,r)=>n.check(Zv(e,r)),n.unwrap=()=>n.element});function L(n,t){return p1(IC,n,t)}const Kv=A("ZodObject",(n,t)=>{aI.init(n,t),me.init(n,t),n._zod.processJSONSchema=(e,r,i)=>I1(n,e,r,i),ne(n,"shape",()=>t.shape),n.keyof=()=>Ls(Object.keys(n._zod.def.shape)),n.catchall=e=>n.clone({...n._zod.def,catchall:e}),n.passthrough=()=>n.clone({...n._zod.def,catchall:x()}),n.loose=()=>n.clone({...n._zod.def,catchall:x()}),n.strict=()=>n.clone({...n._zod.def,catchall:TC()}),n.strip=()=>n.clone({...n._zod.def,catchall:void 0}),n.extend=e=>T$(n,e),n.safeExtend=e=>I$(n,e),n.merge=e=>C$(n,e),n.pick=e=>A$(n,e),n.omit=e=>$$(n,e),n.partial=(...e)=>R$(Qv,n,e[0]),n.required=(...e)=>P$(ey,n,e[0])});function Jv(n,t){const e={type:"object",shape:n??{},...M(t)};return new Kv(e)}function y(n,t){return new Kv({type:"object",shape:n,catchall:x(),...M(t)})}const CC=A("ZodUnion",(n,t)=>{lI.init(n,t),me.init(n,t),n._zod.processJSONSchema=(e,r,i)=>C1(n,e,r,i),n.options=t.options});function V(n,t){return new CC({type:"union",options:n,...M(t)})}const RC=A("ZodIntersection",(n,t)=>{cI.init(n,t),me.init(n,t),n._zod.processJSONSchema=(e,r,i)=>R1(n,e,r,i)});function Ol(n,t){return new RC({type:"intersection",left:n,right:t})}const PC=A("ZodRecord",(n,t)=>{uI.init(n,t),me.init(n,t),n._zod.processJSONSchema=(e,r,i)=>P1(n,e,r,i),n.keyType=t.keyType,n.valueType=t.valueType});function E(n,t,e){return new PC({type:"record",keyType:n,valueType:t,...M(e)})}const _u=A("ZodEnum",(n,t)=>{hI.init(n,t),me.init(n,t),n._zod.processJSONSchema=(r,i,s)=>x1(n,r,i),n.enum=t.entries,n.options=Object.values(t.entries);const e=new Set(Object.keys(t.entries));n.extract=(r,i)=>{const s={};for(const o of r)if(e.has(o))s[o]=t.entries[o];else throw new Error(`Key ${o} not found in enum`);return new _u({...t,checks:[],...M(i),entries:s})},n.exclude=(r,i)=>{const s={...t.entries};for(const o of r)if(e.has(o))delete s[o];else throw new Error(`Key ${o} not found in enum`);return new _u({...t,checks:[],...M(i),entries:s})}});function Ls(n,t){const e=Array.isArray(n)?Object.fromEntries(n.map(r=>[r,r])):n;return new _u({type:"enum",entries:e,...M(t)})}const DC=A("ZodLiteral",(n,t)=>{dI.init(n,t),me.init(n,t),n._zod.processJSONSchema=(e,r,i)=>E1(n,e,r),n.values=new Set(t.values),Object.defineProperty(n,"value",{get(){if(t.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function $(n,t){return new DC({type:"literal",values:Array.isArray(n)?n:[n],...M(t)})}const LC=A("ZodTransform",(n,t)=>{pI.init(n,t),me.init(n,t),n._zod.processJSONSchema=(e,r,i)=>$1(n,e),n._zod.parse=(e,r)=>{if(r.direction==="backward")throw new _v(n.constructor.name);e.addIssue=s=>{if(typeof s=="string")e.issues.push(Ds(s,e.value,t));else{const o=s;o.fatal&&(o.continue=!1),o.code??(o.code="custom"),o.input??(o.input=e.value),o.inst??(o.inst=n),e.issues.push(Ds(o))}};const i=t.transform(e.value,e);return i instanceof Promise?i.then(s=>(e.value=s,e)):(e.value=i,e)}});function zC(n){return new LC({type:"transform",transform:n})}const Qv=A("ZodOptional",(n,t)=>{Hv.init(n,t),me.init(n,t),n._zod.processJSONSchema=(e,r,i)=>Gv(n,e,r,i),n.unwrap=()=>n._zod.def.innerType});function Vf(n){return new Qv({type:"optional",innerType:n})}const OC=A("ZodExactOptional",(n,t)=>{fI.init(n,t),me.init(n,t),n._zod.processJSONSchema=(e,r,i)=>Gv(n,e,r,i),n.unwrap=()=>n._zod.def.innerType});function MC(n){return new OC({type:"optional",innerType:n})}const NC=A("ZodNullable",(n,t)=>{gI.init(n,t),me.init(n,t),n._zod.processJSONSchema=(e,r,i)=>D1(n,e,r,i),n.unwrap=()=>n._zod.def.innerType});function jf(n){return new NC({type:"nullable",innerType:n})}const UC=A("ZodDefault",(n,t)=>{mI.init(n,t),me.init(n,t),n._zod.processJSONSchema=(e,r,i)=>z1(n,e,r,i),n.unwrap=()=>n._zod.def.innerType,n.removeDefault=n.unwrap});function FC(n,t){return new UC({type:"default",innerType:n,get defaultValue(){return typeof t=="function"?t():Av(t)}})}const HC=A("ZodPrefault",(n,t)=>{vI.init(n,t),me.init(n,t),n._zod.processJSONSchema=(e,r,i)=>O1(n,e,r,i),n.unwrap=()=>n._zod.def.innerType});function WC(n,t){return new HC({type:"prefault",innerType:n,get defaultValue(){return typeof t=="function"?t():Av(t)}})}const ey=A("ZodNonOptional",(n,t)=>{yI.init(n,t),me.init(n,t),n._zod.processJSONSchema=(e,r,i)=>L1(n,e,r,i),n.unwrap=()=>n._zod.def.innerType});function ZC(n,t){return new ey({type:"nonoptional",innerType:n,...M(t)})}const BC=A("ZodCatch",(n,t)=>{bI.init(n,t),me.init(n,t),n._zod.processJSONSchema=(e,r,i)=>M1(n,e,r,i),n.unwrap=()=>n._zod.def.innerType,n.removeCatch=n.unwrap});function VC(n,t){return new BC({type:"catch",innerType:n,catchValue:typeof t=="function"?t:()=>t})}const jC=A("ZodPipe",(n,t)=>{wI.init(n,t),me.init(n,t),n._zod.processJSONSchema=(e,r,i)=>N1(n,e,r,i),n.in=t.in,n.out=t.out});function Gf(n,t){return new jC({type:"pipe",in:n,out:t})}const GC=A("ZodReadonly",(n,t)=>{SI.init(n,t),me.init(n,t),n._zod.processJSONSchema=(e,r,i)=>U1(n,e,r,i),n.unwrap=()=>n._zod.def.innerType});function qC(n){return new GC({type:"readonly",innerType:n})}const YC=A("ZodCustom",(n,t)=>{_I.init(n,t),me.init(n,t),n._zod.processJSONSchema=(e,r,i)=>A1(n,e)});function XC(n,t={}){return f1(YC,n,t)}function KC(n){return g1(n)}const Qt={custom:"custom"},ty=["markdown","web-bundle","url"],JC=["committed","pending"];function QC(n){let t;try{t=new URL(n)}catch{return!1}return t.protocol==="http:"||t.protocol==="https:"}Jv({id:d().min(1),kind:Ls(ty),title:d(),status:Ls(JC),externalFilePath:d().optional(),externalURL:d().optional()}).superRefine((n,t)=>{switch(n.externalFilePath!==void 0&&n.externalURL!==void 0&&t.addIssue({code:Qt.custom,message:"externalFilePath and externalURL are mutually exclusive",path:["externalURL"]}),n.kind!=="web-bundle"&&n.status!=="committed"&&t.addIssue({code:Qt.custom,message:"only web-bundle artifacts can be pending",path:["status"]}),n.kind){case"markdown":n.externalFilePath===void 0&&t.addIssue({code:Qt.custom,message:"markdown artifacts require externalFilePath",path:["externalFilePath"]}),n.externalURL!==void 0&&t.addIssue({code:Qt.custom,message:"markdown artifacts cannot set externalURL",path:["externalURL"]});break;case"web-bundle":n.externalFilePath!==void 0&&t.addIssue({code:Qt.custom,message:"web-bundle artifacts cannot set externalFilePath",path:["externalFilePath"]}),n.externalURL!==void 0&&t.addIssue({code:Qt.custom,message:"web-bundle artifacts cannot set externalURL",path:["externalURL"]});break;case"url":if(n.externalURL===void 0){t.addIssue({code:Qt.custom,message:"url artifacts require externalURL",path:["externalURL"]});break}n.externalFilePath!==void 0&&t.addIssue({code:Qt.custom,message:"url artifacts cannot set externalFilePath",path:["externalFilePath"]}),QC(n.externalURL)||t.addIssue({code:Qt.custom,message:"externalURL must be an http(s) URL",path:["externalURL"]});break}});Jv({name:d().min(1),description:d(),accepts:L(Ls(ty)).min(1)});function ny(n){return typeof n=="object"&&n!==null}function eR(n){return!ny(n)||n.type!=="ready"?!1:!("id"in n)}function tR(n){return!(!ny(n)||n.type!=="update-content"||typeof n.id!="string"||typeof n.content!="string")}function nR(n,t){return t.find(e=>e.accepts.includes(n))??null}const he={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"},en={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"},rR=1,iR=y({_meta:E(d(),x()).nullish(),terminal:Ce().optional().default(!1)}),sR=y({_meta:E(d(),x()).nullish(),label:d().nullish(),name:d(),optional:Ce().optional().default(!1),secret:Ce().optional().default(!0)}),oR=y({_meta:E(d(),x()).nullish(),description:d().nullish(),id:d(),name:d()}),aR=y({_meta:E(d(),x()).nullish(),description:d().nullish(),id:d(),link:d().nullish(),name:d(),vars:L(sR)}),lR=y({_meta:E(d(),x()).nullish(),args:L(d()).optional(),description:d().nullish(),env:E(d(),d()).optional(),id:d(),name:d()}),cR=V([aR.and(y({type:$("env_var")})),lR.and(y({type:$("terminal")})),oR]),uR=y({_meta:E(d(),x()).nullish(),methodId:d()}),hR=y({_meta:E(d(),x()).nullish()}),dR=y({_meta:E(d(),x()).nullish(),blob:d(),mimeType:d().nullish(),uri:d()}),pR=y({default:Ce().nullish(),description:d().nullish(),title:d().nullish()}),fR=y({_meta:E(d(),x()).nullish()}),gR=y({_meta:E(d(),x()).nullish()}),mR=y({amount:H(),currency:d()}),vR=y({_meta:E(d(),x()).nullish(),terminalId:d()}),yR=y({_meta:E(d(),x()).nullish(),newText:d(),oldText:d().nullish(),path:d()}),bR=V([d(),H(),H(),Ce(),L(d())]),wR=y({content:E(d(),bR).nullish()}),SR=V([wR.and(y({action:$("accept")})),y({action:$("decline")}),y({action:$("cancel")})]),_R=y({_meta:E(d(),x()).nullish()}),ry=d(),kR=y({_meta:E(d(),x()).nullish(),elicitationId:ry}),xR=y({_meta:E(d(),x()).nullish(),action:SR}),ER=$("object"),AR=$("string"),$R=y({_meta:E(d(),x()).nullish()}),TR=y({_meta:E(d(),x()).nullish(),form:_R.nullish(),url:$R.nullish()}),IR=y({elicitationId:ry,url:d().url()}),iy=y({const:d(),title:d()}),sy=y({_meta:E(d(),x()).nullish(),name:d(),value:d()}),CR=V([$(-32700),$(-32600),$(-32601),$(-32602),$(-32603),$(-32800),$(-32e3),$(-32002),$(-32042),H().int().min(-2147483648,{message:"Invalid value: Expected int32 to be >= -2147483648"}).max(2147483647,{message:"Invalid value: Expected int32 to be <= 2147483647"})]),oy=y({code:CR,data:x().optional(),message:d()}),ay=x(),ly=x(),cy=x(),RR=y({_meta:E(d(),x()).nullish(),readTextFile:Ce().optional().default(!1),writeTextFile:Ce().optional().default(!1)}),uy=y({_meta:E(d(),x()).nullish(),name:d(),value:d()}),hy=y({_meta:E(d(),x()).nullish(),name:d(),title:d().nullish(),version:d()}),PR=y({default:H().nullish(),description:d().nullish(),maximum:H().nullish(),minimum:H().nullish(),title:d().nullish()}),DR=y({_meta:E(d(),x()).nullish()}),LR=y({_meta:E(d(),x()).nullish(),additionalDirectories:L(d()).optional(),cursor:d().nullish(),cwd:d().nullish()}),zR=y({_meta:E(d(),x()).nullish()}),OR=y({_meta:E(d(),x()).nullish(),logout:zR.nullish()}),MR=y({_meta:E(d(),x()).nullish()}),NR=y({_meta:E(d(),x()).nullish()}),UR=y({_meta:E(d(),x()).nullish(),http:Ce().optional().default(!1),sse:Ce().optional().default(!1)}),FR=y({_meta:E(d(),x()).nullish(),headers:L(uy),name:d(),url:d()}),HR=y({_meta:E(d(),x()).nullish(),headers:L(uy),name:d(),url:d()}),WR=y({_meta:E(d(),x()).nullish(),args:L(d()),command:d(),env:L(sy),name:d()}),Ml=V([FR.and(y({type:$("http")})),HR.and(y({type:$("sse")})),WR]),ed=d(),ZR=y({_meta:E(d(),x()).nullish(),description:d().nullish(),modelId:ed,name:d()}),BR=V([$("error"),$("warning"),$("information"),$("hint")]),VR=y({_meta:E(d(),x()).nullish()}),jR=y({_meta:E(d(),x()).nullish()}),GR=y({_meta:E(d(),x()).nullish()}),qR=y({_meta:E(d(),x()).nullish()}),YR=y({_meta:E(d(),x()).nullish()}),XR=y({_meta:E(d(),x()).nullish(),maxCount:H().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish()}),KR=y({diff:d(),uri:d()}),JR=y({endLine:H().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}),startLine:H().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}),text:d()}),QR=y({_meta:E(d(),x()).nullish()}),eP=y({_meta:E(d(),x()).nullish()}),tP=y({languageId:d(),text:d(),uri:d()}),nP=y({_meta:E(d(),x()).nullish(),maxCount:H().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish()}),rP=V([$("rejected"),$("ignored"),$("replaced"),$("cancelled")]),iP=y({excerpts:L(JR),uri:d()}),sP=y({_meta:E(d(),x()).nullish()}),oP=y({_meta:E(d(),x()).nullish()}),aP=y({name:d(),owner:d(),remoteUrl:d()}),lP=y({_meta:E(d(),x()).nullish()}),cP=y({_meta:E(d(),x()).nullish(),jump:QR.nullish(),rename:oP.nullish(),searchAndReplace:lP.nullish()}),uP=y({id:d(),isRegex:Ce().nullish(),replace:d(),search:d(),uri:d()}),hP=V([$("automatic"),$("diagnostic"),$("manual")]),dP=y({_meta:E(d(),x()).nullish(),maxCount:H().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish()}),pP=y({_meta:E(d(),x()).nullish(),diagnostics:VR.nullish(),editHistory:XR.nullish(),openFiles:eP.nullish(),recentFiles:nP.nullish(),relatedSnippets:sP.nullish(),userActions:dP.nullish()}),fP=y({_meta:E(d(),x()).nullish(),additionalDirectories:L(d()).optional(),cwd:d(),mcpServers:L(Ml)}),gP=y({default:H().nullish(),description:d().nullish(),maximum:H().nullish(),minimum:H().nullish(),title:d().nullish()}),dy=d(),mP=V([$("allow_once"),$("allow_always"),$("reject_once"),$("reject_always")]),vP=y({_meta:E(d(),x()).nullish(),kind:mP,name:d(),optionId:dy}),yP=V([$("high"),$("medium"),$("low")]),bP=V([$("pending"),$("in_progress"),$("completed")]),wP=y({_meta:E(d(),x()).nullish(),content:d(),priority:yP,status:bP}),SP=y({_meta:E(d(),x()).nullish(),entries:L(wP)}),Wn=y({character:H().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}),line:H().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"})}),_P=y({id:d(),position:Wn,uri:d()}),kP=y({id:d(),newName:d(),position:Wn,uri:d()}),xP=y({action:d(),position:Wn,timestampMs:H(),uri:d()}),py=V([$("utf-16"),$("utf-32"),$("utf-8")]),EP=y({_meta:E(d(),x()).nullish(),auth:iR.optional().default({terminal:!1}),elicitation:TR.nullish(),fs:RR.optional().default({readTextFile:!1,writeTextFile:!1}),nes:cP.nullish(),positionEncodings:L(py).optional(),terminal:Ce().optional().default(!1)}),AP=y({_meta:E(d(),x()).nullish(),audio:Ce().optional().default(!1),embeddedContext:Ce().optional().default(!1),image:Ce().optional().default(!1)}),fy=H().int().gte(0).lte(65535),$P=y({_meta:E(d(),x()).nullish(),clientCapabilities:EP.optional().default({auth:{terminal:!1},fs:{readTextFile:!1,writeTextFile:!1},terminal:!1}),clientInfo:hy.nullish(),protocolVersion:fy}),Ki=y({end:Wn,start:Wn}),TP=y({message:d(),range:Ki,severity:BR,uri:d()}),IP=y({languageId:d(),lastFocusedMs:H().nullish(),uri:d(),visibleRange:Ki.nullish()}),CP=y({_meta:E(d(),x()).nullish(),diagnostics:L(TP).nullish(),editHistory:L(KR).nullish(),openFiles:L(IP).nullish(),recentFiles:L(tP).nullish(),relatedSnippets:L(iP).nullish(),userActions:L(xP).nullish()}),RP=y({newText:d(),range:Ki}),PP=y({cursorPosition:Wn.nullish(),edits:L(RP),id:d(),uri:d()}),DP=V([PP.and(y({kind:$("edit")})),_P.and(y({kind:$("jump")})),kP.and(y({kind:$("rename")})),uP.and(y({kind:$("searchAndReplace")}))]),LP=y({_meta:E(d(),x()).nullish(),content:d()}),zP=y({_meta:E(d(),x()).nullish()}),Lr=V([H(),d()]).nullable();y({_meta:E(d(),x()).nullish(),requestId:Lr});const OP=Ls(["assistant","user"]),Uo=y({_meta:E(d(),x()).nullish(),audience:L(OP).nullish(),lastModified:d().nullish(),priority:H().nullish()}),MP=y({_meta:E(d(),x()).nullish(),annotations:Uo.nullish(),data:d(),mimeType:d()}),NP=y({_meta:E(d(),x()).nullish(),annotations:Uo.nullish(),data:d(),mimeType:d(),uri:d().nullish()}),UP=y({_meta:E(d(),x()).nullish(),annotations:Uo.nullish(),description:d().nullish(),mimeType:d().nullish(),name:d(),size:H().nullish(),title:d().nullish(),uri:d()}),FP=y({_meta:E(d(),x()).nullish(),optionId:dy}),HP=V([y({outcome:$("cancelled")}),FP.and(y({outcome:$("selected")}))]),WP=y({_meta:E(d(),x()).nullish(),outcome:HP}),ZP=y({_meta:E(d(),x()).nullish()}),BP=y({_meta:E(d(),x()).nullish()}),VP=y({currentValue:Ce()}),jP=d(),gy=d(),GP=V([$("mode"),$("model"),$("thought_level"),d()]),td=d(),my=y({_meta:E(d(),x()).nullish(),description:d().nullish(),name:d(),value:td}),qP=y({_meta:E(d(),x()).nullish(),group:jP,name:d(),options:L(my)}),YP=V([L(my),L(qP)]),XP=y({currentValue:td,options:YP}),Ji=Ol(V([XP.and(y({type:$("select")})),VP.and(y({type:$("boolean")}))]),y({_meta:E(d(),x()).nullish(),category:GP.nullish(),description:d().nullish(),id:gy,name:d()})),KP=y({_meta:E(d(),x()).nullish(),configOptions:L(Ji)}),JP=y({_meta:E(d(),x()).nullish()}),Q=d(),QP=y({_meta:E(d(),x()).nullish(),id:d(),sessionId:Q}),eD=y({_meta:E(d(),x()).nullish(),sessionId:Q}),tD=y({_meta:E(d(),x()).nullish(),sessionId:Q}),nD=y({_meta:E(d(),x()).nullish(),sessionId:Q}),vy=y({_meta:E(d(),x()).nullish(),args:L(d()).optional(),command:d(),cwd:d().nullish(),env:L(sy).optional(),outputByteLimit:H().nullish(),sessionId:Q}),rD=y({_meta:E(d(),x()).nullish(),sessionId:Q,uri:d()}),iD=y({_meta:E(d(),x()).nullish(),position:Wn,sessionId:Q,uri:d(),version:H(),visibleRange:Ki}),sD=y({_meta:E(d(),x()).nullish(),languageId:d(),sessionId:Q,text:d(),uri:d(),version:H()}),oD=y({_meta:E(d(),x()).nullish(),sessionId:Q,uri:d()}),aD=y({_meta:E(d(),x()).nullish(),additionalDirectories:L(d()).optional(),cwd:d(),mcpServers:L(Ml).optional(),sessionId:Q}),yy=y({_meta:E(d(),x()).nullish(),sessionId:Q,terminalId:d()}),lD=y({_meta:E(d(),x()).nullish(),additionalDirectories:L(d()).optional(),cwd:d(),mcpServers:L(Ml),sessionId:Q}),by=y({_meta:E(d(),x()).nullish(),limit:H().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),line:H().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),path:d(),sessionId:Q}),cD=y({_meta:E(d(),x()).nullish(),id:d(),reason:rP.nullish(),sessionId:Q}),wy=y({_meta:E(d(),x()).nullish(),sessionId:Q,terminalId:d()}),uD=y({_meta:E(d(),x()).nullish(),additionalDirectories:L(d()).optional(),cwd:d(),mcpServers:L(Ml).optional(),sessionId:Q}),hD=y({_meta:E(d(),x()).nullish(),additionalDirectories:L(d()).optional(),cwd:d(),sessionId:Q,title:d().nullish(),updatedAt:d().nullish()}),dD=y({_meta:E(d(),x()).nullish(),nextCursor:d().nullish(),sessions:L(hD)}),pD=y({_meta:E(d(),x()).nullish(),title:d().nullish(),updatedAt:d().nullish()}),fD=y({_meta:E(d(),x()).nullish()}),Nl=d(),gD=y({_meta:E(d(),x()).nullish(),currentModeId:Nl}),mD=y({_meta:E(d(),x()).nullish(),description:d().nullish(),id:Nl,name:d()}),Ul=y({_meta:E(d(),x()).nullish(),availableModes:L(mD),currentModeId:Nl}),Fl=y({_meta:E(d(),x()).nullish(),availableModels:L(ZR),currentModelId:ed}),vD=y({_meta:E(d(),x()).nullish(),configOptions:L(Ji).nullish(),models:Fl.nullish(),modes:Ul.nullish(),sessionId:Q}),yD=y({_meta:E(d(),x()).nullish(),configOptions:L(Ji).nullish(),models:Fl.nullish(),modes:Ul.nullish()}),bD=y({_meta:E(d(),x()).nullish(),configOptions:L(Ji).nullish(),models:Fl.nullish(),modes:Ul.nullish(),sessionId:Q}),wD=y({_meta:E(d(),x()).nullish(),configOptions:L(Ji).nullish(),models:Fl.nullish(),modes:Ul.nullish()}),SD=y({_meta:E(d(),x()).nullish()}),_D=y({_meta:E(d(),x()).nullish(),additionalDirectories:ZP.nullish(),close:BP.nullish(),fork:JP.nullish(),list:fD.nullish(),resume:SD.nullish()}),kD=Ol(V([y({type:$("boolean"),value:Ce()}),y({value:td})]),y({_meta:E(d(),x()).nullish(),configId:gy,sessionId:Q})),xD=y({_meta:E(d(),x()).nullish(),configOptions:L(Ji)}),ED=y({_meta:E(d(),x()).nullish(),modeId:Nl,sessionId:Q}),AD=y({_meta:E(d(),x()).nullish()}),$D=y({_meta:E(d(),x()).nullish(),modelId:ed,sessionId:Q}),TD=y({_meta:E(d(),x()).nullish()}),ID=y({_meta:E(d(),x()).nullish(),sessionId:Q}),CD=V([$("end_turn"),$("max_tokens"),$("max_turn_requests"),$("refusal"),$("cancelled")]),RD=V([$("email"),$("uri"),$("date"),$("date-time")]),PD=y({default:d().nullish(),description:d().nullish(),enum:L(d()).nullish(),format:RD.nullish(),maxLength:H().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),minLength:H().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),oneOf:L(iy).nullish(),pattern:d().nullish(),title:d().nullish()}),DD=y({_meta:E(d(),x()).nullish(),context:CP.nullish(),position:Wn,selection:Ki.nullish(),sessionId:Q,triggerKind:hP,uri:d(),version:H()}),LD=y({_meta:E(d(),x()).nullish(),suggestions:L(DP)}),zD=y({_meta:E(d(),x()).nullish(),terminalId:d()}),OD=y({_meta:E(d(),x()).nullish(),exitCode:H().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),signal:d().nullish()}),Sy=y({_meta:E(d(),x()).nullish(),sessionId:Q,terminalId:d()}),MD=y({_meta:E(d(),x()).nullish(),exitStatus:OD.nullish(),output:d(),truncated:Ce()}),ND=y({_meta:E(d(),x()).nullish(),annotations:Uo.nullish(),text:d()}),UD=y({range:Ki.nullish(),text:d()}),FD=y({_meta:E(d(),x()).nullish(),contentChanges:L(UD),sessionId:Q,uri:d(),version:H()});y({method:d(),params:V([eD,sD,FD,rD,oD,iD,QP,cD,ay]).nullish()});const HD=V([$("full"),$("incremental")]),WD=y({_meta:E(d(),x()).nullish(),syncKind:HD}),ZD=y({_meta:E(d(),x()).nullish(),didChange:WD.nullish(),didClose:jR.nullish(),didFocus:GR.nullish(),didOpen:qR.nullish(),didSave:YR.nullish()}),BD=y({_meta:E(d(),x()).nullish(),document:ZD.nullish()}),VD=y({_meta:E(d(),x()).nullish(),context:pP.nullish(),events:BD.nullish()}),jD=y({_meta:E(d(),x()).nullish(),auth:OR.optional().default({}),loadSession:Ce().optional().default(!1),mcpCapabilities:UR.optional().default({http:!1,sse:!1}),nes:VD.nullish(),positionEncoding:py.nullish(),promptCapabilities:AP.optional().default({audio:!1,embeddedContext:!1,image:!1}),sessionCapabilities:_D.optional().default({})}),GD=y({_meta:E(d(),x()).nullish(),agentCapabilities:jD.optional().default({auth:{},loadSession:!1,mcpCapabilities:{http:!1,sse:!1},promptCapabilities:{audio:!1,embeddedContext:!1,image:!1},sessionCapabilities:{}}),agentInfo:hy.nullish(),authMethods:L(cR).optional().default([]),protocolVersion:fy}),qD=y({_meta:E(d(),x()).nullish(),mimeType:d().nullish(),text:d(),uri:d()}),YD=V([qD,dR]),XD=y({_meta:E(d(),x()).nullish(),annotations:Uo.nullish(),resource:YD}),nd=V([ND.and(y({type:$("text")})),NP.and(y({type:$("image")})),MP.and(y({type:$("audio")})),UP.and(y({type:$("resource_link")})),XD.and(y({type:$("resource")}))]),KD=y({_meta:E(d(),x()).nullish(),content:nd}),Nc=y({_meta:E(d(),x()).nullish(),content:nd,messageId:d().nullish()}),JD=y({_meta:E(d(),x()).nullish(),messageId:d().nullish(),prompt:L(nd),sessionId:Q}),QD=y({anyOf:L(iy)}),_y=V([KD.and(y({type:$("content")})),yR.and(y({type:$("diff")})),zD.and(y({type:$("terminal")}))]),ky=d(),xy=y({_meta:E(d(),x()).nullish(),line:H().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),path:d()}),Ey=V([$("pending"),$("in_progress"),$("completed"),$("failed")]),Ay=V([$("read"),$("edit"),$("delete"),$("move"),$("search"),$("execute"),$("think"),$("fetch"),$("switch_mode"),$("other")]),eL=y({_meta:E(d(),x()).nullish(),content:L(_y).optional(),kind:Ay.optional(),locations:L(xy).optional(),rawInput:x().optional(),rawOutput:x().optional(),status:Ey.optional(),title:d(),toolCallId:ky}),$y=y({_meta:E(d(),x()).nullish(),content:L(_y).nullish(),kind:Ay.nullish(),locations:L(xy).nullish(),rawInput:x().optional(),rawOutput:x().optional(),status:Ey.nullish(),title:d().nullish(),toolCallId:ky}),Ty=y({_meta:E(d(),x()).nullish(),options:L(vP),sessionId:Q,toolCall:$y}),tL=y({_meta:E(d(),x()).nullish(),hint:d()}),nL=tL,rL=y({_meta:E(d(),x()).nullish(),description:d(),input:nL.nullish(),name:d()}),iL=y({_meta:E(d(),x()).nullish(),availableCommands:L(rL)}),sL=y({enum:L(d()),type:AR}),oL=V([sL,QD]),aL=y({default:L(d()).nullish(),description:d().nullish(),items:oL,maxItems:H().nullish(),minItems:H().nullish(),title:d().nullish()}),lL=V([PD.and(y({type:$("string")})),gP.and(y({type:$("number")})),PR.and(y({type:$("integer")})),pR.and(y({type:$("boolean")})),aL.and(y({type:$("array")}))]),cL=y({description:d().nullish(),properties:E(d(),lL).optional().default({}),required:L(d()).nullish(),title:d().nullish(),type:ER.optional().default("object")}),uL=y({requestedSchema:cL}),hL=Ol(V([uL.and(y({mode:$("form")})),IR.and(y({mode:$("url")}))]),y({_meta:E(d(),x()).nullish(),message:d(),sessionId:Q})),dL=y({cachedReadTokens:H().nullish(),cachedWriteTokens:H().nullish(),inputTokens:H(),outputTokens:H(),thoughtTokens:H().nullish(),totalTokens:H()}),pL=y({_meta:E(d(),x()).nullish(),stopReason:CD,usage:dL.nullish(),userMessageId:d().nullish()});V([y({id:Lr,result:V([GD,hR,NR,bD,yD,dD,vD,wD,gR,AD,xD,pL,TD,ID,LD,fR,cy])}),y({error:oy,id:Lr})]);const fL=y({_meta:E(d(),x()).nullish(),cost:mR.nullish(),size:H(),used:H()}),gL=V([Nc.and(y({sessionUpdate:$("user_message_chunk")})),Nc.and(y({sessionUpdate:$("agent_message_chunk")})),Nc.and(y({sessionUpdate:$("agent_thought_chunk")})),eL.and(y({sessionUpdate:$("tool_call")})),$y.and(y({sessionUpdate:$("tool_call_update")})),SP.and(y({sessionUpdate:$("plan")})),iL.and(y({sessionUpdate:$("available_commands_update")})),gD.and(y({sessionUpdate:$("current_mode_update")})),KP.and(y({sessionUpdate:$("config_option_update")})),pD.and(y({sessionUpdate:$("session_info_update")})),fL.and(y({sessionUpdate:$("usage_update")}))]),Iy=y({_meta:E(d(),x()).nullish(),sessionId:Q,update:gL});y({method:d(),params:V([Iy,kR,ay]).nullish()});const Cy=y({_meta:E(d(),x()).nullish(),sessionId:Q,terminalId:d()}),mL=y({_meta:E(d(),x()).nullish(),exitCode:H().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),signal:d().nullish()}),vL=y({name:d(),uri:d()}),yL=y({_meta:E(d(),x()).nullish(),repository:aP.nullish(),workspaceFolders:L(vL).nullish(),workspaceUri:d().nullish()});y({id:Lr,method:d(),params:V([$P,uR,MR,fP,lD,LR,aD,uD,nD,ED,kD,JD,$D,yL,DD,tD,ly]).nullish()});const Ry=y({_meta:E(d(),x()).nullish(),content:d(),path:d(),sessionId:Q});y({id:Lr,method:d(),params:V([Ry,by,Ty,vy,Sy,wy,Cy,yy,hL,ly]).nullish()});const bL=y({_meta:E(d(),x()).nullish()});V([y({id:Lr,result:V([bL,LP,WP,vR,MD,zP,mL,DR,xR,cy])}),y({error:oy,id:Lr})]);var J;class wL{constructor(t,e){w(this,J);const r=t(this),i=async(o,a)=>{var c,u,h,p,v,g,_;switch(o){case en.fs_write_text_file:{const k=Ry.parse(a);return(c=r.writeTextFile)==null?void 0:c.call(r,k)}case en.fs_read_text_file:{const k=by.parse(a);return(u=r.readTextFile)==null?void 0:u.call(r,k)}case en.session_request_permission:{const k=Ty.parse(a);return r.requestPermission(k)}case en.terminal_create:{const k=vy.parse(a);return(h=r.createTerminal)==null?void 0:h.call(r,k)}case en.terminal_output:{const k=Sy.parse(a);return(p=r.terminalOutput)==null?void 0:p.call(r,k)}case en.terminal_release:{const k=wy.parse(a);return await((v=r.releaseTerminal)==null?void 0:v.call(r,k))??{}}case en.terminal_wait_for_exit:{const k=Cy.parse(a);return(g=r.waitForTerminalExit)==null?void 0:g.call(r,k)}case en.terminal_kill:{const k=yy.parse(a);return await((_=r.killTerminal)==null?void 0:_.call(r,k))??{}}default:if(r.extMethod)return r.extMethod(o,a);throw $e.methodNotFound(o)}},s=async(o,a)=>{switch(o){case en.session_update:{const c=Iy.parse(a);return r.sessionUpdate(c)}default:if(r.extNotification)return r.extNotification(o,a);throw $e.methodNotFound(o)}};S(this,J,new SL(i,s,e))}async initialize(t){return await l(this,J).sendRequest(he.initialize,t)}async newSession(t){return await l(this,J).sendRequest(he.session_new,t)}async loadSession(t){return await l(this,J).sendRequest(he.session_load,t)??{}}async unstable_forkSession(t){return await l(this,J).sendRequest(he.session_fork,t)}async listSessions(t){return await l(this,J).sendRequest(he.session_list,t)}async unstable_resumeSession(t){return await l(this,J).sendRequest(he.session_resume,t)}async unstable_closeSession(t){return await l(this,J).sendRequest(he.session_close,t)}async setSessionMode(t){return await l(this,J).sendRequest(he.session_set_mode,t)??{}}async unstable_setSessionModel(t){return await l(this,J).sendRequest(he.session_set_model,t)??{}}async setSessionConfigOption(t){return await l(this,J).sendRequest(he.session_set_config_option,t)}async authenticate(t){return await l(this,J).sendRequest(he.authenticate,t)??{}}async unstable_logout(t){return await l(this,J).sendRequest(he.logout,t)??{}}async prompt(t){return await l(this,J).sendRequest(he.session_prompt,t)}async cancel(t){return await l(this,J).sendNotification(he.session_cancel,t)}async unstable_startNes(t){return await l(this,J).sendRequest(he.nes_start,t)}async unstable_suggestNes(t){return await l(this,J).sendRequest(he.nes_suggest,t)}async unstable_closeNes(t){return await l(this,J).sendRequest(he.nes_close,t)??{}}async unstable_didOpenDocument(t){return await l(this,J).sendNotification(he.document_did_open,t)}async unstable_didChangeDocument(t){return await l(this,J).sendNotification(he.document_did_change,t)}async unstable_didCloseDocument(t){return await l(this,J).sendNotification(he.document_did_close,t)}async unstable_didSaveDocument(t){return await l(this,J).sendNotification(he.document_did_save,t)}async unstable_didFocusDocument(t){return await l(this,J).sendNotification(he.document_did_focus,t)}async unstable_acceptNes(t){return await l(this,J).sendNotification(he.nes_accept,t)}async unstable_rejectNes(t){return await l(this,J).sendNotification(he.nes_reject,t)}async extMethod(t,e){return await l(this,J).sendRequest(t,e)}async extNotification(t,e){return await l(this,J).sendNotification(t,e)}get signal(){return l(this,J).signal}get closed(){return l(this,J).closed}}J=new WeakMap;var En,ul,Zs,Bs,vi,yi,Nt,Vs,fe,Py,ku,Dy,Ly,zy,Oy,xu,vs;class SL{constructor(t,e,r){w(this,fe);w(this,En,new Map);w(this,ul,0);w(this,Zs);w(this,Bs);w(this,vi);w(this,yi,Promise.resolve());w(this,Nt,new AbortController);w(this,Vs);S(this,Zs,t),S(this,Bs,e),S(this,vi,r),S(this,Vs,new Promise(i=>{l(this,Nt).signal.addEventListener("abort",()=>i())})),f(this,fe,Py).call(this)}get signal(){return l(this,Nt).signal}get closed(){return l(this,Vs)}async sendRequest(t,e){f(this,fe,xu).call(this);const r=jd(this,ul)._++,i=new Promise((s,o)=>{l(this,En).set(r,{resolve:s,reject:o})});return await f(this,fe,vs).call(this,{jsonrpc:"2.0",id:r,method:t,params:e}),i}async sendNotification(t,e){f(this,fe,xu).call(this),await f(this,fe,vs).call(this,{jsonrpc:"2.0",method:t,params:e})}}En=new WeakMap,ul=new WeakMap,Zs=new WeakMap,Bs=new WeakMap,vi=new WeakMap,yi=new WeakMap,Nt=new WeakMap,Vs=new WeakMap,fe=new WeakSet,Py=async function(){let t;try{const e=l(this,vi).readable.getReader();try{for(;!l(this,Nt).signal.aborted;){const{value:r,done:i}=await e.read();if(i)break;if(r)try{f(this,fe,Dy).call(this,r)}catch(s){console.error("Unexpected error during message processing:",r,s),"id"in r&&r.id!==void 0&&f(this,fe,vs).call(this,{jsonrpc:"2.0",id:r.id,error:{code:-32700,message:"Parse error"}})}}}finally{e.releaseLock()}}catch(e){t=e}finally{f(this,fe,ku).call(this,t)}},ku=function(t){if(l(this,Nt).signal.aborted)return;const e=t??new Error("ACP connection closed");for(const r of l(this,En).values())r.reject(e);l(this,En).clear(),l(this,Nt).abort(e)},Dy=async function(t){if("method"in t&&"id"in t){const e=await f(this,fe,Ly).call(this,t.method,t.params);"error"in e&&console.error("Error handling request",t,e.error),await f(this,fe,vs).call(this,{jsonrpc:"2.0",id:t.id,...e})}else if("method"in t){const e=await f(this,fe,zy).call(this,t.method,t.params);"error"in e&&console.error("Error handling notification",t,e.error)}else"id"in t?f(this,fe,Oy).call(this,t):console.error("Invalid message",{message:t})},Ly=async function(t,e){try{return{result:await l(this,Zs).call(this,t,e)??null}}catch(r){if(r instanceof $e)return r.toResult();if(r instanceof Wf)return $e.invalidParams(r.format()).toResult();let i;(r instanceof Error||typeof r=="object"&&r!=null&&"message"in r&&typeof r.message=="string")&&(i=r.message);try{return $e.internalError(i?JSON.parse(i):{}).toResult()}catch{return $e.internalError({details:i}).toResult()}}},zy=async function(t,e){try{return await l(this,Bs).call(this,t,e),{result:null}}catch(r){if(r instanceof $e)return r.toResult();if(r instanceof Wf)return $e.invalidParams(r.format()).toResult();let i;(r instanceof Error||typeof r=="object"&&r!=null&&"message"in r&&typeof r.message=="string")&&(i=r.message);try{return $e.internalError(i?JSON.parse(i):{}).toResult()}catch{return $e.internalError({details:i}).toResult()}}},Oy=function(t){const e=l(this,En).get(t.id);if(e){if("result"in t)e.resolve(t.result);else if("error"in t){const{code:r,message:i,data:s}=t.error;e.reject(new $e(r,i,s))}l(this,En).delete(t.id)}else console.error("Got response to unknown request",t.id)},xu=function(){if(l(this,Nt).signal.aborted)throw l(this,Nt).signal.reason??new Error("ACP connection closed")},vs=async function(t){return S(this,yi,l(this,yi).then(async()=>{const e=l(this,vi).writable.getWriter();try{await e.write(t)}finally{e.releaseLock()}}).catch(e=>{f(this,fe,ku).call(this,e)})),l(this,yi)};class $e extends Error{constructor(e,r,i){super(r);m(this,"code");m(this,"data");this.code=e,this.name="RequestError",this.data=i}static parseError(e,r){return new $e(-32700,`Parse error${r?`: ${r}`:""}`,e)}static invalidRequest(e,r){return new $e(-32600,`Invalid request${r?`: ${r}`:""}`,e)}static methodNotFound(e){return new $e(-32601,`"Method not found": ${e}`,{method:e})}static invalidParams(e,r){return new $e(-32602,`Invalid params${r?`: ${r}`:""}`,e)}static internalError(e,r){return new $e(-32603,`Internal error${r?`: ${r}`:""}`,e)}static authRequired(e,r){return new $e(-32e3,`Authentication required${r?`: ${r}`:""}`,e)}static resourceNotFound(e){return new $e(-32002,`Resource not found${e?`: ${e}`:""}`,e&&{uri:e})}toResult(){return{error:{code:this.code,message:this.message,data:this.data}}}toErrorResponse(){return{code:this.code,message:this.message,data:this.data}}}const _L=/^Sender \(untrusted metadata\):\n```json\n[\s\S]*?\n```\n\n?/,kL=/^\[[^\n]*Working directory:[^\n]*\]\n\n?/,xL=/\[Television screen context\][\s\S]*?\[\/Television screen context\]\n*/,EL=/\b(tv|television|screen|artifact|artifacts|viewer|filmstrip|layout|focus)\b/i,AL=/\[\[\s*(?:reply_to_current|reply_to\s*:\s*[^\]\n]+|audio_as_voice)\s*\]\]\s*/gi,$L="single_session",TL={name:"television-acp-client",version:"0.0.0"},My="agent:main:television",IL=No(qt);var re,sn,yr,Ut,An,br,$n,wr,Tn,bi,Ft,Ve,on,wi,Sr,an,In,js,_t,kt,hl,ln,I,Ny,Uy,Fy,Eu,Hy,Wy,Zy,By,Vy,jy,Gy,nr,si,oi,Ze,qy,ai,Au,$u,Aa,Yy,Xy,Gs,qs,$a,li,Ky,Jy;class CL extends IL{constructor(e){super();w(this,I);w(this,re,PL());w(this,sn,null);w(this,yr,null);w(this,Ut,null);w(this,An,null);w(this,br,null);w(this,$n,null);w(this,wr);w(this,Tn,null);w(this,bi,1);w(this,Ft,null);w(this,Ve,null);w(this,on,!1);w(this,wi,!1);w(this,Sr,!1);w(this,an,null);w(this,In,new Set);w(this,js);w(this,_t);w(this,kt);w(this,hl,e=>{f(this,I,Uy).call(this,e)});w(this,ln,null);w(this,Gs,()=>{f(this,I,li).call(this,"ACP bridge websocket closed")});w(this,qs,()=>{f(this,I,li).call(this,"ACP bridge websocket error")});S(this,_t,e),S(this,kt,e.sessionMode??$L),S(this,wr,e.mappedSessionStore??RL()),S(this,js,e.createSocket??(r=>new WebSocket(r)))}getState(){return l(this,re)}get messages(){return l(this,re).messageOrder.map(e=>l(this,re).messagesById[e]).filter(e=>e!==void 0)}get enabled(){return l(this,_t).enabled??!1}setEnabled(e){l(this,_t).enabled=e,e||(f(this,I,$a).call(this),S(this,yr,null),S(this,Ut,null),S(this,An,null),S(this,$n,null),f(this,I,Ze).call(this,{lifecycle:{status:"disconnected"},bridge:null}))}async connect(){if(this.disposed)throw new Error("ACPClient has been disposed");if(this.enabled&&l(this,re).lifecycle.status!=="ready"){f(this,I,Ze).call(this,{lifecycle:{status:"connecting"}}),l(this,yr)??S(this,yr,f(this,I,Ny).call(this));try{await l(this,yr),await f(this,I,Eu).call(this)}catch(e){throw f(this,I,li).call(this,ca(e)),e}}}dispose(){f(this,I,$a).call(this),f(this,I,Ze).call(this,{lifecycle:{status:"disposed"},run:{status:"idle",stopReason:null,canCancel:!1,error:null},bridge:null})}async sendMessage(e){if(await this.connect(),l(this,re).lifecycle.status!=="ready"||l(this,re).run.status==="running"||l(this,re).run.status==="cancelling")throw new Error("ACPClient is not ready to send a new message");const r=e.text.trim();if(!r)throw new Error("Cannot send an empty message");f(this,I,si).call(this,{id:f(this,I,ai).call(this,"user"),kind:"user",text:r,status:"final"}),f(this,I,Ze).call(this,{run:{status:"running",stopReason:null,canCancel:!0,error:null}});try{const i=await f(this,I,Aa).call(this).prompt({sessionId:f(this,I,$u).call(this),prompt:[{type:"text",text:f(this,I,qy).call(this,r)}]});f(this,I,nr).call(this,i.stopReason==="cancelled"?"cancelled":"final"),f(this,I,Ze).call(this,{run:{status:i.stopReason==="cancelled"?"cancelled":"completed",stopReason:i.stopReason,canCancel:!1,error:null}})}catch(i){throw f(this,I,Jy).call(this)||(f(this,I,nr).call(this,"error"),f(this,I,Ze).call(this,{run:{status:"error",stopReason:null,canCancel:!1,error:ca(i)}})),i}}async cancel(){if(await this.connect(),!l(this,re).run.canCancel||l(this,re).run.status!=="running")throw new Error("No active cancellable run");f(this,I,Ze).call(this,{run:{...l(this,re).run,status:"cancelling"}}),await f(this,I,Aa).call(this).cancel({sessionId:f(this,I,$u).call(this)})}setScreenContext(e){var s,o,a;if(e===null){if(l(this,Ve)===null)return;S(this,Ve,null),S(this,on,!1);return}const r={screenID:e.screenID,screenName:e.screenName};if(((s=l(this,Ve))==null?void 0:s.screenID)===r.screenID&&((o=l(this,Ve))==null?void 0:o.screenName)===r.screenName)return;const i=((a=l(this,Ve))==null?void 0:a.screenID)??null;if(S(this,Ve,r),l(this,kt)==="single_session"){(!l(this,Tn)||i!==r.screenID)&&S(this,on,!0);return}l(this,Tn)!==qf(l(this,kt),r.screenID,l(this,_t).clientGUID??"default-client")&&(S(this,Ut,null),S(this,An,null),l(this,sn)&&l(this,re).run.status==="idle"&&f(this,I,Eu).call(this).catch(c=>{f(this,I,li).call(this,ca(c))}))}}re=new WeakMap,sn=new WeakMap,yr=new WeakMap,Ut=new WeakMap,An=new WeakMap,br=new WeakMap,$n=new WeakMap,wr=new WeakMap,Tn=new WeakMap,bi=new WeakMap,Ft=new WeakMap,Ve=new WeakMap,on=new WeakMap,wi=new WeakMap,Sr=new WeakMap,an=new WeakMap,In=new WeakMap,js=new WeakMap,_t=new WeakMap,kt=new WeakMap,hl=new WeakMap,ln=new WeakMap,I=new WeakSet,Ny=async function(){try{f(this,I,Ze).call(this,{lifecycle:{status:"connecting"}});const{stream:e,socket:r,metadata:i}=await zL({serverURL:l(this,_t).serverURL,token:l(this,_t).token,createSocket:l(this,js),onDisconnect:l(this,hl)});S(this,$n,i),f(this,I,Ze).call(this,{bridge:i}),S(this,ln,r),r.addEventListener("close",l(this,Gs)),r.addEventListener("error",l(this,qs)),S(this,sn,new wL(s=>({connection:s,sessionUpdate:async o=>{await f(this,I,Wy).call(this,o)},requestPermission:async o=>f(this,I,Zy).call(this,o)}),e)),await l(this,sn).initialize({protocolVersion:rR,clientCapabilities:{},clientInfo:TL})}catch(e){throw e}},Uy=function(e){f(this,I,li).call(this,ca(e))},Fy=function(e){const r=e==null?void 0:e.models;if(!(r!=null&&r.currentModelId))return;const i=r.availableModels.find(s=>s.modelId===r.currentModelId);console.info("[ACPClient] Current model:",(i==null?void 0:i.name)??r.currentModelId,`(${r.currentModelId})`)},Eu=async function(){const e=f(this,I,Xy).call(this);if(l(this,Ut)&&l(this,An)===e){await l(this,Ut);return}S(this,An,e),S(this,Ut,f(this,I,Hy).call(this,e)),await l(this,Ut)},Hy=async function(e){var c;const r=f(this,I,Aa).call(this);f(this,I,Ky).call(this);let i,s=!1,o=null;const a={cwd:f(this,I,Yy).call(this),mcpServers:[],_meta:{sessionKey:e}};try{if(S(this,Sr,!0),S(this,an,null),((c=l(this,$n))==null?void 0:c.sessionIdStrategy)==="mapped"){const u=l(this,wr).getActualSessionId(e);if(u)try{const h=await r.loadSession({...a,sessionId:u});if(DL(h))throw new Error("Mapped ACP session was not found");o=h,i=u,s=!0}catch{const h=await r.newSession(a);o=h,i=h.sessionId,l(this,wr).setActualSessionId(e,i),s=!1}else{const h=await r.newSession(a);o=h,i=h.sessionId,l(this,wr).setActualSessionId(e,i),s=!1}}else try{o=await r.loadSession({...a,sessionId:e}),i=e,s=l(this,re).messageOrder.length>0}catch{const u=await r.newSession(a);o=u,i=u.sessionId,s=!1}}finally{S(this,Sr,!1),S(this,an,null),f(this,I,nr).call(this,"final")}f(this,I,Fy).call(this,o),await r.setSessionConfigOption({sessionId:i,configId:"verbose_level",value:"full"}),S(this,br,i),S(this,Tn,e),S(this,wi,!0),s?(l(this,In).add(e),l(this,kt)==="single_session"&&S(this,on,!1)):(l(this,In).delete(e),S(this,on,l(this,kt)==="single_session")),f(this,I,Ze).call(this,{lifecycle:{status:"ready"}})},Wy=async function(e){const r=e.update;switch(r.sessionUpdate){case"user_message_chunk":r.content.type==="text"&&f(this,I,Gy).call(this,r.content.text);return;case"agent_message_chunk":r.content.type==="text"&&f(this,I,By).call(this,r.content.text);return;case"tool_call":f(this,I,Vy).call(this,r);return;case"tool_call_update":f(this,I,jy).call(this,r);return;case"agent_thought_chunk":return;default:return}},Zy=async function(e){return{outcome:{outcome:"cancelled"}}},By=function(e){S(this,an,null);const r=LL(e);if(!r)return;if(!l(this,Ft)){const s={id:f(this,I,ai).call(this,"assistant"),kind:"assistant",text:r,status:"streaming"};S(this,Ft,s.id),f(this,I,si).call(this,s);return}const i=l(this,re).messagesById[l(this,Ft)];if(!i||i.kind!=="assistant")throw new Error("Open assistant message invariant violated");f(this,I,oi).call(this,{...i,text:`${i.text}${r}`,status:"streaming"})},Vy=function(e){f(this,I,nr).call(this,"final");const r=f(this,I,Au).call(this,e.toolCallId),i=Xf("content"in e?e.content:void 0),s={id:(r==null?void 0:r.id)??f(this,I,ai).call(this,"tool"),kind:"tool_call",toolCallId:e.toolCallId,title:e.title,toolKind:e.kind??"other",status:e.status==="failed"?"failed":e.status==="completed"?"completed":"in_progress",text:(r==null?void 0:r.text)??i,locations:e.locations??(r==null?void 0:r.locations)};if(r){f(this,I,oi).call(this,s);return}f(this,I,si).call(this,s)},jy=function(e){const r=f(this,I,Au).call(this,e.toolCallId),i=(r==null?void 0:r.text)??"",s=Xf(e.content),o=s?`${i}${s}`:i,a={id:(r==null?void 0:r.id)??f(this,I,ai).call(this,"tool"),kind:"tool_call",toolCallId:e.toolCallId,title:(r==null?void 0:r.title)??e.toolCallId,toolKind:(r==null?void 0:r.toolKind)??"other",status:e.status==="failed"?"failed":e.status==="completed"?"completed":"in_progress",text:o,locations:e.locations??(r==null?void 0:r.locations)};if(r){f(this,I,oi).call(this,a);return}f(this,I,si).call(this,a)},Gy=function(e){if(f(this,I,nr).call(this,"final"),!e)return;const r=l(this,Sr)?l(this,an):null;if(!r){const s=Yf(e);if(!s)return;const o={id:f(this,I,ai).call(this,"user"),kind:"user",text:s,status:"final"};f(this,I,si).call(this,o),l(this,Sr)&&S(this,an,o.id);return}const i=l(this,re).messagesById[r];if(!i||i.kind!=="user")throw new Error("Replay user message invariant violated");f(this,I,oi).call(this,{...i,text:Yf(`${i.text}${e}`)})},nr=function(e){if(!l(this,Ft))return;const r=l(this,re).messagesById[l(this,Ft)];(r==null?void 0:r.kind)==="assistant"&&f(this,I,oi).call(this,{...r,status:e}),S(this,Ft,null)},si=function(e){f(this,I,Ze).call(this,{messagesById:{...l(this,re).messagesById,[e.id]:e},messageOrder:[...l(this,re).messageOrder,e.id]})},oi=function(e){f(this,I,Ze).call(this,{messagesById:{...l(this,re).messagesById,[e.id]:e}})},Ze=function(e){const r={...l(this,re),...e};S(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 oe("change"))},qy=function(e){const r=l(this,Tn);if(!r)return e;const i=l(this,Ve)?l(this,kt)==="single_session"?l(this,on)||!l(this,In).has(r):!l(this,In).has(r):!1,s=l(this,wi)&&(l(this,Ve)!==null||EL.test(e));if(!(s||i))return e;s&&S(this,wi,!1),i&&(S(this,on,!1),l(this,In).add(r));const a=["[Television screen context]","This chat session is coming from a Television client.","Using Television requires the knowledge in the `television` skill. Re-read it only if it is not already in context or you know it changed.","If the skill is not installed, it can be installed via `tv skills install <your agent skills path>`."];return l(this,Ve)?(a.push("This conversation is currently attached to the screen below."),a.push(`screen_id: ${l(this,Ve).screenID}`),a.push(`screen_name: ${l(this,Ve).screenName??""}`),a.push("When the user asks to inspect or change Television state with the tv CLI, use this screen ID with the --screen argument.")):a.push("There is currently no active Television screen."),a.push("[/Television screen context]","",e),a.join(`
|
|
43
|
+
`)},ai=function(e){const r=`${e}-${l(this,bi)}`;return S(this,bi,l(this,bi)+1),r},Au=function(e){for(const r of l(this,re).messageOrder){const i=l(this,re).messagesById[r];if((i==null?void 0:i.kind)==="tool_call"&&i.toolCallId===e)return i}return null},$u=function(){if(!l(this,br))throw new Error("ACP session is not ready");return l(this,br)},Aa=function(){if(!l(this,sn))throw new Error("ACP connection is not ready");return l(this,sn)},Yy=function(){var r;const e=(r=l(this,$n))==null?void 0:r.sessionCwd;if(!e)throw new Error("ACP bridge session cwd is not ready");return e},Xy=function(){var r;if(l(this,kt)==="single_session")return`${My}-${(l(this,_t).clientGUID??"default-client").toLowerCase()}`;const e=(r=l(this,Ve))==null?void 0:r.screenID;if(!e)throw new Error("Screen context is required for per-screen session mode");return qf(l(this,kt),e,l(this,_t).clientGUID??"default-client")},Gs=new WeakMap,qs=new WeakMap,$a=function(){S(this,sn,null),S(this,yr,null),S(this,Ut,null),S(this,An,null),S(this,br,null),S(this,Tn,null),S(this,$n,null),l(this,ln)&&(l(this,ln).removeEventListener("close",l(this,Gs)),l(this,ln).removeEventListener("error",l(this,qs)),l(this,ln).close(),S(this,ln,null))},li=function(e){this.disposed||l(this,re).lifecycle.status==="disconnected"||(f(this,I,nr).call(this,"error"),f(this,I,$a).call(this),f(this,I,Ze).call(this,{lifecycle:{status:"disconnected",...e?{error:e}:{}},run:{status:"idle",stopReason:null,canCancel:!1,error:null},bridge:null}))},Ky=function(){S(this,Ft,null),S(this,an,null),S(this,bi,1),f(this,I,Ze).call(this,{run:{status:"idle",stopReason:null,canCancel:!1,error:null},messagesById:{},messageOrder:[]})},Jy=function(){return l(this,re).lifecycle.status==="disconnected"};function RL(){const n=new Map;return{getActualSessionId(t){return n.get(t)??null},setActualSessionId(t,e){n.set(t,e)},clearActualSessionId(t){n.delete(t)}}}function PL(){return{lifecycle:{status:"connecting"},run:{status:"idle",stopReason:null,canCancel:!1,error:null},bridge:null,messagesById:{},messageOrder:[],sendDisabled:!0,cancelDisabled:!0}}function DL(n){return n==null?!0:typeof n=="object"&&Object.keys(n).length===0}function qf(n,t,e){return n==="single_session"?`${My}-${e.toLowerCase()}`:`agent:main:television-${e.toLowerCase()}-${t.toLowerCase()}`}function Qy(n){return n.replace(/^(?:\s*\n)+/,"")}function Yf(n){let t=n;return t=t.replace(_L,""),t=t.replace(kL,""),t=t.replace(xL,""),t=Qy(t),t}function LL(n){let t=n;return t=t.replace(AL,""),t=Qy(t),t}function Xf(n){return!n||n.length===0?"":n.flatMap(t=>t.type==="content"&&t.content.type==="text"?[t.content.text]:[]).join("")}async function zL(n){const t=n.createSocket(NL(n.serverURL,n.token));let e=!1,r,i;const s=new Promise((u,h)=>{r=u,i=h}),o=new ReadableStream({start(u){let h=!1;const p=()=>{t.send(JSON.stringify({type:"acp-bridge-connect"}))},v=k=>{const T=ML(k);if(!T)return;let P;try{P=JSON.parse(T)}catch(R){const W=R instanceof Error?R:new Error(String(R));i(W),u.error(W);return}switch(P.type){case"acp-bridge-status":if(P.status==="ready"){let R;try{R=OL(P)}catch(W){const N=W instanceof Error?W:new Error(String(W));e||i(N),u.error(N);return}e||(e=!0,r(R));return}if(P.status==="error"||P.status==="exited"){const R=new Error(P.error??`ACP bridge ${P.status}`);e||i(R),u.error(R)}return;case"acp-bridge-message":u.enqueue(P.message);return}},g=()=>{var T;if(h)return;h=!0;const k=new Error("ACP bridge websocket closed");e||i(k),(T=n.onDisconnect)==null||T.call(n,k),u.close()},_=()=>{var T;if(h)return;h=!0;const k=new Error("ACP bridge websocket error");e||i(k),(T=n.onDisconnect)==null||T.call(n,k),u.error(k)};t.addEventListener("open",p),t.addEventListener("message",v),t.addEventListener("close",g),t.addEventListener("error",_)}}),a=new WritableStream({async write(u){await s,t.send(JSON.stringify({type:"acp-bridge-message",message:u}))},close(){t.close()},abort(){t.close()}}),c=await s;return{stream:{readable:o,writable:a},socket:t,metadata:c}}function OL(n){const{agent:t,sessionIdStrategy:e,sessionCwd:r}=n;if((t==="openclaw"||t==="hermes")&&(e==="deterministic"||e==="mapped")&&typeof r=="string"&&r.length>0)return{agent:t,sessionIdStrategy:e,sessionCwd:r};throw new Error("ACP bridge ready status missing bootstrap metadata")}function ML(n){if(typeof n=="string")return n;if(n instanceof Uint8Array)return new TextDecoder().decode(n);if(typeof Buffer<"u"&&n instanceof Buffer)return n.toString("utf8");if(typeof n=="object"&&n!==null&&"data"in n){const t=n.data;if(typeof t=="string")return t;if(t instanceof Uint8Array)return new TextDecoder().decode(t);if(Array.isArray(t))return Buffer.concat(t).toString("utf8")}return null}function NL(n,t){const e=new URL(n);return e.protocol=e.protocol==="https:"?"wss:":"ws:",e.pathname="/acp",e.search="",e.searchParams.set("token",t),e.hash="",e.toString()}function ca(n){return n instanceof Error?n.message:String(n)}const Kf="television.acpClientGUID",Jf="television.acpMappedSessions",Qf=1;var Si;class UL{constructor(){w(this,Si,new Map)}getActualSessionId(t){return l(this,Si).get(t)??null}setActualSessionId(t,e){l(this,Si).set(t,e)}clearActualSessionId(t){l(this,Si).delete(t)}}Si=new WeakMap;var _i,Ys,lt,Ta,Ia,Tu;class FL{constructor(t,e){w(this,lt);w(this,_i);w(this,Ys);S(this,_i,t),S(this,Ys,e)}getActualSessionId(t){const e=f(this,lt,Ia).call(this)[f(this,lt,Ta).call(this,t)];return typeof e=="string"&&e.length>0?e:null}setActualSessionId(t,e){const r=f(this,lt,Ia).call(this);r[f(this,lt,Ta).call(this,t)]=e,f(this,lt,Tu).call(this,r)}clearActualSessionId(t){const e=f(this,lt,Ia).call(this);delete e[f(this,lt,Ta).call(this,t)],f(this,lt,Tu).call(this,e)}}_i=new WeakMap,Ys=new WeakMap,lt=new WeakSet,Ta=function(t){return JSON.stringify([l(this,Ys),t])},Ia=function(){const t=l(this,_i).getItem(Jf);if(!t)return{};let e;try{e=JSON.parse(t)}catch{return{}}if(typeof e!="object"||e===null||Array.isArray(e))return{};const r=e;return r.version!==Qf?{}:typeof r.entries!="object"||r.entries===null||Array.isArray(r.entries)?{}:Object.fromEntries(Object.entries(r.entries).filter(i=>typeof i[1]=="string"))},Tu=function(t){const e={version:Qf,entries:t};l(this,_i).setItem(Jf,JSON.stringify(e))};function HL(){return typeof window>"u"?null:window.localStorage}function WL(n){const t=n.getItem(Kf);if(t)return t;const e=Pl().toLowerCase();return n.setItem(Kf,e),e}const eg=4401,ZL=401,ua=1e3,BL=3e4;class $s extends Error{constructor(t="Authentication required"){super(t),this.name="AuthError"}}class eb extends qt{constructor(e){var i,s;super();m(this,"url");m(this,"name");m(this,"status","unauthorized");m(this,"screens",new Map);m(this,"views",[]);m(this,"client");m(this,"acpClient");m(this,"_token");m(this,"attempting",!1);m(this,"nextRetryAt",null);m(this,"hasEverConnected",!1);m(this,"createSocket");m(this,"createClient");m(this,"socket",null);m(this,"connectAttempt",0);m(this,"autoReconnect",!1);m(this,"retryTimer",null);m(this,"retryDelay",ua);m(this,"visibilityEventTarget");m(this,"networkEventTarget");m(this,"onVisibilityChange");m(this,"onNetworkOnline");this.url=we(e.url),this.name=e.name,this._token=e.token??null,this.createSocket=e.createSocket??(o=>new WebSocket(o)),this.createClient=e.createClient??((o,a)=>new s$(o,{token:a??void 0})),this.client=this.createClient(this.url,this._token);const r=e.mappedSessionStore??(e.acpStorage?new FL(e.acpStorage,this.url):new UL);this.acpClient=new CL({serverURL:this.url,token:this._token??"",...e.createACPSocket?{createSocket:e.createACPSocket}:e.createSocket?{createSocket:e.createSocket}:{},...e.clientGUID?{clientGUID:e.clientGUID}:{},mappedSessionStore:r}),this.visibilityEventTarget=e.visibilityEventTarget!==void 0?e.visibilityEventTarget:typeof document<"u"?document:null,this.networkEventTarget=e.networkEventTarget!==void 0?e.networkEventTarget:typeof window<"u"?window:null,this.onVisibilityChange=()=>{this.isPageVisible()&&this.kickReconnect()},this.onNetworkOnline=()=>{this.kickReconnect()},(i=this.visibilityEventTarget)==null||i.addEventListener("visibilitychange",this.onVisibilityChange),(s=this.networkEventTarget)==null||s.addEventListener("online",this.onNetworkOnline)}get token(){return this._token}async connect(e){this._token=e,this.cancelRetryTimer(),this.retryDelay=ua,this.autoReconnect=!0,await this.attempt()}dispose(){var e,r,i;this.autoReconnect=!1,this.connectAttempt+=1,this.cancelRetryTimer(),(e=this.socket)==null||e.close(),this.socket=null,this.setStatus("unauthorized"),(r=this.visibilityEventTarget)==null||r.removeEventListener("visibilitychange",this.onVisibilityChange),(i=this.networkEventTarget)==null||i.removeEventListener("online",this.onNetworkOnline),this.acpClient.dispose()}getViewURL(e){const r=nR(e.kind,this.views);if(!r)return null;const i=`${this.url}/views/${encodeURIComponent(r.id)}/`;return this._token===null?i:`${i}?token=${encodeURIComponent(this._token)}`}getContentURL(e){if(e.kind==="url")return null;const r=`${this.url}/artifacts/${encodeURIComponent(e.id)}/content/`;return this._token===null?r:`${r}?token=${encodeURIComponent(this._token)}`}async createScreen(e){const{screen:r}=await this.client.screens.create({name:e});return this.screens.set(r.id,structuredClone(r)),r}applyServerEvent(e){switch(e.type){case"screen-created":this.screens.set(e.screen.id,structuredClone(e.screen)),this.dispatchEvent(new xa("screens-changed"));break;case"screen-updated":this.screens.set(e.screen.id,structuredClone(e.screen)),this.dispatchEvent(new xa("screens-changed"));break;case"screen-removed":this.screens.delete(e.screenID),this.dispatchEvent(new xa("screens-changed"));break;case"artifact-created":break;case"artifact-attached":{const r=this.screens.get(e.screenID);r&&!hv(r.layout,e.artifact.id)&&(r.layout=[...r.layout,uv(e.artifact.id,{id:e.cardID})]);break}case"artifact-removed":{const r=this.screens.get(e.screenID);r&&(r.layout=tv(r.layout,e.artifactID));break}case"artifact-updated":case"artifact-content-changed":case"screen-changed":case"theme-changed":case"artifact-focus":break;default:return VL(e,"server event")}}async attempt(){var i;this.attempting=!0,this.nextRetryAt=null,this.connectAttempt+=1;const e=this.connectAttempt;(i=this.socket)==null||i.close(),this.client=this.createClient(this.url,this._token),this.setStatus("connecting"),this.dispatchEvent(new oe("change"));const r=this.createSocket(jL(this.url,this._token));return this.socket=r,await new Promise((s,o)=>{let a=!1;const c=()=>{a||this.connectAttempt!==e||(a=!0,this.retryDelay=ua,this.hasEverConnected=!0,this.setStatus("connected"),s())},u=p=>{a||this.connectAttempt!==e||(a=!0,o(p))},h=async()=>{try{const[{screens:p},v,g]=await Promise.all([this.client.screens.list(),this.client.views.list(),this.client.display.get()]);this.screens=new Map(p.map(_=>[_.id,structuredClone(_)])),this.views=v,this.acpClient.setEnabled(g.acpEnabled),this.dispatchEvent(new oe("change")),this.dispatchEvent(new gu("server-event",{serverURL:this.url,event:{type:"screen-changed",screenID:g.activeScreenID}})),c()}catch(p){if(YL(p)){u(new $s);return}u(p instanceof Error?p:new Error(String(p)))}};r.addEventListener("open",()=>{h()}),r.addEventListener("message",p=>{const v=qL(p);v&&(this.applyServerEvent(v),this.dispatchEvent(new gu("server-event",{serverURL:this.url,event:v})))}),r.addEventListener("close",p=>{if(this.connectAttempt!==e)return;this.socket=null;const v=GL(p);if(!a){u(v===eg?new $s:new Error("Connection closed before initialization"));return}if(v===eg){this.autoReconnect=!1,this.cancelRetryTimer(),this.setStatus("unauthorized");return}this.handleTransportFailure(new Error("Connection closed"))}),r.addEventListener("error",()=>{if(this.connectAttempt===e){if(a){this.handleTransportFailure(new Error("WebSocket error"));return}u(new Error("WebSocket connection failed"))}})}).then(()=>{this.attempting=!1},s=>{throw this.attempting=!1,this.handleAttemptFailure(s),s})}handleAttemptFailure(e){if(e instanceof $s){this.autoReconnect=!1,this.cancelRetryTimer(),this.setStatus("unauthorized");return}this.autoReconnect&&this.scheduleRetry()}handleTransportFailure(e){this.autoReconnect&&(this.setStatus("connecting"),this.scheduleRetry())}scheduleRetry(){this.cancelRetryTimer(),this.connectAttempt+=1;const e=this.retryDelay;this.retryDelay=Math.min(this.retryDelay*2,BL),this.nextRetryAt=Date.now()+e,this.retryTimer=setTimeout(()=>{this.retryTimer=null,this.attempt().catch(()=>{})},e),this.dispatchEvent(new oe("change"))}cancelRetryTimer(){this.retryTimer!==null&&(clearTimeout(this.retryTimer),this.retryTimer=null),this.nextRetryAt!==null&&(this.nextRetryAt=null,this.dispatchEvent(new oe("change")))}kickReconnect(){this.autoReconnect&&this.status!=="connected"&&(this.attempting||(this.cancelRetryTimer(),this.retryDelay=ua,this.attempt().catch(()=>{})))}setStatus(e){this.status!==e&&(this.status=e,this.dispatchEvent(new oe("change")))}isPageVisible(){return this.visibilityEventTarget===null?!0:this.visibilityEventTarget.visibilityState==="visible"}}function VL(n,t){throw new Error(`Unexpected ${t}: ${JSON.stringify(n)}`)}function jL(n,t){const e=new URL(n);return e.protocol=e.protocol==="https:"?"wss:":"ws:",e.pathname="/events",e.search="",t&&e.searchParams.set("token",t),e.hash="",e.toString()}function GL(n){return typeof n=="object"&&n!==null&&"code"in n&&typeof n.code=="number"?n.code:null}function qL(n){const t=typeof n=="string"?n:typeof n=="object"&&n!==null&&"data"in n&&typeof n.data=="string"?n.data:"";if(!t)return null;try{return JSON.parse(t)}catch{return null}}function YL(n){return n instanceof fv&&n.status===ZL}const XL="Local";var Xs,Iu;class KL extends qt{constructor(e){super();w(this,Xs);m(this,"servers",new Map);m(this,"localServerURL");m(this,"clientGUID");m(this,"acpStorage");m(this,"localStore");m(this,"createSocket");m(this,"lastActiveServerURL");m(this,"serverListeners",new Map);m(this,"handleLocalStoreChange",()=>{const e=this.localStore.get().activeServerURL;e!==this.lastActiveServerURL&&(this.lastActiveServerURL=e,this.dispatchEvent(new oe("change")))});this.localStore=e.localStore,this.localServerURL=e.localServerURL?we(e.localServerURL):null,this.createSocket=e.createSocket??(i=>new WebSocket(i)),this.lastActiveServerURL=this.localStore.get().activeServerURL;const r=e.acpStorage===void 0?HL():e.acpStorage;this.acpStorage=r,this.clientGUID=e.clientGUID??(r?WL(r):Pl().toLowerCase()),this.localStore.addEventListener("change",this.handleLocalStoreChange)}get activeServer(){const e=this.localStore.get().activeServerURL;return e===null?null:this.servers.get(e)??null}add(e){const r=we(e.url);this.servers.get(r)&&this.remove(r),this.servers.set(r,e);const s=()=>{this.dispatchEvent(new oe("change"))},o=c=>{this.dispatchEvent(new gu("server-event",{serverURL:c.serverURL,event:c.event}))},a=()=>{this.dispatchEvent(new xa("screens-changed"))};e.addEventListener("change",s),e.addEventListener("server-event",o),e.addEventListener("screens-changed",a),this.serverListeners.set(r,{onServerChange:s,onServerEvent:o,onScreensChanged:a}),this.dispatchEvent(new oe("change"))}remove(e){const r=we(e);if(this.localServerURL&&r===this.localServerURL)return;const i=this.servers.get(r);if(!i)return;const s=this.serverListeners.get(r);s&&(i.removeEventListener("change",s.onServerChange),i.removeEventListener("server-event",s.onServerEvent),i.removeEventListener("screens-changed",s.onScreensChanged),this.serverListeners.delete(r)),i.dispose(),this.servers.delete(r);const o=this.localStore.get(),a=o.activeServerURL===r;this.localStore.set({...o,servers:o.servers.filter(c=>c.url!==r),activeServerURL:a?null:o.activeServerURL}),this.dispatchEvent(new oe("change"))}setActive(e){const r=this.localStore.get(),i=e?we(e.url):null;r.activeServerURL!==i&&this.localStore.set({...r,activeServerURL:i})}connectConfiguredServers(e,r){const i=e?we(e):null;if(i){const a=this.localStore.get();a.servers.some(u=>we(u.url)===i)||this.localStore.set({...a,servers:[...a.servers,{url:i,name:XL}]})}const s=this.localStore.get().servers;for(const a of s){const c=we(a.url),h=i!==null&&c===i?r??null:null,p=f(this,Xs,Iu).call(this,{url:a.url,name:a.name,token:h});this.add(p),p.connect(h).catch(()=>{})}const o=i?this.servers.get(i)??null:null;this.setActive(o??this.servers.values().next().value??null)}addServer(e,r){const i=we(e);this.remove(i);const s=this.localStore.get();this.localStore.set({...s,servers:[...s.servers.filter(a=>we(a.url)!==i),{url:i,name:r}]});const o=f(this,Xs,Iu).call(this,{url:i,name:r,token:null});this.add(o),this.setActive(o),o.connect(null).catch(()=>{})}removeServer(e){this.remove(e)}}Xs=new WeakSet,Iu=function(e){return new eb({url:e.url,name:e.name,token:e.token,createSocket:this.createSocket,clientGUID:this.clientGUID,acpStorage:this.acpStorage})};var Ks;class JL extends qt{constructor(){super();w(this,Ks,e=>{const r=QL(e);r!==null&&(e.preventDefault(),this.dispatchEvent(new TA("shortcut-triggered",{shortcut:r})))});document.addEventListener("keydown",l(this,Ks))}dispose(){document.removeEventListener("keydown",l(this,Ks))}}Ks=new WeakMap;function QL(n){for(const[t,e]of Object.entries(o$))if(ez(n,e.trigger))return t;return null}function ez(n,t){return!(n.key.toLowerCase()!==t.key.toLowerCase()||n.metaKey!==!!t.meta||n.ctrlKey!==!!t.ctrl||n.shiftKey!==!!t.shift||n.altKey!==!!t.alt)}const tz="serverURL",nz="token",rz="mode",iz="electron";function tb(n=window.location.search,t=window.location.origin){const r=new URLSearchParams(n).get(tz);return r?new URL(r).origin:new URL(t).origin}function tg(n=window.location.search){return new URLSearchParams(n).get(nz)}function rd(n=window.location.search){return new URLSearchParams(n).get(rz)===iz}let wn=null;async function nb(n,t){if(wn==null||wn.abort(),n===null){wn=null,qa();return}const e=new AbortController;wn=e;try{const r=t.token?{Authorization:`Bearer ${t.token}`}:void 0,i=new URL(`/themes/${n}/theme.css`,t.url).toString(),s=await fetch(i,{signal:e.signal,...r?{headers:r}:{}});if(!s.ok)throw new Error(`Theme fetch failed: ${s.status}`);const o=await s.text();if(wn!==e)return;Km(o)}catch(r){if(r.name==="AbortError")return;qa();const i=r instanceof Error?r.message:String(r);console.warn(`applyTheme: ${i}`)}finally{wn===e&&(wn=null)}}/**
|
|
44
|
+
* @license
|
|
45
|
+
* Copyright 2017 Google LLC
|
|
46
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
47
|
+
*/const Ts=globalThis,ng=n=>n,tl=Ts.trustedTypes,rg=tl?tl.createPolicy("lit-html",{createHTML:n=>n}):void 0,rb="$lit$",_n=`lit$${Math.random().toFixed(9).slice(2)}$`,ib="?"+_n,sz=`<${ib}>`,zr=document,zs=()=>zr.createComment(""),Os=n=>n===null||typeof n!="object"&&typeof n!="function",id=Array.isArray,oz=n=>id(n)||typeof(n==null?void 0:n[Symbol.iterator])=="function",Uc=`[
|
|
48
|
+
\f\r]`,os=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,ig=/-->/g,sg=/>/g,Jn=RegExp(`>|${Uc}(?:([^\\s"'>=/]+)(${Uc}*=${Uc}*(?:[^
|
|
49
|
+
\f\r"'\`<>=]|("|')|))|$)`,"g"),og=/'/g,ag=/"/g,sb=/^(?:script|style|textarea|title)$/i,az=n=>(t,...e)=>({_$litType$:n,strings:t,values:e}),z=az(1),Or=Symbol.for("lit-noChange"),ae=Symbol.for("lit-nothing"),lg=new WeakMap,hr=zr.createTreeWalker(zr,129);function ob(n,t){if(!id(n)||!n.hasOwnProperty("raw"))throw Error("invalid template strings array");return rg!==void 0?rg.createHTML(t):t}const lz=(n,t)=>{const e=n.length-1,r=[];let i,s=t===2?"<svg>":t===3?"<math>":"",o=os;for(let a=0;a<e;a++){const c=n[a];let u,h,p=-1,v=0;for(;v<c.length&&(o.lastIndex=v,h=o.exec(c),h!==null);)v=o.lastIndex,o===os?h[1]==="!--"?o=ig:h[1]!==void 0?o=sg:h[2]!==void 0?(sb.test(h[2])&&(i=RegExp("</"+h[2],"g")),o=Jn):h[3]!==void 0&&(o=Jn):o===Jn?h[0]===">"?(o=i??os,p=-1):h[1]===void 0?p=-2:(p=o.lastIndex-h[2].length,u=h[1],o=h[3]===void 0?Jn:h[3]==='"'?ag:og):o===ag||o===og?o=Jn:o===ig||o===sg?o=os:(o=Jn,i=void 0);const g=o===Jn&&n[a+1].startsWith("/>")?" ":"";s+=o===os?c+sz:p>=0?(r.push(u),c.slice(0,p)+rb+c.slice(p)+_n+g):c+_n+(p===-2?a:g)}return[ob(n,s+(n[e]||"<?>")+(t===2?"</svg>":t===3?"</math>":"")),r]};class Ms{constructor({strings:t,_$litType$:e},r){let i;this.parts=[];let s=0,o=0;const a=t.length-1,c=this.parts,[u,h]=lz(t,e);if(this.el=Ms.createElement(u,r),hr.currentNode=this.el.content,e===2||e===3){const p=this.el.content.firstChild;p.replaceWith(...p.childNodes)}for(;(i=hr.nextNode())!==null&&c.length<a;){if(i.nodeType===1){if(i.hasAttributes())for(const p of i.getAttributeNames())if(p.endsWith(rb)){const v=h[o++],g=i.getAttribute(p).split(_n),_=/([.?@])?(.*)/.exec(v);c.push({type:1,index:s,name:_[2],strings:g,ctor:_[1]==="."?uz:_[1]==="?"?hz:_[1]==="@"?dz:Wl}),i.removeAttribute(p)}else p.startsWith(_n)&&(c.push({type:6,index:s}),i.removeAttribute(p));if(sb.test(i.tagName)){const p=i.textContent.split(_n),v=p.length-1;if(v>0){i.textContent=tl?tl.emptyScript:"";for(let g=0;g<v;g++)i.append(p[g],zs()),hr.nextNode(),c.push({type:2,index:++s});i.append(p[v],zs())}}}else if(i.nodeType===8)if(i.data===ib)c.push({type:2,index:s});else{let p=-1;for(;(p=i.data.indexOf(_n,p+1))!==-1;)c.push({type:7,index:s}),p+=_n.length-1}s++}}static createElement(t,e){const r=zr.createElement("template");return r.innerHTML=t,r}}function Fi(n,t,e=n,r){var o,a;if(t===Or)return t;let i=r!==void 0?(o=e._$Co)==null?void 0:o[r]:e._$Cl;const s=Os(t)?void 0:t._$litDirective$;return(i==null?void 0:i.constructor)!==s&&((a=i==null?void 0:i._$AO)==null||a.call(i,!1),s===void 0?i=void 0:(i=new s(n),i._$AT(n,e,r)),r!==void 0?(e._$Co??(e._$Co=[]))[r]=i:e._$Cl=i),i!==void 0&&(t=Fi(n,i._$AS(n,t.values),i,r)),t}class cz{constructor(t,e){this._$AV=[],this._$AN=void 0,this._$AD=t,this._$AM=e}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(t){const{el:{content:e},parts:r}=this._$AD,i=((t==null?void 0:t.creationScope)??zr).importNode(e,!0);hr.currentNode=i;let s=hr.nextNode(),o=0,a=0,c=r[0];for(;c!==void 0;){if(o===c.index){let u;c.type===2?u=new Hl(s,s.nextSibling,this,t):c.type===1?u=new c.ctor(s,c.name,c.strings,this,t):c.type===6&&(u=new pz(s,this,t)),this._$AV.push(u),c=r[++a]}o!==(c==null?void 0:c.index)&&(s=hr.nextNode(),o++)}return hr.currentNode=zr,i}p(t){let e=0;for(const r of this._$AV)r!==void 0&&(r.strings!==void 0?(r._$AI(t,r,e),e+=r.strings.length-2):r._$AI(t[e])),e++}}let Hl=class ab{get _$AU(){var t;return((t=this._$AM)==null?void 0:t._$AU)??this._$Cv}constructor(t,e,r,i){this.type=2,this._$AH=ae,this._$AN=void 0,this._$AA=t,this._$AB=e,this._$AM=r,this.options=i,this._$Cv=(i==null?void 0:i.isConnected)??!0}get parentNode(){let t=this._$AA.parentNode;const e=this._$AM;return e!==void 0&&(t==null?void 0:t.nodeType)===11&&(t=e.parentNode),t}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(t,e=this){t=Fi(this,t,e),Os(t)?t===ae||t==null||t===""?(this._$AH!==ae&&this._$AR(),this._$AH=ae):t!==this._$AH&&t!==Or&&this._(t):t._$litType$!==void 0?this.$(t):t.nodeType!==void 0?this.T(t):oz(t)?this.k(t):this._(t)}O(t){return this._$AA.parentNode.insertBefore(t,this._$AB)}T(t){this._$AH!==t&&(this._$AR(),this._$AH=this.O(t))}_(t){this._$AH!==ae&&Os(this._$AH)?this._$AA.nextSibling.data=t:this.T(zr.createTextNode(t)),this._$AH=t}$(t){var s;const{values:e,_$litType$:r}=t,i=typeof r=="number"?this._$AC(t):(r.el===void 0&&(r.el=Ms.createElement(ob(r.h,r.h[0]),this.options)),r);if(((s=this._$AH)==null?void 0:s._$AD)===i)this._$AH.p(e);else{const o=new cz(i,this),a=o.u(this.options);o.p(e),this.T(a),this._$AH=o}}_$AC(t){let e=lg.get(t.strings);return e===void 0&&lg.set(t.strings,e=new Ms(t)),e}k(t){id(this._$AH)||(this._$AH=[],this._$AR());const e=this._$AH;let r,i=0;for(const s of t)i===e.length?e.push(r=new ab(this.O(zs()),this.O(zs()),this,this.options)):r=e[i],r._$AI(s),i++;i<e.length&&(this._$AR(r&&r._$AB.nextSibling,i),e.length=i)}_$AR(t=this._$AA.nextSibling,e){var r;for((r=this._$AP)==null?void 0:r.call(this,!1,!0,e);t!==this._$AB;){const i=ng(t).nextSibling;ng(t).remove(),t=i}}setConnected(t){var e;this._$AM===void 0&&(this._$Cv=t,(e=this._$AP)==null||e.call(this,t))}},Wl=class{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(t,e,r,i,s){this.type=1,this._$AH=ae,this._$AN=void 0,this.element=t,this.name=e,this._$AM=i,this.options=s,r.length>2||r[0]!==""||r[1]!==""?(this._$AH=Array(r.length-1).fill(new String),this.strings=r):this._$AH=ae}_$AI(t,e=this,r,i){const s=this.strings;let o=!1;if(s===void 0)t=Fi(this,t,e,0),o=!Os(t)||t!==this._$AH&&t!==Or,o&&(this._$AH=t);else{const a=t;let c,u;for(t=s[0],c=0;c<s.length-1;c++)u=Fi(this,a[r+c],e,c),u===Or&&(u=this._$AH[c]),o||(o=!Os(u)||u!==this._$AH[c]),u===ae?t=ae:t!==ae&&(t+=(u??"")+s[c+1]),this._$AH[c]=u}o&&!i&&this.j(t)}j(t){t===ae?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,t??"")}},uz=class extends Wl{constructor(){super(...arguments),this.type=3}j(t){this.element[this.name]=t===ae?void 0:t}},hz=class extends Wl{constructor(){super(...arguments),this.type=4}j(t){this.element.toggleAttribute(this.name,!!t&&t!==ae)}},dz=class extends Wl{constructor(t,e,r,i,s){super(t,e,r,i,s),this.type=5}_$AI(t,e=this){if((t=Fi(this,t,e,0)??ae)===Or)return;const r=this._$AH,i=t===ae&&r!==ae||t.capture!==r.capture||t.once!==r.once||t.passive!==r.passive,s=t!==ae&&(r===ae||i);i&&this.element.removeEventListener(this.name,this,r),s&&this.element.addEventListener(this.name,this,t),this._$AH=t}handleEvent(t){var e;typeof this._$AH=="function"?this._$AH.call(((e=this.options)==null?void 0:e.host)??this.element,t):this._$AH.handleEvent(t)}};class pz{constructor(t,e,r){this.element=t,this.type=6,this._$AN=void 0,this._$AM=e,this.options=r}get _$AU(){return this._$AM._$AU}_$AI(t){Fi(this,t)}}const fz={I:Hl},Fc=Ts.litHtmlPolyfillSupport;Fc==null||Fc(Ms,Hl),(Ts.litHtmlVersions??(Ts.litHtmlVersions=[])).push("3.3.2");const Re=(n,t,e)=>{const r=t;let i=r._$litPart$;return i===void 0&&(r._$litPart$=i=new Hl(t.insertBefore(zs(),null),null,void 0,{})),i._$AI(n),i};/**
|
|
50
|
+
* @license
|
|
51
|
+
* Copyright 2017 Google LLC
|
|
52
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
53
|
+
*/const sd={CHILD:2},Zl=n=>(...t)=>({_$litDirective$:n,values:t});let od=class{constructor(t){}get _$AU(){return this._$AM._$AU}_$AT(t,e,r){this._$Ct=t,this._$AM=e,this._$Ci=r}_$AS(t,e){return this.update(t,e)}update(t,e){return this.render(...e)}};/**
|
|
54
|
+
* @license
|
|
55
|
+
* Copyright 2017 Google LLC
|
|
56
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
57
|
+
*/let nl=class extends od{constructor(t){if(super(t),this.it=ae,t.type!==sd.CHILD)throw Error(this.constructor.directiveName+"() can only be used in child bindings")}render(t){if(t===ae||t==null)return this._t=void 0,this.it=t;if(t===Or)return t;if(typeof t!="string")throw Error(this.constructor.directiveName+"() called with a non-string value");if(t===this.it)return this._t;this.it=t;const e=[t];return e.raw=e,this._t={_$litType$:this.constructor.resultType,strings:e,values:[]}}};nl.directiveName="unsafeHTML",nl.resultType=1;const gz=Zl(nl);/**
|
|
58
|
+
* @license
|
|
59
|
+
* Copyright 2017 Google LLC
|
|
60
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
61
|
+
*/let Cu=class extends nl{};Cu.directiveName="unsafeSVG",Cu.resultType=2;const lb=Zl(Cu),mz={size:16,color:"currentColor",weight:"regular"};function vz(n){return typeof n=="string"?{regular:n}:n}function vn(n,t="0 0 256 256"){const e=vz(n);return r=>{const{size:i,color:s,weight:o}={...mz,...r},a=e[o]??e.regular;return z`<svg
|
|
62
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
63
|
+
data-ui-icon=""
|
|
64
|
+
width="${i}"
|
|
65
|
+
height="${i}"
|
|
66
|
+
viewBox="${t}"
|
|
67
|
+
fill="${s}"
|
|
68
|
+
>${lb(a)}</svg>`}}/**
|
|
69
|
+
* @license
|
|
70
|
+
* Copyright 2020 Google LLC
|
|
71
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
72
|
+
*/const{I:yz}=fz,cg=n=>n,bz=n=>n.strings===void 0,ug=()=>document.createComment(""),as=(n,t,e)=>{var s;const r=n._$AA.parentNode,i=t===void 0?n._$AB:t._$AA;if(e===void 0){const o=r.insertBefore(ug(),i),a=r.insertBefore(ug(),i);e=new yz(o,a,n,n.options)}else{const o=e._$AB.nextSibling,a=e._$AM,c=a!==n;if(c){let u;(s=e._$AQ)==null||s.call(e,n),e._$AM=n,e._$AP!==void 0&&(u=n._$AU)!==a._$AU&&e._$AP(u)}if(o!==i||c){let u=e._$AA;for(;u!==o;){const h=cg(u).nextSibling;cg(r).insertBefore(u,i),u=h}}}return e},Qn=(n,t,e=n)=>(n._$AI(t,e),n),wz={},Sz=(n,t=wz)=>n._$AH=t,_z=n=>n._$AH,Hc=n=>{n._$AR(),n._$AA.remove()};/**
|
|
73
|
+
* @license
|
|
74
|
+
* Copyright 2017 Google LLC
|
|
75
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
76
|
+
*/const Is=(n,t)=>{var r;const e=n._$AN;if(e===void 0)return!1;for(const i of e)(r=i._$AO)==null||r.call(i,t,!1),Is(i,t);return!0},rl=n=>{let t,e;do{if((t=n._$AM)===void 0)break;e=t._$AN,e.delete(n),n=t}while((e==null?void 0:e.size)===0)},cb=n=>{for(let t;t=n._$AM;n=t){let e=t._$AN;if(e===void 0)t._$AN=e=new Set;else if(e.has(n))break;e.add(n),Ez(t)}};function kz(n){this._$AN!==void 0?(rl(this),this._$AM=n,cb(this)):this._$AM=n}function xz(n,t=!1,e=0){const r=this._$AH,i=this._$AN;if(i!==void 0&&i.size!==0)if(t)if(Array.isArray(r))for(let s=e;s<r.length;s++)Is(r[s],!1),rl(r[s]);else r!=null&&(Is(r,!1),rl(r));else Is(this,n)}const Ez=n=>{n.type==sd.CHILD&&(n._$AP??(n._$AP=xz),n._$AQ??(n._$AQ=kz))};class Az extends od{constructor(){super(...arguments),this._$AN=void 0}_$AT(t,e,r){super._$AT(t,e,r),cb(this),this.isConnected=t._$AU}_$AO(t,e=!0){var r,i;t!==this.isConnected&&(this.isConnected=t,t?(r=this.reconnected)==null||r.call(this):(i=this.disconnected)==null||i.call(this)),e&&(Is(this,t),rl(this))}setValue(t){if(bz(this._$Ct))this._$Ct._$AI(t,this);else{const e=[...this._$Ct._$AH];e[this._$Ci]=t,this._$Ct._$AI(e,this,0)}}disconnected(){}reconnected(){}}/**
|
|
77
|
+
* @license
|
|
78
|
+
* Copyright 2020 Google LLC
|
|
79
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
80
|
+
*/const Ca=()=>new $z;class $z{}const Wc=new WeakMap,Ra=Zl(class extends Az{render(n){return ae}update(n,[t]){var r;const e=t!==this.G;return e&&this.G!==void 0&&this.rt(void 0),(e||this.lt!==this.ct)&&(this.G=t,this.ht=(r=n.options)==null?void 0:r.host,this.rt(this.ct=n.element)),ae}rt(n){if(this.isConnected||(n=void 0),typeof this.G=="function"){const t=this.ht??globalThis;let e=Wc.get(t);e===void 0&&(e=new WeakMap,Wc.set(t,e)),e.get(this.G)!==void 0&&this.G.call(this.ht,void 0),e.set(this.G,n),n!==void 0&&this.G.call(this.ht,n)}else this.G.value=n}get lt(){var n,t;return typeof this.G=="function"?(n=Wc.get(this.ht??globalThis))==null?void 0:n.get(this.G):(t=this.G)==null?void 0:t.value}disconnected(){this.lt===this.ct&&this.rt(void 0)}reconnected(){this.rt(this.ct)}}),Tz=vn('<path fill="none" stroke="currentColor" stroke-width="16" stroke-linecap="round" stroke-linejoin="round" d="M200 224H56C53.8783 224 51.8434 223.157 50.3431 221.657C48.8429 220.157 48 218.122 48 216V40C48 37.8783 48.8429 35.8434 50.3431 34.3431C51.8434 32.8429 53.8783 32 56 32H152L208 88V216C208 218.122 207.157 220.157 205.657 221.657C204.157 223.157 202.122 224 200 224Z"/><path fill="none" stroke="currentColor" stroke-width="16" stroke-linecap="round" stroke-linejoin="round" d="M152 32V88H208"/><path fill="none" stroke="currentColor" stroke-width="16" stroke-linecap="round" d="M80 88H124.5"/><path fill="none" stroke="currentColor" stroke-width="16" stroke-linecap="round" d="M80 128H175"/><path fill="none" stroke="currentColor" stroke-width="16" stroke-linecap="round" d="M80 169H175"/>'),ad=vn('<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"/>'),il=vn('<path d="M213.66,93.66l-80,80a8,8,0,0,1-11.32,0l-80-80A8,8,0,0,1,53.66,82.34L128,156.69l74.34-74.35a8,8,0,0,1,11.32,11.32Z"/>'),Iz=vn('<path d="M213.66,162.34l-80-80a8,8,0,0,0-11.32,0l-80,80A8,8,0,0,0,53.66,173.66L128,99.31l74.34,74.35a8,8,0,0,0,11.32-11.32Z"/>'),Cz=vn({regular:'<path d="M216,64H147.31l34.35-34.34a8,8,0,1,0-11.32-11.32L128,60.69,85.66,18.34A8,8,0,0,0,74.34,29.66L108.69,64H40A16,16,0,0,0,24,80V200a16,16,0,0,0,16,16H216a16,16,0,0,0,16-16V80A16,16,0,0,0,216,64Zm0,136H40V80H216V200Z"/>',bold:'<path d="M216,60H157l27.52-27.52a12,12,0,0,0-17-17L128,55,88.49,15.51a12,12,0,0,0-17,17L99,60H40A20,20,0,0,0,20,80V200a20,20,0,0,0,20,20H216a20,20,0,0,0,20-20V80A20,20,0,0,0,216,60Zm-4,136H44V84H212Z"/>'}),Rz=vn({regular:'<path d="M104,40H56A16,16,0,0,0,40,56v48a16,16,0,0,0,16,16h48a16,16,0,0,0,16-16V56A16,16,0,0,0,104,40Zm0,64H56V56h48v48Zm96-64H152a16,16,0,0,0-16,16v48a16,16,0,0,0,16,16h48a16,16,0,0,0,16-16V56A16,16,0,0,0,200,40Zm0,64H152V56h48v48Zm-96,32H56a16,16,0,0,0-16,16v48a16,16,0,0,0,16,16h48a16,16,0,0,0,16-16V152A16,16,0,0,0,104,136Zm0,64H56V152h48v48Zm96-64H152a16,16,0,0,0-16,16v48a16,16,0,0,0,16,16h48a16,16,0,0,0,16-16V152A16,16,0,0,0,200,136Zm0,64H152V152h48v48Z"/>',bold:'<path d="M100,36H56A20,20,0,0,0,36,56v44a20,20,0,0,0,20,20h44a20,20,0,0,0,20-20V56A20,20,0,0,0,100,36ZM96,96H60V60H96ZM200,36H156a20,20,0,0,0-20,20v44a20,20,0,0,0,20,20h44a20,20,0,0,0,20-20V56A20,20,0,0,0,200,36Zm-4,60H160V60h36Zm-96,40H56a20,20,0,0,0-20,20v44a20,20,0,0,0,20,20h44a20,20,0,0,0,20-20V156A20,20,0,0,0,100,136Zm-4,60H60V160H96Zm104-60H156a20,20,0,0,0-20,20v44a20,20,0,0,0,20,20h44a20,20,0,0,0,20-20V156A20,20,0,0,0,200,136Zm-4,60H160V160h36Z"/>'}),Pz=vn('<path d="M224,128a8,8,0,0,1-8,8H136v80a8,8,0,0,1-16,0V136H40a8,8,0,0,1,0-16h80V40a8,8,0,0,1,16,0v80h80A8,8,0,0,1,224,128Z"/>'),ub=vn('<path d="M136,32V64a8,8,0,0,1-16,0V32a8,8,0,0,1,16,0Zm88,88H192a8,8,0,0,0,0,16h32a8,8,0,0,0,0-16Zm-45.09,47.6a8,8,0,0,0-11.31,11.31l22.62,22.63a8,8,0,0,0,11.32-11.32ZM128,184a8,8,0,0,0-8,8v32a8,8,0,0,0,16,0V192A8,8,0,0,0,128,184ZM77.09,167.6,54.46,190.22a8,8,0,0,0,11.32,11.32L88.4,178.91A8,8,0,0,0,77.09,167.6ZM72,128a8,8,0,0,0-8-8H32a8,8,0,0,0,0,16H64A8,8,0,0,0,72,128ZM65.78,54.46A8,8,0,0,0,54.46,65.78L77.09,88.4A8,8,0,0,0,88.4,77.09Z"/>'),Dz=vn('<path d="M173.66,98.34a8,8,0,0,1,0,11.32l-56,56a8,8,0,0,1-11.32,0l-24-24a8,8,0,0,1,11.32-11.32L112,148.69l50.34-50.35A8,8,0,0,1,173.66,98.34ZM232,128A104,104,0,1,1,128,24,104.11,104.11,0,0,1,232,128Zm-16,0a88,88,0,1,0-88,88A88.1,88.1,0,0,0,216,128Z"/>');class Lz extends Event{constructor(){super("close",{bubbles:!0,composed:!0})}}const hg='a[href],button:not([disabled]),input:not([disabled]),select:not([disabled]),textarea:not([disabled]),[tabindex]:not([tabindex="-1"])',Zc=4;var Oe,Qe,_r,et,Js,ki,xi,B,Ru,Pu,db,Pa,pb,Du,Lu,Qs,eo,kr,fb,zu,gb,mb,Da,ci;class hb extends HTMLElement{constructor(){super();w(this,B);w(this,Oe,!1);w(this,Qe,null);w(this,_r);w(this,et,null);w(this,Js,"bottom-start");w(this,ki,!1);w(this,xi,!1);w(this,Qs,e=>{l(this,Oe)&&(l(this,ki)||e.composedPath().includes(this)||(this.open=!1))});w(this,eo,e=>{if(l(this,Oe)){if(e.key==="Escape"){e.preventDefault(),this.open=!1;return}e.key==="Tab"&&f(this,B,fb).call(this,e)}});w(this,kr,()=>{l(this,Oe)&&f(this,B,Da).call(this)});S(this,_r,this.attachShadow({mode:"open"})),Zh(l(this,_r)),f(this,B,Pu).call(this,"anchor")}connectedCallback(){this.removeAttribute("popover"),this.hasAttribute("tone")||this.setAttribute("tone","light"),f(this,B,Pu).call(this,"open"),f(this,B,ci).call(this),l(this,Oe)&&(f(this,B,Du).call(this),f(this,B,Pa).call(this))}disconnectedCallback(){var e;f(this,B,Lu).call(this),(e=l(this,Qe))==null||e.removeAttribute("aria-expanded")}attributeChangedCallback(e){e==="open"?f(this,B,db).call(this,this.hasAttribute("open")):e==="material"&&l(this,Oe)&&(f(this,B,ci).call(this),f(this,B,Pa).call(this))}get open(){return l(this,Oe)}set open(e){this.toggleAttribute("open",e)}get anchor(){return l(this,Qe)}set anchor(e){l(this,Qe)!==e&&(l(this,Qe)&&l(this,Qe).removeAttribute("aria-expanded"),S(this,Qe,e),f(this,B,Ru).call(this),l(this,Oe)&&f(this,B,Da).call(this))}}Oe=new WeakMap,Qe=new WeakMap,_r=new WeakMap,et=new WeakMap,Js=new WeakMap,ki=new WeakMap,xi=new WeakMap,B=new WeakSet,Ru=function(){l(this,Qe)&&l(this,Qe).setAttribute("aria-expanded",l(this,Oe)?"true":"false")},Pu=function(e){if(!Object.prototype.hasOwnProperty.call(this,e))return;const r=this,i=r[e];delete r[e],r[e]=i},db=function(e){var r,i,s;if(l(this,Oe)!==e){if(S(this,Oe,e),f(this,B,Ru).call(this),!this.isConnected){f(this,B,ci).call(this);return}e?(S(this,ki,!0),setTimeout(()=>{S(this,ki,!1)},0),f(this,B,ci).call(this),f(this,B,Du).call(this),f(this,B,Pa).call(this)):(f(this,B,Lu).call(this),(i=(r=l(this,et))==null?void 0:r.hidePopover)==null||i.call(r),f(this,B,ci).call(this),(s=l(this,Qe))==null||s.focus(),this.dispatchEvent(new Lz))}},Pa=function(){l(this,xi)||(S(this,xi,!0),queueMicrotask(()=>{S(this,xi,!1),!(!l(this,Oe)||!this.isConnected)&&(f(this,B,pb).call(this),f(this,B,mb).call(this))}))},pb=function(){var e,r;if(l(this,et)){try{(r=(e=l(this,et)).showPopover)==null||r.call(e)}catch{}f(this,B,Da).call(this)}},Du=function(){document.addEventListener("click",l(this,Qs)),document.addEventListener("keydown",l(this,eo),!0),window.addEventListener("resize",l(this,kr)),window.addEventListener("scroll",l(this,kr),!0)},Lu=function(){document.removeEventListener("click",l(this,Qs)),document.removeEventListener("keydown",l(this,eo),!0),window.removeEventListener("resize",l(this,kr)),window.removeEventListener("scroll",l(this,kr),!0)},Qs=new WeakMap,eo=new WeakMap,kr=new WeakMap,fb=function(e){const r=f(this,B,zu).call(this);if(r.length===0){e.preventDefault();return}const i=r[0],s=r[r.length-1],o=f(this,B,gb).call(this),a=o instanceof HTMLElement&&r.includes(o);e.shiftKey?(!a||o===i)&&(e.preventDefault(),s.focus()):(!a||o===s)&&(e.preventDefault(),i.focus())},zu=function(){if(!l(this,et))return[];const e=l(this,et).querySelector("slot");if(!(e instanceof HTMLSlotElement))return[];const r=[];for(const i of e.assignedElements({flatten:!0}))if(i instanceof HTMLElement){i.matches(hg)&&r.push(i);for(const s of i.querySelectorAll(hg))r.push(s)}return r},gb=function(){var r;let e=document.activeElement;for(;e&&((r=e.shadowRoot)!=null&&r.activeElement);)e=e.shadowRoot.activeElement;return e},mb=function(){var r;const e=f(this,B,zu).call(this);e.length>0?e[0].focus():(r=l(this,et))==null||r.focus()},Da=function(){if(!l(this,Oe)||!l(this,Qe)||!l(this,et))return;const e=l(this,Qe).getBoundingClientRect(),r=l(this,et).getBoundingClientRect(),s=window.innerHeight-e.bottom,o=r.height+Zc,a=s<o&&e.top>o?"top-start":"bottom-start";S(this,Js,a);const c=a==="bottom-start"?e.bottom+Zc:e.top-r.height-Zc,u=e.left;l(this,et).style.transform=`translate(${u}px, ${c}px)`,l(this,et).setAttribute("data-placement",a)},ci=function(){this.toggleAttribute("open",l(this,Oe));const e=this.getAttribute("material")??"paper";Re(l(this,Oe)?z`<div
|
|
81
|
+
class="panel"
|
|
82
|
+
part="panel"
|
|
83
|
+
popover="manual"
|
|
84
|
+
data-placement=${l(this,Js)}
|
|
85
|
+
tabindex="-1"
|
|
86
|
+
role="dialog"
|
|
87
|
+
material=${e}
|
|
88
|
+
level="1"
|
|
89
|
+
>
|
|
90
|
+
<slot></slot>
|
|
91
|
+
</div>`:ae,l(this,_r)),S(this,et,l(this,_r).querySelector(".panel"))},m(hb,"observedAttributes",["open","material"]);customElements.get("ui-popover")||customElements.define("ui-popover",hb);class vb extends Event{constructor(e){super("dropdown-item-select",{bubbles:!0,composed:!0});m(this,"value");this.value=e}}class zz extends Event{constructor(e){super("select",{bubbles:!0,composed:!0});m(this,"value");this.value=e}}var tt,xt,Cn,Rn,ie,to,no,O,bb,ys,wb,Sb,Ou,_b,bs,rr,xr,ro,dl,io,pl,kb,xb,Mu,ws,Nu,Uu,tn;class yb extends HTMLElement{constructor(){super();w(this,O);w(this,tt,!1);w(this,xt,null);w(this,Cn,null);w(this,Rn);w(this,ie,null);w(this,to,Ca());w(this,no,new MutationObserver(e=>f(this,O,kb).call(this,e)));w(this,xr,()=>{f(this,O,bs).call(this,!l(this,tt))});w(this,ro,e=>{e.key!=="Enter"&&e.key!==" "||(e.preventDefault(),l(this,xr).call(this))});w(this,dl,()=>{l(this,tt)&&f(this,O,bs).call(this,!1)});w(this,io,e=>{e instanceof vb&&(e.stopPropagation(),S(this,tt,!1),f(this,O,ys).call(this,e.value),f(this,O,tn).call(this),this.dispatchEvent(new zz(e.value)))});w(this,pl,()=>{f(this,O,Mu).call(this)});S(this,Rn,this.attachShadow({mode:"open"})),Zh(l(this,Rn))}connectedCallback(){this.addEventListener("dropdown-item-select",l(this,io)),f(this,O,bb).call(this),l(this,no).observe(this,{childList:!0,subtree:!0,characterData:!0,attributes:!0,attributeFilter:["selected","value","slot"]}),f(this,O,tn).call(this)}disconnectedCallback(){this.removeEventListener("dropdown-item-select",l(this,io)),l(this,no).disconnect(),f(this,O,Uu).call(this)}attributeChangedCallback(e){if(e==="open"){f(this,O,bs).call(this,this.hasAttribute("open"));return}f(this,O,tn).call(this)}get open(){return l(this,tt)}set open(e){this.toggleAttribute("open",e)}get title(){return this.getAttribute("title")??""}get value(){return l(this,xt)}set value(e){e===null?(f(this,O,rr).call(this,null,null),f(this,O,wb).call(this)):f(this,O,ys).call(this,e),f(this,O,tn).call(this)}close(){f(this,O,bs).call(this,!1)}}tt=new WeakMap,xt=new WeakMap,Cn=new WeakMap,Rn=new WeakMap,ie=new WeakMap,to=new WeakMap,no=new WeakMap,O=new WeakSet,bb=function(){var r;const e=this.querySelector("dropdown-item[selected]");e&&f(this,O,rr).call(this,e.value,((r=e.textContent)==null?void 0:r.trim())??null)},ys=function(e){var r;for(const i of l(this,O,Ou))i.value===e?(f(this,O,rr).call(this,e,((r=i.textContent)==null?void 0:r.trim())??null),i.hasAttribute("selected")||i.setAttribute("selected","")):i.hasAttribute("selected")&&i.removeAttribute("selected")},wb=function(){const e=this.querySelectorAll("dropdown-item[selected]");for(const r of e)r.removeAttribute("selected")},Sb=function(e){for(const r of l(this,O,Ou))if(r.value===e)return r;return null},Ou=function(){return this.querySelectorAll("dropdown-item")},_b=function(){return l(this,Cn)??this.title},bs=function(e){l(this,tt)!==e&&(S(this,tt,e),f(this,O,tn).call(this))},rr=function(e,r){S(this,xt,e),S(this,Cn,r)},xr=new WeakMap,ro=new WeakMap,dl=new WeakMap,io=new WeakMap,pl=new WeakMap,kb=function(e){e.every(i=>i.target instanceof Element?i.target.closest('[slot="trigger"]')!==null:!1)||f(this,O,xb).call(this)},xb=function(){var r,i;const e=this.querySelector("dropdown-item[selected]");if(e){const s=e.value,o=((r=e.textContent)==null?void 0:r.trim())??null,a=l(this,xt)!==s||l(this,Cn)!==o;f(this,O,rr).call(this,s,o),f(this,O,ys).call(this,s),a?f(this,O,tn).call(this):f(this,O,ws).call(this);return}if(l(this,xt)!==null){const s=f(this,O,Sb).call(this,l(this,xt));if(s){const o=((i=s.textContent)==null?void 0:i.trim())??null,a=l(this,Cn)!==o;f(this,O,rr).call(this,l(this,xt),o),f(this,O,ys).call(this,l(this,xt)),a?f(this,O,tn).call(this):f(this,O,ws).call(this);return}}if(l(this,xt)!==null||l(this,Cn)!==null){f(this,O,rr).call(this,null,null),f(this,O,tn).call(this);return}f(this,O,ws).call(this)},Mu=function(){const e=l(this,Rn).querySelector('slot[name="trigger"]'),r=e instanceof HTMLSlotElement?e.assignedElements()[0]??null:null;l(this,ie)!==r&&(f(this,O,Uu).call(this),S(this,ie,r),l(this,ie)&&(l(this,ie).addEventListener("click",l(this,xr)),l(this,ie)instanceof HTMLButtonElement?l(this,ie).hasAttribute("type")||(l(this,ie).type="button"):(l(this,ie).hasAttribute("role")||l(this,ie).setAttribute("role","button"),l(this,ie).hasAttribute("tabindex")||(l(this,ie).tabIndex=0),l(this,ie).addEventListener("keydown",l(this,ro))))),f(this,O,ws).call(this),f(this,O,Nu).call(this)},ws=function(){l(this,ie)&&(l(this,ie).setAttribute("data-dropdown-trigger",""),l(this,ie).setAttribute("aria-haspopup","listbox"),l(this,ie).setAttribute("aria-expanded",l(this,tt)?"true":"false"))},Nu=function(){const e=l(this,to).value;if(!e)return;const r=l(this,Rn).querySelector("button.fallback-trigger");e.anchor=l(this,ie)??r??null},Uu=function(){l(this,ie)&&(l(this,ie).removeEventListener("click",l(this,xr)),l(this,ie).removeEventListener("keydown",l(this,ro)),l(this,ie).removeAttribute("data-dropdown-trigger"),l(this,ie).removeAttribute("aria-haspopup"),l(this,ie).removeAttribute("aria-expanded"),S(this,ie,null))},tn=function(){this.toggleAttribute("open",l(this,tt)),Re(z`
|
|
92
|
+
<slot name="trigger" @slotchange=${l(this,pl)}>
|
|
93
|
+
<button
|
|
94
|
+
class="fallback-trigger"
|
|
95
|
+
part="trigger"
|
|
96
|
+
type="button"
|
|
97
|
+
aria-haspopup="listbox"
|
|
98
|
+
aria-expanded=${l(this,tt)?"true":"false"}
|
|
99
|
+
@click=${l(this,xr)}
|
|
100
|
+
>
|
|
101
|
+
<span class="trigger-label" part="trigger-label">${l(this,O,_b)}</span>
|
|
102
|
+
<span class="trigger-icon" part="trigger-icon" aria-hidden="true">
|
|
103
|
+
${il({size:16})}
|
|
104
|
+
</span>
|
|
105
|
+
</button>
|
|
106
|
+
</slot>
|
|
107
|
+
<ui-popover
|
|
108
|
+
class="dropdown-popover"
|
|
109
|
+
material="glass-frosted"
|
|
110
|
+
?open=${l(this,tt)}
|
|
111
|
+
@close=${l(this,dl)}
|
|
112
|
+
${Ra(l(this,to))}
|
|
113
|
+
>
|
|
114
|
+
${l(this,tt)?z`<div class="dropdown-list" part="list" role="listbox">
|
|
115
|
+
<slot></slot>
|
|
116
|
+
</div>`:ae}
|
|
117
|
+
</ui-popover>
|
|
118
|
+
`,l(this,Rn)),f(this,O,Nu).call(this),queueMicrotask(()=>f(this,O,Mu).call(this))},m(yb,"observedAttributes",["title","open"]);class Oz extends HTMLElement{}class Mz extends HTMLElement{}class Nz extends HTMLElement{}var Ur,Fu,Ab,so,oo;class Eb extends HTMLElement{constructor(){super(...arguments);w(this,Ur);w(this,so,()=>{this.action||f(this,Ur,Ab).call(this)});w(this,oo,e=>{e.key!=="Enter"&&e.key!==" "||(e.preventDefault(),this.click())})}connectedCallback(){this.hasAttribute("role")||this.setAttribute("role","option"),this.hasAttribute("tabindex")||(this.tabIndex=0),this.addEventListener("click",l(this,so)),this.addEventListener("keydown",l(this,oo)),f(this,Ur,Fu).call(this)}disconnectedCallback(){this.removeEventListener("click",l(this,so)),this.removeEventListener("keydown",l(this,oo))}attributeChangedCallback(){f(this,Ur,Fu).call(this)}get value(){return this.getAttribute("value")??""}get selected(){return this.hasAttribute("selected")}get action(){return this.hasAttribute("action")}}Ur=new WeakSet,Fu=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")},Ab=function(){this.dispatchEvent(new vb(this.value))},so=new WeakMap,oo=new WeakMap,m(Eb,"observedAttributes",["action","selected","value"]);customElements.get("dropdown-menu")||customElements.define("dropdown-menu",yb);customElements.get("dropdown-group")||customElements.define("dropdown-group",Oz);customElements.get("dropdown-label")||customElements.define("dropdown-label",Mz);customElements.get("dropdown-divider")||customElements.define("dropdown-divider",Nz);customElements.get("dropdown-item")||customElements.define("dropdown-item",Eb);class Uz extends Event{constructor(e){super("rename",{bubbles:!0,composed:!0});m(this,"value");this.value=e}}var Ht,Et,se,Me,Ss,ao,Hu,La,Wu,lo,co,uo;class $b extends HTMLElement{constructor(){super(...arguments);w(this,Me);w(this,Ht,"");w(this,Et,!1);w(this,se,null);w(this,ao,e=>{l(this,Et)||(e.preventDefault(),f(this,Me,Hu).call(this))});w(this,lo,e=>{e.stopPropagation()});w(this,co,e=>{var r,i;e.key==="Enter"?(e.preventDefault(),f(this,Me,La).call(this,!0),(r=l(this,se))==null||r.blur()):e.key==="Escape"&&(e.preventDefault(),f(this,Me,La).call(this,!1),(i=l(this,se))==null||i.blur())});w(this,uo,()=>{f(this,Me,La).call(this,!0)})}connectedCallback(){l(this,se)||(S(this,se,document.createElement("span")),l(this,se).className="editable-text-span",this.append(l(this,se)));const e=this.getAttribute("value");e!==null&&S(this,Ht,e),f(this,Me,Ss).call(this),this.addEventListener("dblclick",l(this,ao))}disconnectedCallback(){this.removeEventListener("dblclick",l(this,ao)),l(this,Et)&&f(this,Me,Wu).call(this)}attributeChangedCallback(e){if(e==="value"){const r=this.getAttribute("value")??"";S(this,Ht,r),l(this,Et)||f(this,Me,Ss).call(this)}}get value(){return l(this,Ht)}set value(e){S(this,Ht,e),l(this,Et)||f(this,Me,Ss).call(this)}startEditing(){l(this,Et)||f(this,Me,Hu).call(this)}}Ht=new WeakMap,Et=new WeakMap,se=new WeakMap,Me=new WeakSet,Ss=function(){l(this,se)&&(l(this,se).textContent=l(this,Ht))},ao=new WeakMap,Hu=function(){l(this,se)&&(S(this,Et,!0),l(this,se).setAttribute("contenteditable","plaintext-only"),l(this,se).setAttribute("spellcheck","false"),l(this,se).addEventListener("keydown",l(this,co)),l(this,se).addEventListener("blur",l(this,uo)),l(this,se).addEventListener("mousedown",l(this,lo)),this.toggleAttribute("data-editing",!0),queueMicrotask(()=>{var r;if(!l(this,se))return;l(this,se).focus();const e=(r=this.ownerDocument.defaultView)==null?void 0:r.getSelection();e==null||e.selectAllChildren(l(this,se))}))},La=function(e){if(!l(this,Et)||!l(this,se))return;const r=(l(this,se).textContent??"").trim();S(this,Et,!1),l(this,se).removeAttribute("contenteditable"),l(this,se).removeAttribute("spellcheck"),this.toggleAttribute("data-editing",!1),f(this,Me,Wu).call(this),e&&r.length>0&&r!==l(this,Ht)&&(S(this,Ht,r),this.dispatchEvent(new Uz(r))),f(this,Me,Ss).call(this)},Wu=function(){var e,r,i;(e=l(this,se))==null||e.removeEventListener("keydown",l(this,co)),(r=l(this,se))==null||r.removeEventListener("blur",l(this,uo)),(i=l(this,se))==null||i.removeEventListener("mousedown",l(this,lo))},lo=new WeakMap,co=new WeakMap,uo=new WeakMap,m($b,"observedAttributes",["value"]);customElements.get("editable-text")||customElements.define("editable-text",$b);class Fz extends Event{constructor(){super("close",{bubbles:!0,composed:!0})}}var ho,Zn,Zu,fl,po,Bu;class Tb extends HTMLElement{constructor(){super();w(this,Zn);w(this,ho);w(this,fl,e=>{e.target===e.currentTarget&&f(this,Zn,Zu).call(this)});w(this,po,e=>{this.open&&e.key==="Escape"&&f(this,Zn,Zu).call(this)});S(this,ho,this.attachShadow({mode:"open"}))}connectedCallback(){document.addEventListener("keydown",l(this,po)),f(this,Zn,Bu).call(this)}disconnectedCallback(){document.removeEventListener("keydown",l(this,po))}attributeChangedCallback(){f(this,Zn,Bu).call(this)}get open(){return this.hasAttribute("open")}}ho=new WeakMap,Zn=new WeakSet,Zu=function(){this.dispatchEvent(new Fz)},fl=new WeakMap,po=new WeakMap,Bu=function(){Re(z`
|
|
119
|
+
${this.open?z`
|
|
120
|
+
<div class="backdrop" part="backdrop" @click=${l(this,fl)}>
|
|
121
|
+
<slot></slot>
|
|
122
|
+
</div>
|
|
123
|
+
`:null}
|
|
124
|
+
`,l(this,ho))},m(Tb,"observedAttributes",["open"]);customElements.get("modal-overlay")||customElements.define("modal-overlay",Tb);const Hz=16,Bc=24,Wz=32;var Ei;class Ib extends HTMLElement{constructor(){super();w(this,Ei);S(this,Ei,this.attachShadow({mode:"open"})),Zh(l(this,Ei))}connectedCallback(){this.render()}attributeChangedCallback(){this.render()}getSize(){const e=this.getAttribute("size");if(e===null)return Bc;const r=Number(e);return r===Hz||r===Bc||r===Wz?r:Bc}render(){Re(z`<span class="spin">${ub({size:this.getSize()})}</span>`,l(this,Ei))}}Ei=new WeakMap,m(Ib,"observedAttributes",["size"]);customElements.get("ui-spinner")||customElements.define("ui-spinner",Ib);class Zz extends Event{constructor(){super("close",{bubbles:!0,composed:!0})}}class Bz extends HTMLElement{}var fo,go,Vu;class Cb extends HTMLElement{constructor(){super();w(this,go);w(this,fo);S(this,fo,this.attachShadow({mode:"open"}))}connectedCallback(){f(this,go,Vu).call(this)}attributeChangedCallback(){f(this,go,Vu).call(this)}get closable(){return this.hasAttribute("closable")}}fo=new WeakMap,go=new WeakSet,Vu=function(){const e=this.querySelector("panel-page");Re(z`
|
|
125
|
+
<section class="panel" part="panel">
|
|
126
|
+
<header class="title-bar" part="header">
|
|
127
|
+
<h2 class="title" part="title">${(e==null?void 0:e.getAttribute("title"))??""}</h2>
|
|
128
|
+
${this.closable?z`
|
|
129
|
+
<button
|
|
130
|
+
type="button"
|
|
131
|
+
class="title-button"
|
|
132
|
+
part="button close-button"
|
|
133
|
+
aria-label="Close"
|
|
134
|
+
@click=${()=>this.dispatchEvent(new Zz)}
|
|
135
|
+
>
|
|
136
|
+
<span class="close-icon" part="icon close-icon">${ad({size:16})}</span>
|
|
137
|
+
</button>
|
|
138
|
+
`:null}
|
|
139
|
+
</header>
|
|
140
|
+
<slot></slot>
|
|
141
|
+
</section>
|
|
142
|
+
`,l(this,fo))},m(Cb,"observedAttributes",["closable"]);customElements.get("panel-view")||customElements.define("panel-view",Cb);customElements.get("panel-page")||customElements.define("panel-page",Bz);function Bl(n){return typeof n=="object"&&n!==null}function Vz(n){return!Bl(n)||n.type!=="wheel"||typeof n.deltaX!="number"||typeof n.deltaY!="number"||typeof n.shiftKey!="boolean"?!1:!("id"in n)}function jz(n){return!Bl(n)||n.type!=="swipe-move"||typeof n.deltaX!="number"?!1:!("id"in n)}function Gz(n){return!Bl(n)||n.type!=="swipe-end"||typeof n.velocityX!="number"?!1:!("id"in n)}function Rb(n){return!Bl(n)||n.type!=="open-artifact"||typeof n.artifactID!="string"?!1:!("id"in n)}function qz(n=window){if(n.parent===n)return;let t=0,e=0;n.document.documentElement&&(n.document.documentElement.style.touchAction="pan-y"),n.addEventListener("wheel",u=>{const h=u;t=h.clientX,e=h.clientY,n.parent.postMessage({type:"wheel",deltaX:h.deltaX,deltaY:h.deltaY,shiftKey:h.shiftKey},"*"),h.preventDefault()},{passive:!1});const r=8,i=100,s=1e3,o=new Map;n.addEventListener("pointerdown",u=>{const h=u;h.pointerType==="touch"&&o.set(h.pointerId,{startX:h.clientX,startY:h.clientY,lastX:h.clientX,offset:0,active:!1,discarded:!1,samples:[{time:h.timeStamp,offset:0}]})},{passive:!0}),n.addEventListener("pointermove",u=>{const h=u,p=o.get(h.pointerId);if(!p||p.discarded)return;if(!p.active){const k=h.clientX-p.startX,T=h.clientY-p.startY,P=Math.abs(k),R=Math.abs(T);if(P<r&&R<r)return;if(R>=P){p.discarded=!0;return}p.active=!0}const v=h.clientX-p.lastX;p.lastX=h.clientX,p.offset+=v,p.samples.push({time:h.timeStamp,offset:p.offset});const g=h.timeStamp-i;let _=0;for(let k=0;k<p.samples.length;k+=1){if(p.samples[k].time>=g){_=k;break}_=k+1}if(_>0){const k=Math.max(0,_-1);p.samples.splice(0,k)}n.parent.postMessage({type:"swipe-move",deltaX:v},"*"),h.preventDefault()},{passive:!1}),n.addEventListener("pointerup",u=>{const h=u,p=o.get(h.pointerId);if(!p||(o.delete(h.pointerId),!p.active))return;let v=0;if(p.samples.length>=2){const g=p.samples[0],_=p.samples[p.samples.length-1],k=_.time-g.time;k>0&&(v=(_.offset-g.offset)/k*s)}n.parent.postMessage({type:"swipe-end",velocityX:v},"*")}),n.addEventListener("pointercancel",u=>{const h=u,p=o.get(h.pointerId);p&&(o.delete(h.pointerId),p.active&&n.parent.postMessage({type:"swipe-end",velocityX:0},"*"))}),n.addEventListener("message",u=>{var k,T;const h=u.data;if(h===null||typeof h!="object"||h.type!=="scroll")return;const p=h,v=typeof p.deltaX=="number"?p.deltaX:0,g=typeof p.deltaY=="number"?p.deltaY:0;let _=((T=(k=n.document).elementFromPoint)==null?void 0:T.call(k,t,e))??null;for(;_!==null;){const P=n.getComputedStyle(_);if(g!==0){const R=(P.overflowY==="auto"||P.overflowY==="scroll")&&_.scrollHeight>_.clientHeight,W=g>0?_.scrollTop+_.clientHeight<_.scrollHeight:_.scrollTop>0;if(R&&W){_.scrollBy(v,g);return}}if(v!==0){const R=(P.overflowX==="auto"||P.overflowX==="scroll")&&_.scrollWidth>_.clientWidth,W=v>0?_.scrollLeft+_.clientWidth<_.scrollWidth:_.scrollLeft>0;if(R&&W){_.scrollBy(v,g);return}}_=_.parentElement}n.scrollBy(v,g)});function a(u){if(typeof u!="string")return!1;let h;try{h=new URL(u)}catch{return!1}if(h.protocol!=="artifact:")return!1;const p=h.hostname||h.pathname.replace(/^\/+/,"");return p===""?!1:(n.parent.postMessage({type:"open-artifact",artifactID:p},"*"),!0)}n.document.addEventListener("click",u=>{const h=u,p=typeof h.composedPath=="function"?h.composedPath():[];let v=null;for(const k of p)if(k instanceof HTMLAnchorElement||k&&k.tagName==="A"){v=k;break}if(v===null)return;const g=v.getAttribute("href");if(g===null)return;let _;try{_=new URL(g,n.document.baseURI).toString()}catch{return}a(_)&&u.preventDefault()},!0);const c=n.navigation;c&&c.addEventListener("navigate",u=>{var p;a((p=u.destination)==null?void 0:p.url)&&u.preventDefault()})}function Yz(){return`(${qz.toString()})(window);`}const Xz=it(),Kz=it(),Jz="No handler registered for update-content",Qz="handleUpdateContent: handler already registered";function e2(n){return n instanceof Error&&typeof n.message=="string"?n.message:String(n)}const t2=No(qt);var Ai,$i,Ti,Er,Ar,mo,Ne,ju,Pb,Db,_s,Gu,Gg;let n2=(Gg=class extends t2{constructor(e){super();w(this,Ne);w(this,Ai);w(this,$i);w(this,Ti);w(this,Er,null);w(this,Ar,null);w(this,mo,!1);S(this,Ai,e);const r=e.ownerDocument.defaultView;if(!r)throw new Error("ArtifactView: iframe has no owner window");S(this,$i,r),S(this,Ti,i=>f(this,Ne,Pb).call(this,i)),l(this,$i).addEventListener("message",l(this,Ti))}get content(){return l(this,Ar)}set content(e){f(this,Ne,Gu).call(this),S(this,Ar,e),l(this,mo)&&f(this,Ne,ju).call(this,e)}handleUpdateContent(e){if(f(this,Ne,Gu).call(this),l(this,Er)!==null)throw new Error(Qz);S(this,Er,e)}dispose(){l(this,$i).removeEventListener("message",l(this,Ti)),S(this,Er,null)}},Ai=new WeakMap,$i=new WeakMap,Ti=new WeakMap,Er=new WeakMap,Ar=new WeakMap,mo=new WeakMap,Ne=new WeakSet,ju=function(e){const r={type:"content-updated",content:e};f(this,Ne,_s).call(this,r)},Pb=function(e){if(this.disposed||e.source!==l(this,Ai).contentWindow)return;const r=e.data;if(eR(r)){S(this,mo,!0),this.dispatchEvent(new Xz("ready")),l(this,Ar)!==null&&f(this,Ne,ju).call(this,l(this,Ar));return}if(tR(r)){f(this,Ne,Db).call(this,r);return}if(Rb(r)){this.dispatchEvent(new Kz("open-artifact",{artifactID:r.artifactID}));return}},Db=async function(e){const r=l(this,Er);if(r===null){f(this,Ne,_s).call(this,{type:"response",id:e.id,error:{message:Jz}});return}try{await r(e.content)}catch(i){if(this.disposed)return;f(this,Ne,_s).call(this,{type:"response",id:e.id,error:{message:e2(i)}});return}this.disposed||f(this,Ne,_s).call(this,{type:"response",id:e.id,result:{}})},_s=function(e){const r=l(this,Ai).contentWindow;r&&r.postMessage(e,"*")},Gu=function(){if(this.disposed)throw new Error("ArtifactView is disposed")},Gg);const r2="text/html";async function i2(n){const t=await fetch(n);if(!t.ok)throw new Error(`Failed to fetch artifact content: ${t.status}`);const e=await t.text(),r=new DOMParser().parseFromString(e,"text/html"),i=r.createElement("base");i.href=new URL(n,window.location.href).href,r.head.insertBefore(i,r.head.firstChild);const s=r.createElement("script");s.textContent=Yz(),r.head.appendChild(s);const o=new Blob([`<!DOCTYPE html>
|
|
143
|
+
${r.documentElement.outerHTML}`],{type:r2});return URL.createObjectURL(o)}const dg="television-artifact-bridge",s2="_tvThemeBuster",Lb=it(),o2=it();class a2 extends HTMLElement{constructor(){super(...arguments);m(this,"_artifact",null);m(this,"_viewURL",null);m(this,"_contentURL",null);m(this,"_screen",null);m(this,"_subscribedScreen",null);m(this,"_subscribedServer",null);m(this,"_activeView",null);m(this,"_contentState",{kind:"idle"});m(this,"_fetchSequence",0);m(this,"_blobSequence",0);m(this,"_themeReloadSequence",0);m(this,"_mountedViewURL",null);m(this,"_mountedDirectRenderURL",null);m(this,"_mountedDirectRenderStatus",null);m(this,"_directRender",!1);m(this,"_blobURL",null);m(this,"_subscribedWebview",null);m(this,"_directRenderMessageListener",null);m(this,"handleScreenContentChanged",e=>{if(!(!this._artifact||e.artifactID!==this._artifact.id)){if(this._activeView!==null){this.refetchContent();return}this._directRender&&this._contentURL!==null&&this._artifact.status==="committed"&&this.loadBlobFrame(this._contentURL)}});m(this,"handleServerEvent",e=>{const r=this._screen;if(!r||e.event.type!=="theme-changed"||e.serverURL!==r.server.url)return;const i=this.themeReloadSourceURL();i!==null&&(this._themeReloadSequence+=1,this.loadBlobFrame(this.withThemeBuster(i,this._themeReloadSequence)))});m(this,"handleOpenArtifact",e=>{this.requestFocus(e.artifactID)});m(this,"handleIframeMessage",e=>{const r=this.querySelector("iframe.artifact-frame");!r||r.contentWindow!==e.source||Vz(e.data)&&this.dispatchArtifactWheel({deltaX:e.data.deltaX,deltaY:e.data.deltaY,shiftKey:e.data.shiftKey},i=>{var o;const s={type:"scroll",deltaX:0,deltaY:i};(o=r.contentWindow)==null||o.postMessage(s,this.iframeTargetOrigin(r))})});m(this,"handleWebviewIpcMessage",e=>{var o;const r=e.detail??e;if(!r||r.channel!==dg)return;const i=(o=r.args)==null?void 0:o[0];if(!i||i.type!=="wheel")return;const s=this._subscribedWebview;s&&this.dispatchArtifactWheel({deltaX:i.deltaX??0,deltaY:i.deltaY??0,shiftKey:i.shiftKey??!1},a=>{var c;(c=s.send)==null||c.call(s,dg,{type:"scroll",deltaX:0,deltaY:a})})})}set artifact(e){const r=this._artifact;this._artifact=e,this.render(),r!==null&&r!==e&&this.syncView()}get artifact(){return this._artifact}set viewURL(e){this._viewURL!==e&&(this._viewURL=e,this.syncView())}get viewURL(){return this._viewURL}set contentURL(e){this._contentURL!==e&&(this._contentURL=e,this.syncView())}get contentURL(){return this._contentURL}set screen(e){this._screen!==e&&(this._screen=e,this.syncScreenSubscription(),this.syncServerSubscription())}get screen(){return this._screen}get activeView(){return this._activeView}connectedCallback(){this.setAttribute("level","2"),this.render(),this.syncView(),this.syncScreenSubscription(),this.syncServerSubscription(),window.addEventListener("message",this.handleIframeMessage)}disconnectedCallback(){this.teardownView(),this.unsubscribeFromScreen(),this.unsubscribeFromServer(),window.removeEventListener("message",this.handleIframeMessage),this.unsubscribeFromWebview()}handleClose(){this._artifact&&this.dispatchEvent(new Lb("close-artifact",{artifactID:this._artifact.id,bubbles:!0,composed:!0}))}syncView(){if(!this.isConnected)return;const e=this._artifact;if(!e){this.teardownView(),this._contentState={kind:"idle"},this.render();return}switch(e.kind){case"url":this.teardownView(),this._contentState={kind:"ready"},this.render();return}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 n2(r),this._activeView.handleUpdateContent(async i=>{await this.saveContent(i)}),this._activeView.addEventListener("open-artifact",this.handleOpenArtifact),this.loadBlobFrame(this._viewURL),this.startContentFetch();return}this._activeView!==null&&this.startContentFetch();return}if(this._contentURL!==null){if(!this._directRender||this._mountedDirectRenderURL!==this._contentURL){this.teardownView(),this._directRender=!0,this._mountedDirectRenderURL=this._contentURL,this._contentState={kind:"idle"},this.render(),this.installDirectRenderMessageListener(),e.status==="committed"&&(this._mountedDirectRenderStatus="committed",this.loadBlobFrame(this._contentURL));return}this.installDirectRenderMessageListener(),e.status==="committed"&&this._mountedDirectRenderStatus!=="committed"&&(this._mountedDirectRenderStatus="committed",this.loadBlobFrame(this._contentURL));return}this.teardownView(),this._contentState={kind:"idle"},this.render()}async saveContent(e){const r=this._screen,i=this._artifact;if(!r||!i)throw new Error("artifact-view: cannot save without a screen and artifact");await r.server.client.artifacts.putContent({artifactID:i.id,content:e})}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))}syncServerSubscription(){var r;if(!this.isConnected){this.unsubscribeFromServer();return}const e=((r=this._screen)==null?void 0:r.server)??null;this._subscribedServer!==e&&(this.unsubscribeFromServer(),e!==null&&(e.addEventListener("server-event",this.handleServerEvent),this._subscribedServer=e))}unsubscribeFromScreen(){this._subscribedScreen!==null&&(this._subscribedScreen.removeEventListener("artifact-content-changed",this.handleScreenContentChanged),this._subscribedScreen=null)}unsubscribeFromServer(){this._subscribedServer!==null&&(this._subscribedServer.removeEventListener("server-event",this.handleServerEvent),this._subscribedServer=null)}themeReloadSourceURL(){var e;return this._viewURL!==null?this._activeView!==null?this._viewURL:null:this._directRender&&this._contentURL!==null&&((e=this._artifact)==null?void 0:e.status)==="committed"?this._contentURL:null}withThemeBuster(e,r){const i=new URL(e,window.location.href);return i.searchParams.set(s2,String(r)),i.toString()}startContentFetch(){this._fetchSequence+=1;const e=this._fetchSequence,r=this._contentURL,i=this._activeView;if(!i||r===null){this._contentState={kind:"error"},this.render();return}this._contentState={kind:"loading"},(async()=>{try{const s=await fetch(r);if(e!==this._fetchSequence)return;if(!s.ok){this._contentState={kind:"error"},this.teardownView(),this.render();return}const o=await s.text();if(e!==this._fetchSequence||this._activeView!==i)return;this._activeView.content=o,this._contentState={kind:"ready"}}catch{if(e!==this._fetchSequence)return;this._contentState={kind:"error"},this.teardownView(),this.render()}})()}refetchContent(){this._fetchSequence+=1;const e=this._fetchSequence,r=this._contentURL,i=this._activeView;!i||r===null||(async()=>{try{const s=await fetch(r);if(e!==this._fetchSequence||!s.ok)return;const o=await s.text();if(e!==this._fetchSequence||this._activeView!==i)return;this._activeView.content=o}catch{}})()}loadBlobFrame(e){this._blobSequence+=1;const r=this._blobSequence;(async()=>{try{const i=await i2(e);if(r!==this._blobSequence){URL.revokeObjectURL(i);return}const s=this._blobURL;this._blobURL=i,this.render();const o=this.querySelector("iframe.artifact-frame");o&&(o.src=i),s!==null&&s!==i&&URL.revokeObjectURL(s)}catch{if(r!==this._blobSequence)return;this._contentState={kind:"error"},this.teardownView(),this.render()}})()}teardownView(){this._activeView!==null&&(this._activeView.removeEventListener("open-artifact",this.handleOpenArtifact),this._activeView.dispose(),this._activeView=null),this.removeDirectRenderMessageListener(),this._blobURL!==null&&(URL.revokeObjectURL(this._blobURL),this._blobURL=null),this._mountedViewURL=null,this._mountedDirectRenderURL=null,this._mountedDirectRenderStatus=null,this._directRender=!1,this._fetchSequence+=1,this._blobSequence+=1}installDirectRenderMessageListener(){if(this._directRenderMessageListener!==null)return;const e=r=>{const i=this.querySelector("iframe.artifact-frame");i&&r.source===i.contentWindow&&Rb(r.data)&&this.requestFocus(r.data.artifactID)};this._directRenderMessageListener=e,window.addEventListener("message",e)}removeDirectRenderMessageListener(){this._directRenderMessageListener!==null&&(window.removeEventListener("message",this._directRenderMessageListener),this._directRenderMessageListener=null)}requestFocus(e){const r=this._screen;r&&r.server.client.display.focus({artifactID:e}).catch(i=>{console.warn("artifact-view: display.focus failed",i)})}contentTemplate(){const e=this._artifact;if((e==null?void 0:e.kind)==="url"){const r=e.externalURL;if(!r)throw new Error(`URL artifact ${e.id} is missing externalURL`);return rd()?z`
|
|
144
|
+
<webview
|
|
145
|
+
class="artifact-frame artifact-content"
|
|
146
|
+
src=${r}
|
|
147
|
+
sandbox="allow-scripts allow-same-origin allow-forms"
|
|
148
|
+
></webview>
|
|
149
|
+
`:z`
|
|
150
|
+
<iframe
|
|
151
|
+
class="artifact-frame artifact-content"
|
|
152
|
+
src=${r}
|
|
153
|
+
sandbox="allow-scripts allow-same-origin allow-forms"
|
|
154
|
+
></iframe>
|
|
155
|
+
`}return this._contentState.kind==="error"?z`
|
|
156
|
+
<div class="artifact-content artifact-placeholder">
|
|
157
|
+
<em>Failed to load content</em>
|
|
158
|
+
</div>
|
|
159
|
+
`:this._viewURL!==null||this._directRender?z`
|
|
160
|
+
<iframe
|
|
161
|
+
class="artifact-frame artifact-content"
|
|
162
|
+
src=${this._blobURL??"about:blank"}
|
|
163
|
+
sandbox="allow-scripts"
|
|
164
|
+
></iframe>
|
|
165
|
+
`:z`
|
|
166
|
+
<div class="artifact-content artifact-placeholder">
|
|
167
|
+
<em>Artifact unavailable</em>
|
|
168
|
+
</div>
|
|
169
|
+
`}template(){const e=this._artifact;return z`
|
|
170
|
+
${this.contentTemplate()}
|
|
171
|
+
<footer class="artifact-title-bar" drag-handle material="glass-frosted">
|
|
172
|
+
<div class="artifact-title-group">
|
|
173
|
+
<span class="artifact-title-icon">${Tz({size:16})}</span>
|
|
174
|
+
<span class="artifact-title">${e.title}</span>
|
|
175
|
+
</div>
|
|
176
|
+
<button
|
|
177
|
+
icon-only
|
|
178
|
+
variant="ghost"
|
|
179
|
+
class="artifact-close-btn"
|
|
180
|
+
@click=${()=>this.handleClose()}
|
|
181
|
+
aria-label="Close"
|
|
182
|
+
>
|
|
183
|
+
${ad({size:16})}
|
|
184
|
+
</button>
|
|
185
|
+
</footer>
|
|
186
|
+
`}render(){this._artifact&&(this.setAttribute("kind",this._artifact.kind),Re(this.template(),this),this.syncWebviewSubscription())}dispatchArtifactWheel(e,r){this.dispatchEvent(new o2("artifact-wheel",{bubbles:!0,composed:!0,deltaX:e.deltaX,deltaY:e.deltaY,shiftKey:e.shiftKey,scrollNative:r}))}syncWebviewSubscription(){const e=this.querySelector("webview");e!==this._subscribedWebview&&(this.unsubscribeFromWebview(),e&&(e.addEventListener("ipc-message",this.handleWebviewIpcMessage),this._subscribedWebview=e))}unsubscribeFromWebview(){this._subscribedWebview&&(this._subscribedWebview.removeEventListener("ipc-message",this.handleWebviewIpcMessage),this._subscribedWebview=null)}iframeTargetOrigin(e){const r=e.getAttribute("sandbox")??"";if(!new Set(r.split(/\s+/).filter(Boolean)).has("allow-same-origin"))return"*";const s=e.getAttribute("src")??e.src;if(!s)return"*";try{return new URL(s,window.location.href).origin}catch{return"*"}}}customElements.define("artifact-view",a2);/**
|
|
187
|
+
* @license
|
|
188
|
+
* Copyright 2017 Google LLC
|
|
189
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
190
|
+
*/const pg=(n,t,e)=>{const r=new Map;for(let i=t;i<=e;i++)r.set(n[i],i);return r},fg=Zl(class extends od{constructor(n){if(super(n),n.type!==sd.CHILD)throw Error("repeat() can only be used in text expressions")}dt(n,t,e){let r;e===void 0?e=t:t!==void 0&&(r=t);const i=[],s=[];let o=0;for(const a of n)i[o]=r?r(a,o):o,s[o]=e(a,o),o++;return{values:s,keys:i}}render(n,t,e){return this.dt(n,t,e).values}update(n,[t,e,r]){const i=_z(n),{values:s,keys:o}=this.dt(t,e,r);if(!Array.isArray(i))return this.ut=o,s;const a=this.ut??(this.ut=[]),c=[];let u,h,p=0,v=i.length-1,g=0,_=s.length-1;for(;p<=v&&g<=_;)if(i[p]===null)p++;else if(i[v]===null)v--;else if(a[p]===o[g])c[g]=Qn(i[p],s[g]),p++,g++;else if(a[v]===o[_])c[_]=Qn(i[v],s[_]),v--,_--;else if(a[p]===o[_])c[_]=Qn(i[p],s[_]),as(n,c[_+1],i[p]),p++,_--;else if(a[v]===o[g])c[g]=Qn(i[v],s[g]),as(n,i[p],i[v]),v--,g++;else if(u===void 0&&(u=pg(o,g,_),h=pg(a,p,v)),u.has(a[p]))if(u.has(a[v])){const k=h.get(o[g]),T=k!==void 0?i[k]:null;if(T===null){const P=as(n,i[p]);Qn(P,s[g]),c[g]=P}else c[g]=Qn(T,s[g]),as(n,i[p],T),i[k]=null;g++}else Hc(i[v]),v--;else Hc(i[p]),p++;for(;g<=_;){const k=as(n,c[_+1]);Qn(k,s[g]),c[g++]=k}for(;p<=v;){const k=i[p++];k!==null&&Hc(k)}return this.ut=o,Sz(n,c),Or}}),Ae=n=>({type:"px",...n}),Ee=n=>({type:"unit",...n}),ha=2;class l2{constructor(t){m(this,"basis");m(this,"min");m(this,"_gap");m(this,"_viewport");m(this,"_unit");this.basis=t.basis,this.min=t.min,this._viewport=t.viewport,this._gap=t.gap??Ae({x:ce,y:ce});const e=this._viewport.x??Dr,r=this._viewport.y??Xa,i=this._gap.x??ce,s=this._gap.y??ce,o=e<=MA,a=o?e-i*ha:Math.min(Dr,e-i*ha),c=o?r-s*ha:Math.min(Xa,r-s*ha),u=(a-i*(mt-1))/mt,h=(c-s*(ct-1))/ct,p=this.basis.x??0,v=this.basis.y??0,g=this.min.x??0,_=this.min.y??0;this._unit=Ae(o?{x:Math.max(g,u),y:Math.max(_,h)}:{x:Math.max(g,Math.min(p,u)),y:Math.max(_,Math.min(v,h))})}get unit(){return this._unit}get viewport(){return this._viewport}get gap(){return this._gap}toUnits(t){return Ee({x:t.x==null?void 0:t.x/(this._unit.x??1),y:t.y==null?void 0:t.y/(this._unit.y??1)})}toPixels(t){const e=this._unit.x??0,r=this._unit.y??0,i=this._gap.x??ce,s=this._gap.y??ce,o=t.x==null?void 0:t.x*e+Math.max(0,t.x-1)*i,a=t.y==null?void 0:t.y*r+Math.max(0,t.y-1)*s;return Ae({x:o,y:a})}}const Mr=1e-4,At=1e-6,c2=40,u2=24;function zb(n,t){return Math.max(0,n-t*2)}function Ob(n){const t=[0];for(const e of n)t.push((t[t.length-1]??0)+e);return t}function Mb(n){const t=[0];for(let e=0;e<n.length;e+=1){const r=t[e]??0;t.push(r+n[e]+ce)}return t}function Nb(n,t,e){if(t<0||t>=n.length)return 0;let r=0,i=0;for(let s=t;s<n.length;s+=1){const o=n[s],a=i===0?o:r+ce+o;if(a>e+Mr)break;r=a,i+=1}return Math.max(1,i)}function h2(n,t,e){if(t<0||t>=n.length)return 0;let r=0,i=0;for(let s=t;s>=0;s-=1){const o=n[s],a=i===0?o:r+ce+o;if(a>e+Mr)break;r=a,i+=1}return Math.max(1,i)}function d2(n,t){if(n.length===0)return 0;let e=0,r=0;for(let i=n.length-1;i>=0;i-=1){const s=n[i],o=r===0?s:e+ce+s;if(o>t+Mr)break;e=o,r+=1}return Math.max(1,r)}function ld(n,t){if(n.length===0)return 0;const e=d2(n,t);return Math.max(0,n.length-e)}function gg(n,t,e){if(n.length===0)return 0;const r=Nb(n,t,e),i=Math.min(n.length,t+r);if(i<=t)return 0;const s=n.slice(t,i);return s.reduce((o,a)=>o+a,0)+Math.max(0,s.length-1)*ce}function qu(n,t,e){const r=n[t]??0;return e-r}function ui(n,t,e,r,i){if(n.length===0)return 0;const s=ld(n,i),o=t[s]??0,a=Math.max(0,Math.min(o,e));let c=0;for(let F=0;F<s;F+=1){const Y=t[F]??0,j=t[F+1]??Y;if(a>=Y&&a<=j+Mr){c=F;break}c=F+1}const u=Math.min(c+1,s),h=t[c]??0,p=t[u]??h,v=Math.max(p-h,Mr),g=u===c?0:(a-h)/v,_=Mb(n),k=gg(n,c,i),T=gg(n,u,i),P=(r-k)/2,R=(r-T)/2,W=qu(_,c,P),N=qu(_,u,R);return W+(N-W)*g}function p2(n,t,e,r,i){const s=ld(n,r),o=t[s]??0;let a=0,c=o;for(let u=0;u<c2;u+=1){const h=(a+c)/2;ui(n,t,h,e,r)>i?a=h:c=h}return(a+c)/2}function f2(n,t,e){const r=Mb(n),[i,s]=t,o=n.slice(i,s+1),a=o.reduce((u,h)=>u+h,0)+Math.max(0,o.length-1)*ce,c=(e-a)/2;return qu(r,i,c)}function g2(n,t,e){const r=Nb(n,t,e);return[t,Math.min(n.length-1,t+r-1)]}function m2(n,t,e){const r=h2(n,t,e);return[Math.max(0,t-r+1),t]}function v2(n,t){return n[0]===t[0]&&n[1]===t[1]}function y2(n){const{nodeCols:t,nodeWidthsPx:e,viewportWidthPx:r}=n;if(t.length===0||e.length===0)return{viewspans:[],minScroll:0,maxScroll:0};const i=e.length,s=n.gapPx??ce,o=zb(r,s),a=Ob(t),c=ld(e,o),u=a[c]??0;function h(T){const P=f2(e,T,r),R=p2(e,a,r,o,P);return{nodeRange:T,anchor:Math.max(0,Math.min(u,R))}}const p=[];for(let T=0;T<i;){const P=g2(e,T,o);p.push(h(P)),T=P[1]+1}const v=h(m2(e,i-1,o)),g=p.filter(T=>T.nodeRange[0]<v.nodeRange[0]),_=g[g.length-1];return{viewspans:_&&v2(_.nodeRange,v.nodeRange)?g:[...g,v],minScroll:0,maxScroll:u}}function ti(n,t){var i;let e=0,r=Number.POSITIVE_INFINITY;for(let s=0;s<n.length;s+=1){const o=Math.abs((((i=n[s])==null?void 0:i.anchor)??0)-t);if(o+At<r){r=o,e=s;continue}Math.abs(o-r)<=At&&s<e&&(e=s)}return e}function b2(n,t,e){return e<=0?0:Math.max(0,Math.min(e-1,n+t))}function er(n,t,e){return Math.max(t,Math.min(e,n))}function w2(n,t){var e;for(let r=0;r<n.length;r+=1)if(Math.abs((((e=n[r])==null?void 0:e.anchor)??0)-t)<=At)return r;return-1}function S2(n,t,e){var i,s;if(n.length===0)return t;const r=w2(n,t);if(r>=0){const o=n[r+e];return(o==null?void 0:o.anchor)??n[e>0?n.length-1:0].anchor}if(e>0){for(const o of n)if(o.anchor>t+At)return o.anchor;return((i=n[n.length-1])==null?void 0:i.anchor)??t}for(let o=n.length-1;o>=0;o-=1){const a=n[o];if(a&&a.anchor<t-At)return a.anchor}return((s=n[0])==null?void 0:s.anchor)??t}class _2 extends qt{constructor(e){super();m(this,"_scroll",0);m(this,"_minScroll",0);m(this,"_maxScroll",0);m(this,"_viewspans",[]);m(this,"_activeViewspanIndex",0);m(this,"_nodeWidthsPx",[]);m(this,"_boundaryCols",[0]);m(this,"_viewportWidthPx",0);m(this,"_framedViewportWidthPx",0);this._scroll=(e==null?void 0:e.x)??0}get scroll(){return Ee({x:this._scroll})}get translate(){return Ae({x:ui(this._nodeWidthsPx,this._boundaryCols,this._scroll,this._viewportWidthPx,this._framedViewportWidthPx)})}get activeViewspan(){return this._viewspans[this._activeViewspanIndex]??null}get viewspans(){return this._viewspans}set scroll(e){const r=er(e.x??this._scroll,this._minScroll,this._maxScroll);Math.abs(r-this._scroll)<=At||(this._scroll=r,this._activeViewspanIndex=ti(this._viewspans,this._scroll),this.dispatchEvent(new ei("layout-scroll",{scroll:this.scroll})))}rebuild(e){var v;const r=e.nodeWidths.map(g=>Math.max(0,g.x??0)),i=r.map(g=>e.grid.toPixels(Ee({x:g})).x??0),s=e.grid.viewport.x??0,o=e.grid.gap.x??ce,a=y2({nodeCols:r,nodeWidthsPx:i,viewportWidthPx:s,gapPx:o});this._nodeWidthsPx=i,this._boundaryCols=Ob(r),this._viewportWidthPx=s,this._framedViewportWidthPx=zb(s,o),this._viewspans=a.viewspans,this._minScroll=a.minScroll,this._maxScroll=a.maxScroll;const c=er(this._scroll,this._minScroll,this._maxScroll);this._activeViewspanIndex=ti(this._viewspans,c);const h=e.snap!==!1?((v=this._viewspans[this._activeViewspanIndex])==null?void 0:v.anchor)??c:c,p=er(h,this._minScroll,this._maxScroll);Math.abs(p-this._scroll)>At&&(this._scroll=p,this.dispatchEvent(new ei("layout-scroll",{scroll:this.scroll})))}step(e){var o;if(this._viewspans.length===0)return;const r=b2(this._activeViewspanIndex,e,this._viewspans.length),i=((o=this._viewspans[r])==null?void 0:o.anchor)??this._scroll,s=er(i,this._minScroll,this._maxScroll);this._activeViewspanIndex=r,!(Math.abs(s-this._scroll)<=At)&&(this._scroll=s,this.dispatchEvent(new ei("layout-scroll",{scroll:this.scroll})))}snap(e){var s;if(this._viewspans.length===0)return;const r=e===void 0?((s=this._viewspans[ti(this._viewspans,this._scroll)])==null?void 0:s.anchor)??this._scroll:S2(this._viewspans,this._scroll,e),i=er(r,this._minScroll,this._maxScroll);this._activeViewspanIndex=ti(this._viewspans,i),!(Math.abs(i-this._scroll)<=At)&&(this._scroll=i,this.dispatchEvent(new ei("layout-scroll",{scroll:this.scroll})))}wheel(e){const r=er(this._scroll+(e.x??0),this._minScroll,this._maxScroll);Math.abs(r-this._scroll)<=At||(this._scroll=r,this._activeViewspanIndex=ti(this._viewspans,this._scroll),this.dispatchEvent(new ei("layout-scroll",{scroll:this.scroll})))}wheelPixels(e){const r=e.x??0;if(Math.abs(r)<=Mr)return;const i=ui(this._nodeWidthsPx,this._boundaryCols,this._scroll,this._viewportWidthPx,this._framedViewportWidthPx),s=i-r,o=ui(this._nodeWidthsPx,this._boundaryCols,this._maxScroll,this._viewportWidthPx,this._framedViewportWidthPx),a=ui(this._nodeWidthsPx,this._boundaryCols,this._minScroll,this._viewportWidthPx,this._framedViewportWidthPx),c=Math.max(o,Math.min(a,s));if(Math.abs(c-i)<=Mr)return;let u=this._minScroll,h=this._maxScroll;for(let v=0;v<u2;v+=1){const g=(u+h)/2;ui(this._nodeWidthsPx,this._boundaryCols,g,this._viewportWidthPx,this._framedViewportWidthPx)>c?u=g:h=g}const p=er((u+h)/2,this._minScroll,this._maxScroll);Math.abs(p-this._scroll)<=At||(this._scroll=p,this._activeViewspanIndex=ti(this._viewspans,this._scroll),this.dispatchEvent(new ei("layout-scroll",{scroll:this.scroll})))}}const Vc={"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}},k2=["stack-above","stack-below","reorder-before","reorder-after"];function jc(n,t){return{left:n.left+n.width*t.left,top:n.top+n.height*t.top,width:n.width*t.width,height:n.height*t.height}}function tr(n,t,e){return n>=e.left&&n<e.left+e.width&&t>=e.top&&t<e.top+e.height}function Yu(n){return Number.isFinite(n)?Math.max(Ps,Math.min(Bh,Math.round(n))):Ps}function x2(n,t,e){const r=n.findIndex(a=>a.type==="card"&&a.id===t);if(r===-1)return n;const i=n[r];if(!i||i.type!=="card")return n;const s=Yu(e);if(i.width===s)return n;const o=[...n];return o[r]={...i,width:s},o}function Ub(n,t){for(const e of n){if(e.type==="card"&&e.id===t)return e;if(e.type==="stack")for(const r of e.children){if(r.type==="card"&&r.id===t)return r;if(r.type==="row"){for(const i of r.children)if(i.id===t)return i}}}return null}function Xu(n){return n.height===ct||n.height===Un?{...n,height:Un}:n}function Ku(n){return n.height===Un?{...n,height:ct}:n}function E2(n,t,e,r){const i=n.findIndex(h=>h.type==="stack"&&h.id===t);if(i===-1)return n;const s=n[i];if(!s||s.type!=="stack")return n;const o=s.children.find(h=>h.type==="card"&&h.id===e);if(!o||o.type!=="card")return n;const a=s.children.filter(h=>h.id!==e);if(a.length===s.children.length||a.length<1)return n;const c=[...n];if(a.length===1){const[h]=a;c[i]=h.type==="card"?Ku(h):h}else c[i]={...s,children:a};const u=Math.max(0,Math.min(r,c.length));return c.splice(u,0,Ku(o)),c}const A2=it(),$2=it(),T2=50;function I2(n,t){if(n.type!==t.type)return!1;switch(n.type){case"reorder":return t.index===n.index;case"stack":return t.targetCardId===n.targetCardId&&t.position===n.position;case"stack-child-noop":return!0;case"stack-child-extract":return t.toIndex===n.toIndex;case"stack-child-reorder":return t.position===n.position;default:return!1}}function Fo(n){return{id:n.id,type:"drop-target",width:n.width,height:n.height}}function mg(n){return n.map(R2)}function C2(n){return n.type==="drop-target"?{id:n.id,type:"card",artifactID:n.id,width:n.width,height:n.height}:n}function R2(n){return n.type==="drop-target"?{id:n.id,type:"card",artifactID:n.id,width:n.width,height:n.height}:n.type==="stack"?{...n,children:n.children.map(C2)}:n}function Fb(n,t){return n.find(r=>r.type==="card"&&r.id===t)??null}function vg(n,t){return n.find(r=>r.type==="stack"&&r.id===t)??null}function P2(n,t){const e=[...t],r=e.findIndex(a=>a.type==="card"&&a.id===n.nodeId);if(r===-1)return null;const i=e[r];if(!i||i.type!=="card")return null;e.splice(r,1);const s=Math.max(0,Math.min(n.lastReorderIndex,e.length));e.splice(s,0,i);const o=e.findIndex(a=>a.type==="card"&&a.id===n.nodeId);return o===-1?null:{base:e,visualDraggedIndex:o}}function D2(n,t,e,r){const i=[...n.base];i.splice(n.visualDraggedIndex,1);const s=i.findIndex(v=>v.type==="card"&&v.id===e.targetCardId),o=s===-1?null:i[s];if(!o||o.type!=="card")return null;const a=Fb(r,t.nodeId);if(!a)return null;const c=Xu(a),u=Xu(o),h=Fo(c),p=e.position==="above"?[h,u]:[u,h];return i[s]={id:o.id,type:"stack",children:p},i}function Gc(n,t){return n.parentStackId?z2(n,t):L2(n,t)}function L2(n,t){const e=n.hitTarget;if(e.type==="reorder"){const r=t[n.sourceIndex];if(!r||r.type!=="card")return[...t];const i=[...t];return i.splice(n.sourceIndex,1),i.splice(e.index,0,Fo(r)),i}if(e.type==="stack"){const r=P2(n,t);return r?D2(r,n,e,t)??[...t]:[...t]}return[...t]}function z2(n,t){const e=n.hitTarget;switch(e.type){case"stack-child-reorder":return O2(n,t,e.position);case"stack-child-extract":return M2(n,t,e.toIndex);case"stack-child-noop":return N2(n,t);default:return[...t]}}function O2(n,t,e){const r=t.findIndex(v=>v.type==="stack"&&v.id===n.parentStackId);if(r===-1)return[...t];const i=t[r];if(!i||i.type!=="stack")return[...t];if(!i.children.every(v=>v.type==="card"))return[...t];const s=i.children,o=s.findIndex(v=>v.id===n.nodeId);if(o===-1)return[...t];const a=s[o],c=s.filter(v=>v.id!==n.nodeId),u=Fo(a),h=e==="above"?[u,...c]:[...c,u],p=[...t];return p[r]={...i,children:h},p}function M2(n,t,e){if(!n.parentStackId)return[...t];const r=E2(t,n.parentStackId,n.nodeId,e);if(r===t)return[...t];const i=r.findIndex(a=>a.type==="card"&&a.id===n.nodeId);if(i===-1)return[...t];const s=r[i];if(!s||s.type!=="card")return[...t];const o=[...r];return o[i]=Fo(s),o}function N2(n,t){const e=t.findIndex(c=>c.type==="stack"&&c.id===n.parentStackId);if(e===-1)return[...t];const r=t[e];if(!r||r.type!=="stack")return[...t];const i=r.children.findIndex(c=>c.type==="card"&&c.id===n.nodeId);if(i===-1)return[...t];const s=r.children[i];if(!s||s.type!=="card")return[...t];const o=[...t],a=[...r.children];return a[i]=Fo(s),o[e]={...r,children:a},o}function U2(n,t){return t.find(r=>r.type==="stack"&&r.id===n.id)?n.id:Pl()}function F2(n,t,e){if(n.type==="drop-target"){const r=Ub(t,e);if(!r)throw new Error(`finalize: missing dragged card ${e}`);return Xu(r)}return n}function H2(n,t,e){const r=n.children.map(s=>F2(s,t,e));return{id:U2(n,t),type:"stack",children:r}}function W2(n,t,e){if(n.type==="drop-target"){const r=Ub(t,e);if(!r)throw new Error(`finalize: missing dragged card ${e}`);return Fb(t,e)!==null?r:Ku(r)}return n.type==="card"||n.type==="row"?n:H2(n,t,e)}function Z2(n,t,e){return n.map(r=>W2(r,t,e))}function B2(n,t){return JSON.stringify(n)===JSON.stringify(t)}const V2=No(qt);class j2 extends V2{constructor(e={}){super();m(this,"pending",null);m(this,"active",null)}start(e){if(this.pending||this.active)return;const r=e.pointer.x??0,i=e.pointer.y??0;this.pending={startX:r,startY:i,grabOffsetX:e.grabOffset.x??0,grabOffsetY:e.grabOffset.y??0,nodeId:e.nodeId,sourceIndex:e.source.index,parentStackId:e.source.parentId,width:e.size.x??0,height:e.size.y??0,baseLayout:e.layout}}update(e){const r=e.pointer.x??0,i=e.pointer.y??0,s=this.pending;if(s){const u=r-s.startX,h=i-s.startY;Math.hypot(u,h)>=UA&&(this.pending=null,this.active={...s,pointerX:r,pointerY:i,hitTarget:{type:"reorder",index:s.sourceIndex},lastReorderIndex:s.sourceIndex},this.emitDrag(),this.dispatchEvent(new oe("change")));return}if(!this.active)return;const o=Gc(this.active,this.active.baseLayout),a=this.getHitTargetForPointer(r,i,e,o),c=a.type==="reorder"?a.index:this.active.lastReorderIndex;this.active.pointerX===r&&this.active.pointerY===i&&I2(this.active.hitTarget,a)&&this.active.lastReorderIndex===c||(this.active={...this.active,pointerX:r,pointerY:i,hitTarget:a,lastReorderIndex:c},this.emitDrag(),this.dispatchEvent(new oe("change")))}drop(){if(this.pending){this.cancel();return}if(!this.active)return;const e=this.active.baseLayout;let r=null;try{const i=Gc(this.active,e),s=Z2(i,e,this.active.nodeId);B2(s,e)||(r=s)}catch{r=null}this.reset(),r&&this.dispatchEvent(new $2("drop",{layout:r})),this.dispatchEvent(new oe("change"))}cancel(){!this.pending&&!this.active||(this.reset(),this.dispatchEvent(new oe("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 e=Gc(this.active,this.active.baseLayout);this.dispatchEvent(new A2("drag",{nodeId:this.active.nodeId,source:{index:this.active.sourceIndex,parentId:this.active.parentStackId},grabOffset:Ae({x:this.active.grabOffsetX,y:this.active.grabOffsetY}),pointer:Ae({x:this.active.pointerX,y:this.active.pointerY}),size:Ae({x:this.active.width,y:this.active.height}),projectedLayout:e}))}getHitTargetForPointer(e,r,i,s){return this.active?this.isPointerInsideDragBounds(e,r,i.viewport)?this.active.parentStackId?this.getStackChildHitTarget(e,r,i,s):this.getTopLevelCardHitTarget(e,r,i,s):{type:"reorder",index:this.active.sourceIndex}:{type:"reorder",index:0}}getStackChildHitTarget(e,r,i,s){var u;if(!((u=this.active)!=null&&u.parentStackId))return{type:"stack-child-noop"};const o=this.getSourceStackInteractionRect(i.geometry);if(o&&tr(e,r,o)){const h=o.top+o.height/2;return{type:"stack-child-reorder",position:r<h?"above":"below"}}const a=this.getSourceRemainingSiblingRect(i.geometry);if(a&&tr(e,r,a)){const h=a.top+a.height/2;return{type:"stack-child-reorder",position:r<h?"above":"below"}}return{type:"stack-child-extract",toIndex:this.getTopLevelReorderIndexForPointer(e,r,i,s)}}getSourceRemainingSiblingRect(e){var s,o;if(!((s=this.active)!=null&&s.parentStackId))return;const r=vg(this.active.baseLayout,this.active.parentStackId);if(!r)return;const i=r.children.find(a=>{var c;return a.type==="card"&&a.id!==((c=this.active)==null?void 0:c.nodeId)});if(i)return(o=e.find(a=>a.id===i.id))==null?void 0:o.rect}getSourceStackInteractionRect(e){var o;if(!((o=this.active)!=null&&o.parentStackId))return;const r=e.find(a=>{var c;return a.id===((c=this.active)==null?void 0:c.parentStackId)});if(r)return this.active.sourceStackRect=r.rect,r.rect;const i=vg(this.active.baseLayout,this.active.parentStackId);if(!i)return this.active.sourceStackRect;const s=i.children.find(a=>{var c;return a.type==="card"&&a.id!==((c=this.active)==null?void 0:c.nodeId)});if(s){const a=e.find(c=>c.id===s.id);if(a)return a.rect}return this.active.sourceStackRect}getTopLevelCardHitTarget(e,r,i,s){var g,_,k;const o=this.getTopLevelZoneNodes(i.geometry,s);if(o.length===0)return{type:"reorder",index:((g=this.active)==null?void 0:g.sourceIndex)??0};const c=(i.effectiveVelocity??0)<=T2;for(const T of o){const P=T.rect;if(!tr(e,r,P))continue;const R=this.resolveTopLevelTargetForCard(e,r,T,T.logicalIndex,c);if(R)return R;if(!c&&((_=this.active)!=null&&_.hitTarget))return this.active.hitTarget}const u=this.getNearestTargetableZone(e,o);if(!u)return{type:"reorder",index:((k=this.active)==null?void 0:k.sourceIndex)??0};const h=Math.max(u.rect.left,Math.min(u.rect.left+u.rect.width,e)),p=this.resolveTopLevelTargetForCard(h,r,u,u.logicalIndex,c);if(p)return p;const v=u.rect.left+u.rect.width/2;return{type:"reorder",index:e<v?u.logicalIndex:u.logicalIndex+1}}getTopLevelReorderIndexForPointer(e,r,i,s){var u,h;const o=this.getTopLevelZoneNodes(i.geometry,s);if(o.length===0)return((u=this.active)==null?void 0:u.sourceIndex)??0;for(const p of o){if(!tr(e,r,p.rect))continue;const v=jc(p.rect,Vc["reorder-before"]);if(tr(e,r,v))return p.logicalIndex;const g=jc(p.rect,Vc["reorder-after"]);if(tr(e,r,g))return p.logicalIndex+1}const a=this.getNearestTargetableZone(e,o);if(!a)return((h=this.active)==null?void 0:h.sourceIndex)??0;const c=a.rect.left+a.rect.width/2;return e<c?a.logicalIndex:a.logicalIndex+1}getTopLevelZoneNodes(e,r){const i=new Map(r.map(a=>[a.id,a])),s=[];let o=0;for(const a of e){const c=i.get(a.id);c&&c.type!=="drop-target"&&(c.type==="card"||c.type==="stack")&&(s.push({id:c.id,rect:a.rect,logicalIndex:o}),o+=1)}return s}resolveTopLevelTargetForCard(e,r,i,s,o){const a=i.rect;for(const c of k2){if(!o&&(c==="stack-above"||c==="stack-below"))continue;const u=Vc[c],h=jc(a,u);if(tr(e,r,h))return c==="stack-above"?{type:"stack",targetCardId:i.id,position:"above"}:c==="stack-below"?{type:"stack",targetCardId:i.id,position:"below"}:c==="reorder-before"?{type:"reorder",index:s}:{type:"reorder",index:s+1}}return null}getNearestTargetableZone(e,r){let i=null,s=Number.POSITIVE_INFINITY;for(const o of r){const a=o.rect.left,c=o.rect.left+o.rect.width,u=e<a?a-e:e>c?e-c:0;u<s&&(s=u,i=o)}return i}isPointerInsideDragBounds(e,r,i){return e>=i.left&&e<=i.left+i.width&&r>=i.top&&r<=i.top+i.height}}const yg=60,G2=80,bg=.5,wg=10;class q2{constructor(){m(this,"awaitingFreshWheelGesture",!1);m(this,"lastWheelEventAt",Number.NEGATIVE_INFINITY);m(this,"lastWheelDeltaX",0);m(this,"activeGestureType","none");m(this,"lastWheelGestureAt",Number.NEGATIVE_INFINITY)}markKeyboardNavigation(t){this.awaitingFreshWheelGesture=!0,this.lastWheelEventAt=t,this.activeGestureType="none"}reset(){this.awaitingFreshWheelGesture=!1,this.lastWheelEventAt=Number.NEGATIVE_INFINITY,this.lastWheelDeltaX=0,this.activeGestureType="none",this.lastWheelGestureAt=Number.NEGATIVE_INFINITY}decide(t){const{now:e,shiftKey:r,deltaX:i,deltaY:s,overArtifactContent:o}=t;e-this.lastWheelGestureAt>=yg&&(this.activeGestureType="none");const c=r&&s!==0,u=c?s:i,h=Math.abs(u),p=Math.abs(s);return this.activeGestureType==="vertical-artifact"&&o?h>=bg&&h>=p*wg?this.classifyHorizontal(e,u):(this.lastWheelGestureAt=e,{type:"scroll-native"}):this.activeGestureType==="horizontal-filmstrip"?!c&&o&&p>0&&p>=h*wg?(this.activeGestureType="vertical-artifact",this.lastWheelGestureAt=e,{type:"scroll-native"}):this.classifyHorizontal(e,u):h<bg?(o&&(this.activeGestureType="vertical-artifact"),this.lastWheelGestureAt=e,{type:"scroll-native"}):c||h>p?this.classifyHorizontal(e,u):p>h?(o&&(this.activeGestureType="vertical-artifact"),this.lastWheelGestureAt=e,{type:"scroll-native"}):o?(this.activeGestureType="vertical-artifact",this.lastWheelGestureAt=e,{type:"scroll-native"}):this.classifyHorizontal(e,u)}classifyHorizontal(t,e){const r=t-this.lastWheelEventAt,i=Math.sign(this.lastWheelDeltaX),s=Math.sign(e),o=i!==0&&s!==0&&i!==s,a=i!==0&&Math.abs(e)>=Math.abs(this.lastWheelDeltaX)+G2;return this.awaitingFreshWheelGesture&&r<yg&&!o&&!a?{type:"ignore"}:(this.lastWheelEventAt=t,this.lastWheelDeltaX=e,this.lastWheelGestureAt=t,this.awaitingFreshWheelGesture=!1,this.activeGestureType="horizontal-filmstrip",{type:"scroll-horizontal",horizontalDelta:e})}}const Y2=100,X2=1e3;class K2{constructor(t,e){m(this,"_status","idle");m(this,"cumulativeOffset",0);m(this,"samples",[]);m(this,"scroll");m(this,"setAnimating");this.scroll=t,this.setAnimating=e}get status(){return this._status}start(t){this._status="active",this.cumulativeOffset=0,this.samples=[{time:t,offset:0}]}move(t,e){this._status==="active"&&(this.cumulativeOffset+=e,this.samples.push({time:t,offset:this.cumulativeOffset}),this.pruneSamples(t),this.setAnimating(!1),this.scroll.wheelPixels(Ae({x:-e})))}end(){if(this._status!=="active")return;const t=this.computeVelocityPxPerSec();this.setAnimating(!0),Math.abs(t)<HA?this.scroll.snap():this.scroll.snap(t>0?-1:1),this.reset()}cancel(){this._status==="active"&&(this.setAnimating(!0),this.scroll.snap(),this.reset())}reset(){this._status="idle",this.cumulativeOffset=0,this.samples=[]}pruneSamples(t){const e=t-Y2;let r=0;for(let i=0;i<this.samples.length;i+=1){if(this.samples[i].time>=e){r=i;break}r=i+1}if(r>0){const i=Math.max(0,r-1);this.samples=this.samples.slice(i)}}computeVelocityPxPerSec(){if(this.samples.length<2)return 0;const t=this.samples[0],e=this.samples[this.samples.length-1],r=e.time-t.time;return r<=0?0:(e.offset-t.offset)/r*X2}}function J2({baseLayout:n,visibleLayout:t,resolved:e,cardsByID:r,grid:i,dragState:s,isForeground:o}){var _;const a=new Map(t.map(k=>[k.id,k])),c=e.nodes.map((k,T)=>{const P=a.get(k.id),R=[];for(const N of k.cards){if(s&&N.id===s.nodeId){R.push({key:`placeholder:${N.id}`,kind:"placeholder",card:null,placement:N,isTopLevelCard:!1,isDragged:!1,sourceStackId:s.source.parentId??null});continue}const F=r.get(N.id);F&&R.push({key:F.id,kind:"card",card:F,placement:N,isTopLevelCard:(P==null?void 0:P.type)==="card",isDragged:!1,sourceStackId:null})}if(s!=null&&s.source.parentId&&k.id===s.source.parentId){const N=r.get(s.nodeId);if(N){const F={key:N.id,kind:"card",card:N,placement:null,isTopLevelCard:!1,isDragged:!0,sourceStackId:s.source.parentId},Y=Q2(n,s.source.parentId,s.nodeId),j=Y<0?R.length:Math.min(Y,R.length);R.splice(j,0,F)}}const W=!!(s&&(P==null?void 0:P.type)==="card"&&P.id===s.nodeId&&P.artifactID===s.nodeId);return{key:W?`placeholder:${k.id}`:k.id,kind:"visible",nodeId:k.id,widthPx:i.toPixels(Ee({x:k.width})).x??0,widthUnits:k.width,layoutIndex:T,isForeground:o(T),isPlaceholder:W,slots:R}});if(!s||s.source.parentId&&a.has(s.source.parentId))return c;const u=r.get(s.nodeId);if(!u)return c;const h=s.source.parentId??s.nodeId,p=((_=ur(n).nodes[s.source.index])==null?void 0:_.width)??mt,v={key:h,kind:"ghost",nodeId:h,widthPx:0,widthUnits:p,layoutIndex:null,isForeground:!1,isPlaceholder:!1,slots:[{key:u.id,kind:"card",card:u,placement:null,isTopLevelCard:!s.source.parentId,isDragged:!0,sourceStackId:s.source.parentId??null}]},g=Math.max(0,Math.min(s.source.index,c.length));return c.splice(g,0,v),c}function Sg(n){if(!n)return null;const t=n.projectedLayout,e=n.source.parentId;for(const i of t){if(i.type!=="stack")continue;const s=i.children.findIndex(u=>u.type==="drop-target");if(s===-1)continue;const o=s===0?"above":"below";if(e&&e===i.id)return`stack-child-reorder:${o}`;const a=i.children.find(u=>u.type!=="drop-target");return`stack:${(a==null?void 0:a.type)==="card"?a.artifactID:(a==null?void 0:a.id)??""}:${o}`}const r=t.findIndex(i=>i.type==="drop-target");return r===-1?"none":e?`stack-child-extract:${r}`:`reorder:${r}`}function Q2(n,t,e){const r=n.find(i=>i.type==="stack"&&i.id===t);return!r||r.type!=="stack"?-1:r.children.findIndex(i=>i.type==="card"&&i.id===e)}const eO=2,_g=1e3,da=1e-4,tO=120,kg=!1;function xg(n){return n.replace(/["\\]/g,"\\$&")}function Eg(n,t,e){if(n===0)return 0;const r=t.toPixels(Ee({y:ct})).y??0;return(e-r)/eO}function qc(n){const t=n.clientWidth>0?n.clientWidth:Dr,e=n.clientHeight>0?n.clientHeight:Xa;let r=0,i=0;if(n.isConnected){const o=getComputedStyle(n);r=parseFloat(o.paddingTop)||0,i=parseFloat(o.paddingBottom)||0}const s=Math.max(1,e-r-i);return{width:t,height:s,offsetY:r}}class nO extends Event{constructor(e){super("scroll",{bubbles:!0,composed:!0});m(this,"scrollPosition");this.scrollPosition=e}}class Hb extends Event{constructor(e){super("layout-change",{bubbles:!0,composed:!0});m(this,"layout");this.layout=e}}class rO extends HTMLElement{constructor(){super();m(this,"_layout",[]);m(this,"_scrollPosition",0);m(this,"layoutGrid",null);m(this,"layoutScroll",new _2(Ee({x:0})));m(this,"scrollModelKey","");m(this,"resizeObserver",null);m(this,"renderPending",!1);m(this,"animateNextRender",!0);m(this,"wheelGesture",new q2);m(this,"swipeGesture",new K2(this.layoutScroll,e=>{this.animateNextRender=e}));m(this,"swipePointerId",null);m(this,"swipeStartX",0);m(this,"swipeStartY",0);m(this,"swipeLastX",0);m(this,"swipeActive",!1);m(this,"swipeShouldSuppressClick",!1);m(this,"swipeListenersAttached",!1);m(this,"wheelIdleSnapTimer",null);m(this,"dragController",new j2);m(this,"dragState",null);m(this,"activeDragPointerId",null);m(this,"dragListenersAttached",!1);m(this,"dragFrame",0);m(this,"lastDragFrameTime",0);m(this,"lastPointerX",0);m(this,"lastPointerY",0);m(this,"pointerVelocityPxPerSec",0);m(this,"scrollVelocityPxPerSec",0);m(this,"motionSampleTime",0);m(this,"motionSampleX",0);m(this,"motionSampleY",0);m(this,"lastDragControllerStatus","idle");m(this,"lastProjectedDragLayoutSignature","");m(this,"lastDragDropIntent",null);m(this,"lastActivePlaceholderId",null);m(this,"draggedSlotElement",null);m(this,"draggedSlotContainingBlock",null);m(this,"currentDragPreviewSize",null);m(this,"dragTrackOffsetXPx",0);m(this,"previousProjectedLayoutForOffset",null);m(this,"resizeState",null);m(this,"resizeListenersAttached",!1);m(this,"_cards",new Map);m(this,"onDragControllerChange",()=>{const e=this.dragController.status;e!==this.lastDragControllerStatus&&(this.lastDragControllerStatus=e,e==="idle"&&(this.dragState=null,this.resetDragPreviewState()),this.scheduleRender())});m(this,"onDragControllerDrag",e=>{var c;const r=JSON.stringify(e.projectedLayout),i=Sg(e),s=sO(e.projectedLayout);if(r!==this.lastProjectedDragLayoutSignature||i!==this.lastDragDropIntent||s!==this.lastActivePlaceholderId){const u=mg(e.projectedLayout),h=this.shouldApplyTrackOffset(e.projectedLayout,e.source.parentId),p=e.source.parentId?this.getStackChildAnchorCardId(e.source.parentId,e.nodeId):null;this.dragTrackOffsetXPx=h?this.computeDragTrackOffset(this.previousProjectedLayoutForOffset,u,e.nodeId,e.source.parentId,p,this.dragTrackOffsetXPx):0,this.previousProjectedLayoutForOffset=u,this.lastProjectedDragLayoutSignature=r,this.lastDragDropIntent=i,this.lastActivePlaceholderId=s,this.dragState={nodeId:e.nodeId,source:e.source,grabOffset:e.grabOffset,pointer:e.pointer,size:e.size,projectedLayout:e.projectedLayout},this.scheduleRender();return}this.dragState={nodeId:e.nodeId,source:e.source,grabOffset:e.grabOffset,pointer:e.pointer,size:e.size,projectedLayout:((c=this.dragState)==null?void 0:c.projectedLayout)??e.projectedLayout};const a=this.getCachedDraggedSlotElement(e.nodeId);a&&this.writeDraggedSlotPosition(a,this.dragState)});m(this,"onDragControllerDrop",e=>{this.dragState=null,this.resetDragPreviewState(),this.commitLayout(e.layout)});m(this,"onLayoutScrollInternal",e=>{const i=e.scroll.x??0;Math.abs(i-this._scrollPosition)<da||(this._scrollPosition=i,this.emitScrollPositionChanged(i),this.scheduleRender())});m(this,"handleKeyDown",e=>{if(e.key==="Escape"&&this.dragController.status!=="idle"){e.preventDefault(),this.stopDragFrameLoop(),this.releaseActiveDragPointerCapture(),this.dragController.cancel(),this.detachDragListeners();return}this.dragController.status==="idle"&&(e.key==="ArrowRight"?(e.preventDefault(),this.wheelGesture.markKeyboardNavigation(Date.now()),this.shiftWindow(1)):e.key==="ArrowLeft"&&(e.preventDefault(),this.wheelGesture.markKeyboardNavigation(Date.now()),this.shiftWindow(-1)))});m(this,"handleWheel",e=>{if(this._layout.length===0)return;const r=this.wheelGesture.decide({now:Date.now(),shiftKey:e.shiftKey,deltaX:e.deltaX,deltaY:e.deltaY,overArtifactContent:!1});r.type==="scroll-horizontal"&&(e.preventDefault(),this.applyHorizontalWheel(r.horizontalDelta))});m(this,"handleWindowMessage",e=>{if(this._layout.length===0)return;const r=this.findManagedArtifactFrame(e.source);if(r&&this.isTrustedArtifactFrameMessage(e,r)){if(jz(e.data)){const i=typeof performance<"u"?performance.now():Date.now();this.swipeGesture.status==="idle"&&this.swipeGesture.start(i),this.swipeGesture.move(i,e.data.deltaX);return}if(Gz(e.data)){this.swipeGesture.status==="active"&&this.swipeGesture.end();return}}});m(this,"handleArtifactWheel",e=>{if(this._layout.length===0)return;const r=this.wheelGesture.decide({now:Date.now(),shiftKey:e.shiftKey,deltaX:e.deltaX,deltaY:e.deltaY,overArtifactContent:!0});if(r.type==="scroll-horizontal"){this.applyHorizontalWheel(r.horizontalDelta);return}r.type==="scroll-native"&&e.scrollNative(e.deltaY)});m(this,"handlePointerDown",e=>{if(e.button!==0||this.dragController.status!=="idle"||this.resizeState)return;const r=e.target;if(!(r instanceof Element))return;const i=r.closest("[data-resize-handle]");if(i){this.beginResize(e,i);return}const s=r.closest("[drag-handle]")!==null,o=r.closest("button, input, textarea, select, a, [role='button']")!==null;if(e.pointerType==="touch"&&!s&&!o&&this._layout.length>0){this.beginSwipeTracking(e);return}if(!s){if(!o){const p=r.closest(".node");if(p&&!p.hasAttribute("data-foreground")){const v=p.getAttribute("layout-node");if(v!==null){const g=parseInt(v,10);if(!isNaN(g)){const _=this.findViewspanContainingNode(g);if(_){this.clearWheelIdleSnap(),this.animateNextRender=!0,this.layoutScroll.scroll=Ee({x:_.anchor}),e.preventDefault(),e.stopPropagation();return}}}}}return}if(o)return;const a=r.closest(".card-slot");if(!a)return;const c=a.getAttribute("data-layout-node-id");if(!c)return;const u=oO(this._layout,c);if(!u)return;const h=a.getBoundingClientRect();this.lastPointerX=e.clientX,this.lastPointerY=e.clientY,this.resetMotionTracking(e.clientX,e.clientY),this.focus(),this.dragController.start({nodeId:c,source:{index:u.topLevelIndex,parentId:u.sourceStackId},pointer:Ae({x:e.clientX,y:e.clientY}),grabOffset:Ae({x:e.clientX-h.left,y:e.clientY-h.top}),size:Ae({x:h.width,y:h.height}),layout:this._layout}),this.attachDragListeners(),this.activeDragPointerId=e.pointerId;try{this.setPointerCapture(e.pointerId)}catch{}e.preventDefault()});m(this,"handleResizePointerMove",e=>{const r=this.resizeState;if(!r||e.pointerId!==r.pointerId)return;const i=this.layoutGrid,s=((i==null?void 0:i.unit.x)??Sn)+ce;if(s<=0)return;const o=e.clientX-r.startClientX,a=Yu(r.startWidth+o/s);a!==r.currentWidth&&(r.currentWidth=a,this.scheduleRender())});m(this,"handleResizePointerUp",e=>{const r=this.resizeState;if(!r||e.pointerId!==r.pointerId)return;const i=r.currentWidth,s=r.startWidth,o=r.cardId;this.endResize(e.pointerId),i!==s?this.commitLayout(x2(this._layout,o,i)):this.scheduleRender()});m(this,"handleResizePointerCancel",e=>{!this.resizeState||e.pointerId!==this.resizeState.pointerId||(this.endResize(e.pointerId),this.scheduleRender())});m(this,"handleResizeWindowBlur",()=>{this.resizeState&&(this.endResize(this.resizeState.pointerId),this.scheduleRender())});m(this,"handleResizeKeyDown",e=>{this.resizeState&&e.key==="Escape"&&(e.preventDefault(),this.endResize(this.resizeState.pointerId),this.scheduleRender())});m(this,"handleSwipePointerMove",e=>{if(this.swipePointerId===null||e.pointerId!==this.swipePointerId)return;if(!this.swipeActive){const i=e.clientX-this.swipeStartX,s=e.clientY-this.swipeStartY,o=Math.abs(i),a=Math.abs(s);if(o<xf&&a<xf)return;if(a>=o){this.endSwipeTracking();return}this.swipeActive=!0,this.swipeShouldSuppressClick=!0;try{this.setPointerCapture(e.pointerId)}catch{}this.swipeGesture.start(e.timeStamp)}const r=e.clientX-this.swipeLastX;this.swipeLastX=e.clientX,this.swipeGesture.move(e.timeStamp,r),e.preventDefault()});m(this,"handleSwipePointerUp",e=>{this.swipePointerId===null||e.pointerId!==this.swipePointerId||(this.swipeActive&&this.swipeGesture.end(),this.releaseSwipePointerCapture(e.pointerId),this.endSwipeTracking())});m(this,"handleSwipePointerCancel",e=>{this.swipePointerId===null||e.pointerId!==this.swipePointerId||(this.swipeActive&&this.swipeGesture.cancel(),this.releaseSwipePointerCapture(e.pointerId),this.endSwipeTracking())});m(this,"handleSwipeWindowBlur",()=>{this.swipePointerId!==null&&this.swipeActive&&this.swipeGesture.cancel(),this.swipePointerId!==null&&this.releaseSwipePointerCapture(this.swipePointerId),this.endSwipeTracking()});m(this,"handleSwipeClick",e=>{this.swipeShouldSuppressClick&&(this.swipeShouldSuppressClick=!1,e.preventDefault(),e.stopPropagation(),typeof e.stopImmediatePropagation=="function"&&e.stopImmediatePropagation())});m(this,"handleWindowPointerMove",e=>{this.lastPointerX=e.clientX,this.lastPointerY=e.clientY,this.updatePointerVelocity(e.clientX,e.clientY),this.syncDragTargetForLatestPointer(),this.ensureDragFrameLoop()});m(this,"handleWindowPointerUp",e=>{this.stopDragFrameLoop(),this.releasePointerCaptureForEvent(e.pointerId),this.dragController.drop(),this.clearMotionTracking(),this.detachDragListeners()});m(this,"handleWindowPointerCancel",e=>{this.stopDragFrameLoop(),this.releasePointerCaptureForEvent(e.pointerId),this.dragController.cancel(),this.clearMotionTracking(),this.detachDragListeners()});m(this,"handleWindowBlur",()=>{this.releaseActiveDragPointerCapture(),this.stopDragFrameLoop(),this.dragController.cancel(),this.clearMotionTracking(),this.detachDragListeners()});m(this,"runDragFrame",e=>{if(this.dragController.status==="idle"){this.dragFrame=0;return}const r=Math.max(0,e-this.lastDragFrameTime)/_g;this.lastDragFrameTime=e,this.samplePointerVelocityAt(e,this.lastPointerX,this.lastPointerY);const i=this.getBoundingClientRect(),s=this.clampPointerToViewport(this.lastPointerX,this.lastPointerY,i),o=this.getDragEdgeScrollDeltaPixels(s.x,i,r);this.scrollVelocityPxPerSec=r>da?Math.abs(o)/r:0,Math.abs(o)>da&&(this.animateNextRender=!1,this.layoutScroll.wheelPixels(Ae({x:o}))),this.dragController.status==="active"&&this.syncDragTarget(s.x,s.y,i),this.dragFrame=requestAnimationFrame(this.runDragFrame)});this.dragController.addEventListener("change",this.onDragControllerChange),this.dragController.addEventListener("drag",this.onDragControllerDrag),this.dragController.addEventListener("drop",this.onDragControllerDrop),this.layoutScroll.addEventListener("layout-scroll",this.onLayoutScrollInternal)}set cards(e){this._cards!==e&&(this._cards=e,this.scheduleRender())}get cards(){return this._cards}set layout(e){this._layout=[...e],this.stopDragFrameLoop(),this.dragController.cancel(),this.resizeState&&this.endResize(this.resizeState.pointerId),this.scrollModelKey="",this.syncScrollModel(),this.layoutScroll.scroll=Ee({x:this._scrollPosition}),this.scheduleRender()}get layout(){return this._layout}commitLayout(e){this.layout=e,this.emitLayoutChanged()}set scrollPosition(e){Math.abs(e-this._scrollPosition)<da||(this.animateNextRender=!1,this.syncScrollModel(),this.layoutScroll.scroll=Ee({x:e}))}get scrollPosition(){return this._scrollPosition}focusArtifact(e){const r=ur(this._layout),i=r.nodes.findIndex(o=>o.cards.some(a=>a.artifactID===e));if(i<0)return;let s=0;for(let o=0;o<i;o+=1)s+=r.nodes[o].width;this.scrollPosition=s,queueMicrotask(()=>{const o=this.querySelector(`.card-slot[data-layout-card-id="${xg(e)}"]`);if(!o)return;o.classList.remove("card-focus-pulse"),o.offsetHeight,o.classList.add("card-focus-pulse");const a=()=>{o.classList.remove("card-focus-pulse"),o.removeEventListener("animationend",a)};o.addEventListener("animationend",a)})}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),this.addEventListener("artifact-wheel",this.handleArtifactWheel),window.addEventListener("message",this.handleWindowMessage),typeof ResizeObserver<"u"&&(this.resizeObserver=new ResizeObserver(()=>this.render()),this.resizeObserver.observe(this)),this.render()}disconnectedCallback(){var e;this.removeEventListener("keydown",this.handleKeyDown),this.removeEventListener("wheel",this.handleWheel),this.removeEventListener("pointerdown",this.handlePointerDown),this.removeEventListener("artifact-wheel",this.handleArtifactWheel),window.removeEventListener("message",this.handleWindowMessage),(e=this.resizeObserver)==null||e.disconnect(),this.resizeObserver=null,this.clearWheelIdleSnap(),this.wheelGesture.reset(),this.detachDragListeners(),this.swipeGesture.status==="active"&&this.swipeGesture.cancel(),this.swipePointerId!==null&&this.releaseSwipePointerCapture(this.swipePointerId),this.endSwipeTracking(),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(),this.resizeState&&this.endResize(this.resizeState.pointerId)}scheduleRender(){this.renderPending||(this.renderPending=!0,queueMicrotask(()=>{this.renderPending=!1,this.render()}))}createGrid(e,r){return new l2({basis:Ae({x:Sn,y:Sn}),min:Ae({x:_f,y:_f}),viewport:Ae({x:e,y:r}),gap:Ae({x:ce,y:ce})})}syncScrollModel(){const e=qc(this),i=ur(this._layout).nodes.map(o=>o.width),s=`${e.width}x${e.height}:${i.join(",")}`;s===this.scrollModelKey&&this.layoutGrid||(this.scrollModelKey=s,this.layoutGrid=this.createGrid(e.width,e.height),this.layoutScroll.rebuild({grid:this.layoutGrid,nodeWidths:i.map(o=>Ee({x:o})),snap:kg}))}emitScrollPositionChanged(e){this.dispatchEvent(new nO(e))}emitLayoutChanged(){this.dispatchEvent(new Hb([...this._layout]))}shiftWindow(e){this.clearWheelIdleSnap(),this.syncScrollModel(),this.animateNextRender=!0,this.layoutScroll.step(e)}applyHorizontalWheel(e){this.syncScrollModel();const r=this.layoutGrid;if(!r)return;this.animateNextRender=!1;const i=r.toUnits(Ae({x:e}));this.layoutScroll.wheel(Ee({x:i.x??0}))}scheduleWheelIdleSnap(){this.clearWheelIdleSnap(),this.wheelIdleSnapTimer=setTimeout(()=>{this.wheelIdleSnapTimer=null,this.animateNextRender=!0,this.layoutScroll.snap()},tO)}clearWheelIdleSnap(){this.wheelIdleSnapTimer!==null&&(clearTimeout(this.wheelIdleSnapTimer),this.wheelIdleSnapTimer=null)}findViewspanContainingNode(e){const r=this.layoutScroll.viewspans,i=this._scrollPosition;let s=null,o=Number.POSITIVE_INFINITY;for(const a of r)if(e>=a.nodeRange[0]&&e<=a.nodeRange[1]){const c=Math.abs(a.anchor-i);c<o&&(o=c,s=a)}return s}findManagedArtifactFrame(e){if(!e)return null;const r=this.querySelectorAll("iframe.artifact-frame");for(const i of r)if(i.contentWindow===e)return i;return null}isTrustedArtifactFrameMessage(e,r){if(e.origin==="null")return!0;const i=this.getArtifactFrameOrigin(r);return i===null||e.origin===i}getArtifactFrameOrigin(e){const r=e.getAttribute("src")??e.src;if(!r)return null;try{return new URL(r,window.location.href).origin}catch{return null}}beginResize(e,r){const i=r.getAttribute("data-resize-handle");if(!i)return;const s=this._layout.find(a=>a.type==="card"&&a.id===i);if(!s)return;const o=Yu(typeof s.width=="number"?s.width:mt);this.resizeState={cardId:i,pointerId:e.pointerId,startClientX:e.clientX,startWidth:o,currentWidth:o},this.attachResizeListeners();try{this.setPointerCapture(e.pointerId)}catch{}e.preventDefault(),e.stopPropagation()}attachResizeListeners(){this.resizeListenersAttached||(window.addEventListener("pointermove",this.handleResizePointerMove),window.addEventListener("pointerup",this.handleResizePointerUp),window.addEventListener("pointercancel",this.handleResizePointerCancel),window.addEventListener("blur",this.handleResizeWindowBlur),this.addEventListener("keydown",this.handleResizeKeyDown),this.resizeListenersAttached=!0)}detachResizeListeners(){this.resizeListenersAttached&&(window.removeEventListener("pointermove",this.handleResizePointerMove),window.removeEventListener("pointerup",this.handleResizePointerUp),window.removeEventListener("pointercancel",this.handleResizePointerCancel),window.removeEventListener("blur",this.handleResizeWindowBlur),this.removeEventListener("keydown",this.handleResizeKeyDown),this.resizeListenersAttached=!1)}endResize(e){this.resizeState=null,this.detachResizeListeners();try{this.hasPointerCapture(e)&&this.releasePointerCapture(e)}catch{}}beginSwipeTracking(e){this.swipePointerId=e.pointerId,this.swipeStartX=e.clientX,this.swipeStartY=e.clientY,this.swipeLastX=e.clientX,this.swipeActive=!1,this.swipeShouldSuppressClick=!1,this.attachSwipeListeners()}attachSwipeListeners(){this.swipeListenersAttached||(window.addEventListener("pointermove",this.handleSwipePointerMove),window.addEventListener("pointerup",this.handleSwipePointerUp),window.addEventListener("pointercancel",this.handleSwipePointerCancel),this.addEventListener("pointermove",this.handleSwipePointerMove),this.addEventListener("pointerup",this.handleSwipePointerUp),this.addEventListener("pointercancel",this.handleSwipePointerCancel),window.addEventListener("blur",this.handleSwipeWindowBlur),this.addEventListener("click",this.handleSwipeClick,{capture:!0}),this.swipeListenersAttached=!0)}detachSwipeListeners(){this.swipeListenersAttached&&(window.removeEventListener("pointermove",this.handleSwipePointerMove),window.removeEventListener("pointerup",this.handleSwipePointerUp),window.removeEventListener("pointercancel",this.handleSwipePointerCancel),this.removeEventListener("pointermove",this.handleSwipePointerMove),this.removeEventListener("pointerup",this.handleSwipePointerUp),this.removeEventListener("pointercancel",this.handleSwipePointerCancel),window.removeEventListener("blur",this.handleSwipeWindowBlur),this.removeEventListener("click",this.handleSwipeClick,{capture:!0}),this.swipeListenersAttached=!1)}endSwipeTracking(){this.swipePointerId=null,this.swipeActive=!1,this.detachSwipeListeners()}releaseSwipePointerCapture(e){try{this.hasPointerCapture(e)&&this.releasePointerCapture(e)}catch{}}releaseActiveDragPointerCapture(){this.activeDragPointerId!==null&&this.releasePointerCaptureForEvent(this.activeDragPointerId)}releasePointerCaptureForEvent(e){try{this.hasPointerCapture(e)&&this.releasePointerCapture(e)}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)}getVisibleLayout(){return this.dragController.status!=="active"||!this.dragState?this.applyResizeOverride(this._layout):mg(this.dragState.projectedLayout)}applyResizeOverride(e){const r=this.resizeState;if(!r)return e;const i=e.findIndex(a=>a.type==="card"&&a.id===r.cardId);if(i===-1)return e;const s=e[i];if(!s||s.type!=="card"||s.width===r.currentWidth)return e;const o=[...e];return o[i]={...s,width:r.currentWidth},o}getGridSlotStyle(e){return`grid-column: ${e.col} / span ${e.width}; grid-row: ${e.row} / span ${e.height};`}findContainingBlock(e){let r=e.parentElement;for(;r;){const i=getComputedStyle(r);if(i.transform!=="none"||i.perspective!=="none"||i.filter!=="none")return r;const s=i.willChange;if(s.includes("transform")||s.includes("perspective")||s.includes("filter"))return r;const o=i.contain;if(o.includes("layout")||o.includes("paint")||o.includes("strict"))return r;r=r.parentElement}return document.documentElement}getDraggedSlotStyle(e){const r=this.currentDragPreviewSize??{width:e.size.x??0,height:e.size.y??0};return["position: fixed;",`width: ${r.width}px;`,`height: ${r.height}px;`,"pointer-events: none;","z-index: 10;"].join(" ")}writeDraggedSlotPosition(e,r){(!this.draggedSlotContainingBlock||!this.draggedSlotContainingBlock.isConnected||!this.draggedSlotContainingBlock.contains(e))&&(this.draggedSlotContainingBlock=this.findContainingBlock(e));const i=this.draggedSlotContainingBlock.getBoundingClientRect(),s=r.pointer.x??0,o=r.pointer.y??0,a=r.grabOffset.x??0,c=r.grabOffset.y??0,u=this.currentDragPreviewSize??{width:r.size.x??0,height:r.size.y??0},h=r.size.x??0,p=r.size.y??0,v=h>0?a*(u.width/h):a,g=p>0?c*(u.height/p):c;e.style.left=`${s-v-i.left}px`,e.style.top=`${o-g-i.top}px`,e.style.width=`${u.width}px`,e.style.height=`${u.height}px`}renderSlot(e,r){var o,a;if(e.kind==="placeholder")return e.placement?z`
|
|
191
|
+
<div
|
|
192
|
+
class="card-slot card-placeholder"
|
|
193
|
+
data-layout-placeholder-for=${(r==null?void 0:r.nodeId)??""}
|
|
194
|
+
data-layout-placeholder-ghost="false"
|
|
195
|
+
data-layout-source-stack=${e.sourceStackId??""}
|
|
196
|
+
style=${this.getGridSlotStyle(e.placement)}
|
|
197
|
+
></div>
|
|
198
|
+
`:null;const i=e.card;if(!i)return null;const s=e.isDragged&&r?this.getDraggedSlotStyle(r):e.placement?this.getGridSlotStyle(e.placement):"";return z`
|
|
199
|
+
<div
|
|
200
|
+
class="card-slot"
|
|
201
|
+
data-layout-card-id=${i.artifactID}
|
|
202
|
+
data-layout-node-id=${i.id}
|
|
203
|
+
data-layout-drag-source=${String(e.isDragged)}
|
|
204
|
+
layout-cols=${String(((o=e.placement)==null?void 0:o.width)??"")}
|
|
205
|
+
layout-rows=${String(((a=e.placement)==null?void 0:a.height)??"")}
|
|
206
|
+
style=${s}
|
|
207
|
+
>
|
|
208
|
+
<div class="card-content-mount" data-mount-for=${i.id}></div>
|
|
209
|
+
${e.isTopLevelCard&&!e.isDragged?z`<div
|
|
210
|
+
class="resize-handle"
|
|
211
|
+
data-resize-handle=${i.id}
|
|
212
|
+
data-test-resize-handle=${i.id}
|
|
213
|
+
></div>`:null}
|
|
214
|
+
</div>
|
|
215
|
+
`}renderNode(e,r){return z`
|
|
216
|
+
<div
|
|
217
|
+
class=${e.kind==="ghost"?"drag-source-node":"node"}
|
|
218
|
+
layout-node=${String(e.layoutIndex??"")}
|
|
219
|
+
data-layout-node-id=${e.nodeId}
|
|
220
|
+
data-layout-placeholder=${String(e.kind==="visible"&&e.isPlaceholder)}
|
|
221
|
+
layout-node-cols=${String(e.widthUnits)}
|
|
222
|
+
?data-foreground=${e.kind==="visible"&&e.isForeground}
|
|
223
|
+
style=${e.kind==="visible"?`width: ${e.widthPx}px; --card-width-px: ${e.widthPx};`:""}
|
|
224
|
+
>
|
|
225
|
+
<div class="node-inner" style=${`grid-template-columns: repeat(${e.widthUnits}, var(--layout-unit-x));`}>
|
|
226
|
+
${fg(e.slots,i=>i.key,i=>this.renderSlot(i,r))}
|
|
227
|
+
</div>
|
|
228
|
+
</div>
|
|
229
|
+
`}render(){var Y;const e=qc(this),r=this.createGrid(e.width,e.height);this.layoutGrid=r;const i=this.getVisibleLayout(),s=this.dragController.status==="active",o=ur(i),a=o.nodes.map(j=>j.width),c=`${e.width}x${e.height}:${a.join(",")}`;!s&&c!==this.scrollModelKey&&(this.scrollModelKey=c,this.layoutScroll.rebuild({grid:r,nodeWidths:a.map(j=>Ee({x:j})),snap:kg}),this._scrollPosition=this.layoutScroll.scroll.x??this._scrollPosition);const u=iO(this._layout),h=r.unit.x??Sn,p=r.unit.y??Sn,v=s?this.dragTrackOffsetXPx:0,g=(this.layoutScroll.translate.x??0)+v,_=Eg(o.nodes.length,r,e.height),k=this.animateNextRender&&!s,T=[`transform: translate(${g}px, ${_}px);`,`transition-duration: ${k?NA:0}ms;`,`pointer-events: ${s?"none":"auto"};`].join(" ");this.animateNextRender=!0,this.style.setProperty("--layout-unit-x",`${h}px`),this.style.setProperty("--layout-unit-y",`${p}px`),this.style.setProperty("--layout-gap",`${ce}px`);const P=this.dragState,R=new Set;{let j=g;for(let le=0;le<o.nodes.length;le+=1){const St=r.toPixels(Ee({x:o.nodes[le].width})).x??0,qn=j+St;j>=-1&&qn<=e.width+1&&R.add(le),j=qn+ce}}const W=j=>R.has(j),N=J2({baseLayout:this._layout,visibleLayout:i,resolved:o,cardsByID:u,grid:r,dragState:this.dragState,isForeground:W}),F=Sg(this.dragState);if(F?this.setAttribute("data-test-drop-intent",F):this.removeAttribute("data-test-drop-intent"),this.dragState){let j=null;for(const le of o.nodes){for(const St of le.cards)if(St.id===this.dragState.nodeId){j={width:r.toPixels(Ee({x:St.width})).x??0,height:r.toPixels(Ee({y:St.height})).y??0};break}if(j)break}this.currentDragPreviewSize=j??{width:this.dragState.size.x??0,height:this.dragState.size.y??0}}else this.currentDragPreviewSize=null;Re(z`
|
|
230
|
+
<div class="track" style=${T}>
|
|
231
|
+
${fg(N,j=>j.key,j=>this.renderNode(j,P))}
|
|
232
|
+
</div>
|
|
233
|
+
`,this),this.syncCardElements(u,P?((Y=u.get(P.nodeId))==null?void 0:Y.artifactID)??null:null),this.syncDraggedSlotElement(P)}syncCardElements(e,r){var o;const i=new Map;for(const a of this.querySelectorAll(".card-content-mount[data-mount-for]")){const c=a.getAttribute("data-mount-for");c&&i.set(c,a)}const s=new Set;for(const a of e.values()){const c=this._cards.get(a.artifactID);if(!c)continue;s.add(a.artifactID);const u=i.get(a.id);if(!u){c.removeAttribute("data-dragging");continue}const h=(o=u.parentElement)==null?void 0:o.getAttribute("data-layout-node-id");console.assert(h===a.id,`layout-view: mount mismatch for ${a.id}`),c.parentElement!==u&&u.appendChild(c),console.assert(u.children.length<=1,`layout-view: multiple children for ${a.id}`),c.toggleAttribute("data-dragging",a.artifactID===r)}for(const[a,c]of this._cards)s.has(a)||c.removeAttribute("data-dragging")}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 e=this.getBoundingClientRect();if(this.dragController.status==="active"){const i=this.clampPointerToViewport(this.lastPointerX,this.lastPointerY,e);this.syncDragTarget(i.x,i.y,e);return}if(this.syncDragTarget(this.lastPointerX,this.lastPointerY,e),this.dragController.status==="pending")return;const r=this.clampPointerToViewport(this.lastPointerX,this.lastPointerY,e);(r.x!==this.lastPointerX||r.y!==this.lastPointerY)&&this.syncDragTarget(r.x,r.y,e)}syncDragTarget(e,r,i=this.getBoundingClientRect()){if(this.dragController.status==="idle")return;const s=this.getVisibleLayout(),o=this.dragController.status==="active"?this.dragTrackOffsetXPx:0,a=this.measureLayoutGeometry(s,o);this.dragController.update({pointer:Ae({x:e,y:r}),viewport:{left:i.left,top:i.top,width:i.width,height:i.height},geometry:a,effectiveVelocity:Math.max(this.pointerVelocityPxPerSec,this.scrollVelocityPxPerSec)})}resetMotionTracking(e,r){this.pointerVelocityPxPerSec=0,this.scrollVelocityPxPerSec=0,this.motionSampleTime=performance.now(),this.motionSampleX=e,this.motionSampleY=r}clearMotionTracking(){this.pointerVelocityPxPerSec=0,this.scrollVelocityPxPerSec=0,this.motionSampleTime=0}updatePointerVelocity(e,r){this.samplePointerVelocityAt(performance.now(),e,r)}samplePointerVelocityAt(e,r,i){if(this.motionSampleTime===0){this.motionSampleTime=e,this.motionSampleX=r,this.motionSampleY=i,this.pointerVelocityPxPerSec=0;return}const s=e-this.motionSampleTime;if(s<100)return;const o=r-this.motionSampleX;this.pointerVelocityPxPerSec=Math.abs(o)/s*_g,this.motionSampleTime=e,this.motionSampleX=r,this.motionSampleY=i}clampPointerToViewport(e,r,i){return{x:Math.max(i.left,Math.min(i.left+i.width,e)),y:Math.max(i.top,Math.min(i.top+i.height,r))}}getDragEdgeScrollDeltaPixels(e,r,i){var u;const s=r.left+sa,o=r.left+r.width-sa,a=((u=this.layoutGrid)==null?void 0:u.unit.x)??Sn,c=FA*a;if(e<s){const h=Math.max(0,Math.min(1,(s-e)/sa));return-(c*h**kf)*i}if(e>o){const h=Math.max(0,Math.min(1,(e-o)/sa));return c*h**kf*i}return 0}measureLayoutGeometry(e,r=0){const i=this.layoutGrid;if(!i)return[];const s=ur(e),o=new Map(s.nodes.map(_=>[_.id,_.width])),a=i.toPixels(Ee({y:ct})).y??Xa,c=qc(this),u=(this.layoutScroll.translate.x??0)+r,h=Eg(s.nodes.length,i,c.height),p=c.offsetY+h,v=[];let g=u;for(const _ of e){const k=o.get(_.id)??mt,T=i.toPixels(Ee({x:k})).x??Dr,P={left:g,top:p,width:T,height:a};v.push({id:_.id,rect:P}),g+=T+ce}return v}resetDragPreviewState(){this.dragTrackOffsetXPx=0,this.previousProjectedLayoutForOffset=null,this.lastProjectedDragLayoutSignature="",this.lastDragDropIntent=null,this.lastActivePlaceholderId=null,this.draggedSlotElement=null,this.draggedSlotContainingBlock=null,this.currentDragPreviewSize=null}getCachedDraggedSlotElement(e){var r;return(r=this.draggedSlotElement)!=null&&r.isConnected&&this.draggedSlotElement.getAttribute("data-layout-node-id")===e&&this.draggedSlotElement.getAttribute("data-layout-drag-source")==="true"?this.draggedSlotElement:(this.draggedSlotElement=this.querySelector(`.card-slot[data-layout-node-id="${xg(e)}"][data-layout-drag-source="true"]`),this.draggedSlotElement)}syncDraggedSlotElement(e){if(!e||this.dragController.status!=="active"){this.draggedSlotElement=null;return}const r=this.getCachedDraggedSlotElement(e.nodeId);r&&this.writeDraggedSlotPosition(r,e)}shouldApplyTrackOffset(e,r){if(r)return!0;for(const i of e){if(i.type!=="stack")continue;if(i.children.some(o=>o.type==="drop-target")&&r!==i.id)return!0}return!1}computeDragTrackOffset(e,r,i,s,o,a){if(!e)return a;const c=s?o??this.getStableAnchorCardId(e,r,i):this.getStableAnchorNodeId(e,r,i);if(!c)return a;const u=s?$g(e,c,this.layoutGrid):Tg(e,c,this.layoutGrid),h=s?$g(r,c,this.layoutGrid):Tg(r,c,this.layoutGrid);return u===null||h===null?a:a+(u-h)}getStableAnchorCardId(e,r,i){const s=Ag(e),o=new Set(Ag(r));for(const a of s)if(a!==i&&o.has(a))return a;return null}getStableAnchorNodeId(e,r,i){const s=new Set(r.map(o=>o.id));for(const o of e)if(o.id!==i&&s.has(o.id))return o.id;return null}getStackChildAnchorCardId(e,r){const i=this._layout.find(o=>o.type==="stack"&&o.id===e);if(!i||i.type!=="stack")return null;const s=i.children.find(o=>o.type==="card"&&o.id!==r);return(s==null?void 0:s.id)??null}}function iO(n){const t=new Map;for(const e of n){if(e.type==="card"){t.set(e.id,e);continue}for(const r of e.children)if(r.type==="card")t.set(r.id,r);else for(const i of r.children)t.set(i.id,i)}return t}function sO(n){for(const t of n)if(t.type==="drop-target"||t.type==="stack"&&t.children.some(e=>e.type==="drop-target"))return t.id;return null}function oO(n,t){const e=n.findIndex(r=>r.type==="card"&&r.id===t);if(e!==-1)return{topLevelIndex:e};for(let r=0;r<n.length;r+=1){const i=n[r];if(!(!i||i.type!=="stack")&&i.children.some(s=>s.type==="card"&&s.id===t))return{topLevelIndex:r,sourceStackId:i.id}}return null}function Ag(n){const t=[];for(const e of n){if(e.type==="card"){t.push(e.id);continue}if(e.type==="stack"){const r=e.children.find(i=>i.type==="card");r&&t.push(r.id)}}return t}function $g(n,t,e){if(!e)return null;const r=ur(n),i=new Map(r.nodes.map(o=>[o.id,o.width]));let s=0;for(const o of n){if(o.type==="card"&&o.id===t||o.type==="stack"&&o.children.some(u=>u.type==="card"&&u.id===t))return s;const a=i.get(o.id)??mt,c=e.toPixels(Ee({x:a})).x??Dr;s+=c+ce}return null}function Tg(n,t,e){if(!e)return null;const r=ur(n),i=new Map(r.nodes.map(o=>[o.id,o.width]));let s=0;for(const o of n){if(o.id===t)return s;const a=i.get(o.id)??mt,c=e.toPixels(Ee({x:a})).x??Dr;s+=c+ce}return null}customElements.get("layout-view")||customElements.define("layout-view",rO);class aO extends HTMLElement{constructor(){super(...arguments);m(this,"screenManager",Gt.resolve("ScreenManager"));m(this,"boundModel",null);m(this,"cardEls",new Map);m(this,"handleActiveScreenChanged",()=>{this.rebindModel(),this.render()});m(this,"handleModelChange",()=>{this.render()});m(this,"handleCloseArtifact",e=>{e instanceof Lb&&this.screenManager.activeScreen&&this.screenManager.activeScreen.removeArtifact(e.artifactID)});m(this,"handleScrollPositionChanged",e=>{const r=e;typeof r.scrollPosition=="number"&&Number.isFinite(r.scrollPosition)&&this.screenManager.activeScreen&&this.screenManager.activeScreen.setScrollPosition(r.scrollPosition)});m(this,"handleLayoutChanged",e=>{e instanceof Hb&&this.screenManager.activeScreen&&this.screenManager.activeScreen.setLayout(e.layout)});m(this,"handleServerEvent",e=>{const r=e.event;if(r.type!=="artifact-focus"||!this.boundModel||r.screenID!==this.boundModel.id)return;const i=this.querySelector("layout-view");i&&i.focusArtifact(r.artifactID)})}connectedCallback(){this.screenManager.addEventListener("active-screen-changed",this.handleActiveScreenChanged),this.rebindModel(),this.render()}disconnectedCallback(){this.screenManager.removeEventListener("active-screen-changed",this.handleActiveScreenChanged),this.unbindModel(),this.disposeCardElements()}rebindModel(){const e=this.screenManager.activeScreen;this.boundModel!==e&&(this.unbindModel(),this.boundModel=e,e&&(e.addEventListener("change",this.handleModelChange),e.server.addEventListener("server-event",this.handleServerEvent)))}unbindModel(){this.boundModel&&(this.boundModel.removeEventListener("change",this.handleModelChange),this.boundModel.server.removeEventListener("server-event",this.handleServerEvent),this.boundModel=null)}buildCards(e){if(!e)return this.disposeCardElements(),new Map;const r=new Map;for(const i of e.artifacts.values()){let s=this.cardEls.get(i.id);s||(s=document.createElement("artifact-view"),this.cardEls.set(i.id,s)),s.artifact=i,s.screen=e,s.viewURL=e.server.getViewURL(i),s.contentURL=e.server.getContentURL(i),r.set(i.id,s)}for(const[i,s]of this.cardEls)r.has(i)||(s.remove(),this.cardEls.delete(i));return r}disposeCardElements(){for(const e of this.cardEls.values())e.remove();this.cardEls.clear()}render(){const e=this.screenManager.activeScreen,r=(e==null?void 0:e.layout)??[],i=this.buildCards(e);if(r.length===0){Re(z``,this);return}Re(z`
|
|
234
|
+
<layout-view
|
|
235
|
+
.layout=${r}
|
|
236
|
+
.cards=${i}
|
|
237
|
+
.scrollPosition=${(e==null?void 0:e.scrollPosition)??0}
|
|
238
|
+
@scroll=${this.handleScrollPositionChanged}
|
|
239
|
+
@layout-change=${this.handleLayoutChanged}
|
|
240
|
+
@close-artifact=${this.handleCloseArtifact}
|
|
241
|
+
></layout-view>
|
|
242
|
+
`,this)}}customElements.define("screen-view",aO);function sl(n){return typeof n=="object"&&n!==null}const Yc=new WeakMap,Ig=Object.prototype.hasOwnProperty,lO=(()=>{const n=new Set;let t=HTMLElement.prototype;for(;t;){for(const e of Object.getOwnPropertyNames(t))n.add(e);if(t===Node.prototype)break;t=Object.getPrototypeOf(t)}return n})();function cO(n,t){if(sl(n))return t===null?void 0:n.parse(t);if(n===Boolean)return t!==null;if(t!==null)return n===Number?Number(t):t}function uO(n,t){return sl(n)?t==null?null:n.serialize(t):n===Boolean?t?"":null:t==null?null:String(t)}var vo,Ju,$r,ut,Wt,Ii,Tr,Ci,Se,hi,Wb,Zb,Bb,Vb,za;const ar=class ar extends HTMLElement{constructor(){var i;super();w(this,Se);w(this,$r,new Map);w(this,ut,new Map);w(this,Wt,new Map);w(this,Ii,!1);w(this,Tr,!1);w(this,Ci,!1);const e=f(i=ar,vo,Ju).call(i,this.constructor),r=this;for(const s of e.properties)Ig.call(r,s)&&(l(this,Wt).set(s,r[s]),delete r[s])}static get observedAttributes(){var e;return f(e=ar,vo,Ju).call(e,this).observedAttributes}connected(){}disconnected(){}changed(e){}connectedCallback(){if(f(this,Se,Vb).call(this),!l(this,Tr))for(const e of f(this,Se,hi).call(this).properties)l(this,ut).has(e)||l(this,ut).set(e,void 0);this.dispatchEvent(new Event("reactive:connect")),this.connected(),f(this,Se,za).call(this)}disconnectedCallback(){this.dispatchEvent(new Event("reactive:disconnect")),this.disconnected()}attributeChangedCallback(e,r,i){if(r===i)return;const s=f(this,Se,hi).call(this).byAttr.get(e);s&&(l(this,Wt).has(s.property)||(this[s.property]=cO(s.type,i)))}};vo=new WeakSet,Ju=function(e){const r=Yc.get(e);if(r)return r;const i=[...e.properties??[]],s=e.attributes??{},o=new Map,a=new Map;for(const u of i)if(lO.has(u))throw new Error(`Reactive property "${u}" collides with a built-in DOM property. Rename it to avoid shadowing the platform API.`);for(const[u,h]of Object.entries(s)){if(u.includes("-")&&h.property===void 0)throw new Error(`Attribute "${u}" must declare a "property" name because kebab-case cannot be a property.`);const p=h.property??u;if(!i.includes(p))throw new Error(`Attribute '${u}' references property '${p}', which isn't declared in \`static properties\`. Add it to \`properties\` to make it reactive.`);if(sl(h.type)){if(typeof h.type.parse!="function")throw new Error(`Attribute "${u}" custom coercer is missing a \`parse\` function.`);if(typeof h.type.serialize!="function")throw new Error(`Attribute "${u}" custom coercer is missing a \`serialize\` function.`)}const v={attribute:u,property:p,type:h.type};o.set(u,v),a.set(p,v)}for(const u of i){const h=Object.getOwnPropertyDescriptor(e.prototype,u);if((h==null?void 0:h.get)!==void 0||(h==null?void 0:h.set)!==void 0)throw new Error(`Observed property "${u}" cannot define a custom getter/setter. Use changed() for side effects instead.`);h===void 0&&Object.defineProperty(e.prototype,u,{configurable:!0,enumerable:!0,get(){return l(this,$r).get(u)},set(p){f(this,Se,Wb).call(this,u,p)}})}const c={properties:i,observedAttributes:Object.keys(s),byAttr:o,byProp:a};return Yc.set(e,c),c},$r=new WeakMap,ut=new WeakMap,Wt=new WeakMap,Ii=new WeakMap,Tr=new WeakMap,Ci=new WeakMap,Se=new WeakSet,hi=function(){return Yc.get(this.constructor)},Wb=function(e,r){if(!l(this,Ci)&&l(this,Wt).has(e))return;const i=l(this,$r).get(e);f(this,Se,Zb).call(this,e,i,r)||(l(this,ut).has(e)||l(this,ut).set(e,i),l(this,$r).set(e,r),l(this,Wt).delete(e),f(this,Se,Bb).call(this,e,r),this.isConnected&&f(this,Se,za).call(this))},Zb=function(e,r,i){if(Object.is(r,i))return!0;const s=f(this,Se,hi).call(this).byProp.get(e);if(!s||!sl(s.type))return!1;const o=r==null,a=i==null;if(o||a)return o&&a;try{return s.type.serialize(r)===s.type.serialize(i)}catch{return!1}},Bb=function(e,r){const i=f(this,Se,hi).call(this).byProp.get(e);if(!i)return;const{attribute:s,type:o}=i;if(o===Boolean){const c=this.hasAttribute(s);r&&!c?this.setAttribute(s,""):!r&&c&&this.removeAttribute(s);return}const a=uO(o,r);if(a===null){this.hasAttribute(s)&&this.removeAttribute(s);return}this.getAttribute(s)!==a&&this.setAttribute(s,a)},Vb=function(){const e=this,r=f(this,Se,hi).call(this);for(const i of r.properties){if(!Ig.call(e,i))continue;const s=e[i];delete e[i],!(l(this,Wt).has(i)||l(this,$r).has(i))&&(e[i]=s)}S(this,Ci,!0);try{for(const[i,s]of l(this,Wt))e[i]=s;l(this,Wt).clear()}finally{S(this,Ci,!1)}},za=function(){l(this,Ii)||!this.isConnected||l(this,Tr)&&l(this,ut).size===0||(S(this,Ii,!0),queueMicrotask(()=>{if(S(this,Ii,!1),!this.isConnected||l(this,Tr)&&l(this,ut).size===0)return;const e=new Map(l(this,ut));l(this,ut).clear(),S(this,Tr,!0);try{this.changed(e)}catch(r){console.error(r)}this.isConnected&&l(this,ut).size>0&&f(this,Se,za).call(this)}))},w(ar,vo),m(ar,"properties"),m(ar,"attributes");let Hi=ar;var pe,cn,Pn,Ri,Pi,un,yo,xe,Di,Zt,Z,jb,bo,wo,So,_o,Qu,eh,th,Gb,qb,Yb,Xb,gl,ml,vl,yl,nh,Kb,Oa,bl,Ma,wl,Jb,Qb,ew,tw,nw,at;class hO extends Hi{constructor(){super(...arguments);w(this,Z);w(this,pe,Gt.resolve("ScreenManager"));w(this,cn,Gt.resolve("ServerManager"));w(this,Pn,null);w(this,Ri,new DisposableStack);w(this,Pi,Ca());w(this,un,Ca());w(this,yo,Ca());w(this,xe,{kind:"none"});w(this,Di,!1);w(this,Zt,[]);w(this,bo,()=>{f(this,Z,Qu).call(this),S(this,xe,{kind:"none"}),l(this,at).call(this)});w(this,wo,()=>{l(this,at).call(this)});w(this,So,()=>{l(this,at).call(this)});w(this,_o,()=>{l(this,at).call(this)});w(this,gl,()=>{var i,s;if(l(this,xe).kind==="picker"){f(this,Z,Ma).call(this);return}S(this,Zt,f(this,Z,Kb).call(this));const e=((i=l(this,pe).activeScreen)==null?void 0:i.id)??null,r=e&&l(this,Zt).some(o=>o.screenID===e)?e:((s=l(this,Zt)[0])==null?void 0:s.screenID)??null;S(this,xe,{kind:"picker",filter:"",highlightedID:r}),l(this,at).call(this),queueMicrotask(()=>{var o;(o=l(this,yo).value)==null||o.focus()})});w(this,ml,e=>{var u;const r=l(this,xe);if(r.kind!=="picker")return;const i=e.target;if(!(i instanceof HTMLInputElement))return;const s=i.value,o=f(this,Z,Oa).call(this,l(this,Zt),s),c=r.highlightedID!==null&&o.some(h=>h.screenID===r.highlightedID)?r.highlightedID:((u=o[0])==null?void 0:u.screenID)??null;S(this,xe,{kind:"picker",filter:s,highlightedID:c}),l(this,at).call(this)});w(this,vl,e=>{var s;const r=l(this,xe);if(r.kind!=="picker")return;if(e.key==="Escape"){e.preventDefault(),f(this,Z,Ma).call(this),(s=l(this,Pi).value)==null||s.focus();return}const i=f(this,Z,Oa).call(this,l(this,Zt),r.filter);if(e.key==="ArrowDown"||e.key==="ArrowUp"){if(e.preventDefault(),i.length===0)return;const o=i.findIndex(u=>u.screenID===r.highlightedID),a=e.key==="ArrowDown"?1:-1,c=o<0?0:Math.max(0,Math.min(i.length-1,o+a));S(this,xe,{kind:"picker",filter:r.filter,highlightedID:i[c].screenID}),l(this,at).call(this);return}if(e.key==="Enter"){e.preventDefault();const o=i.find(a=>a.screenID===r.highlightedID);o&&f(this,Z,nh).call(this,o)}});w(this,yl,e=>{f(this,Z,nh).call(this,e)});w(this,bl,e=>{l(this,xe).kind==="picker"&&e.target===l(this,un).value&&(S(this,xe,{kind:"none"}),l(this,at).call(this))});w(this,wl,async()=>{if(l(this,Di))return;const e=f(this,Z,Jb).call(this);if(e){S(this,Di,!0);try{const r=await e.createScreen(dO(new Date));l(this,pe).addTab(e.url,r.id),l(this,pe).setActive(e.url,r.id)}catch{}finally{S(this,Di,!1)}}});w(this,at,()=>{const e=f(this,Z,Yb).call(this);Re(z`
|
|
243
|
+
${f(this,Z,Qb).call(this)}
|
|
244
|
+
<div class="pills" role="group" aria-label="Open tabs">
|
|
245
|
+
${e.map(r=>f(this,Z,ew).call(this,r))}
|
|
246
|
+
</div>
|
|
247
|
+
${f(this,Z,tw).call(this)}
|
|
248
|
+
`,this),l(this,un).value&&(l(this,un).value.anchor=l(this,Pi).value??null)})}connected(){l(this,pe).addEventListener("active-screen-changed",l(this,bo)),l(this,pe).addEventListener("tabs-changed",l(this,wo)),l(this,cn).addEventListener("screens-changed",l(this,So)),f(this,Z,Qu).call(this),l(this,at).call(this),f(this,Z,jb).call(this),l(this,Ri).defer(()=>{l(this,pe).removeEventListener("active-screen-changed",l(this,bo)),l(this,pe).removeEventListener("tabs-changed",l(this,wo)),l(this,cn).removeEventListener("screens-changed",l(this,So)),f(this,Z,eh).call(this)})}disconnected(){l(this,Ri).dispose(),S(this,Ri,new DisposableStack)}}pe=new WeakMap,cn=new WeakMap,Pn=new WeakMap,Ri=new WeakMap,Pi=new WeakMap,un=new WeakMap,yo=new WeakMap,xe=new WeakMap,Di=new WeakMap,Zt=new WeakMap,Z=new WeakSet,jb=async function(){const e=await Ym(this);this.setAttribute("tone",e)},bo=new WeakMap,wo=new WeakMap,So=new WeakMap,_o=new WeakMap,Qu=function(){var r;const e=l(this,pe).activeScreen;l(this,Pn)!==e&&(f(this,Z,eh).call(this),S(this,Pn,e),(r=l(this,Pn))==null||r.addEventListener("change",l(this,_o)))},eh=function(){var e;(e=l(this,Pn))==null||e.removeEventListener("change",l(this,_o)),S(this,Pn,null)},th=function(e,r){l(this,pe).setActive(e,r)},Gb=function(e,r,i){i.stopPropagation();const s=l(this,pe).getTabs(e),o=f(this,Z,Xb).call(this,s,r),a=l(this,pe).activeScreen,c=(a==null?void 0:a.id)===r&&a.server.url===e;l(this,pe).removeTab(e,r),c&&(o?l(this,pe).setActive(e,o):l(this,pe).clearActive())},qb=function(e,r,i){const s=l(this,pe).activeScreen;if((s==null?void 0:s.id)===r){s.rename(i.value);return}const o=l(this,cn).servers.get(e),a=o==null?void 0:o.screens.get(r);!o||!a||o.client.screens.update({screenID:r,name:i.value}).catch(()=>{})},Yb=function(){const e=l(this,pe).activeScreen,r=[];for(const i of l(this,cn).servers.values())for(const s of l(this,pe).getTabs(i.url)){const o=i.screens.get(s);o&&r.push({serverURL:i.url,screenID:o.id,name:o.name,isActive:(e==null?void 0:e.id)===o.id&&e.server.url===i.url})}return r},Xb=function(e,r){const i=e.indexOf(r);if(i<0)return null;const s=e.filter(a=>a!==r);if(s.length===0)return null;const o=Math.max(0,i-1);return s[o]??null},gl=new WeakMap,ml=new WeakMap,vl=new WeakMap,yl=new WeakMap,nh=function(e){l(this,pe).addTab(e.serverURL,e.screenID),l(this,pe).setActive(e.serverURL,e.screenID),f(this,Z,Ma).call(this)},Kb=function(){const e=[];for(const r of l(this,cn).servers.values())for(const i of r.screens.values())e.push({serverURL:r.url,screenID:i.id,name:i.name});return e},Oa=function(e,r){const i=r.trim().toLowerCase();return i.length===0?e:e.filter(s=>s.name.toLowerCase().includes(i))},bl=new WeakMap,Ma=function(){l(this,xe).kind==="picker"&&(l(this,un).value&&(l(this,un).value.open=!1),S(this,xe,{kind:"none"}),l(this,at).call(this))},wl=new WeakMap,Jb=function(){for(const e of l(this,cn).servers.values())return e;return null},Qb=function(){return z`
|
|
249
|
+
<segmented-control variant="glass" role="group" aria-label="Screens">
|
|
250
|
+
<button
|
|
251
|
+
type="button"
|
|
252
|
+
?icon-only=${!0}
|
|
253
|
+
aria-label="Choose screen"
|
|
254
|
+
@click=${l(this,gl)}
|
|
255
|
+
${Ra(l(this,Pi))}
|
|
256
|
+
>
|
|
257
|
+
${Rz({size:16,weight:"regular"})}
|
|
258
|
+
</button>
|
|
259
|
+
<button
|
|
260
|
+
type="button"
|
|
261
|
+
?icon-only=${!0}
|
|
262
|
+
aria-label="New screen"
|
|
263
|
+
@click=${l(this,wl)}
|
|
264
|
+
>
|
|
265
|
+
${Pz({size:16,weight:"regular"})}
|
|
266
|
+
</button>
|
|
267
|
+
</segmented-control>
|
|
268
|
+
`},ew=function(e){return z`
|
|
269
|
+
<span class="tab" ?data-active=${e.isActive}>
|
|
270
|
+
<button
|
|
271
|
+
type="button"
|
|
272
|
+
variant="glass"
|
|
273
|
+
class="screen-name tab-body"
|
|
274
|
+
aria-pressed=${e.isActive?"true":"false"}
|
|
275
|
+
aria-current=${e.isActive?"page":ae}
|
|
276
|
+
aria-label=${e.isActive?`Current tab: ${e.name}`:`Switch to ${e.name}`}
|
|
277
|
+
@mousedown=${r=>{r.button===0&&f(this,Z,th).call(this,e.serverURL,e.screenID)}}
|
|
278
|
+
@click=${()=>f(this,Z,th).call(this,e.serverURL,e.screenID)}
|
|
279
|
+
>
|
|
280
|
+
<span class="tab-leading">
|
|
281
|
+
${Cz({weight:"bold"})}
|
|
282
|
+
</span>
|
|
283
|
+
<editable-text
|
|
284
|
+
class="tab-name"
|
|
285
|
+
.value=${e.name}
|
|
286
|
+
@rename=${r=>f(this,Z,qb).call(this,e.serverURL,e.screenID,r)}
|
|
287
|
+
></editable-text>
|
|
288
|
+
</button>
|
|
289
|
+
<button
|
|
290
|
+
type="button"
|
|
291
|
+
variant="ghost"
|
|
292
|
+
size="xs"
|
|
293
|
+
icon-only
|
|
294
|
+
class="tab-close"
|
|
295
|
+
aria-label=${`Close ${e.name}`}
|
|
296
|
+
@click=${r=>f(this,Z,Gb).call(this,e.serverURL,e.screenID,r)}
|
|
297
|
+
>
|
|
298
|
+
${ad({weight:"bold"})}
|
|
299
|
+
</button>
|
|
300
|
+
</span>
|
|
301
|
+
`},tw=function(){var o;const e=l(this,xe).kind==="picker"?l(this,xe).filter:"",r=l(this,xe).kind==="picker"?l(this,xe).highlightedID:null,i=((o=l(this,pe).activeScreen)==null?void 0:o.id)??null,s=f(this,Z,Oa).call(this,l(this,Zt),e);return z`
|
|
302
|
+
<ui-popover
|
|
303
|
+
class="picker-popover"
|
|
304
|
+
material="glass-frosted"
|
|
305
|
+
?open=${l(this,xe).kind==="picker"}
|
|
306
|
+
@close=${l(this,bl)}
|
|
307
|
+
@keydown=${l(this,vl)}
|
|
308
|
+
${Ra(l(this,un))}
|
|
309
|
+
>
|
|
310
|
+
<div class="picker">
|
|
311
|
+
<input
|
|
312
|
+
type="text"
|
|
313
|
+
class="picker-filter"
|
|
314
|
+
placeholder="Filter screens"
|
|
315
|
+
aria-label="Filter screens"
|
|
316
|
+
.value=${e}
|
|
317
|
+
@input=${l(this,ml)}
|
|
318
|
+
${Ra(l(this,yo))}
|
|
319
|
+
/>
|
|
320
|
+
${s.length===0?z`<p class="picker-empty">
|
|
321
|
+
${l(this,Zt).length===0?"No screens":"No matches"}
|
|
322
|
+
</p>`:f(this,Z,nw).call(this,s,r,i)}
|
|
323
|
+
</div>
|
|
324
|
+
</ui-popover>
|
|
325
|
+
`},nw=function(e,r,i){return z`
|
|
326
|
+
<ul class="picker-list" role="listbox">
|
|
327
|
+
<li class="picker-section-label" role="presentation">Recent</li>
|
|
328
|
+
${e.map(s=>{const o=s.screenID===i;return z`
|
|
329
|
+
<li
|
|
330
|
+
class="picker-row"
|
|
331
|
+
role="option"
|
|
332
|
+
aria-selected=${s.screenID===r}
|
|
333
|
+
aria-current=${o?"true":ae}
|
|
334
|
+
?data-highlighted=${s.screenID===r}
|
|
335
|
+
?data-active=${o}
|
|
336
|
+
@click=${()=>l(this,yl).call(this,s)}
|
|
337
|
+
>
|
|
338
|
+
<span class="picker-name">${s.name}</span>
|
|
339
|
+
</li>
|
|
340
|
+
`})}
|
|
341
|
+
</ul>
|
|
342
|
+
`},at=new WeakMap;customElements.define("screen-select",hO);function dO(n){const t=n.toLocaleDateString("en-US",{month:"long",day:"numeric",year:"numeric"}),e=12,r=n.getHours(),i=r%e===0?e:r%e,s=n.getMinutes().toString().padStart(2,"0"),o=r>=e?"pm":"am";return`${t} at ${i}:${s}${o}`}const Xc=6e4;var Dn,Ir,Li,Na;class pO extends HTMLElement{constructor(){super(...arguments);w(this,Li);w(this,Dn,null);w(this,Ir,null)}connectedCallback(){this.hasAttribute("material")||this.setAttribute("material","glass"),f(this,Li,Na).call(this);const e=Xc-Date.now()%Xc;S(this,Dn,window.setTimeout(()=>{S(this,Dn,null),f(this,Li,Na).call(this),S(this,Ir,window.setInterval(()=>f(this,Li,Na).call(this),Xc))},e))}disconnectedCallback(){l(this,Dn)!==null&&clearTimeout(l(this,Dn)),l(this,Ir)!==null&&clearInterval(l(this,Ir)),S(this,Dn,null),S(this,Ir,null)}}Dn=new WeakMap,Ir=new WeakMap,Li=new WeakSet,Na=function(){const e=new Date,r=new Intl.DateTimeFormat(void 0,{weekday:"short",month:"short",day:"numeric"}).format(e),i=new Intl.DateTimeFormat(void 0,{hour:"numeric",minute:"2-digit"}).format(e);Re(z`<span class="date">${r}</span><span class="time">${i}</span>`,this)};customElements.get("menu-bar-clock")||customElements.define("menu-bar-clock",pO);function fO(n,t){let e=null;const r=()=>t((e==null?void 0:e.messages)??[]),i=()=>{var a;const o=((a=n.activeServer)==null?void 0:a.acpClient)??null;o!==e&&(e==null||e.removeEventListener("change",r),e=o,e&&(e.addEventListener("change",r),e.enabled&&e.connect().catch(c=>{console.error("ACPClient.connect() failed",c)})),r())};n.addEventListener("change",i),i();const s=()=>{n.removeEventListener("change",i),e==null||e.removeEventListener("change",r),e=null};return{dispose:s,[Symbol.dispose](){s()}}}/*! @license DOMPurify 3.3.3 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.3.3/LICENSE */const{entries:rw,setPrototypeOf:Cg,isFrozen:gO,getPrototypeOf:mO,getOwnPropertyDescriptor:vO}=Object;let{freeze:qe,seal:vt,create:Ua}=Object,{apply:rh,construct:ih}=typeof Reflect<"u"&&Reflect;qe||(qe=function(t){return t});vt||(vt=function(t){return t});rh||(rh=function(t,e){for(var r=arguments.length,i=new Array(r>2?r-2:0),s=2;s<r;s++)i[s-2]=arguments[s];return t.apply(e,i)});ih||(ih=function(t){for(var e=arguments.length,r=new Array(e>1?e-1:0),i=1;i<e;i++)r[i-1]=arguments[i];return new t(...r)});const pa=Ye(Array.prototype.forEach),yO=Ye(Array.prototype.lastIndexOf),Rg=Ye(Array.prototype.pop),ls=Ye(Array.prototype.push),bO=Ye(Array.prototype.splice),Fa=Ye(String.prototype.toLowerCase),Kc=Ye(String.prototype.toString),Jc=Ye(String.prototype.match),cs=Ye(String.prototype.replace),wO=Ye(String.prototype.indexOf),SO=Ye(String.prototype.trim),ot=Ye(Object.prototype.hasOwnProperty),He=Ye(RegExp.prototype.test),us=_O(TypeError);function Ye(n){return function(t){t instanceof RegExp&&(t.lastIndex=0);for(var e=arguments.length,r=new Array(e>1?e-1:0),i=1;i<e;i++)r[i-1]=arguments[i];return rh(n,t,r)}}function _O(n){return function(){for(var t=arguments.length,e=new Array(t),r=0;r<t;r++)e[r]=arguments[r];return ih(n,e)}}function G(n,t){let e=arguments.length>2&&arguments[2]!==void 0?arguments[2]:Fa;Cg&&Cg(n,null);let r=t.length;for(;r--;){let i=t[r];if(typeof i=="string"){const s=e(i);s!==i&&(gO(t)||(t[r]=s),i=s)}n[i]=!0}return n}function kO(n){for(let t=0;t<n.length;t++)ot(n,t)||(n[t]=null);return n}function Lt(n){const t=Ua(null);for(const[e,r]of rw(n))ot(n,e)&&(Array.isArray(r)?t[e]=kO(r):r&&typeof r=="object"&&r.constructor===Object?t[e]=Lt(r):t[e]=r);return t}function hs(n,t){for(;n!==null;){const r=vO(n,t);if(r){if(r.get)return Ye(r.get);if(typeof r.value=="function")return Ye(r.value)}n=mO(n)}function e(){return null}return e}const Pg=qe(["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"]),Qc=qe(["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"]),eu=qe(["feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence"]),xO=qe(["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"]),tu=qe(["math","menclose","merror","mfenced","mfrac","mglyph","mi","mlabeledtr","mmultiscripts","mn","mo","mover","mpadded","mphantom","mroot","mrow","ms","mspace","msqrt","mstyle","msub","msup","msubsup","mtable","mtd","mtext","mtr","munder","munderover","mprescripts"]),EO=qe(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),Dg=qe(["#text"]),Lg=qe(["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"]),nu=qe(["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"]),zg=qe(["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"]),fa=qe(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),AO=vt(/\{\{[\w\W]*|[\w\W]*\}\}/gm),$O=vt(/<%[\w\W]*|[\w\W]*%>/gm),TO=vt(/\$\{[\w\W]*/gm),IO=vt(/^data-[\-\w.\u00B7-\uFFFF]+$/),CO=vt(/^aria-[\-\w]+$/),iw=vt(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),RO=vt(/^(?:\w+script|data):/i),PO=vt(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),sw=vt(/^html$/i),DO=vt(/^[a-z][.\w]*(-[.\w]+)+$/i);var Og=Object.freeze({__proto__:null,ARIA_ATTR:CO,ATTR_WHITESPACE:PO,CUSTOM_ELEMENT:DO,DATA_ATTR:IO,DOCTYPE_NAME:sw,ERB_EXPR:$O,IS_ALLOWED_URI:iw,IS_SCRIPT_OR_DATA:RO,MUSTACHE_EXPR:AO,TMPLIT_EXPR:TO});const ds={element:1,text:3,progressingInstruction:7,comment:8,document:9},LO=function(){return typeof window>"u"?null:window},zO=function(t,e){if(typeof t!="object"||typeof t.createPolicy!="function")return null;let r=null;const i="data-tt-policy-suffix";e&&e.hasAttribute(i)&&(r=e.getAttribute(i));const s="dompurify"+(r?"#"+r:"");try{return t.createPolicy(s,{createHTML(o){return o},createScriptURL(o){return o}})}catch{return console.warn("TrustedTypes policy "+s+" could not be created."),null}},Mg=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}};function ow(){let n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:LO();const t=U=>ow(U);if(t.version="3.3.3",t.removed=[],!n||!n.document||n.document.nodeType!==ds.document||!n.Element)return t.isSupported=!1,t;let{document:e}=n;const r=e,i=r.currentScript,{DocumentFragment:s,HTMLTemplateElement:o,Node:a,Element:c,NodeFilter:u,NamedNodeMap:h=n.NamedNodeMap||n.MozNamedAttrMap,HTMLFormElement:p,DOMParser:v,trustedTypes:g}=n,_=c.prototype,k=hs(_,"cloneNode"),T=hs(_,"remove"),P=hs(_,"nextSibling"),R=hs(_,"childNodes"),W=hs(_,"parentNode");if(typeof o=="function"){const U=e.createElement("template");U.content&&U.content.ownerDocument&&(e=U.content.ownerDocument)}let N,F="";const{implementation:Y,createNodeIterator:j,createDocumentFragment:le,getElementsByTagName:St}=e,{importNode:qn}=r;let Pe=Mg();t.isSupported=typeof rw=="function"&&typeof W=="function"&&Y&&Y.createHTMLDocument!==void 0;const{MUSTACHE_EXPR:Yn,ERB_EXPR:It,TMPLIT_EXPR:yn,DATA_ATTR:Gl,ARIA_ATTR:Wo,IS_SCRIPT_OR_DATA:$w,ATTR_WHITESPACE:Sd,CUSTOM_ELEMENT:Tw}=Og;let{IS_ALLOWED_URI:_d}=Og,Te=null;const kd=G({},[...Pg,...Qc,...eu,...tu,...Dg]);let De=null;const xd=G({},[...Lg,...nu,...zg,...fa]);let ye=Object.seal(Ua(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}})),es=null,Zo=null;const bn=Object.seal(Ua(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let Ed=!0,ql=!0,Ad=!1,$d=!0,Br=!1,Bo=!0,Xn=!1,Yl=!1,Xl=!1,Vr=!1,Vo=!1,jo=!1,Td=!0,Id=!1;const Iw="user-content-";let Kl=!0,ts=!1,jr={},Ct=null;const Jl=G({},["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 Cd=null;const Rd=G({},["audio","video","img","source","image","track"]);let Ql=null;const Pd=G({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),Go="http://www.w3.org/1998/Math/MathML",qo="http://www.w3.org/2000/svg",Yt="http://www.w3.org/1999/xhtml";let Gr=Yt,ec=!1,tc=null;const Cw=G({},[Go,qo,Yt],Kc);let Yo=G({},["mi","mo","mn","ms","mtext"]),Xo=G({},["annotation-xml"]);const Rw=G({},["title","style","font","a","script"]);let ns=null;const Pw=["application/xhtml+xml","text/html"],Dw="text/html";let ke=null,qr=null;const Lw=e.createElement("form"),Dd=function(b){return b instanceof RegExp||b instanceof Function},nc=function(){let b=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(!(qr&&qr===b)){if((!b||typeof b!="object")&&(b={}),b=Lt(b),ns=Pw.indexOf(b.PARSER_MEDIA_TYPE)===-1?Dw:b.PARSER_MEDIA_TYPE,ke=ns==="application/xhtml+xml"?Kc:Fa,Te=ot(b,"ALLOWED_TAGS")?G({},b.ALLOWED_TAGS,ke):kd,De=ot(b,"ALLOWED_ATTR")?G({},b.ALLOWED_ATTR,ke):xd,tc=ot(b,"ALLOWED_NAMESPACES")?G({},b.ALLOWED_NAMESPACES,Kc):Cw,Ql=ot(b,"ADD_URI_SAFE_ATTR")?G(Lt(Pd),b.ADD_URI_SAFE_ATTR,ke):Pd,Cd=ot(b,"ADD_DATA_URI_TAGS")?G(Lt(Rd),b.ADD_DATA_URI_TAGS,ke):Rd,Ct=ot(b,"FORBID_CONTENTS")?G({},b.FORBID_CONTENTS,ke):Jl,es=ot(b,"FORBID_TAGS")?G({},b.FORBID_TAGS,ke):Lt({}),Zo=ot(b,"FORBID_ATTR")?G({},b.FORBID_ATTR,ke):Lt({}),jr=ot(b,"USE_PROFILES")?b.USE_PROFILES:!1,Ed=b.ALLOW_ARIA_ATTR!==!1,ql=b.ALLOW_DATA_ATTR!==!1,Ad=b.ALLOW_UNKNOWN_PROTOCOLS||!1,$d=b.ALLOW_SELF_CLOSE_IN_ATTR!==!1,Br=b.SAFE_FOR_TEMPLATES||!1,Bo=b.SAFE_FOR_XML!==!1,Xn=b.WHOLE_DOCUMENT||!1,Vr=b.RETURN_DOM||!1,Vo=b.RETURN_DOM_FRAGMENT||!1,jo=b.RETURN_TRUSTED_TYPE||!1,Xl=b.FORCE_BODY||!1,Td=b.SANITIZE_DOM!==!1,Id=b.SANITIZE_NAMED_PROPS||!1,Kl=b.KEEP_CONTENT!==!1,ts=b.IN_PLACE||!1,_d=b.ALLOWED_URI_REGEXP||iw,Gr=b.NAMESPACE||Yt,Yo=b.MATHML_TEXT_INTEGRATION_POINTS||Yo,Xo=b.HTML_INTEGRATION_POINTS||Xo,ye=b.CUSTOM_ELEMENT_HANDLING||{},b.CUSTOM_ELEMENT_HANDLING&&Dd(b.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(ye.tagNameCheck=b.CUSTOM_ELEMENT_HANDLING.tagNameCheck),b.CUSTOM_ELEMENT_HANDLING&&Dd(b.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(ye.attributeNameCheck=b.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),b.CUSTOM_ELEMENT_HANDLING&&typeof b.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements=="boolean"&&(ye.allowCustomizedBuiltInElements=b.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),Br&&(ql=!1),Vo&&(Vr=!0),jr&&(Te=G({},Dg),De=Ua(null),jr.html===!0&&(G(Te,Pg),G(De,Lg)),jr.svg===!0&&(G(Te,Qc),G(De,nu),G(De,fa)),jr.svgFilters===!0&&(G(Te,eu),G(De,nu),G(De,fa)),jr.mathMl===!0&&(G(Te,tu),G(De,zg),G(De,fa))),ot(b,"ADD_TAGS")||(bn.tagCheck=null),ot(b,"ADD_ATTR")||(bn.attributeCheck=null),b.ADD_TAGS&&(typeof b.ADD_TAGS=="function"?bn.tagCheck=b.ADD_TAGS:(Te===kd&&(Te=Lt(Te)),G(Te,b.ADD_TAGS,ke))),b.ADD_ATTR&&(typeof b.ADD_ATTR=="function"?bn.attributeCheck=b.ADD_ATTR:(De===xd&&(De=Lt(De)),G(De,b.ADD_ATTR,ke))),b.ADD_URI_SAFE_ATTR&&G(Ql,b.ADD_URI_SAFE_ATTR,ke),b.FORBID_CONTENTS&&(Ct===Jl&&(Ct=Lt(Ct)),G(Ct,b.FORBID_CONTENTS,ke)),b.ADD_FORBID_CONTENTS&&(Ct===Jl&&(Ct=Lt(Ct)),G(Ct,b.ADD_FORBID_CONTENTS,ke)),Kl&&(Te["#text"]=!0),Xn&&G(Te,["html","head","body"]),Te.table&&(G(Te,["tbody"]),delete es.tbody),b.TRUSTED_TYPES_POLICY){if(typeof b.TRUSTED_TYPES_POLICY.createHTML!="function")throw us('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof b.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw us('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');N=b.TRUSTED_TYPES_POLICY,F=N.createHTML("")}else N===void 0&&(N=zO(g,i)),N!==null&&typeof F=="string"&&(F=N.createHTML(""));qe&&qe(b),qr=b}},Ld=G({},[...Qc,...eu,...xO]),zd=G({},[...tu,...EO]),zw=function(b){let C=W(b);(!C||!C.tagName)&&(C={namespaceURI:Gr,tagName:"template"});const D=Fa(b.tagName),ue=Fa(C.tagName);return tc[b.namespaceURI]?b.namespaceURI===qo?C.namespaceURI===Yt?D==="svg":C.namespaceURI===Go?D==="svg"&&(ue==="annotation-xml"||Yo[ue]):!!Ld[D]:b.namespaceURI===Go?C.namespaceURI===Yt?D==="math":C.namespaceURI===qo?D==="math"&&Xo[ue]:!!zd[D]:b.namespaceURI===Yt?C.namespaceURI===qo&&!Xo[ue]||C.namespaceURI===Go&&!Yo[ue]?!1:!zd[D]&&(Rw[D]||!Ld[D]):!!(ns==="application/xhtml+xml"&&tc[b.namespaceURI]):!1},Rt=function(b){ls(t.removed,{element:b});try{W(b).removeChild(b)}catch{T(b)}},Kn=function(b,C){try{ls(t.removed,{attribute:C.getAttributeNode(b),from:C})}catch{ls(t.removed,{attribute:null,from:C})}if(C.removeAttribute(b),b==="is")if(Vr||Vo)try{Rt(C)}catch{}else try{C.setAttribute(b,"")}catch{}},Od=function(b){let C=null,D=null;if(Xl)b="<remove></remove>"+b;else{const be=Jc(b,/^[\r\n\t ]+/);D=be&&be[0]}ns==="application/xhtml+xml"&&Gr===Yt&&(b='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+b+"</body></html>");const ue=N?N.createHTML(b):b;if(Gr===Yt)try{C=new v().parseFromString(ue,ns)}catch{}if(!C||!C.documentElement){C=Y.createDocument(Gr,"template",null);try{C.documentElement.innerHTML=ec?F:ue}catch{}}const Ue=C.body||C.documentElement;return b&&D&&Ue.insertBefore(e.createTextNode(D),Ue.childNodes[0]||null),Gr===Yt?St.call(C,Xn?"html":"body")[0]:Xn?C.documentElement:Ue},Md=function(b){return j.call(b.ownerDocument||b,b,u.SHOW_ELEMENT|u.SHOW_COMMENT|u.SHOW_TEXT|u.SHOW_PROCESSING_INSTRUCTION|u.SHOW_CDATA_SECTION,null)},rc=function(b){return b instanceof p&&(typeof b.nodeName!="string"||typeof b.textContent!="string"||typeof b.removeChild!="function"||!(b.attributes instanceof h)||typeof b.removeAttribute!="function"||typeof b.setAttribute!="function"||typeof b.namespaceURI!="string"||typeof b.insertBefore!="function"||typeof b.hasChildNodes!="function")},Nd=function(b){return typeof a=="function"&&b instanceof a};function Xt(U,b,C){pa(U,D=>{D.call(t,b,C,qr)})}const Ud=function(b){let C=null;if(Xt(Pe.beforeSanitizeElements,b,null),rc(b))return Rt(b),!0;const D=ke(b.nodeName);if(Xt(Pe.uponSanitizeElement,b,{tagName:D,allowedTags:Te}),Bo&&b.hasChildNodes()&&!Nd(b.firstElementChild)&&He(/<[/\w!]/g,b.innerHTML)&&He(/<[/\w!]/g,b.textContent)||b.nodeType===ds.progressingInstruction||Bo&&b.nodeType===ds.comment&&He(/<[/\w]/g,b.data))return Rt(b),!0;if(!(bn.tagCheck instanceof Function&&bn.tagCheck(D))&&(!Te[D]||es[D])){if(!es[D]&&Hd(D)&&(ye.tagNameCheck instanceof RegExp&&He(ye.tagNameCheck,D)||ye.tagNameCheck instanceof Function&&ye.tagNameCheck(D)))return!1;if(Kl&&!Ct[D]){const ue=W(b)||b.parentNode,Ue=R(b)||b.childNodes;if(Ue&&ue){const be=Ue.length;for(let Xe=be-1;Xe>=0;--Xe){const Kt=k(Ue[Xe],!0);Kt.__removalCount=(b.__removalCount||0)+1,ue.insertBefore(Kt,P(b))}}}return Rt(b),!0}return b instanceof c&&!zw(b)||(D==="noscript"||D==="noembed"||D==="noframes")&&He(/<\/no(script|embed|frames)/i,b.innerHTML)?(Rt(b),!0):(Br&&b.nodeType===ds.text&&(C=b.textContent,pa([Yn,It,yn],ue=>{C=cs(C,ue," ")}),b.textContent!==C&&(ls(t.removed,{element:b.cloneNode()}),b.textContent=C)),Xt(Pe.afterSanitizeElements,b,null),!1)},Fd=function(b,C,D){if(Zo[C]||Td&&(C==="id"||C==="name")&&(D in e||D in Lw))return!1;if(!(ql&&!Zo[C]&&He(Gl,C))){if(!(Ed&&He(Wo,C))){if(!(bn.attributeCheck instanceof Function&&bn.attributeCheck(C,b))){if(!De[C]||Zo[C]){if(!(Hd(b)&&(ye.tagNameCheck instanceof RegExp&&He(ye.tagNameCheck,b)||ye.tagNameCheck instanceof Function&&ye.tagNameCheck(b))&&(ye.attributeNameCheck instanceof RegExp&&He(ye.attributeNameCheck,C)||ye.attributeNameCheck instanceof Function&&ye.attributeNameCheck(C,b))||C==="is"&&ye.allowCustomizedBuiltInElements&&(ye.tagNameCheck instanceof RegExp&&He(ye.tagNameCheck,D)||ye.tagNameCheck instanceof Function&&ye.tagNameCheck(D))))return!1}else if(!Ql[C]){if(!He(_d,cs(D,Sd,""))){if(!((C==="src"||C==="xlink:href"||C==="href")&&b!=="script"&&wO(D,"data:")===0&&Cd[b])){if(!(Ad&&!He($w,cs(D,Sd,"")))){if(D)return!1}}}}}}}return!0},Hd=function(b){return b!=="annotation-xml"&&Jc(b,Tw)},Wd=function(b){Xt(Pe.beforeSanitizeAttributes,b,null);const{attributes:C}=b;if(!C||rc(b))return;const D={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:De,forceKeepAttr:void 0};let ue=C.length;for(;ue--;){const Ue=C[ue],{name:be,namespaceURI:Xe,value:Kt}=Ue,Yr=ke(be),ic=Kt;let Le=be==="value"?ic:SO(ic);if(D.attrName=Yr,D.attrValue=Le,D.keepAttr=!0,D.forceKeepAttr=void 0,Xt(Pe.uponSanitizeAttribute,b,D),Le=D.attrValue,Id&&(Yr==="id"||Yr==="name")&&(Kn(be,b),Le=Iw+Le),Bo&&He(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,Le)){Kn(be,b);continue}if(Yr==="attributename"&&Jc(Le,"href")){Kn(be,b);continue}if(D.forceKeepAttr)continue;if(!D.keepAttr){Kn(be,b);continue}if(!$d&&He(/\/>/i,Le)){Kn(be,b);continue}Br&&pa([Yn,It,yn],Bd=>{Le=cs(Le,Bd," ")});const Zd=ke(b.nodeName);if(!Fd(Zd,Yr,Le)){Kn(be,b);continue}if(N&&typeof g=="object"&&typeof g.getAttributeType=="function"&&!Xe)switch(g.getAttributeType(Zd,Yr)){case"TrustedHTML":{Le=N.createHTML(Le);break}case"TrustedScriptURL":{Le=N.createScriptURL(Le);break}}if(Le!==ic)try{Xe?b.setAttributeNS(Xe,be,Le):b.setAttribute(be,Le),rc(b)?Rt(b):Rg(t.removed)}catch{Kn(be,b)}}Xt(Pe.afterSanitizeAttributes,b,null)},Ow=function U(b){let C=null;const D=Md(b);for(Xt(Pe.beforeSanitizeShadowDOM,b,null);C=D.nextNode();)Xt(Pe.uponSanitizeShadowNode,C,null),Ud(C),Wd(C),C.content instanceof s&&U(C.content);Xt(Pe.afterSanitizeShadowDOM,b,null)};return t.sanitize=function(U){let b=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},C=null,D=null,ue=null,Ue=null;if(ec=!U,ec&&(U="<!-->"),typeof U!="string"&&!Nd(U))if(typeof U.toString=="function"){if(U=U.toString(),typeof U!="string")throw us("dirty is not a string, aborting")}else throw us("toString is not a function");if(!t.isSupported)return U;if(Yl||nc(b),t.removed=[],typeof U=="string"&&(ts=!1),ts){if(U.nodeName){const Kt=ke(U.nodeName);if(!Te[Kt]||es[Kt])throw us("root node is forbidden and cannot be sanitized in-place")}}else if(U instanceof a)C=Od("<!---->"),D=C.ownerDocument.importNode(U,!0),D.nodeType===ds.element&&D.nodeName==="BODY"||D.nodeName==="HTML"?C=D:C.appendChild(D);else{if(!Vr&&!Br&&!Xn&&U.indexOf("<")===-1)return N&&jo?N.createHTML(U):U;if(C=Od(U),!C)return Vr?null:jo?F:""}C&&Xl&&Rt(C.firstChild);const be=Md(ts?U:C);for(;ue=be.nextNode();)Ud(ue),Wd(ue),ue.content instanceof s&&Ow(ue.content);if(ts)return U;if(Vr){if(Vo)for(Ue=le.call(C.ownerDocument);C.firstChild;)Ue.appendChild(C.firstChild);else Ue=C;return(De.shadowroot||De.shadowrootmode)&&(Ue=qn.call(r,Ue,!0)),Ue}let Xe=Xn?C.outerHTML:C.innerHTML;return Xn&&Te["!doctype"]&&C.ownerDocument&&C.ownerDocument.doctype&&C.ownerDocument.doctype.name&&He(sw,C.ownerDocument.doctype.name)&&(Xe="<!DOCTYPE "+C.ownerDocument.doctype.name+`>
|
|
343
|
+
`+Xe),Br&&pa([Yn,It,yn],Kt=>{Xe=cs(Xe,Kt," ")}),N&&jo?N.createHTML(Xe):Xe},t.setConfig=function(){let U=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};nc(U),Yl=!0},t.clearConfig=function(){qr=null,Yl=!1},t.isValidAttribute=function(U,b,C){qr||nc({});const D=ke(U),ue=ke(b);return Fd(D,ue,C)},t.addHook=function(U,b){typeof b=="function"&&ls(Pe[U],b)},t.removeHook=function(U,b){if(b!==void 0){const C=yO(Pe[U],b);return C===-1?void 0:bO(Pe[U],C,1)[0]}return Rg(Pe[U])},t.removeHooks=function(U){Pe[U]=[]},t.removeAllHooks=function(){Pe=Mg()},t}var aw=ow();function cd(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var Zr=cd();function lw(n){Zr=n}var or={exec:()=>null};function K(n,t=""){let e=typeof n=="string"?n:n.source,r={replace:(i,s)=>{let o=typeof s=="string"?s:s.source;return o=o.replace(Ge.caret,"$1"),e=e.replace(i,o),r},getRegex:()=>new RegExp(e,t)};return r}var OO=(()=>{try{return!!new RegExp("(?<=1)(?<!1)")}catch{return!1}})(),Ge={codeRemoveIndent:/^(?: {1,4}| {0,3}\t)/gm,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,multipleSpaceGlobal:/\s+/g,blankLine:/^[ \t]*$/,doubleBlankLine:/\n[ \t]*\n[ \t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] +\S/,listReplaceTask:/^\[[ xX]\] +/,listTaskCheckbox:/\[[ xX]\]/,anyLine:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\||\| *$/g,tableRowBlankLine:/\n[ \t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^<a /i,endATag:/^<\/a>/i,startPreScriptTag:/^<(pre|code|kbd|script)(\s|>)/i,endPreScriptTag:/^<\/(pre|code|kbd|script)(\s|>)/i,startAngleBracket:/^</,endAngleBracket:/>$/,pedanticHrefTitle:/^([^'"]*[^\s])\s+(['"])(.*)\2/,unicodeAlphaNumeric:/[\p{L}\p{N}]/u,escapeTest:/[&<>"']/,escapeReplace:/[&<>"']/g,escapeTestNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeReplaceNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:n=>new RegExp(`^( {0,3}${n})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:n=>new RegExp(`^ {0,${Math.min(3,n-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),hrRegex:n=>new RegExp(`^ {0,${Math.min(3,n-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),fencesBeginRegex:n=>new RegExp(`^ {0,${Math.min(3,n-1)}}(?:\`\`\`|~~~)`),headingBeginRegex:n=>new RegExp(`^ {0,${Math.min(3,n-1)}}#`),htmlBeginRegex:n=>new RegExp(`^ {0,${Math.min(3,n-1)}}<(?:[a-z].*>|!--)`,"i"),blockquoteBeginRegex:n=>new RegExp(`^ {0,${Math.min(3,n-1)}}>`)},MO=/^(?:[ \t]*(?:\n|$))+/,NO=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,UO=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,Ho=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,FO=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,ud=/ {0,3}(?:[*+-]|\d{1,9}[.)])/,cw=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,uw=K(cw).replace(/bull/g,ud).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(),HO=K(cw).replace(/bull/g,ud).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(),hd=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,WO=/^[^\n]+/,dd=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,ZO=K(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",dd).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),BO=K(/^(bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,ud).getRegex(),Vl="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",pd=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,VO=K("^ {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",pd).replace("tag",Vl).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),hw=K(hd).replace("hr",Ho).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",Vl).getRegex(),jO=K(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",hw).getRegex(),fd={blockquote:jO,code:NO,def:ZO,fences:UO,heading:FO,hr:Ho,html:VO,lheading:uw,list:BO,newline:MO,paragraph:hw,table:or,text:WO},Ng=K("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",Ho).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",Vl).getRegex(),GO={...fd,lheading:HO,table:Ng,paragraph:K(hd).replace("hr",Ho).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",Ng).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",Vl).getRegex()},qO={...fd,html:K(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",pd).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:or,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:K(hd).replace("hr",Ho).replace("heading",` *#{1,6} *[^
|
|
344
|
+
]`).replace("lheading",uw).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},YO=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,XO=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,dw=/^( {2,}|\\)\n(?!\s*$)/,KO=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,Qi=/[\p{P}\p{S}]/u,jl=/[\s\p{P}\p{S}]/u,gd=/[^\s\p{P}\p{S}]/u,JO=K(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,jl).getRegex(),pw=/(?!~)[\p{P}\p{S}]/u,QO=/(?!~)[\s\p{P}\p{S}]/u,eM=/(?:[^\s\p{P}\p{S}]|~)/u,tM=K(/link|precode-code|html/,"g").replace("link",/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-",OO?"(?<!`)()":"(^^|[^`])").replace("code",/(?<b>`+)[^`]+\k<b>(?!`)/).replace("html",/<(?! )[^<>]*?>/).getRegex(),fw=/^(?:\*+(?:((?!\*)punct)|([^\s*]))?)|^_+(?:((?!_)punct)|([^\s_]))?/,nM=K(fw,"u").replace(/punct/g,Qi).getRegex(),rM=K(fw,"u").replace(/punct/g,pw).getRegex(),gw="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",iM=K(gw,"gu").replace(/notPunctSpace/g,gd).replace(/punctSpace/g,jl).replace(/punct/g,Qi).getRegex(),sM=K(gw,"gu").replace(/notPunctSpace/g,eM).replace(/punctSpace/g,QO).replace(/punct/g,pw).getRegex(),oM=K("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,gd).replace(/punctSpace/g,jl).replace(/punct/g,Qi).getRegex(),aM=K(/^~~?(?:((?!~)punct)|[^\s~])/,"u").replace(/punct/g,Qi).getRegex(),lM="^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)",cM=K(lM,"gu").replace(/notPunctSpace/g,gd).replace(/punctSpace/g,jl).replace(/punct/g,Qi).getRegex(),uM=K(/\\(punct)/,"gu").replace(/punct/g,Qi).getRegex(),hM=K(/^<(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(),dM=K(pd).replace("(?:-->|$)","-->").getRegex(),pM=K("^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",dM).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),ol=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\])|[^\[\]\\`])*?/,fM=K(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?\s*\)/).replace("label",ol).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),mw=K(/^!?\[(label)\]\[(ref)\]/).replace("label",ol).replace("ref",dd).getRegex(),vw=K(/^!?\[(ref)\](?:\[\])?/).replace("ref",dd).getRegex(),gM=K("reflink|nolink(?!\\()","g").replace("reflink",mw).replace("nolink",vw).getRegex(),Ug=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,md={_backpedal:or,anyPunctuation:uM,autolink:hM,blockSkip:tM,br:dw,code:XO,del:or,delLDelim:or,delRDelim:or,emStrongLDelim:nM,emStrongRDelimAst:iM,emStrongRDelimUnd:oM,escape:YO,link:fM,nolink:vw,punctuation:JO,reflink:mw,reflinkSearch:gM,tag:pM,text:KO,url:or},mM={...md,link:K(/^!?\[(label)\]\((.*?)\)/).replace("label",ol).getRegex(),reflink:K(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",ol).getRegex()},sh={...md,emStrongRDelimAst:sM,emStrongLDelim:rM,delLDelim:aM,delRDelim:cM,url:K(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol",Ug).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:K(/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace("protocol",Ug).getRegex()},vM={...sh,br:K(dw).replace("{2,}","*").getRegex(),text:K(sh.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},ga={normal:fd,gfm:GO,pedantic:qO},ps={normal:md,gfm:sh,breaks:vM,pedantic:mM},yM={"&":"&","<":"<",">":">",'"':""","'":"'"},Fg=n=>yM[n];function zt(n,t){if(t){if(Ge.escapeTest.test(n))return n.replace(Ge.escapeReplace,Fg)}else if(Ge.escapeTestNoEncode.test(n))return n.replace(Ge.escapeReplaceNoEncode,Fg);return n}function Hg(n){try{n=encodeURI(n).replace(Ge.percentDecode,"%")}catch{return null}return n}function Wg(n,t){var s;let e=n.replace(Ge.findPipe,(o,a,c)=>{let u=!1,h=a;for(;--h>=0&&c[h]==="\\";)u=!u;return u?"|":" |"}),r=e.split(Ge.splitPipe),i=0;if(r[0].trim()||r.shift(),r.length>0&&!((s=r.at(-1))!=null&&s.trim())&&r.pop(),t)if(r.length>t)r.splice(t);else for(;r.length<t;)r.push("");for(;i<r.length;i++)r[i]=r[i].trim().replace(Ge.slashPipe,"|");return r}function fs(n,t,e){let r=n.length;if(r===0)return"";let i=0;for(;i<r&&n.charAt(r-i-1)===t;)i++;return n.slice(0,r-i)}function bM(n,t){if(n.indexOf(t[1])===-1)return-1;let e=0;for(let r=0;r<n.length;r++)if(n[r]==="\\")r++;else if(n[r]===t[0])e++;else if(n[r]===t[1]&&(e--,e<0))return r;return e>0?-2:-1}function wM(n,t=0){let e=t,r="";for(let i of n)if(i===" "){let s=4-e%4;r+=" ".repeat(s),e+=s}else r+=i,e++;return r}function Zg(n,t,e,r,i){let s=t.href,o=t.title||null,a=n[1].replace(i.other.outputLinkReplace,"$1");r.state.inLink=!0;let c={type:n[0].charAt(0)==="!"?"image":"link",raw:e,href:s,title:o,text:a,tokens:r.inlineTokens(a)};return r.state.inLink=!1,c}function SM(n,t,e){let r=n.match(e.other.indentCodeCompensation);if(r===null)return t;let i=r[1];return t.split(`
|
|
345
|
+
`).map(s=>{let o=s.match(e.other.beginningSpace);if(o===null)return s;let[a]=o;return a.length>=i.length?s.slice(i.length):s}).join(`
|
|
346
|
+
`)}var al=class{constructor(n){m(this,"options");m(this,"rules");m(this,"lexer");this.options=n||Zr}space(n){let t=this.rules.block.newline.exec(n);if(t&&t[0].length>0)return{type:"space",raw:t[0]}}code(n){let t=this.rules.block.code.exec(n);if(t){let e=t[0].replace(this.rules.other.codeRemoveIndent,"");return{type:"code",raw:t[0],codeBlockStyle:"indented",text:this.options.pedantic?e:fs(e,`
|
|
347
|
+
`)}}}fences(n){let t=this.rules.block.fences.exec(n);if(t){let e=t[0],r=SM(e,t[3]||"",this.rules);return{type:"code",raw:e,lang:t[2]?t[2].trim().replace(this.rules.inline.anyPunctuation,"$1"):t[2],text:r}}}heading(n){let t=this.rules.block.heading.exec(n);if(t){let e=t[2].trim();if(this.rules.other.endingHash.test(e)){let r=fs(e,"#");(this.options.pedantic||!r||this.rules.other.endingSpaceChar.test(r))&&(e=r.trim())}return{type:"heading",raw:t[0],depth:t[1].length,text:e,tokens:this.lexer.inline(e)}}}hr(n){let t=this.rules.block.hr.exec(n);if(t)return{type:"hr",raw:fs(t[0],`
|
|
348
|
+
`)}}blockquote(n){let t=this.rules.block.blockquote.exec(n);if(t){let e=fs(t[0],`
|
|
349
|
+
`).split(`
|
|
350
|
+
`),r="",i="",s=[];for(;e.length>0;){let o=!1,a=[],c;for(c=0;c<e.length;c++)if(this.rules.other.blockquoteStart.test(e[c]))a.push(e[c]),o=!0;else if(!o)a.push(e[c]);else break;e=e.slice(c);let u=a.join(`
|
|
351
|
+
`),h=u.replace(this.rules.other.blockquoteSetextReplace,`
|
|
352
|
+
$1`).replace(this.rules.other.blockquoteSetextReplace2,"");r=r?`${r}
|
|
353
|
+
${u}`:u,i=i?`${i}
|
|
354
|
+
${h}`:h;let p=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(h,s,!0),this.lexer.state.top=p,e.length===0)break;let v=s.at(-1);if((v==null?void 0:v.type)==="code")break;if((v==null?void 0:v.type)==="blockquote"){let g=v,_=g.raw+`
|
|
355
|
+
`+e.join(`
|
|
356
|
+
`),k=this.blockquote(_);s[s.length-1]=k,r=r.substring(0,r.length-g.raw.length)+k.raw,i=i.substring(0,i.length-g.text.length)+k.text;break}else if((v==null?void 0:v.type)==="list"){let g=v,_=g.raw+`
|
|
357
|
+
`+e.join(`
|
|
358
|
+
`),k=this.list(_);s[s.length-1]=k,r=r.substring(0,r.length-v.raw.length)+k.raw,i=i.substring(0,i.length-g.raw.length)+k.raw,e=_.substring(s.at(-1).raw.length).split(`
|
|
359
|
+
`);continue}}return{type:"blockquote",raw:r,tokens:s,text:i}}}list(n){var e,r;let t=this.rules.block.list.exec(n);if(t){let i=t[1].trim(),s=i.length>1,o={type:"list",raw:"",ordered:s,start:s?+i.slice(0,-1):"",loose:!1,items:[]};i=s?`\\d{1,9}\\${i.slice(-1)}`:`\\${i}`,this.options.pedantic&&(i=s?i:"[*+-]");let a=this.rules.other.listItemRegex(i),c=!1;for(;n;){let h=!1,p="",v="";if(!(t=a.exec(n))||this.rules.block.hr.test(n))break;p=t[0],n=n.substring(p.length);let g=wM(t[2].split(`
|
|
360
|
+
`,1)[0],t[1].length),_=n.split(`
|
|
361
|
+
`,1)[0],k=!g.trim(),T=0;if(this.options.pedantic?(T=2,v=g.trimStart()):k?T=t[1].length+1:(T=g.search(this.rules.other.nonSpaceChar),T=T>4?1:T,v=g.slice(T),T+=t[1].length),k&&this.rules.other.blankLine.test(_)&&(p+=_+`
|
|
362
|
+
`,n=n.substring(_.length+1),h=!0),!h){let P=this.rules.other.nextBulletRegex(T),R=this.rules.other.hrRegex(T),W=this.rules.other.fencesBeginRegex(T),N=this.rules.other.headingBeginRegex(T),F=this.rules.other.htmlBeginRegex(T),Y=this.rules.other.blockquoteBeginRegex(T);for(;n;){let j=n.split(`
|
|
363
|
+
`,1)[0],le;if(_=j,this.options.pedantic?(_=_.replace(this.rules.other.listReplaceNesting," "),le=_):le=_.replace(this.rules.other.tabCharGlobal," "),W.test(_)||N.test(_)||F.test(_)||Y.test(_)||P.test(_)||R.test(_))break;if(le.search(this.rules.other.nonSpaceChar)>=T||!_.trim())v+=`
|
|
364
|
+
`+le.slice(T);else{if(k||g.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4||W.test(g)||N.test(g)||R.test(g))break;v+=`
|
|
365
|
+
`+_}k=!_.trim(),p+=j+`
|
|
366
|
+
`,n=n.substring(j.length+1),g=le.slice(T)}}o.loose||(c?o.loose=!0:this.rules.other.doubleBlankLine.test(p)&&(c=!0)),o.items.push({type:"list_item",raw:p,task:!!this.options.gfm&&this.rules.other.listIsTask.test(v),loose:!1,text:v,tokens:[]}),o.raw+=p}let u=o.items.at(-1);if(u)u.raw=u.raw.trimEnd(),u.text=u.text.trimEnd();else return;o.raw=o.raw.trimEnd();for(let h of o.items){if(this.lexer.state.top=!1,h.tokens=this.lexer.blockTokens(h.text,[]),h.task){if(h.text=h.text.replace(this.rules.other.listReplaceTask,""),((e=h.tokens[0])==null?void 0:e.type)==="text"||((r=h.tokens[0])==null?void 0:r.type)==="paragraph"){h.tokens[0].raw=h.tokens[0].raw.replace(this.rules.other.listReplaceTask,""),h.tokens[0].text=h.tokens[0].text.replace(this.rules.other.listReplaceTask,"");for(let v=this.lexer.inlineQueue.length-1;v>=0;v--)if(this.rules.other.listIsTask.test(this.lexer.inlineQueue[v].src)){this.lexer.inlineQueue[v].src=this.lexer.inlineQueue[v].src.replace(this.rules.other.listReplaceTask,"");break}}let p=this.rules.other.listTaskCheckbox.exec(h.raw);if(p){let v={type:"checkbox",raw:p[0]+" ",checked:p[0]!=="[ ]"};h.checked=v.checked,o.loose?h.tokens[0]&&["paragraph","text"].includes(h.tokens[0].type)&&"tokens"in h.tokens[0]&&h.tokens[0].tokens?(h.tokens[0].raw=v.raw+h.tokens[0].raw,h.tokens[0].text=v.raw+h.tokens[0].text,h.tokens[0].tokens.unshift(v)):h.tokens.unshift({type:"paragraph",raw:v.raw,text:v.raw,tokens:[v]}):h.tokens.unshift(v)}}if(!o.loose){let p=h.tokens.filter(g=>g.type==="space"),v=p.length>0&&p.some(g=>this.rules.other.anyLine.test(g.raw));o.loose=v}}if(o.loose)for(let h of o.items){h.loose=!0;for(let p of h.tokens)p.type==="text"&&(p.type="paragraph")}return o}}html(n){let t=this.rules.block.html.exec(n);if(t)return{type:"html",block:!0,raw:t[0],pre:t[1]==="pre"||t[1]==="script"||t[1]==="style",text:t[0]}}def(n){let t=this.rules.block.def.exec(n);if(t){let e=t[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal," "),r=t[2]?t[2].replace(this.rules.other.hrefBrackets,"$1").replace(this.rules.inline.anyPunctuation,"$1"):"",i=t[3]?t[3].substring(1,t[3].length-1).replace(this.rules.inline.anyPunctuation,"$1"):t[3];return{type:"def",tag:e,raw:t[0],href:r,title:i}}}table(n){var o;let t=this.rules.block.table.exec(n);if(!t||!this.rules.other.tableDelimiter.test(t[2]))return;let e=Wg(t[1]),r=t[2].replace(this.rules.other.tableAlignChars,"").split("|"),i=(o=t[3])!=null&&o.trim()?t[3].replace(this.rules.other.tableRowBlankLine,"").split(`
|
|
367
|
+
`):[],s={type:"table",raw:t[0],header:[],align:[],rows:[]};if(e.length===r.length){for(let a of r)this.rules.other.tableAlignRight.test(a)?s.align.push("right"):this.rules.other.tableAlignCenter.test(a)?s.align.push("center"):this.rules.other.tableAlignLeft.test(a)?s.align.push("left"):s.align.push(null);for(let a=0;a<e.length;a++)s.header.push({text:e[a],tokens:this.lexer.inline(e[a]),header:!0,align:s.align[a]});for(let a of i)s.rows.push(Wg(a,s.header.length).map((c,u)=>({text:c,tokens:this.lexer.inline(c),header:!1,align:s.align[u]})));return s}}lheading(n){let t=this.rules.block.lheading.exec(n);if(t){let e=t[1].trim();return{type:"heading",raw:t[0],depth:t[2].charAt(0)==="="?1:2,text:e,tokens:this.lexer.inline(e)}}}paragraph(n){let t=this.rules.block.paragraph.exec(n);if(t){let e=t[1].charAt(t[1].length-1)===`
|
|
368
|
+
`?t[1].slice(0,-1):t[1];return{type:"paragraph",raw:t[0],text:e,tokens:this.lexer.inline(e)}}}text(n){let t=this.rules.block.text.exec(n);if(t)return{type:"text",raw:t[0],text:t[0],tokens:this.lexer.inline(t[0])}}escape(n){let t=this.rules.inline.escape.exec(n);if(t)return{type:"escape",raw:t[0],text:t[1]}}tag(n){let t=this.rules.inline.tag.exec(n);if(t)return!this.lexer.state.inLink&&this.rules.other.startATag.test(t[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&this.rules.other.endATag.test(t[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&this.rules.other.startPreScriptTag.test(t[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&this.rules.other.endPreScriptTag.test(t[0])&&(this.lexer.state.inRawBlock=!1),{type:"html",raw:t[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:t[0]}}link(n){let t=this.rules.inline.link.exec(n);if(t){let e=t[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(e)){if(!this.rules.other.endAngleBracket.test(e))return;let s=fs(e.slice(0,-1),"\\");if((e.length-s.length)%2===0)return}else{let s=bM(t[2],"()");if(s===-2)return;if(s>-1){let o=(t[0].indexOf("!")===0?5:4)+t[1].length+s;t[2]=t[2].substring(0,s),t[0]=t[0].substring(0,o).trim(),t[3]=""}}let r=t[2],i="";if(this.options.pedantic){let s=this.rules.other.pedanticHrefTitle.exec(r);s&&(r=s[1],i=s[3])}else i=t[3]?t[3].slice(1,-1):"";return r=r.trim(),this.rules.other.startAngleBracket.test(r)&&(this.options.pedantic&&!this.rules.other.endAngleBracket.test(e)?r=r.slice(1):r=r.slice(1,-1)),Zg(t,{href:r&&r.replace(this.rules.inline.anyPunctuation,"$1"),title:i&&i.replace(this.rules.inline.anyPunctuation,"$1")},t[0],this.lexer,this.rules)}}reflink(n,t){let e;if((e=this.rules.inline.reflink.exec(n))||(e=this.rules.inline.nolink.exec(n))){let r=(e[2]||e[1]).replace(this.rules.other.multipleSpaceGlobal," "),i=t[r.toLowerCase()];if(!i){let s=e[0].charAt(0);return{type:"text",raw:s,text:s}}return Zg(e,i,e[0],this.lexer,this.rules)}}emStrong(n,t,e=""){let r=this.rules.inline.emStrongLDelim.exec(n);if(!(!r||!r[1]&&!r[2]&&!r[3]&&!r[4]||r[4]&&e.match(this.rules.other.unicodeAlphaNumeric))&&(!(r[1]||r[3])||!e||this.rules.inline.punctuation.exec(e))){let i=[...r[0]].length-1,s,o,a=i,c=0,u=r[0][0]==="*"?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(u.lastIndex=0,t=t.slice(-1*n.length+i);(r=u.exec(t))!=null;){if(s=r[1]||r[2]||r[3]||r[4]||r[5]||r[6],!s)continue;if(o=[...s].length,r[3]||r[4]){a+=o;continue}else if((r[5]||r[6])&&i%3&&!((i+o)%3)){c+=o;continue}if(a-=o,a>0)continue;o=Math.min(o,o+a+c);let h=[...r[0]][0].length,p=n.slice(0,i+r.index+h+o);if(Math.min(i,o)%2){let g=p.slice(1,-1);return{type:"em",raw:p,text:g,tokens:this.lexer.inlineTokens(g)}}let v=p.slice(2,-2);return{type:"strong",raw:p,text:v,tokens:this.lexer.inlineTokens(v)}}}}codespan(n){let t=this.rules.inline.code.exec(n);if(t){let e=t[2].replace(this.rules.other.newLineCharGlobal," "),r=this.rules.other.nonSpaceChar.test(e),i=this.rules.other.startingSpaceChar.test(e)&&this.rules.other.endingSpaceChar.test(e);return r&&i&&(e=e.substring(1,e.length-1)),{type:"codespan",raw:t[0],text:e}}}br(n){let t=this.rules.inline.br.exec(n);if(t)return{type:"br",raw:t[0]}}del(n,t,e=""){let r=this.rules.inline.delLDelim.exec(n);if(r&&(!r[1]||!e||this.rules.inline.punctuation.exec(e))){let i=[...r[0]].length-1,s,o,a=i,c=this.rules.inline.delRDelim;for(c.lastIndex=0,t=t.slice(-1*n.length+i);(r=c.exec(t))!=null;){if(s=r[1]||r[2]||r[3]||r[4]||r[5]||r[6],!s||(o=[...s].length,o!==i))continue;if(r[3]||r[4]){a+=o;continue}if(a-=o,a>0)continue;o=Math.min(o,o+a);let u=[...r[0]][0].length,h=n.slice(0,i+r.index+u+o),p=h.slice(i,-i);return{type:"del",raw:h,text:p,tokens:this.lexer.inlineTokens(p)}}}}autolink(n){let t=this.rules.inline.autolink.exec(n);if(t){let e,r;return t[2]==="@"?(e=t[1],r="mailto:"+e):(e=t[1],r=e),{type:"link",raw:t[0],text:e,href:r,tokens:[{type:"text",raw:e,text:e}]}}}url(n){var e;let t;if(t=this.rules.inline.url.exec(n)){let r,i;if(t[2]==="@")r=t[0],i="mailto:"+r;else{let s;do s=t[0],t[0]=((e=this.rules.inline._backpedal.exec(t[0]))==null?void 0:e[0])??"";while(s!==t[0]);r=t[0],t[1]==="www."?i="http://"+t[0]:i=t[0]}return{type:"link",raw:t[0],text:r,href:i,tokens:[{type:"text",raw:r,text:r}]}}}inlineText(n){let t=this.rules.inline.text.exec(n);if(t){let e=this.lexer.state.inRawBlock;return{type:"text",raw:t[0],text:t[0],escaped:e}}}},$t=class oh{constructor(t){m(this,"tokens");m(this,"options");m(this,"state");m(this,"inlineQueue");m(this,"tokenizer");this.tokens=[],this.tokens.links=Object.create(null),this.options=t||Zr,this.options.tokenizer=this.options.tokenizer||new al,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 e={other:Ge,block:ga.normal,inline:ps.normal};this.options.pedantic?(e.block=ga.pedantic,e.inline=ps.pedantic):this.options.gfm&&(e.block=ga.gfm,this.options.breaks?e.inline=ps.breaks:e.inline=ps.gfm),this.tokenizer.rules=e}static get rules(){return{block:ga,inline:ps}}static lex(t,e){return new oh(e).lex(t)}static lexInline(t,e){return new oh(e).inlineTokens(t)}lex(t){t=t.replace(Ge.carriageReturn,`
|
|
369
|
+
`),this.blockTokens(t,this.tokens);for(let e=0;e<this.inlineQueue.length;e++){let r=this.inlineQueue[e];this.inlineTokens(r.src,r.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(t,e=[],r=!1){var i,s,o;for(this.tokenizer.lexer=this,this.options.pedantic&&(t=t.replace(Ge.tabCharGlobal," ").replace(Ge.spaceLine,""));t;){let a;if((s=(i=this.options.extensions)==null?void 0:i.block)!=null&&s.some(u=>(a=u.call({lexer:this},t,e))?(t=t.substring(a.raw.length),e.push(a),!0):!1))continue;if(a=this.tokenizer.space(t)){t=t.substring(a.raw.length);let u=e.at(-1);a.raw.length===1&&u!==void 0?u.raw+=`
|
|
370
|
+
`:e.push(a);continue}if(a=this.tokenizer.code(t)){t=t.substring(a.raw.length);let u=e.at(-1);(u==null?void 0:u.type)==="paragraph"||(u==null?void 0:u.type)==="text"?(u.raw+=(u.raw.endsWith(`
|
|
371
|
+
`)?"":`
|
|
372
|
+
`)+a.raw,u.text+=`
|
|
373
|
+
`+a.text,this.inlineQueue.at(-1).src=u.text):e.push(a);continue}if(a=this.tokenizer.fences(t)){t=t.substring(a.raw.length),e.push(a);continue}if(a=this.tokenizer.heading(t)){t=t.substring(a.raw.length),e.push(a);continue}if(a=this.tokenizer.hr(t)){t=t.substring(a.raw.length),e.push(a);continue}if(a=this.tokenizer.blockquote(t)){t=t.substring(a.raw.length),e.push(a);continue}if(a=this.tokenizer.list(t)){t=t.substring(a.raw.length),e.push(a);continue}if(a=this.tokenizer.html(t)){t=t.substring(a.raw.length),e.push(a);continue}if(a=this.tokenizer.def(t)){t=t.substring(a.raw.length);let u=e.at(-1);(u==null?void 0:u.type)==="paragraph"||(u==null?void 0:u.type)==="text"?(u.raw+=(u.raw.endsWith(`
|
|
374
|
+
`)?"":`
|
|
375
|
+
`)+a.raw,u.text+=`
|
|
376
|
+
`+a.raw,this.inlineQueue.at(-1).src=u.text):this.tokens.links[a.tag]||(this.tokens.links[a.tag]={href:a.href,title:a.title},e.push(a));continue}if(a=this.tokenizer.table(t)){t=t.substring(a.raw.length),e.push(a);continue}if(a=this.tokenizer.lheading(t)){t=t.substring(a.raw.length),e.push(a);continue}let c=t;if((o=this.options.extensions)!=null&&o.startBlock){let u=1/0,h=t.slice(1),p;this.options.extensions.startBlock.forEach(v=>{p=v.call({lexer:this},h),typeof p=="number"&&p>=0&&(u=Math.min(u,p))}),u<1/0&&u>=0&&(c=t.substring(0,u+1))}if(this.state.top&&(a=this.tokenizer.paragraph(c))){let u=e.at(-1);r&&(u==null?void 0:u.type)==="paragraph"?(u.raw+=(u.raw.endsWith(`
|
|
377
|
+
`)?"":`
|
|
378
|
+
`)+a.raw,u.text+=`
|
|
379
|
+
`+a.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=u.text):e.push(a),r=c.length!==t.length,t=t.substring(a.raw.length);continue}if(a=this.tokenizer.text(t)){t=t.substring(a.raw.length);let u=e.at(-1);(u==null?void 0:u.type)==="text"?(u.raw+=(u.raw.endsWith(`
|
|
380
|
+
`)?"":`
|
|
381
|
+
`)+a.raw,u.text+=`
|
|
382
|
+
`+a.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=u.text):e.push(a);continue}if(t){let u="Infinite loop on byte: "+t.charCodeAt(0);if(this.options.silent){console.error(u);break}else throw new Error(u)}}return this.state.top=!0,e}inline(t,e=[]){return this.inlineQueue.push({src:t,tokens:e}),e}inlineTokens(t,e=[]){var c,u,h,p,v;this.tokenizer.lexer=this;let r=t,i=null;if(this.tokens.links){let g=Object.keys(this.tokens.links);if(g.length>0)for(;(i=this.tokenizer.rules.inline.reflinkSearch.exec(r))!=null;)g.includes(i[0].slice(i[0].lastIndexOf("[")+1,-1))&&(r=r.slice(0,i.index)+"["+"a".repeat(i[0].length-2)+"]"+r.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;(i=this.tokenizer.rules.inline.anyPunctuation.exec(r))!=null;)r=r.slice(0,i.index)+"++"+r.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);let s;for(;(i=this.tokenizer.rules.inline.blockSkip.exec(r))!=null;)s=i[2]?i[2].length:0,r=r.slice(0,i.index+s)+"["+"a".repeat(i[0].length-s-2)+"]"+r.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);r=((u=(c=this.options.hooks)==null?void 0:c.emStrongMask)==null?void 0:u.call({lexer:this},r))??r;let o=!1,a="";for(;t;){o||(a=""),o=!1;let g;if((p=(h=this.options.extensions)==null?void 0:h.inline)!=null&&p.some(k=>(g=k.call({lexer:this},t,e))?(t=t.substring(g.raw.length),e.push(g),!0):!1))continue;if(g=this.tokenizer.escape(t)){t=t.substring(g.raw.length),e.push(g);continue}if(g=this.tokenizer.tag(t)){t=t.substring(g.raw.length),e.push(g);continue}if(g=this.tokenizer.link(t)){t=t.substring(g.raw.length),e.push(g);continue}if(g=this.tokenizer.reflink(t,this.tokens.links)){t=t.substring(g.raw.length);let k=e.at(-1);g.type==="text"&&(k==null?void 0:k.type)==="text"?(k.raw+=g.raw,k.text+=g.text):e.push(g);continue}if(g=this.tokenizer.emStrong(t,r,a)){t=t.substring(g.raw.length),e.push(g);continue}if(g=this.tokenizer.codespan(t)){t=t.substring(g.raw.length),e.push(g);continue}if(g=this.tokenizer.br(t)){t=t.substring(g.raw.length),e.push(g);continue}if(g=this.tokenizer.del(t,r,a)){t=t.substring(g.raw.length),e.push(g);continue}if(g=this.tokenizer.autolink(t)){t=t.substring(g.raw.length),e.push(g);continue}if(!this.state.inLink&&(g=this.tokenizer.url(t))){t=t.substring(g.raw.length),e.push(g);continue}let _=t;if((v=this.options.extensions)!=null&&v.startInline){let k=1/0,T=t.slice(1),P;this.options.extensions.startInline.forEach(R=>{P=R.call({lexer:this},T),typeof P=="number"&&P>=0&&(k=Math.min(k,P))}),k<1/0&&k>=0&&(_=t.substring(0,k+1))}if(g=this.tokenizer.inlineText(_)){t=t.substring(g.raw.length),g.raw.slice(-1)!=="_"&&(a=g.raw.slice(-1)),o=!0;let k=e.at(-1);(k==null?void 0:k.type)==="text"?(k.raw+=g.raw,k.text+=g.text):e.push(g);continue}if(t){let k="Infinite loop on byte: "+t.charCodeAt(0);if(this.options.silent){console.error(k);break}else throw new Error(k)}}return e}},ll=class{constructor(n){m(this,"options");m(this,"parser");this.options=n||Zr}space(n){return""}code({text:n,lang:t,escaped:e}){var s;let r=(s=(t||"").match(Ge.notSpaceStart))==null?void 0:s[0],i=n.replace(Ge.endingNewline,"")+`
|
|
383
|
+
`;return r?'<pre><code class="language-'+zt(r)+'">'+(e?i:zt(i,!0))+`</code></pre>
|
|
384
|
+
`:"<pre><code>"+(e?i:zt(i,!0))+`</code></pre>
|
|
385
|
+
`}blockquote({tokens:n}){return`<blockquote>
|
|
386
|
+
${this.parser.parse(n)}</blockquote>
|
|
387
|
+
`}html({text:n}){return n}def(n){return""}heading({tokens:n,depth:t}){return`<h${t}>${this.parser.parseInline(n)}</h${t}>
|
|
388
|
+
`}hr(n){return`<hr>
|
|
389
|
+
`}list(n){let t=n.ordered,e=n.start,r="";for(let o=0;o<n.items.length;o++){let a=n.items[o];r+=this.listitem(a)}let i=t?"ol":"ul",s=t&&e!==1?' start="'+e+'"':"";return"<"+i+s+`>
|
|
390
|
+
`+r+"</"+i+`>
|
|
391
|
+
`}listitem(n){return`<li>${this.parser.parse(n.tokens)}</li>
|
|
392
|
+
`}checkbox({checked:n}){return"<input "+(n?'checked="" ':"")+'disabled="" type="checkbox"> '}paragraph({tokens:n}){return`<p>${this.parser.parseInline(n)}</p>
|
|
393
|
+
`}table(n){let t="",e="";for(let i=0;i<n.header.length;i++)e+=this.tablecell(n.header[i]);t+=this.tablerow({text:e});let r="";for(let i=0;i<n.rows.length;i++){let s=n.rows[i];e="";for(let o=0;o<s.length;o++)e+=this.tablecell(s[o]);r+=this.tablerow({text:e})}return r&&(r=`<tbody>${r}</tbody>`),`<table>
|
|
394
|
+
<thead>
|
|
395
|
+
`+t+`</thead>
|
|
396
|
+
`+r+`</table>
|
|
397
|
+
`}tablerow({text:n}){return`<tr>
|
|
398
|
+
${n}</tr>
|
|
399
|
+
`}tablecell(n){let t=this.parser.parseInline(n.tokens),e=n.header?"th":"td";return(n.align?`<${e} align="${n.align}">`:`<${e}>`)+t+`</${e}>
|
|
400
|
+
`}strong({tokens:n}){return`<strong>${this.parser.parseInline(n)}</strong>`}em({tokens:n}){return`<em>${this.parser.parseInline(n)}</em>`}codespan({text:n}){return`<code>${zt(n,!0)}</code>`}br(n){return"<br>"}del({tokens:n}){return`<del>${this.parser.parseInline(n)}</del>`}link({href:n,title:t,tokens:e}){let r=this.parser.parseInline(e),i=Hg(n);if(i===null)return r;n=i;let s='<a href="'+n+'"';return t&&(s+=' title="'+zt(t)+'"'),s+=">"+r+"</a>",s}image({href:n,title:t,text:e,tokens:r}){r&&(e=this.parser.parseInline(r,this.parser.textRenderer));let i=Hg(n);if(i===null)return zt(e);n=i;let s=`<img src="${n}" alt="${zt(e)}"`;return t&&(s+=` title="${zt(t)}"`),s+=">",s}text(n){return"tokens"in n&&n.tokens?this.parser.parseInline(n.tokens):"escaped"in n&&n.escaped?n.text:zt(n.text)}},vd=class{strong({text:n}){return n}em({text:n}){return n}codespan({text:n}){return n}del({text:n}){return n}html({text:n}){return n}text({text:n}){return n}link({text:n}){return""+n}image({text:n}){return""+n}br(){return""}checkbox({raw:n}){return n}},Tt=class ah{constructor(t){m(this,"options");m(this,"renderer");m(this,"textRenderer");this.options=t||Zr,this.options.renderer=this.options.renderer||new ll,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new vd}static parse(t,e){return new ah(e).parse(t)}static parseInline(t,e){return new ah(e).parseInline(t)}parse(t){var r,i;this.renderer.parser=this;let e="";for(let s=0;s<t.length;s++){let o=t[s];if((i=(r=this.options.extensions)==null?void 0:r.renderers)!=null&&i[o.type]){let c=o,u=this.options.extensions.renderers[c.type].call({parser:this},c);if(u!==!1||!["space","hr","heading","code","table","blockquote","list","html","def","paragraph","text"].includes(c.type)){e+=u||"";continue}}let a=o;switch(a.type){case"space":{e+=this.renderer.space(a);break}case"hr":{e+=this.renderer.hr(a);break}case"heading":{e+=this.renderer.heading(a);break}case"code":{e+=this.renderer.code(a);break}case"table":{e+=this.renderer.table(a);break}case"blockquote":{e+=this.renderer.blockquote(a);break}case"list":{e+=this.renderer.list(a);break}case"checkbox":{e+=this.renderer.checkbox(a);break}case"html":{e+=this.renderer.html(a);break}case"def":{e+=this.renderer.def(a);break}case"paragraph":{e+=this.renderer.paragraph(a);break}case"text":{e+=this.renderer.text(a);break}default:{let c='Token with "'+a.type+'" type was not found.';if(this.options.silent)return console.error(c),"";throw new Error(c)}}}return e}parseInline(t,e=this.renderer){var i,s;this.renderer.parser=this;let r="";for(let o=0;o<t.length;o++){let a=t[o];if((s=(i=this.options.extensions)==null?void 0:i.renderers)!=null&&s[a.type]){let u=this.options.extensions.renderers[a.type].call({parser:this},a);if(u!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(a.type)){r+=u||"";continue}}let c=a;switch(c.type){case"escape":{r+=e.text(c);break}case"html":{r+=e.html(c);break}case"link":{r+=e.link(c);break}case"image":{r+=e.image(c);break}case"checkbox":{r+=e.checkbox(c);break}case"strong":{r+=e.strong(c);break}case"em":{r+=e.em(c);break}case"codespan":{r+=e.codespan(c);break}case"br":{r+=e.br(c);break}case"del":{r+=e.del(c);break}case"text":{r+=e.text(c);break}default:{let u='Token with "'+c.type+'" type was not found.';if(this.options.silent)return console.error(u),"";throw new Error(u)}}}return r}},ma,ks=(ma=class{constructor(n){m(this,"options");m(this,"block");this.options=n||Zr}preprocess(n){return n}postprocess(n){return n}processAllTokens(n){return n}emStrongMask(n){return n}provideLexer(){return this.block?$t.lex:$t.lexInline}provideParser(){return this.block?Tt.parse:Tt.parseInline}},m(ma,"passThroughHooks",new Set(["preprocess","postprocess","processAllTokens","emStrongMask"])),m(ma,"passThroughHooksRespectAsync",new Set(["preprocess","postprocess","processAllTokens"])),ma),_M=class{constructor(...n){m(this,"defaults",cd());m(this,"options",this.setOptions);m(this,"parse",this.parseMarkdown(!0));m(this,"parseInline",this.parseMarkdown(!1));m(this,"Parser",Tt);m(this,"Renderer",ll);m(this,"TextRenderer",vd);m(this,"Lexer",$t);m(this,"Tokenizer",al);m(this,"Hooks",ks);this.use(...n)}walkTokens(n,t){var r,i;let e=[];for(let s of n)switch(e=e.concat(t.call(this,s)),s.type){case"table":{let o=s;for(let a of o.header)e=e.concat(this.walkTokens(a.tokens,t));for(let a of o.rows)for(let c of a)e=e.concat(this.walkTokens(c.tokens,t));break}case"list":{let o=s;e=e.concat(this.walkTokens(o.items,t));break}default:{let o=s;(i=(r=this.defaults.extensions)==null?void 0:r.childTokens)!=null&&i[o.type]?this.defaults.extensions.childTokens[o.type].forEach(a=>{let c=o[a].flat(1/0);e=e.concat(this.walkTokens(c,t))}):o.tokens&&(e=e.concat(this.walkTokens(o.tokens,t)))}}return e}use(...n){let t=this.defaults.extensions||{renderers:{},childTokens:{}};return n.forEach(e=>{let r={...e};if(r.async=this.defaults.async||r.async||!1,e.extensions&&(e.extensions.forEach(i=>{if(!i.name)throw new Error("extension name required");if("renderer"in i){let s=t.renderers[i.name];s?t.renderers[i.name]=function(...o){let a=i.renderer.apply(this,o);return a===!1&&(a=s.apply(this,o)),a}:t.renderers[i.name]=i.renderer}if("tokenizer"in i){if(!i.level||i.level!=="block"&&i.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");let s=t[i.level];s?s.unshift(i.tokenizer):t[i.level]=[i.tokenizer],i.start&&(i.level==="block"?t.startBlock?t.startBlock.push(i.start):t.startBlock=[i.start]:i.level==="inline"&&(t.startInline?t.startInline.push(i.start):t.startInline=[i.start]))}"childTokens"in i&&i.childTokens&&(t.childTokens[i.name]=i.childTokens)}),r.extensions=t),e.renderer){let i=this.defaults.renderer||new ll(this.defaults);for(let s in e.renderer){if(!(s in i))throw new Error(`renderer '${s}' does not exist`);if(["options","parser"].includes(s))continue;let o=s,a=e.renderer[o],c=i[o];i[o]=(...u)=>{let h=a.apply(i,u);return h===!1&&(h=c.apply(i,u)),h||""}}r.renderer=i}if(e.tokenizer){let i=this.defaults.tokenizer||new al(this.defaults);for(let s in e.tokenizer){if(!(s in i))throw new Error(`tokenizer '${s}' does not exist`);if(["options","rules","lexer"].includes(s))continue;let o=s,a=e.tokenizer[o],c=i[o];i[o]=(...u)=>{let h=a.apply(i,u);return h===!1&&(h=c.apply(i,u)),h}}r.tokenizer=i}if(e.hooks){let i=this.defaults.hooks||new ks;for(let s in e.hooks){if(!(s in i))throw new Error(`hook '${s}' does not exist`);if(["options","block"].includes(s))continue;let o=s,a=e.hooks[o],c=i[o];ks.passThroughHooks.has(s)?i[o]=u=>{if(this.defaults.async&&ks.passThroughHooksRespectAsync.has(s))return(async()=>{let p=await a.call(i,u);return c.call(i,p)})();let h=a.call(i,u);return c.call(i,h)}:i[o]=(...u)=>{if(this.defaults.async)return(async()=>{let p=await a.apply(i,u);return p===!1&&(p=await c.apply(i,u)),p})();let h=a.apply(i,u);return h===!1&&(h=c.apply(i,u)),h}}r.hooks=i}if(e.walkTokens){let i=this.defaults.walkTokens,s=e.walkTokens;r.walkTokens=function(o){let a=[];return a.push(s.call(this,o)),i&&(a=a.concat(i.call(this,o))),a}}this.defaults={...this.defaults,...r}}),this}setOptions(n){return this.defaults={...this.defaults,...n},this}lexer(n,t){return $t.lex(n,t??this.defaults)}parser(n,t){return Tt.parse(n,t??this.defaults)}parseMarkdown(n){return(t,e)=>{let r={...e},i={...this.defaults,...r},s=this.onError(!!i.silent,!!i.async);if(this.defaults.async===!0&&r.async===!1)return s(new Error("marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise."));if(typeof t>"u"||t===null)return s(new Error("marked(): input parameter is undefined or null"));if(typeof t!="string")return s(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(t)+", string expected"));if(i.hooks&&(i.hooks.options=i,i.hooks.block=n),i.async)return(async()=>{let o=i.hooks?await i.hooks.preprocess(t):t,a=await(i.hooks?await i.hooks.provideLexer():n?$t.lex:$t.lexInline)(o,i),c=i.hooks?await i.hooks.processAllTokens(a):a;i.walkTokens&&await Promise.all(this.walkTokens(c,i.walkTokens));let u=await(i.hooks?await i.hooks.provideParser():n?Tt.parse:Tt.parseInline)(c,i);return i.hooks?await i.hooks.postprocess(u):u})().catch(s);try{i.hooks&&(t=i.hooks.preprocess(t));let o=(i.hooks?i.hooks.provideLexer():n?$t.lex:$t.lexInline)(t,i);i.hooks&&(o=i.hooks.processAllTokens(o)),i.walkTokens&&this.walkTokens(o,i.walkTokens);let a=(i.hooks?i.hooks.provideParser():n?Tt.parse:Tt.parseInline)(o,i);return i.hooks&&(a=i.hooks.postprocess(a)),a}catch(o){return s(o)}}}onError(n,t){return e=>{if(e.message+=`
|
|
401
|
+
Please report this to https://github.com/markedjs/marked.`,n){let r="<p>An error occurred:</p><pre>"+zt(e.message+"",!0)+"</pre>";return t?Promise.resolve(r):r}if(t)return Promise.reject(e);throw e}}},Nr=new _M;function ee(n,t){return Nr.parse(n,t)}ee.options=ee.setOptions=function(n){return Nr.setOptions(n),ee.defaults=Nr.defaults,lw(ee.defaults),ee};ee.getDefaults=cd;ee.defaults=Zr;ee.use=function(...n){return Nr.use(...n),ee.defaults=Nr.defaults,lw(ee.defaults),ee};ee.walkTokens=function(n,t){return Nr.walkTokens(n,t)};ee.parseInline=Nr.parseInline;ee.Parser=Tt;ee.parser=Tt.parse;ee.Renderer=ll;ee.TextRenderer=vd;ee.Lexer=$t;ee.lexer=$t.lex;ee.Tokenizer=al;ee.Hooks=ks;ee.parse=ee;ee.options;ee.setOptions;ee.use;ee.walkTokens;ee.parseInline;Tt.parse;$t.lex;aw.addHook("afterSanitizeAttributes",n=>{n.tagName==="A"&&(n.setAttribute("target","_blank"),n.setAttribute("rel","noopener noreferrer"))});function kM(n){const t=ee.parse(n,{async:!1});return aw.sanitize(t,{USE_PROFILES:{html:!0}})}var ko,hn,Bt,Vt,Mn,yw,Ha;class lh extends Hi{constructor(){super(...arguments);w(this,Mn);m(this,"phase","thinking");m(this,"toolCalls",[]);m(this,"expanded",!1);m(this,"expandedTexts",new Set);w(this,ko,`agent-activity-panel-${++AM}`);m(this,"overflowingTexts",new Set);w(this,hn,null);w(this,Bt,null);w(this,Vt,null);m(this,"handleToggle",()=>{this.toolCalls.length!==0&&(this.expanded=!this.expanded)})}changed(e){Re(this.template(),this),f(this,Mn,yw).call(this),l(this,Bt)!==null&&cancelAnimationFrame(l(this,Bt)),S(this,Bt,requestAnimationFrame(()=>{S(this,Bt,null),f(this,Mn,Ha).call(this)})),e.has("expanded")&&(l(this,Vt)!==null&&clearTimeout(l(this,Vt)),S(this,Vt,window.setTimeout(()=>{S(this,Vt,null),f(this,Mn,Ha).call(this)},EM)))}disconnected(){var e;(e=l(this,hn))==null||e.disconnect(),S(this,hn,null),l(this,Bt)!==null&&(cancelAnimationFrame(l(this,Bt)),S(this,Bt,null)),l(this,Vt)!==null&&(clearTimeout(l(this,Vt)),S(this,Vt,null))}template(){const e=this.toolCalls.length>0;return z`
|
|
402
|
+
${this.barTemplate()}
|
|
403
|
+
${e?this.panelTemplate():null}
|
|
404
|
+
`}barTemplate(){return this.phase==="thinking"?z`<div class="bar bar-static" unselectable>${this.indicator()}${this.label({expanded:this.expanded})}</div>`:z`
|
|
405
|
+
<button
|
|
406
|
+
type="button"
|
|
407
|
+
variant="ghost"
|
|
408
|
+
class="bar"
|
|
409
|
+
unselectable
|
|
410
|
+
aria-expanded=${this.expanded?"true":"false"}
|
|
411
|
+
aria-controls=${l(this,ko)}
|
|
412
|
+
@click=${this.handleToggle}
|
|
413
|
+
>
|
|
414
|
+
${this.indicator()}${this.label({expanded:this.expanded})}
|
|
415
|
+
</button>
|
|
416
|
+
`}panelTemplate(){return z`
|
|
417
|
+
<div
|
|
418
|
+
class="panel"
|
|
419
|
+
id=${l(this,ko)}
|
|
420
|
+
role="region"
|
|
421
|
+
?inert=${!this.expanded}
|
|
422
|
+
aria-hidden=${this.expanded?"false":"true"}
|
|
423
|
+
>
|
|
424
|
+
<div class="panel-inner">
|
|
425
|
+
<ol class="tool-list">
|
|
426
|
+
${this.toolCalls.map(e=>this.toolItemTemplate(e))}
|
|
427
|
+
</ol>
|
|
428
|
+
</div>
|
|
429
|
+
</div>
|
|
430
|
+
`}toolItemTemplate(e){const r=this.expandedTexts.has(e.toolCallId),i=this.overflowingTexts.has(e.toolCallId),s=r?"Show less":"Show more";return z`
|
|
431
|
+
<li class="tool-item">
|
|
432
|
+
<span
|
|
433
|
+
class="tool-dot"
|
|
434
|
+
data-status=${e.status}
|
|
435
|
+
role="img"
|
|
436
|
+
aria-label=${$M(e.status)}
|
|
437
|
+
></span>
|
|
438
|
+
<span class="tool-title">${e.title}</span>
|
|
439
|
+
${e.text?z`
|
|
440
|
+
<div class="tool-output">
|
|
441
|
+
<pre
|
|
442
|
+
class="tool-text"
|
|
443
|
+
data-tool-call-id=${e.toolCallId}
|
|
444
|
+
?data-expanded=${r}
|
|
445
|
+
>${e.text}</pre>
|
|
446
|
+
${i?z`<button
|
|
447
|
+
type="button"
|
|
448
|
+
variant="ghost"
|
|
449
|
+
class="tool-text-toggle"
|
|
450
|
+
@click=${()=>this.toggleTextExpand(e.toolCallId)}
|
|
451
|
+
>
|
|
452
|
+
<span>${s}</span>
|
|
453
|
+
${r?Iz({size:16}):il({size:16})}
|
|
454
|
+
</button>`:null}
|
|
455
|
+
</div>
|
|
456
|
+
`:null}
|
|
457
|
+
</li>
|
|
458
|
+
`}toggleTextExpand(e){const r=new Set(this.expandedTexts);r.has(e)?r.delete(e):r.add(e),this.expandedTexts=r}indicator(){if(this.expanded)return z`<span class="indicator">${il({size:16})}</span>`;const e=this.phase==="thinking"||this.phase==="using";return z`<span class=${e?"indicator indicator-active":"indicator"}
|
|
459
|
+
>${e?ub({size:16}):Dz({size:16})}</span>`}label(e){var s;if(this.phase==="thinking")return"Working…";const r=this.toolCalls.length;if(this.phase==="using"){if(e.expanded)return`Using ${r} ${r===1?"tool":"tools"}…`;const o=[...this.toolCalls].reverse().find(c=>c.status==="in_progress"),a=(o==null?void 0:o.toolKind)??((s=this.toolCalls.at(-1))==null?void 0:s.toolKind)??"other";return xM(a)}return`${e.expanded?"Showing":"Used"} ${r} ${r===1?"tool":"tools"}`}}ko=new WeakMap,hn=new WeakMap,Bt=new WeakMap,Vt=new WeakMap,Mn=new WeakSet,yw=function(){if(!(typeof ResizeObserver>"u")){l(this,hn)||S(this,hn,new ResizeObserver(()=>f(this,Mn,Ha).call(this))),l(this,hn).disconnect();for(const e of this.querySelectorAll(".tool-text"))l(this,hn).observe(e)}},Ha=function(){const e=new Set;for(const r of this.querySelectorAll(".tool-text")){const i=r.dataset.toolCallId;if(i){if(this.expandedTexts.has(i)){e.add(i);continue}r.scrollHeight>r.clientHeight+1&&e.add(i)}}TM(this.overflowingTexts,e)||(this.overflowingTexts=e)},m(lh,"properties",["phase","toolCalls","expanded","expandedTexts","overflowingTexts"]),m(lh,"attributes",{expanded:{type:Boolean}});function xM(n){switch(n){case"read":return"Reading files…";case"edit":return"Editing files…";case"delete":return"Deleting files…";case"move":return"Moving files…";case"search":return"Searching files…";case"execute":return"Running commands…";case"think":return"Thinking…";case"fetch":return"Fetching content…";case"switch_mode":return"Switching modes…";default:return"Working…"}}const EM=160;let AM=0;function $M(n){switch(n){case"completed":return"Completed";case"failed":return"Failed";case"in_progress":return"In progress";default:return"Pending"}}function TM(n,t){if(n.size!==t.size)return!1;for(const e of n)if(!t.has(e))return!1;return!0}customElements.define("agent-activity",lh);function IM(n){const t=[];let e=0;for(;e<n.length;)if(n[e].kind==="tool_call"){const i=[];for(;e<n.length&&n[e].kind==="tool_call";)i.push(n[e]),e+=1;const s=e>=n.length;t.push({kind:"tool-run",toolCalls:i,live:s})}else t.push({kind:"message",message:n[e]}),e+=1;const r=n[n.length-1];return r&&r.kind==="user"&&t.push({kind:"thinking"}),t}const Bg=8,Vg=new WeakMap;function CM(n){const t=Vg.get(n);if(t&&t.text===n.text)return t.html;const e=kM(n.text);return Vg.set(n,{text:n.text,html:e}),e}function jg(n){for(let t=n.length-1;t>=0;t-=1){const e=n[t];if(e&&e.kind==="user")return e.id}return null}var ht,dt,Cr,Rr,Ln,yt,ww,ch,Sw,Sl,_l,uh;class bw extends Hi{constructor(){super(...arguments);w(this,yt);m(this,"messages",[]);w(this,ht,!0);w(this,dt,null);w(this,Cr,null);w(this,Rr,null);w(this,Ln,!1);w(this,Sl,()=>{if(l(this,Ln))return;const e=l(this,dt);if(!e)return;const i=e.scrollHeight-e.clientHeight-e.scrollTop<=Bg;i!==l(this,ht)&&(S(this,ht,i),this.toggleAttribute("data-pinned",i))});w(this,_l,()=>{S(this,ht,!0),this.toggleAttribute("data-pinned",!0),f(this,yt,uh).call(this,!0)})}changed(e){let r=!1;if(e.has("messages")){const i=e.get("messages")??[],s=jg(this.messages);r=s!==null&&s!==jg(i),r&&S(this,ht,!0)}Re(this.template(),this),l(this,dt)||(S(this,dt,this.querySelector(".history-scroll")),l(this,dt)&&f(this,yt,ww).call(this)),this.toggleAttribute("data-pinned",l(this,ht)),f(this,yt,ch).call(this),f(this,yt,uh).call(this,r)}disconnected(){var e,r;(e=l(this,Cr))==null||e.disconnect(),S(this,Cr,null),(r=l(this,Rr))==null||r.disconnect(),S(this,Rr,null)}template(){const e=IM(this.messages);return z`
|
|
460
|
+
<div class="history-scroll" @scroll=${l(this,Sl)}>
|
|
461
|
+
${e.map(r=>{if(r.kind==="tool-run")return z`<agent-activity
|
|
462
|
+
.phase=${r.live?"using":"final"}
|
|
463
|
+
.toolCalls=${r.toolCalls}
|
|
464
|
+
></agent-activity>`;if(r.kind==="thinking")return z`<agent-activity
|
|
465
|
+
.phase=${"thinking"}
|
|
466
|
+
.toolCalls=${[]}
|
|
467
|
+
></agent-activity>`;const i=r.message,s=i.kind==="assistant"?gz(CM(i)):i.text;return z`<div
|
|
468
|
+
class="message message-${i.kind}"
|
|
469
|
+
data-message-id=${i.id}
|
|
470
|
+
>${s}</div>`})}
|
|
471
|
+
</div>
|
|
472
|
+
<button
|
|
473
|
+
type="button"
|
|
474
|
+
class="history-jump"
|
|
475
|
+
aria-label="Jump to latest message"
|
|
476
|
+
@click=${l(this,_l)}
|
|
477
|
+
>
|
|
478
|
+
${il({size:16})}
|
|
479
|
+
</button>
|
|
480
|
+
`}}ht=new WeakMap,dt=new WeakMap,Cr=new WeakMap,Rr=new WeakMap,Ln=new WeakMap,yt=new WeakSet,ww=function(){l(this,dt)&&(typeof ResizeObserver>"u"||(S(this,Cr,new ResizeObserver(()=>f(this,yt,Sw).call(this))),S(this,Rr,new MutationObserver(()=>f(this,yt,ch).call(this))),l(this,Rr).observe(l(this,dt),{childList:!0})))},ch=function(){const e=l(this,dt),r=l(this,Cr);if(!(!e||!r)){r.disconnect();for(const i of Array.from(e.children))r.observe(i)}},Sw=function(){const e=l(this,dt);if(!e)return;if(l(this,ht)){S(this,Ln,!0),e.scrollTop=e.scrollHeight-e.clientHeight,requestAnimationFrame(()=>{S(this,Ln,!1)});return}const i=e.scrollHeight-e.clientHeight-e.scrollTop<=Bg;i!==l(this,ht)&&(S(this,ht,i),this.toggleAttribute("data-pinned",i))},Sl=new WeakMap,_l=new WeakMap,uh=function(e){requestAnimationFrame(()=>{const r=l(this,dt);r&&(!l(this,ht)&&!e||(S(this,Ln,!0),r.scrollTop=r.scrollHeight-r.clientHeight,requestAnimationFrame(()=>{S(this,Ln,!1)})))})},m(bw,"properties",["messages"]);customElements.define("message-history",bw);var zn,xo,zi,kl,xl,pt,Wa,Eo,dh,ph,Ao,$o;class hh extends Hi{constructor(){super(...arguments);w(this,pt);m(this,"placeholder","What do you want to do?");m(this,"open",!1);m(this,"messages",[]);w(this,zn,Gt.resolve("ServerManager"));w(this,xo,Gt.resolve("ShortcutService"));w(this,zi,null);m(this,"handleTriggerActivate",()=>{var r;const e=(r=l(this,zn).activeServer)==null?void 0:r.acpClient;e&&!e.enabled||(this.open=!0)});m(this,"handleKeydown",e=>{var o;if(e.key!=="Enter"||e.shiftKey)return;const r=e.currentTarget,i=r.value.trim();if(e.preventDefault(),!i)return;r.value="",f(this,pt,Wa).call(this,r);const s=(o=l(this,zn).activeServer)==null?void 0:o.acpClient;s!=null&&s.enabled&&s.sendMessage({text:i}).catch(a=>{console.error("ACPClient.sendMessage() failed",a)})});w(this,kl,e=>{f(this,pt,Wa).call(this,e.currentTarget)});w(this,xl,e=>{if(e.target instanceof HTMLTextAreaElement)return;const r=e.currentTarget.querySelector("textarea");r==null||r.focus()});w(this,Eo,e=>{var s;if(e.shortcut!=="focusCommandInput")return;const r=(s=l(this,zn).activeServer)==null?void 0:s.acpClient;if(r&&!r.enabled)return;if(!this.open){this.open=!0;return}const i=this.querySelector("textarea");if(i){if(document.activeElement===i){this.open=!1;return}i.focus()}});w(this,Ao,e=>{e.target instanceof Node&&(this.contains(e.target)||(this.open=!1))});w(this,$o,e=>{e.key==="Escape"&&(this.open=!1)})}connected(){const e=new DisposableStack;S(this,zi,e);const r=fO(l(this,zn),i=>{this.messages=i});e.defer(()=>r.dispose()),l(this,xo).addEventListener("shortcut-triggered",l(this,Eo)),e.defer(()=>l(this,xo).removeEventListener("shortcut-triggered",l(this,Eo))),this.open&&f(this,pt,dh).call(this)}disconnected(){var e;(e=l(this,zi))==null||e.dispose(),S(this,zi,null),f(this,pt,ph).call(this)}changed(e){if(this.open?(this.removeAttribute("material"),this.removeAttribute("tone"),this.removeAttribute("level")):(this.setAttribute("material","paper"),this.setAttribute("tone","dark"),this.setAttribute("level","overlay")),Re(this.template(),this),e.has("open"))if(this.open){f(this,pt,dh).call(this);const r=this.querySelector("textarea");r&&(f(this,pt,Wa).call(this,r),r.focus())}else f(this,pt,ph).call(this)}template(){var r;const e=(r=l(this,zn).activeServer)==null?void 0:r.acpClient;return e&&!e.enabled?null:this.open?z`
|
|
481
|
+
<div
|
|
482
|
+
class="chat"
|
|
483
|
+
material="paper"
|
|
484
|
+
tone="dark"
|
|
485
|
+
level="overlay"
|
|
486
|
+
>
|
|
487
|
+
<message-history selectable .messages=${this.messages}></message-history>
|
|
488
|
+
</div>
|
|
489
|
+
<div
|
|
490
|
+
class="input"
|
|
491
|
+
material="paper"
|
|
492
|
+
tone="dark"
|
|
493
|
+
level="overlay"
|
|
494
|
+
@click=${l(this,xl)}
|
|
495
|
+
>
|
|
496
|
+
<textarea
|
|
497
|
+
class="textarea"
|
|
498
|
+
rows="1"
|
|
499
|
+
@keydown=${this.handleKeydown}
|
|
500
|
+
@input=${l(this,kl)}
|
|
501
|
+
></textarea>
|
|
502
|
+
</div>
|
|
503
|
+
`:z`
|
|
504
|
+
<div
|
|
505
|
+
class="trigger"
|
|
506
|
+
tabindex="0"
|
|
507
|
+
role="button"
|
|
508
|
+
@click=${this.handleTriggerActivate}
|
|
509
|
+
@focus=${this.handleTriggerActivate}
|
|
510
|
+
>
|
|
511
|
+
<span class="label">${this.placeholder}</span>
|
|
512
|
+
<span class="kbd" aria-hidden="true">⌘K</span>
|
|
513
|
+
</div>
|
|
514
|
+
`}}zn=new WeakMap,xo=new WeakMap,zi=new WeakMap,kl=new WeakMap,xl=new WeakMap,pt=new WeakSet,Wa=function(e){e.style.height="auto",e.style.height=`${e.scrollHeight}px`},Eo=new WeakMap,dh=function(){document.addEventListener("mousedown",l(this,Ao)),document.addEventListener("keydown",l(this,$o))},ph=function(){document.removeEventListener("mousedown",l(this,Ao)),document.removeEventListener("keydown",l(this,$o))},Ao=new WeakMap,$o=new WeakMap,m(hh,"properties",["placeholder","open","messages"]),m(hh,"attributes",{placeholder:{type:String},open:{type:Boolean}});customElements.define("command-panel",hh);const RM='<path d="M128,112a28,28,0,0,0-8,54.83V184a8,8,0,0,0,16,0V166.83A28,28,0,0,0,128,112Zm0,40a12,12,0,1,1,12-12A12,12,0,0,1,128,152Zm80-72H176V56a48,48,0,0,0-96,0V80H48A16,16,0,0,0,32,96V208a16,16,0,0,0,16,16H208a16,16,0,0,0,16-16V96A16,16,0,0,0,208,80ZM96,56a32,32,0,0,1,64,0V80H96ZM208,208H48V96H208V208Z"/>';class _w extends Event{constructor(e){super("auth-submit",{bubbles:!0,composed:!0});m(this,"token");this.token=e}}class PM extends HTMLElement{constructor(){super(...arguments);m(this,"_invalid",!1);m(this,"_tokenValue","")}set invalid(e){this._invalid=e,this.render()}get invalid(){return this._invalid}set tokenValue(e){this._tokenValue=e,this.render()}get tokenValue(){return this._tokenValue}connectedCallback(){this.render()}handleInput(e){const r=e.currentTarget;this._tokenValue=r.value}handleSubmit(e){e.preventDefault();const r=this._tokenValue.trim();r&&this.dispatchEvent(new _w(r))}render(){Re(z`
|
|
515
|
+
<modal-overlay open>
|
|
516
|
+
<system-modal material="glass-frosted" level="1" class="auth-modal">
|
|
517
|
+
<form class="auth-form" @submit=${r=>this.handleSubmit(r)}>
|
|
518
|
+
<header>
|
|
519
|
+
<span class="auth-modal-icon" aria-hidden="true">
|
|
520
|
+
<svg width="32" height="32" viewBox="0 0 256 256" fill="currentColor">${lb(RM)}</svg>
|
|
521
|
+
</span>
|
|
522
|
+
<hgroup>
|
|
523
|
+
<h2>Enter access token</h2>
|
|
524
|
+
<p>${"This server requires an access token to connect."}</p>
|
|
525
|
+
</hgroup>
|
|
526
|
+
</header>
|
|
527
|
+
<div class="auth-input-row">
|
|
528
|
+
<input
|
|
529
|
+
class=${this.invalid?"auth-token-input auth-token-input-invalid":"auth-token-input"}
|
|
530
|
+
type="password"
|
|
531
|
+
name="token"
|
|
532
|
+
placeholder="paste token here"
|
|
533
|
+
aria-label="Access token"
|
|
534
|
+
.value=${this.tokenValue}
|
|
535
|
+
@input=${r=>this.handleInput(r)}
|
|
536
|
+
autofocus
|
|
537
|
+
required
|
|
538
|
+
/>
|
|
539
|
+
${this.invalid?z`<p class="auth-modal-error" role="alert">
|
|
540
|
+
The previous token was rejected. Try again.
|
|
541
|
+
</p>`:null}
|
|
542
|
+
</div>
|
|
543
|
+
<button type="submit" variant="primary" class="auth-submit">
|
|
544
|
+
Connect
|
|
545
|
+
</button>
|
|
546
|
+
</form>
|
|
547
|
+
</system-modal>
|
|
548
|
+
</modal-overlay>
|
|
549
|
+
`,this)}}customElements.get("auth-modal")||customElements.define("auth-modal",PM);const DM=250,LM=1e3;class kw extends HTMLElement{constructor(){super(...arguments);m(this,"_nextRetryAt",null);m(this,"_hasEverConnected",!1);m(this,"tickHandle",null)}set nextRetryAt(e){e!==this._nextRetryAt&&(this._nextRetryAt=e,this.updateTickerState(),this.render())}get nextRetryAt(){return this._nextRetryAt}set hasEverConnected(e){e!==this._hasEverConnected&&(this._hasEverConnected=e,this.render())}get hasEverConnected(){return this._hasEverConnected}connectedCallback(){if(this._nextRetryAt===null&&this.hasAttribute("next-retry-at")){const e=Number(this.getAttribute("next-retry-at"));this._nextRetryAt=Number.isFinite(e)?e:null}this.updateTickerState(),this.render()}disconnectedCallback(){this.stopTicker()}attributeChangedCallback(e,r,i){if(e==="next-retry-at"){if(i===null||i==="")this._nextRetryAt=null;else{const s=Number(i);this._nextRetryAt=Number.isFinite(s)?s:null}this.updateTickerState()}else e==="has-ever-connected"&&(this._hasEverConnected=i!==null&&i!=="false");this.render()}updateTickerState(){this._nextRetryAt!==null?this.startTicker():this.stopTicker()}startTicker(){this.tickHandle===null&&(this.tickHandle=setInterval(()=>{this.render()},DM))}stopTicker(){this.tickHandle!==null&&(clearInterval(this.tickHandle),this.tickHandle=null)}render(){const e=this._hasEverConnected,r=e?"Disconnected":"Connecting",i=this._nextRetryAt!==null?this.formatCountdown(this._nextRetryAt):"Reattempting now…";Re(z`
|
|
550
|
+
<modal-overlay open role="status" aria-live="polite">
|
|
551
|
+
<system-modal material="glass-frosted" level="1" class="connecting-overlay-panel">
|
|
552
|
+
<header>
|
|
553
|
+
<ui-spinner size="32"></ui-spinner>
|
|
554
|
+
<hgroup>
|
|
555
|
+
<h2>${r}</h2>
|
|
556
|
+
${e?z`<p>${i}</p>`:null}
|
|
557
|
+
</hgroup>
|
|
558
|
+
</header>
|
|
559
|
+
</system-modal>
|
|
560
|
+
</modal-overlay>
|
|
561
|
+
`,this)}formatCountdown(e){const r=e-Date.now();return r<=0?"Reattempting now…":`Reattempting in ${Math.ceil(r/LM)}s…`}}m(kw,"observedAttributes",["next-retry-at","has-ever-connected"]);customElements.get("connecting-overlay")||customElements.define("connecting-overlay",kw);class zM extends HTMLElement{constructor(){super(...arguments);m(this,"runtimeServerURL",tb());m(this,"electronMode",rd());m(this,"serverManager",Gt.resolve("ServerManager"));m(this,"screenManager",Gt.resolve("ScreenManager"));m(this,"connectError",null);m(this,"handleServerManagerChange",()=>{var e;this.connectError!==null&&((e=this.serverManager.activeServer)==null?void 0:e.status)==="connected"&&(this.connectError=null),this.render()});m(this,"handleScreenManagerChange",()=>{this.render()})}connectedCallback(){this.serverManager.addEventListener("change",this.handleServerManagerChange),this.screenManager.addEventListener("active-screen-changed",this.handleScreenManagerChange),this.screenManager.addEventListener("tabs-changed",this.handleScreenManagerChange),this.addEventListener("auth-submit",e=>{var i;const r=e instanceof _w?e.token:e instanceof CustomEvent&&typeof((i=e.detail)==null?void 0:i.token)=="string"?e.detail.token:null;r&&this.handleAuthSubmit(r)}),this.initializeConnection(),this.render()}disconnectedCallback(){this.serverManager.removeEventListener("change",this.handleServerManagerChange),this.screenManager.removeEventListener("active-screen-changed",this.handleScreenManagerChange),this.screenManager.removeEventListener("tabs-changed",this.handleScreenManagerChange)}async initializeConnection(){if(this.electronMode){this.serverManager.connectConfiguredServers(this.runtimeServerURL,tg());return}if(this.serverManager.activeServer)return;const e=tg(),r=new eb({url:this.runtimeServerURL,name:"Server",token:e});this.serverManager.add(r),this.serverManager.setActive(r);try{await r.connect(e),this.connectError=null}catch(i){this.connectError=i instanceof Error&&!(i instanceof $s)?i.message:null}this.render()}async handleAuthSubmit(e){const r=this.serverManager.activeServer;if(r){this.connectError=null,this.updateTokenQueryParam(e);try{await r.connect(e)}catch(i){i instanceof $s||(this.connectError=i instanceof Error?i.message:String(i))}this.render()}}updateTokenQueryParam(e){const r=new URL(window.location.href);r.searchParams.set("token",e),window.history.replaceState({},"",`${r.pathname}${r.search}${r.hash}`)}render(){const e=this.serverManager.activeServer,r=(e==null?void 0:e.status)??null,i=this.screenManager.activeScreen,s=!!(e&&i&&this.screenManager.hasTab(e.url,i.id));if(r==="unauthorized"){const h=e;if(!h)return;Re(z`
|
|
562
|
+
<main class="auth-gate">
|
|
563
|
+
<auth-modal
|
|
564
|
+
.invalid=${!!h.token}
|
|
565
|
+
.tokenValue=${h.token??""}
|
|
566
|
+
></auth-modal>
|
|
567
|
+
</main>
|
|
568
|
+
`,this);return}const o=r==="connecting",a=(e==null?void 0:e.hasEverConnected)??!1,u=r==="connected"||o&&a;Re(z`
|
|
569
|
+
<main>
|
|
570
|
+
${this.connectError?z`<p data-testid="auth-error">${this.connectError}</p>`:z`
|
|
571
|
+
${s?z`<screen-view></screen-view>`:null}
|
|
572
|
+
${u?z`
|
|
573
|
+
<div class="chrome">
|
|
574
|
+
<div class="top-row" electron-draggable>
|
|
575
|
+
<screen-select></screen-select>
|
|
576
|
+
<menu-bar-clock></menu-bar-clock>
|
|
577
|
+
</div>
|
|
578
|
+
${e!=null&&e.acpClient.enabled?z`<command-panel></command-panel>`:null}
|
|
579
|
+
</div>
|
|
580
|
+
`:null}
|
|
581
|
+
`}
|
|
582
|
+
${o?z`<connecting-overlay
|
|
583
|
+
.nextRetryAt=${(e==null?void 0:e.nextRetryAt)??null}
|
|
584
|
+
.hasEverConnected=${(e==null?void 0:e.hasEverConnected)??!1}
|
|
585
|
+
></connecting-overlay>`:null}
|
|
586
|
+
</main>
|
|
587
|
+
`,this)}}customElements.get("television-app")||customElements.define("television-app",zM);const yd=rd(),bd=tb(),xw=new p$(yd?"television-electron":"television-browser",c$(bd)),pn=new KL({localStore:xw,localServerURL:bd}),Ew=new b$({localStore:xw,serverManager:pn}),OM=new JL,Aw=()=>{const n=pn.activeServer;if(!n||n.status!=="connected"){qa();return}n.client.display.get().then(t=>{if(!(pn.activeServer!==n||n.status!=="connected"))return nb(t.activeThemeName,n)}).catch(()=>{pn.activeServer===n&&qa()})};Aw();pn.addEventListener("change",Aw);pn.addEventListener("server-event",n=>{if(n.event.type!=="theme-changed")return;const t=pn.activeServer;!t||t.url!==n.serverURL||nb(n.event.themeName,t)});Gt.register("ServerManager",()=>pn);Gt.register("ScreenManager",()=>Ew);Gt.register("ShortcutService",()=>OM);globalThis.__telepath={screenManager:Ew,serverManager:pn};const wd=document.createElement("television-app");wd.runtimeServerURL=bd;wd.electronMode=yd;yd&&document.body.classList.add("electron");document.body.appendChild(wd);
|