@telepath-computer/television 0.1.27 → 0.1.29
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +21 -10
- package/dist/browser/assets/index-Bi8GHwko.js +548 -0
- package/dist/browser/assets/index-BporpGDZ.css +1 -0
- package/dist/browser/index.html +2 -2
- package/dist/cli.cjs +43922 -80546
- package/dist/electron.cjs +42950 -79935
- package/dist/views/text/index.html +38 -0
- package/dist/views/text/manifest.json +5 -0
- package/package.json +26 -15
- package/skill/SKILL.md +365 -100
- package/dist/artifact-runtime/index.js +0 -986
- package/dist/artifact-runtime/style.css +0 -1
- package/dist/browser/assets/index-C0Ygc25s.js +0 -555
- package/dist/browser/assets/index-D0BGTUk2.css +0 -1
|
@@ -1,555 +0,0 @@
|
|
|
1
|
-
var Dd=Object.defineProperty;var Ya=e=>{throw TypeError(e)};var Ld=(e,t,n)=>t in e?Dd(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var m=(e,t,n)=>Ld(e,typeof t!="symbol"?t+"":t,n),Ci=(e,t,n)=>t.has(e)||Ya("Cannot "+n);var d=(e,t,n)=>(Ci(e,t,"read from private field"),n?n.call(e):t.get(e)),I=(e,t,n)=>t.has(e)?Ya("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),C=(e,t,n,s)=>(Ci(e,t,"write to private field"),s?s.call(e,n):t.set(e,n),n),y=(e,t,n)=>(Ci(e,t,"access private method"),n);var Xa=(e,t,n,s)=>({set _(r){C(e,t,r,n)},get _(){return d(e,t,s)}});(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const r of document.querySelectorAll('link[rel="modulepreload"]'))s(r);new MutationObserver(r=>{for(const i of r)if(i.type==="childList")for(const o of i.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&s(o)}).observe(document,{childList:!0,subtree:!0});function n(r){const i={};return r.integrity&&(i.integrity=r.integrity),r.referrerPolicy&&(i.referrerPolicy=r.referrerPolicy),r.crossOrigin==="use-credentials"?i.credentials="include":r.crossOrigin==="anonymous"?i.credentials="omit":i.credentials="same-origin",i}function s(r){if(r.ep)return;r.ep=!0;const i=n(r);fetch(r.href,i)}})();const Ja=new WeakMap;function Md(e){return(typeof e=="object"||typeof e=="function")&&e!==null&&"then"in e&&typeof e.then=="function"}function yn(e){return typeof e=="string"?e:typeof e=="symbol"?e.description??e.toString():e.name||"(anonymous class)"}function Qa(){return new Error("register(Key, factory) requires a factory function. Wrap existing instances as () => instance.")}function Od(){return new Error("register(Key, factory) does not accept async factories. Await setup before registering.")}class Nd{constructor(){m(this,"entries",new Map);m(this,"constructionStack",[])}register(t,n){if(n===void 0){if(typeof t!="function")throw Qa();this.validateClassRegistration(t),this.storeFactory(t,()=>this.instantiateClass(t));return}if(typeof n!="function")throw Qa();if(n.constructor.name==="AsyncFunction")throw Od();this.storeFactory(t,n)}has(t){var n;return((n=this.entries.get(t))==null?void 0:n.factory)!==void 0}resolve(t){return this.resolveAny(t)}storeFactory(t,n){const s=this.getOrCreateEntry(t);s.factory=n,s.instance=void 0,s.error=void 0}validateClassRegistration(t){const n=Ja.get(t);if(n){if(t.length!==n.length)throw new Error(`${yn(t)} cannot be registered with register(Class). @injectable(...) declared ${n.length} dependencies but constructor arity is ${t.length}. Use register(Key, () => value) instead.`);return}if(t.length!==0)throw new Error(`${yn(t)} cannot be registered with register(Class). Undecorated classes must have zero required constructor parameters. Use register(Key, () => value) instead.`)}instantiateClass(t){const n=Ja.get(t);if(!n)return new t;const s=n.map(r=>this.resolveAny(r));return new t(...s)}resolveAny(t){return this.getOrCreateEntry(t).proxy}getOrCreateEntry(t){let n=this.entries.get(t);return n||(n={key:t},n.proxy=this.createProxy(n),this.entries.set(t,n),n)}createProxy(t){return new Proxy({},{get:(n,s)=>{if(s==="then")return;const r=this.getInstance(t),i=Reflect.get(r,s,r);return typeof i=="function"?i.bind(r):i},set:(n,s,r)=>{const i=this.getInstance(t);return Reflect.set(i,s,r,i)},has:(n,s)=>{const r=this.getInstance(t);return s in r}})}getInstance(t){if(t.instance)return t.instance;if(t.error)throw t.error;if(!t.factory)throw new Error(`${yn(t.key)} was resolved but never registered`);const n=this.constructionStack.indexOf(t.key);if(n!==-1){const s=[...this.constructionStack.slice(n),t.key].map(r=>yn(r)).join(" -> ");throw new Error(`Circular dependency detected: ${s}`)}this.constructionStack.push(t.key);try{const s=t.factory();if(Md(s))throw new Error(`Factory for ${yn(t.key)} returned a Promise. Await setup before registering.`);if(typeof s!="object"||s===null)throw new Error(`Factory for ${yn(t.key)} returned a non-object value. Wrap primitives in an object.`);return t.instance=s,s}catch(s){throw t.error=s,s}finally{this.constructionStack.pop()}}}const Ze=new Nd,Wd=new Set(["target","currentTarget","eventPhase","defaultPrevented","isTrusted","timeStamp","srcElement","returnValue","cancelBubble","NONE","CAPTURING_PHASE","AT_TARGET","BUBBLING_PHASE","composedPath","stopPropagation","stopImmediatePropagation","preventDefault","initEvent"]);function Fd(e){for(const t of Object.keys(e))if(Wd.has(t))throw new Error(`Event payload key "${t}" is reserved; choose a different property name`)}function Ud(e,t){Fd(t);for(const n of Object.keys(t))Object.defineProperty(e,n,{value:t[n],writable:!0,enumerable:!0,configurable:!0})}function rt(){class e extends Event{constructor(n,s){const{type:r,bubbles:i,cancelable:o,composed:a,...c}=s??{};if(r!==void 0)throw new Error('Do not pass "type" in init; use the constructor argument instead');super(n,{bubbles:i,cancelable:o,composed:a}),Ud(this,c)}}return e}class ln extends globalThis.EventTarget{}const B=rt(),yl=rt(),es=rt(),kl="0123456789ABCDEFGHJKMNPQRSTVWXYZ",Pr=32,Zd=16,wl=10,ec=0xffffffffffff;var Bt;(function(e){e.Base32IncorrectEncoding="B32_ENC_INVALID",e.DecodeTimeInvalidCharacter="DEC_TIME_CHAR",e.DecodeTimeValueMalformed="DEC_TIME_MALFORMED",e.EncodeTimeNegative="ENC_TIME_NEG",e.EncodeTimeSizeExceeded="ENC_TIME_SIZE_EXCEED",e.EncodeTimeValueMalformed="ENC_TIME_MALFORMED",e.PRNGDetectFailure="PRNG_DETECT",e.ULIDInvalid="ULID_INVALID",e.Unexpected="UNEXPECTED",e.UUIDInvalid="UUID_INVALID"})(Bt||(Bt={}));class us extends Error{constructor(t,n){super(`${n} (${t})`),this.name="ULIDError",this.code=t}}function jd(e){const t=Math.floor(e()*Pr)%Pr;return kl.charAt(t)}function Hd(e){const t=Bd(),n=t&&(t.crypto||t.msCrypto)||null;if(typeof(n==null?void 0:n.getRandomValues)=="function")return()=>{const s=new Uint8Array(1);return n.getRandomValues(s),s[0]/256};if(typeof(n==null?void 0:n.randomBytes)=="function")return()=>n.randomBytes(1).readUInt8()/256;throw new us(Bt.PRNGDetectFailure,"Failed to find a reliable PRNG")}function Bd(){return qd()?self:typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:null}function Vd(e,t){let n="";for(;e>0;e--)n=jd(t)+n;return n}function Gd(e,t=wl){if(isNaN(e))throw new us(Bt.EncodeTimeValueMalformed,`Time must be a number: ${e}`);if(e>ec)throw new us(Bt.EncodeTimeSizeExceeded,`Cannot encode a time larger than ${ec}: ${e}`);if(e<0)throw new us(Bt.EncodeTimeNegative,`Time must be positive: ${e}`);if(Number.isInteger(e)===!1)throw new us(Bt.EncodeTimeValueMalformed,`Time must be an integer: ${e}`);let n,s="";for(let r=t;r>0;r--)n=e%Pr,s=kl.charAt(n)+s,e=(e-n)/Pr;return s}function qd(){return typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope}function en(e,t){const n=Hd(),s=Date.now();return Gd(s,wl)+Vd(Zd,n)}function b(e,t,n){function s(a,c){if(a._zod||Object.defineProperty(a,"_zod",{value:{def:c,constr:o,traits:new Set},enumerable:!1}),a._zod.traits.has(e))return;a._zod.traits.add(e),t(a,c);const l=o.prototype,h=Object.keys(l);for(let f=0;f<h.length;f++){const w=h[f];w in a||(a[w]=l[w].bind(a))}}const r=(n==null?void 0:n.Parent)??Object;class i extends r{}Object.defineProperty(i,"name",{value:e});function o(a){var c;const l=n!=null&&n.Parent?new i:this;s(l,a),(c=l._zod).deferred??(c.deferred=[]);for(const h of l._zod.deferred)h();return l}return Object.defineProperty(o,"init",{value:s}),Object.defineProperty(o,Symbol.hasInstance,{value:a=>{var c,l;return n!=null&&n.Parent&&a instanceof n.Parent?!0:(l=(c=a==null?void 0:a._zod)==null?void 0:c.traits)==null?void 0:l.has(e)}}),Object.defineProperty(o,"name",{value:e}),o}class Cn extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class bl extends Error{constructor(t){super(`Encountered unidirectional transform during encode: ${t}`),this.name="ZodEncodeError"}}const Sl={};function It(e){return Sl}function xl(e){const t=Object.values(e).filter(s=>typeof s=="number");return Object.entries(e).filter(([s,r])=>t.indexOf(+s)===-1).map(([s,r])=>r)}function Xi(e,t){return typeof t=="bigint"?t.toString():t}function ei(e){return{get value(){{const t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function jo(e){return e==null}function Ho(e){const t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}function Kd(e,t){const n=(e.toString().split(".")[1]||"").length,s=t.toString();let r=(s.split(".")[1]||"").length;if(r===0&&/\d?e-\d?/.test(s)){const c=s.match(/\d?e-(\d?)/);c!=null&&c[1]&&(r=Number.parseInt(c[1]))}const i=n>r?n:r,o=Number.parseInt(e.toFixed(i).replace(".","")),a=Number.parseInt(t.toFixed(i).replace(".",""));return o%a/10**i}const tc=Symbol("evaluating");function q(e,t,n){let s;Object.defineProperty(e,t,{get(){if(s!==tc)return s===void 0&&(s=tc,s=n()),s},set(r){Object.defineProperty(e,t,{value:r})},configurable:!0})}function un(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function Pt(...e){const t={};for(const n of e){const s=Object.getOwnPropertyDescriptors(n);Object.assign(t,s)}return Object.defineProperties({},t)}function nc(e){return JSON.stringify(e)}function Yd(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}const El="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function ys(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}const Xd=ei(()=>{var e;if(typeof navigator<"u"&&((e=navigator==null?void 0:navigator.userAgent)!=null&&e.includes("Cloudflare")))return!1;try{const t=Function;return new t(""),!0}catch{return!1}});function Fn(e){if(ys(e)===!1)return!1;const t=e.constructor;if(t===void 0||typeof t!="function")return!0;const n=t.prototype;return!(ys(n)===!1||Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")===!1)}function Al(e){return Fn(e)?{...e}:Array.isArray(e)?[...e]:e}const Jd=new Set(["string","number","symbol"]);function Un(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Dt(e,t,n){const s=new e._zod.constr(t??e._zod.def);return(!t||n!=null&&n.parent)&&(s._zod.parent=e),s}function P(e){const t=e;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 Qd(e){return Object.keys(e).filter(t=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}const ep={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 tp(e,t){const n=e._zod.def,s=n.checks;if(s&&s.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");const i=Pt(e._zod.def,{get shape(){const o={};for(const a in t){if(!(a in n.shape))throw new Error(`Unrecognized key: "${a}"`);t[a]&&(o[a]=n.shape[a])}return un(this,"shape",o),o},checks:[]});return Dt(e,i)}function np(e,t){const n=e._zod.def,s=n.checks;if(s&&s.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");const i=Pt(e._zod.def,{get shape(){const o={...e._zod.def.shape};for(const a in t){if(!(a in n.shape))throw new Error(`Unrecognized key: "${a}"`);t[a]&&delete o[a]}return un(this,"shape",o),o},checks:[]});return Dt(e,i)}function sp(e,t){if(!Fn(t))throw new Error("Invalid input to extend: expected a plain object");const n=e._zod.def.checks;if(n&&n.length>0){const i=e._zod.def.shape;for(const o in t)if(Object.getOwnPropertyDescriptor(i,o)!==void 0)throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}const r=Pt(e._zod.def,{get shape(){const i={...e._zod.def.shape,...t};return un(this,"shape",i),i}});return Dt(e,r)}function rp(e,t){if(!Fn(t))throw new Error("Invalid input to safeExtend: expected a plain object");const n=Pt(e._zod.def,{get shape(){const s={...e._zod.def.shape,...t};return un(this,"shape",s),s}});return Dt(e,n)}function ip(e,t){const n=Pt(e._zod.def,{get shape(){const s={...e._zod.def.shape,...t._zod.def.shape};return un(this,"shape",s),s},get catchall(){return t._zod.def.catchall},checks:[]});return Dt(e,n)}function op(e,t,n){const r=t._zod.def.checks;if(r&&r.length>0)throw new Error(".partial() cannot be used on object schemas containing refinements");const o=Pt(t._zod.def,{get shape(){const a=t._zod.def.shape,c={...a};if(n)for(const l in n){if(!(l in a))throw new Error(`Unrecognized key: "${l}"`);n[l]&&(c[l]=e?new e({type:"optional",innerType:a[l]}):a[l])}else for(const l in a)c[l]=e?new e({type:"optional",innerType:a[l]}):a[l];return un(this,"shape",c),c},checks:[]});return Dt(t,o)}function ap(e,t,n){const s=Pt(t._zod.def,{get shape(){const r=t._zod.def.shape,i={...r};if(n)for(const o in n){if(!(o in i))throw new Error(`Unrecognized key: "${o}"`);n[o]&&(i[o]=new e({type:"nonoptional",innerType:r[o]}))}else for(const o in r)i[o]=new e({type:"nonoptional",innerType:r[o]});return un(this,"shape",i),i}});return Dt(t,s)}function An(e,t=0){var n;if(e.aborted===!0)return!0;for(let s=t;s<e.issues.length;s++)if(((n=e.issues[s])==null?void 0:n.continue)!==!0)return!0;return!1}function Tn(e,t){return t.map(n=>{var s;return(s=n).path??(s.path=[]),n.path.unshift(e),n})}function lr(e){return typeof e=="string"?e:e==null?void 0:e.message}function Ct(e,t,n){var r,i,o,a,c,l;const s={...e,path:e.path??[]};if(!e.message){const h=lr((o=(i=(r=e.inst)==null?void 0:r._zod.def)==null?void 0:i.error)==null?void 0:o.call(i,e))??lr((a=t==null?void 0:t.error)==null?void 0:a.call(t,e))??lr((c=n.customError)==null?void 0:c.call(n,e))??lr((l=n.localeError)==null?void 0:l.call(n,e))??"Invalid input";s.message=h}return delete s.inst,delete s.continue,t!=null&&t.reportInput||delete s.input,s}function Bo(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function ks(...e){const[t,n,s]=e;return typeof t=="string"?{message:t,code:"custom",input:n,inst:s}:{...t}}const Tl=(e,t)=>{e.name="$ZodError",Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:t,enumerable:!1}),e.message=JSON.stringify(t,Xi,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},Il=b("$ZodError",Tl),Cl=b("$ZodError",Tl,{Parent:Error});function cp(e,t=n=>n.message){const n={},s=[];for(const r of e.issues)r.path.length>0?(n[r.path[0]]=n[r.path[0]]||[],n[r.path[0]].push(t(r))):s.push(t(r));return{formErrors:s,fieldErrors:n}}function lp(e,t=n=>n.message){const n={_errors:[]},s=r=>{for(const i of r.issues)if(i.code==="invalid_union"&&i.errors.length)i.errors.map(o=>s({issues:o}));else if(i.code==="invalid_key")s({issues:i.issues});else if(i.code==="invalid_element")s({issues:i.issues});else if(i.path.length===0)n._errors.push(t(i));else{let o=n,a=0;for(;a<i.path.length;){const c=i.path[a];a===i.path.length-1?(o[c]=o[c]||{_errors:[]},o[c]._errors.push(t(i))):o[c]=o[c]||{_errors:[]},o=o[c],a++}}};return s(e),n}const Vo=e=>(t,n,s,r)=>{const i=s?Object.assign(s,{async:!1}):{async:!1},o=t._zod.run({value:n,issues:[]},i);if(o instanceof Promise)throw new Cn;if(o.issues.length){const a=new((r==null?void 0:r.Err)??e)(o.issues.map(c=>Ct(c,i,It())));throw El(a,r==null?void 0:r.callee),a}return o.value},Go=e=>async(t,n,s,r)=>{const i=s?Object.assign(s,{async:!0}):{async:!0};let o=t._zod.run({value:n,issues:[]},i);if(o instanceof Promise&&(o=await o),o.issues.length){const a=new((r==null?void 0:r.Err)??e)(o.issues.map(c=>Ct(c,i,It())));throw El(a,r==null?void 0:r.callee),a}return o.value},ti=e=>(t,n,s)=>{const r=s?{...s,async:!1}:{async:!1},i=t._zod.run({value:n,issues:[]},r);if(i instanceof Promise)throw new Cn;return i.issues.length?{success:!1,error:new(e??Il)(i.issues.map(o=>Ct(o,r,It())))}:{success:!0,data:i.value}},up=ti(Cl),ni=e=>async(t,n,s)=>{const r=s?Object.assign(s,{async:!0}):{async:!0};let i=t._zod.run({value:n,issues:[]},r);return i instanceof Promise&&(i=await i),i.issues.length?{success:!1,error:new e(i.issues.map(o=>Ct(o,r,It())))}:{success:!0,data:i.value}},hp=ni(Cl),dp=e=>(t,n,s)=>{const r=s?Object.assign(s,{direction:"backward"}):{direction:"backward"};return Vo(e)(t,n,r)},pp=e=>(t,n,s)=>Vo(e)(t,n,s),fp=e=>async(t,n,s)=>{const r=s?Object.assign(s,{direction:"backward"}):{direction:"backward"};return Go(e)(t,n,r)},gp=e=>async(t,n,s)=>Go(e)(t,n,s),mp=e=>(t,n,s)=>{const r=s?Object.assign(s,{direction:"backward"}):{direction:"backward"};return ti(e)(t,n,r)},vp=e=>(t,n,s)=>ti(e)(t,n,s),_p=e=>async(t,n,s)=>{const r=s?Object.assign(s,{direction:"backward"}):{direction:"backward"};return ni(e)(t,n,r)},yp=e=>async(t,n,s)=>ni(e)(t,n,s),kp=/^[cC][^\s-]{8,}$/,wp=/^[0-9a-z]+$/,bp=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,Sp=/^[0-9a-vA-V]{20}$/,xp=/^[A-Za-z0-9]{27}$/,Ep=/^[a-zA-Z0-9_-]{21}$/,Ap=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,Tp=/^([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})$/,sc=e=>e?new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[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)$/,Ip=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,Cp="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function zp(){return new RegExp(Cp,"u")}const $p=/^(?:(?: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])$/,Rp=/^(([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}|:))$/,Pp=/^((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])$/,Dp=/^(([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])$/,Lp=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,zl=/^[A-Za-z0-9_-]*$/,Mp=/^\+[1-9]\d{6,14}$/,$l="(?:(?:\\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])))",Op=new RegExp(`^${$l}$`);function Rl(e){const t="(?:[01]\\d|2[0-3]):[0-5]\\d";return typeof e.precision=="number"?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function Np(e){return new RegExp(`^${Rl(e)}$`)}function Wp(e){const t=Rl({precision:e.precision}),n=["Z"];e.local&&n.push(""),e.offset&&n.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");const s=`${t}(?:${n.join("|")})`;return new RegExp(`^${$l}T(?:${s})$`)}const Fp=e=>{const t=e?`[\\s\\S]{${(e==null?void 0:e.minimum)??0},${(e==null?void 0:e.maximum)??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)},Up=/^-?\d+$/,Pl=/^-?\d+(?:\.\d+)?$/,Zp=/^(?:true|false)$/i,jp=/^[^A-Z]*$/,Hp=/^[^a-z]*$/,Le=b("$ZodCheck",(e,t)=>{var n;e._zod??(e._zod={}),e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),Dl={number:"number",bigint:"bigint",object:"date"},Ll=b("$ZodCheckLessThan",(e,t)=>{Le.init(e,t);const n=Dl[typeof t.value];e._zod.onattach.push(s=>{const r=s._zod.bag,i=(t.inclusive?r.maximum:r.exclusiveMaximum)??Number.POSITIVE_INFINITY;t.value<i&&(t.inclusive?r.maximum=t.value:r.exclusiveMaximum=t.value)}),e._zod.check=s=>{(t.inclusive?s.value<=t.value:s.value<t.value)||s.issues.push({origin:n,code:"too_big",maximum:typeof t.value=="object"?t.value.getTime():t.value,input:s.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Ml=b("$ZodCheckGreaterThan",(e,t)=>{Le.init(e,t);const n=Dl[typeof t.value];e._zod.onattach.push(s=>{const r=s._zod.bag,i=(t.inclusive?r.minimum:r.exclusiveMinimum)??Number.NEGATIVE_INFINITY;t.value>i&&(t.inclusive?r.minimum=t.value:r.exclusiveMinimum=t.value)}),e._zod.check=s=>{(t.inclusive?s.value>=t.value:s.value>t.value)||s.issues.push({origin:n,code:"too_small",minimum:typeof t.value=="object"?t.value.getTime():t.value,input:s.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Bp=b("$ZodCheckMultipleOf",(e,t)=>{Le.init(e,t),e._zod.onattach.push(n=>{var s;(s=n._zod.bag).multipleOf??(s.multipleOf=t.value)}),e._zod.check=n=>{if(typeof n.value!=typeof t.value)throw new Error("Cannot mix number and bigint in multiple_of check.");(typeof n.value=="bigint"?n.value%t.value===BigInt(0):Kd(n.value,t.value)===0)||n.issues.push({origin:typeof n.value,code:"not_multiple_of",divisor:t.value,input:n.value,inst:e,continue:!t.abort})}}),Vp=b("$ZodCheckNumberFormat",(e,t)=>{var o;Le.init(e,t),t.format=t.format||"float64";const n=(o=t.format)==null?void 0:o.includes("int"),s=n?"int":"number",[r,i]=ep[t.format];e._zod.onattach.push(a=>{const c=a._zod.bag;c.format=t.format,c.minimum=r,c.maximum=i,n&&(c.pattern=Up)}),e._zod.check=a=>{const c=a.value;if(n){if(!Number.isInteger(c)){a.issues.push({expected:s,format:t.format,code:"invalid_type",continue:!1,input:c,inst:e});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:e,origin:s,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:e,origin:s,inclusive:!0,continue:!t.abort});return}}c<r&&a.issues.push({origin:"number",input:c,code:"too_small",minimum:r,inclusive:!0,inst:e,continue:!t.abort}),c>i&&a.issues.push({origin:"number",input:c,code:"too_big",maximum:i,inclusive:!0,inst:e,continue:!t.abort})}}),Gp=b("$ZodCheckMaxLength",(e,t)=>{var n;Le.init(e,t),(n=e._zod.def).when??(n.when=s=>{const r=s.value;return!jo(r)&&r.length!==void 0}),e._zod.onattach.push(s=>{const r=s._zod.bag.maximum??Number.POSITIVE_INFINITY;t.maximum<r&&(s._zod.bag.maximum=t.maximum)}),e._zod.check=s=>{const r=s.value;if(r.length<=t.maximum)return;const o=Bo(r);s.issues.push({origin:o,code:"too_big",maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),qp=b("$ZodCheckMinLength",(e,t)=>{var n;Le.init(e,t),(n=e._zod.def).when??(n.when=s=>{const r=s.value;return!jo(r)&&r.length!==void 0}),e._zod.onattach.push(s=>{const r=s._zod.bag.minimum??Number.NEGATIVE_INFINITY;t.minimum>r&&(s._zod.bag.minimum=t.minimum)}),e._zod.check=s=>{const r=s.value;if(r.length>=t.minimum)return;const o=Bo(r);s.issues.push({origin:o,code:"too_small",minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),Kp=b("$ZodCheckLengthEquals",(e,t)=>{var n;Le.init(e,t),(n=e._zod.def).when??(n.when=s=>{const r=s.value;return!jo(r)&&r.length!==void 0}),e._zod.onattach.push(s=>{const r=s._zod.bag;r.minimum=t.length,r.maximum=t.length,r.length=t.length}),e._zod.check=s=>{const r=s.value,i=r.length;if(i===t.length)return;const o=Bo(r),a=i>t.length;s.issues.push({origin:o,...a?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:s.value,inst:e,continue:!t.abort})}}),si=b("$ZodCheckStringFormat",(e,t)=>{var n,s;Le.init(e,t),e._zod.onattach.push(r=>{const i=r._zod.bag;i.format=t.format,t.pattern&&(i.patterns??(i.patterns=new Set),i.patterns.add(t.pattern))}),t.pattern?(n=e._zod).check??(n.check=r=>{t.pattern.lastIndex=0,!t.pattern.test(r.value)&&r.issues.push({origin:"string",code:"invalid_format",format:t.format,input:r.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(s=e._zod).check??(s.check=()=>{})}),Yp=b("$ZodCheckRegex",(e,t)=>{si.init(e,t),e._zod.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:"string",code:"invalid_format",format:"regex",input:n.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),Xp=b("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=jp),si.init(e,t)}),Jp=b("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=Hp),si.init(e,t)}),Qp=b("$ZodCheckIncludes",(e,t)=>{Le.init(e,t);const n=Un(t.includes),s=new RegExp(typeof t.position=="number"?`^.{${t.position}}${n}`:n);t.pattern=s,e._zod.onattach.push(r=>{const i=r._zod.bag;i.patterns??(i.patterns=new Set),i.patterns.add(s)}),e._zod.check=r=>{r.value.includes(t.includes,t.position)||r.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:r.value,inst:e,continue:!t.abort})}}),ef=b("$ZodCheckStartsWith",(e,t)=>{Le.init(e,t);const n=new RegExp(`^${Un(t.prefix)}.*`);t.pattern??(t.pattern=n),e._zod.onattach.push(s=>{const r=s._zod.bag;r.patterns??(r.patterns=new Set),r.patterns.add(n)}),e._zod.check=s=>{s.value.startsWith(t.prefix)||s.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:s.value,inst:e,continue:!t.abort})}}),tf=b("$ZodCheckEndsWith",(e,t)=>{Le.init(e,t);const n=new RegExp(`.*${Un(t.suffix)}$`);t.pattern??(t.pattern=n),e._zod.onattach.push(s=>{const r=s._zod.bag;r.patterns??(r.patterns=new Set),r.patterns.add(n)}),e._zod.check=s=>{s.value.endsWith(t.suffix)||s.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:s.value,inst:e,continue:!t.abort})}}),nf=b("$ZodCheckOverwrite",(e,t)=>{Le.init(e,t),e._zod.check=n=>{n.value=t.tx(n.value)}});class sf{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 s=t.split(`
|
|
2
|
-
`).filter(o=>o),r=Math.min(...s.map(o=>o.length-o.trimStart().length)),i=s.map(o=>o.slice(r)).map(o=>" ".repeat(this.indent*2)+o);for(const o of i)this.content.push(o)}compile(){const t=Function,n=this==null?void 0:this.args,r=[...((this==null?void 0:this.content)??[""]).map(i=>` ${i}`)];return new t(...n,r.join(`
|
|
3
|
-
`))}}const rf={major:4,minor:3,patch:6},ie=b("$ZodType",(e,t)=>{var r;var n;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=rf;const s=[...e._zod.def.checks??[]];e._zod.traits.has("$ZodCheck")&&s.unshift(e);for(const i of s)for(const o of i._zod.onattach)o(e);if(s.length===0)(n=e._zod).deferred??(n.deferred=[]),(r=e._zod.deferred)==null||r.push(()=>{e._zod.run=e._zod.parse});else{const i=(a,c,l)=>{let h=An(a),f;for(const w of c){if(w._zod.def.when){if(!w._zod.def.when(a))continue}else if(h)continue;const v=a.issues.length,E=w._zod.check(a);if(E instanceof Promise&&(l==null?void 0:l.async)===!1)throw new Cn;if(f||E instanceof Promise)f=(f??Promise.resolve()).then(async()=>{await E,a.issues.length!==v&&(h||(h=An(a,v)))});else{if(a.issues.length===v)continue;h||(h=An(a,v))}}return f?f.then(()=>a):a},o=(a,c,l)=>{if(An(a))return a.aborted=!0,a;const h=i(c,s,l);if(h instanceof Promise){if(l.async===!1)throw new Cn;return h.then(f=>e._zod.parse(f,l))}return e._zod.parse(h,l)};e._zod.run=(a,c)=>{if(c.skipChecks)return e._zod.parse(a,c);if(c.direction==="backward"){const h=e._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 l=e._zod.parse(a,c);if(l instanceof Promise){if(c.async===!1)throw new Cn;return l.then(h=>i(h,s,c))}return i(l,s,c)}}q(e,"~standard",()=>({validate:i=>{var o;try{const a=up(e,i);return a.success?{value:a.data}:{issues:(o=a.error)==null?void 0:o.issues}}catch{return hp(e,i).then(c=>{var l;return c.success?{value:c.data}:{issues:(l=c.error)==null?void 0:l.issues}})}},vendor:"zod",version:1}))}),qo=b("$ZodString",(e,t)=>{var n;ie.init(e,t),e._zod.pattern=[...((n=e==null?void 0:e._zod.bag)==null?void 0:n.patterns)??[]].pop()??Fp(e._zod.bag),e._zod.parse=(s,r)=>{if(t.coerce)try{s.value=String(s.value)}catch{}return typeof s.value=="string"||s.issues.push({expected:"string",code:"invalid_type",input:s.value,inst:e}),s}}),se=b("$ZodStringFormat",(e,t)=>{si.init(e,t),qo.init(e,t)}),of=b("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=Tp),se.init(e,t)}),af=b("$ZodUUID",(e,t)=>{if(t.version){const s={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(s===void 0)throw new Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=sc(s))}else t.pattern??(t.pattern=sc());se.init(e,t)}),cf=b("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=Ip),se.init(e,t)}),lf=b("$ZodURL",(e,t)=>{se.init(e,t),e._zod.check=n=>{try{const s=n.value.trim(),r=new URL(s);t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(r.hostname)||n.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:t.hostname.source,input:n.value,inst:e,continue:!t.abort})),t.protocol&&(t.protocol.lastIndex=0,t.protocol.test(r.protocol.endsWith(":")?r.protocol.slice(0,-1):r.protocol)||n.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:n.value,inst:e,continue:!t.abort})),t.normalize?n.value=r.href:n.value=s;return}catch{n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort})}}}),uf=b("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=zp()),se.init(e,t)}),hf=b("$ZodNanoID",(e,t)=>{t.pattern??(t.pattern=Ep),se.init(e,t)}),df=b("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=kp),se.init(e,t)}),pf=b("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=wp),se.init(e,t)}),ff=b("$ZodULID",(e,t)=>{t.pattern??(t.pattern=bp),se.init(e,t)}),gf=b("$ZodXID",(e,t)=>{t.pattern??(t.pattern=Sp),se.init(e,t)}),mf=b("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=xp),se.init(e,t)}),vf=b("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=Wp(t)),se.init(e,t)}),_f=b("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=Op),se.init(e,t)}),yf=b("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=Np(t)),se.init(e,t)}),kf=b("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=Ap),se.init(e,t)}),wf=b("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=$p),se.init(e,t),e._zod.bag.format="ipv4"}),bf=b("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=Rp),se.init(e,t),e._zod.bag.format="ipv6",e._zod.check=n=>{try{new URL(`http://[${n.value}]`)}catch{n.issues.push({code:"invalid_format",format:"ipv6",input:n.value,inst:e,continue:!t.abort})}}}),Sf=b("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=Pp),se.init(e,t)}),xf=b("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=Dp),se.init(e,t),e._zod.check=n=>{const s=n.value.split("/");try{if(s.length!==2)throw new Error;const[r,i]=s;if(!i)throw new Error;const o=Number(i);if(`${o}`!==i)throw new Error;if(o<0||o>128)throw new Error;new URL(`http://[${r}]`)}catch{n.issues.push({code:"invalid_format",format:"cidrv6",input:n.value,inst:e,continue:!t.abort})}}});function Ol(e){if(e==="")return!0;if(e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}const Ef=b("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=Lp),se.init(e,t),e._zod.bag.contentEncoding="base64",e._zod.check=n=>{Ol(n.value)||n.issues.push({code:"invalid_format",format:"base64",input:n.value,inst:e,continue:!t.abort})}});function Af(e){if(!zl.test(e))return!1;const t=e.replace(/[-_]/g,s=>s==="-"?"+":"/"),n=t.padEnd(Math.ceil(t.length/4)*4,"=");return Ol(n)}const Tf=b("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=zl),se.init(e,t),e._zod.bag.contentEncoding="base64url",e._zod.check=n=>{Af(n.value)||n.issues.push({code:"invalid_format",format:"base64url",input:n.value,inst:e,continue:!t.abort})}}),If=b("$ZodE164",(e,t)=>{t.pattern??(t.pattern=Mp),se.init(e,t)});function Cf(e,t=null){try{const n=e.split(".");if(n.length!==3)return!1;const[s]=n;if(!s)return!1;const r=JSON.parse(atob(s));return!("typ"in r&&(r==null?void 0:r.typ)!=="JWT"||!r.alg||t&&(!("alg"in r)||r.alg!==t))}catch{return!1}}const zf=b("$ZodJWT",(e,t)=>{se.init(e,t),e._zod.check=n=>{Cf(n.value,t.alg)||n.issues.push({code:"invalid_format",format:"jwt",input:n.value,inst:e,continue:!t.abort})}}),Nl=b("$ZodNumber",(e,t)=>{ie.init(e,t),e._zod.pattern=e._zod.bag.pattern??Pl,e._zod.parse=(n,s)=>{if(t.coerce)try{n.value=Number(n.value)}catch{}const r=n.value;if(typeof r=="number"&&!Number.isNaN(r)&&Number.isFinite(r))return n;const i=typeof r=="number"?Number.isNaN(r)?"NaN":Number.isFinite(r)?void 0:"Infinity":void 0;return n.issues.push({expected:"number",code:"invalid_type",input:r,inst:e,...i?{received:i}:{}}),n}}),$f=b("$ZodNumberFormat",(e,t)=>{Vp.init(e,t),Nl.init(e,t)}),Rf=b("$ZodBoolean",(e,t)=>{ie.init(e,t),e._zod.pattern=Zp,e._zod.parse=(n,s)=>{if(t.coerce)try{n.value=!!n.value}catch{}const r=n.value;return typeof r=="boolean"||n.issues.push({expected:"boolean",code:"invalid_type",input:r,inst:e}),n}}),Pf=b("$ZodUnknown",(e,t)=>{ie.init(e,t),e._zod.parse=n=>n}),Df=b("$ZodNever",(e,t)=>{ie.init(e,t),e._zod.parse=(n,s)=>(n.issues.push({expected:"never",code:"invalid_type",input:n.value,inst:e}),n)});function rc(e,t,n){e.issues.length&&t.issues.push(...Tn(n,e.issues)),t.value[n]=e.value}const Lf=b("$ZodArray",(e,t)=>{ie.init(e,t),e._zod.parse=(n,s)=>{const r=n.value;if(!Array.isArray(r))return n.issues.push({expected:"array",code:"invalid_type",input:r,inst:e}),n;n.value=Array(r.length);const i=[];for(let o=0;o<r.length;o++){const a=r[o],c=t.element._zod.run({value:a,issues:[]},s);c instanceof Promise?i.push(c.then(l=>rc(l,n,o))):rc(c,n,o)}return i.length?Promise.all(i).then(()=>n):n}});function Dr(e,t,n,s,r){if(e.issues.length){if(r&&!(n in s))return;t.issues.push(...Tn(n,e.issues))}e.value===void 0?n in s&&(t.value[n]=void 0):t.value[n]=e.value}function Wl(e){var s,r,i,o;const t=Object.keys(e.shape);for(const a of t)if(!((o=(i=(r=(s=e.shape)==null?void 0:s[a])==null?void 0:r._zod)==null?void 0:i.traits)!=null&&o.has("$ZodType")))throw new Error(`Invalid element at key "${a}": expected a Zod schema`);const n=Qd(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(n)}}function Fl(e,t,n,s,r,i){const o=[],a=r.keySet,c=r.catchall._zod,l=c.def.type,h=c.optout==="optional";for(const f in t){if(a.has(f))continue;if(l==="never"){o.push(f);continue}const w=c.run({value:t[f],issues:[]},s);w instanceof Promise?e.push(w.then(v=>Dr(v,n,f,t,h))):Dr(w,n,f,t,h)}return o.length&&n.issues.push({code:"unrecognized_keys",keys:o,input:t,inst:i}),e.length?Promise.all(e).then(()=>n):n}const Mf=b("$ZodObject",(e,t)=>{ie.init(e,t);const n=Object.getOwnPropertyDescriptor(t,"shape");if(!(n!=null&&n.get)){const a=t.shape;Object.defineProperty(t,"shape",{get:()=>{const c={...a};return Object.defineProperty(t,"shape",{value:c}),c}})}const s=ei(()=>Wl(t));q(e._zod,"propValues",()=>{const a=t.shape,c={};for(const l in a){const h=a[l]._zod;if(h.values){c[l]??(c[l]=new Set);for(const f of h.values)c[l].add(f)}}return c});const r=ys,i=t.catchall;let o;e._zod.parse=(a,c)=>{o??(o=s.value);const l=a.value;if(!r(l))return a.issues.push({expected:"object",code:"invalid_type",input:l,inst:e}),a;a.value={};const h=[],f=o.shape;for(const w of o.keys){const v=f[w],E=v._zod.optout==="optional",x=v._zod.run({value:l[w],issues:[]},c);x instanceof Promise?h.push(x.then(z=>Dr(z,a,w,l,E))):Dr(x,a,w,l,E)}return i?Fl(h,l,a,c,s.value,e):h.length?Promise.all(h).then(()=>a):a}}),Of=b("$ZodObjectJIT",(e,t)=>{Mf.init(e,t);const n=e._zod.parse,s=ei(()=>Wl(t)),r=w=>{var ye;const v=new sf(["shape","payload","ctx"]),E=s.value,x=M=>{const G=nc(M);return`shape[${G}]._zod.run({ value: input[${G}], issues: [] }, ctx)`};v.write("const input = payload.value;");const z=Object.create(null);let K=0;for(const M of E.keys)z[M]=`key_${K++}`;v.write("const newResult = {};");for(const M of E.keys){const G=z[M],U=nc(M),Te=w[M],X=((ye=Te==null?void 0:Te._zod)==null?void 0:ye.optout)==="optional";v.write(`const ${G} = ${x(M)};`),X?v.write(`
|
|
4
|
-
if (${G}.issues.length) {
|
|
5
|
-
if (${U} in input) {
|
|
6
|
-
payload.issues = payload.issues.concat(${G}.issues.map(iss => ({
|
|
7
|
-
...iss,
|
|
8
|
-
path: iss.path ? [${U}, ...iss.path] : [${U}]
|
|
9
|
-
})));
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
if (${G}.value === undefined) {
|
|
14
|
-
if (${U} in input) {
|
|
15
|
-
newResult[${U}] = undefined;
|
|
16
|
-
}
|
|
17
|
-
} else {
|
|
18
|
-
newResult[${U}] = ${G}.value;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
`):v.write(`
|
|
22
|
-
if (${G}.issues.length) {
|
|
23
|
-
payload.issues = payload.issues.concat(${G}.issues.map(iss => ({
|
|
24
|
-
...iss,
|
|
25
|
-
path: iss.path ? [${U}, ...iss.path] : [${U}]
|
|
26
|
-
})));
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
if (${G}.value === undefined) {
|
|
30
|
-
if (${U} in input) {
|
|
31
|
-
newResult[${U}] = undefined;
|
|
32
|
-
}
|
|
33
|
-
} else {
|
|
34
|
-
newResult[${U}] = ${G}.value;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
`)}v.write("payload.value = newResult;"),v.write("return payload;");const Z=v.compile();return(M,G)=>Z(w,M,G)};let i;const o=ys,a=!Sl.jitless,l=a&&Xd.value,h=t.catchall;let f;e._zod.parse=(w,v)=>{f??(f=s.value);const E=w.value;return o(E)?a&&l&&(v==null?void 0:v.async)===!1&&v.jitless!==!0?(i||(i=r(t.shape)),w=i(w,v),h?Fl([],E,w,v,f,e):w):n(w,v):(w.issues.push({expected:"object",code:"invalid_type",input:E,inst:e}),w)}});function ic(e,t,n,s){for(const i of e)if(i.issues.length===0)return t.value=i.value,t;const r=e.filter(i=>!An(i));return r.length===1?(t.value=r[0].value,r[0]):(t.issues.push({code:"invalid_union",input:t.value,inst:n,errors:e.map(i=>i.issues.map(o=>Ct(o,s,It())))}),t)}const Ul=b("$ZodUnion",(e,t)=>{ie.init(e,t),q(e._zod,"optin",()=>t.options.some(r=>r._zod.optin==="optional")?"optional":void 0),q(e._zod,"optout",()=>t.options.some(r=>r._zod.optout==="optional")?"optional":void 0),q(e._zod,"values",()=>{if(t.options.every(r=>r._zod.values))return new Set(t.options.flatMap(r=>Array.from(r._zod.values)))}),q(e._zod,"pattern",()=>{if(t.options.every(r=>r._zod.pattern)){const r=t.options.map(i=>i._zod.pattern);return new RegExp(`^(${r.map(i=>Ho(i.source)).join("|")})$`)}});const n=t.options.length===1,s=t.options[0]._zod.run;e._zod.parse=(r,i)=>{if(n)return s(r,i);let o=!1;const a=[];for(const c of t.options){const l=c._zod.run({value:r.value,issues:[]},i);if(l instanceof Promise)a.push(l),o=!0;else{if(l.issues.length===0)return l;a.push(l)}}return o?Promise.all(a).then(c=>ic(c,r,e,i)):ic(a,r,e,i)}}),Nf=b("$ZodDiscriminatedUnion",(e,t)=>{t.inclusive=!1,Ul.init(e,t);const n=e._zod.parse;q(e._zod,"propValues",()=>{const r={};for(const i of t.options){const o=i._zod.propValues;if(!o||Object.keys(o).length===0)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(i)}"`);for(const[a,c]of Object.entries(o)){r[a]||(r[a]=new Set);for(const l of c)r[a].add(l)}}return r});const s=ei(()=>{var o;const r=t.options,i=new Map;for(const a of r){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 l of c){if(i.has(l))throw new Error(`Duplicate discriminator value "${String(l)}"`);i.set(l,a)}}return i});e._zod.parse=(r,i)=>{const o=r.value;if(!ys(o))return r.issues.push({code:"invalid_type",expected:"object",input:o,inst:e}),r;const a=s.value.get(o==null?void 0:o[t.discriminator]);return a?a._zod.run(r,i):t.unionFallback?n(r,i):(r.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:t.discriminator,input:o,path:[t.discriminator],inst:e}),r)}}),Wf=b("$ZodIntersection",(e,t)=>{ie.init(e,t),e._zod.parse=(n,s)=>{const r=n.value,i=t.left._zod.run({value:r,issues:[]},s),o=t.right._zod.run({value:r,issues:[]},s);return i instanceof Promise||o instanceof Promise?Promise.all([i,o]).then(([c,l])=>oc(n,c,l)):oc(n,i,o)}});function Ji(e,t){if(e===t)return{valid:!0,data:e};if(e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(Fn(e)&&Fn(t)){const n=Object.keys(t),s=Object.keys(e).filter(i=>n.indexOf(i)!==-1),r={...e,...t};for(const i of s){const o=Ji(e[i],t[i]);if(!o.valid)return{valid:!1,mergeErrorPath:[i,...o.mergeErrorPath]};r[i]=o.data}return{valid:!0,data:r}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};const n=[];for(let s=0;s<e.length;s++){const r=e[s],i=t[s],o=Ji(r,i);if(!o.valid)return{valid:!1,mergeErrorPath:[s,...o.mergeErrorPath]};n.push(o.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function oc(e,t,n){const s=new Map;let r;for(const a of t.issues)if(a.code==="unrecognized_keys"){r??(r=a);for(const c of a.keys)s.has(c)||s.set(c,{}),s.get(c).l=!0}else e.issues.push(a);for(const a of n.issues)if(a.code==="unrecognized_keys")for(const c of a.keys)s.has(c)||s.set(c,{}),s.get(c).r=!0;else e.issues.push(a);const i=[...s].filter(([,a])=>a.l&&a.r).map(([a])=>a);if(i.length&&r&&e.issues.push({...r,keys:i}),An(e))return e;const o=Ji(t.value,n.value);if(!o.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(o.mergeErrorPath)}`);return e.value=o.data,e}const Ff=b("$ZodRecord",(e,t)=>{ie.init(e,t),e._zod.parse=(n,s)=>{const r=n.value;if(!Fn(r))return n.issues.push({expected:"record",code:"invalid_type",input:r,inst:e}),n;const i=[],o=t.keyType._zod.values;if(o){n.value={};const a=new Set;for(const l of o)if(typeof l=="string"||typeof l=="number"||typeof l=="symbol"){a.add(typeof l=="number"?l.toString():l);const h=t.valueType._zod.run({value:r[l],issues:[]},s);h instanceof Promise?i.push(h.then(f=>{f.issues.length&&n.issues.push(...Tn(l,f.issues)),n.value[l]=f.value})):(h.issues.length&&n.issues.push(...Tn(l,h.issues)),n.value[l]=h.value)}let c;for(const l in r)a.has(l)||(c=c??[],c.push(l));c&&c.length>0&&n.issues.push({code:"unrecognized_keys",input:r,inst:e,keys:c})}else{n.value={};for(const a of Reflect.ownKeys(r)){if(a==="__proto__")continue;let c=t.keyType._zod.run({value:a,issues:[]},s);if(c instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(typeof a=="string"&&Pl.test(a)&&c.issues.length){const f=t.keyType._zod.run({value:Number(a),issues:[]},s);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"?n.value[a]=r[a]:n.issues.push({code:"invalid_key",origin:"record",issues:c.issues.map(f=>Ct(f,s,It())),input:a,path:[a],inst:e});continue}const h=t.valueType._zod.run({value:r[a],issues:[]},s);h instanceof Promise?i.push(h.then(f=>{f.issues.length&&n.issues.push(...Tn(a,f.issues)),n.value[c.value]=f.value})):(h.issues.length&&n.issues.push(...Tn(a,h.issues)),n.value[c.value]=h.value)}}return i.length?Promise.all(i).then(()=>n):n}}),Uf=b("$ZodEnum",(e,t)=>{ie.init(e,t);const n=xl(t.entries),s=new Set(n);e._zod.values=s,e._zod.pattern=new RegExp(`^(${n.filter(r=>Jd.has(typeof r)).map(r=>typeof r=="string"?Un(r):r.toString()).join("|")})$`),e._zod.parse=(r,i)=>{const o=r.value;return s.has(o)||r.issues.push({code:"invalid_value",values:n,input:o,inst:e}),r}}),Zf=b("$ZodLiteral",(e,t)=>{if(ie.init(e,t),t.values.length===0)throw new Error("Cannot create literal schema with no valid values");const n=new Set(t.values);e._zod.values=n,e._zod.pattern=new RegExp(`^(${t.values.map(s=>typeof s=="string"?Un(s):s?Un(s.toString()):String(s)).join("|")})$`),e._zod.parse=(s,r)=>{const i=s.value;return n.has(i)||s.issues.push({code:"invalid_value",values:t.values,input:i,inst:e}),s}}),jf=b("$ZodTransform",(e,t)=>{ie.init(e,t),e._zod.parse=(n,s)=>{if(s.direction==="backward")throw new bl(e.constructor.name);const r=t.transform(n.value,n);if(s.async)return(r instanceof Promise?r:Promise.resolve(r)).then(o=>(n.value=o,n));if(r instanceof Promise)throw new Cn;return n.value=r,n}});function ac(e,t){return e.issues.length&&t===void 0?{issues:[],value:void 0}:e}const Zl=b("$ZodOptional",(e,t)=>{ie.init(e,t),e._zod.optin="optional",e._zod.optout="optional",q(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),q(e._zod,"pattern",()=>{const n=t.innerType._zod.pattern;return n?new RegExp(`^(${Ho(n.source)})?$`):void 0}),e._zod.parse=(n,s)=>{if(t.innerType._zod.optin==="optional"){const r=t.innerType._zod.run(n,s);return r instanceof Promise?r.then(i=>ac(i,n.value)):ac(r,n.value)}return n.value===void 0?n:t.innerType._zod.run(n,s)}}),Hf=b("$ZodExactOptional",(e,t)=>{Zl.init(e,t),q(e._zod,"values",()=>t.innerType._zod.values),q(e._zod,"pattern",()=>t.innerType._zod.pattern),e._zod.parse=(n,s)=>t.innerType._zod.run(n,s)}),Bf=b("$ZodNullable",(e,t)=>{ie.init(e,t),q(e._zod,"optin",()=>t.innerType._zod.optin),q(e._zod,"optout",()=>t.innerType._zod.optout),q(e._zod,"pattern",()=>{const n=t.innerType._zod.pattern;return n?new RegExp(`^(${Ho(n.source)}|null)$`):void 0}),q(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(n,s)=>n.value===null?n:t.innerType._zod.run(n,s)}),Vf=b("$ZodDefault",(e,t)=>{ie.init(e,t),e._zod.optin="optional",q(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,s)=>{if(s.direction==="backward")return t.innerType._zod.run(n,s);if(n.value===void 0)return n.value=t.defaultValue,n;const r=t.innerType._zod.run(n,s);return r instanceof Promise?r.then(i=>cc(i,t)):cc(r,t)}});function cc(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}const Gf=b("$ZodPrefault",(e,t)=>{ie.init(e,t),e._zod.optin="optional",q(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,s)=>(s.direction==="backward"||n.value===void 0&&(n.value=t.defaultValue),t.innerType._zod.run(n,s))}),qf=b("$ZodNonOptional",(e,t)=>{ie.init(e,t),q(e._zod,"values",()=>{const n=t.innerType._zod.values;return n?new Set([...n].filter(s=>s!==void 0)):void 0}),e._zod.parse=(n,s)=>{const r=t.innerType._zod.run(n,s);return r instanceof Promise?r.then(i=>lc(i,e)):lc(r,e)}});function lc(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:"invalid_type",expected:"nonoptional",input:e.value,inst:t}),e}const Kf=b("$ZodCatch",(e,t)=>{ie.init(e,t),q(e._zod,"optin",()=>t.innerType._zod.optin),q(e._zod,"optout",()=>t.innerType._zod.optout),q(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,s)=>{if(s.direction==="backward")return t.innerType._zod.run(n,s);const r=t.innerType._zod.run(n,s);return r instanceof Promise?r.then(i=>(n.value=i.value,i.issues.length&&(n.value=t.catchValue({...n,error:{issues:i.issues.map(o=>Ct(o,s,It()))},input:n.value}),n.issues=[]),n)):(n.value=r.value,r.issues.length&&(n.value=t.catchValue({...n,error:{issues:r.issues.map(i=>Ct(i,s,It()))},input:n.value}),n.issues=[]),n)}}),Yf=b("$ZodPipe",(e,t)=>{ie.init(e,t),q(e._zod,"values",()=>t.in._zod.values),q(e._zod,"optin",()=>t.in._zod.optin),q(e._zod,"optout",()=>t.out._zod.optout),q(e._zod,"propValues",()=>t.in._zod.propValues),e._zod.parse=(n,s)=>{if(s.direction==="backward"){const i=t.out._zod.run(n,s);return i instanceof Promise?i.then(o=>ur(o,t.in,s)):ur(i,t.in,s)}const r=t.in._zod.run(n,s);return r instanceof Promise?r.then(i=>ur(i,t.out,s)):ur(r,t.out,s)}});function ur(e,t,n){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues},n)}const Xf=b("$ZodReadonly",(e,t)=>{ie.init(e,t),q(e._zod,"propValues",()=>t.innerType._zod.propValues),q(e._zod,"values",()=>t.innerType._zod.values),q(e._zod,"optin",()=>{var n,s;return(s=(n=t.innerType)==null?void 0:n._zod)==null?void 0:s.optin}),q(e._zod,"optout",()=>{var n,s;return(s=(n=t.innerType)==null?void 0:n._zod)==null?void 0:s.optout}),e._zod.parse=(n,s)=>{if(s.direction==="backward")return t.innerType._zod.run(n,s);const r=t.innerType._zod.run(n,s);return r instanceof Promise?r.then(uc):uc(r)}});function uc(e){return e.value=Object.freeze(e.value),e}const Jf=b("$ZodCustom",(e,t)=>{Le.init(e,t),ie.init(e,t),e._zod.parse=(n,s)=>n,e._zod.check=n=>{const s=n.value,r=t.fn(s);if(r instanceof Promise)return r.then(i=>hc(i,n,s,e));hc(r,n,s,e)}});function hc(e,t,n,s){if(!e){const r={code:"custom",input:n,inst:s,path:[...s._zod.def.path??[]],continue:!s._zod.def.abort};s._zod.def.params&&(r.params=s._zod.def.params),t.issues.push(ks(r))}}var dc;class Qf{constructor(){this._map=new WeakMap,this._idmap=new Map}add(t,...n){const s=n[0];return this._map.set(t,s),s&&typeof s=="object"&&"id"in s&&this._idmap.set(s.id,t),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(t){const n=this._map.get(t);return n&&typeof n=="object"&&"id"in n&&this._idmap.delete(n.id),this._map.delete(t),this}get(t){const n=t._zod.parent;if(n){const s={...this.get(n)??{}};delete s.id;const r={...s,...this._map.get(t)};return Object.keys(r).length?r:void 0}return this._map.get(t)}has(t){return this._map.has(t)}}function eg(){return new Qf}(dc=globalThis).__zod_globalRegistry??(dc.__zod_globalRegistry=eg());const hs=globalThis.__zod_globalRegistry;function tg(e,t){return new e({type:"string",...P(t)})}function ng(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...P(t)})}function pc(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...P(t)})}function sg(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...P(t)})}function rg(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...P(t)})}function ig(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...P(t)})}function og(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...P(t)})}function ag(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...P(t)})}function cg(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...P(t)})}function lg(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...P(t)})}function ug(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...P(t)})}function hg(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...P(t)})}function dg(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...P(t)})}function pg(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...P(t)})}function fg(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...P(t)})}function gg(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...P(t)})}function mg(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...P(t)})}function vg(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...P(t)})}function _g(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...P(t)})}function yg(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...P(t)})}function kg(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...P(t)})}function wg(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...P(t)})}function bg(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...P(t)})}function Sg(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...P(t)})}function xg(e,t){return new e({type:"string",format:"date",check:"string_format",...P(t)})}function Eg(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...P(t)})}function Ag(e,t){return new e({type:"string",format:"duration",check:"string_format",...P(t)})}function Tg(e,t){return new e({type:"number",checks:[],...P(t)})}function Ig(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...P(t)})}function Cg(e,t){return new e({type:"boolean",...P(t)})}function zg(e){return new e({type:"unknown"})}function $g(e,t){return new e({type:"never",...P(t)})}function fc(e,t){return new Ll({check:"less_than",...P(t),value:e,inclusive:!1})}function zi(e,t){return new Ll({check:"less_than",...P(t),value:e,inclusive:!0})}function gc(e,t){return new Ml({check:"greater_than",...P(t),value:e,inclusive:!1})}function $i(e,t){return new Ml({check:"greater_than",...P(t),value:e,inclusive:!0})}function mc(e,t){return new Bp({check:"multiple_of",...P(t),value:e})}function jl(e,t){return new Gp({check:"max_length",...P(t),maximum:e})}function Lr(e,t){return new qp({check:"min_length",...P(t),minimum:e})}function Hl(e,t){return new Kp({check:"length_equals",...P(t),length:e})}function Rg(e,t){return new Yp({check:"string_format",format:"regex",...P(t),pattern:e})}function Pg(e){return new Xp({check:"string_format",format:"lowercase",...P(e)})}function Dg(e){return new Jp({check:"string_format",format:"uppercase",...P(e)})}function Lg(e,t){return new Qp({check:"string_format",format:"includes",...P(t),includes:e})}function Mg(e,t){return new ef({check:"string_format",format:"starts_with",...P(t),prefix:e})}function Og(e,t){return new tf({check:"string_format",format:"ends_with",...P(t),suffix:e})}function Bn(e){return new nf({check:"overwrite",tx:e})}function Ng(e){return Bn(t=>t.normalize(e))}function Wg(){return Bn(e=>e.trim())}function Fg(){return Bn(e=>e.toLowerCase())}function Ug(){return Bn(e=>e.toUpperCase())}function Zg(){return Bn(e=>Yd(e))}function jg(e,t,n){return new e({type:"array",element:t,...P(n)})}function Hg(e,t,n){return new e({type:"custom",check:"custom",fn:t,...P(n)})}function Bg(e){const t=Vg(n=>(n.addIssue=s=>{if(typeof s=="string")n.issues.push(ks(s,n.value,t._zod.def));else{const r=s;r.fatal&&(r.continue=!1),r.code??(r.code="custom"),r.input??(r.input=n.value),r.inst??(r.inst=t),r.continue??(r.continue=!t._zod.def.abort),n.issues.push(ks(r))}},e(n.value,n)));return t}function Vg(e,t){const n=new Le({check:"custom",...P(t)});return n._zod.check=e,n}function Bl(e){let t=(e==null?void 0:e.target)??"draft-2020-12";return t==="draft-4"&&(t="draft-04"),t==="draft-7"&&(t="draft-07"),{processors:e.processors??{},metadataRegistry:(e==null?void 0:e.metadata)??hs,target:t,unrepresentable:(e==null?void 0:e.unrepresentable)??"throw",override:(e==null?void 0:e.override)??(()=>{}),io:(e==null?void 0:e.io)??"output",counter:0,seen:new Map,cycles:(e==null?void 0:e.cycles)??"ref",reused:(e==null?void 0:e.reused)??"inline",external:(e==null?void 0:e.external)??void 0}}function pe(e,t,n={path:[],schemaPath:[]}){var h,f;var s;const r=e._zod.def,i=t.seen.get(e);if(i)return i.count++,n.schemaPath.includes(e)&&(i.cycle=n.path),i.schema;const o={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,o);const a=(f=(h=e._zod).toJSONSchema)==null?void 0:f.call(h);if(a)o.schema=a;else{const w={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,o.schema,w);else{const E=o.schema,x=t.processors[r.type];if(!x)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${r.type}`);x(e,t,E,w)}const v=e._zod.parent;v&&(o.ref||(o.ref=v),pe(v,t,w),t.seen.get(v).isParent=!0)}const c=t.metadataRegistry.get(e);return c&&Object.assign(o.schema,c),t.io==="input"&&Ce(e)&&(delete o.schema.examples,delete o.schema.default),t.io==="input"&&o.schema._prefault&&((s=o.schema).default??(s.default=o.schema._prefault)),delete o.schema._prefault,t.seen.get(e).schema}function Vl(e,t){var o,a,c,l;const n=e.seen.get(t);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");const s=new Map;for(const h of e.seen.entries()){const f=(o=e.metadataRegistry.get(h[0]))==null?void 0:o.id;if(f){const w=s.get(f);if(w&&w!==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.`);s.set(f,h[0])}}const r=h=>{var x;const f=e.target==="draft-2020-12"?"$defs":"definitions";if(e.external){const z=(x=e.external.registry.get(h[0]))==null?void 0:x.id,K=e.external.uri??(ye=>ye);if(z)return{ref:K(z)};const Z=h[1].defId??h[1].schema.id??`schema${e.counter++}`;return h[1].defId=Z,{defId:Z,ref:`${K("__shared")}#/${f}/${Z}`}}if(h[1]===n)return{ref:"#"};const v=`#/${f}/`,E=h[1].schema.id??`__schema${e.counter++}`;return{defId:E,ref:v+E}},i=h=>{if(h[1].schema.$ref)return;const f=h[1],{ref:w,defId:v}=r(h);f.def={...f.schema},v&&(f.defId=v);const E=f.schema;for(const x in E)delete E[x];E.$ref=w};if(e.cycles==="throw")for(const h of e.seen.entries()){const f=h[1];if(f.cycle)throw new Error(`Cycle detected: #/${(a=f.cycle)==null?void 0:a.join("/")}/<root>
|
|
38
|
-
|
|
39
|
-
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(const h of e.seen.entries()){const f=h[1];if(t===h[0]){i(h);continue}if(e.external){const v=(c=e.external.registry.get(h[0]))==null?void 0:c.id;if(t!==h[0]&&v){i(h);continue}}if((l=e.metadataRegistry.get(h[0]))==null?void 0:l.id){i(h);continue}if(f.cycle){i(h);continue}if(f.count>1&&e.reused==="ref"){i(h);continue}}}function Gl(e,t){var o,a,c;const n=e.seen.get(t);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");const s=l=>{const h=e.seen.get(l);if(h.ref===null)return;const f=h.def??h.schema,w={...f},v=h.ref;if(h.ref=null,v){s(v);const x=e.seen.get(v),z=x.schema;if(z.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0")?(f.allOf=f.allOf??[],f.allOf.push(z)):Object.assign(f,z),Object.assign(f,w),l._zod.parent===v)for(const Z in f)Z==="$ref"||Z==="allOf"||Z in w||delete f[Z];if(z.$ref&&x.def)for(const Z in f)Z==="$ref"||Z==="allOf"||Z in x.def&&JSON.stringify(f[Z])===JSON.stringify(x.def[Z])&&delete f[Z]}const E=l._zod.parent;if(E&&E!==v){s(E);const x=e.seen.get(E);if(x!=null&&x.schema.$ref&&(f.$ref=x.schema.$ref,x.def))for(const z in f)z==="$ref"||z==="allOf"||z in x.def&&JSON.stringify(f[z])===JSON.stringify(x.def[z])&&delete f[z]}e.override({zodSchema:l,jsonSchema:f,path:h.path??[]})};for(const l of[...e.seen.entries()].reverse())s(l[0]);const r={};if(e.target==="draft-2020-12"?r.$schema="https://json-schema.org/draft/2020-12/schema":e.target==="draft-07"?r.$schema="http://json-schema.org/draft-07/schema#":e.target==="draft-04"?r.$schema="http://json-schema.org/draft-04/schema#":e.target,(o=e.external)!=null&&o.uri){const l=(a=e.external.registry.get(t))==null?void 0:a.id;if(!l)throw new Error("Schema is missing an `id` property");r.$id=e.external.uri(l)}Object.assign(r,n.def??n.schema);const i=((c=e.external)==null?void 0:c.defs)??{};for(const l of e.seen.entries()){const h=l[1];h.def&&h.defId&&(i[h.defId]=h.def)}e.external||Object.keys(i).length>0&&(e.target==="draft-2020-12"?r.$defs=i:r.definitions=i);try{const l=JSON.parse(JSON.stringify(r));return Object.defineProperty(l,"~standard",{value:{...t["~standard"],jsonSchema:{input:Mr(t,"input",e.processors),output:Mr(t,"output",e.processors)}},enumerable:!1,writable:!1}),l}catch{throw new Error("Error converting schema to JSON.")}}function Ce(e,t){const n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);const s=e._zod.def;if(s.type==="transform")return!0;if(s.type==="array")return Ce(s.element,n);if(s.type==="set")return Ce(s.valueType,n);if(s.type==="lazy")return Ce(s.getter(),n);if(s.type==="promise"||s.type==="optional"||s.type==="nonoptional"||s.type==="nullable"||s.type==="readonly"||s.type==="default"||s.type==="prefault")return Ce(s.innerType,n);if(s.type==="intersection")return Ce(s.left,n)||Ce(s.right,n);if(s.type==="record"||s.type==="map")return Ce(s.keyType,n)||Ce(s.valueType,n);if(s.type==="pipe")return Ce(s.in,n)||Ce(s.out,n);if(s.type==="object"){for(const r in s.shape)if(Ce(s.shape[r],n))return!0;return!1}if(s.type==="union"){for(const r of s.options)if(Ce(r,n))return!0;return!1}if(s.type==="tuple"){for(const r of s.items)if(Ce(r,n))return!0;return!!(s.rest&&Ce(s.rest,n))}return!1}const Gg=(e,t={})=>n=>{const s=Bl({...n,processors:t});return pe(e,s),Vl(s,e),Gl(s,e)},Mr=(e,t,n={})=>s=>{const{libraryOptions:r,target:i}=s??{},o=Bl({...r??{},target:i,io:t,processors:n});return pe(e,o),Vl(o,e),Gl(o,e)},qg={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},Kg=(e,t,n,s)=>{const r=n;r.type="string";const{minimum:i,maximum:o,format:a,patterns:c,contentEncoding:l}=e._zod.bag;if(typeof i=="number"&&(r.minLength=i),typeof o=="number"&&(r.maxLength=o),a&&(r.format=qg[a]??a,r.format===""&&delete r.format,a==="time"&&delete r.format),l&&(r.contentEncoding=l),c&&c.size>0){const h=[...c];h.length===1?r.pattern=h[0].source:h.length>1&&(r.allOf=[...h.map(f=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:f.source}))])}},Yg=(e,t,n,s)=>{const r=n,{minimum:i,maximum:o,format:a,multipleOf:c,exclusiveMaximum:l,exclusiveMinimum:h}=e._zod.bag;typeof a=="string"&&a.includes("int")?r.type="integer":r.type="number",typeof h=="number"&&(t.target==="draft-04"||t.target==="openapi-3.0"?(r.minimum=h,r.exclusiveMinimum=!0):r.exclusiveMinimum=h),typeof i=="number"&&(r.minimum=i,typeof h=="number"&&t.target!=="draft-04"&&(h>=i?delete r.minimum:delete r.exclusiveMinimum)),typeof l=="number"&&(t.target==="draft-04"||t.target==="openapi-3.0"?(r.maximum=l,r.exclusiveMaximum=!0):r.exclusiveMaximum=l),typeof o=="number"&&(r.maximum=o,typeof l=="number"&&t.target!=="draft-04"&&(l<=o?delete r.maximum:delete r.exclusiveMaximum)),typeof c=="number"&&(r.multipleOf=c)},Xg=(e,t,n,s)=>{n.type="boolean"},Jg=(e,t,n,s)=>{n.not={}},Qg=(e,t,n,s)=>{},em=(e,t,n,s)=>{const r=e._zod.def,i=xl(r.entries);i.every(o=>typeof o=="number")&&(n.type="number"),i.every(o=>typeof o=="string")&&(n.type="string"),n.enum=i},tm=(e,t,n,s)=>{const r=e._zod.def,i=[];for(const o of r.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");i.push(Number(o))}else i.push(o);if(i.length!==0)if(i.length===1){const o=i[0];n.type=o===null?"null":typeof o,t.target==="draft-04"||t.target==="openapi-3.0"?n.enum=[o]:n.const=o}else i.every(o=>typeof o=="number")&&(n.type="number"),i.every(o=>typeof o=="string")&&(n.type="string"),i.every(o=>typeof o=="boolean")&&(n.type="boolean"),i.every(o=>o===null)&&(n.type="null"),n.enum=i},nm=(e,t,n,s)=>{if(t.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema")},sm=(e,t,n,s)=>{if(t.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema")},rm=(e,t,n,s)=>{const r=n,i=e._zod.def,{minimum:o,maximum:a}=e._zod.bag;typeof o=="number"&&(r.minItems=o),typeof a=="number"&&(r.maxItems=a),r.type="array",r.items=pe(i.element,t,{...s,path:[...s.path,"items"]})},im=(e,t,n,s)=>{var l;const r=n,i=e._zod.def;r.type="object",r.properties={};const o=i.shape;for(const h in o)r.properties[h]=pe(o[h],t,{...s,path:[...s.path,"properties",h]});const a=new Set(Object.keys(o)),c=new Set([...a].filter(h=>{const f=i.shape[h]._zod;return t.io==="input"?f.optin===void 0:f.optout===void 0}));c.size>0&&(r.required=Array.from(c)),((l=i.catchall)==null?void 0:l._zod.def.type)==="never"?r.additionalProperties=!1:i.catchall?i.catchall&&(r.additionalProperties=pe(i.catchall,t,{...s,path:[...s.path,"additionalProperties"]})):t.io==="output"&&(r.additionalProperties=!1)},om=(e,t,n,s)=>{const r=e._zod.def,i=r.inclusive===!1,o=r.options.map((a,c)=>pe(a,t,{...s,path:[...s.path,i?"oneOf":"anyOf",c]}));i?n.oneOf=o:n.anyOf=o},am=(e,t,n,s)=>{const r=e._zod.def,i=pe(r.left,t,{...s,path:[...s.path,"allOf",0]}),o=pe(r.right,t,{...s,path:[...s.path,"allOf",1]}),a=l=>"allOf"in l&&Object.keys(l).length===1,c=[...a(i)?i.allOf:[i],...a(o)?o.allOf:[o]];n.allOf=c},cm=(e,t,n,s)=>{const r=n,i=e._zod.def;r.type="object";const o=i.keyType,a=o._zod.bag,c=a==null?void 0:a.patterns;if(i.mode==="loose"&&c&&c.size>0){const h=pe(i.valueType,t,{...s,path:[...s.path,"patternProperties","*"]});r.patternProperties={};for(const f of c)r.patternProperties[f.source]=h}else(t.target==="draft-07"||t.target==="draft-2020-12")&&(r.propertyNames=pe(i.keyType,t,{...s,path:[...s.path,"propertyNames"]})),r.additionalProperties=pe(i.valueType,t,{...s,path:[...s.path,"additionalProperties"]});const l=o._zod.values;if(l){const h=[...l].filter(f=>typeof f=="string"||typeof f=="number");h.length>0&&(r.required=h)}},lm=(e,t,n,s)=>{const r=e._zod.def,i=pe(r.innerType,t,s),o=t.seen.get(e);t.target==="openapi-3.0"?(o.ref=r.innerType,n.nullable=!0):n.anyOf=[i,{type:"null"}]},um=(e,t,n,s)=>{const r=e._zod.def;pe(r.innerType,t,s);const i=t.seen.get(e);i.ref=r.innerType},hm=(e,t,n,s)=>{const r=e._zod.def;pe(r.innerType,t,s);const i=t.seen.get(e);i.ref=r.innerType,n.default=JSON.parse(JSON.stringify(r.defaultValue))},dm=(e,t,n,s)=>{const r=e._zod.def;pe(r.innerType,t,s);const i=t.seen.get(e);i.ref=r.innerType,t.io==="input"&&(n._prefault=JSON.parse(JSON.stringify(r.defaultValue)))},pm=(e,t,n,s)=>{const r=e._zod.def;pe(r.innerType,t,s);const i=t.seen.get(e);i.ref=r.innerType;let o;try{o=r.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}n.default=o},fm=(e,t,n,s)=>{const r=e._zod.def,i=t.io==="input"?r.in._zod.def.type==="transform"?r.out:r.in:r.out;pe(i,t,s);const o=t.seen.get(e);o.ref=i},gm=(e,t,n,s)=>{const r=e._zod.def;pe(r.innerType,t,s);const i=t.seen.get(e);i.ref=r.innerType,n.readOnly=!0},ql=(e,t,n,s)=>{const r=e._zod.def;pe(r.innerType,t,s);const i=t.seen.get(e);i.ref=r.innerType},mm=b("ZodISODateTime",(e,t)=>{vf.init(e,t),ae.init(e,t)});function vm(e){return Sg(mm,e)}const _m=b("ZodISODate",(e,t)=>{_f.init(e,t),ae.init(e,t)});function ym(e){return xg(_m,e)}const km=b("ZodISOTime",(e,t)=>{yf.init(e,t),ae.init(e,t)});function wm(e){return Eg(km,e)}const bm=b("ZodISODuration",(e,t)=>{kf.init(e,t),ae.init(e,t)});function Sm(e){return Ag(bm,e)}const Kl=(e,t)=>{Il.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:n=>lp(e,n)},flatten:{value:n=>cp(e,n)},addIssue:{value:n=>{e.issues.push(n),e.message=JSON.stringify(e.issues,Xi,2)}},addIssues:{value:n=>{e.issues.push(...n),e.message=JSON.stringify(e.issues,Xi,2)}},isEmpty:{get(){return e.issues.length===0}}})},vc=b("ZodError",Kl),He=b("ZodError",Kl,{Parent:Error}),xm=Vo(He),Em=Go(He),Am=ti(He),Tm=ni(He),Im=dp(He),Cm=pp(He),zm=fp(He),$m=gp(He),Rm=mp(He),Pm=vp(He),Dm=_p(He),Lm=yp(He),oe=b("ZodType",(e,t)=>(ie.init(e,t),Object.assign(e["~standard"],{jsonSchema:{input:Mr(e,"input"),output:Mr(e,"output")}}),e.toJSONSchema=Gg(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.check=(...n)=>e.clone(Pt(t,{checks:[...t.checks??[],...n.map(s=>typeof s=="function"?{_zod:{check:s,def:{check:"custom"},onattach:[]}}:s)]}),{parent:!0}),e.with=e.check,e.clone=(n,s)=>Dt(e,n,s),e.brand=()=>e,e.register=(n,s)=>(n.add(e,s),e),e.parse=(n,s)=>xm(e,n,s,{callee:e.parse}),e.safeParse=(n,s)=>Am(e,n,s),e.parseAsync=async(n,s)=>Em(e,n,s,{callee:e.parseAsync}),e.safeParseAsync=async(n,s)=>Tm(e,n,s),e.spa=e.safeParseAsync,e.encode=(n,s)=>Im(e,n,s),e.decode=(n,s)=>Cm(e,n,s),e.encodeAsync=async(n,s)=>zm(e,n,s),e.decodeAsync=async(n,s)=>$m(e,n,s),e.safeEncode=(n,s)=>Rm(e,n,s),e.safeDecode=(n,s)=>Pm(e,n,s),e.safeEncodeAsync=async(n,s)=>Dm(e,n,s),e.safeDecodeAsync=async(n,s)=>Lm(e,n,s),e.refine=(n,s)=>e.check(Tv(n,s)),e.superRefine=n=>e.check(Iv(n)),e.overwrite=n=>e.check(Bn(n)),e.optional=()=>kc(e),e.exactOptional=()=>fv(e),e.nullable=()=>wc(e),e.nullish=()=>kc(wc(e)),e.nonoptional=n=>kv(e,n),e.array=()=>R(e),e.or=n=>W([e,n]),e.and=n=>ri(e,n),e.transform=n=>bc(e,dv(n)),e.default=n=>vv(e,n),e.prefault=n=>yv(e,n),e.catch=n=>bv(e,n),e.pipe=n=>bc(e,n),e.readonly=()=>Ev(e),e.describe=n=>{const s=e.clone();return hs.add(s,{description:n}),s},Object.defineProperty(e,"description",{get(){var n;return(n=hs.get(e))==null?void 0:n.description},configurable:!0}),e.meta=(...n)=>{if(n.length===0)return hs.get(e);const s=e.clone();return hs.add(s,n[0]),s},e.isOptional=()=>e.safeParse(void 0).success,e.isNullable=()=>e.safeParse(null).success,e.apply=n=>n(e),e)),Yl=b("_ZodString",(e,t)=>{qo.init(e,t),oe.init(e,t),e._zod.processJSONSchema=(s,r,i)=>Kg(e,s,r);const n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,e.regex=(...s)=>e.check(Rg(...s)),e.includes=(...s)=>e.check(Lg(...s)),e.startsWith=(...s)=>e.check(Mg(...s)),e.endsWith=(...s)=>e.check(Og(...s)),e.min=(...s)=>e.check(Lr(...s)),e.max=(...s)=>e.check(jl(...s)),e.length=(...s)=>e.check(Hl(...s)),e.nonempty=(...s)=>e.check(Lr(1,...s)),e.lowercase=s=>e.check(Pg(s)),e.uppercase=s=>e.check(Dg(s)),e.trim=()=>e.check(Wg()),e.normalize=(...s)=>e.check(Ng(...s)),e.toLowerCase=()=>e.check(Fg()),e.toUpperCase=()=>e.check(Ug()),e.slugify=()=>e.check(Zg())}),Mm=b("ZodString",(e,t)=>{qo.init(e,t),Yl.init(e,t),e.email=n=>e.check(ng(Om,n)),e.url=n=>e.check(ag(Nm,n)),e.jwt=n=>e.check(bg(Qm,n)),e.emoji=n=>e.check(cg(Wm,n)),e.guid=n=>e.check(pc(_c,n)),e.uuid=n=>e.check(sg(hr,n)),e.uuidv4=n=>e.check(rg(hr,n)),e.uuidv6=n=>e.check(ig(hr,n)),e.uuidv7=n=>e.check(og(hr,n)),e.nanoid=n=>e.check(lg(Fm,n)),e.guid=n=>e.check(pc(_c,n)),e.cuid=n=>e.check(ug(Um,n)),e.cuid2=n=>e.check(hg(Zm,n)),e.ulid=n=>e.check(dg(jm,n)),e.base64=n=>e.check(yg(Ym,n)),e.base64url=n=>e.check(kg(Xm,n)),e.xid=n=>e.check(pg(Hm,n)),e.ksuid=n=>e.check(fg(Bm,n)),e.ipv4=n=>e.check(gg(Vm,n)),e.ipv6=n=>e.check(mg(Gm,n)),e.cidrv4=n=>e.check(vg(qm,n)),e.cidrv6=n=>e.check(_g(Km,n)),e.e164=n=>e.check(wg(Jm,n)),e.datetime=n=>e.check(vm(n)),e.date=n=>e.check(ym(n)),e.time=n=>e.check(wm(n)),e.duration=n=>e.check(Sm(n))});function u(e){return tg(Mm,e)}const ae=b("ZodStringFormat",(e,t)=>{se.init(e,t),Yl.init(e,t)}),Om=b("ZodEmail",(e,t)=>{cf.init(e,t),ae.init(e,t)}),_c=b("ZodGUID",(e,t)=>{of.init(e,t),ae.init(e,t)}),hr=b("ZodUUID",(e,t)=>{af.init(e,t),ae.init(e,t)}),Nm=b("ZodURL",(e,t)=>{lf.init(e,t),ae.init(e,t)}),Wm=b("ZodEmoji",(e,t)=>{uf.init(e,t),ae.init(e,t)}),Fm=b("ZodNanoID",(e,t)=>{hf.init(e,t),ae.init(e,t)}),Um=b("ZodCUID",(e,t)=>{df.init(e,t),ae.init(e,t)}),Zm=b("ZodCUID2",(e,t)=>{pf.init(e,t),ae.init(e,t)}),jm=b("ZodULID",(e,t)=>{ff.init(e,t),ae.init(e,t)}),Hm=b("ZodXID",(e,t)=>{gf.init(e,t),ae.init(e,t)}),Bm=b("ZodKSUID",(e,t)=>{mf.init(e,t),ae.init(e,t)}),Vm=b("ZodIPv4",(e,t)=>{wf.init(e,t),ae.init(e,t)}),Gm=b("ZodIPv6",(e,t)=>{bf.init(e,t),ae.init(e,t)}),qm=b("ZodCIDRv4",(e,t)=>{Sf.init(e,t),ae.init(e,t)}),Km=b("ZodCIDRv6",(e,t)=>{xf.init(e,t),ae.init(e,t)}),Ym=b("ZodBase64",(e,t)=>{Ef.init(e,t),ae.init(e,t)}),Xm=b("ZodBase64URL",(e,t)=>{Tf.init(e,t),ae.init(e,t)}),Jm=b("ZodE164",(e,t)=>{If.init(e,t),ae.init(e,t)}),Qm=b("ZodJWT",(e,t)=>{zf.init(e,t),ae.init(e,t)}),Xl=b("ZodNumber",(e,t)=>{Nl.init(e,t),oe.init(e,t),e._zod.processJSONSchema=(s,r,i)=>Yg(e,s,r),e.gt=(s,r)=>e.check(gc(s,r)),e.gte=(s,r)=>e.check($i(s,r)),e.min=(s,r)=>e.check($i(s,r)),e.lt=(s,r)=>e.check(fc(s,r)),e.lte=(s,r)=>e.check(zi(s,r)),e.max=(s,r)=>e.check(zi(s,r)),e.int=s=>e.check(yc(s)),e.safe=s=>e.check(yc(s)),e.positive=s=>e.check(gc(0,s)),e.nonnegative=s=>e.check($i(0,s)),e.negative=s=>e.check(fc(0,s)),e.nonpositive=s=>e.check(zi(0,s)),e.multipleOf=(s,r)=>e.check(mc(s,r)),e.step=(s,r)=>e.check(mc(s,r)),e.finite=()=>e;const n=e._zod.bag;e.minValue=Math.max(n.minimum??Number.NEGATIVE_INFINITY,n.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,e.maxValue=Math.min(n.maximum??Number.POSITIVE_INFINITY,n.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,e.isInt=(n.format??"").includes("int")||Number.isSafeInteger(n.multipleOf??.5),e.isFinite=!0,e.format=n.format??null});function N(e){return Tg(Xl,e)}const ev=b("ZodNumberFormat",(e,t)=>{$f.init(e,t),Xl.init(e,t)});function yc(e){return Ig(ev,e)}const tv=b("ZodBoolean",(e,t)=>{Rf.init(e,t),oe.init(e,t),e._zod.processJSONSchema=(n,s,r)=>Xg(e,n,s)});function _e(e){return Cg(tv,e)}const nv=b("ZodUnknown",(e,t)=>{Pf.init(e,t),oe.init(e,t),e._zod.processJSONSchema=(n,s,r)=>Qg()});function _(){return zg(nv)}const sv=b("ZodNever",(e,t)=>{Df.init(e,t),oe.init(e,t),e._zod.processJSONSchema=(n,s,r)=>Jg(e,n,s)});function rv(e){return $g(sv,e)}const iv=b("ZodArray",(e,t)=>{Lf.init(e,t),oe.init(e,t),e._zod.processJSONSchema=(n,s,r)=>rm(e,n,s,r),e.element=t.element,e.min=(n,s)=>e.check(Lr(n,s)),e.nonempty=n=>e.check(Lr(1,n)),e.max=(n,s)=>e.check(jl(n,s)),e.length=(n,s)=>e.check(Hl(n,s)),e.unwrap=()=>e.element});function R(e,t){return jg(iv,e,t)}const Jl=b("ZodObject",(e,t)=>{Of.init(e,t),oe.init(e,t),e._zod.processJSONSchema=(n,s,r)=>im(e,n,s,r),q(e,"shape",()=>t.shape),e.keyof=()=>eu(Object.keys(e._zod.def.shape)),e.catchall=n=>e.clone({...e._zod.def,catchall:n}),e.passthrough=()=>e.clone({...e._zod.def,catchall:_()}),e.loose=()=>e.clone({...e._zod.def,catchall:_()}),e.strict=()=>e.clone({...e._zod.def,catchall:rv()}),e.strip=()=>e.clone({...e._zod.def,catchall:void 0}),e.extend=n=>sp(e,n),e.safeExtend=n=>rp(e,n),e.merge=n=>ip(e,n),e.pick=n=>tp(e,n),e.omit=n=>np(e,n),e.partial=(...n)=>op(tu,e,n[0]),e.required=(...n)=>ap(nu,e,n[0])});function Ko(e,t){const n={type:"object",shape:e??{},...P(t)};return new Jl(n)}function p(e,t){return new Jl({type:"object",shape:e,catchall:_(),...P(t)})}const Ql=b("ZodUnion",(e,t)=>{Ul.init(e,t),oe.init(e,t),e._zod.processJSONSchema=(n,s,r)=>om(e,n,s,r),e.options=t.options});function W(e,t){return new Ql({type:"union",options:e,...P(t)})}const ov=b("ZodDiscriminatedUnion",(e,t)=>{Ql.init(e,t),Nf.init(e,t)});function av(e,t,n){return new ov({type:"union",options:t,discriminator:e,...P(n)})}const cv=b("ZodIntersection",(e,t)=>{Wf.init(e,t),oe.init(e,t),e._zod.processJSONSchema=(n,s,r)=>am(e,n,s,r)});function ri(e,t){return new cv({type:"intersection",left:e,right:t})}const lv=b("ZodRecord",(e,t)=>{Ff.init(e,t),oe.init(e,t),e._zod.processJSONSchema=(n,s,r)=>cm(e,n,s,r),e.keyType=t.keyType,e.valueType=t.valueType});function k(e,t,n){return new lv({type:"record",keyType:e,valueType:t,...P(n)})}const Qi=b("ZodEnum",(e,t)=>{Uf.init(e,t),oe.init(e,t),e._zod.processJSONSchema=(s,r,i)=>em(e,s,r),e.enum=t.entries,e.options=Object.values(t.entries);const n=new Set(Object.keys(t.entries));e.extract=(s,r)=>{const i={};for(const o of s)if(n.has(o))i[o]=t.entries[o];else throw new Error(`Key ${o} not found in enum`);return new Qi({...t,checks:[],...P(r),entries:i})},e.exclude=(s,r)=>{const i={...t.entries};for(const o of s)if(n.has(o))delete i[o];else throw new Error(`Key ${o} not found in enum`);return new Qi({...t,checks:[],...P(r),entries:i})}});function eu(e,t){const n=Array.isArray(e)?Object.fromEntries(e.map(s=>[s,s])):e;return new Qi({type:"enum",entries:n,...P(t)})}const uv=b("ZodLiteral",(e,t)=>{Zf.init(e,t),oe.init(e,t),e._zod.processJSONSchema=(n,s,r)=>tm(e,n,s),e.values=new Set(t.values),Object.defineProperty(e,"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 S(e,t){return new uv({type:"literal",values:Array.isArray(e)?e:[e],...P(t)})}const hv=b("ZodTransform",(e,t)=>{jf.init(e,t),oe.init(e,t),e._zod.processJSONSchema=(n,s,r)=>sm(e,n),e._zod.parse=(n,s)=>{if(s.direction==="backward")throw new bl(e.constructor.name);n.addIssue=i=>{if(typeof i=="string")n.issues.push(ks(i,n.value,t));else{const o=i;o.fatal&&(o.continue=!1),o.code??(o.code="custom"),o.input??(o.input=n.value),o.inst??(o.inst=e),n.issues.push(ks(o))}};const r=t.transform(n.value,n);return r instanceof Promise?r.then(i=>(n.value=i,n)):(n.value=r,n)}});function dv(e){return new hv({type:"transform",transform:e})}const tu=b("ZodOptional",(e,t)=>{Zl.init(e,t),oe.init(e,t),e._zod.processJSONSchema=(n,s,r)=>ql(e,n,s,r),e.unwrap=()=>e._zod.def.innerType});function kc(e){return new tu({type:"optional",innerType:e})}const pv=b("ZodExactOptional",(e,t)=>{Hf.init(e,t),oe.init(e,t),e._zod.processJSONSchema=(n,s,r)=>ql(e,n,s,r),e.unwrap=()=>e._zod.def.innerType});function fv(e){return new pv({type:"optional",innerType:e})}const gv=b("ZodNullable",(e,t)=>{Bf.init(e,t),oe.init(e,t),e._zod.processJSONSchema=(n,s,r)=>lm(e,n,s,r),e.unwrap=()=>e._zod.def.innerType});function wc(e){return new gv({type:"nullable",innerType:e})}const mv=b("ZodDefault",(e,t)=>{Vf.init(e,t),oe.init(e,t),e._zod.processJSONSchema=(n,s,r)=>hm(e,n,s,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function vv(e,t){return new mv({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():Al(t)}})}const _v=b("ZodPrefault",(e,t)=>{Gf.init(e,t),oe.init(e,t),e._zod.processJSONSchema=(n,s,r)=>dm(e,n,s,r),e.unwrap=()=>e._zod.def.innerType});function yv(e,t){return new _v({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():Al(t)}})}const nu=b("ZodNonOptional",(e,t)=>{qf.init(e,t),oe.init(e,t),e._zod.processJSONSchema=(n,s,r)=>um(e,n,s,r),e.unwrap=()=>e._zod.def.innerType});function kv(e,t){return new nu({type:"nonoptional",innerType:e,...P(t)})}const wv=b("ZodCatch",(e,t)=>{Kf.init(e,t),oe.init(e,t),e._zod.processJSONSchema=(n,s,r)=>pm(e,n,s,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function bv(e,t){return new wv({type:"catch",innerType:e,catchValue:typeof t=="function"?t:()=>t})}const Sv=b("ZodPipe",(e,t)=>{Yf.init(e,t),oe.init(e,t),e._zod.processJSONSchema=(n,s,r)=>fm(e,n,s,r),e.in=t.in,e.out=t.out});function bc(e,t){return new Sv({type:"pipe",in:e,out:t})}const xv=b("ZodReadonly",(e,t)=>{Xf.init(e,t),oe.init(e,t),e._zod.processJSONSchema=(n,s,r)=>gm(e,n,s,r),e.unwrap=()=>e._zod.def.innerType});function Ev(e){return new xv({type:"readonly",innerType:e})}const Av=b("ZodCustom",(e,t)=>{Jf.init(e,t),oe.init(e,t),e._zod.processJSONSchema=(n,s,r)=>nm(e,n)});function Tv(e,t={}){return Hg(Av,e,t)}function Iv(e){return Bg(e)}const su=Ko({kind:S("file"),path:u()}),Cv=Ko({id:u(),type:S("markdown"),title:u(),token:u(),source:su}),zv=Ko({id:u(),type:S("html"),title:u(),token:u(),source:su});av("type",[Cv,zv]);const ru="markdown";function $v(e){const t=e.type??ru;return{id:e.id??en(),type:t,title:e.title,token:e.token??en(),source:e.source}}const st=4,We=6,iu=2,eo=2,Rv=st,Pv=We,Yo="auto",zt="auto",Zt=120,Sc=75,ce=16,Tt=Zt*st+ce*(st-1),In=Zt*We+ce*(We-1),Dv=200,Lv=4,dr=150,Mv=10,xc=2;function to(e,t={}){return{id:t.id??en(),type:"card",artifactID:e,width:t.width??Yo,height:t.height??zt}}function no(e,t){return e.some(n=>ou(n,t))}function ou(e,t){switch(e.type){case"card":return e.artifactID===t;case"row":return e.children.some(n=>n.artifactID===t);case"stack":return e.children.some(n=>ou(n,t))}}function Ri(e){return e.layout.flatMap(au)}function au(e){switch(e.type){case"card":return[e.artifactID];case"row":return e.children.map(t=>t.artifactID);case"stack":return e.children.flatMap(au)}}const Ov=4,Nv=/^[0-9A-HJKMNP-TV-Z]{26}$/;function cu(e){return hu(e)}function lu(e,t){return hu(e.flatMap(n=>pu(n,t)))}function uu(e){const t=[],n=new Set;for(const s of e){if(s.type==="row"){t.push(`Top-level rows are invalid: ${s.id}`);continue}fu(s,"strip",t,n)}return{valid:t.length===0,errors:t}}function zn(e){const t=cu(e),n=uu(t);if(!n.valid)throw new Error(`Invalid layout: ${n.errors.join("; ")}`);return{totalNodes:t.length,nodes:t.filter(s=>s.type!=="row").map(Zv)}}function hu(e){const t=[];for(const n of e){const s=du(n);for(const r of s){if(r.type==="row"){t.push(...r.children.map(_t));continue}t.push(r)}}return t}function du(e){switch(e.type){case"card":return[_t(e)];case"row":{const t=e.children.map(_t);return t.length===0?[]:t.length===1?[t[0]]:[{...e,children:t}]}case"stack":{const t=[];for(const n of e.children){const s=du(n);for(const r of s){if(r.type==="stack"){t.push(...r.children.map(so));continue}if(r.type==="row"){t.push({...r,children:r.children.map(_t)});continue}t.push(_t(r))}}return t.length===0?[]:t.length===1?[so(t[0])]:[{...e,children:t}]}}}function pu(e,t){switch(e.type){case"card":return e.artifactID===t?[]:[_t(e)];case"row":{const n=e.children.filter(s=>s.artifactID!==t).map(_t);return n.length===0?[]:n.length===1?[n[0]]:[{...e,children:n}]}case"stack":{const n=e.children.flatMap(s=>pu(s,t).filter(i=>i.type!=="stack"));return n.length===0?[]:n.length===1?[so(n[0])]:[{...e,children:n}]}}}function fu(e,t,n,s){switch(e.type){case"card":gu(e,t,n,s);return;case"row":Wv(e,t,n,s);return;case"stack":Fv(e,t,n,s);return}}function gu(e,t,n,s){Xo(e.id,n),typeof e.artifactID!="string"||e.artifactID.length===0?n.push(`Card ${e.id} is missing artifactID`):s.has(e.artifactID)?n.push(`Duplicate artifactID in layout: ${e.artifactID}`):s.add(e.artifactID),Uv(e.width)||n.push(`Card ${e.id} width must be an integer in the range 2-4`),mu(e.height)||n.push(`Card ${e.id} height must be an integer in the range 2-6 or "auto"`);const r=jt(e.width);t==="row"&&r<iu&&n.push(`Row child ${e.id} must be at least 2 columns wide`)}function Wv(e,t,n,s){if(Xo(e.id,n),t!=="stack"&&n.push(`Row ${e.id} may only appear inside a stack`),mu(e.height,Ov)||n.push(`Row ${e.id} height must be an integer in the range 2-4 or "auto"`),!Array.isArray(e.children)||e.children.length===0){n.push(`Row ${e.id} must contain card nodes`);return}let r=0;for(const i of e.children){if(i.type!=="card"){n.push(`Row ${e.id} must contain only card nodes`);continue}gu(i,"row",n,s),r+=jt(i.width)}r!==st&&n.push(`Row ${e.id} children must sum to 4 columns`)}function Fv(e,t,n,s){if(Xo(e.id,n),t!=="strip"&&n.push(`Invalid nested stack at ${e.id}; stack children cannot contain another nested stack`),!Array.isArray(e.children)||e.children.length===0){n.push(`Stack ${e.id} must contain at least one child`);return}let r=0,i=0;for(const a of e.children){if(a.type==="stack"){n.push(`Stack ${e.id} cannot contain another nested stack`);continue}if(fu(a,"stack",n,s),a.height===zt){i+=1;continue}r+=a.height}if(r>We&&n.push(`Stack ${e.id} exceeds the 6-row budget`),i===0)return;const o=We-r;if(o<i*eo||o%i!==0){n.push(`Stack ${e.id} has auto-height children that cannot resolve to whole height >= 2`);return}o/i<eo&&n.push(`Stack ${e.id} has auto-height children below the minimum row size`)}function Xo(e,t){(typeof e!="string"||!Nv.test(e))&&t.push(`Node id must be a ULID: ${String(e)}`)}function Uv(e){return e===Yo||Number.isInteger(e)&&e>=iu&&e<=Rv}function mu(e,t=Pv){return e===zt||Number.isInteger(e)&&e>=eo&&e<=t}function jt(e){return e===Yo?st:e}function Zv(e){if(e.type==="card")return{id:e.id,type:"card",width:jt(e.width),cards:[{id:e.id,artifactID:e.artifactID,col:1,row:1,width:jt(e.width),height:vu(e.height,We)}]};const t=jv(e.children),n=[];let s=1;for(let r=0;r<e.children.length;r+=1){const i=e.children[r],o=t[r];if(i.type==="card")n.push({id:i.id,artifactID:i.artifactID,col:1,row:s,width:jt(i.width),height:o});else{let a=1;for(const c of i.children)n.push({id:c.id,artifactID:c.artifactID,col:a,row:s,width:jt(c.width),height:o}),a+=jt(c.width)}s+=o}return{id:e.id,type:"stack",width:n.reduce((r,i)=>Math.max(r,i.col+i.width-1),1),cards:n}}function jv(e){let t=0,n=0;for(const r of e)r.height===zt?n+=1:t+=r.height;const s=n>0?(We-t)/n:0;return e.map(r=>vu(r.height,s))}function vu(e,t){return e===zt?t:e}function _t(e){return{...e}}function so(e){return e.type==="card"?_t(e):{...e,children:e.children.map(_t)}}const Pi="create-artifact",Di="remove-artifact",pr="update-layout";class Hv extends ln{constructor(n){var r;super();m(this,"artifacts",new Map);m(this,"activeWorkspaceID",null);m(this,"scrollPosition",0);m(this,"artifactReloadVersions",new Map);m(this,"activeWorkspaceData",null);m(this,"clientStore");m(this,"serverManager");m(this,"pendingMutations",new Map);m(this,"pendingWorkspaceCreates",new Map);m(this,"pendingWorkspaceDeletes",new Map);this.clientStore=n.clientStore,this.serverManager=n.serverManager;const s=this.clientStore.get();this.activeWorkspaceID=(s==null?void 0:s.lastWorkspaceID)??null,this.activeWorkspaceID&&(this.scrollPosition=((r=s==null?void 0:s.workspaces[this.activeWorkspaceID])==null?void 0:r.scrollPosition)??0)}get workspaces(){return[...this.serverManager.servers.values()].flatMap(n=>[...n.workspaces.values()])}get activeWorkspace(){return this.activeWorkspaceData}get activeWorkspaceServerURL(){var n;return this.activeWorkspaceID?((n=this.findWorkspace(this.activeWorkspaceID))==null?void 0:n.serverURL)??null:null}get activeArtifacts(){return(this.activeWorkspaceData?Ri(this.activeWorkspaceData):[]).map(n=>this.artifacts.get(n)).filter(n=>n!==void 0)}getArtifactURL(n){const s=this.activeWorkspaceServerURL;if(!s)return null;const r=this.serverManager.servers.get(s),i=this.artifacts.get(n);if(!(r!=null&&r.getArtifactURL)||!i)return null;const o=r.getArtifactURL(i);if(i.type!=="html")return o;const a=this.artifactReloadVersions.get(n)??0,c=new URL(o);return c.searchParams.set("rev",String(a)),c.toString()}setActiveWorkspace(n){this.selectWorkspace(n)}setScrollPosition(n){const s=Math.max(0,n);this.scrollPosition!==s&&(this.scrollPosition=s,this.persistWorkspaceViewState(),this.dispatchEvent(new B("change")))}createArtifact(n){var c;const s=this.activeWorkspaceData;if(!s)return;const r=this.snapshotState(),i=$v({id:en(),type:n.type??ru,title:n.title,source:{kind:"file",path:n.path}});no(s.layout,i.id)||(s.layout=[...s.layout,to(i.id)]),this.artifacts.set(i.id,i),this.scrollPosition=Bv(s.layout),this.persistWorkspaceViewState(),this.dispatchEvent(new B("change"));const o=((c=this.findWorkspace(s.id))==null?void 0:c.server)??null,a=this.getMutationKey(Pi,i.id);this.pendingMutations.set(a,r),this.sendServerMessage(o,{type:"create-artifact",id:i.id,path:n.path,artifactType:i.type,workspaceID:s.id})||(this.pendingMutations.delete(a),this.restoreState(r),this.dispatchEvent(new B("change")))}removeArtifact(n){var a;const s=this.activeWorkspaceData;if(!s||!this.artifacts.has(n))return;const r=this.snapshotState();this.removeArtifactLocally(n),this.dispatchEvent(new B("change"));const i=((a=this.findWorkspace(s.id))==null?void 0:a.server)??null,o=this.getMutationKey(Di,n);this.pendingMutations.set(o,r),this.sendServerMessage(i,{type:"remove-artifact",artifactID:n,workspaceID:s.id})||(this.pendingMutations.delete(o),this.restoreState(r),this.dispatchEvent(new B("change")))}handleServerEvent(n,s){var r;switch(s.type){case"workspace-list":this.syncActiveWorkspaceState(n,!0);break;case"workspace-updated":this.syncActiveWorkspaceState(n,!1),Array.isArray(s.fields.layout)&&this.pendingMutations.delete(this.getMutationKey(pr,s.workspaceID));break;case"workspace-removed":{this.syncActiveWorkspaceState(n,!1);const i=this.pendingWorkspaceDeletes.get(s.workspaceID);i&&(this.pendingWorkspaceDeletes.delete(s.workspaceID),i.resolve());break}case"workspace-created":if(this.pendingWorkspaceCreates.has(s.workspace.id)){const i=this.pendingWorkspaceCreates.get(s.workspace.id);this.pendingWorkspaceCreates.delete(s.workspace.id),this.selectWorkspace(s.workspace.id),i==null||i.resolve();return}this.syncActiveWorkspaceState(n,!1);break;case"workspace":this.applyWorkspaceSnapshot(s.workspace,s.artifacts);break;case"artifact-created":this.pendingMutations.delete(this.getMutationKey(Pi,s.artifact.id)),this.applyArtifactCreated(s);break;case"artifact-updated":this.applyArtifactUpdated(s);break;case"artifact-removed":if(this.pendingMutations.delete(this.getMutationKey(Di,s.artifactID)),((r=this.activeWorkspaceData)==null?void 0:r.id)!==s.workspaceID)return;this.removeArtifactLocally(s.artifactID)&&this.dispatchEvent(new B("change"));break;case"error":this.handleServerError(s);break}}createWorkspace(n,s){const r=this.serverManager.servers.get(n)??null,i=en(),o=Ec();return this.pendingWorkspaceCreates.set(i,o),this.sendServerMessage(r,{type:"create-workspace",id:i,name:s})||(this.pendingWorkspaceCreates.delete(i),o.reject(new Error(`Server unavailable: ${n}`))),o.promise}deleteWorkspace(){var o;const n=this.activeWorkspaceData;if(!n)return Promise.reject(new Error("No active workspace"));const s=this.pendingWorkspaceDeletes.get(n.id);if(s)return s.promise;const r=((o=this.findWorkspace(n.id))==null?void 0:o.server)??null,i=Ec();return this.pendingWorkspaceDeletes.set(n.id,i),this.sendServerMessage(r,{type:"delete-workspace",workspaceID:n.id})||(this.pendingWorkspaceDeletes.delete(n.id),i.reject(new Error(`Server unavailable: ${n.id}`))),i.promise}renameWorkspace(n){var i;const s=this.activeWorkspaceData;if(!s)return;const r=((i=this.findWorkspace(s.id))==null?void 0:i.server)??null;s.name=n,this.dispatchEvent(new B("change")),this.sendServerMessage(r,{type:"update-workspace",workspaceID:s.id,fields:{name:n}})}setLayout(n){var l;const s=this.activeWorkspaceData;if(!s)return;const r=cu(n);if(!uu(r).valid)return;const o=this.snapshotState();s.layout=r,this.dispatchEvent(new B("change"));const a=((l=this.findWorkspace(s.id))==null?void 0:l.server)??null,c=this.getMutationKey(pr,s.id);this.pendingMutations.set(c,o),this.sendServerMessage(a,{type:"update-workspace",workspaceID:s.id,fields:{layout:r.map(h=>structuredClone(h))}})||(this.pendingMutations.delete(c),this.restoreState(o),this.dispatchEvent(new B("change")))}syncActiveWorkspaceState(n,s){const r=this.activeWorkspaceID?this.findWorkspace(this.activeWorkspaceID):null;if(!r){const i=this.pickNextWorkspace();if(!i){const o=this.activeWorkspaceID!==null||this.activeWorkspaceData!==null||this.artifacts.size>0;this.activeWorkspaceID=null,this.activeWorkspaceData=null,this.artifacts.clear(),this.scrollPosition=0,o&&this.dispatchEvent(new B("change"));return}this.selectWorkspace(i.workspace.id);return}this.applyServerWorkspaceState(r.workspace),s&&r.serverURL===n&&this.requestWorkspace(r.serverURL,r.workspace.id)}hasPendingLayoutMutation(n){return this.pendingMutations.has(this.getMutationKey(pr,n))}selectWorkspace(n){const s=this.findWorkspace(n);s&&(this.activeWorkspaceID=n,this.activeWorkspaceData=structuredClone(s.workspace),this.artifacts.clear(),this.restoreWorkspaceViewState(),this.persistActiveWorkspace(),this.requestWorkspace(s.serverURL,n),this.dispatchEvent(new B("change")))}requestWorkspace(n,s){const r=this.serverManager.servers.get(n);this.sendServerMessage(r??null,{type:"get-workspace",workspaceID:s})}applyWorkspaceSnapshot(n,s){if(n.id===this.activeWorkspaceID){this.applyServerWorkspaceState(n),this.artifacts.clear();for(const r of s)this.artifacts.set(r.id,structuredClone(r));this.restoreWorkspaceViewState(),this.dispatchEvent(new B("change"))}}applyServerWorkspaceState(n){if(!this.activeWorkspaceData||this.activeWorkspaceData.id!==n.id){this.activeWorkspaceData=structuredClone(n);return}this.activeWorkspaceData.name=n.name,this.hasPendingLayoutMutation(n.id)||(this.activeWorkspaceData.layout=n.layout.map(s=>structuredClone(s)))}applyArtifactCreated(n){var s;((s=this.activeWorkspaceData)==null?void 0:s.id)===n.workspaceID&&(no(this.activeWorkspaceData.layout,n.artifact.id)||(this.activeWorkspaceData.layout=[...this.activeWorkspaceData.layout,to(n.artifact.id)]),this.artifacts.set(n.artifact.id,n.artifact),this.dispatchEvent(new B("change")))}applyArtifactUpdated(n){const s=this.artifacts.get(n.artifactID);s&&(Object.assign(s,n.fields),s.type==="html"&&this.artifactReloadVersions.set(n.artifactID,(this.artifactReloadVersions.get(n.artifactID)??0)+1),this.dispatchEvent(new B("change")))}removeArtifactLocally(n){if(!this.activeWorkspaceData)return!1;const s=this.artifacts.delete(n);this.artifactReloadVersions.delete(n);const r=Ri(this.activeWorkspaceData).length;return this.activeWorkspaceData.layout=lu(this.activeWorkspaceData.layout,n),!(!s&&r===Ri(this.activeWorkspaceData).length)}snapshotState(){return{activeWorkspaceData:this.activeWorkspaceData?structuredClone(this.activeWorkspaceData):null,scrollPosition:this.scrollPosition,artifacts:new Map([...this.artifacts.entries()].map(([n,s])=>[n,structuredClone(s)]))}}restoreState(n){this.activeWorkspaceData=n.activeWorkspaceData?structuredClone(n.activeWorkspaceData):null,this.scrollPosition=n.scrollPosition,this.artifacts.clear();for(const[s,r]of n.artifacts.entries())this.artifacts.set(s,structuredClone(r));this.persistWorkspaceViewState()}handleServerError(n){const s=n.request;if(s){if(s.type==="create-artifact"){const r=this.getMutationKey(Pi,s.id),i=this.pendingMutations.get(r);if(!i)return;this.pendingMutations.delete(r),this.restoreState(i),this.dispatchEvent(new B("change"));return}if(s.type==="create-workspace"){const r=this.pendingWorkspaceCreates.get(s.id);if(!r)return;this.pendingWorkspaceCreates.delete(s.id),r.reject(new Error(n.message));return}if(s.type==="delete-workspace"){const r=this.pendingWorkspaceDeletes.get(s.workspaceID);if(!r)return;this.pendingWorkspaceDeletes.delete(s.workspaceID),r.reject(new Error(n.message));return}if(s.type==="update-workspace"&&Array.isArray(s.fields.layout)){const r=this.getMutationKey(pr,s.workspaceID),i=this.pendingMutations.get(r);if(!i)return;this.pendingMutations.delete(r),this.restoreState(i),this.dispatchEvent(new B("change"));return}if(s.type==="remove-artifact"){const r=this.getMutationKey(Di,s.artifactID),i=this.pendingMutations.get(r);if(!i)return;this.pendingMutations.delete(r),this.restoreState(i),this.dispatchEvent(new B("change"))}}}restoreWorkspaceViewState(){var s,r;if(!this.activeWorkspaceID){this.scrollPosition=0;return}const n=((r=(s=this.clientStore.get())==null?void 0:s.workspaces[this.activeWorkspaceID])==null?void 0:r.scrollPosition)??0;this.scrollPosition=Math.max(0,n),this.persistWorkspaceViewState()}persistActiveWorkspace(){this.clientStore.update(n=>{n.lastWorkspaceID=this.activeWorkspaceID})}persistWorkspaceViewState(){this.activeWorkspaceID&&this.clientStore.update(n=>{var s,r;(s=n.workspaces)[r=this.activeWorkspaceID]??(s[r]={scrollPosition:0}),n.workspaces[this.activeWorkspaceID].scrollPosition=this.scrollPosition})}findWorkspace(n){for(const[s,r]of this.serverManager.servers){const i=r.workspaces.get(n);if(i)return{serverURL:s,server:r,workspace:i}}return null}pickNextWorkspace(){var s;const n=(s=this.clientStore.get())==null?void 0:s.lastWorkspaceID;if(n){const r=this.findWorkspace(n);if(r)return r}for(const[r,i]of this.serverManager.servers){const o=i.workspaces.values().next().value;if(o)return{serverURL:r,server:i,workspace:o}}return null}sendServerMessage(n,s){return n?n.send(s):!1}getServers(){return this.serverManager.servers}getMutationKey(n,s){return`${n}:${s}`}}function Bv(e){var s;const t=zn(e);if(t.nodes.length<=1)return 0;let n=0;for(let r=0;r<t.nodes.length-1;r+=1)n+=((s=t.nodes[r])==null?void 0:s.width)??0;return n}function Ec(){let e,t;return{promise:new Promise((s,r)=>{e=s,t=r}),resolve:e,reject:t}}var _u=Symbol.for("immer-nothing"),Ac=Symbol.for("immer-draftable"),Fe=Symbol.for("immer-state");function Ye(e,...t){throw new Error(`[Immer] minified error nr: ${e}. Full error at: https://bit.ly/3cXEKWf`)}var ws=Object.getPrototypeOf;function Zn(e){return!!e&&!!e[Fe]}function tn(e){var t;return e?yu(e)||Array.isArray(e)||!!e[Ac]||!!((t=e.constructor)!=null&&t[Ac])||Ys(e)||oi(e):!1}var Vv=Object.prototype.constructor.toString(),Tc=new WeakMap;function yu(e){if(!e||typeof e!="object")return!1;const t=Object.getPrototypeOf(e);if(t===null||t===Object.prototype)return!0;const n=Object.hasOwnProperty.call(t,"constructor")&&t.constructor;if(n===Object)return!0;if(typeof n!="function")return!1;let s=Tc.get(n);return s===void 0&&(s=Function.toString.call(n),Tc.set(n,s)),s===Vv}function Or(e,t,n=!0){ii(e)===0?(n?Reflect.ownKeys(e):Object.keys(e)).forEach(r=>{t(r,e[r],e)}):e.forEach((s,r)=>t(r,s,e))}function ii(e){const t=e[Fe];return t?t.type_:Array.isArray(e)?1:Ys(e)?2:oi(e)?3:0}function ro(e,t){return ii(e)===2?e.has(t):Object.prototype.hasOwnProperty.call(e,t)}function ku(e,t,n){const s=ii(e);s===2?e.set(t,n):s===3?e.add(n):e[t]=n}function Gv(e,t){return e===t?e!==0||1/e===1/t:e!==e&&t!==t}function Ys(e){return e instanceof Map}function oi(e){return e instanceof Set}function Wt(e){return e.copy_||e.base_}function io(e,t){if(Ys(e))return new Map(e);if(oi(e))return new Set(e);if(Array.isArray(e))return Array.prototype.slice.call(e);const n=yu(e);if(t===!0||t==="class_only"&&!n){const s=Object.getOwnPropertyDescriptors(e);delete s[Fe];let r=Reflect.ownKeys(s);for(let i=0;i<r.length;i++){const o=r[i],a=s[o];a.writable===!1&&(a.writable=!0,a.configurable=!0),(a.get||a.set)&&(s[o]={configurable:!0,writable:!0,enumerable:a.enumerable,value:e[o]})}return Object.create(ws(e),s)}else{const s=ws(e);if(s!==null&&n)return{...e};const r=Object.create(s);return Object.assign(r,e)}}function Jo(e,t=!1){return ai(e)||Zn(e)||!tn(e)||(ii(e)>1&&Object.defineProperties(e,{set:fr,add:fr,clear:fr,delete:fr}),Object.freeze(e),t&&Object.values(e).forEach(n=>Jo(n,!0))),e}function qv(){Ye(2)}var fr={value:qv};function ai(e){return e===null||typeof e!="object"?!0:Object.isFrozen(e)}var Kv={};function nn(e){const t=Kv[e];return t||Ye(0,e),t}var bs;function wu(){return bs}function Yv(e,t){return{drafts_:[],parent_:e,immer_:t,canAutoFreeze_:!0,unfinalizedDrafts_:0}}function Ic(e,t){t&&(nn("Patches"),e.patches_=[],e.inversePatches_=[],e.patchListener_=t)}function oo(e){ao(e),e.drafts_.forEach(Xv),e.drafts_=null}function ao(e){e===bs&&(bs=e.parent_)}function Cc(e){return bs=Yv(bs,e)}function Xv(e){const t=e[Fe];t.type_===0||t.type_===1?t.revoke_():t.revoked_=!0}function zc(e,t){t.unfinalizedDrafts_=t.drafts_.length;const n=t.drafts_[0];return e!==void 0&&e!==n?(n[Fe].modified_&&(oo(t),Ye(4)),tn(e)&&(e=Nr(t,e),t.parent_||Wr(t,e)),t.patches_&&nn("Patches").generateReplacementPatches_(n[Fe].base_,e,t.patches_,t.inversePatches_)):e=Nr(t,n,[]),oo(t),t.patches_&&t.patchListener_(t.patches_,t.inversePatches_),e!==_u?e:void 0}function Nr(e,t,n){if(ai(t))return t;const s=e.immer_.shouldUseStrictIteration(),r=t[Fe];if(!r)return Or(t,(i,o)=>$c(e,r,t,i,o,n),s),t;if(r.scope_!==e)return t;if(!r.modified_)return Wr(e,r.base_,!0),r.base_;if(!r.finalized_){r.finalized_=!0,r.scope_.unfinalizedDrafts_--;const i=r.copy_;let o=i,a=!1;r.type_===3&&(o=new Set(i),i.clear(),a=!0),Or(o,(c,l)=>$c(e,r,i,c,l,n,a),s),Wr(e,i,!1),n&&e.patches_&&nn("Patches").generatePatches_(r,n,e.patches_,e.inversePatches_)}return r.copy_}function $c(e,t,n,s,r,i,o){if(r==null||typeof r!="object"&&!o)return;const a=ai(r);if(!(a&&!o)){if(Zn(r)){const c=i&&t&&t.type_!==3&&!ro(t.assigned_,s)?i.concat(s):void 0,l=Nr(e,r,c);if(ku(n,s,l),Zn(l))e.canAutoFreeze_=!1;else return}else o&&n.add(r);if(tn(r)&&!a){if(!e.immer_.autoFreeze_&&e.unfinalizedDrafts_<1||t&&t.base_&&t.base_[s]===r&&a)return;Nr(e,r),(!t||!t.scope_.parent_)&&typeof s!="symbol"&&(Ys(n)?n.has(s):Object.prototype.propertyIsEnumerable.call(n,s))&&Wr(e,r)}}}function Wr(e,t,n=!1){!e.parent_&&e.immer_.autoFreeze_&&e.canAutoFreeze_&&Jo(t,n)}function Jv(e,t){const n=Array.isArray(e),s={type_:n?1:0,scope_:t?t.scope_:wu(),modified_:!1,finalized_:!1,assigned_:{},parent_:t,base_:e,draft_:null,copy_:null,revoke_:null,isManual_:!1};let r=s,i=Qo;n&&(r=[s],i=Ss);const{revoke:o,proxy:a}=Proxy.revocable(r,i);return s.draft_=a,s.revoke_=o,a}var Qo={get(e,t){if(t===Fe)return e;const n=Wt(e);if(!ro(n,t))return Qv(e,n,t);const s=n[t];return e.finalized_||!tn(s)?s:s===Li(e.base_,t)?(Mi(e),e.copy_[t]=lo(s,e)):s},has(e,t){return t in Wt(e)},ownKeys(e){return Reflect.ownKeys(Wt(e))},set(e,t,n){const s=bu(Wt(e),t);if(s!=null&&s.set)return s.set.call(e.draft_,n),!0;if(!e.modified_){const r=Li(Wt(e),t),i=r==null?void 0:r[Fe];if(i&&i.base_===n)return e.copy_[t]=n,e.assigned_[t]=!1,!0;if(Gv(n,r)&&(n!==void 0||ro(e.base_,t)))return!0;Mi(e),co(e)}return e.copy_[t]===n&&(n!==void 0||t in e.copy_)||Number.isNaN(n)&&Number.isNaN(e.copy_[t])||(e.copy_[t]=n,e.assigned_[t]=!0),!0},deleteProperty(e,t){return Li(e.base_,t)!==void 0||t in e.base_?(e.assigned_[t]=!1,Mi(e),co(e)):delete e.assigned_[t],e.copy_&&delete e.copy_[t],!0},getOwnPropertyDescriptor(e,t){const n=Wt(e),s=Reflect.getOwnPropertyDescriptor(n,t);return s&&{writable:!0,configurable:e.type_!==1||t!=="length",enumerable:s.enumerable,value:n[t]}},defineProperty(){Ye(11)},getPrototypeOf(e){return ws(e.base_)},setPrototypeOf(){Ye(12)}},Ss={};Or(Qo,(e,t)=>{Ss[e]=function(){return arguments[0]=arguments[0][0],t.apply(this,arguments)}});Ss.deleteProperty=function(e,t){return Ss.set.call(this,e,t,void 0)};Ss.set=function(e,t,n){return Qo.set.call(this,e[0],t,n,e[0])};function Li(e,t){const n=e[Fe];return(n?Wt(n):e)[t]}function Qv(e,t,n){var r;const s=bu(t,n);return s?"value"in s?s.value:(r=s.get)==null?void 0:r.call(e.draft_):void 0}function bu(e,t){if(!(t in e))return;let n=ws(e);for(;n;){const s=Object.getOwnPropertyDescriptor(n,t);if(s)return s;n=ws(n)}}function co(e){e.modified_||(e.modified_=!0,e.parent_&&co(e.parent_))}function Mi(e){e.copy_||(e.copy_=io(e.base_,e.scope_.immer_.useStrictShallowCopy_))}var e_=class{constructor(e){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.useStrictIteration_=!0,this.produce=(t,n,s)=>{if(typeof t=="function"&&typeof n!="function"){const i=n;n=t;const o=this;return function(c=i,...l){return o.produce(c,h=>n.call(this,h,...l))}}typeof n!="function"&&Ye(6),s!==void 0&&typeof s!="function"&&Ye(7);let r;if(tn(t)){const i=Cc(this),o=lo(t,void 0);let a=!0;try{r=n(o),a=!1}finally{a?oo(i):ao(i)}return Ic(i,s),zc(r,i)}else if(!t||typeof t!="object"){if(r=n(t),r===void 0&&(r=t),r===_u&&(r=void 0),this.autoFreeze_&&Jo(r,!0),s){const i=[],o=[];nn("Patches").generateReplacementPatches_(t,r,i,o),s(i,o)}return r}else Ye(1,t)},this.produceWithPatches=(t,n)=>{if(typeof t=="function")return(o,...a)=>this.produceWithPatches(o,c=>t(c,...a));let s,r;return[this.produce(t,n,(o,a)=>{s=o,r=a}),s,r]},typeof(e==null?void 0:e.autoFreeze)=="boolean"&&this.setAutoFreeze(e.autoFreeze),typeof(e==null?void 0:e.useStrictShallowCopy)=="boolean"&&this.setUseStrictShallowCopy(e.useStrictShallowCopy),typeof(e==null?void 0:e.useStrictIteration)=="boolean"&&this.setUseStrictIteration(e.useStrictIteration)}createDraft(e){tn(e)||Ye(8),Zn(e)&&(e=t_(e));const t=Cc(this),n=lo(e,void 0);return n[Fe].isManual_=!0,ao(t),n}finishDraft(e,t){const n=e&&e[Fe];(!n||!n.isManual_)&&Ye(9);const{scope_:s}=n;return Ic(s,t),zc(void 0,s)}setAutoFreeze(e){this.autoFreeze_=e}setUseStrictShallowCopy(e){this.useStrictShallowCopy_=e}setUseStrictIteration(e){this.useStrictIteration_=e}shouldUseStrictIteration(){return this.useStrictIteration_}applyPatches(e,t){let n;for(n=t.length-1;n>=0;n--){const r=t[n];if(r.path.length===0&&r.op==="replace"){e=r.value;break}}n>-1&&(t=t.slice(n+1));const s=nn("Patches").applyPatches_;return Zn(e)?s(e,t):this.produce(e,r=>s(r,t))}};function lo(e,t){const n=Ys(e)?nn("MapSet").proxyMap_(e,t):oi(e)?nn("MapSet").proxySet_(e,t):Jv(e,t);return(t?t.scope_:wu()).drafts_.push(n),n}function t_(e){return Zn(e)||Ye(10,e),Su(e)}function Su(e){if(!tn(e)||ai(e))return e;const t=e[Fe];let n,s=!0;if(t){if(!t.modified_)return t.base_;t.finalized_=!0,n=io(e,t.scope_.immer_.useStrictShallowCopy_),s=t.scope_.immer_.shouldUseStrictIteration()}else n=io(e,!0);return Or(n,(r,i)=>{ku(n,r,Su(i))},s),t&&(t.finalized_=!1),n}var n_=new e_,s_=n_.produce,r_=Object.defineProperty,i_=(e,t,n)=>t in e?r_(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,gr=(e,t,n)=>i_(e,typeof t!="symbol"?t+"":t,n);function o_(e){return{all:e=e||new Map,on:function(t,n){var s=e.get(t);s?s.push(n):e.set(t,[n])},off:function(t,n){var s=e.get(t);s&&(n?s.splice(s.indexOf(n)>>>0,1):e.set(t,[]))},emit:function(t,n){var s=e.get(t);s&&s.slice().map(function(r){r(n)}),(s=e.get("*"))&&s.slice().map(function(r){r(t,n)})}}}var a_=class{constructor(){gr(this,"emitter",o_()),gr(this,"on",(e,t)=>(this.emitter.on(e,t),{dispose:()=>this.emitter.off(e,t)})),gr(this,"once",(e,t)=>{const n=s=>{t(s),this.emitter.off(e,n)};return this.emitter.on(e,n),{dispose:()=>this.emitter.off(e,n)}}),gr(this,"off",this.emitter.off)}emit(e,...[t]){this.emitter.emit(e,t)}},c_="store-",l_=class extends a_{emitChange(e){this.emit("change",{state:e})}},u_=class{constructor(e,t,n){this.emitter=new l_,this.id=e,this.initValue=t,this.key=`${c_}${e}`,this.storage=(n==null?void 0:n.storage)==="session"?sessionStorage:localStorage,this.get()===void 0&&this.storage.setItem(this.key,JSON.stringify(t))}get(){const e=this.storage.getItem(this.key);return e===null?void 0:JSON.parse(e)}update(e){const t=this.get()??{},n=s_(t,e);this.storage.setItem(this.key,JSON.stringify(n)),this.emitter.emitChange(n)}reset(){this.storage.setItem(this.key,JSON.stringify(this.initValue)),this.emitter.emitChange(this.initValue)}on(e,t){return this.emitter.on(e,({state:n})=>t(n))}subscribe(e){const t=this.on("change",e),n=this.get();return n!==void 0&&e(n),t}};const h_="Local";function kt(e){return new URL(e).origin}function d_(e){return{servers:[{url:kt(e),name:h_}],lastWorkspaceID:null,workspaces:{}}}function p_(e,t){return new u_(e,d_(t))}const f_=4401;class uo extends Error{constructor(t="Authentication required"){super(t),this.name="AuthError"}}class ho extends ln{constructor(n){super();m(this,"url");m(this,"name");m(this,"token");m(this,"status","disconnected");m(this,"workspaces",new Map);m(this,"createSocket");m(this,"socket",null);m(this,"connectAttempt",0);this.url=kt(n.url),this.name=n.name,this.token=n.token??null,this.createSocket=n.createSocket??(s=>new WebSocket(s))}async connect(){var r;this.connectAttempt+=1;const n=this.connectAttempt;(r=this.socket)==null||r.close(),this.status="connecting",this.dispatchEvent(new B("change"));const s=this.createSocket(g_(this.url,this.token));return this.socket=s,await new Promise((i,o)=>{let a=!1;const c=()=>{a||this.connectAttempt!==n||(a=!0,this.status="connected",this.dispatchEvent(new B("change")),i())},l=h=>{a||this.connectAttempt!==n||(a=!0,this.status="disconnected",this.dispatchEvent(new B("change")),o(h))};s.addEventListener("message",h=>{const f=v_(h);this.applyServerMessage(f),this.dispatchEvent(new yl("server-message",{serverURL:this.url,message:f})),a||c()}),s.addEventListener("close",h=>{if(this.connectAttempt===n){if(this.socket=null,m_(h)===f_){l(new uo);return}if(!a){l(new Error("Connection closed before initialization"));return}this.status="disconnected",this.dispatchEvent(new B("change"))}}),s.addEventListener("error",()=>{l(new Error("WebSocket connection failed"))})})}disconnect(){var n;this.connectAttempt+=1,(n=this.socket)==null||n.close(),this.socket=null,this.status="disconnected",this.dispatchEvent(new B("change"))}send(n){return!this.socket||this.socket.readyState!==1?!1:(this.socket.send(JSON.stringify(n)),!0)}getArtifactURL(n){const s=new URL(this.url);return s.pathname=`/artifact/${n.id}`,s.search="",s.searchParams.set("token",n.token),s.hash="",s.toString()}applyServerMessage(n){switch(n.type){case"workspace-list":this.workspaces=new Map(n.workspaces.map(s=>[s.id,structuredClone(s)]));break;case"workspace-created":this.workspaces.set(n.workspace.id,structuredClone(n.workspace));break;case"workspace-updated":{const s=this.workspaces.get(n.workspaceID);s&&(typeof n.fields.name=="string"&&(s.name=n.fields.name),Array.isArray(n.fields.layout)&&(s.layout=n.fields.layout));break}case"workspace-removed":this.workspaces.delete(n.workspaceID);break;case"artifact-created":{const s=this.workspaces.get(n.workspaceID);s&&!no(s.layout,n.artifact.id)&&(s.layout=[...s.layout,to(n.artifact.id)]);break}case"artifact-removed":{const s=this.workspaces.get(n.workspaceID);s&&(s.layout=lu(s.layout,n.artifactID));break}}}}function g_(e,t){const n=new URL(e);return n.protocol=n.protocol==="https:"?"wss:":"ws:",n.pathname="/ws",n.search="",t&&n.searchParams.set("token",t),n.hash="",n.toString()}function m_(e){return typeof e=="object"&&e!==null&&"code"in e&&typeof e.code=="number"?e.code:null}function v_(e){const t=typeof e=="string"?e:typeof e=="object"&&e!==null&&"data"in e&&typeof e.data=="string"?e.data:"";return JSON.parse(t)}class __ extends ln{constructor(n){super();m(this,"servers",new Map);m(this,"localServerURL");m(this,"activeServer",null);m(this,"clientStore");m(this,"createSocket");m(this,"serverListeners",new Map);this.clientStore=n.clientStore,this.localServerURL=n.localServerURL?kt(n.localServerURL):null,this.createSocket=n.createSocket??(s=>new WebSocket(s))}add(n){const s=kt(n.url);this.servers.get(s)&&this.remove(s),this.servers.set(s,n);const i=()=>{this.dispatchEvent(new B("change"))},o=a=>{this.dispatchEvent(new yl("server-message",{serverURL:a.serverURL,message:a.message}))};n.addEventListener("change",i),n.addEventListener("server-message",o),this.serverListeners.set(s,{onServerChange:i,onServerMessage:o}),this.dispatchEvent(new B("change"))}remove(n){const s=kt(n);if(this.localServerURL&&s===this.localServerURL)return;const r=this.servers.get(s);if(!r)return;const i=this.serverListeners.get(s);i&&(r.removeEventListener("change",i.onServerChange),r.removeEventListener("server-message",i.onServerMessage),this.serverListeners.delete(s)),r.disconnect(),this.servers.delete(s),this.activeServer===r&&(this.activeServer=null),this.clientStore.update(o=>{o.servers=o.servers.filter(a=>a.url!==s)}),this.dispatchEvent(new B("change"))}setActive(n){this.activeServer=n,this.dispatchEvent(new B("change"))}connectConfiguredServers(n){var i;const s=((i=this.clientStore.get())==null?void 0:i.servers)??[];for(const o of s){const a=new ho({url:o.url,name:o.name,createSocket:this.createSocket});this.add(a),a.connect().catch(()=>{})}const r=n?this.servers.get(kt(n))??null:null;this.setActive(r??this.servers.values().next().value??null)}addServer(n,s){const r=kt(n);this.remove(r),this.clientStore.update(o=>{o.servers=o.servers.filter(a=>kt(a.url)!==r),o.servers.push({url:r,name:s})});const i=new ho({url:r,name:s,createSocket:this.createSocket});this.add(i),this.setActive(i),i.connect().catch(()=>{})}removeServer(n){this.remove(n)}}const te={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"},ct={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"},y_=1,k_=p({_meta:k(u(),_()).nullish(),terminal:_e().optional().default(!1)}),w_=p({_meta:k(u(),_()).nullish(),label:u().nullish(),name:u(),optional:_e().optional().default(!1),secret:_e().optional().default(!0)}),b_=p({_meta:k(u(),_()).nullish(),description:u().nullish(),id:u(),name:u()}),S_=p({_meta:k(u(),_()).nullish(),description:u().nullish(),id:u(),link:u().nullish(),name:u(),vars:R(w_)}),x_=p({_meta:k(u(),_()).nullish(),args:R(u()).optional(),description:u().nullish(),env:k(u(),u()).optional(),id:u(),name:u()}),E_=W([S_.and(p({type:S("env_var")})),x_.and(p({type:S("terminal")})),b_]),A_=p({_meta:k(u(),_()).nullish(),methodId:u()}),T_=p({_meta:k(u(),_()).nullish()}),I_=p({_meta:k(u(),_()).nullish(),blob:u(),mimeType:u().nullish(),uri:u()}),C_=p({default:_e().nullish(),description:u().nullish(),title:u().nullish()}),z_=p({_meta:k(u(),_()).nullish()}),$_=p({_meta:k(u(),_()).nullish()}),R_=p({amount:N(),currency:u()}),P_=p({_meta:k(u(),_()).nullish(),terminalId:u()}),D_=p({_meta:k(u(),_()).nullish(),newText:u(),oldText:u().nullish(),path:u()}),L_=W([u(),N(),N(),_e(),R(u())]),M_=p({content:k(u(),L_).nullish()}),O_=W([M_.and(p({action:S("accept")})),p({action:S("decline")}),p({action:S("cancel")})]),N_=p({_meta:k(u(),_()).nullish()}),xu=u(),W_=p({_meta:k(u(),_()).nullish(),elicitationId:xu}),F_=p({_meta:k(u(),_()).nullish(),action:O_}),U_=S("object"),Z_=S("string"),j_=p({_meta:k(u(),_()).nullish()}),H_=p({_meta:k(u(),_()).nullish(),form:N_.nullish(),url:j_.nullish()}),B_=p({elicitationId:xu,url:u().url()}),Eu=p({const:u(),title:u()}),Au=p({_meta:k(u(),_()).nullish(),name:u(),value:u()}),V_=W([S(-32700),S(-32600),S(-32601),S(-32602),S(-32603),S(-32800),S(-32e3),S(-32002),S(-32042),N().int().min(-2147483648,{message:"Invalid value: Expected int32 to be >= -2147483648"}).max(2147483647,{message:"Invalid value: Expected int32 to be <= 2147483647"})]),Tu=p({code:V_,data:_().optional(),message:u()}),Iu=_(),Cu=_(),zu=_(),G_=p({_meta:k(u(),_()).nullish(),readTextFile:_e().optional().default(!1),writeTextFile:_e().optional().default(!1)}),$u=p({_meta:k(u(),_()).nullish(),name:u(),value:u()}),Ru=p({_meta:k(u(),_()).nullish(),name:u(),title:u().nullish(),version:u()}),q_=p({default:N().nullish(),description:u().nullish(),maximum:N().nullish(),minimum:N().nullish(),title:u().nullish()}),K_=p({_meta:k(u(),_()).nullish()}),Y_=p({_meta:k(u(),_()).nullish(),additionalDirectories:R(u()).optional(),cursor:u().nullish(),cwd:u().nullish()}),X_=p({_meta:k(u(),_()).nullish()}),J_=p({_meta:k(u(),_()).nullish(),logout:X_.nullish()}),Q_=p({_meta:k(u(),_()).nullish()}),ey=p({_meta:k(u(),_()).nullish()}),ty=p({_meta:k(u(),_()).nullish(),http:_e().optional().default(!1),sse:_e().optional().default(!1)}),ny=p({_meta:k(u(),_()).nullish(),headers:R($u),name:u(),url:u()}),sy=p({_meta:k(u(),_()).nullish(),headers:R($u),name:u(),url:u()}),ry=p({_meta:k(u(),_()).nullish(),args:R(u()),command:u(),env:R(Au),name:u()}),ci=W([ny.and(p({type:S("http")})),sy.and(p({type:S("sse")})),ry]),ea=u(),iy=p({_meta:k(u(),_()).nullish(),description:u().nullish(),modelId:ea,name:u()}),oy=W([S("error"),S("warning"),S("information"),S("hint")]),ay=p({_meta:k(u(),_()).nullish()}),cy=p({_meta:k(u(),_()).nullish()}),ly=p({_meta:k(u(),_()).nullish()}),uy=p({_meta:k(u(),_()).nullish()}),hy=p({_meta:k(u(),_()).nullish()}),dy=p({_meta:k(u(),_()).nullish(),maxCount:N().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish()}),py=p({diff:u(),uri:u()}),fy=p({endLine:N().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}),startLine:N().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}),text:u()}),gy=p({_meta:k(u(),_()).nullish()}),my=p({_meta:k(u(),_()).nullish()}),vy=p({languageId:u(),text:u(),uri:u()}),_y=p({_meta:k(u(),_()).nullish(),maxCount:N().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish()}),yy=W([S("rejected"),S("ignored"),S("replaced"),S("cancelled")]),ky=p({excerpts:R(fy),uri:u()}),wy=p({_meta:k(u(),_()).nullish()}),by=p({_meta:k(u(),_()).nullish()}),Sy=p({name:u(),owner:u(),remoteUrl:u()}),xy=p({_meta:k(u(),_()).nullish()}),Ey=p({_meta:k(u(),_()).nullish(),jump:gy.nullish(),rename:by.nullish(),searchAndReplace:xy.nullish()}),Ay=p({id:u(),isRegex:_e().nullish(),replace:u(),search:u(),uri:u()}),Ty=W([S("automatic"),S("diagnostic"),S("manual")]),Iy=p({_meta:k(u(),_()).nullish(),maxCount:N().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish()}),Cy=p({_meta:k(u(),_()).nullish(),diagnostics:ay.nullish(),editHistory:dy.nullish(),openFiles:my.nullish(),recentFiles:_y.nullish(),relatedSnippets:wy.nullish(),userActions:Iy.nullish()}),zy=p({_meta:k(u(),_()).nullish(),additionalDirectories:R(u()).optional(),cwd:u(),mcpServers:R(ci)}),$y=p({default:N().nullish(),description:u().nullish(),maximum:N().nullish(),minimum:N().nullish(),title:u().nullish()}),Pu=u(),Ry=W([S("allow_once"),S("allow_always"),S("reject_once"),S("reject_always")]),Py=p({_meta:k(u(),_()).nullish(),kind:Ry,name:u(),optionId:Pu}),Dy=W([S("high"),S("medium"),S("low")]),Ly=W([S("pending"),S("in_progress"),S("completed")]),My=p({_meta:k(u(),_()).nullish(),content:u(),priority:Dy,status:Ly}),Oy=p({_meta:k(u(),_()).nullish(),entries:R(My)}),$t=p({character:N().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}),line:N().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"})}),Ny=p({id:u(),position:$t,uri:u()}),Wy=p({id:u(),newName:u(),position:$t,uri:u()}),Fy=p({action:u(),position:$t,timestampMs:N(),uri:u()}),Du=W([S("utf-16"),S("utf-32"),S("utf-8")]),Uy=p({_meta:k(u(),_()).nullish(),auth:k_.optional().default({terminal:!1}),elicitation:H_.nullish(),fs:G_.optional().default({readTextFile:!1,writeTextFile:!1}),nes:Ey.nullish(),positionEncodings:R(Du).optional(),terminal:_e().optional().default(!1)}),Zy=p({_meta:k(u(),_()).nullish(),audio:_e().optional().default(!1),embeddedContext:_e().optional().default(!1),image:_e().optional().default(!1)}),Lu=N().int().gte(0).lte(65535),jy=p({_meta:k(u(),_()).nullish(),clientCapabilities:Uy.optional().default({auth:{terminal:!1},fs:{readTextFile:!1,writeTextFile:!1},terminal:!1}),clientInfo:Ru.nullish(),protocolVersion:Lu}),Vn=p({end:$t,start:$t}),Hy=p({message:u(),range:Vn,severity:oy,uri:u()}),By=p({languageId:u(),lastFocusedMs:N().nullish(),uri:u(),visibleRange:Vn.nullish()}),Vy=p({_meta:k(u(),_()).nullish(),diagnostics:R(Hy).nullish(),editHistory:R(py).nullish(),openFiles:R(By).nullish(),recentFiles:R(vy).nullish(),relatedSnippets:R(ky).nullish(),userActions:R(Fy).nullish()}),Gy=p({newText:u(),range:Vn}),qy=p({cursorPosition:$t.nullish(),edits:R(Gy),id:u(),uri:u()}),Ky=W([qy.and(p({kind:S("edit")})),Ny.and(p({kind:S("jump")})),Wy.and(p({kind:S("rename")})),Ay.and(p({kind:S("searchAndReplace")}))]),Yy=p({_meta:k(u(),_()).nullish(),content:u()}),Xy=p({_meta:k(u(),_()).nullish()}),sn=W([N(),u()]).nullable();p({_meta:k(u(),_()).nullish(),requestId:sn});const Jy=eu(["assistant","user"]),Xs=p({_meta:k(u(),_()).nullish(),audience:R(Jy).nullish(),lastModified:u().nullish(),priority:N().nullish()}),Qy=p({_meta:k(u(),_()).nullish(),annotations:Xs.nullish(),data:u(),mimeType:u()}),ek=p({_meta:k(u(),_()).nullish(),annotations:Xs.nullish(),data:u(),mimeType:u(),uri:u().nullish()}),tk=p({_meta:k(u(),_()).nullish(),annotations:Xs.nullish(),description:u().nullish(),mimeType:u().nullish(),name:u(),size:N().nullish(),title:u().nullish(),uri:u()}),nk=p({_meta:k(u(),_()).nullish(),optionId:Pu}),sk=W([p({outcome:S("cancelled")}),nk.and(p({outcome:S("selected")}))]),rk=p({_meta:k(u(),_()).nullish(),outcome:sk}),ik=p({_meta:k(u(),_()).nullish()}),ok=p({_meta:k(u(),_()).nullish()}),ak=p({currentValue:_e()}),ck=u(),Mu=u(),lk=W([S("mode"),S("model"),S("thought_level"),u()]),ta=u(),Ou=p({_meta:k(u(),_()).nullish(),description:u().nullish(),name:u(),value:ta}),uk=p({_meta:k(u(),_()).nullish(),group:ck,name:u(),options:R(Ou)}),hk=W([R(Ou),R(uk)]),dk=p({currentValue:ta,options:hk}),Gn=ri(W([dk.and(p({type:S("select")})),ak.and(p({type:S("boolean")}))]),p({_meta:k(u(),_()).nullish(),category:lk.nullish(),description:u().nullish(),id:Mu,name:u()})),pk=p({_meta:k(u(),_()).nullish(),configOptions:R(Gn)}),fk=p({_meta:k(u(),_()).nullish()}),V=u(),gk=p({_meta:k(u(),_()).nullish(),id:u(),sessionId:V}),mk=p({_meta:k(u(),_()).nullish(),sessionId:V}),vk=p({_meta:k(u(),_()).nullish(),sessionId:V}),_k=p({_meta:k(u(),_()).nullish(),sessionId:V}),Nu=p({_meta:k(u(),_()).nullish(),args:R(u()).optional(),command:u(),cwd:u().nullish(),env:R(Au).optional(),outputByteLimit:N().nullish(),sessionId:V}),yk=p({_meta:k(u(),_()).nullish(),sessionId:V,uri:u()}),kk=p({_meta:k(u(),_()).nullish(),position:$t,sessionId:V,uri:u(),version:N(),visibleRange:Vn}),wk=p({_meta:k(u(),_()).nullish(),languageId:u(),sessionId:V,text:u(),uri:u(),version:N()}),bk=p({_meta:k(u(),_()).nullish(),sessionId:V,uri:u()}),Sk=p({_meta:k(u(),_()).nullish(),additionalDirectories:R(u()).optional(),cwd:u(),mcpServers:R(ci).optional(),sessionId:V}),Wu=p({_meta:k(u(),_()).nullish(),sessionId:V,terminalId:u()}),xk=p({_meta:k(u(),_()).nullish(),additionalDirectories:R(u()).optional(),cwd:u(),mcpServers:R(ci),sessionId:V}),Fu=p({_meta:k(u(),_()).nullish(),limit:N().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),line:N().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),path:u(),sessionId:V}),Ek=p({_meta:k(u(),_()).nullish(),id:u(),reason:yy.nullish(),sessionId:V}),Uu=p({_meta:k(u(),_()).nullish(),sessionId:V,terminalId:u()}),Ak=p({_meta:k(u(),_()).nullish(),additionalDirectories:R(u()).optional(),cwd:u(),mcpServers:R(ci).optional(),sessionId:V}),Tk=p({_meta:k(u(),_()).nullish(),additionalDirectories:R(u()).optional(),cwd:u(),sessionId:V,title:u().nullish(),updatedAt:u().nullish()}),Ik=p({_meta:k(u(),_()).nullish(),nextCursor:u().nullish(),sessions:R(Tk)}),Ck=p({_meta:k(u(),_()).nullish(),title:u().nullish(),updatedAt:u().nullish()}),zk=p({_meta:k(u(),_()).nullish()}),li=u(),$k=p({_meta:k(u(),_()).nullish(),currentModeId:li}),Rk=p({_meta:k(u(),_()).nullish(),description:u().nullish(),id:li,name:u()}),ui=p({_meta:k(u(),_()).nullish(),availableModes:R(Rk),currentModeId:li}),hi=p({_meta:k(u(),_()).nullish(),availableModels:R(iy),currentModelId:ea}),Pk=p({_meta:k(u(),_()).nullish(),configOptions:R(Gn).nullish(),models:hi.nullish(),modes:ui.nullish(),sessionId:V}),Dk=p({_meta:k(u(),_()).nullish(),configOptions:R(Gn).nullish(),models:hi.nullish(),modes:ui.nullish()}),Lk=p({_meta:k(u(),_()).nullish(),configOptions:R(Gn).nullish(),models:hi.nullish(),modes:ui.nullish(),sessionId:V}),Mk=p({_meta:k(u(),_()).nullish(),configOptions:R(Gn).nullish(),models:hi.nullish(),modes:ui.nullish()}),Ok=p({_meta:k(u(),_()).nullish()}),Nk=p({_meta:k(u(),_()).nullish(),additionalDirectories:ik.nullish(),close:ok.nullish(),fork:fk.nullish(),list:zk.nullish(),resume:Ok.nullish()}),Wk=ri(W([p({type:S("boolean"),value:_e()}),p({value:ta})]),p({_meta:k(u(),_()).nullish(),configId:Mu,sessionId:V})),Fk=p({_meta:k(u(),_()).nullish(),configOptions:R(Gn)}),Uk=p({_meta:k(u(),_()).nullish(),modeId:li,sessionId:V}),Zk=p({_meta:k(u(),_()).nullish()}),jk=p({_meta:k(u(),_()).nullish(),modelId:ea,sessionId:V}),Hk=p({_meta:k(u(),_()).nullish()}),Bk=p({_meta:k(u(),_()).nullish(),sessionId:V}),Vk=W([S("end_turn"),S("max_tokens"),S("max_turn_requests"),S("refusal"),S("cancelled")]),Gk=W([S("email"),S("uri"),S("date"),S("date-time")]),qk=p({default:u().nullish(),description:u().nullish(),enum:R(u()).nullish(),format:Gk.nullish(),maxLength:N().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),minLength:N().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),oneOf:R(Eu).nullish(),pattern:u().nullish(),title:u().nullish()}),Kk=p({_meta:k(u(),_()).nullish(),context:Vy.nullish(),position:$t,selection:Vn.nullish(),sessionId:V,triggerKind:Ty,uri:u(),version:N()}),Yk=p({_meta:k(u(),_()).nullish(),suggestions:R(Ky)}),Xk=p({_meta:k(u(),_()).nullish(),terminalId:u()}),Jk=p({_meta:k(u(),_()).nullish(),exitCode:N().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),signal:u().nullish()}),Zu=p({_meta:k(u(),_()).nullish(),sessionId:V,terminalId:u()}),Qk=p({_meta:k(u(),_()).nullish(),exitStatus:Jk.nullish(),output:u(),truncated:_e()}),ew=p({_meta:k(u(),_()).nullish(),annotations:Xs.nullish(),text:u()}),tw=p({range:Vn.nullish(),text:u()}),nw=p({_meta:k(u(),_()).nullish(),contentChanges:R(tw),sessionId:V,uri:u(),version:N()});p({method:u(),params:W([mk,wk,nw,yk,bk,kk,gk,Ek,Iu]).nullish()});const sw=W([S("full"),S("incremental")]),rw=p({_meta:k(u(),_()).nullish(),syncKind:sw}),iw=p({_meta:k(u(),_()).nullish(),didChange:rw.nullish(),didClose:cy.nullish(),didFocus:ly.nullish(),didOpen:uy.nullish(),didSave:hy.nullish()}),ow=p({_meta:k(u(),_()).nullish(),document:iw.nullish()}),aw=p({_meta:k(u(),_()).nullish(),context:Cy.nullish(),events:ow.nullish()}),cw=p({_meta:k(u(),_()).nullish(),auth:J_.optional().default({}),loadSession:_e().optional().default(!1),mcpCapabilities:ty.optional().default({http:!1,sse:!1}),nes:aw.nullish(),positionEncoding:Du.nullish(),promptCapabilities:Zy.optional().default({audio:!1,embeddedContext:!1,image:!1}),sessionCapabilities:Nk.optional().default({})}),lw=p({_meta:k(u(),_()).nullish(),agentCapabilities:cw.optional().default({auth:{},loadSession:!1,mcpCapabilities:{http:!1,sse:!1},promptCapabilities:{audio:!1,embeddedContext:!1,image:!1},sessionCapabilities:{}}),agentInfo:Ru.nullish(),authMethods:R(E_).optional().default([]),protocolVersion:Lu}),uw=p({_meta:k(u(),_()).nullish(),mimeType:u().nullish(),text:u(),uri:u()}),hw=W([uw,I_]),dw=p({_meta:k(u(),_()).nullish(),annotations:Xs.nullish(),resource:hw}),na=W([ew.and(p({type:S("text")})),ek.and(p({type:S("image")})),Qy.and(p({type:S("audio")})),tk.and(p({type:S("resource_link")})),dw.and(p({type:S("resource")}))]),pw=p({_meta:k(u(),_()).nullish(),content:na}),Oi=p({_meta:k(u(),_()).nullish(),content:na,messageId:u().nullish()}),fw=p({_meta:k(u(),_()).nullish(),messageId:u().nullish(),prompt:R(na),sessionId:V}),gw=p({anyOf:R(Eu)}),ju=W([pw.and(p({type:S("content")})),D_.and(p({type:S("diff")})),Xk.and(p({type:S("terminal")}))]),Hu=u(),Bu=p({_meta:k(u(),_()).nullish(),line:N().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),path:u()}),Vu=W([S("pending"),S("in_progress"),S("completed"),S("failed")]),Gu=W([S("read"),S("edit"),S("delete"),S("move"),S("search"),S("execute"),S("think"),S("fetch"),S("switch_mode"),S("other")]),mw=p({_meta:k(u(),_()).nullish(),content:R(ju).optional(),kind:Gu.optional(),locations:R(Bu).optional(),rawInput:_().optional(),rawOutput:_().optional(),status:Vu.optional(),title:u(),toolCallId:Hu}),qu=p({_meta:k(u(),_()).nullish(),content:R(ju).nullish(),kind:Gu.nullish(),locations:R(Bu).nullish(),rawInput:_().optional(),rawOutput:_().optional(),status:Vu.nullish(),title:u().nullish(),toolCallId:Hu}),Ku=p({_meta:k(u(),_()).nullish(),options:R(Py),sessionId:V,toolCall:qu}),vw=p({_meta:k(u(),_()).nullish(),hint:u()}),_w=vw,yw=p({_meta:k(u(),_()).nullish(),description:u(),input:_w.nullish(),name:u()}),kw=p({_meta:k(u(),_()).nullish(),availableCommands:R(yw)}),ww=p({enum:R(u()),type:Z_}),bw=W([ww,gw]),Sw=p({default:R(u()).nullish(),description:u().nullish(),items:bw,maxItems:N().nullish(),minItems:N().nullish(),title:u().nullish()}),xw=W([qk.and(p({type:S("string")})),$y.and(p({type:S("number")})),q_.and(p({type:S("integer")})),C_.and(p({type:S("boolean")})),Sw.and(p({type:S("array")}))]),Ew=p({description:u().nullish(),properties:k(u(),xw).optional().default({}),required:R(u()).nullish(),title:u().nullish(),type:U_.optional().default("object")}),Aw=p({requestedSchema:Ew}),Tw=ri(W([Aw.and(p({mode:S("form")})),B_.and(p({mode:S("url")}))]),p({_meta:k(u(),_()).nullish(),message:u(),sessionId:V})),Iw=p({cachedReadTokens:N().nullish(),cachedWriteTokens:N().nullish(),inputTokens:N(),outputTokens:N(),thoughtTokens:N().nullish(),totalTokens:N()}),Cw=p({_meta:k(u(),_()).nullish(),stopReason:Vk,usage:Iw.nullish(),userMessageId:u().nullish()});W([p({id:sn,result:W([lw,T_,ey,Lk,Dk,Ik,Pk,Mk,$_,Zk,Fk,Cw,Hk,Bk,Yk,z_,zu])}),p({error:Tu,id:sn})]);const zw=p({_meta:k(u(),_()).nullish(),cost:R_.nullish(),size:N(),used:N()}),$w=W([Oi.and(p({sessionUpdate:S("user_message_chunk")})),Oi.and(p({sessionUpdate:S("agent_message_chunk")})),Oi.and(p({sessionUpdate:S("agent_thought_chunk")})),mw.and(p({sessionUpdate:S("tool_call")})),qu.and(p({sessionUpdate:S("tool_call_update")})),Oy.and(p({sessionUpdate:S("plan")})),kw.and(p({sessionUpdate:S("available_commands_update")})),$k.and(p({sessionUpdate:S("current_mode_update")})),pk.and(p({sessionUpdate:S("config_option_update")})),Ck.and(p({sessionUpdate:S("session_info_update")})),zw.and(p({sessionUpdate:S("usage_update")}))]),Yu=p({_meta:k(u(),_()).nullish(),sessionId:V,update:$w});p({method:u(),params:W([Yu,W_,Iu]).nullish()});const Xu=p({_meta:k(u(),_()).nullish(),sessionId:V,terminalId:u()}),Rw=p({_meta:k(u(),_()).nullish(),exitCode:N().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),signal:u().nullish()}),Pw=p({name:u(),uri:u()}),Dw=p({_meta:k(u(),_()).nullish(),repository:Sy.nullish(),workspaceFolders:R(Pw).nullish(),workspaceUri:u().nullish()});p({id:sn,method:u(),params:W([jy,A_,Q_,zy,xk,Y_,Sk,Ak,_k,Uk,Wk,fw,jk,Dw,Kk,vk,Cu]).nullish()});const Ju=p({_meta:k(u(),_()).nullish(),content:u(),path:u(),sessionId:V});p({id:sn,method:u(),params:W([Ju,Fu,Ku,Nu,Zu,Uu,Xu,Wu,Tw,Cu]).nullish()});const Lw=p({_meta:k(u(),_()).nullish()});W([p({id:sn,result:W([Lw,Yy,rk,P_,Qk,Xy,Rw,K_,F_,zu])}),p({error:Tu,id:sn})]);var H;class Mw{constructor(t,n){I(this,H);const s=t(this),r=async(o,a)=>{var c,l,h,f,w,v,E;switch(o){case ct.fs_write_text_file:{const x=Ju.parse(a);return(c=s.writeTextFile)==null?void 0:c.call(s,x)}case ct.fs_read_text_file:{const x=Fu.parse(a);return(l=s.readTextFile)==null?void 0:l.call(s,x)}case ct.session_request_permission:{const x=Ku.parse(a);return s.requestPermission(x)}case ct.terminal_create:{const x=Nu.parse(a);return(h=s.createTerminal)==null?void 0:h.call(s,x)}case ct.terminal_output:{const x=Zu.parse(a);return(f=s.terminalOutput)==null?void 0:f.call(s,x)}case ct.terminal_release:{const x=Uu.parse(a);return await((w=s.releaseTerminal)==null?void 0:w.call(s,x))??{}}case ct.terminal_wait_for_exit:{const x=Xu.parse(a);return(v=s.waitForTerminalExit)==null?void 0:v.call(s,x)}case ct.terminal_kill:{const x=Wu.parse(a);return await((E=s.killTerminal)==null?void 0:E.call(s,x))??{}}default:if(s.extMethod)return s.extMethod(o,a);throw ge.methodNotFound(o)}},i=async(o,a)=>{switch(o){case ct.session_update:{const c=Yu.parse(a);return s.sessionUpdate(c)}default:if(s.extNotification)return s.extNotification(o,a);throw ge.methodNotFound(o)}};C(this,H,new Ow(r,i,n))}async initialize(t){return await d(this,H).sendRequest(te.initialize,t)}async newSession(t){return await d(this,H).sendRequest(te.session_new,t)}async loadSession(t){return await d(this,H).sendRequest(te.session_load,t)??{}}async unstable_forkSession(t){return await d(this,H).sendRequest(te.session_fork,t)}async listSessions(t){return await d(this,H).sendRequest(te.session_list,t)}async unstable_resumeSession(t){return await d(this,H).sendRequest(te.session_resume,t)}async unstable_closeSession(t){return await d(this,H).sendRequest(te.session_close,t)}async setSessionMode(t){return await d(this,H).sendRequest(te.session_set_mode,t)??{}}async unstable_setSessionModel(t){return await d(this,H).sendRequest(te.session_set_model,t)??{}}async setSessionConfigOption(t){return await d(this,H).sendRequest(te.session_set_config_option,t)}async authenticate(t){return await d(this,H).sendRequest(te.authenticate,t)??{}}async unstable_logout(t){return await d(this,H).sendRequest(te.logout,t)??{}}async prompt(t){return await d(this,H).sendRequest(te.session_prompt,t)}async cancel(t){return await d(this,H).sendNotification(te.session_cancel,t)}async unstable_startNes(t){return await d(this,H).sendRequest(te.nes_start,t)}async unstable_suggestNes(t){return await d(this,H).sendRequest(te.nes_suggest,t)}async unstable_closeNes(t){return await d(this,H).sendRequest(te.nes_close,t)??{}}async unstable_didOpenDocument(t){return await d(this,H).sendNotification(te.document_did_open,t)}async unstable_didChangeDocument(t){return await d(this,H).sendNotification(te.document_did_change,t)}async unstable_didCloseDocument(t){return await d(this,H).sendNotification(te.document_did_close,t)}async unstable_didSaveDocument(t){return await d(this,H).sendNotification(te.document_did_save,t)}async unstable_didFocusDocument(t){return await d(this,H).sendNotification(te.document_did_focus,t)}async unstable_acceptNes(t){return await d(this,H).sendNotification(te.nes_accept,t)}async unstable_rejectNes(t){return await d(this,H).sendNotification(te.nes_reject,t)}async extMethod(t,n){return await d(this,H).sendRequest(t,n)}async extNotification(t,n){return await d(this,H).sendNotification(t,n)}get signal(){return d(this,H).signal}get closed(){return d(this,H).closed}}H=new WeakMap;var bt,Vr,zs,$s,$n,Rn,tt,Rs,re,Qu,po,eh,th,nh,sh,fo,ds;class Ow{constructor(t,n,s){I(this,re);I(this,bt,new Map);I(this,Vr,0);I(this,zs);I(this,$s);I(this,$n);I(this,Rn,Promise.resolve());I(this,tt,new AbortController);I(this,Rs);C(this,zs,t),C(this,$s,n),C(this,$n,s),C(this,Rs,new Promise(r=>{d(this,tt).signal.addEventListener("abort",()=>r())})),y(this,re,Qu).call(this)}get signal(){return d(this,tt).signal}get closed(){return d(this,Rs)}async sendRequest(t,n){y(this,re,fo).call(this);const s=Xa(this,Vr)._++,r=new Promise((i,o)=>{d(this,bt).set(s,{resolve:i,reject:o})});return await y(this,re,ds).call(this,{jsonrpc:"2.0",id:s,method:t,params:n}),r}async sendNotification(t,n){y(this,re,fo).call(this),await y(this,re,ds).call(this,{jsonrpc:"2.0",method:t,params:n})}}bt=new WeakMap,Vr=new WeakMap,zs=new WeakMap,$s=new WeakMap,$n=new WeakMap,Rn=new WeakMap,tt=new WeakMap,Rs=new WeakMap,re=new WeakSet,Qu=async function(){let t;try{const n=d(this,$n).readable.getReader();try{for(;!d(this,tt).signal.aborted;){const{value:s,done:r}=await n.read();if(r)break;if(s)try{y(this,re,eh).call(this,s)}catch(i){console.error("Unexpected error during message processing:",s,i),"id"in s&&s.id!==void 0&&y(this,re,ds).call(this,{jsonrpc:"2.0",id:s.id,error:{code:-32700,message:"Parse error"}})}}}finally{n.releaseLock()}}catch(n){t=n}finally{y(this,re,po).call(this,t)}},po=function(t){if(d(this,tt).signal.aborted)return;const n=t??new Error("ACP connection closed");for(const s of d(this,bt).values())s.reject(n);d(this,bt).clear(),d(this,tt).abort(n)},eh=async function(t){if("method"in t&&"id"in t){const n=await y(this,re,th).call(this,t.method,t.params);"error"in n&&console.error("Error handling request",t,n.error),await y(this,re,ds).call(this,{jsonrpc:"2.0",id:t.id,...n})}else if("method"in t){const n=await y(this,re,nh).call(this,t.method,t.params);"error"in n&&console.error("Error handling notification",t,n.error)}else"id"in t?y(this,re,sh).call(this,t):console.error("Invalid message",{message:t})},th=async function(t,n){try{return{result:await d(this,zs).call(this,t,n)??null}}catch(s){if(s instanceof ge)return s.toResult();if(s instanceof vc)return ge.invalidParams(s.format()).toResult();let r;(s instanceof Error||typeof s=="object"&&s!=null&&"message"in s&&typeof s.message=="string")&&(r=s.message);try{return ge.internalError(r?JSON.parse(r):{}).toResult()}catch{return ge.internalError({details:r}).toResult()}}},nh=async function(t,n){try{return await d(this,$s).call(this,t,n),{result:null}}catch(s){if(s instanceof ge)return s.toResult();if(s instanceof vc)return ge.invalidParams(s.format()).toResult();let r;(s instanceof Error||typeof s=="object"&&s!=null&&"message"in s&&typeof s.message=="string")&&(r=s.message);try{return ge.internalError(r?JSON.parse(r):{}).toResult()}catch{return ge.internalError({details:r}).toResult()}}},sh=function(t){const n=d(this,bt).get(t.id);if(n){if("result"in t)n.resolve(t.result);else if("error"in t){const{code:s,message:r,data:i}=t.error;n.reject(new ge(s,r,i))}d(this,bt).delete(t.id)}else console.error("Got response to unknown request",t.id)},fo=function(){if(d(this,tt).signal.aborted)throw d(this,tt).signal.reason??new Error("ACP connection closed")},ds=async function(t){return C(this,Rn,d(this,Rn).then(async()=>{const n=d(this,$n).writable.getWriter();try{await n.write(t)}finally{n.releaseLock()}}).catch(n=>{y(this,re,po).call(this,n)})),d(this,Rn)};class ge extends Error{constructor(n,s,r){super(s);m(this,"code");m(this,"data");this.code=n,this.name="RequestError",this.data=r}static parseError(n,s){return new ge(-32700,`Parse error${s?`: ${s}`:""}`,n)}static invalidRequest(n,s){return new ge(-32600,`Invalid request${s?`: ${s}`:""}`,n)}static methodNotFound(n){return new ge(-32601,`"Method not found": ${n}`,{method:n})}static invalidParams(n,s){return new ge(-32602,`Invalid params${s?`: ${s}`:""}`,n)}static internalError(n,s){return new ge(-32603,`Internal error${s?`: ${s}`:""}`,n)}static authRequired(n,s){return new ge(-32e3,`Authentication required${s?`: ${s}`:""}`,n)}static resourceNotFound(n){return new ge(-32002,`Resource not found${n?`: ${n}`:""}`,n&&{uri:n})}toResult(){return{error:{code:this.code,message:this.message,data:this.data}}}toErrorResponse(){return{code:this.code,message:this.message,data:this.data}}}const Nw=/^Sender \(untrusted metadata\):\n```json\n[\s\S]*?\n```\n\n?/,Ww=/^\[[^\n]*Working directory:[^\n]*\]\n\n?/,Fw=/\[Television workspace context\][\s\S]*?\[\/Television workspace context\]\n*/,Uw=/\[\[\s*(?:reply_to_current|reply_to\s*:\s*[^\]\n]+|audio_as_voice)\s*\]\]\s*/gi,Zw="single_session",jw={name:"television-acp-client",version:"0.0.0"},rh="agent:main:television";var Q,ut,Pn,ht,Gt,qt,St,Dn,nt,Be,xt,Kt,dt,Et,Ps,pt,Ve,Gr,ft,Yt,T,ih,oh,go,ah,ch,lh,uh,hh,dh,ph,Ft,kn,wn,Me,fh,bn,mo,vo,xr,gh,Ds,Ls,_o,Sn,mh,vh;class Hw extends ln{constructor(n){super();I(this,T);I(this,Q,Bw());I(this,ut,null);I(this,Pn,null);I(this,ht,null);I(this,Gt,null);I(this,qt,null);I(this,St,null);I(this,Dn,1);I(this,nt,null);I(this,Be,null);I(this,xt,!1);I(this,Kt,!1);I(this,dt,null);I(this,Et,new Set);I(this,Ps);I(this,pt);I(this,Ve);I(this,Gr,n=>{y(this,T,oh).call(this,n)});I(this,ft,null);I(this,Yt,!1);I(this,Ds,()=>{y(this,T,Sn).call(this,"ACP bridge websocket closed")});I(this,Ls,()=>{y(this,T,Sn).call(this,"ACP bridge websocket error")});C(this,pt,n),C(this,Ve,n.sessionMode??Zw),C(this,Ps,n.createSocket??(s=>new WebSocket(s)))}getState(){return d(this,Q)}async connect(){if(d(this,Yt))throw new Error("ACPClientService has been disposed");if(d(this,Q).lifecycle.status!=="ready"){y(this,T,Me).call(this,{lifecycle:{status:"connecting"}}),d(this,Pn)??C(this,Pn,y(this,T,ih).call(this));try{await d(this,Pn),await y(this,T,go).call(this)}catch(n){throw y(this,T,Sn).call(this,mr(n)),n}}}async dispose(){d(this,Yt)||(C(this,Yt,!0),y(this,T,_o).call(this),y(this,T,Me).call(this,{lifecycle:{status:"disposed"},run:{status:"idle",stopReason:null,canCancel:!1,error:null}}))}async sendMessage(n){if(await this.connect(),d(this,Q).lifecycle.status!=="ready"||d(this,Q).run.status==="running"||d(this,Q).run.status==="cancelling")throw new Error("ACPClientService is not ready to send a new message");const s=n.text.trim();if(!s)throw new Error("Cannot send an empty message");y(this,T,kn).call(this,{id:y(this,T,bn).call(this,"user"),kind:"user",text:s,status:"final"}),y(this,T,Me).call(this,{run:{status:"running",stopReason:null,canCancel:!0,error:null}});try{const r=await y(this,T,xr).call(this).prompt({sessionId:y(this,T,vo).call(this),prompt:[{type:"text",text:y(this,T,fh).call(this,s)}]});y(this,T,Ft).call(this,r.stopReason==="cancelled"?"cancelled":"final"),y(this,T,Me).call(this,{run:{status:r.stopReason==="cancelled"?"cancelled":"completed",stopReason:r.stopReason,canCancel:!1,error:null}})}catch(r){throw y(this,T,vh).call(this)||(y(this,T,Ft).call(this,"error"),y(this,T,Me).call(this,{run:{status:"error",stopReason:null,canCancel:!1,error:mr(r)}})),r}}async cancel(){if(await this.connect(),!d(this,Q).run.canCancel||d(this,Q).run.status!=="running")throw new Error("No active cancellable run");y(this,T,Me).call(this,{run:{...d(this,Q).run,status:"cancelling"}}),await y(this,T,xr).call(this).cancel({sessionId:y(this,T,vo).call(this)})}setWorkspaceContext(n){var i,o,a;const s={workspaceID:n.workspaceID,workspaceName:n.workspaceName};if(((i=d(this,Be))==null?void 0:i.workspaceID)===s.workspaceID&&((o=d(this,Be))==null?void 0:o.workspaceName)===s.workspaceName)return;const r=((a=d(this,Be))==null?void 0:a.workspaceID)??null;if(C(this,Be,s),d(this,Ve)==="single_session"){(!d(this,St)||r!==s.workspaceID)&&C(this,xt,!0);return}d(this,St)!==Rc(d(this,Ve),s.workspaceID,d(this,pt).clientGUID??"default-client")&&(C(this,ht,null),C(this,Gt,null),d(this,ut)&&d(this,Q).run.status==="idle"&&y(this,T,go).call(this).catch(c=>{y(this,T,Sn).call(this,mr(c))}))}}Q=new WeakMap,ut=new WeakMap,Pn=new WeakMap,ht=new WeakMap,Gt=new WeakMap,qt=new WeakMap,St=new WeakMap,Dn=new WeakMap,nt=new WeakMap,Be=new WeakMap,xt=new WeakMap,Kt=new WeakMap,dt=new WeakMap,Et=new WeakMap,Ps=new WeakMap,pt=new WeakMap,Ve=new WeakMap,Gr=new WeakMap,ft=new WeakMap,Yt=new WeakMap,T=new WeakSet,ih=async function(){try{y(this,T,Me).call(this,{lifecycle:{status:"connecting"}});const{stream:n,socket:s}=await qw({serverURL:d(this,pt).serverURL,token:d(this,pt).token,createSocket:d(this,Ps),onDisconnect:d(this,Gr)});C(this,ft,s),s.addEventListener("close",d(this,Ds)),s.addEventListener("error",d(this,Ls)),C(this,ut,new Mw(r=>({connection:r,sessionUpdate:async i=>{await y(this,T,ch).call(this,i)},requestPermission:async i=>y(this,T,lh).call(this,i)}),n)),await d(this,ut).initialize({protocolVersion:y_,clientCapabilities:{},clientInfo:jw})}catch(n){throw n}},oh=function(n){y(this,T,Sn).call(this,mr(n))},go=async function(){const n=y(this,T,gh).call(this);if(d(this,ht)&&d(this,Gt)===n){await d(this,ht);return}C(this,Gt,n),C(this,ht,y(this,T,ah).call(this,n)),await d(this,ht)},ah=async function(n){const s=y(this,T,xr).call(this);y(this,T,mh).call(this);let r,i=!1;try{C(this,Kt,!0),C(this,dt,null),await s.loadSession({sessionId:n,cwd:"/",mcpServers:[],_meta:{sessionKey:n}}),r=n,i=d(this,Q).messageOrder.length>0}catch{r=(await s.newSession({cwd:"/",mcpServers:[],_meta:{sessionKey:n}})).sessionId,i=!1}finally{C(this,Kt,!1),C(this,dt,null),y(this,T,Ft).call(this,"final")}await s.setSessionConfigOption({sessionId:r,configId:"verbose_level",value:"full"}),C(this,qt,r),C(this,St,n),i?(d(this,Et).add(n),d(this,Ve)==="single_session"&&C(this,xt,!1)):(d(this,Et).delete(n),C(this,xt,d(this,Ve)==="single_session")),y(this,T,Me).call(this,{lifecycle:{status:"ready"}})},ch=async function(n){const s=n.update;switch(s.sessionUpdate){case"user_message_chunk":s.content.type==="text"&&y(this,T,ph).call(this,s.content.text);return;case"agent_message_chunk":s.content.type==="text"&&y(this,T,uh).call(this,s.content.text);return;case"tool_call":y(this,T,hh).call(this,s);return;case"tool_call_update":y(this,T,dh).call(this,s);return;case"agent_thought_chunk":return;default:return}},lh=async function(n){return{outcome:{outcome:"cancelled"}}},uh=function(n){C(this,dt,null);const s=Vw(n);if(!s)return;if(!d(this,nt)){const i={id:y(this,T,bn).call(this,"assistant"),kind:"assistant",text:s,status:"streaming"};C(this,nt,i.id),y(this,T,kn).call(this,i);return}const r=d(this,Q).messagesById[d(this,nt)];if(!r||r.kind!=="assistant")throw new Error("Open assistant message invariant violated");y(this,T,wn).call(this,{...r,text:`${r.text}${s}`,status:"streaming"})},hh=function(n){y(this,T,Ft).call(this,"final");const s=y(this,T,mo).call(this,n.toolCallId),r={id:(s==null?void 0:s.id)??y(this,T,bn).call(this,"tool"),kind:"tool_call",toolCallId:n.toolCallId,title:n.title,toolKind:n.kind??"other",status:n.status==="failed"?"failed":n.status==="completed"?"completed":"in_progress",text:(s==null?void 0:s.text)??"",locations:n.locations??(s==null?void 0:s.locations)};if(s){y(this,T,wn).call(this,r);return}y(this,T,kn).call(this,r)},dh=function(n){const s=y(this,T,mo).call(this,n.toolCallId),r=(s==null?void 0:s.text)??"",i=Gw(n.content),o=i?`${r}${i}`:r,a={id:(s==null?void 0:s.id)??y(this,T,bn).call(this,"tool"),kind:"tool_call",toolCallId:n.toolCallId,title:(s==null?void 0:s.title)??n.toolCallId,toolKind:(s==null?void 0:s.toolKind)??"other",status:n.status==="failed"?"failed":n.status==="completed"?"completed":"in_progress",text:o,locations:n.locations??(s==null?void 0:s.locations)};if(s){y(this,T,wn).call(this,a);return}y(this,T,kn).call(this,a)},ph=function(n){if(y(this,T,Ft).call(this,"final"),!n)return;const s=d(this,Kt)?d(this,dt):null;if(!s){const i=Pc(n);if(!i)return;const o={id:y(this,T,bn).call(this,"user"),kind:"user",text:i,status:"final"};y(this,T,kn).call(this,o),d(this,Kt)&&C(this,dt,o.id);return}const r=d(this,Q).messagesById[s];if(!r||r.kind!=="user")throw new Error("Replay user message invariant violated");y(this,T,wn).call(this,{...r,text:Pc(`${r.text}${n}`)})},Ft=function(n){if(!d(this,nt))return;const s=d(this,Q).messagesById[d(this,nt)];(s==null?void 0:s.kind)==="assistant"&&y(this,T,wn).call(this,{...s,status:n}),C(this,nt,null)},kn=function(n){y(this,T,Me).call(this,{messagesById:{...d(this,Q).messagesById,[n.id]:n},messageOrder:[...d(this,Q).messageOrder,n.id]})},wn=function(n){y(this,T,Me).call(this,{messagesById:{...d(this,Q).messagesById,[n.id]:n}})},Me=function(n){const s={...d(this,Q),...n};C(this,Q,{...s,sendDisabled:s.lifecycle.status!=="ready"||s.run.status==="running"||s.run.status==="cancelling",cancelDisabled:!(s.run.status==="running"||s.run.status==="cancelling")||!s.run.canCancel}),this.dispatchEvent(new B("change"))},fh=function(n){const s=d(this,St);return!d(this,Be)||!s||!(d(this,Ve)==="single_session"?d(this,xt)||!d(this,Et).has(s):!d(this,Et).has(s))?n:(C(this,xt,!1),d(this,Et).add(s),["[Television workspace context]","This chat session is coming from a Television client in the workspace below.",`workspace_id: ${d(this,Be).workspaceID}`,`workspace_name: ${d(this,Be).workspaceName??""}`,"When the user asks to inspect or change Television state with the tv CLI, use this workspace ID with the --workspace argument.","[/Television workspace context]","",n].join(`
|
|
40
|
-
`))},bn=function(n){const s=`${n}-${d(this,Dn)}`;return C(this,Dn,d(this,Dn)+1),s},mo=function(n){for(const s of d(this,Q).messageOrder){const r=d(this,Q).messagesById[s];if((r==null?void 0:r.kind)==="tool_call"&&r.toolCallId===n)return r}return null},vo=function(){if(!d(this,qt))throw new Error("ACP session is not ready");return d(this,qt)},xr=function(){if(!d(this,ut))throw new Error("ACP connection is not ready");return d(this,ut)},gh=function(){var s;if(d(this,Ve)==="single_session")return`${rh}-${(d(this,pt).clientGUID??"default-client").toLowerCase()}`;const n=(s=d(this,Be))==null?void 0:s.workspaceID;if(!n)throw new Error("Workspace context is required for per-workspace session mode");return Rc(d(this,Ve),n,d(this,pt).clientGUID??"default-client")},Ds=new WeakMap,Ls=new WeakMap,_o=function(){C(this,ut,null),C(this,Pn,null),C(this,ht,null),C(this,Gt,null),C(this,qt,null),C(this,St,null),d(this,ft)&&(d(this,ft).removeEventListener("close",d(this,Ds)),d(this,ft).removeEventListener("error",d(this,Ls)),d(this,ft).close(),C(this,ft,null))},Sn=function(n){d(this,Yt)||d(this,Q).lifecycle.status==="disconnected"||(y(this,T,Ft).call(this,"error"),y(this,T,_o).call(this),y(this,T,Me).call(this,{lifecycle:{status:"disconnected",...n?{error:n}:{}},run:{status:"idle",stopReason:null,canCancel:!1,error:null}}))},mh=function(){C(this,nt,null),C(this,dt,null),C(this,Dn,1),y(this,T,Me).call(this,{run:{status:"idle",stopReason:null,canCancel:!1,error:null},messagesById:{},messageOrder:[]})},vh=function(){return d(this,Q).lifecycle.status==="disconnected"};function Bw(){return{lifecycle:{status:"connecting"},run:{status:"idle",stopReason:null,canCancel:!1,error:null},messagesById:{},messageOrder:[],sendDisabled:!0,cancelDisabled:!0}}function Rc(e,t,n){return e==="single_session"?`${rh}-${n.toLowerCase()}`:`agent:main:television-${n.toLowerCase()}-${t.toLowerCase()}`}function _h(e){return e.replace(/^(?:\s*\n)+/,"")}function Pc(e){let t=e;return t=t.replace(Nw,""),t=t.replace(Ww,""),t=t.replace(Fw,""),t=_h(t),t}function Vw(e){let t=e;return t=t.replace(Uw,""),t=_h(t),t}function Gw(e){return!e||e.length===0?"":e.flatMap(t=>t.type==="content"&&t.content.type==="text"?[t.content.text]:[]).join("")}async function qw(e){const t=e.createSocket(Yw(e.serverURL,e.token));let n=!1,s,r;const i=new Promise((c,l)=>{s=c,r=l}),o=new ReadableStream({start(c){let l=!1;const h=()=>{t.send(JSON.stringify({type:"acp-bridge-connect"}))},f=E=>{const x=Kw(E);if(!x)return;let z;try{z=JSON.parse(x)}catch(K){const Z=K instanceof Error?K:new Error(String(K));r(Z),c.error(Z);return}switch(z.type){case"acp-bridge-status":if(z.status==="ready"){n||(n=!0,s());return}if(z.status==="error"||z.status==="exited"){const K=new Error(z.error??`ACP bridge ${z.status}`);n||r(K),c.error(K)}return;case"acp-bridge-message":c.enqueue(z.message);return}},w=()=>{var x;if(l)return;l=!0;const E=new Error("ACP bridge websocket closed");n||r(E),(x=e.onDisconnect)==null||x.call(e,E),c.close()},v=()=>{var x;if(l)return;l=!0;const E=new Error("ACP bridge websocket error");n||r(E),(x=e.onDisconnect)==null||x.call(e,E),c.error(E)};t.addEventListener("open",h),t.addEventListener("message",f),t.addEventListener("close",w),t.addEventListener("error",v)}}),a=new WritableStream({async write(c){await i,t.send(JSON.stringify({type:"acp-bridge-message",message:c}))},close(){t.close()},abort(){t.close()}});return await i,{stream:{readable:o,writable:a},socket:t}}function Kw(e){if(typeof e=="string")return e;if(e instanceof Uint8Array)return new TextDecoder().decode(e);if(typeof Buffer<"u"&&e instanceof Buffer)return e.toString("utf8");if(typeof e=="object"&&e!==null&&"data"in e){const t=e.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 Yw(e,t){const n=new URL(e);return n.protocol=n.protocol==="https:"?"wss:":"ws:",n.pathname="/ws",n.search="",n.searchParams.set("token",t),n.hash="",n.toString()}function mr(e){return e instanceof Error?e.message:String(e)}const Dc="television.acpClientGUID";class Xw extends ln{constructor(n){super();m(this,"workspaceService");m(this,"services",new Map);m(this,"options");m(this,"sessionMode");m(this,"clientGUID");m(this,"activeService",null);m(this,"handleWorkspaceChange",()=>{this.syncActiveService()});this.workspaceService=n.workspaceService,this.sessionMode=n.sessionMode??"single_session",this.options={serverURL:n.serverURL,token:n.token,...n.createSocket?{createSocket:n.createSocket}:{},...n.sessionMode?{sessionMode:n.sessionMode}:{}},this.clientGUID=n.clientGUID??Jw(n.storage??window.localStorage),this.workspaceService.addEventListener("change",this.handleWorkspaceChange),this.syncActiveService()}getActiveService(){return this.activeService}dispose(){this.workspaceService.removeEventListener("change",this.handleWorkspaceChange);for(const n of this.services.values())n.dispose();this.services.clear(),this.activeService=null}syncActiveService(){const n=this.workspaceService.activeWorkspace,s=n?this.getServiceForWorkspace(n):null;this.activeService!==s&&(this.activeService=s,this.dispatchEvent(new B("change")))}getServiceForWorkspace(n){const s=this.sessionMode==="single_session"?"single_session":n.id;let r=this.services.get(s);return r||(r=new Hw({...this.options,sessionMode:this.sessionMode,clientGUID:this.clientGUID}),this.services.set(s,r)),r.setWorkspaceContext({workspaceID:n.id,workspaceName:n.name}),r}}function Jw(e){const t=e.getItem(Dc);if(t)return t;const n=en().toLowerCase();return e.setItem(Dc,n),n}const Qw="serverURL",eb="token",tb="mode",nb="electron";function yh(e=window.location.search,t=window.location.origin){const s=new URLSearchParams(e).get(Qw);return s?new URL(s).origin:new URL(t).origin}function kh(e=window.location.search){return new URLSearchParams(e).get(eb)}function wh(e=window.location.search){return new URLSearchParams(e).get(tb)===nb}/**
|
|
41
|
-
* @license
|
|
42
|
-
* Copyright 2017 Google LLC
|
|
43
|
-
* SPDX-License-Identifier: BSD-3-Clause
|
|
44
|
-
*/const _s=globalThis,Lc=e=>e,Fr=_s.trustedTypes,Mc=Fr?Fr.createPolicy("lit-html",{createHTML:e=>e}):void 0,bh="$lit$",wt=`lit$${Math.random().toFixed(9).slice(2)}$`,Sh="?"+wt,sb=`<${Sh}>`,rn=document,xs=()=>rn.createComment(""),Es=e=>e===null||typeof e!="object"&&typeof e!="function",sa=Array.isArray,rb=e=>sa(e)||typeof(e==null?void 0:e[Symbol.iterator])=="function",Ni=`[
|
|
45
|
-
\f\r]`,ts=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,Oc=/-->/g,Nc=/>/g,Ot=RegExp(`>|${Ni}(?:([^\\s"'>=/]+)(${Ni}*=${Ni}*(?:[^
|
|
46
|
-
\f\r"'\`<>=]|("|')|))|$)`,"g"),Wc=/'/g,Fc=/"/g,xh=/^(?:script|style|textarea|title)$/i,ib=e=>(t,...n)=>({_$litType$:e,strings:t,values:n}),O=ib(1),jn=Symbol.for("lit-noChange"),de=Symbol.for("lit-nothing"),Uc=new WeakMap,Vt=rn.createTreeWalker(rn,129);function Eh(e,t){if(!sa(e)||!e.hasOwnProperty("raw"))throw Error("invalid template strings array");return Mc!==void 0?Mc.createHTML(t):t}const ob=(e,t)=>{const n=e.length-1,s=[];let r,i=t===2?"<svg>":t===3?"<math>":"",o=ts;for(let a=0;a<n;a++){const c=e[a];let l,h,f=-1,w=0;for(;w<c.length&&(o.lastIndex=w,h=o.exec(c),h!==null);)w=o.lastIndex,o===ts?h[1]==="!--"?o=Oc:h[1]!==void 0?o=Nc:h[2]!==void 0?(xh.test(h[2])&&(r=RegExp("</"+h[2],"g")),o=Ot):h[3]!==void 0&&(o=Ot):o===Ot?h[0]===">"?(o=r??ts,f=-1):h[1]===void 0?f=-2:(f=o.lastIndex-h[2].length,l=h[1],o=h[3]===void 0?Ot:h[3]==='"'?Fc:Wc):o===Fc||o===Wc?o=Ot:o===Oc||o===Nc?o=ts:(o=Ot,r=void 0);const v=o===Ot&&e[a+1].startsWith("/>")?" ":"";i+=o===ts?c+sb:f>=0?(s.push(l),c.slice(0,f)+bh+c.slice(f)+wt+v):c+wt+(f===-2?a:v)}return[Eh(e,i+(e[n]||"<?>")+(t===2?"</svg>":t===3?"</math>":"")),s]};class As{constructor({strings:t,_$litType$:n},s){let r;this.parts=[];let i=0,o=0;const a=t.length-1,c=this.parts,[l,h]=ob(t,n);if(this.el=As.createElement(l,s),Vt.currentNode=this.el.content,n===2||n===3){const f=this.el.content.firstChild;f.replaceWith(...f.childNodes)}for(;(r=Vt.nextNode())!==null&&c.length<a;){if(r.nodeType===1){if(r.hasAttributes())for(const f of r.getAttributeNames())if(f.endsWith(bh)){const w=h[o++],v=r.getAttribute(f).split(wt),E=/([.?@])?(.*)/.exec(w);c.push({type:1,index:i,name:E[2],strings:v,ctor:E[1]==="."?cb:E[1]==="?"?lb:E[1]==="@"?ub:di}),r.removeAttribute(f)}else f.startsWith(wt)&&(c.push({type:6,index:i}),r.removeAttribute(f));if(xh.test(r.tagName)){const f=r.textContent.split(wt),w=f.length-1;if(w>0){r.textContent=Fr?Fr.emptyScript:"";for(let v=0;v<w;v++)r.append(f[v],xs()),Vt.nextNode(),c.push({type:2,index:++i});r.append(f[w],xs())}}}else if(r.nodeType===8)if(r.data===Sh)c.push({type:2,index:i});else{let f=-1;for(;(f=r.data.indexOf(wt,f+1))!==-1;)c.push({type:7,index:i}),f+=wt.length-1}i++}}static createElement(t,n){const s=rn.createElement("template");return s.innerHTML=t,s}}function Hn(e,t,n=e,s){var o,a;if(t===jn)return t;let r=s!==void 0?(o=n._$Co)==null?void 0:o[s]:n._$Cl;const i=Es(t)?void 0:t._$litDirective$;return(r==null?void 0:r.constructor)!==i&&((a=r==null?void 0:r._$AO)==null||a.call(r,!1),i===void 0?r=void 0:(r=new i(e),r._$AT(e,n,s)),s!==void 0?(n._$Co??(n._$Co=[]))[s]=r:n._$Cl=r),r!==void 0&&(t=Hn(e,r._$AS(e,t.values),r,s)),t}class ab{constructor(t,n){this._$AV=[],this._$AN=void 0,this._$AD=t,this._$AM=n}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(t){const{el:{content:n},parts:s}=this._$AD,r=((t==null?void 0:t.creationScope)??rn).importNode(n,!0);Vt.currentNode=r;let i=Vt.nextNode(),o=0,a=0,c=s[0];for(;c!==void 0;){if(o===c.index){let l;c.type===2?l=new ra(i,i.nextSibling,this,t):c.type===1?l=new c.ctor(i,c.name,c.strings,this,t):c.type===6&&(l=new hb(i,this,t)),this._$AV.push(l),c=s[++a]}o!==(c==null?void 0:c.index)&&(i=Vt.nextNode(),o++)}return Vt.currentNode=rn,r}p(t){let n=0;for(const s of this._$AV)s!==void 0&&(s.strings!==void 0?(s._$AI(t,s,n),n+=s.strings.length-2):s._$AI(t[n])),n++}}let ra=class Ah{get _$AU(){var t;return((t=this._$AM)==null?void 0:t._$AU)??this._$Cv}constructor(t,n,s,r){this.type=2,this._$AH=de,this._$AN=void 0,this._$AA=t,this._$AB=n,this._$AM=s,this.options=r,this._$Cv=(r==null?void 0:r.isConnected)??!0}get parentNode(){let t=this._$AA.parentNode;const n=this._$AM;return n!==void 0&&(t==null?void 0:t.nodeType)===11&&(t=n.parentNode),t}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(t,n=this){t=Hn(this,t,n),Es(t)?t===de||t==null||t===""?(this._$AH!==de&&this._$AR(),this._$AH=de):t!==this._$AH&&t!==jn&&this._(t):t._$litType$!==void 0?this.$(t):t.nodeType!==void 0?this.T(t):rb(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!==de&&Es(this._$AH)?this._$AA.nextSibling.data=t:this.T(rn.createTextNode(t)),this._$AH=t}$(t){var i;const{values:n,_$litType$:s}=t,r=typeof s=="number"?this._$AC(t):(s.el===void 0&&(s.el=As.createElement(Eh(s.h,s.h[0]),this.options)),s);if(((i=this._$AH)==null?void 0:i._$AD)===r)this._$AH.p(n);else{const o=new ab(r,this),a=o.u(this.options);o.p(n),this.T(a),this._$AH=o}}_$AC(t){let n=Uc.get(t.strings);return n===void 0&&Uc.set(t.strings,n=new As(t)),n}k(t){sa(this._$AH)||(this._$AH=[],this._$AR());const n=this._$AH;let s,r=0;for(const i of t)r===n.length?n.push(s=new Ah(this.O(xs()),this.O(xs()),this,this.options)):s=n[r],s._$AI(i),r++;r<n.length&&(this._$AR(s&&s._$AB.nextSibling,r),n.length=r)}_$AR(t=this._$AA.nextSibling,n){var s;for((s=this._$AP)==null?void 0:s.call(this,!1,!0,n);t!==this._$AB;){const r=Lc(t).nextSibling;Lc(t).remove(),t=r}}setConnected(t){var n;this._$AM===void 0&&(this._$Cv=t,(n=this._$AP)==null||n.call(this,t))}},di=class{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(t,n,s,r,i){this.type=1,this._$AH=de,this._$AN=void 0,this.element=t,this.name=n,this._$AM=r,this.options=i,s.length>2||s[0]!==""||s[1]!==""?(this._$AH=Array(s.length-1).fill(new String),this.strings=s):this._$AH=de}_$AI(t,n=this,s,r){const i=this.strings;let o=!1;if(i===void 0)t=Hn(this,t,n,0),o=!Es(t)||t!==this._$AH&&t!==jn,o&&(this._$AH=t);else{const a=t;let c,l;for(t=i[0],c=0;c<i.length-1;c++)l=Hn(this,a[s+c],n,c),l===jn&&(l=this._$AH[c]),o||(o=!Es(l)||l!==this._$AH[c]),l===de?t=de:t!==de&&(t+=(l??"")+i[c+1]),this._$AH[c]=l}o&&!r&&this.j(t)}j(t){t===de?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,t??"")}},cb=class extends di{constructor(){super(...arguments),this.type=3}j(t){this.element[this.name]=t===de?void 0:t}},lb=class extends di{constructor(){super(...arguments),this.type=4}j(t){this.element.toggleAttribute(this.name,!!t&&t!==de)}},ub=class extends di{constructor(t,n,s,r,i){super(t,n,s,r,i),this.type=5}_$AI(t,n=this){if((t=Hn(this,t,n,0)??de)===jn)return;const s=this._$AH,r=t===de&&s!==de||t.capture!==s.capture||t.once!==s.once||t.passive!==s.passive,i=t!==de&&(s===de||r);r&&this.element.removeEventListener(this.name,this,s),i&&this.element.addEventListener(this.name,this,t),this._$AH=t}handleEvent(t){var n;typeof this._$AH=="function"?this._$AH.call(((n=this.options)==null?void 0:n.host)??this.element,t):this._$AH.handleEvent(t)}};class hb{constructor(t,n,s){this.element=t,this.type=6,this._$AN=void 0,this._$AM=n,this.options=s}get _$AU(){return this._$AM._$AU}_$AI(t){Hn(this,t)}}const Wi=_s.litHtmlPolyfillSupport;Wi==null||Wi(As,ra),(_s.litHtmlVersions??(_s.litHtmlVersions=[])).push("3.3.2");const ue=(e,t,n)=>{const s=t;let r=s._$litPart$;return r===void 0&&(s._$litPart$=r=new ra(t.insertBefore(xs(),null),null,void 0,{})),r._$AI(e),r};/**
|
|
47
|
-
* @license
|
|
48
|
-
* Copyright 2017 Google LLC
|
|
49
|
-
* SPDX-License-Identifier: BSD-3-Clause
|
|
50
|
-
*/const db={CHILD:2},Th=e=>(...t)=>({_$litDirective$:e,values:t});class pb{constructor(t){}get _$AU(){return this._$AM._$AU}_$AT(t,n,s){this._$Ct=t,this._$AM=n,this._$Ci=s}_$AS(t,n){return this.update(t,n)}update(t,n){return this.render(...n)}}/**
|
|
51
|
-
* @license
|
|
52
|
-
* Copyright 2017 Google LLC
|
|
53
|
-
* SPDX-License-Identifier: BSD-3-Clause
|
|
54
|
-
*/class Ur extends pb{constructor(t){if(super(t),this.it=de,t.type!==db.CHILD)throw Error(this.constructor.directiveName+"() can only be used in child bindings")}render(t){if(t===de||t==null)return this._t=void 0,this.it=t;if(t===jn)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 n=[t];return n.raw=n,this._t={_$litType$:this.constructor.resultType,strings:n,values:[]}}}Ur.directiveName="unsafeHTML",Ur.resultType=1;const fb=Th(Ur);/**
|
|
55
|
-
* @license
|
|
56
|
-
* Copyright 2017 Google LLC
|
|
57
|
-
* SPDX-License-Identifier: BSD-3-Clause
|
|
58
|
-
*/class yo extends Ur{}yo.directiveName="unsafeSVG",yo.resultType=2;const gb=Th(yo),mb={size:16,color:"currentColor",weight:"regular"};function vb(e){return typeof e=="string"?{regular:e}:e}function Js(e,t="0 0 256 256"){const n=vb(e);return s=>{const{size:r,color:i,weight:o}={...mb,...s},a=n[o]??n.regular;return O`<svg
|
|
59
|
-
xmlns="http://www.w3.org/2000/svg"
|
|
60
|
-
data-ui-icon=""
|
|
61
|
-
width="${r}"
|
|
62
|
-
height="${r}"
|
|
63
|
-
viewBox="${t}"
|
|
64
|
-
fill="${i}"
|
|
65
|
-
>${gb(a)}</svg>`}}const _b=new Map,Fi=new Set;var Ln,Er;const wa=class wa extends HTMLElement{constructor(){super(...arguments);I(this,Ln)}connectedCallback(){y(this,Ln,Er).call(this)}disconnectedCallback(){Fi.delete(this)}attributeChangedCallback(){y(this,Ln,Er).call(this)}refresh(){y(this,Ln,Er).call(this)}get name(){return this.getAttribute("name")}get size(){const n=this.getAttribute("size");if(n===null)return;const s=Number(n);return Number.isFinite(s)?s:void 0}get weight(){const n=this.getAttribute("weight");return n==="bold"||n==="regular"?n:void 0}};Ln=new WeakSet,Er=function(){const n=this.name?_b.get(this.name):null;if(!n){this.name&&Fi.add(this),ue(null,this);return}Fi.delete(this),ue(n({size:this.size,weight:this.weight}),this)},wa.observedAttributes=["name","size","weight"];let ko=wa;customElements.get("icon-element")||customElements.define("icon-element",ko);const Ih=Js('<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"/>'),yb=Js('<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"/>'),kb=Js({regular:'<path d="M231.87,114l-168-95.89A16,16,0,0,0,40.92,37.34L71.55,128,40.92,218.67A16,16,0,0,0,56,240a16.15,16.15,0,0,0,7.93-2.1l167.92-96.05a16,16,0,0,0,.05-27.89ZM56,224a.56.56,0,0,0,0-.12L85.74,136H144a8,8,0,0,0,0-16H85.74L56.06,32.16A.46.46,0,0,0,56,32l168,95.83Z"/>',bold:'<path d="M233.86,110.48,65.8,14.58A20,20,0,0,0,37.15,38.64L67.33,128,37.15,217.36A20,20,0,0,0,56,244a20.1,20.1,0,0,0,9.81-2.58l.09-.06,168-96.07a20,20,0,0,0,0-34.81ZM63.19,215.26,88.61,140H144a12,12,0,0,0,0-24H88.61L63.18,40.72l152.76,87.17Z"/>'}),Zr=Js('<path d="M213.66,101.66l-80,80a8,8,0,0,1-11.32,0l-80-80A8,8,0,0,1,53.66,90.34L128,164.69l74.34-74.35a8,8,0,0,1,11.32,11.32Z"/>'),wb=Js('<path d="M128,80a48,48,0,1,0,48,48A48.05,48.05,0,0,0,128,80Zm0,80a32,32,0,1,1,32-32A32,32,0,0,1,128,160Zm88-29.84q.06-2.16,0-4.32l14.92-18.64a8,8,0,0,0,1.48-7.06,107.21,107.21,0,0,0-10.88-26.25,8,8,0,0,0-6-3.93l-23.72-2.64q-1.48-1.56-3-3L186,40.54a8,8,0,0,0-3.94-6,107.71,107.71,0,0,0-26.25-10.87,8,8,0,0,0-7.06,1.49L130.16,40Q128,40,125.84,40L107.2,25.11a8,8,0,0,0-7.06-1.48A107.6,107.6,0,0,0,73.89,34.51a8,8,0,0,0-3.93,6L67.32,64.27q-1.56,1.49-3,3L40.54,70a8,8,0,0,0-6,3.94,107.71,107.71,0,0,0-10.87,26.25,8,8,0,0,0,1.49,7.06L40,125.84Q40,128,40,130.16L25.11,148.8a8,8,0,0,0-1.48,7.06,107.21,107.21,0,0,0,10.88,26.25,8,8,0,0,0,6,3.93l23.72,2.64q1.49,1.56,3,3L70,215.46a8,8,0,0,0,3.94,6,107.71,107.71,0,0,0,26.25,10.87,8,8,0,0,0,7.06-1.49L125.84,216q2.16.06,4.32,0l18.64,14.92a8,8,0,0,0,7.06,1.48,107.21,107.21,0,0,0,26.25-10.88,8,8,0,0,0,3.93-6l2.64-23.72q1.56-1.48,3-3L215.46,186a8,8,0,0,0,6-3.94,107.71,107.71,0,0,0,10.87-26.25,8,8,0,0,0-1.49-7.06Zm-16.1-6.5a73.93,73.93,0,0,1,0,8.68,8,8,0,0,0,1.74,5.48l14.19,17.73a91.57,91.57,0,0,1-6.23,15L187,173.11a8,8,0,0,0-5.1,2.64,74.11,74.11,0,0,1-6.14,6.14,8,8,0,0,0-2.64,5.1l-2.51,22.58a91.32,91.32,0,0,1-15,6.23l-17.74-14.19a8,8,0,0,0-5-1.75h-.48a73.93,73.93,0,0,1-8.68,0,8,8,0,0,0-5.48,1.74L100.45,215.8a91.57,91.57,0,0,1-15-6.23L82.89,187a8,8,0,0,0-2.64-5.1,74.11,74.11,0,0,1-6.14-6.14,8,8,0,0,0-5.1-2.64L46.43,170.6a91.32,91.32,0,0,1-6.23-15l14.19-17.74a8,8,0,0,0,1.74-5.48,73.93,73.93,0,0,1,0-8.68,8,8,0,0,0-1.74-5.48L40.2,100.45a91.57,91.57,0,0,1,6.23-15L69,82.89a8,8,0,0,0,5.1-2.64,74.11,74.11,0,0,1,6.14-6.14A8,8,0,0,0,82.89,69L85.4,46.43a91.32,91.32,0,0,1,15-6.23l17.74,14.19a8,8,0,0,0,5.48,1.74,73.93,73.93,0,0,1,8.68,0,8,8,0,0,0,5.48-1.74L155.55,40.2a91.57,91.57,0,0,1,15,6.23L173.11,69a8,8,0,0,0,2.64,5.1,74.11,74.11,0,0,1,6.14,6.14,8,8,0,0,0,5.1,2.64l22.58,2.51a91.32,91.32,0,0,1,6.23,15l-14.19,17.74A8,8,0,0,0,199.87,123.66Z"/>');class Ch extends Event{constructor(t){super("dropdown-item-select",{bubbles:!0,composed:!0}),this.value=t}}class bb extends Event{constructor(t){super("select",{bubbles:!0,composed:!0}),this.value=t}}var Ue,Ge,At,Mn,J,Ms,L,zh,ps,$h,Rh,bo,So,Ar,Ut,Xt,Os,Ns,Ws,qr,Ph,Dh,xo,fs,Eo,lt;const ba=class ba extends HTMLElement{constructor(){super();I(this,L);I(this,Ue,!1);I(this,Ge,null);I(this,At,null);I(this,Mn);I(this,J,null);I(this,Ms,new MutationObserver(n=>y(this,L,Ph).call(this,n)));I(this,Xt,()=>{y(this,L,Ar).call(this,!d(this,Ue))});I(this,Os,n=>{n.key!=="Enter"&&n.key!==" "||(n.preventDefault(),d(this,Xt).call(this))});I(this,Ns,n=>{d(this,Ue)&&(n.composedPath().includes(this)||y(this,L,Ar).call(this,!1))});I(this,Ws,n=>{n instanceof Ch&&(n.stopPropagation(),C(this,Ue,!1),y(this,L,ps).call(this,n.value),y(this,L,lt).call(this),this.dispatchEvent(new bb(n.value)))});I(this,qr,()=>{y(this,L,xo).call(this)});C(this,Mn,this.attachShadow({mode:"open"}))}connectedCallback(){this.addEventListener("dropdown-item-select",d(this,Ws)),document.addEventListener("click",d(this,Ns),!0),y(this,L,zh).call(this),d(this,Ms).observe(this,{childList:!0,subtree:!0,characterData:!0,attributes:!0,attributeFilter:["selected","value","slot"]}),y(this,L,lt).call(this)}disconnectedCallback(){this.removeEventListener("dropdown-item-select",d(this,Ws)),document.removeEventListener("click",d(this,Ns),!0),d(this,Ms).disconnect(),y(this,L,Eo).call(this)}attributeChangedCallback(){y(this,L,lt).call(this)}get title(){return this.getAttribute("title")??""}get value(){return d(this,Ge)}set value(n){n===null?(y(this,L,Ut).call(this,null,null),y(this,L,$h).call(this)):y(this,L,ps).call(this,n),y(this,L,lt).call(this)}close(){y(this,L,Ar).call(this,!1)}};Ue=new WeakMap,Ge=new WeakMap,At=new WeakMap,Mn=new WeakMap,J=new WeakMap,Ms=new WeakMap,L=new WeakSet,zh=function(){var s;const n=this.querySelector("dropdown-item[selected]");n&&y(this,L,Ut).call(this,n.value,((s=n.textContent)==null?void 0:s.trim())??null)},ps=function(n){var s;for(const r of d(this,L,bo))r.value===n?(y(this,L,Ut).call(this,n,((s=r.textContent)==null?void 0:s.trim())??null),r.hasAttribute("selected")||r.setAttribute("selected","")):r.hasAttribute("selected")&&r.removeAttribute("selected")},$h=function(){const n=this.querySelectorAll("dropdown-item[selected]");for(const s of n)s.removeAttribute("selected")},Rh=function(n){for(const s of d(this,L,bo))if(s.value===n)return s;return null},bo=function(){return this.querySelectorAll("dropdown-item")},So=function(){return d(this,At)??this.title},Ar=function(n){d(this,Ue)!==n&&(C(this,Ue,n),y(this,L,lt).call(this))},Ut=function(n,s){C(this,Ge,n),C(this,At,s)},Xt=new WeakMap,Os=new WeakMap,Ns=new WeakMap,Ws=new WeakMap,qr=new WeakMap,Ph=function(n){n.every(r=>r.target instanceof Element?r.target.closest('[slot="trigger"]')!==null:!1)||y(this,L,Dh).call(this)},Dh=function(){var s,r;const n=this.querySelector("dropdown-item[selected]");if(n){const i=n.value,o=((s=n.textContent)==null?void 0:s.trim())??null,a=d(this,Ge)!==i||d(this,At)!==o;y(this,L,Ut).call(this,i,o),y(this,L,ps).call(this,i),a?y(this,L,lt).call(this):y(this,L,fs).call(this);return}if(d(this,Ge)!==null){const i=y(this,L,Rh).call(this,d(this,Ge));if(i){const o=((r=i.textContent)==null?void 0:r.trim())??null,a=d(this,At)!==o;y(this,L,Ut).call(this,d(this,Ge),o),y(this,L,ps).call(this,d(this,Ge)),a?y(this,L,lt).call(this):y(this,L,fs).call(this);return}}if(d(this,Ge)!==null||d(this,At)!==null){y(this,L,Ut).call(this,null,null),y(this,L,lt).call(this);return}y(this,L,fs).call(this)},xo=function(){const n=d(this,Mn).querySelector('slot[name="trigger"]'),s=n instanceof HTMLSlotElement?n.assignedElements({flatten:!0})[0]??null:null;d(this,J)!==s&&(y(this,L,Eo).call(this),C(this,J,s),d(this,J)&&(d(this,J).addEventListener("click",d(this,Xt)),d(this,J)instanceof HTMLButtonElement?d(this,J).hasAttribute("type")||(d(this,J).type="button"):(d(this,J).hasAttribute("role")||d(this,J).setAttribute("role","button"),d(this,J).hasAttribute("tabindex")||(d(this,J).tabIndex=0),d(this,J).addEventListener("keydown",d(this,Os))))),y(this,L,fs).call(this)},fs=function(){d(this,J)&&(d(this,J).setAttribute("data-dropdown-trigger",""),d(this,J).setAttribute("aria-haspopup","listbox"),d(this,J).setAttribute("aria-expanded",d(this,Ue)?"true":"false"),ue(O`
|
|
66
|
-
<span class="trigger-label" data-dropdown-trigger-label>${d(this,L,So)}</span>
|
|
67
|
-
<span class="trigger-icon" data-dropdown-trigger-icon aria-hidden="true">
|
|
68
|
-
${Zr({size:14})}
|
|
69
|
-
</span>
|
|
70
|
-
`,d(this,J)))},Eo=function(){d(this,J)&&(d(this,J).removeEventListener("click",d(this,Xt)),d(this,J).removeEventListener("keydown",d(this,Os)),d(this,J).removeAttribute("data-dropdown-trigger"),d(this,J).removeAttribute("aria-haspopup"),d(this,J).removeAttribute("aria-expanded"),C(this,J,null))},lt=function(){this.toggleAttribute("open",d(this,Ue)),ue(O`
|
|
71
|
-
<slot name="trigger" @slotchange=${d(this,qr)}>
|
|
72
|
-
<button
|
|
73
|
-
class="fallback-trigger"
|
|
74
|
-
part="trigger"
|
|
75
|
-
type="button"
|
|
76
|
-
aria-haspopup="listbox"
|
|
77
|
-
aria-expanded=${d(this,Ue)?"true":"false"}
|
|
78
|
-
@click=${d(this,Xt)}
|
|
79
|
-
>
|
|
80
|
-
<span class="trigger-label" part="trigger-label">${d(this,L,So)}</span>
|
|
81
|
-
<span class="trigger-icon" part="trigger-icon" aria-hidden="true">
|
|
82
|
-
${Zr({size:14})}
|
|
83
|
-
</span>
|
|
84
|
-
</button>
|
|
85
|
-
</slot>
|
|
86
|
-
${d(this,Ue)?O`
|
|
87
|
-
<div class="panel" part="panel" role="listbox">
|
|
88
|
-
<slot></slot>
|
|
89
|
-
</div>
|
|
90
|
-
`:null}
|
|
91
|
-
`,d(this,Mn)),queueMicrotask(()=>y(this,L,xo).call(this))},ba.observedAttributes=["title"];let wo=ba;class Sb extends HTMLElement{}class xb extends HTMLElement{}class Eb extends HTMLElement{}var cn,To,Lh,Fs,Us;const Sa=class Sa extends HTMLElement{constructor(){super(...arguments);I(this,cn);I(this,Fs,()=>{this.action||y(this,cn,Lh).call(this)});I(this,Us,n=>{n.key!=="Enter"&&n.key!==" "||(n.preventDefault(),this.click())})}connectedCallback(){this.hasAttribute("role")||this.setAttribute("role","option"),this.hasAttribute("tabindex")||(this.tabIndex=0),this.addEventListener("click",d(this,Fs)),this.addEventListener("keydown",d(this,Us)),y(this,cn,To).call(this)}disconnectedCallback(){this.removeEventListener("click",d(this,Fs)),this.removeEventListener("keydown",d(this,Us))}attributeChangedCallback(){y(this,cn,To).call(this)}get value(){return this.getAttribute("value")??""}get selected(){return this.hasAttribute("selected")}get action(){return this.hasAttribute("action")}};cn=new WeakSet,To=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")},Lh=function(){this.dispatchEvent(new Ch(this.value))},Fs=new WeakMap,Us=new WeakMap,Sa.observedAttributes=["action","selected","value"];let Ao=Sa;customElements.get("dropdown-menu")||customElements.define("dropdown-menu",wo);customElements.get("dropdown-group")||customElements.define("dropdown-group",Sb);customElements.get("dropdown-label")||customElements.define("dropdown-label",xb);customElements.get("dropdown-divider")||customElements.define("dropdown-divider",Eb);customElements.get("dropdown-item")||customElements.define("dropdown-item",Ao);class Ab extends Event{constructor(){super("close",{bubbles:!0,composed:!0})}}var Zs,Rt,Co,Kr,js,zo;const xa=class xa extends HTMLElement{constructor(){super();I(this,Rt);I(this,Zs);I(this,Kr,n=>{n.target===n.currentTarget&&y(this,Rt,Co).call(this)});I(this,js,n=>{this.open&&n.key==="Escape"&&y(this,Rt,Co).call(this)});C(this,Zs,this.attachShadow({mode:"open"}))}connectedCallback(){document.addEventListener("keydown",d(this,js)),y(this,Rt,zo).call(this)}disconnectedCallback(){document.removeEventListener("keydown",d(this,js))}attributeChangedCallback(){y(this,Rt,zo).call(this)}get open(){return this.hasAttribute("open")}};Zs=new WeakMap,Rt=new WeakSet,Co=function(){this.dispatchEvent(new Ab)},Kr=new WeakMap,js=new WeakMap,zo=function(){ue(O`
|
|
92
|
-
${this.open?O`
|
|
93
|
-
<div class="backdrop" part="backdrop" @click=${d(this,Kr)}>
|
|
94
|
-
<slot></slot>
|
|
95
|
-
</div>
|
|
96
|
-
`:null}
|
|
97
|
-
`,d(this,Zs))},xa.observedAttributes=["open"];let Io=xa;customElements.get("modal-overlay")||customElements.define("modal-overlay",Io);class Mh extends Event{constructor(){super("close",{bubbles:!0,composed:!0})}}class Tb extends HTMLElement{}var Hs,De,Bs,ne,Tr,Ir,Oh,Nh,gs,Wh,Vs,Ro;const Ea=class Ea extends HTMLElement{constructor(){super();I(this,ne);I(this,Hs);I(this,De,[]);I(this,Bs,new MutationObserver(()=>y(this,ne,Wh).call(this)));I(this,Vs,n=>{const s=n.target;if(!(s instanceof Element))return;const r=s.closest("[data-navigate]");if(r){this.navigate(r.dataset.navigate??"");return}s.closest("[data-back]")&&this.back()});C(this,Hs,this.attachShadow({mode:"open"}))}connectedCallback(){this.addEventListener("click",d(this,Vs)),d(this,Bs).observe(this,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["id","title"]}),y(this,ne,gs).call(this)}disconnectedCallback(){this.removeEventListener("click",d(this,Vs)),d(this,Bs).disconnect(),C(this,De,[])}attributeChangedCallback(){y(this,ne,Ro).call(this)}get closable(){return this.hasAttribute("closable")}navigate(n){var i;const s=((i=d(this,ne,Tr))==null?void 0:i.id)??null;n===s||!y(this,ne,Ir).call(this,n)||(d(this,De).push(n),y(this,ne,gs).call(this))}back(){d(this,De).length<=1||(d(this,De).pop(),y(this,ne,gs).call(this))}};Hs=new WeakMap,De=new WeakMap,Bs=new WeakMap,ne=new WeakSet,Tr=function(){const n=d(this,De)[d(this,De).length-1]??null;return n?y(this,ne,Ir).call(this,n):null},Ir=function(n){const s=this.querySelectorAll("panel-page");for(const r of s)if(r.id===n)return r;return null},Oh=function(){if(C(this,De,d(this,De).filter(s=>y(this,ne,Ir).call(this,s)!==null)),d(this,De).length>0)return;const n=this.querySelector("panel-page");n!=null&&n.id&&C(this,De,[n.id])},Nh=function(){y(this,ne,Oh).call(this);const n=d(this,ne,Tr),s=this.querySelectorAll("panel-page");for(const r of s)r.hidden=r!==n},gs=function(){y(this,ne,Nh).call(this),y(this,ne,Ro).call(this)},Wh=function(){y(this,ne,gs).call(this)},Vs=new WeakMap,Ro=function(){const n=d(this,ne,Tr);ue(O`
|
|
98
|
-
<section class="panel" part="panel">
|
|
99
|
-
<header class="title-bar" part="header">
|
|
100
|
-
<div class="title-group" part="title-group">
|
|
101
|
-
${d(this,De).length>1?O`
|
|
102
|
-
<button
|
|
103
|
-
type="button"
|
|
104
|
-
class="title-button"
|
|
105
|
-
part="button back-button"
|
|
106
|
-
aria-label="Back"
|
|
107
|
-
@click=${()=>this.back()}
|
|
108
|
-
>
|
|
109
|
-
<span class="back-icon" part="icon back-icon">
|
|
110
|
-
${Zr({size:14})}
|
|
111
|
-
</span>
|
|
112
|
-
</button>
|
|
113
|
-
`:null}
|
|
114
|
-
<h2 class="title" part="title">${(n==null?void 0:n.getAttribute("title"))??""}</h2>
|
|
115
|
-
</div>
|
|
116
|
-
${this.closable?O`
|
|
117
|
-
<button
|
|
118
|
-
type="button"
|
|
119
|
-
class="title-button"
|
|
120
|
-
part="button close-button"
|
|
121
|
-
aria-label="Close"
|
|
122
|
-
@click=${()=>this.dispatchEvent(new Mh)}
|
|
123
|
-
>
|
|
124
|
-
<span class="close-icon" part="icon close-icon">${Ih({size:14})}</span>
|
|
125
|
-
</button>
|
|
126
|
-
`:null}
|
|
127
|
-
</header>
|
|
128
|
-
<slot></slot>
|
|
129
|
-
</section>
|
|
130
|
-
`,d(this,Hs))},Ea.observedAttributes=["closable"];let $o=Ea;customElements.get("panel-view")||customElements.define("panel-view",$o);customElements.get("panel-page")||customElements.define("panel-page",Tb);const Fh=rt();class Ib extends HTMLElement{constructor(){super(...arguments);m(this,"_artifact",null);m(this,"_artifactURL",null)}set artifact(n){this._artifact=n,this.render()}get artifact(){return this._artifact}set artifactURL(n){this._artifactURL=n,this.render()}get artifactURL(){return this._artifactURL}handleClose(){this._artifact&&this.dispatchEvent(new Fh("close-artifact",{artifactID:this._artifact.id,bubbles:!0,composed:!0}))}template(){const n=this._artifact;return O`
|
|
131
|
-
<header class="artifact-title-bar" drag-handle>
|
|
132
|
-
<span class="artifact-title">${n.title}</span>
|
|
133
|
-
<button
|
|
134
|
-
class="artifact-close-btn"
|
|
135
|
-
@click=${()=>this.handleClose()}
|
|
136
|
-
aria-label="Close"
|
|
137
|
-
>
|
|
138
|
-
${Ih({size:14})}
|
|
139
|
-
</button>
|
|
140
|
-
</header>
|
|
141
|
-
<div class="artifact-content">
|
|
142
|
-
<iframe
|
|
143
|
-
class="artifact-html-frame"
|
|
144
|
-
title=${this._artifact.title}
|
|
145
|
-
src=${this._artifactURL??"about:blank"}
|
|
146
|
-
sandbox="allow-scripts"
|
|
147
|
-
style="width: 100%; height: 100%; border: none;"
|
|
148
|
-
></iframe>
|
|
149
|
-
</div>
|
|
150
|
-
`}render(){this._artifact&&(this.setAttribute("type",this._artifact.type),ue(this.template(),this))}}customElements.define("artifact-view",Ib);const ve=e=>({type:"px",...e}),Se=e=>({type:"unit",...e}),vr=2,Cb=2;class zb{constructor(t){m(this,"basis");m(this,"min");m(this,"_gap");m(this,"_viewport");m(this,"_unit");this.basis=t.basis,this.min=t.min,this._viewport=t.viewport,this._gap=t.gap??ve({x:ce,y:ce});const n=this._viewport.x??Tt,s=this._viewport.y??In,r=this._gap.x??ce,i=this._gap.y??ce,o=Tt+r*Cb,a=n<=o,c=a?n-r*vr:Math.min(Tt,n-r*vr),l=a?s-i*vr:Math.min(In,s-i*vr),h=(c-r*(st-1))/st,f=(l-i*(We-1))/We,w=this.basis.x??0,v=this.basis.y??0,E=this.min.x??0,x=this.min.y??0;this._unit=ve(a?{x:Math.max(E,h),y:Math.max(x,f)}:{x:Math.max(E,Math.min(w,h)),y:Math.max(x,Math.min(v,f))})}get unit(){return this._unit}get viewport(){return this._viewport}get gap(){return this._gap}toUnits(t){return Se({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 n=this._unit.x??0,s=this._unit.y??0,r=this._gap.x??ce,i=this._gap.y??ce,o=t.x==null?void 0:t.x*n+Math.max(0,t.x-1)*r,a=t.y==null?void 0:t.y*s+Math.max(0,t.y-1)*i;return ve({x:o,y:a})}}const on=1e-4,vt=1e-6,$b=40,Rb=24;function Uh(e,t){return Math.max(0,e-t*2)}function Zh(e){const t=[0];for(const n of e)t.push((t[t.length-1]??0)+n);return t}function jh(e){const t=[0];for(let n=0;n<e.length;n+=1){const s=t[n]??0;t.push(s+e[n]+ce)}return t}function Hh(e,t,n){if(t<0||t>=e.length)return 0;let s=0,r=0;for(let i=t;i<e.length;i+=1){const o=e[i],a=r===0?o:s+ce+o;if(a>n+on)break;s=a,r+=1}return Math.max(1,r)}function Pb(e,t,n){if(t<0||t>=e.length)return 0;let s=0,r=0;for(let i=t;i>=0;i-=1){const o=e[i],a=r===0?o:s+ce+o;if(a>n+on)break;s=a,r+=1}return Math.max(1,r)}function Db(e,t){if(e.length===0)return 0;let n=0,s=0;for(let r=e.length-1;r>=0;r-=1){const i=e[r],o=s===0?i:n+ce+i;if(o>t+on)break;n=o,s+=1}return Math.max(1,s)}function ia(e,t){if(e.length===0)return 0;const n=Db(e,t);return Math.max(0,e.length-n)}function Zc(e,t,n){if(e.length===0)return 0;const s=Hh(e,t,n),r=Math.min(e.length,t+s);if(r<=t)return 0;const i=e.slice(t,r);return i.reduce((o,a)=>o+a,0)+Math.max(0,i.length-1)*ce}function Po(e,t,n){const s=e[t]??0;return n-s}function xn(e,t,n,s,r){if(e.length===0)return 0;const i=ia(e,r),o=t[i]??0,a=Math.max(0,Math.min(o,n));let c=0;for(let G=0;G<i;G+=1){const U=t[G]??0,Te=t[G+1]??U;if(a>=U&&a<=Te+on){c=G;break}c=G+1}const l=Math.min(c+1,i),h=t[c]??0,f=t[l]??h,w=Math.max(f-h,on),v=l===c?0:(a-h)/w,E=jh(e),x=Zc(e,c,r),z=Zc(e,l,r),K=(s-x)/2,Z=(s-z)/2,ye=Po(E,c,K),M=Po(E,l,Z);return ye+(M-ye)*v}function jc(e,t,n,s,r){const i=ia(e,s),o=t[i]??0;let a=0,c=o;for(let l=0;l<$b;l+=1){const h=(a+c)/2;xn(e,t,h,n,s)>r?a=h:c=h}return(a+c)/2}function Hc(e,t,n){const s=jh(e),[r,i]=t,o=e.slice(r,i+1),a=o.reduce((l,h)=>l+h,0)+Math.max(0,o.length-1)*ce,c=(n-a)/2;return Po(s,r,c)}function Lb(e,t,n){const s=Hh(e,t,n);return[t,Math.min(e.length-1,t+s-1)]}function Mb(e,t,n){const s=Pb(e,t,n);return[Math.max(0,t-s+1),t]}function Ob(e){const t=new Set,n=[];for(const s of e){const r=`${s.nodeRange[0]}:${s.nodeRange[1]}`;if(t.has(r))continue;const i=n[n.length-1];i&&Math.abs(i.anchor-s.anchor)<=vt||(t.add(r),n.push(s))}return n}function Nb(e){const{nodeCols:t,nodeWidthsPx:n,viewportWidthPx:s}=e;if(t.length===0||n.length===0)return{viewspans:[],minScroll:0,maxScroll:0};const r=e.gapPx??ce,i=Uh(s,r),o=Zh(t),a=ia(n,i),c=o[a]??0,l=[];for(let h=0;h<=a;h+=1){const f=Lb(n,h,i),w=Hc(n,f,s),v=jc(n,o,s,i,w);l.push({nodeRange:f,anchor:Math.max(0,Math.min(c,v))})}for(let h=n.length-1;h>=0;h-=1){const f=Mb(n,h,i),w=`${f[0]}:${f[1]}`;if(l.some(x=>`${x.nodeRange[0]}:${x.nodeRange[1]}`===w))continue;const v=Hc(n,f,s),E=jc(n,o,s,i,v);l.push({nodeRange:f,anchor:Math.max(0,Math.min(c,E))})}return l.sort((h,f)=>Math.abs(h.anchor-f.anchor)>vt?h.anchor-f.anchor:h.nodeRange[0]!==f.nodeRange[0]?h.nodeRange[0]-f.nodeRange[0]:h.nodeRange[1]-f.nodeRange[1]),{viewspans:Ob(l),minScroll:0,maxScroll:c}}function Wb(e,t){var r;let n=0,s=Number.POSITIVE_INFINITY;for(let i=0;i<e.length;i+=1){const o=Math.abs((((r=e[i])==null?void 0:r.anchor)??0)-t);if(o+vt<s){s=o,n=i;continue}Math.abs(o-s)<=vt&&i<n&&(n=i)}return n}function Fb(e,t,n){return n<=0?0:Math.max(0,Math.min(n-1,e+t))}function ns(e,t,n){return Math.max(t,Math.min(n,e))}class Ub extends ln{constructor(n){super();m(this,"_scroll",0);m(this,"minScroll",0);m(this,"maxScroll",0);m(this,"viewspans",[]);m(this,"activeViewspanIndex",null);m(this,"nodeWidthsPx",[]);m(this,"boundaryCols",[0]);m(this,"viewportWidthPx",0);m(this,"framedViewportWidthPx",0);this._scroll=(n==null?void 0:n.x)??0}get scroll(){return Se({x:this._scroll})}get translate(){return ve({x:xn(this.nodeWidthsPx,this.boundaryCols,this._scroll,this.viewportWidthPx,this.framedViewportWidthPx)})}set scroll(n){const s=ns(n.x??this._scroll,this.minScroll,this.maxScroll);Math.abs(s-this._scroll)<=vt||(this._scroll=s,this.activeViewspanIndex=null,this.dispatchEvent(new es("layout-scroll",{scroll:this.scroll})))}rebuild(n){const s=n.nodeWidths.map(l=>Math.max(0,l.x??0)),r=s.map(l=>n.grid.toPixels(Se({x:l})).x??0),i=n.grid.viewport.x??0,o=n.grid.gap.x??ce,a=Nb({nodeCols:s,nodeWidthsPx:r,viewportWidthPx:i,gapPx:o});this.nodeWidthsPx=r,this.boundaryCols=Zh(s),this.viewportWidthPx=i,this.framedViewportWidthPx=Uh(i,o),this.viewspans=a.viewspans,this.minScroll=a.minScroll,this.maxScroll=a.maxScroll,this.activeViewspanIndex=null;const c=ns(this._scroll,this.minScroll,this.maxScroll);Math.abs(c-this._scroll)>vt&&(this._scroll=c,this.dispatchEvent(new es("layout-scroll",{scroll:this.scroll})))}step(n){var a;if(this.viewspans.length===0)return;const s=this.activeViewspanIndex??Wb(this.viewspans,this._scroll),r=Fb(s,n,this.viewspans.length),i=((a=this.viewspans[r])==null?void 0:a.anchor)??this._scroll,o=ns(i,this.minScroll,this.maxScroll);this.activeViewspanIndex=r,!(Math.abs(o-this._scroll)<=vt)&&(this._scroll=o,this.dispatchEvent(new es("layout-scroll",{scroll:this.scroll})))}wheel(n){const s=ns(this._scroll+(n.x??0),this.minScroll,this.maxScroll);this.activeViewspanIndex=null,!(Math.abs(s-this._scroll)<=vt)&&(this._scroll=s,this.dispatchEvent(new es("layout-scroll",{scroll:this.scroll})))}wheelPixels(n){const s=n.x??0;if(Math.abs(s)<=on)return;this.activeViewspanIndex=null;const r=xn(this.nodeWidthsPx,this.boundaryCols,this._scroll,this.viewportWidthPx,this.framedViewportWidthPx),i=r-s,o=xn(this.nodeWidthsPx,this.boundaryCols,this.maxScroll,this.viewportWidthPx,this.framedViewportWidthPx),a=xn(this.nodeWidthsPx,this.boundaryCols,this.minScroll,this.viewportWidthPx,this.framedViewportWidthPx),c=Math.max(o,Math.min(a,i));if(Math.abs(c-r)<=on)return;let l=this.minScroll,h=this.maxScroll;for(let w=0;w<Rb;w+=1){const v=(l+h)/2;xn(this.nodeWidthsPx,this.boundaryCols,v,this.viewportWidthPx,this.framedViewportWidthPx)>c?l=v:h=v}const f=ns((l+h)/2,this.minScroll,this.maxScroll);Math.abs(f-this._scroll)<=vt||(this._scroll=f,this.dispatchEvent(new es("layout-scroll",{scroll:this.scroll})))}}const Ui={"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}},Zb=["stack-above","stack-below","reorder-before","reorder-after"];function Zi(e,t){return{left:e.left+e.width*t.left,top:e.top+e.height*t.top,width:e.width*t.width,height:e.height*t.height}}function Nt(e,t,n){return e>=n.left&&e<n.left+n.width&&t>=n.top&&t<n.top+n.height}function oa(e,t){for(const n of e){if(n.type==="card"&&n.id===t)return n;if(n.type==="stack")for(const s of n.children){if(s.type==="card"&&s.id===t)return s;if(s.type==="row"){for(const r of s.children)if(r.id===t)return r}}}return null}function Do(e){return e.height===We||e.height===zt?{...e,height:zt}:e}function Lo(e){return e.height===zt?{...e,height:We}:e}function jb(e,t,n,s){const r=e.findIndex(h=>h.type==="stack"&&h.id===t);if(r===-1)return e;const i=e[r];if(!i||i.type!=="stack")return e;const o=i.children.find(h=>h.type==="card"&&h.id===n);if(!o||o.type!=="card")return e;const a=i.children.filter(h=>h.id!==n);if(a.length===i.children.length||a.length<1)return e;const c=[...e];if(a.length===1){const[h]=a;c[r]=h.type==="card"?Lo(h):h}else c[r]={...i,children:a};const l=Math.max(0,Math.min(s,c.length));return c.splice(l,0,Lo(o)),c}const Hb=rt(),Bb=rt(),Vb=50;function Gb(e,t){if(e.type!==t.type)return!1;switch(e.type){case"reorder":return t.index===e.index;case"stack":return t.targetCardId===e.targetCardId&&t.position===e.position;case"stack-child-noop":return!0;case"stack-child-extract":return t.toIndex===e.toIndex;case"stack-child-reorder":return t.position===e.position;default:return!1}}function Qs(e){return{id:e.id,type:"drop-target",width:e.width,height:e.height}}function Bc(e){return e.map(Kb)}function qb(e){return e.type==="drop-target"?{id:e.id,type:"card",artifactID:e.id,width:e.width,height:e.height}:e}function Kb(e){return e.type==="drop-target"?{id:e.id,type:"card",artifactID:e.id,width:e.width,height:e.height}:e.type==="stack"?{...e,children:e.children.map(qb)}:e}function Bh(e,t){return e.find(s=>s.type==="card"&&s.id===t)??null}function Vc(e,t){return e.find(s=>s.type==="stack"&&s.id===t)??null}function Yb(e,t){const n=[...t],s=n.findIndex(a=>a.type==="card"&&a.id===e.nodeId);if(s===-1)return null;const r=n[s];if(!r||r.type!=="card")return null;n.splice(s,1);const i=Math.max(0,Math.min(e.lastReorderIndex,n.length));n.splice(i,0,r);const o=n.findIndex(a=>a.type==="card"&&a.id===e.nodeId);return o===-1?null:{base:n,visualDraggedIndex:o}}function Xb(e,t,n,s){const r=[...e.base];r.splice(e.visualDraggedIndex,1);const i=r.findIndex(w=>w.type==="card"&&w.id===n.targetCardId),o=i===-1?null:r[i];if(!o||o.type!=="card")return null;const a=Bh(s,t.nodeId);if(!a)return null;const c=Do(a),l=Do(o),h=Qs(c),f=n.position==="above"?[h,l]:[l,h];return r[i]={id:o.id,type:"stack",children:f},r}function ji(e,t){return e.parentStackId?Qb(e,t):Jb(e,t)}function Jb(e,t){const n=e.hitTarget;if(n.type==="reorder"){const s=t[e.sourceIndex];if(!s||s.type!=="card")return[...t];const r=[...t];return r.splice(e.sourceIndex,1),r.splice(n.index,0,Qs(s)),r}if(n.type==="stack"){const s=Yb(e,t);return s?Xb(s,e,n,t)??[...t]:[...t]}return[...t]}function Qb(e,t){const n=e.hitTarget;switch(n.type){case"stack-child-reorder":return eS(e,t,n.position);case"stack-child-extract":return tS(e,t,n.toIndex);case"stack-child-noop":return nS(e,t);default:return[...t]}}function eS(e,t,n){const s=t.findIndex(w=>w.type==="stack"&&w.id===e.parentStackId);if(s===-1)return[...t];const r=t[s];if(!r||r.type!=="stack")return[...t];if(!r.children.every(w=>w.type==="card"))return[...t];const i=r.children,o=i.findIndex(w=>w.id===e.nodeId);if(o===-1)return[...t];const a=i[o],c=i.filter(w=>w.id!==e.nodeId),l=Qs(a),h=n==="above"?[l,...c]:[...c,l],f=[...t];return f[s]={...r,children:h},f}function tS(e,t,n){if(!e.parentStackId)return[...t];const s=jb(t,e.parentStackId,e.nodeId,n);if(s===t)return[...t];const r=s.findIndex(a=>a.type==="card"&&a.id===e.nodeId);if(r===-1)return[...t];const i=s[r];if(!i||i.type!=="card")return[...t];const o=[...s];return o[r]=Qs(i),o}function nS(e,t){const n=t.findIndex(c=>c.type==="stack"&&c.id===e.parentStackId);if(n===-1)return[...t];const s=t[n];if(!s||s.type!=="stack")return[...t];const r=s.children.findIndex(c=>c.type==="card"&&c.id===e.nodeId);if(r===-1)return[...t];const i=s.children[r];if(!i||i.type!=="card")return[...t];const o=[...t],a=[...s.children];return a[r]=Qs(i),o[n]={...s,children:a},o}function sS(e,t){return t.find(s=>s.type==="stack"&&s.id===e.id)?e.id:en()}function rS(e,t,n){if(e.type==="drop-target"){const s=oa(t,n);if(!s)throw new Error(`finalize: missing dragged card ${n}`);return Do(s)}return e}function iS(e,t,n){const s=e.children.map(i=>rS(i,t,n));return{id:sS(e,t),type:"stack",children:s}}function oS(e,t,n){if(e.type==="drop-target"){const s=oa(t,n);if(!s)throw new Error(`finalize: missing dragged card ${n}`);return Bh(t,n)!==null?s:Lo(s)}return e.type==="card"||e.type==="row"?e:iS(e,t,n)}function aS(e,t,n){return e.map(s=>oS(s,t,n))}function cS(e,t){return JSON.stringify(e)===JSON.stringify(t)}class lS extends ln{constructor(n={}){super();m(this,"pending",null);m(this,"active",null)}start(n){if(this.pending||this.active)return;const s=n.pointer.x??0,r=n.pointer.y??0;this.pending={startX:s,startY:r,grabOffsetX:n.grabOffset.x??0,grabOffsetY:n.grabOffset.y??0,nodeId:n.nodeId,sourceIndex:n.source.index,parentStackId:n.source.parentId,width:n.size.x??0,height:n.size.y??0,baseLayout:n.layout}}update(n){const s=n.pointer.x??0,r=n.pointer.y??0,i=this.pending;if(i){const l=s-i.startX,h=r-i.startY;Math.hypot(l,h)>=Lv&&(this.pending=null,this.active={...i,pointerX:s,pointerY:r,hitTarget:{type:"reorder",index:i.sourceIndex},lastReorderIndex:i.sourceIndex},this.emitDrag(),this.dispatchEvent(new B("change")));return}if(!this.active)return;const o=ji(this.active,this.active.baseLayout),a=this.getHitTargetForPointer(s,r,n,o),c=a.type==="reorder"?a.index:this.active.lastReorderIndex;this.active.pointerX===s&&this.active.pointerY===r&&Gb(this.active.hitTarget,a)&&this.active.lastReorderIndex===c||(this.active={...this.active,pointerX:s,pointerY:r,hitTarget:a,lastReorderIndex:c},this.emitDrag(),this.dispatchEvent(new B("change")))}drop(){if(this.pending){this.cancel();return}if(!this.active)return;const n=this.active.baseLayout;let s=null;try{const r=ji(this.active,n),i=aS(r,n,this.active.nodeId);cS(i,n)||(s=i)}catch{s=null}this.reset(),s&&this.dispatchEvent(new Bb("drop",{layout:s})),this.dispatchEvent(new B("change"))}cancel(){!this.pending&&!this.active||(this.reset(),this.dispatchEvent(new B("change")))}dispose(){this.reset()}get status(){return this.active?"active":this.pending?"pending":"idle"}reset(){this.pending=null,this.active=null}emitDrag(){if(!this.active)return;const n=ji(this.active,this.active.baseLayout);this.dispatchEvent(new Hb("drag",{nodeId:this.active.nodeId,source:{index:this.active.sourceIndex,parentId:this.active.parentStackId},grabOffset:ve({x:this.active.grabOffsetX,y:this.active.grabOffsetY}),pointer:ve({x:this.active.pointerX,y:this.active.pointerY}),size:ve({x:this.active.width,y:this.active.height}),projectedLayout:n}))}getHitTargetForPointer(n,s,r,i){return this.active?this.isPointerInsideDragBounds(n,s,r.viewport)?this.active.parentStackId?this.getStackChildHitTarget(n,s,r,i):this.getTopLevelCardHitTarget(n,s,r,i):{type:"reorder",index:this.active.sourceIndex}:{type:"reorder",index:0}}getStackChildHitTarget(n,s,r,i){var l;if(!((l=this.active)!=null&&l.parentStackId))return{type:"stack-child-noop"};const o=this.getSourceStackInteractionRect(r.geometry);if(o&&Nt(n,s,o)){const h=o.top+o.height/2;return{type:"stack-child-reorder",position:s<h?"above":"below"}}const a=this.getSourceRemainingSiblingRect(r.geometry);if(a&&Nt(n,s,a)){const h=a.top+a.height/2;return{type:"stack-child-reorder",position:s<h?"above":"below"}}return{type:"stack-child-extract",toIndex:this.getTopLevelReorderIndexForPointer(n,s,r,i)}}getSourceRemainingSiblingRect(n){var i,o;if(!((i=this.active)!=null&&i.parentStackId))return;const s=Vc(this.active.baseLayout,this.active.parentStackId);if(!s)return;const r=s.children.find(a=>{var c;return a.type==="card"&&a.id!==((c=this.active)==null?void 0:c.nodeId)});if(r)return(o=n.find(a=>a.id===r.id))==null?void 0:o.rect}getSourceStackInteractionRect(n){var o;if(!((o=this.active)!=null&&o.parentStackId))return;const s=n.find(a=>{var c;return a.id===((c=this.active)==null?void 0:c.parentStackId)});if(s)return this.active.sourceStackRect=s.rect,s.rect;const r=Vc(this.active.baseLayout,this.active.parentStackId);if(!r)return this.active.sourceStackRect;const i=r.children.find(a=>{var c;return a.type==="card"&&a.id!==((c=this.active)==null?void 0:c.nodeId)});if(i){const a=n.find(c=>c.id===i.id);if(a)return a.rect}return this.active.sourceStackRect}getTopLevelCardHitTarget(n,s,r,i){var v,E,x;const o=this.getTopLevelZoneNodes(r.geometry,i);if(o.length===0)return{type:"reorder",index:((v=this.active)==null?void 0:v.sourceIndex)??0};const c=(r.effectiveVelocity??0)<=Vb;for(const z of o){const K=z.rect;if(!Nt(n,s,K))continue;const Z=this.resolveTopLevelTargetForCard(n,s,z,z.logicalIndex,c);if(Z)return Z;if(!c&&((E=this.active)!=null&&E.hitTarget))return this.active.hitTarget}const l=this.getNearestTargetableZone(n,o);if(!l)return{type:"reorder",index:((x=this.active)==null?void 0:x.sourceIndex)??0};const h=Math.max(l.rect.left,Math.min(l.rect.left+l.rect.width,n)),f=this.resolveTopLevelTargetForCard(h,s,l,l.logicalIndex,c);if(f)return f;const w=l.rect.left+l.rect.width/2;return{type:"reorder",index:n<w?l.logicalIndex:l.logicalIndex+1}}getTopLevelReorderIndexForPointer(n,s,r,i){var l,h;const o=this.getTopLevelZoneNodes(r.geometry,i);if(o.length===0)return((l=this.active)==null?void 0:l.sourceIndex)??0;for(const f of o){if(!Nt(n,s,f.rect))continue;const w=Zi(f.rect,Ui["reorder-before"]);if(Nt(n,s,w))return f.logicalIndex;const v=Zi(f.rect,Ui["reorder-after"]);if(Nt(n,s,v))return f.logicalIndex+1}const a=this.getNearestTargetableZone(n,o);if(!a)return((h=this.active)==null?void 0:h.sourceIndex)??0;const c=a.rect.left+a.rect.width/2;return n<c?a.logicalIndex:a.logicalIndex+1}getTopLevelZoneNodes(n,s){const r=new Map(s.map(a=>[a.id,a])),i=[];let o=0;for(const a of n){const c=r.get(a.id);c&&c.type!=="drop-target"&&(c.type==="card"||c.type==="stack")&&(i.push({id:c.id,rect:a.rect,logicalIndex:o}),o+=1)}return i}resolveTopLevelTargetForCard(n,s,r,i,o){const a=r.rect;for(const c of Zb){if(!o&&(c==="stack-above"||c==="stack-below"))continue;const l=Ui[c],h=Zi(a,l);if(Nt(n,s,h))return c==="stack-above"?{type:"stack",targetCardId:r.id,position:"above"}:c==="stack-below"?{type:"stack",targetCardId:r.id,position:"below"}:c==="reorder-before"?{type:"reorder",index:i}:{type:"reorder",index:i+1}}return null}getNearestTargetableZone(n,s){let r=null,i=Number.POSITIVE_INFINITY;for(const o of s){const a=o.rect.left,c=o.rect.left+o.rect.width,l=n<a?a-n:n>c?n-c:0;l<i&&(i=l,r=o)}return r}isPointerInsideDragBounds(n,s,r){return n>=r.left&&n<=r.left+r.width&&s>=r.top&&s<=r.top+r.height}}const Gc=60,uS=80,qc=.5,Kc=10;class hS{constructor(){m(this,"awaitingFreshWheelGesture",!1);m(this,"lastWheelEventAt",Number.NEGATIVE_INFINITY);m(this,"lastWheelDeltaX",0);m(this,"activeGestureType","none");m(this,"lastWheelGestureAt",Number.NEGATIVE_INFINITY)}markKeyboardNavigation(t){this.awaitingFreshWheelGesture=!0,this.lastWheelEventAt=t,this.activeGestureType="none"}reset(){this.awaitingFreshWheelGesture=!1,this.lastWheelEventAt=Number.NEGATIVE_INFINITY,this.lastWheelDeltaX=0,this.activeGestureType="none",this.lastWheelGestureAt=Number.NEGATIVE_INFINITY}decide(t){const{now:n,shiftKey:s,deltaX:r,deltaY:i,overArtifactContent:o}=t;n-this.lastWheelGestureAt>=Gc&&(this.activeGestureType="none");const c=s&&i!==0,l=c?i:r,h=Math.abs(l),f=Math.abs(i);return this.activeGestureType==="vertical-artifact"&&o?h>=qc&&h>=f*Kc?this.classifyHorizontal(n,l):(this.lastWheelGestureAt=n,{type:"scroll-native"}):this.activeGestureType==="horizontal-filmstrip"?!c&&o&&f>0&&f>=h*Kc?(this.activeGestureType="vertical-artifact",this.lastWheelGestureAt=n,{type:"scroll-native"}):this.classifyHorizontal(n,l):h<qc?(o&&(this.activeGestureType="vertical-artifact"),this.lastWheelGestureAt=n,{type:"scroll-native"}):c||h>f?this.classifyHorizontal(n,l):f>h?(o&&(this.activeGestureType="vertical-artifact"),this.lastWheelGestureAt=n,{type:"scroll-native"}):o?(this.activeGestureType="vertical-artifact",this.lastWheelGestureAt=n,{type:"scroll-native"}):this.classifyHorizontal(n,l)}classifyHorizontal(t,n){const s=t-this.lastWheelEventAt,r=Math.sign(this.lastWheelDeltaX),i=Math.sign(n),o=r!==0&&i!==0&&r!==i,a=r!==0&&Math.abs(n)>=Math.abs(this.lastWheelDeltaX)+uS;return this.awaitingFreshWheelGesture&&s<Gc&&!o&&!a?{type:"ignore"}:(this.lastWheelEventAt=t,this.lastWheelDeltaX=n,this.lastWheelGestureAt=t,this.awaitingFreshWheelGesture=!1,this.activeGestureType="horizontal-filmstrip",{type:"scroll-horizontal",horizontalDelta:n})}}const dS=2,Yc=1e3,_r=1e-4;function pS(e){if(!e||typeof e!="object")return!1;const t=e;return t.type==="wheel"&&typeof t.deltaX=="number"&&typeof t.deltaY=="number"&&typeof t.shiftKey=="boolean"}function Xc(e,t,n){if(e===0)return 0;const s=t.toPixels(Se({y:We})).y??0;return(n-s)/dS}class fS extends Event{constructor(n){super("scroll",{bubbles:!0,composed:!0});m(this,"scrollPosition");this.scrollPosition=n}}class Vh extends Event{constructor(n){super("layout-change",{bubbles:!0,composed:!0});m(this,"layout");this.layout=n}}class gS extends HTMLElement{constructor(){super();m(this,"_layout",[]);m(this,"_scrollPosition",0);m(this,"layoutGrid",null);m(this,"layoutScroll",new Ub(Se({x:0})));m(this,"scrollModelKey","");m(this,"resizeObserver",null);m(this,"renderPending",!1);m(this,"animateNextRender",!0);m(this,"wheelGesture",new hS);m(this,"dragController",new lS);m(this,"dragState",null);m(this,"activeDragPointerId",null);m(this,"dragListenersAttached",!1);m(this,"dragFrame",0);m(this,"lastDragFrameTime",0);m(this,"lastPointerX",0);m(this,"lastPointerY",0);m(this,"pointerVelocityPxPerSec",0);m(this,"scrollVelocityPxPerSec",0);m(this,"motionSampleTime",0);m(this,"motionSampleX",0);m(this,"motionSampleY",0);m(this,"dragTrackOffsetXPx",0);m(this,"previousProjectedLayoutForOffset",null);m(this,"renderContent",()=>O``);m(this,"onDragControllerChange",()=>{this.dragController.status==="idle"&&(this.dragState=null,this.dragTrackOffsetXPx=0,this.previousProjectedLayoutForOffset=null),this.scheduleRender()});m(this,"onDragControllerDrag",n=>{const s=Bc(n.projectedLayout),r=this.shouldApplyTrackOffset(n.projectedLayout,n.source.parentId),i=n.source.parentId?this.getStackChildAnchorCardId(n.source.parentId,n.nodeId):null;this.dragTrackOffsetXPx=r?this.computeDragTrackOffset(this.previousProjectedLayoutForOffset,s,n.nodeId,n.source.parentId,i,this.dragTrackOffsetXPx):0,this.previousProjectedLayoutForOffset=s,this.dragState={nodeId:n.nodeId,source:n.source,grabOffset:n.grabOffset,pointer:n.pointer,size:n.size,projectedLayout:n.projectedLayout},this.scheduleRender()});m(this,"onDragControllerDrop",n=>{this.dragState=null,this.dragTrackOffsetXPx=0,this.previousProjectedLayoutForOffset=null,this.commitLayout(n.layout)});m(this,"onLayoutScrollInternal",n=>{const r=n.scroll.x??0;Math.abs(r-this._scrollPosition)<_r||(this._scrollPosition=r,this.emitScrollPositionChanged(r),this.scheduleRender())});m(this,"handleKeyDown",n=>{if(n.key==="Escape"&&this.dragController.status!=="idle"){n.preventDefault(),this.stopDragFrameLoop(),this.releaseActiveDragPointerCapture(),this.dragController.cancel(),this.detachDragListeners();return}this.dragController.status==="idle"&&(n.key==="ArrowRight"?(n.preventDefault(),this.wheelGesture.markKeyboardNavigation(Date.now()),this.shiftWindow(1)):n.key==="ArrowLeft"&&(n.preventDefault(),this.wheelGesture.markKeyboardNavigation(Date.now()),this.shiftWindow(-1)))});m(this,"handleWheel",n=>{if(this._layout.length===0)return;const s=this.wheelGesture.decide({now:Date.now(),shiftKey:n.shiftKey,deltaX:n.deltaX,deltaY:n.deltaY,overArtifactContent:!1});s.type==="scroll-horizontal"&&(n.preventDefault(),this.applyHorizontalWheel(s.horizontalDelta))});m(this,"handleWindowMessage",n=>{var o;if(this._layout.length===0)return;const s=this.findManagedArtifactFrame(n.source);if(!s||!this.isTrustedArtifactFrameMessage(n,s)||!pS(n.data))return;const r=this.wheelGesture.decide({now:Date.now(),shiftKey:n.data.shiftKey,deltaX:n.data.deltaX,deltaY:n.data.deltaY,overArtifactContent:!0});if(r.type==="scroll-horizontal"){this.applyHorizontalWheel(r.horizontalDelta);return}if(r.type!=="scroll-native")return;const i={type:"scroll",deltaX:0,deltaY:n.data.deltaY};(o=s.contentWindow)==null||o.postMessage(i,this.getArtifactFrameTargetOrigin(s))});m(this,"handlePointerDown",n=>{if(n.button!==0||this.dragController.status!=="idle")return;const s=n.target;if(!(s instanceof Element))return;const r=s.closest(".card-slot[data-layout-draggable='true']");if(!r)return;const i=r.getAttribute("data-layout-node-id");if(!i)return;const o=vS(this._layout,i);if(!o)return;const a=r.getBoundingClientRect();this.lastPointerX=n.clientX,this.lastPointerY=n.clientY,this.resetMotionTracking(n.clientX,n.clientY),this.focus(),this.dragController.start({nodeId:i,source:{index:o.topLevelIndex,parentId:o.sourceStackId},pointer:ve({x:n.clientX,y:n.clientY}),grabOffset:ve({x:n.clientX-a.left,y:n.clientY-a.top}),size:ve({x:a.width,y:a.height}),layout:this._layout}),this.attachDragListeners(),this.activeDragPointerId=n.pointerId;try{this.setPointerCapture(n.pointerId)}catch{}n.preventDefault()});m(this,"handleWindowPointerMove",n=>{this.lastPointerX=n.clientX,this.lastPointerY=n.clientY,this.updatePointerVelocity(n.clientX,n.clientY),this.syncDragTargetForLatestPointer(),this.ensureDragFrameLoop()});m(this,"handleWindowPointerUp",n=>{this.stopDragFrameLoop(),this.releasePointerCaptureForEvent(n.pointerId),this.dragController.drop(),this.clearMotionTracking(),this.detachDragListeners()});m(this,"handleWindowPointerCancel",n=>{this.stopDragFrameLoop(),this.releasePointerCaptureForEvent(n.pointerId),this.dragController.cancel(),this.clearMotionTracking(),this.detachDragListeners()});m(this,"handleWindowBlur",()=>{this.releaseActiveDragPointerCapture(),this.stopDragFrameLoop(),this.dragController.cancel(),this.clearMotionTracking(),this.detachDragListeners()});m(this,"runDragFrame",n=>{if(this.dragController.status==="idle"){this.dragFrame=0;return}const s=Math.max(0,n-this.lastDragFrameTime)/Yc;this.lastDragFrameTime=n,this.samplePointerVelocityAt(n,this.lastPointerX,this.lastPointerY);const r=this.getBoundingClientRect(),i=this.clampPointerToViewport(this.lastPointerX,this.lastPointerY,r),o=this.getDragEdgeScrollDeltaPixels(i.x,r,s);this.scrollVelocityPxPerSec=s>_r?Math.abs(o)/s:0,Math.abs(o)>_r&&(this.animateNextRender=!1,this.layoutScroll.wheelPixels(ve({x:o}))),this.dragController.status==="active"&&this.syncDragTarget(i.x,i.y,r),this.dragFrame=requestAnimationFrame(this.runDragFrame)});this.dragController.addEventListener("change",this.onDragControllerChange),this.dragController.addEventListener("drag",this.onDragControllerDrag),this.dragController.addEventListener("drop",this.onDragControllerDrop),this.layoutScroll.addEventListener("layout-scroll",this.onLayoutScrollInternal)}set layout(n){this._layout=[...n],this.stopDragFrameLoop(),this.dragController.cancel(),this.scrollModelKey="",this.syncScrollModel(),this.layoutScroll.scroll=Se({x:this._scrollPosition}),this.scheduleRender()}get layout(){return this._layout}commitLayout(n){this.layout=n,this.emitLayoutChanged()}set scrollPosition(n){Math.abs(n-this._scrollPosition)<_r||(this.animateNextRender=!1,this.syncScrollModel(),this.layoutScroll.scroll=Se({x:n}))}get scrollPosition(){return this._scrollPosition}connectedCallback(){this.hasAttribute("tabindex")||(this.tabIndex=0),this.focus(),this.addEventListener("keydown",this.handleKeyDown),this.addEventListener("wheel",this.handleWheel,{passive:!1}),this.addEventListener("pointerdown",this.handlePointerDown),window.addEventListener("message",this.handleWindowMessage),typeof ResizeObserver<"u"&&(this.resizeObserver=new ResizeObserver(()=>this.render()),this.resizeObserver.observe(this)),this.render()}disconnectedCallback(){var n;this.removeEventListener("keydown",this.handleKeyDown),this.removeEventListener("wheel",this.handleWheel),this.removeEventListener("pointerdown",this.handlePointerDown),window.removeEventListener("message",this.handleWindowMessage),(n=this.resizeObserver)==null||n.disconnect(),this.resizeObserver=null,this.wheelGesture.reset(),this.detachDragListeners(),this.dragController.removeEventListener("change",this.onDragControllerChange),this.dragController.removeEventListener("drag",this.onDragControllerDrag),this.dragController.removeEventListener("drop",this.onDragControllerDrop),this.layoutScroll.removeEventListener("layout-scroll",this.onLayoutScrollInternal),this.dragController.dispose(),this.stopDragFrameLoop()}scheduleRender(){this.renderPending||(this.renderPending=!0,queueMicrotask(()=>{this.renderPending=!1,this.render()}))}createGrid(n,s){return new zb({basis:ve({x:Zt,y:Zt}),min:ve({x:Sc,y:Sc}),viewport:ve({x:n,y:s}),gap:ve({x:ce,y:ce})})}syncScrollModel(){const n=this.clientWidth>0?this.clientWidth:Tt,s=this.clientHeight>0?this.clientHeight:In,i=zn(this._layout).nodes.map(a=>a.width),o=`${n}x${s}:${i.join(",")}`;o===this.scrollModelKey&&this.layoutGrid||(this.scrollModelKey=o,this.layoutGrid=this.createGrid(n,s),this.layoutScroll.rebuild({grid:this.layoutGrid,nodeWidths:i.map(a=>Se({x:a}))}))}emitScrollPositionChanged(n){this.dispatchEvent(new fS(n))}emitLayoutChanged(){this.dispatchEvent(new Vh([...this._layout]))}shiftWindow(n){this.syncScrollModel(),this.animateNextRender=!0,this.layoutScroll.step(n)}applyHorizontalWheel(n){this.syncScrollModel();const s=this.layoutGrid;if(!s)return;this.animateNextRender=!1;const r=s.toUnits(ve({x:n}));this.layoutScroll.wheel(Se({x:r.x??0}))}findManagedArtifactFrame(n){if(!n)return null;const s=this.querySelectorAll("iframe.artifact-html-frame");for(const r of s)if(r.contentWindow===n)return r;return null}isTrustedArtifactFrameMessage(n,s){if(n.origin==="null")return!0;const r=this.getArtifactFrameOrigin(s);return r===null||n.origin===r}getArtifactFrameTargetOrigin(n){const s=n.getAttribute("sandbox")??"";return new Set(s.split(/\s+/).filter(Boolean)).has("allow-same-origin")?this.getArtifactFrameOrigin(n)??"*":"*"}getArtifactFrameOrigin(n){const s=n.getAttribute("src")??n.src;if(!s)return null;try{return new URL(s,window.location.href).origin}catch{return null}}releaseActiveDragPointerCapture(){this.activeDragPointerId!==null&&this.releasePointerCaptureForEvent(this.activeDragPointerId)}releasePointerCaptureForEvent(n){try{this.hasPointerCapture(n)&&this.releasePointerCapture(n)}catch{}}attachDragListeners(){this.dragListenersAttached||(window.addEventListener("pointermove",this.handleWindowPointerMove),window.addEventListener("pointerup",this.handleWindowPointerUp),window.addEventListener("pointercancel",this.handleWindowPointerCancel),this.addEventListener("pointermove",this.handleWindowPointerMove),this.addEventListener("pointerup",this.handleWindowPointerUp),this.addEventListener("pointercancel",this.handleWindowPointerCancel),window.addEventListener("blur",this.handleWindowBlur),this.dragListenersAttached=!0)}detachDragListeners(){this.dragListenersAttached&&(window.removeEventListener("pointermove",this.handleWindowPointerMove),window.removeEventListener("pointerup",this.handleWindowPointerUp),window.removeEventListener("pointercancel",this.handleWindowPointerCancel),this.removeEventListener("pointermove",this.handleWindowPointerMove),this.removeEventListener("pointerup",this.handleWindowPointerUp),this.removeEventListener("pointercancel",this.handleWindowPointerCancel),window.removeEventListener("blur",this.handleWindowBlur),this.dragListenersAttached=!1,this.activeDragPointerId=null)}getDisplayModel(){if(this.dragController.status!=="active"||!this.dragState)return{layout:this._layout,activePlaceholderId:null,placeholdersById:new Map};const n=new Map;return n.set(this.dragState.nodeId,{id:this.dragState.nodeId,sourceCardId:this.dragState.nodeId}),{layout:Bc(this.dragState.projectedLayout),activePlaceholderId:this.dragState.nodeId,placeholdersById:n}}render(){const n=this.clientWidth>0?this.clientWidth:Tt,s=this.clientHeight>0?this.clientHeight:In,r=this.createGrid(n,s);this.layoutGrid=r;const i=this.getDisplayModel(),o=i.layout,a=this.dragController.status==="active",c=zn(o),l=c.nodes.map(U=>U.width),h=_S(o),f=`${n}x${s}:${l.join(",")}`;!a&&f!==this.scrollModelKey&&(this.scrollModelKey=f,this.layoutScroll.rebuild({grid:r,nodeWidths:l.map(U=>Se({x:U}))}),this._scrollPosition=this.layoutScroll.scroll.x??this._scrollPosition);const w=mS(o),v=r.unit.x??Zt,E=r.unit.y??Zt,x=a?this.dragTrackOffsetXPx:0,z=(this.layoutScroll.translate.x??0)+x,K=Xc(c.nodes.length,r,s),Z=this.animateNextRender&&!a,ye=[`transform: translate(${z}px, ${K}px);`,`transition-duration: ${Z?Dv:0}ms;`,`pointer-events: ${a?"none":"auto"};`].join(" ");this.animateNextRender=!0,this.style.setProperty("--layout-unit-x",`${v}px`),this.style.setProperty("--layout-unit-y",`${E}px`),this.style.setProperty("--layout-gap",`${ce}px`);const M=this.dragState,G={width:(M==null?void 0:M.size.x)??0,height:(M==null?void 0:M.size.y)??0};ue(O`
|
|
151
|
-
<div class="track" style=${ye}>
|
|
152
|
-
${c.nodes.map((U,Te)=>O`
|
|
153
|
-
<div
|
|
154
|
-
class="node"
|
|
155
|
-
layout-node=${String(Te)}
|
|
156
|
-
data-layout-node-id=${U.id}
|
|
157
|
-
data-layout-placeholder=${String(i.activePlaceholderId===U.id)}
|
|
158
|
-
layout-node-cols=${String(U.width)}
|
|
159
|
-
style=${`grid-template-columns: repeat(${U.width}, var(--layout-unit-x)); width: ${r.toPixels(Se({x:U.width})).x}px;`}
|
|
160
|
-
>
|
|
161
|
-
${U.cards.map(X=>{const Kn=i.placeholdersById.get(X.id);if(M&&Kn)return O`
|
|
162
|
-
<div
|
|
163
|
-
class="card-slot card-placeholder"
|
|
164
|
-
data-layout-placeholder-for=${M.nodeId}
|
|
165
|
-
data-layout-placeholder-ghost="false"
|
|
166
|
-
data-layout-source-stack=${M.source.parentId??""}
|
|
167
|
-
style=${`grid-column: ${X.col} / span ${X.width}; grid-row: ${X.row} / span ${X.height};`}
|
|
168
|
-
></div>
|
|
169
|
-
`;const dn=w.get(X.id);if(!dn)return null;const Yn=(U.type==="card"&&X.id===U.id||h.has(X.id))&&(!M||U.id!==i.activePlaceholderId);return O`
|
|
170
|
-
<div
|
|
171
|
-
class="card-slot"
|
|
172
|
-
data-layout-card-id=${X.artifactID}
|
|
173
|
-
data-layout-draggable=${String(Yn)}
|
|
174
|
-
data-layout-node-id=${X.id}
|
|
175
|
-
layout-cols=${String(X.width)}
|
|
176
|
-
layout-rows=${String(X.height)}
|
|
177
|
-
style=${`grid-column: ${X.col} / span ${X.width}; grid-row: ${X.row} / span ${X.height};`}
|
|
178
|
-
>
|
|
179
|
-
${this.renderContent(dn)}
|
|
180
|
-
</div>
|
|
181
|
-
`})}
|
|
182
|
-
</div>
|
|
183
|
-
`)}
|
|
184
|
-
</div>
|
|
185
|
-
${M?(()=>{const U=this.getPlaceholderPixelSize(c,i.activePlaceholderId,r,G),Te=M.pointer.x??0,X=M.pointer.y??0,Kn=M.grabOffset.x??0,dn=M.grabOffset.y??0;return O`
|
|
186
|
-
<div
|
|
187
|
-
class="drag-preview"
|
|
188
|
-
data-layout-preview-card-id=${M.nodeId}
|
|
189
|
-
style=${[`width: ${U.width}px;`,`height: ${U.height}px;`,`left: ${Te-Kn}px;`,`top: ${X-dn}px;`].join(" ")}
|
|
190
|
-
>
|
|
191
|
-
${this.renderDraggedPreview(M.nodeId)}
|
|
192
|
-
</div>
|
|
193
|
-
`})():null}
|
|
194
|
-
`,this)}ensureDragFrameLoop(){this.dragFrame!==0||this.dragController.status==="idle"||(this.lastDragFrameTime=performance.now(),this.dragFrame=requestAnimationFrame(this.runDragFrame))}stopDragFrameLoop(){this.dragFrame!==0&&(cancelAnimationFrame(this.dragFrame),this.dragFrame=0,this.scrollVelocityPxPerSec=0)}syncDragTargetForLatestPointer(){if(this.dragController.status==="idle")return;const n=this.getBoundingClientRect();if(this.dragController.status==="active"){const r=this.clampPointerToViewport(this.lastPointerX,this.lastPointerY,n);this.syncDragTarget(r.x,r.y,n);return}if(this.syncDragTarget(this.lastPointerX,this.lastPointerY,n),this.dragController.status==="pending")return;const s=this.clampPointerToViewport(this.lastPointerX,this.lastPointerY,n);(s.x!==this.lastPointerX||s.y!==this.lastPointerY)&&this.syncDragTarget(s.x,s.y,n)}syncDragTarget(n,s,r=this.getBoundingClientRect()){if(this.dragController.status==="idle")return;const i=this.getDisplayModel(),o=new Set(i.placeholdersById.keys()),a=this.dragController.status==="active"?this.dragTrackOffsetXPx:0,c=this.measureLayoutGeometry(i.layout,o,a);this.dragController.update({pointer:ve({x:n,y:s}),viewport:{left:r.left,top:r.top,width:r.width,height:r.height},geometry:c,effectiveVelocity:Math.max(this.pointerVelocityPxPerSec,this.scrollVelocityPxPerSec)})}resetMotionTracking(n,s){this.pointerVelocityPxPerSec=0,this.scrollVelocityPxPerSec=0,this.motionSampleTime=performance.now(),this.motionSampleX=n,this.motionSampleY=s}clearMotionTracking(){this.pointerVelocityPxPerSec=0,this.scrollVelocityPxPerSec=0,this.motionSampleTime=0}updatePointerVelocity(n,s){this.samplePointerVelocityAt(performance.now(),n,s)}samplePointerVelocityAt(n,s,r){if(this.motionSampleTime===0){this.motionSampleTime=n,this.motionSampleX=s,this.motionSampleY=r,this.pointerVelocityPxPerSec=0;return}const i=n-this.motionSampleTime;if(i<100)return;const o=s-this.motionSampleX;this.pointerVelocityPxPerSec=Math.abs(o)/i*Yc,this.motionSampleTime=n,this.motionSampleX=s,this.motionSampleY=r}clampPointerToViewport(n,s,r){return{x:Math.max(r.left,Math.min(r.left+r.width,n)),y:Math.max(r.top,Math.min(r.top+r.height,s))}}isPointerOutsideViewport(n,s,r){return n<r.left||n>r.left+r.width||s<r.top||s>r.top+r.height}getDragEdgeScrollDeltaPixels(n,s,r){var l;const i=s.left+dr,o=s.left+s.width-dr,a=((l=this.layoutGrid)==null?void 0:l.unit.x)??Zt,c=Mv*a;if(n<i){const h=Math.max(0,Math.min(1,(i-n)/dr));return-(c*h**xc)*r}if(n>o){const h=Math.max(0,Math.min(1,(n-o)/dr));return c*h**xc*r}return 0}measureLayoutGeometry(n,s,r=0){const i=this.layoutGrid;if(!i)return[];const o=zn(n),a=new Map(o.nodes.map(E=>[E.id,E.width])),c=i.toPixels(Se({y:We})).y??In,l=this.clientHeight>0?this.clientHeight:In,h=(this.layoutScroll.translate.x??0)+r,f=Xc(o.nodes.length,i,l),w=[];let v=h;for(const E of n){const x=a.get(E.id)??st,z=i.toPixels(Se({x})).x??Tt,K={left:v,top:f,width:z,height:c};w.push({id:E.id,rect:K}),v+=z+ce}return w}getPlaceholderPixelSize(n,s,r,i){if(!s)return i;for(const o of n.nodes)for(const a of o.cards)if(a.id===s)return{width:r.toPixels(Se({x:a.width})).x??i.width,height:r.toPixels(Se({y:a.height})).y??i.height};return i}renderDraggedPreview(n){const s=oa(this._layout,n);return s?this.renderContent(s):O``}shouldApplyTrackOffset(n,s){if(s)return!0;for(const r of n){if(r.type!=="stack")continue;if(r.children.some(o=>o.type==="drop-target")&&s!==r.id)return!0}return!1}computeDragTrackOffset(n,s,r,i,o,a){if(!n)return a;const c=i?o??this.getStableAnchorCardId(n,s,r):this.getStableAnchorNodeId(n,s,r);if(!c)return a;const l=i?Qc(n,c,this.layoutGrid):el(n,c,this.layoutGrid),h=i?Qc(s,c,this.layoutGrid):el(s,c,this.layoutGrid);return l===null||h===null?a:a+(l-h)}getStableAnchorCardId(n,s,r){const i=Jc(n),o=new Set(Jc(s));for(const a of i)if(a!==r&&o.has(a))return a;return null}getStableAnchorNodeId(n,s,r){const i=new Set(s.map(o=>o.id));for(const o of n)if(o.id!==r&&i.has(o.id))return o.id;return null}getStackChildAnchorCardId(n,s){const r=this._layout.find(o=>o.type==="stack"&&o.id===n);if(!r||r.type!=="stack")return null;const i=r.children.find(o=>o.type==="card"&&o.id!==s);return(i==null?void 0:i.id)??null}}function mS(e){const t=new Map;for(const n of e){if(n.type==="card"){t.set(n.id,n);continue}for(const s of n.children)if(s.type==="card")t.set(s.id,s);else for(const r of s.children)t.set(r.id,r)}return t}function vS(e,t){const n=e.findIndex(s=>s.type==="card"&&s.id===t);if(n!==-1)return{topLevelIndex:n};for(let s=0;s<e.length;s+=1){const r=e[s];if(!(!r||r.type!=="stack")&&r.children.some(i=>i.type==="card"&&i.id===t))return{topLevelIndex:s,sourceStackId:r.id}}return null}function _S(e){const t=new Set;for(const n of e)if(n.type==="stack")for(const s of n.children)s.type==="card"&&t.add(s.id);return t}function Jc(e){const t=[];for(const n of e){if(n.type==="card"){t.push(n.id);continue}if(n.type==="stack"){const s=n.children.find(r=>r.type==="card");s&&t.push(s.id)}}return t}function Qc(e,t,n){if(!n)return null;const s=zn(e),r=new Map(s.nodes.map(o=>[o.id,o.width]));let i=0;for(const o of e){if(o.type==="card"&&o.id===t||o.type==="stack"&&o.children.some(l=>l.type==="card"&&l.id===t))return i;const a=r.get(o.id)??st,c=n.toPixels(Se({x:a})).x??Tt;i+=c+ce}return null}function el(e,t,n){if(!n)return null;const s=zn(e),r=new Map(s.nodes.map(o=>[o.id,o.width]));let i=0;for(const o of e){if(o.id===t)return i;const a=r.get(o.id)??st,c=n.toPixels(Se({x:a})).x??Tt;i+=c+ce}return null}customElements.get("layout-view")||customElements.define("layout-view",gS);class yS extends HTMLElement{constructor(){super(...arguments);m(this,"workspaceService",Ze.resolve("WorkspaceService"));m(this,"handleWorkspaceChange",()=>{this.render()});m(this,"handleCloseArtifact",n=>{n instanceof Fh&&this.workspaceService.removeArtifact(n.artifactID)});m(this,"handleScrollPositionChanged",n=>{const s=n;typeof s.scrollPosition=="number"&&Number.isFinite(s.scrollPosition)&&this.workspaceService.setScrollPosition(s.scrollPosition)});m(this,"handleLayoutChanged",n=>{n instanceof Vh&&this.workspaceService.setLayout(n.layout)})}connectedCallback(){this.render(),this.workspaceService.addEventListener("change",this.handleWorkspaceChange)}disconnectedCallback(){this.workspaceService.removeEventListener("change",this.handleWorkspaceChange)}buildArtifactMap(){return new Map(this.workspaceService.activeArtifacts.map(n=>[n.id,n]))}render(){const n=this.workspaceService.activeWorkspace,s=(n==null?void 0:n.layout)??[],r=this.buildArtifactMap();if(s.length===0){ue(O`<p data-testid="empty-workspace">No artifacts yet.</p>`,this);return}ue(O`
|
|
195
|
-
<layout-view
|
|
196
|
-
.layout=${s}
|
|
197
|
-
.renderContent=${o=>{const a=r.get(o.artifactID);return a?O`<artifact-view
|
|
198
|
-
.artifact=${a}
|
|
199
|
-
.artifactURL=${this.workspaceService.getArtifactURL(o.artifactID)}
|
|
200
|
-
></artifact-view>`:O``}}
|
|
201
|
-
.scrollPosition=${this.workspaceService.scrollPosition}
|
|
202
|
-
@scroll=${this.handleScrollPositionChanged}
|
|
203
|
-
@layout-change=${this.handleLayoutChanged}
|
|
204
|
-
@close-artifact=${this.handleCloseArtifact}
|
|
205
|
-
></layout-view>
|
|
206
|
-
`,this)}}customElements.define("workspace-view",yS);const Hi=rt();class kS extends HTMLElement{constructor(){super(...arguments);m(this,"workspaceService",Ze.resolve("WorkspaceService"));m(this,"serverManager",Ze.resolve("ServerManager"));m(this,"handleChange",()=>{this.render()})}connectedCallback(){this.render(),this.workspaceService.addEventListener("change",this.handleChange),this.serverManager.addEventListener("change",this.handleChange)}disconnectedCallback(){this.workspaceService.removeEventListener("change",this.handleChange),this.serverManager.removeEventListener("change",this.handleChange)}handleSelect(n){this.workspaceService.setActiveWorkspace(n.value)}closeDropdown(){var n;(n=this.querySelector("dropdown-menu"))==null||n.close()}handleEditWorkspace(){this.workspaceService.activeWorkspace&&(this.closeDropdown(),this.dispatchEvent(new Hi("edit-workspace",{bubbles:!0,composed:!0})))}handleCreateWorkspace(n){this.closeDropdown(),this.dispatchEvent(new Hi("create-workspace",{serverURL:n,bubbles:!0,composed:!0}))}handleDeleteWorkspace(){this.workspaceService.activeWorkspace&&(this.closeDropdown(),this.dispatchEvent(new Hi("delete-workspace",{bubbles:!0,composed:!0})))}render(){var r;const n=((r=this.workspaceService.activeWorkspace)==null?void 0:r.name)??"No workspaces",s=[...this.serverManager.servers.values()].map(i=>({...i,sortedWorkspaces:[...i.workspaces.values()].sort((o,a)=>o.name.localeCompare(a.name,void 0,{sensitivity:"base"}))}));ue(O`
|
|
207
|
-
<dropdown-menu
|
|
208
|
-
title=${n}
|
|
209
|
-
@select=${i=>this.handleSelect(i)}
|
|
210
|
-
>
|
|
211
|
-
<button
|
|
212
|
-
slot="trigger"
|
|
213
|
-
trigger
|
|
214
|
-
type="button"
|
|
215
|
-
aria-label="Choose workspace"
|
|
216
|
-
></button>
|
|
217
|
-
${s.map(i=>O`
|
|
218
|
-
<dropdown-group>
|
|
219
|
-
<dropdown-label>${i.name}</dropdown-label>
|
|
220
|
-
${i.sortedWorkspaces.map(o=>this.renderWorkspaceItem(o))}
|
|
221
|
-
<dropdown-item
|
|
222
|
-
action
|
|
223
|
-
@click=${()=>this.handleCreateWorkspace(i.url)}
|
|
224
|
-
>
|
|
225
|
-
+ New workspace
|
|
226
|
-
</dropdown-item>
|
|
227
|
-
</dropdown-group>
|
|
228
|
-
`)}
|
|
229
|
-
${this.workspaceService.activeWorkspace?O`
|
|
230
|
-
<dropdown-divider></dropdown-divider>
|
|
231
|
-
<dropdown-group>
|
|
232
|
-
<dropdown-item
|
|
233
|
-
action
|
|
234
|
-
@click=${()=>this.handleEditWorkspace()}
|
|
235
|
-
>
|
|
236
|
-
Edit workspace...
|
|
237
|
-
</dropdown-item>
|
|
238
|
-
<dropdown-item
|
|
239
|
-
action
|
|
240
|
-
danger
|
|
241
|
-
@click=${()=>this.handleDeleteWorkspace()}
|
|
242
|
-
>
|
|
243
|
-
Delete workspace...
|
|
244
|
-
</dropdown-item>
|
|
245
|
-
</dropdown-group>
|
|
246
|
-
`:null}
|
|
247
|
-
</dropdown-menu>
|
|
248
|
-
`,this)}renderWorkspaceItem(n){var r;const s=n.id===this.workspaceService.activeWorkspaceID?((r=this.workspaceService.activeWorkspace)==null?void 0:r.name)??n.name:n.name;return O`
|
|
249
|
-
<dropdown-item
|
|
250
|
-
value=${n.id}
|
|
251
|
-
?selected=${n.id===this.workspaceService.activeWorkspaceID}
|
|
252
|
-
>
|
|
253
|
-
${s}
|
|
254
|
-
</dropdown-item>
|
|
255
|
-
`}}customElements.define("workspace-picker",kS);const tl=new WeakMap,nl=new WeakSet,Gh=new WeakMap,qh=new WeakMap,yr=new WeakSet,Kh=e=>e;function Yh(e,t){return e===Boolean?t===null?!1:t!=="false":t===null?null:e===Number?Number(t):e===Object?JSON.parse(t):t}function wS(e,t){return t==null?null:e===Boolean?t?"":"false":e===Object?JSON.stringify(t):String(t)}function bS(e){const t=new Map;if(!e)return t;if(Array.isArray(e)){for(const n of e)t.set(n,{attribute:!1});return t}for(const[n,s]of Object.entries(e))t.set(n,{type:s.type,attribute:s.attribute??!1});return t}function Ts(e){let t=tl.get(e);return t||(t={constructing:!0,syncingFromAttribute:null,syncingToAttribute:null,values:new Map},tl.set(e,t)),t}function aa(e){return qh.get(e)??new Map}function Xh(e,t){var n;return((n=Gh.get(e))==null?void 0:n.has(t))??!1}function Is(e){return typeof e.attribute=="string"?e.attribute:null}function SS(e,t){for(const[n,s]of aa(e))if(Is(s)===t)return{prop:n,config:s};return null}function Cr(e){if(nl.has(e))return;const t=bS(e.observedProperties);qh.set(e,t);const n=new Set;Gh.set(e,n);for(const[s,r]of t){if(Is(r)&&!r.type)throw new Error(`Observed property "${s}" requires a "type" when "attribute" is set.`);const o=Object.getOwnPropertyDescriptor(e.prototype,s);if(o!=null&&o.get||o!=null&&o.set)throw new Error(`Observed property "${s}" cannot define a custom getter/setter. Use propertyChangedCallback for side effects instead.`);o||(n.add(s),Object.defineProperty(e.prototype,s,{enumerable:!0,configurable:!0,get(){return Ts(this).values.get(s)},set(a){const c=Ts(this),l=c.values.get(s);if(Object.is(l,a))return;c.values.set(s,a);const h=Is(r);if(h&&c.syncingFromAttribute!==h&&c.syncingToAttribute!==h){const f=wS(r.type,a);c.syncingToAttribute=h;try{const w=this;f===null?w.removeAttribute(h):w.setAttribute(h,f)}finally{c.syncingToAttribute=null}}(!c.constructing||c.syncingFromAttribute!==null||l!==void 0)&&this.propertyChangedCallback(s,l,a)}}))}nl.add(e)}function xS(e,t){Cr(t);const n=Ts(e),s=Kh(e),r=aa(t);for(const[i,o]of r){if(!Xh(t,i))continue;const a=Object.prototype.hasOwnProperty.call(e,i),c=a?s[i]:void 0;a&&delete s[i];const l=Is(o);if(l&&e.hasAttribute(l)){const h=Yh(o.type,e.getAttribute(l));n.syncingFromAttribute=l;try{s[i]=h}finally{n.syncingFromAttribute=null}continue}a&&(s[i]=c)}n.constructing=!1}class Cs extends globalThis.HTMLElement{static get observedAttributes(){const t=this;return Cr(t),ES(t),[...aa(t).values()].map(n=>Is(n)).filter(n=>!!n)}constructor(){super();const t=this.constructor;Cr(t),Ts(this),queueMicrotask(()=>xS(this,t))}attributeChangedCallback(t,n,s){const r=this.constructor;Cr(r);const i=SS(r,t);if(!i||!Xh(r,i.prop))return;const o=Ts(this);if(o.syncingToAttribute===t)return;const a=Kh(this);Object.prototype.hasOwnProperty.call(this,i.prop)&&delete a[i.prop],o.syncingFromAttribute=t;try{a[i.prop]=Yh(i.config.type,s)}finally{o.syncingFromAttribute=null}}propertyChangedCallback(t,n,s){}}m(Cs,"observedProperties");function ES(e){if(yr.has(e))return;const t=Object.getOwnPropertyDescriptor(e.prototype,"attributeChangedCallback");if(!t||typeof t.value!="function"){yr.add(e);return}const n=t.value;if(n===Cs.prototype.attributeChangedCallback){yr.add(e);return}Object.defineProperty(e.prototype,"attributeChangedCallback",{configurable:!0,writable:!0,value(s,r,i){Cs.prototype.attributeChangedCallback.call(this,s,r,i),n.call(this,s,r,i)}}),yr.add(e)}/*! @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:Jh,setPrototypeOf:sl,isFrozen:AS,getPrototypeOf:TS,getOwnPropertyDescriptor:IS}=Object;let{freeze:$e,seal:je,create:zr}=Object,{apply:Mo,construct:Oo}=typeof Reflect<"u"&&Reflect;$e||($e=function(t){return t});je||(je=function(t){return t});Mo||(Mo=function(t,n){for(var s=arguments.length,r=new Array(s>2?s-2:0),i=2;i<s;i++)r[i-2]=arguments[i];return t.apply(n,r)});Oo||(Oo=function(t){for(var n=arguments.length,s=new Array(n>1?n-1:0),r=1;r<n;r++)s[r-1]=arguments[r];return new t(...s)});const kr=Re(Array.prototype.forEach),CS=Re(Array.prototype.lastIndexOf),rl=Re(Array.prototype.pop),ss=Re(Array.prototype.push),zS=Re(Array.prototype.splice),$r=Re(String.prototype.toLowerCase),Bi=Re(String.prototype.toString),Vi=Re(String.prototype.match),rs=Re(String.prototype.replace),$S=Re(String.prototype.indexOf),RS=Re(String.prototype.trim),Oe=Re(Object.prototype.hasOwnProperty),Ie=Re(RegExp.prototype.test),is=PS(TypeError);function Re(e){return function(t){t instanceof RegExp&&(t.lastIndex=0);for(var n=arguments.length,s=new Array(n>1?n-1:0),r=1;r<n;r++)s[r-1]=arguments[r];return Mo(e,t,s)}}function PS(e){return function(){for(var t=arguments.length,n=new Array(t),s=0;s<t;s++)n[s]=arguments[s];return Oo(e,n)}}function F(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:$r;sl&&sl(e,null);let s=t.length;for(;s--;){let r=t[s];if(typeof r=="string"){const i=n(r);i!==r&&(AS(t)||(t[s]=i),r=i)}e[r]=!0}return e}function DS(e){for(let t=0;t<e.length;t++)Oe(e,t)||(e[t]=null);return e}function Qe(e){const t=zr(null);for(const[n,s]of Jh(e))Oe(e,n)&&(Array.isArray(s)?t[n]=DS(s):s&&typeof s=="object"&&s.constructor===Object?t[n]=Qe(s):t[n]=s);return t}function os(e,t){for(;e!==null;){const s=IS(e,t);if(s){if(s.get)return Re(s.get);if(typeof s.value=="function")return Re(s.value)}e=TS(e)}function n(){return null}return n}const il=$e(["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"]),Gi=$e(["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"]),qi=$e(["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"]),LS=$e(["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"]),Ki=$e(["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"]),MS=$e(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),ol=$e(["#text"]),al=$e(["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"]),Yi=$e(["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"]),cl=$e(["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"]),wr=$e(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),OS=je(/\{\{[\w\W]*|[\w\W]*\}\}/gm),NS=je(/<%[\w\W]*|[\w\W]*%>/gm),WS=je(/\$\{[\w\W]*/gm),FS=je(/^data-[\-\w.\u00B7-\uFFFF]+$/),US=je(/^aria-[\-\w]+$/),Qh=je(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),ZS=je(/^(?:\w+script|data):/i),jS=je(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),ed=je(/^html$/i),HS=je(/^[a-z][.\w]*(-[.\w]+)+$/i);var ll=Object.freeze({__proto__:null,ARIA_ATTR:US,ATTR_WHITESPACE:jS,CUSTOM_ELEMENT:HS,DATA_ATTR:FS,DOCTYPE_NAME:ed,ERB_EXPR:NS,IS_ALLOWED_URI:Qh,IS_SCRIPT_OR_DATA:ZS,MUSTACHE_EXPR:OS,TMPLIT_EXPR:WS});const as={element:1,text:3,progressingInstruction:7,comment:8,document:9},BS=function(){return typeof window>"u"?null:window},VS=function(t,n){if(typeof t!="object"||typeof t.createPolicy!="function")return null;let s=null;const r="data-tt-policy-suffix";n&&n.hasAttribute(r)&&(s=n.getAttribute(r));const i="dompurify"+(s?"#"+s:"");try{return t.createPolicy(i,{createHTML(o){return o},createScriptURL(o){return o}})}catch{return console.warn("TrustedTypes policy "+i+" could not be created."),null}},ul=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}};function td(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:BS();const t=D=>td(D);if(t.version="3.3.3",t.removed=[],!e||!e.document||e.document.nodeType!==as.document||!e.Element)return t.isSupported=!1,t;let{document:n}=e;const s=n,r=s.currentScript,{DocumentFragment:i,HTMLTemplateElement:o,Node:a,Element:c,NodeFilter:l,NamedNodeMap:h=e.NamedNodeMap||e.MozNamedAttrMap,HTMLFormElement:f,DOMParser:w,trustedTypes:v}=e,E=c.prototype,x=os(E,"cloneNode"),z=os(E,"remove"),K=os(E,"nextSibling"),Z=os(E,"childNodes"),ye=os(E,"parentNode");if(typeof o=="function"){const D=n.createElement("template");D.content&&D.content.ownerDocument&&(n=D.content.ownerDocument)}let M,G="";const{implementation:U,createNodeIterator:Te,createDocumentFragment:X,getElementsByTagName:Kn}=n,{importNode:dn}=s;let xe=ul();t.isSupported=typeof Jh=="function"&&typeof ye=="function"&&U&&U.createHTMLDocument!==void 0;const{MUSTACHE_EXPR:Yn,ERB_EXPR:mi,TMPLIT_EXPR:vi,DATA_ATTR:bd,ARIA_ATTR:Sd,IS_SCRIPT_OR_DATA:xd,ATTR_WHITESPACE:Aa,CUSTOM_ELEMENT:Ed}=ll;let{IS_ALLOWED_URI:Ta}=ll,me=null;const Ia=F({},[...il,...Gi,...qi,...Ki,...ol]);let ke=null;const Ca=F({},[...al,...Yi,...cl,...wr]);let le=Object.seal(zr(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}})),Xn=null,tr=null;const yt=Object.seal(zr(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let za=!0,_i=!0,$a=!1,Ra=!0,pn=!1,nr=!0,Lt=!1,yi=!1,ki=!1,fn=!1,sr=!1,rr=!1,Pa=!0,Da=!1;const Ad="user-content-";let wi=!0,Jn=!1,gn={},Xe=null;const bi=F({},["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 La=null;const Ma=F({},["audio","video","img","source","image","track"]);let Si=null;const Oa=F({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),ir="http://www.w3.org/1998/Math/MathML",or="http://www.w3.org/2000/svg",it="http://www.w3.org/1999/xhtml";let mn=it,xi=!1,Ei=null;const Td=F({},[ir,or,it],Bi);let ar=F({},["mi","mo","mn","ms","mtext"]),cr=F({},["annotation-xml"]);const Id=F({},["title","style","font","a","script"]);let Qn=null;const Cd=["application/xhtml+xml","text/html"],zd="text/html";let fe=null,vn=null;const $d=n.createElement("form"),Na=function(g){return g instanceof RegExp||g instanceof Function},Ai=function(){let g=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(!(vn&&vn===g)){if((!g||typeof g!="object")&&(g={}),g=Qe(g),Qn=Cd.indexOf(g.PARSER_MEDIA_TYPE)===-1?zd:g.PARSER_MEDIA_TYPE,fe=Qn==="application/xhtml+xml"?Bi:$r,me=Oe(g,"ALLOWED_TAGS")?F({},g.ALLOWED_TAGS,fe):Ia,ke=Oe(g,"ALLOWED_ATTR")?F({},g.ALLOWED_ATTR,fe):Ca,Ei=Oe(g,"ALLOWED_NAMESPACES")?F({},g.ALLOWED_NAMESPACES,Bi):Td,Si=Oe(g,"ADD_URI_SAFE_ATTR")?F(Qe(Oa),g.ADD_URI_SAFE_ATTR,fe):Oa,La=Oe(g,"ADD_DATA_URI_TAGS")?F(Qe(Ma),g.ADD_DATA_URI_TAGS,fe):Ma,Xe=Oe(g,"FORBID_CONTENTS")?F({},g.FORBID_CONTENTS,fe):bi,Xn=Oe(g,"FORBID_TAGS")?F({},g.FORBID_TAGS,fe):Qe({}),tr=Oe(g,"FORBID_ATTR")?F({},g.FORBID_ATTR,fe):Qe({}),gn=Oe(g,"USE_PROFILES")?g.USE_PROFILES:!1,za=g.ALLOW_ARIA_ATTR!==!1,_i=g.ALLOW_DATA_ATTR!==!1,$a=g.ALLOW_UNKNOWN_PROTOCOLS||!1,Ra=g.ALLOW_SELF_CLOSE_IN_ATTR!==!1,pn=g.SAFE_FOR_TEMPLATES||!1,nr=g.SAFE_FOR_XML!==!1,Lt=g.WHOLE_DOCUMENT||!1,fn=g.RETURN_DOM||!1,sr=g.RETURN_DOM_FRAGMENT||!1,rr=g.RETURN_TRUSTED_TYPE||!1,ki=g.FORCE_BODY||!1,Pa=g.SANITIZE_DOM!==!1,Da=g.SANITIZE_NAMED_PROPS||!1,wi=g.KEEP_CONTENT!==!1,Jn=g.IN_PLACE||!1,Ta=g.ALLOWED_URI_REGEXP||Qh,mn=g.NAMESPACE||it,ar=g.MATHML_TEXT_INTEGRATION_POINTS||ar,cr=g.HTML_INTEGRATION_POINTS||cr,le=g.CUSTOM_ELEMENT_HANDLING||{},g.CUSTOM_ELEMENT_HANDLING&&Na(g.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(le.tagNameCheck=g.CUSTOM_ELEMENT_HANDLING.tagNameCheck),g.CUSTOM_ELEMENT_HANDLING&&Na(g.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(le.attributeNameCheck=g.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),g.CUSTOM_ELEMENT_HANDLING&&typeof g.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements=="boolean"&&(le.allowCustomizedBuiltInElements=g.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),pn&&(_i=!1),sr&&(fn=!0),gn&&(me=F({},ol),ke=zr(null),gn.html===!0&&(F(me,il),F(ke,al)),gn.svg===!0&&(F(me,Gi),F(ke,Yi),F(ke,wr)),gn.svgFilters===!0&&(F(me,qi),F(ke,Yi),F(ke,wr)),gn.mathMl===!0&&(F(me,Ki),F(ke,cl),F(ke,wr))),Oe(g,"ADD_TAGS")||(yt.tagCheck=null),Oe(g,"ADD_ATTR")||(yt.attributeCheck=null),g.ADD_TAGS&&(typeof g.ADD_TAGS=="function"?yt.tagCheck=g.ADD_TAGS:(me===Ia&&(me=Qe(me)),F(me,g.ADD_TAGS,fe))),g.ADD_ATTR&&(typeof g.ADD_ATTR=="function"?yt.attributeCheck=g.ADD_ATTR:(ke===Ca&&(ke=Qe(ke)),F(ke,g.ADD_ATTR,fe))),g.ADD_URI_SAFE_ATTR&&F(Si,g.ADD_URI_SAFE_ATTR,fe),g.FORBID_CONTENTS&&(Xe===bi&&(Xe=Qe(Xe)),F(Xe,g.FORBID_CONTENTS,fe)),g.ADD_FORBID_CONTENTS&&(Xe===bi&&(Xe=Qe(Xe)),F(Xe,g.ADD_FORBID_CONTENTS,fe)),wi&&(me["#text"]=!0),Lt&&F(me,["html","head","body"]),me.table&&(F(me,["tbody"]),delete Xn.tbody),g.TRUSTED_TYPES_POLICY){if(typeof g.TRUSTED_TYPES_POLICY.createHTML!="function")throw is('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof g.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw is('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');M=g.TRUSTED_TYPES_POLICY,G=M.createHTML("")}else M===void 0&&(M=VS(v,r)),M!==null&&typeof G=="string"&&(G=M.createHTML(""));$e&&$e(g),vn=g}},Wa=F({},[...Gi,...qi,...LS]),Fa=F({},[...Ki,...MS]),Rd=function(g){let A=ye(g);(!A||!A.tagName)&&(A={namespaceURI:mn,tagName:"template"});const $=$r(g.tagName),ee=$r(A.tagName);return Ei[g.namespaceURI]?g.namespaceURI===or?A.namespaceURI===it?$==="svg":A.namespaceURI===ir?$==="svg"&&(ee==="annotation-xml"||ar[ee]):!!Wa[$]:g.namespaceURI===ir?A.namespaceURI===it?$==="math":A.namespaceURI===or?$==="math"&&cr[ee]:!!Fa[$]:g.namespaceURI===it?A.namespaceURI===or&&!cr[ee]||A.namespaceURI===ir&&!ar[ee]?!1:!Fa[$]&&(Id[$]||!Wa[$]):!!(Qn==="application/xhtml+xml"&&Ei[g.namespaceURI]):!1},Je=function(g){ss(t.removed,{element:g});try{ye(g).removeChild(g)}catch{z(g)}},Mt=function(g,A){try{ss(t.removed,{attribute:A.getAttributeNode(g),from:A})}catch{ss(t.removed,{attribute:null,from:A})}if(A.removeAttribute(g),g==="is")if(fn||sr)try{Je(A)}catch{}else try{A.setAttribute(g,"")}catch{}},Ua=function(g){let A=null,$=null;if(ki)g="<remove></remove>"+g;else{const he=Vi(g,/^[\r\n\t ]+/);$=he&&he[0]}Qn==="application/xhtml+xml"&&mn===it&&(g='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+g+"</body></html>");const ee=M?M.createHTML(g):g;if(mn===it)try{A=new w().parseFromString(ee,Qn)}catch{}if(!A||!A.documentElement){A=U.createDocument(mn,"template",null);try{A.documentElement.innerHTML=xi?G:ee}catch{}}const Ee=A.body||A.documentElement;return g&&$&&Ee.insertBefore(n.createTextNode($),Ee.childNodes[0]||null),mn===it?Kn.call(A,Lt?"html":"body")[0]:Lt?A.documentElement:Ee},Za=function(g){return Te.call(g.ownerDocument||g,g,l.SHOW_ELEMENT|l.SHOW_COMMENT|l.SHOW_TEXT|l.SHOW_PROCESSING_INSTRUCTION|l.SHOW_CDATA_SECTION,null)},Ti=function(g){return g instanceof f&&(typeof g.nodeName!="string"||typeof g.textContent!="string"||typeof g.removeChild!="function"||!(g.attributes instanceof h)||typeof g.removeAttribute!="function"||typeof g.setAttribute!="function"||typeof g.namespaceURI!="string"||typeof g.insertBefore!="function"||typeof g.hasChildNodes!="function")},ja=function(g){return typeof a=="function"&&g instanceof a};function ot(D,g,A){kr(D,$=>{$.call(t,g,A,vn)})}const Ha=function(g){let A=null;if(ot(xe.beforeSanitizeElements,g,null),Ti(g))return Je(g),!0;const $=fe(g.nodeName);if(ot(xe.uponSanitizeElement,g,{tagName:$,allowedTags:me}),nr&&g.hasChildNodes()&&!ja(g.firstElementChild)&&Ie(/<[/\w!]/g,g.innerHTML)&&Ie(/<[/\w!]/g,g.textContent)||g.nodeType===as.progressingInstruction||nr&&g.nodeType===as.comment&&Ie(/<[/\w]/g,g.data))return Je(g),!0;if(!(yt.tagCheck instanceof Function&&yt.tagCheck($))&&(!me[$]||Xn[$])){if(!Xn[$]&&Va($)&&(le.tagNameCheck instanceof RegExp&&Ie(le.tagNameCheck,$)||le.tagNameCheck instanceof Function&&le.tagNameCheck($)))return!1;if(wi&&!Xe[$]){const ee=ye(g)||g.parentNode,Ee=Z(g)||g.childNodes;if(Ee&&ee){const he=Ee.length;for(let Pe=he-1;Pe>=0;--Pe){const at=x(Ee[Pe],!0);at.__removalCount=(g.__removalCount||0)+1,ee.insertBefore(at,K(g))}}}return Je(g),!0}return g instanceof c&&!Rd(g)||($==="noscript"||$==="noembed"||$==="noframes")&&Ie(/<\/no(script|embed|frames)/i,g.innerHTML)?(Je(g),!0):(pn&&g.nodeType===as.text&&(A=g.textContent,kr([Yn,mi,vi],ee=>{A=rs(A,ee," ")}),g.textContent!==A&&(ss(t.removed,{element:g.cloneNode()}),g.textContent=A)),ot(xe.afterSanitizeElements,g,null),!1)},Ba=function(g,A,$){if(tr[A]||Pa&&(A==="id"||A==="name")&&($ in n||$ in $d))return!1;if(!(_i&&!tr[A]&&Ie(bd,A))){if(!(za&&Ie(Sd,A))){if(!(yt.attributeCheck instanceof Function&&yt.attributeCheck(A,g))){if(!ke[A]||tr[A]){if(!(Va(g)&&(le.tagNameCheck instanceof RegExp&&Ie(le.tagNameCheck,g)||le.tagNameCheck instanceof Function&&le.tagNameCheck(g))&&(le.attributeNameCheck instanceof RegExp&&Ie(le.attributeNameCheck,A)||le.attributeNameCheck instanceof Function&&le.attributeNameCheck(A,g))||A==="is"&&le.allowCustomizedBuiltInElements&&(le.tagNameCheck instanceof RegExp&&Ie(le.tagNameCheck,$)||le.tagNameCheck instanceof Function&&le.tagNameCheck($))))return!1}else if(!Si[A]){if(!Ie(Ta,rs($,Aa,""))){if(!((A==="src"||A==="xlink:href"||A==="href")&&g!=="script"&&$S($,"data:")===0&&La[g])){if(!($a&&!Ie(xd,rs($,Aa,"")))){if($)return!1}}}}}}}return!0},Va=function(g){return g!=="annotation-xml"&&Vi(g,Ed)},Ga=function(g){ot(xe.beforeSanitizeAttributes,g,null);const{attributes:A}=g;if(!A||Ti(g))return;const $={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:ke,forceKeepAttr:void 0};let ee=A.length;for(;ee--;){const Ee=A[ee],{name:he,namespaceURI:Pe,value:at}=Ee,_n=fe(he),Ii=at;let we=he==="value"?Ii:RS(Ii);if($.attrName=_n,$.attrValue=we,$.keepAttr=!0,$.forceKeepAttr=void 0,ot(xe.uponSanitizeAttribute,g,$),we=$.attrValue,Da&&(_n==="id"||_n==="name")&&(Mt(he,g),we=Ad+we),nr&&Ie(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,we)){Mt(he,g);continue}if(_n==="attributename"&&Vi(we,"href")){Mt(he,g);continue}if($.forceKeepAttr)continue;if(!$.keepAttr){Mt(he,g);continue}if(!Ra&&Ie(/\/>/i,we)){Mt(he,g);continue}pn&&kr([Yn,mi,vi],Ka=>{we=rs(we,Ka," ")});const qa=fe(g.nodeName);if(!Ba(qa,_n,we)){Mt(he,g);continue}if(M&&typeof v=="object"&&typeof v.getAttributeType=="function"&&!Pe)switch(v.getAttributeType(qa,_n)){case"TrustedHTML":{we=M.createHTML(we);break}case"TrustedScriptURL":{we=M.createScriptURL(we);break}}if(we!==Ii)try{Pe?g.setAttributeNS(Pe,he,we):g.setAttribute(he,we),Ti(g)?Je(g):rl(t.removed)}catch{Mt(he,g)}}ot(xe.afterSanitizeAttributes,g,null)},Pd=function D(g){let A=null;const $=Za(g);for(ot(xe.beforeSanitizeShadowDOM,g,null);A=$.nextNode();)ot(xe.uponSanitizeShadowNode,A,null),Ha(A),Ga(A),A.content instanceof i&&D(A.content);ot(xe.afterSanitizeShadowDOM,g,null)};return t.sanitize=function(D){let g=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},A=null,$=null,ee=null,Ee=null;if(xi=!D,xi&&(D="<!-->"),typeof D!="string"&&!ja(D))if(typeof D.toString=="function"){if(D=D.toString(),typeof D!="string")throw is("dirty is not a string, aborting")}else throw is("toString is not a function");if(!t.isSupported)return D;if(yi||Ai(g),t.removed=[],typeof D=="string"&&(Jn=!1),Jn){if(D.nodeName){const at=fe(D.nodeName);if(!me[at]||Xn[at])throw is("root node is forbidden and cannot be sanitized in-place")}}else if(D instanceof a)A=Ua("<!---->"),$=A.ownerDocument.importNode(D,!0),$.nodeType===as.element&&$.nodeName==="BODY"||$.nodeName==="HTML"?A=$:A.appendChild($);else{if(!fn&&!pn&&!Lt&&D.indexOf("<")===-1)return M&&rr?M.createHTML(D):D;if(A=Ua(D),!A)return fn?null:rr?G:""}A&&ki&&Je(A.firstChild);const he=Za(Jn?D:A);for(;ee=he.nextNode();)Ha(ee),Ga(ee),ee.content instanceof i&&Pd(ee.content);if(Jn)return D;if(fn){if(sr)for(Ee=X.call(A.ownerDocument);A.firstChild;)Ee.appendChild(A.firstChild);else Ee=A;return(ke.shadowroot||ke.shadowrootmode)&&(Ee=dn.call(s,Ee,!0)),Ee}let Pe=Lt?A.outerHTML:A.innerHTML;return Lt&&me["!doctype"]&&A.ownerDocument&&A.ownerDocument.doctype&&A.ownerDocument.doctype.name&&Ie(ed,A.ownerDocument.doctype.name)&&(Pe="<!DOCTYPE "+A.ownerDocument.doctype.name+`>
|
|
256
|
-
`+Pe),pn&&kr([Yn,mi,vi],at=>{Pe=rs(Pe,at," ")}),M&&rr?M.createHTML(Pe):Pe},t.setConfig=function(){let D=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};Ai(D),yi=!0},t.clearConfig=function(){vn=null,yi=!1},t.isValidAttribute=function(D,g,A){vn||Ai({});const $=fe(D),ee=fe(g);return Ba($,ee,A)},t.addHook=function(D,g){typeof g=="function"&&ss(xe[D],g)},t.removeHook=function(D,g){if(g!==void 0){const A=CS(xe[D],g);return A===-1?void 0:zS(xe[D],A,1)[0]}return rl(xe[D])},t.removeHooks=function(D){xe[D]=[]},t.removeAllHooks=function(){xe=ul()},t}var nd=td();function ca(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var hn=ca();function sd(e){hn=e}var Ht={exec:()=>null};function j(e,t=""){let n=typeof e=="string"?e:e.source,s={replace:(r,i)=>{let o=typeof i=="string"?i:i.source;return o=o.replace(ze.caret,"$1"),n=n.replace(r,o),s},getRegex:()=>new RegExp(n,t)};return s}var GS=(()=>{try{return!!new RegExp("(?<=1)(?<!1)")}catch{return!1}})(),ze={codeRemoveIndent:/^(?: {1,4}| {0,3}\t)/gm,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,multipleSpaceGlobal:/\s+/g,blankLine:/^[ \t]*$/,doubleBlankLine:/\n[ \t]*\n[ \t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] +\S/,listReplaceTask:/^\[[ xX]\] +/,listTaskCheckbox:/\[[ xX]\]/,anyLine:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\||\| *$/g,tableRowBlankLine:/\n[ \t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^<a /i,endATag:/^<\/a>/i,startPreScriptTag:/^<(pre|code|kbd|script)(\s|>)/i,endPreScriptTag:/^<\/(pre|code|kbd|script)(\s|>)/i,startAngleBracket:/^</,endAngleBracket:/>$/,pedanticHrefTitle:/^([^'"]*[^\s])\s+(['"])(.*)\2/,unicodeAlphaNumeric:/[\p{L}\p{N}]/u,escapeTest:/[&<>"']/,escapeReplace:/[&<>"']/g,escapeTestNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeReplaceNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:e=>new RegExp(`^( {0,3}${e})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:e=>new RegExp(`^ {0,${Math.min(3,e-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),hrRegex:e=>new RegExp(`^ {0,${Math.min(3,e-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),fencesBeginRegex:e=>new RegExp(`^ {0,${Math.min(3,e-1)}}(?:\`\`\`|~~~)`),headingBeginRegex:e=>new RegExp(`^ {0,${Math.min(3,e-1)}}#`),htmlBeginRegex:e=>new RegExp(`^ {0,${Math.min(3,e-1)}}<(?:[a-z].*>|!--)`,"i"),blockquoteBeginRegex:e=>new RegExp(`^ {0,${Math.min(3,e-1)}}>`)},qS=/^(?:[ \t]*(?:\n|$))+/,KS=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,YS=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,er=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,XS=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,la=/ {0,3}(?:[*+-]|\d{1,9}[.)])/,rd=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,id=j(rd).replace(/bull/g,la).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(),JS=j(rd).replace(/bull/g,la).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(),ua=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,QS=/^[^\n]+/,ha=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,e0=j(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",ha).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),t0=j(/^(bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,la).getRegex(),pi="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",da=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,n0=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",da).replace("tag",pi).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),od=j(ua).replace("hr",er).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",pi).getRegex(),s0=j(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",od).getRegex(),pa={blockquote:s0,code:KS,def:e0,fences:YS,heading:XS,hr:er,html:n0,lheading:id,list:t0,newline:qS,paragraph:od,table:Ht,text:QS},hl=j("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",er).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",pi).getRegex(),r0={...pa,lheading:JS,table:hl,paragraph:j(ua).replace("hr",er).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",hl).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",pi).getRegex()},i0={...pa,html:j(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",da).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:Ht,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:j(ua).replace("hr",er).replace("heading",` *#{1,6} *[^
|
|
257
|
-
]`).replace("lheading",id).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},o0=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,a0=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,ad=/^( {2,}|\\)\n(?!\s*$)/,c0=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,qn=/[\p{P}\p{S}]/u,fi=/[\s\p{P}\p{S}]/u,fa=/[^\s\p{P}\p{S}]/u,l0=j(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,fi).getRegex(),cd=/(?!~)[\p{P}\p{S}]/u,u0=/(?!~)[\s\p{P}\p{S}]/u,h0=/(?:[^\s\p{P}\p{S}]|~)/u,d0=j(/link|precode-code|html/,"g").replace("link",/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-",GS?"(?<!`)()":"(^^|[^`])").replace("code",/(?<b>`+)[^`]+\k<b>(?!`)/).replace("html",/<(?! )[^<>]*?>/).getRegex(),ld=/^(?:\*+(?:((?!\*)punct)|([^\s*]))?)|^_+(?:((?!_)punct)|([^\s_]))?/,p0=j(ld,"u").replace(/punct/g,qn).getRegex(),f0=j(ld,"u").replace(/punct/g,cd).getRegex(),ud="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",g0=j(ud,"gu").replace(/notPunctSpace/g,fa).replace(/punctSpace/g,fi).replace(/punct/g,qn).getRegex(),m0=j(ud,"gu").replace(/notPunctSpace/g,h0).replace(/punctSpace/g,u0).replace(/punct/g,cd).getRegex(),v0=j("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,fa).replace(/punctSpace/g,fi).replace(/punct/g,qn).getRegex(),_0=j(/^~~?(?:((?!~)punct)|[^\s~])/,"u").replace(/punct/g,qn).getRegex(),y0="^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)",k0=j(y0,"gu").replace(/notPunctSpace/g,fa).replace(/punctSpace/g,fi).replace(/punct/g,qn).getRegex(),w0=j(/\\(punct)/,"gu").replace(/punct/g,qn).getRegex(),b0=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(),S0=j(da).replace("(?:-->|$)","-->").getRegex(),x0=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",S0).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),jr=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\])|[^\[\]\\`])*?/,E0=j(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?\s*\)/).replace("label",jr).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),hd=j(/^!?\[(label)\]\[(ref)\]/).replace("label",jr).replace("ref",ha).getRegex(),dd=j(/^!?\[(ref)\](?:\[\])?/).replace("ref",ha).getRegex(),A0=j("reflink|nolink(?!\\()","g").replace("reflink",hd).replace("nolink",dd).getRegex(),dl=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,ga={_backpedal:Ht,anyPunctuation:w0,autolink:b0,blockSkip:d0,br:ad,code:a0,del:Ht,delLDelim:Ht,delRDelim:Ht,emStrongLDelim:p0,emStrongRDelimAst:g0,emStrongRDelimUnd:v0,escape:o0,link:E0,nolink:dd,punctuation:l0,reflink:hd,reflinkSearch:A0,tag:x0,text:c0,url:Ht},T0={...ga,link:j(/^!?\[(label)\]\((.*?)\)/).replace("label",jr).getRegex(),reflink:j(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",jr).getRegex()},No={...ga,emStrongRDelimAst:m0,emStrongLDelim:f0,delLDelim:_0,delRDelim:k0,url:j(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol",dl).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",dl).getRegex()},I0={...No,br:j(ad).replace("{2,}","*").getRegex(),text:j(No.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},br={normal:pa,gfm:r0,pedantic:i0},cs={normal:ga,gfm:No,breaks:I0,pedantic:T0},C0={"&":"&","<":"<",">":">",'"':""","'":"'"},pl=e=>C0[e];function et(e,t){if(t){if(ze.escapeTest.test(e))return e.replace(ze.escapeReplace,pl)}else if(ze.escapeTestNoEncode.test(e))return e.replace(ze.escapeReplaceNoEncode,pl);return e}function fl(e){try{e=encodeURI(e).replace(ze.percentDecode,"%")}catch{return null}return e}function gl(e,t){var i;let n=e.replace(ze.findPipe,(o,a,c)=>{let l=!1,h=a;for(;--h>=0&&c[h]==="\\";)l=!l;return l?"|":" |"}),s=n.split(ze.splitPipe),r=0;if(s[0].trim()||s.shift(),s.length>0&&!((i=s.at(-1))!=null&&i.trim())&&s.pop(),t)if(s.length>t)s.splice(t);else for(;s.length<t;)s.push("");for(;r<s.length;r++)s[r]=s[r].trim().replace(ze.slashPipe,"|");return s}function ls(e,t,n){let s=e.length;if(s===0)return"";let r=0;for(;r<s&&e.charAt(s-r-1)===t;)r++;return e.slice(0,s-r)}function z0(e,t){if(e.indexOf(t[1])===-1)return-1;let n=0;for(let s=0;s<e.length;s++)if(e[s]==="\\")s++;else if(e[s]===t[0])n++;else if(e[s]===t[1]&&(n--,n<0))return s;return n>0?-2:-1}function $0(e,t=0){let n=t,s="";for(let r of e)if(r===" "){let i=4-n%4;s+=" ".repeat(i),n+=i}else s+=r,n++;return s}function ml(e,t,n,s,r){let i=t.href,o=t.title||null,a=e[1].replace(r.other.outputLinkReplace,"$1");s.state.inLink=!0;let c={type:e[0].charAt(0)==="!"?"image":"link",raw:n,href:i,title:o,text:a,tokens:s.inlineTokens(a)};return s.state.inLink=!1,c}function R0(e,t,n){let s=e.match(n.other.indentCodeCompensation);if(s===null)return t;let r=s[1];return t.split(`
|
|
258
|
-
`).map(i=>{let o=i.match(n.other.beginningSpace);if(o===null)return i;let[a]=o;return a.length>=r.length?i.slice(r.length):i}).join(`
|
|
259
|
-
`)}var Hr=class{constructor(e){m(this,"options");m(this,"rules");m(this,"lexer");this.options=e||hn}space(e){let t=this.rules.block.newline.exec(e);if(t&&t[0].length>0)return{type:"space",raw:t[0]}}code(e){let t=this.rules.block.code.exec(e);if(t){let n=t[0].replace(this.rules.other.codeRemoveIndent,"");return{type:"code",raw:t[0],codeBlockStyle:"indented",text:this.options.pedantic?n:ls(n,`
|
|
260
|
-
`)}}}fences(e){let t=this.rules.block.fences.exec(e);if(t){let n=t[0],s=R0(n,t[3]||"",this.rules);return{type:"code",raw:n,lang:t[2]?t[2].trim().replace(this.rules.inline.anyPunctuation,"$1"):t[2],text:s}}}heading(e){let t=this.rules.block.heading.exec(e);if(t){let n=t[2].trim();if(this.rules.other.endingHash.test(n)){let s=ls(n,"#");(this.options.pedantic||!s||this.rules.other.endingSpaceChar.test(s))&&(n=s.trim())}return{type:"heading",raw:t[0],depth:t[1].length,text:n,tokens:this.lexer.inline(n)}}}hr(e){let t=this.rules.block.hr.exec(e);if(t)return{type:"hr",raw:ls(t[0],`
|
|
261
|
-
`)}}blockquote(e){let t=this.rules.block.blockquote.exec(e);if(t){let n=ls(t[0],`
|
|
262
|
-
`).split(`
|
|
263
|
-
`),s="",r="",i=[];for(;n.length>0;){let o=!1,a=[],c;for(c=0;c<n.length;c++)if(this.rules.other.blockquoteStart.test(n[c]))a.push(n[c]),o=!0;else if(!o)a.push(n[c]);else break;n=n.slice(c);let l=a.join(`
|
|
264
|
-
`),h=l.replace(this.rules.other.blockquoteSetextReplace,`
|
|
265
|
-
$1`).replace(this.rules.other.blockquoteSetextReplace2,"");s=s?`${s}
|
|
266
|
-
${l}`:l,r=r?`${r}
|
|
267
|
-
${h}`:h;let f=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(h,i,!0),this.lexer.state.top=f,n.length===0)break;let w=i.at(-1);if((w==null?void 0:w.type)==="code")break;if((w==null?void 0:w.type)==="blockquote"){let v=w,E=v.raw+`
|
|
268
|
-
`+n.join(`
|
|
269
|
-
`),x=this.blockquote(E);i[i.length-1]=x,s=s.substring(0,s.length-v.raw.length)+x.raw,r=r.substring(0,r.length-v.text.length)+x.text;break}else if((w==null?void 0:w.type)==="list"){let v=w,E=v.raw+`
|
|
270
|
-
`+n.join(`
|
|
271
|
-
`),x=this.list(E);i[i.length-1]=x,s=s.substring(0,s.length-w.raw.length)+x.raw,r=r.substring(0,r.length-v.raw.length)+x.raw,n=E.substring(i.at(-1).raw.length).split(`
|
|
272
|
-
`);continue}}return{type:"blockquote",raw:s,tokens:i,text:r}}}list(e){var n,s;let t=this.rules.block.list.exec(e);if(t){let r=t[1].trim(),i=r.length>1,o={type:"list",raw:"",ordered:i,start:i?+r.slice(0,-1):"",loose:!1,items:[]};r=i?`\\d{1,9}\\${r.slice(-1)}`:`\\${r}`,this.options.pedantic&&(r=i?r:"[*+-]");let a=this.rules.other.listItemRegex(r),c=!1;for(;e;){let h=!1,f="",w="";if(!(t=a.exec(e))||this.rules.block.hr.test(e))break;f=t[0],e=e.substring(f.length);let v=$0(t[2].split(`
|
|
273
|
-
`,1)[0],t[1].length),E=e.split(`
|
|
274
|
-
`,1)[0],x=!v.trim(),z=0;if(this.options.pedantic?(z=2,w=v.trimStart()):x?z=t[1].length+1:(z=v.search(this.rules.other.nonSpaceChar),z=z>4?1:z,w=v.slice(z),z+=t[1].length),x&&this.rules.other.blankLine.test(E)&&(f+=E+`
|
|
275
|
-
`,e=e.substring(E.length+1),h=!0),!h){let K=this.rules.other.nextBulletRegex(z),Z=this.rules.other.hrRegex(z),ye=this.rules.other.fencesBeginRegex(z),M=this.rules.other.headingBeginRegex(z),G=this.rules.other.htmlBeginRegex(z),U=this.rules.other.blockquoteBeginRegex(z);for(;e;){let Te=e.split(`
|
|
276
|
-
`,1)[0],X;if(E=Te,this.options.pedantic?(E=E.replace(this.rules.other.listReplaceNesting," "),X=E):X=E.replace(this.rules.other.tabCharGlobal," "),ye.test(E)||M.test(E)||G.test(E)||U.test(E)||K.test(E)||Z.test(E))break;if(X.search(this.rules.other.nonSpaceChar)>=z||!E.trim())w+=`
|
|
277
|
-
`+X.slice(z);else{if(x||v.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4||ye.test(v)||M.test(v)||Z.test(v))break;w+=`
|
|
278
|
-
`+E}x=!E.trim(),f+=Te+`
|
|
279
|
-
`,e=e.substring(Te.length+1),v=X.slice(z)}}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(w),loose:!1,text:w,tokens:[]}),o.raw+=f}let l=o.items.at(-1);if(l)l.raw=l.raw.trimEnd(),l.text=l.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,""),((n=h.tokens[0])==null?void 0:n.type)==="text"||((s=h.tokens[0])==null?void 0:s.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 w=this.lexer.inlineQueue.length-1;w>=0;w--)if(this.rules.other.listIsTask.test(this.lexer.inlineQueue[w].src)){this.lexer.inlineQueue[w].src=this.lexer.inlineQueue[w].src.replace(this.rules.other.listReplaceTask,"");break}}let f=this.rules.other.listTaskCheckbox.exec(h.raw);if(f){let w={type:"checkbox",raw:f[0]+" ",checked:f[0]!=="[ ]"};h.checked=w.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=w.raw+h.tokens[0].raw,h.tokens[0].text=w.raw+h.tokens[0].text,h.tokens[0].tokens.unshift(w)):h.tokens.unshift({type:"paragraph",raw:w.raw,text:w.raw,tokens:[w]}):h.tokens.unshift(w)}}if(!o.loose){let f=h.tokens.filter(v=>v.type==="space"),w=f.length>0&&f.some(v=>this.rules.other.anyLine.test(v.raw));o.loose=w}}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(e){let t=this.rules.block.html.exec(e);if(t)return{type:"html",block:!0,raw:t[0],pre:t[1]==="pre"||t[1]==="script"||t[1]==="style",text:t[0]}}def(e){let t=this.rules.block.def.exec(e);if(t){let n=t[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal," "),s=t[2]?t[2].replace(this.rules.other.hrefBrackets,"$1").replace(this.rules.inline.anyPunctuation,"$1"):"",r=t[3]?t[3].substring(1,t[3].length-1).replace(this.rules.inline.anyPunctuation,"$1"):t[3];return{type:"def",tag:n,raw:t[0],href:s,title:r}}}table(e){var o;let t=this.rules.block.table.exec(e);if(!t||!this.rules.other.tableDelimiter.test(t[2]))return;let n=gl(t[1]),s=t[2].replace(this.rules.other.tableAlignChars,"").split("|"),r=(o=t[3])!=null&&o.trim()?t[3].replace(this.rules.other.tableRowBlankLine,"").split(`
|
|
280
|
-
`):[],i={type:"table",raw:t[0],header:[],align:[],rows:[]};if(n.length===s.length){for(let a of s)this.rules.other.tableAlignRight.test(a)?i.align.push("right"):this.rules.other.tableAlignCenter.test(a)?i.align.push("center"):this.rules.other.tableAlignLeft.test(a)?i.align.push("left"):i.align.push(null);for(let a=0;a<n.length;a++)i.header.push({text:n[a],tokens:this.lexer.inline(n[a]),header:!0,align:i.align[a]});for(let a of r)i.rows.push(gl(a,i.header.length).map((c,l)=>({text:c,tokens:this.lexer.inline(c),header:!1,align:i.align[l]})));return i}}lheading(e){let t=this.rules.block.lheading.exec(e);if(t){let n=t[1].trim();return{type:"heading",raw:t[0],depth:t[2].charAt(0)==="="?1:2,text:n,tokens:this.lexer.inline(n)}}}paragraph(e){let t=this.rules.block.paragraph.exec(e);if(t){let n=t[1].charAt(t[1].length-1)===`
|
|
281
|
-
`?t[1].slice(0,-1):t[1];return{type:"paragraph",raw:t[0],text:n,tokens:this.lexer.inline(n)}}}text(e){let t=this.rules.block.text.exec(e);if(t)return{type:"text",raw:t[0],text:t[0],tokens:this.lexer.inline(t[0])}}escape(e){let t=this.rules.inline.escape.exec(e);if(t)return{type:"escape",raw:t[0],text:t[1]}}tag(e){let t=this.rules.inline.tag.exec(e);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(e){let t=this.rules.inline.link.exec(e);if(t){let n=t[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(n)){if(!this.rules.other.endAngleBracket.test(n))return;let i=ls(n.slice(0,-1),"\\");if((n.length-i.length)%2===0)return}else{let i=z0(t[2],"()");if(i===-2)return;if(i>-1){let o=(t[0].indexOf("!")===0?5:4)+t[1].length+i;t[2]=t[2].substring(0,i),t[0]=t[0].substring(0,o).trim(),t[3]=""}}let s=t[2],r="";if(this.options.pedantic){let i=this.rules.other.pedanticHrefTitle.exec(s);i&&(s=i[1],r=i[3])}else r=t[3]?t[3].slice(1,-1):"";return s=s.trim(),this.rules.other.startAngleBracket.test(s)&&(this.options.pedantic&&!this.rules.other.endAngleBracket.test(n)?s=s.slice(1):s=s.slice(1,-1)),ml(t,{href:s&&s.replace(this.rules.inline.anyPunctuation,"$1"),title:r&&r.replace(this.rules.inline.anyPunctuation,"$1")},t[0],this.lexer,this.rules)}}reflink(e,t){let n;if((n=this.rules.inline.reflink.exec(e))||(n=this.rules.inline.nolink.exec(e))){let s=(n[2]||n[1]).replace(this.rules.other.multipleSpaceGlobal," "),r=t[s.toLowerCase()];if(!r){let i=n[0].charAt(0);return{type:"text",raw:i,text:i}}return ml(n,r,n[0],this.lexer,this.rules)}}emStrong(e,t,n=""){let s=this.rules.inline.emStrongLDelim.exec(e);if(!(!s||!s[1]&&!s[2]&&!s[3]&&!s[4]||s[4]&&n.match(this.rules.other.unicodeAlphaNumeric))&&(!(s[1]||s[3])||!n||this.rules.inline.punctuation.exec(n))){let r=[...s[0]].length-1,i,o,a=r,c=0,l=s[0][0]==="*"?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(l.lastIndex=0,t=t.slice(-1*e.length+r);(s=l.exec(t))!=null;){if(i=s[1]||s[2]||s[3]||s[4]||s[5]||s[6],!i)continue;if(o=[...i].length,s[3]||s[4]){a+=o;continue}else if((s[5]||s[6])&&r%3&&!((r+o)%3)){c+=o;continue}if(a-=o,a>0)continue;o=Math.min(o,o+a+c);let h=[...s[0]][0].length,f=e.slice(0,r+s.index+h+o);if(Math.min(r,o)%2){let v=f.slice(1,-1);return{type:"em",raw:f,text:v,tokens:this.lexer.inlineTokens(v)}}let w=f.slice(2,-2);return{type:"strong",raw:f,text:w,tokens:this.lexer.inlineTokens(w)}}}}codespan(e){let t=this.rules.inline.code.exec(e);if(t){let n=t[2].replace(this.rules.other.newLineCharGlobal," "),s=this.rules.other.nonSpaceChar.test(n),r=this.rules.other.startingSpaceChar.test(n)&&this.rules.other.endingSpaceChar.test(n);return s&&r&&(n=n.substring(1,n.length-1)),{type:"codespan",raw:t[0],text:n}}}br(e){let t=this.rules.inline.br.exec(e);if(t)return{type:"br",raw:t[0]}}del(e,t,n=""){let s=this.rules.inline.delLDelim.exec(e);if(s&&(!s[1]||!n||this.rules.inline.punctuation.exec(n))){let r=[...s[0]].length-1,i,o,a=r,c=this.rules.inline.delRDelim;for(c.lastIndex=0,t=t.slice(-1*e.length+r);(s=c.exec(t))!=null;){if(i=s[1]||s[2]||s[3]||s[4]||s[5]||s[6],!i||(o=[...i].length,o!==r))continue;if(s[3]||s[4]){a+=o;continue}if(a-=o,a>0)continue;o=Math.min(o,o+a);let l=[...s[0]][0].length,h=e.slice(0,r+s.index+l+o),f=h.slice(r,-r);return{type:"del",raw:h,text:f,tokens:this.lexer.inlineTokens(f)}}}}autolink(e){let t=this.rules.inline.autolink.exec(e);if(t){let n,s;return t[2]==="@"?(n=t[1],s="mailto:"+n):(n=t[1],s=n),{type:"link",raw:t[0],text:n,href:s,tokens:[{type:"text",raw:n,text:n}]}}}url(e){var n;let t;if(t=this.rules.inline.url.exec(e)){let s,r;if(t[2]==="@")s=t[0],r="mailto:"+s;else{let i;do i=t[0],t[0]=((n=this.rules.inline._backpedal.exec(t[0]))==null?void 0:n[0])??"";while(i!==t[0]);s=t[0],t[1]==="www."?r="http://"+t[0]:r=t[0]}return{type:"link",raw:t[0],text:s,href:r,tokens:[{type:"text",raw:s,text:s}]}}}inlineText(e){let t=this.rules.inline.text.exec(e);if(t){let n=this.lexer.state.inRawBlock;return{type:"text",raw:t[0],text:t[0],escaped:n}}}},qe=class Wo{constructor(t){m(this,"tokens");m(this,"options");m(this,"state");m(this,"inlineQueue");m(this,"tokenizer");this.tokens=[],this.tokens.links=Object.create(null),this.options=t||hn,this.options.tokenizer=this.options.tokenizer||new Hr,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,top:!0};let n={other:ze,block:br.normal,inline:cs.normal};this.options.pedantic?(n.block=br.pedantic,n.inline=cs.pedantic):this.options.gfm&&(n.block=br.gfm,this.options.breaks?n.inline=cs.breaks:n.inline=cs.gfm),this.tokenizer.rules=n}static get rules(){return{block:br,inline:cs}}static lex(t,n){return new Wo(n).lex(t)}static lexInline(t,n){return new Wo(n).inlineTokens(t)}lex(t){t=t.replace(ze.carriageReturn,`
|
|
282
|
-
`),this.blockTokens(t,this.tokens);for(let n=0;n<this.inlineQueue.length;n++){let s=this.inlineQueue[n];this.inlineTokens(s.src,s.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(t,n=[],s=!1){var r,i,o;for(this.tokenizer.lexer=this,this.options.pedantic&&(t=t.replace(ze.tabCharGlobal," ").replace(ze.spaceLine,""));t;){let a;if((i=(r=this.options.extensions)==null?void 0:r.block)!=null&&i.some(l=>(a=l.call({lexer:this},t,n))?(t=t.substring(a.raw.length),n.push(a),!0):!1))continue;if(a=this.tokenizer.space(t)){t=t.substring(a.raw.length);let l=n.at(-1);a.raw.length===1&&l!==void 0?l.raw+=`
|
|
283
|
-
`:n.push(a);continue}if(a=this.tokenizer.code(t)){t=t.substring(a.raw.length);let l=n.at(-1);(l==null?void 0:l.type)==="paragraph"||(l==null?void 0:l.type)==="text"?(l.raw+=(l.raw.endsWith(`
|
|
284
|
-
`)?"":`
|
|
285
|
-
`)+a.raw,l.text+=`
|
|
286
|
-
`+a.text,this.inlineQueue.at(-1).src=l.text):n.push(a);continue}if(a=this.tokenizer.fences(t)){t=t.substring(a.raw.length),n.push(a);continue}if(a=this.tokenizer.heading(t)){t=t.substring(a.raw.length),n.push(a);continue}if(a=this.tokenizer.hr(t)){t=t.substring(a.raw.length),n.push(a);continue}if(a=this.tokenizer.blockquote(t)){t=t.substring(a.raw.length),n.push(a);continue}if(a=this.tokenizer.list(t)){t=t.substring(a.raw.length),n.push(a);continue}if(a=this.tokenizer.html(t)){t=t.substring(a.raw.length),n.push(a);continue}if(a=this.tokenizer.def(t)){t=t.substring(a.raw.length);let l=n.at(-1);(l==null?void 0:l.type)==="paragraph"||(l==null?void 0:l.type)==="text"?(l.raw+=(l.raw.endsWith(`
|
|
287
|
-
`)?"":`
|
|
288
|
-
`)+a.raw,l.text+=`
|
|
289
|
-
`+a.raw,this.inlineQueue.at(-1).src=l.text):this.tokens.links[a.tag]||(this.tokens.links[a.tag]={href:a.href,title:a.title},n.push(a));continue}if(a=this.tokenizer.table(t)){t=t.substring(a.raw.length),n.push(a);continue}if(a=this.tokenizer.lheading(t)){t=t.substring(a.raw.length),n.push(a);continue}let c=t;if((o=this.options.extensions)!=null&&o.startBlock){let l=1/0,h=t.slice(1),f;this.options.extensions.startBlock.forEach(w=>{f=w.call({lexer:this},h),typeof f=="number"&&f>=0&&(l=Math.min(l,f))}),l<1/0&&l>=0&&(c=t.substring(0,l+1))}if(this.state.top&&(a=this.tokenizer.paragraph(c))){let l=n.at(-1);s&&(l==null?void 0:l.type)==="paragraph"?(l.raw+=(l.raw.endsWith(`
|
|
290
|
-
`)?"":`
|
|
291
|
-
`)+a.raw,l.text+=`
|
|
292
|
-
`+a.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=l.text):n.push(a),s=c.length!==t.length,t=t.substring(a.raw.length);continue}if(a=this.tokenizer.text(t)){t=t.substring(a.raw.length);let l=n.at(-1);(l==null?void 0:l.type)==="text"?(l.raw+=(l.raw.endsWith(`
|
|
293
|
-
`)?"":`
|
|
294
|
-
`)+a.raw,l.text+=`
|
|
295
|
-
`+a.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=l.text):n.push(a);continue}if(t){let l="Infinite loop on byte: "+t.charCodeAt(0);if(this.options.silent){console.error(l);break}else throw new Error(l)}}return this.state.top=!0,n}inline(t,n=[]){return this.inlineQueue.push({src:t,tokens:n}),n}inlineTokens(t,n=[]){var c,l,h,f,w;this.tokenizer.lexer=this;let s=t,r=null;if(this.tokens.links){let v=Object.keys(this.tokens.links);if(v.length>0)for(;(r=this.tokenizer.rules.inline.reflinkSearch.exec(s))!=null;)v.includes(r[0].slice(r[0].lastIndexOf("[")+1,-1))&&(s=s.slice(0,r.index)+"["+"a".repeat(r[0].length-2)+"]"+s.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;(r=this.tokenizer.rules.inline.anyPunctuation.exec(s))!=null;)s=s.slice(0,r.index)+"++"+s.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);let i;for(;(r=this.tokenizer.rules.inline.blockSkip.exec(s))!=null;)i=r[2]?r[2].length:0,s=s.slice(0,r.index+i)+"["+"a".repeat(r[0].length-i-2)+"]"+s.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);s=((l=(c=this.options.hooks)==null?void 0:c.emStrongMask)==null?void 0:l.call({lexer:this},s))??s;let o=!1,a="";for(;t;){o||(a=""),o=!1;let v;if((f=(h=this.options.extensions)==null?void 0:h.inline)!=null&&f.some(x=>(v=x.call({lexer:this},t,n))?(t=t.substring(v.raw.length),n.push(v),!0):!1))continue;if(v=this.tokenizer.escape(t)){t=t.substring(v.raw.length),n.push(v);continue}if(v=this.tokenizer.tag(t)){t=t.substring(v.raw.length),n.push(v);continue}if(v=this.tokenizer.link(t)){t=t.substring(v.raw.length),n.push(v);continue}if(v=this.tokenizer.reflink(t,this.tokens.links)){t=t.substring(v.raw.length);let x=n.at(-1);v.type==="text"&&(x==null?void 0:x.type)==="text"?(x.raw+=v.raw,x.text+=v.text):n.push(v);continue}if(v=this.tokenizer.emStrong(t,s,a)){t=t.substring(v.raw.length),n.push(v);continue}if(v=this.tokenizer.codespan(t)){t=t.substring(v.raw.length),n.push(v);continue}if(v=this.tokenizer.br(t)){t=t.substring(v.raw.length),n.push(v);continue}if(v=this.tokenizer.del(t,s,a)){t=t.substring(v.raw.length),n.push(v);continue}if(v=this.tokenizer.autolink(t)){t=t.substring(v.raw.length),n.push(v);continue}if(!this.state.inLink&&(v=this.tokenizer.url(t))){t=t.substring(v.raw.length),n.push(v);continue}let E=t;if((w=this.options.extensions)!=null&&w.startInline){let x=1/0,z=t.slice(1),K;this.options.extensions.startInline.forEach(Z=>{K=Z.call({lexer:this},z),typeof K=="number"&&K>=0&&(x=Math.min(x,K))}),x<1/0&&x>=0&&(E=t.substring(0,x+1))}if(v=this.tokenizer.inlineText(E)){t=t.substring(v.raw.length),v.raw.slice(-1)!=="_"&&(a=v.raw.slice(-1)),o=!0;let x=n.at(-1);(x==null?void 0:x.type)==="text"?(x.raw+=v.raw,x.text+=v.text):n.push(v);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 n}},Br=class{constructor(e){m(this,"options");m(this,"parser");this.options=e||hn}space(e){return""}code({text:e,lang:t,escaped:n}){var i;let s=(i=(t||"").match(ze.notSpaceStart))==null?void 0:i[0],r=e.replace(ze.endingNewline,"")+`
|
|
296
|
-
`;return s?'<pre><code class="language-'+et(s)+'">'+(n?r:et(r,!0))+`</code></pre>
|
|
297
|
-
`:"<pre><code>"+(n?r:et(r,!0))+`</code></pre>
|
|
298
|
-
`}blockquote({tokens:e}){return`<blockquote>
|
|
299
|
-
${this.parser.parse(e)}</blockquote>
|
|
300
|
-
`}html({text:e}){return e}def(e){return""}heading({tokens:e,depth:t}){return`<h${t}>${this.parser.parseInline(e)}</h${t}>
|
|
301
|
-
`}hr(e){return`<hr>
|
|
302
|
-
`}list(e){let t=e.ordered,n=e.start,s="";for(let o=0;o<e.items.length;o++){let a=e.items[o];s+=this.listitem(a)}let r=t?"ol":"ul",i=t&&n!==1?' start="'+n+'"':"";return"<"+r+i+`>
|
|
303
|
-
`+s+"</"+r+`>
|
|
304
|
-
`}listitem(e){return`<li>${this.parser.parse(e.tokens)}</li>
|
|
305
|
-
`}checkbox({checked:e}){return"<input "+(e?'checked="" ':"")+'disabled="" type="checkbox"> '}paragraph({tokens:e}){return`<p>${this.parser.parseInline(e)}</p>
|
|
306
|
-
`}table(e){let t="",n="";for(let r=0;r<e.header.length;r++)n+=this.tablecell(e.header[r]);t+=this.tablerow({text:n});let s="";for(let r=0;r<e.rows.length;r++){let i=e.rows[r];n="";for(let o=0;o<i.length;o++)n+=this.tablecell(i[o]);s+=this.tablerow({text:n})}return s&&(s=`<tbody>${s}</tbody>`),`<table>
|
|
307
|
-
<thead>
|
|
308
|
-
`+t+`</thead>
|
|
309
|
-
`+s+`</table>
|
|
310
|
-
`}tablerow({text:e}){return`<tr>
|
|
311
|
-
${e}</tr>
|
|
312
|
-
`}tablecell(e){let t=this.parser.parseInline(e.tokens),n=e.header?"th":"td";return(e.align?`<${n} align="${e.align}">`:`<${n}>`)+t+`</${n}>
|
|
313
|
-
`}strong({tokens:e}){return`<strong>${this.parser.parseInline(e)}</strong>`}em({tokens:e}){return`<em>${this.parser.parseInline(e)}</em>`}codespan({text:e}){return`<code>${et(e,!0)}</code>`}br(e){return"<br>"}del({tokens:e}){return`<del>${this.parser.parseInline(e)}</del>`}link({href:e,title:t,tokens:n}){let s=this.parser.parseInline(n),r=fl(e);if(r===null)return s;e=r;let i='<a href="'+e+'"';return t&&(i+=' title="'+et(t)+'"'),i+=">"+s+"</a>",i}image({href:e,title:t,text:n,tokens:s}){s&&(n=this.parser.parseInline(s,this.parser.textRenderer));let r=fl(e);if(r===null)return et(n);e=r;let i=`<img src="${e}" alt="${et(n)}"`;return t&&(i+=` title="${et(t)}"`),i+=">",i}text(e){return"tokens"in e&&e.tokens?this.parser.parseInline(e.tokens):"escaped"in e&&e.escaped?e.text:et(e.text)}},ma=class{strong({text:e}){return e}em({text:e}){return e}codespan({text:e}){return e}del({text:e}){return e}html({text:e}){return e}text({text:e}){return e}link({text:e}){return""+e}image({text:e}){return""+e}br(){return""}checkbox({raw:e}){return e}},Ke=class Fo{constructor(t){m(this,"options");m(this,"renderer");m(this,"textRenderer");this.options=t||hn,this.options.renderer=this.options.renderer||new Br,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new ma}static parse(t,n){return new Fo(n).parse(t)}static parseInline(t,n){return new Fo(n).parseInline(t)}parse(t){var s,r;this.renderer.parser=this;let n="";for(let i=0;i<t.length;i++){let o=t[i];if((r=(s=this.options.extensions)==null?void 0:s.renderers)!=null&&r[o.type]){let c=o,l=this.options.extensions.renderers[c.type].call({parser:this},c);if(l!==!1||!["space","hr","heading","code","table","blockquote","list","html","def","paragraph","text"].includes(c.type)){n+=l||"";continue}}let a=o;switch(a.type){case"space":{n+=this.renderer.space(a);break}case"hr":{n+=this.renderer.hr(a);break}case"heading":{n+=this.renderer.heading(a);break}case"code":{n+=this.renderer.code(a);break}case"table":{n+=this.renderer.table(a);break}case"blockquote":{n+=this.renderer.blockquote(a);break}case"list":{n+=this.renderer.list(a);break}case"checkbox":{n+=this.renderer.checkbox(a);break}case"html":{n+=this.renderer.html(a);break}case"def":{n+=this.renderer.def(a);break}case"paragraph":{n+=this.renderer.paragraph(a);break}case"text":{n+=this.renderer.text(a);break}default:{let c='Token with "'+a.type+'" type was not found.';if(this.options.silent)return console.error(c),"";throw new Error(c)}}}return n}parseInline(t,n=this.renderer){var r,i;this.renderer.parser=this;let s="";for(let o=0;o<t.length;o++){let a=t[o];if((i=(r=this.options.extensions)==null?void 0:r.renderers)!=null&&i[a.type]){let l=this.options.extensions.renderers[a.type].call({parser:this},a);if(l!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(a.type)){s+=l||"";continue}}let c=a;switch(c.type){case"escape":{s+=n.text(c);break}case"html":{s+=n.html(c);break}case"link":{s+=n.link(c);break}case"image":{s+=n.image(c);break}case"checkbox":{s+=n.checkbox(c);break}case"strong":{s+=n.strong(c);break}case"em":{s+=n.em(c);break}case"codespan":{s+=n.codespan(c);break}case"br":{s+=n.br(c);break}case"del":{s+=n.del(c);break}case"text":{s+=n.text(c);break}default:{let l='Token with "'+c.type+'" type was not found.';if(this.options.silent)return console.error(l),"";throw new Error(l)}}}return s}},Sr,ms=(Sr=class{constructor(e){m(this,"options");m(this,"block");this.options=e||hn}preprocess(e){return e}postprocess(e){return e}processAllTokens(e){return e}emStrongMask(e){return e}provideLexer(){return this.block?qe.lex:qe.lexInline}provideParser(){return this.block?Ke.parse:Ke.parseInline}},m(Sr,"passThroughHooks",new Set(["preprocess","postprocess","processAllTokens","emStrongMask"])),m(Sr,"passThroughHooksRespectAsync",new Set(["preprocess","postprocess","processAllTokens"])),Sr),P0=class{constructor(...e){m(this,"defaults",ca());m(this,"options",this.setOptions);m(this,"parse",this.parseMarkdown(!0));m(this,"parseInline",this.parseMarkdown(!1));m(this,"Parser",Ke);m(this,"Renderer",Br);m(this,"TextRenderer",ma);m(this,"Lexer",qe);m(this,"Tokenizer",Hr);m(this,"Hooks",ms);this.use(...e)}walkTokens(e,t){var s,r;let n=[];for(let i of e)switch(n=n.concat(t.call(this,i)),i.type){case"table":{let o=i;for(let a of o.header)n=n.concat(this.walkTokens(a.tokens,t));for(let a of o.rows)for(let c of a)n=n.concat(this.walkTokens(c.tokens,t));break}case"list":{let o=i;n=n.concat(this.walkTokens(o.items,t));break}default:{let o=i;(r=(s=this.defaults.extensions)==null?void 0:s.childTokens)!=null&&r[o.type]?this.defaults.extensions.childTokens[o.type].forEach(a=>{let c=o[a].flat(1/0);n=n.concat(this.walkTokens(c,t))}):o.tokens&&(n=n.concat(this.walkTokens(o.tokens,t)))}}return n}use(...e){let t=this.defaults.extensions||{renderers:{},childTokens:{}};return e.forEach(n=>{let s={...n};if(s.async=this.defaults.async||s.async||!1,n.extensions&&(n.extensions.forEach(r=>{if(!r.name)throw new Error("extension name required");if("renderer"in r){let i=t.renderers[r.name];i?t.renderers[r.name]=function(...o){let a=r.renderer.apply(this,o);return a===!1&&(a=i.apply(this,o)),a}:t.renderers[r.name]=r.renderer}if("tokenizer"in r){if(!r.level||r.level!=="block"&&r.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");let i=t[r.level];i?i.unshift(r.tokenizer):t[r.level]=[r.tokenizer],r.start&&(r.level==="block"?t.startBlock?t.startBlock.push(r.start):t.startBlock=[r.start]:r.level==="inline"&&(t.startInline?t.startInline.push(r.start):t.startInline=[r.start]))}"childTokens"in r&&r.childTokens&&(t.childTokens[r.name]=r.childTokens)}),s.extensions=t),n.renderer){let r=this.defaults.renderer||new Br(this.defaults);for(let i in n.renderer){if(!(i in r))throw new Error(`renderer '${i}' does not exist`);if(["options","parser"].includes(i))continue;let o=i,a=n.renderer[o],c=r[o];r[o]=(...l)=>{let h=a.apply(r,l);return h===!1&&(h=c.apply(r,l)),h||""}}s.renderer=r}if(n.tokenizer){let r=this.defaults.tokenizer||new Hr(this.defaults);for(let i in n.tokenizer){if(!(i in r))throw new Error(`tokenizer '${i}' does not exist`);if(["options","rules","lexer"].includes(i))continue;let o=i,a=n.tokenizer[o],c=r[o];r[o]=(...l)=>{let h=a.apply(r,l);return h===!1&&(h=c.apply(r,l)),h}}s.tokenizer=r}if(n.hooks){let r=this.defaults.hooks||new ms;for(let i in n.hooks){if(!(i in r))throw new Error(`hook '${i}' does not exist`);if(["options","block"].includes(i))continue;let o=i,a=n.hooks[o],c=r[o];ms.passThroughHooks.has(i)?r[o]=l=>{if(this.defaults.async&&ms.passThroughHooksRespectAsync.has(i))return(async()=>{let f=await a.call(r,l);return c.call(r,f)})();let h=a.call(r,l);return c.call(r,h)}:r[o]=(...l)=>{if(this.defaults.async)return(async()=>{let f=await a.apply(r,l);return f===!1&&(f=await c.apply(r,l)),f})();let h=a.apply(r,l);return h===!1&&(h=c.apply(r,l)),h}}s.hooks=r}if(n.walkTokens){let r=this.defaults.walkTokens,i=n.walkTokens;s.walkTokens=function(o){let a=[];return a.push(i.call(this,o)),r&&(a=a.concat(r.call(this,o))),a}}this.defaults={...this.defaults,...s}}),this}setOptions(e){return this.defaults={...this.defaults,...e},this}lexer(e,t){return qe.lex(e,t??this.defaults)}parser(e,t){return Ke.parse(e,t??this.defaults)}parseMarkdown(e){return(t,n)=>{let s={...n},r={...this.defaults,...s},i=this.onError(!!r.silent,!!r.async);if(this.defaults.async===!0&&s.async===!1)return i(new Error("marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise."));if(typeof t>"u"||t===null)return i(new Error("marked(): input parameter is undefined or null"));if(typeof t!="string")return i(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(t)+", string expected"));if(r.hooks&&(r.hooks.options=r,r.hooks.block=e),r.async)return(async()=>{let o=r.hooks?await r.hooks.preprocess(t):t,a=await(r.hooks?await r.hooks.provideLexer():e?qe.lex:qe.lexInline)(o,r),c=r.hooks?await r.hooks.processAllTokens(a):a;r.walkTokens&&await Promise.all(this.walkTokens(c,r.walkTokens));let l=await(r.hooks?await r.hooks.provideParser():e?Ke.parse:Ke.parseInline)(c,r);return r.hooks?await r.hooks.postprocess(l):l})().catch(i);try{r.hooks&&(t=r.hooks.preprocess(t));let o=(r.hooks?r.hooks.provideLexer():e?qe.lex:qe.lexInline)(t,r);r.hooks&&(o=r.hooks.processAllTokens(o)),r.walkTokens&&this.walkTokens(o,r.walkTokens);let a=(r.hooks?r.hooks.provideParser():e?Ke.parse:Ke.parseInline)(o,r);return r.hooks&&(a=r.hooks.postprocess(a)),a}catch(o){return i(o)}}}onError(e,t){return n=>{if(n.message+=`
|
|
314
|
-
Please report this to https://github.com/markedjs/marked.`,e){let s="<p>An error occurred:</p><pre>"+et(n.message+"",!0)+"</pre>";return t?Promise.resolve(s):s}if(t)return Promise.reject(n);throw n}}},an=new P0;function Y(e,t){return an.parse(e,t)}Y.options=Y.setOptions=function(e){return an.setOptions(e),Y.defaults=an.defaults,sd(Y.defaults),Y};Y.getDefaults=ca;Y.defaults=hn;Y.use=function(...e){return an.use(...e),Y.defaults=an.defaults,sd(Y.defaults),Y};Y.walkTokens=function(e,t){return an.walkTokens(e,t)};Y.parseInline=an.parseInline;Y.Parser=Ke;Y.parser=Ke.parse;Y.Renderer=Br;Y.TextRenderer=ma;Y.Lexer=qe;Y.lexer=qe.lex;Y.Tokenizer=Hr;Y.Hooks=ms;Y.parse=Y;Y.options;Y.setOptions;Y.use;Y.walkTokens;Y.parseInline;Ke.parse;qe.lex;const D0=8;let vl=!1;function L0(){vl||(vl=!0,nd.addHook("afterSanitizeAttributes",e=>{e.tagName==="A"&&(e.setAttribute("target","_blank"),e.setAttribute("rel","noopener noreferrer"))}))}function M0(e){L0();const t=Y.parse(e,{async:!1});return nd.sanitize(t,{USE_PROFILES:{html:!0}})}function O0(e){return e.kind==="user"||e.kind==="assistant"}function _l(e,t){for(let n=e.length-1;n>=0;n-=1){const s=e[n];if(s&&s.kind===t)return s.id}return null}var gt,On,mt,Nn,Ne,vs,fd,Gs,Yr,Rr;class pd extends Cs{constructor(){super(...arguments);I(this,Ne);m(this,"messages",[]);I(this,gt,!0);I(this,On,null);I(this,mt,null);I(this,Nn,!1);I(this,Gs,()=>{const n=d(this,mt);if(!n)return;const r=n.scrollHeight-n.clientHeight-n.scrollTop<=D0;r!==d(this,gt)&&(C(this,gt,r),y(this,Ne,vs).call(this))});I(this,Yr,()=>{C(this,gt,!0),y(this,Ne,vs).call(this),y(this,Ne,Rr).call(this,{force:!0})})}connectedCallback(){C(this,Nn,!0),C(this,On,_l(this.messages??[],"user")),y(this,Ne,vs).call(this),y(this,Ne,Rr).call(this,{force:!0})}disconnectedCallback(){C(this,Nn,!1),C(this,mt,null)}propertyChangedCallback(n,s,r){if(n!=="messages"||!d(this,Nn))return;const i=this.messages??[],o=_l(i,"user"),a=o!==null&&o!==d(this,On);C(this,On,o),a&&C(this,gt,!0),y(this,Ne,vs).call(this),y(this,Ne,Rr).call(this,{force:a})}}gt=new WeakMap,On=new WeakMap,mt=new WeakMap,Nn=new WeakMap,Ne=new WeakSet,vs=function(){var i;const n=(this.messages??[]).filter(O0),s=d(this,gt);ue(O`
|
|
315
|
-
<div
|
|
316
|
-
class="chat-history-scroll"
|
|
317
|
-
role="log"
|
|
318
|
-
aria-live="polite"
|
|
319
|
-
@scroll=${d(this,Gs)}
|
|
320
|
-
>
|
|
321
|
-
${n.map(o=>y(this,Ne,fd).call(this,o))}
|
|
322
|
-
</div>
|
|
323
|
-
<button
|
|
324
|
-
type="button"
|
|
325
|
-
class="chat-history-jump"
|
|
326
|
-
aria-label="Jump to latest message"
|
|
327
|
-
?hidden=${s}
|
|
328
|
-
@click=${d(this,Yr)}
|
|
329
|
-
>
|
|
330
|
-
${Zr({size:14})}
|
|
331
|
-
<span>Jump to latest</span>
|
|
332
|
-
</button>
|
|
333
|
-
`,this);const r=this.querySelector(".chat-history-scroll");r&&r!==d(this,mt)&&((i=d(this,mt))==null||i.removeEventListener("scroll",d(this,Gs)),C(this,mt,r))},fd=function(n){const s=fb(M0(n.text));if(n.kind==="user")return O`
|
|
334
|
-
<div class="chat-message chat-message-user">
|
|
335
|
-
<div class="chat-message-body">${s}</div>
|
|
336
|
-
</div>
|
|
337
|
-
`;const r=n.status==="cancelled"?O`<span class="chat-message-badge">[cancelled]</span>`:n.status==="error"?O`<span class="chat-message-badge">[error]</span>`:null;return O`
|
|
338
|
-
<div class="chat-message chat-message-assistant">
|
|
339
|
-
<div class="chat-message-body">${s}${r}</div>
|
|
340
|
-
</div>
|
|
341
|
-
`},Gs=new WeakMap,Yr=new WeakMap,Rr=function(n){requestAnimationFrame(()=>{const s=d(this,mt);s&&(!d(this,gt)&&!n.force||(s.scrollTop=s.scrollHeight-s.clientHeight))})},m(pd,"observedProperties",{messages:{type:Object}});customElements.define("chat-history",pd);const N0=rt(),W0=rt(),F0=rt(),U0=3;class gd extends Cs{constructor(){super(...arguments);m(this,"value","");m(this,"disabled",!1);m(this,"disabledPlaceholder","");m(this,"action","send");m(this,"handleInput",n=>{const r=n.currentTarget.value??"";this.value=r,this.dispatchEvent(new N0("change",{value:r,bubbles:!0,composed:!0}))});m(this,"handleKeyDown",n=>{n.key==="Enter"&&(n.shiftKey||n.isComposing||(n.preventDefault(),!this.disabled&&this.action==="send"&&this.submitMessage()))});m(this,"handleButtonClick",()=>{this.disabled||(this.action==="send"?this.submitMessage():this.dispatchEvent(new F0("cancel",{bubbles:!0,composed:!0})))})}connectedCallback(){this.render()}propertyChangedCallback(){this.render()}get textareaEl(){return this.querySelector("textarea")}submitMessage(){var s;const n=(this.value??"").trim();n.length!==0&&(this.dispatchEvent(new W0("submit",{text:n,bubbles:!0,composed:!0})),(s=this.textareaEl)==null||s.focus())}computeRows(){const n=(this.value??"").split(/\r?\n/).length;return Math.min(U0,Math.max(1,n))}render(){const n=this.action==="send",s=n?"Send message":"Cancel",r=n?kb({size:16}):yb({size:16}),i=this.computeRows(),o=this.value??"",a=this.disabled?"":o,c=this.disabled?this.disabledPlaceholder:"";ue(O`
|
|
342
|
-
<textarea
|
|
343
|
-
.value=${a}
|
|
344
|
-
placeholder=${c}
|
|
345
|
-
rows=${i}
|
|
346
|
-
?disabled=${this.disabled}
|
|
347
|
-
@input=${this.handleInput}
|
|
348
|
-
@keydown=${this.handleKeyDown}
|
|
349
|
-
></textarea>
|
|
350
|
-
<button
|
|
351
|
-
type="button"
|
|
352
|
-
aria-label=${s}
|
|
353
|
-
?disabled=${this.disabled}
|
|
354
|
-
@click=${this.handleButtonClick}
|
|
355
|
-
>
|
|
356
|
-
${r}
|
|
357
|
-
</button>
|
|
358
|
-
`,this)}}m(gd,"observedProperties",{value:{type:String},disabled:{type:Boolean},disabledPlaceholder:{type:String},action:{type:String}});customElements.define("chat-input",gd);var Jt,be,Wn,Qt,qs,Ae,Uo,Zo,Ks,Xr,Jr,Qr,md,En;class Z0 extends HTMLElement{constructor(){super(...arguments);I(this,Ae);I(this,Jt,Ze.resolve("ACPClientManager"));I(this,be,null);I(this,Wn,"");I(this,Qt,!1);I(this,qs,()=>{if(!d(this,Qt))return;const n=d(this,Jt).getActiveService();n!==d(this,be)&&(y(this,Ae,Zo).call(this),y(this,Ae,Uo).call(this,n)),y(this,Ae,En).call(this)});I(this,Ks,()=>{d(this,Qt)&&y(this,Ae,En).call(this)});I(this,Xr,n=>{const s=n.value;C(this,Wn,s),y(this,Ae,En).call(this)});I(this,Jr,n=>{if(!d(this,be))return;const s=n.text;C(this,Wn,""),y(this,Ae,En).call(this),d(this,be).sendMessage({text:s}).catch(r=>{console.error("ACPClientService.sendMessage() failed",r)})});I(this,Qr,n=>{d(this,be)&&d(this,be).cancel().catch(s=>{console.error("ACPClientService.cancel() failed",s)})})}connectedCallback(){C(this,Qt,!0),d(this,Jt).addEventListener("change",d(this,qs)),y(this,Ae,Uo).call(this,d(this,Jt).getActiveService()),y(this,Ae,En).call(this)}disconnectedCallback(){C(this,Qt,!1),d(this,Jt).removeEventListener("change",d(this,qs)),y(this,Ae,Zo).call(this)}}Jt=new WeakMap,be=new WeakMap,Wn=new WeakMap,Qt=new WeakMap,qs=new WeakMap,Ae=new WeakSet,Uo=function(n){C(this,be,n),d(this,be)&&(d(this,be).addEventListener("change",d(this,Ks)),d(this,be).connect().catch(s=>{console.error("ACPClientService.connect() failed",s)}))},Zo=function(){d(this,be)&&(d(this,be).removeEventListener("change",d(this,Ks)),C(this,be,null))},Ks=new WeakMap,Xr=new WeakMap,Jr=new WeakMap,Qr=new WeakMap,md=function(n){return n.lifecycle.status==="connecting"?"Connecting to agent…":n.lifecycle.status==="disconnected"?n.lifecycle.error?"Agent unavailable":"Agent disconnected":n.lifecycle.status==="disposed"?"Agent unavailable":n.run.status==="cancelling"?"Cancelling…":""},En=function(){if(!d(this,be)){this.hidden=!0;return}const n=d(this,be).getState();this.hidden=n.lifecycle.status!=="ready";const s=n.messageOrder.map(a=>n.messagesById[a]).filter(a=>a!==void 0),r=n.run.canCancel&&n.run.status==="running"?"cancel":"send",i=n.lifecycle.status!=="ready"||n.run.status==="cancelling",o=y(this,Ae,md).call(this,n);ue(O`
|
|
359
|
-
<chat-history .messages=${s}></chat-history>
|
|
360
|
-
<div class="chat-panel-input">
|
|
361
|
-
<chat-input
|
|
362
|
-
.value=${d(this,Wn)}
|
|
363
|
-
.action=${r}
|
|
364
|
-
.disabled=${i}
|
|
365
|
-
.disabledPlaceholder=${o}
|
|
366
|
-
@change=${d(this,Xr)}
|
|
367
|
-
@submit=${d(this,Jr)}
|
|
368
|
-
@cancel=${d(this,Qr)}
|
|
369
|
-
></chat-input>
|
|
370
|
-
</div>
|
|
371
|
-
`,this)};customElements.get("chat-panel")||customElements.define("chat-panel",Z0);class vd extends HTMLElement{constructor(){super(...arguments);m(this,"workspaceService",Ze.resolve("WorkspaceService"));m(this,"handleWorkspaceChange",()=>{this.render()});m(this,"_mode","edit");m(this,"_targetServerURL");m(this,"createPending",!1)}get open(){return this.hasAttribute("open")}set mode(n){this._mode=n,this.render()}get mode(){return this._mode}set targetServerURL(n){this._targetServerURL=n,this.render()}get targetServerURL(){return this._targetServerURL}attributeChangedCallback(n){n==="open"&&(this.open||(this.createPending=!1),this.render())}connectedCallback(){this.render(),this.workspaceService.addEventListener("change",this.handleWorkspaceChange)}disconnectedCallback(){this.workspaceService.removeEventListener("change",this.handleWorkspaceChange)}emitClose(){this.dispatchEvent(new Event("close",{bubbles:!0}))}async handleSubmit(n){n.preventDefault();const s=n.currentTarget,r=new FormData(s),i=String(r.get("name")??"").trim();if(i){if(this._mode==="edit"){this.workspaceService.renameWorkspace(i),this.emitClose();return}if(this._targetServerURL){this.createPending=!0,this.render();try{await this.workspaceService.createWorkspace(this._targetServerURL,i),this.emitClose()}catch{this.createPending=!1,this.render()}}}}render(){var i;const n=this._mode==="edit"?"Edit workspace":"New workspace",s=this._mode==="edit"?"Save":this.createPending?"Creating...":"Create",r=this._mode==="edit"?((i=this.workspaceService.activeWorkspace)==null?void 0:i.name)??"":"";ue(O`
|
|
372
|
-
<modal-overlay ?open=${this.open}>
|
|
373
|
-
<section class="workspace-modal">
|
|
374
|
-
<form class="workspace-form" @submit=${o=>void this.handleSubmit(o)}>
|
|
375
|
-
<h2 class="workspace-modal-title">${n}</h2>
|
|
376
|
-
<label class="settings-field">
|
|
377
|
-
<span>Name</span>
|
|
378
|
-
<input type="text" name="name" .value=${r} required />
|
|
379
|
-
</label>
|
|
380
|
-
<div class="workspace-form-actions">
|
|
381
|
-
<button type="submit" class="settings-submit-button" ?disabled=${this.createPending}>
|
|
382
|
-
${s}
|
|
383
|
-
</button>
|
|
384
|
-
<button type="button" class="settings-cancel-button" @click=${()=>this.emitClose()}>
|
|
385
|
-
Cancel
|
|
386
|
-
</button>
|
|
387
|
-
</div>
|
|
388
|
-
</form>
|
|
389
|
-
</section>
|
|
390
|
-
</modal-overlay>
|
|
391
|
-
`,this)}}m(vd,"observedAttributes",["open"]);customElements.define("workspace-form-modal",vd);class _d extends HTMLElement{constructor(){super(...arguments);m(this,"workspaceService",Ze.resolve("WorkspaceService"));m(this,"serverManager",Ze.resolve("ServerManager"));m(this,"handleChange",()=>{this.render()});m(this,"deletePending",!1);m(this,"deleteError",null)}get open(){return this.hasAttribute("open")}attributeChangedCallback(n,s,r){n==="open"&&(r!==null&&s===null&&(this.deletePending=!1,this.deleteError=null),this.render())}connectedCallback(){this.render(),this.workspaceService.addEventListener("change",this.handleChange),this.serverManager.addEventListener("change",this.handleChange)}disconnectedCallback(){this.workspaceService.removeEventListener("change",this.handleChange),this.serverManager.removeEventListener("change",this.handleChange)}emitClose(){this.dispatchEvent(new Event("close",{bubbles:!0}))}async handleDeleteWorkspace(){this.deletePending=!0,this.deleteError=null,this.render();try{await this.workspaceService.deleteWorkspace(),this.emitClose()}catch(n){this.deletePending=!1,this.deleteError=n instanceof Error?n.message:String(n),this.render()}}render(){var s;const n=this.workspaceService.activeWorkspaceServerURL!==null&&this.workspaceService.activeWorkspaceServerURL!==this.serverManager.localServerURL;ue(O`
|
|
392
|
-
<modal-overlay ?open=${this.open}>
|
|
393
|
-
<section class="workspace-modal workspace-delete-modal">
|
|
394
|
-
<div class="workspace-form">
|
|
395
|
-
<h2 class="workspace-modal-title">Delete workspace</h2>
|
|
396
|
-
<p class="workspace-delete-copy">
|
|
397
|
-
Delete <strong>${((s=this.workspaceService.activeWorkspace)==null?void 0:s.name)??""}</strong>?
|
|
398
|
-
</p>
|
|
399
|
-
${n?O`<p class="workspace-delete-warning">This will delete it for everyone.</p>`:null}
|
|
400
|
-
${this.deleteError?O`<p class="workspace-delete-error">${this.deleteError}</p>`:null}
|
|
401
|
-
<div class="workspace-form-actions">
|
|
402
|
-
<button
|
|
403
|
-
type="button"
|
|
404
|
-
class="settings-server-remove-button"
|
|
405
|
-
?disabled=${this.deletePending}
|
|
406
|
-
@click=${()=>void this.handleDeleteWorkspace()}
|
|
407
|
-
>
|
|
408
|
-
${this.deletePending?"Deleting...":"Delete"}
|
|
409
|
-
</button>
|
|
410
|
-
<button
|
|
411
|
-
type="button"
|
|
412
|
-
class="settings-cancel-button"
|
|
413
|
-
?disabled=${this.deletePending}
|
|
414
|
-
@click=${()=>this.emitClose()}
|
|
415
|
-
>
|
|
416
|
-
Cancel
|
|
417
|
-
</button>
|
|
418
|
-
</div>
|
|
419
|
-
</div>
|
|
420
|
-
</section>
|
|
421
|
-
</modal-overlay>
|
|
422
|
-
`,this)}}m(_d,"observedAttributes",["open"]);customElements.define("workspace-delete-modal",_d);class yd extends HTMLElement{constructor(){super(...arguments);m(this,"serverManager",Ze.resolve("ServerManager"));m(this,"handleChange",()=>{this.render()});m(this,"addServerFormOpen",!1)}get open(){return this.hasAttribute("open")}attributeChangedCallback(n){n==="open"&&(this.open||(this.addServerFormOpen=!1),this.render())}connectedCallback(){this.render(),this.serverManager.addEventListener("change",this.handleChange)}disconnectedCallback(){this.serverManager.removeEventListener("change",this.handleChange)}emitClose(){this.dispatchEvent(new Event("close",{bubbles:!0}))}openAddServerForm(){this.addServerFormOpen=!0,this.render()}closeAddServerForm(){this.addServerFormOpen&&(this.addServerFormOpen=!1,this.render())}handleAddServer(n){n.preventDefault();const s=n.currentTarget,r=new FormData(s),i=String(r.get("name")??"").trim(),o=String(r.get("url")??"").trim();!i||!o||(this.serverManager.addServer(o,i),this.addServerFormOpen=!1,s.reset(),this.render())}render(){const n=[...this.serverManager.servers.values()];ue(O`
|
|
423
|
-
<modal-overlay ?open=${this.open}>
|
|
424
|
-
<section class="settings-panel">
|
|
425
|
-
<panel-view closable @close=${s=>s instanceof Mh&&this.emitClose()}>
|
|
426
|
-
<panel-page id="main" title="Settings">
|
|
427
|
-
<div class="settings-section">
|
|
428
|
-
<h3 class="settings-section-title">Servers</h3>
|
|
429
|
-
<div class="settings-server-list">
|
|
430
|
-
${n.map(s=>O`
|
|
431
|
-
<div class="settings-card settings-server">
|
|
432
|
-
<div class="settings-server-details">
|
|
433
|
-
<div class="settings-server-name">${s.name}</div>
|
|
434
|
-
<div class="settings-server-url">${s.url}</div>
|
|
435
|
-
</div>
|
|
436
|
-
${s.url!==this.serverManager.localServerURL?O`
|
|
437
|
-
<button
|
|
438
|
-
type="button"
|
|
439
|
-
class="settings-server-remove-button"
|
|
440
|
-
aria-label=${`Remove ${s.name}`}
|
|
441
|
-
@click=${()=>this.serverManager.removeServer(s.url)}
|
|
442
|
-
>
|
|
443
|
-
Remove
|
|
444
|
-
</button>
|
|
445
|
-
`:null}
|
|
446
|
-
</div>
|
|
447
|
-
`)}
|
|
448
|
-
</div>
|
|
449
|
-
${this.addServerFormOpen?O`
|
|
450
|
-
<form class="settings-card settings-add-server-form" @submit=${s=>this.handleAddServer(s)}>
|
|
451
|
-
<label class="settings-field">
|
|
452
|
-
<span>Name</span>
|
|
453
|
-
<input type="text" name="name" required />
|
|
454
|
-
</label>
|
|
455
|
-
<label class="settings-field">
|
|
456
|
-
<span>URL</span>
|
|
457
|
-
<input type="url" name="url" required />
|
|
458
|
-
</label>
|
|
459
|
-
<div class="settings-form-actions">
|
|
460
|
-
<button type="submit" class="settings-submit-button">Connect</button>
|
|
461
|
-
<button
|
|
462
|
-
type="button"
|
|
463
|
-
class="settings-cancel-button"
|
|
464
|
-
data-action="cancel-connect-form"
|
|
465
|
-
@click=${()=>this.closeAddServerForm()}
|
|
466
|
-
>
|
|
467
|
-
Cancel
|
|
468
|
-
</button>
|
|
469
|
-
</div>
|
|
470
|
-
</form>
|
|
471
|
-
`:O`
|
|
472
|
-
<button
|
|
473
|
-
type="button"
|
|
474
|
-
class="settings-submit-button settings-connect-button"
|
|
475
|
-
data-action="show-connect-form"
|
|
476
|
-
@click=${()=>this.openAddServerForm()}
|
|
477
|
-
>
|
|
478
|
-
+ Connect to server
|
|
479
|
-
</button>
|
|
480
|
-
`}
|
|
481
|
-
</div>
|
|
482
|
-
</panel-page>
|
|
483
|
-
</panel-view>
|
|
484
|
-
</section>
|
|
485
|
-
</modal-overlay>
|
|
486
|
-
`,this)}}m(yd,"observedAttributes",["open"]);customElements.define("settings-modal",yd);class kd extends Event{constructor(n){super("auth-submit",{bubbles:!0,composed:!0});m(this,"token");this.token=n}}class j0 extends HTMLElement{constructor(){super(...arguments);m(this,"_invalid",!1);m(this,"_tokenValue","")}set invalid(n){this._invalid=n,this.render()}get invalid(){return this._invalid}set tokenValue(n){this._tokenValue=n,this.render()}get tokenValue(){return this._tokenValue}connectedCallback(){this.render()}handleInput(n){const s=n.currentTarget;this._tokenValue=s.value}handleSubmit(n){n.preventDefault();const s=this._tokenValue.trim();s&&this.dispatchEvent(new kd(s))}render(){ue(O`
|
|
487
|
-
<modal-overlay open>
|
|
488
|
-
<section class="auth-modal">
|
|
489
|
-
<form class="auth-form" @submit=${n=>this.handleSubmit(n)}>
|
|
490
|
-
<h2 class="auth-modal-title">Enter access token</h2>
|
|
491
|
-
<p class="auth-modal-copy">This Television server requires a token.</p>
|
|
492
|
-
<label class="settings-field">
|
|
493
|
-
<span>Token</span>
|
|
494
|
-
<input
|
|
495
|
-
class=${this.invalid?"auth-token-input-invalid":""}
|
|
496
|
-
type="password"
|
|
497
|
-
name="token"
|
|
498
|
-
.value=${this.tokenValue}
|
|
499
|
-
@input=${n=>this.handleInput(n)}
|
|
500
|
-
required
|
|
501
|
-
/>
|
|
502
|
-
</label>
|
|
503
|
-
<button type="submit" class="settings-submit-button">Connect</button>
|
|
504
|
-
</form>
|
|
505
|
-
</section>
|
|
506
|
-
</modal-overlay>
|
|
507
|
-
`,this)}}customElements.get("auth-modal")||customElements.define("auth-modal",j0);class H0 extends HTMLElement{constructor(){super(...arguments);m(this,"runtimeServerURL",yh());m(this,"electronMode",wh());m(this,"serverManager",Ze.resolve("ServerManager"));m(this,"modals",{workspaceForm:{open:!1,mode:"edit"},deleteWorkspace:{open:!1},settings:{open:!1}});m(this,"connectError",null);m(this,"handleServerManagerChange",()=>{this.render()})}connectedCallback(){this.serverManager.addEventListener("change",this.handleServerManagerChange),this.addEventListener("auth-submit",n=>{var r;const s=n instanceof kd?n.token:n instanceof CustomEvent&&typeof((r=n.detail)==null?void 0:r.token)=="string"?n.detail.token:null;s&&this.handleAuthSubmit(s)}),this.initializeConnection(),this.render()}disconnectedCallback(){this.serverManager.removeEventListener("change",this.handleServerManagerChange)}async initializeConnection(){if(this.electronMode){this.serverManager.connectConfiguredServers(this.runtimeServerURL);return}if(this.serverManager.activeServer)return;const n=new ho({url:this.runtimeServerURL,name:"Server",token:kh()});this.serverManager.add(n),this.serverManager.setActive(n);try{await n.connect(),this.connectError=null}catch(s){this.connectError=s instanceof Error&&!(s instanceof uo)?s.message:null}this.render()}async handleAuthSubmit(n){const s=this.serverManager.activeServer;if(s){this.connectError=null,s.token=n,this.updateTokenQueryParam(n);try{await s.connect()}catch(r){r instanceof uo||(this.connectError=r instanceof Error?r.message:String(r))}this.render()}}updateTokenQueryParam(n){const s=new URL(window.location.href);s.searchParams.set("token",n),window.history.replaceState({},"",`${s.pathname}${s.search}${s.hash}`)}render(){const n=this.serverManager.activeServer,s=(n==null?void 0:n.status)??null;if(s==="connecting"){ue(O`
|
|
508
|
-
<main class="auth-gate"><p>Connecting...</p></main>
|
|
509
|
-
`,this);return}if(s==="disconnected"){const i=n;if(!i)return;ue(O`
|
|
510
|
-
<main class="auth-gate">
|
|
511
|
-
<auth-modal
|
|
512
|
-
.invalid=${!!i.token}
|
|
513
|
-
.tokenValue=${i.token??""}
|
|
514
|
-
></auth-modal>
|
|
515
|
-
</main>
|
|
516
|
-
`,this);return}const r=O`
|
|
517
|
-
<header>
|
|
518
|
-
<nav>
|
|
519
|
-
<workspace-picker
|
|
520
|
-
@edit-workspace=${()=>{this.modals.workspaceForm={open:!0,mode:"edit"},this.render()}}
|
|
521
|
-
@create-workspace=${i=>{this.modals.workspaceForm={open:!0,mode:"create",targetServerURL:i.serverURL},this.render()}}
|
|
522
|
-
@delete-workspace=${()=>{this.modals.deleteWorkspace={open:!0},this.render()}}
|
|
523
|
-
></workspace-picker>
|
|
524
|
-
</nav>
|
|
525
|
-
<button
|
|
526
|
-
type="button"
|
|
527
|
-
variant="toolbar"
|
|
528
|
-
size="sm"
|
|
529
|
-
aria-label="Settings"
|
|
530
|
-
@click=${()=>{this.modals.settings={open:!this.modals.settings.open},this.render()}}
|
|
531
|
-
>
|
|
532
|
-
${wb({size:16,weight:"bold"})}
|
|
533
|
-
</button>
|
|
534
|
-
</header>
|
|
535
|
-
<main>
|
|
536
|
-
${this.connectError?O`<p data-testid="auth-error">${this.connectError}</p>`:O`
|
|
537
|
-
<workspace-view></workspace-view>
|
|
538
|
-
${s==="connected"?O`<chat-panel></chat-panel>`:null}
|
|
539
|
-
`}
|
|
540
|
-
</main>
|
|
541
|
-
<workspace-form-modal
|
|
542
|
-
?open=${this.modals.workspaceForm.open}
|
|
543
|
-
.mode=${this.modals.workspaceForm.mode}
|
|
544
|
-
.targetServerURL=${this.modals.workspaceForm.targetServerURL}
|
|
545
|
-
@close=${()=>{this.modals.workspaceForm={open:!1,mode:"edit"},this.render()}}
|
|
546
|
-
></workspace-form-modal>
|
|
547
|
-
<workspace-delete-modal
|
|
548
|
-
?open=${this.modals.deleteWorkspace.open}
|
|
549
|
-
@close=${()=>{this.modals.deleteWorkspace={open:!1},this.render()}}
|
|
550
|
-
></workspace-delete-modal>
|
|
551
|
-
<settings-modal
|
|
552
|
-
?open=${this.modals.settings.open}
|
|
553
|
-
@close=${()=>{this.modals.settings={open:!1},this.render()}}
|
|
554
|
-
></settings-modal>
|
|
555
|
-
`;ue(r,this)}}customElements.get("television-app")||customElements.define("television-app",H0);const va=wh(),gi=yh(),wd=p_(va?"television-electron":"television-browser",gi),_a=new __({clientStore:wd,localServerURL:gi}),ya=new Hv({clientStore:wd,serverManager:_a}),B0=new Xw({serverURL:gi,token:kh()??"",workspaceService:ya});Ze.register("ServerManager",()=>_a);Ze.register("WorkspaceService",()=>ya);Ze.register("ACPClientManager",()=>B0);_a.addEventListener("server-message",e=>{ya.handleServerEvent(e.serverURL,e.message)});const ka=document.createElement("television-app");ka.runtimeServerURL=gi;ka.electronMode=va;va&&document.body.classList.add("electron");document.body.appendChild(ka);
|