@telepath-computer/television 0.1.170 → 0.1.172

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,718 +0,0 @@
1
- var Q0=Object.defineProperty;var Op=r=>{throw TypeError(r)};var eS=(r,t,e)=>t in r?Q0(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e;var g=(r,t,e)=>eS(r,typeof t!="symbol"?t+"":t,e),Hc=(r,t,e)=>t.has(r)||Op("Cannot "+e);var l=(r,t,e)=>(Hc(r,t,"read from private field"),e?e.call(r):t.get(r)),S=(r,t,e)=>t.has(r)?Op("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(r):t.set(r,e),w=(r,t,e,n)=>(Hc(r,t,"write to private field"),n?n.call(r,e):t.set(r,e),e),p=(r,t,e)=>(Hc(r,t,"access private method"),e);var Zc=(r,t,e,n)=>({set _(i){w(r,t,i,e)},get _(){return l(r,t,n)}});import{i as Mp,a as Np,b as Up,c as Fp,d as Hp,e as tS,U as rS,f as Zp,g as Wp,A as nS,h as iS,j as sS}from"./artifact-bridge-C0H5cXgO.js";import{m as oS,a as aS,b as lS}from"./missing-artifact-page-DVzJ41AE.js";var bn=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function cS(r){if(r.__esModule)return r;var t=r.default;if(typeof t=="function"){var e=function n(){return this instanceof n?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};e.prototype=t.prototype}else e={};return Object.defineProperty(e,"__esModule",{value:!0}),Object.keys(r).forEach(function(n){var i=Object.getOwnPropertyDescriptor(r,n);Object.defineProperty(e,n,i.get?i:{enumerable:!0,get:function(){return r[n]}})}),e}var Bp=Object.prototype.toString,Vm=function(t){var e=Bp.call(t),n=e==="[object Arguments]";return n||(n=e!=="[object Array]"&&t!==null&&typeof t=="object"&&typeof t.length=="number"&&t.length>=0&&Bp.call(t.callee)==="[object Function]"),n},Wc,jp;function uS(){if(jp)return Wc;jp=1;var r;if(!Object.keys){var t=Object.prototype.hasOwnProperty,e=Object.prototype.toString,n=Vm,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(y){var m=y.constructor;return m&&m.prototype===y},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 y in window)try{if(!u["$"+y]&&t.call(window,y)&&window[y]!==null&&typeof window[y]=="object")try{c(window[y])}catch{return!0}}catch{return!0}return!1}(),f=function(y){if(typeof window>"u"||!h)return c(y);try{return c(y)}catch{return!1}};r=function(m){var E=m!==null&&typeof m=="object",x=e.call(m)==="[object Function]",I=n(m),P=E&&e.call(m)==="[object String]",R=[];if(!E&&!x&&!I)throw new TypeError("Object.keys called on a non-object");var B=o&&x;if(P&&m.length>0&&!t.call(m,0))for(var N=0;N<m.length;++N)R.push(String(N));if(I&&m.length>0)for(var F=0;F<m.length;++F)R.push(String(F));else for(var Y in m)!(B&&Y==="prototype")&&t.call(m,Y)&&R.push(String(Y));if(s)for(var V=f(m),ce=0;ce<a.length;++ce)!(V&&a[ce]==="constructor")&&t.call(m,a[ce])&&R.push(a[ce]);return R}}return Wc=r,Wc}var hS=Array.prototype.slice,dS=Vm,Vp=Object.keys,Qa=Vp?function(t){return Vp(t)}:uS(),Gp=Object.keys;Qa.shim=function(){if(Object.keys){var t=function(){var e=Object.keys(arguments);return e&&e.length===arguments.length}(1,2);t||(Object.keys=function(n){return dS(n)?Gp(hS.call(n)):Gp(n)})}else Object.keys=Qa;return Object.keys||Qa};var pS=Qa,el=Object.defineProperty||!1;if(el)try{el({},"a",{value:1})}catch{el=!1}var ha=el,Ir=SyntaxError,K=TypeError,fS=Object.getOwnPropertyDescriptor,tl=fS;if(tl)try{tl([],"length")}catch{tl=null}var fs=tl,qp=ha,gS=Ir,ci=K,Yp=fs,Gm=function(t,e,n){if(!t||typeof t!="object"&&typeof t!="function")throw new ci("`obj` must be an object or a function`");if(typeof e!="string"&&typeof e!="symbol")throw new ci("`property` must be a string or a symbol`");if(arguments.length>3&&typeof arguments[3]!="boolean"&&arguments[3]!==null)throw new ci("`nonEnumerable`, if provided, must be a boolean or null");if(arguments.length>4&&typeof arguments[4]!="boolean"&&arguments[4]!==null)throw new ci("`nonWritable`, if provided, must be a boolean or null");if(arguments.length>5&&typeof arguments[5]!="boolean"&&arguments[5]!==null)throw new ci("`nonConfigurable`, if provided, must be a boolean or null");if(arguments.length>6&&typeof arguments[6]!="boolean")throw new ci("`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=!!Yp&&Yp(t,e);if(qp)qp(t,e,{configurable:o===null&&c?c.configurable:!o,enumerable:i===null&&c?c.enumerable:!i,value:n,writable:s===null&&c?c.writable:!s});else if(a||!i&&!s&&!o)t[e]=n;else throw new gS("This environment does not support defining a property as non-configurable, non-writable, or non-enumerable.")},Fu=ha,qm=function(){return!!Fu};qm.hasArrayLengthDefineBug=function(){if(!Fu)return null;try{return Fu([],"length",{value:1}).length!==1}catch{return!0}};var lc=qm,mS=pS,vS=typeof Symbol=="function"&&typeof Symbol("foo")=="symbol",yS=Object.prototype.toString,bS=Array.prototype.concat,Kp=Gm,wS=function(r){return typeof r=="function"&&yS.call(r)==="[object Function]"},Ym=lc(),SS=function(r,t,e,n){if(t in r){if(n===!0){if(r[t]===e)return}else if(!wS(n)||!n())return}Ym?Kp(r,t,e,!0):Kp(r,t,e)},Km=function(r,t){var e=arguments.length>2?arguments[2]:{},n=mS(t);vS&&(n=bS.call(n,Object.getOwnPropertySymbols(t)));for(var i=0;i<n.length;i+=1)SS(r,n[i],t[n[i]],e[n[i]])};Km.supportsDescriptors=!!Ym;var Qn=Km,rl={exports:{}};typeof self<"u"?rl.exports=self:typeof window<"u"?rl.exports=window:rl.exports=Function("return this")();var Jm=rl.exports,_S=Jm,Xm=function(){return typeof bn!="object"||!bn||bn.Math!==Math||bn.Array!==Array?_S:bn},kS=Qn,xS=fs,ES=Xm,AS=function(){var t=ES();if(kS.supportsDescriptors){var e=xS(t,"globalThis");(!e||e.configurable&&(e.enumerable||!e.writable||globalThis!==t))&&Object.defineProperty(t,"globalThis",{configurable:!0,enumerable:!1,value:t,writable:!0})}else(typeof globalThis!="object"||globalThis!==t)&&(t.globalThis=t);return t},$S=Qn,TS=Jm,Qm=Xm,IS=AS,CS=Qm(),ev=function(){return CS};$S(ev,{getPolyfill:Qm,implementation:TS,shim:IS});var od=ev,Cr=function(t){return!!t&&(typeof t=="function"||typeof t=="object")},ad=Object,tv=Error,RS=EvalError,PS=RangeError,ld=ReferenceError,LS=URIError,DS=Math.abs,zS=Math.floor,OS=Math.max,MS=Math.min,NS=Math.pow,US=Math.round,cd=Number.isNaN||function(t){return t!==t},FS=cd,HS=function(t){return FS(t)||t===0?t:t<0?-1:1},gs=function(){if(typeof Symbol!="function"||typeof Object.getOwnPropertySymbols!="function")return!1;if(typeof Symbol.iterator=="symbol")return!0;var t={},e=Symbol("test"),n=Object(e);if(typeof e=="string"||Object.prototype.toString.call(e)!=="[object Symbol]"||Object.prototype.toString.call(n)!=="[object Symbol]")return!1;var i=42;t[e]=i;for(var s in t)return!1;if(typeof Object.keys=="function"&&Object.keys(t).length!==0||typeof Object.getOwnPropertyNames=="function"&&Object.getOwnPropertyNames(t).length!==0)return!1;var o=Object.getOwnPropertySymbols(t);if(o.length!==1||o[0]!==e||!Object.prototype.propertyIsEnumerable.call(t,e))return!1;if(typeof Object.getOwnPropertyDescriptor=="function"){var a=Object.getOwnPropertyDescriptor(t,e);if(a.value!==i||a.enumerable!==!0)return!1}return!0},Jp=typeof Symbol<"u"&&Symbol,ZS=gs,ud=function(){return typeof Jp!="function"||typeof Symbol!="function"||typeof Jp("foo")!="symbol"||typeof Symbol("bar")!="symbol"?!1:ZS()},rv=typeof Reflect<"u"&&Reflect.getPrototypeOf||null,WS=ad,nv=WS.getPrototypeOf||null,BS="Function.prototype.bind called on incompatible ",jS=Object.prototype.toString,VS=Math.max,GS="[object Function]",Xp=function(t,e){for(var n=[],i=0;i<t.length;i+=1)n[i]=t[i];for(var s=0;s<e.length;s+=1)n[s+t.length]=e[s];return n},qS=function(t,e){for(var n=[],i=e,s=0;i<t.length;i+=1,s+=1)n[s]=t[i];return n},YS=function(r,t){for(var e="",n=0;n<r.length;n+=1)e+=r[n],n+1<r.length&&(e+=t);return e},KS=function(t){var e=this;if(typeof e!="function"||jS.apply(e)!==GS)throw new TypeError(BS+e);for(var n=qS(arguments,1),i,s=function(){if(this instanceof i){var h=e.apply(this,Xp(n,arguments));return Object(h)===h?h:this}return e.apply(t,Xp(n,arguments))},o=VS(0,e.length-n.length),a=[],c=0;c<o;c++)a[c]="$"+c;if(i=Function("binder","return function ("+YS(a,",")+"){ return binder.apply(this,arguments); }")(s),e.prototype){var u=function(){};u.prototype=e.prototype,i.prototype=new u,u.prototype=null}return i},JS=KS,da=Function.prototype.bind||JS,hd=Function.prototype.call,dd=Function.prototype.apply,XS=typeof Reflect<"u"&&Reflect&&Reflect.apply,QS=da,e_=dd,t_=hd,r_=XS,iv=r_||QS.call(t_,e_),n_=da,i_=K,s_=hd,o_=iv,cc=function(t){if(t.length<1||typeof t[0]!="function")throw new i_("a function is required");return o_(n_,s_,t)},a_=cc,Qp=fs,sv;try{sv=[].__proto__===Array.prototype}catch(r){if(!r||typeof r!="object"||!("code"in r)||r.code!=="ERR_PROTO_ACCESS")throw r}var Bc=!!sv&&Qp&&Qp(Object.prototype,"__proto__"),ov=Object,ef=ov.getPrototypeOf,l_=Bc&&typeof Bc.get=="function"?a_([Bc.get]):typeof ef=="function"?function(t){return ef(t==null?t:ov(t))}:!1,tf=rv,rf=nv,nf=l_,av=tf?function(t){return tf(t)}:rf?function(t){if(!t||typeof t!="object"&&typeof t!="function")throw new TypeError("getProto: not an object");return rf(t)}:nf?function(t){return nf(t)}:null,c_=Function.prototype.call,u_=Object.prototype.hasOwnProperty,h_=da,Rr=h_.call(c_,u_),q,d_=ad,p_=tv,f_=RS,g_=PS,m_=ld,as=Ir,Ci=K,v_=LS,y_=DS,b_=zS,w_=OS,S_=MS,__=NS,k_=US,x_=HS,lv=Function,jc=function(r){try{return lv('"use strict"; return ('+r+").constructor;")()}catch{}},so=fs,E_=ha,Vc=function(){throw new Ci},A_=so?function(){try{return arguments.callee,Vc}catch{try{return so(arguments,"callee").get}catch{return Vc}}}():Vc,ui=ud(),Le=av,$_=nv,T_=rv,cv=dd,pa=hd,mi={},I_=typeof Uint8Array>"u"||!Le?q:Le(Uint8Array),jn={__proto__:null,"%AggregateError%":typeof AggregateError>"u"?q:AggregateError,"%Array%":Array,"%ArrayBuffer%":typeof ArrayBuffer>"u"?q:ArrayBuffer,"%ArrayIteratorPrototype%":ui&&Le?Le([][Symbol.iterator]()):q,"%AsyncFromSyncIteratorPrototype%":q,"%AsyncFunction%":mi,"%AsyncGenerator%":mi,"%AsyncGeneratorFunction%":mi,"%AsyncIteratorPrototype%":mi,"%Atomics%":typeof Atomics>"u"?q:Atomics,"%BigInt%":typeof BigInt>"u"?q:BigInt,"%BigInt64Array%":typeof BigInt64Array>"u"?q:BigInt64Array,"%BigUint64Array%":typeof BigUint64Array>"u"?q:BigUint64Array,"%Boolean%":Boolean,"%DataView%":typeof DataView>"u"?q:DataView,"%Date%":Date,"%decodeURI%":decodeURI,"%decodeURIComponent%":decodeURIComponent,"%encodeURI%":encodeURI,"%encodeURIComponent%":encodeURIComponent,"%Error%":p_,"%eval%":eval,"%EvalError%":f_,"%Float16Array%":typeof Float16Array>"u"?q:Float16Array,"%Float32Array%":typeof Float32Array>"u"?q:Float32Array,"%Float64Array%":typeof Float64Array>"u"?q:Float64Array,"%FinalizationRegistry%":typeof FinalizationRegistry>"u"?q:FinalizationRegistry,"%Function%":lv,"%GeneratorFunction%":mi,"%Int8Array%":typeof Int8Array>"u"?q:Int8Array,"%Int16Array%":typeof Int16Array>"u"?q:Int16Array,"%Int32Array%":typeof Int32Array>"u"?q:Int32Array,"%isFinite%":isFinite,"%isNaN%":isNaN,"%IteratorPrototype%":ui&&Le?Le(Le([][Symbol.iterator]())):q,"%JSON%":typeof JSON=="object"?JSON:q,"%Map%":typeof Map>"u"?q:Map,"%MapIteratorPrototype%":typeof Map>"u"||!ui||!Le?q:Le(new Map()[Symbol.iterator]()),"%Math%":Math,"%Number%":Number,"%Object%":d_,"%Object.getOwnPropertyDescriptor%":so,"%parseFloat%":parseFloat,"%parseInt%":parseInt,"%Promise%":typeof Promise>"u"?q:Promise,"%Proxy%":typeof Proxy>"u"?q:Proxy,"%RangeError%":g_,"%ReferenceError%":m_,"%Reflect%":typeof Reflect>"u"?q:Reflect,"%RegExp%":RegExp,"%Set%":typeof Set>"u"?q:Set,"%SetIteratorPrototype%":typeof Set>"u"||!ui||!Le?q:Le(new Set()[Symbol.iterator]()),"%SharedArrayBuffer%":typeof SharedArrayBuffer>"u"?q:SharedArrayBuffer,"%String%":String,"%StringIteratorPrototype%":ui&&Le?Le(""[Symbol.iterator]()):q,"%Symbol%":ui?Symbol:q,"%SyntaxError%":as,"%ThrowTypeError%":A_,"%TypedArray%":I_,"%TypeError%":Ci,"%Uint8Array%":typeof Uint8Array>"u"?q:Uint8Array,"%Uint8ClampedArray%":typeof Uint8ClampedArray>"u"?q:Uint8ClampedArray,"%Uint16Array%":typeof Uint16Array>"u"?q:Uint16Array,"%Uint32Array%":typeof Uint32Array>"u"?q:Uint32Array,"%URIError%":v_,"%WeakMap%":typeof WeakMap>"u"?q:WeakMap,"%WeakRef%":typeof WeakRef>"u"?q:WeakRef,"%WeakSet%":typeof WeakSet>"u"?q:WeakSet,"%Function.prototype.call%":pa,"%Function.prototype.apply%":cv,"%Object.defineProperty%":E_,"%Object.getPrototypeOf%":$_,"%Math.abs%":y_,"%Math.floor%":b_,"%Math.max%":w_,"%Math.min%":S_,"%Math.pow%":__,"%Math.round%":k_,"%Math.sign%":x_,"%Reflect.getPrototypeOf%":T_};if(Le)try{null.error}catch(r){var C_=Le(Le(r));jn["%Error.prototype%"]=C_}var R_=function r(t){var e;if(t==="%AsyncFunction%")e=jc("async function () {}");else if(t==="%GeneratorFunction%")e=jc("function* () {}");else if(t==="%AsyncGeneratorFunction%")e=jc("async function* () {}");else if(t==="%AsyncGenerator%"){var n=r("%AsyncGeneratorFunction%");n&&(e=n.prototype)}else if(t==="%AsyncIteratorPrototype%"){var i=r("%AsyncGenerator%");i&&Le&&(e=Le(i.prototype))}return jn[t]=e,e},sf={__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"]},fa=da,Al=Rr,P_=fa.call(pa,Array.prototype.concat),L_=fa.call(cv,Array.prototype.splice),of=fa.call(pa,String.prototype.replace),$l=fa.call(pa,String.prototype.slice),D_=fa.call(pa,RegExp.prototype.exec),z_=/[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g,O_=/\\(\\)?/g,M_=function(t){var e=$l(t,0,1),n=$l(t,-1);if(e==="%"&&n!=="%")throw new as("invalid intrinsic syntax, expected closing `%`");if(n==="%"&&e!=="%")throw new as("invalid intrinsic syntax, expected opening `%`");var i=[];return of(t,z_,function(s,o,a,c){i[i.length]=a?of(c,O_,"$1"):o||s}),i},N_=function(t,e){var n=t,i;if(Al(sf,n)&&(i=sf[n],n="%"+i[0]+"%"),Al(jn,n)){var s=jn[n];if(s===mi&&(s=R_(n)),typeof s>"u"&&!e)throw new Ci("intrinsic "+t+" exists, but is not available. Please file an issue!");return{alias:i,name:n,value:s}}throw new as("intrinsic "+t+" does not exist!")},kt=function(t,e){if(typeof t!="string"||t.length===0)throw new Ci("intrinsic name must be a non-empty string");if(arguments.length>1&&typeof e!="boolean")throw new Ci('"allowMissing" argument must be a boolean');if(D_(/^%?[^%]*%?$/,t)===null)throw new as("`%` may not be present anywhere but at the beginning and end of the intrinsic name");var n=M_(t),i=n.length>0?n[0]:"",s=N_("%"+i+"%",e),o=s.name,a=s.value,c=!1,u=s.alias;u&&(i=u[0],L_(n,P_([0,1],u)));for(var h=1,f=!0;h<n.length;h+=1){var y=n[h],m=$l(y,0,1),E=$l(y,-1);if((m==='"'||m==="'"||m==="`"||E==='"'||E==="'"||E==="`")&&m!==E)throw new as("property names with quotes must have matching quotes");if((y==="constructor"||!f)&&(c=!0),i+="."+y,o="%"+i+"%",Al(jn,o))a=jn[o];else if(a!=null){if(!(y in a)){if(!e)throw new Ci("base intrinsic for "+t+" exists, but the property is not available.");return}if(so&&h+1>=n.length){var x=so(a,y);f=!!x,f&&"get"in x&&!("originalValue"in x.get)?a=x.get:a=a[y]}else f=Al(a,y),a=a[y];f&&!c&&(jn[o]=a)}}return a},Gc,af;function nn(){if(af)return Gc;af=1;var r=kt,t=cc,e=t([r("%String.prototype.indexOf%")]);return Gc=function(i,s){var o=r(i,!!s);return typeof o=="function"&&e(i,".prototype.")>-1?t([o]):o},Gc}var qc,lf;function pd(){if(lf)return qc;lf=1;var r=kt,t=r("%Array%"),e=!t.isArray&&nn()("Object.prototype.toString");return qc=t.isArray||function(i){return e(i)==="[object Array]"},qc}var U_=lc,cf=ha,uv=U_.hasArrayLengthDefineBug(),F_=uv&&pd(),H_=nn(),Z_=H_("Object.prototype.propertyIsEnumerable"),fd=function(t,e,n,i,s,o){if(!cf){if(!t(o)||!o["[[Configurable]]"]||!o["[[Writable]]"]||s in i&&Z_(i,s)!==!!o["[[Enumerable]]"])return!1;var a=o["[[Value]]"];return i[s]=a,e(i[s],a)}return uv&&s==="length"&&"[[Value]]"in o&&F_(i)&&i.length!==o["[[Value]]"]?(i.length=o["[[Value]]"],i.length===o["[[Value]]"]):(cf(i,s,n(o)),!0)},W_=K,Is=Rr,B_={__proto__:null,"[[Configurable]]":!0,"[[Enumerable]]":!0,"[[Get]]":!0,"[[Set]]":!0,"[[Value]]":!0,"[[Writable]]":!0},ms=function(t){if(!t||typeof t!="object")return!1;for(var e in t)if(Is(t,e)&&!B_[e])return!1;var n=Is(t,"[[Value]]")||Is(t,"[[Writable]]"),i=Is(t,"[[Get]]")||Is(t,"[[Set]]");if(n&&i)throw new W_("Property Descriptors may not be both accessor and data descriptors");return!0},hv=function(t){if(typeof t>"u")return t;var e={};return"[[Value]]"in t&&(e.value=t["[[Value]]"]),"[[Writable]]"in t&&(e.writable=!!t["[[Writable]]"]),"[[Get]]"in t&&(e.get=t["[[Get]]"]),"[[Set]]"in t&&(e.set=t["[[Set]]"]),"[[Enumerable]]"in t&&(e.enumerable=!!t["[[Enumerable]]"]),"[[Configurable]]"in t&&(e.configurable=!!t["[[Configurable]]"]),e},j_=K,V_=ms,G_=hv,dv=function(t){if(typeof t<"u"&&!V_(t))throw new j_("Assertion failed: `Desc` must be a Property Descriptor");return G_(t)},q_=K,uf=Rr,Y_=ms,pv=function(t){if(typeof t>"u")return!1;if(!Y_(t))throw new q_("Assertion failed: `Desc` must be a Property Descriptor");return!(!uf(t,"[[Value]]")&&!uf(t,"[[Writable]]"))},vs=function(t){return typeof t=="string"||typeof t=="symbol"},hf=cd,fv=function(t,e){return t===e?t===0?1/t===1/e:!0:hf(t)&&hf(e)},df=K,K_=Cr,J_=fd,X_=dv,Q_=pv,ek=vs,tk=fv,gd=function(t,e,n){if(!K_(t))throw new df("Assertion failed: Type(O) is not Object");if(!ek(e))throw new df("Assertion failed: P is not a Property Key");var i={"[[Configurable]]":!0,"[[Enumerable]]":!1,"[[Value]]":n,"[[Writable]]":!0};return J_(Q_,tk,X_,t,e,i)},gv=Function.prototype.toString,Ei=typeof Reflect=="object"&&Reflect!==null&&Reflect.apply,Hu,nl;if(typeof Ei=="function"&&typeof Object.defineProperty=="function")try{Hu=Object.defineProperty({},"length",{get:function(){throw nl}}),nl={},Ei(function(){throw 42},null,Hu)}catch(r){r!==nl&&(Ei=null)}else Ei=null;var rk=/^\s*class\b/,Zu=function(t){try{var e=gv.call(t);return rk.test(e)}catch{return!1}},Yc=function(t){try{return Zu(t)?!1:(gv.call(t),!0)}catch{return!1}},il=Object.prototype.toString,nk="[object Object]",ik="[object Function]",sk="[object GeneratorFunction]",ok="[object HTMLAllCollection]",ak="[object HTML document.all class]",lk="[object HTMLCollection]",ck=typeof Symbol=="function"&&!!Symbol.toStringTag,uk=!(0 in[,]),Wu=function(){return!1};if(typeof document=="object"){var hk=document.all;il.call(hk)===il.call(document.all)&&(Wu=function(t){if((uk||!t)&&(typeof t>"u"||typeof t=="object"))try{var e=il.call(t);return(e===ok||e===ak||e===lk||e===nk)&&t("")==null}catch{}return!1})}var mv=Ei?function(t){if(Wu(t))return!0;if(!t||typeof t!="function"&&typeof t!="object")return!1;try{Ei(t,null,Hu)}catch(e){if(e!==nl)return!1}return!Zu(t)&&Yc(t)}:function(t){if(Wu(t))return!0;if(!t||typeof t!="function"&&typeof t!="object")return!1;if(ck)return Yc(t);if(Zu(t))return!1;var e=il.call(t);return e!==ik&&e!==sk&&!/^\[object HTML/.test(e)?!1:Yc(t)},dk=mv,pk=function(t){return!!t},Ht=Rr,Da=K,fk=Cr,pf=dk,Kc=pk,gk=function(t){if(!fk(t))throw new Da("ToPropertyDescriptor requires an object");var e={};if(Ht(t,"enumerable")&&(e["[[Enumerable]]"]=Kc(t.enumerable)),Ht(t,"configurable")&&(e["[[Configurable]]"]=Kc(t.configurable)),Ht(t,"value")&&(e["[[Value]]"]=t.value),Ht(t,"writable")&&(e["[[Writable]]"]=Kc(t.writable)),Ht(t,"get")){var n=t.get;if(typeof n<"u"&&!pf(n))throw new Da("getter must be a function");e["[[Get]]"]=n}if(Ht(t,"set")){var i=t.set;if(typeof i<"u"&&!pf(i))throw new Da("setter must be a function");e["[[Set]]"]=i}if((Ht(e,"[[Get]]")||Ht(e,"[[Set]]"))&&(Ht(e,"[[Value]]")||Ht(e,"[[Writable]]")))throw new Da("Invalid property descriptor. Cannot both specify accessors and a value or writable attribute");return e},Jc=K,mk=Cr,ff=ms,vk=fd,yk=dv,bk=pv,wk=vs,Sk=fv,_k=gk,kk=function(t,e,n){if(!mk(t))throw new Jc("Assertion failed: Type(O) is not Object");if(!wk(e))throw new Jc("Assertion failed: P is not a Property Key");var i=ff(n)?n:_k(n);if(!ff(i))throw new Jc("Assertion failed: Desc is not a valid Property Descriptor");return vk(bk,Sk,yk,t,e,i)},gf=K,xk=Cr,Ek=kk,Ak=vs,$k=function(t,e,n){if(!xk(t))throw new gf("Assertion failed: Type(O) is not Object");if(!Ak(e))throw new gf("Assertion failed: P is not a Property Key");var i={"[[Configurable]]":!0,"[[Enumerable]]":!1,"[[Value]]":n,"[[Writable]]":!0};return Ek(t,e,i)},Tk=typeof Reflect<"u"&&Reflect.setPrototypeOf||null,Ik=ad,Ck=Ik.setPrototypeOf||null,Rk=cc,mf=fs,Pk=K,vv={};try{vv.__proto__=null}catch(r){if(!r||typeof r!="object"||!("code"in r)||r.code!=="ERR_PROTO_ACCESS")throw r}var Lk=!("toString"in vv),Xc=mf&&mf(Object.prototype,"__proto__"),Dk=Lk&&(!!Xc&&typeof Xc.set=="function"&&Rk([Xc.set])||function(t,e){if(t==null)throw new Pk("set Object.prototype.__proto__ called on null or undefined");return t.__proto__=e,e}),vf=Tk,zk=Ck,yf=Dk,Ok=K,Mk=vf?function(t,e){if(vf(t,e))return t;throw new Ok("Reflect.setPrototypeOf: failed to set [[Prototype]]")}:zk||(yf?function(t,e){return yf(t,e),t}:null),bf=K,Nk=Cr,wf=av,Uk=function(t){if(!Nk(t))throw new bf("Assertion failed: O must be an Object");if(!wf)throw new bf("This environment does not support fetching prototypes.");return wf(t)},Fk=K,Hk=Mk,Zk=Cr,Wk=Uk,Bk=function(t,e){if(e!==null&&!Zk(e))throw new Fk("Assertion failed: V must be Object or Null");try{Hk(t,e)}catch{return!1}return Wk(t)===e},Qc=gd,Sf=$k,yv=Bk,jk=lc(),md=tv;function ga(r,t,e){var n=new md(e);return yv(n,sl),delete n.constructor,Sf(n,"error",r),Sf(n,"suppressed",t),n}jk&&Object.defineProperty(ga,"prototype",{writable:!1});var sl=ga.prototype;if(!Qc(sl,"constructor",ga)||!Qc(sl,"message","")||!Qc(sl,"name","SuppressedError"))throw new md("unable to install SuppressedError.prototype properties; please report this!");yv(ga.prototype,md.prototype);var Vk=ga,Gk=Vk,bv=function(){return typeof SuppressedError=="function"?SuppressedError:Gk},qk=Qn,_f=od(),Yk=bv,Kk=function(){var t=Yk();return qk(_f,{SuppressedError:t},{SuppressedError:function(){return _f.SuppressedError!==t}}),t};Kk();var Jk=K,Xk=ms,Qk=hv,ex=function(t){if(typeof t<"u"&&!Xk(t))throw new Jk("Assertion failed: `Desc` must be a Property Descriptor");return Qk(t)},tx=K,kf=Rr,rx=ms,nx=function(t){if(typeof t>"u")return!1;if(!rx(t))throw new tx("Assertion failed: `Desc` must be a Property Descriptor");return!(!kf(t,"[[Value]]")&&!kf(t,"[[Writable]]"))},xf=cd,ix=function(t,e){return t===e?t===0?1/t===1/e:!0:xf(t)&&xf(e)},ys=mv,sx=function(t){return!!t},Zt=Rr,za=K,ox=Cr,Ef=ys,eu=sx,ax=function(t){if(!ox(t))throw new za("ToPropertyDescriptor requires an object");var e={};if(Zt(t,"enumerable")&&(e["[[Enumerable]]"]=eu(t.enumerable)),Zt(t,"configurable")&&(e["[[Configurable]]"]=eu(t.configurable)),Zt(t,"value")&&(e["[[Value]]"]=t.value),Zt(t,"writable")&&(e["[[Writable]]"]=eu(t.writable)),Zt(t,"get")){var n=t.get;if(typeof n<"u"&&!Ef(n))throw new za("getter must be a function");e["[[Get]]"]=n}if(Zt(t,"set")){var i=t.set;if(typeof i<"u"&&!Ef(i))throw new za("setter must be a function");e["[[Set]]"]=i}if((Zt(e,"[[Get]]")||Zt(e,"[[Set]]"))&&(Zt(e,"[[Value]]")||Zt(e,"[[Writable]]")))throw new za("Invalid property descriptor. Cannot both specify accessors and a value or writable attribute");return e},tu=K,lx=Cr,Af=ms,cx=fd,ux=ex,hx=nx,dx=vs,px=ix,fx=ax,ma=function(t,e,n){if(!lx(t))throw new tu("Assertion failed: Type(O) is not Object");if(!dx(e))throw new tu("Assertion failed: P is not a Property Key");var i=Af(n)?n:fx(n);if(!Af(i))throw new tu("Assertion failed: Desc is not a valid Property Descriptor");return cx(hx,px,ux,t,e,i)},gx=gs(),mx=gx?Symbol.dispose||Symbol("Symbol.dispose"):null,vx=gs,yx=mx,vd=function(){return vx()&&Symbol.dispose||yx},bx=ud,wx=ma,Sx=vd,_x=function(){var t=Sx();return bx()&&wx(Symbol,"dispose",{"[[Configurable]]":!1,"[[Enumerable]]":!1,"[[Writable]]":!1,"[[Value]]":t}),t},kx=gs(),xx=kx?Symbol.asyncDispose||Symbol("Symbol.asyncDispose"):null,Ex=gs,Ax=xx,yd=function(){return Ex()&&Symbol.asyncDispose||Ax},$x=ud,Tx=ma,Ix=yd,Cx=function(){var t=Ix();return $x()&&Tx(Symbol,"asyncDispose",{"[[Configurable]]":!1,"[[Enumerable]]":!1,"[[Writable]]":!1,"[[Value]]":t}),t},Rx=pd(),Px=kt,Lx=nn(),Dx=K,zx=Rx,Ox=Px("%Reflect.apply%",!0)||Lx("Function.prototype.apply"),uc=function(t,e){var n=arguments.length>2?arguments[2]:[];if(!zx(n))throw new Dx("Assertion failed: optional `argumentsList`, if provided, must be a List");return Ox(t,e,n)};const Mx={},Nx=Object.freeze(Object.defineProperty({__proto__:null,default:Mx},Symbol.toStringTag,{value:"Module"})),Ux=cS(Nx);var bd=typeof Map=="function"&&Map.prototype,ru=Object.getOwnPropertyDescriptor&&bd?Object.getOwnPropertyDescriptor(Map.prototype,"size"):null,Tl=bd&&ru&&typeof ru.get=="function"?ru.get:null,$f=bd&&Map.prototype.forEach,wd=typeof Set=="function"&&Set.prototype,nu=Object.getOwnPropertyDescriptor&&wd?Object.getOwnPropertyDescriptor(Set.prototype,"size"):null,Il=wd&&nu&&typeof nu.get=="function"?nu.get:null,Tf=wd&&Set.prototype.forEach,Fx=typeof WeakMap=="function"&&WeakMap.prototype,Qs=Fx?WeakMap.prototype.has:null,Hx=typeof WeakSet=="function"&&WeakSet.prototype,eo=Hx?WeakSet.prototype.has:null,Zx=typeof WeakRef=="function"&&WeakRef.prototype,If=Zx?WeakRef.prototype.deref:null,Wx=Boolean.prototype.valueOf,Bx=Object.prototype.toString,jx=Function.prototype.toString,Vx=String.prototype.match,Sd=String.prototype.slice,Yr=String.prototype.replace,Gx=String.prototype.toUpperCase,Cf=String.prototype.toLowerCase,wv=RegExp.prototype.test,Rf=Array.prototype.concat,or=Array.prototype.join,qx=Array.prototype.slice,Pf=Math.floor,Bu=typeof BigInt=="function"?BigInt.prototype.valueOf:null,iu=Object.getOwnPropertySymbols,ju=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?Symbol.prototype.toString:null,ls=typeof Symbol=="function"&&typeof Symbol.iterator=="object",to=typeof Symbol=="function"&&Symbol.toStringTag&&(typeof Symbol.toStringTag===ls||!0)?Symbol.toStringTag:null,Sv=Object.prototype.propertyIsEnumerable,Lf=(typeof Reflect=="function"?Reflect.getPrototypeOf:Object.getPrototypeOf)||([].__proto__===Array.prototype?function(r){return r.__proto__}:null);function Df(r,t){if(r===1/0||r===-1/0||r!==r||r&&r>-1e3&&r<1e3||wv.call(/e/,t))return t;var e=/[0-9](?=(?:[0-9]{3})+(?![0-9]))/g;if(typeof r=="number"){var n=r<0?-Pf(-r):Pf(r);if(n!==r){var i=String(n),s=Sd.call(t,i.length+1);return Yr.call(i,e,"$&_")+"."+Yr.call(Yr.call(s,/([0-9]{3})/g,"$&_"),/_$/,"")}}return Yr.call(t,e,"$&_")}var Vu=Ux,zf=Vu.custom,Of=xv(zf)?zf:null,_v={__proto__:null,double:'"',single:"'"},Yx={__proto__:null,double:/(["\\])/g,single:/(['\\])/g},bs=function r(t,e,n,i){var s=e||{};if(yr(s,"quoteStyle")&&!yr(_v,s.quoteStyle))throw new TypeError('option "quoteStyle" must be "single" or "double"');if(yr(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=yr(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(yr(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(yr(s,"numericSeparator")&&typeof s.numericSeparator!="boolean")throw new TypeError('option "numericSeparator", if provided, must be `true` or `false`');var a=s.numericSeparator;if(typeof t>"u")return"undefined";if(t===null)return"null";if(typeof t=="boolean")return t?"true":"false";if(typeof t=="string")return Av(t,s);if(typeof t=="number"){if(t===0)return 1/0/t>0?"0":"-0";var c=String(t);return a?Df(t,c):c}if(typeof t=="bigint"){var u=String(t)+"n";return a?Df(t,u):u}var h=typeof s.depth>"u"?5:s.depth;if(typeof n>"u"&&(n=0),n>=h&&h>0&&typeof t=="object")return Gu(t)?"[Array]":"[Object]";var f=pE(s,n);if(typeof i>"u")i=[];else if(Ev(i,t)>=0)return"[Circular]";function y(Nt,Pr,Ic){if(Pr&&(i=qx.call(i),i.push(Pr)),Ic){var Ea={depth:s.depth};return yr(s,"quoteStyle")&&(Ea.quoteStyle=s.quoteStyle),r(Nt,Ea,n+1,i)}return r(Nt,s,n+1,i)}if(typeof t=="function"&&!Mf(t)){var m=iE(t),E=Oa(t,y);return"[Function"+(m?": "+m:" (anonymous)")+"]"+(E.length>0?" { "+or.call(E,", ")+" }":"")}if(xv(t)){var x=ls?Yr.call(String(t),/^(Symbol\(.*\))_[^)]*$/,"$1"):ju.call(t);return typeof t=="object"&&!ls?Cs(x):x}if(uE(t)){for(var I="<"+Cf.call(String(t.nodeName)),P=t.attributes||[],R=0;R<P.length;R++)I+=" "+P[R].name+"="+kv(Kx(P[R].value),"double",s);return I+=">",t.childNodes&&t.childNodes.length&&(I+="..."),I+="</"+Cf.call(String(t.nodeName))+">",I}if(Gu(t)){if(t.length===0)return"[]";var B=Oa(t,y);return f&&!dE(B)?"["+qu(B,f)+"]":"[ "+or.call(B,", ")+" ]"}if(Xx(t)){var N=Oa(t,y);return!("cause"in Error.prototype)&&"cause"in t&&!Sv.call(t,"cause")?"{ ["+String(t)+"] "+or.call(Rf.call("[cause]: "+y(t.cause),N),", ")+" }":N.length===0?"["+String(t)+"]":"{ ["+String(t)+"] "+or.call(N,", ")+" }"}if(typeof t=="object"&&o){if(Of&&typeof t[Of]=="function"&&Vu)return Vu(t,{depth:h-n});if(o!=="symbol"&&typeof t.inspect=="function")return t.inspect()}if(sE(t)){var F=[];return $f&&$f.call(t,function(Nt,Pr){F.push(y(Pr,t,!0)+" => "+y(Nt,t))}),Nf("Map",Tl.call(t),F,f)}if(lE(t)){var Y=[];return Tf&&Tf.call(t,function(Nt){Y.push(y(Nt,t))}),Nf("Set",Il.call(t),Y,f)}if(oE(t))return su("WeakMap");if(cE(t))return su("WeakSet");if(aE(t))return su("WeakRef");if(eE(t))return Cs(y(Number(t)));if(rE(t))return Cs(y(Bu.call(t)));if(tE(t))return Cs(Wx.call(t));if(Qx(t))return Cs(y(String(t)));if(typeof window<"u"&&t===window)return"{ [object Window] }";if(typeof globalThis<"u"&&t===globalThis||typeof bn<"u"&&t===bn)return"{ [object globalThis] }";if(!Jx(t)&&!Mf(t)){var V=Oa(t,y),ce=Lf?Lf(t)===Object.prototype:t instanceof Object||t.constructor===Object,Et=t instanceof Object?"":"null prototype",ln=!ce&&to&&Object(t)===t&&to in t?Sd.call(sn(t),8,-1):Et?"Object":"",ze=ce||typeof t.constructor!="function"?"":t.constructor.name?t.constructor.name+" ":"",cn=ze+(ln||Et?"["+or.call(Rf.call([],ln||[],Et||[]),": ")+"] ":"");return V.length===0?cn+"{}":f?cn+"{"+qu(V,f)+"}":cn+"{ "+or.call(V,", ")+" }"}return String(t)};function kv(r,t,e){var n=e.quoteStyle||t,i=_v[n];return i+r+i}function Kx(r){return Yr.call(String(r),/"/g,"&quot;")}function ei(r){return!to||!(typeof r=="object"&&(to in r||typeof r[to]<"u"))}function Gu(r){return sn(r)==="[object Array]"&&ei(r)}function Jx(r){return sn(r)==="[object Date]"&&ei(r)}function Mf(r){return sn(r)==="[object RegExp]"&&ei(r)}function Xx(r){return sn(r)==="[object Error]"&&ei(r)}function Qx(r){return sn(r)==="[object String]"&&ei(r)}function eE(r){return sn(r)==="[object Number]"&&ei(r)}function tE(r){return sn(r)==="[object Boolean]"&&ei(r)}function xv(r){if(ls)return r&&typeof r=="object"&&r instanceof Symbol;if(typeof r=="symbol")return!0;if(!r||typeof r!="object"||!ju)return!1;try{return ju.call(r),!0}catch{}return!1}function rE(r){if(!r||typeof r!="object"||!Bu)return!1;try{return Bu.call(r),!0}catch{}return!1}var nE=Object.prototype.hasOwnProperty||function(r){return r in this};function yr(r,t){return nE.call(r,t)}function sn(r){return Bx.call(r)}function iE(r){if(r.name)return r.name;var t=Vx.call(jx.call(r),/^function\s*([\w$]+)/);return t?t[1]:null}function Ev(r,t){if(r.indexOf)return r.indexOf(t);for(var e=0,n=r.length;e<n;e++)if(r[e]===t)return e;return-1}function sE(r){if(!Tl||!r||typeof r!="object")return!1;try{Tl.call(r);try{Il.call(r)}catch{return!0}return r instanceof Map}catch{}return!1}function oE(r){if(!Qs||!r||typeof r!="object")return!1;try{Qs.call(r,Qs);try{eo.call(r,eo)}catch{return!0}return r instanceof WeakMap}catch{}return!1}function aE(r){if(!If||!r||typeof r!="object")return!1;try{return If.call(r),!0}catch{}return!1}function lE(r){if(!Il||!r||typeof r!="object")return!1;try{Il.call(r);try{Tl.call(r)}catch{return!0}return r instanceof Set}catch{}return!1}function cE(r){if(!eo||!r||typeof r!="object")return!1;try{eo.call(r,eo);try{Qs.call(r,Qs)}catch{return!0}return r instanceof WeakSet}catch{}return!1}function uE(r){return!r||typeof r!="object"?!1:typeof HTMLElement<"u"&&r instanceof HTMLElement?!0:typeof r.nodeName=="string"&&typeof r.getAttribute=="function"}function Av(r,t){if(r.length>t.maxStringLength){var e=r.length-t.maxStringLength,n="... "+e+" more character"+(e>1?"s":"");return Av(Sd.call(r,0,t.maxStringLength),t)+n}var i=Yx[t.quoteStyle||"single"];i.lastIndex=0;var s=Yr.call(Yr.call(r,i,"\\$1"),/[\x00-\x1f]/g,hE);return kv(s,"single",t)}function hE(r){var t=r.charCodeAt(0),e={8:"b",9:"t",10:"n",12:"f",13:"r"}[t];return e?"\\"+e:"\\x"+(t<16?"0":"")+Gx.call(t.toString(16))}function Cs(r){return"Object("+r+")"}function su(r){return r+" { ? }"}function Nf(r,t,e,n){var i=n?qu(e,n):or.call(e,", ");return r+" ("+t+") {"+i+"}"}function dE(r){for(var t=0;t<r.length;t++)if(Ev(r[t],`
2
- `)>=0)return!1;return!0}function pE(r,t){var e;if(r.indent===" ")e=" ";else if(typeof r.indent=="number"&&r.indent>0)e=or.call(Array(r.indent+1)," ");else return null;return{base:e,prev:or.call(Array(t+1),e)}}function qu(r,t){if(r.length===0)return"";var e=`
3
- `+t.prev+t.base;return e+or.call(r,","+e)+`
4
- `+t.prev}function Oa(r,t){var e=Gu(r),n=[];if(e){n.length=r.length;for(var i=0;i<r.length;i++)n[i]=yr(r,i)?t(r[i],r):""}var s=typeof iu=="function"?iu(r):[],o;if(ls){o={};for(var a=0;a<s.length;a++)o["$"+s[a]]=s[a]}for(var c in r)yr(r,c)&&(e&&String(Number(c))===c&&c<r.length||ls&&o["$"+c]instanceof Symbol||(wv.call(/[^\w$]/,c)?n.push(t(c,r)+": "+t(r[c],r)):n.push(c+": "+t(r[c],r))));if(typeof iu=="function")for(var u=0;u<s.length;u++)Sv.call(r,s[u])&&n.push("["+t(s[u])+"]: "+t(r[s[u]],r));return n}var fE=bs,gE=K,hc=function(r,t,e){for(var n=r,i;(i=n.next)!=null;n=i)if(i.key===t)return n.next=i.next,e||(i.next=r.next,r.next=i),i},mE=function(r,t){if(r){var e=hc(r,t);return e&&e.value}},vE=function(r,t,e){var n=hc(r,t);n?n.value=e:r.next={key:t,next:r.next,value:e}},yE=function(r,t){return r?!!hc(r,t):!1},bE=function(r,t){if(r)return hc(r,t,!0)},wE=function(){var t,e={assert:function(n){if(!e.has(n))throw new gE("Side channel does not contain "+fE(n))},delete:function(n){var i=t&&t.next,s=bE(t,n);return s&&i&&i===s&&(t=void 0),!!s},get:function(n){return mE(t,n)},has:function(n){return yE(t,n)},set:function(n,i){t||(t={next:void 0}),vE(t,n,i)}};return e},SE=kt,va=nn(),_E=bs,kE=K,Uf=SE("%Map%",!0),xE=va("Map.prototype.get",!0),EE=va("Map.prototype.set",!0),AE=va("Map.prototype.has",!0),$E=va("Map.prototype.delete",!0),TE=va("Map.prototype.size",!0),$v=!!Uf&&function(){var t,e={assert:function(n){if(!e.has(n))throw new kE("Side channel does not contain "+_E(n))},delete:function(n){if(t){var i=$E(t,n);return TE(t)===0&&(t=void 0),i}return!1},get:function(n){if(t)return xE(t,n)},has:function(n){return t?AE(t,n):!1},set:function(n,i){t||(t=new Uf),EE(t,n,i)}};return e},IE=kt,dc=nn(),CE=bs,Ma=$v,RE=K,hi=IE("%WeakMap%",!0),PE=dc("WeakMap.prototype.get",!0),LE=dc("WeakMap.prototype.set",!0),DE=dc("WeakMap.prototype.has",!0),zE=dc("WeakMap.prototype.delete",!0),OE=hi?function(){var t,e,n={assert:function(i){if(!n.has(i))throw new RE("Side channel does not contain "+CE(i))},delete:function(i){if(hi&&i&&(typeof i=="object"||typeof i=="function")){if(t)return zE(t,i)}else if(Ma&&e)return e.delete(i);return!1},get:function(i){return hi&&i&&(typeof i=="object"||typeof i=="function")&&t?PE(t,i):e&&e.get(i)},has:function(i){return hi&&i&&(typeof i=="object"||typeof i=="function")&&t?DE(t,i):!!e&&e.has(i)},set:function(i,s){hi&&i&&(typeof i=="object"||typeof i=="function")?(t||(t=new hi),LE(t,i,s)):Ma&&(e||(e=Ma()),e.set(i,s))}};return n}:Ma,ME=K,NE=bs,UE=wE,FE=$v,HE=OE,ZE=HE||FE||UE,WE=function(){var t,e={assert:function(n){if(!e.has(n))throw new ME("Side channel does not contain "+NE(n))},delete:function(n){return!!t&&t.delete(n)},get:function(n){return t&&t.get(n)},has:function(n){return!!t&&t.has(n)},set:function(n,i){t||(t=ZE()),t.set(n,i)}};return e},BE=Rr,Rs=WE(),pr=K,_d={assert:function(r,t){if(!r||typeof r!="object"&&typeof r!="function")throw new pr("`O` is not an object");if(typeof t!="string")throw new pr("`slot` must be a string");if(Rs.assert(r),!_d.has(r,t))throw new pr("`"+t+"` is not present on `O`")},get:function(r,t){if(!r||typeof r!="object"&&typeof r!="function")throw new pr("`O` is not an object");if(typeof t!="string")throw new pr("`slot` must be a string");var e=Rs.get(r);return e&&e["$"+t]},has:function(r,t){if(!r||typeof r!="object"&&typeof r!="function")throw new pr("`O` is not an object");if(typeof t!="string")throw new pr("`slot` must be a string");var e=Rs.get(r);return!!e&&BE(e,"$"+t)},set:function(r,t,e){if(!r||typeof r!="object"&&typeof r!="function")throw new pr("`O` is not an object");if(typeof t!="string")throw new pr("`slot` must be a string");var n=Rs.get(r);n||(n={},Rs.set(r,n)),n["$"+t]=e}};Object.freeze&&Object.freeze(_d);var kd=_d,Tv=Ir,Jr=kd,ya=function r(t,e){if(!(this instanceof r))return new r(t,e);if(t!=="normal"&&t!=="break"&&t!=="continue"&&t!=="return"&&t!=="throw")throw new Tv('Assertion failed: `type` must be one of "normal", "break", "continue", "return", or "throw"');Jr.set(this,"[[Type]]",t),Jr.set(this,"[[Value]]",e)};ya.prototype.type=function(){return Jr.get(this,"[[Type]]")};ya.prototype.value=function(){return Jr.get(this,"[[Value]]")};ya.prototype["?"]=function(){var t=Jr.get(this,"[[Type]]"),e=Jr.get(this,"[[Value]]");if(t==="throw")throw e;return e};ya.prototype["!"]=function(){var t=Jr.get(this,"[[Type]]");if(t!=="normal")throw new Tv('Assertion failed: Completion Record is not of type "normal"');return Jr.get(this,"[[Value]]")};var xd=ya,jE=xd,Ed=function(t){return new jE("normal",t)},ou,Ff;function VE(){if(Ff)return ou;Ff=1;var r=gs;return ou=function(){return r()&&!!Symbol.toStringTag},ou}var GE=kt,Hf=GE("%Object.defineProperty%",!0),qE=VE()(),YE=Rr,KE=K,Na=qE?Symbol.toStringTag:null,Iv=function(t,e){var n=arguments.length>2&&!!arguments[2]&&arguments[2].force,i=arguments.length>2&&!!arguments[2]&&arguments[2].nonConfigurable;if(typeof n<"u"&&typeof n!="boolean"||typeof i<"u"&&typeof i!="boolean")throw new KE("if provided, the `overrideIfSet` and `nonConfigurable` options must be booleans");Na&&(n||!YE(t,Na))&&(Hf?Hf(t,Na,{configurable:!i,enumerable:!1,value:e,writable:!1}):t[Na]=e)},Cv={exports:{}},JE=kt,Zf=Gm,XE=lc(),Wf=fs,Bf=K,QE=JE("%Math.floor%"),eA=function(t,e){if(typeof t!="function")throw new Bf("`fn` is not a function");if(typeof e!="number"||e<0||e>4294967295||QE(e)!==e)throw new Bf("`length` must be a positive 32-bit integer");var n=arguments.length>2&&!!arguments[2],i=!0,s=!0;if("length"in t&&Wf){var o=Wf(t,"length");o&&!o.configurable&&(i=!1),o&&!o.writable&&(s=!1)}return(i||s||!n)&&(XE?Zf(t,"length",e,!0,!0):Zf(t,"length",e)),t},tA=da,rA=dd,nA=iv,iA=function(){return nA(tA,rA,arguments)};(function(r){var t=eA,e=ha,n=cc,i=iA;r.exports=function(o){var a=n(arguments),c=1+o.length-(arguments.length-1);return t(a,c>0?c:0,!0)},e?e(r.exports,"apply",{value:i}):r.exports.apply=i})(Cv);var Ad=Cv.exports,sA=function(t,e){for(var n=0;n<t.length;n+=1)if(!e(t[n],n,t))return!1;return!0},oA=Object,aA=function(t){return t&&typeof t=="object"&&(typeof t["[[ResourceValue]]"]>"u"||oA(t["[[ResourceValue]]"])===t["[[ResourceValue]]"])&&(t["[[Hint]]"]==="SYNC-DISPOSE"||t["[[Hint]]"]==="ASYNC-DISPOSE")&&(typeof t["[[DisposeMethod]]"]=="function"||typeof t["[[DisposeMethod]]"]>"u")},lA=Rr,cA=pd(),uA=sA,hA=aA,dA=function(t){return t&&typeof t=="object"&&lA(t,"[[DisposableResourceStack]]")&&cA(t["[[DisposableResourceStack]]"])&&(t["[[DisposableResourceStack]]"].length===0||uA(t["[[DisposableResourceStack]]"],hA))},pA=Cr,fA=function(t){if(t===null)return"Null";if(typeof t>"u")return"Undefined";if(pA(t))return"Object";if(typeof t=="number")return"Number";if(typeof t=="boolean")return"Boolean";if(typeof t=="string")return"String"},gA=fA,$d=function(t){return typeof t=="symbol"?"Symbol":typeof t=="bigint"?"BigInt":gA(t)},mA=K,vA=bs,yA=vs,bA=function(t,e){if(!yA(e))throw new mA("Assertion failed: P is not a Property Key, got "+vA(e));return t[e]},jf=K,wA=bA,SA=ys,_A=vs,Vf=bs,kA=function(t,e){if(!_A(e))throw new jf("Assertion failed: P is not a Property Key");var n=wA(t,e);if(n!=null){if(!SA(n))throw new jf(Vf(e)+" is not a function: "+Vf(n));return n}},Yu={exports:{}},xA=kt,EA=xA,Gf=EA("%Reflect.construct%",!0),Cl=ma;try{Cl({},"",{"[[Get]]":function(){}})}catch{Cl=null}if(Cl&&Gf){var qf={},Yf={};Cl(Yf,"length",{"[[Get]]":function(){throw qf},"[[Enumerable]]":!0}),Yu.exports=function(t){try{Gf(t,Yf)}catch(e){return e===qf}}}else Yu.exports=function(t){return typeof t=="function"&&!!t.prototype};var AA=Yu.exports,au=K,Kf=ys,$A=AA,TA=function(t){if(!$A(t))throw new au("C must be a constructor");var e={"[[Resolve]]":void 0,"[[Reject]]":void 0},n=new t(function(i,s){if(typeof e["[[Resolve]]"]<"u"||typeof e["[[Reject]]"]<"u")throw new au("executor has already been called");e["[[Resolve]]"]=i,e["[[Reject]]"]=s});if(!Kf(e["[[Resolve]]"])||!Kf(e["[[Reject]]"]))throw new au("executor must provide valid resolve and reject functions");return{"[[Promise]]":n,"[[Resolve]]":e["[[Resolve]]"],"[[Reject]]":e["[[Reject]]"]}},Jf=Ir,IA=K,lu=uc,Xf=kA,CA=TA,RA=$d,Qf=vd(),eg=yd(),PA=function(t,e){if(RA(t)!=="Object")throw new IA("`V` must be an Object");if(e!=="SYNC-DISPOSE"&&e!=="ASYNC-DISPOSE")throw new Jf("Assertion failed: `hint` must be `~SYNC-DISPOSE~` or `~ASYNC-DISPOSE~`");var n;if(e==="ASYNC-DISPOSE"&&eg&&(n=Xf(t,eg)),!n){if(!Qf)throw new Jf("`Symbol.dispose` is not supported");if(n=Xf(t,Qf),typeof n<"u")return function(){var i=this;if(e==="ASYNC-DISPOSE"){var s=CA(Promise);try{lu(n,i),lu(s["[[Resolve]]"],void 0,[void 0])}catch(o){s["[[Reject]]"](o)}return s["[[Promise]]"]}lu(n,i)}}return n},LA=Ir,cu=K,DA=ys,zA=$d,OA=PA,MA=function(t,e){if(e!=="SYNC-DISPOSE"&&e!=="ASYNC-DISPOSE")throw new LA("Assertion failed: `hint` must be `~SYNC-DISPOSE~` or `~ASYNC-DISPOSE~`");var n;if(arguments.length<3)if(t==null)t=void 0,n=void 0;else{if(typeof t<"u"&&zA(t)!=="Object")throw new cu("`V` must be an Object, or `null` or `undefined`");if(n=OA(t,e),typeof n>"u")throw new cu("dispose method must not be `undefined` on `V` when an object `V` is provided")}else if(n=arguments[2],!DA(n))throw new cu("`method`, when provided, must be a function");return{"[[ResourceValue]]":t,"[[Hint]]":e,"[[DisposeMethod]]":n}},NA=Ir,Ua=K,UA=dA,tg=MA,FA=nn(),HA=FA("Array.prototype.push"),Rv=function(t,e,n){if(!UA(t))throw new Ua("Assertion failed: `disposeCapability` must be a DisposeCapability Record");if(n!=="SYNC-DISPOSE"&&n!=="ASYNC-DISPOSE")throw new NA("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 Ua("Assertion failed: `method`, when present, must be a function");if(!t["[[DisposableResourceStack]]"])throw new Ua("Assertion failed: `disposeCapability.[[DisposableResourceStack]]` must not be ~EMPTY~");var s;if(arguments.length<4){if(e==null&&n==="SYNC_DISPOSE")return"UNUSED";s=tg(e,n)}else{if(typeof e<"u")throw new Ua("Assertion failed: `V` must be undefined when `method` is present");s=tg(void 0,n,i)}return HA(t["[[DisposableResourceStack]]"],s),"UNUSED"},uu,rg;function Td(){if(rg)return uu;rg=1;var r=kt,t=Ad,e=Ir,n=r("%Promise.resolve%",!0),i=n&&t(n);return uu=function(o,a){if(!i)throw new e("This environment does not support Promises.");return i(o,a)},uu}var hu,ng;function ZA(){if(ng)return hu;ng=1;var r=kt,t=Ir,e=r("%Promise%",!0),n=uc,i=Td(),s=$d;return hu=function(a,c,u){if(typeof a<"u"&&s(a)!=="Object")throw new t("Assertion failed: `V` must be `undefined` or an Object");if(c!=="SYNC-DISPOSE"&&c!=="ASYNC-DISPOSE")throw new t("Assertion failed: `hint` must be `~SYNC-DISPOSE~` or `~ASYNC-DISPOSE~`");if(typeof u<"u"&&typeof u!="function")throw new t("Assertion failed: `method` must be `undefined` or a function");var h=typeof u>"u"?u:n(u,a);if(c==="ASYNC-DISPOSE")return i(e,h)},hu}var du,ig;function WA(){if(ig)return du;ig=1;var r=xd;return du=function(e){return new r("throw",e)},du}var BA=kt,pu=Ir,sg=K,jA=BA("%Promise%",!0),VA=nn(),og=VA("Promise.prototype.then",!0),GA=xd,ag=ZA(),qA=Ed,YA=Td(),lg=WA(),KA=bv(),Pv=function(t,e){if(!(e instanceof GA))throw new sg("`completion` must be a Completion Record");var n=t["[[DisposableResourceStack]]"];if(!n)throw new sg("Assertion failed: `disposeCapability.[[DisposableResourceStack]]` must not be ~EMPTY~");for(var i,s=n.length-1;s>=0;s-=1)if(!i)i=n[s]["[[Hint]]"];else if(i!==n[s]["[[Hint]]"])throw new pu("mixed hint stacks are not supported");for(var o=i==="ASYNC-DISPOSE"&&YA(jA,e),a=function(y){if(e.type()==="throw"){var m=e.value(),E=new KA(y,m);e=lg(E)}else e=lg(y)},c=i==="ASYNC-DISPOSE"&&function(m){return og(o,function(){var E=ag(m["[[ResourceValue]]"],m["[[Hint]]"],m["[[DisposeMethod]]"]);if(!E)throw new pu("Assertion failed: non-`~ASYNC-DISPOSE~` resource returned a promise from Dispose");return og(E,qA)},a)},u=n.length-1;u>=0;u-=1)if(i==="ASYNC-DISPOSE")o=c(n[u]);else{var h=n[u];try{var f=ag(h["[[ResourceValue]]"],h["[[Hint]]"],h["[[DisposeMethod]]"]);if(f)throw new pu("Assertion failed: `~SYNC-DISPOSE~` resource returned something from Dispose")}catch(y){a(y)}}return t["[[DisposableResourceStack]]"]=null,i==="ASYNC-DISPOSE"?o:e},Lv=function(){var t=[];return{"[[DisposableResourceStack]]":t}},pc=ld,Id=K,JA=uc,ws=gd,XA=ma,Dv=ys,QA=Ed,at=kd,e1=Iv,zv=Qn.supportsDescriptors,t1=Ad,Cd=Rv,r1=Pv,Ov=Lv,cg=vd(),bt=function r(){if(!(this instanceof r)||at.has(this,"[[DisposableState]]")||at.has(this,"[[DisposeCapability]]"))throw new Id("can only be used with new");at.set(this,"[[DisposableState]]","PENDING"),at.set(this,"[[DisposeCapability]]",Ov())},Mv=function(){var t=this;return at.assert(t,"[[DisposableState]]"),at.get(t,"[[DisposableState]]")==="DISPOSED"},ba=t1(Mv);zv?XA(bt.prototype,"disposed",{"[[Configurable]]":!0,"[[Enumerable]]":!1,"[[Get]]":Mv}):bt.prototype.disposed=!1;var Nv=function(t){at.set(t,"[[DisposableState]]","DISPOSED"),zv||(t.disposed=!0)};ws(bt.prototype,"dispose",function(){var t=this;if(!ba(t))return Nv(t),r1(at.get(t,"[[DisposeCapability]]"),QA())["?"]()});ws(bt.prototype,"use",function(t){var e=this;if(ba(e))throw new pc("a disposed stack can not use anything new");return Cd(at.get(e,"[[DisposeCapability]]"),t,"SYNC-DISPOSE"),t});ws(bt.prototype,"adopt",function(t,e){var n=this;if(ba(n))throw new pc("a disposed stack can not use anything new");if(!Dv(e))throw new Id("`onDispose` must be a function");var i=function(){return JA(e,void 0,[t])};return Cd(at.get(n,"[[DisposeCapability]]"),void 0,"SYNC-DISPOSE",i),t});ws(bt.prototype,"defer",function(t){var e=this;if(ba(e))throw new pc("a disposed stack can not defer anything new");if(!Dv(t))throw new Id("`onDispose` must be a function");Cd(at.get(e,"[[DisposeCapability]]"),void 0,"SYNC-DISPOSE",t)});ws(bt.prototype,"move",function(){var t=this;if(ba(t))throw new pc("a disposed stack can not use anything new");var e=new bt;return at.set(e,"[[DisposeCapability]]",at.get(t,"[[DisposeCapability]]")),at.set(t,"[[DisposeCapability]]",Ov()),Nv(t),e});cg&&ws(bt.prototype,cg,bt.prototype.dispose);e1(bt.prototype,"DisposableStack");var n1=bt,i1=n1,s1=function(){return typeof DisposableStack=="function"?DisposableStack:i1},o1=Qn,a1=od(),l1=s1,c1=function(){var t=l1();return o1(a1,{DisposableStack:t},{DisposableStack:!0}),t},u1=kt,fc=ld,Rd=K,ug=u1("%Promise%",!0),Pd=Rv,h1=uc,Ss=gd,d1=ma,p1=Pv,Uv=ys,Fv=Lv,f1=Ed,hg=Td(),lt=kd,g1=Iv,Hv=Qn.supportsDescriptors,m1=Ad,v1=nn(),y1=v1("Promise.prototype.then",!0),dg=yd(),wt=function r(){if(!(this instanceof r)||lt.has(this,"[[AsyncDisposableState]]")||lt.has(this,"[[DisposeCapability]]"))throw new Rd("can only be used with new");lt.set(this,"[[AsyncDisposableState]]","pending"),lt.set(this,"[[DisposeCapability]]",Fv())},Zv=function(){var t=this;return lt.assert(t,"[[AsyncDisposableState]]"),lt.get(t,"[[AsyncDisposableState]]")==="disposed"},wa=m1(Zv);Hv?d1(wt.prototype,"disposed",{"[[Configurable]]":!0,"[[Enumerable]]":!1,"[[Get]]":Zv}):wt.prototype.disposed=!1;var Wv=function(t){lt.set(t,"[[AsyncDisposableState]]","disposed"),Hv||(t.disposed=!0)};Ss(wt.prototype,"disposeAsync",function(){var t=this;return wa(t)?hg(ug):(Wv(t),y1(hg(ug,p1(lt.get(t,"[[DisposeCapability]]"),f1())),function(e){return e["?"]()}))});Ss(wt.prototype,"use",function(t){var e=this;if(wa(e))throw new fc("a disposed stack can not use anything new");return Pd(lt.get(e,"[[DisposeCapability]]"),t,"ASYNC-DISPOSE"),t});Ss(wt.prototype,"adopt",function(t,e){var n=this;if(wa(n))throw new fc("a disposed stack can not use anything new");if(!Uv(e))throw new Rd("`onDisposeAsync` must be a function");var i=function(){return h1(e,void 0,[t])};return i.value=t,Pd(lt.get(n,"[[DisposeCapability]]"),void 0,"ASYNC-DISPOSE",i),t});Ss(wt.prototype,"defer",function(t){var e=this;if(wa(e))throw new fc("a disposed stack can not defer anything new");if(!Uv(t))throw new Rd("`onDispose` must be a function");Pd(lt.get(e,"[[DisposeCapability]]"),void 0,"ASYNC-DISPOSE",t)});Ss(wt.prototype,"move",function(){var t=this;if(wa(t))throw new fc("a disposed stack can not use anything new");var e=new wt;return lt.set(e,"[[DisposeCapability]]",lt.get(t,"[[DisposeCapability]]")),lt.set(t,"[[DisposeCapability]]",Fv()),Wv(t),e});dg&&Ss(wt.prototype,dg,wt.prototype.disposeAsync);g1(wt.prototype,"AsyncDisposableStack");var b1=wt,w1=b1,S1=function(){return typeof AsyncDisposableStack=="function"?AsyncDisposableStack:w1},_1=Qn,k1=od(),x1=S1,E1=function(){var t=x1();return _1(k1,{AsyncDisposableStack:t},{AsyncDisposableStack:!0}),t},A1=_x,$1=Cx,T1=c1,I1=E1,C1=function(){A1(),$1(),T1(),I1()};C1();const pg=new WeakMap;function R1(r){return(typeof r=="object"||typeof r=="function")&&r!==null&&"then"in r&&typeof r.then=="function"}function di(r){return typeof r=="string"?r:typeof r=="symbol"?r.description??r.toString():r.name||"(anonymous class)"}function fg(){return new Error("register(Key, factory) requires a factory function. Wrap existing instances as () => instance.")}function P1(){return new Error("register(Key, factory) does not accept async factories. Await setup before registering.")}class L1{constructor(){g(this,"entries",new Map);g(this,"constructionStack",[])}register(t,e){if(e===void 0){if(typeof t!="function")throw fg();this.validateClassRegistration(t),this.storeFactory(t,()=>this.instantiateClass(t));return}if(typeof e!="function")throw fg();if(e.constructor.name==="AsyncFunction")throw P1();this.storeFactory(t,e)}has(t){var e;return((e=this.entries.get(t))==null?void 0:e.factory)!==void 0}resolve(t){return this.resolveAny(t)}storeFactory(t,e){const n=this.getOrCreateEntry(t);n.factory=e,n.instance=void 0,n.error=void 0}validateClassRegistration(t){const e=pg.get(t);if(e){if(t.length!==e.length)throw new Error(`${di(t)} cannot be registered with register(Class). @injectable(...) declared ${e.length} dependencies but constructor arity is ${t.length}. Use register(Key, () => value) instead.`);return}if(t.length!==0)throw new Error(`${di(t)} cannot be registered with register(Class). Undecorated classes must have zero required constructor parameters. Use register(Key, () => value) instead.`)}instantiateClass(t){const e=pg.get(t);if(!e)return new t;const n=e.map(i=>this.resolveAny(i));return new t(...n)}resolveAny(t){return this.getOrCreateEntry(t).proxy}getOrCreateEntry(t){let e=this.entries.get(t);return e||(e={key:t},e.proxy=this.createProxy(e),this.entries.set(t,e),e)}createProxy(t){return new Proxy({},{get:(e,n)=>{if(n==="then")return;const i=this.getInstance(t),s=Reflect.get(i,n,i);return typeof s=="function"?s.bind(i):s},set:(e,n,i)=>{const s=this.getInstance(t);return Reflect.set(s,n,i,s)},has:(e,n)=>{const i=this.getInstance(t);return n in i}})}getInstance(t){if(t.instance)return t.instance;if(t.error)throw t.error;if(!t.factory)throw new Error(`${di(t.key)} was resolved but never registered`);const e=this.constructionStack.indexOf(t.key);if(e!==-1){const n=[...this.constructionStack.slice(e),t.key].map(i=>di(i)).join(" -> ");throw new Error(`Circular dependency detected: ${n}`)}this.constructionStack.push(t.key);try{const n=t.factory();if(R1(n))throw new Error(`Factory for ${di(t.key)} returned a Promise. Await setup before registering.`);if(typeof n!="object"||n===null)throw new Error(`Factory for ${di(t.key)} returned a non-object value. Wrap primitives in an object.`);return t.instance=n,n}catch(n){throw t.error=n,n}finally{this.constructionStack.pop()}}}const cr=new L1,D1=.5,gg=.1,mg=8,z1=4,Bv=3,jv=3,O1=4,_n=255,Vv=.2126,Gv=.7152,qv=.0722;async function Yv(r){const t=M1(r);if(!t)return"light";try{return await F1(r,t)>=D1?"light":"dark"}catch{return"light"}}function M1(r){if(typeof document.elementsFromPoint!="function")return null;const t=r.getBoundingClientRect(),e=t.left+t.width/2,n=t.top+t.height/2,i=document.elementsFromPoint(e,n);for(const s of i){if(!(s instanceof HTMLElement)||s===r||r.contains(s))continue;const o=window.getComputedStyle(s);if(N1(o))return s}return null}function N1(r){return Kv(r.backgroundImage)?!0:U1(r.backgroundColor)>0}function U1(r){if(!r)return 0;const t=r.match(/rgba?\(([^)]+)\)/);if(!t)return 0;const e=t[1].split(/[\s,/]+/).filter(Boolean);return e.length===O1?parseFloat(e[Bv]):e.length===jv?1:0}async function F1(r,t){const e=r.getBoundingClientRect(),n=t.getBoundingClientRect(),i={x:Fa((e.left-n.left)/n.width),y:Fa((e.top-n.top)/n.height),width:Fa(e.width/n.width),height:Fa(e.height/n.height)},s=window.getComputedStyle(t),o=Kv(s.backgroundImage);return o?Z1({url:o,surfaceWidth:n.width,surfaceHeight:n.height,region:i}):W1(s.backgroundColor)}function Kv(r){const t=r.match(/url\(\s*["']?([^"')]+)["']?\s*\)/);return t?t[1]:null}const vg=new Map;function H1(r){let t=vg.get(r);return t||(t=new Promise((e,n)=>{const i=new Image;i.crossOrigin="anonymous",i.onload=()=>e(i),i.onerror=()=>n(new Error(`Failed to load ${r}`)),i.src=r}),vg.set(r,t),t)}async function Z1(r){const t=await H1(r.url),e=Math.max(mg,Math.ceil(r.surfaceWidth*gg)),n=Math.max(mg,Math.ceil(r.surfaceHeight*gg)),i=document.createElement("canvas");i.width=e,i.height=n;const s=i.getContext("2d",{willReadFrequently:!0});if(!s)return 1;const o=r.surfaceWidth/r.surfaceHeight,a=t.naturalWidth/t.naturalHeight;let c,u;a>o?(u=n,c=n*a):(c=e,u=e/a);const h=(e-c)/2,f=(n-u)/2;s.drawImage(t,h,f,c,u);const y=Math.max(0,Math.floor(r.region.x*e)),m=Math.max(0,Math.floor(r.region.y*n)),E=Math.max(1,Math.min(e-y,Math.floor(r.region.width*e))),x=Math.max(1,Math.min(n-m,Math.floor(r.region.height*n))),I=s.getImageData(y,m,E,x).data;let P=0,R=0;for(let B=0;B<I.length;B+=z1){const N=I[B]/_n,F=I[B+1]/_n,Y=I[B+2]/_n,V=I[B+Bv]/_n;P+=V*(Vv*N+Gv*F+qv*Y),R+=1}return R>0?P/R:1}function W1(r){const t=r.match(/rgba?\(([^)]+)\)/);if(!t)return 1;const e=t[1].split(/[\s,/]+/).filter(Boolean).map(parseFloat);if(e.length<jv)return 1;const n=e[0]/_n,i=e[1]/_n,s=e[2]/_n;return Vv*n+Gv*i+qv*s}function Fa(r){return r<0?0:r>1?1:r}const B1=["ghost","glass"],oo=[...B1.map(r=>`[variant="${r}"]`),'[material="glass"]'].join(", "),Ha=new WeakSet,yg=new WeakSet;function Jv(r){if(yg.has(r))return;yg.add(r);for(const e of r.querySelectorAll(oo))fu(e);if(typeof MutationObserver!="function")return;new MutationObserver(e=>{for(const n of e)if(n.type==="childList")for(const i of n.addedNodes)j1(i,fu);else n.type==="attributes"&&n.target instanceof HTMLElement&&n.target.matches(oo)&&fu(n.target)}).observe(r,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["variant","material"]})}function j1(r,t){if(r instanceof Element){r instanceof HTMLElement&&r.matches(oo)&&t(r);for(const e of r.querySelectorAll(oo))t(e)}}async function fu(r){var e,n;if(Ha.has(r)||r.hasAttribute("tone")||(e=r.parentElement)!=null&&e.closest("[tone]"))return;Ha.add(r);const t=await Yv(r);if(!r.matches(oo)){Ha.delete(r);return}if(r.hasAttribute("tone")||(n=r.parentElement)!=null&&n.closest("[tone]")){Ha.delete(r);return}r.setAttribute("tone",t)}const V1="*,*:before,*:after{box-sizing:border-box}html,body{margin:0;padding:0}h1,h2,h3,h4,h5,h6,p,ul,ol,blockquote,pre,hr{margin:0}button,input,textarea,select{font:inherit;color:inherit}@font-face{font-family:Hind;src:url("+new URL("Hind-Variable-C47b_dt9.woff2",import.meta.url).href+') format("woff2-variations");font-weight:300 700;font-style:normal;font-display:swap}:root{--font-sans: "Hind", -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;--font-brand: var(--font-sans);--font-mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, monospace;--font-weight-body: 500;--text-base: 13.5px;--text-scale: 1.125;--text-sm: round(calc(var(--text-base) / var(--text-scale)), 1px);--text-lg: round(calc(var(--text-base) * var(--text-scale)), 1px);--text-xl: round(calc(var(--text-lg) * var(--text-scale)), 1px);--leading-base: 1.5;--control-height-xs: 18px;--control-height-sm: 24px;--control-height-md: 28px;--control-height-lg: 32px;--space-2: 2px;--space-4: 4px;--space-6: 6px;--space-8: 8px;--space-10: 10px;--space-12: 12px;--space-16: 16px;--space-20: 20px;--space-24: 24px;--space-32: 32px;--space-48: 48px;--space-64: 64px;--radius-4: 4px;--radius-8: 8px;--radius-12: 12px;--radius-16: 16px;--radius-24: 24px;--radius-full: 9999px;--layer-chrome: 100;--layer-panel: 500;--layer-overlay: 2000;--shadow-hairline: 0 0 0 .5px var(--color-border);--shadow-control: 0 1px 1px rgb(0 0 0 / .04), 0 2px 6px rgb(0 0 0 / .06);--alpha-50: 4%;--alpha-100: 8%;--alpha-150: 11%;--alpha-200: 15%;--alpha-300: 22%;--alpha-400: 30%;--alpha-500: 40%;--alpha-600: 50%;--alpha-700: 65%;--alpha-800: 80%;--alpha-900: 90%;--alpha-950: 95%;--tint-50: color-mix(in srgb, currentColor var(--alpha-50), transparent);--tint-100: color-mix(in srgb, currentColor var(--alpha-100), transparent);--tint-150: color-mix(in srgb, currentColor var(--alpha-150), transparent);--tint-200: color-mix(in srgb, currentColor var(--alpha-200), transparent);--tint-300: color-mix(in srgb, currentColor var(--alpha-300), transparent);--tint-400: color-mix(in srgb, currentColor var(--alpha-400), transparent);--tint-500: color-mix(in srgb, currentColor var(--alpha-500), transparent);--tint-600: color-mix(in srgb, currentColor var(--alpha-600), transparent);--tint-700: color-mix(in srgb, currentColor var(--alpha-700), transparent);--tint-800: color-mix(in srgb, currentColor var(--alpha-800), transparent);--tint-900: color-mix(in srgb, currentColor var(--alpha-900), transparent);--tint-950: color-mix(in srgb, currentColor var(--alpha-950), transparent);--color-overlay-hover: color-mix(in srgb, var(--black) var(--alpha-100), transparent);--color-overlay-active: color-mix(in srgb, var(--black) var(--alpha-300), transparent);--backdrop-blur-glass: blur(20px) saturate(1.4);--black: #000000;--white: #ffffff;--neutral-50: oklch(.985 0 0);--neutral-100: oklch(.97 0 0);--neutral-200: oklch(.923 0 0);--neutral-300: oklch(.869 0 0);--neutral-350: oklch(.79 0 0);--neutral-400: oklch(.709 0 0);--neutral-500: oklch(.553 0 0);--neutral-600: oklch(.444 0 0);--neutral-700: oklch(.374 0 0);--neutral-800: oklch(.268 0 0);--neutral-900: oklch(.216 0 0);--neutral-950: oklch(.147 0 0);--red-50: oklch(.969 .015 12.422);--red-100: oklch(.941 .03 12.58);--red-200: oklch(.892 .058 10.001);--red-300: oklch(.81 .117 11.638);--red-400: oklch(.712 .194 13.428);--red-500: oklch(.645 .246 16.439);--red-600: oklch(.586 .253 17.585);--red-700: oklch(.514 .222 16.935);--red-800: oklch(.455 .188 13.697);--red-900: oklch(.41 .159 10.272);--red-950: oklch(.271 .105 12.094);--orange-50: oklch(.98 .016 73.684);--orange-100: oklch(.954 .038 75.164);--orange-200: oklch(.901 .076 70.697);--orange-300: oklch(.837 .128 66.29);--orange-400: oklch(.75 .183 55.934);--orange-500: oklch(.705 .213 47.604);--orange-600: oklch(.646 .222 41.116);--orange-700: oklch(.553 .195 38.402);--orange-800: oklch(.47 .157 37.304);--orange-900: oklch(.408 .123 38.172);--orange-950: oklch(.266 .079 36.259);--yellow-50: oklch(.987 .026 102.212);--yellow-100: oklch(.973 .071 103.193);--yellow-200: oklch(.945 .129 101.54);--yellow-300: oklch(.905 .182 98.111);--yellow-400: oklch(.852 .199 91.936);--yellow-500: oklch(.795 .184 86.047);--yellow-600: oklch(.681 .162 75.834);--yellow-700: oklch(.554 .135 66.442);--yellow-800: oklch(.476 .114 61.907);--yellow-900: oklch(.421 .095 57.708);--yellow-950: oklch(.286 .066 53.813);--green-50: oklch(.979 .021 166.113);--green-100: oklch(.95 .052 163.051);--green-200: oklch(.905 .093 164.15);--green-300: oklch(.845 .143 164.978);--green-400: oklch(.765 .177 163.223);--green-500: oklch(.696 .17 162.48);--green-600: oklch(.596 .145 163.225);--green-700: oklch(.508 .118 165.612);--green-800: oklch(.432 .095 166.913);--green-900: oklch(.378 .077 168.94);--green-950: oklch(.262 .051 172.552);--blue-50: oklch(.97 .014 254.604);--blue-100: oklch(.932 .032 255.585);--blue-200: oklch(.882 .059 254.128);--blue-300: oklch(.809 .105 251.813);--blue-400: oklch(.707 .165 254.624);--blue-500: oklch(.623 .214 259.815);--blue-600: oklch(.546 .245 262.881);--blue-700: oklch(.488 .243 264.376);--blue-800: oklch(.424 .199 265.638);--blue-900: oklch(.379 .146 265.522);--blue-950: oklch(.282 .091 267.935);--purple-50: oklch(.969 .016 293.756);--purple-100: oklch(.943 .029 294.588);--purple-200: oklch(.894 .057 293.283);--purple-300: oklch(.811 .111 293.571);--purple-400: oklch(.702 .183 293.541);--purple-500: oklch(.606 .25 292.717);--purple-600: oklch(.541 .281 293.009);--purple-700: oklch(.491 .27 292.581);--purple-800: oklch(.432 .232 292.759);--purple-900: oklch(.38 .189 293.745);--purple-950: oklch(.283 .141 291.089)}@supports (corner-shape: squircle){:root{--radius-8: 10px;--radius-12: 15px;--radius-16: 20px;--radius-24: 30px}}:root[data-font=system]{--font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif}:root{--color-bg: var(--neutral-50);--color-bg-muted: var(--neutral-100);--color-surface: var(--white);--color-surface-muted: var(--neutral-100);--color-interactive: var(--neutral-200);--color-interactive-hover: var(--neutral-300);--color-border: rgba(0, 0, 0, .1);--color-border-muted: rgba(0, 0, 0, .06);--color-text: var(--neutral-900);--color-text-muted: var(--neutral-500);--color-link: inherit;--color-focus-ring: var(--neutral-500);--color-overlay-backdrop: rgb(0 0 0 / .5);--color-highlight: rgb(255 255 255 / .5);--color-primary: var(--blue-500);--color-danger: var(--red-600);color-scheme:light}body{font-family:var(--font-sans);font-size:var(--text-base);font-weight:var(--font-weight-body);line-height:var(--leading-base);letter-spacing:.015em;color:var(--color-text);background:var(--color-bg);-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}a{color:var(--color-link);text-underline-offset:.15em;text-decoration-thickness:.08em}h1,h2,h3,h4,h5,h6{font-weight:600;color:inherit}code{font-family:var(--font-mono);font-size:.9em;background:var(--color-bg-muted);padding:var(--space-2) var(--space-4);border-radius:var(--radius-4)}pre{font-family:var(--font-mono);background:var(--color-bg-muted);padding:var(--space-12);border-radius:var(--radius-8);overflow-x:auto}pre code{background:none;padding:0}blockquote{padding-left:var(--space-16);border-left:3px solid var(--color-border);color:var(--color-text-muted)}hr{border:none;border-top:1px solid var(--color-border)}table{border-collapse:collapse}th,td{padding:var(--space-8) var(--space-12);border:1px solid var(--color-border);text-align:left}th{background:var(--color-bg-muted);font-weight:600}input,textarea{border:.5px solid var(--tint-300);border-radius:var(--radius-12);background:var(--tint-100);color:inherit;font:inherit;box-sizing:border-box;transition:background .12s ease,border-color .12s ease,box-shadow .12s ease}input{height:var(--control-height-lg);padding:0 12px}textarea{padding:6px 10px;resize:none}input::placeholder,textarea::placeholder{color:var(--tint-500)}input:focus,textarea:focus{background:color-mix(in srgb,var(--white) var(--alpha-300),transparent);border-color:var(--color-primary);outline:none;box-shadow:0 0 0 1.5px var(--color-primary)}label.field{display:grid;gap:4px;font-size:13px}label.field>span{font-size:11.5px;font-weight:450;color:var(--tint-800)}@supports (corner-shape: squircle){*{corner-shape:squircle}}button{display:inline-flex;align-items:center;justify-content:center;gap:var(--space-6);box-sizing:border-box;height:var(--control-height-md);padding:0 14px 2px;font:inherit;cursor:default}button,segmented-control{background:var(--color-surface);border:.5px solid var(--tint-200);border-radius:var(--radius-12);box-shadow:var(--shadow-control);color:inherit}button:not([material]):hover:not(:disabled){background:color-mix(in srgb,var(--color-surface) 96%,black)}button:not([material]):active:not(:disabled){background:color-mix(in srgb,var(--color-surface) 88%,black);box-shadow:inset 0 1px 2px #00000014}button:focus-visible{outline:2px solid var(--color-focus-ring);outline-offset:2px}button[variant=primary]{background:var(--color-primary);border-color:#0000002e;color:var(--white)}button[variant=primary]:hover:not(:disabled){background:color-mix(in srgb,var(--color-primary) 92%,black)}button[variant=primary]:active:not(:disabled){background:color-mix(in srgb,var(--color-primary) 82%,black);box-shadow:inset 0 1px 2px #0000002e}button[variant=danger]{background:var(--color-danger);border-color:#0000002e;color:var(--white)}button[variant=danger]:hover:not(:disabled){background:color-mix(in srgb,var(--color-danger) 92%,black)}button[variant=danger]:active:not(:disabled){background:color-mix(in srgb,var(--color-danger) 82%,black);box-shadow:inset 0 1px 2px #0000002e}button[variant=ghost]{background:transparent;border-color:transparent;color:inherit;box-shadow:none}button[variant=ghost]:hover:not(:disabled){background:var(--tint-150);backdrop-filter:saturate(1.2);-webkit-backdrop-filter:saturate(1.2)}button[variant=ghost]:active:not(:disabled){background:var(--tint-300);backdrop-filter:saturate(1.4);-webkit-backdrop-filter:saturate(1.4);box-shadow:none}button[variant=ghost][data-active]:not(:disabled),button[variant=ghost][data-active]:hover:not(:disabled),button[variant=ghost][aria-pressed=true]:not(:disabled),button[variant=ghost][aria-pressed=true]:hover:not(:disabled),button[variant=ghost][aria-expanded=true]:not(:disabled),button[variant=ghost][aria-expanded=true]:hover:not(:disabled){background:var(--color-overlay-active);backdrop-filter:saturate(1.3);-webkit-backdrop-filter:saturate(1.3);box-shadow:none}button[variant=glass],segmented-control[variant=glass]{background:transparent;border:.5px solid color-mix(in srgb,var(--black) var(--alpha-100),transparent);box-shadow:none}button[variant=glass]{backdrop-filter:blur(20px) brightness(.95) saturate(1.5);-webkit-backdrop-filter:blur(20px) brightness(.95) saturate(1.5)}button[variant=glass]:hover:not(:disabled){background:linear-gradient(var(--color-overlay-hover),var(--color-overlay-hover));backdrop-filter:blur(20px) brightness(.95) saturate(1.8);-webkit-backdrop-filter:blur(20px) brightness(.95) saturate(1.8)}button[variant=glass]:active:not(:disabled){background:linear-gradient(var(--color-overlay-active),var(--color-overlay-active));backdrop-filter:blur(20px) brightness(.95) saturate(2.2);-webkit-backdrop-filter:blur(20px) brightness(.95) saturate(2.2)}button[variant=glass][aria-pressed=true]:not(:disabled),button[variant=glass][aria-pressed=true]:hover:not(:disabled),button[variant=glass][aria-expanded=true]:not(:disabled),button[variant=glass][aria-expanded=true]:hover:not(:disabled){background:linear-gradient(var(--color-overlay-active),var(--color-overlay-active));backdrop-filter:blur(20px) brightness(.95) saturate(2);-webkit-backdrop-filter:blur(20px) brightness(.95) saturate(2)}[tone=dark] button[variant=glass],[tone=dark] segmented-control[variant=glass]{border-color:var(--tint-400)}button[material],segmented-control[material]{color:inherit;box-shadow:none}button[material]:hover:not(:disabled){background-image:linear-gradient(var(--color-overlay-hover),var(--color-overlay-hover))}button[material]:active:not(:disabled){background-image:linear-gradient(var(--color-overlay-active),var(--color-overlay-active))}[tone=dark] button[material],[tone=dark] segmented-control[material]{border-color:var(--tint-400)}button:disabled{background:var(--tint-300);border-color:transparent;color:var(--tint-700);box-shadow:none}button[variant=ghost]:disabled{background:transparent}:where([tone=dark]) button:not([variant]):not([material]):not(:disabled),:where([tone=dark]) button[variant=default]:not([material]):not(:disabled),:where([tone=dark]) segmented-control:not([variant]):not([material]),:where([tone=dark]) segmented-control[variant=default]:not([material]){background:var(--tint-200);border-color:var(--tint-300);box-shadow:inset 0 .5px 0 var(--tint-300)}:where([tone=dark]) button:not([variant]):hover:not(:disabled),:where([tone=dark]) button[variant=default]:hover:not(:disabled){background:var(--tint-300)}:where([tone=dark]) button:not([variant]):active:not(:disabled),:where([tone=dark]) button[variant=default]:active:not(:disabled){background:var(--tint-400);box-shadow:inset 0 1px 2px #0003}:where([tone=light]) button:not([variant]):not([material]):not(:disabled),:where([tone=light]) button[variant=default]:not([material]):not(:disabled),:where([tone=light]) segmented-control:not([variant]):not([material]),:where([tone=light]) segmented-control[variant=default]:not([material]){background:var(--color-surface);border-color:var(--tint-200);box-shadow:var(--shadow-control)}:where([tone=light]) button:not([variant]):hover:not(:disabled){background:color-mix(in srgb,var(--color-surface) 96%,black)}:where([tone=light]) button:not([variant]):active:not(:disabled){background:color-mix(in srgb,var(--color-surface) 88%,black);box-shadow:inset 0 1px 2px #00000014}button[size=sm],segmented-control[size=sm]{height:var(--control-height-sm)}button[size=sm][icon-only]{width:var(--control-height-sm)}button[size=xs]{height:var(--control-height-xs);padding:0 var(--space-6) 1px;border-radius:var(--radius-8)}button[size=xs][icon-only]{width:var(--control-height-xs);padding:0}button[icon-only]{width:var(--control-height-md);padding:0}[data-ui-icon]{display:inline-block;vertical-align:middle}[selectable],[selectable] *{user-select:text;-webkit-user-select:text}[unselectable],[unselectable] *{user-select:none;-webkit-user-select:none}.prose{line-height:var(--leading-base)}.prose h1{font-size:var(--text-xl);margin-bottom:var(--space-8)}.prose h2{font-size:var(--text-lg);margin-top:var(--space-24);margin-bottom:var(--space-8)}.prose h3,.prose h4,.prose h5,.prose h6{font-size:var(--text-base);margin-top:var(--space-24);margin-bottom:var(--space-8)}.prose p{margin:var(--space-12) 0}.prose ul,.prose ol{padding-left:var(--space-24);margin:var(--space-12) 0}.prose blockquote,.prose pre{margin:var(--space-12) 0}.prose hr{margin:var(--space-24) 0}.prose table{width:100%;margin:var(--space-12) 0}.prose img{max-width:100%;height:auto}.prose>:first-child{margin-top:0}.prose>:last-child{margin-bottom:0}[material=paper]{background:var(--white);border:.5px solid color-mix(in srgb,var(--black) var(--alpha-100),transparent);color:var(--color-text)}[material=glass]{background:transparent;border:.5px solid color-mix(in srgb,var(--black) var(--alpha-100),transparent);backdrop-filter:blur(20px) brightness(.95) saturate(1.5);-webkit-backdrop-filter:blur(20px) brightness(.95) saturate(1.5)}[material=glass-frosted]{background:color-mix(in srgb,var(--white) var(--alpha-800),transparent);border:.5px solid color-mix(in srgb,var(--black) var(--alpha-100),transparent);color:var(--color-text);backdrop-filter:var(--backdrop-blur-glass);-webkit-backdrop-filter:var(--backdrop-blur-glass)}[tone=dark]{color:color-mix(in srgb,var(--white) var(--alpha-950),transparent);border-color:color-mix(in srgb,var(--white) var(--alpha-200),transparent);--color-overlay-hover: color-mix(in srgb, var(--white) var(--alpha-100), transparent);--color-overlay-active: color-mix(in srgb, var(--white) var(--alpha-200), transparent)}[tone=dark][material=paper]{background:#000}[tone=dark][material=glass-frosted]{background:color-mix(in srgb,var(--black) 70%,transparent)}[tone=light]{color:var(--color-text);border-color:color-mix(in srgb,var(--black) var(--alpha-100),transparent);--color-overlay-hover: color-mix(in srgb, var(--black) var(--alpha-50), transparent);--color-overlay-active: color-mix(in srgb, var(--black) var(--alpha-100), transparent)}[level="1"]{box-shadow:0 12px 32px #00000024}[level="2"]{box-shadow:0 4px 6px -2px #0000001f,0 40px 60px -16px #00000038}dropdown-menu{position:relative;display:inline-block;color:inherit}dropdown-group{display:grid;gap:var(--space-4)}dropdown-label{display:block;padding:var(--space-4) var(--space-8);color:var(--color-text-muted);font:inherit;font-size:var(--text-sm);font-weight:600;letter-spacing:.04em;text-transform:uppercase}dropdown-divider{display:block;height:1px;margin:2px 0;background:var(--color-border)}[data-dropdown-trigger][aria-expanded=true],[data-dropdown-trigger][aria-expanded=true]:hover,dropdown-menu[open]::part(trigger),dropdown-menu[open]::part(trigger):hover{background:color-mix(in srgb,var(--color-surface) 88%,black);box-shadow:inset 0 1px 2px #00000014}[data-dropdown-trigger-label],dropdown-menu::part(trigger-label){min-width:0}[data-dropdown-trigger-icon],dropdown-menu::part(trigger-icon){display:inline-flex;align-items:center;justify-content:center;flex:none;color:var(--color-text-muted);transform:translateY(1px)}dropdown-item:focus-visible{outline:2px solid var(--color-focus-ring);outline-offset:2px}ui-popover.dropdown-popover::part(panel){min-width:192px;padding:var(--space-4)}.dropdown-list{display:flex;flex-direction:column;gap:2px}dropdown-item{display:flex;align-items:center;gap:var(--space-8);margin:0;padding:6px 12px;border-radius:var(--radius-8);font:inherit;line-height:1.2;color:inherit;font-weight:var(--font-weight-body);-webkit-user-select:none;user-select:none}dropdown-item>[data-ui-icon]{flex:none}dropdown-item[selected]{background:var(--color-overlay-active)}dropdown-item:hover,dropdown-item[action]:hover{background:var(--color-primary);color:var(--white)}dropdown-item[action]{color:inherit}dropdown-item[danger]{color:var(--color-danger)}dropdown-item[danger]:hover{background:var(--color-danger);color:var(--white)}editable-text{display:inline-block;max-width:100%;vertical-align:top}editable-text>.editable-text-span{display:inline-block;max-width:100%;outline:none;overflow:hidden;white-space:nowrap;cursor:inherit;vertical-align:top}editable-text:not([data-editing])>.editable-text-span{text-overflow:ellipsis}editable-text[data-editing]>.editable-text-span{cursor:text}modal-overlay{color:inherit}modal-overlay::part(backdrop){position:fixed;top:0;right:0;bottom:0;left:0;z-index:var(--layer-overlay);display:flex;align-items:center;justify-content:center;padding:var(--space-16);background:linear-gradient(to bottom,color-mix(in srgb,var(--black) var(--alpha-50),transparent),color-mix(in srgb,var(--black) var(--alpha-400),transparent));backdrop-filter:blur(1px);-webkit-backdrop-filter:blur(1px)}panel-view{display:block}panel-view::part(panel){display:flex;flex-direction:column;gap:var(--space-16);color:var(--color-text)}panel-view::part(header){display:flex;align-items:center;justify-content:space-between;gap:var(--space-12)}panel-view::part(title){margin:0;font:inherit;font-size:var(--text-lg);font-weight:600;color:var(--color-text)}panel-view::part(button){display:inline-flex;align-items:center;justify-content:center;width:28px;height:28px;margin:0;border:1px solid var(--color-border);border-radius:var(--radius-4);background:var(--color-surface);color:var(--color-text);box-shadow:none}panel-view::part(button):hover{background:var(--color-interactive-hover)}panel-view::part(button):focus-visible{outline:2px solid var(--color-focus-ring);outline-offset:2px}panel-view::part(icon){display:inline-flex;align-items:center;justify-content:center;flex:none}ui-popover{display:contents}ui-popover::part(panel){position:fixed;inset:0 auto auto 0;margin:0;min-width:192px;max-width:384px;padding:var(--space-16) var(--space-20);border-radius:var(--radius-12);outline:none;z-index:2000}segmented-control{display:inline-flex;align-items:stretch;box-sizing:border-box;height:var(--control-height-md)}segmented-control>button{height:auto}segmented-control[variant=ghost]{background:transparent;box-shadow:none}[tone=dark] segmented-control[variant=ghost]{border-color:var(--tint-400)}segmented-control>button{position:relative}segmented-control>button[icon-only]{width:auto;height:auto;padding:0 var(--space-6)}segmented-control>button:not([variant]):not(:disabled),[tone] segmented-control>button:not([variant]):not(:disabled){background:transparent;border:0;box-shadow:none}segmented-control>button:first-child{border-top-right-radius:0;border-bottom-right-radius:0}segmented-control>button:last-child{border-top-left-radius:0;border-bottom-left-radius:0}segmented-control>button:not(:first-child):not(:last-child){border-radius:0}segmented-control>button:not([variant]):hover:not(:disabled),[tone] segmented-control>button:not([variant]):hover:not(:disabled){background:var(--color-overlay-hover)}segmented-control>button:not([variant]):active:not(:disabled),[tone] segmented-control>button:not([variant]):active:not(:disabled){background:var(--color-overlay-active);box-shadow:none}segmented-control>button:not([variant])[aria-pressed=true]:not(:disabled),segmented-control>button:not([variant])[aria-current]:not([aria-current=false]):not(:disabled),segmented-control>button:not([variant])[aria-expanded=true]:not(:disabled),[tone] segmented-control>button:not([variant])[aria-pressed=true]:not(:disabled),[tone] segmented-control>button:not([variant])[aria-current]:not([aria-current=false]):not(:disabled),[tone] segmented-control>button:not([variant])[aria-expanded=true]:not(:disabled){background:linear-gradient(var(--color-overlay-active),var(--color-overlay-active))}segmented-control>button:not(:last-child):after{content:"";position:absolute;top:0;bottom:0;right:0;width:.5px;background:var(--tint-200);pointer-events:none}[tone=dark] segmented-control>button:not(:last-child):after{background:var(--tint-400)}segmented-control>dropdown-menu{display:inline-flex;align-items:stretch;height:auto}segmented-control>dropdown-menu>[slot=trigger]{height:auto;position:relative}segmented-control>dropdown-menu>[slot=trigger]:not([variant]):not(:disabled),[tone] segmented-control>dropdown-menu>[slot=trigger]:not([variant]):not(:disabled){background:transparent;border:0;box-shadow:none}segmented-control>dropdown-menu:first-child>[slot=trigger]{border-top-right-radius:0;border-bottom-right-radius:0}segmented-control>dropdown-menu:last-child>[slot=trigger]{border-top-left-radius:0;border-bottom-left-radius:0}segmented-control>dropdown-menu:not(:first-child):not(:last-child)>[slot=trigger]{border-radius:0}segmented-control>dropdown-menu>[slot=trigger]:not([variant]):hover:not(:disabled),[tone] segmented-control>dropdown-menu>[slot=trigger]:not([variant]):hover:not(:disabled){background:var(--color-overlay-hover)}segmented-control>dropdown-menu>[slot=trigger]:not([variant]):active:not(:disabled),[tone] segmented-control>dropdown-menu>[slot=trigger]:not([variant]):active:not(:disabled){background:var(--color-overlay-active);box-shadow:none}segmented-control>dropdown-menu>[slot=trigger]:not([variant])[aria-pressed=true]:not(:disabled),segmented-control>dropdown-menu>[slot=trigger]:not([variant])[aria-current]:not([aria-current=false]):not(:disabled),segmented-control>dropdown-menu>[slot=trigger]:not([variant])[aria-expanded=true]:not(:disabled),[tone] segmented-control>dropdown-menu>[slot=trigger]:not([variant])[aria-pressed=true]:not(:disabled),[tone] segmented-control>dropdown-menu>[slot=trigger]:not([variant])[aria-current]:not([aria-current=false]):not(:disabled),[tone] segmented-control>dropdown-menu>[slot=trigger]:not([variant])[aria-expanded=true]:not(:disabled){background:linear-gradient(var(--color-overlay-active),var(--color-overlay-active))}segmented-control[variant=glass]>button,segmented-control[variant=glass]>dropdown-menu{backdrop-filter:blur(20px) brightness(.95) saturate(1.5);-webkit-backdrop-filter:blur(20px) brightness(.95) saturate(1.5)}segmented-control[variant=glass]>button:not(:disabled):hover,segmented-control[variant=glass]>dropdown-menu:has(>[slot=trigger]:not(:disabled):hover){backdrop-filter:blur(20px) brightness(.95) saturate(1.8);-webkit-backdrop-filter:blur(20px) brightness(.95) saturate(1.8)}segmented-control[variant=glass]>button:not(:disabled):active,segmented-control[variant=glass]>dropdown-menu:has(>[slot=trigger]:not(:disabled):active){backdrop-filter:blur(20px) brightness(.95) saturate(2.2);-webkit-backdrop-filter:blur(20px) brightness(.95) saturate(2.2)}segmented-control[variant=glass]>button:not(:disabled)[aria-pressed=true],segmented-control[variant=glass]>button:not(:disabled)[aria-current]:not([aria-current=false]),segmented-control[variant=glass]>dropdown-menu:has(>[slot=trigger]:not(:disabled)[aria-pressed=true]),segmented-control[variant=glass]>dropdown-menu:has(>[slot=trigger]:not(:disabled)[aria-current]:not([aria-current=false])){backdrop-filter:blur(20px) brightness(.95) saturate(1.8);-webkit-backdrop-filter:blur(20px) brightness(.95) saturate(1.8)}segmented-control[variant=glass]>button:not(:disabled)[aria-expanded=true],segmented-control[variant=glass]>dropdown-menu:has(>[slot=trigger]:not(:disabled)[aria-expanded=true]){backdrop-filter:blur(20px) brightness(.95) saturate(2);-webkit-backdrop-filter:blur(20px) brightness(.95) saturate(2)}segmented-control>dropdown-menu:not(:last-child):after{content:"";position:absolute;top:0;bottom:0;right:0;width:.5px;background:var(--tint-200);pointer-events:none}[tone=dark] segmented-control>dropdown-menu:not(:last-child):after{background:var(--tint-400)}ui-spinner{display:inline-flex;align-items:center;justify-content:center;line-height:0;color:inherit}ui-spinner .spin,.spin{display:inline-flex;animation:ui-spinner-spin 1s steps(8,end) infinite}@keyframes ui-spinner-spin{to{transform:rotate(360deg)}}@media (prefers-reduced-motion: reduce){.spin{animation:none}}system-modal{display:flex;flex-direction:column;width:min(400px,100%);box-sizing:border-box;padding:var(--space-32) var(--space-24);border-radius:var(--radius-12)}system-modal header{display:flex;flex-direction:column;align-items:center;gap:var(--space-16);text-align:center}system-modal header>hgroup{display:flex;flex-direction:column;align-items:center;gap:var(--space-4);max-width:100%}system-modal header h2{margin:0;font-size:var(--text-lg);font-weight:600;letter-spacing:.01em;max-width:100%;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}system-modal header p{margin:0;font-size:var(--text-base);opacity:.7;max-width:100%;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}ui-pill{display:inline-block;vertical-align:baseline;margin:2px 0;padding:0 var(--space-8);font-size:var(--text-sm);font-weight:500;line-height:1.7;border-radius:var(--radius-full);border:1px solid var(--neutral-300);background:var(--neutral-200);color:var(--neutral-900);white-space:nowrap}ui-pill[color=gray]{border-color:var(--neutral-300);background:var(--neutral-200);color:var(--neutral-900)}ui-pill[color=red]{border-color:var(--red-200);background:var(--red-100);color:var(--red-950)}ui-pill[color=orange]{border-color:var(--orange-200);background:var(--orange-100);color:var(--orange-950)}ui-pill[color=yellow]{border-color:var(--yellow-200);background:var(--yellow-100);color:var(--yellow-950)}ui-pill[color=green]{border-color:var(--green-200);background:var(--green-100);color:var(--green-950)}ui-pill[color=blue]{border-color:var(--blue-200);background:var(--blue-100);color:var(--blue-950)}ui-pill[color=purple]{border-color:var(--purple-200);background:var(--purple-100);color:var(--purple-950)}',Ld=new CSSStyleSheet;Ld.replaceSync(V1);const Dd=new CSSStyleSheet;try{document.adoptedStyleSheets=[...document.adoptedStyleSheets,Ld,Dd]}catch{}Jv(document);function Xv(r){Dd.replaceSync(r)}function Rl(){Xv("")}function zd(r){try{r.adoptedStyleSheets=[...r.adoptedStyleSheets,Ld,Dd]}catch{}Jv(r)}const G1=new Set(["target","currentTarget","eventPhase","defaultPrevented","isTrusted","timeStamp","srcElement","returnValue","cancelBubble","NONE","CAPTURING_PHASE","AT_TARGET","BUBBLING_PHASE","composedPath","stopPropagation","stopImmediatePropagation","preventDefault","initEvent"]);function q1(r){for(const t of Object.keys(r))if(G1.has(t))throw new Error(`Event payload key "${t}" is reserved; choose a different property name`)}function Y1(r,t){q1(t);for(const e of Object.keys(t))Object.defineProperty(r,e,{value:t[e],writable:!0,enumerable:!0,configurable:!0})}function je(){class r extends Event{constructor(e,n){const{type:i,bubbles:s,cancelable:o,composed:a,...c}=n??{};if(i!==void 0)throw new Error('Do not pass "type" in init; use the constructor argument instead');super(e,{bubbles:s,cancelable:o,composed:a}),Y1(this,c)}}return r}class Ot extends globalThis.EventTarget{}function K1(r,t,e){const n=r.dispose.bind(r);r.dispose=()=>{if(!t())return e(),n()}}function Sa(r){var e;class t extends r{constructor(...s){super(...s);S(this,e,!1);K1(this,()=>l(this,e),()=>{w(this,e,!0)})}[Symbol.dispose](){this.dispose()}get disposed(){return l(this,e)}}return e=new WeakMap,t}const J1=je(),X1=je(),Q1=je(),Zs=je(),Qv=je(),e$=je(),gu=je(),qe=4,ft=6,ao=2,Ku=2,Od=8,t$=ft,Md="auto",Xr="auto",Or=128,bg=50,ae=16,Vn=Or*qe+ae*(qe-1),lo=Or*ft+ae*(ft-1),r$=Vn+ae*2,n$=200,i$=4,Za=150,s$=10,wg=2,Sg=8,o$=300,a$=4;function ey(r){return ny(r)}function ty(r,t){return ny(r.flatMap(e=>sy(e,t)))}function ry(r){const t=[],e=new Set;for(const n of r){if(n.type==="row"){t.push(`Top-level rows are invalid: ${n.id}`);continue}oy(n,"strip",t,e)}return{valid:t.length===0,errors:t}}function kn(r){const t=ey(r),e=ry(t);if(!e.valid)throw new Error(`Invalid layout: ${e.errors.join("; ")}`);return{totalNodes:t.length,nodes:t.filter(n=>n.type!=="row").map(h$)}}function ny(r){const t=[];for(const e of r){const n=iy(e);for(const i of n){if(i.type==="row"){t.push(...i.children.map($r));continue}t.push(i)}}return t}function iy(r){switch(r.type){case"card":return[$r(r)];case"row":{const t=r.children.map($r);return t.length===0?[]:t.length===1?[t[0]]:[{...r,children:t}]}case"stack":{const t=[];for(const e of r.children){const n=iy(e);for(const i of n){if(i.type==="stack"){t.push(...i.children.map(Ju));continue}if(i.type==="row"){t.push({...i,children:i.children.map($r)});continue}t.push($r(i))}}return t.length===0?[]:t.length===1?[Ju(t[0])]:[{...r,children:t}]}}}function sy(r,t){switch(r.type){case"card":return r.artifactID===t?[]:[$r(r)];case"row":{const e=r.children.filter(n=>n.artifactID!==t).map($r);return e.length===0?[]:e.length===1?[e[0]]:[{...r,children:e}]}case"stack":{const e=r.children.flatMap(n=>sy(n,t).filter(s=>s.type!=="stack"));return e.length===0?[]:e.length===1?[Ju(e[0])]:[{...r,children:e}]}}}function oy(r,t,e,n){switch(r.type){case"card":ay(r,t,e,n);return;case"row":l$(r,t,e,n);return;case"stack":c$(r,t,e,n);return}}function ay(r,t,e,n){"id"in r&&e.push(`Card ${Ps(r)} must not include id`),typeof r.artifactID!="string"||r.artifactID.length===0?e.push("Card is missing artifactID"):n.has(r.artifactID)?e.push(`Duplicate artifactID in layout: ${r.artifactID}`):n.add(r.artifactID),u$(r.width)||e.push(`Card ${Ps(r)} width must be an integer in the range ${ao}-${Od}`),cy(r.height)||e.push(`Card ${Ps(r)} height must be an integer in the range 2-6 or "auto"`);const i=Ai(r.width);t==="stack"&&i!==qe&&e.push(`Stack child ${Ps(r)} width must be ${qe}`),t==="row"&&i<ao&&e.push(`Row child ${Ps(r)} must be at least 2 columns wide`)}function Ps(r){return typeof r.artifactID=="string"&&r.artifactID.length>0?r.artifactID:"<missing artifactID>"}function l$(r,t,e,n){if(ly(r.id,e),t!=="stack"&&e.push(`Row ${r.id} may only appear inside a stack`),cy(r.height,a$)||e.push(`Row ${r.id} height must be an integer in the range 2-4 or "auto"`),!Array.isArray(r.children)||r.children.length===0){e.push(`Row ${r.id} must contain card nodes`);return}let i=0;for(const s of r.children){if(s.type!=="card"){e.push(`Row ${r.id} must contain only card nodes`);continue}ay(s,"row",e,n),i+=Ai(s.width)}i!==qe&&e.push(`Row ${r.id} children must sum to 4 columns`)}function c$(r,t,e,n){if(ly(r.id,e),t!=="strip"&&e.push(`Invalid nested stack at ${r.id}; stack children cannot contain another nested stack`),!Array.isArray(r.children)||r.children.length===0){e.push(`Stack ${r.id} must contain at least one child`);return}let i=0,s=0;for(const a of r.children){if(a.type==="stack"){e.push(`Stack ${r.id} cannot contain another nested stack`);continue}if(oy(a,"stack",e,n),a.height===Xr){s+=1;continue}i+=a.height}if(i>ft&&e.push(`Stack ${r.id} exceeds the 6-row budget`),s===0)return;const o=ft-i;if(o<s*Ku||o%s!==0){e.push(`Stack ${r.id} has auto-height children that cannot resolve to whole height >= 2`);return}o/s<Ku&&e.push(`Stack ${r.id} has auto-height children below the minimum row size`)}function ly(r,t){(typeof r!="string"||r.length===0)&&t.push(`Node id must be a non-empty string: ${String(r)}`)}function u$(r){return r===Md||Number.isInteger(r)&&r>=ao&&r<=Od}function cy(r,t=t$){return r===Xr||Number.isInteger(r)&&r>=Ku&&r<=t}function Ai(r){return r===Md?qe:r}function h$(r){if(r.type==="card")return{id:r.artifactID,type:"card",width:Ai(r.width),cards:[{id:r.artifactID,artifactID:r.artifactID,col:1,row:1,width:Ai(r.width),height:uy(r.height,ft)}]};const t=d$(r.children),e=[];let n=1;for(let i=0;i<r.children.length;i+=1){const s=r.children[i],o=t[i];if(s.type==="card")e.push({id:s.artifactID,artifactID:s.artifactID,col:1,row:n,width:qe,height:o});else{let a=1;for(const c of s.children)e.push({id:c.artifactID,artifactID:c.artifactID,col:a,row:n,width:Ai(c.width),height:o}),a+=Ai(c.width)}n+=o}return{id:r.id,type:"stack",width:e.reduce((i,s)=>Math.max(i,s.col+s.width-1),1),cards:e}}function d$(r){let t=0,e=0;for(const i of r)i.height===Xr?e+=1:t+=i.height;const n=e>0?(ft-t)/e:0;return r.map(i=>uy(i.height,n))}function uy(r,t){return r===Xr?t:r}function $r(r){return{...r}}function Ju(r){return r.type==="card"?$r(r):{...r,children:r.children.map($r)}}function hy(r,t={}){return{type:"card",artifactID:r,width:t.width??Md,height:t.height??Xr}}function ol(r){return r.layout.flatMap(dy)}function dy(r){switch(r.type){case"card":return[r.artifactID];case"row":return r.children.map(t=>t.artifactID);case"stack":return r.children.flatMap(dy)}}const oe=je(),Xu=je(),pi=je(),_g=je();function p$(r){class t extends Error{constructor(n,i){super(n),this.name=r,i&&Object.assign(this,i)}}return t}const Nd=p$("RequestError"),f$=200,g$=300,Wa=401;class m${constructor(t,e){g(this,"serverURL");g(this,"token");g(this,"onUnauthorized");this.serverURL=t.replace(/\/$/,""),this.token=e.token,this.onUnauthorized=e.onUnauthorized}async requestJSON(t,e,n){var o;const i=await this.request(t,e,n!==void 0?JSON.stringify(n):void 0,n!==void 0?{"content-type":"application/json"}:void 0),s=await v$(i);if(!i.ok||i.status<f$||i.status>=g$)throw i.status===Wa&&((o=this.onUnauthorized)==null||o.call(this)),this.createError(typeof s.error=="string"?s.error:i.statusText,i.status);return s}async requestVoid(t,e,n){var s;const i=await this.request(t,e,n!==void 0?JSON.stringify(n):void 0,n!==void 0?{"content-type":"application/json"}:void 0);if(!i.ok)throw i.status===Wa&&((s=this.onUnauthorized)==null||s.call(this)),this.createError(await mu(i,i.statusText),i.status)}async requestText(t,e){var i;const n=await this.request(t,e);if(!n.ok)throw n.status===Wa&&((i=this.onUnauthorized)==null||i.call(this)),this.createError(await mu(n,n.statusText),n.status);return n.text()}async requestRawVoid(t,e,n){var s;const i=await this.request(t,e,n,{"content-type":"text/markdown; charset=utf-8"});if(!i.ok)throw i.status===Wa&&((s=this.onUnauthorized)==null||s.call(this)),this.createError(await mu(i,i.statusText),i.status)}createError(t,e){const n={serverURL:this.serverURL};return e!==void 0&&(n.status=e),new Nd(t,n)}async request(t,e,n,i){const s=`${this.serverURL}${e}`;try{return await fetch(s,{method:t,headers:this.buildHeaders(i),body:n})}catch(o){throw this.createError(o instanceof Error?o.message:"Failed to reach server")}}buildHeaders(t){const e={...t??{}};return this.token&&(e.Authorization=`Bearer ${this.token}`),Object.keys(e).length>0?e:void 0}}async function v$(r){try{return await r.json()}catch{const t=await r.text().catch(()=>"");return t?{message:t}:{}}}async function mu(r,t){try{const e=await r.json();if(typeof e.error=="string")return e.error;if(typeof e.message=="string")return e.message}catch{}return t}function y$(r){return r.map(t=>`${t.name} (${t.id})`).join(", ")}var jt,jl,py;class b${constructor(t){S(this,jl);S(this,jt);w(this,jt,t)}list(){return l(this,jt).requestJSON("GET","/screens")}async get(t={}){const e=await p(this,jl,py).call(this,t.screenID);return l(this,jt).requestJSON("GET",`/screens/${encodeURIComponent(e)}`)}create(t){const e={name:t.name};return t.id!==void 0&&(e.id=t.id),l(this,jt).requestJSON("POST","/screens",e)}update(t){const{screenID:e,...n}=t;return l(this,jt).requestJSON("PATCH",`/screens/${encodeURIComponent(e)}`,n)}remove(t){return l(this,jt).requestJSON("DELETE",`/screens/${encodeURIComponent(t.screenID)}`)}}jt=new WeakMap,jl=new WeakSet,py=async function(t){if(t!==void 0)return t;const{screens:e}=await this.list();if(e.length===1)return e[0].id;throw l(this,jt).createError(`screenID is required when multiple screens exist. Available screens: ${y$(e)}`)};var br;class w${constructor(t){S(this,br);w(this,br,t)}create(t){const e={kind:t.kind,title:t.title};switch(t.kind){case"path":e.path=t.path;break;case"url":e.url=t.url;break}return e.screenID=t.screenID,l(this,br).requestJSON("POST","/artifacts",e)}list(t={}){const e=new URLSearchParams;t.screenID!==void 0&&e.set("screenID",t.screenID);const n=e.toString();return l(this,br).requestJSON("GET",n?`/artifacts?${n}`:"/artifacts")}get(t){return l(this,br).requestJSON("GET",`/artifacts/${encodeURIComponent(t.artifactID)}`)}update(t){const e={};return t.title!==void 0&&(e.title=t.title),t.path!==void 0&&(e.path=t.path),t.url!==void 0&&(e.url=t.url),l(this,br).requestJSON("PATCH",`/artifacts/${encodeURIComponent(t.artifactID)}`,e)}delete(t){return l(this,br).requestJSON("DELETE",`/artifacts/${encodeURIComponent(t.artifactID)}`)}}br=new WeakMap;var Di;class S${constructor(t){S(this,Di);w(this,Di,t)}get(t){return l(this,Di).requestText("GET",`/markdown/${encodeURIComponent(t.artifactID)}`)}update(t){return l(this,Di).requestRawVoid("PUT",`/markdown/${encodeURIComponent(t.artifactID)}`,t.content)}}Di=new WeakMap;var An;class _${constructor(t){S(this,An);w(this,An,t)}get(){return l(this,An).requestJSON("GET","/display")}patch(t){const e={};return t.activeScreenID!==void 0&&(e.activeScreenID=t.activeScreenID),t.activeThemeName!==void 0&&(e.activeThemeName=t.activeThemeName),l(this,An).requestVoid("PATCH","/display",e)}focus(t){return l(this,An).requestJSON("POST","/display/focus",{artifactID:t.artifactID})}}An=new WeakMap;var wr;class k${constructor(t,e={}){g(this,"screens");g(this,"artifacts");g(this,"display");g(this,"markdown");S(this,wr);w(this,wr,new m$(t,e)),this.screens=new b$(l(this,wr)),this.artifacts=new w$(l(this,wr)),this.display=new _$(l(this,wr)),this.markdown=new S$(l(this,wr))}health(){return l(this,wr).requestJSON("GET","/health")}}wr=new WeakMap;const x$={focusCommandInput:{label:"Focus Command Input",trigger:{key:"k",meta:!0}}},E$="Local",A$="store-";function he(r){return new URL(r).origin}function $$(r){return{servers:[{url:he(r),name:E$}],activeServerURL:null,activeScreenID:null,tabs:{},screens:{},authTokens:{}}}function T$(r,t){return[...r.tabs[he(t)]??[]]}function I$(r,t,e){const n=he(t),i=r.tabs[n]??[];return i.includes(e)?r:{...r,tabs:{...r.tabs,[n]:[...i,e]}}}function C$(r,t,e){const n=he(t),i=r.tabs[n]??[],s=i.filter(a=>a!==e);if(s.length===i.length)return r;const o={...r.tabs};return s.length===0?delete o[n]:o[n]=s,{...r,tabs:o}}function R$(r,t,e=Date.now()){const n=r.screens[t]??{scrollPosition:0};return{...r,screens:{...r.screens,[t]:{...n,lastActivatedAt:e}}}}var $n,Tn,In;class P$ extends Ot{constructor(e,n,i={}){super();S(this,$n);S(this,Tn);S(this,In);w(this,$n,`${A$}${e}`),w(this,Tn,i.storage??z$());const s=l(this,Tn).getItem(l(this,$n));s===null?(w(this,In,n),l(this,Tn).setItem(l(this,$n),JSON.stringify(n))):w(this,In,O$(JSON.parse(s),n))}get(){return l(this,In)}set(e){w(this,In,e),l(this,Tn).setItem(l(this,$n),JSON.stringify(e)),this.dispatchEvent(new oe("change"))}}$n=new WeakMap,Tn=new WeakMap,In=new WeakMap;function vu(r,t){return r.authTokens[he(t)]??null}function L$(r,t,e){return{...r,authTokens:{...r.authTokens,[he(t)]:e}}}function D$(r,t){const e=he(t);if(!(e in r.authTokens))return r;const n={...r.authTokens};return delete n[e],{...r,authTokens:n}}function z$(){const r=globalThis.localStorage;if(!r)throw new Error("LocalStore: no storage adapter supplied and window.localStorage is unavailable");return r}function O$(r,t){return{servers:Array.isArray(r.servers)?r.servers:t.servers,activeServerURL:typeof r.activeServerURL=="string"||r.activeServerURL===null?r.activeServerURL:t.activeServerURL,activeScreenID:typeof r.activeScreenID=="string"||r.activeScreenID===null?r.activeScreenID:t.activeScreenID,tabs:r.tabs&&typeof r.tabs=="object"?r.tabs:t.tabs,screens:r.screens&&typeof r.screens=="object"?r.screens:t.screens,authTokens:r.authTokens&&typeof r.authTokens=="object"?r.authTokens:t.authTokens}}class M$ extends Event{constructor(){super("theme-changed")}}const N$=Sa(Ot);var Cn,Ne,Nr,Ge,Ur,Sr,go,ee,mn,fy,mo,gy,my,vy,yy,Qu,eh,th,by;class U$ extends N${constructor(e){var i;super();S(this,ee);g(this,"id");g(this,"server");S(this,Cn);S(this,Ne,new Map);S(this,Nr);S(this,Ge);S(this,Ur);S(this,Sr,null);S(this,go,0);S(this,mo,e=>{if(this.disposed)return;const n=e.event;switch(n.type){case"screen-updated":n.screen.id===this.id&&p(this,ee,gy).call(this,n.screen);break;case"artifact-created":n.screenID===this.id&&p(this,ee,my).call(this,n.artifact);break;case"artifact-updated":p(this,ee,vy).call(this,n.artifact);break;case"artifact-removed":n.screenID===this.id&&p(this,ee,yy).call(this,n.artifactID);break;case"artifact-content-changed":l(this,Ne).has(n.artifactID)&&this.dispatchEvent(new _g("artifact-content-changed",{artifactID:n.artifactID}));break;case"theme-changed":this.dispatchEvent(new M$);break}});this.id=e.screen.id,this.server=e.server,w(this,Cn,e.localStore),w(this,Nr,e.screen.name),w(this,Ge,structuredClone(e.screen.layout));const n=((i=l(this,Cn).get().screens[this.id])==null?void 0:i.scrollPosition)??0;w(this,Ur,Math.max(0,n)),this.server.addEventListener("server-event",l(this,mo)),p(this,ee,fy).call(this)}get name(){return l(this,Nr)}get layout(){return l(this,Ge)}get scrollPosition(){return l(this,Ur)}get artifacts(){return l(this,Ne)}setScrollPosition(e){p(this,ee,mn).call(this);const n=Math.max(0,e);n!==l(this,Ur)&&(w(this,Ur,n),p(this,ee,by).call(this),this.dispatchEvent(new oe("change")))}setLayout(e){p(this,ee,mn).call(this);const n=ey(e);if(!ry(n).valid)return;const s=p(this,ee,eh).call(this);w(this,Ge,n),w(this,Sr,{layout:n,snapshot:s}),this.dispatchEvent(new oe("change")),this.server.client.screens.update({screenID:this.id,layout:n.map(o=>structuredClone(o))}).catch(()=>{var o;this.disposed||((o=l(this,Sr))==null?void 0:o.layout)===n&&(w(this,Sr,null),p(this,ee,th).call(this,s),this.dispatchEvent(new oe("change")))})}rename(e){p(this,ee,mn).call(this),w(this,Nr,e),this.dispatchEvent(new oe("change")),this.server.client.screens.update({screenID:this.id,name:e}).catch(()=>{})}async remove(){p(this,ee,mn).call(this),await this.server.client.screens.remove({screenID:this.id})}removeArtifact(e){if(p(this,ee,mn).call(this),!l(this,Ne).has(e))return;const n=p(this,ee,eh).call(this);p(this,ee,Qu).call(this,e),this.dispatchEvent(new oe("change")),this.server.client.artifacts.delete({artifactID:e}).catch(()=>{this.disposed||(p(this,ee,th).call(this,n),this.dispatchEvent(new oe("change")))})}async refreshFromServer(){p(this,ee,mn).call(this);const e=++Zc(this,go)._;let n;try{n=await this.server.client.screens.get({screenID:this.id})}catch{return}if(this.disposed||e!==l(this,go))return;const i=new Set([...l(this,Ne).values()].filter(s=>s.kind==="path").map(s=>s.id));w(this,Sr,null),w(this,Nr,n.screen.name),w(this,Ge,structuredClone(n.screen.layout)),l(this,Ne).clear();for(const s of n.artifacts)l(this,Ne).set(s.id,s);this.dispatchEvent(new oe("change"));for(const s of n.artifacts)s.kind==="path"&&i.has(s.id)&&this.dispatchEvent(new _g("artifact-content-changed",{artifactID:s.id}))}dispose(){this.server.removeEventListener("server-event",l(this,mo))}}Cn=new WeakMap,Ne=new WeakMap,Nr=new WeakMap,Ge=new WeakMap,Ur=new WeakMap,Sr=new WeakMap,go=new WeakMap,ee=new WeakSet,mn=function(){if(this.disposed)throw new Error("ScreenModel is disposed")},fy=async function(){try{const e=await this.server.client.screens.get({screenID:this.id});if(this.disposed)return;for(const n of e.artifacts)l(this,Ne).set(n.id,n);this.dispatchEvent(new oe("change"))}catch{}},mo=new WeakMap,gy=function(e){l(this,Sr)&&w(this,Sr,null),w(this,Nr,e.name),w(this,Ge,structuredClone(e.layout)),this.dispatchEvent(new oe("change"))},my=function(e){ol({layout:l(this,Ge)}).includes(e.id)||w(this,Ge,[...l(this,Ge),hy(e.id)]),l(this,Ne).set(e.id,e),this.dispatchEvent(new oe("change"))},vy=function(e){const n=l(this,Ne).get(e.id);n&&(l(this,Ne).set(e.id,{...n,...e}),this.dispatchEvent(new oe("change")))},yy=function(e){p(this,ee,Qu).call(this,e)&&this.dispatchEvent(new oe("change"))},Qu=function(e){const n=l(this,Ne).delete(e),i=ol({layout:l(this,Ge)}).length,s=ty(l(this,Ge),e),o=ol({layout:s}).length;return w(this,Ge,s),n||i!==o},eh=function(){return{layout:structuredClone(l(this,Ge)),artifacts:new Map([...l(this,Ne).entries()].map(([e,n])=>[e,structuredClone(n)]))}},th=function(e){w(this,Ge,structuredClone(e.layout)),l(this,Ne).clear();for(const[n,i]of e.artifacts)l(this,Ne).set(n,structuredClone(i))},by=function(){const e=l(this,Cn).get();l(this,Cn).set({...e,screens:{...e.screens,[this.id]:{...e.screens[this.id],scrollPosition:l(this,Ur)}}})};const F$=Sa(Ot);var Pe,Ue,At,vo,yo,bo,wo,Xe,al,rh,vi;class H$ extends F${constructor(e){super();S(this,Xe);S(this,Pe);S(this,Ue);S(this,At,null);S(this,vo,()=>{this.disposed||p(this,Xe,al).call(this)});S(this,yo,()=>{this.disposed||p(this,Xe,al).call(this)});S(this,bo,e=>{if(this.disposed)return;const n=e.event;if(n.type==="screen-removed"){this.removeTab(e.serverURL,n.screenID);const i=l(this,Pe).get();i.activeServerURL===he(e.serverURL)&&i.activeScreenID===n.screenID&&p(this,Xe,vi).call(this,e.serverURL,null);return}if(n.type==="screen-changed"){if(n.screenID===null){p(this,Xe,vi).call(this,e.serverURL,null);return}const i=l(this,Ue).servers.get(he(e.serverURL));if(!i||!i.screens.has(n.screenID))return;this.addTab(e.serverURL,n.screenID),p(this,Xe,vi).call(this,e.serverURL,n.screenID)}});S(this,wo,e=>{if(this.disposed)return;const n=l(this,At);n&&he(e.serverURL)===he(n.server.url)&&n.refreshFromServer()});w(this,Pe,e.localStore),w(this,Ue,e.serverManager),l(this,Pe).addEventListener("change",l(this,vo)),l(this,Ue).addEventListener("change",l(this,yo)),l(this,Ue).addEventListener("server-event",l(this,bo)),l(this,Ue).addEventListener("server-reconnected",l(this,wo)),p(this,Xe,al).call(this)}get activeScreen(){return l(this,At)}get screens(){const e=l(this,Pe).get().screens,n=[];let i=0;for(const s of l(this,Ue).servers.values())for(const o of s.screens.values())n.push({server:s,screen:o,local:e[o.id]??{scrollPosition:0},index:i}),i+=1;return n.sort((s,o)=>{const a=(o.local.lastActivatedAt??0)-(s.local.lastActivatedAt??0);return a===0?s.index-o.index:a}).map(({index:s,...o})=>o)}getTabs(e){const n=he(e),i=T$(l(this,Pe).get(),n),s=l(this,Ue).servers.get(n);return s?i.filter(o=>s.screens.has(o)):i}hasTab(e,n){return this.getTabs(e).includes(n)}addTab(e,n){const i=he(e),s=l(this,Ue).servers.get(i);s&&!s.screens.has(n)||p(this,Xe,rh).call(this,I$(l(this,Pe).get(),i,n))}removeTab(e,n){p(this,Xe,rh).call(this,C$(l(this,Pe).get(),e,n))}setActive(e,n){const i=he(e),s=l(this,Ue).servers.get(i);!s||!s.screens.has(n)||p(this,Xe,vi).call(this,i,n)&&s.client.display.patch({activeScreenID:n}).catch(()=>{})}clearActive(){const e=l(this,Pe).get().activeServerURL;if(!e||!p(this,Xe,vi).call(this,e,null))return;const n=l(this,Ue).servers.get(e);n==null||n.client.display.patch({activeScreenID:null}).catch(()=>{})}dispose(){var e;l(this,Pe).removeEventListener("change",l(this,vo)),l(this,Ue).removeEventListener("change",l(this,yo)),l(this,Ue).removeEventListener("server-event",l(this,bo)),l(this,Ue).removeEventListener("server-reconnected",l(this,wo)),(e=l(this,At))==null||e.dispose(),w(this,At,null)}}Pe=new WeakMap,Ue=new WeakMap,At=new WeakMap,vo=new WeakMap,yo=new WeakMap,bo=new WeakMap,wo=new WeakMap,Xe=new WeakSet,al=function(){var c,u,h;const{activeServerURL:e,activeScreenID:n}=l(this,Pe).get(),i=e?l(this,Ue).servers.get(e)??null:null,s=i&&n?i.screens.get(n)??null:null,o=((c=l(this,At))==null?void 0:c.id)??null,a=(s==null?void 0:s.id)??null;o===a&&((u=l(this,At))==null?void 0:u.server)===i||((h=l(this,At))==null||h.dispose(),w(this,At,i&&s?new U$({screen:s,server:i,localStore:l(this,Pe)}):null),i&&i.acpClient.setScreenContext(s?{screenID:s.id,screenName:s.name}:null),this.dispatchEvent(new J1("active-screen-changed")))},rh=function(e){e!==l(this,Pe).get()&&(l(this,Pe).set(e),this.dispatchEvent(new X1("tabs-changed")))},vi=function(e,n){const i=he(e),s=l(this,Pe).get();if(s.activeServerURL===i&&s.activeScreenID===n)return!1;const o=n===null?{...s,activeServerURL:i,activeScreenID:n}:R$({...s,activeServerURL:i,activeScreenID:n},n);return l(this,Pe).set(o),!0};const wy="0123456789ABCDEFGHJKMNPQRSTVWXYZ",Pl=32,Z$=16,Sy=10,kg=0xffffffffffff;var xn;(function(r){r.Base32IncorrectEncoding="B32_ENC_INVALID",r.DecodeTimeInvalidCharacter="DEC_TIME_CHAR",r.DecodeTimeValueMalformed="DEC_TIME_MALFORMED",r.EncodeTimeNegative="ENC_TIME_NEG",r.EncodeTimeSizeExceeded="ENC_TIME_SIZE_EXCEED",r.EncodeTimeValueMalformed="ENC_TIME_MALFORMED",r.PRNGDetectFailure="PRNG_DETECT",r.ULIDInvalid="ULID_INVALID",r.Unexpected="UNEXPECTED",r.UUIDInvalid="UUID_INVALID"})(xn||(xn={}));class Ws extends Error{constructor(t,e){super(`${e} (${t})`),this.name="ULIDError",this.code=t}}function W$(r){const t=Math.floor(r()*Pl)%Pl;return wy.charAt(t)}function B$(r){const t=j$(),e=t&&(t.crypto||t.msCrypto)||null;if(typeof(e==null?void 0:e.getRandomValues)=="function")return()=>{const n=new Uint8Array(1);return e.getRandomValues(n),n[0]/256};if(typeof(e==null?void 0:e.randomBytes)=="function")return()=>e.randomBytes(1).readUInt8()/256;throw new Ws(xn.PRNGDetectFailure,"Failed to find a reliable PRNG")}function j$(){return q$()?self:typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:null}function V$(r,t){let e="";for(;r>0;r--)e=W$(t)+e;return e}function G$(r,t=Sy){if(isNaN(r))throw new Ws(xn.EncodeTimeValueMalformed,`Time must be a number: ${r}`);if(r>kg)throw new Ws(xn.EncodeTimeSizeExceeded,`Cannot encode a time larger than ${kg}: ${r}`);if(r<0)throw new Ws(xn.EncodeTimeNegative,`Time must be positive: ${r}`);if(Number.isInteger(r)===!1)throw new Ws(xn.EncodeTimeValueMalformed,`Time must be an integer: ${r}`);let e,n="";for(let i=t;i>0;i--)e=r%Pl,n=wy.charAt(e)+n,r=(r-e)/Pl;return n}function q$(){return typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope}function Ud(r,t){const e=B$(),n=Date.now();return G$(n,Sy)+V$(Z$,e)}function A(r,t,e){function n(a,c){if(a._zod||Object.defineProperty(a,"_zod",{value:{def:c,constr:o,traits:new Set},enumerable:!1}),a._zod.traits.has(r))return;a._zod.traits.add(r),t(a,c);const u=o.prototype,h=Object.keys(u);for(let f=0;f<h.length;f++){const y=h[f];y in a||(a[y]=u[y].bind(a))}}const i=(e==null?void 0:e.Parent)??Object;class s extends i{}Object.defineProperty(s,"name",{value:r});function o(a){var c;const u=e!=null&&e.Parent?new s:this;n(u,a),(c=u._zod).deferred??(c.deferred=[]);for(const h of u._zod.deferred)h();return u}return Object.defineProperty(o,"init",{value:n}),Object.defineProperty(o,Symbol.hasInstance,{value:a=>{var c,u;return e!=null&&e.Parent&&a instanceof e.Parent?!0:(u=(c=a==null?void 0:a._zod)==null?void 0:c.traits)==null?void 0:u.has(r)}}),Object.defineProperty(o,"name",{value:r}),o}class Ri extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class _y extends Error{constructor(t){super(`Encountered unidirectional transform during encode: ${t}`),this.name="ZodEncodeError"}}const ky={};function Qr(r){return ky}function xy(r){const t=Object.values(r).filter(n=>typeof n=="number");return Object.entries(r).filter(([n,i])=>t.indexOf(+n)===-1).map(([n,i])=>i)}function nh(r,t){return typeof t=="bigint"?t.toString():t}function gc(r){return{get value(){{const t=r();return Object.defineProperty(this,"value",{value:t}),t}}}}function Fd(r){return r==null}function Hd(r){const t=r.startsWith("^")?1:0,e=r.endsWith("$")?r.length-1:r.length;return r.slice(t,e)}function Y$(r,t){const e=(r.toString().split(".")[1]||"").length,n=t.toString();let i=(n.split(".")[1]||"").length;if(i===0&&/\d?e-\d?/.test(n)){const c=n.match(/\d?e-(\d?)/);c!=null&&c[1]&&(i=Number.parseInt(c[1]))}const s=e>i?e:i,o=Number.parseInt(r.toFixed(s).replace(".","")),a=Number.parseInt(t.toFixed(s).replace(".",""));return o%a/10**s}const xg=Symbol("evaluating");function te(r,t,e){let n;Object.defineProperty(r,t,{get(){if(n!==xg)return n===void 0&&(n=xg,n=e()),n},set(i){Object.defineProperty(r,t,{value:i})},configurable:!0})}function ti(r,t,e){Object.defineProperty(r,t,{value:e,writable:!0,enumerable:!0,configurable:!0})}function on(...r){const t={};for(const e of r){const n=Object.getOwnPropertyDescriptors(e);Object.assign(t,n)}return Object.defineProperties({},t)}function Eg(r){return JSON.stringify(r)}function K$(r){return r.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}const Ey="captureStackTrace"in Error?Error.captureStackTrace:(...r)=>{};function co(r){return typeof r=="object"&&r!==null&&!Array.isArray(r)}const J$=gc(()=>{var r;if(typeof navigator<"u"&&((r=navigator==null?void 0:navigator.userAgent)!=null&&r.includes("Cloudflare")))return!1;try{const t=Function;return new t(""),!0}catch{return!1}});function cs(r){if(co(r)===!1)return!1;const t=r.constructor;if(t===void 0||typeof t!="function")return!0;const e=t.prototype;return!(co(e)===!1||Object.prototype.hasOwnProperty.call(e,"isPrototypeOf")===!1)}function Ay(r){return cs(r)?{...r}:Array.isArray(r)?[...r]:r}const X$=new Set(["string","number","symbol"]);function us(r){return r.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function an(r,t,e){const n=new r._zod.constr(t??r._zod.def);return(!t||e!=null&&e.parent)&&(n._zod.parent=r),n}function O(r){const t=r;if(!t)return{};if(typeof t=="string")return{error:()=>t};if((t==null?void 0:t.message)!==void 0){if((t==null?void 0:t.error)!==void 0)throw new Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error=="string"?{...t,error:()=>t.error}:t}function Q$(r){return Object.keys(r).filter(t=>r[t]._zod.optin==="optional"&&r[t]._zod.optout==="optional")}const eT={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 tT(r,t){const e=r._zod.def,n=e.checks;if(n&&n.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");const s=on(r._zod.def,{get shape(){const o={};for(const a in t){if(!(a in e.shape))throw new Error(`Unrecognized key: "${a}"`);t[a]&&(o[a]=e.shape[a])}return ti(this,"shape",o),o},checks:[]});return an(r,s)}function rT(r,t){const e=r._zod.def,n=e.checks;if(n&&n.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");const s=on(r._zod.def,{get shape(){const o={...r._zod.def.shape};for(const a in t){if(!(a in e.shape))throw new Error(`Unrecognized key: "${a}"`);t[a]&&delete o[a]}return ti(this,"shape",o),o},checks:[]});return an(r,s)}function nT(r,t){if(!cs(t))throw new Error("Invalid input to extend: expected a plain object");const e=r._zod.def.checks;if(e&&e.length>0){const s=r._zod.def.shape;for(const o in t)if(Object.getOwnPropertyDescriptor(s,o)!==void 0)throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}const i=on(r._zod.def,{get shape(){const s={...r._zod.def.shape,...t};return ti(this,"shape",s),s}});return an(r,i)}function iT(r,t){if(!cs(t))throw new Error("Invalid input to safeExtend: expected a plain object");const e=on(r._zod.def,{get shape(){const n={...r._zod.def.shape,...t};return ti(this,"shape",n),n}});return an(r,e)}function sT(r,t){const e=on(r._zod.def,{get shape(){const n={...r._zod.def.shape,...t._zod.def.shape};return ti(this,"shape",n),n},get catchall(){return t._zod.def.catchall},checks:[]});return an(r,e)}function oT(r,t,e){const i=t._zod.def.checks;if(i&&i.length>0)throw new Error(".partial() cannot be used on object schemas containing refinements");const o=on(t._zod.def,{get shape(){const a=t._zod.def.shape,c={...a};if(e)for(const u in e){if(!(u in a))throw new Error(`Unrecognized key: "${u}"`);e[u]&&(c[u]=r?new r({type:"optional",innerType:a[u]}):a[u])}else for(const u in a)c[u]=r?new r({type:"optional",innerType:a[u]}):a[u];return ti(this,"shape",c),c},checks:[]});return an(t,o)}function aT(r,t,e){const n=on(t._zod.def,{get shape(){const i=t._zod.def.shape,s={...i};if(e)for(const o in e){if(!(o in s))throw new Error(`Unrecognized key: "${o}"`);e[o]&&(s[o]=new r({type:"nonoptional",innerType:i[o]}))}else for(const o in i)s[o]=new r({type:"nonoptional",innerType:i[o]});return ti(this,"shape",s),s}});return an(t,n)}function $i(r,t=0){var e;if(r.aborted===!0)return!0;for(let n=t;n<r.issues.length;n++)if(((e=r.issues[n])==null?void 0:e.continue)!==!0)return!0;return!1}function Ti(r,t){return t.map(e=>{var n;return(n=e).path??(n.path=[]),e.path.unshift(r),e})}function Ba(r){return typeof r=="string"?r:r==null?void 0:r.message}function en(r,t,e){var i,s,o,a,c,u;const n={...r,path:r.path??[]};if(!r.message){const h=Ba((o=(s=(i=r.inst)==null?void 0:i._zod.def)==null?void 0:s.error)==null?void 0:o.call(s,r))??Ba((a=t==null?void 0:t.error)==null?void 0:a.call(t,r))??Ba((c=e.customError)==null?void 0:c.call(e,r))??Ba((u=e.localeError)==null?void 0:u.call(e,r))??"Invalid input";n.message=h}return delete n.inst,delete n.continue,t!=null&&t.reportInput||delete n.input,n}function Zd(r){return Array.isArray(r)?"array":typeof r=="string"?"string":"unknown"}function uo(...r){const[t,e,n]=r;return typeof t=="string"?{message:t,code:"custom",input:e,inst:n}:{...t}}const $y=(r,t)=>{r.name="$ZodError",Object.defineProperty(r,"_zod",{value:r._zod,enumerable:!1}),Object.defineProperty(r,"issues",{value:t,enumerable:!1}),r.message=JSON.stringify(t,nh,2),Object.defineProperty(r,"toString",{value:()=>r.message,enumerable:!1})},Ty=A("$ZodError",$y),Iy=A("$ZodError",$y,{Parent:Error});function lT(r,t=e=>e.message){const e={},n=[];for(const i of r.issues)i.path.length>0?(e[i.path[0]]=e[i.path[0]]||[],e[i.path[0]].push(t(i))):n.push(t(i));return{formErrors:n,fieldErrors:e}}function cT(r,t=e=>e.message){const e={_errors:[]},n=i=>{for(const s of i.issues)if(s.code==="invalid_union"&&s.errors.length)s.errors.map(o=>n({issues:o}));else if(s.code==="invalid_key")n({issues:s.issues});else if(s.code==="invalid_element")n({issues:s.issues});else if(s.path.length===0)e._errors.push(t(s));else{let o=e,a=0;for(;a<s.path.length;){const c=s.path[a];a===s.path.length-1?(o[c]=o[c]||{_errors:[]},o[c]._errors.push(t(s))):o[c]=o[c]||{_errors:[]},o=o[c],a++}}};return n(r),e}const Wd=r=>(t,e,n,i)=>{const s=n?Object.assign(n,{async:!1}):{async:!1},o=t._zod.run({value:e,issues:[]},s);if(o instanceof Promise)throw new Ri;if(o.issues.length){const a=new((i==null?void 0:i.Err)??r)(o.issues.map(c=>en(c,s,Qr())));throw Ey(a,i==null?void 0:i.callee),a}return o.value},Bd=r=>async(t,e,n,i)=>{const s=n?Object.assign(n,{async:!0}):{async:!0};let o=t._zod.run({value:e,issues:[]},s);if(o instanceof Promise&&(o=await o),o.issues.length){const a=new((i==null?void 0:i.Err)??r)(o.issues.map(c=>en(c,s,Qr())));throw Ey(a,i==null?void 0:i.callee),a}return o.value},mc=r=>(t,e,n)=>{const i=n?{...n,async:!1}:{async:!1},s=t._zod.run({value:e,issues:[]},i);if(s instanceof Promise)throw new Ri;return s.issues.length?{success:!1,error:new(r??Ty)(s.issues.map(o=>en(o,i,Qr())))}:{success:!0,data:s.value}},uT=mc(Iy),vc=r=>async(t,e,n)=>{const i=n?Object.assign(n,{async:!0}):{async:!0};let s=t._zod.run({value:e,issues:[]},i);return s instanceof Promise&&(s=await s),s.issues.length?{success:!1,error:new r(s.issues.map(o=>en(o,i,Qr())))}:{success:!0,data:s.value}},hT=vc(Iy),dT=r=>(t,e,n)=>{const i=n?Object.assign(n,{direction:"backward"}):{direction:"backward"};return Wd(r)(t,e,i)},pT=r=>(t,e,n)=>Wd(r)(t,e,n),fT=r=>async(t,e,n)=>{const i=n?Object.assign(n,{direction:"backward"}):{direction:"backward"};return Bd(r)(t,e,i)},gT=r=>async(t,e,n)=>Bd(r)(t,e,n),mT=r=>(t,e,n)=>{const i=n?Object.assign(n,{direction:"backward"}):{direction:"backward"};return mc(r)(t,e,i)},vT=r=>(t,e,n)=>mc(r)(t,e,n),yT=r=>async(t,e,n)=>{const i=n?Object.assign(n,{direction:"backward"}):{direction:"backward"};return vc(r)(t,e,i)},bT=r=>async(t,e,n)=>vc(r)(t,e,n),wT=/^[cC][^\s-]{8,}$/,ST=/^[0-9a-z]+$/,_T=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,kT=/^[0-9a-vA-V]{20}$/,xT=/^[A-Za-z0-9]{27}$/,ET=/^[a-zA-Z0-9_-]{21}$/,AT=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,$T=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,Ag=r=>r?new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${r}[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)$/,TT=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,IT="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function CT(){return new RegExp(IT,"u")}const RT=/^(?:(?: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])$/,PT=/^(([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}|:))$/,LT=/^((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])$/,DT=/^(([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])$/,zT=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Cy=/^[A-Za-z0-9_-]*$/,OT=/^\+[1-9]\d{6,14}$/,Ry="(?:(?:\\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])))",MT=new RegExp(`^${Ry}$`);function Py(r){const t="(?:[01]\\d|2[0-3]):[0-5]\\d";return typeof r.precision=="number"?r.precision===-1?`${t}`:r.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${r.precision}}`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function NT(r){return new RegExp(`^${Py(r)}$`)}function UT(r){const t=Py({precision:r.precision}),e=["Z"];r.local&&e.push(""),r.offset&&e.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");const n=`${t}(?:${e.join("|")})`;return new RegExp(`^${Ry}T(?:${n})$`)}const FT=r=>{const t=r?`[\\s\\S]{${(r==null?void 0:r.minimum)??0},${(r==null?void 0:r.maximum)??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)},HT=/^-?\d+$/,Ly=/^-?\d+(?:\.\d+)?$/,ZT=/^(?:true|false)$/i,WT=/^[^A-Z]*$/,BT=/^[^a-z]*$/,ct=A("$ZodCheck",(r,t)=>{var e;r._zod??(r._zod={}),r._zod.def=t,(e=r._zod).onattach??(e.onattach=[])}),Dy={number:"number",bigint:"bigint",object:"date"},zy=A("$ZodCheckLessThan",(r,t)=>{ct.init(r,t);const e=Dy[typeof t.value];r._zod.onattach.push(n=>{const i=n._zod.bag,s=(t.inclusive?i.maximum:i.exclusiveMaximum)??Number.POSITIVE_INFINITY;t.value<s&&(t.inclusive?i.maximum=t.value:i.exclusiveMaximum=t.value)}),r._zod.check=n=>{(t.inclusive?n.value<=t.value:n.value<t.value)||n.issues.push({origin:e,code:"too_big",maximum:typeof t.value=="object"?t.value.getTime():t.value,input:n.value,inclusive:t.inclusive,inst:r,continue:!t.abort})}}),Oy=A("$ZodCheckGreaterThan",(r,t)=>{ct.init(r,t);const e=Dy[typeof t.value];r._zod.onattach.push(n=>{const i=n._zod.bag,s=(t.inclusive?i.minimum:i.exclusiveMinimum)??Number.NEGATIVE_INFINITY;t.value>s&&(t.inclusive?i.minimum=t.value:i.exclusiveMinimum=t.value)}),r._zod.check=n=>{(t.inclusive?n.value>=t.value:n.value>t.value)||n.issues.push({origin:e,code:"too_small",minimum:typeof t.value=="object"?t.value.getTime():t.value,input:n.value,inclusive:t.inclusive,inst:r,continue:!t.abort})}}),jT=A("$ZodCheckMultipleOf",(r,t)=>{ct.init(r,t),r._zod.onattach.push(e=>{var n;(n=e._zod.bag).multipleOf??(n.multipleOf=t.value)}),r._zod.check=e=>{if(typeof e.value!=typeof t.value)throw new Error("Cannot mix number and bigint in multiple_of check.");(typeof e.value=="bigint"?e.value%t.value===BigInt(0):Y$(e.value,t.value)===0)||e.issues.push({origin:typeof e.value,code:"not_multiple_of",divisor:t.value,input:e.value,inst:r,continue:!t.abort})}}),VT=A("$ZodCheckNumberFormat",(r,t)=>{var o;ct.init(r,t),t.format=t.format||"float64";const e=(o=t.format)==null?void 0:o.includes("int"),n=e?"int":"number",[i,s]=eT[t.format];r._zod.onattach.push(a=>{const c=a._zod.bag;c.format=t.format,c.minimum=i,c.maximum=s,e&&(c.pattern=HT)}),r._zod.check=a=>{const c=a.value;if(e){if(!Number.isInteger(c)){a.issues.push({expected:n,format:t.format,code:"invalid_type",continue:!1,input:c,inst:r});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:r,origin:n,inclusive:!0,continue:!t.abort}):a.issues.push({input:c,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:r,origin:n,inclusive:!0,continue:!t.abort});return}}c<i&&a.issues.push({origin:"number",input:c,code:"too_small",minimum:i,inclusive:!0,inst:r,continue:!t.abort}),c>s&&a.issues.push({origin:"number",input:c,code:"too_big",maximum:s,inclusive:!0,inst:r,continue:!t.abort})}}),GT=A("$ZodCheckMaxLength",(r,t)=>{var e;ct.init(r,t),(e=r._zod.def).when??(e.when=n=>{const i=n.value;return!Fd(i)&&i.length!==void 0}),r._zod.onattach.push(n=>{const i=n._zod.bag.maximum??Number.POSITIVE_INFINITY;t.maximum<i&&(n._zod.bag.maximum=t.maximum)}),r._zod.check=n=>{const i=n.value;if(i.length<=t.maximum)return;const o=Zd(i);n.issues.push({origin:o,code:"too_big",maximum:t.maximum,inclusive:!0,input:i,inst:r,continue:!t.abort})}}),qT=A("$ZodCheckMinLength",(r,t)=>{var e;ct.init(r,t),(e=r._zod.def).when??(e.when=n=>{const i=n.value;return!Fd(i)&&i.length!==void 0}),r._zod.onattach.push(n=>{const i=n._zod.bag.minimum??Number.NEGATIVE_INFINITY;t.minimum>i&&(n._zod.bag.minimum=t.minimum)}),r._zod.check=n=>{const i=n.value;if(i.length>=t.minimum)return;const o=Zd(i);n.issues.push({origin:o,code:"too_small",minimum:t.minimum,inclusive:!0,input:i,inst:r,continue:!t.abort})}}),YT=A("$ZodCheckLengthEquals",(r,t)=>{var e;ct.init(r,t),(e=r._zod.def).when??(e.when=n=>{const i=n.value;return!Fd(i)&&i.length!==void 0}),r._zod.onattach.push(n=>{const i=n._zod.bag;i.minimum=t.length,i.maximum=t.length,i.length=t.length}),r._zod.check=n=>{const i=n.value,s=i.length;if(s===t.length)return;const o=Zd(i),a=s>t.length;n.issues.push({origin:o,...a?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:n.value,inst:r,continue:!t.abort})}}),yc=A("$ZodCheckStringFormat",(r,t)=>{var e,n;ct.init(r,t),r._zod.onattach.push(i=>{const s=i._zod.bag;s.format=t.format,t.pattern&&(s.patterns??(s.patterns=new Set),s.patterns.add(t.pattern))}),t.pattern?(e=r._zod).check??(e.check=i=>{t.pattern.lastIndex=0,!t.pattern.test(i.value)&&i.issues.push({origin:"string",code:"invalid_format",format:t.format,input:i.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:r,continue:!t.abort})}):(n=r._zod).check??(n.check=()=>{})}),KT=A("$ZodCheckRegex",(r,t)=>{yc.init(r,t),r._zod.check=e=>{t.pattern.lastIndex=0,!t.pattern.test(e.value)&&e.issues.push({origin:"string",code:"invalid_format",format:"regex",input:e.value,pattern:t.pattern.toString(),inst:r,continue:!t.abort})}}),JT=A("$ZodCheckLowerCase",(r,t)=>{t.pattern??(t.pattern=WT),yc.init(r,t)}),XT=A("$ZodCheckUpperCase",(r,t)=>{t.pattern??(t.pattern=BT),yc.init(r,t)}),QT=A("$ZodCheckIncludes",(r,t)=>{ct.init(r,t);const e=us(t.includes),n=new RegExp(typeof t.position=="number"?`^.{${t.position}}${e}`:e);t.pattern=n,r._zod.onattach.push(i=>{const s=i._zod.bag;s.patterns??(s.patterns=new Set),s.patterns.add(n)}),r._zod.check=i=>{i.value.includes(t.includes,t.position)||i.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:i.value,inst:r,continue:!t.abort})}}),eI=A("$ZodCheckStartsWith",(r,t)=>{ct.init(r,t);const e=new RegExp(`^${us(t.prefix)}.*`);t.pattern??(t.pattern=e),r._zod.onattach.push(n=>{const i=n._zod.bag;i.patterns??(i.patterns=new Set),i.patterns.add(e)}),r._zod.check=n=>{n.value.startsWith(t.prefix)||n.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:n.value,inst:r,continue:!t.abort})}}),tI=A("$ZodCheckEndsWith",(r,t)=>{ct.init(r,t);const e=new RegExp(`.*${us(t.suffix)}$`);t.pattern??(t.pattern=e),r._zod.onattach.push(n=>{const i=n._zod.bag;i.patterns??(i.patterns=new Set),i.patterns.add(e)}),r._zod.check=n=>{n.value.endsWith(t.suffix)||n.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:n.value,inst:r,continue:!t.abort})}}),rI=A("$ZodCheckOverwrite",(r,t)=>{ct.init(r,t),r._zod.check=e=>{e.value=t.tx(e.value)}});class nI{constructor(t=[]){this.content=[],this.indent=0,this&&(this.args=t)}indented(t){this.indent+=1,t(this),this.indent-=1}write(t){if(typeof t=="function"){t(this,{execution:"sync"}),t(this,{execution:"async"});return}const n=t.split(`
5
- `).filter(o=>o),i=Math.min(...n.map(o=>o.length-o.trimStart().length)),s=n.map(o=>o.slice(i)).map(o=>" ".repeat(this.indent*2)+o);for(const o of s)this.content.push(o)}compile(){const t=Function,e=this==null?void 0:this.args,i=[...((this==null?void 0:this.content)??[""]).map(s=>` ${s}`)];return new t(...e,i.join(`
6
- `))}}const iI={major:4,minor:3,patch:6},ve=A("$ZodType",(r,t)=>{var i;var e;r??(r={}),r._zod.def=t,r._zod.bag=r._zod.bag||{},r._zod.version=iI;const n=[...r._zod.def.checks??[]];r._zod.traits.has("$ZodCheck")&&n.unshift(r);for(const s of n)for(const o of s._zod.onattach)o(r);if(n.length===0)(e=r._zod).deferred??(e.deferred=[]),(i=r._zod.deferred)==null||i.push(()=>{r._zod.run=r._zod.parse});else{const s=(a,c,u)=>{let h=$i(a),f;for(const y of c){if(y._zod.def.when){if(!y._zod.def.when(a))continue}else if(h)continue;const m=a.issues.length,E=y._zod.check(a);if(E instanceof Promise&&(u==null?void 0:u.async)===!1)throw new Ri;if(f||E instanceof Promise)f=(f??Promise.resolve()).then(async()=>{await E,a.issues.length!==m&&(h||(h=$i(a,m)))});else{if(a.issues.length===m)continue;h||(h=$i(a,m))}}return f?f.then(()=>a):a},o=(a,c,u)=>{if($i(a))return a.aborted=!0,a;const h=s(c,n,u);if(h instanceof Promise){if(u.async===!1)throw new Ri;return h.then(f=>r._zod.parse(f,u))}return r._zod.parse(h,u)};r._zod.run=(a,c)=>{if(c.skipChecks)return r._zod.parse(a,c);if(c.direction==="backward"){const h=r._zod.parse({value:a.value,issues:[]},{...c,skipChecks:!0});return h instanceof Promise?h.then(f=>o(f,a,c)):o(h,a,c)}const u=r._zod.parse(a,c);if(u instanceof Promise){if(c.async===!1)throw new Ri;return u.then(h=>s(h,n,c))}return s(u,n,c)}}te(r,"~standard",()=>({validate:s=>{var o;try{const a=uT(r,s);return a.success?{value:a.data}:{issues:(o=a.error)==null?void 0:o.issues}}catch{return hT(r,s).then(c=>{var u;return c.success?{value:c.data}:{issues:(u=c.error)==null?void 0:u.issues}})}},vendor:"zod",version:1}))}),jd=A("$ZodString",(r,t)=>{var e;ve.init(r,t),r._zod.pattern=[...((e=r==null?void 0:r._zod.bag)==null?void 0:e.patterns)??[]].pop()??FT(r._zod.bag),r._zod.parse=(n,i)=>{if(t.coerce)try{n.value=String(n.value)}catch{}return typeof n.value=="string"||n.issues.push({expected:"string",code:"invalid_type",input:n.value,inst:r}),n}}),ge=A("$ZodStringFormat",(r,t)=>{yc.init(r,t),jd.init(r,t)}),sI=A("$ZodGUID",(r,t)=>{t.pattern??(t.pattern=$T),ge.init(r,t)}),oI=A("$ZodUUID",(r,t)=>{if(t.version){const n={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(n===void 0)throw new Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=Ag(n))}else t.pattern??(t.pattern=Ag());ge.init(r,t)}),aI=A("$ZodEmail",(r,t)=>{t.pattern??(t.pattern=TT),ge.init(r,t)}),lI=A("$ZodURL",(r,t)=>{ge.init(r,t),r._zod.check=e=>{try{const n=e.value.trim(),i=new URL(n);t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(i.hostname)||e.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:t.hostname.source,input:e.value,inst:r,continue:!t.abort})),t.protocol&&(t.protocol.lastIndex=0,t.protocol.test(i.protocol.endsWith(":")?i.protocol.slice(0,-1):i.protocol)||e.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:e.value,inst:r,continue:!t.abort})),t.normalize?e.value=i.href:e.value=n;return}catch{e.issues.push({code:"invalid_format",format:"url",input:e.value,inst:r,continue:!t.abort})}}}),cI=A("$ZodEmoji",(r,t)=>{t.pattern??(t.pattern=CT()),ge.init(r,t)}),uI=A("$ZodNanoID",(r,t)=>{t.pattern??(t.pattern=ET),ge.init(r,t)}),hI=A("$ZodCUID",(r,t)=>{t.pattern??(t.pattern=wT),ge.init(r,t)}),dI=A("$ZodCUID2",(r,t)=>{t.pattern??(t.pattern=ST),ge.init(r,t)}),pI=A("$ZodULID",(r,t)=>{t.pattern??(t.pattern=_T),ge.init(r,t)}),fI=A("$ZodXID",(r,t)=>{t.pattern??(t.pattern=kT),ge.init(r,t)}),gI=A("$ZodKSUID",(r,t)=>{t.pattern??(t.pattern=xT),ge.init(r,t)}),mI=A("$ZodISODateTime",(r,t)=>{t.pattern??(t.pattern=UT(t)),ge.init(r,t)}),vI=A("$ZodISODate",(r,t)=>{t.pattern??(t.pattern=MT),ge.init(r,t)}),yI=A("$ZodISOTime",(r,t)=>{t.pattern??(t.pattern=NT(t)),ge.init(r,t)}),bI=A("$ZodISODuration",(r,t)=>{t.pattern??(t.pattern=AT),ge.init(r,t)}),wI=A("$ZodIPv4",(r,t)=>{t.pattern??(t.pattern=RT),ge.init(r,t),r._zod.bag.format="ipv4"}),SI=A("$ZodIPv6",(r,t)=>{t.pattern??(t.pattern=PT),ge.init(r,t),r._zod.bag.format="ipv6",r._zod.check=e=>{try{new URL(`http://[${e.value}]`)}catch{e.issues.push({code:"invalid_format",format:"ipv6",input:e.value,inst:r,continue:!t.abort})}}}),_I=A("$ZodCIDRv4",(r,t)=>{t.pattern??(t.pattern=LT),ge.init(r,t)}),kI=A("$ZodCIDRv6",(r,t)=>{t.pattern??(t.pattern=DT),ge.init(r,t),r._zod.check=e=>{const n=e.value.split("/");try{if(n.length!==2)throw new Error;const[i,s]=n;if(!s)throw new Error;const o=Number(s);if(`${o}`!==s)throw new Error;if(o<0||o>128)throw new Error;new URL(`http://[${i}]`)}catch{e.issues.push({code:"invalid_format",format:"cidrv6",input:e.value,inst:r,continue:!t.abort})}}});function My(r){if(r==="")return!0;if(r.length%4!==0)return!1;try{return atob(r),!0}catch{return!1}}const xI=A("$ZodBase64",(r,t)=>{t.pattern??(t.pattern=zT),ge.init(r,t),r._zod.bag.contentEncoding="base64",r._zod.check=e=>{My(e.value)||e.issues.push({code:"invalid_format",format:"base64",input:e.value,inst:r,continue:!t.abort})}});function EI(r){if(!Cy.test(r))return!1;const t=r.replace(/[-_]/g,n=>n==="-"?"+":"/"),e=t.padEnd(Math.ceil(t.length/4)*4,"=");return My(e)}const AI=A("$ZodBase64URL",(r,t)=>{t.pattern??(t.pattern=Cy),ge.init(r,t),r._zod.bag.contentEncoding="base64url",r._zod.check=e=>{EI(e.value)||e.issues.push({code:"invalid_format",format:"base64url",input:e.value,inst:r,continue:!t.abort})}}),$I=A("$ZodE164",(r,t)=>{t.pattern??(t.pattern=OT),ge.init(r,t)});function TI(r,t=null){try{const e=r.split(".");if(e.length!==3)return!1;const[n]=e;if(!n)return!1;const i=JSON.parse(atob(n));return!("typ"in i&&(i==null?void 0:i.typ)!=="JWT"||!i.alg||t&&(!("alg"in i)||i.alg!==t))}catch{return!1}}const II=A("$ZodJWT",(r,t)=>{ge.init(r,t),r._zod.check=e=>{TI(e.value,t.alg)||e.issues.push({code:"invalid_format",format:"jwt",input:e.value,inst:r,continue:!t.abort})}}),Ny=A("$ZodNumber",(r,t)=>{ve.init(r,t),r._zod.pattern=r._zod.bag.pattern??Ly,r._zod.parse=(e,n)=>{if(t.coerce)try{e.value=Number(e.value)}catch{}const i=e.value;if(typeof i=="number"&&!Number.isNaN(i)&&Number.isFinite(i))return e;const s=typeof i=="number"?Number.isNaN(i)?"NaN":Number.isFinite(i)?void 0:"Infinity":void 0;return e.issues.push({expected:"number",code:"invalid_type",input:i,inst:r,...s?{received:s}:{}}),e}}),CI=A("$ZodNumberFormat",(r,t)=>{VT.init(r,t),Ny.init(r,t)}),RI=A("$ZodBoolean",(r,t)=>{ve.init(r,t),r._zod.pattern=ZT,r._zod.parse=(e,n)=>{if(t.coerce)try{e.value=!!e.value}catch{}const i=e.value;return typeof i=="boolean"||e.issues.push({expected:"boolean",code:"invalid_type",input:i,inst:r}),e}}),PI=A("$ZodUnknown",(r,t)=>{ve.init(r,t),r._zod.parse=e=>e}),LI=A("$ZodNever",(r,t)=>{ve.init(r,t),r._zod.parse=(e,n)=>(e.issues.push({expected:"never",code:"invalid_type",input:e.value,inst:r}),e)});function $g(r,t,e){r.issues.length&&t.issues.push(...Ti(e,r.issues)),t.value[e]=r.value}const DI=A("$ZodArray",(r,t)=>{ve.init(r,t),r._zod.parse=(e,n)=>{const i=e.value;if(!Array.isArray(i))return e.issues.push({expected:"array",code:"invalid_type",input:i,inst:r}),e;e.value=Array(i.length);const s=[];for(let o=0;o<i.length;o++){const a=i[o],c=t.element._zod.run({value:a,issues:[]},n);c instanceof Promise?s.push(c.then(u=>$g(u,e,o))):$g(c,e,o)}return s.length?Promise.all(s).then(()=>e):e}});function Ll(r,t,e,n,i){if(r.issues.length){if(i&&!(e in n))return;t.issues.push(...Ti(e,r.issues))}r.value===void 0?e in n&&(t.value[e]=void 0):t.value[e]=r.value}function Uy(r){var n,i,s,o;const t=Object.keys(r.shape);for(const a of t)if(!((o=(s=(i=(n=r.shape)==null?void 0:n[a])==null?void 0:i._zod)==null?void 0:s.traits)!=null&&o.has("$ZodType")))throw new Error(`Invalid element at key "${a}": expected a Zod schema`);const e=Q$(r.shape);return{...r,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(e)}}function Fy(r,t,e,n,i,s){const o=[],a=i.keySet,c=i.catchall._zod,u=c.def.type,h=c.optout==="optional";for(const f in t){if(a.has(f))continue;if(u==="never"){o.push(f);continue}const y=c.run({value:t[f],issues:[]},n);y instanceof Promise?r.push(y.then(m=>Ll(m,e,f,t,h))):Ll(y,e,f,t,h)}return o.length&&e.issues.push({code:"unrecognized_keys",keys:o,input:t,inst:s}),r.length?Promise.all(r).then(()=>e):e}const zI=A("$ZodObject",(r,t)=>{ve.init(r,t);const e=Object.getOwnPropertyDescriptor(t,"shape");if(!(e!=null&&e.get)){const a=t.shape;Object.defineProperty(t,"shape",{get:()=>{const c={...a};return Object.defineProperty(t,"shape",{value:c}),c}})}const n=gc(()=>Uy(t));te(r._zod,"propValues",()=>{const a=t.shape,c={};for(const u in a){const h=a[u]._zod;if(h.values){c[u]??(c[u]=new Set);for(const f of h.values)c[u].add(f)}}return c});const i=co,s=t.catchall;let o;r._zod.parse=(a,c)=>{o??(o=n.value);const u=a.value;if(!i(u))return a.issues.push({expected:"object",code:"invalid_type",input:u,inst:r}),a;a.value={};const h=[],f=o.shape;for(const y of o.keys){const m=f[y],E=m._zod.optout==="optional",x=m._zod.run({value:u[y],issues:[]},c);x instanceof Promise?h.push(x.then(I=>Ll(I,a,y,u,E))):Ll(x,a,y,u,E)}return s?Fy(h,u,a,c,n.value,r):h.length?Promise.all(h).then(()=>a):a}}),OI=A("$ZodObjectJIT",(r,t)=>{zI.init(r,t);const e=r._zod.parse,n=gc(()=>Uy(t)),i=y=>{var B;const m=new nI(["shape","payload","ctx"]),E=n.value,x=N=>{const F=Eg(N);return`shape[${F}]._zod.run({ value: input[${F}], issues: [] }, ctx)`};m.write("const input = payload.value;");const I=Object.create(null);let P=0;for(const N of E.keys)I[N]=`key_${P++}`;m.write("const newResult = {};");for(const N of E.keys){const F=I[N],Y=Eg(N),V=y[N],ce=((B=V==null?void 0:V._zod)==null?void 0:B.optout)==="optional";m.write(`const ${F} = ${x(N)};`),ce?m.write(`
7
- if (${F}.issues.length) {
8
- if (${Y} in input) {
9
- payload.issues = payload.issues.concat(${F}.issues.map(iss => ({
10
- ...iss,
11
- path: iss.path ? [${Y}, ...iss.path] : [${Y}]
12
- })));
13
- }
14
- }
15
-
16
- if (${F}.value === undefined) {
17
- if (${Y} in input) {
18
- newResult[${Y}] = undefined;
19
- }
20
- } else {
21
- newResult[${Y}] = ${F}.value;
22
- }
23
-
24
- `):m.write(`
25
- if (${F}.issues.length) {
26
- payload.issues = payload.issues.concat(${F}.issues.map(iss => ({
27
- ...iss,
28
- path: iss.path ? [${Y}, ...iss.path] : [${Y}]
29
- })));
30
- }
31
-
32
- if (${F}.value === undefined) {
33
- if (${Y} in input) {
34
- newResult[${Y}] = undefined;
35
- }
36
- } else {
37
- newResult[${Y}] = ${F}.value;
38
- }
39
-
40
- `)}m.write("payload.value = newResult;"),m.write("return payload;");const R=m.compile();return(N,F)=>R(y,N,F)};let s;const o=co,a=!ky.jitless,u=a&&J$.value,h=t.catchall;let f;r._zod.parse=(y,m)=>{f??(f=n.value);const E=y.value;return o(E)?a&&u&&(m==null?void 0:m.async)===!1&&m.jitless!==!0?(s||(s=i(t.shape)),y=s(y,m),h?Fy([],E,y,m,f,r):y):e(y,m):(y.issues.push({expected:"object",code:"invalid_type",input:E,inst:r}),y)}});function Tg(r,t,e,n){for(const s of r)if(s.issues.length===0)return t.value=s.value,t;const i=r.filter(s=>!$i(s));return i.length===1?(t.value=i[0].value,i[0]):(t.issues.push({code:"invalid_union",input:t.value,inst:e,errors:r.map(s=>s.issues.map(o=>en(o,n,Qr())))}),t)}const Hy=A("$ZodUnion",(r,t)=>{ve.init(r,t),te(r._zod,"optin",()=>t.options.some(i=>i._zod.optin==="optional")?"optional":void 0),te(r._zod,"optout",()=>t.options.some(i=>i._zod.optout==="optional")?"optional":void 0),te(r._zod,"values",()=>{if(t.options.every(i=>i._zod.values))return new Set(t.options.flatMap(i=>Array.from(i._zod.values)))}),te(r._zod,"pattern",()=>{if(t.options.every(i=>i._zod.pattern)){const i=t.options.map(s=>s._zod.pattern);return new RegExp(`^(${i.map(s=>Hd(s.source)).join("|")})$`)}});const e=t.options.length===1,n=t.options[0]._zod.run;r._zod.parse=(i,s)=>{if(e)return n(i,s);let o=!1;const a=[];for(const c of t.options){const u=c._zod.run({value:i.value,issues:[]},s);if(u instanceof Promise)a.push(u),o=!0;else{if(u.issues.length===0)return u;a.push(u)}}return o?Promise.all(a).then(c=>Tg(c,i,r,s)):Tg(a,i,r,s)}}),MI=A("$ZodDiscriminatedUnion",(r,t)=>{t.inclusive=!1,Hy.init(r,t);const e=r._zod.parse;te(r._zod,"propValues",()=>{const i={};for(const s of t.options){const o=s._zod.propValues;if(!o||Object.keys(o).length===0)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(s)}"`);for(const[a,c]of Object.entries(o)){i[a]||(i[a]=new Set);for(const u of c)i[a].add(u)}}return i});const n=gc(()=>{var o;const i=t.options,s=new Map;for(const a of i){const c=(o=a._zod.propValues)==null?void 0:o[t.discriminator];if(!c||c.size===0)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(a)}"`);for(const u of c){if(s.has(u))throw new Error(`Duplicate discriminator value "${String(u)}"`);s.set(u,a)}}return s});r._zod.parse=(i,s)=>{const o=i.value;if(!co(o))return i.issues.push({code:"invalid_type",expected:"object",input:o,inst:r}),i;const a=n.value.get(o==null?void 0:o[t.discriminator]);return a?a._zod.run(i,s):t.unionFallback?e(i,s):(i.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:t.discriminator,input:o,path:[t.discriminator],inst:r}),i)}}),NI=A("$ZodIntersection",(r,t)=>{ve.init(r,t),r._zod.parse=(e,n)=>{const i=e.value,s=t.left._zod.run({value:i,issues:[]},n),o=t.right._zod.run({value:i,issues:[]},n);return s instanceof Promise||o instanceof Promise?Promise.all([s,o]).then(([c,u])=>Ig(e,c,u)):Ig(e,s,o)}});function ih(r,t){if(r===t)return{valid:!0,data:r};if(r instanceof Date&&t instanceof Date&&+r==+t)return{valid:!0,data:r};if(cs(r)&&cs(t)){const e=Object.keys(t),n=Object.keys(r).filter(s=>e.indexOf(s)!==-1),i={...r,...t};for(const s of n){const o=ih(r[s],t[s]);if(!o.valid)return{valid:!1,mergeErrorPath:[s,...o.mergeErrorPath]};i[s]=o.data}return{valid:!0,data:i}}if(Array.isArray(r)&&Array.isArray(t)){if(r.length!==t.length)return{valid:!1,mergeErrorPath:[]};const e=[];for(let n=0;n<r.length;n++){const i=r[n],s=t[n],o=ih(i,s);if(!o.valid)return{valid:!1,mergeErrorPath:[n,...o.mergeErrorPath]};e.push(o.data)}return{valid:!0,data:e}}return{valid:!1,mergeErrorPath:[]}}function Ig(r,t,e){const n=new Map;let i;for(const a of t.issues)if(a.code==="unrecognized_keys"){i??(i=a);for(const c of a.keys)n.has(c)||n.set(c,{}),n.get(c).l=!0}else r.issues.push(a);for(const a of e.issues)if(a.code==="unrecognized_keys")for(const c of a.keys)n.has(c)||n.set(c,{}),n.get(c).r=!0;else r.issues.push(a);const s=[...n].filter(([,a])=>a.l&&a.r).map(([a])=>a);if(s.length&&i&&r.issues.push({...i,keys:s}),$i(r))return r;const o=ih(t.value,e.value);if(!o.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(o.mergeErrorPath)}`);return r.value=o.data,r}const UI=A("$ZodRecord",(r,t)=>{ve.init(r,t),r._zod.parse=(e,n)=>{const i=e.value;if(!cs(i))return e.issues.push({expected:"record",code:"invalid_type",input:i,inst:r}),e;const s=[],o=t.keyType._zod.values;if(o){e.value={};const a=new Set;for(const u of o)if(typeof u=="string"||typeof u=="number"||typeof u=="symbol"){a.add(typeof u=="number"?u.toString():u);const h=t.valueType._zod.run({value:i[u],issues:[]},n);h instanceof Promise?s.push(h.then(f=>{f.issues.length&&e.issues.push(...Ti(u,f.issues)),e.value[u]=f.value})):(h.issues.length&&e.issues.push(...Ti(u,h.issues)),e.value[u]=h.value)}let c;for(const u in i)a.has(u)||(c=c??[],c.push(u));c&&c.length>0&&e.issues.push({code:"unrecognized_keys",input:i,inst:r,keys:c})}else{e.value={};for(const a of Reflect.ownKeys(i)){if(a==="__proto__")continue;let c=t.keyType._zod.run({value:a,issues:[]},n);if(c instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(typeof a=="string"&&Ly.test(a)&&c.issues.length){const f=t.keyType._zod.run({value:Number(a),issues:[]},n);if(f instanceof Promise)throw new Error("Async schemas not supported in object keys currently");f.issues.length===0&&(c=f)}if(c.issues.length){t.mode==="loose"?e.value[a]=i[a]:e.issues.push({code:"invalid_key",origin:"record",issues:c.issues.map(f=>en(f,n,Qr())),input:a,path:[a],inst:r});continue}const h=t.valueType._zod.run({value:i[a],issues:[]},n);h instanceof Promise?s.push(h.then(f=>{f.issues.length&&e.issues.push(...Ti(a,f.issues)),e.value[c.value]=f.value})):(h.issues.length&&e.issues.push(...Ti(a,h.issues)),e.value[c.value]=h.value)}}return s.length?Promise.all(s).then(()=>e):e}}),FI=A("$ZodEnum",(r,t)=>{ve.init(r,t);const e=xy(t.entries),n=new Set(e);r._zod.values=n,r._zod.pattern=new RegExp(`^(${e.filter(i=>X$.has(typeof i)).map(i=>typeof i=="string"?us(i):i.toString()).join("|")})$`),r._zod.parse=(i,s)=>{const o=i.value;return n.has(o)||i.issues.push({code:"invalid_value",values:e,input:o,inst:r}),i}}),HI=A("$ZodLiteral",(r,t)=>{if(ve.init(r,t),t.values.length===0)throw new Error("Cannot create literal schema with no valid values");const e=new Set(t.values);r._zod.values=e,r._zod.pattern=new RegExp(`^(${t.values.map(n=>typeof n=="string"?us(n):n?us(n.toString()):String(n)).join("|")})$`),r._zod.parse=(n,i)=>{const s=n.value;return e.has(s)||n.issues.push({code:"invalid_value",values:t.values,input:s,inst:r}),n}}),ZI=A("$ZodTransform",(r,t)=>{ve.init(r,t),r._zod.parse=(e,n)=>{if(n.direction==="backward")throw new _y(r.constructor.name);const i=t.transform(e.value,e);if(n.async)return(i instanceof Promise?i:Promise.resolve(i)).then(o=>(e.value=o,e));if(i instanceof Promise)throw new Ri;return e.value=i,e}});function Cg(r,t){return r.issues.length&&t===void 0?{issues:[],value:void 0}:r}const Zy=A("$ZodOptional",(r,t)=>{ve.init(r,t),r._zod.optin="optional",r._zod.optout="optional",te(r._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),te(r._zod,"pattern",()=>{const e=t.innerType._zod.pattern;return e?new RegExp(`^(${Hd(e.source)})?$`):void 0}),r._zod.parse=(e,n)=>{if(t.innerType._zod.optin==="optional"){const i=t.innerType._zod.run(e,n);return i instanceof Promise?i.then(s=>Cg(s,e.value)):Cg(i,e.value)}return e.value===void 0?e:t.innerType._zod.run(e,n)}}),WI=A("$ZodExactOptional",(r,t)=>{Zy.init(r,t),te(r._zod,"values",()=>t.innerType._zod.values),te(r._zod,"pattern",()=>t.innerType._zod.pattern),r._zod.parse=(e,n)=>t.innerType._zod.run(e,n)}),BI=A("$ZodNullable",(r,t)=>{ve.init(r,t),te(r._zod,"optin",()=>t.innerType._zod.optin),te(r._zod,"optout",()=>t.innerType._zod.optout),te(r._zod,"pattern",()=>{const e=t.innerType._zod.pattern;return e?new RegExp(`^(${Hd(e.source)}|null)$`):void 0}),te(r._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),r._zod.parse=(e,n)=>e.value===null?e:t.innerType._zod.run(e,n)}),jI=A("$ZodDefault",(r,t)=>{ve.init(r,t),r._zod.optin="optional",te(r._zod,"values",()=>t.innerType._zod.values),r._zod.parse=(e,n)=>{if(n.direction==="backward")return t.innerType._zod.run(e,n);if(e.value===void 0)return e.value=t.defaultValue,e;const i=t.innerType._zod.run(e,n);return i instanceof Promise?i.then(s=>Rg(s,t)):Rg(i,t)}});function Rg(r,t){return r.value===void 0&&(r.value=t.defaultValue),r}const VI=A("$ZodPrefault",(r,t)=>{ve.init(r,t),r._zod.optin="optional",te(r._zod,"values",()=>t.innerType._zod.values),r._zod.parse=(e,n)=>(n.direction==="backward"||e.value===void 0&&(e.value=t.defaultValue),t.innerType._zod.run(e,n))}),GI=A("$ZodNonOptional",(r,t)=>{ve.init(r,t),te(r._zod,"values",()=>{const e=t.innerType._zod.values;return e?new Set([...e].filter(n=>n!==void 0)):void 0}),r._zod.parse=(e,n)=>{const i=t.innerType._zod.run(e,n);return i instanceof Promise?i.then(s=>Pg(s,r)):Pg(i,r)}});function Pg(r,t){return!r.issues.length&&r.value===void 0&&r.issues.push({code:"invalid_type",expected:"nonoptional",input:r.value,inst:t}),r}const qI=A("$ZodCatch",(r,t)=>{ve.init(r,t),te(r._zod,"optin",()=>t.innerType._zod.optin),te(r._zod,"optout",()=>t.innerType._zod.optout),te(r._zod,"values",()=>t.innerType._zod.values),r._zod.parse=(e,n)=>{if(n.direction==="backward")return t.innerType._zod.run(e,n);const i=t.innerType._zod.run(e,n);return i instanceof Promise?i.then(s=>(e.value=s.value,s.issues.length&&(e.value=t.catchValue({...e,error:{issues:s.issues.map(o=>en(o,n,Qr()))},input:e.value}),e.issues=[]),e)):(e.value=i.value,i.issues.length&&(e.value=t.catchValue({...e,error:{issues:i.issues.map(s=>en(s,n,Qr()))},input:e.value}),e.issues=[]),e)}}),YI=A("$ZodPipe",(r,t)=>{ve.init(r,t),te(r._zod,"values",()=>t.in._zod.values),te(r._zod,"optin",()=>t.in._zod.optin),te(r._zod,"optout",()=>t.out._zod.optout),te(r._zod,"propValues",()=>t.in._zod.propValues),r._zod.parse=(e,n)=>{if(n.direction==="backward"){const s=t.out._zod.run(e,n);return s instanceof Promise?s.then(o=>ja(o,t.in,n)):ja(s,t.in,n)}const i=t.in._zod.run(e,n);return i instanceof Promise?i.then(s=>ja(s,t.out,n)):ja(i,t.out,n)}});function ja(r,t,e){return r.issues.length?(r.aborted=!0,r):t._zod.run({value:r.value,issues:r.issues},e)}const KI=A("$ZodReadonly",(r,t)=>{ve.init(r,t),te(r._zod,"propValues",()=>t.innerType._zod.propValues),te(r._zod,"values",()=>t.innerType._zod.values),te(r._zod,"optin",()=>{var e,n;return(n=(e=t.innerType)==null?void 0:e._zod)==null?void 0:n.optin}),te(r._zod,"optout",()=>{var e,n;return(n=(e=t.innerType)==null?void 0:e._zod)==null?void 0:n.optout}),r._zod.parse=(e,n)=>{if(n.direction==="backward")return t.innerType._zod.run(e,n);const i=t.innerType._zod.run(e,n);return i instanceof Promise?i.then(Lg):Lg(i)}});function Lg(r){return r.value=Object.freeze(r.value),r}const JI=A("$ZodCustom",(r,t)=>{ct.init(r,t),ve.init(r,t),r._zod.parse=(e,n)=>e,r._zod.check=e=>{const n=e.value,i=t.fn(n);if(i instanceof Promise)return i.then(s=>Dg(s,e,n,r));Dg(i,e,n,r)}});function Dg(r,t,e,n){if(!r){const i={code:"custom",input:e,inst:n,path:[...n._zod.def.path??[]],continue:!n._zod.def.abort};n._zod.def.params&&(i.params=n._zod.def.params),t.issues.push(uo(i))}}var zg;class XI{constructor(){this._map=new WeakMap,this._idmap=new Map}add(t,...e){const n=e[0];return this._map.set(t,n),n&&typeof n=="object"&&"id"in n&&this._idmap.set(n.id,t),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(t){const e=this._map.get(t);return e&&typeof e=="object"&&"id"in e&&this._idmap.delete(e.id),this._map.delete(t),this}get(t){const e=t._zod.parent;if(e){const n={...this.get(e)??{}};delete n.id;const i={...n,...this._map.get(t)};return Object.keys(i).length?i:void 0}return this._map.get(t)}has(t){return this._map.has(t)}}function QI(){return new XI}(zg=globalThis).__zod_globalRegistry??(zg.__zod_globalRegistry=QI());const Bs=globalThis.__zod_globalRegistry;function eC(r,t){return new r({type:"string",...O(t)})}function tC(r,t){return new r({type:"string",format:"email",check:"string_format",abort:!1,...O(t)})}function Og(r,t){return new r({type:"string",format:"guid",check:"string_format",abort:!1,...O(t)})}function rC(r,t){return new r({type:"string",format:"uuid",check:"string_format",abort:!1,...O(t)})}function nC(r,t){return new r({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...O(t)})}function iC(r,t){return new r({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...O(t)})}function sC(r,t){return new r({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...O(t)})}function oC(r,t){return new r({type:"string",format:"url",check:"string_format",abort:!1,...O(t)})}function aC(r,t){return new r({type:"string",format:"emoji",check:"string_format",abort:!1,...O(t)})}function lC(r,t){return new r({type:"string",format:"nanoid",check:"string_format",abort:!1,...O(t)})}function cC(r,t){return new r({type:"string",format:"cuid",check:"string_format",abort:!1,...O(t)})}function uC(r,t){return new r({type:"string",format:"cuid2",check:"string_format",abort:!1,...O(t)})}function hC(r,t){return new r({type:"string",format:"ulid",check:"string_format",abort:!1,...O(t)})}function dC(r,t){return new r({type:"string",format:"xid",check:"string_format",abort:!1,...O(t)})}function pC(r,t){return new r({type:"string",format:"ksuid",check:"string_format",abort:!1,...O(t)})}function fC(r,t){return new r({type:"string",format:"ipv4",check:"string_format",abort:!1,...O(t)})}function gC(r,t){return new r({type:"string",format:"ipv6",check:"string_format",abort:!1,...O(t)})}function mC(r,t){return new r({type:"string",format:"cidrv4",check:"string_format",abort:!1,...O(t)})}function vC(r,t){return new r({type:"string",format:"cidrv6",check:"string_format",abort:!1,...O(t)})}function yC(r,t){return new r({type:"string",format:"base64",check:"string_format",abort:!1,...O(t)})}function bC(r,t){return new r({type:"string",format:"base64url",check:"string_format",abort:!1,...O(t)})}function wC(r,t){return new r({type:"string",format:"e164",check:"string_format",abort:!1,...O(t)})}function SC(r,t){return new r({type:"string",format:"jwt",check:"string_format",abort:!1,...O(t)})}function _C(r,t){return new r({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...O(t)})}function kC(r,t){return new r({type:"string",format:"date",check:"string_format",...O(t)})}function xC(r,t){return new r({type:"string",format:"time",check:"string_format",precision:null,...O(t)})}function EC(r,t){return new r({type:"string",format:"duration",check:"string_format",...O(t)})}function AC(r,t){return new r({type:"number",checks:[],...O(t)})}function $C(r,t){return new r({type:"number",check:"number_format",abort:!1,format:"safeint",...O(t)})}function TC(r,t){return new r({type:"boolean",...O(t)})}function IC(r){return new r({type:"unknown"})}function CC(r,t){return new r({type:"never",...O(t)})}function Mg(r,t){return new zy({check:"less_than",...O(t),value:r,inclusive:!1})}function yu(r,t){return new zy({check:"less_than",...O(t),value:r,inclusive:!0})}function Ng(r,t){return new Oy({check:"greater_than",...O(t),value:r,inclusive:!1})}function bu(r,t){return new Oy({check:"greater_than",...O(t),value:r,inclusive:!0})}function Ug(r,t){return new jT({check:"multiple_of",...O(t),value:r})}function Wy(r,t){return new GT({check:"max_length",...O(t),maximum:r})}function Dl(r,t){return new qT({check:"min_length",...O(t),minimum:r})}function By(r,t){return new YT({check:"length_equals",...O(t),length:r})}function RC(r,t){return new KT({check:"string_format",format:"regex",...O(t),pattern:r})}function PC(r){return new JT({check:"string_format",format:"lowercase",...O(r)})}function LC(r){return new XT({check:"string_format",format:"uppercase",...O(r)})}function DC(r,t){return new QT({check:"string_format",format:"includes",...O(t),includes:r})}function zC(r,t){return new eI({check:"string_format",format:"starts_with",...O(t),prefix:r})}function OC(r,t){return new tI({check:"string_format",format:"ends_with",...O(t),suffix:r})}function _s(r){return new rI({check:"overwrite",tx:r})}function MC(r){return _s(t=>t.normalize(r))}function NC(){return _s(r=>r.trim())}function UC(){return _s(r=>r.toLowerCase())}function FC(){return _s(r=>r.toUpperCase())}function HC(){return _s(r=>K$(r))}function ZC(r,t,e){return new r({type:"array",element:t,...O(e)})}function WC(r,t,e){return new r({type:"custom",check:"custom",fn:t,...O(e)})}function BC(r){const t=jC(e=>(e.addIssue=n=>{if(typeof n=="string")e.issues.push(uo(n,e.value,t._zod.def));else{const i=n;i.fatal&&(i.continue=!1),i.code??(i.code="custom"),i.input??(i.input=e.value),i.inst??(i.inst=t),i.continue??(i.continue=!t._zod.def.abort),e.issues.push(uo(i))}},r(e.value,e)));return t}function jC(r,t){const e=new ct({check:"custom",...O(t)});return e._zod.check=r,e}function jy(r){let t=(r==null?void 0:r.target)??"draft-2020-12";return t==="draft-4"&&(t="draft-04"),t==="draft-7"&&(t="draft-07"),{processors:r.processors??{},metadataRegistry:(r==null?void 0:r.metadata)??Bs,target:t,unrepresentable:(r==null?void 0:r.unrepresentable)??"throw",override:(r==null?void 0:r.override)??(()=>{}),io:(r==null?void 0:r.io)??"output",counter:0,seen:new Map,cycles:(r==null?void 0:r.cycles)??"ref",reused:(r==null?void 0:r.reused)??"inline",external:(r==null?void 0:r.external)??void 0}}function Ee(r,t,e={path:[],schemaPath:[]}){var h,f;var n;const i=r._zod.def,s=t.seen.get(r);if(s)return s.count++,e.schemaPath.includes(r)&&(s.cycle=e.path),s.schema;const o={schema:{},count:1,cycle:void 0,path:e.path};t.seen.set(r,o);const a=(f=(h=r._zod).toJSONSchema)==null?void 0:f.call(h);if(a)o.schema=a;else{const y={...e,schemaPath:[...e.schemaPath,r],path:e.path};if(r._zod.processJSONSchema)r._zod.processJSONSchema(t,o.schema,y);else{const E=o.schema,x=t.processors[i.type];if(!x)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${i.type}`);x(r,t,E,y)}const m=r._zod.parent;m&&(o.ref||(o.ref=m),Ee(m,t,y),t.seen.get(m).isParent=!0)}const c=t.metadataRegistry.get(r);return c&&Object.assign(o.schema,c),t.io==="input"&&Ke(r)&&(delete o.schema.examples,delete o.schema.default),t.io==="input"&&o.schema._prefault&&((n=o.schema).default??(n.default=o.schema._prefault)),delete o.schema._prefault,t.seen.get(r).schema}function Vy(r,t){var o,a,c,u;const e=r.seen.get(t);if(!e)throw new Error("Unprocessed schema. This is a bug in Zod.");const n=new Map;for(const h of r.seen.entries()){const f=(o=r.metadataRegistry.get(h[0]))==null?void 0:o.id;if(f){const y=n.get(f);if(y&&y!==h[0])throw new Error(`Duplicate schema id "${f}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);n.set(f,h[0])}}const i=h=>{var x;const f=r.target==="draft-2020-12"?"$defs":"definitions";if(r.external){const I=(x=r.external.registry.get(h[0]))==null?void 0:x.id,P=r.external.uri??(B=>B);if(I)return{ref:P(I)};const R=h[1].defId??h[1].schema.id??`schema${r.counter++}`;return h[1].defId=R,{defId:R,ref:`${P("__shared")}#/${f}/${R}`}}if(h[1]===e)return{ref:"#"};const m=`#/${f}/`,E=h[1].schema.id??`__schema${r.counter++}`;return{defId:E,ref:m+E}},s=h=>{if(h[1].schema.$ref)return;const f=h[1],{ref:y,defId:m}=i(h);f.def={...f.schema},m&&(f.defId=m);const E=f.schema;for(const x in E)delete E[x];E.$ref=y};if(r.cycles==="throw")for(const h of r.seen.entries()){const f=h[1];if(f.cycle)throw new Error(`Cycle detected: #/${(a=f.cycle)==null?void 0:a.join("/")}/<root>
41
-
42
- Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(const h of r.seen.entries()){const f=h[1];if(t===h[0]){s(h);continue}if(r.external){const m=(c=r.external.registry.get(h[0]))==null?void 0:c.id;if(t!==h[0]&&m){s(h);continue}}if((u=r.metadataRegistry.get(h[0]))==null?void 0:u.id){s(h);continue}if(f.cycle){s(h);continue}if(f.count>1&&r.reused==="ref"){s(h);continue}}}function Gy(r,t){var o,a,c;const e=r.seen.get(t);if(!e)throw new Error("Unprocessed schema. This is a bug in Zod.");const n=u=>{const h=r.seen.get(u);if(h.ref===null)return;const f=h.def??h.schema,y={...f},m=h.ref;if(h.ref=null,m){n(m);const x=r.seen.get(m),I=x.schema;if(I.$ref&&(r.target==="draft-07"||r.target==="draft-04"||r.target==="openapi-3.0")?(f.allOf=f.allOf??[],f.allOf.push(I)):Object.assign(f,I),Object.assign(f,y),u._zod.parent===m)for(const R in f)R==="$ref"||R==="allOf"||R in y||delete f[R];if(I.$ref&&x.def)for(const R in f)R==="$ref"||R==="allOf"||R in x.def&&JSON.stringify(f[R])===JSON.stringify(x.def[R])&&delete f[R]}const E=u._zod.parent;if(E&&E!==m){n(E);const x=r.seen.get(E);if(x!=null&&x.schema.$ref&&(f.$ref=x.schema.$ref,x.def))for(const I in f)I==="$ref"||I==="allOf"||I in x.def&&JSON.stringify(f[I])===JSON.stringify(x.def[I])&&delete f[I]}r.override({zodSchema:u,jsonSchema:f,path:h.path??[]})};for(const u of[...r.seen.entries()].reverse())n(u[0]);const i={};if(r.target==="draft-2020-12"?i.$schema="https://json-schema.org/draft/2020-12/schema":r.target==="draft-07"?i.$schema="http://json-schema.org/draft-07/schema#":r.target==="draft-04"?i.$schema="http://json-schema.org/draft-04/schema#":r.target,(o=r.external)!=null&&o.uri){const u=(a=r.external.registry.get(t))==null?void 0:a.id;if(!u)throw new Error("Schema is missing an `id` property");i.$id=r.external.uri(u)}Object.assign(i,e.def??e.schema);const s=((c=r.external)==null?void 0:c.defs)??{};for(const u of r.seen.entries()){const h=u[1];h.def&&h.defId&&(s[h.defId]=h.def)}r.external||Object.keys(s).length>0&&(r.target==="draft-2020-12"?i.$defs=s:i.definitions=s);try{const u=JSON.parse(JSON.stringify(i));return Object.defineProperty(u,"~standard",{value:{...t["~standard"],jsonSchema:{input:zl(t,"input",r.processors),output:zl(t,"output",r.processors)}},enumerable:!1,writable:!1}),u}catch{throw new Error("Error converting schema to JSON.")}}function Ke(r,t){const e=t??{seen:new Set};if(e.seen.has(r))return!1;e.seen.add(r);const n=r._zod.def;if(n.type==="transform")return!0;if(n.type==="array")return Ke(n.element,e);if(n.type==="set")return Ke(n.valueType,e);if(n.type==="lazy")return Ke(n.getter(),e);if(n.type==="promise"||n.type==="optional"||n.type==="nonoptional"||n.type==="nullable"||n.type==="readonly"||n.type==="default"||n.type==="prefault")return Ke(n.innerType,e);if(n.type==="intersection")return Ke(n.left,e)||Ke(n.right,e);if(n.type==="record"||n.type==="map")return Ke(n.keyType,e)||Ke(n.valueType,e);if(n.type==="pipe")return Ke(n.in,e)||Ke(n.out,e);if(n.type==="object"){for(const i in n.shape)if(Ke(n.shape[i],e))return!0;return!1}if(n.type==="union"){for(const i of n.options)if(Ke(i,e))return!0;return!1}if(n.type==="tuple"){for(const i of n.items)if(Ke(i,e))return!0;return!!(n.rest&&Ke(n.rest,e))}return!1}const VC=(r,t={})=>e=>{const n=jy({...e,processors:t});return Ee(r,n),Vy(n,r),Gy(n,r)},zl=(r,t,e={})=>n=>{const{libraryOptions:i,target:s}=n??{},o=jy({...i??{},target:s,io:t,processors:e});return Ee(r,o),Vy(o,r),Gy(o,r)},GC={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},qC=(r,t,e,n)=>{const i=e;i.type="string";const{minimum:s,maximum:o,format:a,patterns:c,contentEncoding:u}=r._zod.bag;if(typeof s=="number"&&(i.minLength=s),typeof o=="number"&&(i.maxLength=o),a&&(i.format=GC[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(f=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:f.source}))])}},YC=(r,t,e,n)=>{const i=e,{minimum:s,maximum:o,format:a,multipleOf:c,exclusiveMaximum:u,exclusiveMinimum:h}=r._zod.bag;typeof a=="string"&&a.includes("int")?i.type="integer":i.type="number",typeof h=="number"&&(t.target==="draft-04"||t.target==="openapi-3.0"?(i.minimum=h,i.exclusiveMinimum=!0):i.exclusiveMinimum=h),typeof s=="number"&&(i.minimum=s,typeof h=="number"&&t.target!=="draft-04"&&(h>=s?delete i.minimum:delete i.exclusiveMinimum)),typeof u=="number"&&(t.target==="draft-04"||t.target==="openapi-3.0"?(i.maximum=u,i.exclusiveMaximum=!0):i.exclusiveMaximum=u),typeof o=="number"&&(i.maximum=o,typeof u=="number"&&t.target!=="draft-04"&&(u<=o?delete i.maximum:delete i.exclusiveMaximum)),typeof c=="number"&&(i.multipleOf=c)},KC=(r,t,e,n)=>{e.type="boolean"},JC=(r,t,e,n)=>{e.not={}},XC=(r,t,e,n)=>{},QC=(r,t,e,n)=>{const i=r._zod.def,s=xy(i.entries);s.every(o=>typeof o=="number")&&(e.type="number"),s.every(o=>typeof o=="string")&&(e.type="string"),e.enum=s},eR=(r,t,e,n)=>{const i=r._zod.def,s=[];for(const o of i.values)if(o===void 0){if(t.unrepresentable==="throw")throw new Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof o=="bigint"){if(t.unrepresentable==="throw")throw new Error("BigInt literals cannot be represented in JSON Schema");s.push(Number(o))}else s.push(o);if(s.length!==0)if(s.length===1){const o=s[0];e.type=o===null?"null":typeof o,t.target==="draft-04"||t.target==="openapi-3.0"?e.enum=[o]:e.const=o}else s.every(o=>typeof o=="number")&&(e.type="number"),s.every(o=>typeof o=="string")&&(e.type="string"),s.every(o=>typeof o=="boolean")&&(e.type="boolean"),s.every(o=>o===null)&&(e.type="null"),e.enum=s},tR=(r,t,e,n)=>{if(t.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema")},rR=(r,t,e,n)=>{if(t.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema")},nR=(r,t,e,n)=>{const i=e,s=r._zod.def,{minimum:o,maximum:a}=r._zod.bag;typeof o=="number"&&(i.minItems=o),typeof a=="number"&&(i.maxItems=a),i.type="array",i.items=Ee(s.element,t,{...n,path:[...n.path,"items"]})},iR=(r,t,e,n)=>{var u;const i=e,s=r._zod.def;i.type="object",i.properties={};const o=s.shape;for(const h in o)i.properties[h]=Ee(o[h],t,{...n,path:[...n.path,"properties",h]});const a=new Set(Object.keys(o)),c=new Set([...a].filter(h=>{const f=s.shape[h]._zod;return t.io==="input"?f.optin===void 0:f.optout===void 0}));c.size>0&&(i.required=Array.from(c)),((u=s.catchall)==null?void 0:u._zod.def.type)==="never"?i.additionalProperties=!1:s.catchall?s.catchall&&(i.additionalProperties=Ee(s.catchall,t,{...n,path:[...n.path,"additionalProperties"]})):t.io==="output"&&(i.additionalProperties=!1)},sR=(r,t,e,n)=>{const i=r._zod.def,s=i.inclusive===!1,o=i.options.map((a,c)=>Ee(a,t,{...n,path:[...n.path,s?"oneOf":"anyOf",c]}));s?e.oneOf=o:e.anyOf=o},oR=(r,t,e,n)=>{const i=r._zod.def,s=Ee(i.left,t,{...n,path:[...n.path,"allOf",0]}),o=Ee(i.right,t,{...n,path:[...n.path,"allOf",1]}),a=u=>"allOf"in u&&Object.keys(u).length===1,c=[...a(s)?s.allOf:[s],...a(o)?o.allOf:[o]];e.allOf=c},aR=(r,t,e,n)=>{const i=e,s=r._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=Ee(s.valueType,t,{...n,path:[...n.path,"patternProperties","*"]});i.patternProperties={};for(const f of c)i.patternProperties[f.source]=h}else(t.target==="draft-07"||t.target==="draft-2020-12")&&(i.propertyNames=Ee(s.keyType,t,{...n,path:[...n.path,"propertyNames"]})),i.additionalProperties=Ee(s.valueType,t,{...n,path:[...n.path,"additionalProperties"]});const u=o._zod.values;if(u){const h=[...u].filter(f=>typeof f=="string"||typeof f=="number");h.length>0&&(i.required=h)}},lR=(r,t,e,n)=>{const i=r._zod.def,s=Ee(i.innerType,t,n),o=t.seen.get(r);t.target==="openapi-3.0"?(o.ref=i.innerType,e.nullable=!0):e.anyOf=[s,{type:"null"}]},cR=(r,t,e,n)=>{const i=r._zod.def;Ee(i.innerType,t,n);const s=t.seen.get(r);s.ref=i.innerType},uR=(r,t,e,n)=>{const i=r._zod.def;Ee(i.innerType,t,n);const s=t.seen.get(r);s.ref=i.innerType,e.default=JSON.parse(JSON.stringify(i.defaultValue))},hR=(r,t,e,n)=>{const i=r._zod.def;Ee(i.innerType,t,n);const s=t.seen.get(r);s.ref=i.innerType,t.io==="input"&&(e._prefault=JSON.parse(JSON.stringify(i.defaultValue)))},dR=(r,t,e,n)=>{const i=r._zod.def;Ee(i.innerType,t,n);const s=t.seen.get(r);s.ref=i.innerType;let o;try{o=i.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}e.default=o},pR=(r,t,e,n)=>{const i=r._zod.def,s=t.io==="input"?i.in._zod.def.type==="transform"?i.out:i.in:i.out;Ee(s,t,n);const o=t.seen.get(r);o.ref=s},fR=(r,t,e,n)=>{const i=r._zod.def;Ee(i.innerType,t,n);const s=t.seen.get(r);s.ref=i.innerType,e.readOnly=!0},qy=(r,t,e,n)=>{const i=r._zod.def;Ee(i.innerType,t,n);const s=t.seen.get(r);s.ref=i.innerType},gR=A("ZodISODateTime",(r,t)=>{mI.init(r,t),be.init(r,t)});function mR(r){return _C(gR,r)}const vR=A("ZodISODate",(r,t)=>{vI.init(r,t),be.init(r,t)});function yR(r){return kC(vR,r)}const bR=A("ZodISOTime",(r,t)=>{yI.init(r,t),be.init(r,t)});function wR(r){return xC(bR,r)}const SR=A("ZodISODuration",(r,t)=>{bI.init(r,t),be.init(r,t)});function _R(r){return EC(SR,r)}const Yy=(r,t)=>{Ty.init(r,t),r.name="ZodError",Object.defineProperties(r,{format:{value:e=>cT(r,e)},flatten:{value:e=>lT(r,e)},addIssue:{value:e=>{r.issues.push(e),r.message=JSON.stringify(r.issues,nh,2)}},addIssues:{value:e=>{r.issues.push(...e),r.message=JSON.stringify(r.issues,nh,2)}},isEmpty:{get(){return r.issues.length===0}}})},Fg=A("ZodError",Yy),xt=A("ZodError",Yy,{Parent:Error}),kR=Wd(xt),xR=Bd(xt),ER=mc(xt),AR=vc(xt),$R=dT(xt),TR=pT(xt),IR=fT(xt),CR=gT(xt),RR=mT(xt),PR=vT(xt),LR=yT(xt),DR=bT(xt),ye=A("ZodType",(r,t)=>(ve.init(r,t),Object.assign(r["~standard"],{jsonSchema:{input:zl(r,"input"),output:zl(r,"output")}}),r.toJSONSchema=VC(r,{}),r.def=t,r.type=t.type,Object.defineProperty(r,"_def",{value:t}),r.check=(...e)=>r.clone(on(t,{checks:[...t.checks??[],...e.map(n=>typeof n=="function"?{_zod:{check:n,def:{check:"custom"},onattach:[]}}:n)]}),{parent:!0}),r.with=r.check,r.clone=(e,n)=>an(r,e,n),r.brand=()=>r,r.register=(e,n)=>(e.add(r,n),r),r.parse=(e,n)=>kR(r,e,n,{callee:r.parse}),r.safeParse=(e,n)=>ER(r,e,n),r.parseAsync=async(e,n)=>xR(r,e,n,{callee:r.parseAsync}),r.safeParseAsync=async(e,n)=>AR(r,e,n),r.spa=r.safeParseAsync,r.encode=(e,n)=>$R(r,e,n),r.decode=(e,n)=>TR(r,e,n),r.encodeAsync=async(e,n)=>IR(r,e,n),r.decodeAsync=async(e,n)=>CR(r,e,n),r.safeEncode=(e,n)=>RR(r,e,n),r.safeDecode=(e,n)=>PR(r,e,n),r.safeEncodeAsync=async(e,n)=>LR(r,e,n),r.safeDecodeAsync=async(e,n)=>DR(r,e,n),r.refine=(e,n)=>r.check(AP(e,n)),r.superRefine=e=>r.check($P(e)),r.overwrite=e=>r.check(_s(e)),r.optional=()=>Wg(r),r.exactOptional=()=>pP(r),r.nullable=()=>Bg(r),r.nullish=()=>Wg(Bg(r)),r.nonoptional=e=>bP(r,e),r.array=()=>z(r),r.or=e=>j([r,e]),r.and=e=>bc(r,e),r.transform=e=>jg(r,hP(e)),r.default=e=>mP(r,e),r.prefault=e=>yP(r,e),r.catch=e=>SP(r,e),r.pipe=e=>jg(r,e),r.readonly=()=>xP(r),r.describe=e=>{const n=r.clone();return Bs.add(n,{description:e}),n},Object.defineProperty(r,"description",{get(){var e;return(e=Bs.get(r))==null?void 0:e.description},configurable:!0}),r.meta=(...e)=>{if(e.length===0)return Bs.get(r);const n=r.clone();return Bs.add(n,e[0]),n},r.isOptional=()=>r.safeParse(void 0).success,r.isNullable=()=>r.safeParse(null).success,r.apply=e=>e(r),r)),Ky=A("_ZodString",(r,t)=>{jd.init(r,t),ye.init(r,t),r._zod.processJSONSchema=(n,i,s)=>qC(r,n,i);const e=r._zod.bag;r.format=e.format??null,r.minLength=e.minimum??null,r.maxLength=e.maximum??null,r.regex=(...n)=>r.check(RC(...n)),r.includes=(...n)=>r.check(DC(...n)),r.startsWith=(...n)=>r.check(zC(...n)),r.endsWith=(...n)=>r.check(OC(...n)),r.min=(...n)=>r.check(Dl(...n)),r.max=(...n)=>r.check(Wy(...n)),r.length=(...n)=>r.check(By(...n)),r.nonempty=(...n)=>r.check(Dl(1,...n)),r.lowercase=n=>r.check(PC(n)),r.uppercase=n=>r.check(LC(n)),r.trim=()=>r.check(NC()),r.normalize=(...n)=>r.check(MC(...n)),r.toLowerCase=()=>r.check(UC()),r.toUpperCase=()=>r.check(FC()),r.slugify=()=>r.check(HC())}),zR=A("ZodString",(r,t)=>{jd.init(r,t),Ky.init(r,t),r.email=e=>r.check(tC(OR,e)),r.url=e=>r.check(oC(MR,e)),r.jwt=e=>r.check(SC(XR,e)),r.emoji=e=>r.check(aC(NR,e)),r.guid=e=>r.check(Og(Hg,e)),r.uuid=e=>r.check(rC(Va,e)),r.uuidv4=e=>r.check(nC(Va,e)),r.uuidv6=e=>r.check(iC(Va,e)),r.uuidv7=e=>r.check(sC(Va,e)),r.nanoid=e=>r.check(lC(UR,e)),r.guid=e=>r.check(Og(Hg,e)),r.cuid=e=>r.check(cC(FR,e)),r.cuid2=e=>r.check(uC(HR,e)),r.ulid=e=>r.check(hC(ZR,e)),r.base64=e=>r.check(yC(YR,e)),r.base64url=e=>r.check(bC(KR,e)),r.xid=e=>r.check(dC(WR,e)),r.ksuid=e=>r.check(pC(BR,e)),r.ipv4=e=>r.check(fC(jR,e)),r.ipv6=e=>r.check(gC(VR,e)),r.cidrv4=e=>r.check(mC(GR,e)),r.cidrv6=e=>r.check(vC(qR,e)),r.e164=e=>r.check(wC(JR,e)),r.datetime=e=>r.check(mR(e)),r.date=e=>r.check(yR(e)),r.time=e=>r.check(wR(e)),r.duration=e=>r.check(_R(e))});function d(r){return eC(zR,r)}const be=A("ZodStringFormat",(r,t)=>{ge.init(r,t),Ky.init(r,t)}),OR=A("ZodEmail",(r,t)=>{aI.init(r,t),be.init(r,t)}),Hg=A("ZodGUID",(r,t)=>{sI.init(r,t),be.init(r,t)}),Va=A("ZodUUID",(r,t)=>{oI.init(r,t),be.init(r,t)}),MR=A("ZodURL",(r,t)=>{lI.init(r,t),be.init(r,t)}),NR=A("ZodEmoji",(r,t)=>{cI.init(r,t),be.init(r,t)}),UR=A("ZodNanoID",(r,t)=>{uI.init(r,t),be.init(r,t)}),FR=A("ZodCUID",(r,t)=>{hI.init(r,t),be.init(r,t)}),HR=A("ZodCUID2",(r,t)=>{dI.init(r,t),be.init(r,t)}),ZR=A("ZodULID",(r,t)=>{pI.init(r,t),be.init(r,t)}),WR=A("ZodXID",(r,t)=>{fI.init(r,t),be.init(r,t)}),BR=A("ZodKSUID",(r,t)=>{gI.init(r,t),be.init(r,t)}),jR=A("ZodIPv4",(r,t)=>{wI.init(r,t),be.init(r,t)}),VR=A("ZodIPv6",(r,t)=>{SI.init(r,t),be.init(r,t)}),GR=A("ZodCIDRv4",(r,t)=>{_I.init(r,t),be.init(r,t)}),qR=A("ZodCIDRv6",(r,t)=>{kI.init(r,t),be.init(r,t)}),YR=A("ZodBase64",(r,t)=>{xI.init(r,t),be.init(r,t)}),KR=A("ZodBase64URL",(r,t)=>{AI.init(r,t),be.init(r,t)}),JR=A("ZodE164",(r,t)=>{$I.init(r,t),be.init(r,t)}),XR=A("ZodJWT",(r,t)=>{II.init(r,t),be.init(r,t)}),Jy=A("ZodNumber",(r,t)=>{Ny.init(r,t),ye.init(r,t),r._zod.processJSONSchema=(n,i,s)=>YC(r,n,i),r.gt=(n,i)=>r.check(Ng(n,i)),r.gte=(n,i)=>r.check(bu(n,i)),r.min=(n,i)=>r.check(bu(n,i)),r.lt=(n,i)=>r.check(Mg(n,i)),r.lte=(n,i)=>r.check(yu(n,i)),r.max=(n,i)=>r.check(yu(n,i)),r.int=n=>r.check(Zg(n)),r.safe=n=>r.check(Zg(n)),r.positive=n=>r.check(Ng(0,n)),r.nonnegative=n=>r.check(bu(0,n)),r.negative=n=>r.check(Mg(0,n)),r.nonpositive=n=>r.check(yu(0,n)),r.multipleOf=(n,i)=>r.check(Ug(n,i)),r.step=(n,i)=>r.check(Ug(n,i)),r.finite=()=>r;const e=r._zod.bag;r.minValue=Math.max(e.minimum??Number.NEGATIVE_INFINITY,e.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,r.maxValue=Math.min(e.maximum??Number.POSITIVE_INFINITY,e.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,r.isInt=(e.format??"").includes("int")||Number.isSafeInteger(e.multipleOf??.5),r.isFinite=!0,r.format=e.format??null});function H(r){return AC(Jy,r)}const QR=A("ZodNumberFormat",(r,t)=>{CI.init(r,t),Jy.init(r,t)});function Zg(r){return $C(QR,r)}const eP=A("ZodBoolean",(r,t)=>{RI.init(r,t),ye.init(r,t),r._zod.processJSONSchema=(e,n,i)=>KC(r,e,n)});function De(r){return TC(eP,r)}const tP=A("ZodUnknown",(r,t)=>{PI.init(r,t),ye.init(r,t),r._zod.processJSONSchema=(e,n,i)=>XC()});function _(){return IC(tP)}const rP=A("ZodNever",(r,t)=>{LI.init(r,t),ye.init(r,t),r._zod.processJSONSchema=(e,n,i)=>JC(r,e,n)});function nP(r){return CC(rP,r)}const iP=A("ZodArray",(r,t)=>{DI.init(r,t),ye.init(r,t),r._zod.processJSONSchema=(e,n,i)=>nR(r,e,n,i),r.element=t.element,r.min=(e,n)=>r.check(Dl(e,n)),r.nonempty=e=>r.check(Dl(1,e)),r.max=(e,n)=>r.check(Wy(e,n)),r.length=(e,n)=>r.check(By(e,n)),r.unwrap=()=>r.element});function z(r,t){return ZC(iP,r,t)}const Xy=A("ZodObject",(r,t)=>{OI.init(r,t),ye.init(r,t),r._zod.processJSONSchema=(e,n,i)=>iR(r,e,n,i),te(r,"shape",()=>t.shape),r.keyof=()=>tb(Object.keys(r._zod.def.shape)),r.catchall=e=>r.clone({...r._zod.def,catchall:e}),r.passthrough=()=>r.clone({...r._zod.def,catchall:_()}),r.loose=()=>r.clone({...r._zod.def,catchall:_()}),r.strict=()=>r.clone({...r._zod.def,catchall:nP()}),r.strip=()=>r.clone({...r._zod.def,catchall:void 0}),r.extend=e=>nT(r,e),r.safeExtend=e=>iT(r,e),r.merge=e=>sT(r,e),r.pick=e=>tT(r,e),r.omit=e=>rT(r,e),r.partial=(...e)=>oT(rb,r,e[0]),r.required=(...e)=>aT(nb,r,e[0])});function Qy(r,t){const e={type:"object",shape:r??{},...O(t)};return new Xy(e)}function v(r,t){return new Xy({type:"object",shape:r,catchall:_(),...O(t)})}const eb=A("ZodUnion",(r,t)=>{Hy.init(r,t),ye.init(r,t),r._zod.processJSONSchema=(e,n,i)=>sR(r,e,n,i),r.options=t.options});function j(r,t){return new eb({type:"union",options:r,...O(t)})}const sP=A("ZodDiscriminatedUnion",(r,t)=>{eb.init(r,t),MI.init(r,t)});function oP(r,t,e){return new sP({type:"union",options:t,discriminator:r,...O(e)})}const aP=A("ZodIntersection",(r,t)=>{NI.init(r,t),ye.init(r,t),r._zod.processJSONSchema=(e,n,i)=>oR(r,e,n,i)});function bc(r,t){return new aP({type:"intersection",left:r,right:t})}const lP=A("ZodRecord",(r,t)=>{UI.init(r,t),ye.init(r,t),r._zod.processJSONSchema=(e,n,i)=>aR(r,e,n,i),r.keyType=t.keyType,r.valueType=t.valueType});function k(r,t,e){return new lP({type:"record",keyType:r,valueType:t,...O(e)})}const sh=A("ZodEnum",(r,t)=>{FI.init(r,t),ye.init(r,t),r._zod.processJSONSchema=(n,i,s)=>QC(r,n,i),r.enum=t.entries,r.options=Object.values(t.entries);const e=new Set(Object.keys(t.entries));r.extract=(n,i)=>{const s={};for(const o of n)if(e.has(o))s[o]=t.entries[o];else throw new Error(`Key ${o} not found in enum`);return new sh({...t,checks:[],...O(i),entries:s})},r.exclude=(n,i)=>{const s={...t.entries};for(const o of n)if(e.has(o))delete s[o];else throw new Error(`Key ${o} not found in enum`);return new sh({...t,checks:[],...O(i),entries:s})}});function tb(r,t){const e=Array.isArray(r)?Object.fromEntries(r.map(n=>[n,n])):r;return new sh({type:"enum",entries:e,...O(t)})}const cP=A("ZodLiteral",(r,t)=>{HI.init(r,t),ye.init(r,t),r._zod.processJSONSchema=(e,n,i)=>eR(r,e,n),r.values=new Set(t.values),Object.defineProperty(r,"value",{get(){if(t.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function $(r,t){return new cP({type:"literal",values:Array.isArray(r)?r:[r],...O(t)})}const uP=A("ZodTransform",(r,t)=>{ZI.init(r,t),ye.init(r,t),r._zod.processJSONSchema=(e,n,i)=>rR(r,e),r._zod.parse=(e,n)=>{if(n.direction==="backward")throw new _y(r.constructor.name);e.addIssue=s=>{if(typeof s=="string")e.issues.push(uo(s,e.value,t));else{const o=s;o.fatal&&(o.continue=!1),o.code??(o.code="custom"),o.input??(o.input=e.value),o.inst??(o.inst=r),e.issues.push(uo(o))}};const i=t.transform(e.value,e);return i instanceof Promise?i.then(s=>(e.value=s,e)):(e.value=i,e)}});function hP(r){return new uP({type:"transform",transform:r})}const rb=A("ZodOptional",(r,t)=>{Zy.init(r,t),ye.init(r,t),r._zod.processJSONSchema=(e,n,i)=>qy(r,e,n,i),r.unwrap=()=>r._zod.def.innerType});function Wg(r){return new rb({type:"optional",innerType:r})}const dP=A("ZodExactOptional",(r,t)=>{WI.init(r,t),ye.init(r,t),r._zod.processJSONSchema=(e,n,i)=>qy(r,e,n,i),r.unwrap=()=>r._zod.def.innerType});function pP(r){return new dP({type:"optional",innerType:r})}const fP=A("ZodNullable",(r,t)=>{BI.init(r,t),ye.init(r,t),r._zod.processJSONSchema=(e,n,i)=>lR(r,e,n,i),r.unwrap=()=>r._zod.def.innerType});function Bg(r){return new fP({type:"nullable",innerType:r})}const gP=A("ZodDefault",(r,t)=>{jI.init(r,t),ye.init(r,t),r._zod.processJSONSchema=(e,n,i)=>uR(r,e,n,i),r.unwrap=()=>r._zod.def.innerType,r.removeDefault=r.unwrap});function mP(r,t){return new gP({type:"default",innerType:r,get defaultValue(){return typeof t=="function"?t():Ay(t)}})}const vP=A("ZodPrefault",(r,t)=>{VI.init(r,t),ye.init(r,t),r._zod.processJSONSchema=(e,n,i)=>hR(r,e,n,i),r.unwrap=()=>r._zod.def.innerType});function yP(r,t){return new vP({type:"prefault",innerType:r,get defaultValue(){return typeof t=="function"?t():Ay(t)}})}const nb=A("ZodNonOptional",(r,t)=>{GI.init(r,t),ye.init(r,t),r._zod.processJSONSchema=(e,n,i)=>cR(r,e,n,i),r.unwrap=()=>r._zod.def.innerType});function bP(r,t){return new nb({type:"nonoptional",innerType:r,...O(t)})}const wP=A("ZodCatch",(r,t)=>{qI.init(r,t),ye.init(r,t),r._zod.processJSONSchema=(e,n,i)=>dR(r,e,n,i),r.unwrap=()=>r._zod.def.innerType,r.removeCatch=r.unwrap});function SP(r,t){return new wP({type:"catch",innerType:r,catchValue:typeof t=="function"?t:()=>t})}const _P=A("ZodPipe",(r,t)=>{YI.init(r,t),ye.init(r,t),r._zod.processJSONSchema=(e,n,i)=>pR(r,e,n,i),r.in=t.in,r.out=t.out});function jg(r,t){return new _P({type:"pipe",in:r,out:t})}const kP=A("ZodReadonly",(r,t)=>{KI.init(r,t),ye.init(r,t),r._zod.processJSONSchema=(e,n,i)=>fR(r,e,n,i),r.unwrap=()=>r._zod.def.innerType});function xP(r){return new kP({type:"readonly",innerType:r})}const EP=A("ZodCustom",(r,t)=>{JI.init(r,t),ye.init(r,t),r._zod.processJSONSchema=(e,n,i)=>tR(r,e)});function AP(r,t={}){return WC(EP,r,t)}function $P(r){return BC(r)}const TP=[".md",".markdown"];function ib(r){if(r.length===0)return!1;const t=r.at(-1);return t==="/"||t==="\\"}function sb(r){const t=r.lastIndexOf("/"),e=r.lastIndexOf("\\");return r.slice(Math.max(t,e)+1)}function IP(r){return sb(r).toLowerCase()}function CP(r,t){const e=IP(r);return t.some(n=>e.endsWith(n))}function ob(r){return!ib(r)&&CP(r,TP)}function RP(r){let t;try{t=new URL(r)}catch{return!1}return t.protocol==="http:"||t.protocol==="https:"}function gr(r){try{const{pathname:t}=new URL(r);return/^\/artifact\/[0-9A-Za-z]{26}(\/|$)/.test(t)}catch{return!1}}const PP=Qy({id:d().min(1),kind:$("path"),title:d(),path:d()}).strict(),LP=Qy({id:d().min(1),kind:$("url"),title:d(),url:d().refine(RP,{message:"url must be an http(s) URL"})}).strict();oP("kind",[PP,LP]);function ab(r){return typeof r=="object"&&r!==null}function lb(r){return!ab(r)||r.type!=="ready"?!1:!("id"in r)}function cb(r){return!(!ab(r)||r.type!=="update-content"||typeof r.id!="string"||typeof r.content!="string")}const DP="/views/markdown/",zP="/views/url-unsupported/";function ub(r){return`/artifact/${encodeURIComponent(r)}`}function OP(r,t){return`${ub(r)}/${encodeURIComponent(t)}`}function MP(r){return`/markdown/${encodeURIComponent(r)}`}function Ol(r,t={electron:!1}){if(r.kind==="url")return t.electron?{renderer:"url-webview",viewURL:r.url,contentURL:null}:gr(r.url)?{renderer:"proxy-iframe",viewURL:r.url,contentURL:null}:{renderer:"url-unsupported",viewURL:zP,contentURL:null};if(ob(r.path)){const n={viewURL:DP,contentURL:MP(r.id)};return t.electron?{renderer:"url-webview",...n}:{renderer:"markdown",...n}}const e=ib(r.path)?`${ub(r.id)}/`:OP(r.id,sb(r.path));return t.electron?{renderer:"url-webview",viewURL:e,contentURL:null}:{renderer:"proxy-iframe",viewURL:e,contentURL:null}}const NP="serverURL",UP="token",FP="mode",HP="electron";function hb(r=window.location.search,t=window.location.origin){const n=new URLSearchParams(r).get(NP);return n?new URL(n).origin:new URL(t).origin}function ZP(r=window.location.search){return new URLSearchParams(r).get(UP)}function ar(r=typeof window>"u"?"":window.location.search){return new URLSearchParams(r).get(FP)===HP}const pe={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"},fr={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"},WP=1,BP=v({_meta:k(d(),_()).nullish(),terminal:De().optional().default(!1)}),jP=v({_meta:k(d(),_()).nullish(),label:d().nullish(),name:d(),optional:De().optional().default(!1),secret:De().optional().default(!0)}),VP=v({_meta:k(d(),_()).nullish(),description:d().nullish(),id:d(),name:d()}),GP=v({_meta:k(d(),_()).nullish(),description:d().nullish(),id:d(),link:d().nullish(),name:d(),vars:z(jP)}),qP=v({_meta:k(d(),_()).nullish(),args:z(d()).optional(),description:d().nullish(),env:k(d(),d()).optional(),id:d(),name:d()}),YP=j([GP.and(v({type:$("env_var")})),qP.and(v({type:$("terminal")})),VP]),KP=v({_meta:k(d(),_()).nullish(),methodId:d()}),JP=v({_meta:k(d(),_()).nullish()}),XP=v({_meta:k(d(),_()).nullish(),blob:d(),mimeType:d().nullish(),uri:d()}),QP=v({default:De().nullish(),description:d().nullish(),title:d().nullish()}),eL=v({_meta:k(d(),_()).nullish()}),tL=v({_meta:k(d(),_()).nullish()}),rL=v({amount:H(),currency:d()}),nL=v({_meta:k(d(),_()).nullish(),terminalId:d()}),iL=v({_meta:k(d(),_()).nullish(),newText:d(),oldText:d().nullish(),path:d()}),sL=j([d(),H(),H(),De(),z(d())]),oL=v({content:k(d(),sL).nullish()}),aL=j([oL.and(v({action:$("accept")})),v({action:$("decline")}),v({action:$("cancel")})]),lL=v({_meta:k(d(),_()).nullish()}),db=d(),cL=v({_meta:k(d(),_()).nullish(),elicitationId:db}),uL=v({_meta:k(d(),_()).nullish(),action:aL}),hL=$("object"),dL=$("string"),pL=v({_meta:k(d(),_()).nullish()}),fL=v({_meta:k(d(),_()).nullish(),form:lL.nullish(),url:pL.nullish()}),gL=v({elicitationId:db,url:d().url()}),pb=v({const:d(),title:d()}),fb=v({_meta:k(d(),_()).nullish(),name:d(),value:d()}),mL=j([$(-32700),$(-32600),$(-32601),$(-32602),$(-32603),$(-32800),$(-32e3),$(-32002),$(-32042),H().int().min(-2147483648,{message:"Invalid value: Expected int32 to be >= -2147483648"}).max(2147483647,{message:"Invalid value: Expected int32 to be <= 2147483647"})]),gb=v({code:mL,data:_().optional(),message:d()}),mb=_(),vb=_(),yb=_(),vL=v({_meta:k(d(),_()).nullish(),readTextFile:De().optional().default(!1),writeTextFile:De().optional().default(!1)}),bb=v({_meta:k(d(),_()).nullish(),name:d(),value:d()}),wb=v({_meta:k(d(),_()).nullish(),name:d(),title:d().nullish(),version:d()}),yL=v({default:H().nullish(),description:d().nullish(),maximum:H().nullish(),minimum:H().nullish(),title:d().nullish()}),bL=v({_meta:k(d(),_()).nullish()}),wL=v({_meta:k(d(),_()).nullish(),additionalDirectories:z(d()).optional(),cursor:d().nullish(),cwd:d().nullish()}),SL=v({_meta:k(d(),_()).nullish()}),_L=v({_meta:k(d(),_()).nullish(),logout:SL.nullish()}),kL=v({_meta:k(d(),_()).nullish()}),xL=v({_meta:k(d(),_()).nullish()}),EL=v({_meta:k(d(),_()).nullish(),http:De().optional().default(!1),sse:De().optional().default(!1)}),AL=v({_meta:k(d(),_()).nullish(),headers:z(bb),name:d(),url:d()}),$L=v({_meta:k(d(),_()).nullish(),headers:z(bb),name:d(),url:d()}),TL=v({_meta:k(d(),_()).nullish(),args:z(d()),command:d(),env:z(fb),name:d()}),wc=j([AL.and(v({type:$("http")})),$L.and(v({type:$("sse")})),TL]),Vd=d(),IL=v({_meta:k(d(),_()).nullish(),description:d().nullish(),modelId:Vd,name:d()}),CL=j([$("error"),$("warning"),$("information"),$("hint")]),RL=v({_meta:k(d(),_()).nullish()}),PL=v({_meta:k(d(),_()).nullish()}),LL=v({_meta:k(d(),_()).nullish()}),DL=v({_meta:k(d(),_()).nullish()}),zL=v({_meta:k(d(),_()).nullish()}),OL=v({_meta:k(d(),_()).nullish(),maxCount:H().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish()}),ML=v({diff:d(),uri:d()}),NL=v({endLine:H().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}),startLine:H().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}),text:d()}),UL=v({_meta:k(d(),_()).nullish()}),FL=v({_meta:k(d(),_()).nullish()}),HL=v({languageId:d(),text:d(),uri:d()}),ZL=v({_meta:k(d(),_()).nullish(),maxCount:H().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish()}),WL=j([$("rejected"),$("ignored"),$("replaced"),$("cancelled")]),BL=v({excerpts:z(NL),uri:d()}),jL=v({_meta:k(d(),_()).nullish()}),VL=v({_meta:k(d(),_()).nullish()}),GL=v({name:d(),owner:d(),remoteUrl:d()}),qL=v({_meta:k(d(),_()).nullish()}),YL=v({_meta:k(d(),_()).nullish(),jump:UL.nullish(),rename:VL.nullish(),searchAndReplace:qL.nullish()}),KL=v({id:d(),isRegex:De().nullish(),replace:d(),search:d(),uri:d()}),JL=j([$("automatic"),$("diagnostic"),$("manual")]),XL=v({_meta:k(d(),_()).nullish(),maxCount:H().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish()}),QL=v({_meta:k(d(),_()).nullish(),diagnostics:RL.nullish(),editHistory:OL.nullish(),openFiles:FL.nullish(),recentFiles:ZL.nullish(),relatedSnippets:jL.nullish(),userActions:XL.nullish()}),eD=v({_meta:k(d(),_()).nullish(),additionalDirectories:z(d()).optional(),cwd:d(),mcpServers:z(wc)}),tD=v({default:H().nullish(),description:d().nullish(),maximum:H().nullish(),minimum:H().nullish(),title:d().nullish()}),Sb=d(),rD=j([$("allow_once"),$("allow_always"),$("reject_once"),$("reject_always")]),nD=v({_meta:k(d(),_()).nullish(),kind:rD,name:d(),optionId:Sb}),iD=j([$("high"),$("medium"),$("low")]),sD=j([$("pending"),$("in_progress"),$("completed")]),oD=v({_meta:k(d(),_()).nullish(),content:d(),priority:iD,status:sD}),aD=v({_meta:k(d(),_()).nullish(),entries:z(oD)}),tn=v({character:H().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}),line:H().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"})}),lD=v({id:d(),position:tn,uri:d()}),cD=v({id:d(),newName:d(),position:tn,uri:d()}),uD=v({action:d(),position:tn,timestampMs:H(),uri:d()}),_b=j([$("utf-16"),$("utf-32"),$("utf-8")]),hD=v({_meta:k(d(),_()).nullish(),auth:BP.optional().default({terminal:!1}),elicitation:fL.nullish(),fs:vL.optional().default({readTextFile:!1,writeTextFile:!1}),nes:YL.nullish(),positionEncodings:z(_b).optional(),terminal:De().optional().default(!1)}),dD=v({_meta:k(d(),_()).nullish(),audio:De().optional().default(!1),embeddedContext:De().optional().default(!1),image:De().optional().default(!1)}),kb=H().int().gte(0).lte(65535),pD=v({_meta:k(d(),_()).nullish(),clientCapabilities:hD.optional().default({auth:{terminal:!1},fs:{readTextFile:!1,writeTextFile:!1},terminal:!1}),clientInfo:wb.nullish(),protocolVersion:kb}),ks=v({end:tn,start:tn}),fD=v({message:d(),range:ks,severity:CL,uri:d()}),gD=v({languageId:d(),lastFocusedMs:H().nullish(),uri:d(),visibleRange:ks.nullish()}),mD=v({_meta:k(d(),_()).nullish(),diagnostics:z(fD).nullish(),editHistory:z(ML).nullish(),openFiles:z(gD).nullish(),recentFiles:z(HL).nullish(),relatedSnippets:z(BL).nullish(),userActions:z(uD).nullish()}),vD=v({newText:d(),range:ks}),yD=v({cursorPosition:tn.nullish(),edits:z(vD),id:d(),uri:d()}),bD=j([yD.and(v({kind:$("edit")})),lD.and(v({kind:$("jump")})),cD.and(v({kind:$("rename")})),KL.and(v({kind:$("searchAndReplace")}))]),wD=v({_meta:k(d(),_()).nullish(),content:d()}),SD=v({_meta:k(d(),_()).nullish()}),Gn=j([H(),d()]).nullable();v({_meta:k(d(),_()).nullish(),requestId:Gn});const _D=tb(["assistant","user"]),_a=v({_meta:k(d(),_()).nullish(),audience:z(_D).nullish(),lastModified:d().nullish(),priority:H().nullish()}),kD=v({_meta:k(d(),_()).nullish(),annotations:_a.nullish(),data:d(),mimeType:d()}),xD=v({_meta:k(d(),_()).nullish(),annotations:_a.nullish(),data:d(),mimeType:d(),uri:d().nullish()}),ED=v({_meta:k(d(),_()).nullish(),annotations:_a.nullish(),description:d().nullish(),mimeType:d().nullish(),name:d(),size:H().nullish(),title:d().nullish(),uri:d()}),AD=v({_meta:k(d(),_()).nullish(),optionId:Sb}),$D=j([v({outcome:$("cancelled")}),AD.and(v({outcome:$("selected")}))]),TD=v({_meta:k(d(),_()).nullish(),outcome:$D}),ID=v({_meta:k(d(),_()).nullish()}),CD=v({_meta:k(d(),_()).nullish()}),RD=v({currentValue:De()}),PD=d(),xb=d(),LD=j([$("mode"),$("model"),$("thought_level"),d()]),Gd=d(),Eb=v({_meta:k(d(),_()).nullish(),description:d().nullish(),name:d(),value:Gd}),DD=v({_meta:k(d(),_()).nullish(),group:PD,name:d(),options:z(Eb)}),zD=j([z(Eb),z(DD)]),OD=v({currentValue:Gd,options:zD}),xs=bc(j([OD.and(v({type:$("select")})),RD.and(v({type:$("boolean")}))]),v({_meta:k(d(),_()).nullish(),category:LD.nullish(),description:d().nullish(),id:xb,name:d()})),MD=v({_meta:k(d(),_()).nullish(),configOptions:z(xs)}),ND=v({_meta:k(d(),_()).nullish()}),Q=d(),UD=v({_meta:k(d(),_()).nullish(),id:d(),sessionId:Q}),FD=v({_meta:k(d(),_()).nullish(),sessionId:Q}),HD=v({_meta:k(d(),_()).nullish(),sessionId:Q}),ZD=v({_meta:k(d(),_()).nullish(),sessionId:Q}),Ab=v({_meta:k(d(),_()).nullish(),args:z(d()).optional(),command:d(),cwd:d().nullish(),env:z(fb).optional(),outputByteLimit:H().nullish(),sessionId:Q}),WD=v({_meta:k(d(),_()).nullish(),sessionId:Q,uri:d()}),BD=v({_meta:k(d(),_()).nullish(),position:tn,sessionId:Q,uri:d(),version:H(),visibleRange:ks}),jD=v({_meta:k(d(),_()).nullish(),languageId:d(),sessionId:Q,text:d(),uri:d(),version:H()}),VD=v({_meta:k(d(),_()).nullish(),sessionId:Q,uri:d()}),GD=v({_meta:k(d(),_()).nullish(),additionalDirectories:z(d()).optional(),cwd:d(),mcpServers:z(wc).optional(),sessionId:Q}),$b=v({_meta:k(d(),_()).nullish(),sessionId:Q,terminalId:d()}),qD=v({_meta:k(d(),_()).nullish(),additionalDirectories:z(d()).optional(),cwd:d(),mcpServers:z(wc),sessionId:Q}),Tb=v({_meta:k(d(),_()).nullish(),limit:H().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),line:H().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),path:d(),sessionId:Q}),YD=v({_meta:k(d(),_()).nullish(),id:d(),reason:WL.nullish(),sessionId:Q}),Ib=v({_meta:k(d(),_()).nullish(),sessionId:Q,terminalId:d()}),KD=v({_meta:k(d(),_()).nullish(),additionalDirectories:z(d()).optional(),cwd:d(),mcpServers:z(wc).optional(),sessionId:Q}),JD=v({_meta:k(d(),_()).nullish(),additionalDirectories:z(d()).optional(),cwd:d(),sessionId:Q,title:d().nullish(),updatedAt:d().nullish()}),XD=v({_meta:k(d(),_()).nullish(),nextCursor:d().nullish(),sessions:z(JD)}),QD=v({_meta:k(d(),_()).nullish(),title:d().nullish(),updatedAt:d().nullish()}),e2=v({_meta:k(d(),_()).nullish()}),Sc=d(),t2=v({_meta:k(d(),_()).nullish(),currentModeId:Sc}),r2=v({_meta:k(d(),_()).nullish(),description:d().nullish(),id:Sc,name:d()}),_c=v({_meta:k(d(),_()).nullish(),availableModes:z(r2),currentModeId:Sc}),kc=v({_meta:k(d(),_()).nullish(),availableModels:z(IL),currentModelId:Vd}),n2=v({_meta:k(d(),_()).nullish(),configOptions:z(xs).nullish(),models:kc.nullish(),modes:_c.nullish(),sessionId:Q}),i2=v({_meta:k(d(),_()).nullish(),configOptions:z(xs).nullish(),models:kc.nullish(),modes:_c.nullish()}),s2=v({_meta:k(d(),_()).nullish(),configOptions:z(xs).nullish(),models:kc.nullish(),modes:_c.nullish(),sessionId:Q}),o2=v({_meta:k(d(),_()).nullish(),configOptions:z(xs).nullish(),models:kc.nullish(),modes:_c.nullish()}),a2=v({_meta:k(d(),_()).nullish()}),l2=v({_meta:k(d(),_()).nullish(),additionalDirectories:ID.nullish(),close:CD.nullish(),fork:ND.nullish(),list:e2.nullish(),resume:a2.nullish()}),c2=bc(j([v({type:$("boolean"),value:De()}),v({value:Gd})]),v({_meta:k(d(),_()).nullish(),configId:xb,sessionId:Q})),u2=v({_meta:k(d(),_()).nullish(),configOptions:z(xs)}),h2=v({_meta:k(d(),_()).nullish(),modeId:Sc,sessionId:Q}),d2=v({_meta:k(d(),_()).nullish()}),p2=v({_meta:k(d(),_()).nullish(),modelId:Vd,sessionId:Q}),f2=v({_meta:k(d(),_()).nullish()}),g2=v({_meta:k(d(),_()).nullish(),sessionId:Q}),m2=j([$("end_turn"),$("max_tokens"),$("max_turn_requests"),$("refusal"),$("cancelled")]),v2=j([$("email"),$("uri"),$("date"),$("date-time")]),y2=v({default:d().nullish(),description:d().nullish(),enum:z(d()).nullish(),format:v2.nullish(),maxLength:H().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),minLength:H().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),oneOf:z(pb).nullish(),pattern:d().nullish(),title:d().nullish()}),b2=v({_meta:k(d(),_()).nullish(),context:mD.nullish(),position:tn,selection:ks.nullish(),sessionId:Q,triggerKind:JL,uri:d(),version:H()}),w2=v({_meta:k(d(),_()).nullish(),suggestions:z(bD)}),S2=v({_meta:k(d(),_()).nullish(),terminalId:d()}),_2=v({_meta:k(d(),_()).nullish(),exitCode:H().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),signal:d().nullish()}),Cb=v({_meta:k(d(),_()).nullish(),sessionId:Q,terminalId:d()}),k2=v({_meta:k(d(),_()).nullish(),exitStatus:_2.nullish(),output:d(),truncated:De()}),x2=v({_meta:k(d(),_()).nullish(),annotations:_a.nullish(),text:d()}),E2=v({range:ks.nullish(),text:d()}),A2=v({_meta:k(d(),_()).nullish(),contentChanges:z(E2),sessionId:Q,uri:d(),version:H()});v({method:d(),params:j([FD,jD,A2,WD,VD,BD,UD,YD,mb]).nullish()});const $2=j([$("full"),$("incremental")]),T2=v({_meta:k(d(),_()).nullish(),syncKind:$2}),I2=v({_meta:k(d(),_()).nullish(),didChange:T2.nullish(),didClose:PL.nullish(),didFocus:LL.nullish(),didOpen:DL.nullish(),didSave:zL.nullish()}),C2=v({_meta:k(d(),_()).nullish(),document:I2.nullish()}),R2=v({_meta:k(d(),_()).nullish(),context:QL.nullish(),events:C2.nullish()}),P2=v({_meta:k(d(),_()).nullish(),auth:_L.optional().default({}),loadSession:De().optional().default(!1),mcpCapabilities:EL.optional().default({http:!1,sse:!1}),nes:R2.nullish(),positionEncoding:_b.nullish(),promptCapabilities:dD.optional().default({audio:!1,embeddedContext:!1,image:!1}),sessionCapabilities:l2.optional().default({})}),L2=v({_meta:k(d(),_()).nullish(),agentCapabilities:P2.optional().default({auth:{},loadSession:!1,mcpCapabilities:{http:!1,sse:!1},promptCapabilities:{audio:!1,embeddedContext:!1,image:!1},sessionCapabilities:{}}),agentInfo:wb.nullish(),authMethods:z(YP).optional().default([]),protocolVersion:kb}),D2=v({_meta:k(d(),_()).nullish(),mimeType:d().nullish(),text:d(),uri:d()}),z2=j([D2,XP]),O2=v({_meta:k(d(),_()).nullish(),annotations:_a.nullish(),resource:z2}),qd=j([x2.and(v({type:$("text")})),xD.and(v({type:$("image")})),kD.and(v({type:$("audio")})),ED.and(v({type:$("resource_link")})),O2.and(v({type:$("resource")}))]),M2=v({_meta:k(d(),_()).nullish(),content:qd}),wu=v({_meta:k(d(),_()).nullish(),content:qd,messageId:d().nullish()}),N2=v({_meta:k(d(),_()).nullish(),messageId:d().nullish(),prompt:z(qd),sessionId:Q}),U2=v({anyOf:z(pb)}),Rb=j([M2.and(v({type:$("content")})),iL.and(v({type:$("diff")})),S2.and(v({type:$("terminal")}))]),Pb=d(),Lb=v({_meta:k(d(),_()).nullish(),line:H().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),path:d()}),Db=j([$("pending"),$("in_progress"),$("completed"),$("failed")]),zb=j([$("read"),$("edit"),$("delete"),$("move"),$("search"),$("execute"),$("think"),$("fetch"),$("switch_mode"),$("other")]),F2=v({_meta:k(d(),_()).nullish(),content:z(Rb).optional(),kind:zb.optional(),locations:z(Lb).optional(),rawInput:_().optional(),rawOutput:_().optional(),status:Db.optional(),title:d(),toolCallId:Pb}),Ob=v({_meta:k(d(),_()).nullish(),content:z(Rb).nullish(),kind:zb.nullish(),locations:z(Lb).nullish(),rawInput:_().optional(),rawOutput:_().optional(),status:Db.nullish(),title:d().nullish(),toolCallId:Pb}),Mb=v({_meta:k(d(),_()).nullish(),options:z(nD),sessionId:Q,toolCall:Ob}),H2=v({_meta:k(d(),_()).nullish(),hint:d()}),Z2=H2,W2=v({_meta:k(d(),_()).nullish(),description:d(),input:Z2.nullish(),name:d()}),B2=v({_meta:k(d(),_()).nullish(),availableCommands:z(W2)}),j2=v({enum:z(d()),type:dL}),V2=j([j2,U2]),G2=v({default:z(d()).nullish(),description:d().nullish(),items:V2,maxItems:H().nullish(),minItems:H().nullish(),title:d().nullish()}),q2=j([y2.and(v({type:$("string")})),tD.and(v({type:$("number")})),yL.and(v({type:$("integer")})),QP.and(v({type:$("boolean")})),G2.and(v({type:$("array")}))]),Y2=v({description:d().nullish(),properties:k(d(),q2).optional().default({}),required:z(d()).nullish(),title:d().nullish(),type:hL.optional().default("object")}),K2=v({requestedSchema:Y2}),J2=bc(j([K2.and(v({mode:$("form")})),gL.and(v({mode:$("url")}))]),v({_meta:k(d(),_()).nullish(),message:d(),sessionId:Q})),X2=v({cachedReadTokens:H().nullish(),cachedWriteTokens:H().nullish(),inputTokens:H(),outputTokens:H(),thoughtTokens:H().nullish(),totalTokens:H()}),Q2=v({_meta:k(d(),_()).nullish(),stopReason:m2,usage:X2.nullish(),userMessageId:d().nullish()});j([v({id:Gn,result:j([L2,JP,xL,s2,i2,XD,n2,o2,tL,d2,u2,Q2,f2,g2,w2,eL,yb])}),v({error:gb,id:Gn})]);const ez=v({_meta:k(d(),_()).nullish(),cost:rL.nullish(),size:H(),used:H()}),tz=j([wu.and(v({sessionUpdate:$("user_message_chunk")})),wu.and(v({sessionUpdate:$("agent_message_chunk")})),wu.and(v({sessionUpdate:$("agent_thought_chunk")})),F2.and(v({sessionUpdate:$("tool_call")})),Ob.and(v({sessionUpdate:$("tool_call_update")})),aD.and(v({sessionUpdate:$("plan")})),B2.and(v({sessionUpdate:$("available_commands_update")})),t2.and(v({sessionUpdate:$("current_mode_update")})),MD.and(v({sessionUpdate:$("config_option_update")})),QD.and(v({sessionUpdate:$("session_info_update")})),ez.and(v({sessionUpdate:$("usage_update")}))]),Nb=v({_meta:k(d(),_()).nullish(),sessionId:Q,update:tz});v({method:d(),params:j([Nb,cL,mb]).nullish()});const Ub=v({_meta:k(d(),_()).nullish(),sessionId:Q,terminalId:d()}),rz=v({_meta:k(d(),_()).nullish(),exitCode:H().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),signal:d().nullish()}),nz=v({name:d(),uri:d()}),iz=v({_meta:k(d(),_()).nullish(),repository:GL.nullish(),workspaceFolders:z(nz).nullish(),workspaceUri:d().nullish()});v({id:Gn,method:d(),params:j([pD,KP,kL,eD,qD,wL,GD,KD,ZD,h2,c2,N2,p2,iz,b2,HD,vb]).nullish()});const Fb=v({_meta:k(d(),_()).nullish(),content:d(),path:d(),sessionId:Q});v({id:Gn,method:d(),params:j([Fb,Tb,Mb,Ab,Cb,Ib,Ub,$b,J2,vb]).nullish()});const sz=v({_meta:k(d(),_()).nullish()});j([v({id:Gn,result:j([sz,wD,TD,nL,k2,SD,rz,bL,uL,yb])}),v({error:gb,id:Gn})]);var X;class oz{constructor(t,e){S(this,X);const n=t(this),i=async(o,a)=>{var c,u,h,f,y,m,E;switch(o){case fr.fs_write_text_file:{const x=Fb.parse(a);return(c=n.writeTextFile)==null?void 0:c.call(n,x)}case fr.fs_read_text_file:{const x=Tb.parse(a);return(u=n.readTextFile)==null?void 0:u.call(n,x)}case fr.session_request_permission:{const x=Mb.parse(a);return n.requestPermission(x)}case fr.terminal_create:{const x=Ab.parse(a);return(h=n.createTerminal)==null?void 0:h.call(n,x)}case fr.terminal_output:{const x=Cb.parse(a);return(f=n.terminalOutput)==null?void 0:f.call(n,x)}case fr.terminal_release:{const x=Ib.parse(a);return await((y=n.releaseTerminal)==null?void 0:y.call(n,x))??{}}case fr.terminal_wait_for_exit:{const x=Ub.parse(a);return(m=n.waitForTerminalExit)==null?void 0:m.call(n,x)}case fr.terminal_kill:{const x=$b.parse(a);return await((E=n.killTerminal)==null?void 0:E.call(n,x))??{}}default:if(n.extMethod)return n.extMethod(o,a);throw Ce.methodNotFound(o)}},s=async(o,a)=>{switch(o){case fr.session_update:{const c=Nb.parse(a);return n.sessionUpdate(c)}default:if(n.extNotification)return n.extNotification(o,a);throw Ce.methodNotFound(o)}};w(this,X,new az(i,s,e))}async initialize(t){return await l(this,X).sendRequest(pe.initialize,t)}async newSession(t){return await l(this,X).sendRequest(pe.session_new,t)}async loadSession(t){return await l(this,X).sendRequest(pe.session_load,t)??{}}async unstable_forkSession(t){return await l(this,X).sendRequest(pe.session_fork,t)}async listSessions(t){return await l(this,X).sendRequest(pe.session_list,t)}async unstable_resumeSession(t){return await l(this,X).sendRequest(pe.session_resume,t)}async unstable_closeSession(t){return await l(this,X).sendRequest(pe.session_close,t)}async setSessionMode(t){return await l(this,X).sendRequest(pe.session_set_mode,t)??{}}async unstable_setSessionModel(t){return await l(this,X).sendRequest(pe.session_set_model,t)??{}}async setSessionConfigOption(t){return await l(this,X).sendRequest(pe.session_set_config_option,t)}async authenticate(t){return await l(this,X).sendRequest(pe.authenticate,t)??{}}async unstable_logout(t){return await l(this,X).sendRequest(pe.logout,t)??{}}async prompt(t){return await l(this,X).sendRequest(pe.session_prompt,t)}async cancel(t){return await l(this,X).sendNotification(pe.session_cancel,t)}async unstable_startNes(t){return await l(this,X).sendRequest(pe.nes_start,t)}async unstable_suggestNes(t){return await l(this,X).sendRequest(pe.nes_suggest,t)}async unstable_closeNes(t){return await l(this,X).sendRequest(pe.nes_close,t)??{}}async unstable_didOpenDocument(t){return await l(this,X).sendNotification(pe.document_did_open,t)}async unstable_didChangeDocument(t){return await l(this,X).sendNotification(pe.document_did_change,t)}async unstable_didCloseDocument(t){return await l(this,X).sendNotification(pe.document_did_close,t)}async unstable_didSaveDocument(t){return await l(this,X).sendNotification(pe.document_did_save,t)}async unstable_didFocusDocument(t){return await l(this,X).sendNotification(pe.document_did_focus,t)}async unstable_acceptNes(t){return await l(this,X).sendNotification(pe.nes_accept,t)}async unstable_rejectNes(t){return await l(this,X).sendNotification(pe.nes_reject,t)}async extMethod(t,e){return await l(this,X).sendRequest(t,e)}async extNotification(t,e){return await l(this,X).sendNotification(t,e)}get signal(){return l(this,X).signal}get closed(){return l(this,X).closed}}X=new WeakMap;var Fr,Vl,So,_o,zi,Oi,Vt,ko,me,Hb,oh,Zb,Wb,Bb,jb,ah,js;class az{constructor(t,e,n){S(this,me);S(this,Fr,new Map);S(this,Vl,0);S(this,So);S(this,_o);S(this,zi);S(this,Oi,Promise.resolve());S(this,Vt,new AbortController);S(this,ko);w(this,So,t),w(this,_o,e),w(this,zi,n),w(this,ko,new Promise(i=>{l(this,Vt).signal.addEventListener("abort",()=>i())})),p(this,me,Hb).call(this)}get signal(){return l(this,Vt).signal}get closed(){return l(this,ko)}async sendRequest(t,e){p(this,me,ah).call(this);const n=Zc(this,Vl)._++,i=new Promise((s,o)=>{l(this,Fr).set(n,{resolve:s,reject:o})});return await p(this,me,js).call(this,{jsonrpc:"2.0",id:n,method:t,params:e}),i}async sendNotification(t,e){p(this,me,ah).call(this),await p(this,me,js).call(this,{jsonrpc:"2.0",method:t,params:e})}}Fr=new WeakMap,Vl=new WeakMap,So=new WeakMap,_o=new WeakMap,zi=new WeakMap,Oi=new WeakMap,Vt=new WeakMap,ko=new WeakMap,me=new WeakSet,Hb=async function(){let t;try{const e=l(this,zi).readable.getReader();try{for(;!l(this,Vt).signal.aborted;){const{value:n,done:i}=await e.read();if(i)break;if(n)try{p(this,me,Zb).call(this,n)}catch(s){console.error("Unexpected error during message processing:",n,s),"id"in n&&n.id!==void 0&&p(this,me,js).call(this,{jsonrpc:"2.0",id:n.id,error:{code:-32700,message:"Parse error"}})}}}finally{e.releaseLock()}}catch(e){t=e}finally{p(this,me,oh).call(this,t)}},oh=function(t){if(l(this,Vt).signal.aborted)return;const e=t??new Error("ACP connection closed");for(const n of l(this,Fr).values())n.reject(e);l(this,Fr).clear(),l(this,Vt).abort(e)},Zb=async function(t){if("method"in t&&"id"in t){const e=await p(this,me,Wb).call(this,t.method,t.params);"error"in e&&console.error("Error handling request",t,e.error),await p(this,me,js).call(this,{jsonrpc:"2.0",id:t.id,...e})}else if("method"in t){const e=await p(this,me,Bb).call(this,t.method,t.params);"error"in e&&console.error("Error handling notification",t,e.error)}else"id"in t?p(this,me,jb).call(this,t):console.error("Invalid message",{message:t})},Wb=async function(t,e){try{return{result:await l(this,So).call(this,t,e)??null}}catch(n){if(n instanceof Ce)return n.toResult();if(n instanceof Fg)return Ce.invalidParams(n.format()).toResult();let i;(n instanceof Error||typeof n=="object"&&n!=null&&"message"in n&&typeof n.message=="string")&&(i=n.message);try{return Ce.internalError(i?JSON.parse(i):{}).toResult()}catch{return Ce.internalError({details:i}).toResult()}}},Bb=async function(t,e){try{return await l(this,_o).call(this,t,e),{result:null}}catch(n){if(n instanceof Ce)return n.toResult();if(n instanceof Fg)return Ce.invalidParams(n.format()).toResult();let i;(n instanceof Error||typeof n=="object"&&n!=null&&"message"in n&&typeof n.message=="string")&&(i=n.message);try{return Ce.internalError(i?JSON.parse(i):{}).toResult()}catch{return Ce.internalError({details:i}).toResult()}}},jb=function(t){const e=l(this,Fr).get(t.id);if(e){if("result"in t)e.resolve(t.result);else if("error"in t){const{code:n,message:i,data:s}=t.error;e.reject(new Ce(n,i,s))}l(this,Fr).delete(t.id)}else console.error("Got response to unknown request",t.id)},ah=function(){if(l(this,Vt).signal.aborted)throw l(this,Vt).signal.reason??new Error("ACP connection closed")},js=async function(t){return w(this,Oi,l(this,Oi).then(async()=>{const e=l(this,zi).writable.getWriter();try{await e.write(t)}finally{e.releaseLock()}}).catch(e=>{p(this,me,oh).call(this,e)})),l(this,Oi)};class Ce extends Error{constructor(e,n,i){super(n);g(this,"code");g(this,"data");this.code=e,this.name="RequestError",this.data=i}static parseError(e,n){return new Ce(-32700,`Parse error${n?`: ${n}`:""}`,e)}static invalidRequest(e,n){return new Ce(-32600,`Invalid request${n?`: ${n}`:""}`,e)}static methodNotFound(e){return new Ce(-32601,`"Method not found": ${e}`,{method:e})}static invalidParams(e,n){return new Ce(-32602,`Invalid params${n?`: ${n}`:""}`,e)}static internalError(e,n){return new Ce(-32603,`Internal error${n?`: ${n}`:""}`,e)}static authRequired(e,n){return new Ce(-32e3,`Authentication required${n?`: ${n}`:""}`,e)}static resourceNotFound(e){return new Ce(-32002,`Resource not found${e?`: ${e}`:""}`,e&&{uri:e})}toResult(){return{error:{code:this.code,message:this.message,data:this.data}}}toErrorResponse(){return{code:this.code,message:this.message,data:this.data}}}const lz=/^Sender \(untrusted metadata\):\n```json\n[\s\S]*?\n```\n\n?/,cz=/^\[[^\n]*Working directory:[^\n]*\]\n\n?/,uz=/\[Television screen context\][\s\S]*?\[\/Television screen context\]\n*/,hz=/\b(tv|television|screen|artifact|artifacts|viewer|filmstrip|layout|focus)\b/i,dz=/\[\[\s*(?:reply_to_current|reply_to\s*:\s*[^\]\n]+|audio_as_voice)\s*\]\]\s*/gi,pz="single_session",fz={name:"television-acp-client",version:"0.0.0"},Vb="agent:main:television",gz=Sa(Ot);var Mi,Gt,ht,qt,Hr,$t,_r,Yt,Kt,Zr,Tt,Ni,Ui,Jt,Je,kr,Fi,Rn,xr,Wr,xo,It,Xt,Gl,Qt,T,lh,Gb,qb,Yb,ll,Kb,Jb,Xb,Qb,ew,tw,rw,vn,yi,bi,mr,nw,wi,ch,uh,cl,iw,ul,hh,dh,Eo,Ao,hl,Si,ph,sw;class mz extends gz{constructor(e){super();S(this,T);S(this,Mi,"disconnected");S(this,Gt,null);S(this,ht,new Map);S(this,qt,null);S(this,Hr,null);S(this,$t,null);S(this,_r,null);S(this,Yt,null);S(this,Kt,null);S(this,Zr);S(this,Tt,null);S(this,Ni,0);S(this,Ui,1);S(this,Jt,null);S(this,Je,null);S(this,kr,!1);S(this,Fi,!1);S(this,Rn,!1);S(this,xr,null);S(this,Wr,new Set);S(this,xo);S(this,It);S(this,Xt);S(this,Gl,e=>{p(this,T,qb).call(this,e)});S(this,Qt,null);S(this,Eo,()=>{p(this,T,Si).call(this,"ACP bridge websocket closed")});S(this,Ao,()=>{p(this,T,Si).call(this,"ACP bridge websocket error")});w(this,It,e),w(this,Xt,e.sessionMode??pz),w(this,Zr,e.mappedSessionStore??vz()),w(this,xo,e.createSocket??(n=>new WebSocket(n)))}get status(){return l(this,Mi)}get messages(){return[...l(this,ht).values()]}get enabled(){return l(this,It).enabled??!1}setToken(e){l(this,It).token=e??""}setEnabled(e){l(this,It).enabled=e,e||(p(this,T,hl).call(this),w(this,Gt,null),p(this,T,mr).call(this,"disconnected"))}async connect(){if(this.disposed)throw new Error("ACPClient has been disposed");if(this.enabled&&this.status==="disconnected"){l(this,Hr)===null&&(w(this,Gt,null),w(this,Hr,p(this,T,Gb).call(this)));try{await l(this,Hr),await p(this,T,ll).call(this)}catch(e){throw p(this,T,Si).call(this,Su(e)),e}}}dispose(){p(this,T,hl).call(this),w(this,Gt,null),p(this,T,mr).call(this,"disposed")}async sendMessage(e){if(await this.connect(),(this.status==="running"||this.status==="cancelling")&&(await this.cancel(),await p(this,T,lh).call(this,"ready")),(l(this,Yt)===null||l(this,Tt)!==p(this,T,ul).call(this))&&await p(this,T,ll).call(this),this.status!=="ready")throw new Error("ACPClient is not ready to send a new message");const n=e.text.trim();if(!n)throw new Error("Cannot send an empty message");p(this,T,yi).call(this,{id:p(this,T,wi).call(this,"user"),kind:"user",text:n,status:"final"}),p(this,T,mr).call(this,"running");try{const i=await p(this,T,cl).call(this).prompt({sessionId:p(this,T,uh).call(this),prompt:[{type:"text",text:p(this,T,nw).call(this,n)}]});p(this,T,vn).call(this,i.stopReason==="cancelled"?"cancelled":"final"),p(this,T,mr).call(this,"ready")}catch(i){throw p(this,T,sw).call(this)||(p(this,T,vn).call(this,"error"),p(this,T,mr).call(this,"ready")),i}}async startNewSession(){var n;await this.connect(),(this.status==="running"||this.status==="cancelling")&&(await this.cancel(),await p(this,T,lh).call(this,"ready"));const e=p(this,T,ul).call(this);((n=l(this,Kt))==null?void 0:n.sessionIdStrategy)==="mapped"?l(this,Zr).clearActualSessionId(e):w(this,Ni,l(this,Ni)+1),w(this,$t,null),w(this,_r,null),w(this,Yt,null),w(this,Tt,null),p(this,T,ph).call(this)}async cancel(){this.status==="running"&&(p(this,T,mr).call(this,"cancelling"),await p(this,T,cl).call(this).cancel({sessionId:p(this,T,uh).call(this)}))}setScreenContext(e){var s,o,a;if(e===null){if(l(this,Je)===null)return;w(this,Je,null),w(this,kr,!1);return}const n={screenID:e.screenID,screenName:e.screenName};if(((s=l(this,Je))==null?void 0:s.screenID)===n.screenID&&((o=l(this,Je))==null?void 0:o.screenName)===n.screenName)return;const i=((a=l(this,Je))==null?void 0:a.screenID)??null;if(w(this,Je,n),l(this,Xt)==="single_session"){(!l(this,Tt)||i!==n.screenID)&&w(this,kr,!0);return}l(this,Tt)!==p(this,T,hh).call(this,n.screenID)&&(w(this,$t,null),w(this,_r,null),l(this,qt)&&this.status==="ready"&&p(this,T,ll).call(this).catch(c=>{p(this,T,Si).call(this,Su(c))}))}}Mi=new WeakMap,Gt=new WeakMap,ht=new WeakMap,qt=new WeakMap,Hr=new WeakMap,$t=new WeakMap,_r=new WeakMap,Yt=new WeakMap,Kt=new WeakMap,Zr=new WeakMap,Tt=new WeakMap,Ni=new WeakMap,Ui=new WeakMap,Jt=new WeakMap,Je=new WeakMap,kr=new WeakMap,Fi=new WeakMap,Rn=new WeakMap,xr=new WeakMap,Wr=new WeakMap,xo=new WeakMap,It=new WeakMap,Xt=new WeakMap,Gl=new WeakMap,Qt=new WeakMap,T=new WeakSet,lh=async function(e){if(this.status!==e){if(this.status==="disposed")throw new Error("ACPClient has been disposed");if(this.status==="disconnected")throw new Error(l(this,Gt)??"ACPClient is disconnected");await new Promise((n,i)=>{const s=()=>{this.removeEventListener("status-changed",o)},o=()=>{if(this.status===e){s(),n();return}if(this.status==="disposed"){s(),i(new Error("ACPClient has been disposed"));return}this.status==="disconnected"&&(s(),i(new Error(l(this,Gt)??"ACPClient is disconnected")))};this.addEventListener("status-changed",o)})}},Gb=async function(){try{const{stream:e,socket:n,metadata:i}=await Sz({serverURL:l(this,It).serverURL,token:l(this,It).token,createSocket:l(this,xo),onDisconnect:l(this,Gl)});w(this,Kt,i),w(this,Qt,n),n.addEventListener("close",l(this,Eo)),n.addEventListener("error",l(this,Ao)),w(this,qt,new oz(s=>({connection:s,sessionUpdate:async o=>{await p(this,T,Jb).call(this,o)},requestPermission:async o=>p(this,T,Xb).call(this,o)}),e)),await l(this,qt).initialize({protocolVersion:WP,clientCapabilities:{},clientInfo:fz})}catch(e){throw e}},qb=function(e){p(this,T,Si).call(this,Su(e))},Yb=function(e){const n=e==null?void 0:e.models;if(!(n!=null&&n.currentModelId))return;const i=n.availableModels.find(s=>s.modelId===n.currentModelId);console.info("[ACPClient] Current model:",(i==null?void 0:i.name)??n.currentModelId,`(${n.currentModelId})`)},ll=async function(){const e=p(this,T,ul).call(this);if(l(this,$t)&&l(this,_r)===e){await l(this,$t);return}w(this,_r,e),w(this,$t,p(this,T,Kb).call(this,e)),await l(this,$t)},Kb=async function(e){var c;const n=p(this,T,cl).call(this);p(this,T,ph).call(this);let i,s=!1,o=null;const a={cwd:p(this,T,iw).call(this),mcpServers:[],_meta:{sessionKey:e}};try{if(w(this,Rn,!0),w(this,xr,null),((c=l(this,Kt))==null?void 0:c.sessionIdStrategy)==="mapped"){const u=l(this,Zr).getActualSessionId(e);if(u)try{const h=await n.loadSession({...a,sessionId:u});if(yz(h))throw new Error("Mapped ACP session was not found");o=h,i=u,s=!0}catch{const h=await n.newSession(a);o=h,i=h.sessionId,l(this,Zr).setActualSessionId(e,i),s=!1}else{const h=await n.newSession(a);o=h,i=h.sessionId,l(this,Zr).setActualSessionId(e,i),s=!1}}else try{o=await n.loadSession({...a,sessionId:e}),i=e,s=l(this,ht).size>0}catch{const u=await n.newSession(a);o=u,i=u.sessionId,s=!1}}finally{w(this,Rn,!1),w(this,xr,null),p(this,T,vn).call(this,"final")}p(this,T,Yb).call(this,o),await n.setSessionConfigOption({sessionId:i,configId:"verbose_level",value:"full"}),w(this,Yt,i),w(this,Tt,e),w(this,Fi,!0),s?(l(this,Wr).add(e),l(this,Xt)==="single_session"&&w(this,kr,!1)):(l(this,Wr).delete(e),w(this,kr,l(this,Xt)==="single_session")),w(this,Gt,null),p(this,T,mr).call(this,"ready")},Jb=async function(e){const n=e.update;switch(n.sessionUpdate){case"user_message_chunk":n.content.type==="text"&&p(this,T,rw).call(this,n.content.text);return;case"agent_message_chunk":n.content.type==="text"&&p(this,T,Qb).call(this,n.content.text);return;case"tool_call":p(this,T,ew).call(this,n);return;case"tool_call_update":p(this,T,tw).call(this,n);return;case"agent_thought_chunk":return;default:return}},Xb=async function(e){return{outcome:{outcome:"cancelled"}}},Qb=function(e){w(this,xr,null);const n=wz(e);if(!n)return;if(!l(this,Jt)){const s={id:p(this,T,wi).call(this,"assistant"),kind:"assistant",text:n,status:"streaming"};w(this,Jt,s.id),p(this,T,yi).call(this,s);return}const i=l(this,ht).get(l(this,Jt));if(!i||i.kind!=="assistant")throw new Error("Open assistant message invariant violated");p(this,T,bi).call(this,{...i,text:`${i.text}${n}`,status:"streaming"})},ew=function(e){p(this,T,vn).call(this,"final");const n=p(this,T,ch).call(this,e.toolCallId),i=Gg("content"in e?e.content:void 0),s={id:(n==null?void 0:n.id)??p(this,T,wi).call(this,"tool"),kind:"tool_call",toolCallId:e.toolCallId,title:e.title,toolKind:e.kind??"other",status:e.status==="failed"?"failed":e.status==="completed"?"completed":"in_progress",text:(n==null?void 0:n.text)??i,locations:e.locations??(n==null?void 0:n.locations)};if(n){p(this,T,bi).call(this,s);return}p(this,T,yi).call(this,s)},tw=function(e){const n=p(this,T,ch).call(this,e.toolCallId),i=(n==null?void 0:n.text)??"",s=Gg(e.content),o=s?`${i}${s}`:i,a={id:(n==null?void 0:n.id)??p(this,T,wi).call(this,"tool"),kind:"tool_call",toolCallId:e.toolCallId,title:(n==null?void 0:n.title)??e.toolCallId,toolKind:(n==null?void 0:n.toolKind)??"other",status:e.status==="failed"?"failed":e.status==="completed"?"completed":"in_progress",text:o,locations:e.locations??(n==null?void 0:n.locations)};if(n){p(this,T,bi).call(this,a);return}p(this,T,yi).call(this,a)},rw=function(e){if(p(this,T,vn).call(this,"final"),!e)return;const n=l(this,Rn)?l(this,xr):null;if(!n){const s=Vg(e);if(!s)return;const o={id:p(this,T,wi).call(this,"user"),kind:"user",text:s,status:"final"};p(this,T,yi).call(this,o),l(this,Rn)&&w(this,xr,o.id);return}const i=l(this,ht).get(n);if(!i||i.kind!=="user")throw new Error("Replay user message invariant violated");p(this,T,bi).call(this,{...i,text:Vg(`${i.text}${e}`)})},vn=function(e){if(!l(this,Jt))return;const n=l(this,ht).get(l(this,Jt));(n==null?void 0:n.kind)==="assistant"&&p(this,T,bi).call(this,{...n,status:e}),w(this,Jt,null)},yi=function(e){l(this,ht).set(e.id,e),this.dispatchEvent(new gu("messages-changed"))},bi=function(e){l(this,ht).set(e.id,e),this.dispatchEvent(new gu("messages-changed"))},mr=function(e){l(this,Mi)!==e&&(w(this,Mi,e),this.dispatchEvent(new e$("status-changed")))},nw=function(e){const n=l(this,Tt);if(!n)return e;const i=l(this,Je)?l(this,Xt)==="single_session"?l(this,kr)||!l(this,Wr).has(n):!l(this,Wr).has(n):!1,s=l(this,Fi)&&(l(this,Je)!==null||hz.test(e));if(!(s||i))return e;s&&w(this,Fi,!1),i&&(w(this,kr,!1),l(this,Wr).add(n));const a=["[Television screen context]","This chat session is coming from a Television client.","Using Television requires the knowledge in the `television` skill. Re-read it only if it is not already in context or you know it changed.","If the skill is not installed, it can be installed via `tv skills install <your agent skills path>`."];return l(this,Je)?(a.push("This conversation is currently attached to the screen below."),a.push(`screen_id: ${l(this,Je).screenID}`),a.push(`screen_name: ${l(this,Je).screenName??""}`),a.push("When the user asks to inspect or change Television state with the tv CLI, use this screen ID with the --screen argument.")):a.push("There is currently no active Television screen."),a.push("[/Television screen context]","",e),a.join(`
43
- `)},wi=function(e){const n=`${e}-${l(this,Ui)}`;return w(this,Ui,l(this,Ui)+1),n},ch=function(e){for(const n of l(this,ht).values())if((n==null?void 0:n.kind)==="tool_call"&&n.toolCallId===e)return n;return null},uh=function(){if(!l(this,Yt))throw new Error("ACP session is not ready");return l(this,Yt)},cl=function(){if(!l(this,qt))throw new Error("ACP connection is not ready");return l(this,qt)},iw=function(){var n;const e=(n=l(this,Kt))==null?void 0:n.sessionCwd;if(!e)throw new Error("ACP bridge session cwd is not ready");return e},ul=function(){var n;if(l(this,Xt)==="single_session")return p(this,T,dh).call(this,`${Vb}-${(l(this,It).clientGUID??"default-client").toLowerCase()}`);const e=(n=l(this,Je))==null?void 0:n.screenID;if(!e)throw new Error("Screen context is required for per-screen session mode");return p(this,T,hh).call(this,e)},hh=function(e){return p(this,T,dh).call(this,bz(l(this,Xt),e,l(this,It).clientGUID??"default-client"))},dh=function(e){var n;return((n=l(this,Kt))==null?void 0:n.sessionIdStrategy)==="deterministic"&&l(this,Ni)>0?`${e}:epoch-${l(this,Ni)}`:e},Eo=new WeakMap,Ao=new WeakMap,hl=function(){w(this,qt,null),w(this,Hr,null),w(this,$t,null),w(this,_r,null),w(this,Yt,null),w(this,Tt,null),w(this,Kt,null),l(this,Qt)&&(l(this,Qt).removeEventListener("close",l(this,Eo)),l(this,Qt).removeEventListener("error",l(this,Ao)),l(this,Qt).close(),w(this,Qt,null))},Si=function(e){const n=l(this,qt)!==null||l(this,Hr)!==null||l(this,$t)!==null||l(this,_r)!==null||l(this,Yt)!==null||l(this,Tt)!==null||l(this,Kt)!==null||l(this,Qt)!==null;this.disposed||this.status==="disconnected"&&!n||(p(this,T,vn).call(this,"error"),p(this,T,hl).call(this),w(this,Gt,e??null),p(this,T,mr).call(this,"disconnected"))},ph=function(){const e=l(this,ht).size>0;w(this,Jt,null),w(this,xr,null),w(this,Ui,1),l(this,ht).clear(),e&&this.dispatchEvent(new gu("messages-changed"))},sw=function(){return this.status==="disconnected"};function vz(){const r=new Map;return{getActualSessionId(t){return r.get(t)??null},setActualSessionId(t,e){r.set(t,e)},clearActualSessionId(t){r.delete(t)}}}function yz(r){return r==null?!0:typeof r=="object"&&Object.keys(r).length===0}function bz(r,t,e){return r==="single_session"?`${Vb}-${e.toLowerCase()}`:`agent:main:television-${e.toLowerCase()}-${t.toLowerCase()}`}function ow(r){return r.replace(/^(?:\s*\n)+/,"")}function Vg(r){let t=r;return t=t.replace(lz,""),t=t.replace(cz,""),t=t.replace(uz,""),t=ow(t),t}function wz(r){let t=r;return t=t.replace(dz,""),t=ow(t),t}function Gg(r){return!r||r.length===0?"":r.flatMap(t=>t.type==="content"&&t.content.type==="text"?[t.content.text]:[]).join("")}async function Sz(r){const t=r.createSocket(xz(r.serverURL,r.token));let e=!1,n,i;const s=new Promise((u,h)=>{n=u,i=h}),o=new ReadableStream({start(u){let h=!1;const f=()=>{t.send(JSON.stringify({type:"acp-bridge-connect"}))},y=x=>{const I=kz(x);if(!I)return;let P;try{P=JSON.parse(I)}catch(R){const B=R instanceof Error?R:new Error(String(R));i(B),u.error(B);return}switch(P.type){case"acp-bridge-status":if(P.status==="ready"){let R;try{R=_z(P)}catch(B){const N=B instanceof Error?B:new Error(String(B));e||i(N),u.error(N);return}e||(e=!0,n(R));return}if(P.status==="error"||P.status==="exited"){const R=new Error(P.error??`ACP bridge ${P.status}`);e||i(R),u.error(R)}return;case"acp-bridge-message":u.enqueue(P.message);return}},m=()=>{var I;if(h)return;h=!0;const x=new Error("ACP bridge websocket closed");e||i(x),(I=r.onDisconnect)==null||I.call(r,x),u.close()},E=()=>{var I;if(h)return;h=!0;const x=new Error("ACP bridge websocket error");e||i(x),(I=r.onDisconnect)==null||I.call(r,x),u.error(x)};t.addEventListener("open",f),t.addEventListener("message",y),t.addEventListener("close",m),t.addEventListener("error",E)}}),a=new WritableStream({async write(u){await s,t.send(JSON.stringify({type:"acp-bridge-message",message:u}))},close(){t.close()},abort(){t.close()}}),c=await s;return{stream:{readable:o,writable:a},socket:t,metadata:c}}function _z(r){const{agent:t,sessionIdStrategy:e,sessionCwd:n}=r;if((t==="openclaw"||t==="hermes")&&(e==="deterministic"||e==="mapped")&&typeof n=="string"&&n.length>0)return{agent:t,sessionIdStrategy:e,sessionCwd:n};throw new Error("ACP bridge ready status missing bootstrap metadata")}function kz(r){if(typeof r=="string")return r;if(r instanceof Uint8Array)return new TextDecoder().decode(r);if(typeof Buffer<"u"&&r instanceof Buffer)return r.toString("utf8");if(typeof r=="object"&&r!==null&&"data"in r){const t=r.data;if(typeof t=="string")return t;if(t instanceof Uint8Array)return new TextDecoder().decode(t);if(Array.isArray(t))return Buffer.concat(t).toString("utf8")}return null}function xz(r,t){const e=new URL(r);return e.protocol=e.protocol==="https:"?"wss:":"ws:",e.pathname="/acp",e.search="",e.searchParams.set("token",t),e.hash="",e.toString()}function Su(r){return r instanceof Error?r.message:String(r)}const qg="television.acpClientGUID",Yg="television.acpMappedSessions",Kg=1;var Hi;class Ez{constructor(){S(this,Hi,new Map)}getActualSessionId(t){return l(this,Hi).get(t)??null}setActualSessionId(t,e){l(this,Hi).set(t,e)}clearActualSessionId(t){l(this,Hi).delete(t)}}Hi=new WeakMap;var Zi,$o,pt,dl,pl,fh;class Az{constructor(t,e){S(this,pt);S(this,Zi);S(this,$o);w(this,Zi,t),w(this,$o,e)}getActualSessionId(t){const e=p(this,pt,pl).call(this)[p(this,pt,dl).call(this,t)];return typeof e=="string"&&e.length>0?e:null}setActualSessionId(t,e){const n=p(this,pt,pl).call(this);n[p(this,pt,dl).call(this,t)]=e,p(this,pt,fh).call(this,n)}clearActualSessionId(t){const e=p(this,pt,pl).call(this);delete e[p(this,pt,dl).call(this,t)],p(this,pt,fh).call(this,e)}}Zi=new WeakMap,$o=new WeakMap,pt=new WeakSet,dl=function(t){return JSON.stringify([l(this,$o),t])},pl=function(){const t=l(this,Zi).getItem(Yg);if(!t)return{};let e;try{e=JSON.parse(t)}catch{return{}}if(typeof e!="object"||e===null||Array.isArray(e))return{};const n=e;return n.version!==Kg?{}:typeof n.entries!="object"||n.entries===null||Array.isArray(n.entries)?{}:Object.fromEntries(Object.entries(n.entries).filter(i=>typeof i[1]=="string"))},fh=function(t){const e={version:Kg,entries:t};l(this,Zi).setItem(Yg,JSON.stringify(e))};function $z(){return typeof window>"u"?null:window.localStorage}function Tz(r){const t=r.getItem(qg);if(t)return t;const e=Ud().toLowerCase();return r.setItem(qg,e),e}const Jg=4401,Iz=401,Ga=1e3,Cz=3e4;class ro extends Error{constructor(t="Authentication required"){super(t),this.name="AuthError"}}class aw extends Ot{constructor(e){var i,s;super();g(this,"url");g(this,"name");g(this,"status","unauthorized");g(this,"screens",new Map);g(this,"client");g(this,"acpClient");g(this,"_token");g(this,"attempting",!1);g(this,"nextRetryAt",null);g(this,"hasEverConnected",!1);g(this,"hasAuthRejected",!1);g(this,"createSocket");g(this,"createClient");g(this,"socket",null);g(this,"connectAttempt",0);g(this,"autoReconnect",!1);g(this,"retryTimer",null);g(this,"retryDelay",Ga);g(this,"visibilityEventTarget");g(this,"networkEventTarget");g(this,"onVisibilityChange");g(this,"onNetworkOnline");this.url=he(e.url),this.name=e.name,this._token=e.token??null,this.createSocket=e.createSocket??(o=>new WebSocket(o)),this.createClient=e.createClient??((o,a)=>new k$(o,{token:a??void 0,onUnauthorized:()=>this.handleAuthRejected()})),this.client=this.createClient(this.url,this._token);const n=e.mappedSessionStore??(e.acpStorage?new Az(e.acpStorage,this.url):new Ez);this.acpClient=new mz({serverURL:this.url,token:this._token??"",...e.createACPSocket?{createSocket:e.createACPSocket}:e.createSocket?{createSocket:e.createSocket}:{},...e.clientGUID?{clientGUID:e.clientGUID}:{},mappedSessionStore:n}),this.visibilityEventTarget=e.visibilityEventTarget!==void 0?e.visibilityEventTarget:typeof document<"u"?document:null,this.networkEventTarget=e.networkEventTarget!==void 0?e.networkEventTarget:typeof window<"u"?window:null,this.onVisibilityChange=()=>{this.isPageVisible()&&this.kickReconnect()},this.onNetworkOnline=()=>{this.kickReconnect()},(i=this.visibilityEventTarget)==null||i.addEventListener("visibilitychange",this.onVisibilityChange),(s=this.networkEventTarget)==null||s.addEventListener("online",this.onNetworkOnline)}get token(){return this._token}clearToken(){this._token=null,this.acpClient.setToken(null),this.client=this.createClient(this.url,null)}async connect(e){this._token=e,this.hasAuthRejected=!1,this.acpClient.setToken(e),this.cancelRetryTimer(),this.retryDelay=Ga,this.autoReconnect=!0,await this.attempt()}dispose(){var e,n,i;this.autoReconnect=!1,this.connectAttempt+=1,this.cancelRetryTimer(),(e=this.socket)==null||e.close(),this.socket=null,this.setStatus("unauthorized"),(n=this.visibilityEventTarget)==null||n.removeEventListener("visibilitychange",this.onVisibilityChange),(i=this.networkEventTarget)==null||i.removeEventListener("online",this.onNetworkOnline),this.acpClient.dispose()}getViewURL(e){const n=Ol(e,{electron:ar()});return ar()?new URL(n.viewURL,this.url).toString():n.renderer==="proxy-iframe"?new URL(n.viewURL,this.url).toString():n.viewURL}getContentURL(e){const n=Ol(e,{electron:ar()}).contentURL;return n===null?null:new URL(n,this.url).toString()}async createScreen(e){const{screen:n}=await this.client.screens.create({name:e});return this.screens.set(n.id,structuredClone(n)),n}applyServerEvent(e){switch(e.type){case"screen-created":this.screens.set(e.screen.id,structuredClone(e.screen)),this.dispatchEvent(new Zs("screens-changed"));break;case"screen-updated":this.screens.set(e.screen.id,structuredClone(e.screen)),this.dispatchEvent(new Zs("screens-changed"));break;case"screen-removed":this.screens.delete(e.screenID),this.dispatchEvent(new Zs("screens-changed"));break;case"artifact-created":{const n=this.screens.get(e.screenID);n&&!ol(n).includes(e.artifact.id)&&(n.layout=[...n.layout,hy(e.artifact.id)]);break}case"artifact-removed":{const n=this.screens.get(e.screenID);n&&(n.layout=ty(n.layout,e.artifactID));break}case"artifact-updated":case"artifact-content-changed":case"screen-changed":case"theme-changed":case"artifact-focus":break;default:return Rz(e,"server event")}}async attempt(){var i;this.attempting=!0,this.nextRetryAt=null,this.connectAttempt+=1;const e=this.connectAttempt;(i=this.socket)==null||i.close(),this.client=this.createClient(this.url,this._token),this.setStatus("disconnected"),this.dispatchEvent(new oe("change"));const n=this.createSocket(Pz(this.url,this._token));return this.socket=n,await new Promise((s,o)=>{let a=!1;const c=()=>{a||this.connectAttempt!==e||(a=!0,this.retryDelay=Ga,this.hasEverConnected=!0,this.setStatus("connected"),s())},u=f=>{a||this.connectAttempt!==e||(a=!0,o(f))},h=async()=>{const f=this.hasEverConnected;try{const[{screens:y},m]=await Promise.all([this.client.screens.list(),this.client.display.get()]);this.screens=new Map(y.map(E=>[E.id,structuredClone(E)])),this.acpClient.setEnabled(m.acpEnabled),this.dispatchEvent(new oe("change")),f&&this.dispatchEvent(new Zs("screens-changed")),this.dispatchEvent(new Xu("server-event",{serverURL:this.url,event:{type:"screen-changed",screenID:m.activeScreenID}})),c(),f&&this.connectAttempt===e&&this.dispatchEvent(new Qv("server-reconnected",{serverURL:this.url}))}catch(y){if(zz(y)){u(new ro);return}u(y instanceof Error?y:new Error(String(y)))}};n.addEventListener("open",()=>{h()}),n.addEventListener("message",f=>{const y=Dz(f);y&&(this.applyServerEvent(y),this.dispatchEvent(new Xu("server-event",{serverURL:this.url,event:y})))}),n.addEventListener("close",f=>{if(this.connectAttempt!==e)return;this.socket=null;const y=Lz(f);if(!a){u(y===Jg?new ro:new Error("Connection closed before initialization"));return}if(y===Jg){this.handleAuthRejected();return}this.handleTransportFailure(new Error("Connection closed"))}),n.addEventListener("error",()=>{if(this.connectAttempt===e){if(a){this.handleTransportFailure(new Error("WebSocket error"));return}u(new Error("WebSocket connection failed"))}})}).then(()=>{this.attempting=!1},s=>{throw this.attempting=!1,this.handleAttemptFailure(s),s})}handleAuthRejected(){this.hasAuthRejected=!0,this.autoReconnect=!1,this.cancelRetryTimer(),this.setStatus("unauthorized")}handleAttemptFailure(e){if(e instanceof ro){this.handleAuthRejected();return}this.autoReconnect&&this.scheduleRetry()}handleTransportFailure(e){this.autoReconnect&&(this.setStatus("disconnected"),this.scheduleRetry())}scheduleRetry(){this.cancelRetryTimer(),this.connectAttempt+=1;const e=this.retryDelay;this.retryDelay=Math.min(this.retryDelay*2,Cz),this.nextRetryAt=Date.now()+e,this.retryTimer=setTimeout(()=>{this.retryTimer=null,this.attempt().catch(()=>{})},e),this.dispatchEvent(new oe("change"))}cancelRetryTimer(){this.retryTimer!==null&&(clearTimeout(this.retryTimer),this.retryTimer=null),this.nextRetryAt!==null&&(this.nextRetryAt=null,this.dispatchEvent(new oe("change")))}kickReconnect(){this.autoReconnect&&this.status!=="connected"&&(this.attempting||(this.cancelRetryTimer(),this.retryDelay=Ga,this.attempt().catch(()=>{})))}setStatus(e){this.status!==e&&(this.status=e,this.dispatchEvent(new oe("change")))}isPageVisible(){return this.visibilityEventTarget===null?!0:this.visibilityEventTarget.visibilityState==="visible"}}function Rz(r,t){throw new Error(`Unexpected ${t}: ${JSON.stringify(r)}`)}function Pz(r,t){const e=new URL(r);return e.protocol=e.protocol==="https:"?"wss:":"ws:",e.pathname="/events",e.search="",t&&e.searchParams.set("token",t),e.hash="",e.toString()}function Lz(r){return typeof r=="object"&&r!==null&&"code"in r&&typeof r.code=="number"?r.code:null}function Dz(r){const t=typeof r=="string"?r:typeof r=="object"&&r!==null&&"data"in r&&typeof r.data=="string"?r.data:"";if(!t)return null;try{return JSON.parse(t)}catch{return null}}function zz(r){return r instanceof Nd&&r.status===Iz}const Oz="Local";var To,gh;class Mz extends Ot{constructor(e){super();S(this,To);g(this,"servers",new Map);g(this,"localServerURL");g(this,"clientGUID");g(this,"acpStorage");g(this,"localStore");g(this,"createSocket");g(this,"lastActiveServerURL");g(this,"serverListeners",new Map);g(this,"handleLocalStoreChange",()=>{const e=this.localStore.get().activeServerURL;e!==this.lastActiveServerURL&&(this.lastActiveServerURL=e,this.dispatchEvent(new oe("change")))});this.localStore=e.localStore,this.localServerURL=e.localServerURL?he(e.localServerURL):null,this.createSocket=e.createSocket??(i=>new WebSocket(i)),this.lastActiveServerURL=this.localStore.get().activeServerURL;const n=e.acpStorage===void 0?$z():e.acpStorage;this.acpStorage=n,this.clientGUID=e.clientGUID??(n?Tz(n):Ud().toLowerCase()),this.localStore.addEventListener("change",this.handleLocalStoreChange)}get activeServer(){const e=this.localStore.get().activeServerURL;return e===null?null:this.servers.get(e)??null}add(e){const n=he(e.url);this.servers.get(n)&&this.remove(n),this.servers.set(n,e);const s=()=>{this.dispatchEvent(new oe("change"))},o=u=>{this.dispatchEvent(new Xu("server-event",{serverURL:u.serverURL,event:u.event}))},a=()=>{this.dispatchEvent(new Zs("screens-changed"))},c=u=>{this.dispatchEvent(new Qv("server-reconnected",{serverURL:u.serverURL}))};e.addEventListener("change",s),e.addEventListener("server-event",o),e.addEventListener("screens-changed",a),e.addEventListener("server-reconnected",c),this.serverListeners.set(n,{onServerChange:s,onServerEvent:o,onScreensChanged:a,onServerReconnected:c}),this.dispatchEvent(new oe("change"))}remove(e){const n=he(e);if(this.localServerURL&&n===this.localServerURL)return;const i=this.servers.get(n);if(!i)return;const s=this.serverListeners.get(n);s&&(i.removeEventListener("change",s.onServerChange),i.removeEventListener("server-event",s.onServerEvent),i.removeEventListener("screens-changed",s.onScreensChanged),i.removeEventListener("server-reconnected",s.onServerReconnected),this.serverListeners.delete(n)),i.dispose(),this.servers.delete(n);const o=this.localStore.get(),a=o.activeServerURL===n;this.localStore.set({...o,servers:o.servers.filter(c=>c.url!==n),activeServerURL:a?null:o.activeServerURL}),this.dispatchEvent(new oe("change"))}getStoredAuthToken(e){return vu(this.localStore.get(),e)}setStoredAuthToken(e,n){this.localStore.set(L$(this.localStore.get(),e,n))}clearStoredAuthToken(e){const n=this.localStore.get(),i=D$(n,e);i!==n&&this.localStore.set(i)}setActive(e){const n=this.localStore.get(),i=e?he(e.url):null;n.activeServerURL!==i&&this.localStore.set({...n,activeServerURL:i})}connectConfiguredServers(e,n){const i=e?he(e):null;if(i){const a=this.localStore.get();a.servers.some(u=>he(u.url)===i)||this.localStore.set({...a,servers:[...a.servers,{url:i,name:Oz}]})}const s=this.localStore.get().servers;for(const a of s){const c=he(a.url),h=i!==null&&c===i?n??vu(this.localStore.get(),c):vu(this.localStore.get(),c),f=p(this,To,gh).call(this,{url:a.url,name:a.name,token:h});this.add(f),f.connect(h).catch(()=>{})}const o=i?this.servers.get(i)??null:null;this.setActive(o??this.servers.values().next().value??null)}addServer(e,n){const i=he(e);this.remove(i);const s=this.localStore.get();this.localStore.set({...s,servers:[...s.servers.filter(a=>he(a.url)!==i),{url:i,name:n}]});const o=p(this,To,gh).call(this,{url:i,name:n,token:this.getStoredAuthToken(i)});this.add(o),this.setActive(o),o.connect(o.token).catch(()=>{})}removeServer(e){this.remove(e)}}To=new WeakSet,gh=function(e){return new aw({url:e.url,name:e.name,token:e.token,createSocket:this.createSocket,clientGUID:this.clientGUID,acpStorage:this.acpStorage})};var Io;class Nz extends Ot{constructor(){super();S(this,Io,e=>{const n=Uz(e);n!==null&&(e.preventDefault(),this.dispatchEvent(new Q1("shortcut-triggered",{shortcut:n})))});document.addEventListener("keydown",l(this,Io))}dispose(){document.removeEventListener("keydown",l(this,Io))}}Io=new WeakMap;function Uz(r){for(const[t,e]of Object.entries(x$))if(Fz(r,e.trigger))return t;return null}function Fz(r,t){return!(r.key.toLowerCase()!==t.key.toLowerCase()||r.metaKey!==!!t.meta||r.ctrlKey!==!!t.ctrl||r.shiftKey!==!!t.shift||r.altKey!==!!t.alt)}const mh="tv-nav:",hs="tv-reload",Xg=100,Hz=1e3,Zz=60,Wz=60,Bz=24,jz=30,Vz=jz*Bz*Wz*Zz*Hz;function Tr(r){try{const t=new URL(r,window.location.href),e=t.searchParams.has(hs);return t.searchParams.delete(hs),t.origin===window.location.origin?`${t.pathname}${t.search}${t.hash}`:e?t.toString():r}catch{return r}}var Co,Wi,ue,ne,Pn,ke,lw,zr,cw,vh,yh;class Gz extends Ot{constructor(e,n){super();S(this,ke);S(this,Co);S(this,Wi);S(this,ue,[]);S(this,ne,-1);S(this,Pn,0);w(this,Co,e),w(this,Wi,Tr(n)),p(this,ke,lw).call(this)}get currentURL(){var e;return l(this,ne)===-1?null:((e=l(this,ue)[l(this,ne)])==null?void 0:e.url)??null}get canGoBack(){return l(this,ne)>-1}get canGoForward(){return l(this,ne)<l(this,ue).length-1}get entries(){return l(this,ue).map(e=>({...e}))}get cursor(){return l(this,ne)}navigate(e){const n=Tr(e);if(n===l(this,Wi)){if(l(this,ne)===-1)return;w(this,ne,-1),p(this,ke,zr).call(this);return}l(this,ne)<l(this,ue).length-1&&w(this,ue,l(this,ue).slice(0,l(this,ne)+1)),l(this,ue).push({url:n}),w(this,ne,l(this,ue).length-1),p(this,ke,vh).call(this),p(this,ke,zr).call(this)}replace(e){var i;if(l(this,ne)===-1){this.navigate(e);return}const n=Tr(e);if(n===l(this,Wi)){w(this,ue,l(this,ue).filter((s,o)=>o!==l(this,ne))),w(this,ne,-1),p(this,ke,zr).call(this);return}((i=l(this,ue)[l(this,ne)])==null?void 0:i.url)!==n&&(w(this,ue,l(this,ue).map((s,o)=>o===l(this,ne)?{url:n}:s)),p(this,ke,zr).call(this))}back(){l(this,ne)!==-1&&(w(this,ne,l(this,ne)-1),p(this,ke,zr).call(this))}forward(){this.canGoForward&&(w(this,ne,l(this,ne)+1),p(this,ke,zr).call(this))}reset(){l(this,ne)===-1&&l(this,ue).length===0||(w(this,ue,[]),w(this,ne,-1),p(this,ke,zr).call(this))}}Co=new WeakMap,Wi=new WeakMap,ue=new WeakMap,ne=new WeakMap,Pn=new WeakMap,ke=new WeakSet,lw=function(){const e=localStorage.getItem(l(this,ke,yh));if(e!==null)try{const n=JSON.parse(e);if(!uw(n))return;w(this,ue,n.entries.map(i=>({url:i.url}))),w(this,ne,n.cursor),w(this,Pn,n.lastWritten),p(this,ke,vh).call(this)}catch{w(this,ue,[]),w(this,ne,-1),w(this,Pn,0)}},zr=function(){w(this,Pn,Date.now());try{localStorage.setItem(l(this,ke,yh),JSON.stringify(p(this,ke,cw).call(this)))}catch(e){if(!Kz(e))throw e}this.dispatchEvent(new oe("change"))},cw=function(){return{v:1,entries:l(this,ue).map(e=>({...e})),cursor:l(this,ne),lastWritten:l(this,Pn)}},vh=function(){if(l(this,ue).length<=Xg)return;const e=l(this,ue).length-Xg;w(this,ue,l(this,ue).slice(e)),w(this,ne,Math.max(-1,l(this,ne)-e))},yh=function(){return qz(l(this,Co))};function qz(r){return`${mh}${r}`}function Yz(r){const t=Date.now()-Vz,e=[];for(let n=0;n<localStorage.length;n+=1){const i=localStorage.key(n);if(!(i!=null&&i.startsWith(mh)))continue;const s=i.slice(mh.length),o=localStorage.getItem(i);if(o===null)continue;let a;try{a=JSON.parse(o)}catch{e.push(i);continue}if(!uw(a)){e.push(i);continue}!r.has(s)&&a.lastWritten<t&&e.push(i)}for(const n of e)localStorage.removeItem(n)}function Kz(r){return r instanceof DOMException&&r.name==="QuotaExceededError"}function uw(r){if(typeof r!="object"||r===null)return!1;const t=r;if(t.v!==1||!Array.isArray(t.entries))return!1;const e=t.cursor;return typeof e!="number"||!Number.isInteger(e)||typeof t.lastWritten!="number"||!Number.isFinite(t.lastWritten)||e<-1||e>=t.entries.length?!1:t.entries.every(n=>typeof n=="object"&&n!==null&&typeof n.url=="string")}let Dr=null;async function hw(r,t){if(Dr==null||Dr.abort(),r===null){Dr=null,Rl();return}const e=new AbortController;Dr=e;try{const n=t.token?{Authorization:`Bearer ${t.token}`}:void 0,i=new URL(`/themes/${r}/theme.css`,t.url).toString(),s=await fetch(i,{signal:e.signal,...n?{headers:n}:{}});if(!s.ok)throw new Error(`Theme fetch failed: ${s.status}`);const o=await s.text();if(Dr!==e)return;Xv(o)}catch(n){if(n.name==="AbortError")return;Rl();const i=n instanceof Error?n.message:String(n);console.warn(`applyTheme: ${i}`)}finally{Dr===e&&(Dr=null)}}/**
44
- * @license
45
- * Copyright 2017 Google LLC
46
- * SPDX-License-Identifier: BSD-3-Clause
47
- */const no=globalThis,Qg=r=>r,Ml=no.trustedTypes,em=Ml?Ml.createPolicy("lit-html",{createHTML:r=>r}):void 0,dw="$lit$",Mr=`lit$${Math.random().toFixed(9).slice(2)}$`,pw="?"+Mr,Jz=`<${pw}>`,qn=document,ho=()=>qn.createComment(""),po=r=>r===null||typeof r!="object"&&typeof r!="function",Yd=Array.isArray,Xz=r=>Yd(r)||typeof(r==null?void 0:r[Symbol.iterator])=="function",_u=`[
48
- \f\r]`,Ls=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,tm=/-->/g,rm=/>/g,dn=RegExp(`>|${_u}(?:([^\\s"'>=/]+)(${_u}*=${_u}*(?:[^
49
- \f\r"'\`<>=]|("|')|))|$)`,"g"),nm=/'/g,im=/"/g,fw=/^(?:script|style|textarea|title)$/i,Qz=r=>(t,...e)=>({_$litType$:r,strings:t,values:e}),D=Qz(1),Yn=Symbol.for("lit-noChange"),le=Symbol.for("lit-nothing"),sm=new WeakMap,En=qn.createTreeWalker(qn,129);function gw(r,t){if(!Yd(r)||!r.hasOwnProperty("raw"))throw Error("invalid template strings array");return em!==void 0?em.createHTML(t):t}const eO=(r,t)=>{const e=r.length-1,n=[];let i,s=t===2?"<svg>":t===3?"<math>":"",o=Ls;for(let a=0;a<e;a++){const c=r[a];let u,h,f=-1,y=0;for(;y<c.length&&(o.lastIndex=y,h=o.exec(c),h!==null);)y=o.lastIndex,o===Ls?h[1]==="!--"?o=tm:h[1]!==void 0?o=rm:h[2]!==void 0?(fw.test(h[2])&&(i=RegExp("</"+h[2],"g")),o=dn):h[3]!==void 0&&(o=dn):o===dn?h[0]===">"?(o=i??Ls,f=-1):h[1]===void 0?f=-2:(f=o.lastIndex-h[2].length,u=h[1],o=h[3]===void 0?dn:h[3]==='"'?im:nm):o===im||o===nm?o=dn:o===tm||o===rm?o=Ls:(o=dn,i=void 0);const m=o===dn&&r[a+1].startsWith("/>")?" ":"";s+=o===Ls?c+Jz:f>=0?(n.push(u),c.slice(0,f)+dw+c.slice(f)+Mr+m):c+Mr+(f===-2?a:m)}return[gw(r,s+(r[e]||"<?>")+(t===2?"</svg>":t===3?"</math>":"")),n]};class fo{constructor({strings:t,_$litType$:e},n){let i;this.parts=[];let s=0,o=0;const a=t.length-1,c=this.parts,[u,h]=eO(t,e);if(this.el=fo.createElement(u,n),En.currentNode=this.el.content,e===2||e===3){const f=this.el.content.firstChild;f.replaceWith(...f.childNodes)}for(;(i=En.nextNode())!==null&&c.length<a;){if(i.nodeType===1){if(i.hasAttributes())for(const f of i.getAttributeNames())if(f.endsWith(dw)){const y=h[o++],m=i.getAttribute(f).split(Mr),E=/([.?@])?(.*)/.exec(y);c.push({type:1,index:s,name:E[2],strings:m,ctor:E[1]==="."?rO:E[1]==="?"?nO:E[1]==="@"?iO:Ec}),i.removeAttribute(f)}else f.startsWith(Mr)&&(c.push({type:6,index:s}),i.removeAttribute(f));if(fw.test(i.tagName)){const f=i.textContent.split(Mr),y=f.length-1;if(y>0){i.textContent=Ml?Ml.emptyScript:"";for(let m=0;m<y;m++)i.append(f[m],ho()),En.nextNode(),c.push({type:2,index:++s});i.append(f[y],ho())}}}else if(i.nodeType===8)if(i.data===pw)c.push({type:2,index:s});else{let f=-1;for(;(f=i.data.indexOf(Mr,f+1))!==-1;)c.push({type:7,index:s}),f+=Mr.length-1}s++}}static createElement(t,e){const n=qn.createElement("template");return n.innerHTML=t,n}}function ds(r,t,e=r,n){var o,a;if(t===Yn)return t;let i=n!==void 0?(o=e._$Co)==null?void 0:o[n]:e._$Cl;const s=po(t)?void 0:t._$litDirective$;return(i==null?void 0:i.constructor)!==s&&((a=i==null?void 0:i._$AO)==null||a.call(i,!1),s===void 0?i=void 0:(i=new s(r),i._$AT(r,e,n)),n!==void 0?(e._$Co??(e._$Co=[]))[n]=i:e._$Cl=i),i!==void 0&&(t=ds(r,i._$AS(r,t.values),i,n)),t}class tO{constructor(t,e){this._$AV=[],this._$AN=void 0,this._$AD=t,this._$AM=e}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(t){const{el:{content:e},parts:n}=this._$AD,i=((t==null?void 0:t.creationScope)??qn).importNode(e,!0);En.currentNode=i;let s=En.nextNode(),o=0,a=0,c=n[0];for(;c!==void 0;){if(o===c.index){let u;c.type===2?u=new xc(s,s.nextSibling,this,t):c.type===1?u=new c.ctor(s,c.name,c.strings,this,t):c.type===6&&(u=new sO(s,this,t)),this._$AV.push(u),c=n[++a]}o!==(c==null?void 0:c.index)&&(s=En.nextNode(),o++)}return En.currentNode=qn,i}p(t){let e=0;for(const n of this._$AV)n!==void 0&&(n.strings!==void 0?(n._$AI(t,n,e),e+=n.strings.length-2):n._$AI(t[e])),e++}}let xc=class mw{get _$AU(){var t;return((t=this._$AM)==null?void 0:t._$AU)??this._$Cv}constructor(t,e,n,i){this.type=2,this._$AH=le,this._$AN=void 0,this._$AA=t,this._$AB=e,this._$AM=n,this.options=i,this._$Cv=(i==null?void 0:i.isConnected)??!0}get parentNode(){let t=this._$AA.parentNode;const e=this._$AM;return e!==void 0&&(t==null?void 0:t.nodeType)===11&&(t=e.parentNode),t}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(t,e=this){t=ds(this,t,e),po(t)?t===le||t==null||t===""?(this._$AH!==le&&this._$AR(),this._$AH=le):t!==this._$AH&&t!==Yn&&this._(t):t._$litType$!==void 0?this.$(t):t.nodeType!==void 0?this.T(t):Xz(t)?this.k(t):this._(t)}O(t){return this._$AA.parentNode.insertBefore(t,this._$AB)}T(t){this._$AH!==t&&(this._$AR(),this._$AH=this.O(t))}_(t){this._$AH!==le&&po(this._$AH)?this._$AA.nextSibling.data=t:this.T(qn.createTextNode(t)),this._$AH=t}$(t){var s;const{values:e,_$litType$:n}=t,i=typeof n=="number"?this._$AC(t):(n.el===void 0&&(n.el=fo.createElement(gw(n.h,n.h[0]),this.options)),n);if(((s=this._$AH)==null?void 0:s._$AD)===i)this._$AH.p(e);else{const o=new tO(i,this),a=o.u(this.options);o.p(e),this.T(a),this._$AH=o}}_$AC(t){let e=sm.get(t.strings);return e===void 0&&sm.set(t.strings,e=new fo(t)),e}k(t){Yd(this._$AH)||(this._$AH=[],this._$AR());const e=this._$AH;let n,i=0;for(const s of t)i===e.length?e.push(n=new mw(this.O(ho()),this.O(ho()),this,this.options)):n=e[i],n._$AI(s),i++;i<e.length&&(this._$AR(n&&n._$AB.nextSibling,i),e.length=i)}_$AR(t=this._$AA.nextSibling,e){var n;for((n=this._$AP)==null?void 0:n.call(this,!1,!0,e);t!==this._$AB;){const i=Qg(t).nextSibling;Qg(t).remove(),t=i}}setConnected(t){var e;this._$AM===void 0&&(this._$Cv=t,(e=this._$AP)==null||e.call(this,t))}},Ec=class{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(t,e,n,i,s){this.type=1,this._$AH=le,this._$AN=void 0,this.element=t,this.name=e,this._$AM=i,this.options=s,n.length>2||n[0]!==""||n[1]!==""?(this._$AH=Array(n.length-1).fill(new String),this.strings=n):this._$AH=le}_$AI(t,e=this,n,i){const s=this.strings;let o=!1;if(s===void 0)t=ds(this,t,e,0),o=!po(t)||t!==this._$AH&&t!==Yn,o&&(this._$AH=t);else{const a=t;let c,u;for(t=s[0],c=0;c<s.length-1;c++)u=ds(this,a[n+c],e,c),u===Yn&&(u=this._$AH[c]),o||(o=!po(u)||u!==this._$AH[c]),u===le?t=le:t!==le&&(t+=(u??"")+s[c+1]),this._$AH[c]=u}o&&!i&&this.j(t)}j(t){t===le?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,t??"")}},rO=class extends Ec{constructor(){super(...arguments),this.type=3}j(t){this.element[this.name]=t===le?void 0:t}},nO=class extends Ec{constructor(){super(...arguments),this.type=4}j(t){this.element.toggleAttribute(this.name,!!t&&t!==le)}},iO=class extends Ec{constructor(t,e,n,i,s){super(t,e,n,i,s),this.type=5}_$AI(t,e=this){if((t=ds(this,t,e,0)??le)===Yn)return;const n=this._$AH,i=t===le&&n!==le||t.capture!==n.capture||t.once!==n.once||t.passive!==n.passive,s=t!==le&&(n===le||i);i&&this.element.removeEventListener(this.name,this,n),s&&this.element.addEventListener(this.name,this,t),this._$AH=t}handleEvent(t){var e;typeof this._$AH=="function"?this._$AH.call(((e=this.options)==null?void 0:e.host)??this.element,t):this._$AH.handleEvent(t)}};class sO{constructor(t,e,n){this.element=t,this.type=6,this._$AN=void 0,this._$AM=e,this.options=n}get _$AU(){return this._$AM._$AU}_$AI(t){ds(this,t)}}const oO={I:xc},ku=no.litHtmlPolyfillSupport;ku==null||ku(fo,xc),(no.litHtmlVersions??(no.litHtmlVersions=[])).push("3.3.2");const Be=(r,t,e)=>{const n=t;let i=n._$litPart$;return i===void 0&&(n._$litPart$=i=new xc(t.insertBefore(ho(),null),null,void 0,{})),i._$AI(r),i};/**
50
- * @license
51
- * Copyright 2017 Google LLC
52
- * SPDX-License-Identifier: BSD-3-Clause
53
- */const Kd={CHILD:2},Ac=r=>(...t)=>({_$litDirective$:r,values:t});let Jd=class{constructor(t){}get _$AU(){return this._$AM._$AU}_$AT(t,e,n){this._$Ct=t,this._$AM=e,this._$Ci=n}_$AS(t,e){return this.update(t,e)}update(t,e){return this.render(...e)}};/**
54
- * @license
55
- * Copyright 2017 Google LLC
56
- * SPDX-License-Identifier: BSD-3-Clause
57
- */let Nl=class extends Jd{constructor(t){if(super(t),this.it=le,t.type!==Kd.CHILD)throw Error(this.constructor.directiveName+"() can only be used in child bindings")}render(t){if(t===le||t==null)return this._t=void 0,this.it=t;if(t===Yn)return t;if(typeof t!="string")throw Error(this.constructor.directiveName+"() called with a non-string value");if(t===this.it)return this._t;this.it=t;const e=[t];return e.raw=e,this._t={_$litType$:this.constructor.resultType,strings:e,values:[]}}};Nl.directiveName="unsafeHTML",Nl.resultType=1;const aO=Ac(Nl);/**
58
- * @license
59
- * Copyright 2017 Google LLC
60
- * SPDX-License-Identifier: BSD-3-Clause
61
- */let bh=class extends Nl{};bh.directiveName="unsafeSVG",bh.resultType=2;const vw=Ac(bh),lO={size:16,color:"currentColor",weight:"regular"};function cO(r){return typeof r=="string"?{regular:r}:r}function Mt(r,t="0 0 256 256"){const e=cO(r);return n=>{const{size:i,color:s,weight:o}={...lO,...n},a=e[o]??e.regular;return D`<svg
62
- xmlns="http://www.w3.org/2000/svg"
63
- data-ui-icon=""
64
- width="${i}"
65
- height="${i}"
66
- viewBox="${t}"
67
- fill="${s}"
68
- >${vw(a)}</svg>`}}/**
69
- * @license
70
- * Copyright 2020 Google LLC
71
- * SPDX-License-Identifier: BSD-3-Clause
72
- */const{I:uO}=oO,om=r=>r,hO=r=>r.strings===void 0,am=()=>document.createComment(""),Ds=(r,t,e)=>{var s;const n=r._$AA.parentNode,i=t===void 0?r._$AB:t._$AA;if(e===void 0){const o=n.insertBefore(am(),i),a=n.insertBefore(am(),i);e=new uO(o,a,r,r.options)}else{const o=e._$AB.nextSibling,a=e._$AM,c=a!==r;if(c){let u;(s=e._$AQ)==null||s.call(e,r),e._$AM=r,e._$AP!==void 0&&(u=r._$AU)!==a._$AU&&e._$AP(u)}if(o!==i||c){let u=e._$AA;for(;u!==o;){const h=om(u).nextSibling;om(n).insertBefore(u,i),u=h}}}return e},pn=(r,t,e=r)=>(r._$AI(t,e),r),dO={},pO=(r,t=dO)=>r._$AH=t,fO=r=>r._$AH,xu=r=>{r._$AR(),r._$AA.remove()};/**
73
- * @license
74
- * Copyright 2017 Google LLC
75
- * SPDX-License-Identifier: BSD-3-Clause
76
- */const io=(r,t)=>{var n;const e=r._$AN;if(e===void 0)return!1;for(const i of e)(n=i._$AO)==null||n.call(i,t,!1),io(i,t);return!0},Ul=r=>{let t,e;do{if((t=r._$AM)===void 0)break;e=t._$AN,e.delete(r),r=t}while((e==null?void 0:e.size)===0)},yw=r=>{for(let t;t=r._$AM;r=t){let e=t._$AN;if(e===void 0)t._$AN=e=new Set;else if(e.has(r))break;e.add(r),vO(t)}};function gO(r){this._$AN!==void 0?(Ul(this),this._$AM=r,yw(this)):this._$AM=r}function mO(r,t=!1,e=0){const n=this._$AH,i=this._$AN;if(i!==void 0&&i.size!==0)if(t)if(Array.isArray(n))for(let s=e;s<n.length;s++)io(n[s],!1),Ul(n[s]);else n!=null&&(io(n,!1),Ul(n));else io(this,r)}const vO=r=>{r.type==Kd.CHILD&&(r._$AP??(r._$AP=mO),r._$AQ??(r._$AQ=gO))};class yO extends Jd{constructor(){super(...arguments),this._$AN=void 0}_$AT(t,e,n){super._$AT(t,e,n),yw(this),this.isConnected=t._$AU}_$AO(t,e=!0){var n,i;t!==this.isConnected&&(this.isConnected=t,t?(n=this.reconnected)==null||n.call(this):(i=this.disconnected)==null||i.call(this)),e&&(io(this,t),Ul(this))}setValue(t){if(hO(this._$Ct))this._$Ct._$AI(t,this);else{const e=[...this._$Ct._$AH];e[this._$Ci]=t,this._$Ct._$AI(e,this,0)}}disconnected(){}reconnected(){}}/**
77
- * @license
78
- * Copyright 2020 Google LLC
79
- * SPDX-License-Identifier: BSD-3-Clause
80
- */const fl=()=>new bO;class bO{}const Eu=new WeakMap,gl=Ac(class extends yO{render(r){return le}update(r,[t]){var n;const e=t!==this.G;return e&&this.G!==void 0&&this.rt(void 0),(e||this.lt!==this.ct)&&(this.G=t,this.ht=(n=r.options)==null?void 0:n.host,this.rt(this.ct=r.element)),le}rt(r){if(this.isConnected||(r=void 0),typeof this.G=="function"){const t=this.ht??globalThis;let e=Eu.get(t);e===void 0&&(e=new WeakMap,Eu.set(t,e)),e.get(this.G)!==void 0&&this.G.call(this.ht,void 0),e.set(this.G,r),r!==void 0&&this.G.call(this.ht,r)}else this.G.value=r}get lt(){var r,t;return typeof this.G=="function"?(r=Eu.get(this.ht??globalThis))==null?void 0:r.get(this.G):(t=this.G)==null?void 0:t.value}disconnected(){this.lt===this.ct&&this.rt(void 0)}reconnected(){this.rt(this.ct)}}),Xd=Mt('<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"/>'),wO=Mt('<path d="M224,128a8,8,0,0,1-8,8H59.31l58.35,58.34a8,8,0,0,1-11.32,11.32l-72-72a8,8,0,0,1,0-11.32l72-72a8,8,0,0,1,11.32,11.32L59.31,120H216A8,8,0,0,1,224,128Z"/>'),SO=Mt('<path d="M216,56V200a16,16,0,0,1-16,16H56a16,16,0,0,1-16-16V56A16,16,0,0,1,56,40H200A16,16,0,0,1,216,56Z"/>'),Fl=Mt('<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"/>'),_O=Mt('<path d="M213.66,162.34l-80-80a8,8,0,0,0-11.32,0l-80,80A8,8,0,0,0,53.66,173.66L128,99.31l74.34,74.35a8,8,0,0,0,11.32-11.32Z"/>'),kO=Mt({regular:'<path d="M216,64H147.31l34.35-34.34a8,8,0,1,0-11.32-11.32L128,60.69,85.66,18.34A8,8,0,0,0,74.34,29.66L108.69,64H40A16,16,0,0,0,24,80V200a16,16,0,0,0,16,16H216a16,16,0,0,0,16-16V80A16,16,0,0,0,216,64Zm0,136H40V80H216V200Z"/>',bold:'<path d="M216,60H157l27.52-27.52a12,12,0,0,0-17-17L128,55,88.49,15.51a12,12,0,0,0-17,17L99,60H40A20,20,0,0,0,20,80V200a20,20,0,0,0,20,20H216a20,20,0,0,0,20-20V80A20,20,0,0,0,216,60Zm-4,136H44V84H212Z"/>'}),xO=Mt({regular:'<path d="M224,160V96a8,8,0,0,0-8-8H168V40a8,8,0,0,0-8-8H40a8,8,0,0,0-8,8V160a8,8,0,0,0,8,8H88v48a8,8,0,0,0,8,8H216a8,8,0,0,0,8-8V160Zm-60.69,48-40-40h33.38l40,40ZM168,156.69V123.31l40,40v33.38Zm40-16L171.31,104H208ZM48,48H152v56h0v48H48Zm56,123.31L140.69,208H104Z"/>',duotone:'<path d="M216,96V216H96V160h64V96Z" opacity="0.2"/><path d="M216,88H168V40a8,8,0,0,0-8-8H40a8,8,0,0,0-8,8V160a8,8,0,0,0,8,8H88v48a8,8,0,0,0,8,8H216a8,8,0,0,0,8-8V96A8,8,0,0,0,216,88ZM48,48H152V152H48ZM208,208H104V168h56a8,8,0,0,0,8-8V104h40Z"/>'}),EO=Mt({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"/>',duotone:'<path d="M112,56v48a8,8,0,0,1-8,8H56a8,8,0,0,1-8-8V56a8,8,0,0,1,8-8h48A8,8,0,0,1,112,56Zm88-8H152a8,8,0,0,0-8,8v48a8,8,0,0,0,8,8h48a8,8,0,0,0,8-8V56A8,8,0,0,0,200,48Zm-96,96H56a8,8,0,0,0-8,8v48a8,8,0,0,0,8,8h48a8,8,0,0,0,8-8V152A8,8,0,0,0,104,144Zm96,0H152a8,8,0,0,0-8,8v48a8,8,0,0,0,8,8h48a8,8,0,0,0,8-8V152A8,8,0,0,0,200,144Z" opacity="0.2"/><path d="M200,136H152a16,16,0,0,0-16,16v48a16,16,0,0,0,16,16h48a16,16,0,0,0,16-16V152A16,16,0,0,0,200,136Zm0,64H152V152h48v48ZM104,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,64H56V152h48v48Z"/>'}),AO=Mt('<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"/>'),bw=Mt({regular:'<path d="M136,32V64a8,8,0,0,1-16,0V32a8,8,0,0,1,16,0Zm88,88H192a8,8,0,0,0,0,16h32a8,8,0,0,0,0-16Zm-45.09,47.6a8,8,0,0,0-11.31,11.31l22.62,22.63a8,8,0,0,0,11.32-11.32ZM128,184a8,8,0,0,0-8,8v32a8,8,0,0,0,16,0V192A8,8,0,0,0,128,184ZM77.09,167.6,54.46,190.22a8,8,0,0,0,11.32,11.32L88.4,178.91A8,8,0,0,0,77.09,167.6ZM72,128a8,8,0,0,0-8-8H32a8,8,0,0,0,0,16H64A8,8,0,0,0,72,128ZM65.78,54.46A8,8,0,0,0,54.46,65.78L77.09,88.4A8,8,0,0,0,88.4,77.09Z"/>',bold:'<path d="M140,32V64a12,12,0,0,1-24,0V32a12,12,0,0,1,24,0Zm84,84H192a12,12,0,0,0,0,24h32a12,12,0,0,0,0-24Zm-42.26,48.77a12,12,0,1,0-17,17l22.63,22.63a12,12,0,0,0,17-17ZM128,180a12,12,0,0,0-12,12v32a12,12,0,0,0,24,0V192A12,12,0,0,0,128,180ZM74.26,164.77,51.63,187.4a12,12,0,0,0,17,17l22.63-22.63a12,12,0,1,0-17-17ZM76,128a12,12,0,0,0-12-12H32a12,12,0,0,0,0,24H64A12,12,0,0,0,76,128ZM68.6,51.63a12,12,0,1,0-17,17L74.26,91.23a12,12,0,0,0,17-17Z"/>'}),$O=Mt('<path d="M173.66,98.34a8,8,0,0,1,0,11.32l-56,56a8,8,0,0,1-11.32,0l-24-24a8,8,0,0,1,11.32-11.32L112,148.69l50.34-50.35A8,8,0,0,1,173.66,98.34ZM232,128A104,104,0,1,1,128,24,104.11,104.11,0,0,1,232,128Zm-16,0a88,88,0,1,0-88,88A88.1,88.1,0,0,0,216,128Z"/>');class TO extends Event{constructor(){super("close",{bubbles:!0,composed:!0})}}const lm='a[href],button:not([disabled]),input:not([disabled]),select:not([disabled]),textarea:not([disabled]),[tabindex]:not([tabindex="-1"])',Au=4;var Fe,it,Ln,st,Ro,Bi,ji,W,wh,Sh,Sw,ml,_w,_h,kh,Po,Lo,Dn,kw,xh,xw,Ew,vl,_i;class ww extends HTMLElement{constructor(){super();S(this,W);S(this,Fe,!1);S(this,it,null);S(this,Ln);S(this,st,null);S(this,Ro,"bottom-start");S(this,Bi,!1);S(this,ji,!1);S(this,Po,e=>{l(this,Fe)&&(l(this,Bi)||e.composedPath().includes(this)||(this.open=!1))});S(this,Lo,e=>{if(l(this,Fe)){if(e.key==="Escape"){e.preventDefault(),this.open=!1;return}e.key==="Tab"&&p(this,W,kw).call(this,e)}});S(this,Dn,()=>{l(this,Fe)&&p(this,W,vl).call(this)});w(this,Ln,this.attachShadow({mode:"open"})),zd(l(this,Ln)),p(this,W,Sh).call(this,"anchor")}connectedCallback(){this.removeAttribute("popover"),this.hasAttribute("tone")||this.setAttribute("tone","light"),p(this,W,Sh).call(this,"open"),p(this,W,_i).call(this),l(this,Fe)&&(p(this,W,_h).call(this),p(this,W,ml).call(this))}disconnectedCallback(){var e;p(this,W,kh).call(this),(e=l(this,it))==null||e.removeAttribute("aria-expanded")}attributeChangedCallback(e){e==="open"?p(this,W,Sw).call(this,this.hasAttribute("open")):e==="material"&&l(this,Fe)&&(p(this,W,_i).call(this),p(this,W,ml).call(this))}get open(){return l(this,Fe)}set open(e){this.toggleAttribute("open",e)}get anchor(){return l(this,it)}set anchor(e){l(this,it)!==e&&(l(this,it)&&l(this,it).removeAttribute("aria-expanded"),w(this,it,e),p(this,W,wh).call(this),l(this,Fe)&&p(this,W,vl).call(this))}}Fe=new WeakMap,it=new WeakMap,Ln=new WeakMap,st=new WeakMap,Ro=new WeakMap,Bi=new WeakMap,ji=new WeakMap,W=new WeakSet,wh=function(){l(this,it)&&l(this,it).setAttribute("aria-expanded",l(this,Fe)?"true":"false")},Sh=function(e){if(!Object.prototype.hasOwnProperty.call(this,e))return;const n=this,i=n[e];delete n[e],n[e]=i},Sw=function(e){var n,i,s;if(l(this,Fe)!==e){if(w(this,Fe,e),p(this,W,wh).call(this),!this.isConnected){p(this,W,_i).call(this);return}e?(w(this,Bi,!0),setTimeout(()=>{w(this,Bi,!1)},0),p(this,W,_i).call(this),p(this,W,_h).call(this),p(this,W,ml).call(this)):(p(this,W,kh).call(this),(i=(n=l(this,st))==null?void 0:n.hidePopover)==null||i.call(n),p(this,W,_i).call(this),(s=l(this,it))==null||s.focus(),this.dispatchEvent(new TO))}},ml=function(){l(this,ji)||(w(this,ji,!0),queueMicrotask(()=>{w(this,ji,!1),!(!l(this,Fe)||!this.isConnected)&&(p(this,W,_w).call(this),p(this,W,Ew).call(this))}))},_w=function(){var e,n;if(l(this,st)){try{(n=(e=l(this,st)).showPopover)==null||n.call(e)}catch{}p(this,W,vl).call(this)}},_h=function(){document.addEventListener("click",l(this,Po)),document.addEventListener("keydown",l(this,Lo),!0),window.addEventListener("resize",l(this,Dn)),window.addEventListener("scroll",l(this,Dn),!0)},kh=function(){document.removeEventListener("click",l(this,Po)),document.removeEventListener("keydown",l(this,Lo),!0),window.removeEventListener("resize",l(this,Dn)),window.removeEventListener("scroll",l(this,Dn),!0)},Po=new WeakMap,Lo=new WeakMap,Dn=new WeakMap,kw=function(e){const n=p(this,W,xh).call(this);if(n.length===0){e.preventDefault();return}const i=n[0],s=n[n.length-1],o=p(this,W,xw).call(this),a=o instanceof HTMLElement&&n.includes(o);e.shiftKey?(!a||o===i)&&(e.preventDefault(),s.focus()):(!a||o===s)&&(e.preventDefault(),i.focus())},xh=function(){if(!l(this,st))return[];const e=l(this,st).querySelector("slot");if(!(e instanceof HTMLSlotElement))return[];const n=[];for(const i of e.assignedElements({flatten:!0}))if(i instanceof HTMLElement){i.matches(lm)&&n.push(i);for(const s of i.querySelectorAll(lm))n.push(s)}return n},xw=function(){var n;let e=document.activeElement;for(;e&&((n=e.shadowRoot)!=null&&n.activeElement);)e=e.shadowRoot.activeElement;return e},Ew=function(){var n;const e=p(this,W,xh).call(this);e.length>0?e[0].focus():(n=l(this,st))==null||n.focus()},vl=function(){if(!l(this,Fe)||!l(this,it)||!l(this,st))return;const e=l(this,it).getBoundingClientRect(),n=l(this,st).getBoundingClientRect(),s=window.innerHeight-e.bottom,o=n.height+Au,a=s<o&&e.top>o?"top-start":"bottom-start";w(this,Ro,a);const c=a==="bottom-start"?e.bottom+Au:e.top-n.height-Au,u=e.left;l(this,st).style.transform=`translate(${u}px, ${c}px)`,l(this,st).setAttribute("data-placement",a)},_i=function(){this.toggleAttribute("open",l(this,Fe));const e=this.getAttribute("material")??"paper";Be(l(this,Fe)?D`<div
81
- class="panel"
82
- part="panel"
83
- popover="manual"
84
- data-placement=${l(this,Ro)}
85
- tabindex="-1"
86
- role="dialog"
87
- material=${e}
88
- level="1"
89
- >
90
- <slot></slot>
91
- </div>`:le,l(this,Ln)),w(this,st,l(this,Ln).querySelector(".panel"))},g(ww,"observedAttributes",["open","material"]);customElements.get("ui-popover")||customElements.define("ui-popover",ww);class Aw extends Event{constructor(e){super("dropdown-item-select",{bubbles:!0,composed:!0});g(this,"value");this.value=e}}class IO extends Event{constructor(e){super("select",{bubbles:!0,composed:!0});g(this,"value");this.value=e}}var ot,Ct,Br,jr,se,Do,zo,M,Tw,Vs,Iw,Cw,Eh,Rw,Gs,yn,zn,Oo,ql,Mo,Yl,Pw,Lw,Ah,qs,$h,Th,vr;class $w extends HTMLElement{constructor(){super();S(this,M);S(this,ot,!1);S(this,Ct,null);S(this,Br,null);S(this,jr);S(this,se,null);S(this,Do,fl());S(this,zo,new MutationObserver(e=>p(this,M,Pw).call(this,e)));S(this,zn,()=>{p(this,M,Gs).call(this,!l(this,ot))});S(this,Oo,e=>{e.key!=="Enter"&&e.key!==" "||(e.preventDefault(),l(this,zn).call(this))});S(this,ql,()=>{l(this,ot)&&p(this,M,Gs).call(this,!1)});S(this,Mo,e=>{e instanceof Aw&&(e.stopPropagation(),w(this,ot,!1),p(this,M,Vs).call(this,e.value),p(this,M,vr).call(this),this.dispatchEvent(new IO(e.value)))});S(this,Yl,()=>{p(this,M,Ah).call(this)});w(this,jr,this.attachShadow({mode:"open"})),zd(l(this,jr))}connectedCallback(){this.addEventListener("dropdown-item-select",l(this,Mo)),p(this,M,Tw).call(this),l(this,zo).observe(this,{childList:!0,subtree:!0,characterData:!0,attributes:!0,attributeFilter:["selected","value","slot"]}),p(this,M,vr).call(this)}disconnectedCallback(){this.removeEventListener("dropdown-item-select",l(this,Mo)),l(this,zo).disconnect(),p(this,M,Th).call(this)}attributeChangedCallback(e){if(e==="open"){p(this,M,Gs).call(this,this.hasAttribute("open"));return}p(this,M,vr).call(this)}get open(){return l(this,ot)}set open(e){this.toggleAttribute("open",e)}get title(){return this.getAttribute("title")??""}get value(){return l(this,Ct)}set value(e){e===null?(p(this,M,yn).call(this,null,null),p(this,M,Iw).call(this)):p(this,M,Vs).call(this,e),p(this,M,vr).call(this)}close(){p(this,M,Gs).call(this,!1)}}ot=new WeakMap,Ct=new WeakMap,Br=new WeakMap,jr=new WeakMap,se=new WeakMap,Do=new WeakMap,zo=new WeakMap,M=new WeakSet,Tw=function(){var n;const e=this.querySelector("dropdown-item[selected]");e&&p(this,M,yn).call(this,e.value,((n=e.textContent)==null?void 0:n.trim())??null)},Vs=function(e){var n;for(const i of l(this,M,Eh))i.value===e?(p(this,M,yn).call(this,e,((n=i.textContent)==null?void 0:n.trim())??null),i.hasAttribute("selected")||i.setAttribute("selected","")):i.hasAttribute("selected")&&i.removeAttribute("selected")},Iw=function(){const e=this.querySelectorAll("dropdown-item[selected]");for(const n of e)n.removeAttribute("selected")},Cw=function(e){for(const n of l(this,M,Eh))if(n.value===e)return n;return null},Eh=function(){return this.querySelectorAll("dropdown-item")},Rw=function(){return l(this,Br)??this.title},Gs=function(e){l(this,ot)!==e&&(w(this,ot,e),p(this,M,vr).call(this))},yn=function(e,n){w(this,Ct,e),w(this,Br,n)},zn=new WeakMap,Oo=new WeakMap,ql=new WeakMap,Mo=new WeakMap,Yl=new WeakMap,Pw=function(e){e.every(i=>i.target instanceof Element?i.target.closest('[slot="trigger"]')!==null:!1)||p(this,M,Lw).call(this)},Lw=function(){var n,i;const e=this.querySelector("dropdown-item[selected]");if(e){const s=e.value,o=((n=e.textContent)==null?void 0:n.trim())??null,a=l(this,Ct)!==s||l(this,Br)!==o;p(this,M,yn).call(this,s,o),p(this,M,Vs).call(this,s),a?p(this,M,vr).call(this):p(this,M,qs).call(this);return}if(l(this,Ct)!==null){const s=p(this,M,Cw).call(this,l(this,Ct));if(s){const o=((i=s.textContent)==null?void 0:i.trim())??null,a=l(this,Br)!==o;p(this,M,yn).call(this,l(this,Ct),o),p(this,M,Vs).call(this,l(this,Ct)),a?p(this,M,vr).call(this):p(this,M,qs).call(this);return}}if(l(this,Ct)!==null||l(this,Br)!==null){p(this,M,yn).call(this,null,null),p(this,M,vr).call(this);return}p(this,M,qs).call(this)},Ah=function(){const e=l(this,jr).querySelector('slot[name="trigger"]'),n=e instanceof HTMLSlotElement?e.assignedElements()[0]??null:null;l(this,se)!==n&&(p(this,M,Th).call(this),w(this,se,n),l(this,se)&&(l(this,se).addEventListener("click",l(this,zn)),l(this,se)instanceof HTMLButtonElement?l(this,se).hasAttribute("type")||(l(this,se).type="button"):(l(this,se).hasAttribute("role")||l(this,se).setAttribute("role","button"),l(this,se).hasAttribute("tabindex")||(l(this,se).tabIndex=0),l(this,se).addEventListener("keydown",l(this,Oo))))),p(this,M,qs).call(this),p(this,M,$h).call(this)},qs=function(){l(this,se)&&(l(this,se).setAttribute("data-dropdown-trigger",""),l(this,se).setAttribute("aria-haspopup","listbox"),l(this,se).setAttribute("aria-expanded",l(this,ot)?"true":"false"))},$h=function(){const e=l(this,Do).value;if(!e)return;const n=l(this,jr).querySelector("button.fallback-trigger");e.anchor=l(this,se)??n??null},Th=function(){l(this,se)&&(l(this,se).removeEventListener("click",l(this,zn)),l(this,se).removeEventListener("keydown",l(this,Oo)),l(this,se).removeAttribute("data-dropdown-trigger"),l(this,se).removeAttribute("aria-haspopup"),l(this,se).removeAttribute("aria-expanded"),w(this,se,null))},vr=function(){this.toggleAttribute("open",l(this,ot)),Be(D`
92
- <slot name="trigger" @slotchange=${l(this,Yl)}>
93
- <button
94
- class="fallback-trigger"
95
- part="trigger"
96
- type="button"
97
- aria-haspopup="listbox"
98
- aria-expanded=${l(this,ot)?"true":"false"}
99
- @click=${l(this,zn)}
100
- >
101
- <span class="trigger-label" part="trigger-label">${l(this,M,Rw)}</span>
102
- <span class="trigger-icon" part="trigger-icon" aria-hidden="true">
103
- ${Fl({size:16})}
104
- </span>
105
- </button>
106
- </slot>
107
- <ui-popover
108
- class="dropdown-popover"
109
- material="glass-frosted"
110
- ?open=${l(this,ot)}
111
- @close=${l(this,ql)}
112
- ${gl(l(this,Do))}
113
- >
114
- ${l(this,ot)?D`<div class="dropdown-list" part="list" role="listbox">
115
- <slot></slot>
116
- </div>`:le}
117
- </ui-popover>
118
- `,l(this,jr)),p(this,M,$h).call(this),queueMicrotask(()=>p(this,M,Ah).call(this))},g($w,"observedAttributes",["title","open"]);class CO extends HTMLElement{}class RO extends HTMLElement{}class PO extends HTMLElement{}var Xn,Ih,zw,No,Uo;class Dw extends HTMLElement{constructor(){super(...arguments);S(this,Xn);S(this,No,()=>{this.action||p(this,Xn,zw).call(this)});S(this,Uo,e=>{e.key!=="Enter"&&e.key!==" "||(e.preventDefault(),this.click())})}connectedCallback(){this.hasAttribute("role")||this.setAttribute("role","option"),this.hasAttribute("tabindex")||(this.tabIndex=0),this.addEventListener("click",l(this,No)),this.addEventListener("keydown",l(this,Uo)),p(this,Xn,Ih).call(this)}disconnectedCallback(){this.removeEventListener("click",l(this,No)),this.removeEventListener("keydown",l(this,Uo))}attributeChangedCallback(){p(this,Xn,Ih).call(this)}get value(){return this.getAttribute("value")??""}get selected(){return this.hasAttribute("selected")}get action(){return this.hasAttribute("action")}}Xn=new WeakSet,Ih=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")},zw=function(){this.dispatchEvent(new Aw(this.value))},No=new WeakMap,Uo=new WeakMap,g(Dw,"observedAttributes",["action","selected","value"]);customElements.get("dropdown-menu")||customElements.define("dropdown-menu",$w);customElements.get("dropdown-group")||customElements.define("dropdown-group",CO);customElements.get("dropdown-label")||customElements.define("dropdown-label",RO);customElements.get("dropdown-divider")||customElements.define("dropdown-divider",PO);customElements.get("dropdown-item")||customElements.define("dropdown-item",Dw);class LO extends Event{constructor(e){super("rename",{bubbles:!0,composed:!0});g(this,"value");this.value=e}}var er,Rt,ie,He,Ys,Fo,Ch,yl,Rh,Ho,Zo,Wo;class Ow extends HTMLElement{constructor(){super(...arguments);S(this,He);S(this,er,"");S(this,Rt,!1);S(this,ie,null);S(this,Fo,e=>{l(this,Rt)||(e.preventDefault(),p(this,He,Ch).call(this))});S(this,Ho,e=>{e.stopPropagation()});S(this,Zo,e=>{var n,i;e.key==="Enter"?(e.preventDefault(),p(this,He,yl).call(this,!0),(n=l(this,ie))==null||n.blur()):e.key==="Escape"&&(e.preventDefault(),p(this,He,yl).call(this,!1),(i=l(this,ie))==null||i.blur())});S(this,Wo,()=>{p(this,He,yl).call(this,!0)})}connectedCallback(){l(this,ie)||(w(this,ie,document.createElement("span")),l(this,ie).className="editable-text-span",this.append(l(this,ie)));const e=this.getAttribute("value");e!==null&&w(this,er,e),p(this,He,Ys).call(this),this.addEventListener("dblclick",l(this,Fo))}disconnectedCallback(){this.removeEventListener("dblclick",l(this,Fo)),l(this,Rt)&&p(this,He,Rh).call(this)}attributeChangedCallback(e){if(e==="value"){const n=this.getAttribute("value")??"";w(this,er,n),l(this,Rt)||p(this,He,Ys).call(this)}}get value(){return l(this,er)}set value(e){w(this,er,e),l(this,Rt)||p(this,He,Ys).call(this)}startEditing(){l(this,Rt)||p(this,He,Ch).call(this)}}er=new WeakMap,Rt=new WeakMap,ie=new WeakMap,He=new WeakSet,Ys=function(){l(this,ie)&&(l(this,ie).textContent=l(this,er),l(this,ie).scrollLeft=0)},Fo=new WeakMap,Ch=function(){l(this,ie)&&(w(this,Rt,!0),l(this,ie).setAttribute("contenteditable","plaintext-only"),l(this,ie).setAttribute("spellcheck","false"),l(this,ie).addEventListener("keydown",l(this,Zo)),l(this,ie).addEventListener("blur",l(this,Wo)),l(this,ie).addEventListener("mousedown",l(this,Ho)),this.toggleAttribute("data-editing",!0),queueMicrotask(()=>{var n;if(!l(this,ie))return;l(this,ie).focus();const e=(n=this.ownerDocument.defaultView)==null?void 0:n.getSelection();e==null||e.selectAllChildren(l(this,ie))}))},yl=function(e){if(!l(this,Rt)||!l(this,ie))return;const n=(l(this,ie).textContent??"").trim();w(this,Rt,!1),l(this,ie).removeAttribute("contenteditable"),l(this,ie).removeAttribute("spellcheck"),this.toggleAttribute("data-editing",!1),p(this,He,Rh).call(this),e&&n.length>0&&n!==l(this,er)&&(w(this,er,n),this.dispatchEvent(new LO(n))),p(this,He,Ys).call(this)},Rh=function(){var e,n,i;(e=l(this,ie))==null||e.removeEventListener("keydown",l(this,Zo)),(n=l(this,ie))==null||n.removeEventListener("blur",l(this,Wo)),(i=l(this,ie))==null||i.removeEventListener("mousedown",l(this,Ho))},Ho=new WeakMap,Zo=new WeakMap,Wo=new WeakMap,g(Ow,"observedAttributes",["value"]);customElements.get("editable-text")||customElements.define("editable-text",Ow);class DO extends Event{constructor(){super("close",{bubbles:!0,composed:!0})}}var Bo,rn,Ph,Kl,jo,Lh;class Mw extends HTMLElement{constructor(){super();S(this,rn);S(this,Bo);S(this,Kl,e=>{e.target===e.currentTarget&&p(this,rn,Ph).call(this)});S(this,jo,e=>{this.open&&e.key==="Escape"&&p(this,rn,Ph).call(this)});w(this,Bo,this.attachShadow({mode:"open"}))}connectedCallback(){document.addEventListener("keydown",l(this,jo)),p(this,rn,Lh).call(this)}disconnectedCallback(){document.removeEventListener("keydown",l(this,jo))}attributeChangedCallback(){p(this,rn,Lh).call(this)}get open(){return this.hasAttribute("open")}}Bo=new WeakMap,rn=new WeakSet,Ph=function(){this.dispatchEvent(new DO)},Kl=new WeakMap,jo=new WeakMap,Lh=function(){Be(D`
119
- ${this.open?D`
120
- <div class="backdrop" part="backdrop" @click=${l(this,Kl)}>
121
- <slot></slot>
122
- </div>
123
- `:null}
124
- `,l(this,Bo))},g(Mw,"observedAttributes",["open"]);customElements.get("modal-overlay")||customElements.define("modal-overlay",Mw);const zO=16,$u=24,OO=32;var Vi;class Nw extends HTMLElement{constructor(){super();S(this,Vi);w(this,Vi,this.attachShadow({mode:"open"})),zd(l(this,Vi))}connectedCallback(){this.render()}attributeChangedCallback(){this.render()}getSize(){const e=this.getAttribute("size");if(e===null)return $u;const n=Number(e);return n===zO||n===$u||n===OO?n:$u}getWeight(){return this.getAttribute("weight")==="bold"?"bold":"regular"}render(){Be(D`<span class="spin">${bw({size:this.getSize(),weight:this.getWeight()})}</span>`,l(this,Vi))}}Vi=new WeakMap,g(Nw,"observedAttributes",["size","weight"]);customElements.get("ui-spinner")||customElements.define("ui-spinner",Nw);class MO extends Event{constructor(){super("close",{bubbles:!0,composed:!0})}}class NO extends HTMLElement{}var Vo,Go,Dh;class Uw extends HTMLElement{constructor(){super();S(this,Go);S(this,Vo);w(this,Vo,this.attachShadow({mode:"open"}))}connectedCallback(){p(this,Go,Dh).call(this)}attributeChangedCallback(){p(this,Go,Dh).call(this)}get closable(){return this.hasAttribute("closable")}}Vo=new WeakMap,Go=new WeakSet,Dh=function(){const e=this.querySelector("panel-page");Be(D`
125
- <section class="panel" part="panel">
126
- <header class="title-bar" part="header">
127
- <h2 class="title" part="title">${(e==null?void 0:e.getAttribute("title"))??""}</h2>
128
- ${this.closable?D`
129
- <button
130
- type="button"
131
- class="title-button"
132
- part="button close-button"
133
- aria-label="Close"
134
- @click=${()=>this.dispatchEvent(new MO)}
135
- >
136
- <span class="close-icon" part="icon close-icon">${Xd({size:16})}</span>
137
- </button>
138
- `:null}
139
- </header>
140
- <slot></slot>
141
- </section>
142
- `,l(this,Vo))},g(Uw,"observedAttributes",["closable"]);customElements.get("panel-view")||customElements.define("panel-view",Uw);customElements.get("panel-page")||customElements.define("panel-page",NO);const UO=`
143
- <svg viewBox="0 0 12 12" aria-hidden="true" focusable="false">
144
- <path d="M10.2 3.1 5.1 8.2 2.4 5.5" />
145
- </svg>
146
- `,FO=`
147
- :host {
148
- display: block;
149
- margin: var(--checkbox-list-margin, var(--space-12) 0);
150
- }
151
-
152
- [part~="list"] {
153
- display: grid;
154
- gap: var(--checkbox-list-gap, var(--space-6));
155
- }
156
- `,HO=`
157
- :host {
158
- display: block;
159
- --checkbox-size: 1em;
160
- --checkbox-gap: var(--space-8);
161
- --checkbox-color: var(--color-primary);
162
- --checkbox-border-color: var(--color-border);
163
- --checkbox-bg: transparent;
164
- --checkbox-check-color: var(--color-bg);
165
- --checkbox-checked-content-color: var(--color-text-muted);
166
- --checkbox-checked-decoration: line-through;
167
- --checkbox-checked-decoration-thickness: 0.08em;
168
- }
169
-
170
- [part~="label"] {
171
- display: grid;
172
- grid-template-columns: var(--checkbox-size) minmax(0, 1fr);
173
- gap: var(--checkbox-gap);
174
- align-items: baseline;
175
- }
176
-
177
- input {
178
- position: absolute;
179
- opacity: 0;
180
- pointer-events: none;
181
- width: 1px;
182
- height: 1px;
183
- }
184
-
185
- [part~="box"] {
186
- display: inline-grid;
187
- place-items: center;
188
- width: var(--checkbox-size);
189
- height: var(--checkbox-size);
190
- border: 1px solid var(--checkbox-border-color);
191
- border-radius: var(--checkbox-radius, var(--radius-4));
192
- background: var(--checkbox-bg);
193
- color: var(--checkbox-check-color);
194
- transform: translateY(0.12em);
195
- cursor: not-allowed;
196
- }
197
-
198
- [part~="check"] {
199
- display: block;
200
- width: calc(var(--checkbox-size) * 0.72);
201
- height: calc(var(--checkbox-size) * 0.72);
202
- opacity: 0;
203
- }
204
-
205
- [part~="check"] svg {
206
- display: block;
207
- width: 100%;
208
- height: 100%;
209
- }
210
-
211
- [part~="check"] path {
212
- fill: none;
213
- stroke: currentColor;
214
- stroke-width: 2;
215
- stroke-linecap: round;
216
- stroke-linejoin: round;
217
- }
218
-
219
- [part~="content"] {
220
- min-width: 0;
221
- }
222
-
223
- :host([checked]) [part~="box"] {
224
- border-color: var(--checkbox-color);
225
- background: var(--checkbox-color);
226
- }
227
-
228
- :host([checked]) [part~="check"] {
229
- opacity: 1;
230
- }
231
-
232
- :host([checked]) [part~="content"] {
233
- color: var(--checkbox-checked-content-color);
234
- text-decoration-line: var(--checkbox-checked-decoration);
235
- text-decoration-thickness: var(--checkbox-checked-decoration-thickness);
236
- }
237
- `;var qo;class ZO extends HTMLElement{constructor(){super();S(this,qo);w(this,qo,this.attachShadow({mode:"open"})),l(this,qo).innerHTML=`<style>${FO}</style><div part="list"><slot></slot></div>`}connectedCallback(){this.hasAttribute("role")||this.setAttribute("role","list")}}qo=new WeakMap;var Gi,Yo,Ko,zh;class Fw extends HTMLElement{constructor(){super();S(this,Ko);S(this,Gi);S(this,Yo);w(this,Gi,this.attachShadow({mode:"open"})),l(this,Gi).innerHTML=`
238
- <style>${HO}</style>
239
- <label part="label">
240
- <input type="checkbox" disabled tabindex="-1">
241
- <span part="box"><span part="check">${UO}</span></span>
242
- <span part="content"><slot></slot></span>
243
- </label>
244
- `;const e=l(this,Gi).querySelector("input");if(!(e instanceof HTMLInputElement))throw new Error("checkbox-item failed to initialize input");w(this,Yo,e)}connectedCallback(){this.hasAttribute("role")||this.setAttribute("role","listitem"),this.setAttribute("aria-disabled","true"),p(this,Ko,zh).call(this)}attributeChangedCallback(){p(this,Ko,zh).call(this)}}Gi=new WeakMap,Yo=new WeakMap,Ko=new WeakSet,zh=function(){const e=this.hasAttribute("checked");l(this,Yo).checked=e,this.setAttribute("aria-checked",e?"true":"false")},g(Fw,"observedAttributes",["checked"]);customElements.get("checkbox-list")||customElements.define("checkbox-list",ZO);customElements.get("checkbox-item")||customElements.define("checkbox-item",Fw);const Hw=je(),Zw="No handler registered for update-content",Ww="handleUpdateContent: handler already registered",cm="television-artifact-bridge";function Bw(r){return r instanceof Error&&typeof r.message=="string"?r.message:String(r)}const jw=Sa(Ot);var qi,Yi,Ki,On,Mn,Jo,Ze,Oh,Vw,Gw,Ks,Mh,jm;let WO=(jm=class extends jw{constructor(e){super();S(this,Ze);S(this,qi);S(this,Yi);S(this,Ki);S(this,On,null);S(this,Mn,null);S(this,Jo,!1);w(this,qi,e);const n=e.ownerDocument.defaultView;if(!n)throw new Error("ArtifactView: iframe has no owner window");w(this,Yi,n),w(this,Ki,i=>p(this,Ze,Vw).call(this,i)),l(this,Yi).addEventListener("message",l(this,Ki))}get content(){return l(this,Mn)}set content(e){p(this,Ze,Mh).call(this),w(this,Mn,e),l(this,Jo)&&p(this,Ze,Oh).call(this,e)}handleUpdateContent(e){if(p(this,Ze,Mh).call(this),l(this,On)!==null)throw new Error(Ww);w(this,On,e)}dispose(){l(this,Yi).removeEventListener("message",l(this,Ki)),w(this,On,null)}},qi=new WeakMap,Yi=new WeakMap,Ki=new WeakMap,On=new WeakMap,Mn=new WeakMap,Jo=new WeakMap,Ze=new WeakSet,Oh=function(e){const n={type:"content-updated",content:e};p(this,Ze,Ks).call(this,n)},Vw=function(e){if(this.disposed||e.source!==l(this,qi).contentWindow)return;const n=e.data;if(lb(n)){w(this,Jo,!0),this.dispatchEvent(new Hw("ready")),l(this,Mn)!==null&&p(this,Ze,Oh).call(this,l(this,Mn));return}if(cb(n)){p(this,Ze,Gw).call(this,n);return}},Gw=async function(e){const n=l(this,On);if(n===null){p(this,Ze,Ks).call(this,{type:"response",id:e.id,error:{message:Zw}});return}try{await n(e.content)}catch(i){if(this.disposed)return;p(this,Ze,Ks).call(this,{type:"response",id:e.id,error:{message:Bw(i)}});return}this.disposed||p(this,Ze,Ks).call(this,{type:"response",id:e.id,result:{}})},Ks=function(e){const n=l(this,qi).contentWindow;n&&n.postMessage(e,"*")},Mh=function(){if(this.disposed)throw new Error("ArtifactView is disposed")},jm);var Nn,Ji,Un,Fn,Xo,We,Nh,qw,Yw,Js,Uh;class BO extends jw{constructor(e){super();S(this,We);S(this,Nn);S(this,Ji);S(this,Un,null);S(this,Fn,null);S(this,Xo,!1);w(this,Nn,e),w(this,Ji,n=>p(this,We,qw).call(this,n)),l(this,Nn).addEventListener("ipc-message",l(this,Ji))}get content(){return l(this,Fn)}set content(e){p(this,We,Uh).call(this),w(this,Fn,e),l(this,Xo)&&p(this,We,Nh).call(this,e)}handleUpdateContent(e){if(p(this,We,Uh).call(this),l(this,Un)!==null)throw new Error(Ww);w(this,Un,e)}dispose(){l(this,Nn).removeEventListener("ipc-message",l(this,Ji)),w(this,Un,null)}}Nn=new WeakMap,Ji=new WeakMap,Un=new WeakMap,Fn=new WeakMap,Xo=new WeakMap,We=new WeakSet,Nh=function(e){const n={type:"content-updated",content:e};p(this,We,Js).call(this,n)},qw=function(e){var s;if(this.disposed)return;const n=e.detail??e;if(!n||n.channel!==cm)return;const i=(s=n.args)==null?void 0:s[0];if(lb(i)){w(this,Xo,!0),this.dispatchEvent(new Hw("ready")),l(this,Fn)!==null&&p(this,We,Nh).call(this,l(this,Fn));return}if(cb(i)){p(this,We,Yw).call(this,i);return}},Yw=async function(e){const n=l(this,Un);if(n===null){p(this,We,Js).call(this,{type:"response",id:e.id,error:{message:Zw}});return}try{await n(e.content)}catch(i){if(this.disposed)return;p(this,We,Js).call(this,{type:"response",id:e.id,error:{message:Bw(i)}});return}this.disposed||p(this,We,Js).call(this,{type:"response",id:e.id,result:{}})},Js=function(e){var n,i;(i=(n=l(this,Nn)).send)==null||i.call(n,cm,e)},Uh=function(){if(this.disposed)throw new Error("WebviewArtifactViewRuntime is disposed")};const um="television-artifact-bridge",hm="/views/url-unsupported/",jO=404,Kw=je(),VO=je(),GO=je();class qO extends HTMLElement{constructor(){super(...arguments);g(this,"_artifact",null);g(this,"_viewURL",null);g(this,"_contentURL",null);g(this,"_screen",null);g(this,"_standaloneScroll",!1);g(this,"_subscribedWebview",null);g(this,"_embedLoadFrame",null);g(this,"_embedLoadKey",null);g(this,"_bridgePending",!0);g(this,"_bridgeCurrentGuid",null);g(this,"_bridgeLifecycleWindow",null);g(this,"_activeReloadFrameSrc",null);g(this,"_markdownFrame",null);g(this,"_markdownHost",null);g(this,"_markdownContentURL",null);g(this,"_proxyReloadVersion",0);g(this,"_navigationState",null);g(this,"_navigationArtifactId",null);g(this,"_navigationCanonicalURL",null);g(this,"_preserveFrameSrcOnNavigationRender",!1);g(this,"_missingArtifactID",null);g(this,"handleIframeMessage",e=>{var u,h;const n=this.querySelector("iframe.artifact-frame");if(!n)return;const i=Mp(e.data),s=Np(e.data)&&e.data.native===!0&&e.data.sameDocument!==!0,o=n.contentWindow===e.source,a=(i||s)&&this._bridgeLifecycleWindow!==null&&this._bridgeLifecycleWindow===e.source,c=i&&this.isArtifactFrameMessageOrigin(n,e.origin);if(!(!o&&!a&&!c)){if(Up(e.data)){this.handleBridgeReady(e.data,n);return}if(i){this.handleBridgeLeaving(e.data.guid);return}if(Fp(e.data)){this.dispatchArtifactWheel({deltaX:e.data.deltaX,shiftKey:e.data.shiftKey});return}if(Hp(e.data)){this.markLegacyBridgeProofOfLife(e.data,n),this.dispatchArtifactFilmstripKey(e.data.direction);return}if(tS(e.data)){this.markLegacyBridgeProofOfLife(e.data,n),(u=n.contentWindow)==null||u.postMessage({type:rS,url:this.currentExternalTargetURL()},"*");return}if(Zp(e.data)){this.markLegacyBridgeProofOfLife(e.data,n),(h=n.contentWindow)==null||h.postMessage(this.currentMissingArtifactMessage(),"*");return}if(Wp(e.data)){this.markLegacyBridgeProofOfLife(e.data,n),this.handleProxyContentChanged();return}if(Np(e.data)){const f=e.data.native===!0&&e.data.sameDocument!==!0;this.handleNavigationRequest(e.data),f||this.markLegacyBridgeProofOfLife(e.data,n);return}}});g(this,"handleNavigationChange",()=>{const e=this._preserveFrameSrcOnNavigationRender,n=!e;n&&this.closeBridgeGate({render:!1}),this.render({preserveFrameSrc:e}),this._preserveFrameSrcOnNavigationRender=!1,n&&window.setTimeout(()=>this.forceCurrentFrameSrc(),0)});g(this,"handleArtifactContentChanged",e=>{var i;if(e.artifactID===((i=this._artifact)==null?void 0:i.id)){if(this._markdownHost&&this._markdownContentURL||this.isCurrentMarkdownMissing()){this.fetchMarkdownContent();return}this.reloadProxyFrame()}});g(this,"handleThemeChanged",()=>{var e;((e=this._artifact)==null?void 0:e.kind)==="url"&&gr(this._artifact.url)||this.reloadProxyFrame()});g(this,"handleWebviewIpcMessage",e=>{var o,a;const n=e.detail??e;if(!n||n.channel!==um)return;const i=(o=n.args)==null?void 0:o[0];if(!i)return;const s=this._subscribedWebview;if(s){if(Up(i)){this.handleBridgeReady(i,s);return}if(Mp(i)){this.handleBridgeLeaving(i.guid);return}if(Zp(i)){this.markLegacyBridgeProofOfLife(i,s);const c=this.currentMissingArtifactMessage();c&&((a=s.send)==null||a.call(s,um,c));return}if(Fp(i)){this.markLegacyBridgeProofOfLife(i,s),this.dispatchArtifactWheel({deltaX:i.deltaX,shiftKey:i.shiftKey});return}if(Hp(i)){this.markLegacyBridgeProofOfLife(i,s),this.dispatchArtifactFilmstripKey(i.direction);return}Wp(i)&&(this.markLegacyBridgeProofOfLife(i,s),this.handleProxyContentChanged())}});g(this,"handleWebviewDidStartNavigation",e=>{const n=e.detail??e;n.isMainFrame===!0&&n.isInPlace!==!0&&this.closeBridgeGate()});g(this,"handleWebviewDidFailLoad",e=>{(e.detail??e).isMainFrame!==!1&&this.closeBridgeGate()});g(this,"handleWebviewDidNavigate",e=>{this.handleWebviewNavigationEvent(e)});g(this,"handleWebviewDidNavigateInPage",e=>{this._preserveFrameSrcOnNavigationRender=!0,this.handleWebviewNavigationEvent(e)||(this._preserveFrameSrcOnNavigationRender=!1)});g(this,"handleEmbedLoad",()=>{const e=this.querySelector(".artifact-frame");!e||e!==this._embedLoadFrame||this.setAttribute("data-embed-loaded","")})}set artifact(e){const n=this._artifact,i=n?!YO(n,e):!0;((n==null?void 0:n.id)!==e.id||n.kind==="path"&&e.kind==="path"&&n.path!==e.path)&&(this._missingArtifactID=null),i&&(this._bridgePending=!0,this._bridgeCurrentGuid=null,this._bridgeLifecycleWindow=null,this._activeReloadFrameSrc=null),this._artifact=e,this.syncNavigationState(),this.render(),this.syncWebviewSubscription()}get artifact(){return this._artifact}set viewURL(e){this._viewURL=e,this.syncNavigationState(),this.render(),this.syncWebviewSubscription()}get viewURL(){return this._viewURL}set contentURL(e){this._contentURL=e,this.render()}get contentURL(){return this._contentURL}set screen(e){var n,i,s,o;this._screen!==e&&((n=this._screen)==null||n.removeEventListener("artifact-content-changed",this.handleArtifactContentChanged),(i=this._screen)==null||i.removeEventListener("theme-changed",this.handleThemeChanged),this._screen=e,(s=this._screen)==null||s.addEventListener("artifact-content-changed",this.handleArtifactContentChanged),(o=this._screen)==null||o.addEventListener("theme-changed",this.handleThemeChanged),this.syncMarkdownHost())}get screen(){return this._screen}get activeView(){return null}set standaloneScroll(e){this._standaloneScroll=e}get standaloneScroll(){return this._standaloneScroll}connectedCallback(){this.setAttribute("level","2"),window.addEventListener("message",this.handleIframeMessage),this.rearmArtifactFrameOnConnect(),this.render(),this.syncWebviewSubscription(),this.syncNavigationState()}disconnectedCallback(){var e,n;window.removeEventListener("message",this.handleIframeMessage),this.unsubscribeFromWebview(),this.unsubscribeFromEmbedLoad(),this.syncNavigationState(),(e=this._screen)==null||e.removeEventListener("artifact-content-changed",this.handleArtifactContentChanged),(n=this._screen)==null||n.removeEventListener("theme-changed",this.handleThemeChanged),this.disposeMarkdownHost()}handleClose(){this._artifact&&this.dispatchEvent(new Kw("close-artifact",{artifactID:this._artifact.id,bubbles:!0,composed:!0}))}currentExternalTargetURL(){var n,i;const e=((n=this._navigationState)==null?void 0:n.currentURL)??null;return e&&Tu(e)?e:((i=this._artifact)==null?void 0:i.kind)==="url"?this._artifact.url:null}currentMissingArtifactMessage(){const e=this._artifact;return(e==null?void 0:e.kind)!=="path"?null:{type:nS,title:e.title,path:e.path}}handleBridgeReady(e,n=this.querySelector(".artifact-frame")){if(this.isArtifactFrame(n)){if(typeof e.guid=="string"){(e.guid!==this._bridgeCurrentGuid||this._bridgePending)&&(this._bridgeCurrentGuid=e.guid,this._bridgeLifecycleWindow=n.tagName.toLowerCase()==="iframe"?n.contentWindow:null,this._bridgePending=!1,this.render({preserveFrameSrc:!0}));return}this.markLegacyBridgeProofOfLife(e,n)}}handleBridgeLeaving(e){e===this._bridgeCurrentGuid&&this.closeBridgeGate()}markLegacyBridgeProofOfLife(e,n=this.querySelector(".artifact-frame")){this.isArtifactFrame(n)&&(!this._bridgePending||KO(e)||(this._bridgePending=!1,this.render({preserveFrameSrc:!0})))}closeBridgeGate(e={}){const n=!this._bridgePending||this._bridgeCurrentGuid!==null;this._bridgePending=!0,this._bridgeCurrentGuid=null,this._bridgeLifecycleWindow=null,n&&e.render!==!1&&this.render({preserveFrameSrc:!0})}isArtifactFrame(e){if(!e)return!1;const n=e.tagName.toLowerCase();return n==="iframe"||n==="webview"}isArtifactFrameMessageOrigin(e,n){try{return new URL(e.getAttribute("src")??e.src,window.location.href).origin===n}catch{return!1}}shouldGateFrame(){return this._bridgePending}rearmArtifactFrameOnConnect(){const e=this.querySelector(".artifact-frame");this.isArtifactFrame(e)&&this.closeBridgeGate({render:!1})}handleProxyContentChanged(){var e;((e=this._artifact)==null?void 0:e.kind)!=="url"||!gr(this._artifact.url)||this.reloadProxyFrame()}handleNavigationRequest(e){this.syncNavigationState();const n=this._navigationState;if(!n)return;const i=this.convertIframeNavigationURL(e.url);if(i===hm||i===n.currentURL)return;const s=e.native===!0;(e.sameDocument||s)&&(this._preserveFrameSrcOnNavigationRender=!0),s&&e.sameDocument!==!0&&this.closeBridgeGate({render:!1}),e.replace?n.replace(i):n.navigate(i)}dispatchArtifactFilmstripKey(e){this._standaloneScroll||this.dispatchEvent(new GO("artifact-filmstrip-key",{bubbles:!0,composed:!0,direction:e}))}dispatchArtifactWheel(e){this._standaloneScroll||this.dispatchEvent(new VO("artifact-wheel",{bubbles:!0,composed:!0,deltaX:e.deltaX,shiftKey:e.shiftKey}))}syncNavigationState(){if(!this.isConnected||!this._artifact){this.disposeNavigationState();return}const e=this.canonicalURLForArtifact(this._artifact);this._navigationState&&this._navigationArtifactId===this._artifact.id&&this._navigationCanonicalURL===e||(this.disposeNavigationState(),this._navigationState=new Gz(this._artifact.id,e),this._navigationArtifactId=this._artifact.id,this._navigationCanonicalURL=e,this._navigationState.addEventListener("change",this.handleNavigationChange),this._navigationState.currentURL!==null&&this.render())}disposeNavigationState(){var e;(e=this._navigationState)==null||e.removeEventListener("change",this.handleNavigationChange),this._navigationState=null,this._navigationArtifactId=null,this._navigationCanonicalURL=null,this._preserveFrameSrcOnNavigationRender=!1}canonicalURLForArtifact(e){const n=Ol(e,{electron:ar()}),i=this._viewURL??n.viewURL;return e.kind==="url"&&gr(e.url)||n.renderer==="url-webview"?Tr(i):dm(i,i)}convertIframeNavigationURL(e){var i,s;if(((i=this._artifact)==null?void 0:i.kind)==="url"&&gr(this._artifact.url)&&gr(e))return Tr(e);const n=(s=this.querySelector(".artifact-frame"))==null?void 0:s.getAttribute("src");return dm(e,n??this._viewURL??null)}handleWebviewNavigationEvent(e){const n=e.url;if(typeof n!="string")return!1;this.syncNavigationState();const i=this._navigationState;if(!i)return!1;const s=Tr(n);return s===i.currentURL?!1:(i.navigate(s),!0)}viewURLForInternalNavigation(e){if(!e.startsWith("/")||!this._viewURL)return e;try{return new URL(e,this._viewURL).toString()}catch{return e}}syncWebviewSubscription(){const e=this.querySelector("webview");e!==this._subscribedWebview&&(this.unsubscribeFromWebview(),e&&(e.addEventListener("ipc-message",this.handleWebviewIpcMessage),e.addEventListener("did-start-navigation",this.handleWebviewDidStartNavigation),e.addEventListener("did-fail-load",this.handleWebviewDidFailLoad),e.addEventListener("did-navigate",this.handleWebviewDidNavigate),e.addEventListener("did-navigate-in-page",this.handleWebviewDidNavigateInPage),this._subscribedWebview=e))}unsubscribeFromWebview(){this._subscribedWebview&&(this._subscribedWebview.removeEventListener("ipc-message",this.handleWebviewIpcMessage),this._subscribedWebview.removeEventListener("did-start-navigation",this.handleWebviewDidStartNavigation),this._subscribedWebview.removeEventListener("did-fail-load",this.handleWebviewDidFailLoad),this._subscribedWebview.removeEventListener("did-navigate",this.handleWebviewDidNavigate),this._subscribedWebview.removeEventListener("did-navigate-in-page",this.handleWebviewDidNavigateInPage),this._subscribedWebview=null)}syncEmbedLoadState(){var s;const e=this.querySelector(".artifact-frame"),n=e?`${e.tagName.toLowerCase()}:${e.getAttribute("src")??""}:${e.dataset.contentUrl??""}`:null;if(e&&e===this._embedLoadFrame&&n===this._embedLoadKey||(this.unsubscribeFromEmbedLoad(),this.removeAttribute("data-embed-loaded"),!e||!n))return;if(this._embedLoadFrame=e,this._embedLoadKey=n,e.tagName.toLowerCase()==="webview"){e.addEventListener("did-finish-load",this.handleEmbedLoad),e.addEventListener("did-fail-load",this.handleEmbedLoad);return}e.addEventListener("load",this.handleEmbedLoad);const i=e;try{((s=i.contentDocument)==null?void 0:s.readyState)==="complete"&&this.handleEmbedLoad()}catch{}}unsubscribeFromEmbedLoad(){if(!this._embedLoadFrame){this._embedLoadKey=null;return}this._embedLoadFrame.removeEventListener("load",this.handleEmbedLoad),this._embedLoadFrame.removeEventListener("did-finish-load",this.handleEmbedLoad),this._embedLoadFrame.removeEventListener("did-fail-load",this.handleEmbedLoad),this._embedLoadFrame=null,this._embedLoadKey=null}iframeTargetOrigin(e){const n=e.getAttribute("sandbox")??"";if(!new Set(n.split(/\s+/).filter(Boolean)).has("allow-same-origin"))return"*";const s=e.getAttribute("src")??e.src;if(!s)return"*";try{return new URL(s,window.location.href).origin}catch{return"*"}}syncMarkdownHost(){const e=this.querySelector("[data-content-url]"),n=(e==null?void 0:e.dataset.contentUrl)??null;if(!e||!n||!this._artifact||!this._screen){this.disposeMarkdownHost();return}if(e===this._markdownFrame&&n===this._markdownContentURL)return;this.disposeMarkdownHost(),this._markdownFrame=e,this._markdownContentURL=n;const i=e.tagName.toLowerCase()==="webview"?new BO(e):new WO(e);this._markdownHost=i,i.handleUpdateContent(async s=>{const o=this._artifact,a=this._screen;if(!o||!a)throw new Error("No markdown artifact selected");await a.server.client.markdown.update({artifactID:o.id,content:s}),i.content=s}),this.fetchMarkdownContent()}async fetchMarkdownContent(){const e=this._artifact,n=this._markdownHost,i=this._screen;if(!(!e||!i))try{const s=await i.server.client.markdown.get({artifactID:e.id});if(this._missingArtifactID=null,!n){this.render();return}n.content=s}catch(s){if(s instanceof Nd&&s.status===jO){this._missingArtifactID=e.id,this.disposeMarkdownHost(),this.render();return}}}isCurrentMarkdownMissing(){var e;return this._missingArtifactID===((e=this._artifact)==null?void 0:e.id)&&this._artifact.kind==="path"&&ob(this._artifact.path)}missingArtifactTemplate(e){return D`
245
- <section class="artifact-missing artifact-content" role="status" aria-label="Artifact file not found">
246
- <div class="artifact-missing-wrapper">
247
- <h1>${oS()}</h1>
248
- <p>${aS()}</p>
249
- <section class="artifact-missing-path" aria-label="Missing artifact path">
250
- <p class="artifact-missing-path-label">Registered path:</p>
251
- <p><code>${e.path}</code></p>
252
- </section>
253
- <p>${lS()}</p>
254
- </div>
255
- </section>
256
- `}disposeMarkdownHost(){var e;(e=this._markdownHost)==null||e.dispose(),this._markdownHost=null,this._markdownFrame=null,this._markdownContentURL=null}reloadProxyFrame(){var o,a,c,u;const e=this.querySelector(".artifact-frame:not([data-content-url])");if(!e||e.tagName.toLowerCase()==="webview"&&!(((o=this._artifact)==null?void 0:o.kind)==="path"||((a=this._artifact)==null?void 0:a.kind)==="url"&&gr(this._artifact.url)))return;const n=((c=this._artifact)==null?void 0:c.kind)==="url"&&gr(this._artifact.url)?((u=this._navigationState)==null?void 0:u.currentURL)??e.getAttribute("src"):e.getAttribute("src");if(n===null)return;this.closeBridgeGate({render:!1});const i=new URL(n,window.location.href);i.searchParams.set(hs,String(++this._proxyReloadVersion));const s=n.startsWith("/")?`${i.pathname}${i.search}${i.hash}`:i.href;this._activeReloadFrameSrc=s,this.removeAttribute("data-embed-loaded"),this.render({frameSrcOverride:s})}contentTemplate(e,n){var h;if(e.kind==="path"&&this.isCurrentMarkdownMissing())return this.missingArtifactTemplate(e);const i=this.routeForCurrentNavigation(e),s=(h=this.querySelector(".artifact-frame"))==null?void 0:h.getAttribute("src");let o=null;this._activeReloadFrameSrc&&(JO(this._activeReloadFrameSrc,i.viewURL)?o=this._activeReloadFrameSrc:this._activeReloadFrameSrc=null);const a=n.frameSrcOverride??o??(n.preserveFrameSrc&&s?s:i.viewURL),c=this._contentURL??i.contentURL,u=this.shouldGateFrame();return i.renderer==="url-webview"?i.contentURL?D`<webview allowpopups class="artifact-frame artifact-content" src=${a} data-content-url=${c} ?data-bridge-pending=${u}></webview>`:D`<webview allowpopups class="artifact-frame artifact-content" src=${a} ?data-bridge-pending=${u}></webview>`:i.renderer==="markdown"?D`<iframe class="artifact-frame artifact-content" src=${a} data-content-url=${c} ?data-bridge-pending=${u}></iframe>`:D`<iframe class="artifact-frame artifact-content" src=${a} ?data-bridge-pending=${u}></iframe>`}routeForCurrentNavigation(e){var s;const n=Ol(e,{electron:ar()}),i=((s=this._navigationState)==null?void 0:s.currentURL)??null;if(i===null){const o=this._viewURL??n.viewURL;return n.renderer==="markdown"?{renderer:"markdown",viewURL:o,contentURL:this._contentURL??n.contentURL}:{...n,viewURL:o}}return Tu(i)&&!ar()?gr(i)?{renderer:"proxy-iframe",viewURL:i,contentURL:null}:{renderer:"proxy-iframe",viewURL:hm,contentURL:null}:Tu(i)&&ar()?{renderer:"url-webview",viewURL:i,contentURL:null}:ar()?{renderer:"url-webview",viewURL:this.viewURLForInternalNavigation(i),contentURL:null}:{renderer:"proxy-iframe",viewURL:this.viewURLForInternalNavigation(i),contentURL:null}}forceCurrentFrameSrc(){if(!this._artifact)return;const e=this.routeForCurrentNavigation(this._artifact);if(e.renderer==="url-webview")return;const n=this.querySelector("iframe.artifact-frame");if(n){this.closeBridgeGate(),this._activeReloadFrameSrc=null,this.removeAttribute("data-embed-loaded");try{n.contentWindow&&(n.contentWindow.location.href=e.viewURL)}catch{n.src=e.viewURL}n.src=e.viewURL,n.setAttribute("src",e.viewURL),this.syncEmbedLoadState()}}titleIconTemplate(){const e=this._navigationState;return e!=null&&e.canGoBack?D`
257
- <button
258
- icon-only
259
- size="sm"
260
- variant="ghost"
261
- class="artifact-title-icon artifact-history-back"
262
- @click=${()=>e.back()}
263
- aria-label="Back"
264
- >
265
- ${wO({size:16})}
266
- </button>
267
- `:D`
268
- <button
269
- icon-only
270
- size="sm"
271
- variant="ghost"
272
- class="artifact-title-icon"
273
- disabled
274
- aria-label="No history"
275
- >
276
- ${xO({size:16,weight:"duotone"})}
277
- </button>
278
- `}template(e={preserveFrameSrc:!1}){const n=this._artifact;return D`
279
- ${this.contentTemplate(n,e)}
280
- <footer class="artifact-title-bar" drag-handle material="glass-frosted">
281
- <div class="artifact-title-group">
282
- ${this.titleIconTemplate()}
283
- <span class="artifact-title">${n.title}</span>
284
- </div>
285
- <div class="artifact-title-actions">
286
- <button
287
- icon-only
288
- size="sm"
289
- variant="ghost"
290
- class="artifact-close-btn"
291
- @click=${()=>this.handleClose()}
292
- aria-label="Close"
293
- >
294
- ${Xd({size:16})}
295
- </button>
296
- </div>
297
- </footer>
298
- `}render(e={}){this._artifact&&(this.setAttribute("kind",this._artifact.kind),Be(this.template({preserveFrameSrc:e.preserveFrameSrc??!1,frameSrcOverride:e.frameSrcOverride}),this),e.forceFrameSrc&&this.forceCurrentFrameSrc(),this.syncWebviewSubscription(),this.syncEmbedLoadState(),this.syncMarkdownHost())}}function Tu(r){return r.startsWith("http://")||r.startsWith("https://")}function YO(r,t){return r.id!==t.id||r.kind!==t.kind?!1:r.kind==="path"&&t.kind==="path"?r.path===t.path:r.kind==="url"&&t.kind==="url"?r.url===t.url:!0}function KO(r){return typeof r=="object"&&r!==null&&"guid"in r}function JO(r,t){try{const e=new URL(r,window.location.href),n=new URL(t,window.location.href);return e.searchParams.delete(hs),n.searchParams.delete(hs),e.origin===n.origin&&e.pathname===n.pathname&&e.search===n.search}catch{return!1}}function dm(r,t){try{const e=new URL(r,window.location.href);if(t){const n=new URL(t,window.location.href);if(e.origin===n.origin)return e.searchParams.delete(hs),`${e.pathname}${e.search}${e.hash}`}}catch{return Tr(r)}return Tr(r)}customElements.define("artifact-view",qO);/**
299
- * @license
300
- * Copyright 2017 Google LLC
301
- * SPDX-License-Identifier: BSD-3-Clause
302
- */const pm=(r,t,e)=>{const n=new Map;for(let i=t;i<=e;i++)n.set(r[i],i);return n},fm=Ac(class extends Jd{constructor(r){if(super(r),r.type!==Kd.CHILD)throw Error("repeat() can only be used in text expressions")}dt(r,t,e){let n;e===void 0?e=t:t!==void 0&&(n=t);const i=[],s=[];let o=0;for(const a of r)i[o]=n?n(a,o):o,s[o]=e(a,o),o++;return{values:s,keys:i}}render(r,t,e){return this.dt(r,t,e).values}update(r,[t,e,n]){const i=fO(r),{values:s,keys:o}=this.dt(t,e,n);if(!Array.isArray(i))return this.ut=o,s;const a=this.ut??(this.ut=[]),c=[];let u,h,f=0,y=i.length-1,m=0,E=s.length-1;for(;f<=y&&m<=E;)if(i[f]===null)f++;else if(i[y]===null)y--;else if(a[f]===o[m])c[m]=pn(i[f],s[m]),f++,m++;else if(a[y]===o[E])c[E]=pn(i[y],s[E]),y--,E--;else if(a[f]===o[E])c[E]=pn(i[f],s[E]),Ds(r,c[E+1],i[f]),f++,E--;else if(a[y]===o[m])c[m]=pn(i[y],s[m]),Ds(r,i[f],i[y]),y--,m++;else if(u===void 0&&(u=pm(o,m,E),h=pm(a,f,y)),u.has(a[f]))if(u.has(a[y])){const x=h.get(o[m]),I=x!==void 0?i[x]:null;if(I===null){const P=Ds(r,i[f]);pn(P,s[m]),c[m]=P}else c[m]=pn(I,s[m]),Ds(r,i[f],I),i[x]=null;m++}else xu(i[y]),y--;else xu(i[f]),f++;for(;m<=E;){const x=Ds(r,c[E+1]);pn(x,s[m]),c[m++]=x}for(;f<=y;){const x=i[f++];x!==null&&xu(x)}return this.ut=o,pO(r,c),Yn}}),Ie=r=>({type:"px",...r}),Te=r=>({type:"unit",...r}),qa=2;class XO{constructor(t){g(this,"basis");g(this,"min");g(this,"_gap");g(this,"_viewport");g(this,"_unit");this.basis=t.basis,this.min=t.min,this._viewport=t.viewport,this._gap=t.gap??Ie({x:ae,y:ae});const e=this._viewport.x??Vn,n=this._viewport.y??lo,i=this._gap.x??ae,s=this._gap.y??ae,o=e<=r$,a=o?e-i*qa:Math.min(Vn,e-i*qa),c=o?n-s*qa:Math.min(lo,n-s*qa),u=(a-i*(qe-1))/qe,h=(c-s*(ft-1))/ft,f=this.basis.x??0,y=this.basis.y??0,m=this.min.x??0,E=this.min.y??0;this._unit=Ie(o?{x:Math.max(m,u),y:Math.max(E,h)}:{x:Math.max(m,Math.min(f,u)),y:Math.max(E,Math.min(y,h))})}get unit(){return this._unit}get viewport(){return this._viewport}get gap(){return this._gap}toUnits(t){return Te({x:t.x==null?void 0:t.x/(this._unit.x??1),y:t.y==null?void 0:t.y/(this._unit.y??1)})}toPixels(t){const e=this._unit.x??0,n=this._unit.y??0,i=this._gap.x??ae,s=this._gap.y??ae,o=t.x==null?void 0:t.x*e+Math.max(0,t.x-1)*i,a=t.y==null?void 0:t.y*n+Math.max(0,t.y-1)*s;return Ie({x:o,y:a})}}const Kn=1e-4,Lt=1e-6,QO=40,eM=24;function Jw(r,t){return Math.max(0,r-t*2)}function Xw(r){const t=[0];for(const e of r)t.push((t[t.length-1]??0)+e);return t}function Qw(r){const t=[0];for(let e=0;e<r.length;e+=1){const n=t[e]??0;t.push(n+r[e]+ae)}return t}function e0(r,t,e){if(t<0||t>=r.length)return 0;let n=0,i=0;for(let s=t;s<r.length;s+=1){const o=r[s],a=i===0?o:n+ae+o;if(a>e+Kn)break;n=a,i+=1}return Math.max(1,i)}function tM(r,t,e){if(t<0||t>=r.length)return 0;let n=0,i=0;for(let s=t;s>=0;s-=1){const o=r[s],a=i===0?o:n+ae+o;if(a>e+Kn)break;n=a,i+=1}return Math.max(1,i)}function rM(r,t){if(r.length===0)return 0;let e=0,n=0;for(let i=r.length-1;i>=0;i-=1){const s=r[i],o=n===0?s:e+ae+s;if(o>t+Kn)break;e=o,n+=1}return Math.max(1,n)}function Qd(r,t){if(r.length===0)return 0;const e=rM(r,t);return Math.max(0,r.length-e)}function gm(r,t,e){if(r.length===0)return 0;const n=e0(r,t,e),i=Math.min(r.length,t+n);if(i<=t)return 0;const s=r.slice(t,i);return s.reduce((o,a)=>o+a,0)+Math.max(0,s.length-1)*ae}function Fh(r,t,e){const n=r[t]??0;return e-n}function ki(r,t,e,n,i){if(r.length===0)return 0;const s=Qd(r,i),o=t[s]??0,a=Math.max(0,Math.min(o,e));let c=0;for(let F=0;F<s;F+=1){const Y=t[F]??0,V=t[F+1]??Y;if(a>=Y&&a<=V+Kn){c=F;break}c=F+1}const u=Math.min(c+1,s),h=t[c]??0,f=t[u]??h,y=Math.max(f-h,Kn),m=u===c?0:(a-h)/y,E=Qw(r),x=gm(r,c,i),I=gm(r,u,i),P=(n-x)/2,R=(n-I)/2,B=Fh(E,c,P),N=Fh(E,u,R);return B+(N-B)*m}function nM(r,t,e,n,i){const s=Qd(r,n),o=t[s]??0;let a=0,c=o;for(let u=0;u<QO;u+=1){const h=(a+c)/2;ki(r,t,h,e,n)>i?a=h:c=h}return(a+c)/2}function iM(r,t,e){const n=Qw(r),[i,s]=t,o=r.slice(i,s+1),a=o.reduce((u,h)=>u+h,0)+Math.max(0,o.length-1)*ae,c=(e-a)/2;return Fh(n,i,c)}function sM(r,t,e){const n=e0(r,t,e);return[t,Math.min(r.length-1,t+n-1)]}function oM(r,t,e){const n=tM(r,t,e);return[Math.max(0,t-n+1),t]}function aM(r,t){return r[0]===t[0]&&r[1]===t[1]}function lM(r){const{nodeCols:t,nodeWidthsPx:e,viewportWidthPx:n}=r;if(t.length===0||e.length===0)return{viewspans:[],minScroll:0,maxScroll:0};const i=e.length,s=r.gapPx??ae,o=Jw(n,s),a=Xw(t),c=Qd(e,o),u=a[c]??0;function h(I){const P=iM(e,I,n),R=nM(e,a,n,o,P);return{nodeRange:I,anchor:Math.max(0,Math.min(u,R))}}const f=[];for(let I=0;I<i;){const P=sM(e,I,o);f.push(h(P)),I=P[1]+1}const y=h(oM(e,i-1,o)),m=f.filter(I=>I.nodeRange[0]<y.nodeRange[0]),E=m[m.length-1];return{viewspans:E&&aM(E.nodeRange,y.nodeRange)?m:[...m,y],minScroll:0,maxScroll:u}}function fi(r,t){var i;let e=0,n=Number.POSITIVE_INFINITY;for(let s=0;s<r.length;s+=1){const o=Math.abs((((i=r[s])==null?void 0:i.anchor)??0)-t);if(o+Lt<n){n=o,e=s;continue}Math.abs(o-n)<=Lt&&s<e&&(e=s)}return e}function cM(r,t,e){return e<=0?0:Math.max(0,Math.min(e-1,r+t))}function fn(r,t,e){return Math.max(t,Math.min(e,r))}function uM(r,t){var e;for(let n=0;n<r.length;n+=1)if(Math.abs((((e=r[n])==null?void 0:e.anchor)??0)-t)<=Lt)return n;return-1}function hM(r,t,e){var i,s;if(r.length===0)return t;const n=uM(r,t);if(n>=0){const o=r[n+e];return(o==null?void 0:o.anchor)??r[e>0?r.length-1:0].anchor}if(e>0){for(const o of r)if(o.anchor>t+Lt)return o.anchor;return((i=r[r.length-1])==null?void 0:i.anchor)??t}for(let o=r.length-1;o>=0;o-=1){const a=r[o];if(a&&a.anchor<t-Lt)return a.anchor}return((s=r[0])==null?void 0:s.anchor)??t}class dM extends Ot{constructor(e){super();g(this,"_scroll",0);g(this,"_minScroll",0);g(this,"_maxScroll",0);g(this,"_viewspans",[]);g(this,"_activeViewspanIndex",0);g(this,"_nodeWidthsPx",[]);g(this,"_boundaryCols",[0]);g(this,"_viewportWidthPx",0);g(this,"_framedViewportWidthPx",0);this._scroll=(e==null?void 0:e.x)??0}get scroll(){return Te({x:this._scroll})}get translate(){return Ie({x:ki(this._nodeWidthsPx,this._boundaryCols,this._scroll,this._viewportWidthPx,this._framedViewportWidthPx)})}get activeViewspan(){return this._viewspans[this._activeViewspanIndex]??null}get viewspans(){return this._viewspans}set scroll(e){const n=fn(e.x??this._scroll,this._minScroll,this._maxScroll);Math.abs(n-this._scroll)<=Lt||(this._scroll=n,this._activeViewspanIndex=fi(this._viewspans,this._scroll),this.dispatchEvent(new pi("layout-scroll",{scroll:this.scroll})))}rebuild(e){var y;const n=e.nodeWidths.map(m=>Math.max(0,m.x??0)),i=n.map(m=>e.grid.toPixels(Te({x:m})).x??0),s=e.grid.viewport.x??0,o=e.grid.gap.x??ae,a=lM({nodeCols:n,nodeWidthsPx:i,viewportWidthPx:s,gapPx:o});this._nodeWidthsPx=i,this._boundaryCols=Xw(n),this._viewportWidthPx=s,this._framedViewportWidthPx=Jw(s,o),this._viewspans=a.viewspans,this._minScroll=a.minScroll,this._maxScroll=a.maxScroll;const c=fn(this._scroll,this._minScroll,this._maxScroll);this._activeViewspanIndex=fi(this._viewspans,c);const h=e.snap!==!1?((y=this._viewspans[this._activeViewspanIndex])==null?void 0:y.anchor)??c:c,f=fn(h,this._minScroll,this._maxScroll);Math.abs(f-this._scroll)>Lt&&(this._scroll=f,this.dispatchEvent(new pi("layout-scroll",{scroll:this.scroll})))}step(e){var o;if(this._viewspans.length===0)return;const n=cM(this._activeViewspanIndex,e,this._viewspans.length),i=((o=this._viewspans[n])==null?void 0:o.anchor)??this._scroll,s=fn(i,this._minScroll,this._maxScroll);this._activeViewspanIndex=n,!(Math.abs(s-this._scroll)<=Lt)&&(this._scroll=s,this.dispatchEvent(new pi("layout-scroll",{scroll:this.scroll})))}snap(e){var s;if(this._viewspans.length===0)return;const n=e===void 0?((s=this._viewspans[fi(this._viewspans,this._scroll)])==null?void 0:s.anchor)??this._scroll:hM(this._viewspans,this._scroll,e),i=fn(n,this._minScroll,this._maxScroll);this._activeViewspanIndex=fi(this._viewspans,i),!(Math.abs(i-this._scroll)<=Lt)&&(this._scroll=i,this.dispatchEvent(new pi("layout-scroll",{scroll:this.scroll})))}wheel(e){const n=fn(this._scroll+(e.x??0),this._minScroll,this._maxScroll);Math.abs(n-this._scroll)<=Lt||(this._scroll=n,this._activeViewspanIndex=fi(this._viewspans,this._scroll),this.dispatchEvent(new pi("layout-scroll",{scroll:this.scroll})))}wheelPixels(e){const n=e.x??0;if(Math.abs(n)<=Kn)return;const i=ki(this._nodeWidthsPx,this._boundaryCols,this._scroll,this._viewportWidthPx,this._framedViewportWidthPx),s=i-n,o=ki(this._nodeWidthsPx,this._boundaryCols,this._maxScroll,this._viewportWidthPx,this._framedViewportWidthPx),a=ki(this._nodeWidthsPx,this._boundaryCols,this._minScroll,this._viewportWidthPx,this._framedViewportWidthPx),c=Math.max(o,Math.min(a,s));if(Math.abs(c-i)<=Kn)return;let u=this._minScroll,h=this._maxScroll;for(let y=0;y<eM;y+=1){const m=(u+h)/2;ki(this._nodeWidthsPx,this._boundaryCols,m,this._viewportWidthPx,this._framedViewportWidthPx)>c?u=m:h=m}const f=fn((u+h)/2,this._minScroll,this._maxScroll);Math.abs(f-this._scroll)<=Lt||(this._scroll=f,this._activeViewspanIndex=fi(this._viewspans,this._scroll),this.dispatchEvent(new pi("layout-scroll",{scroll:this.scroll})))}}const Iu={"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}},pM=["stack-above","stack-below","reorder-before","reorder-after"];function Cu(r,t){return{left:r.left+r.width*t.left,top:r.top+r.height*t.top,width:r.width*t.width,height:r.height*t.height}}function gn(r,t,e){return r>=e.left&&r<e.left+e.width&&t>=e.top&&t<e.top+e.height}function Pi(r){return r.artifactID}function Hh(r){return Number.isFinite(r)?Math.max(ao,Math.min(Od,Math.round(r))):ao}function fM(r,t,e){const n=r.findIndex(a=>a.type==="card"&&Pi(a)===t);if(n===-1)return r;const i=r[n];if(!i||i.type!=="card")return r;const s=Hh(e);if(i.width===s)return r;const o=[...r];return o[n]={...i,width:s},o}function t0(r,t){for(const e of r){if(e.type==="card"&&Pi(e)===t)return e;if(e.type==="stack")for(const n of e.children){if(n.type==="card"&&Pi(n)===t)return n;if(n.type==="row"){for(const i of n.children)if(Pi(i)===t)return i}}}return null}function Zh(r){const t=r.height===ft||r.height===Xr?Xr:r.height;return r.width===qe&&r.height===t?r:{...r,width:qe,height:t}}function Wh(r){return r.height===Xr?{...r,height:ft}:r}function gM(r,t,e,n){const i=r.findIndex(h=>h.type==="stack"&&h.id===t);if(i===-1)return r;const s=r[i];if(!s||s.type!=="stack")return r;const o=s.children.find(h=>h.type==="card"&&Pi(h)===e);if(!o||o.type!=="card")return r;const a=s.children.filter(h=>h.type!=="card"||Pi(h)!==e);if(a.length===s.children.length||a.length<1)return r;const c=[...r];if(a.length===1){const[h]=a;c[i]=h.type==="card"?Wh(h):h}else c[i]={...s,children:a};const u=Math.max(0,Math.min(n,c.length));return c.splice(u,0,Wh(o)),c}const mM=je(),vM=je(),yM=50;function bM(r,t){if(r.type!==t.type)return!1;switch(r.type){case"reorder":return t.index===r.index;case"stack":return t.targetCardId===r.targetCardId&&t.position===r.position;case"stack-child-noop":return!0;case"stack-child-extract":return t.toIndex===r.toIndex;case"stack-child-reorder":return t.position===r.position;default:return!1}}function Qe(r){return r.artifactID}function mm(r){return r.type==="card"?Qe(r):r.id}function ka(r){return{id:Qe(r),type:"drop-target",width:r.width,height:r.height}}function vm(r){return r.map(SM)}function wM(r){return r.type==="drop-target"?{type:"card",artifactID:r.id,width:r.width,height:r.height}:r}function SM(r){return r.type==="drop-target"?{type:"card",artifactID:r.id,width:r.width,height:r.height}:r.type==="stack"?{...r,children:r.children.map(wM)}:r}function r0(r,t){return r.find(n=>n.type==="card"&&Qe(n)===t)??null}function ym(r,t){return r.find(n=>n.type==="stack"&&n.id===t)??null}function _M(r,t){const e=[...t],n=e.findIndex(a=>a.type==="card"&&Qe(a)===r.nodeId);if(n===-1)return null;const i=e[n];if(!i||i.type!=="card")return null;e.splice(n,1);const s=Math.max(0,Math.min(r.lastReorderIndex,e.length));e.splice(s,0,i);const o=e.findIndex(a=>a.type==="card"&&Qe(a)===r.nodeId);return o===-1?null:{base:e,visualDraggedIndex:o}}function kM(r,t,e,n){const i=[...r.base];i.splice(r.visualDraggedIndex,1);const s=i.findIndex(y=>y.type==="card"&&Qe(y)===e.targetCardId),o=s===-1?null:i[s];if(!o||o.type!=="card")return null;const a=r0(n,t.nodeId);if(!a)return null;const c=Zh(a),u=Zh(o),h=ka(c),f=e.position==="above"?[h,u]:[u,h];return i[s]={id:Qe(o),type:"stack",children:f},i}function Ru(r,t){return r.parentStackId?EM(r,t):xM(r,t)}function xM(r,t){const e=r.hitTarget;if(e.type==="reorder"){const n=t[r.sourceIndex];if(!n||n.type!=="card")return[...t];const i=[...t];return i.splice(r.sourceIndex,1),i.splice(e.index,0,ka(n)),i}if(e.type==="stack"){const n=_M(r,t);return n?kM(n,r,e,t)??[...t]:[...t]}return[...t]}function EM(r,t){const e=r.hitTarget;switch(e.type){case"stack-child-reorder":return AM(r,t,e.position);case"stack-child-extract":return $M(r,t,e.toIndex);case"stack-child-noop":return TM(r,t);default:return[...t]}}function AM(r,t,e){const n=t.findIndex(y=>y.type==="stack"&&y.id===r.parentStackId);if(n===-1)return[...t];const i=t[n];if(!i||i.type!=="stack")return[...t];if(!i.children.every(y=>y.type==="card"))return[...t];const s=i.children,o=s.findIndex(y=>Qe(y)===r.nodeId);if(o===-1)return[...t];const a=s[o],c=s.filter(y=>Qe(y)!==r.nodeId),u=ka(a),h=e==="above"?[u,...c]:[...c,u],f=[...t];return f[n]={...i,children:h},f}function $M(r,t,e){if(!r.parentStackId)return[...t];const n=gM(t,r.parentStackId,r.nodeId,e);if(n===t)return[...t];const i=n.findIndex(a=>a.type==="card"&&Qe(a)===r.nodeId);if(i===-1)return[...t];const s=n[i];if(!s||s.type!=="card")return[...t];const o=[...n];return o[i]=ka(s),o}function TM(r,t){const e=t.findIndex(c=>c.type==="stack"&&c.id===r.parentStackId);if(e===-1)return[...t];const n=t[e];if(!n||n.type!=="stack")return[...t];const i=n.children.findIndex(c=>c.type==="card"&&Qe(c)===r.nodeId);if(i===-1)return[...t];const s=n.children[i];if(!s||s.type!=="card")return[...t];const o=[...t],a=[...n.children];return a[i]=ka(s),o[e]={...n,children:a},o}function IM(r,t){return t.find(n=>n.type==="stack"&&n.id===r.id)?r.id:Ud()}function CM(r,t,e){if(r.type==="drop-target"){const n=t0(t,e);if(!n)throw new Error(`finalize: missing dragged card ${e}`);return Zh(n)}return r}function RM(r,t,e){const n=r.children.map(s=>CM(s,t,e));return{id:IM(r,t),type:"stack",children:n}}function PM(r,t,e){if(r.type==="drop-target"){const n=t0(t,e);if(!n)throw new Error(`finalize: missing dragged card ${e}`);return r0(t,e)!==null?n:Wh(n)}return r.type==="card"||r.type==="row"?r:RM(r,t,e)}function LM(r,t,e){return r.map(n=>PM(n,t,e))}function DM(r,t){return JSON.stringify(r)===JSON.stringify(t)}const zM=Sa(Ot);class OM extends zM{constructor(e={}){super();g(this,"pending",null);g(this,"active",null)}start(e){if(this.pending||this.active)return;const n=e.pointer.x??0,i=e.pointer.y??0;this.pending={startX:n,startY:i,grabOffsetX:e.grabOffset.x??0,grabOffsetY:e.grabOffset.y??0,nodeId:e.nodeId,sourceIndex:e.source.index,parentStackId:e.source.parentId,width:e.size.x??0,height:e.size.y??0,baseLayout:e.layout}}update(e){const n=e.pointer.x??0,i=e.pointer.y??0,s=this.pending;if(s){const u=n-s.startX,h=i-s.startY;Math.hypot(u,h)>=i$&&(this.pending=null,this.active={...s,pointerX:n,pointerY:i,hitTarget:{type:"reorder",index:s.sourceIndex},lastReorderIndex:s.sourceIndex},this.emitDrag(),this.dispatchEvent(new oe("change")));return}if(!this.active)return;const o=Ru(this.active,this.active.baseLayout),a=this.getHitTargetForPointer(n,i,e,o),c=a.type==="reorder"?a.index:this.active.lastReorderIndex;this.active.pointerX===n&&this.active.pointerY===i&&bM(this.active.hitTarget,a)&&this.active.lastReorderIndex===c||(this.active={...this.active,pointerX:n,pointerY:i,hitTarget:a,lastReorderIndex:c},this.emitDrag(),this.dispatchEvent(new oe("change")))}drop(){if(this.pending){this.cancel();return}if(!this.active)return;const e=this.active.baseLayout;let n=null;try{const i=Ru(this.active,e),s=LM(i,e,this.active.nodeId);DM(s,e)||(n=s)}catch{n=null}this.reset(),n&&this.dispatchEvent(new vM("drop",{layout:n})),this.dispatchEvent(new oe("change"))}cancel(){!this.pending&&!this.active||(this.reset(),this.dispatchEvent(new oe("change")))}dispose(){this.reset()}get status(){return this.active?"active":this.pending?"pending":"idle"}reset(){this.pending=null,this.active=null}emitDrag(){if(!this.active)return;const e=Ru(this.active,this.active.baseLayout);this.dispatchEvent(new mM("drag",{nodeId:this.active.nodeId,source:{index:this.active.sourceIndex,parentId:this.active.parentStackId},grabOffset:Ie({x:this.active.grabOffsetX,y:this.active.grabOffsetY}),pointer:Ie({x:this.active.pointerX,y:this.active.pointerY}),size:Ie({x:this.active.width,y:this.active.height}),projectedLayout:e}))}getHitTargetForPointer(e,n,i,s){return this.active?this.isPointerInsideDragBounds(e,n,i.viewport)?this.active.parentStackId?this.getStackChildHitTarget(e,n,i,s):this.getTopLevelCardHitTarget(e,n,i,s):{type:"reorder",index:this.active.sourceIndex}:{type:"reorder",index:0}}getStackChildHitTarget(e,n,i,s){var u;if(!((u=this.active)!=null&&u.parentStackId))return{type:"stack-child-noop"};const o=this.getSourceStackInteractionRect(i.geometry);if(o&&gn(e,n,o)){const h=o.top+o.height/2;return{type:"stack-child-reorder",position:n<h?"above":"below"}}const a=this.getSourceRemainingSiblingRect(i.geometry);if(a&&gn(e,n,a)){const h=a.top+a.height/2;return{type:"stack-child-reorder",position:n<h?"above":"below"}}return{type:"stack-child-extract",toIndex:this.getTopLevelReorderIndexForPointer(e,n,i,s)}}getSourceRemainingSiblingRect(e){var s,o;if(!((s=this.active)!=null&&s.parentStackId))return;const n=ym(this.active.baseLayout,this.active.parentStackId);if(!n)return;const i=n.children.find(a=>{var c;return a.type==="card"&&Qe(a)!==((c=this.active)==null?void 0:c.nodeId)});if(i)return(o=e.find(a=>a.id===Qe(i)))==null?void 0:o.rect}getSourceStackInteractionRect(e){var o;if(!((o=this.active)!=null&&o.parentStackId))return;const n=e.find(a=>{var c;return a.id===((c=this.active)==null?void 0:c.parentStackId)});if(n)return this.active.sourceStackRect=n.rect,n.rect;const i=ym(this.active.baseLayout,this.active.parentStackId);if(!i)return this.active.sourceStackRect;const s=i.children.find(a=>{var c;return a.type==="card"&&Qe(a)!==((c=this.active)==null?void 0:c.nodeId)});if(s){const a=e.find(c=>c.id===Qe(s));if(a)return a.rect}return this.active.sourceStackRect}getTopLevelCardHitTarget(e,n,i,s){var m,E,x;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)<=yM;for(const I of o){const P=I.rect;if(!gn(e,n,P))continue;const R=this.resolveTopLevelTargetForCard(e,n,I,I.logicalIndex,c);if(R)return R;if(!c&&((E=this.active)!=null&&E.hitTarget))return this.active.hitTarget.type==="reorder"?this.active.hitTarget:this.active.hitTarget.type==="stack"&&this.active.hitTarget.targetCardId===I.id?this.active.hitTarget:{type:"reorder",index:e<this.active.pointerX?I.logicalIndex:I.logicalIndex+1}}const u=this.getNearestTargetableZone(e,o);if(!u)return{type:"reorder",index:((x=this.active)==null?void 0:x.sourceIndex)??0};const h=Math.max(u.rect.left,Math.min(u.rect.left+u.rect.width,e)),f=this.resolveTopLevelTargetForCard(h,n,u,u.logicalIndex,c);if(f)return f;const y=u.rect.left+u.rect.width/2;return{type:"reorder",index:e<y?u.logicalIndex:u.logicalIndex+1}}getTopLevelReorderIndexForPointer(e,n,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 f of o){if(!gn(e,n,f.rect))continue;const y=Cu(f.rect,Iu["reorder-before"]);if(gn(e,n,y))return f.logicalIndex;const m=Cu(f.rect,Iu["reorder-after"]);if(gn(e,n,m))return f.logicalIndex+1}const a=this.getNearestTargetableZone(e,o);if(!a)return((h=this.active)==null?void 0:h.sourceIndex)??0;const c=a.rect.left+a.rect.width/2;return e<c?a.logicalIndex:a.logicalIndex+1}getTopLevelZoneNodes(e,n){const i=new Map(n.map(a=>[mm(a),a])),s=[];let o=0;for(const a of e){const c=i.get(a.id);c&&c.type!=="drop-target"&&(c.type==="card"||c.type==="stack")&&(s.push({id:mm(c),rect:a.rect,logicalIndex:o}),o+=1)}return s}resolveTopLevelTargetForCard(e,n,i,s,o){const a=i.rect;for(const c of pM){if(!o&&(c==="stack-above"||c==="stack-below"))continue;const u=Iu[c],h=Cu(a,u);if(gn(e,n,h))return c==="stack-above"?{type:"stack",targetCardId:i.id,position:"above"}:c==="stack-below"?{type:"stack",targetCardId:i.id,position:"below"}:c==="reorder-before"?{type:"reorder",index:s}:{type:"reorder",index:s+1}}return null}getNearestTargetableZone(e,n){let i=null,s=Number.POSITIVE_INFINITY;for(const o of n){const a=o.rect.left,c=o.rect.left+o.rect.width,u=e<a?a-e:e>c?e-c:0;u<s&&(s=u,i=o)}return i}isPointerInsideDragBounds(e,n,i){return e>=i.left&&e<=i.left+i.width&&n>=i.top&&n<=i.top+i.height}}const MM=100,NM=1e3;class UM{constructor(t,e){g(this,"_status","idle");g(this,"cumulativeOffset",0);g(this,"samples",[]);g(this,"scroll");g(this,"setAnimating");this.scroll=t,this.setAnimating=e}get status(){return this._status}start(t){this._status="active",this.cumulativeOffset=0,this.samples=[{time:t,offset:0}]}move(t,e){this._status==="active"&&(this.cumulativeOffset+=e,this.samples.push({time:t,offset:this.cumulativeOffset}),this.pruneSamples(t),this.setAnimating(!1),this.scroll.wheelPixels(Ie({x:-e})))}end(){if(this._status!=="active")return;const t=this.computeVelocityPxPerSec();this.setAnimating(!0),Math.abs(t)<o$?this.scroll.snap():this.scroll.snap(t>0?-1:1),this.reset()}cancel(){this._status==="active"&&(this.setAnimating(!0),this.scroll.snap(),this.reset())}reset(){this._status="idle",this.cumulativeOffset=0,this.samples=[]}pruneSamples(t){const e=t-MM;let n=0;for(let i=0;i<this.samples.length;i+=1){if(this.samples[i].time>=e){n=i;break}n=i+1}if(n>0){const i=Math.max(0,n-1);this.samples=this.samples.slice(i)}}computeVelocityPxPerSec(){if(this.samples.length<2)return 0;const t=this.samples[0],e=this.samples[this.samples.length-1],n=e.time-t.time;return n<=0?0:(e.offset-t.offset)/n*NM}}function Ii(r){return r.artifactID}function FM(r){return r.type==="card"?Ii(r):r.id}function HM({baseLayout:r,visibleLayout:t,resolved:e,cardsByID:n,grid:i,dragState:s,isForeground:o}){var E;const a=new Map(t.map(x=>[FM(x),x])),c=e.nodes.map((x,I)=>{const P=a.get(x.id),R=[];for(const N of x.cards){if(s&&N.artifactID===s.nodeId){R.push({key:`placeholder:${N.artifactID}`,kind:"placeholder",card:null,placement:N,isTopLevelCard:!1,isDragged:!1,sourceStackId:s.source.parentId??null});continue}const F=n.get(N.artifactID);F&&R.push({key:Ii(F),kind:"card",card:F,placement:N,isTopLevelCard:(P==null?void 0:P.type)==="card",isDragged:!1,sourceStackId:null})}if(s!=null&&s.source.parentId&&x.id===s.source.parentId){const N=n.get(s.nodeId);if(N){const F={key:Ii(N),kind:"card",card:N,placement:null,isTopLevelCard:!1,isDragged:!0,sourceStackId:s.source.parentId},Y=ZM(r,s.source.parentId,s.nodeId),V=Y<0?R.length:Math.min(Y,R.length);R.splice(V,0,F)}}const B=!!(s&&(P==null?void 0:P.type)==="card"&&Ii(P)===s.nodeId);return{key:B?`placeholder:${x.id}`:x.id,kind:"visible",nodeId:x.id,widthPx:i.toPixels(Te({x:x.width})).x??0,widthUnits:x.width,layoutIndex:I,isForeground:o(I),isPlaceholder:B,slots:R}});if(!s||s.source.parentId&&a.has(s.source.parentId))return c;const u=n.get(s.nodeId);if(!u)return c;const h=s.source.parentId??s.nodeId,f=((E=kn(r).nodes[s.source.index])==null?void 0:E.width)??qe,y={key:h,kind:"ghost",nodeId:h,widthPx:0,widthUnits:f,layoutIndex:null,isForeground:!1,isPlaceholder:!1,slots:[{key:Ii(u),kind:"card",card:u,placement:null,isTopLevelCard:!s.source.parentId,isDragged:!0,sourceStackId:s.source.parentId??null}]},m=Math.max(0,Math.min(s.source.index,c.length));return c.splice(m,0,y),c}function bm(r){if(!r)return null;const t=r.projectedLayout,e=r.source.parentId;for(const i of t){if(i.type!=="stack")continue;const s=i.children.findIndex(u=>u.type==="drop-target");if(s===-1)continue;const o=s===0?"above":"below";if(e&&e===i.id)return`stack-child-reorder:${o}`;const a=i.children.find(u=>u.type!=="drop-target");return`stack:${(a==null?void 0:a.type)==="card"?a.artifactID:(a==null?void 0:a.id)??""}:${o}`}const n=t.findIndex(i=>i.type==="drop-target");return n===-1?"none":e?`stack-child-extract:${n}`:`reorder:${n}`}function ZM(r,t,e){const n=r.find(i=>i.type==="stack"&&i.id===t);return!n||n.type!=="stack"?-1:n.children.findIndex(i=>i.type==="card"&&Ii(i)===e)}const WM=2,wm=1e3,gi=1e-4,BM=120,Sm=!1;function _m(r){return r.replace(/["\\]/g,"\\$&")}function we(r){return r.artifactID}function Li(r){return r.type==="card"?we(r):r.id}function km(r,t,e){if(r===0)return 0;const n=t.toPixels(Te({y:ft})).y??0;return(e-n)/WM}function Pu(r){const t=r.clientWidth>0?r.clientWidth:Vn,e=r.clientHeight>0?r.clientHeight:lo;let n=0,i=0;if(r.isConnected){const u=getComputedStyle(r);n=parseFloat(u.paddingTop)||0,i=parseFloat(u.paddingBottom)||0}const s=Math.max(1,e-n-i),o=r.isConnected&&parseFloat(getComputedStyle(r).getPropertyValue("--layout-virtual-bottom-balance"))||0,a=lo+ae*2,c=Math.min(o,Math.max(0,s-a));return{width:t,height:s-c,offsetY:n}}function jM(r){return r.shiftKey&&r.deltaX===0&&r.deltaY!==0?r.deltaY:r.deltaX}function VM(r){var e;if(!(r instanceof Element))return!1;const t=r.closest("input, textarea, select, [contenteditable], [role='textbox'], [role='searchbox'], [role='combobox'], [role='spinbutton'], [role='slider']");return t?t.hasAttribute("contenteditable")?((e=t.getAttribute("contenteditable"))==null?void 0:e.toLowerCase())!=="false":!0:!1}class GM extends Event{constructor(e){super("scroll",{bubbles:!0,composed:!0});g(this,"scrollPosition");this.scrollPosition=e}}class n0 extends Event{constructor(e){super("layout-change",{bubbles:!0,composed:!0});g(this,"layout");this.layout=e}}class qM extends HTMLElement{constructor(){super();g(this,"_layout",[]);g(this,"_scrollPosition",0);g(this,"layoutGrid",null);g(this,"layoutScroll",new dM(Te({x:0})));g(this,"scrollModelKey","");g(this,"resizeObserver",null);g(this,"renderPending",!1);g(this,"animateNextRender",!0);g(this,"swipeGesture",new UM(this.layoutScroll,e=>{this.animateNextRender=e}));g(this,"swipePointerId",null);g(this,"swipeStartX",0);g(this,"swipeStartY",0);g(this,"swipeLastX",0);g(this,"swipeActive",!1);g(this,"swipeShouldSuppressClick",!1);g(this,"swipeListenersAttached",!1);g(this,"wheelIdleSnapTimer",null);g(this,"dragController",new OM);g(this,"dragState",null);g(this,"activeDragPointerId",null);g(this,"dragListenersAttached",!1);g(this,"dragFrame",0);g(this,"lastDragFrameTime",0);g(this,"lastPointerX",0);g(this,"lastPointerY",0);g(this,"pointerVelocityPxPerSec",0);g(this,"scrollVelocityPxPerSec",0);g(this,"motionSampleTime",0);g(this,"motionSampleX",0);g(this,"motionSampleY",0);g(this,"lastDragControllerStatus","idle");g(this,"lastProjectedDragLayoutSignature","");g(this,"lastDragDropIntent",null);g(this,"lastActivePlaceholderId",null);g(this,"draggedSlotElement",null);g(this,"draggedSlotContainingBlock",null);g(this,"currentDragPreviewSize",null);g(this,"dragTrackOffsetXPx",0);g(this,"previousProjectedLayoutForOffset",null);g(this,"resizeState",null);g(this,"resizeListenersAttached",!1);g(this,"_cards",new Map);g(this,"onDragControllerChange",()=>{const e=this.dragController.status;e!==this.lastDragControllerStatus&&(this.lastDragControllerStatus=e,e==="idle"&&(this.dragState=null,this.resetDragPreviewState()),this.scheduleRender())});g(this,"onDragControllerDrag",e=>{var c;const n=JSON.stringify(e.projectedLayout),i=bm(e),s=KM(e.projectedLayout);if(n!==this.lastProjectedDragLayoutSignature||i!==this.lastDragDropIntent||s!==this.lastActivePlaceholderId){const u=vm(e.projectedLayout),h=this.shouldApplyTrackOffset(e.projectedLayout,e.source.parentId),f=e.source.parentId?this.getStackChildAnchorCardId(e.source.parentId,e.nodeId):null;this.dragTrackOffsetXPx=h?this.computeDragTrackOffset(this.previousProjectedLayoutForOffset,u,e.nodeId,e.source.parentId,f,this.dragTrackOffsetXPx):0,this.previousProjectedLayoutForOffset=u,this.lastProjectedDragLayoutSignature=n,this.lastDragDropIntent=i,this.lastActivePlaceholderId=s,this.dragState={nodeId:e.nodeId,source:e.source,grabOffset:e.grabOffset,pointer:e.pointer,size:e.size,projectedLayout:e.projectedLayout},this.scheduleRender();return}this.dragState={nodeId:e.nodeId,source:e.source,grabOffset:e.grabOffset,pointer:e.pointer,size:e.size,projectedLayout:((c=this.dragState)==null?void 0:c.projectedLayout)??e.projectedLayout};const a=this.getCachedDraggedSlotElement(e.nodeId);a&&this.writeDraggedSlotPosition(a,this.dragState)});g(this,"onDragControllerDrop",e=>{this.dragState=null,this.resetDragPreviewState(),this.commitLayout(e.layout)});g(this,"onLayoutScrollInternal",e=>{const i=e.scroll.x??0;Math.abs(i-this._scrollPosition)<gi||(this._scrollPosition=i,this.emitScrollPositionChanged(i),this.scheduleRender())});g(this,"handleKeyDown",e=>{if(e.key==="Escape"&&this.dragController.status!=="idle"){e.preventDefault(),this.stopDragFrameLoop(),this.releaseActiveDragPointerCapture(),this.dragController.cancel(),this.detachDragListeners();return}this.dragController.status==="idle"&&(VM(e.target)||(e.key==="ArrowRight"?(e.preventDefault(),this.stepFilmstrip(1)):e.key==="ArrowLeft"&&(e.preventDefault(),this.stepFilmstrip(-1))))});g(this,"handleWheel",e=>{if(this._layout.length===0)return;const n=jM(e);Math.abs(n)<gi||(e.preventDefault(),this.applyHorizontalWheel(n))});g(this,"handleWindowMessage",e=>{if(this._layout.length===0)return;const n=this.findManagedArtifactFrame(e.source);if(n&&this.isTrustedArtifactFrameMessage(e,n)){if(iS(e.data)){const i=typeof performance<"u"?performance.now():Date.now();this.swipeGesture.status==="idle"&&this.swipeGesture.start(i),this.swipeGesture.move(i,e.data.deltaX);return}if(sS(e.data)){this.swipeGesture.status==="active"&&this.swipeGesture.end();return}}});g(this,"handleArtifactFilmstripKey",e=>{this._layout.length!==0&&this.stepFilmstrip(e.direction)});g(this,"handleArtifactWheel",e=>{this._layout.length!==0&&(Math.abs(e.deltaX)<gi||this.applyHorizontalWheel(e.deltaX))});g(this,"handlePointerDown",e=>{if(e.button!==0||this.dragController.status!=="idle"||this.resizeState)return;const n=e.target;if(!(n instanceof Element))return;const i=n.closest("[data-resize-handle]");if(i){this.beginResize(e,i);return}const s=n.closest("[drag-handle]")!==null,o=n.closest("button, input, textarea, select, a, [role='button']")!==null;if(e.pointerType==="touch"&&!s&&!o&&this._layout.length>0){this.beginSwipeTracking(e);return}if(!s){if(!o){const f=n.closest(".node");if(f&&!f.hasAttribute("data-foreground")){const y=f.getAttribute("layout-node");if(y!==null){const m=parseInt(y,10);if(!isNaN(m)){const E=this.findViewspanContainingNode(m);if(E){this.clearWheelIdleSnap(),this.animateNextRender=!0,this.layoutScroll.scroll=Te({x:E.anchor}),e.preventDefault(),e.stopPropagation();return}}}}}return}if(o)return;const a=n.closest(".card-slot");if(!a)return;const c=a.getAttribute("data-layout-card-id");if(!c)return;const u=JM(this._layout,c);if(!u)return;const h=a.getBoundingClientRect();this.lastPointerX=e.clientX,this.lastPointerY=e.clientY,this.resetMotionTracking(e.clientX,e.clientY),this.focus(),this.dragController.start({nodeId:c,source:{index:u.topLevelIndex,parentId:u.sourceStackId},pointer:Ie({x:e.clientX,y:e.clientY}),grabOffset:Ie({x:e.clientX-h.left,y:e.clientY-h.top}),size:Ie({x:h.width,y:h.height}),layout:this._layout}),this.attachDragListeners(),this.activeDragPointerId=e.pointerId;try{this.setPointerCapture(e.pointerId)}catch{}e.preventDefault()});g(this,"handleResizePointerMove",e=>{const n=this.resizeState;if(!n||e.pointerId!==n.pointerId)return;const i=this.layoutGrid,s=((i==null?void 0:i.unit.x)??Or)+ae;if(s<=0)return;const o=e.clientX-n.startClientX,a=Hh(n.startWidth+o/s);a!==n.currentWidth&&(n.currentWidth=a,this.scheduleRender())});g(this,"handleResizePointerUp",e=>{const n=this.resizeState;if(!n||e.pointerId!==n.pointerId)return;const i=n.currentWidth,s=n.startWidth,o=n.cardId;this.endResize(e.pointerId),i!==s?this.commitLayout(fM(this._layout,o,i)):this.scheduleRender()});g(this,"handleResizePointerCancel",e=>{!this.resizeState||e.pointerId!==this.resizeState.pointerId||(this.endResize(e.pointerId),this.scheduleRender())});g(this,"handleResizeWindowBlur",()=>{this.resizeState&&(this.endResize(this.resizeState.pointerId),this.scheduleRender())});g(this,"handleResizeKeyDown",e=>{this.resizeState&&e.key==="Escape"&&(e.preventDefault(),this.endResize(this.resizeState.pointerId),this.scheduleRender())});g(this,"handleSwipePointerMove",e=>{if(this.swipePointerId===null||e.pointerId!==this.swipePointerId)return;if(!this.swipeActive){const i=e.clientX-this.swipeStartX,s=e.clientY-this.swipeStartY,o=Math.abs(i),a=Math.abs(s);if(o<Sg&&a<Sg)return;if(a>=o){this.endSwipeTracking();return}this.swipeActive=!0,this.swipeShouldSuppressClick=!0;try{this.setPointerCapture(e.pointerId)}catch{}this.swipeGesture.start(e.timeStamp)}const n=e.clientX-this.swipeLastX;this.swipeLastX=e.clientX,this.swipeGesture.move(e.timeStamp,n),e.preventDefault()});g(this,"handleSwipePointerUp",e=>{this.swipePointerId===null||e.pointerId!==this.swipePointerId||(this.swipeActive&&this.swipeGesture.end(),this.releaseSwipePointerCapture(e.pointerId),this.endSwipeTracking())});g(this,"handleSwipePointerCancel",e=>{this.swipePointerId===null||e.pointerId!==this.swipePointerId||(this.swipeActive&&this.swipeGesture.cancel(),this.releaseSwipePointerCapture(e.pointerId),this.endSwipeTracking())});g(this,"handleSwipeWindowBlur",()=>{this.swipePointerId!==null&&this.swipeActive&&this.swipeGesture.cancel(),this.swipePointerId!==null&&this.releaseSwipePointerCapture(this.swipePointerId),this.endSwipeTracking()});g(this,"handleSwipeClick",e=>{this.swipeShouldSuppressClick&&(this.swipeShouldSuppressClick=!1,e.preventDefault(),e.stopPropagation(),typeof e.stopImmediatePropagation=="function"&&e.stopImmediatePropagation())});g(this,"handleWindowPointerMove",e=>{this.activeDragPointerId!==null&&e.pointerId!==this.activeDragPointerId||(this.lastPointerX=e.clientX,this.lastPointerY=e.clientY,this.updatePointerVelocity(e.clientX,e.clientY),this.syncDragTargetForLatestPointer(),this.ensureDragFrameLoop())});g(this,"handleWindowPointerUp",e=>{this.activeDragPointerId!==null&&e.pointerId!==this.activeDragPointerId||(this.stopDragFrameLoop(),this.releasePointerCaptureForEvent(e.pointerId),this.dragController.drop(),this.clearMotionTracking(),this.detachDragListeners())});g(this,"handleWindowPointerCancel",e=>{if(!(this.activeDragPointerId!==null&&e.pointerId!==this.activeDragPointerId)){if(this.dragController.status==="active"){this.ensureDragFrameLoop();return}this.stopDragFrameLoop(),this.releasePointerCaptureForEvent(e.pointerId),this.dragController.cancel(),this.clearMotionTracking(),this.detachDragListeners()}});g(this,"handleWindowBlur",()=>{this.releaseActiveDragPointerCapture(),this.stopDragFrameLoop(),this.dragController.cancel(),this.clearMotionTracking(),this.detachDragListeners()});g(this,"runDragFrame",e=>{if(this.dragController.status==="idle"){this.dragFrame=0;return}const n=Math.max(0,e-this.lastDragFrameTime)/wm;this.lastDragFrameTime=e,this.samplePointerVelocityAt(e,this.lastPointerX,this.lastPointerY);const i=this.getBoundingClientRect(),s=this.clampPointerToViewport(this.lastPointerX,this.lastPointerY,i),o=this.getDragEdgeScrollDeltaPixels(s.x,i,n);this.scrollVelocityPxPerSec=n>gi?Math.abs(o)/n:0,Math.abs(o)>gi&&(this.animateNextRender=!1,this.layoutScroll.wheelPixels(Ie({x:o}))),this.dragController.status==="active"&&this.syncDragTarget(s.x,s.y,i),this.dragFrame=requestAnimationFrame(this.runDragFrame)});this.dragController.addEventListener("change",this.onDragControllerChange),this.dragController.addEventListener("drag",this.onDragControllerDrag),this.dragController.addEventListener("drop",this.onDragControllerDrop),this.layoutScroll.addEventListener("layout-scroll",this.onLayoutScrollInternal)}set cards(e){this._cards!==e&&(this._cards=e,this.scheduleRender())}get cards(){return this._cards}set layout(e){const n=[...e];this.dragController.status!=="idle"&&JSON.stringify(n)===JSON.stringify(this._layout)||(this._layout=n,this.stopDragFrameLoop(),this.dragController.cancel(),this.resizeState&&this.endResize(this.resizeState.pointerId),this.scrollModelKey="",this.syncScrollModel(),this.layoutScroll.scroll=Te({x:this._scrollPosition}),this.scheduleRender())}get layout(){return this._layout}commitLayout(e){this.layout=e,this.emitLayoutChanged()}set scrollPosition(e){Math.abs(e-this._scrollPosition)<gi||(this.animateNextRender=!1,this.syncScrollModel(),this.layoutScroll.scroll=Te({x:e}))}get scrollPosition(){return this._scrollPosition}focusArtifact(e){const n=kn(this._layout),i=n.nodes.findIndex(o=>o.cards.some(a=>a.artifactID===e));if(i<0)return;let s=0;for(let o=0;o<i;o+=1)s+=n.nodes[o].width;this.scrollPosition=s,queueMicrotask(()=>{const o=this.querySelector(`.card-slot[data-layout-card-id="${_m(e)}"]`);if(!o)return;o.classList.remove("card-focus-pulse"),o.offsetHeight,o.classList.add("card-focus-pulse");const a=()=>{o.classList.remove("card-focus-pulse"),o.removeEventListener("animationend",a)};o.addEventListener("animationend",a)})}connectedCallback(){this.hasAttribute("tabindex")||(this.tabIndex=0),this.focus(),this.addEventListener("keydown",this.handleKeyDown),this.addEventListener("wheel",this.handleWheel,{passive:!1}),this.addEventListener("pointerdown",this.handlePointerDown),this.addEventListener("artifact-wheel",this.handleArtifactWheel),this.addEventListener("artifact-filmstrip-key",this.handleArtifactFilmstripKey),window.addEventListener("message",this.handleWindowMessage),typeof ResizeObserver<"u"&&(this.resizeObserver=new ResizeObserver(()=>this.render()),this.resizeObserver.observe(this)),this.render()}disconnectedCallback(){var e;this.removeEventListener("keydown",this.handleKeyDown),this.removeEventListener("wheel",this.handleWheel),this.removeEventListener("pointerdown",this.handlePointerDown),this.removeEventListener("artifact-wheel",this.handleArtifactWheel),this.removeEventListener("artifact-filmstrip-key",this.handleArtifactFilmstripKey),window.removeEventListener("message",this.handleWindowMessage),(e=this.resizeObserver)==null||e.disconnect(),this.resizeObserver=null,this.clearWheelIdleSnap(),this.detachDragListeners(),this.swipeGesture.status==="active"&&this.swipeGesture.cancel(),this.swipePointerId!==null&&this.releaseSwipePointerCapture(this.swipePointerId),this.endSwipeTracking(),this.dragController.removeEventListener("change",this.onDragControllerChange),this.dragController.removeEventListener("drag",this.onDragControllerDrag),this.dragController.removeEventListener("drop",this.onDragControllerDrop),this.layoutScroll.removeEventListener("layout-scroll",this.onLayoutScrollInternal),this.dragController.dispose(),this.stopDragFrameLoop(),this.resizeState&&this.endResize(this.resizeState.pointerId)}scheduleRender(){this.renderPending||(this.renderPending=!0,queueMicrotask(()=>{this.renderPending=!1,this.render()}))}createGrid(e,n){return new XO({basis:Ie({x:Or,y:Or}),min:Ie({x:bg,y:bg}),viewport:Ie({x:e,y:n}),gap:Ie({x:ae,y:ae})})}syncScrollModel(){const e=Pu(this),i=kn(this._layout).nodes.map(o=>o.width),s=`${e.width}x${e.height}:${i.join(",")}`;s===this.scrollModelKey&&this.layoutGrid||(this.scrollModelKey=s,this.layoutGrid=this.createGrid(e.width,e.height),this.layoutScroll.rebuild({grid:this.layoutGrid,nodeWidths:i.map(o=>Te({x:o})),snap:Sm}))}emitScrollPositionChanged(e){this.dispatchEvent(new GM(e))}emitLayoutChanged(){this.dispatchEvent(new n0([...this._layout]))}stepFilmstrip(e){this.clearWheelIdleSnap(),this.syncScrollModel(),this.animateNextRender=!0,this.layoutScroll.step(e)}applyHorizontalWheel(e){this.syncScrollModel();const n=this.layoutGrid;if(!n)return;this.animateNextRender=!1;const i=n.toUnits(Ie({x:e}));this.layoutScroll.wheel(Te({x:i.x??0}))}scheduleWheelIdleSnap(){this.clearWheelIdleSnap(),this.wheelIdleSnapTimer=setTimeout(()=>{this.wheelIdleSnapTimer=null,this.animateNextRender=!0,this.layoutScroll.snap()},BM)}clearWheelIdleSnap(){this.wheelIdleSnapTimer!==null&&(clearTimeout(this.wheelIdleSnapTimer),this.wheelIdleSnapTimer=null)}findViewspanContainingNode(e){const n=this.layoutScroll.viewspans,i=this._scrollPosition;let s=null,o=Number.POSITIVE_INFINITY;for(const a of n)if(e>=a.nodeRange[0]&&e<=a.nodeRange[1]){const c=Math.abs(a.anchor-i);c<o&&(o=c,s=a)}return s}findManagedArtifactFrame(e){if(!e)return null;const n=this.querySelectorAll("iframe.artifact-frame");for(const i of n)if(i.contentWindow===e)return i;return null}isTrustedArtifactFrameMessage(e,n){if(e.origin==="null")return!0;const i=this.getArtifactFrameOrigin(n);return i===null||e.origin===i}getArtifactFrameOrigin(e){const n=e.getAttribute("src")??e.src;if(!n)return null;try{return new URL(n,window.location.href).origin}catch{return null}}beginResize(e,n){const i=n.getAttribute("data-resize-handle");if(!i)return;const s=this._layout.find(a=>a.type==="card"&&we(a)===i);if(!s)return;const o=Hh(typeof s.width=="number"?s.width:qe);this.resizeState={cardId:i,pointerId:e.pointerId,startClientX:e.clientX,startWidth:o,currentWidth:o},this.attachResizeListeners();try{this.setPointerCapture(e.pointerId)}catch{}e.preventDefault(),e.stopPropagation()}attachResizeListeners(){this.resizeListenersAttached||(window.addEventListener("pointermove",this.handleResizePointerMove),window.addEventListener("pointerup",this.handleResizePointerUp),window.addEventListener("pointercancel",this.handleResizePointerCancel),window.addEventListener("blur",this.handleResizeWindowBlur),this.addEventListener("keydown",this.handleResizeKeyDown),this.resizeListenersAttached=!0)}detachResizeListeners(){this.resizeListenersAttached&&(window.removeEventListener("pointermove",this.handleResizePointerMove),window.removeEventListener("pointerup",this.handleResizePointerUp),window.removeEventListener("pointercancel",this.handleResizePointerCancel),window.removeEventListener("blur",this.handleResizeWindowBlur),this.removeEventListener("keydown",this.handleResizeKeyDown),this.resizeListenersAttached=!1)}endResize(e){this.resizeState=null,this.detachResizeListeners();try{this.hasPointerCapture(e)&&this.releasePointerCapture(e)}catch{}}beginSwipeTracking(e){this.swipePointerId=e.pointerId,this.swipeStartX=e.clientX,this.swipeStartY=e.clientY,this.swipeLastX=e.clientX,this.swipeActive=!1,this.swipeShouldSuppressClick=!1,this.attachSwipeListeners()}attachSwipeListeners(){this.swipeListenersAttached||(window.addEventListener("pointermove",this.handleSwipePointerMove),window.addEventListener("pointerup",this.handleSwipePointerUp),window.addEventListener("pointercancel",this.handleSwipePointerCancel),this.addEventListener("pointermove",this.handleSwipePointerMove),this.addEventListener("pointerup",this.handleSwipePointerUp),this.addEventListener("pointercancel",this.handleSwipePointerCancel),window.addEventListener("blur",this.handleSwipeWindowBlur),this.addEventListener("click",this.handleSwipeClick,{capture:!0}),this.swipeListenersAttached=!0)}detachSwipeListeners(){this.swipeListenersAttached&&(window.removeEventListener("pointermove",this.handleSwipePointerMove),window.removeEventListener("pointerup",this.handleSwipePointerUp),window.removeEventListener("pointercancel",this.handleSwipePointerCancel),this.removeEventListener("pointermove",this.handleSwipePointerMove),this.removeEventListener("pointerup",this.handleSwipePointerUp),this.removeEventListener("pointercancel",this.handleSwipePointerCancel),window.removeEventListener("blur",this.handleSwipeWindowBlur),this.removeEventListener("click",this.handleSwipeClick,{capture:!0}),this.swipeListenersAttached=!1)}endSwipeTracking(){this.swipePointerId=null,this.swipeActive=!1,this.detachSwipeListeners()}releaseSwipePointerCapture(e){try{this.hasPointerCapture(e)&&this.releasePointerCapture(e)}catch{}}releaseActiveDragPointerCapture(){this.activeDragPointerId!==null&&this.releasePointerCaptureForEvent(this.activeDragPointerId)}releasePointerCaptureForEvent(e){try{this.hasPointerCapture(e)&&this.releasePointerCapture(e)}catch{}}attachDragListeners(){this.dragListenersAttached||(window.addEventListener("pointermove",this.handleWindowPointerMove),window.addEventListener("pointerup",this.handleWindowPointerUp),window.addEventListener("pointercancel",this.handleWindowPointerCancel),this.addEventListener("pointermove",this.handleWindowPointerMove),this.addEventListener("pointerup",this.handleWindowPointerUp),this.addEventListener("pointercancel",this.handleWindowPointerCancel),window.addEventListener("blur",this.handleWindowBlur),this.dragListenersAttached=!0)}detachDragListeners(){this.dragListenersAttached&&(window.removeEventListener("pointermove",this.handleWindowPointerMove),window.removeEventListener("pointerup",this.handleWindowPointerUp),window.removeEventListener("pointercancel",this.handleWindowPointerCancel),this.removeEventListener("pointermove",this.handleWindowPointerMove),this.removeEventListener("pointerup",this.handleWindowPointerUp),this.removeEventListener("pointercancel",this.handleWindowPointerCancel),window.removeEventListener("blur",this.handleWindowBlur),this.dragListenersAttached=!1,this.activeDragPointerId=null)}getVisibleLayout(){return this.dragController.status!=="active"||!this.dragState?this.applyResizeOverride(this._layout):vm(this.dragState.projectedLayout)}applyResizeOverride(e){const n=this.resizeState;if(!n)return e;const i=e.findIndex(a=>a.type==="card"&&we(a)===n.cardId);if(i===-1)return e;const s=e[i];if(!s||s.type!=="card"||s.width===n.currentWidth)return e;const o=[...e];return o[i]={...s,width:n.currentWidth},o}getGridSlotStyle(e){return`grid-column: ${e.col} / span ${e.width}; grid-row: ${e.row} / span ${e.height};`}findContainingBlock(e){let n=e.parentElement;for(;n;){const i=getComputedStyle(n);if(i.transform!=="none"||i.perspective!=="none"||i.filter!=="none")return n;const s=i.willChange;if(s.includes("transform")||s.includes("perspective")||s.includes("filter"))return n;const o=i.contain;if(o.includes("layout")||o.includes("paint")||o.includes("strict"))return n;n=n.parentElement}return document.documentElement}getDraggedSlotStyle(e){const n=this.currentDragPreviewSize??{width:e.size.x??0,height:e.size.y??0};return["position: fixed;",`width: ${n.width}px;`,`height: ${n.height}px;`,"pointer-events: none;","z-index: 10;"].join(" ")}writeDraggedSlotPosition(e,n){(!this.draggedSlotContainingBlock||!this.draggedSlotContainingBlock.isConnected||!this.draggedSlotContainingBlock.contains(e))&&(this.draggedSlotContainingBlock=this.findContainingBlock(e));const i=this.draggedSlotContainingBlock.getBoundingClientRect(),s=n.pointer.x??0,o=n.pointer.y??0,a=n.grabOffset.x??0,c=n.grabOffset.y??0,u=this.currentDragPreviewSize??{width:n.size.x??0,height:n.size.y??0},h=n.size.x??0,f=n.size.y??0,y=h>0?a*(u.width/h):a,m=f>0?c*(u.height/f):c;e.style.left=`${s-y-i.left}px`,e.style.top=`${o-m-i.top}px`,e.style.width=`${u.width}px`,e.style.height=`${u.height}px`}renderSlot(e,n){var o,a;if(e.kind==="placeholder")return e.placement?D`
303
- <div
304
- class="card-slot card-placeholder"
305
- data-layout-placeholder-for=${(n==null?void 0:n.nodeId)??""}
306
- data-layout-placeholder-ghost="false"
307
- data-layout-source-stack=${e.sourceStackId??""}
308
- style=${this.getGridSlotStyle(e.placement)}
309
- ></div>
310
- `:null;const i=e.card;if(!i)return null;const s=e.isDragged&&n?this.getDraggedSlotStyle(n):e.placement?this.getGridSlotStyle(e.placement):"";return D`
311
- <div
312
- class="card-slot"
313
- data-layout-card-id=${we(i)}
314
- data-layout-drag-source=${String(e.isDragged)}
315
- layout-cols=${String(((o=e.placement)==null?void 0:o.width)??"")}
316
- layout-rows=${String(((a=e.placement)==null?void 0:a.height)??"")}
317
- style=${s}
318
- >
319
- <div class="card-content-mount" data-mount-for=${we(i)}></div>
320
- ${e.isTopLevelCard&&!e.isDragged?D`<div
321
- class="resize-handle"
322
- data-resize-handle=${we(i)}
323
- data-test-resize-handle=${we(i)}
324
- ></div>`:null}
325
- </div>
326
- `}renderNode(e,n){return D`
327
- <div
328
- class=${e.kind==="ghost"?"drag-source-node":"node"}
329
- layout-node=${String(e.layoutIndex??"")}
330
- data-layout-node-id=${e.nodeId}
331
- data-layout-placeholder=${String(e.kind==="visible"&&e.isPlaceholder)}
332
- layout-node-cols=${String(e.widthUnits)}
333
- ?data-foreground=${e.kind==="visible"&&e.isForeground}
334
- style=${e.kind==="visible"?`width: ${e.widthPx}px; --card-width-px: ${e.widthPx};`:""}
335
- >
336
- <div class="node-inner" style=${`grid-template-columns: repeat(${e.widthUnits}, var(--layout-unit-x));`}>
337
- ${fm(e.slots,i=>i.key,i=>this.renderSlot(i,n))}
338
- </div>
339
- </div>
340
- `}render(){var Y;const e=Pu(this),n=this.createGrid(e.width,e.height);this.layoutGrid=n;const i=this.getVisibleLayout(),s=this.dragController.status==="active",o=kn(i),a=o.nodes.map(V=>V.width),c=`${e.width}x${e.height}:${a.join(",")}`;!s&&c!==this.scrollModelKey&&(this.scrollModelKey=c,this.layoutScroll.rebuild({grid:n,nodeWidths:a.map(V=>Te({x:V})),snap:Sm}),this._scrollPosition=this.layoutScroll.scroll.x??this._scrollPosition);const u=YM(this._layout),h=n.unit.x??Or,f=n.unit.y??Or,y=s?this.dragTrackOffsetXPx:0,m=(this.layoutScroll.translate.x??0)+y,E=km(o.nodes.length,n,e.height),x=this.animateNextRender&&!s,I=[`transform: translate(${m}px, ${E}px);`,`transition-duration: ${x?n$:0}ms;`,`pointer-events: ${s?"none":"auto"};`].join(" ");this.animateNextRender=!0,this.style.setProperty("--layout-unit-x",`${h}px`),this.style.setProperty("--layout-unit-y",`${f}px`),this.style.setProperty("--layout-gap",`${ae}px`);const P=this.dragState,R=new Set;{let V=m;for(let ce=0;ce<o.nodes.length;ce+=1){const Et=n.toPixels(Te({x:o.nodes[ce].width})).x??0,ln=V+Et;V>=-1&&ln<=e.width+1&&R.add(ce),V=ln+ae}}const B=V=>R.has(V),N=HM({baseLayout:this._layout,visibleLayout:i,resolved:o,cardsByID:u,grid:n,dragState:this.dragState,isForeground:B}),F=bm(this.dragState);if(F?this.setAttribute("data-test-drop-intent",F):this.removeAttribute("data-test-drop-intent"),this.dragState){let V=null;for(const ce of o.nodes){for(const Et of ce.cards)if(Et.artifactID===this.dragState.nodeId){V={width:n.toPixels(Te({x:Et.width})).x??0,height:n.toPixels(Te({y:Et.height})).y??0};break}if(V)break}this.currentDragPreviewSize=V??{width:this.dragState.size.x??0,height:this.dragState.size.y??0}}else this.currentDragPreviewSize=null;Be(D`
341
- <div class="track" style=${I}>
342
- ${fm(N,V=>V.key,V=>this.renderNode(V,P))}
343
- </div>
344
- `,this),this.syncCardElements(u,P?((Y=u.get(P.nodeId))==null?void 0:Y.artifactID)??null:null),this.syncDraggedSlotElement(P)}syncCardElements(e,n){var o;const i=new Map;for(const a of this.querySelectorAll(".card-content-mount[data-mount-for]")){const c=a.getAttribute("data-mount-for");c&&i.set(c,a)}const s=new Set;for(const a of e.values()){const c=this._cards.get(a.artifactID);if(!c)continue;s.add(a.artifactID);const u=i.get(we(a));if(!u){c.removeAttribute("data-dragging");continue}const h=(o=u.parentElement)==null?void 0:o.getAttribute("data-layout-card-id");console.assert(h===we(a),`layout-view: mount mismatch for ${we(a)}`),c.parentElement!==u&&u.appendChild(c),console.assert(u.children.length<=1,`layout-view: multiple children for ${we(a)}`),c.toggleAttribute("data-dragging",a.artifactID===n)}for(const[a,c]of this._cards)s.has(a)||c.removeAttribute("data-dragging")}ensureDragFrameLoop(){this.dragFrame!==0||this.dragController.status==="idle"||(this.lastDragFrameTime=performance.now(),this.dragFrame=requestAnimationFrame(this.runDragFrame))}stopDragFrameLoop(){this.dragFrame!==0&&(cancelAnimationFrame(this.dragFrame),this.dragFrame=0,this.scrollVelocityPxPerSec=0)}syncDragTargetForLatestPointer(){if(this.dragController.status==="idle")return;const e=this.getBoundingClientRect();if(this.dragController.status==="active"){const i=this.clampPointerToViewport(this.lastPointerX,this.lastPointerY,e);this.syncDragTarget(i.x,i.y,e);return}if(this.syncDragTarget(this.lastPointerX,this.lastPointerY,e),this.dragController.status==="pending")return;const n=this.clampPointerToViewport(this.lastPointerX,this.lastPointerY,e);(n.x!==this.lastPointerX||n.y!==this.lastPointerY)&&this.syncDragTarget(n.x,n.y,e)}syncDragTarget(e,n,i=this.getBoundingClientRect()){if(this.dragController.status==="idle")return;const s=this.getVisibleLayout(),o=this.dragController.status==="active"?this.dragTrackOffsetXPx:0,a=this.measureLayoutGeometry(s,o);this.dragController.update({pointer:Ie({x:e,y:n}),viewport:{left:i.left,top:i.top,width:i.width,height:i.height},geometry:a,effectiveVelocity:Math.max(this.pointerVelocityPxPerSec,this.scrollVelocityPxPerSec)})}resetMotionTracking(e,n){this.pointerVelocityPxPerSec=0,this.scrollVelocityPxPerSec=0,this.motionSampleTime=performance.now(),this.motionSampleX=e,this.motionSampleY=n}clearMotionTracking(){this.pointerVelocityPxPerSec=0,this.scrollVelocityPxPerSec=0,this.motionSampleTime=0}updatePointerVelocity(e,n){this.samplePointerVelocityAt(performance.now(),e,n)}samplePointerVelocityAt(e,n,i){if(this.motionSampleTime===0){this.motionSampleTime=e,this.motionSampleX=n,this.motionSampleY=i,this.pointerVelocityPxPerSec=0;return}const s=e-this.motionSampleTime;if(s<100)return;const o=n-this.motionSampleX;this.pointerVelocityPxPerSec=Math.abs(o)/s*wm,this.motionSampleTime=e,this.motionSampleX=n,this.motionSampleY=i}clampPointerToViewport(e,n,i){return{x:Math.max(i.left,Math.min(i.left+i.width,e)),y:Math.max(i.top,Math.min(i.top+i.height,n))}}getDragEdgeScrollDeltaPixels(e,n,i){var u;const s=n.left+Za,o=n.left+n.width-Za,a=((u=this.layoutGrid)==null?void 0:u.unit.x)??Or,c=s$*a;if(e<s){const h=Math.max(0,Math.min(1,(s-e)/Za));return-(c*h**wg)*i}if(e>o){const h=Math.max(0,Math.min(1,(e-o)/Za));return c*h**wg*i}return 0}measureLayoutGeometry(e,n=0){const i=this.layoutGrid;if(!i)return[];const s=kn(e),o=new Map(s.nodes.map(E=>[E.id,E.width])),a=i.toPixels(Te({y:ft})).y??lo,c=Pu(this),u=(this.layoutScroll.translate.x??0)+n,h=km(s.nodes.length,i,c.height),f=c.offsetY+h,y=[];let m=u;for(const E of e){const x=Li(E),I=o.get(x)??qe,P=i.toPixels(Te({x:I})).x??Vn,R={left:m,top:f,width:P,height:a};y.push({id:x,rect:R}),m+=P+ae}return y}resetDragPreviewState(){this.dragTrackOffsetXPx=0,this.previousProjectedLayoutForOffset=null,this.lastProjectedDragLayoutSignature="",this.lastDragDropIntent=null,this.lastActivePlaceholderId=null,this.draggedSlotElement=null,this.draggedSlotContainingBlock=null,this.currentDragPreviewSize=null}getCachedDraggedSlotElement(e){var n;return(n=this.draggedSlotElement)!=null&&n.isConnected&&this.draggedSlotElement.getAttribute("data-layout-card-id")===e&&this.draggedSlotElement.getAttribute("data-layout-drag-source")==="true"?this.draggedSlotElement:(this.draggedSlotElement=this.querySelector(`.card-slot[data-layout-card-id="${_m(e)}"][data-layout-drag-source="true"]`),this.draggedSlotElement)}syncDraggedSlotElement(e){if(!e||this.dragController.status!=="active"){this.draggedSlotElement=null;return}const n=this.getCachedDraggedSlotElement(e.nodeId);n&&this.writeDraggedSlotPosition(n,e)}shouldApplyTrackOffset(e,n){if(n)return!0;for(const i of e){if(i.type!=="stack")continue;if(i.children.some(o=>o.type==="drop-target")&&n!==i.id)return!0}return!1}computeDragTrackOffset(e,n,i,s,o,a){if(!e)return a;const c=s?o??this.getStableAnchorCardId(e,n,i):this.getStableAnchorNodeId(e,n,i);if(!c)return a;const u=s?Em(e,c,this.layoutGrid):Am(e,c,this.layoutGrid),h=s?Em(n,c,this.layoutGrid):Am(n,c,this.layoutGrid);return u===null||h===null?a:a+(u-h)}getStableAnchorCardId(e,n,i){const s=xm(e),o=new Set(xm(n));for(const a of s)if(a!==i&&o.has(a))return a;return null}getStableAnchorNodeId(e,n,i){const s=new Set(n.map(Li));for(const o of e){const a=Li(o);if(a!==i&&s.has(a))return a}return null}getStackChildAnchorCardId(e,n){const i=this._layout.find(o=>o.type==="stack"&&o.id===e);if(!i||i.type!=="stack")return null;const s=i.children.find(o=>o.type==="card"&&we(o)!==n);return s?we(s):null}}function YM(r){const t=new Map;for(const e of r){if(e.type==="card"){t.set(we(e),e);continue}for(const n of e.children)if(n.type==="card")t.set(we(n),n);else for(const i of n.children)t.set(we(i),i)}return t}function KM(r){for(const t of r)if(t.type==="drop-target"||t.type==="stack"&&t.children.some(e=>e.type==="drop-target"))return t.id;return null}function JM(r,t){const e=r.findIndex(n=>n.type==="card"&&we(n)===t);if(e!==-1)return{topLevelIndex:e};for(let n=0;n<r.length;n+=1){const i=r[n];if(!(!i||i.type!=="stack")&&i.children.some(s=>s.type==="card"&&we(s)===t))return{topLevelIndex:n,sourceStackId:i.id}}return null}function xm(r){const t=[];for(const e of r){if(e.type==="card"){t.push(we(e));continue}if(e.type==="stack"){const n=e.children.find(i=>i.type==="card");n&&t.push(we(n))}}return t}function Em(r,t,e){if(!e)return null;const n=kn(r),i=new Map(n.nodes.map(o=>[o.id,o.width]));let s=0;for(const o of r){if(o.type==="card"&&we(o)===t||o.type==="stack"&&o.children.some(u=>u.type==="card"&&we(u)===t))return s;const a=i.get(Li(o))??qe,c=e.toPixels(Te({x:a})).x??Vn;s+=c+ae}return null}function Am(r,t,e){if(!e)return null;const n=kn(r),i=new Map(n.nodes.map(o=>[o.id,o.width]));let s=0;for(const o of r){if(Li(o)===t)return s;const a=i.get(Li(o))??qe,c=e.toPixels(Te({x:a})).x??Vn;s+=c+ae}return null}customElements.get("layout-view")||customElements.define("layout-view",qM);class XM extends HTMLElement{constructor(){super(...arguments);g(this,"screenManager",cr.resolve("ScreenManager"));g(this,"boundModel",null);g(this,"cardEls",new Map);g(this,"handleActiveScreenChanged",()=>{this.rebindModel(),this.render()});g(this,"handleModelChange",()=>{this.render()});g(this,"handleCloseArtifact",e=>{e instanceof Kw&&this.screenManager.activeScreen&&this.screenManager.activeScreen.removeArtifact(e.artifactID)});g(this,"handleScrollPositionChanged",e=>{const n=e;typeof n.scrollPosition=="number"&&Number.isFinite(n.scrollPosition)&&this.screenManager.activeScreen&&this.screenManager.activeScreen.setScrollPosition(n.scrollPosition)});g(this,"handleLayoutChanged",e=>{e instanceof n0&&this.screenManager.activeScreen&&this.screenManager.activeScreen.setLayout(e.layout)});g(this,"handleGlobalArrowKey",e=>{var s;if(e.key!=="ArrowLeft"&&e.key!=="ArrowRight"||e.metaKey||e.ctrlKey||e.altKey||e.shiftKey||this.isTextEditingTarget(e.target))return;const n=e.target;if(n instanceof Node&&((s=this.querySelector("layout-view"))!=null&&s.contains(n)))return;const i=this.querySelector("layout-view");i&&(e.preventDefault(),i.stepFilmstrip(e.key==="ArrowRight"?1:-1))});g(this,"handleServerEvent",e=>{const n=e.event;if(n.type!=="artifact-focus"||!this.boundModel||n.screenID!==this.boundModel.id)return;const i=this.querySelector("layout-view");i&&i.focusArtifact(n.artifactID)})}connectedCallback(){this.screenManager.addEventListener("active-screen-changed",this.handleActiveScreenChanged),window.addEventListener("keydown",this.handleGlobalArrowKey,{capture:!0}),this.rebindModel(),this.render()}disconnectedCallback(){this.screenManager.removeEventListener("active-screen-changed",this.handleActiveScreenChanged),window.removeEventListener("keydown",this.handleGlobalArrowKey,{capture:!0}),this.unbindModel(),this.disposeCardElements()}rebindModel(){const e=this.screenManager.activeScreen;this.boundModel!==e&&(this.unbindModel(),this.boundModel=e,e&&(e.addEventListener("change",this.handleModelChange),e.server.addEventListener("server-event",this.handleServerEvent)))}unbindModel(){this.boundModel&&(this.boundModel.removeEventListener("change",this.handleModelChange),this.boundModel.server.removeEventListener("server-event",this.handleServerEvent),this.boundModel=null)}isTextEditingTarget(e){var i;if(!(e instanceof Element))return!1;const n=e.closest("input, textarea, select, [contenteditable], [role='textbox'], [role='searchbox'], [role='combobox'], [role='spinbutton'], [role='slider']");return n?n.hasAttribute("contenteditable")?((i=n.getAttribute("contenteditable"))==null?void 0:i.toLowerCase())!=="false":!0:!1}buildCards(e){if(!e)return this.disposeCardElements(),new Map;const n=new Map;for(const i of e.artifacts.values()){let s=this.cardEls.get(i.id);s||(s=document.createElement("artifact-view"),this.cardEls.set(i.id,s)),s.artifact=i,s.screen=e,s.viewURL=e.server.getViewURL(i),s.contentURL=e.server.getContentURL(i),n.set(i.id,s)}for(const[i,s]of this.cardEls)n.has(i)||(s.remove(),this.cardEls.delete(i));return n}disposeCardElements(){for(const e of this.cardEls.values())e.remove();this.cardEls.clear()}render(){const e=this.screenManager.activeScreen,n=(e==null?void 0:e.layout)??[],i=this.buildCards(e);if(n.length===0){Be(D``,this);return}Be(D`
345
- <layout-view
346
- .layout=${n}
347
- .cards=${i}
348
- .scrollPosition=${(e==null?void 0:e.scrollPosition)??0}
349
- @scroll=${this.handleScrollPositionChanged}
350
- @layout-change=${this.handleLayoutChanged}
351
- @close-artifact=${this.handleCloseArtifact}
352
- ></layout-view>
353
- `,this)}}customElements.define("screen-view",XM);function Hl(r){return typeof r=="object"&&r!==null}const Lu=new WeakMap,$m=Object.prototype.hasOwnProperty,QM=(()=>{const r=new Set;let t=HTMLElement.prototype;for(;t;){for(const e of Object.getOwnPropertyNames(t))r.add(e);if(t===Node.prototype)break;t=Object.getPrototypeOf(t)}return r})();function eN(r,t){if(Hl(r))return t===null?void 0:r.parse(t);if(r===Boolean)return t!==null;if(t!==null)return r===Number?Number(t):t}function tN(r,t){return Hl(r)?t==null?null:r.serialize(t):r===Boolean?t?"":null:t==null?null:String(t)}var Qo,Bh,Hn,gt,tr,Xi,Zn,Qi,xe,xi,i0,s0,o0,a0,bl;const Sn=class Sn extends HTMLElement{constructor(){var i;super();S(this,xe);S(this,Hn,new Map);S(this,gt,new Map);S(this,tr,new Map);S(this,Xi,!1);S(this,Zn,!1);S(this,Qi,!1);const e=p(i=Sn,Qo,Bh).call(i,this.constructor),n=this;for(const s of e.properties)$m.call(n,s)&&(l(this,tr).set(s,n[s]),delete n[s])}static get observedAttributes(){var e;return p(e=Sn,Qo,Bh).call(e,this).observedAttributes}connected(){}disconnected(){}changed(e){}connectedCallback(){if(p(this,xe,a0).call(this),!l(this,Zn))for(const e of p(this,xe,xi).call(this).properties)l(this,gt).has(e)||l(this,gt).set(e,void 0);this.dispatchEvent(new Event("reactive:connect")),this.connected(),p(this,xe,bl).call(this)}disconnectedCallback(){this.dispatchEvent(new Event("reactive:disconnect")),this.disconnected()}attributeChangedCallback(e,n,i){if(n===i)return;const s=p(this,xe,xi).call(this).byAttr.get(e);s&&(l(this,tr).has(s.property)||(this[s.property]=eN(s.type,i)))}};Qo=new WeakSet,Bh=function(e){const n=Lu.get(e);if(n)return n;const i=[...e.properties??[]],s=e.attributes??{},o=new Map,a=new Map;for(const u of i)if(QM.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 f=h.property??u;if(!i.includes(f))throw new Error(`Attribute '${u}' references property '${f}', which isn't declared in \`static properties\`. Add it to \`properties\` to make it reactive.`);if(Hl(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 y={attribute:u,property:f,type:h.type};o.set(u,y),a.set(f,y)}for(const u of i){const h=Object.getOwnPropertyDescriptor(e.prototype,u);if((h==null?void 0:h.get)!==void 0||(h==null?void 0:h.set)!==void 0)throw new Error(`Observed property "${u}" cannot define a custom getter/setter. Use changed() for side effects instead.`);h===void 0&&Object.defineProperty(e.prototype,u,{configurable:!0,enumerable:!0,get(){return l(this,Hn).get(u)},set(f){p(this,xe,i0).call(this,u,f)}})}const c={properties:i,observedAttributes:Object.keys(s),byAttr:o,byProp:a};return Lu.set(e,c),c},Hn=new WeakMap,gt=new WeakMap,tr=new WeakMap,Xi=new WeakMap,Zn=new WeakMap,Qi=new WeakMap,xe=new WeakSet,xi=function(){return Lu.get(this.constructor)},i0=function(e,n){if(!l(this,Qi)&&l(this,tr).has(e))return;const i=l(this,Hn).get(e);p(this,xe,s0).call(this,e,i,n)||(l(this,gt).has(e)||l(this,gt).set(e,i),l(this,Hn).set(e,n),l(this,tr).delete(e),p(this,xe,o0).call(this,e,n),this.isConnected&&p(this,xe,bl).call(this))},s0=function(e,n,i){if(Object.is(n,i))return!0;const s=p(this,xe,xi).call(this).byProp.get(e);if(!s||!Hl(s.type))return!1;const o=n==null,a=i==null;if(o||a)return o&&a;try{return s.type.serialize(n)===s.type.serialize(i)}catch{return!1}},o0=function(e,n){const i=p(this,xe,xi).call(this).byProp.get(e);if(!i)return;const{attribute:s,type:o}=i;if(o===Boolean){const c=this.hasAttribute(s);n&&!c?this.setAttribute(s,""):!n&&c&&this.removeAttribute(s);return}const a=tN(o,n);if(a===null){this.hasAttribute(s)&&this.removeAttribute(s);return}this.getAttribute(s)!==a&&this.setAttribute(s,a)},a0=function(){const e=this,n=p(this,xe,xi).call(this);for(const i of n.properties){if(!$m.call(e,i))continue;const s=e[i];delete e[i],!(l(this,tr).has(i)||l(this,Hn).has(i))&&(e[i]=s)}w(this,Qi,!0);try{for(const[i,s]of l(this,tr))e[i]=s;l(this,tr).clear()}finally{w(this,Qi,!1)}},bl=function(){l(this,Xi)||!this.isConnected||l(this,Zn)&&l(this,gt).size===0||(w(this,Xi,!0),queueMicrotask(()=>{if(w(this,Xi,!1),!this.isConnected||l(this,Zn)&&l(this,gt).size===0)return;const e=new Map(l(this,gt));l(this,gt).clear(),w(this,Zn,!0);try{this.changed(e)}catch(n){console.error(n)}this.isConnected&&l(this,gt).size>0&&p(this,xe,bl).call(this)}))},S(Sn,Qo),g(Sn,"properties"),g(Sn,"attributes");let ps=Sn;var fe,Vr,Gr,es,ts,Er,ea,$e,rs,rr,Z,l0,ta,ra,na,ia,jh,Vh,Gh,c0,u0,h0,d0,Jl,Xl,Ql,ec,qh,p0,wl,tc,Sl,rc,f0,g0,m0,v0,y0,dt;class rN extends ps{constructor(){super(...arguments);S(this,Z);S(this,fe,cr.resolve("ScreenManager"));S(this,Vr,cr.resolve("ServerManager"));S(this,Gr,null);S(this,es,new DisposableStack);S(this,ts,fl());S(this,Er,fl());S(this,ea,fl());S(this,$e,{kind:"none"});S(this,rs,!1);S(this,rr,[]);S(this,ta,()=>{p(this,Z,jh).call(this),w(this,$e,{kind:"none"}),l(this,dt).call(this)});S(this,ra,()=>{l(this,dt).call(this)});S(this,na,()=>{l(this,dt).call(this)});S(this,ia,()=>{l(this,dt).call(this)});S(this,Jl,()=>{var i,s;if(l(this,$e).kind==="picker"){p(this,Z,Sl).call(this);return}w(this,rr,p(this,Z,p0).call(this));const e=((i=l(this,fe).activeScreen)==null?void 0:i.id)??null,n=e&&l(this,rr).some(o=>o.screenID===e)?e:((s=l(this,rr)[0])==null?void 0:s.screenID)??null;w(this,$e,{kind:"picker",filter:"",highlightedID:n}),l(this,dt).call(this),queueMicrotask(()=>{var o;(o=l(this,ea).value)==null||o.focus()})});S(this,Xl,e=>{var u;const n=l(this,$e);if(n.kind!=="picker")return;const i=e.target;if(!(i instanceof HTMLInputElement))return;const s=i.value,o=p(this,Z,wl).call(this,l(this,rr),s),c=n.highlightedID!==null&&o.some(h=>h.screenID===n.highlightedID)?n.highlightedID:((u=o[0])==null?void 0:u.screenID)??null;w(this,$e,{kind:"picker",filter:s,highlightedID:c}),l(this,dt).call(this)});S(this,Ql,e=>{var s;const n=l(this,$e);if(n.kind!=="picker")return;if(e.key==="Escape"){e.preventDefault(),p(this,Z,Sl).call(this),(s=l(this,ts).value)==null||s.focus();return}const i=p(this,Z,wl).call(this,l(this,rr),n.filter);if(e.key==="ArrowDown"||e.key==="ArrowUp"){if(e.preventDefault(),i.length===0)return;const o=i.findIndex(u=>u.screenID===n.highlightedID),a=e.key==="ArrowDown"?1:-1,c=o<0?0:Math.max(0,Math.min(i.length-1,o+a));w(this,$e,{kind:"picker",filter:n.filter,highlightedID:i[c].screenID}),l(this,dt).call(this);return}if(e.key==="Enter"){e.preventDefault();const o=i.find(a=>a.screenID===n.highlightedID);o&&p(this,Z,qh).call(this,o)}});S(this,ec,e=>{p(this,Z,qh).call(this,e)});S(this,tc,e=>{l(this,$e).kind==="picker"&&e.target===l(this,Er).value&&(w(this,$e,{kind:"none"}),l(this,dt).call(this))});S(this,rc,async()=>{if(l(this,rs))return;const e=p(this,Z,f0).call(this);if(e){w(this,rs,!0);try{const n=await e.createScreen(nN(new Date));l(this,fe).addTab(e.url,n.id),l(this,fe).setActive(e.url,n.id)}catch{}finally{w(this,rs,!1)}}});S(this,dt,()=>{const e=p(this,Z,h0).call(this);Be(D`
354
- ${p(this,Z,g0).call(this)}
355
- <div class="pills" role="group" aria-label="Open tabs">
356
- ${e.map(n=>p(this,Z,m0).call(this,n))}
357
- </div>
358
- ${p(this,Z,v0).call(this)}
359
- `,this),l(this,Er).value&&(l(this,Er).value.anchor=l(this,ts).value??null)})}connected(){l(this,fe).addEventListener("active-screen-changed",l(this,ta)),l(this,fe).addEventListener("tabs-changed",l(this,ra)),l(this,Vr).addEventListener("screens-changed",l(this,na)),p(this,Z,jh).call(this),l(this,dt).call(this),p(this,Z,l0).call(this),l(this,es).defer(()=>{l(this,fe).removeEventListener("active-screen-changed",l(this,ta)),l(this,fe).removeEventListener("tabs-changed",l(this,ra)),l(this,Vr).removeEventListener("screens-changed",l(this,na)),p(this,Z,Vh).call(this)})}disconnected(){l(this,es).dispose(),w(this,es,new DisposableStack)}}fe=new WeakMap,Vr=new WeakMap,Gr=new WeakMap,es=new WeakMap,ts=new WeakMap,Er=new WeakMap,ea=new WeakMap,$e=new WeakMap,rs=new WeakMap,rr=new WeakMap,Z=new WeakSet,l0=async function(){const e=await Yv(this);this.setAttribute("tone",e)},ta=new WeakMap,ra=new WeakMap,na=new WeakMap,ia=new WeakMap,jh=function(){var n;const e=l(this,fe).activeScreen;l(this,Gr)!==e&&(p(this,Z,Vh).call(this),w(this,Gr,e),(n=l(this,Gr))==null||n.addEventListener("change",l(this,ia)))},Vh=function(){var e;(e=l(this,Gr))==null||e.removeEventListener("change",l(this,ia)),w(this,Gr,null)},Gh=function(e,n){l(this,fe).setActive(e,n)},c0=function(e,n,i){i.stopPropagation();const s=l(this,fe).getTabs(e),o=p(this,Z,d0).call(this,s,n),a=l(this,fe).activeScreen,c=(a==null?void 0:a.id)===n&&a.server.url===e;l(this,fe).removeTab(e,n),c&&(o?l(this,fe).setActive(e,o):l(this,fe).clearActive())},u0=function(e,n,i){const s=l(this,fe).activeScreen;if((s==null?void 0:s.id)===n){s.rename(i.value);return}const o=l(this,Vr).servers.get(e),a=o==null?void 0:o.screens.get(n);!o||!a||o.client.screens.update({screenID:n,name:i.value}).catch(()=>{})},h0=function(){const e=l(this,fe).activeScreen,n=[];for(const i of l(this,Vr).servers.values())for(const s of l(this,fe).getTabs(i.url)){const o=i.screens.get(s);o&&n.push({serverURL:i.url,screenID:o.id,name:o.name,isActive:(e==null?void 0:e.id)===o.id&&e.server.url===i.url})}return n},d0=function(e,n){const i=e.indexOf(n);if(i<0)return null;const s=e.filter(a=>a!==n);if(s.length===0)return null;const o=Math.max(0,i-1);return s[o]??null},Jl=new WeakMap,Xl=new WeakMap,Ql=new WeakMap,ec=new WeakMap,qh=function(e){l(this,fe).addTab(e.serverURL,e.screenID),l(this,fe).setActive(e.serverURL,e.screenID),p(this,Z,Sl).call(this)},p0=function(){return l(this,fe).screens.map(e=>({serverURL:e.server.url,screenID:e.screen.id,name:e.screen.name}))},wl=function(e,n){const i=n.trim().toLowerCase();return i.length===0?e:e.filter(s=>s.name.toLowerCase().includes(i))},tc=new WeakMap,Sl=function(){l(this,$e).kind==="picker"&&(l(this,Er).value&&(l(this,Er).value.open=!1),w(this,$e,{kind:"none"}),l(this,dt).call(this))},rc=new WeakMap,f0=function(){for(const e of l(this,Vr).servers.values())return e;return null},g0=function(){return D`
360
- <segmented-control variant="glass" role="group" aria-label="Screens">
361
- <button
362
- type="button"
363
- ?icon-only=${!0}
364
- aria-label="Choose screen"
365
- @click=${l(this,Jl)}
366
- ${gl(l(this,ts))}
367
- >
368
- ${EO({size:16,weight:"regular"})}
369
- </button>
370
- <button
371
- type="button"
372
- ?icon-only=${!0}
373
- aria-label="New screen"
374
- @click=${l(this,rc)}
375
- >
376
- ${AO({size:16,weight:"regular"})}
377
- </button>
378
- </segmented-control>
379
- `},m0=function(e){return D`
380
- <span class="tab" ?data-active=${e.isActive}>
381
- <button
382
- type="button"
383
- variant="glass"
384
- class="screen-name tab-body"
385
- aria-pressed=${e.isActive?"true":"false"}
386
- aria-current=${e.isActive?"page":le}
387
- aria-label=${e.isActive?`Current tab: ${e.name}`:`Switch to ${e.name}`}
388
- @mousedown=${n=>{n.button===0&&p(this,Z,Gh).call(this,e.serverURL,e.screenID)}}
389
- @click=${()=>p(this,Z,Gh).call(this,e.serverURL,e.screenID)}
390
- >
391
- <span class="tab-leading">
392
- ${kO({weight:"bold"})}
393
- </span>
394
- <editable-text
395
- class="tab-name"
396
- .value=${e.name}
397
- @rename=${n=>p(this,Z,u0).call(this,e.serverURL,e.screenID,n)}
398
- ></editable-text>
399
- </button>
400
- <button
401
- type="button"
402
- variant="ghost"
403
- size="xs"
404
- icon-only
405
- class="tab-close"
406
- aria-label=${`Close ${e.name}`}
407
- @click=${n=>p(this,Z,c0).call(this,e.serverURL,e.screenID,n)}
408
- >
409
- ${Xd({weight:"bold"})}
410
- </button>
411
- </span>
412
- `},v0=function(){var o;const e=l(this,$e).kind==="picker"?l(this,$e).filter:"",n=l(this,$e).kind==="picker"?l(this,$e).highlightedID:null,i=((o=l(this,fe).activeScreen)==null?void 0:o.id)??null,s=p(this,Z,wl).call(this,l(this,rr),e);return D`
413
- <ui-popover
414
- class="picker-popover"
415
- material="glass-frosted"
416
- ?open=${l(this,$e).kind==="picker"}
417
- @close=${l(this,tc)}
418
- @keydown=${l(this,Ql)}
419
- ${gl(l(this,Er))}
420
- >
421
- <div class="picker">
422
- <input
423
- type="text"
424
- class="picker-filter"
425
- placeholder="Filter screens"
426
- aria-label="Filter screens"
427
- .value=${e}
428
- @input=${l(this,Xl)}
429
- ${gl(l(this,ea))}
430
- />
431
- ${s.length===0?D`<p class="picker-empty">
432
- ${l(this,rr).length===0?"No screens":"No matches"}
433
- </p>`:p(this,Z,y0).call(this,s,n,i)}
434
- </div>
435
- </ui-popover>
436
- `},y0=function(e,n,i){return D`
437
- <ul class="picker-list" role="listbox">
438
- <li class="picker-section-label" role="presentation">Recent</li>
439
- ${e.map(s=>{const o=s.screenID===i;return D`
440
- <li
441
- class="picker-row"
442
- role="option"
443
- aria-selected=${s.screenID===n}
444
- aria-current=${o?"true":le}
445
- ?data-highlighted=${s.screenID===n}
446
- ?data-active=${o}
447
- @click=${()=>l(this,ec).call(this,s)}
448
- >
449
- <span class="picker-name">${s.name}</span>
450
- </li>
451
- `})}
452
- </ul>
453
- `},dt=new WeakMap;customElements.define("screen-select",rN);function nN(r){const t=r.toLocaleDateString("en-US",{month:"long",day:"numeric",year:"numeric"}),e=12,n=r.getHours(),i=n%e===0?e:n%e,s=r.getMinutes().toString().padStart(2,"0"),o=n>=e?"pm":"am";return`${t} at ${i}:${s}${o}`}/*! @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:b0,setPrototypeOf:Tm,isFrozen:iN,getPrototypeOf:sN,getOwnPropertyDescriptor:oN}=Object;let{freeze:tt,seal:St,create:_l}=Object,{apply:Yh,construct:Kh}=typeof Reflect<"u"&&Reflect;tt||(tt=function(t){return t});St||(St=function(t){return t});Yh||(Yh=function(t,e){for(var n=arguments.length,i=new Array(n>2?n-2:0),s=2;s<n;s++)i[s-2]=arguments[s];return t.apply(e,i)});Kh||(Kh=function(t){for(var e=arguments.length,n=new Array(e>1?e-1:0),i=1;i<e;i++)n[i-1]=arguments[i];return new t(...n)});const Ya=rt(Array.prototype.forEach),aN=rt(Array.prototype.lastIndexOf),Im=rt(Array.prototype.pop),zs=rt(Array.prototype.push),lN=rt(Array.prototype.splice),kl=rt(String.prototype.toLowerCase),Du=rt(String.prototype.toString),zu=rt(String.prototype.match),Os=rt(String.prototype.replace),cN=rt(String.prototype.indexOf),uN=rt(String.prototype.trim),ut=rt(Object.prototype.hasOwnProperty),Ye=rt(RegExp.prototype.test),Ms=hN(TypeError);function rt(r){return function(t){t instanceof RegExp&&(t.lastIndex=0);for(var e=arguments.length,n=new Array(e>1?e-1:0),i=1;i<e;i++)n[i-1]=arguments[i];return Yh(r,t,n)}}function hN(r){return function(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];return Kh(r,e)}}function G(r,t){let e=arguments.length>2&&arguments[2]!==void 0?arguments[2]:kl;Tm&&Tm(r,null);let n=t.length;for(;n--;){let i=t[n];if(typeof i=="string"){const s=e(i);s!==i&&(iN(t)||(t[n]=s),i=s)}r[i]=!0}return r}function dN(r){for(let t=0;t<r.length;t++)ut(r,t)||(r[t]=null);return r}function Wt(r){const t=_l(null);for(const[e,n]of b0(r))ut(r,e)&&(Array.isArray(n)?t[e]=dN(n):n&&typeof n=="object"&&n.constructor===Object?t[e]=Wt(n):t[e]=n);return t}function Ns(r,t){for(;r!==null;){const n=oN(r,t);if(n){if(n.get)return rt(n.get);if(typeof n.value=="function")return rt(n.value)}r=sN(r)}function e(){return null}return e}const Cm=tt(["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"]),Ou=tt(["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"]),Mu=tt(["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"]),pN=tt(["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"]),Nu=tt(["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"]),fN=tt(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),Rm=tt(["#text"]),Pm=tt(["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"]),Uu=tt(["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"]),Lm=tt(["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"]),Ka=tt(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),gN=St(/\{\{[\w\W]*|[\w\W]*\}\}/gm),mN=St(/<%[\w\W]*|[\w\W]*%>/gm),vN=St(/\$\{[\w\W]*/gm),yN=St(/^data-[\-\w.\u00B7-\uFFFF]+$/),bN=St(/^aria-[\-\w]+$/),w0=St(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),wN=St(/^(?:\w+script|data):/i),SN=St(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),S0=St(/^html$/i),_N=St(/^[a-z][.\w]*(-[.\w]+)+$/i);var Dm=Object.freeze({__proto__:null,ARIA_ATTR:bN,ATTR_WHITESPACE:SN,CUSTOM_ELEMENT:_N,DATA_ATTR:yN,DOCTYPE_NAME:S0,ERB_EXPR:mN,IS_ALLOWED_URI:w0,IS_SCRIPT_OR_DATA:wN,MUSTACHE_EXPR:gN,TMPLIT_EXPR:vN});const Us={element:1,text:3,progressingInstruction:7,comment:8,document:9},kN=function(){return typeof window>"u"?null:window},xN=function(t,e){if(typeof t!="object"||typeof t.createPolicy!="function")return null;let n=null;const i="data-tt-policy-suffix";e&&e.hasAttribute(i)&&(n=e.getAttribute(i));const s="dompurify"+(n?"#"+n:"");try{return t.createPolicy(s,{createHTML(o){return o},createScriptURL(o){return o}})}catch{return console.warn("TrustedTypes policy "+s+" could not be created."),null}},zm=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}};function _0(){let r=arguments.length>0&&arguments[0]!==void 0?arguments[0]:kN();const t=U=>_0(U);if(t.version="3.3.3",t.removed=[],!r||!r.document||r.document.nodeType!==Us.document||!r.Element)return t.isSupported=!1,t;let{document:e}=r;const n=e,i=n.currentScript,{DocumentFragment:s,HTMLTemplateElement:o,Node:a,Element:c,NodeFilter:u,NamedNodeMap:h=r.NamedNodeMap||r.MozNamedAttrMap,HTMLFormElement:f,DOMParser:y,trustedTypes:m}=r,E=c.prototype,x=Ns(E,"cloneNode"),I=Ns(E,"remove"),P=Ns(E,"nextSibling"),R=Ns(E,"childNodes"),B=Ns(E,"parentNode");if(typeof o=="function"){const U=e.createElement("template");U.content&&U.content.ownerDocument&&(e=U.content.ownerDocument)}let N,F="";const{implementation:Y,createNodeIterator:V,createDocumentFragment:ce,getElementsByTagName:Et}=e,{importNode:ln}=n;let ze=zm();t.isSupported=typeof b0=="function"&&typeof B=="function"&&Y&&Y.createHTMLDocument!==void 0;const{MUSTACHE_EXPR:cn,ERB_EXPR:Nt,TMPLIT_EXPR:Pr,DATA_ATTR:Ic,ARIA_ATTR:Ea,IS_SCRIPT_OR_DATA:W0,ATTR_WHITESPACE:dp,CUSTOM_ELEMENT:B0}=Dm;let{IS_ALLOWED_URI:pp}=Dm,Re=null;const fp=G({},[...Cm,...Ou,...Mu,...Nu,...Rm]);let Oe=null;const gp=G({},[...Pm,...Uu,...Lm,...Ka]);let Se=Object.seal(_l(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}})),As=null,Aa=null;const Lr=Object.seal(_l(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let mp=!0,Cc=!0,vp=!1,yp=!0,ni=!1,$a=!0,un=!1,Rc=!1,Pc=!1,ii=!1,Ta=!1,Ia=!1,bp=!0,wp=!1;const j0="user-content-";let Lc=!0,$s=!1,si={},Ut=null;const Dc=G({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","style","svg","template","thead","title","video","xmp"]);let Sp=null;const _p=G({},["audio","video","img","source","image","track"]);let zc=null;const kp=G({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),Ca="http://www.w3.org/1998/Math/MathML",Ra="http://www.w3.org/2000/svg",ur="http://www.w3.org/1999/xhtml";let oi=ur,Oc=!1,Mc=null;const V0=G({},[Ca,Ra,ur],Du);let Pa=G({},["mi","mo","mn","ms","mtext"]),La=G({},["annotation-xml"]);const G0=G({},["title","style","font","a","script"]);let Ts=null;const q0=["application/xhtml+xml","text/html"],Y0="text/html";let Ae=null,ai=null;const K0=e.createElement("form"),xp=function(b){return b instanceof RegExp||b instanceof Function},Nc=function(){let b=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(!(ai&&ai===b)){if((!b||typeof b!="object")&&(b={}),b=Wt(b),Ts=q0.indexOf(b.PARSER_MEDIA_TYPE)===-1?Y0:b.PARSER_MEDIA_TYPE,Ae=Ts==="application/xhtml+xml"?Du:kl,Re=ut(b,"ALLOWED_TAGS")?G({},b.ALLOWED_TAGS,Ae):fp,Oe=ut(b,"ALLOWED_ATTR")?G({},b.ALLOWED_ATTR,Ae):gp,Mc=ut(b,"ALLOWED_NAMESPACES")?G({},b.ALLOWED_NAMESPACES,Du):V0,zc=ut(b,"ADD_URI_SAFE_ATTR")?G(Wt(kp),b.ADD_URI_SAFE_ATTR,Ae):kp,Sp=ut(b,"ADD_DATA_URI_TAGS")?G(Wt(_p),b.ADD_DATA_URI_TAGS,Ae):_p,Ut=ut(b,"FORBID_CONTENTS")?G({},b.FORBID_CONTENTS,Ae):Dc,As=ut(b,"FORBID_TAGS")?G({},b.FORBID_TAGS,Ae):Wt({}),Aa=ut(b,"FORBID_ATTR")?G({},b.FORBID_ATTR,Ae):Wt({}),si=ut(b,"USE_PROFILES")?b.USE_PROFILES:!1,mp=b.ALLOW_ARIA_ATTR!==!1,Cc=b.ALLOW_DATA_ATTR!==!1,vp=b.ALLOW_UNKNOWN_PROTOCOLS||!1,yp=b.ALLOW_SELF_CLOSE_IN_ATTR!==!1,ni=b.SAFE_FOR_TEMPLATES||!1,$a=b.SAFE_FOR_XML!==!1,un=b.WHOLE_DOCUMENT||!1,ii=b.RETURN_DOM||!1,Ta=b.RETURN_DOM_FRAGMENT||!1,Ia=b.RETURN_TRUSTED_TYPE||!1,Pc=b.FORCE_BODY||!1,bp=b.SANITIZE_DOM!==!1,wp=b.SANITIZE_NAMED_PROPS||!1,Lc=b.KEEP_CONTENT!==!1,$s=b.IN_PLACE||!1,pp=b.ALLOWED_URI_REGEXP||w0,oi=b.NAMESPACE||ur,Pa=b.MATHML_TEXT_INTEGRATION_POINTS||Pa,La=b.HTML_INTEGRATION_POINTS||La,Se=b.CUSTOM_ELEMENT_HANDLING||{},b.CUSTOM_ELEMENT_HANDLING&&xp(b.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(Se.tagNameCheck=b.CUSTOM_ELEMENT_HANDLING.tagNameCheck),b.CUSTOM_ELEMENT_HANDLING&&xp(b.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(Se.attributeNameCheck=b.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),b.CUSTOM_ELEMENT_HANDLING&&typeof b.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements=="boolean"&&(Se.allowCustomizedBuiltInElements=b.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),ni&&(Cc=!1),Ta&&(ii=!0),si&&(Re=G({},Rm),Oe=_l(null),si.html===!0&&(G(Re,Cm),G(Oe,Pm)),si.svg===!0&&(G(Re,Ou),G(Oe,Uu),G(Oe,Ka)),si.svgFilters===!0&&(G(Re,Mu),G(Oe,Uu),G(Oe,Ka)),si.mathMl===!0&&(G(Re,Nu),G(Oe,Lm),G(Oe,Ka))),ut(b,"ADD_TAGS")||(Lr.tagCheck=null),ut(b,"ADD_ATTR")||(Lr.attributeCheck=null),b.ADD_TAGS&&(typeof b.ADD_TAGS=="function"?Lr.tagCheck=b.ADD_TAGS:(Re===fp&&(Re=Wt(Re)),G(Re,b.ADD_TAGS,Ae))),b.ADD_ATTR&&(typeof b.ADD_ATTR=="function"?Lr.attributeCheck=b.ADD_ATTR:(Oe===gp&&(Oe=Wt(Oe)),G(Oe,b.ADD_ATTR,Ae))),b.ADD_URI_SAFE_ATTR&&G(zc,b.ADD_URI_SAFE_ATTR,Ae),b.FORBID_CONTENTS&&(Ut===Dc&&(Ut=Wt(Ut)),G(Ut,b.FORBID_CONTENTS,Ae)),b.ADD_FORBID_CONTENTS&&(Ut===Dc&&(Ut=Wt(Ut)),G(Ut,b.ADD_FORBID_CONTENTS,Ae)),Lc&&(Re["#text"]=!0),un&&G(Re,["html","head","body"]),Re.table&&(G(Re,["tbody"]),delete As.tbody),b.TRUSTED_TYPES_POLICY){if(typeof b.TRUSTED_TYPES_POLICY.createHTML!="function")throw Ms('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof b.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw Ms('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');N=b.TRUSTED_TYPES_POLICY,F=N.createHTML("")}else N===void 0&&(N=xN(m,i)),N!==null&&typeof F=="string"&&(F=N.createHTML(""));tt&&tt(b),ai=b}},Ep=G({},[...Ou,...Mu,...pN]),Ap=G({},[...Nu,...fN]),J0=function(b){let C=B(b);(!C||!C.tagName)&&(C={namespaceURI:oi,tagName:"template"});const L=kl(b.tagName),de=kl(C.tagName);return Mc[b.namespaceURI]?b.namespaceURI===Ra?C.namespaceURI===ur?L==="svg":C.namespaceURI===Ca?L==="svg"&&(de==="annotation-xml"||Pa[de]):!!Ep[L]:b.namespaceURI===Ca?C.namespaceURI===ur?L==="math":C.namespaceURI===Ra?L==="math"&&La[de]:!!Ap[L]:b.namespaceURI===ur?C.namespaceURI===Ra&&!La[de]||C.namespaceURI===Ca&&!Pa[de]?!1:!Ap[L]&&(G0[L]||!Ep[L]):!!(Ts==="application/xhtml+xml"&&Mc[b.namespaceURI]):!1},Ft=function(b){zs(t.removed,{element:b});try{B(b).removeChild(b)}catch{I(b)}},hn=function(b,C){try{zs(t.removed,{attribute:C.getAttributeNode(b),from:C})}catch{zs(t.removed,{attribute:null,from:C})}if(C.removeAttribute(b),b==="is")if(ii||Ta)try{Ft(C)}catch{}else try{C.setAttribute(b,"")}catch{}},$p=function(b){let C=null,L=null;if(Pc)b="<remove></remove>"+b;else{const _e=zu(b,/^[\r\n\t ]+/);L=_e&&_e[0]}Ts==="application/xhtml+xml"&&oi===ur&&(b='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+b+"</body></html>");const de=N?N.createHTML(b):b;if(oi===ur)try{C=new y().parseFromString(de,Ts)}catch{}if(!C||!C.documentElement){C=Y.createDocument(oi,"template",null);try{C.documentElement.innerHTML=Oc?F:de}catch{}}const Ve=C.body||C.documentElement;return b&&L&&Ve.insertBefore(e.createTextNode(L),Ve.childNodes[0]||null),oi===ur?Et.call(C,un?"html":"body")[0]:un?C.documentElement:Ve},Tp=function(b){return V.call(b.ownerDocument||b,b,u.SHOW_ELEMENT|u.SHOW_COMMENT|u.SHOW_TEXT|u.SHOW_PROCESSING_INSTRUCTION|u.SHOW_CDATA_SECTION,null)},Uc=function(b){return b instanceof f&&(typeof b.nodeName!="string"||typeof b.textContent!="string"||typeof b.removeChild!="function"||!(b.attributes instanceof h)||typeof b.removeAttribute!="function"||typeof b.setAttribute!="function"||typeof b.namespaceURI!="string"||typeof b.insertBefore!="function"||typeof b.hasChildNodes!="function")},Ip=function(b){return typeof a=="function"&&b instanceof a};function hr(U,b,C){Ya(U,L=>{L.call(t,b,C,ai)})}const Cp=function(b){let C=null;if(hr(ze.beforeSanitizeElements,b,null),Uc(b))return Ft(b),!0;const L=Ae(b.nodeName);if(hr(ze.uponSanitizeElement,b,{tagName:L,allowedTags:Re}),$a&&b.hasChildNodes()&&!Ip(b.firstElementChild)&&Ye(/<[/\w!]/g,b.innerHTML)&&Ye(/<[/\w!]/g,b.textContent)||b.nodeType===Us.progressingInstruction||$a&&b.nodeType===Us.comment&&Ye(/<[/\w]/g,b.data))return Ft(b),!0;if(!(Lr.tagCheck instanceof Function&&Lr.tagCheck(L))&&(!Re[L]||As[L])){if(!As[L]&&Pp(L)&&(Se.tagNameCheck instanceof RegExp&&Ye(Se.tagNameCheck,L)||Se.tagNameCheck instanceof Function&&Se.tagNameCheck(L)))return!1;if(Lc&&!Ut[L]){const de=B(b)||b.parentNode,Ve=R(b)||b.childNodes;if(Ve&&de){const _e=Ve.length;for(let nt=_e-1;nt>=0;--nt){const dr=x(Ve[nt],!0);dr.__removalCount=(b.__removalCount||0)+1,de.insertBefore(dr,P(b))}}}return Ft(b),!0}return b instanceof c&&!J0(b)||(L==="noscript"||L==="noembed"||L==="noframes")&&Ye(/<\/no(script|embed|frames)/i,b.innerHTML)?(Ft(b),!0):(ni&&b.nodeType===Us.text&&(C=b.textContent,Ya([cn,Nt,Pr],de=>{C=Os(C,de," ")}),b.textContent!==C&&(zs(t.removed,{element:b.cloneNode()}),b.textContent=C)),hr(ze.afterSanitizeElements,b,null),!1)},Rp=function(b,C,L){if(Aa[C]||bp&&(C==="id"||C==="name")&&(L in e||L in K0))return!1;if(!(Cc&&!Aa[C]&&Ye(Ic,C))){if(!(mp&&Ye(Ea,C))){if(!(Lr.attributeCheck instanceof Function&&Lr.attributeCheck(C,b))){if(!Oe[C]||Aa[C]){if(!(Pp(b)&&(Se.tagNameCheck instanceof RegExp&&Ye(Se.tagNameCheck,b)||Se.tagNameCheck instanceof Function&&Se.tagNameCheck(b))&&(Se.attributeNameCheck instanceof RegExp&&Ye(Se.attributeNameCheck,C)||Se.attributeNameCheck instanceof Function&&Se.attributeNameCheck(C,b))||C==="is"&&Se.allowCustomizedBuiltInElements&&(Se.tagNameCheck instanceof RegExp&&Ye(Se.tagNameCheck,L)||Se.tagNameCheck instanceof Function&&Se.tagNameCheck(L))))return!1}else if(!zc[C]){if(!Ye(pp,Os(L,dp,""))){if(!((C==="src"||C==="xlink:href"||C==="href")&&b!=="script"&&cN(L,"data:")===0&&Sp[b])){if(!(vp&&!Ye(W0,Os(L,dp,"")))){if(L)return!1}}}}}}}return!0},Pp=function(b){return b!=="annotation-xml"&&zu(b,B0)},Lp=function(b){hr(ze.beforeSanitizeAttributes,b,null);const{attributes:C}=b;if(!C||Uc(b))return;const L={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:Oe,forceKeepAttr:void 0};let de=C.length;for(;de--;){const Ve=C[de],{name:_e,namespaceURI:nt,value:dr}=Ve,li=Ae(_e),Fc=dr;let Me=_e==="value"?Fc:uN(Fc);if(L.attrName=li,L.attrValue=Me,L.keepAttr=!0,L.forceKeepAttr=void 0,hr(ze.uponSanitizeAttribute,b,L),Me=L.attrValue,wp&&(li==="id"||li==="name")&&(hn(_e,b),Me=j0+Me),$a&&Ye(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,Me)){hn(_e,b);continue}if(li==="attributename"&&zu(Me,"href")){hn(_e,b);continue}if(L.forceKeepAttr)continue;if(!L.keepAttr){hn(_e,b);continue}if(!yp&&Ye(/\/>/i,Me)){hn(_e,b);continue}ni&&Ya([cn,Nt,Pr],zp=>{Me=Os(Me,zp," ")});const Dp=Ae(b.nodeName);if(!Rp(Dp,li,Me)){hn(_e,b);continue}if(N&&typeof m=="object"&&typeof m.getAttributeType=="function"&&!nt)switch(m.getAttributeType(Dp,li)){case"TrustedHTML":{Me=N.createHTML(Me);break}case"TrustedScriptURL":{Me=N.createScriptURL(Me);break}}if(Me!==Fc)try{nt?b.setAttributeNS(nt,_e,Me):b.setAttribute(_e,Me),Uc(b)?Ft(b):Im(t.removed)}catch{hn(_e,b)}}hr(ze.afterSanitizeAttributes,b,null)},X0=function U(b){let C=null;const L=Tp(b);for(hr(ze.beforeSanitizeShadowDOM,b,null);C=L.nextNode();)hr(ze.uponSanitizeShadowNode,C,null),Cp(C),Lp(C),C.content instanceof s&&U(C.content);hr(ze.afterSanitizeShadowDOM,b,null)};return t.sanitize=function(U){let b=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},C=null,L=null,de=null,Ve=null;if(Oc=!U,Oc&&(U="<!-->"),typeof U!="string"&&!Ip(U))if(typeof U.toString=="function"){if(U=U.toString(),typeof U!="string")throw Ms("dirty is not a string, aborting")}else throw Ms("toString is not a function");if(!t.isSupported)return U;if(Rc||Nc(b),t.removed=[],typeof U=="string"&&($s=!1),$s){if(U.nodeName){const dr=Ae(U.nodeName);if(!Re[dr]||As[dr])throw Ms("root node is forbidden and cannot be sanitized in-place")}}else if(U instanceof a)C=$p("<!---->"),L=C.ownerDocument.importNode(U,!0),L.nodeType===Us.element&&L.nodeName==="BODY"||L.nodeName==="HTML"?C=L:C.appendChild(L);else{if(!ii&&!ni&&!un&&U.indexOf("<")===-1)return N&&Ia?N.createHTML(U):U;if(C=$p(U),!C)return ii?null:Ia?F:""}C&&Pc&&Ft(C.firstChild);const _e=Tp($s?U:C);for(;de=_e.nextNode();)Cp(de),Lp(de),de.content instanceof s&&X0(de.content);if($s)return U;if(ii){if(Ta)for(Ve=ce.call(C.ownerDocument);C.firstChild;)Ve.appendChild(C.firstChild);else Ve=C;return(Oe.shadowroot||Oe.shadowrootmode)&&(Ve=ln.call(n,Ve,!0)),Ve}let nt=un?C.outerHTML:C.innerHTML;return un&&Re["!doctype"]&&C.ownerDocument&&C.ownerDocument.doctype&&C.ownerDocument.doctype.name&&Ye(S0,C.ownerDocument.doctype.name)&&(nt="<!DOCTYPE "+C.ownerDocument.doctype.name+`>
454
- `+nt),ni&&Ya([cn,Nt,Pr],dr=>{nt=Os(nt,dr," ")}),N&&Ia?N.createHTML(nt):nt},t.setConfig=function(){let U=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};Nc(U),Rc=!0},t.clearConfig=function(){ai=null,Rc=!1},t.isValidAttribute=function(U,b,C){ai||Nc({});const L=Ae(U),de=Ae(b);return Rp(L,de,C)},t.addHook=function(U,b){typeof b=="function"&&zs(ze[U],b)},t.removeHook=function(U,b){if(b!==void 0){const C=aN(ze[U],b);return C===-1?void 0:lN(ze[U],C,1)[0]}return Im(ze[U])},t.removeHooks=function(U){ze[U]=[]},t.removeAllHooks=function(){ze=zm()},t}var k0=_0();function ep(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var ri=ep();function x0(r){ri=r}var wn={exec:()=>null};function J(r,t=""){let e=typeof r=="string"?r:r.source,n={replace:(i,s)=>{let o=typeof s=="string"?s:s.source;return o=o.replace(et.caret,"$1"),e=e.replace(i,o),n},getRegex:()=>new RegExp(e,t)};return n}var EN=(()=>{try{return!!new RegExp("(?<=1)(?<!1)")}catch{return!1}})(),et={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:r=>new RegExp(`^( {0,3}${r})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:r=>new RegExp(`^ {0,${Math.min(3,r-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),hrRegex:r=>new RegExp(`^ {0,${Math.min(3,r-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),fencesBeginRegex:r=>new RegExp(`^ {0,${Math.min(3,r-1)}}(?:\`\`\`|~~~)`),headingBeginRegex:r=>new RegExp(`^ {0,${Math.min(3,r-1)}}#`),htmlBeginRegex:r=>new RegExp(`^ {0,${Math.min(3,r-1)}}<(?:[a-z].*>|!--)`,"i"),blockquoteBeginRegex:r=>new RegExp(`^ {0,${Math.min(3,r-1)}}>`)},AN=/^(?:[ \t]*(?:\n|$))+/,$N=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,TN=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,xa=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,IN=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,tp=/ {0,3}(?:[*+-]|\d{1,9}[.)])/,E0=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,A0=J(E0).replace(/bull/g,tp).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(),CN=J(E0).replace(/bull/g,tp).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(),rp=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,RN=/^[^\n]+/,np=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,PN=J(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",np).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),LN=J(/^(bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,tp).getRegex(),$c="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",ip=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,DN=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",ip).replace("tag",$c).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),$0=J(rp).replace("hr",xa).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",$c).getRegex(),zN=J(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",$0).getRegex(),sp={blockquote:zN,code:$N,def:PN,fences:TN,heading:IN,hr:xa,html:DN,lheading:A0,list:LN,newline:AN,paragraph:$0,table:wn,text:RN},Om=J("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",xa).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",$c).getRegex(),ON={...sp,lheading:CN,table:Om,paragraph:J(rp).replace("hr",xa).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",Om).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",$c).getRegex()},MN={...sp,html:J(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",ip).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:wn,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:J(rp).replace("hr",xa).replace("heading",` *#{1,6} *[^
455
- ]`).replace("lheading",A0).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},NN=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,UN=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,T0=/^( {2,}|\\)\n(?!\s*$)/,FN=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,Es=/[\p{P}\p{S}]/u,Tc=/[\s\p{P}\p{S}]/u,op=/[^\s\p{P}\p{S}]/u,HN=J(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,Tc).getRegex(),I0=/(?!~)[\p{P}\p{S}]/u,ZN=/(?!~)[\s\p{P}\p{S}]/u,WN=/(?:[^\s\p{P}\p{S}]|~)/u,BN=J(/link|precode-code|html/,"g").replace("link",/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-",EN?"(?<!`)()":"(^^|[^`])").replace("code",/(?<b>`+)[^`]+\k<b>(?!`)/).replace("html",/<(?! )[^<>]*?>/).getRegex(),C0=/^(?:\*+(?:((?!\*)punct)|([^\s*]))?)|^_+(?:((?!_)punct)|([^\s_]))?/,jN=J(C0,"u").replace(/punct/g,Es).getRegex(),VN=J(C0,"u").replace(/punct/g,I0).getRegex(),R0="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",GN=J(R0,"gu").replace(/notPunctSpace/g,op).replace(/punctSpace/g,Tc).replace(/punct/g,Es).getRegex(),qN=J(R0,"gu").replace(/notPunctSpace/g,WN).replace(/punctSpace/g,ZN).replace(/punct/g,I0).getRegex(),YN=J("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,op).replace(/punctSpace/g,Tc).replace(/punct/g,Es).getRegex(),KN=J(/^~~?(?:((?!~)punct)|[^\s~])/,"u").replace(/punct/g,Es).getRegex(),JN="^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)",XN=J(JN,"gu").replace(/notPunctSpace/g,op).replace(/punctSpace/g,Tc).replace(/punct/g,Es).getRegex(),QN=J(/\\(punct)/,"gu").replace(/punct/g,Es).getRegex(),e6=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(),t6=J(ip).replace("(?:-->|$)","-->").getRegex(),r6=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",t6).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),Zl=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\])|[^\[\]\\`])*?/,n6=J(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?\s*\)/).replace("label",Zl).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),P0=J(/^!?\[(label)\]\[(ref)\]/).replace("label",Zl).replace("ref",np).getRegex(),L0=J(/^!?\[(ref)\](?:\[\])?/).replace("ref",np).getRegex(),i6=J("reflink|nolink(?!\\()","g").replace("reflink",P0).replace("nolink",L0).getRegex(),Mm=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,ap={_backpedal:wn,anyPunctuation:QN,autolink:e6,blockSkip:BN,br:T0,code:UN,del:wn,delLDelim:wn,delRDelim:wn,emStrongLDelim:jN,emStrongRDelimAst:GN,emStrongRDelimUnd:YN,escape:NN,link:n6,nolink:L0,punctuation:HN,reflink:P0,reflinkSearch:i6,tag:r6,text:FN,url:wn},s6={...ap,link:J(/^!?\[(label)\]\((.*?)\)/).replace("label",Zl).getRegex(),reflink:J(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",Zl).getRegex()},Jh={...ap,emStrongRDelimAst:qN,emStrongLDelim:VN,delLDelim:KN,delRDelim:XN,url:J(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol",Mm).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",Mm).getRegex()},o6={...Jh,br:J(T0).replace("{2,}","*").getRegex(),text:J(Jh.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},Ja={normal:sp,gfm:ON,pedantic:MN},Fs={normal:ap,gfm:Jh,breaks:o6,pedantic:s6},a6={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},Nm=r=>a6[r];function Bt(r,t){if(t){if(et.escapeTest.test(r))return r.replace(et.escapeReplace,Nm)}else if(et.escapeTestNoEncode.test(r))return r.replace(et.escapeReplaceNoEncode,Nm);return r}function Um(r){try{r=encodeURI(r).replace(et.percentDecode,"%")}catch{return null}return r}function Fm(r,t){var s;let e=r.replace(et.findPipe,(o,a,c)=>{let u=!1,h=a;for(;--h>=0&&c[h]==="\\";)u=!u;return u?"|":" |"}),n=e.split(et.splitPipe),i=0;if(n[0].trim()||n.shift(),n.length>0&&!((s=n.at(-1))!=null&&s.trim())&&n.pop(),t)if(n.length>t)n.splice(t);else for(;n.length<t;)n.push("");for(;i<n.length;i++)n[i]=n[i].trim().replace(et.slashPipe,"|");return n}function Hs(r,t,e){let n=r.length;if(n===0)return"";let i=0;for(;i<n&&r.charAt(n-i-1)===t;)i++;return r.slice(0,n-i)}function l6(r,t){if(r.indexOf(t[1])===-1)return-1;let e=0;for(let n=0;n<r.length;n++)if(r[n]==="\\")n++;else if(r[n]===t[0])e++;else if(r[n]===t[1]&&(e--,e<0))return n;return e>0?-2:-1}function c6(r,t=0){let e=t,n="";for(let i of r)if(i===" "){let s=4-e%4;n+=" ".repeat(s),e+=s}else n+=i,e++;return n}function Hm(r,t,e,n,i){let s=t.href,o=t.title||null,a=r[1].replace(i.other.outputLinkReplace,"$1");n.state.inLink=!0;let c={type:r[0].charAt(0)==="!"?"image":"link",raw:e,href:s,title:o,text:a,tokens:n.inlineTokens(a)};return n.state.inLink=!1,c}function u6(r,t,e){let n=r.match(e.other.indentCodeCompensation);if(n===null)return t;let i=n[1];return t.split(`
456
- `).map(s=>{let o=s.match(e.other.beginningSpace);if(o===null)return s;let[a]=o;return a.length>=i.length?s.slice(i.length):s}).join(`
457
- `)}var Wl=class{constructor(r){g(this,"options");g(this,"rules");g(this,"lexer");this.options=r||ri}space(r){let t=this.rules.block.newline.exec(r);if(t&&t[0].length>0)return{type:"space",raw:t[0]}}code(r){let t=this.rules.block.code.exec(r);if(t){let e=t[0].replace(this.rules.other.codeRemoveIndent,"");return{type:"code",raw:t[0],codeBlockStyle:"indented",text:this.options.pedantic?e:Hs(e,`
458
- `)}}}fences(r){let t=this.rules.block.fences.exec(r);if(t){let e=t[0],n=u6(e,t[3]||"",this.rules);return{type:"code",raw:e,lang:t[2]?t[2].trim().replace(this.rules.inline.anyPunctuation,"$1"):t[2],text:n}}}heading(r){let t=this.rules.block.heading.exec(r);if(t){let e=t[2].trim();if(this.rules.other.endingHash.test(e)){let n=Hs(e,"#");(this.options.pedantic||!n||this.rules.other.endingSpaceChar.test(n))&&(e=n.trim())}return{type:"heading",raw:t[0],depth:t[1].length,text:e,tokens:this.lexer.inline(e)}}}hr(r){let t=this.rules.block.hr.exec(r);if(t)return{type:"hr",raw:Hs(t[0],`
459
- `)}}blockquote(r){let t=this.rules.block.blockquote.exec(r);if(t){let e=Hs(t[0],`
460
- `).split(`
461
- `),n="",i="",s=[];for(;e.length>0;){let o=!1,a=[],c;for(c=0;c<e.length;c++)if(this.rules.other.blockquoteStart.test(e[c]))a.push(e[c]),o=!0;else if(!o)a.push(e[c]);else break;e=e.slice(c);let u=a.join(`
462
- `),h=u.replace(this.rules.other.blockquoteSetextReplace,`
463
- $1`).replace(this.rules.other.blockquoteSetextReplace2,"");n=n?`${n}
464
- ${u}`:u,i=i?`${i}
465
- ${h}`:h;let f=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(h,s,!0),this.lexer.state.top=f,e.length===0)break;let y=s.at(-1);if((y==null?void 0:y.type)==="code")break;if((y==null?void 0:y.type)==="blockquote"){let m=y,E=m.raw+`
466
- `+e.join(`
467
- `),x=this.blockquote(E);s[s.length-1]=x,n=n.substring(0,n.length-m.raw.length)+x.raw,i=i.substring(0,i.length-m.text.length)+x.text;break}else if((y==null?void 0:y.type)==="list"){let m=y,E=m.raw+`
468
- `+e.join(`
469
- `),x=this.list(E);s[s.length-1]=x,n=n.substring(0,n.length-y.raw.length)+x.raw,i=i.substring(0,i.length-m.raw.length)+x.raw,e=E.substring(s.at(-1).raw.length).split(`
470
- `);continue}}return{type:"blockquote",raw:n,tokens:s,text:i}}}list(r){var e,n;let t=this.rules.block.list.exec(r);if(t){let i=t[1].trim(),s=i.length>1,o={type:"list",raw:"",ordered:s,start:s?+i.slice(0,-1):"",loose:!1,items:[]};i=s?`\\d{1,9}\\${i.slice(-1)}`:`\\${i}`,this.options.pedantic&&(i=s?i:"[*+-]");let a=this.rules.other.listItemRegex(i),c=!1;for(;r;){let h=!1,f="",y="";if(!(t=a.exec(r))||this.rules.block.hr.test(r))break;f=t[0],r=r.substring(f.length);let m=c6(t[2].split(`
471
- `,1)[0],t[1].length),E=r.split(`
472
- `,1)[0],x=!m.trim(),I=0;if(this.options.pedantic?(I=2,y=m.trimStart()):x?I=t[1].length+1:(I=m.search(this.rules.other.nonSpaceChar),I=I>4?1:I,y=m.slice(I),I+=t[1].length),x&&this.rules.other.blankLine.test(E)&&(f+=E+`
473
- `,r=r.substring(E.length+1),h=!0),!h){let P=this.rules.other.nextBulletRegex(I),R=this.rules.other.hrRegex(I),B=this.rules.other.fencesBeginRegex(I),N=this.rules.other.headingBeginRegex(I),F=this.rules.other.htmlBeginRegex(I),Y=this.rules.other.blockquoteBeginRegex(I);for(;r;){let V=r.split(`
474
- `,1)[0],ce;if(E=V,this.options.pedantic?(E=E.replace(this.rules.other.listReplaceNesting," "),ce=E):ce=E.replace(this.rules.other.tabCharGlobal," "),B.test(E)||N.test(E)||F.test(E)||Y.test(E)||P.test(E)||R.test(E))break;if(ce.search(this.rules.other.nonSpaceChar)>=I||!E.trim())y+=`
475
- `+ce.slice(I);else{if(x||m.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4||B.test(m)||N.test(m)||R.test(m))break;y+=`
476
- `+E}x=!E.trim(),f+=V+`
477
- `,r=r.substring(V.length+1),m=ce.slice(I)}}o.loose||(c?o.loose=!0:this.rules.other.doubleBlankLine.test(f)&&(c=!0)),o.items.push({type:"list_item",raw:f,task:!!this.options.gfm&&this.rules.other.listIsTask.test(y),loose:!1,text:y,tokens:[]}),o.raw+=f}let u=o.items.at(-1);if(u)u.raw=u.raw.trimEnd(),u.text=u.text.trimEnd();else return;o.raw=o.raw.trimEnd();for(let h of o.items){if(this.lexer.state.top=!1,h.tokens=this.lexer.blockTokens(h.text,[]),h.task){if(h.text=h.text.replace(this.rules.other.listReplaceTask,""),((e=h.tokens[0])==null?void 0:e.type)==="text"||((n=h.tokens[0])==null?void 0:n.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 y=this.lexer.inlineQueue.length-1;y>=0;y--)if(this.rules.other.listIsTask.test(this.lexer.inlineQueue[y].src)){this.lexer.inlineQueue[y].src=this.lexer.inlineQueue[y].src.replace(this.rules.other.listReplaceTask,"");break}}let f=this.rules.other.listTaskCheckbox.exec(h.raw);if(f){let y={type:"checkbox",raw:f[0]+" ",checked:f[0]!=="[ ]"};h.checked=y.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=y.raw+h.tokens[0].raw,h.tokens[0].text=y.raw+h.tokens[0].text,h.tokens[0].tokens.unshift(y)):h.tokens.unshift({type:"paragraph",raw:y.raw,text:y.raw,tokens:[y]}):h.tokens.unshift(y)}}if(!o.loose){let f=h.tokens.filter(m=>m.type==="space"),y=f.length>0&&f.some(m=>this.rules.other.anyLine.test(m.raw));o.loose=y}}if(o.loose)for(let h of o.items){h.loose=!0;for(let f of h.tokens)f.type==="text"&&(f.type="paragraph")}return o}}html(r){let t=this.rules.block.html.exec(r);if(t)return{type:"html",block:!0,raw:t[0],pre:t[1]==="pre"||t[1]==="script"||t[1]==="style",text:t[0]}}def(r){let t=this.rules.block.def.exec(r);if(t){let e=t[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal," "),n=t[2]?t[2].replace(this.rules.other.hrefBrackets,"$1").replace(this.rules.inline.anyPunctuation,"$1"):"",i=t[3]?t[3].substring(1,t[3].length-1).replace(this.rules.inline.anyPunctuation,"$1"):t[3];return{type:"def",tag:e,raw:t[0],href:n,title:i}}}table(r){var o;let t=this.rules.block.table.exec(r);if(!t||!this.rules.other.tableDelimiter.test(t[2]))return;let e=Fm(t[1]),n=t[2].replace(this.rules.other.tableAlignChars,"").split("|"),i=(o=t[3])!=null&&o.trim()?t[3].replace(this.rules.other.tableRowBlankLine,"").split(`
478
- `):[],s={type:"table",raw:t[0],header:[],align:[],rows:[]};if(e.length===n.length){for(let a of n)this.rules.other.tableAlignRight.test(a)?s.align.push("right"):this.rules.other.tableAlignCenter.test(a)?s.align.push("center"):this.rules.other.tableAlignLeft.test(a)?s.align.push("left"):s.align.push(null);for(let a=0;a<e.length;a++)s.header.push({text:e[a],tokens:this.lexer.inline(e[a]),header:!0,align:s.align[a]});for(let a of i)s.rows.push(Fm(a,s.header.length).map((c,u)=>({text:c,tokens:this.lexer.inline(c),header:!1,align:s.align[u]})));return s}}lheading(r){let t=this.rules.block.lheading.exec(r);if(t){let e=t[1].trim();return{type:"heading",raw:t[0],depth:t[2].charAt(0)==="="?1:2,text:e,tokens:this.lexer.inline(e)}}}paragraph(r){let t=this.rules.block.paragraph.exec(r);if(t){let e=t[1].charAt(t[1].length-1)===`
479
- `?t[1].slice(0,-1):t[1];return{type:"paragraph",raw:t[0],text:e,tokens:this.lexer.inline(e)}}}text(r){let t=this.rules.block.text.exec(r);if(t)return{type:"text",raw:t[0],text:t[0],tokens:this.lexer.inline(t[0])}}escape(r){let t=this.rules.inline.escape.exec(r);if(t)return{type:"escape",raw:t[0],text:t[1]}}tag(r){let t=this.rules.inline.tag.exec(r);if(t)return!this.lexer.state.inLink&&this.rules.other.startATag.test(t[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&this.rules.other.endATag.test(t[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&this.rules.other.startPreScriptTag.test(t[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&this.rules.other.endPreScriptTag.test(t[0])&&(this.lexer.state.inRawBlock=!1),{type:"html",raw:t[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:t[0]}}link(r){let t=this.rules.inline.link.exec(r);if(t){let e=t[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(e)){if(!this.rules.other.endAngleBracket.test(e))return;let s=Hs(e.slice(0,-1),"\\");if((e.length-s.length)%2===0)return}else{let s=l6(t[2],"()");if(s===-2)return;if(s>-1){let o=(t[0].indexOf("!")===0?5:4)+t[1].length+s;t[2]=t[2].substring(0,s),t[0]=t[0].substring(0,o).trim(),t[3]=""}}let n=t[2],i="";if(this.options.pedantic){let s=this.rules.other.pedanticHrefTitle.exec(n);s&&(n=s[1],i=s[3])}else i=t[3]?t[3].slice(1,-1):"";return n=n.trim(),this.rules.other.startAngleBracket.test(n)&&(this.options.pedantic&&!this.rules.other.endAngleBracket.test(e)?n=n.slice(1):n=n.slice(1,-1)),Hm(t,{href:n&&n.replace(this.rules.inline.anyPunctuation,"$1"),title:i&&i.replace(this.rules.inline.anyPunctuation,"$1")},t[0],this.lexer,this.rules)}}reflink(r,t){let e;if((e=this.rules.inline.reflink.exec(r))||(e=this.rules.inline.nolink.exec(r))){let n=(e[2]||e[1]).replace(this.rules.other.multipleSpaceGlobal," "),i=t[n.toLowerCase()];if(!i){let s=e[0].charAt(0);return{type:"text",raw:s,text:s}}return Hm(e,i,e[0],this.lexer,this.rules)}}emStrong(r,t,e=""){let n=this.rules.inline.emStrongLDelim.exec(r);if(!(!n||!n[1]&&!n[2]&&!n[3]&&!n[4]||n[4]&&e.match(this.rules.other.unicodeAlphaNumeric))&&(!(n[1]||n[3])||!e||this.rules.inline.punctuation.exec(e))){let i=[...n[0]].length-1,s,o,a=i,c=0,u=n[0][0]==="*"?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(u.lastIndex=0,t=t.slice(-1*r.length+i);(n=u.exec(t))!=null;){if(s=n[1]||n[2]||n[3]||n[4]||n[5]||n[6],!s)continue;if(o=[...s].length,n[3]||n[4]){a+=o;continue}else if((n[5]||n[6])&&i%3&&!((i+o)%3)){c+=o;continue}if(a-=o,a>0)continue;o=Math.min(o,o+a+c);let h=[...n[0]][0].length,f=r.slice(0,i+n.index+h+o);if(Math.min(i,o)%2){let m=f.slice(1,-1);return{type:"em",raw:f,text:m,tokens:this.lexer.inlineTokens(m)}}let y=f.slice(2,-2);return{type:"strong",raw:f,text:y,tokens:this.lexer.inlineTokens(y)}}}}codespan(r){let t=this.rules.inline.code.exec(r);if(t){let e=t[2].replace(this.rules.other.newLineCharGlobal," "),n=this.rules.other.nonSpaceChar.test(e),i=this.rules.other.startingSpaceChar.test(e)&&this.rules.other.endingSpaceChar.test(e);return n&&i&&(e=e.substring(1,e.length-1)),{type:"codespan",raw:t[0],text:e}}}br(r){let t=this.rules.inline.br.exec(r);if(t)return{type:"br",raw:t[0]}}del(r,t,e=""){let n=this.rules.inline.delLDelim.exec(r);if(n&&(!n[1]||!e||this.rules.inline.punctuation.exec(e))){let i=[...n[0]].length-1,s,o,a=i,c=this.rules.inline.delRDelim;for(c.lastIndex=0,t=t.slice(-1*r.length+i);(n=c.exec(t))!=null;){if(s=n[1]||n[2]||n[3]||n[4]||n[5]||n[6],!s||(o=[...s].length,o!==i))continue;if(n[3]||n[4]){a+=o;continue}if(a-=o,a>0)continue;o=Math.min(o,o+a);let u=[...n[0]][0].length,h=r.slice(0,i+n.index+u+o),f=h.slice(i,-i);return{type:"del",raw:h,text:f,tokens:this.lexer.inlineTokens(f)}}}}autolink(r){let t=this.rules.inline.autolink.exec(r);if(t){let e,n;return t[2]==="@"?(e=t[1],n="mailto:"+e):(e=t[1],n=e),{type:"link",raw:t[0],text:e,href:n,tokens:[{type:"text",raw:e,text:e}]}}}url(r){var e;let t;if(t=this.rules.inline.url.exec(r)){let n,i;if(t[2]==="@")n=t[0],i="mailto:"+n;else{let s;do s=t[0],t[0]=((e=this.rules.inline._backpedal.exec(t[0]))==null?void 0:e[0])??"";while(s!==t[0]);n=t[0],t[1]==="www."?i="http://"+t[0]:i=t[0]}return{type:"link",raw:t[0],text:n,href:i,tokens:[{type:"text",raw:n,text:n}]}}}inlineText(r){let t=this.rules.inline.text.exec(r);if(t){let e=this.lexer.state.inRawBlock;return{type:"text",raw:t[0],text:t[0],escaped:e}}}},Dt=class Xh{constructor(t){g(this,"tokens");g(this,"options");g(this,"state");g(this,"inlineQueue");g(this,"tokenizer");this.tokens=[],this.tokens.links=Object.create(null),this.options=t||ri,this.options.tokenizer=this.options.tokenizer||new Wl,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,top:!0};let e={other:et,block:Ja.normal,inline:Fs.normal};this.options.pedantic?(e.block=Ja.pedantic,e.inline=Fs.pedantic):this.options.gfm&&(e.block=Ja.gfm,this.options.breaks?e.inline=Fs.breaks:e.inline=Fs.gfm),this.tokenizer.rules=e}static get rules(){return{block:Ja,inline:Fs}}static lex(t,e){return new Xh(e).lex(t)}static lexInline(t,e){return new Xh(e).inlineTokens(t)}lex(t){t=t.replace(et.carriageReturn,`
480
- `),this.blockTokens(t,this.tokens);for(let e=0;e<this.inlineQueue.length;e++){let n=this.inlineQueue[e];this.inlineTokens(n.src,n.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(t,e=[],n=!1){var i,s,o;for(this.tokenizer.lexer=this,this.options.pedantic&&(t=t.replace(et.tabCharGlobal," ").replace(et.spaceLine,""));t;){let a;if((s=(i=this.options.extensions)==null?void 0:i.block)!=null&&s.some(u=>(a=u.call({lexer:this},t,e))?(t=t.substring(a.raw.length),e.push(a),!0):!1))continue;if(a=this.tokenizer.space(t)){t=t.substring(a.raw.length);let u=e.at(-1);a.raw.length===1&&u!==void 0?u.raw+=`
481
- `:e.push(a);continue}if(a=this.tokenizer.code(t)){t=t.substring(a.raw.length);let u=e.at(-1);(u==null?void 0:u.type)==="paragraph"||(u==null?void 0:u.type)==="text"?(u.raw+=(u.raw.endsWith(`
482
- `)?"":`
483
- `)+a.raw,u.text+=`
484
- `+a.text,this.inlineQueue.at(-1).src=u.text):e.push(a);continue}if(a=this.tokenizer.fences(t)){t=t.substring(a.raw.length),e.push(a);continue}if(a=this.tokenizer.heading(t)){t=t.substring(a.raw.length),e.push(a);continue}if(a=this.tokenizer.hr(t)){t=t.substring(a.raw.length),e.push(a);continue}if(a=this.tokenizer.blockquote(t)){t=t.substring(a.raw.length),e.push(a);continue}if(a=this.tokenizer.list(t)){t=t.substring(a.raw.length),e.push(a);continue}if(a=this.tokenizer.html(t)){t=t.substring(a.raw.length),e.push(a);continue}if(a=this.tokenizer.def(t)){t=t.substring(a.raw.length);let u=e.at(-1);(u==null?void 0:u.type)==="paragraph"||(u==null?void 0:u.type)==="text"?(u.raw+=(u.raw.endsWith(`
485
- `)?"":`
486
- `)+a.raw,u.text+=`
487
- `+a.raw,this.inlineQueue.at(-1).src=u.text):this.tokens.links[a.tag]||(this.tokens.links[a.tag]={href:a.href,title:a.title},e.push(a));continue}if(a=this.tokenizer.table(t)){t=t.substring(a.raw.length),e.push(a);continue}if(a=this.tokenizer.lheading(t)){t=t.substring(a.raw.length),e.push(a);continue}let c=t;if((o=this.options.extensions)!=null&&o.startBlock){let u=1/0,h=t.slice(1),f;this.options.extensions.startBlock.forEach(y=>{f=y.call({lexer:this},h),typeof f=="number"&&f>=0&&(u=Math.min(u,f))}),u<1/0&&u>=0&&(c=t.substring(0,u+1))}if(this.state.top&&(a=this.tokenizer.paragraph(c))){let u=e.at(-1);n&&(u==null?void 0:u.type)==="paragraph"?(u.raw+=(u.raw.endsWith(`
488
- `)?"":`
489
- `)+a.raw,u.text+=`
490
- `+a.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=u.text):e.push(a),n=c.length!==t.length,t=t.substring(a.raw.length);continue}if(a=this.tokenizer.text(t)){t=t.substring(a.raw.length);let u=e.at(-1);(u==null?void 0:u.type)==="text"?(u.raw+=(u.raw.endsWith(`
491
- `)?"":`
492
- `)+a.raw,u.text+=`
493
- `+a.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=u.text):e.push(a);continue}if(t){let u="Infinite loop on byte: "+t.charCodeAt(0);if(this.options.silent){console.error(u);break}else throw new Error(u)}}return this.state.top=!0,e}inline(t,e=[]){return this.inlineQueue.push({src:t,tokens:e}),e}inlineTokens(t,e=[]){var c,u,h,f,y;this.tokenizer.lexer=this;let n=t,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(n))!=null;)m.includes(i[0].slice(i[0].lastIndexOf("[")+1,-1))&&(n=n.slice(0,i.index)+"["+"a".repeat(i[0].length-2)+"]"+n.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;(i=this.tokenizer.rules.inline.anyPunctuation.exec(n))!=null;)n=n.slice(0,i.index)+"++"+n.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);let s;for(;(i=this.tokenizer.rules.inline.blockSkip.exec(n))!=null;)s=i[2]?i[2].length:0,n=n.slice(0,i.index+s)+"["+"a".repeat(i[0].length-s-2)+"]"+n.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);n=((u=(c=this.options.hooks)==null?void 0:c.emStrongMask)==null?void 0:u.call({lexer:this},n))??n;let o=!1,a="";for(;t;){o||(a=""),o=!1;let m;if((f=(h=this.options.extensions)==null?void 0:h.inline)!=null&&f.some(x=>(m=x.call({lexer:this},t,e))?(t=t.substring(m.raw.length),e.push(m),!0):!1))continue;if(m=this.tokenizer.escape(t)){t=t.substring(m.raw.length),e.push(m);continue}if(m=this.tokenizer.tag(t)){t=t.substring(m.raw.length),e.push(m);continue}if(m=this.tokenizer.link(t)){t=t.substring(m.raw.length),e.push(m);continue}if(m=this.tokenizer.reflink(t,this.tokens.links)){t=t.substring(m.raw.length);let x=e.at(-1);m.type==="text"&&(x==null?void 0:x.type)==="text"?(x.raw+=m.raw,x.text+=m.text):e.push(m);continue}if(m=this.tokenizer.emStrong(t,n,a)){t=t.substring(m.raw.length),e.push(m);continue}if(m=this.tokenizer.codespan(t)){t=t.substring(m.raw.length),e.push(m);continue}if(m=this.tokenizer.br(t)){t=t.substring(m.raw.length),e.push(m);continue}if(m=this.tokenizer.del(t,n,a)){t=t.substring(m.raw.length),e.push(m);continue}if(m=this.tokenizer.autolink(t)){t=t.substring(m.raw.length),e.push(m);continue}if(!this.state.inLink&&(m=this.tokenizer.url(t))){t=t.substring(m.raw.length),e.push(m);continue}let E=t;if((y=this.options.extensions)!=null&&y.startInline){let x=1/0,I=t.slice(1),P;this.options.extensions.startInline.forEach(R=>{P=R.call({lexer:this},I),typeof P=="number"&&P>=0&&(x=Math.min(x,P))}),x<1/0&&x>=0&&(E=t.substring(0,x+1))}if(m=this.tokenizer.inlineText(E)){t=t.substring(m.raw.length),m.raw.slice(-1)!=="_"&&(a=m.raw.slice(-1)),o=!0;let x=e.at(-1);(x==null?void 0:x.type)==="text"?(x.raw+=m.raw,x.text+=m.text):e.push(m);continue}if(t){let x="Infinite loop on byte: "+t.charCodeAt(0);if(this.options.silent){console.error(x);break}else throw new Error(x)}}return e}},Bl=class{constructor(r){g(this,"options");g(this,"parser");this.options=r||ri}space(r){return""}code({text:r,lang:t,escaped:e}){var s;let n=(s=(t||"").match(et.notSpaceStart))==null?void 0:s[0],i=r.replace(et.endingNewline,"")+`
494
- `;return n?'<pre><code class="language-'+Bt(n)+'">'+(e?i:Bt(i,!0))+`</code></pre>
495
- `:"<pre><code>"+(e?i:Bt(i,!0))+`</code></pre>
496
- `}blockquote({tokens:r}){return`<blockquote>
497
- ${this.parser.parse(r)}</blockquote>
498
- `}html({text:r}){return r}def(r){return""}heading({tokens:r,depth:t}){return`<h${t}>${this.parser.parseInline(r)}</h${t}>
499
- `}hr(r){return`<hr>
500
- `}list(r){let t=r.ordered,e=r.start,n="";for(let o=0;o<r.items.length;o++){let a=r.items[o];n+=this.listitem(a)}let i=t?"ol":"ul",s=t&&e!==1?' start="'+e+'"':"";return"<"+i+s+`>
501
- `+n+"</"+i+`>
502
- `}listitem(r){return`<li>${this.parser.parse(r.tokens)}</li>
503
- `}checkbox({checked:r}){return"<input "+(r?'checked="" ':"")+'disabled="" type="checkbox"> '}paragraph({tokens:r}){return`<p>${this.parser.parseInline(r)}</p>
504
- `}table(r){let t="",e="";for(let i=0;i<r.header.length;i++)e+=this.tablecell(r.header[i]);t+=this.tablerow({text:e});let n="";for(let i=0;i<r.rows.length;i++){let s=r.rows[i];e="";for(let o=0;o<s.length;o++)e+=this.tablecell(s[o]);n+=this.tablerow({text:e})}return n&&(n=`<tbody>${n}</tbody>`),`<table>
505
- <thead>
506
- `+t+`</thead>
507
- `+n+`</table>
508
- `}tablerow({text:r}){return`<tr>
509
- ${r}</tr>
510
- `}tablecell(r){let t=this.parser.parseInline(r.tokens),e=r.header?"th":"td";return(r.align?`<${e} align="${r.align}">`:`<${e}>`)+t+`</${e}>
511
- `}strong({tokens:r}){return`<strong>${this.parser.parseInline(r)}</strong>`}em({tokens:r}){return`<em>${this.parser.parseInline(r)}</em>`}codespan({text:r}){return`<code>${Bt(r,!0)}</code>`}br(r){return"<br>"}del({tokens:r}){return`<del>${this.parser.parseInline(r)}</del>`}link({href:r,title:t,tokens:e}){let n=this.parser.parseInline(e),i=Um(r);if(i===null)return n;r=i;let s='<a href="'+r+'"';return t&&(s+=' title="'+Bt(t)+'"'),s+=">"+n+"</a>",s}image({href:r,title:t,text:e,tokens:n}){n&&(e=this.parser.parseInline(n,this.parser.textRenderer));let i=Um(r);if(i===null)return Bt(e);r=i;let s=`<img src="${r}" alt="${Bt(e)}"`;return t&&(s+=` title="${Bt(t)}"`),s+=">",s}text(r){return"tokens"in r&&r.tokens?this.parser.parseInline(r.tokens):"escaped"in r&&r.escaped?r.text:Bt(r.text)}},lp=class{strong({text:r}){return r}em({text:r}){return r}codespan({text:r}){return r}del({text:r}){return r}html({text:r}){return r}text({text:r}){return r}link({text:r}){return""+r}image({text:r}){return""+r}br(){return""}checkbox({raw:r}){return r}},zt=class Qh{constructor(t){g(this,"options");g(this,"renderer");g(this,"textRenderer");this.options=t||ri,this.options.renderer=this.options.renderer||new Bl,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new lp}static parse(t,e){return new Qh(e).parse(t)}static parseInline(t,e){return new Qh(e).parseInline(t)}parse(t){var n,i;this.renderer.parser=this;let e="";for(let s=0;s<t.length;s++){let o=t[s];if((i=(n=this.options.extensions)==null?void 0:n.renderers)!=null&&i[o.type]){let c=o,u=this.options.extensions.renderers[c.type].call({parser:this},c);if(u!==!1||!["space","hr","heading","code","table","blockquote","list","html","def","paragraph","text"].includes(c.type)){e+=u||"";continue}}let a=o;switch(a.type){case"space":{e+=this.renderer.space(a);break}case"hr":{e+=this.renderer.hr(a);break}case"heading":{e+=this.renderer.heading(a);break}case"code":{e+=this.renderer.code(a);break}case"table":{e+=this.renderer.table(a);break}case"blockquote":{e+=this.renderer.blockquote(a);break}case"list":{e+=this.renderer.list(a);break}case"checkbox":{e+=this.renderer.checkbox(a);break}case"html":{e+=this.renderer.html(a);break}case"def":{e+=this.renderer.def(a);break}case"paragraph":{e+=this.renderer.paragraph(a);break}case"text":{e+=this.renderer.text(a);break}default:{let c='Token with "'+a.type+'" type was not found.';if(this.options.silent)return console.error(c),"";throw new Error(c)}}}return e}parseInline(t,e=this.renderer){var i,s;this.renderer.parser=this;let n="";for(let o=0;o<t.length;o++){let a=t[o];if((s=(i=this.options.extensions)==null?void 0:i.renderers)!=null&&s[a.type]){let u=this.options.extensions.renderers[a.type].call({parser:this},a);if(u!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(a.type)){n+=u||"";continue}}let c=a;switch(c.type){case"escape":{n+=e.text(c);break}case"html":{n+=e.html(c);break}case"link":{n+=e.link(c);break}case"image":{n+=e.image(c);break}case"checkbox":{n+=e.checkbox(c);break}case"strong":{n+=e.strong(c);break}case"em":{n+=e.em(c);break}case"codespan":{n+=e.codespan(c);break}case"br":{n+=e.br(c);break}case"del":{n+=e.del(c);break}case"text":{n+=e.text(c);break}default:{let u='Token with "'+c.type+'" type was not found.';if(this.options.silent)return console.error(u),"";throw new Error(u)}}}return n}},Xa,Xs=(Xa=class{constructor(r){g(this,"options");g(this,"block");this.options=r||ri}preprocess(r){return r}postprocess(r){return r}processAllTokens(r){return r}emStrongMask(r){return r}provideLexer(){return this.block?Dt.lex:Dt.lexInline}provideParser(){return this.block?zt.parse:zt.parseInline}},g(Xa,"passThroughHooks",new Set(["preprocess","postprocess","processAllTokens","emStrongMask"])),g(Xa,"passThroughHooksRespectAsync",new Set(["preprocess","postprocess","processAllTokens"])),Xa),h6=class{constructor(...r){g(this,"defaults",ep());g(this,"options",this.setOptions);g(this,"parse",this.parseMarkdown(!0));g(this,"parseInline",this.parseMarkdown(!1));g(this,"Parser",zt);g(this,"Renderer",Bl);g(this,"TextRenderer",lp);g(this,"Lexer",Dt);g(this,"Tokenizer",Wl);g(this,"Hooks",Xs);this.use(...r)}walkTokens(r,t){var n,i;let e=[];for(let s of r)switch(e=e.concat(t.call(this,s)),s.type){case"table":{let o=s;for(let a of o.header)e=e.concat(this.walkTokens(a.tokens,t));for(let a of o.rows)for(let c of a)e=e.concat(this.walkTokens(c.tokens,t));break}case"list":{let o=s;e=e.concat(this.walkTokens(o.items,t));break}default:{let o=s;(i=(n=this.defaults.extensions)==null?void 0:n.childTokens)!=null&&i[o.type]?this.defaults.extensions.childTokens[o.type].forEach(a=>{let c=o[a].flat(1/0);e=e.concat(this.walkTokens(c,t))}):o.tokens&&(e=e.concat(this.walkTokens(o.tokens,t)))}}return e}use(...r){let t=this.defaults.extensions||{renderers:{},childTokens:{}};return r.forEach(e=>{let n={...e};if(n.async=this.defaults.async||n.async||!1,e.extensions&&(e.extensions.forEach(i=>{if(!i.name)throw new Error("extension name required");if("renderer"in i){let s=t.renderers[i.name];s?t.renderers[i.name]=function(...o){let a=i.renderer.apply(this,o);return a===!1&&(a=s.apply(this,o)),a}:t.renderers[i.name]=i.renderer}if("tokenizer"in i){if(!i.level||i.level!=="block"&&i.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");let s=t[i.level];s?s.unshift(i.tokenizer):t[i.level]=[i.tokenizer],i.start&&(i.level==="block"?t.startBlock?t.startBlock.push(i.start):t.startBlock=[i.start]:i.level==="inline"&&(t.startInline?t.startInline.push(i.start):t.startInline=[i.start]))}"childTokens"in i&&i.childTokens&&(t.childTokens[i.name]=i.childTokens)}),n.extensions=t),e.renderer){let i=this.defaults.renderer||new Bl(this.defaults);for(let s in e.renderer){if(!(s in i))throw new Error(`renderer '${s}' does not exist`);if(["options","parser"].includes(s))continue;let o=s,a=e.renderer[o],c=i[o];i[o]=(...u)=>{let h=a.apply(i,u);return h===!1&&(h=c.apply(i,u)),h||""}}n.renderer=i}if(e.tokenizer){let i=this.defaults.tokenizer||new Wl(this.defaults);for(let s in e.tokenizer){if(!(s in i))throw new Error(`tokenizer '${s}' does not exist`);if(["options","rules","lexer"].includes(s))continue;let o=s,a=e.tokenizer[o],c=i[o];i[o]=(...u)=>{let h=a.apply(i,u);return h===!1&&(h=c.apply(i,u)),h}}n.tokenizer=i}if(e.hooks){let i=this.defaults.hooks||new Xs;for(let s in e.hooks){if(!(s in i))throw new Error(`hook '${s}' does not exist`);if(["options","block"].includes(s))continue;let o=s,a=e.hooks[o],c=i[o];Xs.passThroughHooks.has(s)?i[o]=u=>{if(this.defaults.async&&Xs.passThroughHooksRespectAsync.has(s))return(async()=>{let f=await a.call(i,u);return c.call(i,f)})();let h=a.call(i,u);return c.call(i,h)}:i[o]=(...u)=>{if(this.defaults.async)return(async()=>{let f=await a.apply(i,u);return f===!1&&(f=await c.apply(i,u)),f})();let h=a.apply(i,u);return h===!1&&(h=c.apply(i,u)),h}}n.hooks=i}if(e.walkTokens){let i=this.defaults.walkTokens,s=e.walkTokens;n.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,...n}}),this}setOptions(r){return this.defaults={...this.defaults,...r},this}lexer(r,t){return Dt.lex(r,t??this.defaults)}parser(r,t){return zt.parse(r,t??this.defaults)}parseMarkdown(r){return(t,e)=>{let n={...e},i={...this.defaults,...n},s=this.onError(!!i.silent,!!i.async);if(this.defaults.async===!0&&n.async===!1)return s(new Error("marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise."));if(typeof t>"u"||t===null)return s(new Error("marked(): input parameter is undefined or null"));if(typeof t!="string")return s(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(t)+", string expected"));if(i.hooks&&(i.hooks.options=i,i.hooks.block=r),i.async)return(async()=>{let o=i.hooks?await i.hooks.preprocess(t):t,a=await(i.hooks?await i.hooks.provideLexer():r?Dt.lex:Dt.lexInline)(o,i),c=i.hooks?await i.hooks.processAllTokens(a):a;i.walkTokens&&await Promise.all(this.walkTokens(c,i.walkTokens));let u=await(i.hooks?await i.hooks.provideParser():r?zt.parse:zt.parseInline)(c,i);return i.hooks?await i.hooks.postprocess(u):u})().catch(s);try{i.hooks&&(t=i.hooks.preprocess(t));let o=(i.hooks?i.hooks.provideLexer():r?Dt.lex:Dt.lexInline)(t,i);i.hooks&&(o=i.hooks.processAllTokens(o)),i.walkTokens&&this.walkTokens(o,i.walkTokens);let a=(i.hooks?i.hooks.provideParser():r?zt.parse:zt.parseInline)(o,i);return i.hooks&&(a=i.hooks.postprocess(a)),a}catch(o){return s(o)}}}onError(r,t){return e=>{if(e.message+=`
512
- Please report this to https://github.com/markedjs/marked.`,r){let n="<p>An error occurred:</p><pre>"+Bt(e.message+"",!0)+"</pre>";return t?Promise.resolve(n):n}if(t)return Promise.reject(e);throw e}}},Jn=new h6;function re(r,t){return Jn.parse(r,t)}re.options=re.setOptions=function(r){return Jn.setOptions(r),re.defaults=Jn.defaults,x0(re.defaults),re};re.getDefaults=ep;re.defaults=ri;re.use=function(...r){return Jn.use(...r),re.defaults=Jn.defaults,x0(re.defaults),re};re.walkTokens=function(r,t){return Jn.walkTokens(r,t)};re.parseInline=Jn.parseInline;re.Parser=zt;re.parser=zt.parse;re.Renderer=Bl;re.TextRenderer=lp;re.Lexer=Dt;re.lexer=Dt.lex;re.Tokenizer=Wl;re.Hooks=Xs;re.parse=re;re.options;re.setOptions;re.use;re.walkTokens;re.parseInline;zt.parse;Dt.lex;k0.addHook("afterSanitizeAttributes",r=>{r.tagName==="A"&&(r.setAttribute("target","_blank"),r.setAttribute("rel","noopener noreferrer"))});function d6(r){const t=re.parse(r,{async:!1});return k0.sanitize(t,{USE_PROFILES:{html:!0}})}var sa,Ar,nr,ir,Kr,D0,xl;class ed extends ps{constructor(){super(...arguments);S(this,Kr);g(this,"phase","thinking");g(this,"toolCalls",[]);g(this,"expanded",!1);g(this,"expandedTexts",new Set);S(this,sa,`agent-activity-panel-${++g6}`);g(this,"overflowingTexts",new Set);S(this,Ar,null);S(this,nr,null);S(this,ir,null);g(this,"handleToggle",()=>{this.toolCalls.length!==0&&(this.expanded=!this.expanded)})}changed(e){Be(this.template(),this),p(this,Kr,D0).call(this),l(this,nr)!==null&&cancelAnimationFrame(l(this,nr)),w(this,nr,requestAnimationFrame(()=>{w(this,nr,null),p(this,Kr,xl).call(this)})),e.has("expanded")&&(l(this,ir)!==null&&clearTimeout(l(this,ir)),w(this,ir,window.setTimeout(()=>{w(this,ir,null),p(this,Kr,xl).call(this)},f6)))}disconnected(){var e;(e=l(this,Ar))==null||e.disconnect(),w(this,Ar,null),l(this,nr)!==null&&(cancelAnimationFrame(l(this,nr)),w(this,nr,null)),l(this,ir)!==null&&(clearTimeout(l(this,ir)),w(this,ir,null))}template(){const e=this.toolCalls.length>0;return D`
513
- ${this.barTemplate()}
514
- ${e?this.panelTemplate():null}
515
- `}barTemplate(){return this.phase==="thinking"?D`<div class="bar bar-static" unselectable>${this.indicator()}${this.label({expanded:this.expanded})}</div>`:D`
516
- <button
517
- type="button"
518
- variant="ghost"
519
- class="bar"
520
- unselectable
521
- aria-expanded=${this.expanded?"true":"false"}
522
- aria-controls=${l(this,sa)}
523
- @click=${this.handleToggle}
524
- >
525
- ${this.indicator()}${this.label({expanded:this.expanded})}
526
- </button>
527
- `}panelTemplate(){return D`
528
- <div
529
- class="panel"
530
- id=${l(this,sa)}
531
- role="region"
532
- ?inert=${!this.expanded}
533
- aria-hidden=${this.expanded?"false":"true"}
534
- >
535
- <div class="panel-inner">
536
- <ol class="tool-list">
537
- ${this.toolCalls.map(e=>this.toolItemTemplate(e))}
538
- </ol>
539
- </div>
540
- </div>
541
- `}toolItemTemplate(e){const n=this.expandedTexts.has(e.toolCallId),i=this.overflowingTexts.has(e.toolCallId),s=n?"Show less":"Show more";return D`
542
- <li class="tool-item">
543
- <span
544
- class="tool-dot"
545
- data-status=${e.status}
546
- role="img"
547
- aria-label=${m6(e.status)}
548
- ></span>
549
- <span class="tool-title">${e.title}</span>
550
- ${e.text?D`
551
- <div class="tool-output">
552
- <pre
553
- class="tool-text"
554
- data-tool-call-id=${e.toolCallId}
555
- ?data-expanded=${n}
556
- >${e.text}</pre>
557
- ${i?D`<button
558
- type="button"
559
- variant="ghost"
560
- class="tool-text-toggle"
561
- @click=${()=>this.toggleTextExpand(e.toolCallId)}
562
- >
563
- <span>${s}</span>
564
- ${n?_O({size:16}):Fl({size:16})}
565
- </button>`:null}
566
- </div>
567
- `:null}
568
- </li>
569
- `}toggleTextExpand(e){const n=new Set(this.expandedTexts);n.has(e)?n.delete(e):n.add(e),this.expandedTexts=n}indicator(){if(this.expanded)return D`<span class="indicator">${Fl({size:16})}</span>`;const e=this.phase==="thinking"||this.phase==="using";return D`<span class=${e?"indicator indicator-active":"indicator"}
570
- >${e?bw({size:16}):$O({size:16})}</span>`}label(e){var s;if(this.phase==="thinking")return"Thinking…";const n=this.toolCalls.length;if(this.phase==="using"){if(e.expanded)return`Using ${n} ${n===1?"tool":"tools"}…`;const o=[...this.toolCalls].reverse().find(c=>c.status==="in_progress"),a=(o==null?void 0:o.toolKind)??((s=this.toolCalls.at(-1))==null?void 0:s.toolKind)??"other";return p6(a)}return`${e.expanded?"Showing":"Used"} ${n} ${n===1?"tool":"tools"}`}}sa=new WeakMap,Ar=new WeakMap,nr=new WeakMap,ir=new WeakMap,Kr=new WeakSet,D0=function(){if(!(typeof ResizeObserver>"u")){l(this,Ar)||w(this,Ar,new ResizeObserver(()=>p(this,Kr,xl).call(this))),l(this,Ar).disconnect();for(const e of this.querySelectorAll(".tool-text"))l(this,Ar).observe(e)}},xl=function(){const e=new Set;for(const n of this.querySelectorAll(".tool-text")){const i=n.dataset.toolCallId;if(i){if(this.expandedTexts.has(i)){e.add(i);continue}n.scrollHeight>n.clientHeight+1&&e.add(i)}}v6(this.overflowingTexts,e)||(this.overflowingTexts=e)},g(ed,"properties",["phase","toolCalls","expanded","expandedTexts","overflowingTexts"]),g(ed,"attributes",{expanded:{type:Boolean}});function p6(r){switch(r){case"read":return"Reading files…";case"edit":return"Editing files…";case"delete":return"Deleting files…";case"move":return"Moving files…";case"search":return"Searching files…";case"execute":return"Running commands…";case"think":return"Thinking…";case"fetch":return"Fetching content…";case"switch_mode":return"Switching modes…";default:return"Working…"}}const f6=160;let g6=0;function m6(r){switch(r){case"completed":return"Completed";case"failed":return"Failed";case"in_progress":return"In progress";default:return"Pending"}}function v6(r,t){if(r.size!==t.size)return!1;for(const e of r)if(!t.has(e))return!1;return!0}customElements.define("agent-activity",ed);function y6(r){const t=[];let e=0;for(;e<r.length;)if(r[e].kind==="tool_call"){const i=[];for(;e<r.length&&r[e].kind==="tool_call";)i.push(r[e]),e+=1;const s=e>=r.length;t.push({kind:"tool-run",toolCalls:i,live:s})}else t.push({kind:"message",message:r[e]}),e+=1;const n=r[r.length-1];return n&&n.kind==="user"&&t.push({kind:"thinking"}),t}const Zm=8,Wm=new WeakMap;function b6(r){const t=Wm.get(r);if(t&&t.text===r.text)return t.html;const e=d6(r.text);return Wm.set(r,{text:r.text,html:e}),e}function Bm(r){for(let t=r.length-1;t>=0;t-=1){const e=r[t];if(e&&e.kind==="user")return e.id}return null}var mt,vt,Wn,Bn,qr,_t,O0,td,M0,nc,ic,rd;class z0 extends ps{constructor(){super(...arguments);S(this,_t);g(this,"messages",[]);S(this,mt,!0);S(this,vt,null);S(this,Wn,null);S(this,Bn,null);S(this,qr,!1);S(this,nc,()=>{if(l(this,qr))return;const e=l(this,vt);if(!e)return;const i=e.scrollHeight-e.clientHeight-e.scrollTop<=Zm;i!==l(this,mt)&&(w(this,mt,i),this.toggleAttribute("data-pinned",i))});S(this,ic,()=>{w(this,mt,!0),this.toggleAttribute("data-pinned",!0),p(this,_t,rd).call(this,!0)})}changed(e){let n=!1;if(e.has("messages")){const i=e.get("messages")??[],s=Bm(this.messages);n=s!==null&&s!==Bm(i),n&&w(this,mt,!0)}Be(this.template(),this),l(this,vt)||(w(this,vt,this.querySelector(".history-scroll")),l(this,vt)&&p(this,_t,O0).call(this)),this.toggleAttribute("data-pinned",l(this,mt)),p(this,_t,td).call(this),p(this,_t,rd).call(this,n)}disconnected(){var e,n;(e=l(this,Wn))==null||e.disconnect(),w(this,Wn,null),(n=l(this,Bn))==null||n.disconnect(),w(this,Bn,null)}template(){const e=y6(this.messages);return D`
571
- <div class="history-scroll" @scroll=${l(this,nc)}>
572
- ${e.map(n=>{if(n.kind==="tool-run")return D`<agent-activity
573
- .phase=${n.live?"using":"final"}
574
- .toolCalls=${n.toolCalls}
575
- ></agent-activity>`;if(n.kind==="thinking")return D`<agent-activity
576
- .phase=${"thinking"}
577
- .toolCalls=${[]}
578
- ></agent-activity>`;const i=n.message,s=i.kind==="assistant"?aO(b6(i)):i.text;return D`<div
579
- class="message message-${i.kind}"
580
- data-message-id=${i.id}
581
- >${s}</div>`})}
582
- </div>
583
- <button
584
- type="button"
585
- class="history-jump"
586
- aria-label="Jump to latest message"
587
- @click=${l(this,ic)}
588
- >
589
- ${Fl({size:16})}
590
- </button>
591
- `}}mt=new WeakMap,vt=new WeakMap,Wn=new WeakMap,Bn=new WeakMap,qr=new WeakMap,_t=new WeakSet,O0=function(){l(this,vt)&&(typeof ResizeObserver>"u"||(w(this,Wn,new ResizeObserver(()=>p(this,_t,M0).call(this))),w(this,Bn,new MutationObserver(()=>p(this,_t,td).call(this))),l(this,Bn).observe(l(this,vt),{childList:!0})))},td=function(){const e=l(this,vt),n=l(this,Wn);if(!(!e||!n)){n.disconnect();for(const i of Array.from(e.children))n.observe(i)}},M0=function(){const e=l(this,vt);if(!e)return;if(l(this,mt)){w(this,qr,!0),e.scrollTop=e.scrollHeight-e.clientHeight,requestAnimationFrame(()=>{w(this,qr,!1)});return}const i=e.scrollHeight-e.clientHeight-e.scrollTop<=Zm;i!==l(this,mt)&&(w(this,mt,i),this.toggleAttribute("data-pinned",i))},nc=new WeakMap,ic=new WeakMap,rd=function(e){requestAnimationFrame(()=>{const n=l(this,vt);n&&(!l(this,mt)&&!e||(w(this,qr,!0),n.scrollTop=n.scrollHeight-n.clientHeight,requestAnimationFrame(()=>{w(this,qr,!1)})))})},g(z0,"properties",["messages"]);customElements.define("message-history",z0);var Pt,oa,ns,sr,is,ss,aa,os,sc,oc,ac,yt,El,la,id,sd,ca,ua;class nd extends ps{constructor(){super(...arguments);S(this,yt);g(this,"placeholder","What do you want to do?");g(this,"open",!1);g(this,"messages",[]);g(this,"status","disconnected");S(this,Pt,cr.resolve("ServerManager"));S(this,oa,cr.resolve("ShortcutService"));S(this,ns,null);S(this,sr,null);S(this,is,()=>{var e;this.status=((e=l(this,sr))==null?void 0:e.status)??"disconnected"});S(this,ss,()=>{var e;this.messages=((e=l(this,sr))==null?void 0:e.messages)??[]});S(this,aa,()=>{var e,n;(e=l(this,sr))==null||e.removeEventListener("status-changed",l(this,is)),(n=l(this,sr))==null||n.removeEventListener("messages-changed",l(this,ss)),w(this,sr,null)});S(this,os,()=>{var n;const e=((n=l(this,Pt).activeServer)==null?void 0:n.acpClient)??null;e!==l(this,sr)&&(l(this,aa).call(this),w(this,sr,e),e==null||e.addEventListener("status-changed",l(this,is)),e==null||e.addEventListener("messages-changed",l(this,ss)),l(this,is).call(this),l(this,ss).call(this),e!=null&&e.enabled&&e.status==="disconnected"&&e.connect().catch(i=>{console.error("ACPClient.connect() failed",i)}))});g(this,"handleTriggerActivate",()=>{var n;const e=(n=l(this,Pt).activeServer)==null?void 0:n.acpClient;e&&!e.enabled||(this.open=!0)});g(this,"handleKeydown",e=>{var o;if(e.key!=="Enter"||e.shiftKey)return;const n=e.currentTarget,i=n.value.trim();if(e.preventDefault(),!i)return;n.value="",p(this,yt,El).call(this,n);const s=(o=l(this,Pt).activeServer)==null?void 0:o.acpClient;if(s!=null&&s.enabled){if(i==="/new"){s.startNewSession().catch(a=>{console.error("ACPClient.startNewSession() failed",a)});return}s.sendMessage({text:i}).catch(a=>{console.error("ACPClient.sendMessage() failed",a)})}});S(this,sc,e=>{p(this,yt,El).call(this,e.currentTarget)});S(this,oc,e=>{var i;e.stopPropagation();const n=(i=l(this,Pt).activeServer)==null?void 0:i.acpClient;n&&n.cancel().catch(s=>{console.error("ACPClient.cancel() failed",s)})});S(this,ac,e=>{if(e.target instanceof HTMLTextAreaElement)return;const n=e.currentTarget.querySelector("textarea");n==null||n.focus()});S(this,la,e=>{var s;if(e.shortcut!=="focusCommandInput")return;const n=(s=l(this,Pt).activeServer)==null?void 0:s.acpClient;if(n&&!n.enabled)return;if(!this.open){this.open=!0;return}const i=this.querySelector("textarea");if(i){if(document.activeElement===i){this.open=!1;return}i.focus()}});S(this,ca,e=>{e.target instanceof Node&&(this.contains(e.target)||(this.open=!1))});S(this,ua,e=>{e.key==="Escape"&&(this.open=!1)})}connected(){const e=new DisposableStack;w(this,ns,e),l(this,Pt).addEventListener("change",l(this,os)),e.defer(()=>{l(this,Pt).removeEventListener("change",l(this,os)),l(this,aa).call(this)}),l(this,os).call(this),l(this,oa).addEventListener("shortcut-triggered",l(this,la)),e.defer(()=>l(this,oa).removeEventListener("shortcut-triggered",l(this,la))),this.open&&p(this,yt,id).call(this)}disconnected(){var e;(e=l(this,ns))==null||e.dispose(),w(this,ns,null),p(this,yt,sd).call(this)}changed(e){if(this.open&&this.status!=="disconnected"?(this.removeAttribute("material"),this.removeAttribute("tone"),this.removeAttribute("level")):(this.setAttribute("material","paper"),this.setAttribute("tone","dark"),this.setAttribute("level","overlay")),Be(this.template(),this),e.has("open"))if(this.open){p(this,yt,id).call(this);const n=this.querySelector("textarea");n&&(p(this,yt,El).call(this,n),n.focus())}else p(this,yt,sd).call(this)}template(){var i;const e=(i=l(this,Pt).activeServer)==null?void 0:i.acpClient;if(e&&!e.enabled||this.status==="disposed")return null;if(this.status==="disconnected")return D`
592
- <div class="connecting" aria-disabled="true">
593
- <ui-spinner size="16" weight="bold"></ui-spinner>
594
- <span class="label">Connecting<span class="dots" aria-hidden="true"></span></span>
595
- </div>
596
- `;if(this.open){const s=this.status==="running"||this.status==="cancelling",o=this.status==="cancelling";return D`
597
- <div class="open">
598
- <div
599
- class="chat"
600
- material="paper"
601
- tone="dark"
602
- level="overlay"
603
- >
604
- <message-history selectable .messages=${this.messages}></message-history>
605
- </div>
606
- <div
607
- class="input"
608
- material="paper"
609
- tone="dark"
610
- level="overlay"
611
- @click=${l(this,ac)}
612
- >
613
- <textarea
614
- class="textarea"
615
- rows="1"
616
- @keydown=${this.handleKeydown}
617
- @input=${l(this,sc)}
618
- ></textarea>
619
- ${s?D`
620
- <button
621
- type="button"
622
- icon-only
623
- variant="ghost"
624
- aria-label=${o?"Cancelling…":"Stop generating"}
625
- ?disabled=${o}
626
- @click=${l(this,oc)}
627
- >
628
- ${o?D`<ui-spinner size="16" weight="bold"></ui-spinner>`:SO({size:16})}
629
- </button>
630
- `:null}
631
- </div>
632
- </div>
633
- `}return D`
634
- <div
635
- class="trigger"
636
- tabindex="0"
637
- role="button"
638
- @click=${this.handleTriggerActivate}
639
- @focus=${this.handleTriggerActivate}
640
- >
641
- <span class="label">${this.placeholder}</span>
642
- <span class="kbd" aria-hidden="true">⌘K</span>
643
- </div>
644
- `}}Pt=new WeakMap,oa=new WeakMap,ns=new WeakMap,sr=new WeakMap,is=new WeakMap,ss=new WeakMap,aa=new WeakMap,os=new WeakMap,sc=new WeakMap,oc=new WeakMap,ac=new WeakMap,yt=new WeakSet,El=function(e){e.style.height="auto",e.style.height=`${e.scrollHeight}px`},la=new WeakMap,id=function(){document.addEventListener("mousedown",l(this,ca)),document.addEventListener("keydown",l(this,ua))},sd=function(){document.removeEventListener("mousedown",l(this,ca)),document.removeEventListener("keydown",l(this,ua))},ca=new WeakMap,ua=new WeakMap,g(nd,"properties",["placeholder","open","messages","status"]),g(nd,"attributes",{placeholder:{type:String},open:{type:Boolean}});customElements.define("command-panel",nd);const w6='<path d="M128,112a28,28,0,0,0-8,54.83V184a8,8,0,0,0,16,0V166.83A28,28,0,0,0,128,112Zm0,40a12,12,0,1,1,12-12A12,12,0,0,1,128,152Zm80-72H176V56a48,48,0,0,0-96,0V80H48A16,16,0,0,0,32,96V208a16,16,0,0,0,16,16H208a16,16,0,0,0,16-16V96A16,16,0,0,0,208,80ZM96,56a32,32,0,0,1,64,0V80H96ZM208,208H48V96H208V208Z"/>';class N0 extends Event{constructor(e){super("auth-submit",{bubbles:!0,composed:!0});g(this,"token");this.token=e}}class S6 extends HTMLElement{constructor(){super(...arguments);g(this,"_invalid",!1);g(this,"_tokenValue","")}set invalid(e){this._invalid=e,this.render()}get invalid(){return this._invalid}set tokenValue(e){this._tokenValue=e,this.render()}get tokenValue(){return this._tokenValue}connectedCallback(){this.render()}handleInput(e){const n=e.currentTarget;this._tokenValue=n.value}handleSubmit(e){e.preventDefault();const n=this._tokenValue.trim();n&&this.dispatchEvent(new N0(n))}render(){Be(D`
645
- <modal-overlay open>
646
- <system-modal material="glass-frosted" level="1" class="auth-modal">
647
- <form class="auth-form" @submit=${n=>this.handleSubmit(n)}>
648
- <header>
649
- <span class="auth-modal-icon" aria-hidden="true">
650
- <svg width="32" height="32" viewBox="0 0 256 256" fill="currentColor">${vw(w6)}</svg>
651
- </span>
652
- <hgroup>
653
- <h2>Enter access token</h2>
654
- <p>${"This server requires an access token to connect."}</p>
655
- </hgroup>
656
- </header>
657
- <div class="auth-input-row">
658
- <input
659
- class=${this.invalid?"auth-token-input auth-token-input-invalid":"auth-token-input"}
660
- type="password"
661
- name="token"
662
- placeholder="paste token here"
663
- aria-label="Access token"
664
- .value=${this.tokenValue}
665
- @input=${n=>this.handleInput(n)}
666
- autofocus
667
- required
668
- />
669
- ${this.invalid?D`<p class="auth-modal-error" role="alert">
670
- The previous token was rejected. Try again.
671
- </p>`:null}
672
- </div>
673
- <button variant="primary" class="auth-submit">
674
- Connect
675
- </button>
676
- </form>
677
- </system-modal>
678
- </modal-overlay>
679
- `,this)}}customElements.get("auth-modal")||customElements.define("auth-modal",S6);const _6=250,k6=1e3;class U0 extends HTMLElement{constructor(){super(...arguments);g(this,"_nextRetryAt",null);g(this,"_hasEverConnected",!1);g(this,"tickHandle",null)}set nextRetryAt(e){e!==this._nextRetryAt&&(this._nextRetryAt=e,this.updateTickerState(),this.render())}get nextRetryAt(){return this._nextRetryAt}set hasEverConnected(e){e!==this._hasEverConnected&&(this._hasEverConnected=e,this.render())}get hasEverConnected(){return this._hasEverConnected}connectedCallback(){if(this._nextRetryAt===null&&this.hasAttribute("next-retry-at")){const e=Number(this.getAttribute("next-retry-at"));this._nextRetryAt=Number.isFinite(e)?e:null}this.updateTickerState(),this.render()}disconnectedCallback(){this.stopTicker()}attributeChangedCallback(e,n,i){if(e==="next-retry-at"){if(i===null||i==="")this._nextRetryAt=null;else{const s=Number(i);this._nextRetryAt=Number.isFinite(s)?s:null}this.updateTickerState()}else e==="has-ever-connected"&&(this._hasEverConnected=i!==null&&i!=="false");this.render()}updateTickerState(){this._nextRetryAt!==null?this.startTicker():this.stopTicker()}startTicker(){this.tickHandle===null&&(this.tickHandle=setInterval(()=>{this.render()},_6))}stopTicker(){this.tickHandle!==null&&(clearInterval(this.tickHandle),this.tickHandle=null)}render(){const e=this._hasEverConnected,n=e?"Disconnected":"Connecting",i=this._nextRetryAt!==null?this.formatCountdown(this._nextRetryAt):"Reattempting now…";Be(D`
680
- <modal-overlay open role="status" aria-live="polite">
681
- <system-modal material="glass-frosted" level="1" class="connecting-overlay-panel">
682
- <header>
683
- <ui-spinner size="32"></ui-spinner>
684
- <hgroup>
685
- <h2>${n}</h2>
686
- ${e?D`<p>${i}</p>`:null}
687
- </hgroup>
688
- </header>
689
- </system-modal>
690
- </modal-overlay>
691
- `,this)}formatCountdown(e){const n=e-Date.now();return n<=0?"Reattempting now…":`Reattempting in ${Math.ceil(n/k6)}s…`}}g(U0,"observedAttributes",["next-retry-at","has-ever-connected"]);customElements.get("connecting-overlay")||customElements.define("connecting-overlay",U0);class x6 extends HTMLElement{constructor(){super(...arguments);g(this,"runtimeServerURL",hb());g(this,"electronMode",ar());g(this,"serverManager",cr.resolve("ServerManager"));g(this,"screenManager",cr.resolve("ScreenManager"));g(this,"connectError",null);g(this,"topRowResizeObserver",null);g(this,"observedTopRow",null);g(this,"handleServerManagerChange",()=>{var e;this.clearStoredTokenIfUnauthorized(),this.connectError!==null&&((e=this.serverManager.activeServer)==null?void 0:e.status)==="connected"&&(this.connectError=null),this.render()});g(this,"handleScreenManagerChange",()=>{this.render()})}connectedCallback(){this.serverManager.addEventListener("change",this.handleServerManagerChange),this.screenManager.addEventListener("active-screen-changed",this.handleScreenManagerChange),this.screenManager.addEventListener("tabs-changed",this.handleScreenManagerChange),this.addEventListener("auth-submit",e=>{var i;const n=e instanceof N0?e.token:e instanceof CustomEvent&&typeof((i=e.detail)==null?void 0:i.token)=="string"?e.detail.token:null;n&&this.handleAuthSubmit(n)}),this.initializeConnection(),this.render()}disconnectedCallback(){var e;this.serverManager.removeEventListener("change",this.handleServerManagerChange),this.screenManager.removeEventListener("active-screen-changed",this.handleScreenManagerChange),this.screenManager.removeEventListener("tabs-changed",this.handleScreenManagerChange),(e=this.topRowResizeObserver)==null||e.disconnect(),this.topRowResizeObserver=null,this.observedTopRow=null}async initializeConnection(){const e=ZP();if(this.electronMode){e&&(this.serverManager.setStoredAuthToken(this.runtimeServerURL,e),this.stripTokenQueryParam()),this.serverManager.connectConfiguredServers(this.runtimeServerURL,e);return}if(this.serverManager.activeServer)return;e&&(this.serverManager.setStoredAuthToken(this.runtimeServerURL,e),this.stripTokenQueryParam());const n=e??this.serverManager.getStoredAuthToken(this.runtimeServerURL),i=new aw({url:this.runtimeServerURL,name:"Server",token:n});this.serverManager.add(i),this.serverManager.setActive(i);try{await i.connect(n),this.connectError=null}catch(s){this.connectError=s instanceof Error&&!(s instanceof ro)?s.message:null}this.render()}async handleAuthSubmit(e){const n=this.serverManager.activeServer;if(n){this.connectError=null,this.serverManager.setStoredAuthToken(n.url,e);try{await n.connect(e)}catch(i){i instanceof ro||(this.connectError=i instanceof Error?i.message:String(i))}this.render()}}stripTokenQueryParam(){const e=new URL(window.location.href);e.searchParams.delete("token"),window.history.replaceState({},"",`${e.pathname}${e.search}${e.hash}`)}clearStoredTokenIfUnauthorized(){const e=this.serverManager.activeServer;!e||e.status!=="unauthorized"||!e.token||!e.hasAuthRejected||(this.serverManager.clearStoredAuthToken(e.url),e.clearToken())}render(){const e=this.serverManager.activeServer,n=(e==null?void 0:e.status)??null,i=this.screenManager.activeScreen,s=!!(e&&i&&this.screenManager.hasTab(e.url,i.id));if(n==="unauthorized"){const h=e;if(!h)return;Be(D`
692
- <main class="auth-gate">
693
- <auth-modal
694
- .invalid=${!!h.token}
695
- .tokenValue=${h.token??""}
696
- ></auth-modal>
697
- </main>
698
- `,this),this.updateLayoutChromeBalance();return}const o=n==="disconnected",a=(e==null?void 0:e.hasEverConnected)??!1,u=n==="connected"||o&&a;Be(D`
699
- <main>
700
- ${this.connectError?D`<p data-testid="auth-error">${this.connectError}</p>`:D`
701
- ${u?D`
702
- <div class="top-row" electron-draggable>
703
- <screen-select></screen-select>
704
- </div>
705
- `:null}
706
- ${s?D`<screen-view></screen-view>`:null}
707
- ${u&&(e!=null&&e.acpClient.enabled)?D`
708
- <div class="command-panel-region">
709
- <command-panel></command-panel>
710
- </div>
711
- `:null}
712
- `}
713
- ${o?D`<connecting-overlay
714
- .nextRetryAt=${(e==null?void 0:e.nextRetryAt)??null}
715
- .hasEverConnected=${(e==null?void 0:e.hasEverConnected)??!1}
716
- ></connecting-overlay>`:null}
717
- </main>
718
- `,this),this.updateLayoutChromeBalance()}updateLayoutChromeBalance(){var o;const e=this.querySelector("main"),n=this.querySelector(".top-row"),i=this.querySelector(".command-panel-region"),s=n&&!i?n.getBoundingClientRect().height:0;e==null||e.style.setProperty("--layout-virtual-bottom-balance",`${s}px`),n!==this.observedTopRow&&((o=this.topRowResizeObserver)==null||o.disconnect(),this.observedTopRow=n,n&&typeof ResizeObserver<"u"?(this.topRowResizeObserver=new ResizeObserver(()=>this.updateLayoutChromeBalance()),this.topRowResizeObserver.observe(n)):this.topRowResizeObserver=null)}}customElements.get("television-app")||customElements.define("television-app",x6);const cp=ar(),up=hb(),F0=new P$(cp?"television-electron":"television-browser",$$(up)),lr=new Mz({localStore:F0,localServerURL:up}),H0=new H$({localStore:F0,serverManager:lr}),E6=new Nz,A6=()=>{const r=[...lr.servers.values()].filter(t=>t.status==="connected");r.length!==0&&Promise.all(r.map(t=>t.client.artifacts.list())).then(t=>{const e=new Set(t.flatMap(({artifacts:n})=>n.map(i=>i.id)));Yz(e)}).catch(()=>{})},Z0=()=>{const r=lr.activeServer;if(!r||r.status!=="connected"){Rl();return}A6(),r.client.display.get().then(t=>{if(!(lr.activeServer!==r||r.status!=="connected"))return hw(t.activeThemeName,r)}).catch(()=>{lr.activeServer===r&&Rl()})};Z0();lr.addEventListener("change",Z0);lr.addEventListener("server-event",r=>{if(r.event.type!=="theme-changed")return;const t=lr.activeServer;!t||t.url!==r.serverURL||hw(r.event.themeName,t)});cr.register("ServerManager",()=>lr);cr.register("ScreenManager",()=>H0);cr.register("ShortcutService",()=>E6);globalThis.__telepath={screenManager:H0,serverManager:lr};const hp=document.createElement("television-app");hp.runtimeServerURL=up;hp.electronMode=cp;cp&&document.body.classList.add("electron");document.body.appendChild(hp);