@telepath-computer/television 0.1.80 → 0.1.81
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.
|
@@ -0,0 +1,580 @@
|
|
|
1
|
+
var Fb=Object.defineProperty;var cd=n=>{throw TypeError(n)};var Zb=(n,e,t)=>e in n?Fb(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var b=(n,e,t)=>Zb(n,typeof e!="symbol"?e+"":e,t),Rl=(n,e,t)=>e.has(n)||cd("Cannot "+t);var l=(n,e,t)=>(Rl(n,e,"read from private field"),t?t.call(n):e.get(n)),w=(n,e,t)=>e.has(n)?cd("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(n):e.set(n,t),x=(n,e,t,r)=>(Rl(n,e,"write to private field"),r?r.call(n,t):e.set(n,t),t),f=(n,e,t)=>(Rl(n,e,"access private method"),t);var ud=(n,e,t,r)=>({set _(i){x(n,e,i,t)},get _(){return l(n,e,r)}});(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const i of document.querySelectorAll('link[rel="modulepreload"]'))r(i);new MutationObserver(i=>{for(const s of i)if(s.type==="childList")for(const o of s.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&r(o)}).observe(document,{childList:!0,subtree:!0});function t(i){const s={};return i.integrity&&(s.integrity=i.integrity),i.referrerPolicy&&(s.referrerPolicy=i.referrerPolicy),i.crossOrigin==="use-credentials"?s.credentials="include":i.crossOrigin==="anonymous"?s.credentials="omit":s.credentials="same-origin",s}function r(i){if(i.ep)return;i.ep=!0;const s=t(i);fetch(i.href,s)}})();var Vn=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Wb(n){if(n.__esModule)return n;var e=n.default;if(typeof e=="function"){var t=function r(){return this instanceof r?Reflect.construct(e,arguments,this.constructor):e.apply(this,arguments)};t.prototype=e.prototype}else t={};return Object.defineProperty(t,"__esModule",{value:!0}),Object.keys(n).forEach(function(r){var i=Object.getOwnPropertyDescriptor(n,r);Object.defineProperty(t,r,i.get?i:{enumerable:!0,get:function(){return n[r]}})}),t}var hd=Object.prototype.toString,ig=function(e){var t=hd.call(e),r=t==="[object Arguments]";return r||(r=t!=="[object Array]"&&e!==null&&typeof e=="object"&&typeof e.length=="number"&&e.length>=0&&hd.call(e.callee)==="[object Function]"),r},Dl,dd;function Hb(){if(dd)return Dl;dd=1;var n;if(!Object.keys){var e=Object.prototype.hasOwnProperty,t=Object.prototype.toString,r=ig,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 m=v.constructor;return m&&m.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]&&e.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(m){var E=m!==null&&typeof m=="object",k=t.call(m)==="[object Function]",T=r(m),O=E&&t.call(m)==="[object String]",P=[];if(!E&&!k&&!T)throw new TypeError("Object.keys called on a non-object");var V=o&&k;if(O&&m.length>0&&!e.call(m,0))for(var F=0;F<m.length;++F)P.push(String(F));if(T&&m.length>0)for(var B=0;B<m.length;++B)P.push(String(B));else for(var U in m)!(V&&U==="prototype")&&e.call(m,U)&&P.push(String(U));if(s)for(var Q=p(m),j=0;j<a.length;++j)!(Q&&a[j]==="constructor")&&e.call(m,a[j])&&P.push(a[j]);return P}}return Dl=n,Dl}var Vb=Array.prototype.slice,Bb=ig,pd=Object.keys,qo=pd?function(e){return pd(e)}:Hb(),fd=Object.keys;qo.shim=function(){if(Object.keys){var e=function(){var t=Object.keys(arguments);return t&&t.length===arguments.length}(1,2);e||(Object.keys=function(r){return Bb(r)?fd(Vb.call(r)):fd(r)})}else Object.keys=qo;return Object.keys||qo};var Gb=qo,Yo=Object.defineProperty||!1;if(Yo)try{Yo({},"a",{value:1})}catch{Yo=!1}var so=Yo,tn=SyntaxError,K=TypeError,jb=Object.getOwnPropertyDescriptor,Xo=jb;if(Xo)try{Xo([],"length")}catch{Xo=null}var Ai=Xo,gd=so,qb=tn,zr=K,md=Ai,sg=function(e,t,r){if(!e||typeof e!="object"&&typeof e!="function")throw new zr("`obj` must be an object or a function`");if(typeof t!="string"&&typeof t!="symbol")throw new zr("`property` must be a string or a symbol`");if(arguments.length>3&&typeof arguments[3]!="boolean"&&arguments[3]!==null)throw new zr("`nonEnumerable`, if provided, must be a boolean or null");if(arguments.length>4&&typeof arguments[4]!="boolean"&&arguments[4]!==null)throw new zr("`nonWritable`, if provided, must be a boolean or null");if(arguments.length>5&&typeof arguments[5]!="boolean"&&arguments[5]!==null)throw new zr("`nonConfigurable`, if provided, must be a boolean or null");if(arguments.length>6&&typeof arguments[6]!="boolean")throw new zr("`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=!!md&&md(e,t);if(gd)gd(e,t,{configurable:o===null&&c?c.configurable:!o,enumerable:i===null&&c?c.enumerable:!i,value:r,writable:s===null&&c?c.writable:!s});else if(a||!i&&!s&&!o)e[t]=r;else throw new qb("This environment does not support defining a property as non-configurable, non-writable, or non-enumerable.")},Ic=so,og=function(){return!!Ic};og.hasArrayLengthDefineBug=function(){if(!Ic)return null;try{return Ic([],"length",{value:1}).length!==1}catch{return!0}};var el=og,Yb=Gb,Xb=typeof Symbol=="function"&&typeof Symbol("foo")=="symbol",Kb=Object.prototype.toString,Jb=Array.prototype.concat,vd=sg,Qb=function(n){return typeof n=="function"&&Kb.call(n)==="[object Function]"},ag=el(),ew=function(n,e,t,r){if(e in n){if(r===!0){if(n[e]===t)return}else if(!Qb(r)||!r())return}ag?vd(n,e,t,!0):vd(n,e,t)},lg=function(n,e){var t=arguments.length>2?arguments[2]:{},r=Yb(e);Xb&&(r=Jb.call(r,Object.getOwnPropertySymbols(e)));for(var i=0;i<r.length;i+=1)ew(n,r[i],e[r[i]],t[r[i]])};lg.supportsDescriptors=!!ag;var xr=lg,Ko={exports:{}};typeof self<"u"?Ko.exports=self:typeof window<"u"?Ko.exports=window:Ko.exports=Function("return this")();var cg=Ko.exports,tw=cg,ug=function(){return typeof Vn!="object"||!Vn||Vn.Math!==Math||Vn.Array!==Array?tw:Vn},nw=xr,rw=Ai,iw=ug,sw=function(){var e=iw();if(nw.supportsDescriptors){var t=rw(e,"globalThis");(!t||t.configurable&&(t.enumerable||!t.writable||globalThis!==e))&&Object.defineProperty(e,"globalThis",{configurable:!0,enumerable:!1,value:e,writable:!0})}else(typeof globalThis!="object"||globalThis!==e)&&(e.globalThis=e);return e},ow=xr,aw=cg,hg=ug,lw=sw,cw=hg(),dg=function(){return cw};ow(dg,{getPolyfill:hg,implementation:aw,shim:lw});var Du=dg,nn=function(e){return!!e&&(typeof e=="function"||typeof e=="object")},Lu=Object,pg=Error,uw=EvalError,hw=RangeError,zu=ReferenceError,dw=URIError,pw=Math.abs,fw=Math.floor,gw=Math.max,mw=Math.min,vw=Math.pow,yw=Math.round,Ou=Number.isNaN||function(e){return e!==e},bw=Ou,ww=function(e){return bw(e)||e===0?e:e<0?-1:1},$i=function(){if(typeof Symbol!="function"||typeof Object.getOwnPropertySymbols!="function")return!1;if(typeof Symbol.iterator=="symbol")return!0;var e={},t=Symbol("test"),r=Object(t);if(typeof t=="string"||Object.prototype.toString.call(t)!=="[object Symbol]"||Object.prototype.toString.call(r)!=="[object Symbol]")return!1;var i=42;e[t]=i;for(var s in e)return!1;if(typeof Object.keys=="function"&&Object.keys(e).length!==0||typeof Object.getOwnPropertyNames=="function"&&Object.getOwnPropertyNames(e).length!==0)return!1;var o=Object.getOwnPropertySymbols(e);if(o.length!==1||o[0]!==t||!Object.prototype.propertyIsEnumerable.call(e,t))return!1;if(typeof Object.getOwnPropertyDescriptor=="function"){var a=Object.getOwnPropertyDescriptor(e,t);if(a.value!==i||a.enumerable!==!0)return!1}return!0},yd=typeof Symbol<"u"&&Symbol,Sw=$i,Mu=function(){return typeof yd!="function"||typeof Symbol!="function"||typeof yd("foo")!="symbol"||typeof Symbol("bar")!="symbol"?!1:Sw()},Ll,bd;function fg(){return bd||(bd=1,Ll=typeof Reflect<"u"&&Reflect.getPrototypeOf||null),Ll}var zl,wd;function gg(){if(wd)return zl;wd=1;var n=Lu;return zl=n.getPrototypeOf||null,zl}var _w="Function.prototype.bind called on incompatible ",kw=Object.prototype.toString,Ew=Math.max,xw="[object Function]",Sd=function(e,t){for(var r=[],i=0;i<e.length;i+=1)r[i]=e[i];for(var s=0;s<t.length;s+=1)r[s+e.length]=t[s];return r},Aw=function(e,t){for(var r=[],i=t,s=0;i<e.length;i+=1,s+=1)r[s]=e[i];return r},$w=function(n,e){for(var t="",r=0;r<n.length;r+=1)t+=n[r],r+1<n.length&&(t+=e);return t},Iw=function(e){var t=this;if(typeof t!="function"||kw.apply(t)!==xw)throw new TypeError(_w+t);for(var r=Aw(arguments,1),i,s=function(){if(this instanceof i){var h=t.apply(this,Sd(r,arguments));return Object(h)===h?h:this}return t.apply(e,Sd(r,arguments))},o=Ew(0,t.length-r.length),a=[],c=0;c<o;c++)a[c]="$"+c;if(i=Function("binder","return function ("+$w(a,",")+"){ return binder.apply(this,arguments); }")(s),t.prototype){var u=function(){};u.prototype=t.prototype,i.prototype=new u,u.prototype=null}return i},Tw=Iw,oo=Function.prototype.bind||Tw,Nu=Function.prototype.call,Uu=Function.prototype.apply,Cw=typeof Reflect<"u"&&Reflect&&Reflect.apply,Pw=oo,Rw=Uu,Dw=Nu,Lw=Cw,mg=Lw||Pw.call(Dw,Rw),zw=oo,Ow=K,Mw=Nu,Nw=mg,tl=function(e){if(e.length<1||typeof e[0]!="function")throw new Ow("a function is required");return Nw(zw,Mw,e)},Ol,_d;function Uw(){if(_d)return Ol;_d=1;var n=tl,e=Ai,t;try{t=[].__proto__===Array.prototype}catch(o){if(!o||typeof o!="object"||!("code"in o)||o.code!=="ERR_PROTO_ACCESS")throw o}var r=!!t&&e&&e(Object.prototype,"__proto__"),i=Object,s=i.getPrototypeOf;return Ol=r&&typeof r.get=="function"?n([r.get]):typeof s=="function"?function(a){return s(a==null?a:i(a))}:!1,Ol}var Ml,kd;function vg(){if(kd)return Ml;kd=1;var n=fg(),e=gg(),t=Uw();return Ml=n?function(i){return n(i)}:e?function(i){if(!i||typeof i!="object"&&typeof i!="function")throw new TypeError("getProto: not an object");return e(i)}:t?function(i){return t(i)}:null,Ml}var Fw=Function.prototype.call,Zw=Object.prototype.hasOwnProperty,Ww=oo,rn=Ww.call(Fw,Zw),X,Hw=Lu,Vw=pg,Bw=uw,Gw=hw,jw=zu,wi=tn,Qr=K,qw=dw,Yw=pw,Xw=fw,Kw=gw,Jw=mw,Qw=vw,e0=yw,t0=ww,yg=Function,Nl=function(n){try{return yg('"use strict"; return ('+n+").constructor;")()}catch{}},hs=Ai,n0=so,Ul=function(){throw new Qr},r0=hs?function(){try{return arguments.callee,Ul}catch{try{return hs(arguments,"callee").get}catch{return Ul}}}():Ul,Or=Mu(),Ie=vg(),i0=gg(),s0=fg(),bg=Uu,ao=Nu,Zr={},o0=typeof Uint8Array>"u"||!Ie?X:Ie(Uint8Array),yr={__proto__:null,"%AggregateError%":typeof AggregateError>"u"?X:AggregateError,"%Array%":Array,"%ArrayBuffer%":typeof ArrayBuffer>"u"?X:ArrayBuffer,"%ArrayIteratorPrototype%":Or&&Ie?Ie([][Symbol.iterator]()):X,"%AsyncFromSyncIteratorPrototype%":X,"%AsyncFunction%":Zr,"%AsyncGenerator%":Zr,"%AsyncGeneratorFunction%":Zr,"%AsyncIteratorPrototype%":Zr,"%Atomics%":typeof Atomics>"u"?X:Atomics,"%BigInt%":typeof BigInt>"u"?X:BigInt,"%BigInt64Array%":typeof BigInt64Array>"u"?X:BigInt64Array,"%BigUint64Array%":typeof BigUint64Array>"u"?X:BigUint64Array,"%Boolean%":Boolean,"%DataView%":typeof DataView>"u"?X:DataView,"%Date%":Date,"%decodeURI%":decodeURI,"%decodeURIComponent%":decodeURIComponent,"%encodeURI%":encodeURI,"%encodeURIComponent%":encodeURIComponent,"%Error%":Vw,"%eval%":eval,"%EvalError%":Bw,"%Float16Array%":typeof Float16Array>"u"?X:Float16Array,"%Float32Array%":typeof Float32Array>"u"?X:Float32Array,"%Float64Array%":typeof Float64Array>"u"?X:Float64Array,"%FinalizationRegistry%":typeof FinalizationRegistry>"u"?X:FinalizationRegistry,"%Function%":yg,"%GeneratorFunction%":Zr,"%Int8Array%":typeof Int8Array>"u"?X:Int8Array,"%Int16Array%":typeof Int16Array>"u"?X:Int16Array,"%Int32Array%":typeof Int32Array>"u"?X:Int32Array,"%isFinite%":isFinite,"%isNaN%":isNaN,"%IteratorPrototype%":Or&&Ie?Ie(Ie([][Symbol.iterator]())):X,"%JSON%":typeof JSON=="object"?JSON:X,"%Map%":typeof Map>"u"?X:Map,"%MapIteratorPrototype%":typeof Map>"u"||!Or||!Ie?X:Ie(new Map()[Symbol.iterator]()),"%Math%":Math,"%Number%":Number,"%Object%":Hw,"%Object.getOwnPropertyDescriptor%":hs,"%parseFloat%":parseFloat,"%parseInt%":parseInt,"%Promise%":typeof Promise>"u"?X:Promise,"%Proxy%":typeof Proxy>"u"?X:Proxy,"%RangeError%":Gw,"%ReferenceError%":jw,"%Reflect%":typeof Reflect>"u"?X:Reflect,"%RegExp%":RegExp,"%Set%":typeof Set>"u"?X:Set,"%SetIteratorPrototype%":typeof Set>"u"||!Or||!Ie?X:Ie(new Set()[Symbol.iterator]()),"%SharedArrayBuffer%":typeof SharedArrayBuffer>"u"?X:SharedArrayBuffer,"%String%":String,"%StringIteratorPrototype%":Or&&Ie?Ie(""[Symbol.iterator]()):X,"%Symbol%":Or?Symbol:X,"%SyntaxError%":wi,"%ThrowTypeError%":r0,"%TypedArray%":o0,"%TypeError%":Qr,"%Uint8Array%":typeof Uint8Array>"u"?X:Uint8Array,"%Uint8ClampedArray%":typeof Uint8ClampedArray>"u"?X:Uint8ClampedArray,"%Uint16Array%":typeof Uint16Array>"u"?X:Uint16Array,"%Uint32Array%":typeof Uint32Array>"u"?X:Uint32Array,"%URIError%":qw,"%WeakMap%":typeof WeakMap>"u"?X:WeakMap,"%WeakRef%":typeof WeakRef>"u"?X:WeakRef,"%WeakSet%":typeof WeakSet>"u"?X:WeakSet,"%Function.prototype.call%":ao,"%Function.prototype.apply%":bg,"%Object.defineProperty%":n0,"%Object.getPrototypeOf%":i0,"%Math.abs%":Yw,"%Math.floor%":Xw,"%Math.max%":Kw,"%Math.min%":Jw,"%Math.pow%":Qw,"%Math.round%":e0,"%Math.sign%":t0,"%Reflect.getPrototypeOf%":s0};if(Ie)try{null.error}catch(n){var a0=Ie(Ie(n));yr["%Error.prototype%"]=a0}var l0=function n(e){var t;if(e==="%AsyncFunction%")t=Nl("async function () {}");else if(e==="%GeneratorFunction%")t=Nl("function* () {}");else if(e==="%AsyncGeneratorFunction%")t=Nl("async function* () {}");else if(e==="%AsyncGenerator%"){var r=n("%AsyncGeneratorFunction%");r&&(t=r.prototype)}else if(e==="%AsyncIteratorPrototype%"){var i=n("%AsyncGenerator%");i&&Ie&&(t=Ie(i.prototype))}return yr[e]=t,t},Ed={__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"]},lo=oo,pa=rn,c0=lo.call(ao,Array.prototype.concat),u0=lo.call(bg,Array.prototype.splice),xd=lo.call(ao,String.prototype.replace),fa=lo.call(ao,String.prototype.slice),h0=lo.call(ao,RegExp.prototype.exec),d0=/[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g,p0=/\\(\\)?/g,f0=function(e){var t=fa(e,0,1),r=fa(e,-1);if(t==="%"&&r!=="%")throw new wi("invalid intrinsic syntax, expected closing `%`");if(r==="%"&&t!=="%")throw new wi("invalid intrinsic syntax, expected opening `%`");var i=[];return xd(e,d0,function(s,o,a,c){i[i.length]=a?xd(c,p0,"$1"):o||s}),i},g0=function(e,t){var r=e,i;if(pa(Ed,r)&&(i=Ed[r],r="%"+i[0]+"%"),pa(yr,r)){var s=yr[r];if(s===Zr&&(s=l0(r)),typeof s>"u"&&!t)throw new Qr("intrinsic "+e+" exists, but is not available. Please file an issue!");return{alias:i,name:r,value:s}}throw new wi("intrinsic "+e+" does not exist!")},ut=function(e,t){if(typeof e!="string"||e.length===0)throw new Qr("intrinsic name must be a non-empty string");if(arguments.length>1&&typeof t!="boolean")throw new Qr('"allowMissing" argument must be a boolean');if(h0(/^%?[^%]*%?$/,e)===null)throw new wi("`%` may not be present anywhere but at the beginning and end of the intrinsic name");var r=f0(e),i=r.length>0?r[0]:"",s=g0("%"+i+"%",t),o=s.name,a=s.value,c=!1,u=s.alias;u&&(i=u[0],u0(r,c0([0,1],u)));for(var h=1,p=!0;h<r.length;h+=1){var v=r[h],m=fa(v,0,1),E=fa(v,-1);if((m==='"'||m==="'"||m==="`"||E==='"'||E==="'"||E==="`")&&m!==E)throw new wi("property names with quotes must have matching quotes");if((v==="constructor"||!p)&&(c=!0),i+="."+v,o="%"+i+"%",pa(yr,o))a=yr[o];else if(a!=null){if(!(v in a)){if(!t)throw new Qr("base intrinsic for "+e+" exists, but the property is not available.");return}if(hs&&h+1>=r.length){var k=hs(a,v);p=!!k,p&&"get"in k&&!("originalValue"in k.get)?a=k.get:a=a[v]}else p=pa(a,v),a=a[v];p&&!c&&(yr[o]=a)}}return a},Fl,Ad;function Pn(){if(Ad)return Fl;Ad=1;var n=ut,e=tl,t=e([n("%String.prototype.indexOf%")]);return Fl=function(i,s){var o=n(i,!!s);return typeof o=="function"&&t(i,".prototype.")>-1?e([o]):o},Fl}var Zl,$d;function Fu(){if($d)return Zl;$d=1;var n=ut,e=n("%Array%"),t=!e.isArray&&Pn()("Object.prototype.toString");return Zl=e.isArray||function(i){return t(i)==="[object Array]"},Zl}var m0=el,Id=so,wg=m0.hasArrayLengthDefineBug(),v0=wg&&Fu(),y0=Pn(),b0=y0("Object.prototype.propertyIsEnumerable"),Zu=function(e,t,r,i,s,o){if(!Id){if(!e(o)||!o["[[Configurable]]"]||!o["[[Writable]]"]||s in i&&b0(i,s)!==!!o["[[Enumerable]]"])return!1;var a=o["[[Value]]"];return i[s]=a,t(i[s],a)}return wg&&s==="length"&&"[[Value]]"in o&&v0(i)&&i.length!==o["[[Value]]"]?(i.length=o["[[Value]]"],i.length===o["[[Value]]"]):(Id(i,s,r(o)),!0)},w0=K,Zi=rn,S0={__proto__:null,"[[Configurable]]":!0,"[[Enumerable]]":!0,"[[Get]]":!0,"[[Set]]":!0,"[[Value]]":!0,"[[Writable]]":!0},Ii=function(e){if(!e||typeof e!="object")return!1;for(var t in e)if(Zi(e,t)&&!S0[t])return!1;var r=Zi(e,"[[Value]]")||Zi(e,"[[Writable]]"),i=Zi(e,"[[Get]]")||Zi(e,"[[Set]]");if(r&&i)throw new w0("Property Descriptors may not be both accessor and data descriptors");return!0},Sg=function(e){if(typeof e>"u")return e;var t={};return"[[Value]]"in e&&(t.value=e["[[Value]]"]),"[[Writable]]"in e&&(t.writable=!!e["[[Writable]]"]),"[[Get]]"in e&&(t.get=e["[[Get]]"]),"[[Set]]"in e&&(t.set=e["[[Set]]"]),"[[Enumerable]]"in e&&(t.enumerable=!!e["[[Enumerable]]"]),"[[Configurable]]"in e&&(t.configurable=!!e["[[Configurable]]"]),t},_0=K,k0=Ii,E0=Sg,_g=function(e){if(typeof e<"u"&&!k0(e))throw new _0("Assertion failed: `Desc` must be a Property Descriptor");return E0(e)},x0=K,Td=rn,A0=Ii,kg=function(e){if(typeof e>"u")return!1;if(!A0(e))throw new x0("Assertion failed: `Desc` must be a Property Descriptor");return!(!Td(e,"[[Value]]")&&!Td(e,"[[Writable]]"))},Ti=function(e){return typeof e=="string"||typeof e=="symbol"},Cd=Ou,Eg=function(e,t){return e===t?e===0?1/e===1/t:!0:Cd(e)&&Cd(t)},Pd=K,$0=nn,I0=Zu,T0=_g,C0=kg,P0=Ti,R0=Eg,Wu=function(e,t,r){if(!$0(e))throw new Pd("Assertion failed: Type(O) is not Object");if(!P0(t))throw new Pd("Assertion failed: P is not a Property Key");var i={"[[Configurable]]":!0,"[[Enumerable]]":!1,"[[Value]]":r,"[[Writable]]":!0};return I0(C0,R0,T0,e,t,i)},xg=Function.prototype.toString,Yr=typeof Reflect=="object"&&Reflect!==null&&Reflect.apply,Tc,Jo;if(typeof Yr=="function"&&typeof Object.defineProperty=="function")try{Tc=Object.defineProperty({},"length",{get:function(){throw Jo}}),Jo={},Yr(function(){throw 42},null,Tc)}catch(n){n!==Jo&&(Yr=null)}else Yr=null;var D0=/^\s*class\b/,Cc=function(e){try{var t=xg.call(e);return D0.test(t)}catch{return!1}},Wl=function(e){try{return Cc(e)?!1:(xg.call(e),!0)}catch{return!1}},Qo=Object.prototype.toString,L0="[object Object]",z0="[object Function]",O0="[object GeneratorFunction]",M0="[object HTMLAllCollection]",N0="[object HTML document.all class]",U0="[object HTMLCollection]",F0=typeof Symbol=="function"&&!!Symbol.toStringTag,Z0=!(0 in[,]),Pc=function(){return!1};if(typeof document=="object"){var W0=document.all;Qo.call(W0)===Qo.call(document.all)&&(Pc=function(e){if((Z0||!e)&&(typeof e>"u"||typeof e=="object"))try{var t=Qo.call(e);return(t===M0||t===N0||t===U0||t===L0)&&e("")==null}catch{}return!1})}var Ag=Yr?function(e){if(Pc(e))return!0;if(!e||typeof e!="function"&&typeof e!="object")return!1;try{Yr(e,null,Tc)}catch(t){if(t!==Jo)return!1}return!Cc(e)&&Wl(e)}:function(e){if(Pc(e))return!0;if(!e||typeof e!="function"&&typeof e!="object")return!1;if(F0)return Wl(e);if(Cc(e))return!1;var t=Qo.call(e);return t!==z0&&t!==O0&&!/^\[object HTML/.test(t)?!1:Wl(e)},H0=Ag,V0=function(e){return!!e},Et=rn,To=K,B0=nn,Rd=H0,Hl=V0,G0=function(e){if(!B0(e))throw new To("ToPropertyDescriptor requires an object");var t={};if(Et(e,"enumerable")&&(t["[[Enumerable]]"]=Hl(e.enumerable)),Et(e,"configurable")&&(t["[[Configurable]]"]=Hl(e.configurable)),Et(e,"value")&&(t["[[Value]]"]=e.value),Et(e,"writable")&&(t["[[Writable]]"]=Hl(e.writable)),Et(e,"get")){var r=e.get;if(typeof r<"u"&&!Rd(r))throw new To("getter must be a function");t["[[Get]]"]=r}if(Et(e,"set")){var i=e.set;if(typeof i<"u"&&!Rd(i))throw new To("setter must be a function");t["[[Set]]"]=i}if((Et(t,"[[Get]]")||Et(t,"[[Set]]"))&&(Et(t,"[[Value]]")||Et(t,"[[Writable]]")))throw new To("Invalid property descriptor. Cannot both specify accessors and a value or writable attribute");return t},Vl=K,j0=nn,Dd=Ii,q0=Zu,Y0=_g,X0=kg,K0=Ti,J0=Eg,Q0=G0,eS=function(e,t,r){if(!j0(e))throw new Vl("Assertion failed: Type(O) is not Object");if(!K0(t))throw new Vl("Assertion failed: P is not a Property Key");var i=Dd(r)?r:Q0(r);if(!Dd(i))throw new Vl("Assertion failed: Desc is not a valid Property Descriptor");return q0(X0,J0,Y0,e,t,i)},Ld=K,tS=nn,nS=eS,rS=Ti,iS=function(e,t,r){if(!tS(e))throw new Ld("Assertion failed: Type(O) is not Object");if(!rS(t))throw new Ld("Assertion failed: P is not a Property Key");var i={"[[Configurable]]":!0,"[[Enumerable]]":!1,"[[Value]]":r,"[[Writable]]":!0};return nS(e,t,i)},sS=typeof Reflect<"u"&&Reflect.setPrototypeOf||null,oS=Lu,aS=oS.setPrototypeOf||null,lS=tl,zd=Ai,cS=K,$g={};try{$g.__proto__=null}catch(n){if(!n||typeof n!="object"||!("code"in n)||n.code!=="ERR_PROTO_ACCESS")throw n}var uS=!("toString"in $g),Bl=zd&&zd(Object.prototype,"__proto__"),hS=uS&&(!!Bl&&typeof Bl.set=="function"&&lS([Bl.set])||function(e,t){if(e==null)throw new cS("set Object.prototype.__proto__ called on null or undefined");return e.__proto__=t,t}),Od=sS,dS=aS,Md=hS,pS=K,fS=Od?function(e,t){if(Od(e,t))return e;throw new pS("Reflect.setPrototypeOf: failed to set [[Prototype]]")}:dS||(Md?function(e,t){return Md(e,t),e}:null),Nd=K,gS=nn,Ud=vg(),mS=function(e){if(!gS(e))throw new Nd("Assertion failed: O must be an Object");if(!Ud)throw new Nd("This environment does not support fetching prototypes.");return Ud(e)},vS=K,yS=fS,bS=nn,wS=mS,SS=function(e,t){if(t!==null&&!bS(t))throw new vS("Assertion failed: V must be Object or Null");try{yS(e,t)}catch{return!1}return wS(e)===t},Gl=Wu,Fd=iS,Ig=SS,_S=el(),Hu=pg;function co(n,e,t){var r=new Hu(t);return Ig(r,ea),delete r.constructor,Fd(r,"error",n),Fd(r,"suppressed",e),r}_S&&Object.defineProperty(co,"prototype",{writable:!1});var ea=co.prototype;if(!Gl(ea,"constructor",co)||!Gl(ea,"message","")||!Gl(ea,"name","SuppressedError"))throw new Hu("unable to install SuppressedError.prototype properties; please report this!");Ig(co.prototype,Hu.prototype);var kS=co,ES=kS,Tg=function(){return typeof SuppressedError=="function"?SuppressedError:ES},xS=xr,Zd=Du(),AS=Tg,$S=function(){var e=AS();return xS(Zd,{SuppressedError:e},{SuppressedError:function(){return Zd.SuppressedError!==e}}),e};$S();var IS=K,TS=Ii,CS=Sg,PS=function(e){if(typeof e<"u"&&!TS(e))throw new IS("Assertion failed: `Desc` must be a Property Descriptor");return CS(e)},RS=K,Wd=rn,DS=Ii,LS=function(e){if(typeof e>"u")return!1;if(!DS(e))throw new RS("Assertion failed: `Desc` must be a Property Descriptor");return!(!Wd(e,"[[Value]]")&&!Wd(e,"[[Writable]]"))},Hd=Ou,zS=function(e,t){return e===t?e===0?1/e===1/t:!0:Hd(e)&&Hd(t)},Ci=Ag,OS=function(e){return!!e},xt=rn,Co=K,MS=nn,Vd=Ci,jl=OS,NS=function(e){if(!MS(e))throw new Co("ToPropertyDescriptor requires an object");var t={};if(xt(e,"enumerable")&&(t["[[Enumerable]]"]=jl(e.enumerable)),xt(e,"configurable")&&(t["[[Configurable]]"]=jl(e.configurable)),xt(e,"value")&&(t["[[Value]]"]=e.value),xt(e,"writable")&&(t["[[Writable]]"]=jl(e.writable)),xt(e,"get")){var r=e.get;if(typeof r<"u"&&!Vd(r))throw new Co("getter must be a function");t["[[Get]]"]=r}if(xt(e,"set")){var i=e.set;if(typeof i<"u"&&!Vd(i))throw new Co("setter must be a function");t["[[Set]]"]=i}if((xt(t,"[[Get]]")||xt(t,"[[Set]]"))&&(xt(t,"[[Value]]")||xt(t,"[[Writable]]")))throw new Co("Invalid property descriptor. Cannot both specify accessors and a value or writable attribute");return t},ql=K,US=nn,Bd=Ii,FS=Zu,ZS=PS,WS=LS,HS=Ti,VS=zS,BS=NS,uo=function(e,t,r){if(!US(e))throw new ql("Assertion failed: Type(O) is not Object");if(!HS(t))throw new ql("Assertion failed: P is not a Property Key");var i=Bd(r)?r:BS(r);if(!Bd(i))throw new ql("Assertion failed: Desc is not a valid Property Descriptor");return FS(WS,VS,ZS,e,t,i)},GS=$i(),jS=GS?Symbol.dispose||Symbol("Symbol.dispose"):null,qS=$i,YS=jS,Vu=function(){return qS()&&Symbol.dispose||YS},XS=Mu,KS=uo,JS=Vu,QS=function(){var e=JS();return XS()&&KS(Symbol,"dispose",{"[[Configurable]]":!1,"[[Enumerable]]":!1,"[[Writable]]":!1,"[[Value]]":e}),e},e_=$i(),t_=e_?Symbol.asyncDispose||Symbol("Symbol.asyncDispose"):null,n_=$i,r_=t_,Bu=function(){return n_()&&Symbol.asyncDispose||r_},i_=Mu,s_=uo,o_=Bu,a_=function(){var e=o_();return i_()&&s_(Symbol,"asyncDispose",{"[[Configurable]]":!1,"[[Enumerable]]":!1,"[[Writable]]":!1,"[[Value]]":e}),e},l_=Fu(),c_=ut,u_=Pn(),h_=K,d_=l_,p_=c_("%Reflect.apply%",!0)||u_("Function.prototype.apply"),nl=function(e,t){var r=arguments.length>2?arguments[2]:[];if(!d_(r))throw new h_("Assertion failed: optional `argumentsList`, if provided, must be a List");return p_(e,t,r)};const f_={},g_=Object.freeze(Object.defineProperty({__proto__:null,default:f_},Symbol.toStringTag,{value:"Module"})),m_=Wb(g_);var Gu=typeof Map=="function"&&Map.prototype,Yl=Object.getOwnPropertyDescriptor&&Gu?Object.getOwnPropertyDescriptor(Map.prototype,"size"):null,ga=Gu&&Yl&&typeof Yl.get=="function"?Yl.get:null,Gd=Gu&&Map.prototype.forEach,ju=typeof Set=="function"&&Set.prototype,Xl=Object.getOwnPropertyDescriptor&&ju?Object.getOwnPropertyDescriptor(Set.prototype,"size"):null,ma=ju&&Xl&&typeof Xl.get=="function"?Xl.get:null,jd=ju&&Set.prototype.forEach,v_=typeof WeakMap=="function"&&WeakMap.prototype,os=v_?WeakMap.prototype.has:null,y_=typeof WeakSet=="function"&&WeakSet.prototype,as=y_?WeakSet.prototype.has:null,b_=typeof WeakRef=="function"&&WeakRef.prototype,qd=b_?WeakRef.prototype.deref:null,w_=Boolean.prototype.valueOf,S_=Object.prototype.toString,__=Function.prototype.toString,k_=String.prototype.match,qu=String.prototype.slice,En=String.prototype.replace,E_=String.prototype.toUpperCase,Yd=String.prototype.toLowerCase,Cg=RegExp.prototype.test,Xd=Array.prototype.concat,Lt=Array.prototype.join,x_=Array.prototype.slice,Kd=Math.floor,Rc=typeof BigInt=="function"?BigInt.prototype.valueOf:null,Kl=Object.getOwnPropertySymbols,Dc=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?Symbol.prototype.toString:null,Si=typeof Symbol=="function"&&typeof Symbol.iterator=="object",ls=typeof Symbol=="function"&&Symbol.toStringTag&&(typeof Symbol.toStringTag===Si||!0)?Symbol.toStringTag:null,Pg=Object.prototype.propertyIsEnumerable,Jd=(typeof Reflect=="function"?Reflect.getPrototypeOf:Object.getPrototypeOf)||([].__proto__===Array.prototype?function(n){return n.__proto__}:null);function Qd(n,e){if(n===1/0||n===-1/0||n!==n||n&&n>-1e3&&n<1e3||Cg.call(/e/,e))return e;var t=/[0-9](?=(?:[0-9]{3})+(?![0-9]))/g;if(typeof n=="number"){var r=n<0?-Kd(-n):Kd(n);if(r!==n){var i=String(r),s=qu.call(e,i.length+1);return En.call(i,t,"$&_")+"."+En.call(En.call(s,/([0-9]{3})/g,"$&_"),/_$/,"")}}return En.call(e,t,"$&_")}var Lc=m_,ep=Lc.custom,tp=Lg(ep)?ep:null,Rg={__proto__:null,double:'"',single:"'"},A_={__proto__:null,double:/(["\\])/g,single:/(['\\])/g},Pi=function n(e,t,r,i){var s=t||{};if(Vt(s,"quoteStyle")&&!Vt(Rg,s.quoteStyle))throw new TypeError('option "quoteStyle" must be "single" or "double"');if(Vt(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=Vt(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(Vt(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(Vt(s,"numericSeparator")&&typeof s.numericSeparator!="boolean")throw new TypeError('option "numericSeparator", if provided, must be `true` or `false`');var a=s.numericSeparator;if(typeof e>"u")return"undefined";if(e===null)return"null";if(typeof e=="boolean")return e?"true":"false";if(typeof e=="string")return Og(e,s);if(typeof e=="number"){if(e===0)return 1/0/e>0?"0":"-0";var c=String(e);return a?Qd(e,c):c}if(typeof e=="bigint"){var u=String(e)+"n";return a?Qd(e,u):u}var h=typeof s.depth>"u"?5:s.depth;if(typeof r>"u"&&(r=0),r>=h&&h>0&&typeof e=="object")return zc(e)?"[Array]":"[Object]";var p=V_(s,r);if(typeof i>"u")i=[];else if(zg(i,e)>=0)return"[Circular]";function v(St,on,wl){if(on&&(i=x_.call(i),i.push(on)),wl){var wo={depth:s.depth};return Vt(s,"quoteStyle")&&(wo.quoteStyle=s.quoteStyle),n(St,wo,r+1,i)}return n(St,s,r+1,i)}if(typeof e=="function"&&!np(e)){var m=z_(e),E=Po(e,v);return"[Function"+(m?": "+m:" (anonymous)")+"]"+(E.length>0?" { "+Lt.call(E,", ")+" }":"")}if(Lg(e)){var k=Si?En.call(String(e),/^(Symbol\(.*\))_[^)]*$/,"$1"):Dc.call(e);return typeof e=="object"&&!Si?Wi(k):k}if(Z_(e)){for(var T="<"+Yd.call(String(e.nodeName)),O=e.attributes||[],P=0;P<O.length;P++)T+=" "+O[P].name+"="+Dg($_(O[P].value),"double",s);return T+=">",e.childNodes&&e.childNodes.length&&(T+="..."),T+="</"+Yd.call(String(e.nodeName))+">",T}if(zc(e)){if(e.length===0)return"[]";var V=Po(e,v);return p&&!H_(V)?"["+Oc(V,p)+"]":"[ "+Lt.call(V,", ")+" ]"}if(T_(e)){var F=Po(e,v);return!("cause"in Error.prototype)&&"cause"in e&&!Pg.call(e,"cause")?"{ ["+String(e)+"] "+Lt.call(Xd.call("[cause]: "+v(e.cause),F),", ")+" }":F.length===0?"["+String(e)+"]":"{ ["+String(e)+"] "+Lt.call(F,", ")+" }"}if(typeof e=="object"&&o){if(tp&&typeof e[tp]=="function"&&Lc)return Lc(e,{depth:h-r});if(o!=="symbol"&&typeof e.inspect=="function")return e.inspect()}if(O_(e)){var B=[];return Gd&&Gd.call(e,function(St,on){B.push(v(on,e,!0)+" => "+v(St,e))}),rp("Map",ga.call(e),B,p)}if(U_(e)){var U=[];return jd&&jd.call(e,function(St){U.push(v(St,e))}),rp("Set",ma.call(e),U,p)}if(M_(e))return Jl("WeakMap");if(F_(e))return Jl("WeakSet");if(N_(e))return Jl("WeakRef");if(P_(e))return Wi(v(Number(e)));if(D_(e))return Wi(v(Rc.call(e)));if(R_(e))return Wi(w_.call(e));if(C_(e))return Wi(v(String(e)));if(typeof window<"u"&&e===window)return"{ [object Window] }";if(typeof globalThis<"u"&&e===globalThis||typeof Vn<"u"&&e===Vn)return"{ [object globalThis] }";if(!I_(e)&&!np(e)){var Q=Po(e,v),j=Jd?Jd(e)===Object.prototype:e instanceof Object||e.constructor===Object,rt=e instanceof Object?"":"null prototype",Mt=!j&&ls&&Object(e)===e&&ls in e?qu.call(Rn(e),8,-1):rt?"Object":"",ke=j||typeof e.constructor!="function"?"":e.constructor.name?e.constructor.name+" ":"",zn=ke+(Mt||rt?"["+Lt.call(Xd.call([],Mt||[],rt||[]),": ")+"] ":"");return Q.length===0?zn+"{}":p?zn+"{"+Oc(Q,p)+"}":zn+"{ "+Lt.call(Q,", ")+" }"}return String(e)};function Dg(n,e,t){var r=t.quoteStyle||e,i=Rg[r];return i+n+i}function $_(n){return En.call(String(n),/"/g,""")}function Ar(n){return!ls||!(typeof n=="object"&&(ls in n||typeof n[ls]<"u"))}function zc(n){return Rn(n)==="[object Array]"&&Ar(n)}function I_(n){return Rn(n)==="[object Date]"&&Ar(n)}function np(n){return Rn(n)==="[object RegExp]"&&Ar(n)}function T_(n){return Rn(n)==="[object Error]"&&Ar(n)}function C_(n){return Rn(n)==="[object String]"&&Ar(n)}function P_(n){return Rn(n)==="[object Number]"&&Ar(n)}function R_(n){return Rn(n)==="[object Boolean]"&&Ar(n)}function Lg(n){if(Si)return n&&typeof n=="object"&&n instanceof Symbol;if(typeof n=="symbol")return!0;if(!n||typeof n!="object"||!Dc)return!1;try{return Dc.call(n),!0}catch{}return!1}function D_(n){if(!n||typeof n!="object"||!Rc)return!1;try{return Rc.call(n),!0}catch{}return!1}var L_=Object.prototype.hasOwnProperty||function(n){return n in this};function Vt(n,e){return L_.call(n,e)}function Rn(n){return S_.call(n)}function z_(n){if(n.name)return n.name;var e=k_.call(__.call(n),/^function\s*([\w$]+)/);return e?e[1]:null}function zg(n,e){if(n.indexOf)return n.indexOf(e);for(var t=0,r=n.length;t<r;t++)if(n[t]===e)return t;return-1}function O_(n){if(!ga||!n||typeof n!="object")return!1;try{ga.call(n);try{ma.call(n)}catch{return!0}return n instanceof Map}catch{}return!1}function M_(n){if(!os||!n||typeof n!="object")return!1;try{os.call(n,os);try{as.call(n,as)}catch{return!0}return n instanceof WeakMap}catch{}return!1}function N_(n){if(!qd||!n||typeof n!="object")return!1;try{return qd.call(n),!0}catch{}return!1}function U_(n){if(!ma||!n||typeof n!="object")return!1;try{ma.call(n);try{ga.call(n)}catch{return!0}return n instanceof Set}catch{}return!1}function F_(n){if(!as||!n||typeof n!="object")return!1;try{as.call(n,as);try{os.call(n,os)}catch{return!0}return n instanceof WeakSet}catch{}return!1}function Z_(n){return!n||typeof n!="object"?!1:typeof HTMLElement<"u"&&n instanceof HTMLElement?!0:typeof n.nodeName=="string"&&typeof n.getAttribute=="function"}function Og(n,e){if(n.length>e.maxStringLength){var t=n.length-e.maxStringLength,r="... "+t+" more character"+(t>1?"s":"");return Og(qu.call(n,0,e.maxStringLength),e)+r}var i=A_[e.quoteStyle||"single"];i.lastIndex=0;var s=En.call(En.call(n,i,"\\$1"),/[\x00-\x1f]/g,W_);return Dg(s,"single",e)}function W_(n){var e=n.charCodeAt(0),t={8:"b",9:"t",10:"n",12:"f",13:"r"}[e];return t?"\\"+t:"\\x"+(e<16?"0":"")+E_.call(e.toString(16))}function Wi(n){return"Object("+n+")"}function Jl(n){return n+" { ? }"}function rp(n,e,t,r){var i=r?Oc(t,r):Lt.call(t,", ");return n+" ("+e+") {"+i+"}"}function H_(n){for(var e=0;e<n.length;e++)if(zg(n[e],`
|
|
2
|
+
`)>=0)return!1;return!0}function V_(n,e){var t;if(n.indent===" ")t=" ";else if(typeof n.indent=="number"&&n.indent>0)t=Lt.call(Array(n.indent+1)," ");else return null;return{base:t,prev:Lt.call(Array(e+1),t)}}function Oc(n,e){if(n.length===0)return"";var t=`
|
|
3
|
+
`+e.prev+e.base;return t+Lt.call(n,","+t)+`
|
|
4
|
+
`+e.prev}function Po(n,e){var t=zc(n),r=[];if(t){r.length=n.length;for(var i=0;i<n.length;i++)r[i]=Vt(n,i)?e(n[i],n):""}var s=typeof Kl=="function"?Kl(n):[],o;if(Si){o={};for(var a=0;a<s.length;a++)o["$"+s[a]]=s[a]}for(var c in n)Vt(n,c)&&(t&&String(Number(c))===c&&c<n.length||Si&&o["$"+c]instanceof Symbol||(Cg.call(/[^\w$]/,c)?r.push(e(c,n)+": "+e(n[c],n)):r.push(c+": "+e(n[c],n))));if(typeof Kl=="function")for(var u=0;u<s.length;u++)Pg.call(n,s[u])&&r.push("["+e(s[u])+"]: "+e(n[s[u]],n));return r}var B_=Pi,G_=K,rl=function(n,e,t){for(var r=n,i;(i=r.next)!=null;r=i)if(i.key===e)return r.next=i.next,t||(i.next=n.next,n.next=i),i},j_=function(n,e){if(n){var t=rl(n,e);return t&&t.value}},q_=function(n,e,t){var r=rl(n,e);r?r.value=t:n.next={key:e,next:n.next,value:t}},Y_=function(n,e){return n?!!rl(n,e):!1},X_=function(n,e){if(n)return rl(n,e,!0)},K_=function(){var e,t={assert:function(r){if(!t.has(r))throw new G_("Side channel does not contain "+B_(r))},delete:function(r){var i=e&&e.next,s=X_(e,r);return s&&i&&i===s&&(e=void 0),!!s},get:function(r){return j_(e,r)},has:function(r){return Y_(e,r)},set:function(r,i){e||(e={next:void 0}),q_(e,r,i)}};return t},J_=ut,ho=Pn(),Q_=Pi,ek=K,ip=J_("%Map%",!0),tk=ho("Map.prototype.get",!0),nk=ho("Map.prototype.set",!0),rk=ho("Map.prototype.has",!0),ik=ho("Map.prototype.delete",!0),sk=ho("Map.prototype.size",!0),Mg=!!ip&&function(){var e,t={assert:function(r){if(!t.has(r))throw new ek("Side channel does not contain "+Q_(r))},delete:function(r){if(e){var i=ik(e,r);return sk(e)===0&&(e=void 0),i}return!1},get:function(r){if(e)return tk(e,r)},has:function(r){return e?rk(e,r):!1},set:function(r,i){e||(e=new ip),nk(e,r,i)}};return t},ok=ut,il=Pn(),ak=Pi,Ro=Mg,lk=K,Mr=ok("%WeakMap%",!0),ck=il("WeakMap.prototype.get",!0),uk=il("WeakMap.prototype.set",!0),hk=il("WeakMap.prototype.has",!0),dk=il("WeakMap.prototype.delete",!0),pk=Mr?function(){var e,t,r={assert:function(i){if(!r.has(i))throw new lk("Side channel does not contain "+ak(i))},delete:function(i){if(Mr&&i&&(typeof i=="object"||typeof i=="function")){if(e)return dk(e,i)}else if(Ro&&t)return t.delete(i);return!1},get:function(i){return Mr&&i&&(typeof i=="object"||typeof i=="function")&&e?ck(e,i):t&&t.get(i)},has:function(i){return Mr&&i&&(typeof i=="object"||typeof i=="function")&&e?hk(e,i):!!t&&t.has(i)},set:function(i,s){Mr&&i&&(typeof i=="object"||typeof i=="function")?(e||(e=new Mr),uk(e,i,s)):Ro&&(t||(t=Ro()),t.set(i,s))}};return r}:Ro,fk=K,gk=Pi,mk=K_,vk=Mg,yk=pk,bk=yk||vk||mk,wk=function(){var e,t={assert:function(r){if(!t.has(r))throw new fk("Side channel does not contain "+gk(r))},delete:function(r){return!!e&&e.delete(r)},get:function(r){return e&&e.get(r)},has:function(r){return!!e&&e.has(r)},set:function(r,i){e||(e=bk()),e.set(r,i)}};return t},Sk=rn,Hi=wk(),Zt=K,Yu={assert:function(n,e){if(!n||typeof n!="object"&&typeof n!="function")throw new Zt("`O` is not an object");if(typeof e!="string")throw new Zt("`slot` must be a string");if(Hi.assert(n),!Yu.has(n,e))throw new Zt("`"+e+"` is not present on `O`")},get:function(n,e){if(!n||typeof n!="object"&&typeof n!="function")throw new Zt("`O` is not an object");if(typeof e!="string")throw new Zt("`slot` must be a string");var t=Hi.get(n);return t&&t["$"+e]},has:function(n,e){if(!n||typeof n!="object"&&typeof n!="function")throw new Zt("`O` is not an object");if(typeof e!="string")throw new Zt("`slot` must be a string");var t=Hi.get(n);return!!t&&Sk(t,"$"+e)},set:function(n,e,t){if(!n||typeof n!="object"&&typeof n!="function")throw new Zt("`O` is not an object");if(typeof e!="string")throw new Zt("`slot` must be a string");var r=Hi.get(n);r||(r={},Hi.set(n,r)),r["$"+e]=t}};Object.freeze&&Object.freeze(Yu);var Xu=Yu,Ng=tn,xn=Xu,po=function n(e,t){if(!(this instanceof n))return new n(e,t);if(e!=="normal"&&e!=="break"&&e!=="continue"&&e!=="return"&&e!=="throw")throw new Ng('Assertion failed: `type` must be one of "normal", "break", "continue", "return", or "throw"');xn.set(this,"[[Type]]",e),xn.set(this,"[[Value]]",t)};po.prototype.type=function(){return xn.get(this,"[[Type]]")};po.prototype.value=function(){return xn.get(this,"[[Value]]")};po.prototype["?"]=function(){var e=xn.get(this,"[[Type]]"),t=xn.get(this,"[[Value]]");if(e==="throw")throw t;return t};po.prototype["!"]=function(){var e=xn.get(this,"[[Type]]");if(e!=="normal")throw new Ng('Assertion failed: Completion Record is not of type "normal"');return xn.get(this,"[[Value]]")};var Ku=po,_k=Ku,Ju=function(e){return new _k("normal",e)},Ql,sp;function kk(){if(sp)return Ql;sp=1;var n=$i;return Ql=function(){return n()&&!!Symbol.toStringTag},Ql}var Ek=ut,op=Ek("%Object.defineProperty%",!0),xk=kk()(),Ak=rn,$k=K,Do=xk?Symbol.toStringTag:null,Ug=function(e,t){var r=arguments.length>2&&!!arguments[2]&&arguments[2].force,i=arguments.length>2&&!!arguments[2]&&arguments[2].nonConfigurable;if(typeof r<"u"&&typeof r!="boolean"||typeof i<"u"&&typeof i!="boolean")throw new $k("if provided, the `overrideIfSet` and `nonConfigurable` options must be booleans");Do&&(r||!Ak(e,Do))&&(op?op(e,Do,{configurable:!i,enumerable:!1,value:t,writable:!1}):e[Do]=t)},Fg={exports:{}},Ik=ut,ap=sg,Tk=el(),lp=Ai,cp=K,Ck=Ik("%Math.floor%"),Pk=function(e,t){if(typeof e!="function")throw new cp("`fn` is not a function");if(typeof t!="number"||t<0||t>4294967295||Ck(t)!==t)throw new cp("`length` must be a positive 32-bit integer");var r=arguments.length>2&&!!arguments[2],i=!0,s=!0;if("length"in e&&lp){var o=lp(e,"length");o&&!o.configurable&&(i=!1),o&&!o.writable&&(s=!1)}return(i||s||!r)&&(Tk?ap(e,"length",t,!0,!0):ap(e,"length",t)),e},Rk=oo,Dk=Uu,Lk=mg,zk=function(){return Lk(Rk,Dk,arguments)};(function(n){var e=Pk,t=so,r=tl,i=zk;n.exports=function(o){var a=r(arguments),c=1+o.length-(arguments.length-1);return e(a,c>0?c:0,!0)},t?t(n.exports,"apply",{value:i}):n.exports.apply=i})(Fg);var Qu=Fg.exports,Ok=function(e,t){for(var r=0;r<e.length;r+=1)if(!t(e[r],r,e))return!1;return!0},Mk=Object,Nk=function(e){return e&&typeof e=="object"&&(typeof e["[[ResourceValue]]"]>"u"||Mk(e["[[ResourceValue]]"])===e["[[ResourceValue]]"])&&(e["[[Hint]]"]==="SYNC-DISPOSE"||e["[[Hint]]"]==="ASYNC-DISPOSE")&&(typeof e["[[DisposeMethod]]"]=="function"||typeof e["[[DisposeMethod]]"]>"u")},Uk=rn,Fk=Fu(),Zk=Ok,Wk=Nk,Hk=function(e){return e&&typeof e=="object"&&Uk(e,"[[DisposableResourceStack]]")&&Fk(e["[[DisposableResourceStack]]"])&&(e["[[DisposableResourceStack]]"].length===0||Zk(e["[[DisposableResourceStack]]"],Wk))},Vk=nn,Bk=function(e){if(e===null)return"Null";if(typeof e>"u")return"Undefined";if(Vk(e))return"Object";if(typeof e=="number")return"Number";if(typeof e=="boolean")return"Boolean";if(typeof e=="string")return"String"},Gk=Bk,eh=function(e){return typeof e=="symbol"?"Symbol":typeof e=="bigint"?"BigInt":Gk(e)},jk=K,qk=Pi,Yk=Ti,Xk=function(e,t){if(!Yk(t))throw new jk("Assertion failed: P is not a Property Key, got "+qk(t));return e[t]},up=K,Kk=Xk,Jk=Ci,Qk=Ti,hp=Pi,eE=function(e,t){if(!Qk(t))throw new up("Assertion failed: P is not a Property Key");var r=Kk(e,t);if(r!=null){if(!Jk(r))throw new up(hp(t)+" is not a function: "+hp(r));return r}},Mc={exports:{}},tE=ut,nE=tE,dp=nE("%Reflect.construct%",!0),va=uo;try{va({},"",{"[[Get]]":function(){}})}catch{va=null}if(va&&dp){var pp={},fp={};va(fp,"length",{"[[Get]]":function(){throw pp},"[[Enumerable]]":!0}),Mc.exports=function(e){try{dp(e,fp)}catch(t){return t===pp}}}else Mc.exports=function(e){return typeof e=="function"&&!!e.prototype};var rE=Mc.exports,ec=K,gp=Ci,iE=rE,sE=function(e){if(!iE(e))throw new ec("C must be a constructor");var t={"[[Resolve]]":void 0,"[[Reject]]":void 0},r=new e(function(i,s){if(typeof t["[[Resolve]]"]<"u"||typeof t["[[Reject]]"]<"u")throw new ec("executor has already been called");t["[[Resolve]]"]=i,t["[[Reject]]"]=s});if(!gp(t["[[Resolve]]"])||!gp(t["[[Reject]]"]))throw new ec("executor must provide valid resolve and reject functions");return{"[[Promise]]":r,"[[Resolve]]":t["[[Resolve]]"],"[[Reject]]":t["[[Reject]]"]}},mp=tn,oE=K,tc=nl,vp=eE,aE=sE,lE=eh,yp=Vu(),bp=Bu(),cE=function(e,t){if(lE(e)!=="Object")throw new oE("`V` must be an Object");if(t!=="SYNC-DISPOSE"&&t!=="ASYNC-DISPOSE")throw new mp("Assertion failed: `hint` must be `~SYNC-DISPOSE~` or `~ASYNC-DISPOSE~`");var r;if(t==="ASYNC-DISPOSE"&&bp&&(r=vp(e,bp)),!r){if(!yp)throw new mp("`Symbol.dispose` is not supported");if(r=vp(e,yp),typeof r<"u")return function(){var i=this;if(t==="ASYNC-DISPOSE"){var s=aE(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},uE=tn,nc=K,hE=Ci,dE=eh,pE=cE,fE=function(e,t){if(t!=="SYNC-DISPOSE"&&t!=="ASYNC-DISPOSE")throw new uE("Assertion failed: `hint` must be `~SYNC-DISPOSE~` or `~ASYNC-DISPOSE~`");var r;if(arguments.length<3)if(e==null)e=void 0,r=void 0;else{if(typeof e<"u"&&dE(e)!=="Object")throw new nc("`V` must be an Object, or `null` or `undefined`");if(r=pE(e,t),typeof r>"u")throw new nc("dispose method must not be `undefined` on `V` when an object `V` is provided")}else if(r=arguments[2],!hE(r))throw new nc("`method`, when provided, must be a function");return{"[[ResourceValue]]":e,"[[Hint]]":t,"[[DisposeMethod]]":r}},gE=tn,Lo=K,mE=Hk,wp=fE,vE=Pn(),yE=vE("Array.prototype.push"),Zg=function(e,t,r){if(!mE(e))throw new Lo("Assertion failed: `disposeCapability` must be a DisposeCapability Record");if(r!=="SYNC-DISPOSE"&&r!=="ASYNC-DISPOSE")throw new gE("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 Lo("Assertion failed: `method`, when present, must be a function");if(!e["[[DisposableResourceStack]]"])throw new Lo("Assertion failed: `disposeCapability.[[DisposableResourceStack]]` must not be ~EMPTY~");var s;if(arguments.length<4){if(t==null&&r==="SYNC_DISPOSE")return"UNUSED";s=wp(t,r)}else{if(typeof t<"u")throw new Lo("Assertion failed: `V` must be undefined when `method` is present");s=wp(void 0,r,i)}return yE(e["[[DisposableResourceStack]]"],s),"UNUSED"},rc,Sp;function th(){if(Sp)return rc;Sp=1;var n=ut,e=Qu,t=tn,r=n("%Promise.resolve%",!0),i=r&&e(r);return rc=function(o,a){if(!i)throw new t("This environment does not support Promises.");return i(o,a)},rc}var ic,_p;function bE(){if(_p)return ic;_p=1;var n=ut,e=tn,t=n("%Promise%",!0),r=nl,i=th(),s=eh;return ic=function(a,c,u){if(typeof a<"u"&&s(a)!=="Object")throw new e("Assertion failed: `V` must be `undefined` or an Object");if(c!=="SYNC-DISPOSE"&&c!=="ASYNC-DISPOSE")throw new e("Assertion failed: `hint` must be `~SYNC-DISPOSE~` or `~ASYNC-DISPOSE~`");if(typeof u<"u"&&typeof u!="function")throw new e("Assertion failed: `method` must be `undefined` or a function");var h=typeof u>"u"?u:r(u,a);if(c==="ASYNC-DISPOSE")return i(t,h)},ic}var sc,kp;function wE(){if(kp)return sc;kp=1;var n=Ku;return sc=function(t){return new n("throw",t)},sc}var SE=ut,oc=tn,Ep=K,_E=SE("%Promise%",!0),kE=Pn(),xp=kE("Promise.prototype.then",!0),EE=Ku,Ap=bE(),xE=Ju,AE=th(),$p=wE(),$E=Tg(),Wg=function(e,t){if(!(t instanceof EE))throw new Ep("`completion` must be a Completion Record");var r=e["[[DisposableResourceStack]]"];if(!r)throw new Ep("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 oc("mixed hint stacks are not supported");for(var o=i==="ASYNC-DISPOSE"&&AE(_E,t),a=function(v){if(t.type()==="throw"){var m=t.value(),E=new $E(v,m);t=$p(E)}else t=$p(v)},c=i==="ASYNC-DISPOSE"&&function(m){return xp(o,function(){var E=Ap(m["[[ResourceValue]]"],m["[[Hint]]"],m["[[DisposeMethod]]"]);if(!E)throw new oc("Assertion failed: non-`~ASYNC-DISPOSE~` resource returned a promise from Dispose");return xp(E,xE)},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=Ap(h["[[ResourceValue]]"],h["[[Hint]]"],h["[[DisposeMethod]]"]);if(p)throw new oc("Assertion failed: `~SYNC-DISPOSE~` resource returned something from Dispose")}catch(v){a(v)}}return e["[[DisposableResourceStack]]"]=null,i==="ASYNC-DISPOSE"?o:t},Hg=function(){var e=[];return{"[[DisposableResourceStack]]":e}},sl=zu,nh=K,IE=nl,Ri=Wu,TE=uo,Vg=Ci,CE=Ju,Ye=Xu,PE=Ug,Bg=xr.supportsDescriptors,RE=Qu,rh=Zg,DE=Wg,Gg=Hg,Ip=Vu(),at=function n(){if(!(this instanceof n)||Ye.has(this,"[[DisposableState]]")||Ye.has(this,"[[DisposeCapability]]"))throw new nh("can only be used with new");Ye.set(this,"[[DisposableState]]","PENDING"),Ye.set(this,"[[DisposeCapability]]",Gg())},jg=function(){var e=this;return Ye.assert(e,"[[DisposableState]]"),Ye.get(e,"[[DisposableState]]")==="DISPOSED"},fo=RE(jg);Bg?TE(at.prototype,"disposed",{"[[Configurable]]":!0,"[[Enumerable]]":!1,"[[Get]]":jg}):at.prototype.disposed=!1;var qg=function(e){Ye.set(e,"[[DisposableState]]","DISPOSED"),Bg||(e.disposed=!0)};Ri(at.prototype,"dispose",function(){var e=this;if(!fo(e))return qg(e),DE(Ye.get(e,"[[DisposeCapability]]"),CE())["?"]()});Ri(at.prototype,"use",function(e){var t=this;if(fo(t))throw new sl("a disposed stack can not use anything new");return rh(Ye.get(t,"[[DisposeCapability]]"),e,"SYNC-DISPOSE"),e});Ri(at.prototype,"adopt",function(e,t){var r=this;if(fo(r))throw new sl("a disposed stack can not use anything new");if(!Vg(t))throw new nh("`onDispose` must be a function");var i=function(){return IE(t,void 0,[e])};return rh(Ye.get(r,"[[DisposeCapability]]"),void 0,"SYNC-DISPOSE",i),e});Ri(at.prototype,"defer",function(e){var t=this;if(fo(t))throw new sl("a disposed stack can not defer anything new");if(!Vg(e))throw new nh("`onDispose` must be a function");rh(Ye.get(t,"[[DisposeCapability]]"),void 0,"SYNC-DISPOSE",e)});Ri(at.prototype,"move",function(){var e=this;if(fo(e))throw new sl("a disposed stack can not use anything new");var t=new at;return Ye.set(t,"[[DisposeCapability]]",Ye.get(e,"[[DisposeCapability]]")),Ye.set(e,"[[DisposeCapability]]",Gg()),qg(e),t});Ip&&Ri(at.prototype,Ip,at.prototype.dispose);PE(at.prototype,"DisposableStack");var LE=at,zE=LE,OE=function(){return typeof DisposableStack=="function"?DisposableStack:zE},ME=xr,NE=Du(),UE=OE,FE=function(){var e=UE();return ME(NE,{DisposableStack:e},{DisposableStack:!0}),e},ZE=ut,ol=zu,ih=K,Tp=ZE("%Promise%",!0),sh=Zg,WE=nl,Di=Wu,HE=uo,VE=Wg,Yg=Ci,Xg=Hg,BE=Ju,Cp=th(),Xe=Xu,GE=Ug,Kg=xr.supportsDescriptors,jE=Qu,qE=Pn(),YE=qE("Promise.prototype.then",!0),Pp=Bu(),lt=function n(){if(!(this instanceof n)||Xe.has(this,"[[AsyncDisposableState]]")||Xe.has(this,"[[DisposeCapability]]"))throw new ih("can only be used with new");Xe.set(this,"[[AsyncDisposableState]]","pending"),Xe.set(this,"[[DisposeCapability]]",Xg())},Jg=function(){var e=this;return Xe.assert(e,"[[AsyncDisposableState]]"),Xe.get(e,"[[AsyncDisposableState]]")==="disposed"},go=jE(Jg);Kg?HE(lt.prototype,"disposed",{"[[Configurable]]":!0,"[[Enumerable]]":!1,"[[Get]]":Jg}):lt.prototype.disposed=!1;var Qg=function(e){Xe.set(e,"[[AsyncDisposableState]]","disposed"),Kg||(e.disposed=!0)};Di(lt.prototype,"disposeAsync",function(){var e=this;return go(e)?Cp(Tp):(Qg(e),YE(Cp(Tp,VE(Xe.get(e,"[[DisposeCapability]]"),BE())),function(t){return t["?"]()}))});Di(lt.prototype,"use",function(e){var t=this;if(go(t))throw new ol("a disposed stack can not use anything new");return sh(Xe.get(t,"[[DisposeCapability]]"),e,"ASYNC-DISPOSE"),e});Di(lt.prototype,"adopt",function(e,t){var r=this;if(go(r))throw new ol("a disposed stack can not use anything new");if(!Yg(t))throw new ih("`onDisposeAsync` must be a function");var i=function(){return WE(t,void 0,[e])};return i.value=e,sh(Xe.get(r,"[[DisposeCapability]]"),void 0,"ASYNC-DISPOSE",i),e});Di(lt.prototype,"defer",function(e){var t=this;if(go(t))throw new ol("a disposed stack can not defer anything new");if(!Yg(e))throw new ih("`onDispose` must be a function");sh(Xe.get(t,"[[DisposeCapability]]"),void 0,"ASYNC-DISPOSE",e)});Di(lt.prototype,"move",function(){var e=this;if(go(e))throw new ol("a disposed stack can not use anything new");var t=new lt;return Xe.set(t,"[[DisposeCapability]]",Xe.get(e,"[[DisposeCapability]]")),Xe.set(e,"[[DisposeCapability]]",Xg()),Qg(e),t});Pp&&Di(lt.prototype,Pp,lt.prototype.disposeAsync);GE(lt.prototype,"AsyncDisposableStack");var XE=lt,KE=XE,JE=function(){return typeof AsyncDisposableStack=="function"?AsyncDisposableStack:KE},QE=xr,ex=Du(),tx=JE,nx=function(){var e=tx();return QE(ex,{AsyncDisposableStack:e},{AsyncDisposableStack:!0}),e},rx=QS,ix=a_,sx=FE,ox=nx,ax=function(){rx(),ix(),sx(),ox()};ax();const Rp=new WeakMap;function lx(n){return(typeof n=="object"||typeof n=="function")&&n!==null&&"then"in n&&typeof n.then=="function"}function Nr(n){return typeof n=="string"?n:typeof n=="symbol"?n.description??n.toString():n.name||"(anonymous class)"}function Dp(){return new Error("register(Key, factory) requires a factory function. Wrap existing instances as () => instance.")}function cx(){return new Error("register(Key, factory) does not accept async factories. Await setup before registering.")}class ux{constructor(){b(this,"entries",new Map);b(this,"constructionStack",[])}register(e,t){if(t===void 0){if(typeof e!="function")throw Dp();this.validateClassRegistration(e),this.storeFactory(e,()=>this.instantiateClass(e));return}if(typeof t!="function")throw Dp();if(t.constructor.name==="AsyncFunction")throw cx();this.storeFactory(e,t)}has(e){var t;return((t=this.entries.get(e))==null?void 0:t.factory)!==void 0}resolve(e){return this.resolveAny(e)}storeFactory(e,t){const r=this.getOrCreateEntry(e);r.factory=t,r.instance=void 0,r.error=void 0}validateClassRegistration(e){const t=Rp.get(e);if(t){if(e.length!==t.length)throw new Error(`${Nr(e)} cannot be registered with register(Class). @injectable(...) declared ${t.length} dependencies but constructor arity is ${e.length}. Use register(Key, () => value) instead.`);return}if(e.length!==0)throw new Error(`${Nr(e)} cannot be registered with register(Class). Undecorated classes must have zero required constructor parameters. Use register(Key, () => value) instead.`)}instantiateClass(e){const t=Rp.get(e);if(!t)return new e;const r=t.map(i=>this.resolveAny(i));return new e(...r)}resolveAny(e){return this.getOrCreateEntry(e).proxy}getOrCreateEntry(e){let t=this.entries.get(e);return t||(t={key:e},t.proxy=this.createProxy(t),this.entries.set(e,t),t)}createProxy(e){return new Proxy({},{get:(t,r)=>{if(r==="then")return;const i=this.getInstance(e),s=Reflect.get(i,r,i);return typeof s=="function"?s.bind(i):s},set:(t,r,i)=>{const s=this.getInstance(e);return Reflect.set(s,r,i,s)},has:(t,r)=>{const i=this.getInstance(e);return r in i}})}getInstance(e){if(e.instance)return e.instance;if(e.error)throw e.error;if(!e.factory)throw new Error(`${Nr(e.key)} was resolved but never registered`);const t=this.constructionStack.indexOf(e.key);if(t!==-1){const r=[...this.constructionStack.slice(t),e.key].map(i=>Nr(i)).join(" -> ");throw new Error(`Circular dependency detected: ${r}`)}this.constructionStack.push(e.key);try{const r=e.factory();if(lx(r))throw new Error(`Factory for ${Nr(e.key)} returned a Promise. Await setup before registering.`);if(typeof r!="object"||r===null)throw new Error(`Factory for ${Nr(e.key)} returned a non-object value. Wrap primitives in an object.`);return e.instance=r,r}catch(r){throw e.error=r,r}finally{this.constructionStack.pop()}}}const zt=new ux,hx=new Set(["target","currentTarget","eventPhase","defaultPrevented","isTrusted","timeStamp","srcElement","returnValue","cancelBubble","NONE","CAPTURING_PHASE","AT_TARGET","BUBBLING_PHASE","composedPath","stopPropagation","stopImmediatePropagation","preventDefault","initEvent"]);function dx(n){for(const e of Object.keys(n))if(hx.has(e))throw new Error(`Event payload key "${e}" is reserved; choose a different property name`)}function px(n,e){dx(e);for(const t of Object.keys(e))Object.defineProperty(n,t,{value:e[t],writable:!0,enumerable:!0,configurable:!0})}function nt(){class n extends Event{constructor(t,r){const{type:i,bubbles:s,cancelable:o,composed:a,...c}=r??{};if(i!==void 0)throw new Error('Do not pass "type" in init; use the constructor argument instead');super(t,{bubbles:s,cancelable:o,composed:a}),px(this,c)}}return n}class Ot extends globalThis.EventTarget{}function fx(n,e,t){const r=n.dispose.bind(n);n.dispose=()=>{if(!e())return t(),r()}}function mo(n){var t;class e extends n{constructor(...s){super(...s);w(this,t,!1);fx(this,()=>l(this,t),()=>{x(this,t,!0)})}[Symbol.dispose](){this.dispose()}get disposed(){return l(this,t)}}return t=new WeakMap,e}const gx=nt(),mx=nt(),ta=nt(),em="0123456789ABCDEFGHJKMNPQRSTVWXYZ",ya=32,vx=16,tm=10,Lp=0xffffffffffff;var qn;(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"})(qn||(qn={}));class Ji extends Error{constructor(e,t){super(`${t} (${e})`),this.name="ULIDError",this.code=e}}function yx(n){const e=Math.floor(n()*ya)%ya;return em.charAt(e)}function bx(n){const e=wx(),t=e&&(e.crypto||e.msCrypto)||null;if(typeof(t==null?void 0:t.getRandomValues)=="function")return()=>{const r=new Uint8Array(1);return t.getRandomValues(r),r[0]/256};if(typeof(t==null?void 0:t.randomBytes)=="function")return()=>t.randomBytes(1).readUInt8()/256;throw new Ji(qn.PRNGDetectFailure,"Failed to find a reliable PRNG")}function wx(){return kx()?self:typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:null}function Sx(n,e){let t="";for(;n>0;n--)t=yx(e)+t;return t}function _x(n,e=tm){if(isNaN(n))throw new Ji(qn.EncodeTimeValueMalformed,`Time must be a number: ${n}`);if(n>Lp)throw new Ji(qn.EncodeTimeSizeExceeded,`Cannot encode a time larger than ${Lp}: ${n}`);if(n<0)throw new Ji(qn.EncodeTimeNegative,`Time must be positive: ${n}`);if(Number.isInteger(n)===!1)throw new Ji(qn.EncodeTimeValueMalformed,`Time must be an integer: ${n}`);let t,r="";for(let i=e;i>0;i--)t=n%ya,r=em.charAt(t)+r,n=(n-t)/ya;return r}function kx(){return typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope}function al(n,e){const t=bx(),r=Date.now();return _x(r,tm)+Sx(vx,t)}const wt=4,tt=6,ds=2,Nc=2,oh=8,Ex=tt,ah="auto",An="auto",hn=120,zp=50,ce=16,br=hn*wt+ce*(wt-1),ba=hn*tt+ce*(tt-1),xx=br+ce*2,Ax=200,$x=4,zo=150,Ix=10,Op=2,Mp=8,Tx=300,Cx=4;function nm(n){return sm(n)}function rm(n,e){return sm(n.flatMap(t=>am(t,e)))}function im(n){const e=[],t=new Set;for(const r of n){if(r.type==="row"){e.push(`Top-level rows are invalid: ${r.id}`);continue}lm(r,"strip",e,t)}return{valid:e.length===0,errors:e}}function Xr(n){const e=nm(n),t=im(e);if(!t.valid)throw new Error(`Invalid layout: ${t.errors.join("; ")}`);return{totalNodes:e.length,nodes:e.filter(r=>r.type!=="row").map(Lx)}}function sm(n){const e=[];for(const t of n){const r=om(t);for(const i of r){if(i.type==="row"){e.push(...i.children.map(en));continue}e.push(i)}}return e}function om(n){switch(n.type){case"card":return[en(n)];case"row":{const e=n.children.map(en);return e.length===0?[]:e.length===1?[e[0]]:[{...n,children:e}]}case"stack":{const e=[];for(const t of n.children){const r=om(t);for(const i of r){if(i.type==="stack"){e.push(...i.children.map(Uc));continue}if(i.type==="row"){e.push({...i,children:i.children.map(en)});continue}e.push(en(i))}}return e.length===0?[]:e.length===1?[Uc(e[0])]:[{...n,children:e}]}}}function am(n,e){switch(n.type){case"card":return n.artifactID===e?[]:[en(n)];case"row":{const t=n.children.filter(r=>r.artifactID!==e).map(en);return t.length===0?[]:t.length===1?[t[0]]:[{...n,children:t}]}case"stack":{const t=n.children.flatMap(r=>am(r,e).filter(s=>s.type!=="stack"));return t.length===0?[]:t.length===1?[Uc(t[0])]:[{...n,children:t}]}}}function lm(n,e,t,r){switch(n.type){case"card":cm(n,e,t,r);return;case"row":Px(n,e,t,r);return;case"stack":Rx(n,e,t,r);return}}function cm(n,e,t,r){lh(n.id,t),typeof n.artifactID!="string"||n.artifactID.length===0?t.push(`Card ${n.id} is missing artifactID`):r.has(n.artifactID)?t.push(`Duplicate artifactID in layout: ${n.artifactID}`):r.add(n.artifactID),Dx(n.width)||t.push(`Card ${n.id} width must be an integer in the range ${ds}-${oh}`),um(n.height)||t.push(`Card ${n.id} height must be an integer in the range 2-6 or "auto"`);const i=Bn(n.width);e==="row"&&i<ds&&t.push(`Row child ${n.id} must be at least 2 columns wide`)}function Px(n,e,t,r){if(lh(n.id,t),e!=="stack"&&t.push(`Row ${n.id} may only appear inside a stack`),um(n.height,Cx)||t.push(`Row ${n.id} height must be an integer in the range 2-4 or "auto"`),!Array.isArray(n.children)||n.children.length===0){t.push(`Row ${n.id} must contain card nodes`);return}let i=0;for(const s of n.children){if(s.type!=="card"){t.push(`Row ${n.id} must contain only card nodes`);continue}cm(s,"row",t,r),i+=Bn(s.width)}i!==wt&&t.push(`Row ${n.id} children must sum to 4 columns`)}function Rx(n,e,t,r){if(lh(n.id,t),e!=="strip"&&t.push(`Invalid nested stack at ${n.id}; stack children cannot contain another nested stack`),!Array.isArray(n.children)||n.children.length===0){t.push(`Stack ${n.id} must contain at least one child`);return}let i=0,s=0;for(const a of n.children){if(a.type==="stack"){t.push(`Stack ${n.id} cannot contain another nested stack`);continue}if(lm(a,"stack",t,r),a.height===An){s+=1;continue}i+=a.height}if(i>tt&&t.push(`Stack ${n.id} exceeds the 6-row budget`),s===0)return;const o=tt-i;if(o<s*Nc||o%s!==0){t.push(`Stack ${n.id} has auto-height children that cannot resolve to whole height >= 2`);return}o/s<Nc&&t.push(`Stack ${n.id} has auto-height children below the minimum row size`)}function lh(n,e){(typeof n!="string"||n.length===0)&&e.push(`Node id must be a non-empty string: ${String(n)}`)}function Dx(n){return n===ah||Number.isInteger(n)&&n>=ds&&n<=oh}function um(n,e=Ex){return n===An||Number.isInteger(n)&&n>=Nc&&n<=e}function Bn(n){return n===ah?wt:n}function Lx(n){if(n.type==="card")return{id:n.id,type:"card",width:Bn(n.width),cards:[{id:n.id,artifactID:n.artifactID,col:1,row:1,width:Bn(n.width),height:hm(n.height,tt)}]};const e=zx(n.children),t=[];let r=1;for(let i=0;i<n.children.length;i+=1){const s=n.children[i],o=e[i];if(s.type==="card")t.push({id:s.id,artifactID:s.artifactID,col:1,row:r,width:Math.min(wt,Bn(s.width)),height:o});else{let a=1;for(const c of s.children)t.push({id:c.id,artifactID:c.artifactID,col:a,row:r,width:Bn(c.width),height:o}),a+=Bn(c.width)}r+=o}return{id:n.id,type:"stack",width:t.reduce((i,s)=>Math.max(i,s.col+s.width-1),1),cards:t}}function zx(n){let e=0,t=0;for(const i of n)i.height===An?t+=1:e+=i.height;const r=t>0?(tt-e)/t:0;return n.map(i=>hm(i.height,r))}function hm(n,e){return n===An?e:n}function en(n){return{...n}}function Uc(n){return n.type==="card"?en(n):{...n,children:n.children.map(en)}}function dm(n,e={}){return{id:e.id??al(),type:"card",artifactID:n,width:e.width??ah,height:e.height??An}}function pm(n,e){return n.some(t=>fm(t,e))}function fm(n,e){switch(n.type){case"card":return n.artifactID===e;case"row":return n.children.some(t=>t.artifactID===e);case"stack":return n.children.some(t=>fm(t,e))}}function Np(n){return n.layout.flatMap(gm)}function gm(n){switch(n.type){case"card":return[n.artifactID];case"row":return n.children.map(e=>e.artifactID);case"stack":return n.children.flatMap(gm)}}const ie=nt(),mm=nt(),Ur=nt(),Ox=nt();function Mx(n){class e extends Error{constructor(r,i){super(r),this.name=n,i&&Object.assign(this,i)}}return e}const Nx=Mx("RequestError"),Ux=200,Fx=300;class Zx{constructor(e,t){b(this,"serverURL");b(this,"token");this.serverURL=e.replace(/\/$/,""),this.token=t.token}async requestJSON(e,t,r){const i=await this.request(e,t,r!==void 0?JSON.stringify(r):void 0,r!==void 0?{"content-type":"application/json"}:void 0),s=await Wx(i);if(!i.ok||i.status<Ux||i.status>=Fx)throw this.createError(typeof s.error=="string"?s.error:i.statusText,i.status);return s}async requestVoid(e,t){const r=await this.request(e,t);if(!r.ok)throw this.createError(await ac(r,r.statusText),r.status)}async requestText(e,t){const r=await this.request(e,t);if(!r.ok)throw this.createError(await ac(r,r.statusText),r.status);return r.text()}async requestRawVoid(e,t,r){const i=await this.request(e,t,r,{"content-type":"text/plain"});if(!i.ok)throw this.createError(await ac(i,i.statusText),i.status)}createError(e,t){const r={serverURL:this.serverURL};return t!==void 0&&(r.status=t),new Nx(e,r)}async request(e,t,r,i){const s=`${this.serverURL}${t}`;try{return await fetch(s,{method:e,headers:this.buildHeaders(i),body:r})}catch(o){throw this.createError(o instanceof Error?o.message:"Failed to reach server")}}buildHeaders(e){const t={...e??{}};return this.token&&(t.Authorization=`Bearer ${this.token}`),Object.keys(t).length>0?t:void 0}}async function Wx(n){try{return await n.json()}catch{const e=await n.text().catch(()=>"");return e?{message:e}:{}}}async function ac(n,e){try{const t=await n.json();if(typeof t.error=="string")return t.error;if(typeof t.message=="string")return t.message}catch{}return e}function Hx(n){return n.map(e=>`${e.name} (${e.id})`).join(", ")}var It,Ra,vm;class Vx{constructor(e){w(this,Ra);w(this,It);x(this,It,e)}list(){return l(this,It).requestJSON("GET","/screens")}async get(e={}){const t=await f(this,Ra,vm).call(this,e.screenID);return l(this,It).requestJSON("GET",`/screens/${encodeURIComponent(t)}`)}create(e){const t={name:e.name};return e.id!==void 0&&(t.id=e.id),l(this,It).requestJSON("POST","/screens",t)}update(e){const{screenID:t,...r}=e;return l(this,It).requestJSON("PATCH",`/screens/${encodeURIComponent(t)}`,r)}remove(e){return l(this,It).requestJSON("DELETE",`/screens/${encodeURIComponent(e.screenID)}`)}}It=new WeakMap,Ra=new WeakSet,vm=async function(e){if(e!==void 0)return e;const{screens:t}=await this.list();if(t.length===1)return t[0].id;throw l(this,It).createError(`screenID is required when multiple screens exist. Available screens: ${Hx(t)}`)};var Le;class Bx{constructor(e){w(this,Le);x(this,Le,e)}create(e){const t={type:e.type,title:e.title};return e.externalFilePath!==void 0&&(t.externalFilePath=e.externalFilePath),e.externalURL!==void 0&&(t.externalURL=e.externalURL),e.screenID!==void 0&&(t.screenID=e.screenID),l(this,Le).requestJSON("POST","/artifacts",t)}list(e={}){const t=new URLSearchParams;e.screenID!==void 0&&t.set("screenID",e.screenID),e.unplaced&&t.set("unplaced","true");const r=t.toString();return l(this,Le).requestJSON("GET",r?`/artifacts?${r}`:"/artifacts")}get(e){return l(this,Le).requestJSON("GET",`/artifacts/${encodeURIComponent(e.artifactID)}`)}update(e){const t={};return e.title!==void 0&&(t.title=e.title),l(this,Le).requestJSON("PATCH",`/artifacts/${encodeURIComponent(e.artifactID)}`,t)}edit(e){return l(this,Le).requestJSON("POST",`/artifacts/${encodeURIComponent(e.artifactID)}/edit`)}commitPending(e){return l(this,Le).requestJSON("POST",`/artifacts/${encodeURIComponent(e.artifactID)}/commit`)}abandonPending(e){return l(this,Le).requestVoid("POST",`/artifacts/${encodeURIComponent(e.artifactID)}/abandon`)}attach(e){return l(this,Le).requestJSON("POST",`/screens/${encodeURIComponent(e.screenID)}/artifacts/${encodeURIComponent(e.artifactID)}`)}detach(e){return l(this,Le).requestJSON("DELETE",`/screens/${encodeURIComponent(e.screenID)}/artifacts/${encodeURIComponent(e.artifactID)}`)}delete(e){return l(this,Le).requestJSON("DELETE",`/artifacts/${encodeURIComponent(e.artifactID)}`)}getContent(e){return l(this,Le).requestText("GET",`/artifacts/${encodeURIComponent(e.artifactID)}/content`)}putContent(e){return l(this,Le).requestRawVoid("PUT",`/artifacts/${encodeURIComponent(e.artifactID)}/content`,e.content)}}Le=new WeakMap;var Kn;class Gx{constructor(e){w(this,Kn);x(this,Kn,e)}state(){return l(this,Kn).requestJSON("GET","/viewer/state")}setActive(e){return l(this,Kn).requestJSON("PUT","/viewer/active-screen",{screenID:e.screenID})}focus(e){const t={artifactID:e.artifactID};return e.screenID!==void 0&&(t.screenID=e.screenID),l(this,Kn).requestJSON("POST","/viewer/focus",t)}}Kn=new WeakMap;var bs;class jx{constructor(e){w(this,bs);x(this,bs,e)}async list(){const{views:e}=await l(this,bs).requestJSON("GET","/views");return e}}bs=new WeakMap;var Bt;class qx{constructor(e,t={}){b(this,"screens");b(this,"artifacts");b(this,"viewer");b(this,"views");w(this,Bt);x(this,Bt,new Zx(e,t)),this.screens=new Vx(l(this,Bt)),this.artifacts=new Bx(l(this,Bt)),this.viewer=new Gx(l(this,Bt)),this.views=new jx(l(this,Bt))}health(){return l(this,Bt).requestJSON("GET","/health")}}Bt=new WeakMap;const Yx={focusCommandInput:{label:"Focus Command Input",trigger:{key:"k",meta:!0}}},Xx=mo(Ot);var Jn,Be,Qn,Ne,pt,pn,fn,re,Zn,ym,ws,bm,wm,Sm,_m,Fc,Zc,Wc,km;class Kx extends Xx{constructor(t){var i;super();w(this,re);b(this,"id");b(this,"server");w(this,Jn);w(this,Be,new Map);w(this,Qn);w(this,Ne);w(this,pt);w(this,pn);w(this,fn,null);w(this,ws,t=>{if(this.disposed)return;const r=t.event;switch(r.type){case"screen-updated":r.screen.id===this.id&&f(this,re,bm).call(this,r.screen);break;case"artifact-created":break;case"artifact-attached":r.screenID===this.id&&f(this,re,wm).call(this,r.cardID,r.artifact);break;case"artifact-updated":f(this,re,Sm).call(this,r.artifact);break;case"artifact-removed":r.screenID===this.id&&f(this,re,_m).call(this,r.artifactID);break;case"artifact-content-changed":l(this,Be).has(r.artifactID)&&this.dispatchEvent(new Ox("artifact-content-changed",{artifactID:r.artifactID}));break}});this.id=t.screen.id,this.server=t.server,x(this,Jn,t.localStore),x(this,Qn,t.screen.name),x(this,Ne,structuredClone(t.screen.layout)),x(this,pt,t.screen.pinned);const r=((i=l(this,Jn).get().screens[this.id])==null?void 0:i.scrollPosition)??0;x(this,pn,Math.max(0,r)),this.server.addEventListener("server-event",l(this,ws)),f(this,re,ym).call(this)}get name(){return l(this,Qn)}get layout(){return l(this,Ne)}get pinned(){return l(this,pt)}get scrollPosition(){return l(this,pn)}get artifacts(){return l(this,Be)}setScrollPosition(t){f(this,re,Zn).call(this);const r=Math.max(0,t);r!==l(this,pn)&&(x(this,pn,r),f(this,re,km).call(this),this.dispatchEvent(new ie("change")))}setLayout(t){f(this,re,Zn).call(this);const r=nm(t);if(!im(r).valid)return;const s=f(this,re,Zc).call(this);x(this,Ne,r),x(this,fn,{layout:r,snapshot:s}),this.dispatchEvent(new ie("change")),this.server.client.screens.update({screenID:this.id,layout:r.map(o=>structuredClone(o))}).catch(()=>{var o;this.disposed||((o=l(this,fn))==null?void 0:o.layout)===r&&(x(this,fn,null),f(this,re,Wc).call(this,s),this.dispatchEvent(new ie("change")))})}rename(t){f(this,re,Zn).call(this),x(this,Qn,t),this.dispatchEvent(new ie("change")),this.server.client.screens.update({screenID:this.id,name:t}).catch(()=>{})}setPinned(t){if(f(this,re,Zn).call(this),l(this,pt)===t)return;const r=l(this,pt);x(this,pt,t),this.dispatchEvent(new ie("change")),this.server.client.screens.update({screenID:this.id,pinned:t}).catch(()=>{this.disposed||l(this,pt)===t&&(x(this,pt,r),this.dispatchEvent(new ie("change")))})}async remove(){f(this,re,Zn).call(this),await this.server.client.screens.remove({screenID:this.id})}removeArtifact(t){if(f(this,re,Zn).call(this),!l(this,Be).has(t))return;const r=f(this,re,Zc).call(this);f(this,re,Fc).call(this,t),this.dispatchEvent(new ie("change")),this.server.client.artifacts.detach({artifactID:t,screenID:this.id}).catch(()=>{this.disposed||(f(this,re,Wc).call(this,r),this.dispatchEvent(new ie("change")))})}dispose(){this.server.removeEventListener("server-event",l(this,ws))}}Jn=new WeakMap,Be=new WeakMap,Qn=new WeakMap,Ne=new WeakMap,pt=new WeakMap,pn=new WeakMap,fn=new WeakMap,re=new WeakSet,Zn=function(){if(this.disposed)throw new Error("ScreenModel is disposed")},ym=async function(){try{const t=await this.server.client.screens.get({screenID:this.id});if(this.disposed)return;for(const r of t.artifacts)l(this,Be).set(r.id,r);this.dispatchEvent(new ie("change"))}catch{}},ws=new WeakMap,bm=function(t){l(this,fn)&&x(this,fn,null),x(this,Qn,t.name),x(this,Ne,structuredClone(t.layout)),x(this,pt,t.pinned),this.dispatchEvent(new ie("change"))},wm=function(t,r){pm(l(this,Ne),r.id)||x(this,Ne,[...l(this,Ne),dm(r.id,{id:t})]),l(this,Be).set(r.id,r),this.dispatchEvent(new ie("change"))},Sm=function(t){const r=l(this,Be).get(t.id);r&&(l(this,Be).set(t.id,{...r,...t}),this.dispatchEvent(new ie("change")))},_m=function(t){f(this,re,Fc).call(this,t)&&this.dispatchEvent(new ie("change"))},Fc=function(t){const r=l(this,Be).delete(t),i=Np({layout:l(this,Ne)}).length,s=rm(l(this,Ne),t),o=Np({layout:s}).length;return x(this,Ne,s),r||i!==o},Zc=function(){return{layout:structuredClone(l(this,Ne)),artifacts:new Map([...l(this,Be).entries()].map(([t,r])=>[t,structuredClone(r)]))}},Wc=function(t){x(this,Ne,structuredClone(t.layout)),l(this,Be).clear();for(const[r,i]of t.artifacts)l(this,Be).set(r,structuredClone(i))},km=function(){const t=l(this,Jn).get();l(this,Jn).set({...t,screens:{...t.screens,[this.id]:{scrollPosition:l(this,pn)}}})};const Jx=mo(Ot);var it,Tt,ft,Ss,_s,ks,ti,na;class Qx extends Jx{constructor(t){super();w(this,ti);w(this,it);w(this,Tt);w(this,ft,null);w(this,Ss,()=>{this.disposed||f(this,ti,na).call(this)});w(this,_s,()=>{this.disposed||f(this,ti,na).call(this)});w(this,ks,t=>{var i;if(this.disposed)return;const r=t.event;if(r.type==="screen-removed"&&((i=l(this,ft))==null?void 0:i.id)===r.screenID&&this.clearActive(),r.type==="viewer-active-screen-changed"){const s=l(this,Tt).servers.get(t.serverURL);s&&s.screens.has(r.screenID)&&this.setActive(t.serverURL,r.screenID)}});x(this,it,t.localStore),x(this,Tt,t.serverManager),l(this,it).addEventListener("change",l(this,Ss)),l(this,Tt).addEventListener("change",l(this,_s)),l(this,Tt).addEventListener("server-event",l(this,ks)),f(this,ti,na).call(this)}get activeScreen(){return l(this,ft)}setActive(t,r){const i=l(this,it).get();i.activeServerURL===t&&i.activeScreenID===r||l(this,it).set({...i,activeServerURL:t,activeScreenID:r})}clearActive(){const t=l(this,it).get();t.activeScreenID!==null&&l(this,it).set({...t,activeScreenID:null})}dispose(){var t;l(this,it).removeEventListener("change",l(this,Ss)),l(this,Tt).removeEventListener("change",l(this,_s)),l(this,Tt).removeEventListener("server-event",l(this,ks)),(t=l(this,ft))==null||t.dispose(),x(this,ft,null)}}it=new WeakMap,Tt=new WeakMap,ft=new WeakMap,Ss=new WeakMap,_s=new WeakMap,ks=new WeakMap,ti=new WeakSet,na=function(){var c,u,h;const{activeServerURL:t,activeScreenID:r}=l(this,it).get(),i=t?l(this,Tt).servers.get(t)??null:null,s=i&&r?i.screens.get(r)??null:null,o=((c=l(this,ft))==null?void 0:c.id)??null,a=(s==null?void 0:s.id)??null;o===a&&((u=l(this,ft))==null?void 0:u.server)===i||((h=l(this,ft))==null||h.dispose(),x(this,ft,i&&s?new Kx({screen:s,server:i,localStore:l(this,it)}):null),i&&i.acpClient.setScreenContext(s?{screenID:s.id,screenName:s.name}:null),this.dispatchEvent(new gx("active-screen-changed")))};const e1="Local",t1="store-";function dt(n){return new URL(n).origin}function n1(n){return{servers:[{url:dt(n),name:e1}],activeServerURL:null,activeScreenID:null,screens:{}}}var er,tr,nr;class r1 extends Ot{constructor(t,r,i={}){super();w(this,er);w(this,tr);w(this,nr);x(this,er,`${t1}${t}`),x(this,tr,i.storage??i1());const s=l(this,tr).getItem(l(this,er));s===null?(x(this,nr,r),l(this,tr).setItem(l(this,er),JSON.stringify(r))):x(this,nr,JSON.parse(s))}get(){return l(this,nr)}set(t){x(this,nr,t),l(this,tr).setItem(l(this,er),JSON.stringify(t)),this.dispatchEvent(new ie("change"))}}er=new WeakMap,tr=new WeakMap,nr=new WeakMap;function i1(){const n=globalThis.localStorage;if(!n)throw new Error("LocalStore: no storage adapter supplied and window.localStorage is unavailable");return n}function A(n,e,t){function r(a,c){if(a._zod||Object.defineProperty(a,"_zod",{value:{def:c,constr:o,traits:new Set},enumerable:!1}),a._zod.traits.has(n))return;a._zod.traits.add(n),e(a,c);const u=o.prototype,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=(t==null?void 0:t.Parent)??Object;class s extends i{}Object.defineProperty(s,"name",{value:n});function o(a){var c;const u=t!=null&&t.Parent?new s:this;r(u,a),(c=u._zod).deferred??(c.deferred=[]);for(const 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 t!=null&&t.Parent&&a instanceof t.Parent?!0:(u=(c=a==null?void 0:a._zod)==null?void 0:c.traits)==null?void 0:u.has(n)}}),Object.defineProperty(o,"name",{value:n}),o}class ei extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class Em extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name="ZodEncodeError"}}const xm={};function $n(n){return xm}function Am(n){const e=Object.values(n).filter(r=>typeof r=="number");return Object.entries(n).filter(([r,i])=>e.indexOf(+r)===-1).map(([r,i])=>i)}function Hc(n,e){return typeof e=="bigint"?e.toString():e}function ch(n){return{get value(){{const e=n();return Object.defineProperty(this,"value",{value:e}),e}}}}function uh(n){return n==null}function hh(n){const e=n.startsWith("^")?1:0,t=n.endsWith("$")?n.length-1:n.length;return n.slice(e,t)}function s1(n,e){const t=(n.toString().split(".")[1]||"").length,r=e.toString();let i=(r.split(".")[1]||"").length;if(i===0&&/\d?e-\d?/.test(r)){const c=r.match(/\d?e-(\d?)/);c!=null&&c[1]&&(i=Number.parseInt(c[1]))}const s=t>i?t:i,o=Number.parseInt(n.toFixed(s).replace(".","")),a=Number.parseInt(e.toFixed(s).replace(".",""));return o%a/10**s}const Up=Symbol("evaluating");function oe(n,e,t){let r;Object.defineProperty(n,e,{get(){if(r!==Up)return r===void 0&&(r=Up,r=t()),r},set(i){Object.defineProperty(n,e,{value:i})},configurable:!0})}function $r(n,e,t){Object.defineProperty(n,e,{value:t,writable:!0,enumerable:!0,configurable:!0})}function Dn(...n){const e={};for(const t of n){const r=Object.getOwnPropertyDescriptors(t);Object.assign(e,r)}return Object.defineProperties({},e)}function Fp(n){return JSON.stringify(n)}function o1(n){return n.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}const $m="captureStackTrace"in Error?Error.captureStackTrace:(...n)=>{};function wa(n){return typeof n=="object"&&n!==null&&!Array.isArray(n)}const a1=ch(()=>{var n;if(typeof navigator<"u"&&((n=navigator==null?void 0:navigator.userAgent)!=null&&n.includes("Cloudflare")))return!1;try{const e=Function;return new e(""),!0}catch{return!1}});function _i(n){if(wa(n)===!1)return!1;const e=n.constructor;if(e===void 0||typeof e!="function")return!0;const t=e.prototype;return!(wa(t)===!1||Object.prototype.hasOwnProperty.call(t,"isPrototypeOf")===!1)}function Im(n){return _i(n)?{...n}:Array.isArray(n)?[...n]:n}const l1=new Set(["string","number","symbol"]);function ki(n){return n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Ln(n,e,t){const r=new n._zod.constr(e??n._zod.def);return(!e||t!=null&&t.parent)&&(r._zod.parent=n),r}function z(n){const e=n;if(!e)return{};if(typeof e=="string")return{error:()=>e};if((e==null?void 0:e.message)!==void 0){if((e==null?void 0:e.error)!==void 0)throw new Error("Cannot specify both `message` and `error` params");e.error=e.message}return delete e.message,typeof e.error=="string"?{...e,error:()=>e.error}:e}function c1(n){return Object.keys(n).filter(e=>n[e]._zod.optin==="optional"&&n[e]._zod.optout==="optional")}const u1={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 h1(n,e){const t=n._zod.def,r=t.checks;if(r&&r.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");const s=Dn(n._zod.def,{get shape(){const o={};for(const a in e){if(!(a in t.shape))throw new Error(`Unrecognized key: "${a}"`);e[a]&&(o[a]=t.shape[a])}return $r(this,"shape",o),o},checks:[]});return Ln(n,s)}function d1(n,e){const t=n._zod.def,r=t.checks;if(r&&r.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");const s=Dn(n._zod.def,{get shape(){const o={...n._zod.def.shape};for(const a in e){if(!(a in t.shape))throw new Error(`Unrecognized key: "${a}"`);e[a]&&delete o[a]}return $r(this,"shape",o),o},checks:[]});return Ln(n,s)}function p1(n,e){if(!_i(e))throw new Error("Invalid input to extend: expected a plain object");const t=n._zod.def.checks;if(t&&t.length>0){const s=n._zod.def.shape;for(const o in e)if(Object.getOwnPropertyDescriptor(s,o)!==void 0)throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}const i=Dn(n._zod.def,{get shape(){const s={...n._zod.def.shape,...e};return $r(this,"shape",s),s}});return Ln(n,i)}function f1(n,e){if(!_i(e))throw new Error("Invalid input to safeExtend: expected a plain object");const t=Dn(n._zod.def,{get shape(){const r={...n._zod.def.shape,...e};return $r(this,"shape",r),r}});return Ln(n,t)}function g1(n,e){const t=Dn(n._zod.def,{get shape(){const r={...n._zod.def.shape,...e._zod.def.shape};return $r(this,"shape",r),r},get catchall(){return e._zod.def.catchall},checks:[]});return Ln(n,t)}function m1(n,e,t){const i=e._zod.def.checks;if(i&&i.length>0)throw new Error(".partial() cannot be used on object schemas containing refinements");const o=Dn(e._zod.def,{get shape(){const a=e._zod.def.shape,c={...a};if(t)for(const u in t){if(!(u in a))throw new Error(`Unrecognized key: "${u}"`);t[u]&&(c[u]=n?new n({type:"optional",innerType:a[u]}):a[u])}else for(const u in a)c[u]=n?new n({type:"optional",innerType:a[u]}):a[u];return $r(this,"shape",c),c},checks:[]});return Ln(e,o)}function v1(n,e,t){const r=Dn(e._zod.def,{get shape(){const i=e._zod.def.shape,s={...i};if(t)for(const o in t){if(!(o in s))throw new Error(`Unrecognized key: "${o}"`);t[o]&&(s[o]=new n({type:"nonoptional",innerType:i[o]}))}else for(const o in i)s[o]=new n({type:"nonoptional",innerType:i[o]});return $r(this,"shape",s),s}});return Ln(e,r)}function Kr(n,e=0){var t;if(n.aborted===!0)return!0;for(let r=e;r<n.issues.length;r++)if(((t=n.issues[r])==null?void 0:t.continue)!==!0)return!0;return!1}function Jr(n,e){return e.map(t=>{var r;return(r=t).path??(r.path=[]),t.path.unshift(n),t})}function Oo(n){return typeof n=="string"?n:n==null?void 0:n.message}function In(n,e,t){var i,s,o,a,c,u;const r={...n,path:n.path??[]};if(!n.message){const h=Oo((o=(s=(i=n.inst)==null?void 0:i._zod.def)==null?void 0:s.error)==null?void 0:o.call(s,n))??Oo((a=e==null?void 0:e.error)==null?void 0:a.call(e,n))??Oo((c=t.customError)==null?void 0:c.call(t,n))??Oo((u=t.localeError)==null?void 0:u.call(t,n))??"Invalid input";r.message=h}return delete r.inst,delete r.continue,e!=null&&e.reportInput||delete r.input,r}function dh(n){return Array.isArray(n)?"array":typeof n=="string"?"string":"unknown"}function ps(...n){const[e,t,r]=n;return typeof e=="string"?{message:e,code:"custom",input:t,inst:r}:{...e}}const Tm=(n,e)=>{n.name="$ZodError",Object.defineProperty(n,"_zod",{value:n._zod,enumerable:!1}),Object.defineProperty(n,"issues",{value:e,enumerable:!1}),n.message=JSON.stringify(e,Hc,2),Object.defineProperty(n,"toString",{value:()=>n.message,enumerable:!1})},Cm=A("$ZodError",Tm),Pm=A("$ZodError",Tm,{Parent:Error});function y1(n,e=t=>t.message){const t={},r=[];for(const i of n.issues)i.path.length>0?(t[i.path[0]]=t[i.path[0]]||[],t[i.path[0]].push(e(i))):r.push(e(i));return{formErrors:r,fieldErrors:t}}function b1(n,e=t=>t.message){const t={_errors:[]},r=i=>{for(const s of i.issues)if(s.code==="invalid_union"&&s.errors.length)s.errors.map(o=>r({issues:o}));else if(s.code==="invalid_key")r({issues:s.issues});else if(s.code==="invalid_element")r({issues:s.issues});else if(s.path.length===0)t._errors.push(e(s));else{let o=t,a=0;for(;a<s.path.length;){const c=s.path[a];a===s.path.length-1?(o[c]=o[c]||{_errors:[]},o[c]._errors.push(e(s))):o[c]=o[c]||{_errors:[]},o=o[c],a++}}};return r(n),t}const ph=n=>(e,t,r,i)=>{const s=r?Object.assign(r,{async:!1}):{async:!1},o=e._zod.run({value:t,issues:[]},s);if(o instanceof Promise)throw new ei;if(o.issues.length){const a=new((i==null?void 0:i.Err)??n)(o.issues.map(c=>In(c,s,$n())));throw $m(a,i==null?void 0:i.callee),a}return o.value},fh=n=>async(e,t,r,i)=>{const s=r?Object.assign(r,{async:!0}):{async:!0};let o=e._zod.run({value:t,issues:[]},s);if(o instanceof Promise&&(o=await o),o.issues.length){const a=new((i==null?void 0:i.Err)??n)(o.issues.map(c=>In(c,s,$n())));throw $m(a,i==null?void 0:i.callee),a}return o.value},ll=n=>(e,t,r)=>{const i=r?{...r,async:!1}:{async:!1},s=e._zod.run({value:t,issues:[]},i);if(s instanceof Promise)throw new ei;return s.issues.length?{success:!1,error:new(n??Cm)(s.issues.map(o=>In(o,i,$n())))}:{success:!0,data:s.value}},w1=ll(Pm),cl=n=>async(e,t,r)=>{const i=r?Object.assign(r,{async:!0}):{async:!0};let s=e._zod.run({value:t,issues:[]},i);return s instanceof Promise&&(s=await s),s.issues.length?{success:!1,error:new n(s.issues.map(o=>In(o,i,$n())))}:{success:!0,data:s.value}},S1=cl(Pm),_1=n=>(e,t,r)=>{const i=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return ph(n)(e,t,i)},k1=n=>(e,t,r)=>ph(n)(e,t,r),E1=n=>async(e,t,r)=>{const i=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return fh(n)(e,t,i)},x1=n=>async(e,t,r)=>fh(n)(e,t,r),A1=n=>(e,t,r)=>{const i=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return ll(n)(e,t,i)},$1=n=>(e,t,r)=>ll(n)(e,t,r),I1=n=>async(e,t,r)=>{const i=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return cl(n)(e,t,i)},T1=n=>async(e,t,r)=>cl(n)(e,t,r),C1=/^[cC][^\s-]{8,}$/,P1=/^[0-9a-z]+$/,R1=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,D1=/^[0-9a-vA-V]{20}$/,L1=/^[A-Za-z0-9]{27}$/,z1=/^[a-zA-Z0-9_-]{21}$/,O1=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,M1=/^([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})$/,Zp=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)$/,N1=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,U1="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function F1(){return new RegExp(U1,"u")}const Z1=/^(?:(?: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])$/,W1=/^(([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}|:))$/,H1=/^((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])$/,V1=/^(([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])$/,B1=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Rm=/^[A-Za-z0-9_-]*$/,G1=/^\+[1-9]\d{6,14}$/,Dm="(?:(?:\\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])))",j1=new RegExp(`^${Dm}$`);function Lm(n){const e="(?:[01]\\d|2[0-3]):[0-5]\\d";return typeof n.precision=="number"?n.precision===-1?`${e}`:n.precision===0?`${e}:[0-5]\\d`:`${e}:[0-5]\\d\\.\\d{${n.precision}}`:`${e}(?::[0-5]\\d(?:\\.\\d+)?)?`}function q1(n){return new RegExp(`^${Lm(n)}$`)}function Y1(n){const e=Lm({precision:n.precision}),t=["Z"];n.local&&t.push(""),n.offset&&t.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");const r=`${e}(?:${t.join("|")})`;return new RegExp(`^${Dm}T(?:${r})$`)}const X1=n=>{const e=n?`[\\s\\S]{${(n==null?void 0:n.minimum)??0},${(n==null?void 0:n.maximum)??""}}`:"[\\s\\S]*";return new RegExp(`^${e}$`)},K1=/^-?\d+$/,zm=/^-?\d+(?:\.\d+)?$/,J1=/^(?:true|false)$/i,Q1=/^[^A-Z]*$/,eA=/^[^a-z]*$/,Ke=A("$ZodCheck",(n,e)=>{var t;n._zod??(n._zod={}),n._zod.def=e,(t=n._zod).onattach??(t.onattach=[])}),Om={number:"number",bigint:"bigint",object:"date"},Mm=A("$ZodCheckLessThan",(n,e)=>{Ke.init(n,e);const t=Om[typeof e.value];n._zod.onattach.push(r=>{const i=r._zod.bag,s=(e.inclusive?i.maximum:i.exclusiveMaximum)??Number.POSITIVE_INFINITY;e.value<s&&(e.inclusive?i.maximum=e.value:i.exclusiveMaximum=e.value)}),n._zod.check=r=>{(e.inclusive?r.value<=e.value:r.value<e.value)||r.issues.push({origin:t,code:"too_big",maximum:typeof e.value=="object"?e.value.getTime():e.value,input:r.value,inclusive:e.inclusive,inst:n,continue:!e.abort})}}),Nm=A("$ZodCheckGreaterThan",(n,e)=>{Ke.init(n,e);const t=Om[typeof e.value];n._zod.onattach.push(r=>{const i=r._zod.bag,s=(e.inclusive?i.minimum:i.exclusiveMinimum)??Number.NEGATIVE_INFINITY;e.value>s&&(e.inclusive?i.minimum=e.value:i.exclusiveMinimum=e.value)}),n._zod.check=r=>{(e.inclusive?r.value>=e.value:r.value>e.value)||r.issues.push({origin:t,code:"too_small",minimum:typeof e.value=="object"?e.value.getTime():e.value,input:r.value,inclusive:e.inclusive,inst:n,continue:!e.abort})}}),tA=A("$ZodCheckMultipleOf",(n,e)=>{Ke.init(n,e),n._zod.onattach.push(t=>{var r;(r=t._zod.bag).multipleOf??(r.multipleOf=e.value)}),n._zod.check=t=>{if(typeof t.value!=typeof e.value)throw new Error("Cannot mix number and bigint in multiple_of check.");(typeof t.value=="bigint"?t.value%e.value===BigInt(0):s1(t.value,e.value)===0)||t.issues.push({origin:typeof t.value,code:"not_multiple_of",divisor:e.value,input:t.value,inst:n,continue:!e.abort})}}),nA=A("$ZodCheckNumberFormat",(n,e)=>{var o;Ke.init(n,e),e.format=e.format||"float64";const t=(o=e.format)==null?void 0:o.includes("int"),r=t?"int":"number",[i,s]=u1[e.format];n._zod.onattach.push(a=>{const c=a._zod.bag;c.format=e.format,c.minimum=i,c.maximum=s,t&&(c.pattern=K1)}),n._zod.check=a=>{const c=a.value;if(t){if(!Number.isInteger(c)){a.issues.push({expected:r,format:e.format,code:"invalid_type",continue:!1,input:c,inst:n});return}if(!Number.isSafeInteger(c)){c>0?a.issues.push({input:c,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:n,origin:r,inclusive:!0,continue:!e.abort}):a.issues.push({input:c,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:n,origin:r,inclusive:!0,continue:!e.abort});return}}c<i&&a.issues.push({origin:"number",input:c,code:"too_small",minimum:i,inclusive:!0,inst:n,continue:!e.abort}),c>s&&a.issues.push({origin:"number",input:c,code:"too_big",maximum:s,inclusive:!0,inst:n,continue:!e.abort})}}),rA=A("$ZodCheckMaxLength",(n,e)=>{var t;Ke.init(n,e),(t=n._zod.def).when??(t.when=r=>{const i=r.value;return!uh(i)&&i.length!==void 0}),n._zod.onattach.push(r=>{const i=r._zod.bag.maximum??Number.POSITIVE_INFINITY;e.maximum<i&&(r._zod.bag.maximum=e.maximum)}),n._zod.check=r=>{const i=r.value;if(i.length<=e.maximum)return;const o=dh(i);r.issues.push({origin:o,code:"too_big",maximum:e.maximum,inclusive:!0,input:i,inst:n,continue:!e.abort})}}),iA=A("$ZodCheckMinLength",(n,e)=>{var t;Ke.init(n,e),(t=n._zod.def).when??(t.when=r=>{const i=r.value;return!uh(i)&&i.length!==void 0}),n._zod.onattach.push(r=>{const i=r._zod.bag.minimum??Number.NEGATIVE_INFINITY;e.minimum>i&&(r._zod.bag.minimum=e.minimum)}),n._zod.check=r=>{const i=r.value;if(i.length>=e.minimum)return;const o=dh(i);r.issues.push({origin:o,code:"too_small",minimum:e.minimum,inclusive:!0,input:i,inst:n,continue:!e.abort})}}),sA=A("$ZodCheckLengthEquals",(n,e)=>{var t;Ke.init(n,e),(t=n._zod.def).when??(t.when=r=>{const i=r.value;return!uh(i)&&i.length!==void 0}),n._zod.onattach.push(r=>{const i=r._zod.bag;i.minimum=e.length,i.maximum=e.length,i.length=e.length}),n._zod.check=r=>{const i=r.value,s=i.length;if(s===e.length)return;const o=dh(i),a=s>e.length;r.issues.push({origin:o,...a?{code:"too_big",maximum:e.length}:{code:"too_small",minimum:e.length},inclusive:!0,exact:!0,input:r.value,inst:n,continue:!e.abort})}}),ul=A("$ZodCheckStringFormat",(n,e)=>{var t,r;Ke.init(n,e),n._zod.onattach.push(i=>{const s=i._zod.bag;s.format=e.format,e.pattern&&(s.patterns??(s.patterns=new Set),s.patterns.add(e.pattern))}),e.pattern?(t=n._zod).check??(t.check=i=>{e.pattern.lastIndex=0,!e.pattern.test(i.value)&&i.issues.push({origin:"string",code:"invalid_format",format:e.format,input:i.value,...e.pattern?{pattern:e.pattern.toString()}:{},inst:n,continue:!e.abort})}):(r=n._zod).check??(r.check=()=>{})}),oA=A("$ZodCheckRegex",(n,e)=>{ul.init(n,e),n._zod.check=t=>{e.pattern.lastIndex=0,!e.pattern.test(t.value)&&t.issues.push({origin:"string",code:"invalid_format",format:"regex",input:t.value,pattern:e.pattern.toString(),inst:n,continue:!e.abort})}}),aA=A("$ZodCheckLowerCase",(n,e)=>{e.pattern??(e.pattern=Q1),ul.init(n,e)}),lA=A("$ZodCheckUpperCase",(n,e)=>{e.pattern??(e.pattern=eA),ul.init(n,e)}),cA=A("$ZodCheckIncludes",(n,e)=>{Ke.init(n,e);const t=ki(e.includes),r=new RegExp(typeof e.position=="number"?`^.{${e.position}}${t}`:t);e.pattern=r,n._zod.onattach.push(i=>{const s=i._zod.bag;s.patterns??(s.patterns=new Set),s.patterns.add(r)}),n._zod.check=i=>{i.value.includes(e.includes,e.position)||i.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:e.includes,input:i.value,inst:n,continue:!e.abort})}}),uA=A("$ZodCheckStartsWith",(n,e)=>{Ke.init(n,e);const t=new RegExp(`^${ki(e.prefix)}.*`);e.pattern??(e.pattern=t),n._zod.onattach.push(r=>{const i=r._zod.bag;i.patterns??(i.patterns=new Set),i.patterns.add(t)}),n._zod.check=r=>{r.value.startsWith(e.prefix)||r.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:e.prefix,input:r.value,inst:n,continue:!e.abort})}}),hA=A("$ZodCheckEndsWith",(n,e)=>{Ke.init(n,e);const t=new RegExp(`.*${ki(e.suffix)}$`);e.pattern??(e.pattern=t),n._zod.onattach.push(r=>{const i=r._zod.bag;i.patterns??(i.patterns=new Set),i.patterns.add(t)}),n._zod.check=r=>{r.value.endsWith(e.suffix)||r.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:e.suffix,input:r.value,inst:n,continue:!e.abort})}}),dA=A("$ZodCheckOverwrite",(n,e)=>{Ke.init(n,e),n._zod.check=t=>{t.value=e.tx(t.value)}});class pA{constructor(e=[]){this.content=[],this.indent=0,this&&(this.args=e)}indented(e){this.indent+=1,e(this),this.indent-=1}write(e){if(typeof e=="function"){e(this,{execution:"sync"}),e(this,{execution:"async"});return}const r=e.split(`
|
|
5
|
+
`).filter(o=>o),i=Math.min(...r.map(o=>o.length-o.trimStart().length)),s=r.map(o=>o.slice(i)).map(o=>" ".repeat(this.indent*2)+o);for(const o of s)this.content.push(o)}compile(){const e=Function,t=this==null?void 0:this.args,i=[...((this==null?void 0:this.content)??[""]).map(s=>` ${s}`)];return new e(...t,i.join(`
|
|
6
|
+
`))}}const fA={major:4,minor:3,patch:6},fe=A("$ZodType",(n,e)=>{var i;var t;n??(n={}),n._zod.def=e,n._zod.bag=n._zod.bag||{},n._zod.version=fA;const r=[...n._zod.def.checks??[]];n._zod.traits.has("$ZodCheck")&&r.unshift(n);for(const s of r)for(const o of s._zod.onattach)o(n);if(r.length===0)(t=n._zod).deferred??(t.deferred=[]),(i=n._zod.deferred)==null||i.push(()=>{n._zod.run=n._zod.parse});else{const s=(a,c,u)=>{let h=Kr(a),p;for(const v of c){if(v._zod.def.when){if(!v._zod.def.when(a))continue}else if(h)continue;const m=a.issues.length,E=v._zod.check(a);if(E instanceof Promise&&(u==null?void 0:u.async)===!1)throw new ei;if(p||E instanceof Promise)p=(p??Promise.resolve()).then(async()=>{await E,a.issues.length!==m&&(h||(h=Kr(a,m)))});else{if(a.issues.length===m)continue;h||(h=Kr(a,m))}}return p?p.then(()=>a):a},o=(a,c,u)=>{if(Kr(a))return a.aborted=!0,a;const h=s(c,r,u);if(h instanceof Promise){if(u.async===!1)throw new ei;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 ei;return u.then(h=>s(h,r,c))}return s(u,r,c)}}oe(n,"~standard",()=>({validate:s=>{var o;try{const a=w1(n,s);return a.success?{value:a.data}:{issues:(o=a.error)==null?void 0:o.issues}}catch{return S1(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}))}),gh=A("$ZodString",(n,e)=>{var t;fe.init(n,e),n._zod.pattern=[...((t=n==null?void 0:n._zod.bag)==null?void 0:t.patterns)??[]].pop()??X1(n._zod.bag),n._zod.parse=(r,i)=>{if(e.coerce)try{r.value=String(r.value)}catch{}return typeof r.value=="string"||r.issues.push({expected:"string",code:"invalid_type",input:r.value,inst:n}),r}}),de=A("$ZodStringFormat",(n,e)=>{ul.init(n,e),gh.init(n,e)}),gA=A("$ZodGUID",(n,e)=>{e.pattern??(e.pattern=M1),de.init(n,e)}),mA=A("$ZodUUID",(n,e)=>{if(e.version){const r={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[e.version];if(r===void 0)throw new Error(`Invalid UUID version: "${e.version}"`);e.pattern??(e.pattern=Zp(r))}else e.pattern??(e.pattern=Zp());de.init(n,e)}),vA=A("$ZodEmail",(n,e)=>{e.pattern??(e.pattern=N1),de.init(n,e)}),yA=A("$ZodURL",(n,e)=>{de.init(n,e),n._zod.check=t=>{try{const r=t.value.trim(),i=new URL(r);e.hostname&&(e.hostname.lastIndex=0,e.hostname.test(i.hostname)||t.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:e.hostname.source,input:t.value,inst:n,continue:!e.abort})),e.protocol&&(e.protocol.lastIndex=0,e.protocol.test(i.protocol.endsWith(":")?i.protocol.slice(0,-1):i.protocol)||t.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:e.protocol.source,input:t.value,inst:n,continue:!e.abort})),e.normalize?t.value=i.href:t.value=r;return}catch{t.issues.push({code:"invalid_format",format:"url",input:t.value,inst:n,continue:!e.abort})}}}),bA=A("$ZodEmoji",(n,e)=>{e.pattern??(e.pattern=F1()),de.init(n,e)}),wA=A("$ZodNanoID",(n,e)=>{e.pattern??(e.pattern=z1),de.init(n,e)}),SA=A("$ZodCUID",(n,e)=>{e.pattern??(e.pattern=C1),de.init(n,e)}),_A=A("$ZodCUID2",(n,e)=>{e.pattern??(e.pattern=P1),de.init(n,e)}),kA=A("$ZodULID",(n,e)=>{e.pattern??(e.pattern=R1),de.init(n,e)}),EA=A("$ZodXID",(n,e)=>{e.pattern??(e.pattern=D1),de.init(n,e)}),xA=A("$ZodKSUID",(n,e)=>{e.pattern??(e.pattern=L1),de.init(n,e)}),AA=A("$ZodISODateTime",(n,e)=>{e.pattern??(e.pattern=Y1(e)),de.init(n,e)}),$A=A("$ZodISODate",(n,e)=>{e.pattern??(e.pattern=j1),de.init(n,e)}),IA=A("$ZodISOTime",(n,e)=>{e.pattern??(e.pattern=q1(e)),de.init(n,e)}),TA=A("$ZodISODuration",(n,e)=>{e.pattern??(e.pattern=O1),de.init(n,e)}),CA=A("$ZodIPv4",(n,e)=>{e.pattern??(e.pattern=Z1),de.init(n,e),n._zod.bag.format="ipv4"}),PA=A("$ZodIPv6",(n,e)=>{e.pattern??(e.pattern=W1),de.init(n,e),n._zod.bag.format="ipv6",n._zod.check=t=>{try{new URL(`http://[${t.value}]`)}catch{t.issues.push({code:"invalid_format",format:"ipv6",input:t.value,inst:n,continue:!e.abort})}}}),RA=A("$ZodCIDRv4",(n,e)=>{e.pattern??(e.pattern=H1),de.init(n,e)}),DA=A("$ZodCIDRv6",(n,e)=>{e.pattern??(e.pattern=V1),de.init(n,e),n._zod.check=t=>{const r=t.value.split("/");try{if(r.length!==2)throw new Error;const[i,s]=r;if(!s)throw new Error;const o=Number(s);if(`${o}`!==s)throw new Error;if(o<0||o>128)throw new Error;new URL(`http://[${i}]`)}catch{t.issues.push({code:"invalid_format",format:"cidrv6",input:t.value,inst:n,continue:!e.abort})}}});function Um(n){if(n==="")return!0;if(n.length%4!==0)return!1;try{return atob(n),!0}catch{return!1}}const LA=A("$ZodBase64",(n,e)=>{e.pattern??(e.pattern=B1),de.init(n,e),n._zod.bag.contentEncoding="base64",n._zod.check=t=>{Um(t.value)||t.issues.push({code:"invalid_format",format:"base64",input:t.value,inst:n,continue:!e.abort})}});function zA(n){if(!Rm.test(n))return!1;const e=n.replace(/[-_]/g,r=>r==="-"?"+":"/"),t=e.padEnd(Math.ceil(e.length/4)*4,"=");return Um(t)}const OA=A("$ZodBase64URL",(n,e)=>{e.pattern??(e.pattern=Rm),de.init(n,e),n._zod.bag.contentEncoding="base64url",n._zod.check=t=>{zA(t.value)||t.issues.push({code:"invalid_format",format:"base64url",input:t.value,inst:n,continue:!e.abort})}}),MA=A("$ZodE164",(n,e)=>{e.pattern??(e.pattern=G1),de.init(n,e)});function NA(n,e=null){try{const t=n.split(".");if(t.length!==3)return!1;const[r]=t;if(!r)return!1;const i=JSON.parse(atob(r));return!("typ"in i&&(i==null?void 0:i.typ)!=="JWT"||!i.alg||e&&(!("alg"in i)||i.alg!==e))}catch{return!1}}const UA=A("$ZodJWT",(n,e)=>{de.init(n,e),n._zod.check=t=>{NA(t.value,e.alg)||t.issues.push({code:"invalid_format",format:"jwt",input:t.value,inst:n,continue:!e.abort})}}),Fm=A("$ZodNumber",(n,e)=>{fe.init(n,e),n._zod.pattern=n._zod.bag.pattern??zm,n._zod.parse=(t,r)=>{if(e.coerce)try{t.value=Number(t.value)}catch{}const i=t.value;if(typeof i=="number"&&!Number.isNaN(i)&&Number.isFinite(i))return t;const s=typeof i=="number"?Number.isNaN(i)?"NaN":Number.isFinite(i)?void 0:"Infinity":void 0;return t.issues.push({expected:"number",code:"invalid_type",input:i,inst:n,...s?{received:s}:{}}),t}}),FA=A("$ZodNumberFormat",(n,e)=>{nA.init(n,e),Fm.init(n,e)}),ZA=A("$ZodBoolean",(n,e)=>{fe.init(n,e),n._zod.pattern=J1,n._zod.parse=(t,r)=>{if(e.coerce)try{t.value=!!t.value}catch{}const i=t.value;return typeof i=="boolean"||t.issues.push({expected:"boolean",code:"invalid_type",input:i,inst:n}),t}}),WA=A("$ZodUnknown",(n,e)=>{fe.init(n,e),n._zod.parse=t=>t}),HA=A("$ZodNever",(n,e)=>{fe.init(n,e),n._zod.parse=(t,r)=>(t.issues.push({expected:"never",code:"invalid_type",input:t.value,inst:n}),t)});function Wp(n,e,t){n.issues.length&&e.issues.push(...Jr(t,n.issues)),e.value[t]=n.value}const VA=A("$ZodArray",(n,e)=>{fe.init(n,e),n._zod.parse=(t,r)=>{const i=t.value;if(!Array.isArray(i))return t.issues.push({expected:"array",code:"invalid_type",input:i,inst:n}),t;t.value=Array(i.length);const s=[];for(let o=0;o<i.length;o++){const a=i[o],c=e.element._zod.run({value:a,issues:[]},r);c instanceof Promise?s.push(c.then(u=>Wp(u,t,o))):Wp(c,t,o)}return s.length?Promise.all(s).then(()=>t):t}});function Sa(n,e,t,r,i){if(n.issues.length){if(i&&!(t in r))return;e.issues.push(...Jr(t,n.issues))}n.value===void 0?t in r&&(e.value[t]=void 0):e.value[t]=n.value}function Zm(n){var r,i,s,o;const e=Object.keys(n.shape);for(const a of e)if(!((o=(s=(i=(r=n.shape)==null?void 0:r[a])==null?void 0:i._zod)==null?void 0:s.traits)!=null&&o.has("$ZodType")))throw new Error(`Invalid element at key "${a}": expected a Zod schema`);const t=c1(n.shape);return{...n,keys:e,keySet:new Set(e),numKeys:e.length,optionalKeys:new Set(t)}}function Wm(n,e,t,r,i,s){const o=[],a=i.keySet,c=i.catchall._zod,u=c.def.type,h=c.optout==="optional";for(const p in e){if(a.has(p))continue;if(u==="never"){o.push(p);continue}const v=c.run({value:e[p],issues:[]},r);v instanceof Promise?n.push(v.then(m=>Sa(m,t,p,e,h))):Sa(v,t,p,e,h)}return o.length&&t.issues.push({code:"unrecognized_keys",keys:o,input:e,inst:s}),n.length?Promise.all(n).then(()=>t):t}const BA=A("$ZodObject",(n,e)=>{fe.init(n,e);const t=Object.getOwnPropertyDescriptor(e,"shape");if(!(t!=null&&t.get)){const a=e.shape;Object.defineProperty(e,"shape",{get:()=>{const c={...a};return Object.defineProperty(e,"shape",{value:c}),c}})}const r=ch(()=>Zm(e));oe(n._zod,"propValues",()=>{const a=e.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=wa,s=e.catchall;let o;n._zod.parse=(a,c)=>{o??(o=r.value);const u=a.value;if(!i(u))return a.issues.push({expected:"object",code:"invalid_type",input:u,inst:n}),a;a.value={};const h=[],p=o.shape;for(const v of o.keys){const m=p[v],E=m._zod.optout==="optional",k=m._zod.run({value:u[v],issues:[]},c);k instanceof Promise?h.push(k.then(T=>Sa(T,a,v,u,E))):Sa(k,a,v,u,E)}return s?Wm(h,u,a,c,r.value,n):h.length?Promise.all(h).then(()=>a):a}}),GA=A("$ZodObjectJIT",(n,e)=>{BA.init(n,e);const t=n._zod.parse,r=ch(()=>Zm(e)),i=v=>{var V;const m=new pA(["shape","payload","ctx"]),E=r.value,k=F=>{const B=Fp(F);return`shape[${B}]._zod.run({ value: input[${B}], issues: [] }, ctx)`};m.write("const input = payload.value;");const T=Object.create(null);let O=0;for(const F of E.keys)T[F]=`key_${O++}`;m.write("const newResult = {};");for(const F of E.keys){const B=T[F],U=Fp(F),Q=v[F],j=((V=Q==null?void 0:Q._zod)==null?void 0:V.optout)==="optional";m.write(`const ${B} = ${k(F)};`),j?m.write(`
|
|
7
|
+
if (${B}.issues.length) {
|
|
8
|
+
if (${U} in input) {
|
|
9
|
+
payload.issues = payload.issues.concat(${B}.issues.map(iss => ({
|
|
10
|
+
...iss,
|
|
11
|
+
path: iss.path ? [${U}, ...iss.path] : [${U}]
|
|
12
|
+
})));
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
if (${B}.value === undefined) {
|
|
17
|
+
if (${U} in input) {
|
|
18
|
+
newResult[${U}] = undefined;
|
|
19
|
+
}
|
|
20
|
+
} else {
|
|
21
|
+
newResult[${U}] = ${B}.value;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
`):m.write(`
|
|
25
|
+
if (${B}.issues.length) {
|
|
26
|
+
payload.issues = payload.issues.concat(${B}.issues.map(iss => ({
|
|
27
|
+
...iss,
|
|
28
|
+
path: iss.path ? [${U}, ...iss.path] : [${U}]
|
|
29
|
+
})));
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
if (${B}.value === undefined) {
|
|
33
|
+
if (${U} in input) {
|
|
34
|
+
newResult[${U}] = undefined;
|
|
35
|
+
}
|
|
36
|
+
} else {
|
|
37
|
+
newResult[${U}] = ${B}.value;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
`)}m.write("payload.value = newResult;"),m.write("return payload;");const P=m.compile();return(F,B)=>P(v,F,B)};let s;const o=wa,a=!xm.jitless,u=a&&a1.value,h=e.catchall;let p;n._zod.parse=(v,m)=>{p??(p=r.value);const E=v.value;return o(E)?a&&u&&(m==null?void 0:m.async)===!1&&m.jitless!==!0?(s||(s=i(e.shape)),v=s(v,m),h?Wm([],E,v,m,p,n):v):t(v,m):(v.issues.push({expected:"object",code:"invalid_type",input:E,inst:n}),v)}});function Hp(n,e,t,r){for(const s of n)if(s.issues.length===0)return e.value=s.value,e;const i=n.filter(s=>!Kr(s));return i.length===1?(e.value=i[0].value,i[0]):(e.issues.push({code:"invalid_union",input:e.value,inst:t,errors:n.map(s=>s.issues.map(o=>In(o,r,$n())))}),e)}const jA=A("$ZodUnion",(n,e)=>{fe.init(n,e),oe(n._zod,"optin",()=>e.options.some(i=>i._zod.optin==="optional")?"optional":void 0),oe(n._zod,"optout",()=>e.options.some(i=>i._zod.optout==="optional")?"optional":void 0),oe(n._zod,"values",()=>{if(e.options.every(i=>i._zod.values))return new Set(e.options.flatMap(i=>Array.from(i._zod.values)))}),oe(n._zod,"pattern",()=>{if(e.options.every(i=>i._zod.pattern)){const i=e.options.map(s=>s._zod.pattern);return new RegExp(`^(${i.map(s=>hh(s.source)).join("|")})$`)}});const t=e.options.length===1,r=e.options[0]._zod.run;n._zod.parse=(i,s)=>{if(t)return r(i,s);let o=!1;const a=[];for(const c of e.options){const u=c._zod.run({value:i.value,issues:[]},s);if(u instanceof Promise)a.push(u),o=!0;else{if(u.issues.length===0)return u;a.push(u)}}return o?Promise.all(a).then(c=>Hp(c,i,n,s)):Hp(a,i,n,s)}}),qA=A("$ZodIntersection",(n,e)=>{fe.init(n,e),n._zod.parse=(t,r)=>{const i=t.value,s=e.left._zod.run({value:i,issues:[]},r),o=e.right._zod.run({value:i,issues:[]},r);return s instanceof Promise||o instanceof Promise?Promise.all([s,o]).then(([c,u])=>Vp(t,c,u)):Vp(t,s,o)}});function Vc(n,e){if(n===e)return{valid:!0,data:n};if(n instanceof Date&&e instanceof Date&&+n==+e)return{valid:!0,data:n};if(_i(n)&&_i(e)){const t=Object.keys(e),r=Object.keys(n).filter(s=>t.indexOf(s)!==-1),i={...n,...e};for(const s of r){const o=Vc(n[s],e[s]);if(!o.valid)return{valid:!1,mergeErrorPath:[s,...o.mergeErrorPath]};i[s]=o.data}return{valid:!0,data:i}}if(Array.isArray(n)&&Array.isArray(e)){if(n.length!==e.length)return{valid:!1,mergeErrorPath:[]};const t=[];for(let r=0;r<n.length;r++){const i=n[r],s=e[r],o=Vc(i,s);if(!o.valid)return{valid:!1,mergeErrorPath:[r,...o.mergeErrorPath]};t.push(o.data)}return{valid:!0,data:t}}return{valid:!1,mergeErrorPath:[]}}function Vp(n,e,t){const r=new Map;let i;for(const a of e.issues)if(a.code==="unrecognized_keys"){i??(i=a);for(const c of a.keys)r.has(c)||r.set(c,{}),r.get(c).l=!0}else n.issues.push(a);for(const a of t.issues)if(a.code==="unrecognized_keys")for(const c of a.keys)r.has(c)||r.set(c,{}),r.get(c).r=!0;else n.issues.push(a);const s=[...r].filter(([,a])=>a.l&&a.r).map(([a])=>a);if(s.length&&i&&n.issues.push({...i,keys:s}),Kr(n))return n;const o=Vc(e.value,t.value);if(!o.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(o.mergeErrorPath)}`);return n.value=o.data,n}const YA=A("$ZodRecord",(n,e)=>{fe.init(n,e),n._zod.parse=(t,r)=>{const i=t.value;if(!_i(i))return t.issues.push({expected:"record",code:"invalid_type",input:i,inst:n}),t;const s=[],o=e.keyType._zod.values;if(o){t.value={};const a=new Set;for(const u of o)if(typeof u=="string"||typeof u=="number"||typeof u=="symbol"){a.add(typeof u=="number"?u.toString():u);const h=e.valueType._zod.run({value:i[u],issues:[]},r);h instanceof Promise?s.push(h.then(p=>{p.issues.length&&t.issues.push(...Jr(u,p.issues)),t.value[u]=p.value})):(h.issues.length&&t.issues.push(...Jr(u,h.issues)),t.value[u]=h.value)}let c;for(const u in i)a.has(u)||(c=c??[],c.push(u));c&&c.length>0&&t.issues.push({code:"unrecognized_keys",input:i,inst:n,keys:c})}else{t.value={};for(const a of Reflect.ownKeys(i)){if(a==="__proto__")continue;let c=e.keyType._zod.run({value:a,issues:[]},r);if(c instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(typeof a=="string"&&zm.test(a)&&c.issues.length){const p=e.keyType._zod.run({value:Number(a),issues:[]},r);if(p instanceof Promise)throw new Error("Async schemas not supported in object keys currently");p.issues.length===0&&(c=p)}if(c.issues.length){e.mode==="loose"?t.value[a]=i[a]:t.issues.push({code:"invalid_key",origin:"record",issues:c.issues.map(p=>In(p,r,$n())),input:a,path:[a],inst:n});continue}const h=e.valueType._zod.run({value:i[a],issues:[]},r);h instanceof Promise?s.push(h.then(p=>{p.issues.length&&t.issues.push(...Jr(a,p.issues)),t.value[c.value]=p.value})):(h.issues.length&&t.issues.push(...Jr(a,h.issues)),t.value[c.value]=h.value)}}return s.length?Promise.all(s).then(()=>t):t}}),XA=A("$ZodEnum",(n,e)=>{fe.init(n,e);const t=Am(e.entries),r=new Set(t);n._zod.values=r,n._zod.pattern=new RegExp(`^(${t.filter(i=>l1.has(typeof i)).map(i=>typeof i=="string"?ki(i):i.toString()).join("|")})$`),n._zod.parse=(i,s)=>{const o=i.value;return r.has(o)||i.issues.push({code:"invalid_value",values:t,input:o,inst:n}),i}}),KA=A("$ZodLiteral",(n,e)=>{if(fe.init(n,e),e.values.length===0)throw new Error("Cannot create literal schema with no valid values");const t=new Set(e.values);n._zod.values=t,n._zod.pattern=new RegExp(`^(${e.values.map(r=>typeof r=="string"?ki(r):r?ki(r.toString()):String(r)).join("|")})$`),n._zod.parse=(r,i)=>{const s=r.value;return t.has(s)||r.issues.push({code:"invalid_value",values:e.values,input:s,inst:n}),r}}),JA=A("$ZodTransform",(n,e)=>{fe.init(n,e),n._zod.parse=(t,r)=>{if(r.direction==="backward")throw new Em(n.constructor.name);const i=e.transform(t.value,t);if(r.async)return(i instanceof Promise?i:Promise.resolve(i)).then(o=>(t.value=o,t));if(i instanceof Promise)throw new ei;return t.value=i,t}});function Bp(n,e){return n.issues.length&&e===void 0?{issues:[],value:void 0}:n}const Hm=A("$ZodOptional",(n,e)=>{fe.init(n,e),n._zod.optin="optional",n._zod.optout="optional",oe(n._zod,"values",()=>e.innerType._zod.values?new Set([...e.innerType._zod.values,void 0]):void 0),oe(n._zod,"pattern",()=>{const t=e.innerType._zod.pattern;return t?new RegExp(`^(${hh(t.source)})?$`):void 0}),n._zod.parse=(t,r)=>{if(e.innerType._zod.optin==="optional"){const i=e.innerType._zod.run(t,r);return i instanceof Promise?i.then(s=>Bp(s,t.value)):Bp(i,t.value)}return t.value===void 0?t:e.innerType._zod.run(t,r)}}),QA=A("$ZodExactOptional",(n,e)=>{Hm.init(n,e),oe(n._zod,"values",()=>e.innerType._zod.values),oe(n._zod,"pattern",()=>e.innerType._zod.pattern),n._zod.parse=(t,r)=>e.innerType._zod.run(t,r)}),e$=A("$ZodNullable",(n,e)=>{fe.init(n,e),oe(n._zod,"optin",()=>e.innerType._zod.optin),oe(n._zod,"optout",()=>e.innerType._zod.optout),oe(n._zod,"pattern",()=>{const t=e.innerType._zod.pattern;return t?new RegExp(`^(${hh(t.source)}|null)$`):void 0}),oe(n._zod,"values",()=>e.innerType._zod.values?new Set([...e.innerType._zod.values,null]):void 0),n._zod.parse=(t,r)=>t.value===null?t:e.innerType._zod.run(t,r)}),t$=A("$ZodDefault",(n,e)=>{fe.init(n,e),n._zod.optin="optional",oe(n._zod,"values",()=>e.innerType._zod.values),n._zod.parse=(t,r)=>{if(r.direction==="backward")return e.innerType._zod.run(t,r);if(t.value===void 0)return t.value=e.defaultValue,t;const i=e.innerType._zod.run(t,r);return i instanceof Promise?i.then(s=>Gp(s,e)):Gp(i,e)}});function Gp(n,e){return n.value===void 0&&(n.value=e.defaultValue),n}const n$=A("$ZodPrefault",(n,e)=>{fe.init(n,e),n._zod.optin="optional",oe(n._zod,"values",()=>e.innerType._zod.values),n._zod.parse=(t,r)=>(r.direction==="backward"||t.value===void 0&&(t.value=e.defaultValue),e.innerType._zod.run(t,r))}),r$=A("$ZodNonOptional",(n,e)=>{fe.init(n,e),oe(n._zod,"values",()=>{const t=e.innerType._zod.values;return t?new Set([...t].filter(r=>r!==void 0)):void 0}),n._zod.parse=(t,r)=>{const i=e.innerType._zod.run(t,r);return i instanceof Promise?i.then(s=>jp(s,n)):jp(i,n)}});function jp(n,e){return!n.issues.length&&n.value===void 0&&n.issues.push({code:"invalid_type",expected:"nonoptional",input:n.value,inst:e}),n}const i$=A("$ZodCatch",(n,e)=>{fe.init(n,e),oe(n._zod,"optin",()=>e.innerType._zod.optin),oe(n._zod,"optout",()=>e.innerType._zod.optout),oe(n._zod,"values",()=>e.innerType._zod.values),n._zod.parse=(t,r)=>{if(r.direction==="backward")return e.innerType._zod.run(t,r);const i=e.innerType._zod.run(t,r);return i instanceof Promise?i.then(s=>(t.value=s.value,s.issues.length&&(t.value=e.catchValue({...t,error:{issues:s.issues.map(o=>In(o,r,$n()))},input:t.value}),t.issues=[]),t)):(t.value=i.value,i.issues.length&&(t.value=e.catchValue({...t,error:{issues:i.issues.map(s=>In(s,r,$n()))},input:t.value}),t.issues=[]),t)}}),s$=A("$ZodPipe",(n,e)=>{fe.init(n,e),oe(n._zod,"values",()=>e.in._zod.values),oe(n._zod,"optin",()=>e.in._zod.optin),oe(n._zod,"optout",()=>e.out._zod.optout),oe(n._zod,"propValues",()=>e.in._zod.propValues),n._zod.parse=(t,r)=>{if(r.direction==="backward"){const s=e.out._zod.run(t,r);return s instanceof Promise?s.then(o=>Mo(o,e.in,r)):Mo(s,e.in,r)}const i=e.in._zod.run(t,r);return i instanceof Promise?i.then(s=>Mo(s,e.out,r)):Mo(i,e.out,r)}});function Mo(n,e,t){return n.issues.length?(n.aborted=!0,n):e._zod.run({value:n.value,issues:n.issues},t)}const o$=A("$ZodReadonly",(n,e)=>{fe.init(n,e),oe(n._zod,"propValues",()=>e.innerType._zod.propValues),oe(n._zod,"values",()=>e.innerType._zod.values),oe(n._zod,"optin",()=>{var t,r;return(r=(t=e.innerType)==null?void 0:t._zod)==null?void 0:r.optin}),oe(n._zod,"optout",()=>{var t,r;return(r=(t=e.innerType)==null?void 0:t._zod)==null?void 0:r.optout}),n._zod.parse=(t,r)=>{if(r.direction==="backward")return e.innerType._zod.run(t,r);const i=e.innerType._zod.run(t,r);return i instanceof Promise?i.then(qp):qp(i)}});function qp(n){return n.value=Object.freeze(n.value),n}const a$=A("$ZodCustom",(n,e)=>{Ke.init(n,e),fe.init(n,e),n._zod.parse=(t,r)=>t,n._zod.check=t=>{const r=t.value,i=e.fn(r);if(i instanceof Promise)return i.then(s=>Yp(s,t,r,n));Yp(i,t,r,n)}});function Yp(n,e,t,r){if(!n){const i={code:"custom",input:t,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(i.params=r._zod.def.params),e.issues.push(ps(i))}}var Xp;class l${constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...t){const r=t[0];return this._map.set(e,r),r&&typeof r=="object"&&"id"in r&&this._idmap.set(r.id,e),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(e){const t=this._map.get(e);return t&&typeof t=="object"&&"id"in t&&this._idmap.delete(t.id),this._map.delete(e),this}get(e){const t=e._zod.parent;if(t){const r={...this.get(t)??{}};delete r.id;const i={...r,...this._map.get(e)};return Object.keys(i).length?i:void 0}return this._map.get(e)}has(e){return this._map.has(e)}}function c$(){return new l$}(Xp=globalThis).__zod_globalRegistry??(Xp.__zod_globalRegistry=c$());const Qi=globalThis.__zod_globalRegistry;function u$(n,e){return new n({type:"string",...z(e)})}function h$(n,e){return new n({type:"string",format:"email",check:"string_format",abort:!1,...z(e)})}function Kp(n,e){return new n({type:"string",format:"guid",check:"string_format",abort:!1,...z(e)})}function d$(n,e){return new n({type:"string",format:"uuid",check:"string_format",abort:!1,...z(e)})}function p$(n,e){return new n({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...z(e)})}function f$(n,e){return new n({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...z(e)})}function g$(n,e){return new n({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...z(e)})}function m$(n,e){return new n({type:"string",format:"url",check:"string_format",abort:!1,...z(e)})}function v$(n,e){return new n({type:"string",format:"emoji",check:"string_format",abort:!1,...z(e)})}function y$(n,e){return new n({type:"string",format:"nanoid",check:"string_format",abort:!1,...z(e)})}function b$(n,e){return new n({type:"string",format:"cuid",check:"string_format",abort:!1,...z(e)})}function w$(n,e){return new n({type:"string",format:"cuid2",check:"string_format",abort:!1,...z(e)})}function S$(n,e){return new n({type:"string",format:"ulid",check:"string_format",abort:!1,...z(e)})}function _$(n,e){return new n({type:"string",format:"xid",check:"string_format",abort:!1,...z(e)})}function k$(n,e){return new n({type:"string",format:"ksuid",check:"string_format",abort:!1,...z(e)})}function E$(n,e){return new n({type:"string",format:"ipv4",check:"string_format",abort:!1,...z(e)})}function x$(n,e){return new n({type:"string",format:"ipv6",check:"string_format",abort:!1,...z(e)})}function A$(n,e){return new n({type:"string",format:"cidrv4",check:"string_format",abort:!1,...z(e)})}function $$(n,e){return new n({type:"string",format:"cidrv6",check:"string_format",abort:!1,...z(e)})}function I$(n,e){return new n({type:"string",format:"base64",check:"string_format",abort:!1,...z(e)})}function T$(n,e){return new n({type:"string",format:"base64url",check:"string_format",abort:!1,...z(e)})}function C$(n,e){return new n({type:"string",format:"e164",check:"string_format",abort:!1,...z(e)})}function P$(n,e){return new n({type:"string",format:"jwt",check:"string_format",abort:!1,...z(e)})}function R$(n,e){return new n({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...z(e)})}function D$(n,e){return new n({type:"string",format:"date",check:"string_format",...z(e)})}function L$(n,e){return new n({type:"string",format:"time",check:"string_format",precision:null,...z(e)})}function z$(n,e){return new n({type:"string",format:"duration",check:"string_format",...z(e)})}function O$(n,e){return new n({type:"number",checks:[],...z(e)})}function M$(n,e){return new n({type:"number",check:"number_format",abort:!1,format:"safeint",...z(e)})}function N$(n,e){return new n({type:"boolean",...z(e)})}function U$(n){return new n({type:"unknown"})}function F$(n,e){return new n({type:"never",...z(e)})}function Jp(n,e){return new Mm({check:"less_than",...z(e),value:n,inclusive:!1})}function lc(n,e){return new Mm({check:"less_than",...z(e),value:n,inclusive:!0})}function Qp(n,e){return new Nm({check:"greater_than",...z(e),value:n,inclusive:!1})}function cc(n,e){return new Nm({check:"greater_than",...z(e),value:n,inclusive:!0})}function ef(n,e){return new tA({check:"multiple_of",...z(e),value:n})}function Vm(n,e){return new rA({check:"max_length",...z(e),maximum:n})}function _a(n,e){return new iA({check:"min_length",...z(e),minimum:n})}function Bm(n,e){return new sA({check:"length_equals",...z(e),length:n})}function Z$(n,e){return new oA({check:"string_format",format:"regex",...z(e),pattern:n})}function W$(n){return new aA({check:"string_format",format:"lowercase",...z(n)})}function H$(n){return new lA({check:"string_format",format:"uppercase",...z(n)})}function V$(n,e){return new cA({check:"string_format",format:"includes",...z(e),includes:n})}function B$(n,e){return new uA({check:"string_format",format:"starts_with",...z(e),prefix:n})}function G$(n,e){return new hA({check:"string_format",format:"ends_with",...z(e),suffix:n})}function Li(n){return new dA({check:"overwrite",tx:n})}function j$(n){return Li(e=>e.normalize(n))}function q$(){return Li(n=>n.trim())}function Y$(){return Li(n=>n.toLowerCase())}function X$(){return Li(n=>n.toUpperCase())}function K$(){return Li(n=>o1(n))}function J$(n,e,t){return new n({type:"array",element:e,...z(t)})}function Q$(n,e,t){return new n({type:"custom",check:"custom",fn:e,...z(t)})}function eI(n){const e=tI(t=>(t.addIssue=r=>{if(typeof r=="string")t.issues.push(ps(r,t.value,e._zod.def));else{const i=r;i.fatal&&(i.continue=!1),i.code??(i.code="custom"),i.input??(i.input=t.value),i.inst??(i.inst=e),i.continue??(i.continue=!e._zod.def.abort),t.issues.push(ps(i))}},n(t.value,t)));return e}function tI(n,e){const t=new Ke({check:"custom",...z(e)});return t._zod.check=n,t}function Gm(n){let e=(n==null?void 0:n.target)??"draft-2020-12";return e==="draft-4"&&(e="draft-04"),e==="draft-7"&&(e="draft-07"),{processors:n.processors??{},metadataRegistry:(n==null?void 0:n.metadata)??Qi,target:e,unrepresentable:(n==null?void 0:n.unrepresentable)??"throw",override:(n==null?void 0:n.override)??(()=>{}),io:(n==null?void 0:n.io)??"output",counter:0,seen:new Map,cycles:(n==null?void 0:n.cycles)??"ref",reused:(n==null?void 0:n.reused)??"inline",external:(n==null?void 0:n.external)??void 0}}function _e(n,e,t={path:[],schemaPath:[]}){var h,p;var r;const i=n._zod.def,s=e.seen.get(n);if(s)return s.count++,t.schemaPath.includes(n)&&(s.cycle=t.path),s.schema;const o={schema:{},count:1,cycle:void 0,path:t.path};e.seen.set(n,o);const a=(p=(h=n._zod).toJSONSchema)==null?void 0:p.call(h);if(a)o.schema=a;else{const v={...t,schemaPath:[...t.schemaPath,n],path:t.path};if(n._zod.processJSONSchema)n._zod.processJSONSchema(e,o.schema,v);else{const E=o.schema,k=e.processors[i.type];if(!k)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${i.type}`);k(n,e,E,v)}const m=n._zod.parent;m&&(o.ref||(o.ref=m),_e(m,e,v),e.seen.get(m).isParent=!0)}const c=e.metadataRegistry.get(n);return c&&Object.assign(o.schema,c),e.io==="input"&&Me(n)&&(delete o.schema.examples,delete o.schema.default),e.io==="input"&&o.schema._prefault&&((r=o.schema).default??(r.default=o.schema._prefault)),delete o.schema._prefault,e.seen.get(n).schema}function jm(n,e){var o,a,c,u;const t=n.seen.get(e);if(!t)throw new Error("Unprocessed schema. This is a bug in Zod.");const r=new Map;for(const 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,O=n.external.uri??(V=>V);if(T)return{ref:O(T)};const P=h[1].defId??h[1].schema.id??`schema${n.counter++}`;return h[1].defId=P,{defId:P,ref:`${O("__shared")}#/${p}/${P}`}}if(h[1]===t)return{ref:"#"};const m=`#/${p}/`,E=h[1].schema.id??`__schema${n.counter++}`;return{defId:E,ref:m+E}},s=h=>{if(h[1].schema.$ref)return;const p=h[1],{ref:v,defId:m}=i(h);p.def={...p.schema},m&&(p.defId=m);const E=p.schema;for(const k in E)delete E[k];E.$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(e===h[0]){s(h);continue}if(n.external){const m=(c=n.external.registry.get(h[0]))==null?void 0:c.id;if(e!==h[0]&&m){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 qm(n,e){var o,a,c;const t=n.seen.get(e);if(!t)throw new Error("Unprocessed schema. This is a bug in Zod.");const r=u=>{const h=n.seen.get(u);if(h.ref===null)return;const p=h.def??h.schema,v={...p},m=h.ref;if(h.ref=null,m){r(m);const k=n.seen.get(m),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===m)for(const P in p)P==="$ref"||P==="allOf"||P in v||delete p[P];if(T.$ref&&k.def)for(const P in p)P==="$ref"||P==="allOf"||P in k.def&&JSON.stringify(p[P])===JSON.stringify(k.def[P])&&delete p[P]}const E=u._zod.parent;if(E&&E!==m){r(E);const k=n.seen.get(E);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(e))==null?void 0:a.id;if(!u)throw new Error("Schema is missing an `id` property");i.$id=n.external.uri(u)}Object.assign(i,t.def??t.schema);const s=((c=n.external)==null?void 0:c.defs)??{};for(const u of n.seen.entries()){const 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:{...e["~standard"],jsonSchema:{input:ka(e,"input",n.processors),output:ka(e,"output",n.processors)}},enumerable:!1,writable:!1}),u}catch{throw new Error("Error converting schema to JSON.")}}function Me(n,e){const t=e??{seen:new Set};if(t.seen.has(n))return!1;t.seen.add(n);const r=n._zod.def;if(r.type==="transform")return!0;if(r.type==="array")return Me(r.element,t);if(r.type==="set")return Me(r.valueType,t);if(r.type==="lazy")return Me(r.getter(),t);if(r.type==="promise"||r.type==="optional"||r.type==="nonoptional"||r.type==="nullable"||r.type==="readonly"||r.type==="default"||r.type==="prefault")return Me(r.innerType,t);if(r.type==="intersection")return Me(r.left,t)||Me(r.right,t);if(r.type==="record"||r.type==="map")return Me(r.keyType,t)||Me(r.valueType,t);if(r.type==="pipe")return Me(r.in,t)||Me(r.out,t);if(r.type==="object"){for(const i in r.shape)if(Me(r.shape[i],t))return!0;return!1}if(r.type==="union"){for(const i of r.options)if(Me(i,t))return!0;return!1}if(r.type==="tuple"){for(const i of r.items)if(Me(i,t))return!0;return!!(r.rest&&Me(r.rest,t))}return!1}const nI=(n,e={})=>t=>{const r=Gm({...t,processors:e});return _e(n,r),jm(r,n),qm(r,n)},ka=(n,e,t={})=>r=>{const{libraryOptions:i,target:s}=r??{},o=Gm({...i??{},target:s,io:e,processors:t});return _e(n,o),jm(o,n),qm(o,n)},rI={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},iI=(n,e,t,r)=>{const i=t;i.type="string";const{minimum:s,maximum:o,format:a,patterns:c,contentEncoding:u}=n._zod.bag;if(typeof s=="number"&&(i.minLength=s),typeof o=="number"&&(i.maxLength=o),a&&(i.format=rI[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=>({...e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0"?{type:"string"}:{},pattern:p.source}))])}},sI=(n,e,t,r)=>{const i=t,{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"&&(e.target==="draft-04"||e.target==="openapi-3.0"?(i.minimum=h,i.exclusiveMinimum=!0):i.exclusiveMinimum=h),typeof s=="number"&&(i.minimum=s,typeof h=="number"&&e.target!=="draft-04"&&(h>=s?delete i.minimum:delete i.exclusiveMinimum)),typeof u=="number"&&(e.target==="draft-04"||e.target==="openapi-3.0"?(i.maximum=u,i.exclusiveMaximum=!0):i.exclusiveMaximum=u),typeof o=="number"&&(i.maximum=o,typeof u=="number"&&e.target!=="draft-04"&&(u<=o?delete i.maximum:delete i.exclusiveMaximum)),typeof c=="number"&&(i.multipleOf=c)},oI=(n,e,t,r)=>{t.type="boolean"},aI=(n,e,t,r)=>{t.not={}},lI=(n,e,t,r)=>{},cI=(n,e,t,r)=>{const i=n._zod.def,s=Am(i.entries);s.every(o=>typeof o=="number")&&(t.type="number"),s.every(o=>typeof o=="string")&&(t.type="string"),t.enum=s},uI=(n,e,t,r)=>{const i=n._zod.def,s=[];for(const o of i.values)if(o===void 0){if(e.unrepresentable==="throw")throw new Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof o=="bigint"){if(e.unrepresentable==="throw")throw new Error("BigInt literals cannot be represented in JSON Schema");s.push(Number(o))}else s.push(o);if(s.length!==0)if(s.length===1){const o=s[0];t.type=o===null?"null":typeof o,e.target==="draft-04"||e.target==="openapi-3.0"?t.enum=[o]:t.const=o}else s.every(o=>typeof o=="number")&&(t.type="number"),s.every(o=>typeof o=="string")&&(t.type="string"),s.every(o=>typeof o=="boolean")&&(t.type="boolean"),s.every(o=>o===null)&&(t.type="null"),t.enum=s},hI=(n,e,t,r)=>{if(e.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema")},dI=(n,e,t,r)=>{if(e.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema")},pI=(n,e,t,r)=>{const i=t,s=n._zod.def,{minimum:o,maximum:a}=n._zod.bag;typeof o=="number"&&(i.minItems=o),typeof a=="number"&&(i.maxItems=a),i.type="array",i.items=_e(s.element,e,{...r,path:[...r.path,"items"]})},fI=(n,e,t,r)=>{var u;const i=t,s=n._zod.def;i.type="object",i.properties={};const o=s.shape;for(const h in o)i.properties[h]=_e(o[h],e,{...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 e.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,e,{...r,path:[...r.path,"additionalProperties"]})):e.io==="output"&&(i.additionalProperties=!1)},gI=(n,e,t,r)=>{const i=n._zod.def,s=i.inclusive===!1,o=i.options.map((a,c)=>_e(a,e,{...r,path:[...r.path,s?"oneOf":"anyOf",c]}));s?t.oneOf=o:t.anyOf=o},mI=(n,e,t,r)=>{const i=n._zod.def,s=_e(i.left,e,{...r,path:[...r.path,"allOf",0]}),o=_e(i.right,e,{...r,path:[...r.path,"allOf",1]}),a=u=>"allOf"in u&&Object.keys(u).length===1,c=[...a(s)?s.allOf:[s],...a(o)?o.allOf:[o]];t.allOf=c},vI=(n,e,t,r)=>{const i=t,s=n._zod.def;i.type="object";const o=s.keyType,a=o._zod.bag,c=a==null?void 0:a.patterns;if(s.mode==="loose"&&c&&c.size>0){const h=_e(s.valueType,e,{...r,path:[...r.path,"patternProperties","*"]});i.patternProperties={};for(const p of c)i.patternProperties[p.source]=h}else(e.target==="draft-07"||e.target==="draft-2020-12")&&(i.propertyNames=_e(s.keyType,e,{...r,path:[...r.path,"propertyNames"]})),i.additionalProperties=_e(s.valueType,e,{...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)}},yI=(n,e,t,r)=>{const i=n._zod.def,s=_e(i.innerType,e,r),o=e.seen.get(n);e.target==="openapi-3.0"?(o.ref=i.innerType,t.nullable=!0):t.anyOf=[s,{type:"null"}]},bI=(n,e,t,r)=>{const i=n._zod.def;_e(i.innerType,e,r);const s=e.seen.get(n);s.ref=i.innerType},wI=(n,e,t,r)=>{const i=n._zod.def;_e(i.innerType,e,r);const s=e.seen.get(n);s.ref=i.innerType,t.default=JSON.parse(JSON.stringify(i.defaultValue))},SI=(n,e,t,r)=>{const i=n._zod.def;_e(i.innerType,e,r);const s=e.seen.get(n);s.ref=i.innerType,e.io==="input"&&(t._prefault=JSON.parse(JSON.stringify(i.defaultValue)))},_I=(n,e,t,r)=>{const i=n._zod.def;_e(i.innerType,e,r);const s=e.seen.get(n);s.ref=i.innerType;let o;try{o=i.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}t.default=o},kI=(n,e,t,r)=>{const i=n._zod.def,s=e.io==="input"?i.in._zod.def.type==="transform"?i.out:i.in:i.out;_e(s,e,r);const o=e.seen.get(n);o.ref=s},EI=(n,e,t,r)=>{const i=n._zod.def;_e(i.innerType,e,r);const s=e.seen.get(n);s.ref=i.innerType,t.readOnly=!0},Ym=(n,e,t,r)=>{const i=n._zod.def;_e(i.innerType,e,r);const s=e.seen.get(n);s.ref=i.innerType},xI=A("ZodISODateTime",(n,e)=>{AA.init(n,e),me.init(n,e)});function AI(n){return R$(xI,n)}const $I=A("ZodISODate",(n,e)=>{$A.init(n,e),me.init(n,e)});function II(n){return D$($I,n)}const TI=A("ZodISOTime",(n,e)=>{IA.init(n,e),me.init(n,e)});function CI(n){return L$(TI,n)}const PI=A("ZodISODuration",(n,e)=>{TA.init(n,e),me.init(n,e)});function RI(n){return z$(PI,n)}const Xm=(n,e)=>{Cm.init(n,e),n.name="ZodError",Object.defineProperties(n,{format:{value:t=>b1(n,t)},flatten:{value:t=>y1(n,t)},addIssue:{value:t=>{n.issues.push(t),n.message=JSON.stringify(n.issues,Hc,2)}},addIssues:{value:t=>{n.issues.push(...t),n.message=JSON.stringify(n.issues,Hc,2)}},isEmpty:{get(){return n.issues.length===0}}})},tf=A("ZodError",Xm),ht=A("ZodError",Xm,{Parent:Error}),DI=ph(ht),LI=fh(ht),zI=ll(ht),OI=cl(ht),MI=_1(ht),NI=k1(ht),UI=E1(ht),FI=x1(ht),ZI=A1(ht),WI=$1(ht),HI=I1(ht),VI=T1(ht),ge=A("ZodType",(n,e)=>(fe.init(n,e),Object.assign(n["~standard"],{jsonSchema:{input:ka(n,"input"),output:ka(n,"output")}}),n.toJSONSchema=nI(n,{}),n.def=e,n.type=e.type,Object.defineProperty(n,"_def",{value:e}),n.check=(...t)=>n.clone(Dn(e,{checks:[...e.checks??[],...t.map(r=>typeof r=="function"?{_zod:{check:r,def:{check:"custom"},onattach:[]}}:r)]}),{parent:!0}),n.with=n.check,n.clone=(t,r)=>Ln(n,t,r),n.brand=()=>n,n.register=(t,r)=>(t.add(n,r),n),n.parse=(t,r)=>DI(n,t,r,{callee:n.parse}),n.safeParse=(t,r)=>zI(n,t,r),n.parseAsync=async(t,r)=>LI(n,t,r,{callee:n.parseAsync}),n.safeParseAsync=async(t,r)=>OI(n,t,r),n.spa=n.safeParseAsync,n.encode=(t,r)=>MI(n,t,r),n.decode=(t,r)=>NI(n,t,r),n.encodeAsync=async(t,r)=>UI(n,t,r),n.decodeAsync=async(t,r)=>FI(n,t,r),n.safeEncode=(t,r)=>ZI(n,t,r),n.safeDecode=(t,r)=>WI(n,t,r),n.safeEncodeAsync=async(t,r)=>HI(n,t,r),n.safeDecodeAsync=async(t,r)=>VI(n,t,r),n.refine=(t,r)=>n.check(zT(t,r)),n.superRefine=t=>n.check(OT(t)),n.overwrite=t=>n.check(Li(t)),n.optional=()=>sf(n),n.exactOptional=()=>_T(n),n.nullable=()=>of(n),n.nullish=()=>sf(of(n)),n.nonoptional=t=>IT(n,t),n.array=()=>D(n),n.or=t=>G([n,t]),n.and=t=>hl(n,t),n.transform=t=>af(n,wT(t)),n.default=t=>xT(n,t),n.prefault=t=>$T(n,t),n.catch=t=>CT(n,t),n.pipe=t=>af(n,t),n.readonly=()=>DT(n),n.describe=t=>{const r=n.clone();return Qi.add(r,{description:t}),r},Object.defineProperty(n,"description",{get(){var t;return(t=Qi.get(n))==null?void 0:t.description},configurable:!0}),n.meta=(...t)=>{if(t.length===0)return Qi.get(n);const r=n.clone();return Qi.add(r,t[0]),r},n.isOptional=()=>n.safeParse(void 0).success,n.isNullable=()=>n.safeParse(null).success,n.apply=t=>t(n),n)),Km=A("_ZodString",(n,e)=>{gh.init(n,e),ge.init(n,e),n._zod.processJSONSchema=(r,i,s)=>iI(n,r,i);const t=n._zod.bag;n.format=t.format??null,n.minLength=t.minimum??null,n.maxLength=t.maximum??null,n.regex=(...r)=>n.check(Z$(...r)),n.includes=(...r)=>n.check(V$(...r)),n.startsWith=(...r)=>n.check(B$(...r)),n.endsWith=(...r)=>n.check(G$(...r)),n.min=(...r)=>n.check(_a(...r)),n.max=(...r)=>n.check(Vm(...r)),n.length=(...r)=>n.check(Bm(...r)),n.nonempty=(...r)=>n.check(_a(1,...r)),n.lowercase=r=>n.check(W$(r)),n.uppercase=r=>n.check(H$(r)),n.trim=()=>n.check(q$()),n.normalize=(...r)=>n.check(j$(...r)),n.toLowerCase=()=>n.check(Y$()),n.toUpperCase=()=>n.check(X$()),n.slugify=()=>n.check(K$())}),BI=A("ZodString",(n,e)=>{gh.init(n,e),Km.init(n,e),n.email=t=>n.check(h$(GI,t)),n.url=t=>n.check(m$(jI,t)),n.jwt=t=>n.check(P$(lT,t)),n.emoji=t=>n.check(v$(qI,t)),n.guid=t=>n.check(Kp(nf,t)),n.uuid=t=>n.check(d$(No,t)),n.uuidv4=t=>n.check(p$(No,t)),n.uuidv6=t=>n.check(f$(No,t)),n.uuidv7=t=>n.check(g$(No,t)),n.nanoid=t=>n.check(y$(YI,t)),n.guid=t=>n.check(Kp(nf,t)),n.cuid=t=>n.check(b$(XI,t)),n.cuid2=t=>n.check(w$(KI,t)),n.ulid=t=>n.check(S$(JI,t)),n.base64=t=>n.check(I$(sT,t)),n.base64url=t=>n.check(T$(oT,t)),n.xid=t=>n.check(_$(QI,t)),n.ksuid=t=>n.check(k$(eT,t)),n.ipv4=t=>n.check(E$(tT,t)),n.ipv6=t=>n.check(x$(nT,t)),n.cidrv4=t=>n.check(A$(rT,t)),n.cidrv6=t=>n.check($$(iT,t)),n.e164=t=>n.check(C$(aT,t)),n.datetime=t=>n.check(AI(t)),n.date=t=>n.check(II(t)),n.time=t=>n.check(CI(t)),n.duration=t=>n.check(RI(t))});function d(n){return u$(BI,n)}const me=A("ZodStringFormat",(n,e)=>{de.init(n,e),Km.init(n,e)}),GI=A("ZodEmail",(n,e)=>{vA.init(n,e),me.init(n,e)}),nf=A("ZodGUID",(n,e)=>{gA.init(n,e),me.init(n,e)}),No=A("ZodUUID",(n,e)=>{mA.init(n,e),me.init(n,e)}),jI=A("ZodURL",(n,e)=>{yA.init(n,e),me.init(n,e)}),qI=A("ZodEmoji",(n,e)=>{bA.init(n,e),me.init(n,e)}),YI=A("ZodNanoID",(n,e)=>{wA.init(n,e),me.init(n,e)}),XI=A("ZodCUID",(n,e)=>{SA.init(n,e),me.init(n,e)}),KI=A("ZodCUID2",(n,e)=>{_A.init(n,e),me.init(n,e)}),JI=A("ZodULID",(n,e)=>{kA.init(n,e),me.init(n,e)}),QI=A("ZodXID",(n,e)=>{EA.init(n,e),me.init(n,e)}),eT=A("ZodKSUID",(n,e)=>{xA.init(n,e),me.init(n,e)}),tT=A("ZodIPv4",(n,e)=>{CA.init(n,e),me.init(n,e)}),nT=A("ZodIPv6",(n,e)=>{PA.init(n,e),me.init(n,e)}),rT=A("ZodCIDRv4",(n,e)=>{RA.init(n,e),me.init(n,e)}),iT=A("ZodCIDRv6",(n,e)=>{DA.init(n,e),me.init(n,e)}),sT=A("ZodBase64",(n,e)=>{LA.init(n,e),me.init(n,e)}),oT=A("ZodBase64URL",(n,e)=>{OA.init(n,e),me.init(n,e)}),aT=A("ZodE164",(n,e)=>{MA.init(n,e),me.init(n,e)}),lT=A("ZodJWT",(n,e)=>{UA.init(n,e),me.init(n,e)}),Jm=A("ZodNumber",(n,e)=>{Fm.init(n,e),ge.init(n,e),n._zod.processJSONSchema=(r,i,s)=>sI(n,r,i),n.gt=(r,i)=>n.check(Qp(r,i)),n.gte=(r,i)=>n.check(cc(r,i)),n.min=(r,i)=>n.check(cc(r,i)),n.lt=(r,i)=>n.check(Jp(r,i)),n.lte=(r,i)=>n.check(lc(r,i)),n.max=(r,i)=>n.check(lc(r,i)),n.int=r=>n.check(rf(r)),n.safe=r=>n.check(rf(r)),n.positive=r=>n.check(Qp(0,r)),n.nonnegative=r=>n.check(cc(0,r)),n.negative=r=>n.check(Jp(0,r)),n.nonpositive=r=>n.check(lc(0,r)),n.multipleOf=(r,i)=>n.check(ef(r,i)),n.step=(r,i)=>n.check(ef(r,i)),n.finite=()=>n;const t=n._zod.bag;n.minValue=Math.max(t.minimum??Number.NEGATIVE_INFINITY,t.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,n.maxValue=Math.min(t.maximum??Number.POSITIVE_INFINITY,t.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,n.isInt=(t.format??"").includes("int")||Number.isSafeInteger(t.multipleOf??.5),n.isFinite=!0,n.format=t.format??null});function W(n){return O$(Jm,n)}const cT=A("ZodNumberFormat",(n,e)=>{FA.init(n,e),Jm.init(n,e)});function rf(n){return M$(cT,n)}const uT=A("ZodBoolean",(n,e)=>{ZA.init(n,e),ge.init(n,e),n._zod.processJSONSchema=(t,r,i)=>oI(n,t,r)});function Te(n){return N$(uT,n)}const hT=A("ZodUnknown",(n,e)=>{WA.init(n,e),ge.init(n,e),n._zod.processJSONSchema=(t,r,i)=>lI()});function S(){return U$(hT)}const dT=A("ZodNever",(n,e)=>{HA.init(n,e),ge.init(n,e),n._zod.processJSONSchema=(t,r,i)=>aI(n,t,r)});function pT(n){return F$(dT,n)}const fT=A("ZodArray",(n,e)=>{VA.init(n,e),ge.init(n,e),n._zod.processJSONSchema=(t,r,i)=>pI(n,t,r,i),n.element=e.element,n.min=(t,r)=>n.check(_a(t,r)),n.nonempty=t=>n.check(_a(1,t)),n.max=(t,r)=>n.check(Vm(t,r)),n.length=(t,r)=>n.check(Bm(t,r)),n.unwrap=()=>n.element});function D(n,e){return J$(fT,n,e)}const Qm=A("ZodObject",(n,e)=>{GA.init(n,e),ge.init(n,e),n._zod.processJSONSchema=(t,r,i)=>fI(n,t,r,i),oe(n,"shape",()=>e.shape),n.keyof=()=>Ea(Object.keys(n._zod.def.shape)),n.catchall=t=>n.clone({...n._zod.def,catchall:t}),n.passthrough=()=>n.clone({...n._zod.def,catchall:S()}),n.loose=()=>n.clone({...n._zod.def,catchall:S()}),n.strict=()=>n.clone({...n._zod.def,catchall:pT()}),n.strip=()=>n.clone({...n._zod.def,catchall:void 0}),n.extend=t=>p1(n,t),n.safeExtend=t=>f1(n,t),n.merge=t=>g1(n,t),n.pick=t=>h1(n,t),n.omit=t=>d1(n,t),n.partial=(...t)=>m1(tv,n,t[0]),n.required=(...t)=>v1(nv,n,t[0])});function ev(n,e){const t={type:"object",shape:n??{},...z(e)};return new Qm(t)}function g(n,e){return new Qm({type:"object",shape:n,catchall:S(),...z(e)})}const gT=A("ZodUnion",(n,e)=>{jA.init(n,e),ge.init(n,e),n._zod.processJSONSchema=(t,r,i)=>gI(n,t,r,i),n.options=e.options});function G(n,e){return new gT({type:"union",options:n,...z(e)})}const mT=A("ZodIntersection",(n,e)=>{qA.init(n,e),ge.init(n,e),n._zod.processJSONSchema=(t,r,i)=>mI(n,t,r,i)});function hl(n,e){return new mT({type:"intersection",left:n,right:e})}const vT=A("ZodRecord",(n,e)=>{YA.init(n,e),ge.init(n,e),n._zod.processJSONSchema=(t,r,i)=>vI(n,t,r,i),n.keyType=e.keyType,n.valueType=e.valueType});function _(n,e,t){return new vT({type:"record",keyType:n,valueType:e,...z(t)})}const Bc=A("ZodEnum",(n,e)=>{XA.init(n,e),ge.init(n,e),n._zod.processJSONSchema=(r,i,s)=>cI(n,r,i),n.enum=e.entries,n.options=Object.values(e.entries);const t=new Set(Object.keys(e.entries));n.extract=(r,i)=>{const s={};for(const o of r)if(t.has(o))s[o]=e.entries[o];else throw new Error(`Key ${o} not found in enum`);return new Bc({...e,checks:[],...z(i),entries:s})},n.exclude=(r,i)=>{const s={...e.entries};for(const o of r)if(t.has(o))delete s[o];else throw new Error(`Key ${o} not found in enum`);return new Bc({...e,checks:[],...z(i),entries:s})}});function Ea(n,e){const t=Array.isArray(n)?Object.fromEntries(n.map(r=>[r,r])):n;return new Bc({type:"enum",entries:t,...z(e)})}const yT=A("ZodLiteral",(n,e)=>{KA.init(n,e),ge.init(n,e),n._zod.processJSONSchema=(t,r,i)=>uI(n,t,r),n.values=new Set(e.values),Object.defineProperty(n,"value",{get(){if(e.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return e.values[0]}})});function $(n,e){return new yT({type:"literal",values:Array.isArray(n)?n:[n],...z(e)})}const bT=A("ZodTransform",(n,e)=>{JA.init(n,e),ge.init(n,e),n._zod.processJSONSchema=(t,r,i)=>dI(n,t),n._zod.parse=(t,r)=>{if(r.direction==="backward")throw new Em(n.constructor.name);t.addIssue=s=>{if(typeof s=="string")t.issues.push(ps(s,t.value,e));else{const o=s;o.fatal&&(o.continue=!1),o.code??(o.code="custom"),o.input??(o.input=t.value),o.inst??(o.inst=n),t.issues.push(ps(o))}};const i=e.transform(t.value,t);return i instanceof Promise?i.then(s=>(t.value=s,t)):(t.value=i,t)}});function wT(n){return new bT({type:"transform",transform:n})}const tv=A("ZodOptional",(n,e)=>{Hm.init(n,e),ge.init(n,e),n._zod.processJSONSchema=(t,r,i)=>Ym(n,t,r,i),n.unwrap=()=>n._zod.def.innerType});function sf(n){return new tv({type:"optional",innerType:n})}const ST=A("ZodExactOptional",(n,e)=>{QA.init(n,e),ge.init(n,e),n._zod.processJSONSchema=(t,r,i)=>Ym(n,t,r,i),n.unwrap=()=>n._zod.def.innerType});function _T(n){return new ST({type:"optional",innerType:n})}const kT=A("ZodNullable",(n,e)=>{e$.init(n,e),ge.init(n,e),n._zod.processJSONSchema=(t,r,i)=>yI(n,t,r,i),n.unwrap=()=>n._zod.def.innerType});function of(n){return new kT({type:"nullable",innerType:n})}const ET=A("ZodDefault",(n,e)=>{t$.init(n,e),ge.init(n,e),n._zod.processJSONSchema=(t,r,i)=>wI(n,t,r,i),n.unwrap=()=>n._zod.def.innerType,n.removeDefault=n.unwrap});function xT(n,e){return new ET({type:"default",innerType:n,get defaultValue(){return typeof e=="function"?e():Im(e)}})}const AT=A("ZodPrefault",(n,e)=>{n$.init(n,e),ge.init(n,e),n._zod.processJSONSchema=(t,r,i)=>SI(n,t,r,i),n.unwrap=()=>n._zod.def.innerType});function $T(n,e){return new AT({type:"prefault",innerType:n,get defaultValue(){return typeof e=="function"?e():Im(e)}})}const nv=A("ZodNonOptional",(n,e)=>{r$.init(n,e),ge.init(n,e),n._zod.processJSONSchema=(t,r,i)=>bI(n,t,r,i),n.unwrap=()=>n._zod.def.innerType});function IT(n,e){return new nv({type:"nonoptional",innerType:n,...z(e)})}const TT=A("ZodCatch",(n,e)=>{i$.init(n,e),ge.init(n,e),n._zod.processJSONSchema=(t,r,i)=>_I(n,t,r,i),n.unwrap=()=>n._zod.def.innerType,n.removeCatch=n.unwrap});function CT(n,e){return new TT({type:"catch",innerType:n,catchValue:typeof e=="function"?e:()=>e})}const PT=A("ZodPipe",(n,e)=>{s$.init(n,e),ge.init(n,e),n._zod.processJSONSchema=(t,r,i)=>kI(n,t,r,i),n.in=e.in,n.out=e.out});function af(n,e){return new PT({type:"pipe",in:n,out:e})}const RT=A("ZodReadonly",(n,e)=>{o$.init(n,e),ge.init(n,e),n._zod.processJSONSchema=(t,r,i)=>EI(n,t,r,i),n.unwrap=()=>n._zod.def.innerType});function DT(n){return new RT({type:"readonly",innerType:n})}const LT=A("ZodCustom",(n,e)=>{a$.init(n,e),ge.init(n,e),n._zod.processJSONSchema=(t,r,i)=>hI(n,t)});function zT(n,e={}){return Q$(LT,n,e)}function OT(n){return eI(n)}const uc={custom:"custom"},MT=["text/markdown","text/html"],NT=["committed","pending"];function UT(n){let e;try{e=new URL(n)}catch{return!1}return e.protocol==="http:"||e.protocol==="https:"}ev({id:d().min(1),type:Ea(MT),title:d(),status:Ea(NT),externalFilePath:d().optional(),externalURL:d().optional()}).superRefine((n,e)=>{n.externalFilePath!==void 0&&n.externalURL!==void 0&&e.addIssue({code:uc.custom,message:"externalFilePath and externalURL are mutually exclusive",path:["externalURL"]}),n.externalURL!==void 0&&(UT(n.externalURL)||e.addIssue({code:uc.custom,message:"externalURL must be an http(s) URL",path:["externalURL"]}),n.status!=="committed"&&e.addIssue({code:uc.custom,message:"URL-backed artifacts must have status committed",path:["status"]}))});ev({name:d().min(1),description:d(),accepts:D(d().min(1)).min(1)});function rv(n){return typeof n=="object"&&n!==null}function FT(n){return!rv(n)||n.type!=="ready"?!1:!("id"in n)}function ZT(n){return!(!rv(n)||n.type!=="update-content"||typeof n.id!="string"||typeof n.content!="string")}function WT(n,e){if(n===e)return 2;if(n==="*/*")return 0;const t=n.indexOf("/");if(t>0&&n.slice(t+1)==="*"){const r=n.slice(0,t),i=e.indexOf("/");if(i>0&&e.slice(0,i)===r)return 1}return null}function HT(n,e){let t=null;for(const r of n.accepts){const i=WT(r,e);i!==null&&(t===null||i>t)&&(t=i)}return t}function VT(n,e){let t=-1,r=null;for(const i of e){const s=HT(i,n);s!==null&&(s>t||s===t&&r!==null&&i.id<r.id)&&(t=s,r=i)}return r}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"},Wt={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"},BT=1,GT=g({_meta:_(d(),S()).nullish(),terminal:Te().optional().default(!1)}),jT=g({_meta:_(d(),S()).nullish(),label:d().nullish(),name:d(),optional:Te().optional().default(!1),secret:Te().optional().default(!0)}),qT=g({_meta:_(d(),S()).nullish(),description:d().nullish(),id:d(),name:d()}),YT=g({_meta:_(d(),S()).nullish(),description:d().nullish(),id:d(),link:d().nullish(),name:d(),vars:D(jT)}),XT=g({_meta:_(d(),S()).nullish(),args:D(d()).optional(),description:d().nullish(),env:_(d(),d()).optional(),id:d(),name:d()}),KT=G([YT.and(g({type:$("env_var")})),XT.and(g({type:$("terminal")})),qT]),JT=g({_meta:_(d(),S()).nullish(),methodId:d()}),QT=g({_meta:_(d(),S()).nullish()}),eC=g({_meta:_(d(),S()).nullish(),blob:d(),mimeType:d().nullish(),uri:d()}),tC=g({default:Te().nullish(),description:d().nullish(),title:d().nullish()}),nC=g({_meta:_(d(),S()).nullish()}),rC=g({_meta:_(d(),S()).nullish()}),iC=g({amount:W(),currency:d()}),sC=g({_meta:_(d(),S()).nullish(),terminalId:d()}),oC=g({_meta:_(d(),S()).nullish(),newText:d(),oldText:d().nullish(),path:d()}),aC=G([d(),W(),W(),Te(),D(d())]),lC=g({content:_(d(),aC).nullish()}),cC=G([lC.and(g({action:$("accept")})),g({action:$("decline")}),g({action:$("cancel")})]),uC=g({_meta:_(d(),S()).nullish()}),iv=d(),hC=g({_meta:_(d(),S()).nullish(),elicitationId:iv}),dC=g({_meta:_(d(),S()).nullish(),action:cC}),pC=$("object"),fC=$("string"),gC=g({_meta:_(d(),S()).nullish()}),mC=g({_meta:_(d(),S()).nullish(),form:uC.nullish(),url:gC.nullish()}),vC=g({elicitationId:iv,url:d().url()}),sv=g({const:d(),title:d()}),ov=g({_meta:_(d(),S()).nullish(),name:d(),value:d()}),yC=G([$(-32700),$(-32600),$(-32601),$(-32602),$(-32603),$(-32800),$(-32e3),$(-32002),$(-32042),W().int().min(-2147483648,{message:"Invalid value: Expected int32 to be >= -2147483648"}).max(2147483647,{message:"Invalid value: Expected int32 to be <= 2147483647"})]),av=g({code:yC,data:S().optional(),message:d()}),lv=S(),cv=S(),uv=S(),bC=g({_meta:_(d(),S()).nullish(),readTextFile:Te().optional().default(!1),writeTextFile:Te().optional().default(!1)}),hv=g({_meta:_(d(),S()).nullish(),name:d(),value:d()}),dv=g({_meta:_(d(),S()).nullish(),name:d(),title:d().nullish(),version:d()}),wC=g({default:W().nullish(),description:d().nullish(),maximum:W().nullish(),minimum:W().nullish(),title:d().nullish()}),SC=g({_meta:_(d(),S()).nullish()}),_C=g({_meta:_(d(),S()).nullish(),additionalDirectories:D(d()).optional(),cursor:d().nullish(),cwd:d().nullish()}),kC=g({_meta:_(d(),S()).nullish()}),EC=g({_meta:_(d(),S()).nullish(),logout:kC.nullish()}),xC=g({_meta:_(d(),S()).nullish()}),AC=g({_meta:_(d(),S()).nullish()}),$C=g({_meta:_(d(),S()).nullish(),http:Te().optional().default(!1),sse:Te().optional().default(!1)}),IC=g({_meta:_(d(),S()).nullish(),headers:D(hv),name:d(),url:d()}),TC=g({_meta:_(d(),S()).nullish(),headers:D(hv),name:d(),url:d()}),CC=g({_meta:_(d(),S()).nullish(),args:D(d()),command:d(),env:D(ov),name:d()}),dl=G([IC.and(g({type:$("http")})),TC.and(g({type:$("sse")})),CC]),mh=d(),PC=g({_meta:_(d(),S()).nullish(),description:d().nullish(),modelId:mh,name:d()}),RC=G([$("error"),$("warning"),$("information"),$("hint")]),DC=g({_meta:_(d(),S()).nullish()}),LC=g({_meta:_(d(),S()).nullish()}),zC=g({_meta:_(d(),S()).nullish()}),OC=g({_meta:_(d(),S()).nullish()}),MC=g({_meta:_(d(),S()).nullish()}),NC=g({_meta:_(d(),S()).nullish(),maxCount:W().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish()}),UC=g({diff:d(),uri:d()}),FC=g({endLine:W().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}),startLine:W().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}),text:d()}),ZC=g({_meta:_(d(),S()).nullish()}),WC=g({_meta:_(d(),S()).nullish()}),HC=g({languageId:d(),text:d(),uri:d()}),VC=g({_meta:_(d(),S()).nullish(),maxCount:W().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish()}),BC=G([$("rejected"),$("ignored"),$("replaced"),$("cancelled")]),GC=g({excerpts:D(FC),uri:d()}),jC=g({_meta:_(d(),S()).nullish()}),qC=g({_meta:_(d(),S()).nullish()}),YC=g({name:d(),owner:d(),remoteUrl:d()}),XC=g({_meta:_(d(),S()).nullish()}),KC=g({_meta:_(d(),S()).nullish(),jump:ZC.nullish(),rename:qC.nullish(),searchAndReplace:XC.nullish()}),JC=g({id:d(),isRegex:Te().nullish(),replace:d(),search:d(),uri:d()}),QC=G([$("automatic"),$("diagnostic"),$("manual")]),eP=g({_meta:_(d(),S()).nullish(),maxCount:W().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish()}),tP=g({_meta:_(d(),S()).nullish(),diagnostics:DC.nullish(),editHistory:NC.nullish(),openFiles:WC.nullish(),recentFiles:VC.nullish(),relatedSnippets:jC.nullish(),userActions:eP.nullish()}),nP=g({_meta:_(d(),S()).nullish(),additionalDirectories:D(d()).optional(),cwd:d(),mcpServers:D(dl)}),rP=g({default:W().nullish(),description:d().nullish(),maximum:W().nullish(),minimum:W().nullish(),title:d().nullish()}),pv=d(),iP=G([$("allow_once"),$("allow_always"),$("reject_once"),$("reject_always")]),sP=g({_meta:_(d(),S()).nullish(),kind:iP,name:d(),optionId:pv}),oP=G([$("high"),$("medium"),$("low")]),aP=G([$("pending"),$("in_progress"),$("completed")]),lP=g({_meta:_(d(),S()).nullish(),content:d(),priority:oP,status:aP}),cP=g({_meta:_(d(),S()).nullish(),entries:D(lP)}),Tn=g({character:W().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}),line:W().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"})}),uP=g({id:d(),position:Tn,uri:d()}),hP=g({id:d(),newName:d(),position:Tn,uri:d()}),dP=g({action:d(),position:Tn,timestampMs:W(),uri:d()}),fv=G([$("utf-16"),$("utf-32"),$("utf-8")]),pP=g({_meta:_(d(),S()).nullish(),auth:GT.optional().default({terminal:!1}),elicitation:mC.nullish(),fs:bC.optional().default({readTextFile:!1,writeTextFile:!1}),nes:KC.nullish(),positionEncodings:D(fv).optional(),terminal:Te().optional().default(!1)}),fP=g({_meta:_(d(),S()).nullish(),audio:Te().optional().default(!1),embeddedContext:Te().optional().default(!1),image:Te().optional().default(!1)}),gv=W().int().gte(0).lte(65535),gP=g({_meta:_(d(),S()).nullish(),clientCapabilities:pP.optional().default({auth:{terminal:!1},fs:{readTextFile:!1,writeTextFile:!1},terminal:!1}),clientInfo:dv.nullish(),protocolVersion:gv}),zi=g({end:Tn,start:Tn}),mP=g({message:d(),range:zi,severity:RC,uri:d()}),vP=g({languageId:d(),lastFocusedMs:W().nullish(),uri:d(),visibleRange:zi.nullish()}),yP=g({_meta:_(d(),S()).nullish(),diagnostics:D(mP).nullish(),editHistory:D(UC).nullish(),openFiles:D(vP).nullish(),recentFiles:D(HC).nullish(),relatedSnippets:D(GC).nullish(),userActions:D(dP).nullish()}),bP=g({newText:d(),range:zi}),wP=g({cursorPosition:Tn.nullish(),edits:D(bP),id:d(),uri:d()}),SP=G([wP.and(g({kind:$("edit")})),uP.and(g({kind:$("jump")})),hP.and(g({kind:$("rename")})),JC.and(g({kind:$("searchAndReplace")}))]),_P=g({_meta:_(d(),S()).nullish(),content:d()}),kP=g({_meta:_(d(),S()).nullish()}),wr=G([W(),d()]).nullable();g({_meta:_(d(),S()).nullish(),requestId:wr});const EP=Ea(["assistant","user"]),vo=g({_meta:_(d(),S()).nullish(),audience:D(EP).nullish(),lastModified:d().nullish(),priority:W().nullish()}),xP=g({_meta:_(d(),S()).nullish(),annotations:vo.nullish(),data:d(),mimeType:d()}),AP=g({_meta:_(d(),S()).nullish(),annotations:vo.nullish(),data:d(),mimeType:d(),uri:d().nullish()}),$P=g({_meta:_(d(),S()).nullish(),annotations:vo.nullish(),description:d().nullish(),mimeType:d().nullish(),name:d(),size:W().nullish(),title:d().nullish(),uri:d()}),IP=g({_meta:_(d(),S()).nullish(),optionId:pv}),TP=G([g({outcome:$("cancelled")}),IP.and(g({outcome:$("selected")}))]),CP=g({_meta:_(d(),S()).nullish(),outcome:TP}),PP=g({_meta:_(d(),S()).nullish()}),RP=g({_meta:_(d(),S()).nullish()}),DP=g({currentValue:Te()}),LP=d(),mv=d(),zP=G([$("mode"),$("model"),$("thought_level"),d()]),vh=d(),vv=g({_meta:_(d(),S()).nullish(),description:d().nullish(),name:d(),value:vh}),OP=g({_meta:_(d(),S()).nullish(),group:LP,name:d(),options:D(vv)}),MP=G([D(vv),D(OP)]),NP=g({currentValue:vh,options:MP}),Oi=hl(G([NP.and(g({type:$("select")})),DP.and(g({type:$("boolean")}))]),g({_meta:_(d(),S()).nullish(),category:zP.nullish(),description:d().nullish(),id:mv,name:d()})),UP=g({_meta:_(d(),S()).nullish(),configOptions:D(Oi)}),FP=g({_meta:_(d(),S()).nullish()}),te=d(),ZP=g({_meta:_(d(),S()).nullish(),id:d(),sessionId:te}),WP=g({_meta:_(d(),S()).nullish(),sessionId:te}),HP=g({_meta:_(d(),S()).nullish(),sessionId:te}),VP=g({_meta:_(d(),S()).nullish(),sessionId:te}),yv=g({_meta:_(d(),S()).nullish(),args:D(d()).optional(),command:d(),cwd:d().nullish(),env:D(ov).optional(),outputByteLimit:W().nullish(),sessionId:te}),BP=g({_meta:_(d(),S()).nullish(),sessionId:te,uri:d()}),GP=g({_meta:_(d(),S()).nullish(),position:Tn,sessionId:te,uri:d(),version:W(),visibleRange:zi}),jP=g({_meta:_(d(),S()).nullish(),languageId:d(),sessionId:te,text:d(),uri:d(),version:W()}),qP=g({_meta:_(d(),S()).nullish(),sessionId:te,uri:d()}),YP=g({_meta:_(d(),S()).nullish(),additionalDirectories:D(d()).optional(),cwd:d(),mcpServers:D(dl).optional(),sessionId:te}),bv=g({_meta:_(d(),S()).nullish(),sessionId:te,terminalId:d()}),XP=g({_meta:_(d(),S()).nullish(),additionalDirectories:D(d()).optional(),cwd:d(),mcpServers:D(dl),sessionId:te}),wv=g({_meta:_(d(),S()).nullish(),limit:W().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),line:W().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),path:d(),sessionId:te}),KP=g({_meta:_(d(),S()).nullish(),id:d(),reason:BC.nullish(),sessionId:te}),Sv=g({_meta:_(d(),S()).nullish(),sessionId:te,terminalId:d()}),JP=g({_meta:_(d(),S()).nullish(),additionalDirectories:D(d()).optional(),cwd:d(),mcpServers:D(dl).optional(),sessionId:te}),QP=g({_meta:_(d(),S()).nullish(),additionalDirectories:D(d()).optional(),cwd:d(),sessionId:te,title:d().nullish(),updatedAt:d().nullish()}),eR=g({_meta:_(d(),S()).nullish(),nextCursor:d().nullish(),sessions:D(QP)}),tR=g({_meta:_(d(),S()).nullish(),title:d().nullish(),updatedAt:d().nullish()}),nR=g({_meta:_(d(),S()).nullish()}),pl=d(),rR=g({_meta:_(d(),S()).nullish(),currentModeId:pl}),iR=g({_meta:_(d(),S()).nullish(),description:d().nullish(),id:pl,name:d()}),fl=g({_meta:_(d(),S()).nullish(),availableModes:D(iR),currentModeId:pl}),gl=g({_meta:_(d(),S()).nullish(),availableModels:D(PC),currentModelId:mh}),sR=g({_meta:_(d(),S()).nullish(),configOptions:D(Oi).nullish(),models:gl.nullish(),modes:fl.nullish(),sessionId:te}),oR=g({_meta:_(d(),S()).nullish(),configOptions:D(Oi).nullish(),models:gl.nullish(),modes:fl.nullish()}),aR=g({_meta:_(d(),S()).nullish(),configOptions:D(Oi).nullish(),models:gl.nullish(),modes:fl.nullish(),sessionId:te}),lR=g({_meta:_(d(),S()).nullish(),configOptions:D(Oi).nullish(),models:gl.nullish(),modes:fl.nullish()}),cR=g({_meta:_(d(),S()).nullish()}),uR=g({_meta:_(d(),S()).nullish(),additionalDirectories:PP.nullish(),close:RP.nullish(),fork:FP.nullish(),list:nR.nullish(),resume:cR.nullish()}),hR=hl(G([g({type:$("boolean"),value:Te()}),g({value:vh})]),g({_meta:_(d(),S()).nullish(),configId:mv,sessionId:te})),dR=g({_meta:_(d(),S()).nullish(),configOptions:D(Oi)}),pR=g({_meta:_(d(),S()).nullish(),modeId:pl,sessionId:te}),fR=g({_meta:_(d(),S()).nullish()}),gR=g({_meta:_(d(),S()).nullish(),modelId:mh,sessionId:te}),mR=g({_meta:_(d(),S()).nullish()}),vR=g({_meta:_(d(),S()).nullish(),sessionId:te}),yR=G([$("end_turn"),$("max_tokens"),$("max_turn_requests"),$("refusal"),$("cancelled")]),bR=G([$("email"),$("uri"),$("date"),$("date-time")]),wR=g({default:d().nullish(),description:d().nullish(),enum:D(d()).nullish(),format:bR.nullish(),maxLength:W().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),minLength:W().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),oneOf:D(sv).nullish(),pattern:d().nullish(),title:d().nullish()}),SR=g({_meta:_(d(),S()).nullish(),context:yP.nullish(),position:Tn,selection:zi.nullish(),sessionId:te,triggerKind:QC,uri:d(),version:W()}),_R=g({_meta:_(d(),S()).nullish(),suggestions:D(SP)}),kR=g({_meta:_(d(),S()).nullish(),terminalId:d()}),ER=g({_meta:_(d(),S()).nullish(),exitCode:W().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),signal:d().nullish()}),_v=g({_meta:_(d(),S()).nullish(),sessionId:te,terminalId:d()}),xR=g({_meta:_(d(),S()).nullish(),exitStatus:ER.nullish(),output:d(),truncated:Te()}),AR=g({_meta:_(d(),S()).nullish(),annotations:vo.nullish(),text:d()}),$R=g({range:zi.nullish(),text:d()}),IR=g({_meta:_(d(),S()).nullish(),contentChanges:D($R),sessionId:te,uri:d(),version:W()});g({method:d(),params:G([WP,jP,IR,BP,qP,GP,ZP,KP,lv]).nullish()});const TR=G([$("full"),$("incremental")]),CR=g({_meta:_(d(),S()).nullish(),syncKind:TR}),PR=g({_meta:_(d(),S()).nullish(),didChange:CR.nullish(),didClose:LC.nullish(),didFocus:zC.nullish(),didOpen:OC.nullish(),didSave:MC.nullish()}),RR=g({_meta:_(d(),S()).nullish(),document:PR.nullish()}),DR=g({_meta:_(d(),S()).nullish(),context:tP.nullish(),events:RR.nullish()}),LR=g({_meta:_(d(),S()).nullish(),auth:EC.optional().default({}),loadSession:Te().optional().default(!1),mcpCapabilities:$C.optional().default({http:!1,sse:!1}),nes:DR.nullish(),positionEncoding:fv.nullish(),promptCapabilities:fP.optional().default({audio:!1,embeddedContext:!1,image:!1}),sessionCapabilities:uR.optional().default({})}),zR=g({_meta:_(d(),S()).nullish(),agentCapabilities:LR.optional().default({auth:{},loadSession:!1,mcpCapabilities:{http:!1,sse:!1},promptCapabilities:{audio:!1,embeddedContext:!1,image:!1},sessionCapabilities:{}}),agentInfo:dv.nullish(),authMethods:D(KT).optional().default([]),protocolVersion:gv}),OR=g({_meta:_(d(),S()).nullish(),mimeType:d().nullish(),text:d(),uri:d()}),MR=G([OR,eC]),NR=g({_meta:_(d(),S()).nullish(),annotations:vo.nullish(),resource:MR}),yh=G([AR.and(g({type:$("text")})),AP.and(g({type:$("image")})),xP.and(g({type:$("audio")})),$P.and(g({type:$("resource_link")})),NR.and(g({type:$("resource")}))]),UR=g({_meta:_(d(),S()).nullish(),content:yh}),hc=g({_meta:_(d(),S()).nullish(),content:yh,messageId:d().nullish()}),FR=g({_meta:_(d(),S()).nullish(),messageId:d().nullish(),prompt:D(yh),sessionId:te}),ZR=g({anyOf:D(sv)}),kv=G([UR.and(g({type:$("content")})),oC.and(g({type:$("diff")})),kR.and(g({type:$("terminal")}))]),Ev=d(),xv=g({_meta:_(d(),S()).nullish(),line:W().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),path:d()}),Av=G([$("pending"),$("in_progress"),$("completed"),$("failed")]),$v=G([$("read"),$("edit"),$("delete"),$("move"),$("search"),$("execute"),$("think"),$("fetch"),$("switch_mode"),$("other")]),WR=g({_meta:_(d(),S()).nullish(),content:D(kv).optional(),kind:$v.optional(),locations:D(xv).optional(),rawInput:S().optional(),rawOutput:S().optional(),status:Av.optional(),title:d(),toolCallId:Ev}),Iv=g({_meta:_(d(),S()).nullish(),content:D(kv).nullish(),kind:$v.nullish(),locations:D(xv).nullish(),rawInput:S().optional(),rawOutput:S().optional(),status:Av.nullish(),title:d().nullish(),toolCallId:Ev}),Tv=g({_meta:_(d(),S()).nullish(),options:D(sP),sessionId:te,toolCall:Iv}),HR=g({_meta:_(d(),S()).nullish(),hint:d()}),VR=HR,BR=g({_meta:_(d(),S()).nullish(),description:d(),input:VR.nullish(),name:d()}),GR=g({_meta:_(d(),S()).nullish(),availableCommands:D(BR)}),jR=g({enum:D(d()),type:fC}),qR=G([jR,ZR]),YR=g({default:D(d()).nullish(),description:d().nullish(),items:qR,maxItems:W().nullish(),minItems:W().nullish(),title:d().nullish()}),XR=G([wR.and(g({type:$("string")})),rP.and(g({type:$("number")})),wC.and(g({type:$("integer")})),tC.and(g({type:$("boolean")})),YR.and(g({type:$("array")}))]),KR=g({description:d().nullish(),properties:_(d(),XR).optional().default({}),required:D(d()).nullish(),title:d().nullish(),type:pC.optional().default("object")}),JR=g({requestedSchema:KR}),QR=hl(G([JR.and(g({mode:$("form")})),vC.and(g({mode:$("url")}))]),g({_meta:_(d(),S()).nullish(),message:d(),sessionId:te})),eD=g({cachedReadTokens:W().nullish(),cachedWriteTokens:W().nullish(),inputTokens:W(),outputTokens:W(),thoughtTokens:W().nullish(),totalTokens:W()}),tD=g({_meta:_(d(),S()).nullish(),stopReason:yR,usage:eD.nullish(),userMessageId:d().nullish()});G([g({id:wr,result:G([zR,QT,AC,aR,oR,eR,sR,lR,rC,fR,dR,tD,mR,vR,_R,nC,uv])}),g({error:av,id:wr})]);const nD=g({_meta:_(d(),S()).nullish(),cost:iC.nullish(),size:W(),used:W()}),rD=G([hc.and(g({sessionUpdate:$("user_message_chunk")})),hc.and(g({sessionUpdate:$("agent_message_chunk")})),hc.and(g({sessionUpdate:$("agent_thought_chunk")})),WR.and(g({sessionUpdate:$("tool_call")})),Iv.and(g({sessionUpdate:$("tool_call_update")})),cP.and(g({sessionUpdate:$("plan")})),GR.and(g({sessionUpdate:$("available_commands_update")})),rR.and(g({sessionUpdate:$("current_mode_update")})),UP.and(g({sessionUpdate:$("config_option_update")})),tR.and(g({sessionUpdate:$("session_info_update")})),nD.and(g({sessionUpdate:$("usage_update")}))]),Cv=g({_meta:_(d(),S()).nullish(),sessionId:te,update:rD});g({method:d(),params:G([Cv,hC,lv]).nullish()});const Pv=g({_meta:_(d(),S()).nullish(),sessionId:te,terminalId:d()}),iD=g({_meta:_(d(),S()).nullish(),exitCode:W().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),signal:d().nullish()}),sD=g({name:d(),uri:d()}),oD=g({_meta:_(d(),S()).nullish(),repository:YC.nullish(),workspaceFolders:D(sD).nullish(),workspaceUri:d().nullish()});g({id:wr,method:d(),params:G([gP,JT,xC,nP,XP,_C,YP,JP,VP,pR,hR,FR,gR,oD,SR,HP,cv]).nullish()});const Rv=g({_meta:_(d(),S()).nullish(),content:d(),path:d(),sessionId:te});g({id:wr,method:d(),params:G([Rv,wv,Tv,yv,_v,Sv,Pv,bv,QR,cv]).nullish()});const aD=g({_meta:_(d(),S()).nullish()});G([g({id:wr,result:G([aD,_P,CP,sC,xR,kP,iD,SC,dC,uv])}),g({error:av,id:wr})]);var ee;class lD{constructor(e,t){w(this,ee);const r=e(this),i=async(o,a)=>{var c,u,h,p,v,m,E;switch(o){case Wt.fs_write_text_file:{const k=Rv.parse(a);return(c=r.writeTextFile)==null?void 0:c.call(r,k)}case Wt.fs_read_text_file:{const k=wv.parse(a);return(u=r.readTextFile)==null?void 0:u.call(r,k)}case Wt.session_request_permission:{const k=Tv.parse(a);return r.requestPermission(k)}case Wt.terminal_create:{const k=yv.parse(a);return(h=r.createTerminal)==null?void 0:h.call(r,k)}case Wt.terminal_output:{const k=_v.parse(a);return(p=r.terminalOutput)==null?void 0:p.call(r,k)}case Wt.terminal_release:{const k=Sv.parse(a);return await((v=r.releaseTerminal)==null?void 0:v.call(r,k))??{}}case Wt.terminal_wait_for_exit:{const k=Pv.parse(a);return(m=r.waitForTerminalExit)==null?void 0:m.call(r,k)}case Wt.terminal_kill:{const k=bv.parse(a);return await((E=r.killTerminal)==null?void 0:E.call(r,k))??{}}default:if(r.extMethod)return r.extMethod(o,a);throw Ae.methodNotFound(o)}},s=async(o,a)=>{switch(o){case Wt.session_update:{const c=Cv.parse(a);return r.sessionUpdate(c)}default:if(r.extNotification)return r.extNotification(o,a);throw Ae.methodNotFound(o)}};x(this,ee,new cD(i,s,t))}async initialize(e){return await l(this,ee).sendRequest(he.initialize,e)}async newSession(e){return await l(this,ee).sendRequest(he.session_new,e)}async loadSession(e){return await l(this,ee).sendRequest(he.session_load,e)??{}}async unstable_forkSession(e){return await l(this,ee).sendRequest(he.session_fork,e)}async listSessions(e){return await l(this,ee).sendRequest(he.session_list,e)}async unstable_resumeSession(e){return await l(this,ee).sendRequest(he.session_resume,e)}async unstable_closeSession(e){return await l(this,ee).sendRequest(he.session_close,e)}async setSessionMode(e){return await l(this,ee).sendRequest(he.session_set_mode,e)??{}}async unstable_setSessionModel(e){return await l(this,ee).sendRequest(he.session_set_model,e)??{}}async setSessionConfigOption(e){return await l(this,ee).sendRequest(he.session_set_config_option,e)}async authenticate(e){return await l(this,ee).sendRequest(he.authenticate,e)??{}}async unstable_logout(e){return await l(this,ee).sendRequest(he.logout,e)??{}}async prompt(e){return await l(this,ee).sendRequest(he.session_prompt,e)}async cancel(e){return await l(this,ee).sendNotification(he.session_cancel,e)}async unstable_startNes(e){return await l(this,ee).sendRequest(he.nes_start,e)}async unstable_suggestNes(e){return await l(this,ee).sendRequest(he.nes_suggest,e)}async unstable_closeNes(e){return await l(this,ee).sendRequest(he.nes_close,e)??{}}async unstable_didOpenDocument(e){return await l(this,ee).sendNotification(he.document_did_open,e)}async unstable_didChangeDocument(e){return await l(this,ee).sendNotification(he.document_did_change,e)}async unstable_didCloseDocument(e){return await l(this,ee).sendNotification(he.document_did_close,e)}async unstable_didSaveDocument(e){return await l(this,ee).sendNotification(he.document_did_save,e)}async unstable_didFocusDocument(e){return await l(this,ee).sendNotification(he.document_did_focus,e)}async unstable_acceptNes(e){return await l(this,ee).sendNotification(he.nes_accept,e)}async unstable_rejectNes(e){return await l(this,ee).sendNotification(he.nes_reject,e)}async extMethod(e,t){return await l(this,ee).sendRequest(e,t)}async extNotification(e,t){return await l(this,ee).sendNotification(e,t)}get signal(){return l(this,ee).signal}get closed(){return l(this,ee).closed}}ee=new WeakMap;var gn,Da,Es,xs,ni,ri,Ct,As,pe,Dv,Gc,Lv,zv,Ov,Mv,jc,es;class cD{constructor(e,t,r){w(this,pe);w(this,gn,new Map);w(this,Da,0);w(this,Es);w(this,xs);w(this,ni);w(this,ri,Promise.resolve());w(this,Ct,new AbortController);w(this,As);x(this,Es,e),x(this,xs,t),x(this,ni,r),x(this,As,new Promise(i=>{l(this,Ct).signal.addEventListener("abort",()=>i())})),f(this,pe,Dv).call(this)}get signal(){return l(this,Ct).signal}get closed(){return l(this,As)}async sendRequest(e,t){f(this,pe,jc).call(this);const r=ud(this,Da)._++,i=new Promise((s,o)=>{l(this,gn).set(r,{resolve:s,reject:o})});return await f(this,pe,es).call(this,{jsonrpc:"2.0",id:r,method:e,params:t}),i}async sendNotification(e,t){f(this,pe,jc).call(this),await f(this,pe,es).call(this,{jsonrpc:"2.0",method:e,params:t})}}gn=new WeakMap,Da=new WeakMap,Es=new WeakMap,xs=new WeakMap,ni=new WeakMap,ri=new WeakMap,Ct=new WeakMap,As=new WeakMap,pe=new WeakSet,Dv=async function(){let e;try{const t=l(this,ni).readable.getReader();try{for(;!l(this,Ct).signal.aborted;){const{value:r,done:i}=await t.read();if(i)break;if(r)try{f(this,pe,Lv).call(this,r)}catch(s){console.error("Unexpected error during message processing:",r,s),"id"in r&&r.id!==void 0&&f(this,pe,es).call(this,{jsonrpc:"2.0",id:r.id,error:{code:-32700,message:"Parse error"}})}}}finally{t.releaseLock()}}catch(t){e=t}finally{f(this,pe,Gc).call(this,e)}},Gc=function(e){if(l(this,Ct).signal.aborted)return;const t=e??new Error("ACP connection closed");for(const r of l(this,gn).values())r.reject(t);l(this,gn).clear(),l(this,Ct).abort(t)},Lv=async function(e){if("method"in e&&"id"in e){const t=await f(this,pe,zv).call(this,e.method,e.params);"error"in t&&console.error("Error handling request",e,t.error),await f(this,pe,es).call(this,{jsonrpc:"2.0",id:e.id,...t})}else if("method"in e){const t=await f(this,pe,Ov).call(this,e.method,e.params);"error"in t&&console.error("Error handling notification",e,t.error)}else"id"in e?f(this,pe,Mv).call(this,e):console.error("Invalid message",{message:e})},zv=async function(e,t){try{return{result:await l(this,Es).call(this,e,t)??null}}catch(r){if(r instanceof Ae)return r.toResult();if(r instanceof tf)return Ae.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 Ae.internalError(i?JSON.parse(i):{}).toResult()}catch{return Ae.internalError({details:i}).toResult()}}},Ov=async function(e,t){try{return await l(this,xs).call(this,e,t),{result:null}}catch(r){if(r instanceof Ae)return r.toResult();if(r instanceof tf)return Ae.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 Ae.internalError(i?JSON.parse(i):{}).toResult()}catch{return Ae.internalError({details:i}).toResult()}}},Mv=function(e){const t=l(this,gn).get(e.id);if(t){if("result"in e)t.resolve(e.result);else if("error"in e){const{code:r,message:i,data:s}=e.error;t.reject(new Ae(r,i,s))}l(this,gn).delete(e.id)}else console.error("Got response to unknown request",e.id)},jc=function(){if(l(this,Ct).signal.aborted)throw l(this,Ct).signal.reason??new Error("ACP connection closed")},es=async function(e){return x(this,ri,l(this,ri).then(async()=>{const t=l(this,ni).writable.getWriter();try{await t.write(e)}finally{t.releaseLock()}}).catch(t=>{f(this,pe,Gc).call(this,t)})),l(this,ri)};class Ae extends Error{constructor(t,r,i){super(r);b(this,"code");b(this,"data");this.code=t,this.name="RequestError",this.data=i}static parseError(t,r){return new Ae(-32700,`Parse error${r?`: ${r}`:""}`,t)}static invalidRequest(t,r){return new Ae(-32600,`Invalid request${r?`: ${r}`:""}`,t)}static methodNotFound(t){return new Ae(-32601,`"Method not found": ${t}`,{method:t})}static invalidParams(t,r){return new Ae(-32602,`Invalid params${r?`: ${r}`:""}`,t)}static internalError(t,r){return new Ae(-32603,`Internal error${r?`: ${r}`:""}`,t)}static authRequired(t,r){return new Ae(-32e3,`Authentication required${r?`: ${r}`:""}`,t)}static resourceNotFound(t){return new Ae(-32002,`Resource not found${t?`: ${t}`:""}`,t&&{uri:t})}toResult(){return{error:{code:this.code,message:this.message,data:this.data}}}toErrorResponse(){return{code:this.code,message:this.message,data:this.data}}}const uD=/^Sender \(untrusted metadata\):\n```json\n[\s\S]*?\n```\n\n?/,hD=/^\[[^\n]*Working directory:[^\n]*\]\n\n?/,dD=/\[Television screen context\][\s\S]*?\[\/Television screen context\]\n*/,pD=/\[\[\s*(?:reply_to_current|reply_to\s*:\s*[^\]\n]+|audio_as_voice)\s*\]\]\s*/gi,fD="single_session",gD={name:"television-acp-client",version:"0.0.0"},Nv="agent:main:television",mD=mo(Ot);var ae,Gt,ii,jt,rr,ir,sr,or,mn,si,Pt,Qe,qt,ar,Yt,vn,$s,Xt,gt,La,Kt,I,Uv,Fv,Zv,qc,Wv,Hv,Vv,Bv,Gv,jv,qv,Wn,Wr,Hr,Ve,Yv,Vr,Yc,Xc,ra,Xv,Kv,Is,Ts,Kc,Br,Jv,Qv;class vD extends mD{constructor(t){super();w(this,I);w(this,ae,bD());w(this,Gt,null);w(this,ii,null);w(this,jt,null);w(this,rr,null);w(this,ir,null);w(this,sr,null);w(this,or);w(this,mn,null);w(this,si,1);w(this,Pt,null);w(this,Qe,null);w(this,qt,!1);w(this,ar,!1);w(this,Yt,null);w(this,vn,new Set);w(this,$s);w(this,Xt);w(this,gt);w(this,La,t=>{f(this,I,Fv).call(this,t)});w(this,Kt,null);w(this,Is,()=>{f(this,I,Br).call(this,"ACP bridge websocket closed")});w(this,Ts,()=>{f(this,I,Br).call(this,"ACP bridge websocket error")});x(this,Xt,t),x(this,gt,t.sessionMode??fD),x(this,or,t.mappedSessionStore??yD()),x(this,$s,t.createSocket??(r=>new WebSocket(r)))}getState(){return l(this,ae)}get messages(){return l(this,ae).messageOrder.map(t=>l(this,ae).messagesById[t]).filter(t=>t!==void 0)}async connect(){if(this.disposed)throw new Error("ACPClient has been disposed");if(l(this,ae).lifecycle.status!=="ready"){f(this,I,Ve).call(this,{lifecycle:{status:"connecting"}}),l(this,ii)??x(this,ii,f(this,I,Uv).call(this));try{await l(this,ii),await f(this,I,qc).call(this)}catch(t){throw f(this,I,Br).call(this,Uo(t)),t}}}dispose(){f(this,I,Kc).call(this),f(this,I,Ve).call(this,{lifecycle:{status:"disposed"},run:{status:"idle",stopReason:null,canCancel:!1,error:null},bridge:null})}async sendMessage(t){if(await this.connect(),l(this,ae).lifecycle.status!=="ready"||l(this,ae).run.status==="running"||l(this,ae).run.status==="cancelling")throw new Error("ACPClient is not ready to send a new message");const r=t.text.trim();if(!r)throw new Error("Cannot send an empty message");f(this,I,Wr).call(this,{id:f(this,I,Vr).call(this,"user"),kind:"user",text:r,status:"final"}),f(this,I,Ve).call(this,{run:{status:"running",stopReason:null,canCancel:!0,error:null}});try{const i=await f(this,I,ra).call(this).prompt({sessionId:f(this,I,Xc).call(this),prompt:[{type:"text",text:f(this,I,Yv).call(this,r)}]});f(this,I,Wn).call(this,i.stopReason==="cancelled"?"cancelled":"final"),f(this,I,Ve).call(this,{run:{status:i.stopReason==="cancelled"?"cancelled":"completed",stopReason:i.stopReason,canCancel:!1,error:null}})}catch(i){throw f(this,I,Qv).call(this)||(f(this,I,Wn).call(this,"error"),f(this,I,Ve).call(this,{run:{status:"error",stopReason:null,canCancel:!1,error:Uo(i)}})),i}}async cancel(){if(await this.connect(),!l(this,ae).run.canCancel||l(this,ae).run.status!=="running")throw new Error("No active cancellable run");f(this,I,Ve).call(this,{run:{...l(this,ae).run,status:"cancelling"}}),await f(this,I,ra).call(this).cancel({sessionId:f(this,I,Xc).call(this)})}setScreenContext(t){var s,o,a;if(t===null){if(l(this,Qe)===null)return;x(this,Qe,null),x(this,qt,!1);return}const r={screenID:t.screenID,screenName:t.screenName};if(((s=l(this,Qe))==null?void 0:s.screenID)===r.screenID&&((o=l(this,Qe))==null?void 0:o.screenName)===r.screenName)return;const i=((a=l(this,Qe))==null?void 0:a.screenID)??null;if(x(this,Qe,r),l(this,gt)==="single_session"){(!l(this,mn)||i!==r.screenID)&&x(this,qt,!0);return}l(this,mn)!==lf(l(this,gt),r.screenID,l(this,Xt).clientGUID??"default-client")&&(x(this,jt,null),x(this,rr,null),l(this,Gt)&&l(this,ae).run.status==="idle"&&f(this,I,qc).call(this).catch(c=>{f(this,I,Br).call(this,Uo(c))}))}}ae=new WeakMap,Gt=new WeakMap,ii=new WeakMap,jt=new WeakMap,rr=new WeakMap,ir=new WeakMap,sr=new WeakMap,or=new WeakMap,mn=new WeakMap,si=new WeakMap,Pt=new WeakMap,Qe=new WeakMap,qt=new WeakMap,ar=new WeakMap,Yt=new WeakMap,vn=new WeakMap,$s=new WeakMap,Xt=new WeakMap,gt=new WeakMap,La=new WeakMap,Kt=new WeakMap,I=new WeakSet,Uv=async function(){try{f(this,I,Ve).call(this,{lifecycle:{status:"connecting"}});const{stream:t,socket:r,metadata:i}=await _D({serverURL:l(this,Xt).serverURL,token:l(this,Xt).token,createSocket:l(this,$s),onDisconnect:l(this,La)});x(this,sr,i),f(this,I,Ve).call(this,{bridge:i}),x(this,Kt,r),r.addEventListener("close",l(this,Is)),r.addEventListener("error",l(this,Ts)),x(this,Gt,new lD(s=>({connection:s,sessionUpdate:async o=>{await f(this,I,Hv).call(this,o)},requestPermission:async o=>f(this,I,Vv).call(this,o)}),t)),await l(this,Gt).initialize({protocolVersion:BT,clientCapabilities:{},clientInfo:gD})}catch(t){throw t}},Fv=function(t){f(this,I,Br).call(this,Uo(t))},Zv=function(t){const r=t==null?void 0:t.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})`)},qc=async function(){const t=f(this,I,Kv).call(this);if(l(this,jt)&&l(this,rr)===t){await l(this,jt);return}x(this,rr,t),x(this,jt,f(this,I,Wv).call(this,t)),await l(this,jt)},Wv=async function(t){var c;const r=f(this,I,ra).call(this);f(this,I,Jv).call(this);let i,s=!1,o=null;const a={cwd:f(this,I,Xv).call(this),mcpServers:[],_meta:{sessionKey:t}};try{if(x(this,ar,!0),x(this,Yt,null),((c=l(this,sr))==null?void 0:c.sessionIdStrategy)==="mapped"){const u=l(this,or).getActualSessionId(t);if(u)try{const h=await r.loadSession({...a,sessionId:u});if(wD(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,or).setActualSessionId(t,i),s=!1}else{const h=await r.newSession(a);o=h,i=h.sessionId,l(this,or).setActualSessionId(t,i),s=!1}}else try{o=await r.loadSession({...a,sessionId:t}),i=t,s=l(this,ae).messageOrder.length>0}catch{const u=await r.newSession(a);o=u,i=u.sessionId,s=!1}}finally{x(this,ar,!1),x(this,Yt,null),f(this,I,Wn).call(this,"final")}f(this,I,Zv).call(this,o),await r.setSessionConfigOption({sessionId:i,configId:"verbose_level",value:"full"}),x(this,ir,i),x(this,mn,t),s?(l(this,vn).add(t),l(this,gt)==="single_session"&&x(this,qt,!1)):(l(this,vn).delete(t),x(this,qt,l(this,gt)==="single_session")),f(this,I,Ve).call(this,{lifecycle:{status:"ready"}})},Hv=async function(t){const r=t.update;switch(r.sessionUpdate){case"user_message_chunk":r.content.type==="text"&&f(this,I,qv).call(this,r.content.text);return;case"agent_message_chunk":r.content.type==="text"&&f(this,I,Bv).call(this,r.content.text);return;case"tool_call":f(this,I,Gv).call(this,r);return;case"tool_call_update":f(this,I,jv).call(this,r);return;case"agent_thought_chunk":return;default:return}},Vv=async function(t){return{outcome:{outcome:"cancelled"}}},Bv=function(t){x(this,Yt,null);const r=SD(t);if(!r)return;if(!l(this,Pt)){const s={id:f(this,I,Vr).call(this,"assistant"),kind:"assistant",text:r,status:"streaming"};x(this,Pt,s.id),f(this,I,Wr).call(this,s);return}const i=l(this,ae).messagesById[l(this,Pt)];if(!i||i.kind!=="assistant")throw new Error("Open assistant message invariant violated");f(this,I,Hr).call(this,{...i,text:`${i.text}${r}`,status:"streaming"})},Gv=function(t){f(this,I,Wn).call(this,"final");const r=f(this,I,Yc).call(this,t.toolCallId),i=uf("content"in t?t.content:void 0),s={id:(r==null?void 0:r.id)??f(this,I,Vr).call(this,"tool"),kind:"tool_call",toolCallId:t.toolCallId,title:t.title,toolKind:t.kind??"other",status:t.status==="failed"?"failed":t.status==="completed"?"completed":"in_progress",text:(r==null?void 0:r.text)??i,locations:t.locations??(r==null?void 0:r.locations)};if(r){f(this,I,Hr).call(this,s);return}f(this,I,Wr).call(this,s)},jv=function(t){const r=f(this,I,Yc).call(this,t.toolCallId),i=(r==null?void 0:r.text)??"",s=uf(t.content),o=s?`${i}${s}`:i,a={id:(r==null?void 0:r.id)??f(this,I,Vr).call(this,"tool"),kind:"tool_call",toolCallId:t.toolCallId,title:(r==null?void 0:r.title)??t.toolCallId,toolKind:(r==null?void 0:r.toolKind)??"other",status:t.status==="failed"?"failed":t.status==="completed"?"completed":"in_progress",text:o,locations:t.locations??(r==null?void 0:r.locations)};if(r){f(this,I,Hr).call(this,a);return}f(this,I,Wr).call(this,a)},qv=function(t){if(f(this,I,Wn).call(this,"final"),!t)return;const r=l(this,ar)?l(this,Yt):null;if(!r){const s=cf(t);if(!s)return;const o={id:f(this,I,Vr).call(this,"user"),kind:"user",text:s,status:"final"};f(this,I,Wr).call(this,o),l(this,ar)&&x(this,Yt,o.id);return}const i=l(this,ae).messagesById[r];if(!i||i.kind!=="user")throw new Error("Replay user message invariant violated");f(this,I,Hr).call(this,{...i,text:cf(`${i.text}${t}`)})},Wn=function(t){if(!l(this,Pt))return;const r=l(this,ae).messagesById[l(this,Pt)];(r==null?void 0:r.kind)==="assistant"&&f(this,I,Hr).call(this,{...r,status:t}),x(this,Pt,null)},Wr=function(t){f(this,I,Ve).call(this,{messagesById:{...l(this,ae).messagesById,[t.id]:t},messageOrder:[...l(this,ae).messageOrder,t.id]})},Hr=function(t){f(this,I,Ve).call(this,{messagesById:{...l(this,ae).messagesById,[t.id]:t}})},Ve=function(t){const r={...l(this,ae),...t};x(this,ae,{...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 ie("change"))},Yv=function(t){const r=l(this,mn);return!l(this,Qe)||!r||!(l(this,gt)==="single_session"?l(this,qt)||!l(this,vn).has(r):!l(this,vn).has(r))?t:(x(this,qt,!1),l(this,vn).add(r),["[Television screen context]","This chat session is coming from a Television client in the screen below.",`screen_id: ${l(this,Qe).screenID}`,`screen_name: ${l(this,Qe).screenName??""}`,"When the user asks to inspect or change Television state with the tv CLI, use this screen ID with the --screen argument.","[/Television screen context]","",t].join(`
|
|
43
|
+
`))},Vr=function(t){const r=`${t}-${l(this,si)}`;return x(this,si,l(this,si)+1),r},Yc=function(t){for(const r of l(this,ae).messageOrder){const i=l(this,ae).messagesById[r];if((i==null?void 0:i.kind)==="tool_call"&&i.toolCallId===t)return i}return null},Xc=function(){if(!l(this,ir))throw new Error("ACP session is not ready");return l(this,ir)},ra=function(){if(!l(this,Gt))throw new Error("ACP connection is not ready");return l(this,Gt)},Xv=function(){var r;const t=(r=l(this,sr))==null?void 0:r.sessionCwd;if(!t)throw new Error("ACP bridge session cwd is not ready");return t},Kv=function(){var r;if(l(this,gt)==="single_session")return`${Nv}-${(l(this,Xt).clientGUID??"default-client").toLowerCase()}`;const t=(r=l(this,Qe))==null?void 0:r.screenID;if(!t)throw new Error("Screen context is required for per-screen session mode");return lf(l(this,gt),t,l(this,Xt).clientGUID??"default-client")},Is=new WeakMap,Ts=new WeakMap,Kc=function(){x(this,Gt,null),x(this,ii,null),x(this,jt,null),x(this,rr,null),x(this,ir,null),x(this,mn,null),x(this,sr,null),l(this,Kt)&&(l(this,Kt).removeEventListener("close",l(this,Is)),l(this,Kt).removeEventListener("error",l(this,Ts)),l(this,Kt).close(),x(this,Kt,null))},Br=function(t){this.disposed||l(this,ae).lifecycle.status==="disconnected"||(f(this,I,Wn).call(this,"error"),f(this,I,Kc).call(this),f(this,I,Ve).call(this,{lifecycle:{status:"disconnected",...t?{error:t}:{}},run:{status:"idle",stopReason:null,canCancel:!1,error:null},bridge:null}))},Jv=function(){x(this,Pt,null),x(this,Yt,null),x(this,si,1),f(this,I,Ve).call(this,{run:{status:"idle",stopReason:null,canCancel:!1,error:null},messagesById:{},messageOrder:[]})},Qv=function(){return l(this,ae).lifecycle.status==="disconnected"};function yD(){const n=new Map;return{getActualSessionId(e){return n.get(e)??null},setActualSessionId(e,t){n.set(e,t)},clearActualSessionId(e){n.delete(e)}}}function bD(){return{lifecycle:{status:"connecting"},run:{status:"idle",stopReason:null,canCancel:!1,error:null},bridge:null,messagesById:{},messageOrder:[],sendDisabled:!0,cancelDisabled:!0}}function wD(n){return n==null?!0:typeof n=="object"&&Object.keys(n).length===0}function lf(n,e,t){return n==="single_session"?`${Nv}-${t.toLowerCase()}`:`agent:main:television-${t.toLowerCase()}-${e.toLowerCase()}`}function ey(n){return n.replace(/^(?:\s*\n)+/,"")}function cf(n){let e=n;return e=e.replace(uD,""),e=e.replace(hD,""),e=e.replace(dD,""),e=ey(e),e}function SD(n){let e=n;return e=e.replace(pD,""),e=ey(e),e}function uf(n){return!n||n.length===0?"":n.flatMap(e=>e.type==="content"&&e.content.type==="text"?[e.content.text]:[]).join("")}async function _D(n){const e=n.createSocket(xD(n.serverURL,n.token));let t=!1,r,i;const s=new Promise((u,h)=>{r=u,i=h}),o=new ReadableStream({start(u){let h=!1;const p=()=>{e.send(JSON.stringify({type:"acp-bridge-connect"}))},v=k=>{const T=ED(k);if(!T)return;let O;try{O=JSON.parse(T)}catch(P){const V=P instanceof Error?P:new Error(String(P));i(V),u.error(V);return}switch(O.type){case"acp-bridge-status":if(O.status==="ready"){let P;try{P=kD(O)}catch(V){const F=V instanceof Error?V:new Error(String(V));t||i(F),u.error(F);return}t||(t=!0,r(P));return}if(O.status==="error"||O.status==="exited"){const P=new Error(O.error??`ACP bridge ${O.status}`);t||i(P),u.error(P)}return;case"acp-bridge-message":u.enqueue(O.message);return}},m=()=>{var T;if(h)return;h=!0;const k=new Error("ACP bridge websocket closed");t||i(k),(T=n.onDisconnect)==null||T.call(n,k),u.close()},E=()=>{var T;if(h)return;h=!0;const k=new Error("ACP bridge websocket error");t||i(k),(T=n.onDisconnect)==null||T.call(n,k),u.error(k)};e.addEventListener("open",p),e.addEventListener("message",v),e.addEventListener("close",m),e.addEventListener("error",E)}}),a=new WritableStream({async write(u){await s,e.send(JSON.stringify({type:"acp-bridge-message",message:u}))},close(){e.close()},abort(){e.close()}}),c=await s;return{stream:{readable:o,writable:a},socket:e,metadata:c}}function kD(n){const{agent:e,sessionIdStrategy:t,sessionCwd:r}=n;if((e==="openclaw"||e==="hermes")&&(t==="deterministic"||t==="mapped")&&typeof r=="string"&&r.length>0)return{agent:e,sessionIdStrategy:t,sessionCwd:r};throw new Error("ACP bridge ready status missing bootstrap metadata")}function ED(n){if(typeof n=="string")return n;if(n instanceof Uint8Array)return new TextDecoder().decode(n);if(typeof Buffer<"u"&&n instanceof Buffer)return n.toString("utf8");if(typeof n=="object"&&n!==null&&"data"in n){const e=n.data;if(typeof e=="string")return e;if(e instanceof Uint8Array)return new TextDecoder().decode(e);if(Array.isArray(e))return Buffer.concat(e).toString("utf8")}return null}function xD(n,e){const t=new URL(n);return t.protocol=t.protocol==="https:"?"wss:":"ws:",t.pathname="/acp",t.search="",t.searchParams.set("token",e),t.hash="",t.toString()}function Uo(n){return n instanceof Error?n.message:String(n)}const hf="television.acpClientGUID",df="television.acpMappedSessions",pf=1;var oi;class AD{constructor(){w(this,oi,new Map)}getActualSessionId(e){return l(this,oi).get(e)??null}setActualSessionId(e,t){l(this,oi).set(e,t)}clearActualSessionId(e){l(this,oi).delete(e)}}oi=new WeakMap;var ai,Cs,et,ia,sa,Jc;class $D{constructor(e,t){w(this,et);w(this,ai);w(this,Cs);x(this,ai,e),x(this,Cs,t)}getActualSessionId(e){const t=f(this,et,sa).call(this)[f(this,et,ia).call(this,e)];return typeof t=="string"&&t.length>0?t:null}setActualSessionId(e,t){const r=f(this,et,sa).call(this);r[f(this,et,ia).call(this,e)]=t,f(this,et,Jc).call(this,r)}clearActualSessionId(e){const t=f(this,et,sa).call(this);delete t[f(this,et,ia).call(this,e)],f(this,et,Jc).call(this,t)}}ai=new WeakMap,Cs=new WeakMap,et=new WeakSet,ia=function(e){return JSON.stringify([l(this,Cs),e])},sa=function(){const e=l(this,ai).getItem(df);if(!e)return{};let t;try{t=JSON.parse(e)}catch{return{}}if(typeof t!="object"||t===null||Array.isArray(t))return{};const r=t;return r.version!==pf?{}:typeof r.entries!="object"||r.entries===null||Array.isArray(r.entries)?{}:Object.fromEntries(Object.entries(r.entries).filter(i=>typeof i[1]=="string"))},Jc=function(e){const t={version:pf,entries:e};l(this,ai).setItem(df,JSON.stringify(t))};function ID(){return typeof window>"u"?null:window.localStorage}function TD(n){const e=n.getItem(hf);if(e)return e;const t=al().toLowerCase();return n.setItem(hf,t),t}const CD=4401;class Qc extends Error{constructor(e="Authentication required"){super(e),this.name="AuthError"}}class ty extends Ot{constructor(t){super();b(this,"url");b(this,"name");b(this,"token");b(this,"status","disconnected");b(this,"screens",new Map);b(this,"views",[]);b(this,"client");b(this,"acpClient");b(this,"createSocket");b(this,"createClient");b(this,"socket",null);b(this,"connectAttempt",0);this.url=dt(t.url),this.name=t.name,this.token=t.token??null,this.createSocket=t.createSocket??(i=>new WebSocket(i)),this.createClient=t.createClient??((i,s)=>new qx(i,{token:s??void 0})),this.client=this.createClient(this.url,this.token);const r=t.mappedSessionStore??(t.acpStorage?new $D(t.acpStorage,this.url):new AD);this.acpClient=new vD({serverURL:this.url,token:this.token??"",...t.createACPSocket?{createSocket:t.createACPSocket}:t.createSocket?{createSocket:t.createSocket}:{},...t.clientGUID?{clientGUID:t.clientGUID}:{},mappedSessionStore:r})}async connect(){var i;this.connectAttempt+=1;const t=this.connectAttempt;(i=this.socket)==null||i.close(),this.client=this.createClient(this.url,this.token),this.status="connecting",this.dispatchEvent(new ie("change"));const r=this.createSocket(PD(this.url,this.token));return this.socket=r,await new Promise((s,o)=>{let a=!1;const c=()=>{a||this.connectAttempt!==t||(a=!0,this.status="connected",this.dispatchEvent(new ie("change")),s())},u=p=>{a||this.connectAttempt!==t||(a=!0,this.status="disconnected",this.dispatchEvent(new ie("change")),o(p))},h=async()=>{try{const[{screens:p},v]=await Promise.all([this.client.screens.list(),this.client.views.list()]);this.screens=new Map(p.map(m=>[m.id,structuredClone(m)])),this.views=v,this.dispatchEvent(new ie("change")),c()}catch(p){u(p instanceof Error?p:new Error(String(p)))}};r.addEventListener("open",()=>{h()}),r.addEventListener("message",p=>{const v=DD(p);v&&(this.applyServerEvent(v),this.dispatchEvent(new mm("server-event",{serverURL:this.url,event:v})))}),r.addEventListener("close",p=>{if(this.connectAttempt===t){if(this.socket=null,RD(p)===CD){u(new Qc);return}if(!a){u(new Error("Connection closed before initialization"));return}this.status="disconnected",this.dispatchEvent(new ie("change"))}}),r.addEventListener("error",()=>{u(new Error("WebSocket connection failed"))})})}disconnect(){var t;this.connectAttempt+=1,(t=this.socket)==null||t.close(),this.socket=null,this.status="disconnected",this.dispatchEvent(new ie("change"))}dispose(){this.disconnect(),this.acpClient.dispose()}getViewURL(t){const r=VT(t.type,this.views);if(!r)return null;const i=`${this.url}/views/${encodeURIComponent(r.id)}/`;return this.token===null?i:`${i}?token=${encodeURIComponent(this.token)}`}getContentURL(t){const r=`${this.url}/artifacts/${encodeURIComponent(t)}/content`;return this.token===null?r:`${r}?token=${encodeURIComponent(this.token)}`}async createScreen(t){const{screen:r}=await this.client.screens.create({name:t});return this.screens.set(r.id,structuredClone(r)),r}applyServerEvent(t){switch(t.type){case"screen-created":this.screens.set(t.screen.id,structuredClone(t.screen)),this.dispatchEvent(new ta("screens-changed"));break;case"screen-updated":this.screens.set(t.screen.id,structuredClone(t.screen)),this.dispatchEvent(new ta("screens-changed"));break;case"screen-removed":this.screens.delete(t.screenID),this.dispatchEvent(new ta("screens-changed"));break;case"artifact-created":break;case"artifact-attached":{const r=this.screens.get(t.screenID);r&&!pm(r.layout,t.artifact.id)&&(r.layout=[...r.layout,dm(t.artifact.id,{id:t.cardID})]);break}case"artifact-removed":{const r=this.screens.get(t.screenID);r&&(r.layout=rm(r.layout,t.artifactID));break}}}}function PD(n,e){const t=new URL(n);return t.protocol=t.protocol==="https:"?"wss:":"ws:",t.pathname="/events",t.search="",e&&t.searchParams.set("token",e),t.hash="",t.toString()}function RD(n){return typeof n=="object"&&n!==null&&"code"in n&&typeof n.code=="number"?n.code:null}function DD(n){const e=typeof n=="string"?n:typeof n=="object"&&n!==null&&"data"in n&&typeof n.data=="string"?n.data:"";if(!e)return null;try{return JSON.parse(e)}catch{return null}}const LD="Local";var Ps,eu;class zD extends Ot{constructor(t){super();w(this,Ps);b(this,"servers",new Map);b(this,"localServerURL");b(this,"clientGUID");b(this,"acpStorage");b(this,"localStore");b(this,"createSocket");b(this,"lastActiveServerURL");b(this,"serverListeners",new Map);b(this,"handleLocalStoreChange",()=>{const t=this.localStore.get().activeServerURL;t!==this.lastActiveServerURL&&(this.lastActiveServerURL=t,this.dispatchEvent(new ie("change")))});this.localStore=t.localStore,this.localServerURL=t.localServerURL?dt(t.localServerURL):null,this.createSocket=t.createSocket??(i=>new WebSocket(i)),this.lastActiveServerURL=this.localStore.get().activeServerURL;const r=t.acpStorage===void 0?ID():t.acpStorage;this.acpStorage=r,this.clientGUID=t.clientGUID??(r?TD(r):al().toLowerCase()),this.localStore.addEventListener("change",this.handleLocalStoreChange)}get activeServer(){const t=this.localStore.get().activeServerURL;return t===null?null:this.servers.get(t)??null}add(t){const r=dt(t.url);this.servers.get(r)&&this.remove(r),this.servers.set(r,t);const s=()=>{this.dispatchEvent(new ie("change"))},o=c=>{this.dispatchEvent(new mm("server-event",{serverURL:c.serverURL,event:c.event}))},a=()=>{this.dispatchEvent(new ta("screens-changed"))};t.addEventListener("change",s),t.addEventListener("server-event",o),t.addEventListener("screens-changed",a),this.serverListeners.set(r,{onServerChange:s,onServerEvent:o,onScreensChanged:a}),this.dispatchEvent(new ie("change"))}remove(t){const r=dt(t);if(this.localServerURL&&r===this.localServerURL)return;const i=this.servers.get(r);if(!i)return;const s=this.serverListeners.get(r);s&&(i.removeEventListener("change",s.onServerChange),i.removeEventListener("server-event",s.onServerEvent),i.removeEventListener("screens-changed",s.onScreensChanged),this.serverListeners.delete(r)),i.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 ie("change"))}setActive(t){const r=this.localStore.get(),i=t?dt(t.url):null;r.activeServerURL!==i&&this.localStore.set({...r,activeServerURL:i})}connectConfiguredServers(t,r){const i=t?dt(t):null;if(i){const a=this.localStore.get();a.servers.some(u=>dt(u.url)===i)||this.localStore.set({...a,servers:[...a.servers,{url:i,name:LD}]})}const s=this.localStore.get().servers;for(const a of s){const c=dt(a.url),u=i!==null&&c===i,h=f(this,Ps,eu).call(this,{url:a.url,name:a.name,token:u?r??null:null});this.add(h),h.connect().catch(()=>{})}const o=i?this.servers.get(i)??null:null;this.setActive(o??this.servers.values().next().value??null)}addServer(t,r){const i=dt(t);this.remove(i);const s=this.localStore.get();this.localStore.set({...s,servers:[...s.servers.filter(a=>dt(a.url)!==i),{url:i,name:r}]});const o=f(this,Ps,eu).call(this,{url:i,name:r,token:null});this.add(o),this.setActive(o),o.connect().catch(()=>{})}removeServer(t){this.remove(t)}}Ps=new WeakSet,eu=function(t){return new ty({url:t.url,name:t.name,token:t.token,createSocket:this.createSocket,clientGUID:this.clientGUID,acpStorage:this.acpStorage})};var Rs;class OD extends Ot{constructor(){super();w(this,Rs,t=>{const r=MD(t);r!==null&&(t.preventDefault(),this.dispatchEvent(new mx("shortcut-triggered",{shortcut:r})))});document.addEventListener("keydown",l(this,Rs))}dispose(){document.removeEventListener("keydown",l(this,Rs))}}Rs=new WeakMap;function MD(n){for(const[e,t]of Object.entries(Yx))if(ND(n,t.trigger))return e;return null}function ND(n,e){return!(n.key.toLowerCase()!==e.key.toLowerCase()||n.metaKey!==!!e.meta||n.ctrlKey!==!!e.ctrl||n.shiftKey!==!!e.shift||n.altKey!==!!e.alt)}const UD="serverURL",FD="token",ZD="mode",WD="electron";function ny(n=window.location.search,e=window.location.origin){const r=new URLSearchParams(n).get(UD);return r?new URL(r).origin:new URL(e).origin}function ff(n=window.location.search){return new URLSearchParams(n).get(FD)}function bh(n=window.location.search){return new URLSearchParams(n).get(ZD)===WD}/**
|
|
44
|
+
* @license
|
|
45
|
+
* Copyright 2017 Google LLC
|
|
46
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
47
|
+
*/const cs=globalThis,gf=n=>n,xa=cs.trustedTypes,mf=xa?xa.createPolicy("lit-html",{createHTML:n=>n}):void 0,ry="$lit$",dn=`lit$${Math.random().toFixed(9).slice(2)}$`,iy="?"+dn,HD=`<${iy}>`,Sr=document,fs=()=>Sr.createComment(""),gs=n=>n===null||typeof n!="object"&&typeof n!="function",wh=Array.isArray,VD=n=>wh(n)||typeof(n==null?void 0:n[Symbol.iterator])=="function",dc=`[
|
|
48
|
+
\f\r]`,Vi=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,vf=/-->/g,yf=/>/g,Nn=RegExp(`>|${dc}(?:([^\\s"'>=/]+)(${dc}*=${dc}*(?:[^
|
|
49
|
+
\f\r"'\`<>=]|("|')|))|$)`,"g"),bf=/'/g,wf=/"/g,sy=/^(?:script|style|textarea|title)$/i,BD=n=>(e,...t)=>({_$litType$:n,strings:e,values:t}),N=BD(1),Ei=Symbol.for("lit-noChange"),ne=Symbol.for("lit-nothing"),Sf=new WeakMap,Yn=Sr.createTreeWalker(Sr,129);function oy(n,e){if(!wh(n)||!n.hasOwnProperty("raw"))throw Error("invalid template strings array");return mf!==void 0?mf.createHTML(e):e}const GD=(n,e)=>{const t=n.length-1,r=[];let i,s=e===2?"<svg>":e===3?"<math>":"",o=Vi;for(let a=0;a<t;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===Vi?h[1]==="!--"?o=vf:h[1]!==void 0?o=yf:h[2]!==void 0?(sy.test(h[2])&&(i=RegExp("</"+h[2],"g")),o=Nn):h[3]!==void 0&&(o=Nn):o===Nn?h[0]===">"?(o=i??Vi,p=-1):h[1]===void 0?p=-2:(p=o.lastIndex-h[2].length,u=h[1],o=h[3]===void 0?Nn:h[3]==='"'?wf:bf):o===wf||o===bf?o=Nn:o===vf||o===yf?o=Vi:(o=Nn,i=void 0);const m=o===Nn&&n[a+1].startsWith("/>")?" ":"";s+=o===Vi?c+HD:p>=0?(r.push(u),c.slice(0,p)+ry+c.slice(p)+dn+m):c+dn+(p===-2?a:m)}return[oy(n,s+(n[t]||"<?>")+(e===2?"</svg>":e===3?"</math>":"")),r]};class ms{constructor({strings:e,_$litType$:t},r){let i;this.parts=[];let s=0,o=0;const a=e.length-1,c=this.parts,[u,h]=GD(e,t);if(this.el=ms.createElement(u,r),Yn.currentNode=this.el.content,t===2||t===3){const p=this.el.content.firstChild;p.replaceWith(...p.childNodes)}for(;(i=Yn.nextNode())!==null&&c.length<a;){if(i.nodeType===1){if(i.hasAttributes())for(const p of i.getAttributeNames())if(p.endsWith(ry)){const v=h[o++],m=i.getAttribute(p).split(dn),E=/([.?@])?(.*)/.exec(v);c.push({type:1,index:s,name:E[2],strings:m,ctor:E[1]==="."?qD:E[1]==="?"?YD:E[1]==="@"?XD:ml}),i.removeAttribute(p)}else p.startsWith(dn)&&(c.push({type:6,index:s}),i.removeAttribute(p));if(sy.test(i.tagName)){const p=i.textContent.split(dn),v=p.length-1;if(v>0){i.textContent=xa?xa.emptyScript:"";for(let m=0;m<v;m++)i.append(p[m],fs()),Yn.nextNode(),c.push({type:2,index:++s});i.append(p[v],fs())}}}else if(i.nodeType===8)if(i.data===iy)c.push({type:2,index:s});else{let p=-1;for(;(p=i.data.indexOf(dn,p+1))!==-1;)c.push({type:7,index:s}),p+=dn.length-1}s++}}static createElement(e,t){const r=Sr.createElement("template");return r.innerHTML=e,r}}function xi(n,e,t=n,r){var o,a;if(e===Ei)return e;let i=r!==void 0?(o=t._$Co)==null?void 0:o[r]:t._$Cl;const s=gs(e)?void 0:e._$litDirective$;return(i==null?void 0:i.constructor)!==s&&((a=i==null?void 0:i._$AO)==null||a.call(i,!1),s===void 0?i=void 0:(i=new s(n),i._$AT(n,t,r)),r!==void 0?(t._$Co??(t._$Co=[]))[r]=i:t._$Cl=i),i!==void 0&&(e=xi(n,i._$AS(n,e.values),i,r)),e}class jD{constructor(e,t){this._$AV=[],this._$AN=void 0,this._$AD=e,this._$AM=t}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(e){const{el:{content:t},parts:r}=this._$AD,i=((e==null?void 0:e.creationScope)??Sr).importNode(t,!0);Yn.currentNode=i;let s=Yn.nextNode(),o=0,a=0,c=r[0];for(;c!==void 0;){if(o===c.index){let u;c.type===2?u=new Sh(s,s.nextSibling,this,e):c.type===1?u=new c.ctor(s,c.name,c.strings,this,e):c.type===6&&(u=new KD(s,this,e)),this._$AV.push(u),c=r[++a]}o!==(c==null?void 0:c.index)&&(s=Yn.nextNode(),o++)}return Yn.currentNode=Sr,i}p(e){let t=0;for(const r of this._$AV)r!==void 0&&(r.strings!==void 0?(r._$AI(e,r,t),t+=r.strings.length-2):r._$AI(e[t])),t++}}let Sh=class ay{get _$AU(){var e;return((e=this._$AM)==null?void 0:e._$AU)??this._$Cv}constructor(e,t,r,i){this.type=2,this._$AH=ne,this._$AN=void 0,this._$AA=e,this._$AB=t,this._$AM=r,this.options=i,this._$Cv=(i==null?void 0:i.isConnected)??!0}get parentNode(){let e=this._$AA.parentNode;const t=this._$AM;return t!==void 0&&(e==null?void 0:e.nodeType)===11&&(e=t.parentNode),e}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(e,t=this){e=xi(this,e,t),gs(e)?e===ne||e==null||e===""?(this._$AH!==ne&&this._$AR(),this._$AH=ne):e!==this._$AH&&e!==Ei&&this._(e):e._$litType$!==void 0?this.$(e):e.nodeType!==void 0?this.T(e):VD(e)?this.k(e):this._(e)}O(e){return this._$AA.parentNode.insertBefore(e,this._$AB)}T(e){this._$AH!==e&&(this._$AR(),this._$AH=this.O(e))}_(e){this._$AH!==ne&&gs(this._$AH)?this._$AA.nextSibling.data=e:this.T(Sr.createTextNode(e)),this._$AH=e}$(e){var s;const{values:t,_$litType$:r}=e,i=typeof r=="number"?this._$AC(e):(r.el===void 0&&(r.el=ms.createElement(oy(r.h,r.h[0]),this.options)),r);if(((s=this._$AH)==null?void 0:s._$AD)===i)this._$AH.p(t);else{const o=new jD(i,this),a=o.u(this.options);o.p(t),this.T(a),this._$AH=o}}_$AC(e){let t=Sf.get(e.strings);return t===void 0&&Sf.set(e.strings,t=new ms(e)),t}k(e){wh(this._$AH)||(this._$AH=[],this._$AR());const t=this._$AH;let r,i=0;for(const s of e)i===t.length?t.push(r=new ay(this.O(fs()),this.O(fs()),this,this.options)):r=t[i],r._$AI(s),i++;i<t.length&&(this._$AR(r&&r._$AB.nextSibling,i),t.length=i)}_$AR(e=this._$AA.nextSibling,t){var r;for((r=this._$AP)==null?void 0:r.call(this,!1,!0,t);e!==this._$AB;){const i=gf(e).nextSibling;gf(e).remove(),e=i}}setConnected(e){var t;this._$AM===void 0&&(this._$Cv=e,(t=this._$AP)==null||t.call(this,e))}},ml=class{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(e,t,r,i,s){this.type=1,this._$AH=ne,this._$AN=void 0,this.element=e,this.name=t,this._$AM=i,this.options=s,r.length>2||r[0]!==""||r[1]!==""?(this._$AH=Array(r.length-1).fill(new String),this.strings=r):this._$AH=ne}_$AI(e,t=this,r,i){const s=this.strings;let o=!1;if(s===void 0)e=xi(this,e,t,0),o=!gs(e)||e!==this._$AH&&e!==Ei,o&&(this._$AH=e);else{const a=e;let c,u;for(e=s[0],c=0;c<s.length-1;c++)u=xi(this,a[r+c],t,c),u===Ei&&(u=this._$AH[c]),o||(o=!gs(u)||u!==this._$AH[c]),u===ne?e=ne:e!==ne&&(e+=(u??"")+s[c+1]),this._$AH[c]=u}o&&!i&&this.j(e)}j(e){e===ne?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,e??"")}},qD=class extends ml{constructor(){super(...arguments),this.type=3}j(e){this.element[this.name]=e===ne?void 0:e}},YD=class extends ml{constructor(){super(...arguments),this.type=4}j(e){this.element.toggleAttribute(this.name,!!e&&e!==ne)}},XD=class extends ml{constructor(e,t,r,i,s){super(e,t,r,i,s),this.type=5}_$AI(e,t=this){if((e=xi(this,e,t,0)??ne)===Ei)return;const r=this._$AH,i=e===ne&&r!==ne||e.capture!==r.capture||e.once!==r.once||e.passive!==r.passive,s=e!==ne&&(r===ne||i);i&&this.element.removeEventListener(this.name,this,r),s&&this.element.addEventListener(this.name,this,e),this._$AH=e}handleEvent(e){var t;typeof this._$AH=="function"?this._$AH.call(((t=this.options)==null?void 0:t.host)??this.element,e):this._$AH.handleEvent(e)}};class KD{constructor(e,t,r){this.element=e,this.type=6,this._$AN=void 0,this._$AM=t,this.options=r}get _$AU(){return this._$AM._$AU}_$AI(e){xi(this,e)}}const pc=cs.litHtmlPolyfillSupport;pc==null||pc(ms,Sh),(cs.litHtmlVersions??(cs.litHtmlVersions=[])).push("3.3.2");const Fe=(n,e,t)=>{const r=e;let i=r._$litPart$;return i===void 0&&(r._$litPart$=i=new Sh(e.insertBefore(fs(),null),null,void 0,{})),i._$AI(n),i},JD=.5,_f=.1,kf=8,QD=4,ly=3,cy=3,e2=4,Xn=255,uy=.2126,hy=.7152,dy=.0722;async function py(n){const e=t2(n);if(!e)return"light";try{return await i2(n,e)>=JD?"light":"dark"}catch{return"light"}}function t2(n){if(typeof document.elementsFromPoint!="function")return null;const e=n.getBoundingClientRect(),t=e.left+e.width/2,r=e.top+e.height/2,i=document.elementsFromPoint(t,r);for(const s of i){if(!(s instanceof HTMLElement)||s===n||n.contains(s))continue;const o=window.getComputedStyle(s);if(n2(o))return s}return null}function n2(n){return n.backgroundImage&&n.backgroundImage!=="none"?!0:r2(n.backgroundColor)>0}function r2(n){if(!n)return 0;const e=n.match(/rgba?\(([^)]+)\)/);if(!e)return 0;const t=e[1].split(/[\s,/]+/).filter(Boolean);return t.length===e2?parseFloat(t[ly]):t.length===cy?1:0}async function i2(n,e){const t=n.getBoundingClientRect(),r=e.getBoundingClientRect(),i={x:Fo((t.left-r.left)/r.width),y:Fo((t.top-r.top)/r.height),width:Fo(t.width/r.width),height:Fo(t.height/r.height)},s=window.getComputedStyle(e),o=s2(s.backgroundImage);return o?a2({url:o,surfaceWidth:r.width,surfaceHeight:r.height,region:i}):l2(s.backgroundColor)}function s2(n){const e=n.match(/url\(\s*["']?([^"')]+)["']?\s*\)/);return e?e[1]:null}const Ef=new Map;function o2(n){let e=Ef.get(n);return e||(e=new Promise((t,r)=>{const i=new Image;i.crossOrigin="anonymous",i.onload=()=>t(i),i.onerror=()=>r(new Error(`Failed to load ${n}`)),i.src=n}),Ef.set(n,e),e)}async function a2(n){const e=await o2(n.url),t=Math.max(kf,Math.ceil(n.surfaceWidth*_f)),r=Math.max(kf,Math.ceil(n.surfaceHeight*_f)),i=document.createElement("canvas");i.width=t,i.height=r;const s=i.getContext("2d",{willReadFrequently:!0});if(!s)return 1;const o=n.surfaceWidth/n.surfaceHeight,a=e.naturalWidth/e.naturalHeight;let c,u;a>o?(u=r,c=r*a):(c=t,u=t/a);const h=(t-c)/2,p=(r-u)/2;s.drawImage(e,h,p,c,u);const v=Math.max(0,Math.floor(n.region.x*t)),m=Math.max(0,Math.floor(n.region.y*r)),E=Math.max(1,Math.min(t-v,Math.floor(n.region.width*t))),k=Math.max(1,Math.min(r-m,Math.floor(n.region.height*r))),T=s.getImageData(v,m,E,k).data;let O=0,P=0;for(let V=0;V<T.length;V+=QD){const F=T[V]/Xn,B=T[V+1]/Xn,U=T[V+2]/Xn,Q=T[V+ly]/Xn;O+=Q*(uy*F+hy*B+dy*U),P+=1}return P>0?O/P:1}function l2(n){const e=n.match(/rgba?\(([^)]+)\)/);if(!e)return 1;const t=e[1].split(/[\s,/]+/).filter(Boolean).map(parseFloat);if(t.length<cy)return 1;const r=t[0]/Xn,i=t[1]/Xn,s=t[2]/Xn;return uy*r+hy*i+dy*s}function Fo(n){return n<0?0:n>1?1:n}const c2=["ghost","glass"],vs=c2.flatMap(n=>[`button[variant="${n}"]`,`segmented-control[variant="${n}"]`]).join(", "),Zo=new WeakSet,xf=new WeakSet;function fy(n){if(xf.has(n))return;xf.add(n);for(const t of n.querySelectorAll(vs))fc(t);if(typeof MutationObserver!="function")return;new MutationObserver(t=>{for(const r of t)if(r.type==="childList")for(const i of r.addedNodes)u2(i,fc);else r.type==="attributes"&&r.target instanceof HTMLElement&&r.target.matches(vs)&&fc(r.target)}).observe(n,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["variant"]})}function u2(n,e){if(n instanceof Element){n instanceof HTMLElement&&n.matches(vs)&&e(n);for(const t of n.querySelectorAll(vs))e(t)}}async function fc(n){if(Zo.has(n)||n.hasAttribute("tone"))return;Zo.add(n);const e=await py(n);if(!n.matches(vs)){Zo.delete(n);return}if(n.hasAttribute("tone")){Zo.delete(n);return}n.setAttribute("tone",e)}const h2="*,*: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-sm: 24px;--control-height-md: 28px;--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;--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-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-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-md);padding:0 10px}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)}button[variant=ghost]:active:not(:disabled){background:var(--color-overlay-active);box-shadow:none}button[variant=ghost][data-active]:not(:disabled),button[variant=ghost][data-active]: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);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);backdrop-filter:blur(20px) brightness(.95) saturate(1.5);-webkit-backdrop-filter:blur(20px) brightness(.95) saturate(1.5);box-shadow:none}button[variant=glass]:hover:not(:disabled){background:linear-gradient(var(--color-overlay-hover),var(--color-overlay-hover))}button[variant=glass]:active:not(:disabled){background:linear-gradient(var(--color-overlay-active),var(--color-overlay-active))}[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[icon-only]{width:var(--control-height-md);padding:0}[data-ui-icon]{display:inline-block;vertical-align:middle}.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-200), transparent);--color-overlay-active: color-mix(in srgb, var(--white) var(--alpha-300), 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-100), transparent);--color-overlay-active: color-mix(in srgb, var(--black) var(--alpha-200), 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)}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:var(--color-overlay-backdrop)}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([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(: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>[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: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-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)}',_h=new CSSStyleSheet;_h.replaceSync(h2);try{document.adoptedStyleSheets=[...document.adoptedStyleSheets,_h]}catch{}fy(document);function gy(n){try{n.adoptedStyleSheets=[...n.adoptedStyleSheets,_h]}catch{}fy(n)}/**
|
|
50
|
+
* @license
|
|
51
|
+
* Copyright 2017 Google LLC
|
|
52
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
53
|
+
*/const my={CHILD:2},kh=n=>(...e)=>({_$litDirective$:n,values:e});class vy{constructor(e){}get _$AU(){return this._$AM._$AU}_$AT(e,t,r){this._$Ct=e,this._$AM=t,this._$Ci=r}_$AS(e,t){return this.update(e,t)}update(e,t){return this.render(...t)}}/**
|
|
54
|
+
* @license
|
|
55
|
+
* Copyright 2017 Google LLC
|
|
56
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
57
|
+
*/let Aa=class extends vy{constructor(e){if(super(e),this.it=ne,e.type!==my.CHILD)throw Error(this.constructor.directiveName+"() can only be used in child bindings")}render(e){if(e===ne||e==null)return this._t=void 0,this.it=e;if(e===Ei)return e;if(typeof e!="string")throw Error(this.constructor.directiveName+"() called with a non-string value");if(e===this.it)return this._t;this.it=e;const t=[e];return t.raw=t,this._t={_$litType$:this.constructor.resultType,strings:t,values:[]}}};Aa.directiveName="unsafeHTML",Aa.resultType=1;const d2=kh(Aa);/**
|
|
58
|
+
* @license
|
|
59
|
+
* Copyright 2017 Google LLC
|
|
60
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
61
|
+
*/class tu extends Aa{}tu.directiveName="unsafeSVG",tu.resultType=2;const p2=kh(tu),f2={size:16,color:"currentColor",weight:"regular"};function g2(n){return typeof n=="string"?{regular:n}:n}function sn(n,e="0 0 256 256"){const t=g2(n);return r=>{const{size:i,color:s,weight:o}={...f2,...r},a=t[o]??t.regular;return N`<svg
|
|
62
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
63
|
+
data-ui-icon=""
|
|
64
|
+
width="${i}"
|
|
65
|
+
height="${i}"
|
|
66
|
+
viewBox="${e}"
|
|
67
|
+
fill="${s}"
|
|
68
|
+
>${p2(a)}</svg>`}}/**
|
|
69
|
+
* @license
|
|
70
|
+
* Copyright 2020 Google LLC
|
|
71
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
72
|
+
*/const m2=n=>n.strings===void 0;/**
|
|
73
|
+
* @license
|
|
74
|
+
* Copyright 2017 Google LLC
|
|
75
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
76
|
+
*/const us=(n,e)=>{var r;const t=n._$AN;if(t===void 0)return!1;for(const i of t)(r=i._$AO)==null||r.call(i,e,!1),us(i,e);return!0},$a=n=>{let e,t;do{if((e=n._$AM)===void 0)break;t=e._$AN,t.delete(n),n=e}while((t==null?void 0:t.size)===0)},yy=n=>{for(let e;e=n._$AM;n=e){let t=e._$AN;if(t===void 0)e._$AN=t=new Set;else if(t.has(n))break;t.add(n),b2(e)}};function v2(n){this._$AN!==void 0?($a(this),this._$AM=n,yy(this)):this._$AM=n}function y2(n,e=!1,t=0){const r=this._$AH,i=this._$AN;if(i!==void 0&&i.size!==0)if(e)if(Array.isArray(r))for(let s=t;s<r.length;s++)us(r[s],!1),$a(r[s]);else r!=null&&(us(r,!1),$a(r));else us(this,n)}const b2=n=>{n.type==my.CHILD&&(n._$AP??(n._$AP=y2),n._$AQ??(n._$AQ=v2))};class w2 extends vy{constructor(){super(...arguments),this._$AN=void 0}_$AT(e,t,r){super._$AT(e,t,r),yy(this),this.isConnected=e._$AU}_$AO(e,t=!0){var r,i;e!==this.isConnected&&(this.isConnected=e,e?(r=this.reconnected)==null||r.call(this):(i=this.disconnected)==null||i.call(this)),t&&(us(this,e),$a(this))}setValue(e){if(m2(this._$Ct))this._$Ct._$AI(e,this);else{const t=[...this._$Ct._$AH];t[this._$Ci]=e,this._$Ct._$AI(t,this,0)}}disconnected(){}reconnected(){}}/**
|
|
77
|
+
* @license
|
|
78
|
+
* Copyright 2020 Google LLC
|
|
79
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
80
|
+
*/const ln=()=>new S2;class S2{}const gc=new WeakMap,cn=kh(class extends w2{render(n){return ne}update(n,[e]){var r;const t=e!==this.G;return t&&this.G!==void 0&&this.rt(void 0),(t||this.lt!==this.ct)&&(this.G=e,this.ht=(r=n.options)==null?void 0:r.host,this.rt(this.ct=n.element)),ne}rt(n){if(this.isConnected||(n=void 0),typeof this.G=="function"){const e=this.ht??globalThis;let t=gc.get(e);t===void 0&&(t=new WeakMap,gc.set(e,t)),t.get(this.G)!==void 0&&this.G.call(this.ht,void 0),t.set(this.G,n),n!==void 0&&this.G.call(this.ht,n)}else this.G.value=n}get lt(){var n,e;return typeof this.G=="function"?(n=gc.get(this.ht??globalThis))==null?void 0:n.get(this.G):(e=this.G)==null?void 0:e.value}disconnected(){this.lt===this.ct&&this.rt(void 0)}reconnected(){this.rt(this.ct)}}),_2=sn('<path fill="none" stroke="currentColor" stroke-width="16" stroke-linecap="round" stroke-linejoin="round" d="M200 224H56C53.8783 224 51.8434 223.157 50.3431 221.657C48.8429 220.157 48 218.122 48 216V40C48 37.8783 48.8429 35.8434 50.3431 34.3431C51.8434 32.8429 53.8783 32 56 32H152L208 88V216C208 218.122 207.157 220.157 205.657 221.657C204.157 223.157 202.122 224 200 224Z"/><path fill="none" stroke="currentColor" stroke-width="16" stroke-linecap="round" stroke-linejoin="round" d="M152 32V88H208"/><path fill="none" stroke="currentColor" stroke-width="16" stroke-linecap="round" d="M80 88H124.5"/><path fill="none" stroke="currentColor" stroke-width="16" stroke-linecap="round" d="M80 128H175"/><path fill="none" stroke="currentColor" stroke-width="16" stroke-linecap="round" d="M80 169H175"/>'),by=sn('<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"/>'),wy=sn('<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"/>'),k2=sn({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"/>'}),E2=sn('<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"/>'),x2=sn({regular:'<path d="M219.31,108.68l-80-80a16,16,0,0,0-22.62,0l-80,80A15.87,15.87,0,0,0,32,120v96a8,8,0,0,0,8,8h64a8,8,0,0,0,8-8V160h32v56a8,8,0,0,0,8,8h64a8,8,0,0,0,8-8V120A15.87,15.87,0,0,0,219.31,108.68ZM208,208H160V152a8,8,0,0,0-8-8H104a8,8,0,0,0-8,8v56H48V120l80-80,80,80Z"/>',bold:'<path d="M222.14,105.85l-80-80a20,20,0,0,0-28.28,0l-80,80A19.86,19.86,0,0,0,28,120v96a12,12,0,0,0,12,12h64a12,12,0,0,0,12-12V164h24v52a12,12,0,0,0,12,12h64a12,12,0,0,0,12-12V120A19.86,19.86,0,0,0,222.14,105.85ZM204,204H164V152a12,12,0,0,0-12-12H104a12,12,0,0,0-12,12v52H52V121.65l76-76,76,76Z"/>',fill:'<path d="M224,120v96a8,8,0,0,1-8,8H160a8,8,0,0,1-8-8V164a4,4,0,0,0-4-4H108a4,4,0,0,0-4,4v52a8,8,0,0,1-8,8H40a8,8,0,0,1-8-8V120a16,16,0,0,1,4.69-11.31l80-80a16,16,0,0,1,22.62,0l80,80A16,16,0,0,1,224,120Z"/>'}),A2=sn({regular:'<path d="M227.31,73.37,182.63,28.68a16,16,0,0,0-22.63,0L36.69,152A15.86,15.86,0,0,0,32,163.31V208a16,16,0,0,0,16,16H92.69A15.86,15.86,0,0,0,104,219.31L227.31,96a16,16,0,0,0,0-22.63ZM51.31,160,136,75.31,152.69,92,68,176.68ZM48,179.31,76.69,208H48Zm48,25.38L79.31,188,164,103.31,180.69,120Zm96-96L147.31,64l24-24L216,84.68Z"/>',bold:'<path d="M230.14,70.54,185.46,25.85a20,20,0,0,0-28.29,0L33.86,149.17A19.85,19.85,0,0,0,28,163.31V208a20,20,0,0,0,20,20H92.69a19.86,19.86,0,0,0,14.14-5.86L230.14,98.82a20,20,0,0,0,0-28.28ZM93,180l71-71,11,11-71,71ZM76,163,65,152l71-71,11,11ZM52,173l15.51,15.51h0L83,204H52ZM192,103,153,64l18.34-18.34,39,39Z"/>'}),$2=sn({regular:'<path d="M216,48H176V40a24,24,0,0,0-24-24H104A24,24,0,0,0,80,40v8H40a8,8,0,0,0,0,16h8V208a16,16,0,0,0,16,16H192a16,16,0,0,0,16-16V64h8a8,8,0,0,0,0-16ZM96,40a8,8,0,0,1,8-8h48a8,8,0,0,1,8,8v8H96Zm96,168H64V64H192ZM112,104v64a8,8,0,0,1-16,0V104a8,8,0,0,1,16,0Zm48,0v64a8,8,0,0,1-16,0V104a8,8,0,0,1,16,0Z"/>',bold:'<path d="M216,44H176V40a24,24,0,0,0-24-24H104A24,24,0,0,0,80,40v4H40a12,12,0,0,0,0,24h4V208a20,20,0,0,0,20,20H192a20,20,0,0,0,20-20V68h4a12,12,0,0,0,0-24ZM104,40h48v4H104Zm84,164H68V68H188Zm-84-48V120a12,12,0,0,1,24,0v36a12,12,0,0,1-24,0Zm40,0V120a12,12,0,0,1,24,0v36a12,12,0,0,1-24,0Z"/>'}),I2=sn({regular:'<path d="M235.32,81.37,174.63,20.69a16,16,0,0,0-22.63,0L98.37,74.49c-10.66-3.34-35-7.37-60.4,13.14a16,16,0,0,0-1.29,23.78L85,159.71,42.34,202.34a8,8,0,0,0,11.32,11.32L96.29,171l48.29,48.29A16,16,0,0,0,155.9,224c.38,0,.75,0,1.13,0a15.93,15.93,0,0,0,11.64-6.33c19.64-26.1,17.75-47.32,13.19-60L235.33,104A16,16,0,0,0,235.32,81.37ZM224,92.69h0l-57.27,57.46a8,8,0,0,0-1.49,9.22c9.46,18.93-1.8,38.59-9.34,48.62L48,100.08c12.08-9.74,23.64-12.31,32.48-12.31A40.13,40.13,0,0,1,96.81,91a8,8,0,0,0,9.25-1.51L163.32,32,224,92.68Z"/>',bold:'<path d="M238.15,78.54,177.46,17.86a20,20,0,0,0-28.3,0L97.2,70c-12.43-3.33-36.68-5.72-61.74,14.5a20,20,0,0,0-1.6,29.73l45.46,45.47-39.8,39.8a12,12,0,0,0,17,17l39.8-39.81,45.47,45.46A20,20,0,0,0,155.91,228c.46,0,.93,0,1.4-.05A20,20,0,0,0,171.87,220c4.69-6.23,11-16.13,14.44-28s3.45-22.88.16-33.4l51.7-51.87A20,20,0,0,0,238.15,78.54Zm-74.26,68.79a12,12,0,0,0-2.23,13.84c3.43,6.86,6.9,21-6.28,40.65L54.08,100.53c21.09-14.59,39.53-6.64,41-6a11.67,11.67,0,0,0,13.81-2.29l54.43-54.61,55,55Z"/>',fill:'<path d="M235.33,104l-53.47,53.65c4.56,12.67,6.45,33.89-13.19,60A15.93,15.93,0,0,1,157,224c-.38,0-.75,0-1.13,0a16,16,0,0,1-11.32-4.69L96.29,171,53.66,213.66a8,8,0,0,1-11.32-11.32L85,159.71l-48.3-48.3A16,16,0,0,1,38,87.63c25.42-20.51,49.75-16.48,60.4-13.14L152,20.7a16,16,0,0,1,22.63,0l60.69,60.68A16,16,0,0,1,235.33,104Z"/>'});class T2 extends Event{constructor(){super("close",{bubbles:!0,composed:!0})}}const Af='a[href],button:not([disabled]),input:not([disabled]),select:not([disabled]),textarea:not([disabled]),[tabindex]:not([tabindex="-1"])',mc=4;var ze,Jt,lr,Ge,Ds,li,ci,Y,nu,_y,oa,ky,ru,iu,Ls,zs,cr,Ey,su,xy,Ay,aa,Gr;class Sy extends HTMLElement{constructor(){super();w(this,Y);w(this,ze,!1);w(this,Jt,null);w(this,lr);w(this,Ge,null);w(this,Ds,"bottom-start");w(this,li,!1);w(this,ci,!1);w(this,Ls,t=>{l(this,ze)&&(l(this,li)||t.composedPath().includes(this)||(this.open=!1))});w(this,zs,t=>{if(l(this,ze)){if(t.key==="Escape"){t.preventDefault(),this.open=!1;return}t.key==="Tab"&&f(this,Y,Ey).call(this,t)}});w(this,cr,()=>{l(this,ze)&&f(this,Y,aa).call(this)});x(this,lr,this.attachShadow({mode:"open"})),gy(l(this,lr)),f(this,Y,nu).call(this,"anchor")}connectedCallback(){this.removeAttribute("popover"),this.hasAttribute("tone")||this.setAttribute("tone","light"),f(this,Y,nu).call(this,"open"),f(this,Y,Gr).call(this),l(this,ze)&&(f(this,Y,ru).call(this),f(this,Y,oa).call(this))}disconnectedCallback(){f(this,Y,iu).call(this)}attributeChangedCallback(t){t==="open"?f(this,Y,_y).call(this,this.hasAttribute("open")):t==="material"&&l(this,ze)&&(f(this,Y,Gr).call(this),f(this,Y,oa).call(this))}get open(){return l(this,ze)}set open(t){this.toggleAttribute("open",t)}get anchor(){return l(this,Jt)}set anchor(t){l(this,Jt)!==t&&(x(this,Jt,t),l(this,ze)&&f(this,Y,aa).call(this))}}ze=new WeakMap,Jt=new WeakMap,lr=new WeakMap,Ge=new WeakMap,Ds=new WeakMap,li=new WeakMap,ci=new WeakMap,Y=new WeakSet,nu=function(t){if(!Object.prototype.hasOwnProperty.call(this,t))return;const r=this,i=r[t];delete r[t],r[t]=i},_y=function(t){var r,i,s;if(l(this,ze)!==t){if(x(this,ze,t),!this.isConnected){f(this,Y,Gr).call(this);return}t?(x(this,li,!0),setTimeout(()=>{x(this,li,!1)},0),f(this,Y,Gr).call(this),f(this,Y,ru).call(this),f(this,Y,oa).call(this)):(f(this,Y,iu).call(this),(i=(r=l(this,Ge))==null?void 0:r.hidePopover)==null||i.call(r),f(this,Y,Gr).call(this),(s=l(this,Jt))==null||s.focus(),this.dispatchEvent(new T2))}},oa=function(){l(this,ci)||(x(this,ci,!0),queueMicrotask(()=>{x(this,ci,!1),!(!l(this,ze)||!this.isConnected)&&(f(this,Y,ky).call(this),f(this,Y,Ay).call(this))}))},ky=function(){var t,r;if(l(this,Ge)){try{(r=(t=l(this,Ge)).showPopover)==null||r.call(t)}catch{}f(this,Y,aa).call(this)}},ru=function(){document.addEventListener("click",l(this,Ls)),document.addEventListener("keydown",l(this,zs),!0),window.addEventListener("resize",l(this,cr)),window.addEventListener("scroll",l(this,cr),!0)},iu=function(){document.removeEventListener("click",l(this,Ls)),document.removeEventListener("keydown",l(this,zs),!0),window.removeEventListener("resize",l(this,cr)),window.removeEventListener("scroll",l(this,cr),!0)},Ls=new WeakMap,zs=new WeakMap,cr=new WeakMap,Ey=function(t){const r=f(this,Y,su).call(this);if(r.length===0){t.preventDefault();return}const i=r[0],s=r[r.length-1],o=f(this,Y,xy).call(this),a=o instanceof HTMLElement&&r.includes(o);t.shiftKey?(!a||o===i)&&(t.preventDefault(),s.focus()):(!a||o===s)&&(t.preventDefault(),i.focus())},su=function(){if(!l(this,Ge))return[];const t=l(this,Ge).querySelector("slot");if(!(t instanceof HTMLSlotElement))return[];const r=[];for(const i of t.assignedElements({flatten:!0}))if(i instanceof HTMLElement){i.matches(Af)&&r.push(i);for(const s of i.querySelectorAll(Af))r.push(s)}return r},xy=function(){var r;let t=document.activeElement;for(;t&&((r=t.shadowRoot)!=null&&r.activeElement);)t=t.shadowRoot.activeElement;return t},Ay=function(){var r;const t=f(this,Y,su).call(this);t.length>0?t[0].focus():(r=l(this,Ge))==null||r.focus()},aa=function(){if(!l(this,ze)||!l(this,Jt)||!l(this,Ge))return;const t=l(this,Jt).getBoundingClientRect(),r=l(this,Ge).getBoundingClientRect(),s=window.innerHeight-t.bottom,o=r.height+mc,a=s<o&&t.top>o?"top-start":"bottom-start";x(this,Ds,a);const c=a==="bottom-start"?t.bottom+mc:t.top-r.height-mc,u=t.left;l(this,Ge).style.transform=`translate(${u}px, ${c}px)`,l(this,Ge).setAttribute("data-placement",a)},Gr=function(){this.toggleAttribute("open",l(this,ze));const t=this.getAttribute("material")??"paper";Fe(l(this,ze)?N`<div
|
|
81
|
+
class="panel"
|
|
82
|
+
part="panel"
|
|
83
|
+
popover="manual"
|
|
84
|
+
data-placement=${l(this,Ds)}
|
|
85
|
+
tabindex="-1"
|
|
86
|
+
role="dialog"
|
|
87
|
+
material=${t}
|
|
88
|
+
level="1"
|
|
89
|
+
>
|
|
90
|
+
<slot></slot>
|
|
91
|
+
</div>`:ne,l(this,lr)),x(this,Ge,l(this,lr).querySelector(".panel"))},b(Sy,"observedAttributes",["open","material"]);customElements.get("ui-popover")||customElements.define("ui-popover",Sy);class $y extends Event{constructor(t){super("dropdown-item-select",{bubbles:!0,composed:!0});b(this,"value");this.value=t}}class C2 extends Event{constructor(t){super("select",{bubbles:!0,composed:!0});b(this,"value");this.value=t}}var je,mt,yn,bn,le,Os,Ms,L,Ty,ts,Cy,Py,ou,Ry,ns,Hn,ur,Ns,za,Us,Oa,Dy,Ly,au,rs,lu,cu,Ht;class Iy extends HTMLElement{constructor(){super();w(this,L);w(this,je,!1);w(this,mt,null);w(this,yn,null);w(this,bn);w(this,le,null);w(this,Os,ln());w(this,Ms,new MutationObserver(t=>f(this,L,Dy).call(this,t)));w(this,ur,()=>{f(this,L,ns).call(this,!l(this,je))});w(this,Ns,t=>{t.key!=="Enter"&&t.key!==" "||(t.preventDefault(),l(this,ur).call(this))});w(this,za,()=>{l(this,je)&&f(this,L,ns).call(this,!1)});w(this,Us,t=>{t instanceof $y&&(t.stopPropagation(),x(this,je,!1),f(this,L,ts).call(this,t.value),f(this,L,Ht).call(this),this.dispatchEvent(new C2(t.value)))});w(this,Oa,()=>{f(this,L,au).call(this)});x(this,bn,this.attachShadow({mode:"open"})),gy(l(this,bn))}connectedCallback(){this.addEventListener("dropdown-item-select",l(this,Us)),f(this,L,Ty).call(this),l(this,Ms).observe(this,{childList:!0,subtree:!0,characterData:!0,attributes:!0,attributeFilter:["selected","value","slot"]}),f(this,L,Ht).call(this)}disconnectedCallback(){this.removeEventListener("dropdown-item-select",l(this,Us)),l(this,Ms).disconnect(),f(this,L,cu).call(this)}attributeChangedCallback(t){if(t==="open"){f(this,L,ns).call(this,this.hasAttribute("open"));return}f(this,L,Ht).call(this)}get open(){return l(this,je)}set open(t){this.toggleAttribute("open",t)}get title(){return this.getAttribute("title")??""}get value(){return l(this,mt)}set value(t){t===null?(f(this,L,Hn).call(this,null,null),f(this,L,Cy).call(this)):f(this,L,ts).call(this,t),f(this,L,Ht).call(this)}close(){f(this,L,ns).call(this,!1)}}je=new WeakMap,mt=new WeakMap,yn=new WeakMap,bn=new WeakMap,le=new WeakMap,Os=new WeakMap,Ms=new WeakMap,L=new WeakSet,Ty=function(){var r;const t=this.querySelector("dropdown-item[selected]");t&&f(this,L,Hn).call(this,t.value,((r=t.textContent)==null?void 0:r.trim())??null)},ts=function(t){var r;for(const i of l(this,L,ou))i.value===t?(f(this,L,Hn).call(this,t,((r=i.textContent)==null?void 0:r.trim())??null),i.hasAttribute("selected")||i.setAttribute("selected","")):i.hasAttribute("selected")&&i.removeAttribute("selected")},Cy=function(){const t=this.querySelectorAll("dropdown-item[selected]");for(const r of t)r.removeAttribute("selected")},Py=function(t){for(const r of l(this,L,ou))if(r.value===t)return r;return null},ou=function(){return this.querySelectorAll("dropdown-item")},Ry=function(){return l(this,yn)??this.title},ns=function(t){l(this,je)!==t&&(x(this,je,t),f(this,L,Ht).call(this))},Hn=function(t,r){x(this,mt,t),x(this,yn,r)},ur=new WeakMap,Ns=new WeakMap,za=new WeakMap,Us=new WeakMap,Oa=new WeakMap,Dy=function(t){t.every(i=>i.target instanceof Element?i.target.closest('[slot="trigger"]')!==null:!1)||f(this,L,Ly).call(this)},Ly=function(){var r,i;const t=this.querySelector("dropdown-item[selected]");if(t){const s=t.value,o=((r=t.textContent)==null?void 0:r.trim())??null,a=l(this,mt)!==s||l(this,yn)!==o;f(this,L,Hn).call(this,s,o),f(this,L,ts).call(this,s),a?f(this,L,Ht).call(this):f(this,L,rs).call(this);return}if(l(this,mt)!==null){const s=f(this,L,Py).call(this,l(this,mt));if(s){const o=((i=s.textContent)==null?void 0:i.trim())??null,a=l(this,yn)!==o;f(this,L,Hn).call(this,l(this,mt),o),f(this,L,ts).call(this,l(this,mt)),a?f(this,L,Ht).call(this):f(this,L,rs).call(this);return}}if(l(this,mt)!==null||l(this,yn)!==null){f(this,L,Hn).call(this,null,null),f(this,L,Ht).call(this);return}f(this,L,rs).call(this)},au=function(){const t=l(this,bn).querySelector('slot[name="trigger"]'),r=t instanceof HTMLSlotElement?t.assignedElements()[0]??null:null;l(this,le)!==r&&(f(this,L,cu).call(this),x(this,le,r),l(this,le)&&(l(this,le).addEventListener("click",l(this,ur)),l(this,le)instanceof HTMLButtonElement?l(this,le).hasAttribute("type")||(l(this,le).type="button"):(l(this,le).hasAttribute("role")||l(this,le).setAttribute("role","button"),l(this,le).hasAttribute("tabindex")||(l(this,le).tabIndex=0),l(this,le).addEventListener("keydown",l(this,Ns))))),f(this,L,rs).call(this),f(this,L,lu).call(this)},rs=function(){l(this,le)&&(l(this,le).setAttribute("data-dropdown-trigger",""),l(this,le).setAttribute("aria-haspopup","listbox"),l(this,le).setAttribute("aria-expanded",l(this,je)?"true":"false"))},lu=function(){const t=l(this,Os).value;if(!t)return;const r=l(this,bn).querySelector("button.fallback-trigger");t.anchor=l(this,le)??r??null},cu=function(){l(this,le)&&(l(this,le).removeEventListener("click",l(this,ur)),l(this,le).removeEventListener("keydown",l(this,Ns)),l(this,le).removeAttribute("data-dropdown-trigger"),l(this,le).removeAttribute("aria-haspopup"),l(this,le).removeAttribute("aria-expanded"),x(this,le,null))},Ht=function(){this.toggleAttribute("open",l(this,je)),Fe(N`
|
|
92
|
+
<slot name="trigger" @slotchange=${l(this,Oa)}>
|
|
93
|
+
<button
|
|
94
|
+
class="fallback-trigger"
|
|
95
|
+
part="trigger"
|
|
96
|
+
type="button"
|
|
97
|
+
aria-haspopup="listbox"
|
|
98
|
+
aria-expanded=${l(this,je)?"true":"false"}
|
|
99
|
+
@click=${l(this,ur)}
|
|
100
|
+
>
|
|
101
|
+
<span class="trigger-label" part="trigger-label">${l(this,L,Ry)}</span>
|
|
102
|
+
<span class="trigger-icon" part="trigger-icon" aria-hidden="true">
|
|
103
|
+
${wy({size:16})}
|
|
104
|
+
</span>
|
|
105
|
+
</button>
|
|
106
|
+
</slot>
|
|
107
|
+
<ui-popover
|
|
108
|
+
class="dropdown-popover"
|
|
109
|
+
material="glass-frosted"
|
|
110
|
+
?open=${l(this,je)}
|
|
111
|
+
@close=${l(this,za)}
|
|
112
|
+
${cn(l(this,Os))}
|
|
113
|
+
>
|
|
114
|
+
${l(this,je)?N`<div class="dropdown-list" part="list" role="listbox">
|
|
115
|
+
<slot></slot>
|
|
116
|
+
</div>`:ne}
|
|
117
|
+
</ui-popover>
|
|
118
|
+
`,l(this,bn)),f(this,L,lu).call(this),queueMicrotask(()=>f(this,L,au).call(this))},b(Iy,"observedAttributes",["title","open"]);class P2 extends HTMLElement{}class R2 extends HTMLElement{}class D2 extends HTMLElement{}var Er,uu,Oy,Fs,Zs;class zy extends HTMLElement{constructor(){super(...arguments);w(this,Er);w(this,Fs,()=>{this.action||f(this,Er,Oy).call(this)});w(this,Zs,t=>{t.key!=="Enter"&&t.key!==" "||(t.preventDefault(),this.click())})}connectedCallback(){this.hasAttribute("role")||this.setAttribute("role","option"),this.hasAttribute("tabindex")||(this.tabIndex=0),this.addEventListener("click",l(this,Fs)),this.addEventListener("keydown",l(this,Zs)),f(this,Er,uu).call(this)}disconnectedCallback(){this.removeEventListener("click",l(this,Fs)),this.removeEventListener("keydown",l(this,Zs))}attributeChangedCallback(){f(this,Er,uu).call(this)}get value(){return this.getAttribute("value")??""}get selected(){return this.hasAttribute("selected")}get action(){return this.hasAttribute("action")}}Er=new WeakSet,uu=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")},Oy=function(){this.dispatchEvent(new $y(this.value))},Fs=new WeakMap,Zs=new WeakMap,b(zy,"observedAttributes",["action","selected","value"]);customElements.get("dropdown-menu")||customElements.define("dropdown-menu",Iy);customElements.get("dropdown-group")||customElements.define("dropdown-group",P2);customElements.get("dropdown-label")||customElements.define("dropdown-label",R2);customElements.get("dropdown-divider")||customElements.define("dropdown-divider",D2);customElements.get("dropdown-item")||customElements.define("dropdown-item",zy);class L2 extends Event{constructor(){super("close",{bubbles:!0,composed:!0})}}var Ws,Cn,hu,Ma,Hs,du;class My extends HTMLElement{constructor(){super();w(this,Cn);w(this,Ws);w(this,Ma,t=>{t.target===t.currentTarget&&f(this,Cn,hu).call(this)});w(this,Hs,t=>{this.open&&t.key==="Escape"&&f(this,Cn,hu).call(this)});x(this,Ws,this.attachShadow({mode:"open"}))}connectedCallback(){document.addEventListener("keydown",l(this,Hs)),f(this,Cn,du).call(this)}disconnectedCallback(){document.removeEventListener("keydown",l(this,Hs))}attributeChangedCallback(){f(this,Cn,du).call(this)}get open(){return this.hasAttribute("open")}}Ws=new WeakMap,Cn=new WeakSet,hu=function(){this.dispatchEvent(new L2)},Ma=new WeakMap,Hs=new WeakMap,du=function(){Fe(N`
|
|
119
|
+
${this.open?N`
|
|
120
|
+
<div class="backdrop" part="backdrop" @click=${l(this,Ma)}>
|
|
121
|
+
<slot></slot>
|
|
122
|
+
</div>
|
|
123
|
+
`:null}
|
|
124
|
+
`,l(this,Ws))},b(My,"observedAttributes",["open"]);customElements.get("modal-overlay")||customElements.define("modal-overlay",My);class z2 extends Event{constructor(){super("close",{bubbles:!0,composed:!0})}}class O2 extends HTMLElement{}var Vs,Bs,pu;class Ny extends HTMLElement{constructor(){super();w(this,Bs);w(this,Vs);x(this,Vs,this.attachShadow({mode:"open"}))}connectedCallback(){f(this,Bs,pu).call(this)}attributeChangedCallback(){f(this,Bs,pu).call(this)}get closable(){return this.hasAttribute("closable")}}Vs=new WeakMap,Bs=new WeakSet,pu=function(){const t=this.querySelector("panel-page");Fe(N`
|
|
125
|
+
<section class="panel" part="panel">
|
|
126
|
+
<header class="title-bar" part="header">
|
|
127
|
+
<h2 class="title" part="title">${(t==null?void 0:t.getAttribute("title"))??""}</h2>
|
|
128
|
+
${this.closable?N`
|
|
129
|
+
<button
|
|
130
|
+
type="button"
|
|
131
|
+
class="title-button"
|
|
132
|
+
part="button close-button"
|
|
133
|
+
aria-label="Close"
|
|
134
|
+
@click=${()=>this.dispatchEvent(new z2)}
|
|
135
|
+
>
|
|
136
|
+
<span class="close-icon" part="icon close-icon">${by({size:16})}</span>
|
|
137
|
+
</button>
|
|
138
|
+
`:null}
|
|
139
|
+
</header>
|
|
140
|
+
<slot></slot>
|
|
141
|
+
</section>
|
|
142
|
+
`,l(this,Vs))},b(Ny,"observedAttributes",["closable"]);customElements.get("panel-view")||customElements.define("panel-view",Ny);customElements.get("panel-page")||customElements.define("panel-page",O2);function vl(n){return typeof n=="object"&&n!==null}function M2(n){return!vl(n)||n.type!=="wheel"||typeof n.deltaX!="number"||typeof n.deltaY!="number"||typeof n.shiftKey!="boolean"?!1:!("id"in n)}function N2(n){return!vl(n)||n.type!=="swipe-move"||typeof n.deltaX!="number"?!1:!("id"in n)}function U2(n){return!vl(n)||n.type!=="swipe-end"||typeof n.velocityX!="number"?!1:!("id"in n)}function Uy(n){return!vl(n)||n.type!=="open-artifact"||typeof n.artifactID!="string"?!1:!("id"in n)}function F2(n=window){if(n.parent===n)return;let e=0,t=0;n.document.documentElement&&(n.document.documentElement.style.touchAction="pan-y"),n.addEventListener("wheel",u=>{const h=u;e=h.clientX,t=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,O=Math.abs(k),P=Math.abs(T);if(O<r&&P<r)return;if(P>=O){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 m=h.timeStamp-i;let E=0;for(let k=0;k<p.samples.length;k+=1){if(p.samples[k].time>=m){E=k;break}E=k+1}if(E>0){const k=Math.max(0,E-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 m=p.samples[0],E=p.samples[p.samples.length-1],k=E.time-m.time;k>0&&(v=(E.offset-m.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,m=typeof p.deltaY=="number"?p.deltaY:0;let E=((T=(k=n.document).elementFromPoint)==null?void 0:T.call(k,e,t))??null;for(;E!==null;){const O=n.getComputedStyle(E);if(m!==0){const P=(O.overflowY==="auto"||O.overflowY==="scroll")&&E.scrollHeight>E.clientHeight,V=m>0?E.scrollTop+E.clientHeight<E.scrollHeight:E.scrollTop>0;if(P&&V){E.scrollBy(v,m);return}}if(v!==0){const P=(O.overflowX==="auto"||O.overflowX==="scroll")&&E.scrollWidth>E.clientWidth,V=v>0?E.scrollLeft+E.clientWidth<E.scrollWidth:E.scrollLeft>0;if(P&&V){E.scrollBy(v,m);return}}E=E.parentElement}n.scrollBy(v,m)});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 m=v.getAttribute("href");if(m===null)return;let E;try{E=new URL(m,n.document.baseURI).toString()}catch{return}a(E)&&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 Z2(){return`(${F2.toString()})(window);`}const W2=nt(),H2=nt(),V2="No handler registered for update-content",B2="handleUpdateContent: handler already registered";function G2(n){return n instanceof Error&&typeof n.message=="string"?n.message:String(n)}const j2=mo(Ot);var ui,hi,di,hr,dr,Gs,Re,fu,Fy,Zy,is,gu,rg;let q2=(rg=class extends j2{constructor(t){super();w(this,Re);w(this,ui);w(this,hi);w(this,di);w(this,hr,null);w(this,dr,null);w(this,Gs,!1);x(this,ui,t);const r=t.ownerDocument.defaultView;if(!r)throw new Error("ArtifactView: iframe has no owner window");x(this,hi,r),x(this,di,i=>f(this,Re,Fy).call(this,i)),l(this,hi).addEventListener("message",l(this,di))}get content(){return l(this,dr)}set content(t){f(this,Re,gu).call(this),x(this,dr,t),l(this,Gs)&&f(this,Re,fu).call(this,t)}handleUpdateContent(t){if(f(this,Re,gu).call(this),l(this,hr)!==null)throw new Error(B2);x(this,hr,t)}dispose(){l(this,hi).removeEventListener("message",l(this,di)),x(this,hr,null)}},ui=new WeakMap,hi=new WeakMap,di=new WeakMap,hr=new WeakMap,dr=new WeakMap,Gs=new WeakMap,Re=new WeakSet,fu=function(t){const r={type:"content-updated",content:t};f(this,Re,is).call(this,r)},Fy=function(t){if(this.disposed||t.source!==l(this,ui).contentWindow)return;const r=t.data;if(FT(r)){x(this,Gs,!0),this.dispatchEvent(new W2("ready")),l(this,dr)!==null&&f(this,Re,fu).call(this,l(this,dr));return}if(ZT(r)){f(this,Re,Zy).call(this,r);return}if(Uy(r)){this.dispatchEvent(new H2("open-artifact",{artifactID:r.artifactID}));return}},Zy=async function(t){const r=l(this,hr);if(r===null){f(this,Re,is).call(this,{type:"response",id:t.id,error:{message:V2}});return}try{await r(t.content)}catch(i){if(this.disposed)return;f(this,Re,is).call(this,{type:"response",id:t.id,error:{message:G2(i)}});return}this.disposed||f(this,Re,is).call(this,{type:"response",id:t.id,result:{}})},is=function(t){const r=l(this,ui).contentWindow;r&&r.postMessage(t,"*")},gu=function(){if(this.disposed)throw new Error("ArtifactView is disposed")},rg);async function Y2(n){const e=await fetch(n);if(!e.ok)throw new Error(`Failed to fetch artifact content: ${e.status}`);const t=await e.text(),r=new DOMParser().parseFromString(t,"text/html"),i=r.createElement("base");i.href=new URL(n,window.location.href).href,r.head.insertBefore(i,r.head.firstChild);const s=r.createElement("script");s.textContent=Z2(),r.head.appendChild(s);const o=new Blob([`<!DOCTYPE html>
|
|
143
|
+
${r.documentElement.outerHTML}`],{type:"text/html"});return URL.createObjectURL(o)}const $f="television-artifact-bridge",Wy=nt(),X2=nt();class K2 extends HTMLElement{constructor(){super(...arguments);b(this,"_artifact",null);b(this,"_viewURL",null);b(this,"_contentURL",null);b(this,"_screen",null);b(this,"_subscribedScreen",null);b(this,"_activeView",null);b(this,"_contentState",{kind:"idle"});b(this,"_fetchSequence",0);b(this,"_blobSequence",0);b(this,"_mountedViewURL",null);b(this,"_directRender",!1);b(this,"_blobURL",null);b(this,"_subscribedWebview",null);b(this,"_directRenderMessageListener",null);b(this,"handleScreenContentChanged",t=>{!this._artifact||t.artifactID!==this._artifact.id||this._activeView!==null&&this.refetchContent()});b(this,"handleOpenArtifact",t=>{this.requestFocus(t.artifactID)});b(this,"handleIframeMessage",t=>{const r=this.querySelector("iframe.artifact-frame");!r||r.contentWindow!==t.source||M2(t.data)&&this.dispatchArtifactWheel({deltaX:t.data.deltaX,deltaY:t.data.deltaY,shiftKey:t.data.shiftKey},i=>{var o;const s={type:"scroll",deltaX:0,deltaY:i};(o=r.contentWindow)==null||o.postMessage(s,this.iframeTargetOrigin(r))})});b(this,"handleWebviewIpcMessage",t=>{var o;const r=t.detail??t;if(!r||r.channel!==$f)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,$f,{type:"scroll",deltaX:0,deltaY:a})})})}set artifact(t){const r=this._artifact;this._artifact=t,this.render(),r!==null&&r!==t&&this.syncView()}get artifact(){return this._artifact}set viewURL(t){this._viewURL!==t&&(this._viewURL=t,this.syncView())}get viewURL(){return this._viewURL}set contentURL(t){this._contentURL!==t&&(this._contentURL=t,this.syncView())}get contentURL(){return this._contentURL}set screen(t){this._screen!==t&&(this._screen=t,this.syncScreenSubscription())}get screen(){return this._screen}set dragging(t){t?this.setAttribute("dragging","true"):this.removeAttribute("dragging")}get dragging(){return this.getAttribute("dragging")==="true"}get activeView(){return this._activeView}connectedCallback(){this.setAttribute("level","2"),this.render(),this.syncView(),this.syncScreenSubscription(),window.addEventListener("message",this.handleIframeMessage)}disconnectedCallback(){this.teardownView(),this.unsubscribeFromScreen(),window.removeEventListener("message",this.handleIframeMessage),this.unsubscribeFromWebview()}handleClose(){this._artifact&&this.dispatchEvent(new Wy("close-artifact",{artifactID:this._artifact.id,bubbles:!0,composed:!0}))}syncView(){var t,r;if(this.isConnected){if((t=this._artifact)!=null&&t.externalURL){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 i=this.querySelector("iframe.artifact-frame");if(!i){this._contentState={kind:"error"},this.render();return}this._activeView=new q2(i),this._activeView.handleUpdateContent(async s=>{await this.saveContent(s)}),this._activeView.addEventListener("open-artifact",this.handleOpenArtifact),this.loadBlobFrame(this._viewURL),this.startContentFetch();return}this._activeView!==null&&this.startContentFetch();return}if(this._contentURL!==null){this.teardownView(),this._directRender=!0,this._contentState={kind:"idle"},this.render(),this.installDirectRenderMessageListener(),((r=this._artifact)==null?void 0:r.status)==="committed"&&this.loadBlobFrame(this._contentURL);return}this.teardownView(),this._contentState={kind:"idle"},this.render()}}async saveContent(t){const r=this._screen,i=this._artifact;if(!r||!i)throw new Error("artifact-view: cannot save without a screen and artifact");await r.server.client.artifacts.putContent({artifactID:i.id,content:t})}syncScreenSubscription(){if(!this.isConnected){this.unsubscribeFromScreen();return}this._subscribedScreen!==this._screen&&(this.unsubscribeFromScreen(),this._screen!==null&&(this._screen.addEventListener("artifact-content-changed",this.handleScreenContentChanged),this._subscribedScreen=this._screen))}unsubscribeFromScreen(){this._subscribedScreen!==null&&(this._subscribedScreen.removeEventListener("artifact-content-changed",this.handleScreenContentChanged),this._subscribedScreen=null)}startContentFetch(){this._fetchSequence+=1;const t=this._fetchSequence,r=this._contentURL,i=this._activeView;if(!i||r===null){this._contentState={kind:"error"},this.render();return}this._contentState={kind:"loading"},(async()=>{try{const s=await fetch(r);if(t!==this._fetchSequence)return;if(!s.ok){this._contentState={kind:"error"},this.teardownView(),this.render();return}const o=await s.text();if(t!==this._fetchSequence||this._activeView!==i)return;this._activeView.content=o,this._contentState={kind:"ready"}}catch{if(t!==this._fetchSequence)return;this._contentState={kind:"error"},this.teardownView(),this.render()}})()}refetchContent(){this._fetchSequence+=1;const t=this._fetchSequence,r=this._contentURL,i=this._activeView;!i||r===null||(async()=>{try{const s=await fetch(r);if(t!==this._fetchSequence||!s.ok)return;const o=await s.text();if(t!==this._fetchSequence||this._activeView!==i)return;this._activeView.content=o}catch{}})()}loadBlobFrame(t){this._blobSequence+=1;const r=this._blobSequence;(async()=>{try{const i=await Y2(t);if(r!==this._blobSequence){URL.revokeObjectURL(i);return}this._blobURL=i,this.render();const s=this.querySelector("iframe.artifact-frame");s&&(s.src=i)}catch{if(r!==this._blobSequence)return;this._contentState={kind:"error"},this.teardownView(),this.render()}})()}teardownView(){this._activeView!==null&&(this._activeView.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._directRender=!1,this._fetchSequence+=1,this._blobSequence+=1}installDirectRenderMessageListener(){if(this._directRenderMessageListener!==null)return;const t=r=>{const i=this.querySelector("iframe.artifact-frame");i&&r.source===i.contentWindow&&Uy(r.data)&&this.requestFocus(r.data.artifactID)};this._directRenderMessageListener=t,window.addEventListener("message",t)}removeDirectRenderMessageListener(){this._directRenderMessageListener!==null&&(window.removeEventListener("message",this._directRenderMessageListener),this._directRenderMessageListener=null)}requestFocus(t){const r=this._screen;r&&r.server.client.viewer.focus({artifactID:t}).catch(i=>{console.warn("artifact-view: viewer.focus failed",i)})}contentTemplate(){var t;if((t=this._artifact)!=null&&t.externalURL){const r=this._artifact.externalURL;return bh()?N`
|
|
144
|
+
<webview
|
|
145
|
+
class="artifact-frame artifact-content"
|
|
146
|
+
src=${r}
|
|
147
|
+
allowpopups
|
|
148
|
+
></webview>
|
|
149
|
+
`:N`
|
|
150
|
+
<iframe
|
|
151
|
+
class="artifact-frame artifact-content"
|
|
152
|
+
src=${r}
|
|
153
|
+
sandbox="allow-scripts"
|
|
154
|
+
></iframe>
|
|
155
|
+
`}return this._contentState.kind==="error"?N`
|
|
156
|
+
<div class="artifact-content artifact-placeholder">
|
|
157
|
+
<em>Failed to load content</em>
|
|
158
|
+
</div>
|
|
159
|
+
`:this._viewURL!==null||this._directRender?N`
|
|
160
|
+
<iframe
|
|
161
|
+
class="artifact-frame artifact-content"
|
|
162
|
+
src=${this._blobURL??"about:blank"}
|
|
163
|
+
sandbox="allow-scripts"
|
|
164
|
+
></iframe>
|
|
165
|
+
`:N`
|
|
166
|
+
<div class="artifact-content artifact-placeholder">
|
|
167
|
+
<em>Artifact unavailable</em>
|
|
168
|
+
</div>
|
|
169
|
+
`}template(){const t=this._artifact;return N`
|
|
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">${_2({size:16})}</span>
|
|
174
|
+
<span class="artifact-title">${t.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
|
+
${by({size:16})}
|
|
184
|
+
</button>
|
|
185
|
+
</footer>
|
|
186
|
+
`}render(){this._artifact&&(this.setAttribute("type",this._artifact.type),Fe(this.template(),this),this.syncWebviewSubscription())}dispatchArtifactWheel(t,r){this.dispatchEvent(new X2("artifact-wheel",{bubbles:!0,composed:!0,deltaX:t.deltaX,deltaY:t.deltaY,shiftKey:t.shiftKey,scrollNative:r}))}syncWebviewSubscription(){const t=this.querySelector("webview");t!==this._subscribedWebview&&(this.unsubscribeFromWebview(),t&&(t.addEventListener("ipc-message",this.handleWebviewIpcMessage),this._subscribedWebview=t))}unsubscribeFromWebview(){this._subscribedWebview&&(this._subscribedWebview.removeEventListener("ipc-message",this.handleWebviewIpcMessage),this._subscribedWebview=null)}iframeTargetOrigin(t){const r=t.getAttribute("sandbox")??"";if(!new Set(r.split(/\s+/).filter(Boolean)).has("allow-same-origin"))return"*";const s=t.getAttribute("src")??t.src;if(!s)return"*";try{return new URL(s,window.location.href).origin}catch{return"*"}}}customElements.define("artifact-view",K2);const xe=n=>({type:"px",...n}),ye=n=>({type:"unit",...n}),Wo=2;class J2{constructor(e){b(this,"basis");b(this,"min");b(this,"_gap");b(this,"_viewport");b(this,"_unit");this.basis=e.basis,this.min=e.min,this._viewport=e.viewport,this._gap=e.gap??xe({x:ce,y:ce});const t=this._viewport.x??br,r=this._viewport.y??ba,i=this._gap.x??ce,s=this._gap.y??ce,o=t<=xx,a=o?t-i*Wo:Math.min(br,t-i*Wo),c=o?r-s*Wo:Math.min(ba,r-s*Wo),u=(a-i*(wt-1))/wt,h=(c-s*(tt-1))/tt,p=this.basis.x??0,v=this.basis.y??0,m=this.min.x??0,E=this.min.y??0;this._unit=xe(o?{x:Math.max(m,u),y:Math.max(E,h)}:{x:Math.max(m,Math.min(p,u)),y:Math.max(E,Math.min(v,h))})}get unit(){return this._unit}get viewport(){return this._viewport}get gap(){return this._gap}toUnits(e){return ye({x:e.x==null?void 0:e.x/(this._unit.x??1),y:e.y==null?void 0:e.y/(this._unit.y??1)})}toPixels(e){const t=this._unit.x??0,r=this._unit.y??0,i=this._gap.x??ce,s=this._gap.y??ce,o=e.x==null?void 0:e.x*t+Math.max(0,e.x-1)*i,a=e.y==null?void 0:e.y*r+Math.max(0,e.y-1)*s;return xe({x:o,y:a})}}const _r=1e-4,vt=1e-6,Q2=40,eL=24;function Hy(n,e){return Math.max(0,n-e*2)}function Vy(n){const e=[0];for(const t of n)e.push((e[e.length-1]??0)+t);return e}function By(n){const e=[0];for(let t=0;t<n.length;t+=1){const r=e[t]??0;e.push(r+n[t]+ce)}return e}function Gy(n,e,t){if(e<0||e>=n.length)return 0;let r=0,i=0;for(let s=e;s<n.length;s+=1){const o=n[s],a=i===0?o:r+ce+o;if(a>t+_r)break;r=a,i+=1}return Math.max(1,i)}function tL(n,e,t){if(e<0||e>=n.length)return 0;let r=0,i=0;for(let s=e;s>=0;s-=1){const o=n[s],a=i===0?o:r+ce+o;if(a>t+_r)break;r=a,i+=1}return Math.max(1,i)}function nL(n,e){if(n.length===0)return 0;let t=0,r=0;for(let i=n.length-1;i>=0;i-=1){const s=n[i],o=r===0?s:t+ce+s;if(o>e+_r)break;t=o,r+=1}return Math.max(1,r)}function Eh(n,e){if(n.length===0)return 0;const t=nL(n,e);return Math.max(0,n.length-t)}function If(n,e,t){if(n.length===0)return 0;const r=Gy(n,e,t),i=Math.min(n.length,e+r);if(i<=e)return 0;const s=n.slice(e,i);return s.reduce((o,a)=>o+a,0)+Math.max(0,s.length-1)*ce}function mu(n,e,t){const r=n[e]??0;return t-r}function jr(n,e,t,r,i){if(n.length===0)return 0;const s=Eh(n,i),o=e[s]??0,a=Math.max(0,Math.min(o,t));let c=0;for(let B=0;B<s;B+=1){const U=e[B]??0,Q=e[B+1]??U;if(a>=U&&a<=Q+_r){c=B;break}c=B+1}const u=Math.min(c+1,s),h=e[c]??0,p=e[u]??h,v=Math.max(p-h,_r),m=u===c?0:(a-h)/v,E=By(n),k=If(n,c,i),T=If(n,u,i),O=(r-k)/2,P=(r-T)/2,V=mu(E,c,O),F=mu(E,u,P);return V+(F-V)*m}function rL(n,e,t,r,i){const s=Eh(n,r),o=e[s]??0;let a=0,c=o;for(let u=0;u<Q2;u+=1){const h=(a+c)/2;jr(n,e,h,t,r)>i?a=h:c=h}return(a+c)/2}function iL(n,e,t){const r=By(n),[i,s]=e,o=n.slice(i,s+1),a=o.reduce((u,h)=>u+h,0)+Math.max(0,o.length-1)*ce,c=(t-a)/2;return mu(r,i,c)}function sL(n,e,t){const r=Gy(n,e,t);return[e,Math.min(n.length-1,e+r-1)]}function oL(n,e,t){const r=tL(n,e,t);return[Math.max(0,e-r+1),e]}function aL(n,e){return n[0]===e[0]&&n[1]===e[1]}function lL(n){const{nodeCols:e,nodeWidthsPx:t,viewportWidthPx:r}=n;if(e.length===0||t.length===0)return{viewspans:[],minScroll:0,maxScroll:0};const i=t.length,s=n.gapPx??ce,o=Hy(r,s),a=Vy(e),c=Eh(t,o),u=a[c]??0;function h(T){const O=iL(t,T,r),P=rL(t,a,r,o,O);return{nodeRange:T,anchor:Math.max(0,Math.min(u,P))}}const p=[];for(let T=0;T<i;){const O=sL(t,T,o);p.push(h(O)),T=O[1]+1}const v=h(oL(t,i-1,o)),m=p.filter(T=>T.nodeRange[0]<v.nodeRange[0]),E=m[m.length-1];return{viewspans:E&&aL(E.nodeRange,v.nodeRange)?m:[...m,v],minScroll:0,maxScroll:u}}function Fr(n,e){var i;let t=0,r=Number.POSITIVE_INFINITY;for(let s=0;s<n.length;s+=1){const o=Math.abs((((i=n[s])==null?void 0:i.anchor)??0)-e);if(o+vt<r){r=o,t=s;continue}Math.abs(o-r)<=vt&&s<t&&(t=s)}return t}function cL(n,e,t){return t<=0?0:Math.max(0,Math.min(t-1,n+e))}function Un(n,e,t){return Math.max(e,Math.min(t,n))}function uL(n,e){var t;for(let r=0;r<n.length;r+=1)if(Math.abs((((t=n[r])==null?void 0:t.anchor)??0)-e)<=vt)return r;return-1}function hL(n,e,t){var i,s;if(n.length===0)return e;const r=uL(n,e);if(r>=0){const o=n[r+t];return(o==null?void 0:o.anchor)??n[t>0?n.length-1:0].anchor}if(t>0){for(const o of n)if(o.anchor>e+vt)return o.anchor;return((i=n[n.length-1])==null?void 0:i.anchor)??e}for(let o=n.length-1;o>=0;o-=1){const a=n[o];if(a&&a.anchor<e-vt)return a.anchor}return((s=n[0])==null?void 0:s.anchor)??e}class dL extends Ot{constructor(t){super();b(this,"_scroll",0);b(this,"_minScroll",0);b(this,"_maxScroll",0);b(this,"_viewspans",[]);b(this,"_activeViewspanIndex",0);b(this,"_nodeWidthsPx",[]);b(this,"_boundaryCols",[0]);b(this,"_viewportWidthPx",0);b(this,"_framedViewportWidthPx",0);this._scroll=(t==null?void 0:t.x)??0}get scroll(){return ye({x:this._scroll})}get translate(){return xe({x:jr(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(t){const r=Un(t.x??this._scroll,this._minScroll,this._maxScroll);Math.abs(r-this._scroll)<=vt||(this._scroll=r,this._activeViewspanIndex=Fr(this._viewspans,this._scroll),this.dispatchEvent(new Ur("layout-scroll",{scroll:this.scroll})))}rebuild(t){var v;const r=t.nodeWidths.map(m=>Math.max(0,m.x??0)),i=r.map(m=>t.grid.toPixels(ye({x:m})).x??0),s=t.grid.viewport.x??0,o=t.grid.gap.x??ce,a=lL({nodeCols:r,nodeWidthsPx:i,viewportWidthPx:s,gapPx:o});this._nodeWidthsPx=i,this._boundaryCols=Vy(r),this._viewportWidthPx=s,this._framedViewportWidthPx=Hy(s,o),this._viewspans=a.viewspans,this._minScroll=a.minScroll,this._maxScroll=a.maxScroll;const c=Un(this._scroll,this._minScroll,this._maxScroll);this._activeViewspanIndex=Fr(this._viewspans,c);const h=t.snap!==!1?((v=this._viewspans[this._activeViewspanIndex])==null?void 0:v.anchor)??c:c,p=Un(h,this._minScroll,this._maxScroll);Math.abs(p-this._scroll)>vt&&(this._scroll=p,this.dispatchEvent(new Ur("layout-scroll",{scroll:this.scroll})))}step(t){var o;if(this._viewspans.length===0)return;const r=cL(this._activeViewspanIndex,t,this._viewspans.length),i=((o=this._viewspans[r])==null?void 0:o.anchor)??this._scroll,s=Un(i,this._minScroll,this._maxScroll);this._activeViewspanIndex=r,!(Math.abs(s-this._scroll)<=vt)&&(this._scroll=s,this.dispatchEvent(new Ur("layout-scroll",{scroll:this.scroll})))}snap(t){var s;if(this._viewspans.length===0)return;const r=t===void 0?((s=this._viewspans[Fr(this._viewspans,this._scroll)])==null?void 0:s.anchor)??this._scroll:hL(this._viewspans,this._scroll,t),i=Un(r,this._minScroll,this._maxScroll);this._activeViewspanIndex=Fr(this._viewspans,i),!(Math.abs(i-this._scroll)<=vt)&&(this._scroll=i,this.dispatchEvent(new Ur("layout-scroll",{scroll:this.scroll})))}wheel(t){const r=Un(this._scroll+(t.x??0),this._minScroll,this._maxScroll);Math.abs(r-this._scroll)<=vt||(this._scroll=r,this._activeViewspanIndex=Fr(this._viewspans,this._scroll),this.dispatchEvent(new Ur("layout-scroll",{scroll:this.scroll})))}wheelPixels(t){const r=t.x??0;if(Math.abs(r)<=_r)return;const i=jr(this._nodeWidthsPx,this._boundaryCols,this._scroll,this._viewportWidthPx,this._framedViewportWidthPx),s=i-r,o=jr(this._nodeWidthsPx,this._boundaryCols,this._maxScroll,this._viewportWidthPx,this._framedViewportWidthPx),a=jr(this._nodeWidthsPx,this._boundaryCols,this._minScroll,this._viewportWidthPx,this._framedViewportWidthPx),c=Math.max(o,Math.min(a,s));if(Math.abs(c-i)<=_r)return;let u=this._minScroll,h=this._maxScroll;for(let v=0;v<eL;v+=1){const m=(u+h)/2;jr(this._nodeWidthsPx,this._boundaryCols,m,this._viewportWidthPx,this._framedViewportWidthPx)>c?u=m:h=m}const p=Un((u+h)/2,this._minScroll,this._maxScroll);Math.abs(p-this._scroll)<=vt||(this._scroll=p,this._activeViewspanIndex=Fr(this._viewspans,this._scroll),this.dispatchEvent(new Ur("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}},pL=["stack-above","stack-below","reorder-before","reorder-after"];function yc(n,e){return{left:n.left+n.width*e.left,top:n.top+n.height*e.top,width:n.width*e.width,height:n.height*e.height}}function Fn(n,e,t){return n>=t.left&&n<t.left+t.width&&e>=t.top&&e<t.top+t.height}function vu(n){return Number.isFinite(n)?Math.max(ds,Math.min(oh,Math.round(n))):ds}function fL(n,e,t){const r=n.findIndex(a=>a.type==="card"&&a.id===e);if(r===-1)return n;const i=n[r];if(!i||i.type!=="card")return n;const s=vu(t);if(i.width===s)return n;const o=[...n];return o[r]={...i,width:s},o}function xh(n,e){for(const t of n){if(t.type==="card"&&t.id===e)return t;if(t.type==="stack")for(const r of t.children){if(r.type==="card"&&r.id===e)return r;if(r.type==="row"){for(const i of r.children)if(i.id===e)return i}}}return null}function yu(n){return n.height===tt||n.height===An?{...n,height:An}:n}function bu(n){return n.height===An?{...n,height:tt}:n}function gL(n,e,t,r){const i=n.findIndex(h=>h.type==="stack"&&h.id===e);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===t);if(!o||o.type!=="card")return n;const a=s.children.filter(h=>h.id!==t);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"?bu(h):h}else c[i]={...s,children:a};const u=Math.max(0,Math.min(r,c.length));return c.splice(u,0,bu(o)),c}const mL=nt(),vL=nt(),yL=50;function bL(n,e){if(n.type!==e.type)return!1;switch(n.type){case"reorder":return e.index===n.index;case"stack":return e.targetCardId===n.targetCardId&&e.position===n.position;case"stack-child-noop":return!0;case"stack-child-extract":return e.toIndex===n.toIndex;case"stack-child-reorder":return e.position===n.position;default:return!1}}function yo(n){return{id:n.id,type:"drop-target",width:n.width,height:n.height}}function Tf(n){return n.map(SL)}function wL(n){return n.type==="drop-target"?{id:n.id,type:"card",artifactID:n.id,width:n.width,height:n.height}:n}function SL(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(wL)}:n}function jy(n,e){return n.find(r=>r.type==="card"&&r.id===e)??null}function Cf(n,e){return n.find(r=>r.type==="stack"&&r.id===e)??null}function _L(n,e){const t=[...e],r=t.findIndex(a=>a.type==="card"&&a.id===n.nodeId);if(r===-1)return null;const i=t[r];if(!i||i.type!=="card")return null;t.splice(r,1);const s=Math.max(0,Math.min(n.lastReorderIndex,t.length));t.splice(s,0,i);const o=t.findIndex(a=>a.type==="card"&&a.id===n.nodeId);return o===-1?null:{base:t,visualDraggedIndex:o}}function kL(n,e,t,r){const i=[...n.base];i.splice(n.visualDraggedIndex,1);const s=i.findIndex(v=>v.type==="card"&&v.id===t.targetCardId),o=s===-1?null:i[s];if(!o||o.type!=="card")return null;const a=jy(r,e.nodeId);if(!a)return null;const c=yu(a),u=yu(o),h=yo(c),p=t.position==="above"?[h,u]:[u,h];return i[s]={id:o.id,type:"stack",children:p},i}function bc(n,e){return n.parentStackId?xL(n,e):EL(n,e)}function EL(n,e){const t=n.hitTarget;if(t.type==="reorder"){const r=e[n.sourceIndex];if(!r||r.type!=="card")return[...e];const i=[...e];return i.splice(n.sourceIndex,1),i.splice(t.index,0,yo(r)),i}if(t.type==="stack"){const r=_L(n,e);return r?kL(r,n,t,e)??[...e]:[...e]}return[...e]}function xL(n,e){const t=n.hitTarget;switch(t.type){case"stack-child-reorder":return AL(n,e,t.position);case"stack-child-extract":return $L(n,e,t.toIndex);case"stack-child-noop":return IL(n,e);default:return[...e]}}function AL(n,e,t){const r=e.findIndex(v=>v.type==="stack"&&v.id===n.parentStackId);if(r===-1)return[...e];const i=e[r];if(!i||i.type!=="stack")return[...e];if(!i.children.every(v=>v.type==="card"))return[...e];const s=i.children,o=s.findIndex(v=>v.id===n.nodeId);if(o===-1)return[...e];const a=s[o],c=s.filter(v=>v.id!==n.nodeId),u=yo(a),h=t==="above"?[u,...c]:[...c,u],p=[...e];return p[r]={...i,children:h},p}function $L(n,e,t){if(!n.parentStackId)return[...e];const r=gL(e,n.parentStackId,n.nodeId,t);if(r===e)return[...e];const i=r.findIndex(a=>a.type==="card"&&a.id===n.nodeId);if(i===-1)return[...e];const s=r[i];if(!s||s.type!=="card")return[...e];const o=[...r];return o[i]=yo(s),o}function IL(n,e){const t=e.findIndex(c=>c.type==="stack"&&c.id===n.parentStackId);if(t===-1)return[...e];const r=e[t];if(!r||r.type!=="stack")return[...e];const i=r.children.findIndex(c=>c.type==="card"&&c.id===n.nodeId);if(i===-1)return[...e];const s=r.children[i];if(!s||s.type!=="card")return[...e];const o=[...e],a=[...r.children];return a[i]=yo(s),o[t]={...r,children:a},o}function TL(n,e){return e.find(r=>r.type==="stack"&&r.id===n.id)?n.id:al()}function CL(n,e,t){if(n.type==="drop-target"){const r=xh(e,t);if(!r)throw new Error(`finalize: missing dragged card ${t}`);return yu(r)}return n}function PL(n,e,t){const r=n.children.map(s=>CL(s,e,t));return{id:TL(n,e),type:"stack",children:r}}function RL(n,e,t){if(n.type==="drop-target"){const r=xh(e,t);if(!r)throw new Error(`finalize: missing dragged card ${t}`);return jy(e,t)!==null?r:bu(r)}return n.type==="card"||n.type==="row"?n:PL(n,e,t)}function DL(n,e,t){return n.map(r=>RL(r,e,t))}function LL(n,e){return JSON.stringify(n)===JSON.stringify(e)}const zL=mo(Ot);class OL extends zL{constructor(t={}){super();b(this,"pending",null);b(this,"active",null)}start(t){if(this.pending||this.active)return;const r=t.pointer.x??0,i=t.pointer.y??0;this.pending={startX:r,startY:i,grabOffsetX:t.grabOffset.x??0,grabOffsetY:t.grabOffset.y??0,nodeId:t.nodeId,sourceIndex:t.source.index,parentStackId:t.source.parentId,width:t.size.x??0,height:t.size.y??0,baseLayout:t.layout}}update(t){const r=t.pointer.x??0,i=t.pointer.y??0,s=this.pending;if(s){const u=r-s.startX,h=i-s.startY;Math.hypot(u,h)>=$x&&(this.pending=null,this.active={...s,pointerX:r,pointerY:i,hitTarget:{type:"reorder",index:s.sourceIndex},lastReorderIndex:s.sourceIndex},this.emitDrag(),this.dispatchEvent(new ie("change")));return}if(!this.active)return;const o=bc(this.active,this.active.baseLayout),a=this.getHitTargetForPointer(r,i,t,o),c=a.type==="reorder"?a.index:this.active.lastReorderIndex;this.active.pointerX===r&&this.active.pointerY===i&&bL(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 ie("change")))}drop(){if(this.pending){this.cancel();return}if(!this.active)return;const t=this.active.baseLayout;let r=null;try{const i=bc(this.active,t),s=DL(i,t,this.active.nodeId);LL(s,t)||(r=s)}catch{r=null}this.reset(),r&&this.dispatchEvent(new vL("drop",{layout:r})),this.dispatchEvent(new ie("change"))}cancel(){!this.pending&&!this.active||(this.reset(),this.dispatchEvent(new ie("change")))}dispose(){this.reset()}get status(){return this.active?"active":this.pending?"pending":"idle"}reset(){this.pending=null,this.active=null}emitDrag(){if(!this.active)return;const t=bc(this.active,this.active.baseLayout);this.dispatchEvent(new mL("drag",{nodeId:this.active.nodeId,source:{index:this.active.sourceIndex,parentId:this.active.parentStackId},grabOffset:xe({x:this.active.grabOffsetX,y:this.active.grabOffsetY}),pointer:xe({x:this.active.pointerX,y:this.active.pointerY}),size:xe({x:this.active.width,y:this.active.height}),projectedLayout:t}))}getHitTargetForPointer(t,r,i,s){return this.active?this.isPointerInsideDragBounds(t,r,i.viewport)?this.active.parentStackId?this.getStackChildHitTarget(t,r,i,s):this.getTopLevelCardHitTarget(t,r,i,s):{type:"reorder",index:this.active.sourceIndex}:{type:"reorder",index:0}}getStackChildHitTarget(t,r,i,s){var u;if(!((u=this.active)!=null&&u.parentStackId))return{type:"stack-child-noop"};const o=this.getSourceStackInteractionRect(i.geometry);if(o&&Fn(t,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&&Fn(t,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(t,r,i,s)}}getSourceRemainingSiblingRect(t){var s,o;if(!((s=this.active)!=null&&s.parentStackId))return;const r=Cf(this.active.baseLayout,this.active.parentStackId);if(!r)return;const i=r.children.find(a=>{var c;return a.type==="card"&&a.id!==((c=this.active)==null?void 0:c.nodeId)});if(i)return(o=t.find(a=>a.id===i.id))==null?void 0:o.rect}getSourceStackInteractionRect(t){var o;if(!((o=this.active)!=null&&o.parentStackId))return;const r=t.find(a=>{var c;return a.id===((c=this.active)==null?void 0:c.parentStackId)});if(r)return this.active.sourceStackRect=r.rect,r.rect;const i=Cf(this.active.baseLayout,this.active.parentStackId);if(!i)return this.active.sourceStackRect;const s=i.children.find(a=>{var c;return a.type==="card"&&a.id!==((c=this.active)==null?void 0:c.nodeId)});if(s){const a=t.find(c=>c.id===s.id);if(a)return a.rect}return this.active.sourceStackRect}getTopLevelCardHitTarget(t,r,i,s){var m,E,k;const o=this.getTopLevelZoneNodes(i.geometry,s);if(o.length===0)return{type:"reorder",index:((m=this.active)==null?void 0:m.sourceIndex)??0};const c=(i.effectiveVelocity??0)<=yL;for(const T of o){const O=T.rect;if(!Fn(t,r,O))continue;const P=this.resolveTopLevelTargetForCard(t,r,T,T.logicalIndex,c);if(P)return P;if(!c&&((E=this.active)!=null&&E.hitTarget))return this.active.hitTarget}const u=this.getNearestTargetableZone(t,o);if(!u)return{type:"reorder",index:((k=this.active)==null?void 0:k.sourceIndex)??0};const h=Math.max(u.rect.left,Math.min(u.rect.left+u.rect.width,t)),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:t<v?u.logicalIndex:u.logicalIndex+1}}getTopLevelReorderIndexForPointer(t,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(!Fn(t,r,p.rect))continue;const v=yc(p.rect,vc["reorder-before"]);if(Fn(t,r,v))return p.logicalIndex;const m=yc(p.rect,vc["reorder-after"]);if(Fn(t,r,m))return p.logicalIndex+1}const a=this.getNearestTargetableZone(t,o);if(!a)return((h=this.active)==null?void 0:h.sourceIndex)??0;const c=a.rect.left+a.rect.width/2;return t<c?a.logicalIndex:a.logicalIndex+1}getTopLevelZoneNodes(t,r){const i=new Map(r.map(a=>[a.id,a])),s=[];let o=0;for(const a of t){const c=i.get(a.id);c&&c.type!=="drop-target"&&(c.type==="card"||c.type==="stack")&&(s.push({id:c.id,rect:a.rect,logicalIndex:o}),o+=1)}return s}resolveTopLevelTargetForCard(t,r,i,s,o){const a=i.rect;for(const c of pL){if(!o&&(c==="stack-above"||c==="stack-below"))continue;const u=vc[c],h=yc(a,u);if(Fn(t,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(t,r){let i=null,s=Number.POSITIVE_INFINITY;for(const o of r){const a=o.rect.left,c=o.rect.left+o.rect.width,u=t<a?a-t:t>c?t-c:0;u<s&&(s=u,i=o)}return i}isPointerInsideDragBounds(t,r,i){return t>=i.left&&t<=i.left+i.width&&r>=i.top&&r<=i.top+i.height}}const Pf=60,ML=80,Rf=.5,Df=10;class NL{constructor(){b(this,"awaitingFreshWheelGesture",!1);b(this,"lastWheelEventAt",Number.NEGATIVE_INFINITY);b(this,"lastWheelDeltaX",0);b(this,"activeGestureType","none");b(this,"lastWheelGestureAt",Number.NEGATIVE_INFINITY)}markKeyboardNavigation(e){this.awaitingFreshWheelGesture=!0,this.lastWheelEventAt=e,this.activeGestureType="none"}reset(){this.awaitingFreshWheelGesture=!1,this.lastWheelEventAt=Number.NEGATIVE_INFINITY,this.lastWheelDeltaX=0,this.activeGestureType="none",this.lastWheelGestureAt=Number.NEGATIVE_INFINITY}decide(e){const{now:t,shiftKey:r,deltaX:i,deltaY:s,overArtifactContent:o}=e;t-this.lastWheelGestureAt>=Pf&&(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>=Rf&&h>=p*Df?this.classifyHorizontal(t,u):(this.lastWheelGestureAt=t,{type:"scroll-native"}):this.activeGestureType==="horizontal-filmstrip"?!c&&o&&p>0&&p>=h*Df?(this.activeGestureType="vertical-artifact",this.lastWheelGestureAt=t,{type:"scroll-native"}):this.classifyHorizontal(t,u):h<Rf?(o&&(this.activeGestureType="vertical-artifact"),this.lastWheelGestureAt=t,{type:"scroll-native"}):c||h>p?this.classifyHorizontal(t,u):p>h?(o&&(this.activeGestureType="vertical-artifact"),this.lastWheelGestureAt=t,{type:"scroll-native"}):o?(this.activeGestureType="vertical-artifact",this.lastWheelGestureAt=t,{type:"scroll-native"}):this.classifyHorizontal(t,u)}classifyHorizontal(e,t){const r=e-this.lastWheelEventAt,i=Math.sign(this.lastWheelDeltaX),s=Math.sign(t),o=i!==0&&s!==0&&i!==s,a=i!==0&&Math.abs(t)>=Math.abs(this.lastWheelDeltaX)+ML;return this.awaitingFreshWheelGesture&&r<Pf&&!o&&!a?{type:"ignore"}:(this.lastWheelEventAt=e,this.lastWheelDeltaX=t,this.lastWheelGestureAt=e,this.awaitingFreshWheelGesture=!1,this.activeGestureType="horizontal-filmstrip",{type:"scroll-horizontal",horizontalDelta:t})}}const UL=100,FL=1e3;class ZL{constructor(e,t){b(this,"_status","idle");b(this,"cumulativeOffset",0);b(this,"samples",[]);b(this,"scroll");b(this,"setAnimating");this.scroll=e,this.setAnimating=t}get status(){return this._status}start(e){this._status="active",this.cumulativeOffset=0,this.samples=[{time:e,offset:0}]}move(e,t){this._status==="active"&&(this.cumulativeOffset+=t,this.samples.push({time:e,offset:this.cumulativeOffset}),this.pruneSamples(e),this.setAnimating(!1),this.scroll.wheelPixels(xe({x:-t})))}end(){if(this._status!=="active")return;const e=this.computeVelocityPxPerSec();this.setAnimating(!0),Math.abs(e)<Tx?this.scroll.snap():this.scroll.snap(e>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(e){const t=e-UL;let r=0;for(let i=0;i<this.samples.length;i+=1){if(this.samples[i].time>=t){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 e=this.samples[0],t=this.samples[this.samples.length-1],r=t.time-e.time;return r<=0?0:(t.offset-e.offset)/r*FL}}const WL=2,Lf=1e3,Ho=1e-4,HL=120,zf=!1;function VL(n){return n.replace(/["\\]/g,"\\$&")}function Of(n,e,t){if(n===0)return 0;const r=e.toPixels(ye({y:tt})).y??0;return(t-r)/WL}function wc(n){const e=n.clientWidth>0?n.clientWidth:br,t=n.clientHeight>0?n.clientHeight:ba;let r=0,i=0;if(n.isConnected){const o=getComputedStyle(n);r=parseFloat(o.paddingTop)||0,i=parseFloat(o.paddingBottom)||0}const s=Math.max(1,t-r-i);return{width:e,height:s,offsetY:r}}class BL extends Event{constructor(t){super("scroll",{bubbles:!0,composed:!0});b(this,"scrollPosition");this.scrollPosition=t}}class qy extends Event{constructor(t){super("layout-change",{bubbles:!0,composed:!0});b(this,"layout");this.layout=t}}class GL extends HTMLElement{constructor(){super();b(this,"_layout",[]);b(this,"_scrollPosition",0);b(this,"layoutGrid",null);b(this,"layoutScroll",new dL(ye({x:0})));b(this,"scrollModelKey","");b(this,"resizeObserver",null);b(this,"renderPending",!1);b(this,"animateNextRender",!0);b(this,"wheelGesture",new NL);b(this,"swipeGesture",new ZL(this.layoutScroll,t=>{this.animateNextRender=t}));b(this,"swipePointerId",null);b(this,"swipeStartX",0);b(this,"swipeStartY",0);b(this,"swipeLastX",0);b(this,"swipeActive",!1);b(this,"swipeShouldSuppressClick",!1);b(this,"swipeListenersAttached",!1);b(this,"wheelIdleSnapTimer",null);b(this,"dragController",new OL);b(this,"dragState",null);b(this,"activeDragPointerId",null);b(this,"dragListenersAttached",!1);b(this,"dragFrame",0);b(this,"lastDragFrameTime",0);b(this,"lastPointerX",0);b(this,"lastPointerY",0);b(this,"pointerVelocityPxPerSec",0);b(this,"scrollVelocityPxPerSec",0);b(this,"motionSampleTime",0);b(this,"motionSampleX",0);b(this,"motionSampleY",0);b(this,"dragTrackOffsetXPx",0);b(this,"previousProjectedLayoutForOffset",null);b(this,"resizeState",null);b(this,"resizeListenersAttached",!1);b(this,"renderContent",()=>N``);b(this,"onDragControllerChange",()=>{this.dragController.status==="idle"&&(this.dragState=null,this.dragTrackOffsetXPx=0,this.previousProjectedLayoutForOffset=null),this.scheduleRender()});b(this,"onDragControllerDrag",t=>{const r=Tf(t.projectedLayout),i=this.shouldApplyTrackOffset(t.projectedLayout,t.source.parentId),s=t.source.parentId?this.getStackChildAnchorCardId(t.source.parentId,t.nodeId):null;this.dragTrackOffsetXPx=i?this.computeDragTrackOffset(this.previousProjectedLayoutForOffset,r,t.nodeId,t.source.parentId,s,this.dragTrackOffsetXPx):0,this.previousProjectedLayoutForOffset=r,this.dragState={nodeId:t.nodeId,source:t.source,grabOffset:t.grabOffset,pointer:t.pointer,size:t.size,projectedLayout:t.projectedLayout},this.scheduleRender()});b(this,"onDragControllerDrop",t=>{this.dragState=null,this.dragTrackOffsetXPx=0,this.previousProjectedLayoutForOffset=null,this.commitLayout(t.layout)});b(this,"onLayoutScrollInternal",t=>{const i=t.scroll.x??0;Math.abs(i-this._scrollPosition)<Ho||(this._scrollPosition=i,this.emitScrollPositionChanged(i),this.scheduleRender())});b(this,"handleKeyDown",t=>{if(t.key==="Escape"&&this.dragController.status!=="idle"){t.preventDefault(),this.stopDragFrameLoop(),this.releaseActiveDragPointerCapture(),this.dragController.cancel(),this.detachDragListeners();return}this.dragController.status==="idle"&&(t.key==="ArrowRight"?(t.preventDefault(),this.wheelGesture.markKeyboardNavigation(Date.now()),this.shiftWindow(1)):t.key==="ArrowLeft"&&(t.preventDefault(),this.wheelGesture.markKeyboardNavigation(Date.now()),this.shiftWindow(-1)))});b(this,"handleWheel",t=>{if(this._layout.length===0)return;const r=this.wheelGesture.decide({now:Date.now(),shiftKey:t.shiftKey,deltaX:t.deltaX,deltaY:t.deltaY,overArtifactContent:!1});r.type==="scroll-horizontal"&&(t.preventDefault(),this.applyHorizontalWheel(r.horizontalDelta))});b(this,"handleWindowMessage",t=>{if(this._layout.length===0)return;const r=this.findManagedArtifactFrame(t.source);if(r&&this.isTrustedArtifactFrameMessage(t,r)){if(N2(t.data)){const i=typeof performance<"u"?performance.now():Date.now();this.swipeGesture.status==="idle"&&this.swipeGesture.start(i),this.swipeGesture.move(i,t.data.deltaX);return}if(U2(t.data)){this.swipeGesture.status==="active"&&this.swipeGesture.end();return}}});b(this,"handleArtifactWheel",t=>{if(this._layout.length===0)return;const r=this.wheelGesture.decide({now:Date.now(),shiftKey:t.shiftKey,deltaX:t.deltaX,deltaY:t.deltaY,overArtifactContent:!0});if(r.type==="scroll-horizontal"){this.applyHorizontalWheel(r.horizontalDelta);return}r.type==="scroll-native"&&t.scrollNative(t.deltaY)});b(this,"handlePointerDown",t=>{if(t.button!==0||this.dragController.status!=="idle"||this.resizeState)return;const r=t.target;if(!(r instanceof Element))return;const i=r.closest("[data-resize-handle]");if(i){this.beginResize(t,i);return}const s=r.closest("[drag-handle]")!==null,o=r.closest("button, input, textarea, select, a, [role='button']")!==null;if(t.pointerType==="touch"&&!s&&!o&&this._layout.length>0){this.beginSwipeTracking(t);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 m=parseInt(v,10);if(!isNaN(m)){const E=this.findViewspanContainingNode(m);if(E){this.clearWheelIdleSnap(),this.animateNextRender=!0,this.layoutScroll.scroll=ye({x:E.anchor}),t.preventDefault(),t.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=qL(this._layout,c);if(!u)return;const h=a.getBoundingClientRect();this.lastPointerX=t.clientX,this.lastPointerY=t.clientY,this.resetMotionTracking(t.clientX,t.clientY),this.focus(),this.dragController.start({nodeId:c,source:{index:u.topLevelIndex,parentId:u.sourceStackId},pointer:xe({x:t.clientX,y:t.clientY}),grabOffset:xe({x:t.clientX-h.left,y:t.clientY-h.top}),size:xe({x:h.width,y:h.height}),layout:this._layout}),this.attachDragListeners(),this.activeDragPointerId=t.pointerId;try{this.setPointerCapture(t.pointerId)}catch{}t.preventDefault()});b(this,"handleResizePointerMove",t=>{const r=this.resizeState;if(!r||t.pointerId!==r.pointerId)return;const i=this.layoutGrid,s=((i==null?void 0:i.unit.x)??hn)+ce;if(s<=0)return;const o=t.clientX-r.startClientX,a=vu(r.startWidth+o/s);a!==r.currentWidth&&(r.currentWidth=a,this.scheduleRender())});b(this,"handleResizePointerUp",t=>{const r=this.resizeState;if(!r||t.pointerId!==r.pointerId)return;const i=r.currentWidth,s=r.startWidth,o=r.cardId;this.endResize(t.pointerId),i!==s?this.commitLayout(fL(this._layout,o,i)):this.scheduleRender()});b(this,"handleResizePointerCancel",t=>{!this.resizeState||t.pointerId!==this.resizeState.pointerId||(this.endResize(t.pointerId),this.scheduleRender())});b(this,"handleResizeWindowBlur",()=>{this.resizeState&&(this.endResize(this.resizeState.pointerId),this.scheduleRender())});b(this,"handleResizeKeyDown",t=>{this.resizeState&&t.key==="Escape"&&(t.preventDefault(),this.endResize(this.resizeState.pointerId),this.scheduleRender())});b(this,"handleSwipePointerMove",t=>{if(this.swipePointerId===null||t.pointerId!==this.swipePointerId)return;if(!this.swipeActive){const i=t.clientX-this.swipeStartX,s=t.clientY-this.swipeStartY,o=Math.abs(i),a=Math.abs(s);if(o<Mp&&a<Mp)return;if(a>=o){this.endSwipeTracking();return}this.swipeActive=!0,this.swipeShouldSuppressClick=!0;try{this.setPointerCapture(t.pointerId)}catch{}this.swipeGesture.start(t.timeStamp)}const r=t.clientX-this.swipeLastX;this.swipeLastX=t.clientX,this.swipeGesture.move(t.timeStamp,r),t.preventDefault()});b(this,"handleSwipePointerUp",t=>{this.swipePointerId===null||t.pointerId!==this.swipePointerId||(this.swipeActive&&this.swipeGesture.end(),this.releaseSwipePointerCapture(t.pointerId),this.endSwipeTracking())});b(this,"handleSwipePointerCancel",t=>{this.swipePointerId===null||t.pointerId!==this.swipePointerId||(this.swipeActive&&this.swipeGesture.cancel(),this.releaseSwipePointerCapture(t.pointerId),this.endSwipeTracking())});b(this,"handleSwipeWindowBlur",()=>{this.swipePointerId!==null&&this.swipeActive&&this.swipeGesture.cancel(),this.swipePointerId!==null&&this.releaseSwipePointerCapture(this.swipePointerId),this.endSwipeTracking()});b(this,"handleSwipeClick",t=>{this.swipeShouldSuppressClick&&(this.swipeShouldSuppressClick=!1,t.preventDefault(),t.stopPropagation(),typeof t.stopImmediatePropagation=="function"&&t.stopImmediatePropagation())});b(this,"handleWindowPointerMove",t=>{this.lastPointerX=t.clientX,this.lastPointerY=t.clientY,this.updatePointerVelocity(t.clientX,t.clientY),this.syncDragTargetForLatestPointer(),this.ensureDragFrameLoop()});b(this,"handleWindowPointerUp",t=>{this.stopDragFrameLoop(),this.releasePointerCaptureForEvent(t.pointerId),this.dragController.drop(),this.clearMotionTracking(),this.detachDragListeners()});b(this,"handleWindowPointerCancel",t=>{this.stopDragFrameLoop(),this.releasePointerCaptureForEvent(t.pointerId),this.dragController.cancel(),this.clearMotionTracking(),this.detachDragListeners()});b(this,"handleWindowBlur",()=>{this.releaseActiveDragPointerCapture(),this.stopDragFrameLoop(),this.dragController.cancel(),this.clearMotionTracking(),this.detachDragListeners()});b(this,"runDragFrame",t=>{if(this.dragController.status==="idle"){this.dragFrame=0;return}const r=Math.max(0,t-this.lastDragFrameTime)/Lf;this.lastDragFrameTime=t,this.samplePointerVelocityAt(t,this.lastPointerX,this.lastPointerY);const i=this.getBoundingClientRect(),s=this.clampPointerToViewport(this.lastPointerX,this.lastPointerY,i),o=this.getDragEdgeScrollDeltaPixels(s.x,i,r);this.scrollVelocityPxPerSec=r>Ho?Math.abs(o)/r:0,Math.abs(o)>Ho&&(this.animateNextRender=!1,this.layoutScroll.wheelPixels(xe({x:o}))),this.dragController.status==="active"&&this.syncDragTarget(s.x,s.y,i),this.dragFrame=requestAnimationFrame(this.runDragFrame)});this.dragController.addEventListener("change",this.onDragControllerChange),this.dragController.addEventListener("drag",this.onDragControllerDrag),this.dragController.addEventListener("drop",this.onDragControllerDrop),this.layoutScroll.addEventListener("layout-scroll",this.onLayoutScrollInternal)}set layout(t){this._layout=[...t],this.stopDragFrameLoop(),this.dragController.cancel(),this.resizeState&&this.endResize(this.resizeState.pointerId),this.scrollModelKey="",this.syncScrollModel(),this.layoutScroll.scroll=ye({x:this._scrollPosition}),this.scheduleRender()}get layout(){return this._layout}commitLayout(t){this.layout=t,this.emitLayoutChanged()}set scrollPosition(t){Math.abs(t-this._scrollPosition)<Ho||(this.animateNextRender=!1,this.syncScrollModel(),this.layoutScroll.scroll=ye({x:t}))}get scrollPosition(){return this._scrollPosition}focusArtifact(t){const r=Xr(this._layout),i=r.nodes.findIndex(o=>o.cards.some(a=>a.artifactID===t));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="${VL(t)}"]`);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 t;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),(t=this.resizeObserver)==null||t.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(t,r){return new J2({basis:xe({x:hn,y:hn}),min:xe({x:zp,y:zp}),viewport:xe({x:t,y:r}),gap:xe({x:ce,y:ce})})}syncScrollModel(){const t=wc(this),i=Xr(this._layout).nodes.map(o=>o.width),s=`${t.width}x${t.height}:${i.join(",")}`;s===this.scrollModelKey&&this.layoutGrid||(this.scrollModelKey=s,this.layoutGrid=this.createGrid(t.width,t.height),this.layoutScroll.rebuild({grid:this.layoutGrid,nodeWidths:i.map(o=>ye({x:o})),snap:zf}))}emitScrollPositionChanged(t){this.dispatchEvent(new BL(t))}emitLayoutChanged(){this.dispatchEvent(new qy([...this._layout]))}shiftWindow(t){this.clearWheelIdleSnap(),this.syncScrollModel(),this.animateNextRender=!0,this.layoutScroll.step(t)}applyHorizontalWheel(t){this.syncScrollModel();const r=this.layoutGrid;if(!r)return;this.animateNextRender=!1;const i=r.toUnits(xe({x:t}));this.layoutScroll.wheel(ye({x:i.x??0}))}scheduleWheelIdleSnap(){this.clearWheelIdleSnap(),this.wheelIdleSnapTimer=setTimeout(()=>{this.wheelIdleSnapTimer=null,this.animateNextRender=!0,this.layoutScroll.snap()},HL)}clearWheelIdleSnap(){this.wheelIdleSnapTimer!==null&&(clearTimeout(this.wheelIdleSnapTimer),this.wheelIdleSnapTimer=null)}findViewspanContainingNode(t){const r=this.layoutScroll.viewspans,i=this._scrollPosition;let s=null,o=Number.POSITIVE_INFINITY;for(const a of r)if(t>=a.nodeRange[0]&&t<=a.nodeRange[1]){const c=Math.abs(a.anchor-i);c<o&&(o=c,s=a)}return s}findManagedArtifactFrame(t){if(!t)return null;const r=this.querySelectorAll("iframe.artifact-frame");for(const i of r)if(i.contentWindow===t)return i;return null}isTrustedArtifactFrameMessage(t,r){if(t.origin==="null")return!0;const i=this.getArtifactFrameOrigin(r);return i===null||t.origin===i}getArtifactFrameOrigin(t){const r=t.getAttribute("src")??t.src;if(!r)return null;try{return new URL(r,window.location.href).origin}catch{return null}}beginResize(t,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=vu(typeof s.width=="number"?s.width:wt);this.resizeState={cardId:i,pointerId:t.pointerId,startClientX:t.clientX,startWidth:o,currentWidth:o},this.attachResizeListeners();try{this.setPointerCapture(t.pointerId)}catch{}t.preventDefault(),t.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(t){this.resizeState=null,this.detachResizeListeners();try{this.hasPointerCapture(t)&&this.releasePointerCapture(t)}catch{}}beginSwipeTracking(t){this.swipePointerId=t.pointerId,this.swipeStartX=t.clientX,this.swipeStartY=t.clientY,this.swipeLastX=t.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(t){try{this.hasPointerCapture(t)&&this.releasePointerCapture(t)}catch{}}releaseActiveDragPointerCapture(){this.activeDragPointerId!==null&&this.releasePointerCaptureForEvent(this.activeDragPointerId)}releasePointerCaptureForEvent(t){try{this.hasPointerCapture(t)&&this.releasePointerCapture(t)}catch{}}attachDragListeners(){this.dragListenersAttached||(window.addEventListener("pointermove",this.handleWindowPointerMove),window.addEventListener("pointerup",this.handleWindowPointerUp),window.addEventListener("pointercancel",this.handleWindowPointerCancel),this.addEventListener("pointermove",this.handleWindowPointerMove),this.addEventListener("pointerup",this.handleWindowPointerUp),this.addEventListener("pointercancel",this.handleWindowPointerCancel),window.addEventListener("blur",this.handleWindowBlur),this.dragListenersAttached=!0)}detachDragListeners(){this.dragListenersAttached&&(window.removeEventListener("pointermove",this.handleWindowPointerMove),window.removeEventListener("pointerup",this.handleWindowPointerUp),window.removeEventListener("pointercancel",this.handleWindowPointerCancel),this.removeEventListener("pointermove",this.handleWindowPointerMove),this.removeEventListener("pointerup",this.handleWindowPointerUp),this.removeEventListener("pointercancel",this.handleWindowPointerCancel),window.removeEventListener("blur",this.handleWindowBlur),this.dragListenersAttached=!1,this.activeDragPointerId=null)}getDisplayModel(){if(this.dragController.status!=="active"||!this.dragState)return{layout:this.applyResizeOverride(this._layout),activePlaceholderId:null,placeholdersById:new Map};const t=new Map;return t.set(this.dragState.nodeId,{id:this.dragState.nodeId,sourceCardId:this.dragState.nodeId}),{layout:Tf(this.dragState.projectedLayout),activePlaceholderId:this.dragState.nodeId,placeholdersById:t}}applyResizeOverride(t){const r=this.resizeState;if(!r)return t;const i=t.findIndex(a=>a.type==="card"&&a.id===r.cardId);if(i===-1)return t;const s=t[i];if(!s||s.type!=="card"||s.width===r.currentWidth)return t;const o=[...t];return o[i]={...s,width:r.currentWidth},o}render(){const t=wc(this),r=this.createGrid(t.width,t.height);this.layoutGrid=r;const i=this.getDisplayModel(),s=i.layout,o=this.dragController.status==="active",a=Xr(s),c=a.nodes.map(U=>U.width),u=`${t.width}x${t.height}:${c.join(",")}`;!o&&u!==this.scrollModelKey&&(this.scrollModelKey=u,this.layoutScroll.rebuild({grid:r,nodeWidths:c.map(U=>ye({x:U})),snap:zf}),this._scrollPosition=this.layoutScroll.scroll.x??this._scrollPosition);const h=jL(s),p=r.unit.x??hn,v=r.unit.y??hn,m=o?this.dragTrackOffsetXPx:0,E=(this.layoutScroll.translate.x??0)+m,k=Of(a.nodes.length,r,t.height),T=this.animateNextRender&&!o,O=[`transform: translate(${E}px, ${k}px);`,`transition-duration: ${T?Ax:0}ms;`,`pointer-events: ${o?"none":"auto"};`].join(" ");this.animateNextRender=!0,this.style.setProperty("--layout-unit-x",`${p}px`),this.style.setProperty("--layout-unit-y",`${v}px`),this.style.setProperty("--layout-gap",`${ce}px`);const P=this.dragState,V={width:(P==null?void 0:P.size.x)??0,height:(P==null?void 0:P.size.y)??0},F=new Set;{for(let Q=0;Q<a.nodes.length;Q+=1)r.toPixels(ye({x:a.nodes[Q].width})).x;let U=E;for(let Q=0;Q<a.nodes.length;Q+=1){const j=r.toPixels(ye({x:a.nodes[Q].width})).x??0,rt=U+j;U>=-1&&rt<=t.width+1&&F.add(Q),U=rt+ce}}const B=U=>F.has(U);Fe(N`
|
|
187
|
+
<div class="track" style=${O}>
|
|
188
|
+
${a.nodes.map((U,Q)=>N`
|
|
189
|
+
<div
|
|
190
|
+
class="node"
|
|
191
|
+
layout-node=${String(Q)}
|
|
192
|
+
data-layout-node-id=${U.id}
|
|
193
|
+
data-layout-placeholder=${String(i.activePlaceholderId===U.id)}
|
|
194
|
+
layout-node-cols=${String(U.width)}
|
|
195
|
+
?data-foreground=${B(Q)}
|
|
196
|
+
style=${`width: ${r.toPixels(ye({x:U.width})).x}px; --card-width-px: ${r.toPixels(ye({x:U.width})).x};`}
|
|
197
|
+
>
|
|
198
|
+
<div class="node-inner" style=${`grid-template-columns: repeat(${U.width}, var(--layout-unit-x));`}>
|
|
199
|
+
${U.cards.map(j=>{const rt=i.placeholdersById.get(j.id);if(P&&rt)return N`
|
|
200
|
+
<div
|
|
201
|
+
class="card-slot card-placeholder"
|
|
202
|
+
data-layout-placeholder-for=${P.nodeId}
|
|
203
|
+
data-layout-placeholder-ghost="false"
|
|
204
|
+
data-layout-source-stack=${P.source.parentId??""}
|
|
205
|
+
style=${`grid-column: ${j.col} / span ${j.width}; grid-row: ${j.row} / span ${j.height};`}
|
|
206
|
+
></div>
|
|
207
|
+
`;const Mt=h.get(j.id);if(!Mt)return null;const ke=U.type==="card";return N`
|
|
208
|
+
<div
|
|
209
|
+
class="card-slot"
|
|
210
|
+
data-layout-card-id=${j.artifactID}
|
|
211
|
+
data-layout-node-id=${j.id}
|
|
212
|
+
layout-cols=${String(j.width)}
|
|
213
|
+
layout-rows=${String(j.height)}
|
|
214
|
+
style=${`grid-column: ${j.col} / span ${j.width}; grid-row: ${j.row} / span ${j.height};`}
|
|
215
|
+
>
|
|
216
|
+
${this.renderContent(Mt,{isDragging:!1})}
|
|
217
|
+
${ke?N`<div
|
|
218
|
+
class="resize-handle"
|
|
219
|
+
data-resize-handle=${j.id}
|
|
220
|
+
data-test-resize-handle=${j.id}
|
|
221
|
+
></div>`:null}
|
|
222
|
+
</div>
|
|
223
|
+
`})}
|
|
224
|
+
</div>
|
|
225
|
+
</div>
|
|
226
|
+
`)}
|
|
227
|
+
</div>
|
|
228
|
+
${P?(()=>{const U=this.getPlaceholderPixelSize(a,i.activePlaceholderId,r,V),Q=P.pointer.x??0,j=P.pointer.y??0,rt=P.grabOffset.x??0,Mt=P.grabOffset.y??0;return N`
|
|
229
|
+
<div
|
|
230
|
+
class="drag-preview"
|
|
231
|
+
data-layout-preview-card-id=${P.nodeId}
|
|
232
|
+
style=${[`width: ${U.width}px;`,`height: ${U.height}px;`,`left: ${Q-rt}px;`,`top: ${j-Mt}px;`].join(" ")}
|
|
233
|
+
>
|
|
234
|
+
${this.renderDraggedPreview(P.nodeId)}
|
|
235
|
+
</div>
|
|
236
|
+
`})():null}
|
|
237
|
+
`,this)}ensureDragFrameLoop(){this.dragFrame!==0||this.dragController.status==="idle"||(this.lastDragFrameTime=performance.now(),this.dragFrame=requestAnimationFrame(this.runDragFrame))}stopDragFrameLoop(){this.dragFrame!==0&&(cancelAnimationFrame(this.dragFrame),this.dragFrame=0,this.scrollVelocityPxPerSec=0)}syncDragTargetForLatestPointer(){if(this.dragController.status==="idle")return;const t=this.getBoundingClientRect();if(this.dragController.status==="active"){const i=this.clampPointerToViewport(this.lastPointerX,this.lastPointerY,t);this.syncDragTarget(i.x,i.y,t);return}if(this.syncDragTarget(this.lastPointerX,this.lastPointerY,t),this.dragController.status==="pending")return;const r=this.clampPointerToViewport(this.lastPointerX,this.lastPointerY,t);(r.x!==this.lastPointerX||r.y!==this.lastPointerY)&&this.syncDragTarget(r.x,r.y,t)}syncDragTarget(t,r,i=this.getBoundingClientRect()){if(this.dragController.status==="idle")return;const s=this.getDisplayModel(),o=new Set(s.placeholdersById.keys()),a=this.dragController.status==="active"?this.dragTrackOffsetXPx:0,c=this.measureLayoutGeometry(s.layout,o,a);this.dragController.update({pointer:xe({x:t,y:r}),viewport:{left:i.left,top:i.top,width:i.width,height:i.height},geometry:c,effectiveVelocity:Math.max(this.pointerVelocityPxPerSec,this.scrollVelocityPxPerSec)})}resetMotionTracking(t,r){this.pointerVelocityPxPerSec=0,this.scrollVelocityPxPerSec=0,this.motionSampleTime=performance.now(),this.motionSampleX=t,this.motionSampleY=r}clearMotionTracking(){this.pointerVelocityPxPerSec=0,this.scrollVelocityPxPerSec=0,this.motionSampleTime=0}updatePointerVelocity(t,r){this.samplePointerVelocityAt(performance.now(),t,r)}samplePointerVelocityAt(t,r,i){if(this.motionSampleTime===0){this.motionSampleTime=t,this.motionSampleX=r,this.motionSampleY=i,this.pointerVelocityPxPerSec=0;return}const s=t-this.motionSampleTime;if(s<100)return;const o=r-this.motionSampleX;this.pointerVelocityPxPerSec=Math.abs(o)/s*Lf,this.motionSampleTime=t,this.motionSampleX=r,this.motionSampleY=i}clampPointerToViewport(t,r,i){return{x:Math.max(i.left,Math.min(i.left+i.width,t)),y:Math.max(i.top,Math.min(i.top+i.height,r))}}isPointerOutsideViewport(t,r,i){return t<i.left||t>i.left+i.width||r<i.top||r>i.top+i.height}getDragEdgeScrollDeltaPixels(t,r,i){var u;const s=r.left+zo,o=r.left+r.width-zo,a=((u=this.layoutGrid)==null?void 0:u.unit.x)??hn,c=Ix*a;if(t<s){const h=Math.max(0,Math.min(1,(s-t)/zo));return-(c*h**Op)*i}if(t>o){const h=Math.max(0,Math.min(1,(t-o)/zo));return c*h**Op*i}return 0}measureLayoutGeometry(t,r,i=0){const s=this.layoutGrid;if(!s)return[];const o=Xr(t),a=new Map(o.nodes.map(k=>[k.id,k.width])),c=s.toPixels(ye({y:tt})).y??ba,u=wc(this),h=(this.layoutScroll.translate.x??0)+i,p=Of(o.nodes.length,s,u.height),v=u.offsetY+p,m=[];let E=h;for(const k of t){const T=a.get(k.id)??wt,O=s.toPixels(ye({x:T})).x??br,P={left:E,top:v,width:O,height:c};m.push({id:k.id,rect:P}),E+=O+ce}return m}getPlaceholderPixelSize(t,r,i,s){if(!r)return s;for(const o of t.nodes)for(const a of o.cards)if(a.id===r)return{width:i.toPixels(ye({x:a.width})).x??s.width,height:i.toPixels(ye({y:a.height})).y??s.height};return s}renderDraggedPreview(t){const r=xh(this._layout,t);return r?this.renderContent(r,{isDragging:!0}):N``}shouldApplyTrackOffset(t,r){if(r)return!0;for(const i of t){if(i.type!=="stack")continue;if(i.children.some(o=>o.type==="drop-target")&&r!==i.id)return!0}return!1}computeDragTrackOffset(t,r,i,s,o,a){if(!t)return a;const c=s?o??this.getStableAnchorCardId(t,r,i):this.getStableAnchorNodeId(t,r,i);if(!c)return a;const u=s?Nf(t,c,this.layoutGrid):Uf(t,c,this.layoutGrid),h=s?Nf(r,c,this.layoutGrid):Uf(r,c,this.layoutGrid);return u===null||h===null?a:a+(u-h)}getStableAnchorCardId(t,r,i){const s=Mf(t),o=new Set(Mf(r));for(const a of s)if(a!==i&&o.has(a))return a;return null}getStableAnchorNodeId(t,r,i){const s=new Set(r.map(o=>o.id));for(const o of t)if(o.id!==i&&s.has(o.id))return o.id;return null}getStackChildAnchorCardId(t,r){const i=this._layout.find(o=>o.type==="stack"&&o.id===t);if(!i||i.type!=="stack")return null;const s=i.children.find(o=>o.type==="card"&&o.id!==r);return(s==null?void 0:s.id)??null}}function jL(n){const e=new Map;for(const t of n){if(t.type==="card"){e.set(t.id,t);continue}for(const r of t.children)if(r.type==="card")e.set(r.id,r);else for(const i of r.children)e.set(i.id,i)}return e}function qL(n,e){const t=n.findIndex(r=>r.type==="card"&&r.id===e);if(t!==-1)return{topLevelIndex:t};for(let r=0;r<n.length;r+=1){const i=n[r];if(!(!i||i.type!=="stack")&&i.children.some(s=>s.type==="card"&&s.id===e))return{topLevelIndex:r,sourceStackId:i.id}}return null}function Mf(n){const e=[];for(const t of n){if(t.type==="card"){e.push(t.id);continue}if(t.type==="stack"){const r=t.children.find(i=>i.type==="card");r&&e.push(r.id)}}return e}function Nf(n,e,t){if(!t)return null;const r=Xr(n),i=new Map(r.nodes.map(o=>[o.id,o.width]));let s=0;for(const o of n){if(o.type==="card"&&o.id===e||o.type==="stack"&&o.children.some(u=>u.type==="card"&&u.id===e))return s;const a=i.get(o.id)??wt,c=t.toPixels(ye({x:a})).x??br;s+=c+ce}return null}function Uf(n,e,t){if(!t)return null;const r=Xr(n),i=new Map(r.nodes.map(o=>[o.id,o.width]));let s=0;for(const o of n){if(o.id===e)return s;const a=i.get(o.id)??wt,c=t.toPixels(ye({x:a})).x??br;s+=c+ce}return null}customElements.get("layout-view")||customElements.define("layout-view",GL);class YL extends HTMLElement{constructor(){super(...arguments);b(this,"screenManager",zt.resolve("ScreenManager"));b(this,"boundModel",null);b(this,"handleActiveScreenChanged",()=>{this.rebindModel(),this.render()});b(this,"handleModelChange",()=>{this.render()});b(this,"handleCloseArtifact",t=>{t instanceof Wy&&this.screenManager.activeScreen&&this.screenManager.activeScreen.removeArtifact(t.artifactID)});b(this,"handleScrollPositionChanged",t=>{const r=t;typeof r.scrollPosition=="number"&&Number.isFinite(r.scrollPosition)&&this.screenManager.activeScreen&&this.screenManager.activeScreen.setScrollPosition(r.scrollPosition)});b(this,"handleLayoutChanged",t=>{t instanceof qy&&this.screenManager.activeScreen&&this.screenManager.activeScreen.setLayout(t.layout)});b(this,"handleServerEvent",t=>{const r=t.event;if(r.type!=="viewer-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()}rebindModel(){const t=this.screenManager.activeScreen;this.boundModel!==t&&(this.unbindModel(),this.boundModel=t,t&&(t.addEventListener("change",this.handleModelChange),t.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)}buildArtifactMap(){const t=this.screenManager.activeScreen;return t?new Map(t.artifacts):new Map}render(){const t=this.screenManager.activeScreen,r=(t==null?void 0:t.layout)??[],i=this.buildArtifactMap();if(r.length===0){Fe(N`<p data-testid="empty-screen" class="empty">
|
|
238
|
+
No artifacts yet. Create one by asking for something.
|
|
239
|
+
</p>`,this);return}Fe(N`
|
|
240
|
+
<layout-view
|
|
241
|
+
.layout=${r}
|
|
242
|
+
.renderContent=${(o,a)=>{const c=i.get(o.artifactID);return!c||!t?N``:N`<artifact-view
|
|
243
|
+
.artifact=${c}
|
|
244
|
+
.screen=${t}
|
|
245
|
+
.viewURL=${t.server.getViewURL(c)}
|
|
246
|
+
.contentURL=${t.server.getContentURL(c.id)}
|
|
247
|
+
.dragging=${a.isDragging}
|
|
248
|
+
></artifact-view>`}}
|
|
249
|
+
.scrollPosition=${(t==null?void 0:t.scrollPosition)??0}
|
|
250
|
+
@scroll=${this.handleScrollPositionChanged}
|
|
251
|
+
@layout-change=${this.handleLayoutChanged}
|
|
252
|
+
@close-artifact=${this.handleCloseArtifact}
|
|
253
|
+
></layout-view>
|
|
254
|
+
`,this)}}customElements.define("screen-view",YL);class XL extends HTMLElement{connectedCallback(){}}customElements.get("home-screen")||customElements.define("home-screen",XL);function Ia(n){return typeof n=="object"&&n!==null}const Sc=new WeakMap,Ff=Object.prototype.hasOwnProperty,KL=(()=>{const n=new Set;let e=HTMLElement.prototype;for(;e;){for(const t of Object.getOwnPropertyNames(e))n.add(t);if(e===Node.prototype)break;e=Object.getPrototypeOf(e)}return n})();function JL(n,e){if(Ia(n))return e===null?void 0:n.parse(e);if(n===Boolean)return e!==null;if(e!==null)return n===Number?Number(e):e}function QL(n,e){return Ia(n)?e==null?null:n.serialize(e):n===Boolean?e?"":null:e==null?null:String(e)}var js,wu,pr,st,Rt,pi,fr,fi,Se,qr,Yy,Xy,Ky,Jy,la;const jn=class jn extends HTMLElement{constructor(){var i;super();w(this,Se);w(this,pr,new Map);w(this,st,new Map);w(this,Rt,new Map);w(this,pi,!1);w(this,fr,!1);w(this,fi,!1);const t=f(i=jn,js,wu).call(i,this.constructor),r=this;for(const s of t.properties)Ff.call(r,s)&&(l(this,Rt).set(s,r[s]),delete r[s])}static get observedAttributes(){var t;return f(t=jn,js,wu).call(t,this).observedAttributes}connected(){}disconnected(){}changed(t){}connectedCallback(){if(f(this,Se,Jy).call(this),!l(this,fr))for(const t of f(this,Se,qr).call(this).properties)l(this,st).has(t)||l(this,st).set(t,void 0);this.dispatchEvent(new Event("reactive:connect")),this.connected(),f(this,Se,la).call(this)}disconnectedCallback(){this.dispatchEvent(new Event("reactive:disconnect")),this.disconnected()}attributeChangedCallback(t,r,i){if(r===i)return;const s=f(this,Se,qr).call(this).byAttr.get(t);s&&(l(this,Rt).has(s.property)||(this[s.property]=JL(s.type,i)))}};js=new WeakSet,wu=function(t){const r=Sc.get(t);if(r)return r;const i=[...t.properties??[]],s=t.attributes??{},o=new Map,a=new Map;for(const u of i)if(KL.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(Ia(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(t.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(t.prototype,u,{configurable:!0,enumerable:!0,get(){return l(this,pr).get(u)},set(p){f(this,Se,Yy).call(this,u,p)}})}const c={properties:i,observedAttributes:Object.keys(s),byAttr:o,byProp:a};return Sc.set(t,c),c},pr=new WeakMap,st=new WeakMap,Rt=new WeakMap,pi=new WeakMap,fr=new WeakMap,fi=new WeakMap,Se=new WeakSet,qr=function(){return Sc.get(this.constructor)},Yy=function(t,r){if(!l(this,fi)&&l(this,Rt).has(t))return;const i=l(this,pr).get(t);f(this,Se,Xy).call(this,t,i,r)||(l(this,st).has(t)||l(this,st).set(t,i),l(this,pr).set(t,r),l(this,Rt).delete(t),f(this,Se,Ky).call(this,t,r),this.isConnected&&f(this,Se,la).call(this))},Xy=function(t,r,i){if(Object.is(r,i))return!0;const s=f(this,Se,qr).call(this).byProp.get(t);if(!s||!Ia(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}},Ky=function(t,r){const i=f(this,Se,qr).call(this).byProp.get(t);if(!i)return;const{attribute:s,type:o}=i;if(o===Boolean){const c=this.hasAttribute(s);r&&!c?this.setAttribute(s,""):!r&&c&&this.removeAttribute(s);return}const a=QL(o,r);if(a===null){this.hasAttribute(s)&&this.removeAttribute(s);return}this.getAttribute(s)!==a&&this.setAttribute(s,a)},Jy=function(){const t=this,r=f(this,Se,qr).call(this);for(const i of r.properties){if(!Ff.call(t,i))continue;const s=t[i];delete t[i],!(l(this,Rt).has(i)||l(this,pr).has(i))&&(t[i]=s)}x(this,fi,!0);try{for(const[i,s]of l(this,Rt))t[i]=s;l(this,Rt).clear()}finally{x(this,fi,!1)}},la=function(){l(this,pi)||!this.isConnected||l(this,fr)&&l(this,st).size===0||(x(this,pi,!0),queueMicrotask(()=>{if(x(this,pi,!1),!this.isConnected||l(this,fr)&&l(this,st).size===0)return;const t=new Map(l(this,st));l(this,st).clear(),x(this,fr,!0);try{this.changed(t)}catch(r){console.error(r)}this.isConnected&&l(this,st).size>0&&f(this,Se,la).call(this)}))},w(jn,js),b(jn,"properties"),b(jn,"attributes");let ys=jn;var we,gr,wn,gi,mr,qs,mi,Sn,_n,kn,Ys,H,vi,Dt,Z,Qy,Xs,Ks,Su,_u,Na,Ua,Fa,Za,Wa,Ha,Va,Js,yi,Ba,Ga,ja,qa,ku,eb,ca,Ya,tb,un,nb,rb,ib,sb,ob,ab,lb,cb,ub,qe;class ez extends ys{constructor(){super(...arguments);w(this,Z);w(this,we,zt.resolve("ScreenManager"));w(this,gr,zt.resolve("ServerManager"));w(this,wn,null);w(this,gi,new DisposableStack);w(this,mr,ln());w(this,qs,ln());w(this,mi,ln());w(this,Sn,ln());w(this,_n,ln());w(this,kn,ln());w(this,Ys,ln());w(this,H,{kind:"none"});w(this,vi,!1);w(this,Dt,[]);w(this,Xs,()=>{f(this,Z,Su).call(this),x(this,H,{kind:"none"}),l(this,qe).call(this)});w(this,Ks,()=>{l(this,qe).call(this)});w(this,Na,t=>{l(this,H).kind==="none"||l(this,H).kind==="picker"||(t.stopImmediatePropagation(),f(this,Z,un).call(this))});w(this,Ua,()=>{var r;const t=l(this,we).activeScreen;t&&((r=l(this,mr).value)==null||r.close(),t.setPinned(!t.pinned))});w(this,Fa,()=>{var r;const t=l(this,we).activeScreen;t&&((r=l(this,mr).value)==null||r.close(),x(this,H,{kind:"rename",draft:t.name}),l(this,qe).call(this))});w(this,Za,()=>{var t;l(this,we).activeScreen&&((t=l(this,mr).value)==null||t.close(),x(this,H,{kind:"delete",error:null}),l(this,qe).call(this))});w(this,Wa,t=>{if(l(this,H).kind!=="rename")return;const r=t.target;r instanceof HTMLInputElement&&x(this,H,{kind:"rename",draft:r.value})});w(this,Ha,t=>{if(t.preventDefault(),l(this,H).kind!=="rename")return;const r=l(this,we).activeScreen;if(!r)return;const i=l(this,H).draft.trim();i.length>0&&i!==r.name&&r.rename(i),f(this,Z,un).call(this)});w(this,Va,async()=>{if(l(this,H).kind!=="delete")return;const t=l(this,we).activeScreen;if(t){x(this,H,{kind:"delete",error:null});try{await t.remove(),l(this,we).clearActive(),f(this,Z,un).call(this)}catch(r){x(this,H,{kind:"delete",error:r instanceof Error?r.message:"Failed to delete screen."}),l(this,qe).call(this)}}});w(this,Js,()=>{f(this,Z,un).call(this)});w(this,yi,t=>{const r=t.target;(l(this,H).kind==="rename"&&r===l(this,Sn).value||l(this,H).kind==="delete"&&r===l(this,_n).value||l(this,H).kind==="picker"&&r===l(this,kn).value)&&(x(this,H,{kind:"none"}),l(this,qe).call(this))});w(this,Ba,()=>{var i,s;if(l(this,H).kind==="picker"){f(this,Z,un).call(this);return}x(this,Dt,f(this,Z,eb).call(this));const t=((i=l(this,we).activeScreen)==null?void 0:i.id)??null,r=t&&l(this,Dt).some(o=>o.screenID===t)?t:((s=l(this,Dt)[0])==null?void 0:s.screenID)??null;x(this,H,{kind:"picker",filter:"",highlightedID:r}),l(this,qe).call(this),queueMicrotask(()=>{var o;(o=l(this,Ys).value)==null||o.focus()})});w(this,Ga,t=>{var u;const r=l(this,H);if(r.kind!=="picker")return;const i=t.target;if(!(i instanceof HTMLInputElement))return;const s=i.value,o=f(this,Z,ca).call(this,l(this,Dt),s),c=r.highlightedID!==null&&o.some(h=>h.screenID===r.highlightedID)?r.highlightedID:((u=o[0])==null?void 0:u.screenID)??null;x(this,H,{kind:"picker",filter:s,highlightedID:c}),l(this,qe).call(this)});w(this,ja,t=>{var s;const r=l(this,H);if(r.kind!=="picker")return;if(t.key==="Escape"){t.preventDefault(),f(this,Z,un).call(this),(s=l(this,mi).value)==null||s.focus();return}const i=f(this,Z,ca).call(this,l(this,Dt),r.filter);if(t.key==="ArrowDown"||t.key==="ArrowUp"){if(t.preventDefault(),i.length===0)return;const o=i.findIndex(u=>u.screenID===r.highlightedID),a=t.key==="ArrowDown"?1:-1,c=o<0?0:Math.max(0,Math.min(i.length-1,o+a));x(this,H,{kind:"picker",filter:r.filter,highlightedID:i[c].screenID}),l(this,qe).call(this);return}if(t.key==="Enter"){t.preventDefault();const o=i.find(a=>a.screenID===r.highlightedID);o&&f(this,Z,ku).call(this,o)}});w(this,qa,t=>{f(this,Z,ku).call(this,t)});w(this,Ya,async()=>{if(l(this,vi))return;const t=f(this,Z,tb).call(this);if(t){x(this,vi,!0);try{const r=await t.createScreen(tz(new Date));l(this,we).setActive(t.url,r.id)}catch{}finally{x(this,vi,!1)}}});w(this,qe,()=>{var s;const t=l(this,we).activeScreen,r=f(this,Z,sb).call(this);Fe(N`
|
|
255
|
+
${f(this,Z,nb).call(this)}
|
|
256
|
+
<div class="pills">
|
|
257
|
+
${r.map(o=>o.isActive&&t?f(this,Z,ab).call(this,t):f(this,Z,lb).call(this,o.serverURL,o.screenID,o.name))}
|
|
258
|
+
</div>
|
|
259
|
+
${f(this,Z,rb).call(this)}
|
|
260
|
+
${t?f(this,Z,cb).call(this):ne}
|
|
261
|
+
${t?f(this,Z,ub).call(this,t):ne}
|
|
262
|
+
`,this);const i=l(this,qs).value??null;l(this,Sn).value&&(l(this,Sn).value.anchor=i),l(this,_n).value&&(l(this,_n).value.anchor=i),l(this,kn).value&&(l(this,kn).value.anchor=l(this,mi).value??null),(s=i==null?void 0:i.scrollIntoView)==null||s.call(i,{block:"nearest",inline:"nearest"})})}connected(){l(this,we).addEventListener("active-screen-changed",l(this,Xs)),f(this,Z,Su).call(this),l(this,qe).call(this),f(this,Z,Qy).call(this),l(this,gi).defer(()=>{l(this,we).removeEventListener("active-screen-changed",l(this,Xs)),f(this,Z,_u).call(this)})}disconnected(){l(this,gi).dispose(),x(this,gi,new DisposableStack)}}we=new WeakMap,gr=new WeakMap,wn=new WeakMap,gi=new WeakMap,mr=new WeakMap,qs=new WeakMap,mi=new WeakMap,Sn=new WeakMap,_n=new WeakMap,kn=new WeakMap,Ys=new WeakMap,H=new WeakMap,vi=new WeakMap,Dt=new WeakMap,Z=new WeakSet,Qy=async function(){const t=await py(this);this.setAttribute("tone",t)},Xs=new WeakMap,Ks=new WeakMap,Su=function(){var r;const t=l(this,we).activeScreen;l(this,wn)!==t&&(f(this,Z,_u).call(this),x(this,wn,t),(r=l(this,wn))==null||r.addEventListener("change",l(this,Ks)))},_u=function(){var t;(t=l(this,wn))==null||t.removeEventListener("change",l(this,Ks)),x(this,wn,null)},Na=new WeakMap,Ua=new WeakMap,Fa=new WeakMap,Za=new WeakMap,Wa=new WeakMap,Ha=new WeakMap,Va=new WeakMap,Js=new WeakMap,yi=new WeakMap,Ba=new WeakMap,Ga=new WeakMap,ja=new WeakMap,qa=new WeakMap,ku=function(t){l(this,we).setActive(t.serverURL,t.screenID),f(this,Z,un).call(this)},eb=function(){const t=[];for(const r of l(this,gr).servers.values())for(const i of r.screens.values())t.push({serverURL:r.url,screenID:i.id,name:i.name,pinned:i.pinned});return t.sort((r,i)=>r.pinned!==i.pinned?r.pinned?-1:1:r.name.localeCompare(i.name,void 0,{sensitivity:"base"}))},ca=function(t,r){const i=r.trim().toLowerCase();return i.length===0?t:t.filter(s=>s.name.toLowerCase().includes(i))},Ya=new WeakMap,tb=function(){for(const t of l(this,gr).servers.values())return t;return null},un=function(){let t;l(this,H).kind==="rename"?t=l(this,Sn).value:l(this,H).kind==="delete"?t=l(this,_n).value:l(this,H).kind==="picker"&&(t=l(this,kn).value),t&&(t.open=!1),x(this,H,{kind:"none"}),l(this,qe).call(this)},nb=function(){return N`
|
|
263
|
+
<segmented-control variant="glass" role="group" aria-label="Screens">
|
|
264
|
+
<button
|
|
265
|
+
type="button"
|
|
266
|
+
?icon-only=${!0}
|
|
267
|
+
aria-label="Choose screen"
|
|
268
|
+
?data-active=${l(this,H).kind==="picker"}
|
|
269
|
+
@click=${l(this,Ba)}
|
|
270
|
+
${cn(l(this,mi))}
|
|
271
|
+
>
|
|
272
|
+
${k2({size:16,weight:"regular"})}
|
|
273
|
+
</button>
|
|
274
|
+
<button
|
|
275
|
+
type="button"
|
|
276
|
+
?icon-only=${!0}
|
|
277
|
+
aria-label="New screen"
|
|
278
|
+
@click=${l(this,Ya)}
|
|
279
|
+
>
|
|
280
|
+
${E2({size:16,weight:"regular"})}
|
|
281
|
+
</button>
|
|
282
|
+
</segmented-control>
|
|
283
|
+
`},rb=function(){var o;const t=l(this,H).kind==="picker"?l(this,H).filter:"",r=l(this,H).kind==="picker"?l(this,H).highlightedID:null,i=((o=l(this,we).activeScreen)==null?void 0:o.id)??null,s=f(this,Z,ca).call(this,l(this,Dt),t);return N`
|
|
284
|
+
<ui-popover
|
|
285
|
+
class="picker-popover"
|
|
286
|
+
material="glass-frosted"
|
|
287
|
+
?open=${l(this,H).kind==="picker"}
|
|
288
|
+
@close=${l(this,yi)}
|
|
289
|
+
@keydown=${l(this,ja)}
|
|
290
|
+
${cn(l(this,kn))}
|
|
291
|
+
>
|
|
292
|
+
<div class="picker">
|
|
293
|
+
<input
|
|
294
|
+
type="text"
|
|
295
|
+
class="picker-filter"
|
|
296
|
+
placeholder="Filter screens"
|
|
297
|
+
aria-label="Filter screens"
|
|
298
|
+
.value=${t}
|
|
299
|
+
@input=${l(this,Ga)}
|
|
300
|
+
${cn(l(this,Ys))}
|
|
301
|
+
/>
|
|
302
|
+
${s.length===0?N`<p class="picker-empty">
|
|
303
|
+
${l(this,Dt).length===0?"No other screens":"No matches"}
|
|
304
|
+
</p>`:f(this,Z,ib).call(this,s,r,i)}
|
|
305
|
+
</div>
|
|
306
|
+
</ui-popover>
|
|
307
|
+
`},ib=function(t,r,i){const s=t.filter(c=>c.pinned),o=t.filter(c=>!c.pinned),a=c=>{const u=c.screenID===i;return N`
|
|
308
|
+
<li
|
|
309
|
+
class="picker-row"
|
|
310
|
+
role="option"
|
|
311
|
+
aria-selected=${c.screenID===r}
|
|
312
|
+
aria-current=${u?"true":ne}
|
|
313
|
+
?data-highlighted=${c.screenID===r}
|
|
314
|
+
?data-active=${u}
|
|
315
|
+
@click=${()=>l(this,qa).call(this,c)}
|
|
316
|
+
>
|
|
317
|
+
<span class="picker-name">${c.name}</span>
|
|
318
|
+
</li>
|
|
319
|
+
`};return N`
|
|
320
|
+
<ul class="picker-list" role="listbox">
|
|
321
|
+
${s.length>0?N`
|
|
322
|
+
<li class="picker-section-label" role="presentation">Pinned</li>
|
|
323
|
+
${s.map(a)}
|
|
324
|
+
`:ne}
|
|
325
|
+
${o.length>0?N`
|
|
326
|
+
<li class="picker-section-label" role="presentation">Recents</li>
|
|
327
|
+
${o.map(a)}
|
|
328
|
+
`:ne}
|
|
329
|
+
</ul>
|
|
330
|
+
`},sb=function(){var o;const t=((o=l(this,we).activeScreen)==null?void 0:o.id)??null,r=[];let i=!1;for(const a of l(this,gr).servers.values())for(const c of a.screens.values()){if(!c.pinned)continue;const u=c.id===t;u&&(i=!0),r.push({serverURL:a.url,screenID:c.id,name:c.name,isActive:u})}const s=l(this,we).activeScreen;if(s&&!i){let a=null;for(const c of l(this,gr).servers.values())if(c.screens.has(s.id)){a=c.url;break}a!==null&&r.push({serverURL:a,screenID:s.id,name:s.name,isActive:!0})}return r},ob=function(t,r){l(this,we).setActive(t,r)},ab=function(t){return N`
|
|
331
|
+
<dropdown-menu ${cn(l(this,mr))}>
|
|
332
|
+
<button
|
|
333
|
+
slot="trigger"
|
|
334
|
+
type="button"
|
|
335
|
+
variant="glass"
|
|
336
|
+
class="screen-name"
|
|
337
|
+
aria-current="page"
|
|
338
|
+
aria-label=${`Screen actions for ${t.name}`}
|
|
339
|
+
?data-active=${l(this,H).kind==="rename"||l(this,H).kind==="delete"}
|
|
340
|
+
@click=${l(this,Na)}
|
|
341
|
+
${cn(l(this,qs))}
|
|
342
|
+
>
|
|
343
|
+
${t.name}
|
|
344
|
+
</button>
|
|
345
|
+
<dropdown-group>
|
|
346
|
+
<dropdown-item action @click=${l(this,Ua)}>
|
|
347
|
+
${I2()} ${t.pinned?"Unpin screen":"Pin screen"}
|
|
348
|
+
</dropdown-item>
|
|
349
|
+
<dropdown-item action @click=${l(this,Fa)}>
|
|
350
|
+
${A2()} Rename
|
|
351
|
+
</dropdown-item>
|
|
352
|
+
<dropdown-item action danger @click=${l(this,Za)}>
|
|
353
|
+
${$2()} Delete
|
|
354
|
+
</dropdown-item>
|
|
355
|
+
</dropdown-group>
|
|
356
|
+
</dropdown-menu>
|
|
357
|
+
`},lb=function(t,r,i){return N`
|
|
358
|
+
<button
|
|
359
|
+
type="button"
|
|
360
|
+
variant="glass"
|
|
361
|
+
class="screen-name"
|
|
362
|
+
aria-label=${`Switch to ${i}`}
|
|
363
|
+
@click=${()=>f(this,Z,ob).call(this,t,r)}
|
|
364
|
+
>
|
|
365
|
+
${i}
|
|
366
|
+
</button>
|
|
367
|
+
`},cb=function(){const t=l(this,H).kind==="rename"?l(this,H).draft:"";return N`
|
|
368
|
+
<ui-popover
|
|
369
|
+
class="rename-popover"
|
|
370
|
+
?open=${l(this,H).kind==="rename"}
|
|
371
|
+
@close=${l(this,yi)}
|
|
372
|
+
${cn(l(this,Sn))}
|
|
373
|
+
>
|
|
374
|
+
<form class="screen-form" @submit=${l(this,Ha)}>
|
|
375
|
+
<label class="field">
|
|
376
|
+
<span>Screen name</span>
|
|
377
|
+
<input
|
|
378
|
+
type="text"
|
|
379
|
+
.value=${t}
|
|
380
|
+
@input=${l(this,Wa)}
|
|
381
|
+
/>
|
|
382
|
+
</label>
|
|
383
|
+
<div class="actions">
|
|
384
|
+
<button type="button" @click=${l(this,Js)}>Cancel</button>
|
|
385
|
+
<button type="submit" variant="primary">Save</button>
|
|
386
|
+
</div>
|
|
387
|
+
</form>
|
|
388
|
+
</ui-popover>
|
|
389
|
+
`},ub=function(t){const r=l(this,H).kind==="delete"?l(this,H).error:null;return N`
|
|
390
|
+
<ui-popover
|
|
391
|
+
class="delete-popover"
|
|
392
|
+
?open=${l(this,H).kind==="delete"}
|
|
393
|
+
@close=${l(this,yi)}
|
|
394
|
+
${cn(l(this,_n))}
|
|
395
|
+
>
|
|
396
|
+
<div class="screen-form">
|
|
397
|
+
<p class="confirm-text">Delete "${t.name}"?</p>
|
|
398
|
+
${r?N`<p class="error">${r}</p>`:ne}
|
|
399
|
+
<div class="actions">
|
|
400
|
+
<button type="button" @click=${l(this,Js)}>Cancel</button>
|
|
401
|
+
<button
|
|
402
|
+
type="button"
|
|
403
|
+
variant="danger"
|
|
404
|
+
@click=${l(this,Va)}
|
|
405
|
+
>
|
|
406
|
+
Delete
|
|
407
|
+
</button>
|
|
408
|
+
</div>
|
|
409
|
+
</div>
|
|
410
|
+
</ui-popover>
|
|
411
|
+
`},qe=new WeakMap;customElements.define("screen-select",ez);function tz(n){const e=n.toLocaleDateString("en-US",{month:"long",day:"numeric",year:"numeric"}),t=12,r=n.getHours(),i=r%t===0?t:r%t,s=n.getMinutes().toString().padStart(2,"0"),o=r>=t?"pm":"am";return`${e} at ${i}:${s}${o}`}function nz(n,e){let t=null;const r=()=>e((t==null?void 0:t.messages)??[]),i=()=>{var a;const o=((a=n.activeServer)==null?void 0:a.acpClient)??null;o!==t&&(t==null||t.removeEventListener("change",r),t=o,t&&(t.addEventListener("change",r),t.connect().catch(c=>{console.error("ACPClient.connect() failed",c)})),r())};n.addEventListener("change",i),i();const s=()=>{n.removeEventListener("change",i),t==null||t.removeEventListener("change",r),t=null};return{dispose:s,[Symbol.dispose](){s()}}}/*! @license DOMPurify 3.3.3 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.3.3/LICENSE */const{entries:hb,setPrototypeOf:Zf,isFrozen:rz,getPrototypeOf:iz,getOwnPropertyDescriptor:sz}=Object;let{freeze:Ze,seal:ct,create:ua}=Object,{apply:Eu,construct:xu}=typeof Reflect<"u"&&Reflect;Ze||(Ze=function(e){return e});ct||(ct=function(e){return e});Eu||(Eu=function(e,t){for(var r=arguments.length,i=new Array(r>2?r-2:0),s=2;s<r;s++)i[s-2]=arguments[s];return e.apply(t,i)});xu||(xu=function(e){for(var t=arguments.length,r=new Array(t>1?t-1:0),i=1;i<t;i++)r[i-1]=arguments[i];return new e(...r)});const Vo=We(Array.prototype.forEach),oz=We(Array.prototype.lastIndexOf),Wf=We(Array.prototype.pop),Bi=We(Array.prototype.push),az=We(Array.prototype.splice),ha=We(String.prototype.toLowerCase),_c=We(String.prototype.toString),kc=We(String.prototype.match),Gi=We(String.prototype.replace),lz=We(String.prototype.indexOf),cz=We(String.prototype.trim),Je=We(Object.prototype.hasOwnProperty),Oe=We(RegExp.prototype.test),ji=uz(TypeError);function We(n){return function(e){e instanceof RegExp&&(e.lastIndex=0);for(var t=arguments.length,r=new Array(t>1?t-1:0),i=1;i<t;i++)r[i-1]=arguments[i];return Eu(n,e,r)}}function uz(n){return function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return xu(n,t)}}function q(n,e){let t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:ha;Zf&&Zf(n,null);let r=e.length;for(;r--;){let i=e[r];if(typeof i=="string"){const s=t(i);s!==i&&(rz(e)||(e[r]=s),i=s)}n[i]=!0}return n}function hz(n){for(let e=0;e<n.length;e++)Je(n,e)||(n[e]=null);return n}function At(n){const e=ua(null);for(const[t,r]of hb(n))Je(n,t)&&(Array.isArray(r)?e[t]=hz(r):r&&typeof r=="object"&&r.constructor===Object?e[t]=At(r):e[t]=r);return e}function qi(n,e){for(;n!==null;){const r=sz(n,e);if(r){if(r.get)return We(r.get);if(typeof r.value=="function")return We(r.value)}n=iz(n)}function t(){return null}return t}const Hf=Ze(["a","abbr","acronym","address","area","article","aside","audio","b","bdi","bdo","big","blink","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","content","data","datalist","dd","decorator","del","details","dfn","dialog","dir","div","dl","dt","element","em","fieldset","figcaption","figure","font","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","img","input","ins","kbd","label","legend","li","main","map","mark","marquee","menu","menuitem","meter","nav","nobr","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","search","section","select","shadow","slot","small","source","spacer","span","strike","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","tr","track","tt","u","ul","var","video","wbr"]),Ec=Ze(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","enterkeyhint","exportparts","filter","font","g","glyph","glyphref","hkern","image","inputmode","line","lineargradient","marker","mask","metadata","mpath","part","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),xc=Ze(["feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence"]),dz=Ze(["animate","color-profile","cursor","discard","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignobject","hatch","hatchpath","mesh","meshgradient","meshpatch","meshrow","missing-glyph","script","set","solidcolor","unknown","use"]),Ac=Ze(["math","menclose","merror","mfenced","mfrac","mglyph","mi","mlabeledtr","mmultiscripts","mn","mo","mover","mpadded","mphantom","mroot","mrow","ms","mspace","msqrt","mstyle","msub","msup","msubsup","mtable","mtd","mtext","mtr","munder","munderover","mprescripts"]),pz=Ze(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),Vf=Ze(["#text"]),Bf=Ze(["accept","action","align","alt","autocapitalize","autocomplete","autopictureinpicture","autoplay","background","bgcolor","border","capture","cellpadding","cellspacing","checked","cite","class","clear","color","cols","colspan","controls","controlslist","coords","crossorigin","datetime","decoding","default","dir","disabled","disablepictureinpicture","disableremoteplayback","download","draggable","enctype","enterkeyhint","exportparts","face","for","headers","height","hidden","high","href","hreflang","id","inert","inputmode","integrity","ismap","kind","label","lang","list","loading","loop","low","max","maxlength","media","method","min","minlength","multiple","muted","name","nonce","noshade","novalidate","nowrap","open","optimum","part","pattern","placeholder","playsinline","popover","popovertarget","popovertargetaction","poster","preload","pubdate","radiogroup","readonly","rel","required","rev","reversed","role","rows","rowspan","spellcheck","scope","selected","shape","size","sizes","slot","span","srclang","start","src","srcset","step","style","summary","tabindex","title","translate","type","usemap","valign","value","width","wrap","xmlns","slot"]),$c=Ze(["accent-height","accumulate","additive","alignment-baseline","amplitude","ascent","attributename","attributetype","azimuth","basefrequency","baseline-shift","begin","bias","by","class","clip","clippathunits","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","cx","cy","d","dx","dy","diffuseconstant","direction","display","divisor","dur","edgemode","elevation","end","exponent","fill","fill-opacity","fill-rule","filter","filterunits","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","fx","fy","g1","g2","glyph-name","glyphref","gradientunits","gradienttransform","height","href","id","image-rendering","in","in2","intercept","k","k1","k2","k3","k4","kerning","keypoints","keysplines","keytimes","lang","lengthadjust","letter-spacing","kernelmatrix","kernelunitlength","lighting-color","local","marker-end","marker-mid","marker-start","markerheight","markerunits","markerwidth","maskcontentunits","maskunits","max","mask","mask-type","media","method","mode","min","name","numoctaves","offset","operator","opacity","order","orient","orientation","origin","overflow","paint-order","path","pathlength","patterncontentunits","patterntransform","patternunits","points","preservealpha","preserveaspectratio","primitiveunits","r","rx","ry","radius","refx","refy","repeatcount","repeatdur","restart","result","rotate","scale","seed","shape-rendering","slope","specularconstant","specularexponent","spreadmethod","startoffset","stddeviation","stitchtiles","stop-color","stop-opacity","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke","stroke-width","style","surfacescale","systemlanguage","tabindex","tablevalues","targetx","targety","transform","transform-origin","text-anchor","text-decoration","text-rendering","textlength","type","u1","u2","unicode","values","viewbox","visibility","version","vert-adv-y","vert-origin-x","vert-origin-y","width","word-spacing","wrap","writing-mode","xchannelselector","ychannelselector","x","x1","x2","xmlns","y","y1","y2","z","zoomandpan"]),Gf=Ze(["accent","accentunder","align","bevelled","close","columnsalign","columnlines","columnspan","denomalign","depth","dir","display","displaystyle","encoding","fence","frame","height","href","id","largeop","length","linethickness","lspace","lquote","mathbackground","mathcolor","mathsize","mathvariant","maxsize","minsize","movablelimits","notation","numalign","open","rowalign","rowlines","rowspacing","rowspan","rspace","rquote","scriptlevel","scriptminsize","scriptsizemultiplier","selection","separator","separators","stretchy","subscriptshift","supscriptshift","symmetric","voffset","width","xmlns"]),Bo=Ze(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),fz=ct(/\{\{[\w\W]*|[\w\W]*\}\}/gm),gz=ct(/<%[\w\W]*|[\w\W]*%>/gm),mz=ct(/\$\{[\w\W]*/gm),vz=ct(/^data-[\-\w.\u00B7-\uFFFF]+$/),yz=ct(/^aria-[\-\w]+$/),db=ct(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),bz=ct(/^(?:\w+script|data):/i),wz=ct(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),pb=ct(/^html$/i),Sz=ct(/^[a-z][.\w]*(-[.\w]+)+$/i);var jf=Object.freeze({__proto__:null,ARIA_ATTR:yz,ATTR_WHITESPACE:wz,CUSTOM_ELEMENT:Sz,DATA_ATTR:vz,DOCTYPE_NAME:pb,ERB_EXPR:gz,IS_ALLOWED_URI:db,IS_SCRIPT_OR_DATA:bz,MUSTACHE_EXPR:fz,TMPLIT_EXPR:mz});const Yi={element:1,text:3,progressingInstruction:7,comment:8,document:9},_z=function(){return typeof window>"u"?null:window},kz=function(e,t){if(typeof e!="object"||typeof e.createPolicy!="function")return null;let r=null;const i="data-tt-policy-suffix";t&&t.hasAttribute(i)&&(r=t.getAttribute(i));const s="dompurify"+(r?"#"+r:"");try{return e.createPolicy(s,{createHTML(o){return o},createScriptURL(o){return o}})}catch{return console.warn("TrustedTypes policy "+s+" could not be created."),null}},qf=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}};function fb(){let n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:_z();const e=M=>fb(M);if(e.version="3.3.3",e.removed=[],!n||!n.document||n.document.nodeType!==Yi.document||!n.Element)return e.isSupported=!1,e;let{document:t}=n;const r=t,i=r.currentScript,{DocumentFragment:s,HTMLTemplateElement:o,Node:a,Element:c,NodeFilter:u,NamedNodeMap:h=n.NamedNodeMap||n.MozNamedAttrMap,HTMLFormElement:p,DOMParser:v,trustedTypes:m}=n,E=c.prototype,k=qi(E,"cloneNode"),T=qi(E,"remove"),O=qi(E,"nextSibling"),P=qi(E,"childNodes"),V=qi(E,"parentNode");if(typeof o=="function"){const M=t.createElement("template");M.content&&M.content.ownerDocument&&(t=M.content.ownerDocument)}let F,B="";const{implementation:U,createNodeIterator:Q,createDocumentFragment:j,getElementsByTagName:rt}=t,{importNode:Mt}=r;let ke=qf();e.isSupported=typeof hb=="function"&&typeof V=="function"&&U&&U.createHTMLDocument!==void 0;const{MUSTACHE_EXPR:zn,ERB_EXPR:St,TMPLIT_EXPR:on,DATA_ATTR:wl,ARIA_ATTR:wo,IS_SCRIPT_OR_DATA:Cb,ATTR_WHITESPACE:Uh,CUSTOM_ELEMENT:Pb}=jf;let{IS_ALLOWED_URI:Fh}=jf,$e=null;const Zh=q({},[...Hf,...Ec,...xc,...Ac,...Vf]);let Ce=null;const Wh=q({},[...Bf,...$c,...Gf,...Bo]);let ve=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}})),Ni=null,So=null;const an=Object.seal(ua(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let Hh=!0,Sl=!0,Vh=!1,Bh=!0,Tr=!1,_o=!0,On=!1,_l=!1,kl=!1,Cr=!1,ko=!1,Eo=!1,Gh=!0,jh=!1;const Rb="user-content-";let El=!0,Ui=!1,Pr={},_t=null;const xl=q({},["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 qh=null;const Yh=q({},["audio","video","img","source","image","track"]);let Al=null;const Xh=q({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),xo="http://www.w3.org/1998/Math/MathML",Ao="http://www.w3.org/2000/svg",Nt="http://www.w3.org/1999/xhtml";let Rr=Nt,$l=!1,Il=null;const Db=q({},[xo,Ao,Nt],_c);let $o=q({},["mi","mo","mn","ms","mtext"]),Io=q({},["annotation-xml"]);const Lb=q({},["title","style","font","a","script"]);let Fi=null;const zb=["application/xhtml+xml","text/html"],Ob="text/html";let Ee=null,Dr=null;const Mb=t.createElement("form"),Kh=function(y){return y instanceof RegExp||y instanceof Function},Tl=function(){let y=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(!(Dr&&Dr===y)){if((!y||typeof y!="object")&&(y={}),y=At(y),Fi=zb.indexOf(y.PARSER_MEDIA_TYPE)===-1?Ob:y.PARSER_MEDIA_TYPE,Ee=Fi==="application/xhtml+xml"?_c:ha,$e=Je(y,"ALLOWED_TAGS")?q({},y.ALLOWED_TAGS,Ee):Zh,Ce=Je(y,"ALLOWED_ATTR")?q({},y.ALLOWED_ATTR,Ee):Wh,Il=Je(y,"ALLOWED_NAMESPACES")?q({},y.ALLOWED_NAMESPACES,_c):Db,Al=Je(y,"ADD_URI_SAFE_ATTR")?q(At(Xh),y.ADD_URI_SAFE_ATTR,Ee):Xh,qh=Je(y,"ADD_DATA_URI_TAGS")?q(At(Yh),y.ADD_DATA_URI_TAGS,Ee):Yh,_t=Je(y,"FORBID_CONTENTS")?q({},y.FORBID_CONTENTS,Ee):xl,Ni=Je(y,"FORBID_TAGS")?q({},y.FORBID_TAGS,Ee):At({}),So=Je(y,"FORBID_ATTR")?q({},y.FORBID_ATTR,Ee):At({}),Pr=Je(y,"USE_PROFILES")?y.USE_PROFILES:!1,Hh=y.ALLOW_ARIA_ATTR!==!1,Sl=y.ALLOW_DATA_ATTR!==!1,Vh=y.ALLOW_UNKNOWN_PROTOCOLS||!1,Bh=y.ALLOW_SELF_CLOSE_IN_ATTR!==!1,Tr=y.SAFE_FOR_TEMPLATES||!1,_o=y.SAFE_FOR_XML!==!1,On=y.WHOLE_DOCUMENT||!1,Cr=y.RETURN_DOM||!1,ko=y.RETURN_DOM_FRAGMENT||!1,Eo=y.RETURN_TRUSTED_TYPE||!1,kl=y.FORCE_BODY||!1,Gh=y.SANITIZE_DOM!==!1,jh=y.SANITIZE_NAMED_PROPS||!1,El=y.KEEP_CONTENT!==!1,Ui=y.IN_PLACE||!1,Fh=y.ALLOWED_URI_REGEXP||db,Rr=y.NAMESPACE||Nt,$o=y.MATHML_TEXT_INTEGRATION_POINTS||$o,Io=y.HTML_INTEGRATION_POINTS||Io,ve=y.CUSTOM_ELEMENT_HANDLING||{},y.CUSTOM_ELEMENT_HANDLING&&Kh(y.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(ve.tagNameCheck=y.CUSTOM_ELEMENT_HANDLING.tagNameCheck),y.CUSTOM_ELEMENT_HANDLING&&Kh(y.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(ve.attributeNameCheck=y.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),y.CUSTOM_ELEMENT_HANDLING&&typeof y.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements=="boolean"&&(ve.allowCustomizedBuiltInElements=y.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),Tr&&(Sl=!1),ko&&(Cr=!0),Pr&&($e=q({},Vf),Ce=ua(null),Pr.html===!0&&(q($e,Hf),q(Ce,Bf)),Pr.svg===!0&&(q($e,Ec),q(Ce,$c),q(Ce,Bo)),Pr.svgFilters===!0&&(q($e,xc),q(Ce,$c),q(Ce,Bo)),Pr.mathMl===!0&&(q($e,Ac),q(Ce,Gf),q(Ce,Bo))),Je(y,"ADD_TAGS")||(an.tagCheck=null),Je(y,"ADD_ATTR")||(an.attributeCheck=null),y.ADD_TAGS&&(typeof y.ADD_TAGS=="function"?an.tagCheck=y.ADD_TAGS:($e===Zh&&($e=At($e)),q($e,y.ADD_TAGS,Ee))),y.ADD_ATTR&&(typeof y.ADD_ATTR=="function"?an.attributeCheck=y.ADD_ATTR:(Ce===Wh&&(Ce=At(Ce)),q(Ce,y.ADD_ATTR,Ee))),y.ADD_URI_SAFE_ATTR&&q(Al,y.ADD_URI_SAFE_ATTR,Ee),y.FORBID_CONTENTS&&(_t===xl&&(_t=At(_t)),q(_t,y.FORBID_CONTENTS,Ee)),y.ADD_FORBID_CONTENTS&&(_t===xl&&(_t=At(_t)),q(_t,y.ADD_FORBID_CONTENTS,Ee)),El&&($e["#text"]=!0),On&&q($e,["html","head","body"]),$e.table&&(q($e,["tbody"]),delete Ni.tbody),y.TRUSTED_TYPES_POLICY){if(typeof y.TRUSTED_TYPES_POLICY.createHTML!="function")throw ji('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof y.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw ji('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');F=y.TRUSTED_TYPES_POLICY,B=F.createHTML("")}else F===void 0&&(F=kz(m,i)),F!==null&&typeof B=="string"&&(B=F.createHTML(""));Ze&&Ze(y),Dr=y}},Jh=q({},[...Ec,...xc,...dz]),Qh=q({},[...Ac,...pz]),Nb=function(y){let C=V(y);(!C||!C.tagName)&&(C={namespaceURI:Rr,tagName:"template"});const R=ha(y.tagName),ue=ha(C.tagName);return Il[y.namespaceURI]?y.namespaceURI===Ao?C.namespaceURI===Nt?R==="svg":C.namespaceURI===xo?R==="svg"&&(ue==="annotation-xml"||$o[ue]):!!Jh[R]:y.namespaceURI===xo?C.namespaceURI===Nt?R==="math":C.namespaceURI===Ao?R==="math"&&Io[ue]:!!Qh[R]:y.namespaceURI===Nt?C.namespaceURI===Ao&&!Io[ue]||C.namespaceURI===xo&&!$o[ue]?!1:!Qh[R]&&(Lb[R]||!Jh[R]):!!(Fi==="application/xhtml+xml"&&Il[y.namespaceURI]):!1},kt=function(y){Bi(e.removed,{element:y});try{V(y).removeChild(y)}catch{T(y)}},Mn=function(y,C){try{Bi(e.removed,{attribute:C.getAttributeNode(y),from:C})}catch{Bi(e.removed,{attribute:null,from:C})}if(C.removeAttribute(y),y==="is")if(Cr||ko)try{kt(C)}catch{}else try{C.setAttribute(y,"")}catch{}},ed=function(y){let C=null,R=null;if(kl)y="<remove></remove>"+y;else{const be=kc(y,/^[\r\n\t ]+/);R=be&&be[0]}Fi==="application/xhtml+xml"&&Rr===Nt&&(y='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+y+"</body></html>");const ue=F?F.createHTML(y):y;if(Rr===Nt)try{C=new v().parseFromString(ue,Fi)}catch{}if(!C||!C.documentElement){C=U.createDocument(Rr,"template",null);try{C.documentElement.innerHTML=$l?B:ue}catch{}}const De=C.body||C.documentElement;return y&&R&&De.insertBefore(t.createTextNode(R),De.childNodes[0]||null),Rr===Nt?rt.call(C,On?"html":"body")[0]:On?C.documentElement:De},td=function(y){return Q.call(y.ownerDocument||y,y,u.SHOW_ELEMENT|u.SHOW_COMMENT|u.SHOW_TEXT|u.SHOW_PROCESSING_INSTRUCTION|u.SHOW_CDATA_SECTION,null)},Cl=function(y){return y instanceof p&&(typeof y.nodeName!="string"||typeof y.textContent!="string"||typeof y.removeChild!="function"||!(y.attributes instanceof h)||typeof y.removeAttribute!="function"||typeof y.setAttribute!="function"||typeof y.namespaceURI!="string"||typeof y.insertBefore!="function"||typeof y.hasChildNodes!="function")},nd=function(y){return typeof a=="function"&&y instanceof a};function Ut(M,y,C){Vo(M,R=>{R.call(e,y,C,Dr)})}const rd=function(y){let C=null;if(Ut(ke.beforeSanitizeElements,y,null),Cl(y))return kt(y),!0;const R=Ee(y.nodeName);if(Ut(ke.uponSanitizeElement,y,{tagName:R,allowedTags:$e}),_o&&y.hasChildNodes()&&!nd(y.firstElementChild)&&Oe(/<[/\w!]/g,y.innerHTML)&&Oe(/<[/\w!]/g,y.textContent)||y.nodeType===Yi.progressingInstruction||_o&&y.nodeType===Yi.comment&&Oe(/<[/\w]/g,y.data))return kt(y),!0;if(!(an.tagCheck instanceof Function&&an.tagCheck(R))&&(!$e[R]||Ni[R])){if(!Ni[R]&&sd(R)&&(ve.tagNameCheck instanceof RegExp&&Oe(ve.tagNameCheck,R)||ve.tagNameCheck instanceof Function&&ve.tagNameCheck(R)))return!1;if(El&&!_t[R]){const ue=V(y)||y.parentNode,De=P(y)||y.childNodes;if(De&&ue){const be=De.length;for(let He=be-1;He>=0;--He){const Ft=k(De[He],!0);Ft.__removalCount=(y.__removalCount||0)+1,ue.insertBefore(Ft,O(y))}}}return kt(y),!0}return y instanceof c&&!Nb(y)||(R==="noscript"||R==="noembed"||R==="noframes")&&Oe(/<\/no(script|embed|frames)/i,y.innerHTML)?(kt(y),!0):(Tr&&y.nodeType===Yi.text&&(C=y.textContent,Vo([zn,St,on],ue=>{C=Gi(C,ue," ")}),y.textContent!==C&&(Bi(e.removed,{element:y.cloneNode()}),y.textContent=C)),Ut(ke.afterSanitizeElements,y,null),!1)},id=function(y,C,R){if(So[C]||Gh&&(C==="id"||C==="name")&&(R in t||R in Mb))return!1;if(!(Sl&&!So[C]&&Oe(wl,C))){if(!(Hh&&Oe(wo,C))){if(!(an.attributeCheck instanceof Function&&an.attributeCheck(C,y))){if(!Ce[C]||So[C]){if(!(sd(y)&&(ve.tagNameCheck instanceof RegExp&&Oe(ve.tagNameCheck,y)||ve.tagNameCheck instanceof Function&&ve.tagNameCheck(y))&&(ve.attributeNameCheck instanceof RegExp&&Oe(ve.attributeNameCheck,C)||ve.attributeNameCheck instanceof Function&&ve.attributeNameCheck(C,y))||C==="is"&&ve.allowCustomizedBuiltInElements&&(ve.tagNameCheck instanceof RegExp&&Oe(ve.tagNameCheck,R)||ve.tagNameCheck instanceof Function&&ve.tagNameCheck(R))))return!1}else if(!Al[C]){if(!Oe(Fh,Gi(R,Uh,""))){if(!((C==="src"||C==="xlink:href"||C==="href")&&y!=="script"&&lz(R,"data:")===0&&qh[y])){if(!(Vh&&!Oe(Cb,Gi(R,Uh,"")))){if(R)return!1}}}}}}}return!0},sd=function(y){return y!=="annotation-xml"&&kc(y,Pb)},od=function(y){Ut(ke.beforeSanitizeAttributes,y,null);const{attributes:C}=y;if(!C||Cl(y))return;const R={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:Ce,forceKeepAttr:void 0};let ue=C.length;for(;ue--;){const De=C[ue],{name:be,namespaceURI:He,value:Ft}=De,Lr=Ee(be),Pl=Ft;let Pe=be==="value"?Pl:cz(Pl);if(R.attrName=Lr,R.attrValue=Pe,R.keepAttr=!0,R.forceKeepAttr=void 0,Ut(ke.uponSanitizeAttribute,y,R),Pe=R.attrValue,jh&&(Lr==="id"||Lr==="name")&&(Mn(be,y),Pe=Rb+Pe),_o&&Oe(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,Pe)){Mn(be,y);continue}if(Lr==="attributename"&&kc(Pe,"href")){Mn(be,y);continue}if(R.forceKeepAttr)continue;if(!R.keepAttr){Mn(be,y);continue}if(!Bh&&Oe(/\/>/i,Pe)){Mn(be,y);continue}Tr&&Vo([zn,St,on],ld=>{Pe=Gi(Pe,ld," ")});const ad=Ee(y.nodeName);if(!id(ad,Lr,Pe)){Mn(be,y);continue}if(F&&typeof m=="object"&&typeof m.getAttributeType=="function"&&!He)switch(m.getAttributeType(ad,Lr)){case"TrustedHTML":{Pe=F.createHTML(Pe);break}case"TrustedScriptURL":{Pe=F.createScriptURL(Pe);break}}if(Pe!==Pl)try{He?y.setAttributeNS(He,be,Pe):y.setAttribute(be,Pe),Cl(y)?kt(y):Wf(e.removed)}catch{Mn(be,y)}}Ut(ke.afterSanitizeAttributes,y,null)},Ub=function M(y){let C=null;const R=td(y);for(Ut(ke.beforeSanitizeShadowDOM,y,null);C=R.nextNode();)Ut(ke.uponSanitizeShadowNode,C,null),rd(C),od(C),C.content instanceof s&&M(C.content);Ut(ke.afterSanitizeShadowDOM,y,null)};return e.sanitize=function(M){let y=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},C=null,R=null,ue=null,De=null;if($l=!M,$l&&(M="<!-->"),typeof M!="string"&&!nd(M))if(typeof M.toString=="function"){if(M=M.toString(),typeof M!="string")throw ji("dirty is not a string, aborting")}else throw ji("toString is not a function");if(!e.isSupported)return M;if(_l||Tl(y),e.removed=[],typeof M=="string"&&(Ui=!1),Ui){if(M.nodeName){const Ft=Ee(M.nodeName);if(!$e[Ft]||Ni[Ft])throw ji("root node is forbidden and cannot be sanitized in-place")}}else if(M instanceof a)C=ed("<!---->"),R=C.ownerDocument.importNode(M,!0),R.nodeType===Yi.element&&R.nodeName==="BODY"||R.nodeName==="HTML"?C=R:C.appendChild(R);else{if(!Cr&&!Tr&&!On&&M.indexOf("<")===-1)return F&&Eo?F.createHTML(M):M;if(C=ed(M),!C)return Cr?null:Eo?B:""}C&&kl&&kt(C.firstChild);const be=td(Ui?M:C);for(;ue=be.nextNode();)rd(ue),od(ue),ue.content instanceof s&&Ub(ue.content);if(Ui)return M;if(Cr){if(ko)for(De=j.call(C.ownerDocument);C.firstChild;)De.appendChild(C.firstChild);else De=C;return(Ce.shadowroot||Ce.shadowrootmode)&&(De=Mt.call(r,De,!0)),De}let He=On?C.outerHTML:C.innerHTML;return On&&$e["!doctype"]&&C.ownerDocument&&C.ownerDocument.doctype&&C.ownerDocument.doctype.name&&Oe(pb,C.ownerDocument.doctype.name)&&(He="<!DOCTYPE "+C.ownerDocument.doctype.name+`>
|
|
412
|
+
`+He),Tr&&Vo([zn,St,on],Ft=>{He=Gi(He,Ft," ")}),F&&Eo?F.createHTML(He):He},e.setConfig=function(){let M=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};Tl(M),_l=!0},e.clearConfig=function(){Dr=null,_l=!1},e.isValidAttribute=function(M,y,C){Dr||Tl({});const R=Ee(M),ue=Ee(y);return id(R,ue,C)},e.addHook=function(M,y){typeof y=="function"&&Bi(ke[M],y)},e.removeHook=function(M,y){if(y!==void 0){const C=oz(ke[M],y);return C===-1?void 0:az(ke[M],C,1)[0]}return Wf(ke[M])},e.removeHooks=function(M){ke[M]=[]},e.removeAllHooks=function(){ke=qf()},e}var gb=fb();function Ah(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var Ir=Ah();function mb(n){Ir=n}var Gn={exec:()=>null};function J(n,e=""){let t=typeof n=="string"?n:n.source,r={replace:(i,s)=>{let o=typeof s=="string"?s:s.source;return o=o.replace(Ue.caret,"$1"),t=t.replace(i,o),r},getRegex:()=>new RegExp(t,e)};return r}var Ez=(()=>{try{return!!new RegExp("(?<=1)(?<!1)")}catch{return!1}})(),Ue={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)}}>`)},xz=/^(?:[ \t]*(?:\n|$))+/,Az=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,$z=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,bo=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,Iz=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,$h=/ {0,3}(?:[*+-]|\d{1,9}[.)])/,vb=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,yb=J(vb).replace(/bull/g,$h).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(),Tz=J(vb).replace(/bull/g,$h).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(),Ih=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,Cz=/^[^\n]+/,Th=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,Pz=J(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",Th).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),Rz=J(/^(bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,$h).getRegex(),yl="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",Ch=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,Dz=J("^ {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",Ch).replace("tag",yl).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),bb=J(Ih).replace("hr",bo).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",yl).getRegex(),Lz=J(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",bb).getRegex(),Ph={blockquote:Lz,code:Az,def:Pz,fences:$z,heading:Iz,hr:bo,html:Dz,lheading:yb,list:Rz,newline:xz,paragraph:bb,table:Gn,text:Cz},Yf=J("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",bo).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",yl).getRegex(),zz={...Ph,lheading:Tz,table:Yf,paragraph:J(Ih).replace("hr",bo).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",Yf).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",yl).getRegex()},Oz={...Ph,html:J(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",Ch).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:Gn,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:J(Ih).replace("hr",bo).replace("heading",` *#{1,6} *[^
|
|
413
|
+
]`).replace("lheading",yb).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},Mz=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,Nz=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,wb=/^( {2,}|\\)\n(?!\s*$)/,Uz=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,Mi=/[\p{P}\p{S}]/u,bl=/[\s\p{P}\p{S}]/u,Rh=/[^\s\p{P}\p{S}]/u,Fz=J(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,bl).getRegex(),Sb=/(?!~)[\p{P}\p{S}]/u,Zz=/(?!~)[\s\p{P}\p{S}]/u,Wz=/(?:[^\s\p{P}\p{S}]|~)/u,Hz=J(/link|precode-code|html/,"g").replace("link",/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-",Ez?"(?<!`)()":"(^^|[^`])").replace("code",/(?<b>`+)[^`]+\k<b>(?!`)/).replace("html",/<(?! )[^<>]*?>/).getRegex(),_b=/^(?:\*+(?:((?!\*)punct)|([^\s*]))?)|^_+(?:((?!_)punct)|([^\s_]))?/,Vz=J(_b,"u").replace(/punct/g,Mi).getRegex(),Bz=J(_b,"u").replace(/punct/g,Sb).getRegex(),kb="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",Gz=J(kb,"gu").replace(/notPunctSpace/g,Rh).replace(/punctSpace/g,bl).replace(/punct/g,Mi).getRegex(),jz=J(kb,"gu").replace(/notPunctSpace/g,Wz).replace(/punctSpace/g,Zz).replace(/punct/g,Sb).getRegex(),qz=J("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,Rh).replace(/punctSpace/g,bl).replace(/punct/g,Mi).getRegex(),Yz=J(/^~~?(?:((?!~)punct)|[^\s~])/,"u").replace(/punct/g,Mi).getRegex(),Xz="^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)",Kz=J(Xz,"gu").replace(/notPunctSpace/g,Rh).replace(/punctSpace/g,bl).replace(/punct/g,Mi).getRegex(),Jz=J(/\\(punct)/,"gu").replace(/punct/g,Mi).getRegex(),Qz=J(/^<(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(),eO=J(Ch).replace("(?:-->|$)","-->").getRegex(),tO=J("^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",eO).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),Ta=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\])|[^\[\]\\`])*?/,nO=J(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?\s*\)/).replace("label",Ta).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),Eb=J(/^!?\[(label)\]\[(ref)\]/).replace("label",Ta).replace("ref",Th).getRegex(),xb=J(/^!?\[(ref)\](?:\[\])?/).replace("ref",Th).getRegex(),rO=J("reflink|nolink(?!\\()","g").replace("reflink",Eb).replace("nolink",xb).getRegex(),Xf=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,Dh={_backpedal:Gn,anyPunctuation:Jz,autolink:Qz,blockSkip:Hz,br:wb,code:Nz,del:Gn,delLDelim:Gn,delRDelim:Gn,emStrongLDelim:Vz,emStrongRDelimAst:Gz,emStrongRDelimUnd:qz,escape:Mz,link:nO,nolink:xb,punctuation:Fz,reflink:Eb,reflinkSearch:rO,tag:tO,text:Uz,url:Gn},iO={...Dh,link:J(/^!?\[(label)\]\((.*?)\)/).replace("label",Ta).getRegex(),reflink:J(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",Ta).getRegex()},Au={...Dh,emStrongRDelimAst:jz,emStrongLDelim:Bz,delLDelim:Yz,delRDelim:Kz,url:J(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol",Xf).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:J(/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace("protocol",Xf).getRegex()},sO={...Au,br:J(wb).replace("{2,}","*").getRegex(),text:J(Au.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},Go={normal:Ph,gfm:zz,pedantic:Oz},Xi={normal:Dh,gfm:Au,breaks:sO,pedantic:iO},oO={"&":"&","<":"<",">":">",'"':""","'":"'"},Kf=n=>oO[n];function $t(n,e){if(e){if(Ue.escapeTest.test(n))return n.replace(Ue.escapeReplace,Kf)}else if(Ue.escapeTestNoEncode.test(n))return n.replace(Ue.escapeReplaceNoEncode,Kf);return n}function Jf(n){try{n=encodeURI(n).replace(Ue.percentDecode,"%")}catch{return null}return n}function Qf(n,e){var s;let t=n.replace(Ue.findPipe,(o,a,c)=>{let u=!1,h=a;for(;--h>=0&&c[h]==="\\";)u=!u;return u?"|":" |"}),r=t.split(Ue.splitPipe),i=0;if(r[0].trim()||r.shift(),r.length>0&&!((s=r.at(-1))!=null&&s.trim())&&r.pop(),e)if(r.length>e)r.splice(e);else for(;r.length<e;)r.push("");for(;i<r.length;i++)r[i]=r[i].trim().replace(Ue.slashPipe,"|");return r}function Ki(n,e,t){let r=n.length;if(r===0)return"";let i=0;for(;i<r&&n.charAt(r-i-1)===e;)i++;return n.slice(0,r-i)}function aO(n,e){if(n.indexOf(e[1])===-1)return-1;let t=0;for(let r=0;r<n.length;r++)if(n[r]==="\\")r++;else if(n[r]===e[0])t++;else if(n[r]===e[1]&&(t--,t<0))return r;return t>0?-2:-1}function lO(n,e=0){let t=e,r="";for(let i of n)if(i===" "){let s=4-t%4;r+=" ".repeat(s),t+=s}else r+=i,t++;return r}function eg(n,e,t,r,i){let s=e.href,o=e.title||null,a=n[1].replace(i.other.outputLinkReplace,"$1");r.state.inLink=!0;let c={type:n[0].charAt(0)==="!"?"image":"link",raw:t,href:s,title:o,text:a,tokens:r.inlineTokens(a)};return r.state.inLink=!1,c}function cO(n,e,t){let r=n.match(t.other.indentCodeCompensation);if(r===null)return e;let i=r[1];return e.split(`
|
|
414
|
+
`).map(s=>{let o=s.match(t.other.beginningSpace);if(o===null)return s;let[a]=o;return a.length>=i.length?s.slice(i.length):s}).join(`
|
|
415
|
+
`)}var Ca=class{constructor(n){b(this,"options");b(this,"rules");b(this,"lexer");this.options=n||Ir}space(n){let e=this.rules.block.newline.exec(n);if(e&&e[0].length>0)return{type:"space",raw:e[0]}}code(n){let e=this.rules.block.code.exec(n);if(e){let t=e[0].replace(this.rules.other.codeRemoveIndent,"");return{type:"code",raw:e[0],codeBlockStyle:"indented",text:this.options.pedantic?t:Ki(t,`
|
|
416
|
+
`)}}}fences(n){let e=this.rules.block.fences.exec(n);if(e){let t=e[0],r=cO(t,e[3]||"",this.rules);return{type:"code",raw:t,lang:e[2]?e[2].trim().replace(this.rules.inline.anyPunctuation,"$1"):e[2],text:r}}}heading(n){let e=this.rules.block.heading.exec(n);if(e){let t=e[2].trim();if(this.rules.other.endingHash.test(t)){let r=Ki(t,"#");(this.options.pedantic||!r||this.rules.other.endingSpaceChar.test(r))&&(t=r.trim())}return{type:"heading",raw:e[0],depth:e[1].length,text:t,tokens:this.lexer.inline(t)}}}hr(n){let e=this.rules.block.hr.exec(n);if(e)return{type:"hr",raw:Ki(e[0],`
|
|
417
|
+
`)}}blockquote(n){let e=this.rules.block.blockquote.exec(n);if(e){let t=Ki(e[0],`
|
|
418
|
+
`).split(`
|
|
419
|
+
`),r="",i="",s=[];for(;t.length>0;){let o=!1,a=[],c;for(c=0;c<t.length;c++)if(this.rules.other.blockquoteStart.test(t[c]))a.push(t[c]),o=!0;else if(!o)a.push(t[c]);else break;t=t.slice(c);let u=a.join(`
|
|
420
|
+
`),h=u.replace(this.rules.other.blockquoteSetextReplace,`
|
|
421
|
+
$1`).replace(this.rules.other.blockquoteSetextReplace2,"");r=r?`${r}
|
|
422
|
+
${u}`:u,i=i?`${i}
|
|
423
|
+
${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,t.length===0)break;let v=s.at(-1);if((v==null?void 0:v.type)==="code")break;if((v==null?void 0:v.type)==="blockquote"){let m=v,E=m.raw+`
|
|
424
|
+
`+t.join(`
|
|
425
|
+
`),k=this.blockquote(E);s[s.length-1]=k,r=r.substring(0,r.length-m.raw.length)+k.raw,i=i.substring(0,i.length-m.text.length)+k.text;break}else if((v==null?void 0:v.type)==="list"){let m=v,E=m.raw+`
|
|
426
|
+
`+t.join(`
|
|
427
|
+
`),k=this.list(E);s[s.length-1]=k,r=r.substring(0,r.length-v.raw.length)+k.raw,i=i.substring(0,i.length-m.raw.length)+k.raw,t=E.substring(s.at(-1).raw.length).split(`
|
|
428
|
+
`);continue}}return{type:"blockquote",raw:r,tokens:s,text:i}}}list(n){var t,r;let e=this.rules.block.list.exec(n);if(e){let i=e[1].trim(),s=i.length>1,o={type:"list",raw:"",ordered:s,start:s?+i.slice(0,-1):"",loose:!1,items:[]};i=s?`\\d{1,9}\\${i.slice(-1)}`:`\\${i}`,this.options.pedantic&&(i=s?i:"[*+-]");let a=this.rules.other.listItemRegex(i),c=!1;for(;n;){let h=!1,p="",v="";if(!(e=a.exec(n))||this.rules.block.hr.test(n))break;p=e[0],n=n.substring(p.length);let m=lO(e[2].split(`
|
|
429
|
+
`,1)[0],e[1].length),E=n.split(`
|
|
430
|
+
`,1)[0],k=!m.trim(),T=0;if(this.options.pedantic?(T=2,v=m.trimStart()):k?T=e[1].length+1:(T=m.search(this.rules.other.nonSpaceChar),T=T>4?1:T,v=m.slice(T),T+=e[1].length),k&&this.rules.other.blankLine.test(E)&&(p+=E+`
|
|
431
|
+
`,n=n.substring(E.length+1),h=!0),!h){let O=this.rules.other.nextBulletRegex(T),P=this.rules.other.hrRegex(T),V=this.rules.other.fencesBeginRegex(T),F=this.rules.other.headingBeginRegex(T),B=this.rules.other.htmlBeginRegex(T),U=this.rules.other.blockquoteBeginRegex(T);for(;n;){let Q=n.split(`
|
|
432
|
+
`,1)[0],j;if(E=Q,this.options.pedantic?(E=E.replace(this.rules.other.listReplaceNesting," "),j=E):j=E.replace(this.rules.other.tabCharGlobal," "),V.test(E)||F.test(E)||B.test(E)||U.test(E)||O.test(E)||P.test(E))break;if(j.search(this.rules.other.nonSpaceChar)>=T||!E.trim())v+=`
|
|
433
|
+
`+j.slice(T);else{if(k||m.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4||V.test(m)||F.test(m)||P.test(m))break;v+=`
|
|
434
|
+
`+E}k=!E.trim(),p+=Q+`
|
|
435
|
+
`,n=n.substring(Q.length+1),m=j.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,""),((t=h.tokens[0])==null?void 0:t.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(m=>m.type==="space"),v=p.length>0&&p.some(m=>this.rules.other.anyLine.test(m.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 e=this.rules.block.html.exec(n);if(e)return{type:"html",block:!0,raw:e[0],pre:e[1]==="pre"||e[1]==="script"||e[1]==="style",text:e[0]}}def(n){let e=this.rules.block.def.exec(n);if(e){let t=e[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal," "),r=e[2]?e[2].replace(this.rules.other.hrefBrackets,"$1").replace(this.rules.inline.anyPunctuation,"$1"):"",i=e[3]?e[3].substring(1,e[3].length-1).replace(this.rules.inline.anyPunctuation,"$1"):e[3];return{type:"def",tag:t,raw:e[0],href:r,title:i}}}table(n){var o;let e=this.rules.block.table.exec(n);if(!e||!this.rules.other.tableDelimiter.test(e[2]))return;let t=Qf(e[1]),r=e[2].replace(this.rules.other.tableAlignChars,"").split("|"),i=(o=e[3])!=null&&o.trim()?e[3].replace(this.rules.other.tableRowBlankLine,"").split(`
|
|
436
|
+
`):[],s={type:"table",raw:e[0],header:[],align:[],rows:[]};if(t.length===r.length){for(let a of r)this.rules.other.tableAlignRight.test(a)?s.align.push("right"):this.rules.other.tableAlignCenter.test(a)?s.align.push("center"):this.rules.other.tableAlignLeft.test(a)?s.align.push("left"):s.align.push(null);for(let a=0;a<t.length;a++)s.header.push({text:t[a],tokens:this.lexer.inline(t[a]),header:!0,align:s.align[a]});for(let a of i)s.rows.push(Qf(a,s.header.length).map((c,u)=>({text:c,tokens:this.lexer.inline(c),header:!1,align:s.align[u]})));return s}}lheading(n){let e=this.rules.block.lheading.exec(n);if(e){let t=e[1].trim();return{type:"heading",raw:e[0],depth:e[2].charAt(0)==="="?1:2,text:t,tokens:this.lexer.inline(t)}}}paragraph(n){let e=this.rules.block.paragraph.exec(n);if(e){let t=e[1].charAt(e[1].length-1)===`
|
|
437
|
+
`?e[1].slice(0,-1):e[1];return{type:"paragraph",raw:e[0],text:t,tokens:this.lexer.inline(t)}}}text(n){let e=this.rules.block.text.exec(n);if(e)return{type:"text",raw:e[0],text:e[0],tokens:this.lexer.inline(e[0])}}escape(n){let e=this.rules.inline.escape.exec(n);if(e)return{type:"escape",raw:e[0],text:e[1]}}tag(n){let e=this.rules.inline.tag.exec(n);if(e)return!this.lexer.state.inLink&&this.rules.other.startATag.test(e[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&this.rules.other.endATag.test(e[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&this.rules.other.startPreScriptTag.test(e[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&this.rules.other.endPreScriptTag.test(e[0])&&(this.lexer.state.inRawBlock=!1),{type:"html",raw:e[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:e[0]}}link(n){let e=this.rules.inline.link.exec(n);if(e){let t=e[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(t)){if(!this.rules.other.endAngleBracket.test(t))return;let s=Ki(t.slice(0,-1),"\\");if((t.length-s.length)%2===0)return}else{let s=aO(e[2],"()");if(s===-2)return;if(s>-1){let o=(e[0].indexOf("!")===0?5:4)+e[1].length+s;e[2]=e[2].substring(0,s),e[0]=e[0].substring(0,o).trim(),e[3]=""}}let r=e[2],i="";if(this.options.pedantic){let s=this.rules.other.pedanticHrefTitle.exec(r);s&&(r=s[1],i=s[3])}else i=e[3]?e[3].slice(1,-1):"";return r=r.trim(),this.rules.other.startAngleBracket.test(r)&&(this.options.pedantic&&!this.rules.other.endAngleBracket.test(t)?r=r.slice(1):r=r.slice(1,-1)),eg(e,{href:r&&r.replace(this.rules.inline.anyPunctuation,"$1"),title:i&&i.replace(this.rules.inline.anyPunctuation,"$1")},e[0],this.lexer,this.rules)}}reflink(n,e){let t;if((t=this.rules.inline.reflink.exec(n))||(t=this.rules.inline.nolink.exec(n))){let r=(t[2]||t[1]).replace(this.rules.other.multipleSpaceGlobal," "),i=e[r.toLowerCase()];if(!i){let s=t[0].charAt(0);return{type:"text",raw:s,text:s}}return eg(t,i,t[0],this.lexer,this.rules)}}emStrong(n,e,t=""){let r=this.rules.inline.emStrongLDelim.exec(n);if(!(!r||!r[1]&&!r[2]&&!r[3]&&!r[4]||r[4]&&t.match(this.rules.other.unicodeAlphaNumeric))&&(!(r[1]||r[3])||!t||this.rules.inline.punctuation.exec(t))){let i=[...r[0]].length-1,s,o,a=i,c=0,u=r[0][0]==="*"?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(u.lastIndex=0,e=e.slice(-1*n.length+i);(r=u.exec(e))!=null;){if(s=r[1]||r[2]||r[3]||r[4]||r[5]||r[6],!s)continue;if(o=[...s].length,r[3]||r[4]){a+=o;continue}else if((r[5]||r[6])&&i%3&&!((i+o)%3)){c+=o;continue}if(a-=o,a>0)continue;o=Math.min(o,o+a+c);let h=[...r[0]][0].length,p=n.slice(0,i+r.index+h+o);if(Math.min(i,o)%2){let m=p.slice(1,-1);return{type:"em",raw:p,text:m,tokens:this.lexer.inlineTokens(m)}}let v=p.slice(2,-2);return{type:"strong",raw:p,text:v,tokens:this.lexer.inlineTokens(v)}}}}codespan(n){let e=this.rules.inline.code.exec(n);if(e){let t=e[2].replace(this.rules.other.newLineCharGlobal," "),r=this.rules.other.nonSpaceChar.test(t),i=this.rules.other.startingSpaceChar.test(t)&&this.rules.other.endingSpaceChar.test(t);return r&&i&&(t=t.substring(1,t.length-1)),{type:"codespan",raw:e[0],text:t}}}br(n){let e=this.rules.inline.br.exec(n);if(e)return{type:"br",raw:e[0]}}del(n,e,t=""){let r=this.rules.inline.delLDelim.exec(n);if(r&&(!r[1]||!t||this.rules.inline.punctuation.exec(t))){let i=[...r[0]].length-1,s,o,a=i,c=this.rules.inline.delRDelim;for(c.lastIndex=0,e=e.slice(-1*n.length+i);(r=c.exec(e))!=null;){if(s=r[1]||r[2]||r[3]||r[4]||r[5]||r[6],!s||(o=[...s].length,o!==i))continue;if(r[3]||r[4]){a+=o;continue}if(a-=o,a>0)continue;o=Math.min(o,o+a);let u=[...r[0]][0].length,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 e=this.rules.inline.autolink.exec(n);if(e){let t,r;return e[2]==="@"?(t=e[1],r="mailto:"+t):(t=e[1],r=t),{type:"link",raw:e[0],text:t,href:r,tokens:[{type:"text",raw:t,text:t}]}}}url(n){var t;let e;if(e=this.rules.inline.url.exec(n)){let r,i;if(e[2]==="@")r=e[0],i="mailto:"+r;else{let s;do s=e[0],e[0]=((t=this.rules.inline._backpedal.exec(e[0]))==null?void 0:t[0])??"";while(s!==e[0]);r=e[0],e[1]==="www."?i="http://"+e[0]:i=e[0]}return{type:"link",raw:e[0],text:r,href:i,tokens:[{type:"text",raw:r,text:r}]}}}inlineText(n){let e=this.rules.inline.text.exec(n);if(e){let t=this.lexer.state.inRawBlock;return{type:"text",raw:e[0],text:e[0],escaped:t}}}},yt=class $u{constructor(e){b(this,"tokens");b(this,"options");b(this,"state");b(this,"inlineQueue");b(this,"tokenizer");this.tokens=[],this.tokens.links=Object.create(null),this.options=e||Ir,this.options.tokenizer=this.options.tokenizer||new Ca,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,top:!0};let t={other:Ue,block:Go.normal,inline:Xi.normal};this.options.pedantic?(t.block=Go.pedantic,t.inline=Xi.pedantic):this.options.gfm&&(t.block=Go.gfm,this.options.breaks?t.inline=Xi.breaks:t.inline=Xi.gfm),this.tokenizer.rules=t}static get rules(){return{block:Go,inline:Xi}}static lex(e,t){return new $u(t).lex(e)}static lexInline(e,t){return new $u(t).inlineTokens(e)}lex(e){e=e.replace(Ue.carriageReturn,`
|
|
438
|
+
`),this.blockTokens(e,this.tokens);for(let t=0;t<this.inlineQueue.length;t++){let r=this.inlineQueue[t];this.inlineTokens(r.src,r.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(e,t=[],r=!1){var i,s,o;for(this.tokenizer.lexer=this,this.options.pedantic&&(e=e.replace(Ue.tabCharGlobal," ").replace(Ue.spaceLine,""));e;){let a;if((s=(i=this.options.extensions)==null?void 0:i.block)!=null&&s.some(u=>(a=u.call({lexer:this},e,t))?(e=e.substring(a.raw.length),t.push(a),!0):!1))continue;if(a=this.tokenizer.space(e)){e=e.substring(a.raw.length);let u=t.at(-1);a.raw.length===1&&u!==void 0?u.raw+=`
|
|
439
|
+
`:t.push(a);continue}if(a=this.tokenizer.code(e)){e=e.substring(a.raw.length);let u=t.at(-1);(u==null?void 0:u.type)==="paragraph"||(u==null?void 0:u.type)==="text"?(u.raw+=(u.raw.endsWith(`
|
|
440
|
+
`)?"":`
|
|
441
|
+
`)+a.raw,u.text+=`
|
|
442
|
+
`+a.text,this.inlineQueue.at(-1).src=u.text):t.push(a);continue}if(a=this.tokenizer.fences(e)){e=e.substring(a.raw.length),t.push(a);continue}if(a=this.tokenizer.heading(e)){e=e.substring(a.raw.length),t.push(a);continue}if(a=this.tokenizer.hr(e)){e=e.substring(a.raw.length),t.push(a);continue}if(a=this.tokenizer.blockquote(e)){e=e.substring(a.raw.length),t.push(a);continue}if(a=this.tokenizer.list(e)){e=e.substring(a.raw.length),t.push(a);continue}if(a=this.tokenizer.html(e)){e=e.substring(a.raw.length),t.push(a);continue}if(a=this.tokenizer.def(e)){e=e.substring(a.raw.length);let u=t.at(-1);(u==null?void 0:u.type)==="paragraph"||(u==null?void 0:u.type)==="text"?(u.raw+=(u.raw.endsWith(`
|
|
443
|
+
`)?"":`
|
|
444
|
+
`)+a.raw,u.text+=`
|
|
445
|
+
`+a.raw,this.inlineQueue.at(-1).src=u.text):this.tokens.links[a.tag]||(this.tokens.links[a.tag]={href:a.href,title:a.title},t.push(a));continue}if(a=this.tokenizer.table(e)){e=e.substring(a.raw.length),t.push(a);continue}if(a=this.tokenizer.lheading(e)){e=e.substring(a.raw.length),t.push(a);continue}let c=e;if((o=this.options.extensions)!=null&&o.startBlock){let u=1/0,h=e.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=e.substring(0,u+1))}if(this.state.top&&(a=this.tokenizer.paragraph(c))){let u=t.at(-1);r&&(u==null?void 0:u.type)==="paragraph"?(u.raw+=(u.raw.endsWith(`
|
|
446
|
+
`)?"":`
|
|
447
|
+
`)+a.raw,u.text+=`
|
|
448
|
+
`+a.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=u.text):t.push(a),r=c.length!==e.length,e=e.substring(a.raw.length);continue}if(a=this.tokenizer.text(e)){e=e.substring(a.raw.length);let u=t.at(-1);(u==null?void 0:u.type)==="text"?(u.raw+=(u.raw.endsWith(`
|
|
449
|
+
`)?"":`
|
|
450
|
+
`)+a.raw,u.text+=`
|
|
451
|
+
`+a.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=u.text):t.push(a);continue}if(e){let u="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent){console.error(u);break}else throw new Error(u)}}return this.state.top=!0,t}inline(e,t=[]){return this.inlineQueue.push({src:e,tokens:t}),t}inlineTokens(e,t=[]){var c,u,h,p,v;this.tokenizer.lexer=this;let r=e,i=null;if(this.tokens.links){let m=Object.keys(this.tokens.links);if(m.length>0)for(;(i=this.tokenizer.rules.inline.reflinkSearch.exec(r))!=null;)m.includes(i[0].slice(i[0].lastIndexOf("[")+1,-1))&&(r=r.slice(0,i.index)+"["+"a".repeat(i[0].length-2)+"]"+r.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;(i=this.tokenizer.rules.inline.anyPunctuation.exec(r))!=null;)r=r.slice(0,i.index)+"++"+r.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);let s;for(;(i=this.tokenizer.rules.inline.blockSkip.exec(r))!=null;)s=i[2]?i[2].length:0,r=r.slice(0,i.index+s)+"["+"a".repeat(i[0].length-s-2)+"]"+r.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);r=((u=(c=this.options.hooks)==null?void 0:c.emStrongMask)==null?void 0:u.call({lexer:this},r))??r;let o=!1,a="";for(;e;){o||(a=""),o=!1;let m;if((p=(h=this.options.extensions)==null?void 0:h.inline)!=null&&p.some(k=>(m=k.call({lexer:this},e,t))?(e=e.substring(m.raw.length),t.push(m),!0):!1))continue;if(m=this.tokenizer.escape(e)){e=e.substring(m.raw.length),t.push(m);continue}if(m=this.tokenizer.tag(e)){e=e.substring(m.raw.length),t.push(m);continue}if(m=this.tokenizer.link(e)){e=e.substring(m.raw.length),t.push(m);continue}if(m=this.tokenizer.reflink(e,this.tokens.links)){e=e.substring(m.raw.length);let k=t.at(-1);m.type==="text"&&(k==null?void 0:k.type)==="text"?(k.raw+=m.raw,k.text+=m.text):t.push(m);continue}if(m=this.tokenizer.emStrong(e,r,a)){e=e.substring(m.raw.length),t.push(m);continue}if(m=this.tokenizer.codespan(e)){e=e.substring(m.raw.length),t.push(m);continue}if(m=this.tokenizer.br(e)){e=e.substring(m.raw.length),t.push(m);continue}if(m=this.tokenizer.del(e,r,a)){e=e.substring(m.raw.length),t.push(m);continue}if(m=this.tokenizer.autolink(e)){e=e.substring(m.raw.length),t.push(m);continue}if(!this.state.inLink&&(m=this.tokenizer.url(e))){e=e.substring(m.raw.length),t.push(m);continue}let E=e;if((v=this.options.extensions)!=null&&v.startInline){let k=1/0,T=e.slice(1),O;this.options.extensions.startInline.forEach(P=>{O=P.call({lexer:this},T),typeof O=="number"&&O>=0&&(k=Math.min(k,O))}),k<1/0&&k>=0&&(E=e.substring(0,k+1))}if(m=this.tokenizer.inlineText(E)){e=e.substring(m.raw.length),m.raw.slice(-1)!=="_"&&(a=m.raw.slice(-1)),o=!0;let k=t.at(-1);(k==null?void 0:k.type)==="text"?(k.raw+=m.raw,k.text+=m.text):t.push(m);continue}if(e){let k="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent){console.error(k);break}else throw new Error(k)}}return t}},Pa=class{constructor(n){b(this,"options");b(this,"parser");this.options=n||Ir}space(n){return""}code({text:n,lang:e,escaped:t}){var s;let r=(s=(e||"").match(Ue.notSpaceStart))==null?void 0:s[0],i=n.replace(Ue.endingNewline,"")+`
|
|
452
|
+
`;return r?'<pre><code class="language-'+$t(r)+'">'+(t?i:$t(i,!0))+`</code></pre>
|
|
453
|
+
`:"<pre><code>"+(t?i:$t(i,!0))+`</code></pre>
|
|
454
|
+
`}blockquote({tokens:n}){return`<blockquote>
|
|
455
|
+
${this.parser.parse(n)}</blockquote>
|
|
456
|
+
`}html({text:n}){return n}def(n){return""}heading({tokens:n,depth:e}){return`<h${e}>${this.parser.parseInline(n)}</h${e}>
|
|
457
|
+
`}hr(n){return`<hr>
|
|
458
|
+
`}list(n){let e=n.ordered,t=n.start,r="";for(let o=0;o<n.items.length;o++){let a=n.items[o];r+=this.listitem(a)}let i=e?"ol":"ul",s=e&&t!==1?' start="'+t+'"':"";return"<"+i+s+`>
|
|
459
|
+
`+r+"</"+i+`>
|
|
460
|
+
`}listitem(n){return`<li>${this.parser.parse(n.tokens)}</li>
|
|
461
|
+
`}checkbox({checked:n}){return"<input "+(n?'checked="" ':"")+'disabled="" type="checkbox"> '}paragraph({tokens:n}){return`<p>${this.parser.parseInline(n)}</p>
|
|
462
|
+
`}table(n){let e="",t="";for(let i=0;i<n.header.length;i++)t+=this.tablecell(n.header[i]);e+=this.tablerow({text:t});let r="";for(let i=0;i<n.rows.length;i++){let s=n.rows[i];t="";for(let o=0;o<s.length;o++)t+=this.tablecell(s[o]);r+=this.tablerow({text:t})}return r&&(r=`<tbody>${r}</tbody>`),`<table>
|
|
463
|
+
<thead>
|
|
464
|
+
`+e+`</thead>
|
|
465
|
+
`+r+`</table>
|
|
466
|
+
`}tablerow({text:n}){return`<tr>
|
|
467
|
+
${n}</tr>
|
|
468
|
+
`}tablecell(n){let e=this.parser.parseInline(n.tokens),t=n.header?"th":"td";return(n.align?`<${t} align="${n.align}">`:`<${t}>`)+e+`</${t}>
|
|
469
|
+
`}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>${$t(n,!0)}</code>`}br(n){return"<br>"}del({tokens:n}){return`<del>${this.parser.parseInline(n)}</del>`}link({href:n,title:e,tokens:t}){let r=this.parser.parseInline(t),i=Jf(n);if(i===null)return r;n=i;let s='<a href="'+n+'"';return e&&(s+=' title="'+$t(e)+'"'),s+=">"+r+"</a>",s}image({href:n,title:e,text:t,tokens:r}){r&&(t=this.parser.parseInline(r,this.parser.textRenderer));let i=Jf(n);if(i===null)return $t(t);n=i;let s=`<img src="${n}" alt="${$t(t)}"`;return e&&(s+=` title="${$t(e)}"`),s+=">",s}text(n){return"tokens"in n&&n.tokens?this.parser.parseInline(n.tokens):"escaped"in n&&n.escaped?n.text:$t(n.text)}},Lh=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}},bt=class Iu{constructor(e){b(this,"options");b(this,"renderer");b(this,"textRenderer");this.options=e||Ir,this.options.renderer=this.options.renderer||new Pa,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new Lh}static parse(e,t){return new Iu(t).parse(e)}static parseInline(e,t){return new Iu(t).parseInline(e)}parse(e){var r,i;this.renderer.parser=this;let t="";for(let s=0;s<e.length;s++){let o=e[s];if((i=(r=this.options.extensions)==null?void 0:r.renderers)!=null&&i[o.type]){let c=o,u=this.options.extensions.renderers[c.type].call({parser:this},c);if(u!==!1||!["space","hr","heading","code","table","blockquote","list","html","def","paragraph","text"].includes(c.type)){t+=u||"";continue}}let a=o;switch(a.type){case"space":{t+=this.renderer.space(a);break}case"hr":{t+=this.renderer.hr(a);break}case"heading":{t+=this.renderer.heading(a);break}case"code":{t+=this.renderer.code(a);break}case"table":{t+=this.renderer.table(a);break}case"blockquote":{t+=this.renderer.blockquote(a);break}case"list":{t+=this.renderer.list(a);break}case"checkbox":{t+=this.renderer.checkbox(a);break}case"html":{t+=this.renderer.html(a);break}case"def":{t+=this.renderer.def(a);break}case"paragraph":{t+=this.renderer.paragraph(a);break}case"text":{t+=this.renderer.text(a);break}default:{let c='Token with "'+a.type+'" type was not found.';if(this.options.silent)return console.error(c),"";throw new Error(c)}}}return t}parseInline(e,t=this.renderer){var i,s;this.renderer.parser=this;let r="";for(let o=0;o<e.length;o++){let a=e[o];if((s=(i=this.options.extensions)==null?void 0:i.renderers)!=null&&s[a.type]){let u=this.options.extensions.renderers[a.type].call({parser:this},a);if(u!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(a.type)){r+=u||"";continue}}let c=a;switch(c.type){case"escape":{r+=t.text(c);break}case"html":{r+=t.html(c);break}case"link":{r+=t.link(c);break}case"image":{r+=t.image(c);break}case"checkbox":{r+=t.checkbox(c);break}case"strong":{r+=t.strong(c);break}case"em":{r+=t.em(c);break}case"codespan":{r+=t.codespan(c);break}case"br":{r+=t.br(c);break}case"del":{r+=t.del(c);break}case"text":{r+=t.text(c);break}default:{let u='Token with "'+c.type+'" type was not found.';if(this.options.silent)return console.error(u),"";throw new Error(u)}}}return r}},jo,ss=(jo=class{constructor(n){b(this,"options");b(this,"block");this.options=n||Ir}preprocess(n){return n}postprocess(n){return n}processAllTokens(n){return n}emStrongMask(n){return n}provideLexer(){return this.block?yt.lex:yt.lexInline}provideParser(){return this.block?bt.parse:bt.parseInline}},b(jo,"passThroughHooks",new Set(["preprocess","postprocess","processAllTokens","emStrongMask"])),b(jo,"passThroughHooksRespectAsync",new Set(["preprocess","postprocess","processAllTokens"])),jo),uO=class{constructor(...n){b(this,"defaults",Ah());b(this,"options",this.setOptions);b(this,"parse",this.parseMarkdown(!0));b(this,"parseInline",this.parseMarkdown(!1));b(this,"Parser",bt);b(this,"Renderer",Pa);b(this,"TextRenderer",Lh);b(this,"Lexer",yt);b(this,"Tokenizer",Ca);b(this,"Hooks",ss);this.use(...n)}walkTokens(n,e){var r,i;let t=[];for(let s of n)switch(t=t.concat(e.call(this,s)),s.type){case"table":{let o=s;for(let a of o.header)t=t.concat(this.walkTokens(a.tokens,e));for(let a of o.rows)for(let c of a)t=t.concat(this.walkTokens(c.tokens,e));break}case"list":{let o=s;t=t.concat(this.walkTokens(o.items,e));break}default:{let o=s;(i=(r=this.defaults.extensions)==null?void 0:r.childTokens)!=null&&i[o.type]?this.defaults.extensions.childTokens[o.type].forEach(a=>{let c=o[a].flat(1/0);t=t.concat(this.walkTokens(c,e))}):o.tokens&&(t=t.concat(this.walkTokens(o.tokens,e)))}}return t}use(...n){let e=this.defaults.extensions||{renderers:{},childTokens:{}};return n.forEach(t=>{let r={...t};if(r.async=this.defaults.async||r.async||!1,t.extensions&&(t.extensions.forEach(i=>{if(!i.name)throw new Error("extension name required");if("renderer"in i){let s=e.renderers[i.name];s?e.renderers[i.name]=function(...o){let a=i.renderer.apply(this,o);return a===!1&&(a=s.apply(this,o)),a}:e.renderers[i.name]=i.renderer}if("tokenizer"in i){if(!i.level||i.level!=="block"&&i.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");let s=e[i.level];s?s.unshift(i.tokenizer):e[i.level]=[i.tokenizer],i.start&&(i.level==="block"?e.startBlock?e.startBlock.push(i.start):e.startBlock=[i.start]:i.level==="inline"&&(e.startInline?e.startInline.push(i.start):e.startInline=[i.start]))}"childTokens"in i&&i.childTokens&&(e.childTokens[i.name]=i.childTokens)}),r.extensions=e),t.renderer){let i=this.defaults.renderer||new Pa(this.defaults);for(let s in t.renderer){if(!(s in i))throw new Error(`renderer '${s}' does not exist`);if(["options","parser"].includes(s))continue;let o=s,a=t.renderer[o],c=i[o];i[o]=(...u)=>{let h=a.apply(i,u);return h===!1&&(h=c.apply(i,u)),h||""}}r.renderer=i}if(t.tokenizer){let i=this.defaults.tokenizer||new Ca(this.defaults);for(let s in t.tokenizer){if(!(s in i))throw new Error(`tokenizer '${s}' does not exist`);if(["options","rules","lexer"].includes(s))continue;let o=s,a=t.tokenizer[o],c=i[o];i[o]=(...u)=>{let h=a.apply(i,u);return h===!1&&(h=c.apply(i,u)),h}}r.tokenizer=i}if(t.hooks){let i=this.defaults.hooks||new ss;for(let s in t.hooks){if(!(s in i))throw new Error(`hook '${s}' does not exist`);if(["options","block"].includes(s))continue;let o=s,a=t.hooks[o],c=i[o];ss.passThroughHooks.has(s)?i[o]=u=>{if(this.defaults.async&&ss.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(t.walkTokens){let i=this.defaults.walkTokens,s=t.walkTokens;r.walkTokens=function(o){let a=[];return a.push(s.call(this,o)),i&&(a=a.concat(i.call(this,o))),a}}this.defaults={...this.defaults,...r}}),this}setOptions(n){return this.defaults={...this.defaults,...n},this}lexer(n,e){return yt.lex(n,e??this.defaults)}parser(n,e){return bt.parse(n,e??this.defaults)}parseMarkdown(n){return(e,t)=>{let r={...t},i={...this.defaults,...r},s=this.onError(!!i.silent,!!i.async);if(this.defaults.async===!0&&r.async===!1)return s(new Error("marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise."));if(typeof e>"u"||e===null)return s(new Error("marked(): input parameter is undefined or null"));if(typeof e!="string")return s(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(e)+", string expected"));if(i.hooks&&(i.hooks.options=i,i.hooks.block=n),i.async)return(async()=>{let o=i.hooks?await i.hooks.preprocess(e):e,a=await(i.hooks?await i.hooks.provideLexer():n?yt.lex:yt.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?bt.parse:bt.parseInline)(c,i);return i.hooks?await i.hooks.postprocess(u):u})().catch(s);try{i.hooks&&(e=i.hooks.preprocess(e));let o=(i.hooks?i.hooks.provideLexer():n?yt.lex:yt.lexInline)(e,i);i.hooks&&(o=i.hooks.processAllTokens(o)),i.walkTokens&&this.walkTokens(o,i.walkTokens);let a=(i.hooks?i.hooks.provideParser():n?bt.parse:bt.parseInline)(o,i);return i.hooks&&(a=i.hooks.postprocess(a)),a}catch(o){return s(o)}}}onError(n,e){return t=>{if(t.message+=`
|
|
470
|
+
Please report this to https://github.com/markedjs/marked.`,n){let r="<p>An error occurred:</p><pre>"+$t(t.message+"",!0)+"</pre>";return e?Promise.resolve(r):r}if(e)return Promise.reject(t);throw t}}},kr=new uO;function se(n,e){return kr.parse(n,e)}se.options=se.setOptions=function(n){return kr.setOptions(n),se.defaults=kr.defaults,mb(se.defaults),se};se.getDefaults=Ah;se.defaults=Ir;se.use=function(...n){return kr.use(...n),se.defaults=kr.defaults,mb(se.defaults),se};se.walkTokens=function(n,e){return kr.walkTokens(n,e)};se.parseInline=kr.parseInline;se.Parser=bt;se.parser=bt.parse;se.Renderer=Pa;se.TextRenderer=Lh;se.Lexer=yt;se.lexer=yt.lex;se.Tokenizer=Ca;se.Hooks=ss;se.parse=se;se.options;se.setOptions;se.use;se.walkTokens;se.parseInline;bt.parse;yt.lex;gb.addHook("afterSanitizeAttributes",n=>{n.tagName==="A"&&(n.setAttribute("target","_blank"),n.setAttribute("rel","noopener noreferrer"))});function hO(n){const e=se.parse(n,{async:!1});return gb.sanitize(e,{USE_PROFILES:{html:!0}})}const dO=8,tg=new WeakMap;function pO(n){const e=tg.get(n);if(e&&e.text===n.text)return e.html;const t=hO(n.text);return tg.set(n,{text:n.text,html:t}),t}function fO(n){return n.replace(/_/g," ")}function gO(n){return N`
|
|
471
|
+
<div class="tool-call-header">
|
|
472
|
+
<span class="tool-call-title">${n.title}</span>
|
|
473
|
+
<span class="tool-call-meta">${n.toolKind} · ${fO(n.status)}</span>
|
|
474
|
+
</div>
|
|
475
|
+
${n.text?N`<pre class="tool-call-text">${n.text}</pre>`:null}
|
|
476
|
+
`}function ng(n){for(let e=n.length-1;e>=0;e-=1){const t=n[e];if(t&&t.kind==="user")return t.id}return null}var Qt,vr,Xa,Ka,Qs,Tu;class Ab extends ys{constructor(){super(...arguments);w(this,Qs);b(this,"messages",[]);w(this,Qt,!0);w(this,vr,null);w(this,Xa,()=>{const t=l(this,vr);if(!t)return;const i=t.scrollHeight-t.clientHeight-t.scrollTop<=dO;i!==l(this,Qt)&&(x(this,Qt,i),this.toggleAttribute("data-pinned",i))});w(this,Ka,()=>{x(this,Qt,!0),this.toggleAttribute("data-pinned",!0),f(this,Qs,Tu).call(this,!0)})}changed(t){let r=!1;if(t.has("messages")){const i=t.get("messages")??[],s=ng(this.messages);r=s!==null&&s!==ng(i),r&&x(this,Qt,!0)}Fe(this.template(),this),l(this,vr)||x(this,vr,this.querySelector(".history-scroll")),this.toggleAttribute("data-pinned",l(this,Qt)),f(this,Qs,Tu).call(this,r)}template(){return N`
|
|
477
|
+
<div class="history-scroll" @scroll=${l(this,Xa)}>
|
|
478
|
+
${this.messages.map(t=>{const r=t.kind==="assistant"?d2(pO(t)):t.kind==="tool_call"?gO(t):t.text;return N`<div
|
|
479
|
+
class="message message-${t.kind}"
|
|
480
|
+
data-message-id=${t.id}
|
|
481
|
+
>${r}</div>`})}
|
|
482
|
+
</div>
|
|
483
|
+
<button
|
|
484
|
+
type="button"
|
|
485
|
+
class="history-jump"
|
|
486
|
+
aria-label="Jump to latest message"
|
|
487
|
+
@click=${l(this,Ka)}
|
|
488
|
+
>
|
|
489
|
+
${wy({size:16})}
|
|
490
|
+
</button>
|
|
491
|
+
`}}Qt=new WeakMap,vr=new WeakMap,Xa=new WeakMap,Ka=new WeakMap,Qs=new WeakSet,Tu=function(t){requestAnimationFrame(()=>{const r=l(this,vr);r&&(!l(this,Qt)&&!t||(r.scrollTop=r.scrollHeight-r.clientHeight))})},b(Ab,"properties",["messages"]);customElements.define("message-history",Ab);var eo,to,bi,Ja,Qa,ot,da,no,Pu,Ru,ro,io;class Cu extends ys{constructor(){super(...arguments);w(this,ot);b(this,"placeholder","What do you want to do?");b(this,"open",!1);b(this,"messages",[]);w(this,eo,zt.resolve("ServerManager"));w(this,to,zt.resolve("ShortcutService"));w(this,bi,null);b(this,"handleTriggerActivate",()=>{this.open=!0});b(this,"handleKeydown",t=>{var o;if(t.key!=="Enter"||t.shiftKey)return;const r=t.currentTarget,i=r.value.trim();if(t.preventDefault(),!i)return;r.value="",f(this,ot,da).call(this,r);const s=(o=l(this,eo).activeServer)==null?void 0:o.acpClient;s&&s.sendMessage({text:i}).catch(a=>{console.error("ACPClient.sendMessage() failed",a)})});w(this,Ja,t=>{f(this,ot,da).call(this,t.currentTarget)});w(this,Qa,t=>{if(t.target instanceof HTMLTextAreaElement)return;const r=t.currentTarget.querySelector("textarea");r==null||r.focus()});w(this,no,t=>{if(t.shortcut!=="focusCommandInput")return;if(!this.open){this.open=!0;return}const r=this.querySelector("textarea");if(r){if(document.activeElement===r){this.open=!1;return}r.focus()}});w(this,ro,t=>{t.target instanceof Node&&(this.contains(t.target)||(this.open=!1))});w(this,io,t=>{t.key==="Escape"&&(this.open=!1)})}connected(){const t=new DisposableStack;x(this,bi,t);const r=nz(l(this,eo),i=>{this.messages=i});t.defer(()=>r.dispose()),l(this,to).addEventListener("shortcut-triggered",l(this,no)),t.defer(()=>l(this,to).removeEventListener("shortcut-triggered",l(this,no))),this.open&&f(this,ot,Pu).call(this)}disconnected(){var t;(t=l(this,bi))==null||t.dispose(),x(this,bi,null),f(this,ot,Ru).call(this)}changed(t){if(this.open?(this.removeAttribute("material"),this.removeAttribute("tone"),this.removeAttribute("level")):(this.setAttribute("material","paper"),this.setAttribute("tone","dark"),this.setAttribute("level","overlay")),Fe(this.template(),this),t.has("open"))if(this.open){f(this,ot,Pu).call(this);const r=this.querySelector("textarea");r&&(f(this,ot,da).call(this,r),r.focus())}else f(this,ot,Ru).call(this)}template(){return this.open?N`
|
|
492
|
+
${this.messages.length>0?N`
|
|
493
|
+
<div
|
|
494
|
+
class="chat"
|
|
495
|
+
material="paper"
|
|
496
|
+
tone="dark"
|
|
497
|
+
level="overlay"
|
|
498
|
+
>
|
|
499
|
+
<message-history .messages=${this.messages}></message-history>
|
|
500
|
+
</div>
|
|
501
|
+
`:null}
|
|
502
|
+
<div
|
|
503
|
+
class="input"
|
|
504
|
+
material="paper"
|
|
505
|
+
tone="dark"
|
|
506
|
+
level="overlay"
|
|
507
|
+
@click=${l(this,Qa)}
|
|
508
|
+
>
|
|
509
|
+
<textarea
|
|
510
|
+
class="textarea"
|
|
511
|
+
rows="1"
|
|
512
|
+
@keydown=${this.handleKeydown}
|
|
513
|
+
@input=${l(this,Ja)}
|
|
514
|
+
></textarea>
|
|
515
|
+
</div>
|
|
516
|
+
`:N`
|
|
517
|
+
<div
|
|
518
|
+
class="trigger"
|
|
519
|
+
tabindex="0"
|
|
520
|
+
role="button"
|
|
521
|
+
@click=${this.handleTriggerActivate}
|
|
522
|
+
@focus=${this.handleTriggerActivate}
|
|
523
|
+
>
|
|
524
|
+
<span class="label">${this.placeholder}</span>
|
|
525
|
+
<span class="kbd" aria-hidden="true">⌘K</span>
|
|
526
|
+
</div>
|
|
527
|
+
`}}eo=new WeakMap,to=new WeakMap,bi=new WeakMap,Ja=new WeakMap,Qa=new WeakMap,ot=new WeakSet,da=function(t){t.style.height="auto",t.style.height=`${t.scrollHeight}px`},no=new WeakMap,Pu=function(){document.addEventListener("mousedown",l(this,ro)),document.addEventListener("keydown",l(this,io))},Ru=function(){document.removeEventListener("mousedown",l(this,ro)),document.removeEventListener("keydown",l(this,io))},ro=new WeakMap,io=new WeakMap,b(Cu,"properties",["placeholder","open","messages"]),b(Cu,"attributes",{placeholder:{type:String},open:{type:Boolean}});customElements.define("command-panel",Cu);class $b extends Event{constructor(t){super("auth-submit",{bubbles:!0,composed:!0});b(this,"token");this.token=t}}class mO extends HTMLElement{constructor(){super(...arguments);b(this,"_invalid",!1);b(this,"_tokenValue","")}set invalid(t){this._invalid=t,this.render()}get invalid(){return this._invalid}set tokenValue(t){this._tokenValue=t,this.render()}get tokenValue(){return this._tokenValue}connectedCallback(){this.render()}handleInput(t){const r=t.currentTarget;this._tokenValue=r.value}handleSubmit(t){t.preventDefault();const r=this._tokenValue.trim();r&&this.dispatchEvent(new $b(r))}render(){Fe(N`
|
|
528
|
+
<modal-overlay open>
|
|
529
|
+
<section class="auth-modal">
|
|
530
|
+
<form class="auth-form" @submit=${t=>this.handleSubmit(t)}>
|
|
531
|
+
<h2 class="auth-modal-title">Enter access token</h2>
|
|
532
|
+
<p class="auth-modal-copy">This Television server requires a token.</p>
|
|
533
|
+
<label class="settings-field">
|
|
534
|
+
<span>Token</span>
|
|
535
|
+
<input
|
|
536
|
+
class=${this.invalid?"auth-token-input-invalid":""}
|
|
537
|
+
type="password"
|
|
538
|
+
name="token"
|
|
539
|
+
.value=${this.tokenValue}
|
|
540
|
+
@input=${t=>this.handleInput(t)}
|
|
541
|
+
required
|
|
542
|
+
/>
|
|
543
|
+
</label>
|
|
544
|
+
<button type="submit" class="settings-submit-button">Connect</button>
|
|
545
|
+
</form>
|
|
546
|
+
</section>
|
|
547
|
+
</modal-overlay>
|
|
548
|
+
`,this)}}customElements.get("auth-modal")||customElements.define("auth-modal",mO);class vO extends HTMLElement{constructor(){super(...arguments);b(this,"runtimeServerURL",ny());b(this,"electronMode",bh());b(this,"serverManager",zt.resolve("ServerManager"));b(this,"screenManager",zt.resolve("ScreenManager"));b(this,"connectError",null);b(this,"handleServerManagerChange",()=>{this.render()});b(this,"handleActiveScreenChanged",()=>{this.render()})}connectedCallback(){this.serverManager.addEventListener("change",this.handleServerManagerChange),this.screenManager.addEventListener("active-screen-changed",this.handleActiveScreenChanged),this.addEventListener("auth-submit",t=>{var i;const r=t instanceof $b?t.token:t instanceof CustomEvent&&typeof((i=t.detail)==null?void 0:i.token)=="string"?t.detail.token:null;r&&this.handleAuthSubmit(r)}),this.initializeConnection(),this.render()}disconnectedCallback(){this.serverManager.removeEventListener("change",this.handleServerManagerChange),this.screenManager.removeEventListener("active-screen-changed",this.handleActiveScreenChanged)}async initializeConnection(){if(this.electronMode){this.serverManager.connectConfiguredServers(this.runtimeServerURL,ff());return}if(this.serverManager.activeServer)return;const t=new ty({url:this.runtimeServerURL,name:"Server",token:ff()});this.serverManager.add(t),this.serverManager.setActive(t);try{await t.connect(),this.connectError=null}catch(r){this.connectError=r instanceof Error&&!(r instanceof Qc)?r.message:null}this.render()}async handleAuthSubmit(t){const r=this.serverManager.activeServer;if(r){this.connectError=null,r.token=t,this.updateTokenQueryParam(t);try{await r.connect()}catch(i){i instanceof Qc||(this.connectError=i instanceof Error?i.message:String(i))}this.render()}}updateTokenQueryParam(t){const r=new URL(window.location.href);r.searchParams.set("token",t),window.history.replaceState({},"",`${r.pathname}${r.search}${r.hash}`)}render(){const t=this.serverManager.activeServer,r=(t==null?void 0:t.status)??null;if(r==="connecting"){Fe(N`
|
|
549
|
+
<main class="auth-gate"><p>Connecting...</p></main>
|
|
550
|
+
`,this);return}if(r==="disconnected"){const o=t;if(!o)return;Fe(N`
|
|
551
|
+
<main class="auth-gate">
|
|
552
|
+
<auth-modal
|
|
553
|
+
.invalid=${!!o.token}
|
|
554
|
+
.tokenValue=${o.token??""}
|
|
555
|
+
></auth-modal>
|
|
556
|
+
</main>
|
|
557
|
+
`,this);return}const s=this.screenManager.activeScreen?N`<screen-view></screen-view>`:N`<home-screen></home-screen>`;Fe(N`
|
|
558
|
+
<main>
|
|
559
|
+
${this.connectError?N`<p data-testid="auth-error">${this.connectError}</p>`:N`
|
|
560
|
+
${s}
|
|
561
|
+
${r==="connected"?N`
|
|
562
|
+
<div class="chrome">
|
|
563
|
+
<div class="top-row electron-draggable">
|
|
564
|
+
<button
|
|
565
|
+
type="button"
|
|
566
|
+
variant="glass"
|
|
567
|
+
icon-only
|
|
568
|
+
aria-label="Home"
|
|
569
|
+
@click=${()=>this.screenManager.clearActive()}
|
|
570
|
+
>
|
|
571
|
+
${x2({size:16,weight:"regular"})}
|
|
572
|
+
</button>
|
|
573
|
+
<screen-select></screen-select>
|
|
574
|
+
</div>
|
|
575
|
+
<command-panel></command-panel>
|
|
576
|
+
</div>
|
|
577
|
+
`:null}
|
|
578
|
+
`}
|
|
579
|
+
</main>
|
|
580
|
+
`,this)}}customElements.get("television-app")||customElements.define("television-app",vO);const zh=bh(),Oh=ny(),Ib=new r1(zh?"television-electron":"television-browser",n1(Oh)),Mh=new zD({localStore:Ib,localServerURL:Oh}),Tb=new Qx({localStore:Ib,serverManager:Mh}),yO=new OD;zt.register("ServerManager",()=>Mh);zt.register("ScreenManager",()=>Tb);zt.register("ShortcutService",()=>yO);globalThis.__telepath={screenManager:Tb,serverManager:Mh};const Nh=document.createElement("television-app");Nh.runtimeServerURL=Oh;Nh.electronMode=zh;zh&&document.body.classList.add("electron");document.body.appendChild(Nh);
|